An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Fix inline appearance menu positioning
Danield80401454a19
diff --git a/app/src/protyle/toolbar/Font.ts b/app/src/protyle/toolbar/Font.tsindex 07b303bc6b..5e05480f76 100644--- a/app/src/protyle/toolbar/Font.ts+++ b/app/src/protyle/toolbar/Font.ts@@ -38,6 +38,7 @@ export class Font extends ToolbarItem {super(protyle, menuItem);this.element.addEventListener("click", () => {const triggerRect = this.element.getBoundingClientRect();+ const visibleTriggerRect = triggerRect.width > 0 && triggerRect.height > 0 ? triggerRect : undefined;protyle.toolbar.element.classList.add("fn__none");protyle.toolbar.subElement.innerHTML = "";protyle.toolbar.subElement.style.width = "";@@ -50,7 +51,9 @@ export class Font extends ToolbarItem {protyle.toolbar.subElementCloseCB = undefined;focusByRange(protyle.toolbar.range);/// #if !MOBILE- protyle.toolbar.setSelectionElementPosition(protyle, protyle.toolbar.subElement, triggerRect);+ protyle.toolbar.setSelectionElementPosition(+ protyle, protyle.toolbar.subElement, visibleTriggerRect, appearanceElement+ );/// #endif});}diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.tsindex 85d69237d3..4b5945d902 100644--- a/app/src/protyle/toolbar/index.ts+++ b/app/src/protyle/toolbar/index.ts@@ -188,7 +188,8 @@ export class Toolbar {/// #endif}- public setSelectionElementPosition(protyle: IProtyle, element: HTMLElement, triggerRect?: DOMRect) {+ public setSelectionElementPosition(protyle: IProtyle, element: HTMLElement, triggerRect?: DOMRect,+ scrollElement?: HTMLElement) {if (!this.rangePosition || !this.range) {return;}@@ -199,6 +200,17 @@ export class Toolbar {(this.rangePosition.isBottom ? rangeRects[rangeRects.length - 1] : rangeRects[0]) ||this.range.getBoundingClientRect();const gap = this.isMultipleClick ? 2 : 4;+ if (scrollElement) {+ const availableHeight = Math.max(+ rangeRect.top - protyleRect.top - 30 - gap,+ protyleRect.bottom - rangeRect.bottom - gap,+ 0+ );+ const overflowHeight = Math.max(0, element.offsetHeight - availableHeight);+ if (overflowHeight > 0) {+ scrollElement.style.maxHeight = `${Math.max(0, scrollElement.offsetHeight - overflowHeight)}px`;+ }+ }const above = rangeRect.top - element.clientHeight - gap;const below = rangeRect.bottom + gap;const y = this.rangePosition.isBottom ?diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.tsindex 15e168db91..1a3488aaf8 100644--- a/app/src/protyle/wysiwyg/keydown.ts+++ b/app/src/protyle/wysiwyg/keydown.ts@@ -1818,6 +1818,9 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {if (matchHotKey(menuItem.hotkey, event)) {// 设置 lastHTMLs 会导致 protyle.toolbar.range 和 range 不一致,需重置一下 https://github.com/siyuan-note/siyuan/issues/10933protyle.toolbar.range = range;+ if (menuItem.name === "text") {+ protyle.toolbar.rangePosition = getSelectionPosition(nodeElement, range, true);+ }if (["block-ref"].includes(menuItem.name) && protyle.toolbar.range.toString() === "") {return true;}