@jx3box/jx3box-editor 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/css/article_markdown.less +0 -6
- package/assets/css/markdown/common.less +13 -0
- package/assets/css/markdown.less +0 -7
- package/assets/css/module/code.less +1 -1
- package/assets/data/markdown_whitelist.json +14 -0
- package/assets/js/code.js +13 -0
- package/package.json +4 -3
- package/src/Article.vue +2 -5
- package/src/ArticleMarkdown.vue +19 -7
- package/src/Markdown.vue +35 -3
- package/src/components/markdown/macro.vue +46 -0
- package/src/components/markdown/pz.vue +49 -0
- package/vue.config.js +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
.c-editor-markdown-macro {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
|
|
4
|
+
.u-input {
|
|
5
|
+
.el-textarea__inner {
|
|
6
|
+
|
|
7
|
+
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
.el-dialog__body {
|
|
11
|
+
padding-top: 0;
|
|
12
|
+
}
|
|
13
|
+
}
|
package/assets/css/markdown.less
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"xssOptions": {
|
|
3
|
+
"whiteList": {
|
|
4
|
+
"pre": ["class", "style"],
|
|
5
|
+
"div": ["class", "style"],
|
|
6
|
+
"video": ["controls", "width", "height", "style", "src"],
|
|
7
|
+
"audio": ["controls", "src"],
|
|
8
|
+
"source": ["src", "type", "style"],
|
|
9
|
+
"iframe": ["src", "frameborder", "scrolling", "allowfullscreen"],
|
|
10
|
+
"details":[],
|
|
11
|
+
"summary":[]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jx3box/jx3box-editor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "JX3BOX Article & Editor",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,18 +31,19 @@
|
|
|
31
31
|
"last 2 versions"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@jx3box/jx3box-common": "^6.7.
|
|
34
|
+
"@jx3box/jx3box-common": "^6.7.8",
|
|
35
35
|
"@jx3box/jx3box-data": "^1.8.3",
|
|
36
36
|
"@jx3box/jx3box-emotion": "^1.0.10",
|
|
37
37
|
"@jx3box/jx3box-macro": "^1.0.1",
|
|
38
38
|
"@jx3box/jx3box-talent": "^1.1.2",
|
|
39
|
-
"@jx3box/markdown": "0.
|
|
39
|
+
"@jx3box/markdown": "^0.1.3",
|
|
40
40
|
"@tinymce/tinymce-vue": "^3.2.2",
|
|
41
41
|
"axios": "^0.19.2",
|
|
42
42
|
"core-js": "^3.6.5",
|
|
43
43
|
"csslab": "^4.0.3",
|
|
44
44
|
"element-ui": "^2.13.2",
|
|
45
45
|
"hevue-img-preview": "^5.0.0",
|
|
46
|
+
"highlight.js": "^11.3.1",
|
|
46
47
|
"jquery": "^3.5.1",
|
|
47
48
|
"js-base64": "^3.6.1",
|
|
48
49
|
"katex": "^0.13.0",
|
package/src/Article.vue
CHANGED
|
@@ -62,9 +62,6 @@
|
|
|
62
62
|
import { Pagination, Button, Popover } from "element-ui";
|
|
63
63
|
import "@jx3box/jx3box-common/css/element.css";
|
|
64
64
|
|
|
65
|
-
// 语法高亮
|
|
66
|
-
import Prism from "prismjs";
|
|
67
|
-
|
|
68
65
|
// 相册
|
|
69
66
|
// import gallery from "vue-gallery-slideshow";
|
|
70
67
|
import Vue from "vue";
|
|
@@ -91,7 +88,7 @@ import renderMacro from "../assets/js/macro";
|
|
|
91
88
|
import renderTalent from "../assets/js/qixue";
|
|
92
89
|
import renderTalent2 from "../assets/js/talent2";
|
|
93
90
|
import renderKatex from "../assets/js/katex";
|
|
94
|
-
|
|
91
|
+
import renderCode from "../assets/js/code";
|
|
95
92
|
import renderImgPreview from "../assets/js/renderImgPreview";
|
|
96
93
|
|
|
97
94
|
// 剑三
|
|
@@ -180,7 +177,7 @@ export default {
|
|
|
180
177
|
// 折叠块
|
|
181
178
|
renderFoldBlock($root);
|
|
182
179
|
// 代码
|
|
183
|
-
|
|
180
|
+
renderCode(`code[class=^'language-']`)
|
|
184
181
|
// Tatex
|
|
185
182
|
renderKatex();
|
|
186
183
|
|
package/src/ArticleMarkdown.vue
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="c-article-markdown">
|
|
3
|
-
<
|
|
3
|
+
<markdown-render class="c-markdown" ref="article" v-model="origin" @change="updateOrigin"></markdown-render>
|
|
4
4
|
<div class="w-jx3-element-pop" :style="jx3_element.style">
|
|
5
5
|
<jx3-item :item_id="item.id" :jx3ClientType="item.client" v-show="jx3_element.type == 'item'" />
|
|
6
6
|
<jx3-buff :client="buff.client" :id="buff.id" :level="buff.level" v-show="jx3_element.type == 'buff'" />
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
</template>
|
|
11
11
|
|
|
12
12
|
<script>
|
|
13
|
+
import markdownRender from '@jx3box/markdown/src/render.vue'
|
|
14
|
+
|
|
13
15
|
// 基本文本
|
|
14
16
|
import execLazyload from "../assets/js/img";
|
|
15
17
|
import execFilterIframe from "../assets/js/iframe";
|
|
@@ -21,6 +23,8 @@ import renderDirectory from "../assets/js/directory";
|
|
|
21
23
|
import renderMacro from "../assets/js/macro";
|
|
22
24
|
import renderTalent from "../assets/js/qixue";
|
|
23
25
|
import renderTalent2 from "../assets/js/talent2";
|
|
26
|
+
import renderKatex from "../assets/js/katex";
|
|
27
|
+
import renderCode from "../assets/js/code";
|
|
24
28
|
|
|
25
29
|
// 剑三
|
|
26
30
|
import Item from "./Item";
|
|
@@ -28,6 +32,8 @@ import Buff from "./Buff";
|
|
|
28
32
|
import Skill from "./Skill";
|
|
29
33
|
import renderJx3Element from "../assets/js/jx3_element";
|
|
30
34
|
|
|
35
|
+
import {xssOptions} from '../assets/data/markdown_whitelist.json'
|
|
36
|
+
|
|
31
37
|
export default {
|
|
32
38
|
name: "ArticleMarkdown",
|
|
33
39
|
props: {
|
|
@@ -68,6 +74,8 @@ export default {
|
|
|
68
74
|
},
|
|
69
75
|
type: "",
|
|
70
76
|
},
|
|
77
|
+
|
|
78
|
+
xssOptions
|
|
71
79
|
};
|
|
72
80
|
},
|
|
73
81
|
computed: {
|
|
@@ -85,12 +93,16 @@ export default {
|
|
|
85
93
|
return "";
|
|
86
94
|
}
|
|
87
95
|
},
|
|
88
|
-
doDOM: function(
|
|
96
|
+
doDOM: function() {
|
|
89
97
|
// 宏
|
|
90
98
|
renderMacro();
|
|
91
99
|
// 奇穴
|
|
92
100
|
renderTalent();
|
|
93
101
|
renderTalent2();
|
|
102
|
+
// Tatex
|
|
103
|
+
renderKatex();
|
|
104
|
+
// 语法高亮
|
|
105
|
+
renderCode(`code[class=^'lang-']`)
|
|
94
106
|
// 物品
|
|
95
107
|
renderJx3Element(this);
|
|
96
108
|
},
|
|
@@ -113,17 +125,16 @@ export default {
|
|
|
113
125
|
render: function() {
|
|
114
126
|
let result = this.doReg(this.html);
|
|
115
127
|
this.data = result;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
this
|
|
128
|
+
|
|
129
|
+
// TODO: 过滤未展示
|
|
130
|
+
this.$forceUpdate()
|
|
119
131
|
|
|
120
132
|
// 等待html加载完毕后
|
|
121
133
|
this.$nextTick(() => {
|
|
122
134
|
this.$emit("contentLoaded");
|
|
123
135
|
|
|
124
136
|
// 统一DOM处理
|
|
125
|
-
|
|
126
|
-
this.doDOM($root);
|
|
137
|
+
this.doDOM();
|
|
127
138
|
this.$emit("contentRendered");
|
|
128
139
|
|
|
129
140
|
// 目录处理
|
|
@@ -145,6 +156,7 @@ export default {
|
|
|
145
156
|
"jx3-item": Item,
|
|
146
157
|
"jx3-buff": Buff,
|
|
147
158
|
"jx3-skill": Skill,
|
|
159
|
+
markdownRender,
|
|
148
160
|
},
|
|
149
161
|
};
|
|
150
162
|
</script>
|
package/src/Markdown.vue
CHANGED
|
@@ -10,12 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
<slot></slot>
|
|
12
12
|
|
|
13
|
-
<
|
|
13
|
+
<markdown-editor class="c-markdown" ref="md" v-model="data" @change="updateData" :subfield="false">
|
|
14
14
|
<template slot="left-toolbar-after">
|
|
15
15
|
<span class="c-markdown-toolbar-image c-markdown-toolbar-item" title="上传图片" @click="selectImages"><i class="el-icon-picture-outline-round"></i></span>
|
|
16
16
|
<span class="c-markdown-toolbar-file c-markdown-toolbar-item" title="上传附件" @click="selectFiles"><i class="el-icon-paperclip"></i></span>
|
|
17
|
+
<!-- <macro @insert="insertMacro" /> -->
|
|
18
|
+
<!-- <pz @insert="insertPz" /> -->
|
|
17
19
|
</template>
|
|
18
|
-
</
|
|
20
|
+
</markdown-editor>
|
|
19
21
|
<input class="c-markdown-store-item" id="c-markdown-store-images" type="file" @change="uploadImages" ref="markdownImages" multiple :accept="allow_image_types" />
|
|
20
22
|
<input class="c-markdown-store-item" id="c-markdown-store-files" type="file" @change="uploadFiles" ref="markdownFiles" multiple />
|
|
21
23
|
|
|
@@ -24,9 +26,19 @@
|
|
|
24
26
|
</template>
|
|
25
27
|
|
|
26
28
|
<script>
|
|
29
|
+
import markdownEditor from '@jx3box/markdown/src/editor.vue'
|
|
30
|
+
|
|
31
|
+
import {xssOptions} from '../assets/data/markdown_whitelist.json'
|
|
32
|
+
import { uploadFile } from "../service/cms";
|
|
33
|
+
|
|
27
34
|
import Upload from "./Upload";
|
|
28
35
|
import Resource from "./Resource";
|
|
29
|
-
|
|
36
|
+
|
|
37
|
+
// jx3
|
|
38
|
+
import macro from '@/components/markdown/macro.vue'
|
|
39
|
+
import pz from '@/components/markdown/pz.vue'
|
|
40
|
+
|
|
41
|
+
|
|
30
42
|
export default {
|
|
31
43
|
name: "Markdown",
|
|
32
44
|
props: {
|
|
@@ -51,8 +63,12 @@ export default {
|
|
|
51
63
|
}
|
|
52
64
|
},
|
|
53
65
|
components: {
|
|
66
|
+
markdownEditor,
|
|
54
67
|
Upload,
|
|
55
68
|
Resource,
|
|
69
|
+
|
|
70
|
+
// macro,
|
|
71
|
+
// pz,
|
|
56
72
|
},
|
|
57
73
|
data: function() {
|
|
58
74
|
return {
|
|
@@ -62,6 +78,8 @@ export default {
|
|
|
62
78
|
image_ext: ["png", "jpg", "gif", "bmp", "webp"],
|
|
63
79
|
files: [],
|
|
64
80
|
resolved_files: [],
|
|
81
|
+
|
|
82
|
+
xssOptions
|
|
65
83
|
};
|
|
66
84
|
},
|
|
67
85
|
model: {
|
|
@@ -192,6 +210,20 @@ export default {
|
|
|
192
210
|
// TODO:
|
|
193
211
|
// tinyMCE.editors["tinymce"].insertContent(data);
|
|
194
212
|
},
|
|
213
|
+
insertMacro(data) {
|
|
214
|
+
this.$md.insertText(this.$md.getTextareaDom(), {
|
|
215
|
+
prefix: data,
|
|
216
|
+
subfix: "",
|
|
217
|
+
str: "",
|
|
218
|
+
});
|
|
219
|
+
},
|
|
220
|
+
insertPz(data) {
|
|
221
|
+
this.$md.insertText(this.$md.getTextareaDom(), {
|
|
222
|
+
prefix: data,
|
|
223
|
+
subfix: "",
|
|
224
|
+
str: "",
|
|
225
|
+
});
|
|
226
|
+
}
|
|
195
227
|
},
|
|
196
228
|
filters: {},
|
|
197
229
|
created: function() {},
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="c-editor-markdown-dialog c-editor-markdown-macro">
|
|
3
|
+
<span class="c-markdown-toolbar-file c-markdown-toolbar-item" @click="handleClick" title="插入宏">宏</span>
|
|
4
|
+
|
|
5
|
+
<el-dialog :visible.sync="visible" title="插入宏" :modal-append-to-body="false">
|
|
6
|
+
<el-input class="u-input u-input-macro" type="textarea" :rows="15" v-model="macro" show-word-limit :maxlength="128"></el-input>
|
|
7
|
+
|
|
8
|
+
<div slot="footer">
|
|
9
|
+
<el-button @click="cancel">取消</el-button>
|
|
10
|
+
<el-button type="primary" @click="insert">插入</el-button>
|
|
11
|
+
</div>
|
|
12
|
+
</el-dialog>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script>
|
|
17
|
+
export default {
|
|
18
|
+
name: 'markdown_marco',
|
|
19
|
+
data() {
|
|
20
|
+
return {
|
|
21
|
+
visible: false,
|
|
22
|
+
macro: ''
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
methods: {
|
|
26
|
+
handleClick() {
|
|
27
|
+
this.visible = true
|
|
28
|
+
},
|
|
29
|
+
cancel() {
|
|
30
|
+
this.visible = false
|
|
31
|
+
this.macro = ''
|
|
32
|
+
},
|
|
33
|
+
insert() {
|
|
34
|
+
const content = `<pre class="e-jx3macro-area w-jx3macro">${this.macro}</pre>`
|
|
35
|
+
|
|
36
|
+
this.$emit('insert', content)
|
|
37
|
+
|
|
38
|
+
this.visible = false
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<style lang="less">
|
|
45
|
+
@import '../../../assets/css/markdown/common.less';
|
|
46
|
+
</style>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="m-macro-dialog m-pz-dialog">
|
|
3
|
+
<span class="c-markdown-toolbar-file c-markdown-toolbar-item" @click="handleClick" title="插入配装方案">装</span>
|
|
4
|
+
|
|
5
|
+
<el-dialog :visible.sync="visible" title="配装方案" :modal-append-to-body="false">
|
|
6
|
+
|
|
7
|
+
<p>👘 请填入魔盒配装方案的<a target="_blank" href="/tool/32032">【嵌入版】</a>编码</p>
|
|
8
|
+
|
|
9
|
+
<el-input class="m-macro-input" type="textarea" :rows="4" v-model="pzCode"></el-input>
|
|
10
|
+
|
|
11
|
+
<div slot="footer">
|
|
12
|
+
<el-button @click="cancel">取消</el-button>
|
|
13
|
+
<el-button type="primary" @click="insert">插入</el-button>
|
|
14
|
+
</div>
|
|
15
|
+
</el-dialog>
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script>
|
|
20
|
+
export default {
|
|
21
|
+
name: 'markdown_marco',
|
|
22
|
+
data() {
|
|
23
|
+
return {
|
|
24
|
+
visible: false,
|
|
25
|
+
pzCode: ''
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
methods: {
|
|
29
|
+
handleClick() {
|
|
30
|
+
this.visible = true
|
|
31
|
+
},
|
|
32
|
+
cancel() {
|
|
33
|
+
this.visible = false
|
|
34
|
+
this.pzCode = ''
|
|
35
|
+
},
|
|
36
|
+
insert() {
|
|
37
|
+
const content = `${this.pzCode}`
|
|
38
|
+
|
|
39
|
+
this.$emit('insert', content)
|
|
40
|
+
|
|
41
|
+
this.visible = false
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<style lang="less">
|
|
48
|
+
@import '../../../assets/css/markdown/common.less';
|
|
49
|
+
</style>
|