From 56143952c4d7844646a1f53c387a91aac2445aea Mon Sep 17 00:00:00 2001 From: zhengyi Date: Thu, 8 Feb 2024 23:38:00 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20insert=20image=20failed=20?= =?UTF-8?q?use=20attachment=20selector=20in=20hotkey.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://git.mczhengyi.top/zhengyi/halo-plugin-vditor/issues/62 --- console/src/views/VditorMde.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/console/src/views/VditorMde.vue b/console/src/views/VditorMde.vue index d02b79f..1379984 100644 --- a/console/src/views/VditorMde.vue +++ b/console/src/views/VditorMde.vue @@ -62,6 +62,7 @@ const debounceOnUpdate = () => { // 选取附件后处理 const attachmentSelect = (attachments: AttachmentLike[]) => { + setCursor(lastSelectionRange); // Reference https://github.com/guqing/willow-mde/blob/4b8e697132f8a8f4b08dd0f92cf10d070cb26793/console/src/components/toolbar/Toolbar.vue#L104 attachments.forEach((attachment) => { if (typeof attachment === "string") { @@ -129,7 +130,10 @@ onMounted(async () => { vditorLoaded.value = true; }, input: debounceOnUpdate, - showAttachment: () => (attachmentSelectorModalShow.value = true), + showAttachment: () => { + lastSelectionRange = getCursor(); + attachmentSelectorModalShow.value = true; + }, language: lang, codeBlockPreview: editorConfig.value.basic.codeBlockPreview, uploadImage: (files: File[]) => {