33 <editor id =" tinymceEditor" :init =" tinymceInit" v-model =" content" :key =" tinymceFlag" ></editor >
44 </div >
55</template >
6-
76<script >
87// eslint-disable-next-line
98import tinymce from ' tinymce/tinymce'
109import Editor from ' @tinymce/tinymce-vue'
1110import ' tinymce/themes/silver/theme'
12- import ' tinymce/plugins/textcolor'
13- import ' tinymce/plugins/advlist'
14- import ' tinymce/plugins/table'
15- import ' tinymce/plugins/lists'
16- import ' tinymce/plugins/paste'
17- import ' tinymce/plugins/preview'
18- import ' tinymce/plugins/fullscreen'
19- import ' tinymce/plugins/image'
20- import ' tinymce/plugins/code'
21- import ' tinymce/plugins/link'
11+ import ' ./importAll'
2212
2313export default {
2414 name: ' TinymceEditor' ,
@@ -39,6 +29,11 @@ export default {
3929 type: Boolean ,
4030 default: true ,
4131 },
32+ toolbar: {
33+ type: String ,
34+ // eslint-disable-next-line
35+ default: ' undo redo |formatselect | bold italic strikethrough forecolor backcolor formatpainter | link image | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat | preview fullscreen code' ,
36+ },
4237 },
4338 components: {
4439 Editor,
@@ -64,32 +59,25 @@ export default {
6459 statusbar: false , // 隐藏编辑器底部的状态栏
6560 paste_data_images: true , // 允许粘贴图像
6661 menubar: this .showMenubar , // 隐藏最上方menu
67- plugins: ' advlist table lists paste preview fullscreen image code link' ,
6862 // eslint-disable-next-line
69- toolbar: ' undo redo |fontselect fontsizeselect forecolor backcolor bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | link image | h1 h2 h3 blockquote table numlist bullist | preview fullscreen code' ,
63+ plugins: ' print fullpage searchreplace autolink directionality visualblocks visualchars template codesample charmap hr pagebreak nonbreaking anchor toc insertdatetime wordcount textpattern help advlist table lists paste preview fullscreen image imagetools code link' ,
64+ toolbar: this .toolbar ,
7065 // eslint-disable-next-line
7166 images_upload_handler : async function (blobInfo , success , failure ) {
72- // eslint-disable-next-line
73- let json
74- const xhr = new XMLHttpRequest ()
75- xhr .withCredentials = false
76- xhr .open (' POST' , ` ${ _this .upload_url } ` )
77- // eslint-disable-next-line
78- xhr .onload = function () {
79- if (xhr .status !== 200 ) {
80- failure (` HTTP Error: ${ xhr .status } ` )
81- return
82- }
83- json = JSON .parse (xhr .responseText )
84- if (json[0 ] && json[0 ].url ) {
85- success (json[0 ].url )
86- } else {
87- failure (` Invalid JSON: ${ xhr .responseText } ` )
67+ const file = new File ([blobInfo .blob ()], blobInfo .filename (), {
68+ type: ' image/*' ,
69+ })
70+ _this .$axios ({
71+ method: ' post' ,
72+ url: ' /cms/file/' ,
73+ data: {
74+ file,
75+ },
76+ }).then ((res ) => {
77+ if (res[0 ] && res[0 ].url ) {
78+ success (res[0 ].url )
8879 }
89- }
90- const formData = new FormData ()
91- formData .append (' file' , blobInfo .blob (), blobInfo .filename ())
92- xhr .send (formData)
80+ }).catch (err => failure (err))
9381 },
9482 }
9583 },
0 commit comments