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: Improve block drag tooltip truncation https://github.com/siyuan-note/siyuan/issues/19195
Danielab81a987b291
diff --git a/app/src/protyle/util/dragTip.ts b/app/src/protyle/util/dragTip.tsindex 9a5dc384b3..e41d58bfc7 100644--- a/app/src/protyle/util/dragTip.ts+++ b/app/src/protyle/util/dragTip.ts@@ -49,7 +49,7 @@ const renderDragTip = () => {dragTipState.titleElement.style.cssText = "max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--b3-tooltips-color);";dragTipState.actionElement = document.createElement("div");dragTipState.actionElement.className = "drag-tip__action";- dragTipState.actionElement.style.cssText = "color:var(--b3-tooltips-second-color);font-size:12px;";+ dragTipState.actionElement.style.cssText = "max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--b3-tooltips-second-color);font-size:12px;";dragTipState.element.append(dragTipState.titleElement, dragTipState.actionElement);document.body.append(dragTipState.element);} else {diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.tsindex a5c3af917a..f5e0511fd4 100644--- a/app/src/protyle/util/editorCommonEvent.ts+++ b/app/src/protyle/util/editorCommonEvent.ts@@ -2235,6 +2235,11 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {});let dragCache: { nodeId: string, indent: number, rgb: { r: number, g: number, b: number }, guides: string };let disabledPosition: string;+ const getDragTargetText = (element: HTMLElement) => {+ const text = getContenteditableElement(element)?.textContent?.trim() || "";+ const characters = Array.from(text);+ return characters.length > 20 ? characters.slice(0, 20).join("") + "..." : text;+ };// 列表项目标的插入点与提示处理:设置 class、CSS 变量、showDragTipconst applyLiTarget = (htmlTarget: HTMLElement, event: DragEvent, canDropAsSibling = true): void => {clearBlockDragoverTarget();@@ -2307,7 +2312,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {`rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, 0.6)`);highlightByLevel(editorElement, htmlTarget);// 提示文案:修饰键显示对应操作,无修饰键显示插入位置- const targetText = (getContenteditableElement(htmlTarget)?.textContent?.trim() || "").slice(0, 20);+ const targetText = getDragTargetText(htmlTarget);let action: string;if (event.altKey || (event.shiftKey && protyle.lite)) {// Alt=引用;lite 模式 Shift 也为引用@@ -2879,7 +2884,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {let displayText = cachedTargetText;if (!displayText && targetElement.classList.contains("list")) {const firstLi = targetElement.querySelector(":scope > .li");- displayText = getContenteditableElement(firstLi as HTMLElement)?.textContent?.trim() || "";+ displayText = getDragTargetText(firstLi as HTMLElement);}// 默认移动(无修饰键、非 AV 目标、普通块源、非超级块本身)时,更新下半为带目标名的位置文案if (!event.altKey && !event.shiftKey && !event.ctrlKey && gutterType && !isAvSubType && !isAvTarget && !targetElement.classList.contains("sb")) {@@ -2952,7 +2957,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {targetElement.classList.add(edgeClass);addDragover(targetElement);const sbFirstBlock = targetElement.querySelector("[data-node-id]") as HTMLElement;- const sbText = getContenteditableElement(sbFirstBlock)?.textContent?.trim() || "";+ const sbText = getDragTargetText(sbFirstBlock);if (!event.altKey && !event.shiftKey && !event.ctrlKey && gutterType && !isAvSubType && !isAvTarget && sbText) {const key = isSbLeftEdge? window.siyuan.languages.dragTipMoveTargetFront@@ -3093,13 +3098,13 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {}dragoverElement = targetElement;// 目标变化时更新缓存- cachedTargetText = getContenteditableElement(targetElement as HTMLElement)?.textContent?.trim() || "";+ cachedTargetText = getDragTargetText(targetElement as HTMLElement);cachedIsCol = !!hasClosestByAttribute(targetElement as HTMLElement, "data-sb-layout", "col");highlightColColumn(targetElement as HTMLElement);}// 默认移动(无修饰键、非 AV 目标、普通块源)时,更新下半为带目标名的位置文案if (!event.altKey && !event.shiftKey && !event.ctrlKey && gutterType && !isAvSubType && targetElement && !isAvTarget && point.className) {- const targetText = getContenteditableElement(targetElement as HTMLElement)?.textContent?.trim() || "";+ const targetText = getDragTargetText(targetElement as HTMLElement);const isFront = point.className === "dragover__top" || point.className === "dragover__left";const isBack = point.className === "dragover__bottom" || point.className === "dragover__right";if (targetText && (isFront || isBack)) {