diff --git a/rsbuild.config.ts b/rsbuild.config.ts index 6862e0d..205271f 100644 --- a/rsbuild.config.ts +++ b/rsbuild.config.ts @@ -1,4 +1,3 @@ -import path from "node:path" import { defineConfig, loadEnv } from "@rsbuild/core" import { pluginVue } from "@rsbuild/plugin-vue" import AutoImport from "unplugin-auto-import/rspack" @@ -85,11 +84,6 @@ const config: ReturnType = defineConfig(({ envMode }) => { oj: "./src/oj", admin: "./src/admin", shared: "./src/shared", - // 强制 @wangeditor-next/editor 所有导入(ESM/CJS)走同一个文件 - // 避免 Rspack v2 按 exports conditions 分别解析 .mjs/.js 产生双实例 - "@wangeditor-next/editor$": path.resolve( - "./node_modules/@wangeditor-next/editor/dist/index.js" - ), }, }, server: { diff --git a/src/shared/components/TextEditor.vue b/src/shared/components/TextEditor.vue index c62295e..ac99b09 100644 --- a/src/shared/components/TextEditor.vue +++ b/src/shared/components/TextEditor.vue @@ -25,6 +25,7 @@ const props = withDefaults(defineProps(), { const message = useMessage() const editorRef = shallowRef() +const toolbarEditorRef = shallowRef() const toolbarConfig: Partial = { toolbarKeys: [ @@ -91,8 +92,10 @@ function onClick() { editorRef.value.focus() } -function handleCreated(editor: IDomEditor) { +async function handleCreated(editor: IDomEditor) { editorRef.value = editor + await nextTick() + toolbarEditorRef.value = editor } async function customUpload(file: File, insertFn: InsertFnType) { @@ -113,7 +116,7 @@ async function customUpload(file: File, insertFn: InsertFnType) {