Skip to content

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

:bug: 打开定位

Vanessaacfa766027bf
diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.ts
index 2a84761435..d9bb785b2a 100644
--- a/app/src/protyle/util/onGet.ts
+++ b/app/src/protyle/util/onGet.ts
@@ -251,10 +251,7 @@ const setHTML = (options: {
// 使用动态滚动条定位到最后一个块,重启后无法触发滚动事件,需要再次更新 index
protyle.scroll.updateIndex(protyle, options.scrollAttr.startId);
// https://github.com/siyuan-note/siyuan/issues/8224
- const contentRect = protyle.contentElement.getBoundingClientRect();
- if (protyle.wysiwyg.element.clientHeight - parseInt(protyle.wysiwyg.element.style.paddingBottom) < protyle.contentElement.clientHeight &&
- protyle.wysiwyg.element.lastElementChild.getBoundingClientRect().bottom < contentRect.bottom &&
- protyle.wysiwyg.element.firstElementChild.getBoundingClientRect().top > contentRect.top) {
+ if (protyle.contentElement.scrollHeight <= protyle.contentElement.clientHeight) {
showMessage(window.siyuan.languages.scrollGetMore);
}
}
@@ -361,12 +358,8 @@ export const enableProtyle = (protyle: IProtyle) => {
const focusElementById = (protyle: IProtyle, action: string[], scrollAttr?: IScrollAttr) => {
let focusElement: Element;
- let range: Range;
if (scrollAttr && scrollAttr.focusId) {
focusElement = protyle.wysiwyg.element.querySelector(`[data-node-id="${scrollAttr.focusId}"]`)
- if (action.includes(Constants.CB_GET_FOCUS)) {
- range = focusByOffset(focusElement, scrollAttr.focusStart, scrollAttr.focusEnd) as Range;
- }
} else {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${protyle.block.id}"]`)).find((item: HTMLElement) => {
if (!hasClosestByAttribute(item, "data-type", "block-render", true)) {
@@ -386,7 +379,12 @@ const focusElementById = (protyle: IProtyle, action: string[], scrollAttr?: IScr
bgFade(focusElement);
}
if (action.includes(Constants.CB_GET_FOCUS) || action.includes(Constants.CB_GET_FOCUSFIRST)) {
- focusBlock(focusElement);
+ let range: Range;
+ if (scrollAttr && scrollAttr.focusId) {
+ range = focusByOffset(focusElement, scrollAttr.focusStart, scrollAttr.focusEnd) as Range;
+ } else {
+ focusBlock(focusElement);
+ }
/// #if !MOBILE
if (!action.includes(Constants.CB_GET_UNUNDO)) {
pushBack(protyle, range, focusElement);