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 (#17922)

Emptylighte8306fd5d46e
diff --git a/app/src/assets/scss/protyle/_protyle.scss b/app/src/assets/scss/protyle/_protyle.scss
index 092241b70d..cdcee62a83 100644
--- a/app/src/assets/scss/protyle/_protyle.scss
+++ b/app/src/assets/scss/protyle/_protyle.scss
@@ -121,7 +121,7 @@
position: fixed;
z-index: 3;
padding: 1px;
- cursor: copy;
+ cursor: pointer;
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 1c68886d6b..dc099880d9 100644
--- a/app/src/protyle/gutter/index.ts
+++ b/app/src/protyle/gutter/index.ts
@@ -585,21 +585,23 @@ export class Gutter {
plusElement.style.top = `${(plusElement === beforeElement ? rect.top - plusHeight + 2 : rect.bottom - 2)}px`;
};
if (compressed) {
- // 压缩模式:右侧横排显示两个+号,下方插入在前(更靠近块标,更常用),上方插入在后
+ // 压缩模式:右侧竖排显示两个+号,上方插入在上,下方插入在下
// 两个+号紧贴(间距 0),避免鼠标从一个移到另一个时经过缝隙触发 mouseleave 隐藏
// 鼠标越往右移动+号越大
const xRatio = (event.clientX - rect.left) / rect.width;
setPlusSize(beforeElement, xRatio);
setPlusSize(afterElement, xRatio);
const iconRect = buttonElement.querySelector("svg").getBoundingClientRect();
- const top = iconRect.top + iconRect.height / 2 - afterElement.offsetHeight / 2;
+ const centerY = iconRect.top + iconRect.height / 2;
+ const totalHeight = beforeElement.offsetHeight + afterElement.offsetHeight;
+ const startY = centerY - totalHeight / 2;
const startX = rect.right - 2;
+ beforeElement.style.display = "";
+ beforeElement.style.left = `${startX}px`;
+ beforeElement.style.top = `${startY}px`;
afterElement.style.display = "";
afterElement.style.left = `${startX}px`;
- afterElement.style.top = `${top}px`;
- beforeElement.style.display = "";
- beforeElement.style.left = `${startX + afterElement.offsetWidth}px`;
- beforeElement.style.top = `${top}px`;
+ afterElement.style.top = `${startY + beforeElement.offsetHeight}px`;
} else {
// 正常模式下上边缘=上方插入,下边缘=下方插入
const target = event.clientY < rect.top + rect.height / 2 ? beforeElement : afterElement;