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

Daniel0d5effa6e641
diff --git a/app/src/assets/scss/protyle/_protyle.scss b/app/src/assets/scss/protyle/_protyle.scss
index 0542187ba0..1f36987b47 100644
--- a/app/src/assets/scss/protyle/_protyle.scss
+++ b/app/src/assets/scss/protyle/_protyle.scss
@@ -97,8 +97,8 @@
position: absolute;
top: 50%;
left: 50%;
- width: 24px;
- height: 24px;
+ width: 20px;
+ height: 20px;
transform: translate(-50%, -50%);
border-radius: var(--b3-border-radius);
z-index: 0;
@@ -109,7 +109,7 @@
&:not(.protyle-gutters__line):not(.protyle-gutters__plus):hover::before {
opacity: 1;
- background-color: var(--b3-theme-background-light);
+ background-color: var(--b3-list-icon-hover);
}
&:active {
@@ -143,12 +143,12 @@
z-index: 3;
padding: 0;
cursor: pointer;
- background-color: var(--b3-theme-background-light);
- // 透明 ::before 扩大可悬浮热区,视觉仍是细线但命中区更大(约 8px)
+ background-color: var(--b3-list-icon-hover);
+ // 透明 ::before 扩大命中区,覆盖框线到+号的间隙,避免鼠标移动中途命中块内容触发重置而闪烁
&::before {
content: '';
position: absolute;
- inset: -4px;
+ inset: -10px;
}
}
@@ -161,6 +161,12 @@
background-color: transparent;
// 从小放大播放动画(不受 display 切换影响,可靠触发)
animation: plusPopIn .28s cubic-bezier(.34, 1.56, .64, 1) both;
+ // 透明 ::before 扩大命中区,避免鼠标在+号边缘抖动脱离导致+号消失
+ &::before {
+ content: '';
+ position: absolute;
+ inset: -6px;
+ }
svg {
color: var(--b3-theme-on-surface-light);
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts
index b324c8eb6f..26c909176f 100644
--- a/app/src/protyle/gutter/index.ts
+++ b/app/src/protyle/gutter/index.ts
@@ -545,7 +545,7 @@ export class Gutter {
if (protyle.disabled || !lineBefore || !lineAfter || !plusBefore || !plusAfter) {
return;
}
- // 情况A:鼠标在框线或+号上 → 显示对应+号(框线所在方向)
+ // 情况A:鼠标在框线或+号上 → 显示对应+号,框线设透明(视觉隐藏但保留命中区,避免 display:none 导致脱离触发重置闪烁)
const lineEl = hasClosestByClassName(event.target, "protyle-gutters__line");
const plusEl = hasClosestByClassName(event.target, "protyle-gutters__plus");
const hoverEl = lineEl || plusEl;
@@ -554,10 +554,9 @@ export class Gutter {
const isBefore = hoverEl.getAttribute("data-type").includes("Before");
plusBefore.style.display = isBefore ? "" : "none";
plusAfter.style.display = isBefore ? "none" : "";
- // 鼠标在+号上时隐藏框线(+号已替代框线视觉);hover 框线时保持框线可见
- const showLine = !plusEl;
- lineBefore.style.display = showLine ? "" : "none";
- lineAfter.style.display = showLine ? "" : "none";
+ // 框线视觉隐藏(opacity:0),但 display 保持以维持命中区
+ lineBefore.style.opacity = "0";
+ lineAfter.style.opacity = "0";
return;
}
const buttonElement = hasClosestByTag(event.target, "BUTTON");
@@ -589,22 +588,24 @@ export class Gutter {
const top = centerY - lineH / 2;
const plusSize = 16;
lineBefore.style.display = "";
+ lineBefore.style.opacity = "1";
lineBefore.style.width = "2px";
lineBefore.style.height = `${lineH}px`;
lineBefore.style.left = `${rect.left}px`;
lineBefore.style.top = `${top}px`;
lineAfter.style.display = "";
+ lineAfter.style.opacity = "1";
lineAfter.style.width = "2px";
lineAfter.style.height = `${lineH}px`;
lineAfter.style.left = `${rect.right - 2}px`;
lineAfter.style.top = `${top}px`;
plusBefore.style.width = `${plusSize}px`;
plusBefore.style.height = `${plusSize}px`;
- plusBefore.style.left = `${rect.left - 9 - plusSize / 2}px`;
+ plusBefore.style.left = `${rect.left - 6 - plusSize / 2}px`;
plusBefore.style.top = `${centerY - plusSize / 2}px`;
plusAfter.style.width = `${plusSize}px`;
plusAfter.style.height = `${plusSize}px`;
- plusAfter.style.left = `${rect.right + 7 - plusSize / 2}px`;
+ plusAfter.style.left = `${rect.right + 4 - plusSize / 2}px`;
plusAfter.style.top = `${centerY - plusSize / 2}px`;
// 竖排时隐藏块标提示,避免其遮挡左侧框线
hideTooltip();
@@ -615,11 +616,13 @@ export class Gutter {
const plusSize = 16;
const plusLeft = rect.left + (rect.width - plusSize) / 2;
lineBefore.style.display = "";
+ lineBefore.style.opacity = "1";
lineBefore.style.width = `${lineW}px`;
lineBefore.style.height = "2px";
lineBefore.style.left = `${left}px`;
lineBefore.style.top = `${rect.top}px`;
lineAfter.style.display = "";
+ lineAfter.style.opacity = "1";
lineAfter.style.width = `${lineW}px`;
lineAfter.style.height = "2px";
lineAfter.style.left = `${left}px`;
@@ -627,11 +630,11 @@ export class Gutter {
plusBefore.style.width = `${plusSize}px`;
plusBefore.style.height = `${plusSize}px`;
plusBefore.style.left = `${plusLeft}px`;
- plusBefore.style.top = `${rect.top - 8 - plusSize / 2 + 1}px`;
+ plusBefore.style.top = `${rect.top - 5 - plusSize / 2 + 1}px`;
plusAfter.style.width = `${plusSize}px`;
plusAfter.style.height = `${plusSize}px`;
plusAfter.style.left = `${plusLeft}px`;
- plusAfter.style.top = `${rect.bottom + 6 - plusSize / 2 + 1}px`;
+ plusAfter.style.top = `${rect.bottom + 3 - plusSize / 2 + 1}px`;
}
window.clearTimeout(hidePlusTimeout);
});