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/17032
Vanessadc69ca74282b
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.tsindex 75280deb92..66f1541111 100644--- a/app/src/protyle/toolbar/index.ts+++ b/app/src/protyle/toolbar/index.ts@@ -57,6 +57,7 @@ export class Toolbar {public element: HTMLElement;public subElement: HTMLElement;public subElementCloseCB: () => void;+ public subElementResizeCB: () => void;public range: Range;public toolbarHeight: number;private readonly LINE_HEIGHT = 32;@@ -986,7 +987,7 @@ export class Toolbar {<span class="fn__space"></span><button data-type="close" class="block__icon block__icon--show b3-tooltips b3-tooltips__nw" aria-label="${window.siyuan.languages.close}"><svg><use xlink:href="#iconClose"></use></svg></button></div>-<div class="protyle-util__scroll"><div class="fn__flex"><div class="protyle-linenumber__rows"></div><textarea ${protyle.disabled ? " readonly" : ""} spellcheck="false" class="b3-text-field b3-text-field--text fn__flex-1" placeholder="${placeholder}" style="resize:none;font-family: var(--b3-font-family-code);"></textarea></div></div></div>+<div class="protyle-util__scroll"><div class="fn__flex"><div class="protyle-linenumber__rows"></div><textarea ${protyle.disabled ? " readonly" : ""} spellcheck="false" class="b3-text-field b3-text-field--text fn__flex-1" placeholder="${placeholder}" style="overflow:hidden;resize:none;font-family: var(--b3-font-family-code);"></textarea></div></div></div><div class="resize__rd"></div><div class="resize__ld"></div><div class="resize__lt"></div><div class="resize__rt"></div><div class="resize__r"></div><div class="resize__d"></div><div class="resize__t"></div><div class="resize__l"></div>`;const gutter = this.subElement.querySelector(".protyle-linenumber__rows") as HTMLElement;const renderTextareaLineNumber = () => {@@ -1009,9 +1010,9 @@ export class Toolbar {mirror.style.fontVariantLigatures = textCs.fontVariantLigatures;mirror.style.letterSpacing = textCs.letterSpacing;// 宽度需与 textarea 文本区一致:clientWidth 减去左右内边距- mirror.style.width = textElement.clientWidth - parseInt(textCs.paddingLeft) - parseInt(textCs.paddingRight) + "px";+ mirror.style.width = textElement.getBoundingClientRect().width + "px";mirror.style.boxSizing = "border-box";- mirror.style.padding = "0";+ mirror.style.padding = "4px 8px";mirror.innerHTML = lineList.map(line => `<div>${line.trim() ? escapeHtml(line) : " "}</div>`).join("");// 挂到行号栏所在容器,保证字体上下文一致(gutter.parentElement || document.body).appendChild(mirror);@@ -1186,12 +1187,8 @@ export class Toolbar {return;}});- const resizeObserver = new ResizeObserver(() => {- renderTextareaLineNumber();- });- resizeObserver.observe(this.subElement);+ this.subElementResizeCB = renderTextareaLineNumber;this.subElementCloseCB = () => {- resizeObserver.disconnect();const noChange = !renderElement.parentElement || protyle.disabled ||(textElement.value && oldTextValue === textElement.value);let inlineLastNode: Element;@@ -1447,7 +1444,6 @@ export class Toolbar {});this.subElement.style.zIndex = (++window.siyuan.zIndex).toString();this.subElement.classList.remove("fn__none");- this.subElementCloseCB = undefined;/// #if !MOBILEconst nodeRect = languageElements[0].getBoundingClientRect();setPosition(this.subElement, nodeRect.left, nodeRect.bottom, nodeRect.height);@@ -1476,7 +1472,6 @@ export class Toolbar {</div>`;this.subElement.style.zIndex = (++window.siyuan.zIndex).toString();this.subElement.classList.remove("fn__none");- this.subElementCloseCB = undefined;this.subElement.firstElementChild.addEventListener("click", (event) => {let target = event.target as HTMLElement;while (target && target !== this.subElement) {@@ -1679,7 +1674,6 @@ export class Toolbar {});this.subElement.style.zIndex = (++window.siyuan.zIndex).toString();this.subElement.classList.remove("fn__none");- this.subElementCloseCB = undefined;this.element.classList.add("fn__none");inputElement.select();genList();@@ -1757,7 +1751,6 @@ export class Toolbar {});this.subElement.style.zIndex = (++window.siyuan.zIndex).toString();this.subElement.classList.remove("fn__none");- this.subElementCloseCB = undefined;this.element.classList.add("fn__none");inputElement.select();genList(true);@@ -1852,7 +1845,6 @@ export class Toolbar {});this.subElement.style.zIndex = (++window.siyuan.zIndex).toString();this.subElement.classList.remove("fn__none");- this.subElementCloseCB = undefined;this.element.classList.add("fn__none");const rangePosition = getSelectionPosition(nodeElement, range);setPosition(this.subElement, rangePosition.left, rangePosition.top - 48, this.LINE_HEIGHT);@@ -1990,5 +1982,7 @@ export class Toolbar {private clearSubElement() {this.subElement.removeAttribute("style");+ this.subElementCloseCB = null;+ this.subElementResizeCB = null;}}diff --git a/app/src/protyle/ui/initUI.ts b/app/src/protyle/ui/initUI.tsindex 7c09cd4e94..745d5de0f5 100644--- a/app/src/protyle/ui/initUI.ts+++ b/app/src/protyle/ui/initUI.ts@@ -63,13 +63,16 @@ export const initUI = (protyle: IProtyle) => {protyle.element.appendChild(protyle.toolbar.element);protyle.element.appendChild(protyle.toolbar.subElement);/// #if !MOBILE- moveResize(protyle.toolbar.subElement, () => {+ moveResize(protyle.toolbar.subElement, (type) => {const pinElement = protyle.toolbar.subElement.querySelector('.block__icons [data-type="pin"]');if (pinElement) {pinElement.querySelector("svg use").setAttribute("xlink:href", "#iconUnpin");pinElement.setAttribute("aria-label", window.siyuan.languages.unpin);protyle.toolbar.subElement.firstElementChild.setAttribute("data-drag", "true");}+ if (type !== "move" && protyle.toolbar.subElementResizeCB) {+ protyle.toolbar.subElementResizeCB();+ }});/// #endif