diff --git a/app/src/constants.ts b/app/src/constants.ts index bf17913f3..7794fed20 100644 --- a/app/src/constants.ts +++ b/app/src/constants.ts @@ -35,7 +35,6 @@ export abstract class Constants { // size public static readonly SIZE_TOOLBAR_HEIGHT: number = 42; - public static readonly SIZE_GET = 36; public static readonly SIZE_GET_MAX = 102400; public static readonly SIZE_UNDO = 64; public static readonly SIZE_TITLE = 512; diff --git a/app/src/editor/util.ts b/app/src/editor/util.ts index f3b86ec89..278560984 100644 --- a/app/src/editor/util.ts +++ b/app/src/editor/util.ts @@ -218,7 +218,7 @@ const switchEditor = (editor: Editor, options: IOpenFileOptions, allModels: IMod fetchPost("/api/filetree/getDoc", { id: options.id, mode: (options.action && options.action.includes(Constants.CB_GET_CONTEXT)) ? 3 : 0, - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, editor.editor.protyle, options.action); // 大纲点击折叠标题下的内容时,需更新反链面板 diff --git a/app/src/layout/dock/Outline.ts b/app/src/layout/dock/Outline.ts index 421c9e6b6..41297d05d 100644 --- a/app/src/layout/dock/Outline.ts +++ b/app/src/layout/dock/Outline.ts @@ -142,7 +142,7 @@ export class Outline extends Model { fetchPost("/api/filetree/getDoc", { id: item.editor.protyle.block.rootID, mode: 0, - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, item.editor.protyle, [Constants.CB_GET_FOCUS]); }); diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts index 2ed8216d6..d726e9a64 100644 --- a/app/src/menus/protyle.ts +++ b/app/src/menus/protyle.ts @@ -451,7 +451,7 @@ export const zoomOut = (protyle: IProtyle, id: string, focusId?: string, isPushB } fetchPost("/api/filetree/getDoc", { id, - size: id === protyle.block.rootID ? Constants.SIZE_GET : Constants.SIZE_GET_MAX, + size: id === protyle.block.rootID ? window.siyuan.config.editor.dynamicLoadBlocks : Constants.SIZE_GET_MAX, }, getResponse => { if (isPushBack) { onGet(getResponse, protyle, id === protyle.block.rootID ? [Constants.CB_GET_FOCUS, Constants.CB_GET_HTML] : [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS, Constants.CB_GET_HTML]); @@ -468,7 +468,7 @@ export const zoomOut = (protyle: IProtyle, id: string, focusId?: string, isPushB fetchPost("/api/filetree/getDoc", { id: focusId, mode: 3, - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getFocusResponse => { onGet(getFocusResponse, protyle, isPushBack ? [Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS, Constants.CB_GET_UNUNDO]); }); diff --git a/app/src/mobile/editor.ts b/app/src/mobile/editor.ts index ef6807104..11c9d8580 100644 --- a/app/src/mobile/editor.ts +++ b/app/src/mobile/editor.ts @@ -47,7 +47,7 @@ export const openMobileFileById = (id: string, action = [Constants.CB_GET_HL]) = addLoading(window.siyuan.mobileEditor.protyle); fetchPost("/api/filetree/getDoc", { id, - size: action.includes(Constants.CB_GET_ALL) ? Constants.SIZE_GET_MAX : Constants.SIZE_GET, + size: action.includes(Constants.CB_GET_ALL) ? Constants.SIZE_GET_MAX : window.siyuan.config.editor.dynamicLoadBlocks, mode: action.includes(Constants.CB_GET_CONTEXT) ? 3 : 0, }, getResponse => { onGet(getResponse, window.siyuan.mobileEditor.protyle, action); diff --git a/app/src/mobile/util/MobileBacklinks.ts b/app/src/mobile/util/MobileBacklinks.ts index e8fcc490c..8ee8a11f4 100644 --- a/app/src/mobile/util/MobileBacklinks.ts +++ b/app/src/mobile/util/MobileBacklinks.ts @@ -144,7 +144,7 @@ export class MobileBacklinks { if (response.data.refRootID === window.siyuan.mobileEditor.protyle.block.rootID) { fetchPost("/api/filetree/getDoc", { id: window.siyuan.mobileEditor.protyle.block.id, - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, window.siyuan.mobileEditor.protyle); }); diff --git a/app/src/protyle/breadcrumb/action.ts b/app/src/protyle/breadcrumb/action.ts index b3660c26b..38306a26d 100644 --- a/app/src/protyle/breadcrumb/action.ts +++ b/app/src/protyle/breadcrumb/action.ts @@ -21,7 +21,7 @@ export const netImg2LocalAssets = (protyle: IProtyle) => { fetchPost("/api/filetree/getDoc", { id: protyle.block.id, mode: 0, - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, protyle, [Constants.CB_GET_FOCUS], saveScroll(protyle, true)); }); @@ -31,7 +31,7 @@ export const netImg2LocalAssets = (protyle: IProtyle) => { fetchPost("/api/filetree/getDoc", { id: item.editor.protyle.block.rootID, mode: 0, - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, item.editor.protyle, [Constants.CB_GET_FOCUS], saveScroll(protyle, true)); }); diff --git a/app/src/protyle/breadcrumb/index.ts b/app/src/protyle/breadcrumb/index.ts index 76d808ae8..0c46cfd5c 100644 --- a/app/src/protyle/breadcrumb/index.ts +++ b/app/src/protyle/breadcrumb/index.ts @@ -69,7 +69,7 @@ export class Breadcrumb { fetchPost("/api/filetree/getDoc", { id: protyle.options.blockId, mode: 0, - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, protyle); }); @@ -78,7 +78,7 @@ export class Breadcrumb { fetchPost("/api/filetree/getDoc", { id: protyle.options.blockId, mode: 3, - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, protyle, [Constants.CB_GET_HL]); }); @@ -231,7 +231,7 @@ export class Breadcrumb { fetchPost("/api/filetree/getDoc", { id: protyle.block.id, mode: 0, - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, protyle, [Constants.CB_GET_FOCUS], saveScroll(protyle, true)); }); @@ -241,7 +241,7 @@ export class Breadcrumb { fetchPost("/api/filetree/getDoc", { id: item.editor.protyle.block.rootID, mode: 0, - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, item.editor.protyle, [Constants.CB_GET_FOCUS], saveScroll(protyle, true)); }); @@ -270,7 +270,7 @@ export class Breadcrumb { fetchPost("/api/filetree/getDoc", { id: protyle.block.showAll ? protyle.block.id : protyle.block.rootID, mode: 0, - size: protyle.block.showAll ? Constants.SIZE_GET_MAX : Constants.SIZE_GET, + size: protyle.block.showAll ? Constants.SIZE_GET_MAX : window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, protyle, protyle.block.showAll ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS], saveScroll(protyle, true), true); }); @@ -296,7 +296,7 @@ export class Breadcrumb { protyle.scroll.lastScrollTop = 0; fetchPost("/api/filetree/getDoc", { id: protyle.block.rootID, - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, protyle); window.siyuan.menus.menu.remove(); diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.ts index 3e5639399..87c4d7252 100644 --- a/app/src/protyle/index.ts +++ b/app/src/protyle/index.ts @@ -99,7 +99,7 @@ export class Protyle { if (this.protyle.block.showAll && data.cmd === "heading2doc" && !this.protyle.options.backlinkData) { fetchPost("/api/filetree/getDoc", { id: this.protyle.block.rootID, - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, this.protyle); }); @@ -167,7 +167,7 @@ export class Protyle { id: options.blockId, k: options.key || "", mode: (mergedOptions.action && mergedOptions.action.includes(Constants.CB_GET_CONTEXT)) ? 3 : 0, // 0: 仅当前 ID(默认值),1:向上 2:向下,3:上下都加载,4:加载最后 - size: mergedOptions.action?.includes(Constants.CB_GET_ALL) ? Constants.SIZE_GET_MAX : Constants.SIZE_GET, + size: mergedOptions.action?.includes(Constants.CB_GET_ALL) ? Constants.SIZE_GET_MAX : window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, this.protyle, mergedOptions.action, options.scrollAttr); if (this.protyle.model) { diff --git a/app/src/protyle/scroll/event.ts b/app/src/protyle/scroll/event.ts index 782306833..10ae75e00 100644 --- a/app/src/protyle/scroll/event.ts +++ b/app/src/protyle/scroll/event.ts @@ -82,7 +82,7 @@ export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => { id: protyle.wysiwyg.element.firstElementChild.getAttribute("data-node-id"), mode: 1, k: protyle.options.key || "", - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { protyle.contentElement.style.overflow = ""; protyle.contentElement.style.width = ""; @@ -97,7 +97,7 @@ export const scrollEvent = (protyle: IProtyle, element: HTMLElement) => { id: protyle.wysiwyg.element.lastElementChild.getAttribute("data-node-id"), mode: 2, k: protyle.options.key || "", - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, protyle, [Constants.CB_GET_APPEND, Constants.CB_GET_UNCHANGEID]); }); diff --git a/app/src/protyle/scroll/index.ts b/app/src/protyle/scroll/index.ts index 7a0bbf1cd..3c3539091 100644 --- a/app/src/protyle/scroll/index.ts +++ b/app/src/protyle/scroll/index.ts @@ -45,7 +45,7 @@ export class Scroll { index: parseInt(this.inputElement.value), id: protyle.block.parentID, mode: 0, - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, protyle, [Constants.CB_GET_FOCUSFIRST, Constants.CB_GET_UNCHANGEID]); }); @@ -59,7 +59,7 @@ export class Scroll { if (protyle.block.showAll) { this.element.classList.add("fn__none"); } else { - if (protyle.block.childBlockCount > Constants.SIZE_GET) { + if (protyle.block.childBlockCount > window.siyuan.config.editor.dynamicLoadBlocks) { this.element.classList.remove("fn__none"); } else { this.element.classList.add("fn__none"); diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts index 148c1f245..3e812aa5e 100644 --- a/app/src/protyle/util/editorCommonEvent.ts +++ b/app/src/protyle/util/editorCommonEvent.ts @@ -655,7 +655,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { }); fetchPost("/api/filetree/getDoc", { id: protyle.block.id, - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, protyle); /// #if !MOBILE diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.ts index 2c6dcddd4..8317407a0 100644 --- a/app/src/protyle/util/onGet.ts +++ b/app/src/protyle/util/onGet.ts @@ -272,7 +272,7 @@ const setHTML = (options: { id: protyle.wysiwyg.element.lastElementChild.getAttribute("data-node-id"), mode: 2, k: protyle.options.key || "", - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, protyle, [Constants.CB_GET_APPEND, Constants.CB_GET_UNCHANGEID]); }); diff --git a/app/src/protyle/util/reload.ts b/app/src/protyle/util/reload.ts index ee548aaba..75481051e 100644 --- a/app/src/protyle/util/reload.ts +++ b/app/src/protyle/util/reload.ts @@ -28,7 +28,7 @@ export const reloadProtyle = (protyle: IProtyle) => { fetchPost("/api/filetree/getDoc", { id: protyle.block.showAll ? protyle.block.id : protyle.block.rootID, mode: 0, - size: protyle.block.showAll ? Constants.SIZE_GET_MAX : Constants.SIZE_GET, + size: protyle.block.showAll ? Constants.SIZE_GET_MAX : window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, protyle, protyle.block.showAll ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_FOCUS], saveScroll(protyle, true), true); }); diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index 8a92bd76e..3e711043d 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -1212,7 +1212,7 @@ export class WYSIWYG { id: protyle.wysiwyg.element.firstElementChild.getAttribute("data-node-id"), mode: 1, k: protyle.options.key || "", - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { preventGetTopHTML = false; onGet(getResponse, protyle, [Constants.CB_GET_BEFORE, Constants.CB_GET_UNCHANGEID]); diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index 238212e98..7348a9570 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -462,7 +462,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { fetchPost("/api/filetree/getDoc", { id: protyle.block.rootID, mode: 0, - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, protyle, [Constants.CB_GET_FOCUS]); }); @@ -478,7 +478,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { fetchPost("/api/filetree/getDoc", { id: protyle.block.rootID, mode: 4, - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, protyle, [Constants.CB_GET_FOCUS]); }); diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts index 0b87788c6..2dcf4a218 100644 --- a/app/src/protyle/wysiwyg/transaction.ts +++ b/app/src/protyle/wysiwyg/transaction.ts @@ -108,7 +108,7 @@ const promiseTransaction = () => { id: protyle.wysiwyg.element.lastElementChild.getAttribute("data-node-id"), mode: 2, k: protyle.options.key || "", - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, protyle, [Constants.CB_GET_APPEND, Constants.CB_GET_UNCHANGEID]); }); diff --git a/app/src/search/index.ts b/app/src/search/index.ts index b81680d82..b6c1ece23 100644 --- a/app/src/search/index.ts +++ b/app/src/search/index.ts @@ -187,7 +187,7 @@ export class Search extends Model { id, k: value, mode: foldResponse.data ? 0 : 3, - size: foldResponse.data ? Constants.SIZE_GET_MAX : Constants.SIZE_GET, + size: foldResponse.data ? Constants.SIZE_GET_MAX : window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, this.protyle.protyle, foldResponse.data ? [Constants.CB_GET_ALL, Constants.CB_GET_HTML] : [Constants.CB_GET_HL, Constants.CB_GET_HTML]); const matchElement = this.protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${id}"] span[data-type="search-mark"]`); diff --git a/app/src/search/spread.ts b/app/src/search/spread.ts index 5c1dcf86e..3c0a4ebf0 100644 --- a/app/src/search/spread.ts +++ b/app/src/search/spread.ts @@ -668,7 +668,7 @@ const getArticle = (options: { id: options.id, k: options.k, mode: foldResponse.data ? 0 : 3, - size: foldResponse.data ? Constants.SIZE_GET_MAX : Constants.SIZE_GET, + size: foldResponse.data ? Constants.SIZE_GET_MAX : window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, protyle.protyle, foldResponse.data ? [Constants.CB_GET_ALL, Constants.CB_GET_HTML] : [Constants.CB_GET_HL, Constants.CB_GET_HTML]); const matchElement = protyle.protyle.wysiwyg.element.querySelector(`div[data-node-id="${options.id}"] span[data-type="search-mark"]`); diff --git a/app/src/util/backForward.ts b/app/src/util/backForward.ts index b931d8c1f..6b882dfc6 100644 --- a/app/src/util/backForward.ts +++ b/app/src/util/backForward.ts @@ -133,7 +133,7 @@ const focusStack = async (stack: IBackStack) => { fetchPost("/api/filetree/getDoc", { id: stack.id, mode: stack.isZoom ? 0 : 3, - size: stack.isZoom ? Constants.SIZE_GET_MAX : Constants.SIZE_GET, + size: stack.isZoom ? Constants.SIZE_GET_MAX : window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, stack.protyle, [Constants.CB_GET_HTML]); Array.from(stack.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${stack.id}"]`)).find(item => { @@ -162,7 +162,7 @@ const focusStack = async (stack: IBackStack) => { fetchPost("/api/filetree/getDoc", { id: stack.id, // 忘记为什么要用 rootChildID 了,但用了会产生 https://github.com/siyuan-note/siyuan/issues/6004 问题 mode: stack.isZoom ? 0 : 3, - size: stack.isZoom ? Constants.SIZE_GET_MAX : Constants.SIZE_GET, + size: stack.isZoom ? Constants.SIZE_GET_MAX : window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, stack.protyle, stack.isZoom ? [Constants.CB_GET_HTML, Constants.CB_GET_ALL] : [Constants.CB_GET_HTML]); Array.from(stack.protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${stack.id}"]`)).find(item => { diff --git a/app/src/util/globalShortcut.ts b/app/src/util/globalShortcut.ts index ebb457814..be9b27079 100644 --- a/app/src/util/globalShortcut.ts +++ b/app/src/util/globalShortcut.ts @@ -816,7 +816,7 @@ const editKeydown = (event: KeyboardEvent) => { protyle.scroll.lastScrollTop = 0; fetchPost("/api/filetree/getDoc", { id: protyle.block.parentID, - size: Constants.SIZE_GET, + size: window.siyuan.config.editor.dynamicLoadBlocks, }, getResponse => { onGet(getResponse, protyle); });