From 65e9dfa023fb4ec7c39ee2a9f7a3b060a7fa8410 Mon Sep 17 00:00:00 2001 From: qiang Date: Thu, 13 Oct 2022 20:51:42 +0800 Subject: [PATCH] fix: init editor context before init quill (question/154702) --- .../src/vue/editor/quill/index.ts | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/packages/uni-components/src/vue/editor/quill/index.ts b/packages/uni-components/src/vue/editor/quill/index.ts index 9170775ba..88a18584b 100644 --- a/packages/uni-components/src/vue/editor/quill/index.ts +++ b/packages/uni-components/src/vue/editor/quill/index.ts @@ -242,35 +242,6 @@ export function useQuill( quillReady = true trigger('ready', {} as Event, {}) } - onMounted(() => { - const imageResizeModules: ResizeModuleName[] = [] - if (props.showImgSize) { - imageResizeModules.push('DisplaySize') - } - if (props.showImgToolbar) { - imageResizeModules.push('Toolbar') - } - if (props.showImgResize) { - imageResizeModules.push('Resize') - } - const quillSrc = - __PLATFORM__ === 'app' - ? './__uniappquill.js' - : 'https://unpkg.com/quill@1.3.7/dist/quill.min.js' - loadScript((window as WindowExt).Quill, quillSrc, () => { - if (imageResizeModules.length) { - const imageResizeSrc = - __PLATFORM__ === 'app' - ? './__uniappquillimageresize.js' - : 'https://unpkg.com/quill-image-resize-mp@3.0.1/image-resize.min.js' - loadScript((window as WindowExt).ImageResize, imageResizeSrc, () => { - initQuill(imageResizeModules) - }) - } else { - initQuill(imageResizeModules) - } - }) - }) const id = useContextInfo() useSubscribe<{ callbackId: string; data: any }>( (type, data: any, resolve) => { @@ -438,4 +409,33 @@ export function useQuill( id, true ) + onMounted(() => { + const imageResizeModules: ResizeModuleName[] = [] + if (props.showImgSize) { + imageResizeModules.push('DisplaySize') + } + if (props.showImgToolbar) { + imageResizeModules.push('Toolbar') + } + if (props.showImgResize) { + imageResizeModules.push('Resize') + } + const quillSrc = + __PLATFORM__ === 'app' + ? './__uniappquill.js' + : 'https://unpkg.com/quill@1.3.7/dist/quill.min.js' + loadScript((window as WindowExt).Quill, quillSrc, () => { + if (imageResizeModules.length) { + const imageResizeSrc = + __PLATFORM__ === 'app' + ? './__uniappquillimageresize.js' + : 'https://unpkg.com/quill-image-resize-mp@3.0.1/image-resize.min.js' + loadScript((window as WindowExt).ImageResize, imageResizeSrc, () => { + initQuill(imageResizeModules) + }) + } else { + initQuill(imageResizeModules) + } + }) + }) } -- GitLab