Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/8554

Vanessa3f99ff6f4ed8
diff --git a/app/src/assets/scss/protyle/_protyle.scss b/app/src/assets/scss/protyle/_protyle.scss
index 0b28d352df..e4531e4290 100644
--- a/app/src/assets/scss/protyle/_protyle.scss
+++ b/app/src/assets/scss/protyle/_protyle.scss
@@ -214,7 +214,7 @@
flex-shrink: 0;
box-sizing: border-box;
min-height: 42px;
- z-index: 1;
+ z-index: 4; // 需大于 protyle-select
font-size: 14px;
border-radius: var(--b3-border-radius-b) var(--b3-border-radius-b) 0 0;
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts
index 030d59c7e8..49e554eb95 100644
--- a/app/src/protyle/toolbar/index.ts
+++ b/app/src/protyle/toolbar/index.ts
@@ -214,9 +214,14 @@ export class Toolbar {
const rangePosition = getSelectionPosition(nodeElement, range, true);
this.element.classList.remove("fn__none");
this.toolbarHeight = this.element.clientHeight;
+ const protyleRect = protyle.element.getBoundingClientRect();
+ const rangeRects = range.getClientRects();
+ const rangeRect = rangePosition.isBottom ? rangeRects[rangeRects.length - 1] : rangeRects[0];
+ const above = rangeRect.top - this.toolbarHeight - 4;
+ const below = rangeRect.bottom + 4;
const y = rangePosition.isBottom ?
- Math.min(rangePosition.top + 4, protyle.element.getBoundingClientRect().bottom - this.toolbarHeight) :
- Math.max(rangePosition.top - this.toolbarHeight - 4, protyle.element.getBoundingClientRect().top + 30);
+ (below + this.toolbarHeight <= protyleRect.bottom ? below : Math.max(above, protyleRect.top + 30)) :
+ (above >= protyleRect.top + 30 ? above : Math.min(below, protyleRect.bottom - this.toolbarHeight));
this.element.setAttribute("data-inity", y + Constants.ZWSP + protyle.contentElement.scrollTop.toString());
setPosition(this.element, rangePosition.left - this.element.clientWidth / 4, y);
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index 2cb86b81f7..319cd00d9d 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -1995,7 +1995,7 @@ export class WYSIWYG {
ids.push(item.getAttribute("data-node-id"));
});
countBlockWord(ids);
- // 划选后不能存在跨块的 range https://github.com/siyuan-note/siyuan/issues/4473
+ // 修正三击及跨块选区落在块边界时的 range
if (getSelection().rangeCount > 0) {
const range = getSelection().getRangeAt(0);
if (range.toString() === "" ||
@@ -2050,8 +2050,6 @@ export class WYSIWYG {
setFirstNodeRange(getContenteditableElement(endBlockElement), range);
} else if (range.endOffset === 0 && range.endContainer.nodeType === 1 && (range.endContainer as HTMLElement).tagName === "DIV") {
setLastNodeRange(getContenteditableElement(startBlockElement), range, false);
- } else {
- range.collapse(true);
}
}
}