An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: fix https://github.com/siyuan-note/siyuan/issues/11606
Vanessabcb1bcc29089
diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.tsindex a9410f2992..b9518a0469 100644--- a/app/src/protyle/util/selection.ts+++ b/app/src/protyle/util/selection.ts@@ -486,10 +486,11 @@ export const focusByRange = (range: Range) => {selection.addRange(range);};-export const focusBlock = (element: Element, parentElement?: HTMLElement, toStart = true) => {+export const focusBlock = (element: Element, parentElement?: HTMLElement, toStart = true): false | Range => {if (!element) {return false;}+// hr、嵌入块、数学公式、iframe、音频、视频、图表渲染块等,删除段落块后,光标位置矫正 https://github.com/siyuan-note/siyuan/issues/4143if (element.classList.contains("render-node") || element.classList.contains("iframe") || element.classList.contains("hr") || element.classList.contains("av")) {const range = document.createRange();@@ -609,6 +610,11 @@ export const focusBlock = (element: Element, parentElement?: HTMLElement, toStarreturn range;} else if (parentElement) {parentElement.focus();+ } else {+ // li 下面为 hr、嵌入块、数学公式、iframe、音频、视频、图表渲染块等时递归处理+ if (element.classList.contains("li")) {+ return focusBlock(element.querySelector('[data-node-id]'), parentElement, toStart);+ }}return false;};diff --git a/app/src/protyle/wysiwyg/remove.ts b/app/src/protyle/wysiwyg/remove.tsindex 675d8fe0b6..86b94464ed 100644--- a/app/src/protyle/wysiwyg/remove.ts+++ b/app/src/protyle/wysiwyg/remove.ts@@ -197,13 +197,7 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: RanremoveBlock(protyle, blockElement, range, type);return;}- // 设置 bq 和代码块光标- if (["NodeCodeBlock", "NodeTable", "NodeAttributeView"].includes(blockType)) {- if (blockElement.previousElementSibling) {- focusBlock(blockElement.previousElementSibling, undefined, false);- }- return;- }+if (!blockElement.previousElementSibling && blockElement.parentElement.getAttribute("data-type") === "NodeBlockquote") {range.insertNode(document.createElement("wbr"));const blockParentElement = blockElement.parentElement;@@ -249,6 +243,14 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: RanremoveLi(protyle, blockElement, range, type === "Delete");return;}+ // 设置 bq 和代码块光标+ // 需放在列表处理后 https://github.com/siyuan-note/siyuan/issues/11606+ if (["NodeCodeBlock", "NodeTable", "NodeAttributeView"].includes(blockType)) {+ if (blockElement.previousElementSibling) {+ focusBlock(blockElement.previousElementSibling, undefined, false);+ }+ return;+ }if (blockType === "NodeHeading") {turnsIntoTransaction({protyle: protyle,