From dc40b527c6b1986aec6382ec1b9d1e8f823763a8 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Wed, 28 Sep 2022 11:12:55 +0800 Subject: [PATCH] fix: post editor generates toc causing cursor movement error Signed-off-by: Ryan Wang --- src/modules/contents/posts/PostEditor.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/contents/posts/PostEditor.vue b/src/modules/contents/posts/PostEditor.vue index b5b54543..e93fe971 100644 --- a/src/modules/contents/posts/PostEditor.vue +++ b/src/modules/contents/posts/PostEditor.vue @@ -16,7 +16,7 @@ import PostSettingModal from "./components/PostSettingModal.vue"; import PostPreviewModal from "./components/PostPreviewModal.vue"; import AttachmentSelectorModal from "../attachments/components/AttachmentSelectorModal.vue"; import type { PostRequest } from "@halo-dev/api-client"; -import { computed, markRaw, onMounted, ref, watch } from "vue"; +import { computed, markRaw, nextTick, onMounted, ref, watch } from "vue"; import cloneDeep from "lodash.clonedeep"; import { apiClient } from "@/utils/api-client"; import { useRouteQuery } from "@vueuse/router"; @@ -125,7 +125,9 @@ const editor = useEditor({ autofocus: "start", onUpdate: () => { formState.value.content.raw = editor.value?.getHTML() + ""; - handleGenerateTableOfContent(); + nextTick(() => { + handleGenerateTableOfContent(); + }); }, });