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: https://github.com/siyuan-note/siyuan/issues/14619
Vanessa84e59e83f552
diff --git a/app/src/protyle/util/selection.ts b/app/src/protyle/util/selection.tsindex 23086aa5cb..9fedb55ed9 100644--- a/app/src/protyle/util/selection.ts+++ b/app/src/protyle/util/selection.ts@@ -417,7 +417,7 @@ export const focusByOffset = (container: Element, start: number, end: number, is} else if (isFocus && (isNotEditBlock(container) || container.classList.contains("av"))) {return focusBlock(container);}- let startNode;+ let startNode: Node;searchNode(container, container.firstChild, node => {if (node.nodeType === Node.TEXT_NODE) {const dataLength = (node as Text).data.length;@@ -428,6 +428,14 @@ export const focusByOffset = (container: Element, start: number, end: number, isstart -= dataLength;end -= dataLength;return false;+ } else if (node.nodeType === Node.ELEMENT_NODE && (node as Element).tagName === "BR") {+ if (start <= 1) {+ startNode = node;+ return true;+ }+ start -= 1;+ end -= 1;+ return false;}});@@ -448,7 +456,7 @@ export const focusByOffset = (container: Element, start: number, end: number, isconst range = document.createRange();if (startNode) {- if (start < (startNode as Text).data.length) {+ if (startNode.nodeType === Node.TEXT_NODE && start < (startNode as Text).data.length) {range.setStart(startNode, start);} else {range.setStartAfter(startNode);diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.tsindex 749ada0625..8ccff2fbc1 100644--- a/app/src/protyle/wysiwyg/index.ts+++ b/app/src/protyle/wysiwyg/index.ts@@ -422,6 +422,9 @@ export class WYSIWYG {if (isEndOfBlock(range)) {textPlain = textPlain.replace(/\n$/, "");}+ } else if (hasClosestByTag(range.startContainer, "TD") || hasClosestByTag(range.startContainer, "TH")) {+ tempElement.innerHTML = tempElement.innerHTML.replace(/<br>/g, "\n").replace(/<br\/>/g, "\n");+ textPlain = tempElement.textContent;} else if (!hasClosestByTag(range.startContainer, "CODE")) {textPlain = range.toString();}@@ -1678,6 +1681,9 @@ export class WYSIWYG {protyle.hint.render(protyle);if (!selectAVElement) {textPlain = textPlain || protyle.lute.BlockDOM2StdMd(html).trimEnd(); // 需要 trimEnd,否则 \n 会导致 https://github.com/siyuan-note/siyuan/issues/6218+ if (nodeElement.classList.contains("table")) {+ textPlain = textPlain.replace(/<br>/g, "\n").replace(/<br\/>/g, "\n");+ }}textPlain = textPlain.replace(/\u00A0/g, " "); // Replace non-breaking spaces with normal spaces when copying https://github.com/siyuan-note/siyuan/issues/9382event.clipboardData.setData("text/plain", textPlain);