Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Block icons support quickly inserting blocks above or below https://github.com/siyuan-note/siyuan/issues/17900

Danielbaca7e4d4344
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts
index 475141919d..915f11a28e 100644
--- a/app/src/protyle/gutter/index.ts
+++ b/app/src/protyle/gutter/index.ts
@@ -516,7 +516,10 @@ export class Gutter {
});
// 延迟隐藏计时器,鼠标在块标/框线/+号之间移动时提供缓冲,避免中途 mouseleave 误隐藏
let hidePlusTimeout: number;
+ // 当前悬浮的块标 button,供情况A 坐标判断(鼠标在块标内不误触发+号)
+ let activeBlockButton: Element;
const hideInsert = () => {
+ activeBlockButton = undefined;
this.element.querySelectorAll(".protyle-gutters__line, .protyle-gutters__plus").forEach(item => {
(item as HTMLElement).style.display = "none";
});
@@ -551,6 +554,15 @@ export class Gutter {
const hoverEl = lineEl || plusEl;
if (hoverEl) {
window.clearTimeout(hidePlusTimeout);
+ // 鼠标若仍在块标 button 几何范围内,视为块标 hover,不触发+号
+ // 避免框线::before 扩展区侵入块标导致误把点击块标弹菜单变成插入块
+ if (activeBlockButton) {
+ const br = activeBlockButton.getBoundingClientRect();
+ if (event.clientX >= br.left && event.clientX <= br.right &&
+ event.clientY >= br.top && event.clientY <= br.bottom) {
+ return;
+ }
+ }
const isBefore = hoverEl.getAttribute("data-type").includes("Before");
plusBefore.style.display = isBefore ? "" : "none";
plusAfter.style.display = isBefore ? "none" : "";
@@ -573,6 +585,7 @@ export class Gutter {
// 情况B:悬浮有效块标 → 显示框线(贴边),并预设+号位置(隐藏)
plusBefore.dataset.nodeId = id;
plusAfter.dataset.nodeId = id;
+ activeBlockButton = buttonElement;
const rect = buttonElement.getBoundingClientRect();
const compressed = this.element.style.width === "24px";
// 竖排时不显示+号提示(清空 aria-label 避免触发 tooltip),横排时恢复