Vanessa 2025-05-12 10:40:14 +08:00
parent 8094e28b13
commit 69cc3bd361
2 changed files with 9 additions and 0 deletions

View file

@ -608,6 +608,7 @@ export class Toolbar {
if (newNodes.length === 1 && newNodes[0].textContent === Constants.ZWSP) {
this.range.setStart(newNodes[0], 1);
this.range.collapse(true);
keepZWPS = false;
}
if (!keepZWPS) {
// 合并元素
@ -693,6 +694,12 @@ export class Toolbar {
currentNode = hasNextSibling(newNodes[i - 1]) as HTMLElement;
}
if (!currentNode) {
if (previousElement.nodeType !== 3) {
const currentType = (previousElement.getAttribute("data-type") || "").split(" ");
if (currentType.includes("code") || currentType.includes("tag") || currentType.includes("kbd")) {
previousElement.insertAdjacentText("afterend", Constants.ZWSP);
}
}
break;
}
if (currentNode.nodeType === 3) {

View file

@ -972,6 +972,8 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
if (position.start === 2 && inlineElement &&
getSelectionOffset(inlineElement, protyle.wysiwyg.element, range).start === 1 &&
inlineElement.innerText.startsWith(Constants.ZWSP) &&
// 7.1 ctrl+g 后删除 https://github.com/siyuan-note/siyuan/issues/14290#issuecomment-2867478746
inlineElement.innerText !== Constants.ZWSP &&
// 需排除行内代码前有一个字符的情况
editElement.innerText.startsWith(Constants.ZWSP)) {
focusBlock(nodeElement);