11<template >
22 <div class =' tinymce-container editor-container' >
3- <textarea class =' tinymce-textarea' :id =" id " ></textarea >
3+ <textarea class =' tinymce-textarea' :id =" tinymceId " ></textarea >
44 <div class =" editor-custom-btn-container" >
55 <editorImage color =" #20a0ff" class =" editor-upload-btn" @successCBK =" imageSuccessCBK" ></editorImage >
66 </div >
@@ -15,8 +15,7 @@ export default {
1515 components: { editorImage },
1616 props: {
1717 id: {
18- type: String ,
19- default: ' tinymceEditor'
18+ type: String
2019 },
2120 value: {
2221 type: String ,
@@ -29,12 +28,6 @@ export default {
2928 return [' removeformat undo redo | bullist numlist | outdent indent | forecolor | fullscreen code' , ' bold italic blockquote | h2 p media link | alignleft aligncenter alignright' ]
3029 }
3130 },
32- data () {
33- return {
34- hasChange: false ,
35- hasInit: false
36- }
37- },
3831 menubar: {
3932 default: ' '
4033 },
@@ -44,6 +37,13 @@ export default {
4437 default: 360
4538 }
4639 },
40+ data () {
41+ return {
42+ hasChange: false ,
43+ hasInit: false ,
44+ tinymceId: this .id || ' vue-tinymce-' + + new Date ()
45+ }
46+ },
4747 watch: {
4848 value (val ) {
4949 if (! this .hasChange && this .hasInit ) {
@@ -54,7 +54,7 @@ export default {
5454 mounted () {
5555 const _this = this
5656 window .tinymce .init ({
57- selector: ` #${ this .id } ` ,
57+ selector: ` #${ this .tinymceId } ` ,
5858 height: this .height ,
5959 body_class: ' panel-body ' ,
6060 object_resizing: false ,
@@ -153,12 +153,12 @@ export default {
153153 imageSuccessCBK (arr ) {
154154 const _this = this
155155 arr .forEach (v => {
156- window .tinymce .get (_this .id ).insertContent (` <img class="wscnph" src="${ v .url } " >` )
156+ window .tinymce .get (_this .tinymceId ).insertContent (` <img class="wscnph" src="${ v .url } " >` )
157157 })
158158 }
159159 },
160160 destroyed () {
161- window .tinymce .get (this .id ).destroy ()
161+ window .tinymce .get (this .tinymceId ).destroy ()
162162 }
163163}
164164 </script >
0 commit comments