Skip to content

Commit 6d696f1

Browse files
committed
ci:merge
2 parents c39212d + c42a1ce commit 6d696f1

11 files changed

Lines changed: 92 additions & 18636 deletions

File tree

.github/workflows/npmpkg.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
name: Publish NPM Package
22

3-
on:
4-
push:
5-
branches:
6-
- master
3+
on: [push]
4+
# on:
5+
# push:
6+
# branches:
7+
# - master
78

89
jobs:
910
build:

package-lock.json

Lines changed: 0 additions & 18492 deletions
This file was deleted.

public/demo/article_jx3.html

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34,34 +34,3 @@ <h6>NPC</h6>
3434
<p><a class="e-jx3-npc w-jx3-element" href="https://www.jx3box.com/app/database/?type=npc&amp;query=69700&amp;level=" target="_blank" rel="noopener" data-type="npc" data-mode="" data-id="69700" data-client="std">[追捧者头子]</a></p>
3535

3636

37-
<div class="e-pz-iframe"><iframe style="border:none;background:none;max-width:100%;overflow:hidden;" src="https://www.jx3box.com/pz/iframe.html?id=70" width="1280" height="720" frameborder="0"></iframe></div>
38-
39-
<a class="e-jx3-buff w-jx3-element isBuff" href="https://origin.jx3box.com/app/database/?type=buff&amp;query=124&amp;level=1" data-type="buff" data-client="origin" data-id="124" data-level="1">[花语酥心]</a>
40-
41-
<br />
42-
43-
<a class="e-jx3-buff w-jx3-element isDebuff" href="https://www.jx3box.com/app/database/?type=buff&amp;query=1267&amp;level=0" data-type="buff" data-client="std" data-id="1267" data-level="0">[虫蛊・销魂]</a>
44-
45-
<br />
46-
47-
<a class="e-jx3-skill w-jx3-element" href="https://www.jx3box.com/app/database/?type=skill&amp;query=551&amp;level=0" data-type="skill" data-client="std" data-id="551" data-level="0">[心鼓弦]</a>
48-
49-
<br />
50-
51-
<a class="e-jx3-item e-jx3-item-q3 w-jx3-element" href="https://www.jx3box.com/item/#/view/5_10428" target="_blank" rel="noopener" data-type="item" data-mode="" data-id="5_10428" data-quality="3" data-client="std">[幽月凝光]</a>
52-
53-
<pre class="e-jx3-resource"><span class="u-id">ID:551</span>
54-
<img class="u-pic" title="IconID:898" src="https://img.jx3box.com/icon/898.png" />
55-
<span class="u-name">心鼓弦</span>
56-
<span class="u-desc">救治一个重伤的友方目标,可在战斗中使用。</span>
57-
</pre>
58-
59-
<hr />
60-
61-
<p>#TT哭泣</p>
62-
63-
<a data-type="emotion" class="e-jx3-emotion w-jx3-element" data-id="940" target="_blank" href="/emotion/940">
64-
<img class="e-jx3-emotion-img" data-type="emotion" data-id="940" style="width:80px;" src="https://img.jx3box.com/upload/post/2022/6/10/76986_7373574.gif" alt="940" />
65-
</a>
66-
67-

public/demo/article_jx3box.html

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ <h4>圈人</h4>
77
<a class="e-jx3-author w-jx3-element" href="/author/8" target="_blank" rel="noopener" data-type="author" data-mode="" data-id="8">@浮烟</a>
88
</p>
99

10-
<p>
11-
文件下载链接:
12-
<a href="https://cdn.jx3box.com/2020/01/%E5%87%8C%E9%9B%AA%E9%98%81%E8%AE%A1%E7%AE%97%E5%99%A83.2%EF%BC%88%E6%9B%B4%E6%96%B0%E5%A4%A7%E9%99%84%E9%AD%94%EF%BC%89.xlsx">
13-
凌雪阁计算器(xlsx)
14-
</a>
15-
</p>
16-
1710

