From e1d8a609d0f214a5bab041c78064047a6ef7226f Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 5 Oct 2023 20:30:20 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/5485 --- app/src/protyle/wysiwyg/keydown.ts | 7 ++++++- app/src/protyle/wysiwyg/remove.ts | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index 29b3fc5dd..b61e99801 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -1471,8 +1471,13 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { } if (matchHotKey("⌘C", event) && selectText === "") { + const selectElements = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select")); + if (selectElements.length === 0) { + nodeElement.classList.add("protyle-wysiwyg--select"); + selectElements.push(nodeElement); + } let html = ""; - protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select").forEach(item => { + selectElements.forEach(item => { html += removeEmbed(item); }); if (html !== "") { diff --git a/app/src/protyle/wysiwyg/remove.ts b/app/src/protyle/wysiwyg/remove.ts index 4b3cfd1d7..a813417af 100644 --- a/app/src/protyle/wysiwyg/remove.ts +++ b/app/src/protyle/wysiwyg/remove.ts @@ -203,7 +203,7 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Ran action: "delete", id, }); - sideElement = getPreviousBlock(topElement) || getNextBlock(topElement) || topElement.parentElement || protyle.wysiwyg.element.firstElementChild; + sideElement = getNextBlock(topElement) || getPreviousBlock(topElement) || topElement.parentElement || protyle.wysiwyg.element.firstElementChild; if (topElement.getAttribute("data-type") === "NodeHeading" && topElement.getAttribute("fold") === "1") { // https://github.com/siyuan-note/siyuan/issues/2188 setFold(protyle, topElement, undefined, true); @@ -268,8 +268,8 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Ran sideElement = undefined; focusByWbr(emptyElement, range); } - - focusBlock(sideElement, undefined, false); + // https://github.com/siyuan-note/siyuan/issues/5485 + focusBlock(sideElement); scrollCenter(protyle, sideElement); if (listElement) { inserts.push({