Skip to content

Commit 6c8301c

Browse files
authored
feat(tinymce): migrate tinymce to @tinymce/tinymce-vue to adapt to Vue3 (#450)
1 parent 76d979a commit 6c8301c

File tree

5 files changed

+25
-62
lines changed

5 files changed

+25
-62
lines changed

package-lock.json

Lines changed: 3 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"dependencies": {
1616
"@antv/g2plot": "^0.11.35",
1717
"@babel/polyfill": "^7.4.4",
18-
"@tinymce/tinymce-vue": "^2.0.0",
18+
"@tinymce/tinymce-vue": "^4.0.0",
1919
"axios": "^0.21.1",
2020
"core-js": "^3.6.5",
2121
"dayjs": "^1.10.4",
@@ -30,7 +30,6 @@
3030
"photoswipe": "^4.1.2",
3131
"screenfull": "^4.2.0",
3232
"swiper": "^6.4.5",
33-
"tinymce": "^5.0.1",
3433
"vue": "^3.0.0",
3534
"vue-croppa": "^1.3.8",
3635
"vue-router": "^4.0.0-beta.4",

src/component/base/tinymce/import-all.js

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

src/component/base/tinymce/index.vue

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,9 @@
44
</div>
55
</template>
66
<script>
7-
// eslint-disable-next-line
8-
import tinymce from 'tinymce/tinymce'
97
import Editor from '@tinymce/tinymce-vue'
108
import { post } from '@/lin/plugin/axios'
119
12-
import 'tinymce/themes/silver'
13-
import './import-all'
14-
1510
export default {
1611
name: 'TinymceEditor',
1712
props: {
@@ -27,64 +22,50 @@ export default {
2722
type: Number,
2823
default: undefined,
2924
},
30-
upload_url: {
31-
type: String,
32-
default: '',
33-
},
3425
showMenubar: {
3526
type: Boolean,
3627
default: true,
3728
},
3829
toolbar: {
3930
type: String,
40-
default: ` undo redo
41-
| formatselect
42-
| bold italic strikethrough forecolor backcolor formatpainter
43-
| link image | alignleft aligncenter alignright alignjustify
44-
| numlist bullist outdent indent
45-
| removeformat
31+
default: ` undo redo
32+
| formatselect
33+
| bold italic strikethrough forecolor backcolor formatpainter
34+
| link image | alignleft aligncenter alignright alignjustify
35+
| numlist bullist outdent indent
36+
| removeformat
4637
| preview fullscreen code`,
4738
},
48-
baseUrl: {
49-
type: String,
50-
default: '',
51-
},
5239
},
5340
components: {
5441
Editor,
5542
},
5643
data() {
5744
return {
45+
content: '',
5846
tinymceFlag: 1,
5947
tinymceInit: {},
60-
content: '',
6148
}
6249
},
6350
created() {
6451
this.tinymceInit = {
65-
language_url: `${this.baseUrl}/tinymce/langs/zh_CN.js`,
66-
skin_url: `${this.baseUrl}/tinymce/skins/ui/oxide`,
67-
content_css: `${this.baseUrl}/tinymce/skins/content/default/content.css`,
6852
language: 'zh_CN',
6953
height: this.height,
70-
width: undefined,
71-
browser_spellcheck: true, // 拼写检查
72-
branding: false, // 去水印
73-
elementpath: false, // 禁用编辑器底部的状态栏
54+
branding: true, // 去水印
7455
statusbar: false, // 隐藏编辑器底部的状态栏
56+
elementpath: false, // 禁用编辑器底部的状态栏
57+
toolbar: this.toolbar,
7558
paste_data_images: true, // 允许粘贴图像
59+
browser_spellcheck: true, // 拼写检查
7660
menubar: this.showMenubar, // 隐藏最上方menu
77-
plugins: `print fullpage searchreplace autolink directionality visualblocks
78-
visualchars template codesample charmap hr pagebreak nonbreaking anchor toc insertdatetime
61+
plugins: `print fullpage searchreplace autolink directionality visualblocks
62+
visualchars template codesample charmap hr pagebreak nonbreaking anchor toc insertdatetime
7963
wordcount textpattern help advlist table lists paste preview fullscreen image imagetools code link`,
80-
toolbar: this.toolbar,
8164
async images_upload_handler(blobInfo, success, failure) {
8265
const file = new File([blobInfo.blob()], blobInfo.filename(), {
8366
type: 'image/*',
8467
})
85-
post('cms/file', {
86-
file,
87-
})
68+
post('cms/file', { file })
8869
.then(res => {
8970
if (res.length && res[0]?.url) {
9071
success(res[0].url)
@@ -117,3 +98,9 @@ export default {
11798
},
11899
}
119100
</script>
101+
102+
<style lang="scss">
103+
.tox-notification {
104+
display: none !important;
105+
}
106+
</style>

src/plugin/custom/view/tinymce.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="lin-container">
33
<div class="lin-title">富文本舞台页面</div>
4-
<div class="lin-wrap"><tinymce @change="change" upload_url="http://dev.lin.colorful3.com/cms/file/" /></div>
4+
<div class="lin-wrap"><tinymce @change="change" :defaultContent="text" /></div>
55
</div>
66
</template>
77

0 commit comments

Comments
 (0)