1811
<h4>播放器</h4>
1912
<pre class="w-audio e-audio">name|飞舞;author|醉栩;user_id|8719;src|https://cdn.jx3box.com/design/event/jx3cxk/web/item/luolebai.mp3;avatar|https://oss.jx3box.com/upload/avatar/2022/12/11/8719_8836198.jpg</pre>
@@ -43,97 +36,3 @@ <h4>信纸</h4>
4336
</div>
4437
<style>.letter--yueye{max-width: 1240px;margin:0 auto;color:#fff;font-size:18px;}.letter-title--yueye{background:url("https://cdn.jx3box.com/upload/design/letter/2023/11/27/4011_8157448.png") no-repeat top;text-align:center;background-size: 100% 100%;height: 75px;width: 320px;font-weight: bold;line-height: 75px;font-size: 24px;letter-spacing: 2px;box-sizing: border-box;margin: 0 auto;padding: 0 20px;margin-bottom: 20px;word-wrap: normal;word-break: keep-all;text-overflow: ellipsis;overflow: hidden;}.letter-body--yueye{background:url("https://cdn.jx3box.com/upload/design/letter/2023/11/29/4011_9334649.png");background-size: 100%;line-height: 36px;}.letter-body--yueye p{margin: 0;line-height: 36px;}.letter-header--yueye{background:url("https://cdn.jx3box.com/upload/design/letter/2023/11/29/4011_6979374.png") top center no-repeat;background-size: 100%;padding-top:50px;}.letter-footer--yueye{background:url("https://cdn.jx3box.com/upload/design/letter/2023/11/29/4011_7953837.png") bottom center no-repeat;background-size: 100%;padding:0 4% 50px 4%;min-height:100px;}</style>
4538
<p>&nbsp;</p>
46-
47-
<template>
48-
<div class="c-letter-paper">
49-
<div
50-
:class="`c-letter-title c-letter-title__${data.slug}`"
51-
:style="{
52-
backgroundImage: `url(${data.img_title || ''})`,
53-
backgroundRepeat: 'no-repeat',
54-
backgroundSize: 'cover',
55-
}"
56-
>
57-
我是抬头
58-
</div>
59-
<div
60-
:class="`c-letter-content c-letter-content__${data.slug}`"
61-
:style="{
62-
backgroundImage: `url(${data.img_body || ''})`,
63-
}"
64-
>
65-
<div
66-
class="u-header"
67-
:style="{
68-
backgroundImage: `url(${data.img_header || ''})`,
69-
backgroundRepeat: 'no-repeat',
70-
backgroundPosition: 'top center',
71-
}"
72-
>
73-
<div
74-
class="u-footer"
75-
:style="{
76-
backgroundImage: `url(${data.img_footer || ''})`,
77-
backgroundRepeat: 'no-repeat',
78-
backgroundPosition: 'bottom center',
79-
}"
80-
>
81-
<p v-for="o in 4" :key="o">明月几时有,把酒问青天。</p>
82-
</div>
83-
</div>
84-
</div>
85-
</div>
86-
</template>
87-
88-
<script>
89-
export default {
90-
name: "letter-demo",
91-
props: {
92-
data: {
93-
type: Object,
94-
default: () => {},
95-
},
96-
},
97-
data() {
98-
return {
99-
styleTag: null,
100-
};
101-
},
102-
watch: {
103-
"data.style": {
104-
immediate: true,
105-
handler(val) {
106-
this.insertStyle(val);
107-
},
108-
},
109-
},
110-
methods: {
111-
insertStyle(style) {
112-
if (this.styleTag) {
113-
document.body.removeChild(this.styleTag);
114-
}
115-
this.styleTag = document.createElement("style");
116-
this.styleTag.textContent = style;
117-
document.body.appendChild(this.styleTag);
118-
},
119-
},
120-
};
121-
</script>
122-
<style lang="less">
123-
.c-letter-title {
124-
background-size: cover;
125-
}
126-
.c-letter-content {
127-
margin-top: 20px;
128-
background-repeat: repeat-y;
129-
background-size: contain;
130-
}
131-
.c-letter-content .u-header,
132-
.c-letter-content .u-footer {
133-
background-size: contain;
134-
background-repeat: no-repeat;
135-
}
136-
.c-letter-content .u-footer {
137-
background-position: bottom;
138-
}
139-
</style>

