@jx3box/jx3box-editor 1.0.1 → 1.0.6
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/assets/js/directory.js +1 -1
- package/package.json +4 -3
- package/src/Article.vue +2 -5
- package/src/ArticleMarkdown.vue +18 -21
- 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/assets/js/directory.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jx3box/jx3box-editor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
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.5",
|
|
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 id="c-article" class="c-markdown" ref="article" v-model="origin" @change="updateOrigin" :preRender="doReg"></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: {
|
|
@@ -38,10 +44,8 @@ export default {
|
|
|
38
44
|
return {
|
|
39
45
|
// 原始md
|
|
40
46
|
origin : '',
|
|
41
|
-
// 原始渲染md后的html
|
|
47
|
+
// 原始渲染md后的html(传入文本回调处理函数)
|
|
42
48
|
html: "",
|
|
43
|
-
// 文本处理后的html
|
|
44
|
-
data: "",
|
|
45
49
|
|
|
46
50
|
// 物品
|
|
47
51
|
item: {
|
|
@@ -68,6 +72,8 @@ export default {
|
|
|
68
72
|
},
|
|
69
73
|
type: "",
|
|
70
74
|
},
|
|
75
|
+
|
|
76
|
+
xssOptions
|
|
71
77
|
};
|
|
72
78
|
},
|
|
73
79
|
computed: {
|
|
@@ -85,24 +91,21 @@ export default {
|
|
|
85
91
|
return "";
|
|
86
92
|
}
|
|
87
93
|
},
|
|
88
|
-
doDOM: function(
|
|
94
|
+
doDOM: function() {
|
|
89
95
|
// 宏
|
|
90
96
|
renderMacro();
|
|
91
97
|
// 奇穴
|
|
92
98
|
renderTalent();
|
|
93
99
|
renderTalent2();
|
|
100
|
+
// Tatex
|
|
101
|
+
renderKatex();
|
|
102
|
+
// 语法高亮
|
|
103
|
+
renderCode(`code[class=^'lang-']`)
|
|
94
104
|
// 物品
|
|
95
105
|
renderJx3Element(this);
|
|
96
106
|
},
|
|
97
107
|
doDir: function() {
|
|
98
|
-
|
|
99
|
-
let target = "";
|
|
100
|
-
if (this.hasPages && !this.all) {
|
|
101
|
-
target = "#c-article-part" + this.page;
|
|
102
|
-
// 全部
|
|
103
|
-
} else {
|
|
104
|
-
target = "#c-article";
|
|
105
|
-
}
|
|
108
|
+
let target = "#c-article";
|
|
106
109
|
let dir = renderDirectory(target, this.directorybox);
|
|
107
110
|
if (dir) this.$emit("directoryRendered");
|
|
108
111
|
},
|
|
@@ -111,19 +114,12 @@ export default {
|
|
|
111
114
|
this.render()
|
|
112
115
|
},
|
|
113
116
|
render: function() {
|
|
114
|
-
let result = this.doReg(this.html);
|
|
115
|
-
this.data = result;
|
|
116
|
-
},
|
|
117
|
-
run: function() {
|
|
118
|
-
this.render();
|
|
119
|
-
|
|
120
117
|
// 等待html加载完毕后
|
|
121
118
|
this.$nextTick(() => {
|
|
122
119
|
this.$emit("contentLoaded");
|
|
123
120
|
|
|
124
121
|
// 统一DOM处理
|
|
125
|
-
|
|
126
|
-
this.doDOM($root);
|
|
122
|
+
this.doDOM();
|
|
127
123
|
this.$emit("contentRendered");
|
|
128
124
|
|
|
129
125
|
// 目录处理
|
|
@@ -145,6 +141,7 @@ export default {
|
|
|
145
141
|
"jx3-item": Item,
|
|
146
142
|
"jx3-buff": Buff,
|
|
147
143
|
"jx3-skill": Skill,
|
|
144
|
+
markdownRender,
|
|
148
145
|
},
|
|
149
146
|
};
|
|
150
147
|
</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>
|