Commit 1093ec3e6e4fe1f49b7458c29e518744fe56532f
1 parent
bc6214cd
fix(tinymce): fixed multiple editors showing only one (#83)
Showing
3 changed files
with
15 additions
and
8 deletions
CHANGELOG.zh_CN.md
build/vite/plugin/dynamicImport/index.ts
src/components/Tinymce/src/Editor.vue
1 | 1 | <template> |
2 | 2 | <div class="tinymce-container" :style="{ width: containerWidth }"> |
3 | - <textarea :id="tinymceId" ref="elRef"></textarea> | |
3 | + <textarea :id="tinymceId" ref="elRef" :style="{ visibility: 'hidden' }"></textarea> | |
4 | 4 | </div> |
5 | 5 | </template> |
6 | 6 | |
... | ... | @@ -15,7 +15,6 @@ |
15 | 15 | watch, |
16 | 16 | onUnmounted, |
17 | 17 | onDeactivated, |
18 | - watchEffect, | |
19 | 18 | } from 'vue'; |
20 | 19 | import { basicProps } from './props'; |
21 | 20 | import toolbar from './toolbar'; |
... | ... | @@ -36,12 +35,9 @@ |
36 | 35 | emits: ['change', 'update:modelValue'], |
37 | 36 | setup(props, { emit, attrs }) { |
38 | 37 | const editorRef = ref<any>(null); |
38 | + const tinymceId = ref<string>(snowUuid('tiny-vue')); | |
39 | 39 | const elRef = ref<Nullable<HTMLElement>>(null); |
40 | 40 | |
41 | - const tinymceId = computed(() => { | |
42 | - return snowUuid('tiny-vue'); | |
43 | - }); | |
44 | - | |
45 | 41 | const tinymceContent = computed(() => { |
46 | 42 | return props.modelValue; |
47 | 43 | }); |
... | ... | @@ -118,12 +114,18 @@ |
118 | 114 | |
119 | 115 | function init() { |
120 | 116 | toPromise().then(() => { |
121 | - initEditor(); | |
117 | + setTimeout(() => { | |
118 | + initEditor(); | |
119 | + }, 0); | |
122 | 120 | }); |
123 | 121 | } |
124 | 122 | |
125 | 123 | function initEditor() { |
126 | 124 | getTinymce().PluginManager.add('lineHeight', lineHeight(getTinymce())); |
125 | + const el = unref(elRef); | |
126 | + if (el) { | |
127 | + el.style.visibility = ''; | |
128 | + } | |
127 | 129 | getTinymce().init(unref(initOptions)); |
128 | 130 | } |
129 | 131 | ... | ... |