src/Article.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import execLazyload from "./assets/js/img";
6666
import execFilterIframe from "./assets/js/iframe";
6767
import execFilterLink from "./assets/js/a";
6868
import execSplitPages from "./assets/js/nextpage";
69+
import normalizeMarkdownForVditor from "./assets/js/normalizeMarkdownForVditor";
6970
7071
// 扩展文本
7172
import renderFoldBlock from "./assets/js/fold";
@@ -244,8 +245,9 @@ export default {
244245
},
245246
renderMarkdownChunk: async function (chunk) {
246247
const temp = document.createElement("div");
248+
const normalizedChunk = normalizeMarkdownForVditor(chunk);
247249
248-
await Vditor.preview(temp, chunk || "", {
250+
await Vditor.preview(temp, normalizedChunk, {
249251
mode: "light",
250252
lang: "zh_CN",
251253
hljs: {
@@ -254,7 +256,9 @@ export default {
254256
style: "github",
255257
},
256258
markdown: {
259+
mark: true,
257260
sanitize: true,
261+
toc: true,
258262
},
259263
icon: "ant",
260264
});

src/Markdown.vue

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
import Vditor from "vditor";
3636
import "vditor/dist/index.css";
3737
import "github-markdown-css/github-markdown-light.css";
38+
import normalizeMarkdownForVditor from "./assets/js/normalizeMarkdownForVditor";
3839
3940
const { __cms } = JX3BOX;
4041
const UPLOAD_API = `${__cms}api/cms/upload`;
@@ -130,6 +131,7 @@ export default {
130131
previewVisible: false,
131132
isRebuildingEditor: false,
132133
isUploadingImage: false,
134+
previewRenderVersion: 0,
133135
counterElement: null,
134136
counterClickListener: null,
135137
counterClickTimestamps: [],
@@ -235,7 +237,9 @@ export default {
235237
style: "github",
236238
},
237239
markdown: {
240+
mark: true,
238241
sanitize: true,
242+
toc: true,
239243
},
240244
mode: this.getPreviewMode(),
241245
},
@@ -300,7 +304,7 @@ export default {
300304
if (this.editor.getValue() === nextValue) return;
301305
this.editor.setValue(nextValue);
302306
if (this.previewVisible) {
303-
this.editor.renderPreview();
307+
this.renderPreviewContent();
304308
}
305309
},
306310
getToolbarButton(name) {
@@ -356,9 +360,38 @@ export default {
356360
357361
this.syncEditorPanels();
358362
if (this.previewVisible) {
359-
this.editor.renderPreview();
363+
this.renderPreviewContent();
360364
}
361365
},
366+
renderPreviewContent: async function () {
367+
if (!this.editorReady || !this.editor) return;
368+
369+
const previewRoot = this.$refs.editorHost?.querySelector?.(".vditor-preview");
370+
const previewBody = previewRoot?.querySelector?.(".vditor-reset") || previewRoot;
371+
if (!previewBody) return;
372+
373+
const version = ++this.previewRenderVersion;
374+
const normalizedMarkdown = normalizeMarkdownForVditor(this.editor.getValue());
375+
376+
await Vditor.preview(previewBody, normalizedMarkdown, {
377+
mode: "light",
378+
lang: "zh_CN",
379+
hljs: {
380+
enable: true,
381+
lineNumber: false,
382+
style: "github",
383+
},
384+
markdown: {
385+
mark: true,
386+
sanitize: true,
387+
toc: true,
388+
},
389+
icon: "ant",
390+
});
391+
392+
if (version !== this.previewRenderVersion) return;
393+
previewBody.classList.add("markdown-body");
394+
},
362395
togglePreview() {
363396
this.previewVisible = !this.previewVisible;
364397
@@ -528,8 +561,8 @@ export default {
528561
}
529562
530563
.vditor-toolbar {
531-
display: flex;
532-
align-items: center;
564+
display: flex;
565+
align-items: center;
533566
padding: 10px 12px;
534567
background: #f6f8fa;
535568
border-bottom: 1px solid #d8dee4;

src/assets/css/module/author.less

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,14 @@
133133
.y(-3px);
134134
}
135135
}
136-
.u-medals {
136+
.m-medals {
137137
padding: 0 2px;
138138
line-height: unset;
139139

140140
.m-medal {
141141
line-height: normal;
142142
flex-wrap: wrap;
143+
.flex;
143144
}
144145
}
145146

src/assets/css/module/directory.less

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@
9090
line-height: 18px;
9191
color: darken(#dcdfe6, 5%);
9292
cursor: pointer;
93+
.flex;
94+
align-items: center;
9395
&:hover {
9496
color: darken(#dcdfe6, 20%);
9597
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const PROTECTED_SEGMENT_REGEXP = /(```[\s\S]*?```|~~~[\s\S]*?~~~|`[^`\n]*`|\$\$[\s\S]*?\$\$|\$[^$\n]+\$)/g;
2+
3+
function replaceUnderline(text) {
4+
return text.replace(/\+\+([^\n+][^\n]*?)\+\+/g, "<u>$1</u>");
5+
}
6+
7+
function replaceSuperscript(text) {
8+
return text.replace(
9+
/(^|[^\w\\])([A-Za-z0-9)\]}\u4e00-\u9fa5]+)\^([^^\s][^^]*?)\^/g,
10+
(match, prefix, base, value) => {
11+
return `${prefix}${base}<sup>${value}</sup>`;
12+
}
13+
);
14+
}
15+
16+
function replaceSubscript(text) {
17+
return text.replace(/(^|[^\w\\])([A-Za-z0-9)\]}\u4e00-\u9fa5]+)~([^~\s][^~]*?)~/g, (match, prefix, base, value) => {
18+
return `${prefix}${base}<sub>${value}</sub>`;
19+
});
20+
}
21+
22+
function normalizePlainMarkdown(text) {
23+
return [replaceUnderline, replaceSuperscript, replaceSubscript].reduce((result, transform) => {
24+
return transform(result);
25+
}, text);
26+
}
27+
28+
export default function normalizeMarkdownForVditor(markdown) {
29+
const source = String(markdown || "");
30+
if (!source) return "";
31+
32+
const segments = source.split(PROTECTED_SEGMENT_REGEXP);
33+
34+
return segments
35+
.map((segment, index) => {
36+
return index % 2 === 1 ? segment : normalizePlainMarkdown(segment);
37+
})
38+
.join("");
39+
}

src/components/Author.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
</div>
4444
<!-- <div class="u-honor" :style="honorStyle" v-if="honor">{{ honor }}</div> -->
4545
<div class="u-trophy" v-if="hasTrophy">
46-
<div class="u-medals" v-if="medals && medals.length">
46+
<div class="m-medals" v-if="medals && medals.length">
4747
<div class="m-medal">
4848
<a
4949
v-for="item in medals"

0 commit comments

Comments
 (0)