Skip to content

Commit c6baa9b

Browse files
committed
fix: 🐛 use nextTick to defer execution after the DOM update circle
1 parent e206e06 commit c6baa9b

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

docs/components/demo/DemoEditor.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
{ value: '', label: 'None' },
1414
]"
1515
></VOptions>
16+
<div>{{ selectedTheme }}</div>
1617
</div>
1718
<div class="text-sm text-gray-400 font-bold mb-2">TOOLBAR</div>
1819
<div class="flex md:flex-col gap-2 mb-4">
@@ -26,6 +27,7 @@
2627
{ value: '', label: 'None' },
2728
]"
2829
></VOptions>
30+
<div>{{ selectedToolbar }}</div>
2931
</div>
3032
</div>
3133
<div class="initial flex-1 flex flex-col">
@@ -46,7 +48,7 @@
4648
<script lang="ts">
4749
import { Quill } from "@vueup/vue-quill";
4850
import { Delta } from "types-quill-delta";
49-
import { defineComponent, onMounted, ref } from "vue";
51+
import { defineComponent, watch, onMounted, ref } from "vue";
5052
import VOptions from "../VOptions.vue";
5153
import { deltaContent } from "./delta-content";
5254
@@ -77,6 +79,10 @@ export default defineComponent({
7779
const selectedTheme = ref<string>("snow");
7880
const selectedToolbar = ref<string>("essential");
7981
82+
watch([selectedTheme, selectedToolbar], () => {
83+
myEditor.value.reinit();
84+
});
85+
8086
return {
8187
selectedTheme,
8288
selectedToolbar,

src/components/QuillEditor.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
defineComponent,
1313
onBeforeUnmount,
1414
onMounted,
15+
nextTick,
1516
PropType,
1617
watch,
1718
ref,
@@ -214,9 +215,12 @@ export default defineComponent({
214215
}
215216

216217
const reinit = () => {
217-
if (!ctx.slots.toolbar && quill)
218-
quill.getModule("toolbar")?.container.remove();
219-
initialize();
218+
nextTick(() => {
219+
if (!ctx.slots.toolbar && quill)
220+
quill.getModule("toolbar")?.container.remove();
221+
initialize();
222+
console.log("reinit call");
223+
})
220224
}
221225

222226
watch(

0 commit comments

Comments
 (0)