From a53fb49ec3aa89c26e64ecade7baad5246ad006d Mon Sep 17 00:00:00 2001 From: Sinclair Chen Date: Wed, 5 Oct 2022 16:08:01 -0700 Subject: [PATCH] don't insert extra lines when upload photos --- web/components/editor.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/web/components/editor.tsx b/web/components/editor.tsx index 27e8ac45..f84e62e2 100644 --- a/web/components/editor.tsx +++ b/web/components/editor.tsx @@ -311,12 +311,12 @@ const useUploadMutation = (editor: Editor | null) => { onSuccess(urls) { if (!editor) return - let trans = editor.view.state.tr - urls.forEach((src: any) => { - const node = editor.view.state.schema.nodes.image.create({ src }) - trans = trans.insert(editor.view.state.selection.to, node) + let trans = editor.chain().focus() + urls.forEach((src) => { + trans = trans.createParagraphNear() + trans = trans.setImage({ src }) }) - editor.view.dispatch(trans) + trans.run() }, } )