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/16661

Vanessab2e021e09bfa
diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.ts
index 45c24f23bd..76016fce62 100644
--- a/app/src/protyle/util/onGet.ts
+++ b/app/src/protyle/util/onGet.ts
@@ -477,17 +477,19 @@ const focusElementById = (protyle: IProtyle, action: string[], scrollAttr?: IScr
bgFade(focusElement);
}
if (action.includes(Constants.CB_GET_FOCUS) || action.includes(Constants.CB_GET_FOCUSFIRST)) {
- let range: Range;
- if (scrollAttr && scrollAttr.focusId) {
- range = focusByOffset(focusElement, scrollAttr.focusStart, scrollAttr.focusEnd) as Range;
- } else {
- focusBlock(focusElement, undefined, action.includes(Constants.CB_GET_OUTLINE) ? false : true);
- }
- /// #if !MOBILE
- if (!action.includes(Constants.CB_GET_UNUNDO)) {
- pushBack(protyle, range, focusElement);
- }
- /// #endif
+ setTimeout(() => {
+ let range: Range;
+ if (scrollAttr && scrollAttr.focusId) {
+ range = focusByOffset(focusElement, scrollAttr.focusStart, scrollAttr.focusEnd) as Range;
+ } else {
+ focusBlock(focusElement, undefined, action.includes(Constants.CB_GET_OUTLINE) ? false : true);
+ }
+ /// #if !MOBILE
+ if (!action.includes(Constants.CB_GET_UNUNDO)) {
+ pushBack(protyle, range, focusElement);
+ }
+ /// #endif
+ }, focusElement.getAttribute("data-type") === "NodeCodeBlock" ? Constants.TIMEOUT_TRANSITION : 0);
}
const hasScrollTop = scrollAttr && typeof scrollAttr.scrollTop === "number";
if (hasScrollTop) {