Skip to content

Commit

Permalink
fix(tinymce): fixed multiple editors showing only one (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Nov 9, 2020
1 parent a7ce344 commit 52ec763
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Wip

### 🐛 Bug Fixes

- 修复多个富文本编辑器只显示一个

## 2.0.0-rc.9 (2020-11-9)

### ✨ Features
Expand Down
1 change: 0 additions & 1 deletion build/vite/plugin/dynamicImport/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const dynamicImportTransform = function (env: any = {}): Transform {
export default function (id) {
switch (id) {
${files
.map((p) =>
` case '${getPath(p)}': return () => import('${p
.replace('src/views', '/@/views')
Expand Down
16 changes: 9 additions & 7 deletions src/components/Tinymce/src/Editor.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="tinymce-container" :style="{ width: containerWidth }">
<textarea :id="tinymceId" ref="elRef"></textarea>
<textarea :id="tinymceId" ref="elRef" :style="{ visibility: 'hidden' }"></textarea>
</div>
</template>

Expand All @@ -15,7 +15,6 @@
watch,
onUnmounted,
onDeactivated,
watchEffect,
} from 'vue';
import { basicProps } from './props';
import toolbar from './toolbar';
Expand All @@ -36,12 +35,9 @@
emits: ['change', 'update:modelValue'],
setup(props, { emit, attrs }) {
const editorRef = ref<any>(null);
const tinymceId = ref<string>(snowUuid('tiny-vue'));
const elRef = ref<Nullable<HTMLElement>>(null);
const tinymceId = computed(() => {
return snowUuid('tiny-vue');
});
const tinymceContent = computed(() => {
return props.modelValue;
});
Expand Down Expand Up @@ -118,12 +114,18 @@
function init() {
toPromise().then(() => {
initEditor();
setTimeout(() => {
initEditor();
}, 0);
});
}
function initEditor() {
getTinymce().PluginManager.add('lineHeight', lineHeight(getTinymce()));
const el = unref(elRef);
if (el) {
el.style.visibility = '';
}
getTinymce().init(unref(initOptions));
}
Expand Down

0 comments on commit 52ec763

Please sign in to comment.