From ca0c0b8140ca260afd3d6821796f110e7e3866dd Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Tue, 28 Feb 2023 22:42:18 +0800 Subject: [PATCH] fix: get the wrong link after selecting an attachment (halo-dev/console#893) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #### What type of PR is this? /kind bug #### What this PR does / why we need it: 修复默认编辑器从附件库选择非图片、音视频的附件,以链接的形式插入之后得到的链接不正确的问题。 #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/3408 #### Screenshots: before: image after: image #### Special notes for your reviewer: 测试方式: 1. 上传若干 zip 格式附件。 2. 在编辑器中选择这些附件并插入,检查链接是否正确。 #### Does this PR introduce a user-facing change? ```release-note None ``` --- .../contents/attachments/composables/use-attachment.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/modules/contents/attachments/composables/use-attachment.ts b/src/modules/contents/attachments/composables/use-attachment.ts index 4c0ac1766..9bf47c5fe 100644 --- a/src/modules/contents/attachments/composables/use-attachment.ts +++ b/src/modules/contents/attachments/composables/use-attachment.ts @@ -314,11 +314,7 @@ export function useAttachmentSelect( }) .filter(Boolean) as Content[]; - editor.value - ?.chain() - .focus() - .insertContent([...contents, { type: "paragraph", content: "" }]) - .run(); + editor.value?.chain().focus().insertContent(contents).run(); }; return {