diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index 21d03a71a..d7bf22a9a 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -25,7 +25,7 @@ import {dropEvent} from "../util/editorCommonEvent"; import {input} from "./input"; import { getContenteditableElement, - getLastBlock, + getLastBlock, getNextBlock, getPreviousHeading, getTopAloneElement, hasNextSibling, @@ -297,7 +297,12 @@ export class WYSIWYG { html = `
${html}
${Constants.ZWSP}
`; } } + const nextElement = getNextBlock(selectElements[selectElements.length - 1]); removeBlock(protyle, nodeElement, range); + if (nextElement) { + // Ctrl+X 剪切后光标应跳到下一行行首 https://github.com/siyuan-note/siyuan/issues/5485 + focusBlock(nextElement); + } } else { const id = nodeElement.getAttribute("data-node-id"); const oldHTML = nodeElement.outerHTML; diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index 03cc94ba9..6ab32d959 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -1362,11 +1362,19 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { if (isNotEditBlock(nodeElement) && matchHotKey("⌘X", event)) { let html = ""; - protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select").forEach(item => { + nodeElement.classList.add("protyle-wysiwyg--select"); + const selectElements = protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select") + selectElements.forEach(item => { html += removeEmbed(item); }); writeText(protyle.lute.BlockDOM2StdMd(html).trimEnd()); + const nextElement = getNextBlock(selectElements[selectElements.length - 1]); removeBlock(protyle, nodeElement, range); + if (nextElement) { + focusBlock(nextElement); + } + event.preventDefault(); + event.stopPropagation(); } if (matchHotKey(window.siyuan.config.keymap.editor.general.vLayout.custom, event)) { diff --git a/app/src/protyle/wysiwyg/remove.ts b/app/src/protyle/wysiwyg/remove.ts index 507c6362e..abfb9e432 100644 --- a/app/src/protyle/wysiwyg/remove.ts +++ b/app/src/protyle/wysiwyg/remove.ts @@ -443,7 +443,7 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Ran focusSideBlock(previousElement); } else { const previousLastEditElement = getContenteditableElement(previousLastElement); - if (editableElement.textContent !== "") { + if (editableElement && editableElement.textContent !== "") { // 非空块 range.setEndAfter(editableElement.lastChild); // 数学公式会车后再删除 https://github.com/siyuan-note/siyuan/issues/3850