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/17916
Daniel3db8ca7a93b8
diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.tsindex c55e174d7b..6630f54324 100644--- a/app/src/protyle/render/av/col.ts+++ b/app/src/protyle/render/av/col.ts@@ -466,6 +466,11 @@ export const bindEditEvent = (options: {blockID: options.blockID});(options.menuElement.querySelector('[data-type="addOption"]') as HTMLInputElement).focus();+ // 添加选项后面板增高,需按首次锚点重新定位(sticky 锁底部,顶部上移避免溢出视口)+ const prevTop = parseFloat(options.menuElement.dataset.positionTop);+ if (!isNaN(prevTop)) {+ setPosition(options.menuElement, parseFloat(options.menuElement.dataset.positionX), prevTop, 0, 0, true);+ }}});}diff --git a/app/src/protyle/render/av/select.ts b/app/src/protyle/render/av/select.tsindex 1983e1b64b..cb9aa7f258 100644--- a/app/src/protyle/render/av/select.ts+++ b/app/src/protyle/render/av/select.ts@@ -12,6 +12,7 @@ import * as dayjs from "dayjs";import {getFieldsByData} from "./view";import {getFieldIdByCellElement} from "./row";import {Constants} from "../../../constants";+import {setPosition} from "../../../util/setPosition";let cellValues: IAVCellValue[];@@ -138,7 +139,13 @@ export const removeCellOption = (protyle: IProtyle, cellElements: HTMLElement[],return true;}});+ // chips 减少导致菜单高度变化后重新定位(锁底部,顶部自适应),需在移除 target 前获取 menuElement+ const menuElement = hasClosestByClassName(target, "b3-menu");target.remove();+ if (menuElement) {+ const cellRect = cellElements[cellElements.length - 1].getBoundingClientRect();+ setPosition(menuElement, cellRect.left, cellRect.bottom, cellRect.height, 0, true);+ }};export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement, blockElement: Element, isCustomAttr: boolean, cellElements?: HTMLElement[]) => {@@ -236,6 +243,9 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement,}if (selectedElement) {menuElement.querySelector(".b3-menu__items").scrollTop = oldScroll + (menuElement.querySelector(".b3-chips").clientHeight - oldChipsHeight);+ // chips 增减导致菜单高度变化后重新定位(锁底部,顶部自适应,避免底部溢出视口)+ const cellRect = cellElements[cellElements.length - 1].getBoundingClientRect();+ setPosition(menuElement, cellRect.left, cellRect.bottom, cellRect.height, 0, true);}});if (menu.isOpen) {@@ -353,6 +363,9 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement,}if (selectedElement) {menuElement.querySelector(".b3-menu__items").scrollTop = oldScroll + (menuElement.querySelector(".b3-chips").clientHeight - oldChipsHeight);+ // chips 增减导致菜单高度变化后重新定位(锁底部,顶部自适应,避免底部溢出视口)+ const cellRect = cellElements[cellElements.length - 1].getBoundingClientRect();+ setPosition(menuElement, cellRect.left, cellRect.bottom, cellRect.height, 0, true);}}, undefined, true);}@@ -443,6 +456,9 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement,bindSelectEvent(protyle, data, menuElement, cellElements, blockElement);}menuElement.querySelector(".b3-menu__items").scrollTop = oldScroll;+ // chips 增减导致菜单高度变化后重新定位(锁底部,顶部自适应,避免底部溢出视口)+ const cellRect = cellElements[cellElements.length - 1].getBoundingClientRect();+ setPosition(menuElement, cellRect.left, cellRect.bottom, cellRect.height, 0, true);name = inputElement.value;desc = descElement.value;color = newColor;@@ -641,6 +657,9 @@ export const addColOptionOrCell = (protyle: IProtyle, data: IAV, cellElements: HbindSelectEvent(protyle, data, menuElement, cellElements, blockElement);menuElement.querySelector("input").focus();menuElement.querySelector(".b3-menu__items").scrollTop = oldScroll + (menuElement.querySelector(".b3-chips").clientHeight - oldChipsHeight);+ // chips 增减导致菜单高度变化后重新定位(锁底部,顶部自适应,避免底部溢出视口)+ const cellRect = cellElements[cellElements.length - 1].getBoundingClientRect();+ setPosition(menuElement, cellRect.left, cellRect.bottom, cellRect.height, 0, true);}};diff --git a/app/src/util/setPosition.ts b/app/src/util/setPosition.tsindex 10c8f8f2f1..5dc4b0656d 100644--- a/app/src/util/setPosition.ts+++ b/app/src/util/setPosition.ts@@ -20,14 +20,22 @@ export const setPosition = (element: HTMLElement, left: number, top: number, tar}if (sticky) {- // 粘滞定位:同一锚点(top 不变)下,锁定底部边缘- // 菜单内容变化导致高度增减时,底部不动、顶部上下移动(向上撑开/向下收缩),避免位置跳动和底部溢出+ // 粘滞定位:同一锚点(top 不变)下保持稳定+ // - 下方有空间时优先向下展开(用首次锚点 top,底部随高度自然延伸)+ // - 下方放不下时才向上撑开(锁定底部边缘,顶部上移)+ // 由此菜单高度增减时既不跳动也不溢出const lockedBottom = element.dataset.positionBottom;const lockedX = element.dataset.positionX;const sameAnchor = element.dataset.positionTop === String(top);if (sameAnchor && lockedBottom !== undefined) {- const newTop = parseFloat(lockedBottom) - rect.height;- element.style.top = (newTop >= topBarHeight ? newTop : topBarHeight) + "px";+ if (top + rect.height <= window.innerHeight) {+ // 下方放得下:向下展开,回到首次锚点+ element.style.top = top + "px";+ } else {+ // 下方放不下:向上撑开,锁定底部边缘+ const newTop = parseFloat(lockedBottom) - rect.height;+ element.style.top = (newTop >= topBarHeight ? newTop : topBarHeight) + "px";+ }}if (sameAnchor && lockedX !== undefined) {element.style.left = lockedX + "px";