Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: fix https://github.com/siyuan-note/siyuan/issues/12241

Vanessa5a10723db9d2
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index f8a4906907..3830df5dad 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -798,7 +798,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
return;
}
} else if (selectText === "") {
- const editElement = getContenteditableElement(nodeElement);
+ const editElement = getContenteditableElement(nodeElement) as HTMLElement;
if (!editElement) {
nodeElement.classList.add("protyle-wysiwyg--select");
removeBlock(protyle, nodeElement, range, event.key === "Backspace" ? "Backspace" : "Delete");
@@ -809,11 +809,11 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
const position = getSelectionOffset(editElement, protyle.wysiwyg.element, range);
if (event.key === "Delete" || matchHotKey("⌃D", event)) {
// 段末反向删除 https://github.com/siyuan-note/insider/issues/274
- if (position.end === editElement.textContent.length ||
+ if (position.end === editElement.innerText.length ||
// 软换行后删除 https://github.com/siyuan-note/siyuan/issues/11118
- (position.end === editElement.textContent.length - 1 && editElement.textContent.endsWith("\n")) ||
+ (position.end === editElement.innerText.length - 1 && editElement.innerText.endsWith("\n")) ||
// 图片后无内容删除 https://github.com/siyuan-note/siyuan/issues/11868
- (position.end === editElement.textContent.length - 1 && editElement.textContent.endsWith(Constants.ZWSP))) {
+ (position.end === editElement.innerText.length - 1 && editElement.innerText.endsWith(Constants.ZWSP))) {
const nextElement = getNextBlock(getTopAloneElement(nodeElement));
if (nextElement) {
const nextRange = focusBlock(nextElement);
@@ -827,7 +827,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
event.preventDefault();
return;
}
- } else if (position.end === editElement.textContent.length - 1 && nodeElement.getAttribute("data-type") === "NodeCodeBlock") {
+ } else if (position.end === editElement.innerText.length - 1 && nodeElement.getAttribute("data-type") === "NodeCodeBlock") {
event.stopPropagation();
event.preventDefault();
return;
@@ -850,7 +850,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
const currentNode = range.startContainer.childNodes[range.startOffset - 1] as HTMLElement;
if (position.start === 0 && (
range.startOffset === 0 ||
- (currentNode && currentNode.nodeType === 3 && !hasPreviousSibling(currentNode) && currentNode.textContent === "") // https://ld246.com/article/1649251218696
+ (currentNode && currentNode.nodeType === 3 && !hasPreviousSibling(currentNode) && currentNode.innerText === "") // https://ld246.com/article/1649251218696
)) {
removeBlock(protyle, nodeElement, range, "Backspace");
event.stopPropagation();
@@ -884,15 +884,15 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
const inlineElement = hasClosestByMatchTag(range.startContainer, "SPAN");
if (position.start === 2 && inlineElement &&
getSelectionOffset(inlineElement, protyle.wysiwyg.element, range).start === 1 &&
- inlineElement.textContent.startsWith(Constants.ZWSP)) {
+ inlineElement.innerText.startsWith(Constants.ZWSP)) {
focusBlock(nodeElement);
event.stopPropagation();
event.preventDefault();
return;
}
- if (position.start === 1 && !inlineElement && editElement.textContent.startsWith(Constants.ZWSP) &&
+ if (position.start === 1 && !inlineElement && editElement.innerText.startsWith(Constants.ZWSP) &&
// https://github.com/siyuan-note/siyuan/issues/12149
- editElement.textContent.length > 1) {
+ editElement.innerText.length > 1) {
setFirstNodeRange(editElement, range);
removeBlock(protyle, nodeElement, range, "Backspace");
event.stopPropagation();