Skip to content

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

:bug: fix https://github.com/siyuan-note/siyuan/issues/5814

Vanessa42c061b11886
diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts
index a2c5699160..91ea511404 100644
--- a/app/src/protyle/hint/index.ts
+++ b/app/src/protyle/hint/index.ts
@@ -442,11 +442,18 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
range.insertNode(document.createElement("wbr"));
html = nodeElement.outerHTML;
range.deleteContents();
- const tempElement = document.createElement("template");
+ let tempElement = document.createElement("div");
tempElement.innerHTML = value.replace(/<mark>/g, "").replace(/<\/mark>/g, "");
- range.insertNode(tempElement.content.cloneNode(true));
+ tempElement = tempElement.firstChild as HTMLDivElement;
+ range.insertNode(tempElement);
+ range.setStart(tempElement.firstChild, 0);
+ range.setEnd(tempElement.lastChild, tempElement.lastChild.textContent.length);
updateTransaction(protyle, id, nodeElement.outerHTML, html);
- focusByWbr(nodeElement, range);
+ const wbrElement = nodeElement.querySelector("wbr");
+ if (wbrElement) {
+ wbrElement.remove();
+ }
+ focusByRange(range);
return;
} else if (this.splitChar === ":") {
addEmoji(value);
diff --git a/app/src/protyle/util/insertHTML.ts b/app/src/protyle/util/insertHTML.ts
index d832657a8f..f9f2e7afd4 100644
--- a/app/src/protyle/util/insertHTML.ts
+++ b/app/src/protyle/util/insertHTML.ts
@@ -54,7 +54,7 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false) =>
if (inlineMathElement) {
// 表格内选中数学公式 https://ld246.com/article/1631708573504
inlineMathElement.remove();
- } else if (range.startContainer.nodeType === 3 && range.startContainer.parentElement.getAttribute("data-type").indexOf("block-ref")>-1) {
+ } else if (range.startContainer.nodeType === 3 && range.startContainer.parentElement.getAttribute("data-type")?.indexOf("block-ref")>-1) {
// ref 选中处理 https://ld246.com/article/1629214377537
range.startContainer.parentElement.remove();
// 选中 ref**bbb** 后 alt+[
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index 0cf3d2b12a..61cd7c4488 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -503,6 +503,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
if (!event.altKey && !event.shiftKey && !isCtrl(event) && (event.key.indexOf("Arrow") > -1 || event.key === "Enter") &&
!protyle.hint.element.classList.contains("fn__none") && protyle.hint.select(event, protyle)) {
event.stopPropagation();
+ event.preventDefault();
return;
}
if (matchHotKey("⌘/", event)) {