This commit is contained in:
Vanessa 2022-07-21 23:25:39 +08:00
parent 69ece9ab18
commit e86e8e242f
3 changed files with 16 additions and 3 deletions

View file

@ -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 = `<div data-subtype="${selectElements[0].getAttribute("data-subtype")}" data-node-id="${Lute.NewNodeID()}" data-type="NodeList" class="list">${html}<div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div></div>`;
}
}
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;

View file

@ -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)) {

View file

@ -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