diff --git a/app/src/block/Panel.ts b/app/src/block/Panel.ts index 066084a7f..0bbcbd4ce 100644 --- a/app/src/block/Panel.ts +++ b/app/src/block/Panel.ts @@ -190,7 +190,6 @@ export class BlockPanel { const index = parseInt(editorElement.getAttribute("data-index")); const editor = new Protyle(editorElement, { blockId: this.nodeIds[index], - hasContext: false, defId: this.defIds[index] ||this.defIds[0] || "", action: [Constants.CB_GET_ALL], render: { diff --git a/app/src/editor/index.ts b/app/src/editor/index.ts index 8b7896ea7..2263cfbff 100644 --- a/app/src/editor/index.ts +++ b/app/src/editor/index.ts @@ -14,7 +14,6 @@ export class Editor extends Model { tab: Tab, blockId: string, mode?: TEditorMode, - hasContext?: boolean action?: string[] }) { super({ @@ -30,7 +29,6 @@ export class Editor extends Model { private initProtyle(options: { blockId: string, - hasContext?: boolean action?: string[] mode?: TEditorMode, }) { @@ -38,7 +36,6 @@ export class Editor extends Model { action: options.action, blockId: options.blockId, mode: options.mode, - hasContext: options.hasContext, render: { title: true, background: true, diff --git a/app/src/editor/util.ts b/app/src/editor/util.ts index 0dbf3532d..7764ec1ef 100644 --- a/app/src/editor/util.ts +++ b/app/src/editor/util.ts @@ -32,7 +32,6 @@ export const openFileById = (options: { id: string, position?: string, mode?: TEditorMode, - hasContext?: boolean, action?: string[] keepCursor?: boolean zoomIn?: boolean @@ -50,7 +49,6 @@ export const openFileById = (options: { rootID: data.data.rootID, position: options.position, mode: options.mode, - hasContext: options.hasContext, action: options.action, zoomIn: options.zoomIn, keepCursor: options.keepCursor @@ -200,7 +198,7 @@ const switchEditor = (editor: Editor, options: IOpenFileOptions, allModels: IMod if ((!nodeElement || nodeElement?.clientHeight === 0) && options.id !== options.rootID) { fetchPost("/api/filetree/getDoc", { id: options.id, - mode: options.hasContext ? 3 : 0, + mode: (options.action && !options.action.includes(Constants.CB_GET_ALL)) ? 3 : 0, size: Constants.SIZE_GET, }, getResponse => { onGet(getResponse, editor.editor.protyle, options.action); @@ -274,7 +272,6 @@ const newTab = (options: IOpenFileOptions) => { tab, blockId: options.id, mode: options.mode, - hasContext: options.hasContext, action: options.action, }); } diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts index 1fdf57216..2a00c5999 100644 --- a/app/src/layout/Wnd.ts +++ b/app/src/layout/Wnd.ts @@ -333,7 +333,6 @@ export class Wnd { } else { openFileById({ id: keepCursorId, - hasContext: true, action: [Constants.CB_GET_FOCUS] }); } diff --git a/app/src/layout/dock/Backlinks.ts b/app/src/layout/dock/Backlinks.ts index fe873d221..d7096412b 100644 --- a/app/src/layout/dock/Backlinks.ts +++ b/app/src/layout/dock/Backlinks.ts @@ -137,14 +137,12 @@ export class Backlinks extends Model { click(element: HTMLElement) { openFileById({ id: element.getAttribute("data-node-id"), - hasContext: true, action: [Constants.CB_GET_FOCUS] }); }, ctrlClick(element: HTMLElement) { openFileById({ id: element.getAttribute("data-node-id"), - hasContext: true, keepCursor: true, }); }, @@ -152,7 +150,6 @@ export class Backlinks extends Model { openFileById({ id: element.getAttribute("data-node-id"), position: "right", - hasContext: true, action: [Constants.CB_GET_FOCUS] }); }, @@ -160,7 +157,6 @@ export class Backlinks extends Model { openFileById({ id: element.getAttribute("data-node-id"), position: "bottom", - hasContext: true, action: [Constants.CB_GET_FOCUS] }); } @@ -191,7 +187,6 @@ export class Backlinks extends Model { } else { openFileById({ id: element.getAttribute("data-node-id"), - hasContext: true, action: [Constants.CB_GET_FOCUS] }); } @@ -199,7 +194,6 @@ export class Backlinks extends Model { ctrlClick(element: HTMLElement) { openFileById({ id: element.getAttribute("data-node-id"), - hasContext: true, keepCursor: true, }); }, @@ -207,7 +201,6 @@ export class Backlinks extends Model { openFileById({ id: element.getAttribute("data-node-id"), position: "right", - hasContext: true, action: [Constants.CB_GET_FOCUS] }); }, @@ -215,7 +208,6 @@ export class Backlinks extends Model { openFileById({ id: element.getAttribute("data-node-id"), position: "bottom", - hasContext: true, action: [Constants.CB_GET_FOCUS] }); }, diff --git a/app/src/layout/dock/Bookmark.ts b/app/src/layout/dock/Bookmark.ts index e951c5969..06917c4b6 100644 --- a/app/src/layout/dock/Bookmark.ts +++ b/app/src/layout/dock/Bookmark.ts @@ -80,7 +80,6 @@ export class Bookmark extends Model { fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { openFileById({ id, - hasContext: !foldResponse.data, action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], }); }); @@ -152,7 +151,6 @@ export class Bookmark extends Model { ctrlClick(element: HTMLElement) { openFileById({ id: element.getAttribute("data-node-id"), - hasContext: true, keepCursor: true, }); }, @@ -160,7 +158,6 @@ export class Bookmark extends Model { openFileById({ id: element.getAttribute("data-node-id"), position: "right", - hasContext: true, action: [Constants.CB_GET_FOCUS] }); }, @@ -168,7 +165,6 @@ export class Bookmark extends Model { openFileById({ id: element.getAttribute("data-node-id"), position: "bottom", - hasContext: true, action: [Constants.CB_GET_FOCUS] }); } diff --git a/app/src/layout/dock/Graph.ts b/app/src/layout/dock/Graph.ts index d612227fe..49edc6f7e 100644 --- a/app/src/layout/dock/Graph.ts +++ b/app/src/layout/dock/Graph.ts @@ -598,14 +598,12 @@ export class Graph extends Model { openFileById({ id: node.id, position: "bottom", - hasContext: true, action: [Constants.CB_GET_FOCUS] }); } else if (window.siyuan.altIsPressed) { openFileById({ id: node.id, position: "right", - hasContext: true, action: [Constants.CB_GET_FOCUS] }); } else if (window.siyuan.ctrlIsPressed) { @@ -614,7 +612,7 @@ export class Graph extends Model { nodeIds: [node.id], })); } else { - openFileById({id: node.id, hasContext: true, action: [Constants.CB_GET_FOCUS]}); + openFileById({id: node.id, action: [Constants.CB_GET_FOCUS]}); } }); }, 1000); diff --git a/app/src/layout/dock/Outline.ts b/app/src/layout/dock/Outline.ts index fbdbed8bc..51e793b0a 100644 --- a/app/src/layout/dock/Outline.ts +++ b/app/src/layout/dock/Outline.ts @@ -98,7 +98,6 @@ export class Outline extends Model { fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { openFileById({ id, - hasContext: !foldResponse.data, action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SETID], }); }); diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts index b646cdc29..653f89ca3 100644 --- a/app/src/menus/protyle.ts +++ b/app/src/menus/protyle.ts @@ -89,7 +89,6 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => { fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => { openFileById({ id: refBlockId, - hasContext: !foldResponse.data, action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_HL], keepCursor: true, zoomIn: foldResponse.data @@ -106,7 +105,6 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => { openFileById({ id: refBlockId, position: "right", - hasContext: !foldResponse.data, action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], zoomIn: foldResponse.data }); @@ -122,7 +120,6 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => { openFileById({ id: refBlockId, position: "bottom", - hasContext: !foldResponse.data, action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], zoomIn: foldResponse.data }); @@ -357,14 +354,12 @@ export const zoomOut = (protyle: IProtyle, id: string, focusId?: string, isPushB if (window.siyuan.mobileEditor) { window.localStorage.setItem(Constants.LOCAL_DOCINFO, JSON.stringify({ id, - hasContext: id === protyle.block.rootID, action: id === protyle.block.rootID ? [Constants.CB_GET_HL] : [Constants.CB_GET_ALL] })); window.siyuan.backStack.push({ id: protyle.block.id, scrollTop: protyle.contentElement.scrollTop, callback: id === protyle.block.rootID ? [Constants.CB_GET_HL] : [Constants.CB_GET_ALL], - hasContext: false }); } fetchPost("/api/filetree/getDoc", { diff --git a/app/src/mobile/editor.ts b/app/src/mobile/editor.ts index 5f7b5c4fd..ad7a349eb 100644 --- a/app/src/mobile/editor.ts +++ b/app/src/mobile/editor.ts @@ -12,8 +12,8 @@ import {hasClosestByAttribute} from "../protyle/util/hasClosest"; import {setEditMode} from "../protyle/util/setEditMode"; import {hideElements} from "../protyle/ui/hideElements"; -export const openMobileFileById = (id: string, hasContext?: boolean, action = [Constants.CB_GET_HL], pushStack = true) => { - window.localStorage.setItem(Constants.LOCAL_DOCINFO, JSON.stringify({id, hasContext, action})); +export const openMobileFileById = (id: string, action = [Constants.CB_GET_HL], pushStack = true) => { + window.localStorage.setItem(Constants.LOCAL_DOCINFO, JSON.stringify({id, action})); if (window.siyuan.mobileEditor) { hideElements(["toolbar", "hint", "util"], window.siyuan.mobileEditor.protyle); if (window.siyuan.mobileEditor.protyle.contentElement.classList.contains("fn__none")) { @@ -32,7 +32,7 @@ export const openMobileFileById = (id: string, hasContext?: boolean, action = [C window.siyuan.backStack.push({ id, scrollTop: window.siyuan.mobileEditor.protyle.contentElement.scrollTop, - hasContext + callback: action, }); } focusBlock(blockElement); @@ -53,7 +53,7 @@ export const openMobileFileById = (id: string, hasContext?: boolean, action = [C fetchPost("/api/filetree/getDoc", { id, size: action.includes(Constants.CB_GET_ALL) ? Constants.SIZE_GET_MAX : Constants.SIZE_GET, - mode: hasContext ? 3 : 0, + mode: !action.includes(Constants.CB_GET_ALL) ? 3 : 0, }, getResponse => { onGet(getResponse, window.siyuan.mobileEditor.protyle, action); window.siyuan.mobileEditor.protyle.breadcrumb.render(window.siyuan.mobileEditor.protyle); @@ -63,7 +63,6 @@ export const openMobileFileById = (id: string, hasContext?: boolean, action = [C window.siyuan.mobileEditor = new Protyle(document.getElementById("editor"), { blockId: id, action, - hasContext: hasContext, render: { background: true, gutter: true, @@ -89,8 +88,7 @@ export const openMobileFileById = (id: string, hasContext?: boolean, action = [C window.siyuan.backStack.push({ id, scrollTop: window.siyuan.mobileEditor.protyle.contentElement.scrollTop, - callback: [Constants.CB_GET_HL], - hasContext + callback: action, }); } }); diff --git a/app/src/mobile/index.ts b/app/src/mobile/index.ts index 96a14784d..8b62e4bd4 100644 --- a/app/src/mobile/index.ts +++ b/app/src/mobile/index.ts @@ -83,7 +83,7 @@ window.goBack = () => { } previousBackStack = window.siyuan.backStack.pop(); const item = window.siyuan.backStack[window.siyuan.backStack.length - 1]; - openMobileFileById(item.id, item.hasContext, item.callback, false); + openMobileFileById(item.id, item.callback, false); setTimeout(() => { window.siyuan.mobileEditor.protyle.contentElement.scrollTo({ top: previousBackStack?.scrollTop || 0, diff --git a/app/src/mobile/util/MobileBacklinks.ts b/app/src/mobile/util/MobileBacklinks.ts index bc20f7637..0da41ac31 100644 --- a/app/src/mobile/util/MobileBacklinks.ts +++ b/app/src/mobile/util/MobileBacklinks.ts @@ -46,7 +46,7 @@ export class MobileBacklinks { element: this.element.querySelector(".backlinkList") as HTMLElement, data: null, click(element: HTMLElement) { - openMobileFileById(element.getAttribute("data-node-id"), true, [Constants.CB_GET_FOCUS]); + openMobileFileById(element.getAttribute("data-node-id"), [Constants.CB_GET_FOCUS]); } }); this.mTree = new Tree({ @@ -73,7 +73,7 @@ export class MobileBacklinks { }).element); window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY}); } else { - openMobileFileById(element.getAttribute("data-node-id"), true, [Constants.CB_GET_FOCUS]); + openMobileFileById(element.getAttribute("data-node-id"), [Constants.CB_GET_FOCUS]); } }, blockExtHTML: '' diff --git a/app/src/mobile/util/MobileBookmarks.ts b/app/src/mobile/util/MobileBookmarks.ts index 7d86bc4d4..c557cdb22 100644 --- a/app/src/mobile/util/MobileBookmarks.ts +++ b/app/src/mobile/util/MobileBookmarks.ts @@ -83,7 +83,7 @@ export class MobileBookmarks { }); } } else { - openMobileFileById(id, true, [Constants.CB_GET_FOCUS]); + openMobileFileById(id, [Constants.CB_GET_FOCUS]); } }, blockExtHTML: '', diff --git a/app/src/mobile/util/MobileOutline.ts b/app/src/mobile/util/MobileOutline.ts index 2f96de306..39c4f5d01 100644 --- a/app/src/mobile/util/MobileOutline.ts +++ b/app/src/mobile/util/MobileOutline.ts @@ -28,20 +28,9 @@ export class MobileOutline { data: null, click: (element: HTMLElement) => { const id = element.getAttribute("data-node-id"); - const targetElement = window.siyuan.mobileEditor.protyle.wysiwyg.element.querySelector(`[data-node-id="${id}"]`); - if (targetElement) { - targetElement.scrollIntoView(); - focusBlock(targetElement); - window.siyuan.backStack.push({ - id, - scrollTop: window.siyuan.mobileEditor.protyle.contentElement.scrollTop, - hasContext: true - }); - } else { - fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { - openMobileFileById(id, !foldResponse.data, foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SETID]); - }); - } + fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { + openMobileFileById(id,foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SETID]); + }); } }); this.element.firstElementChild.querySelector('[data-type="collapse"]').addEventListener(getEventName(), () => { diff --git a/app/src/mobile/util/initFramework.ts b/app/src/mobile/util/initFramework.ts index 704f8aac6..9b7e2993d 100644 --- a/app/src/mobile/util/initFramework.ts +++ b/app/src/mobile/util/initFramework.ts @@ -114,11 +114,11 @@ export const initFramework = () => { const localDoc = JSON.parse(window.localStorage.getItem(Constants.LOCAL_DOCINFO) || '{"id": ""}'); fetchPost("/api/block/checkBlockExist", {id: localDoc.id}, existResponse => { if (existResponse.data) { - openMobileFileById(localDoc.id, localDoc.hasContext, localDoc.action); + openMobileFileById(localDoc.id, localDoc.action); } else { fetchPost("/api/block/getRecentUpdatedBlocks", {}, (response) => { if (response.data.length !== 0) { - openMobileFileById(response.data[0].id, true); + openMobileFileById(response.data[0].id); } else { setEmpty(); } diff --git a/app/src/mobile/util/search.ts b/app/src/mobile/util/search.ts index c302202c9..febe4b4d7 100644 --- a/app/src/mobile/util/search.ts +++ b/app/src/mobile/util/search.ts @@ -80,7 +80,7 @@ export const popSearch = (modelElement: HTMLElement, modelMainElement: HTMLEleme preventScroll(window.siyuan.mobileEditor.protyle); } fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { - openMobileFileById(id, !foldResponse.data, foldResponse.data ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL]); + openMobileFileById(id,foldResponse.data ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL]); }); closePanel(); event.preventDefault(); diff --git a/app/src/mobile/util/touch.ts b/app/src/mobile/util/touch.ts index 6c0fcd487..1aa090be2 100644 --- a/app/src/mobile/util/touch.ts +++ b/app/src/mobile/util/touch.ts @@ -29,7 +29,7 @@ export const handleTouchEnd = () => { const item = forwardStack.pop(); item.scrollTop = window.siyuan.mobileEditor.protyle.contentElement.scrollTop; window.siyuan.backStack.push(item); - openMobileFileById(item.id, item.hasContext, item.callback, false); + openMobileFileById(item.id, item.callback, false); setTimeout(() => { window.siyuan.mobileEditor.protyle.contentElement.scrollTo({ top: window.siyuan.backStack[window.siyuan.backStack.length - 2]?.scrollTop || 0, @@ -49,7 +49,7 @@ export const handleTouchEnd = () => { const item = window.siyuan.backStack.pop(); item.scrollTop = window.siyuan.mobileEditor.protyle.contentElement.scrollTop; forwardStack.push(item); - openMobileFileById(item.id, item.hasContext, item.callback, false); + openMobileFileById(item.id, item.callback, false); setTimeout(() => { window.siyuan.mobileEditor.protyle.contentElement.scrollTo({ top: forwardStack[forwardStack.length - 2]?.scrollTop || 0, diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts index 9d069b21f..aa0acb820 100644 --- a/app/src/protyle/hint/index.ts +++ b/app/src/protyle/hint/index.ts @@ -506,11 +506,10 @@ ${unicode2Emoji(emoji.unicode, true)}`; }, () => { insertHTML(genEmptyBlock(false, false, `Untitled`), protyle); /// #if MOBILE - openMobileFileById(newSubDocId, true); + openMobileFileById(newSubDocId); /// #else openFileById({ id: newSubDocId, - hasContext: true, action: [Constants.CB_GET_HL] }); /// #endif diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.ts index 3a3ea4a9e..77a3abf68 100644 --- a/app/src/protyle/index.ts +++ b/app/src/protyle/index.ts @@ -157,7 +157,7 @@ class Protyle { fetchPost("/api/filetree/getDoc", { id: options.blockId, k: options.key || "", - mode: options.hasContext ? 3 : 0, // 0: 仅当前 ID,1:向上 2:向下,3:上下都加载,4:加载最后 + mode: (options.action && !options.action.includes(Constants.CB_GET_ALL)) ? 3 : 0, // 0: 仅当前 ID(默认值),1:向上 2:向下,3:上下都加载,4:加载最后 size: options.action?.includes(Constants.CB_GET_ALL) ? Constants.SIZE_GET_MAX : Constants.SIZE_GET, }, getResponse => { onGet(getResponse, this.protyle, options.action); diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index 5e76dc252..9d514050d 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -1357,13 +1357,12 @@ export class WYSIWYG { fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => { /// #if MOBILE - openMobileFileById(refBlockId, !foldResponse.data, foldResponse.data ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL]); + openMobileFileById(refBlockId, foldResponse.data ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL]); /// #else if (window.siyuan.shiftIsPressed) { openFileById({ id: refBlockId, position: "bottom", - hasContext: !foldResponse.data, action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], zoomIn: foldResponse.data }); @@ -1371,14 +1370,12 @@ export class WYSIWYG { openFileById({ id: refBlockId, position: "right", - hasContext: !foldResponse.data, action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], zoomIn: foldResponse.data }); } else if (window.siyuan.ctrlIsPressed) { openFileById({ id: refBlockId, - hasContext: !foldResponse.data, action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_HL], keepCursor: true, zoomIn: foldResponse.data @@ -1386,7 +1383,6 @@ export class WYSIWYG { } else { openFileById({ id: refBlockId, - hasContext: !foldResponse.data, action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], zoomIn: foldResponse.data }); @@ -1488,13 +1484,12 @@ export class WYSIWYG { if (embedItemElement) { const embedId = embedItemElement.getAttribute("data-id"); /// #if MOBILE - openMobileFileById(embedId, false, [Constants.CB_GET_ALL]); + openMobileFileById(embedId, [Constants.CB_GET_ALL]); /// #else if (window.siyuan.shiftIsPressed) { openFileById({ id: embedId, position: "bottom", - hasContext: false, action: [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL], zoomIn: true }); @@ -1502,14 +1497,12 @@ export class WYSIWYG { openFileById({ id: embedId, position: "right", - hasContext: false, action: [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL], zoomIn: true }); } else if (window.siyuan.ctrlIsPressed) { openFileById({ id: embedId, - hasContext: false, action: [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL], keepCursor: true, zoomIn: true diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index 231a0127a..b1bdd5888 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -1532,7 +1532,6 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { // 打开块引和编辑器中引用、反链、书签中点击事件需保持一致,都加载上下文 openFileById({ id, - hasContext: true, keepCursor: true, }); event.preventDefault(); @@ -1542,7 +1541,6 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { openFileById({ id, position: "right", - hasContext: true, action: [Constants.CB_GET_FOCUS] }); event.preventDefault(); @@ -1552,7 +1550,6 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { openFileById({ id, position: "bottom", - hasContext: true, action: [Constants.CB_GET_FOCUS] }); event.preventDefault(); diff --git a/app/src/search/index.ts b/app/src/search/index.ts index 874c79a71..8f66e9256 100644 --- a/app/src/search/index.ts +++ b/app/src/search/index.ts @@ -116,8 +116,7 @@ export class Search extends Model { fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { openFileById({ id, - hasContext: !foldResponse.data, - action: [Constants.CB_GET_FOCUS], + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], zoomIn: foldResponse.data, position: "right", }); @@ -136,8 +135,7 @@ export class Search extends Model { fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { openFileById({ id, - hasContext: !foldResponse.data, - action: [Constants.CB_GET_FOCUS], + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], zoomIn: foldResponse.data }); }); @@ -198,7 +196,7 @@ export class Search extends Model { } else { this.protyle = new Protyle(this.element.querySelector("#searchPreview") as HTMLElement, { blockId: id, - hasContext: !foldResponse.data, + action: foldResponse.data ? [Constants.CB_GET_HL, Constants.CB_GET_ALL] : [Constants.CB_GET_HL], key: value, render: { gutter: true, diff --git a/app/src/search/spread.ts b/app/src/search/spread.ts index 6a90e91c7..71c5f2a65 100644 --- a/app/src/search/spread.ts +++ b/app/src/search/spread.ts @@ -468,8 +468,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { openFileById({ id, - hasContext: !foldResponse.data, - action: [Constants.CB_GET_FOCUS], + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], zoomIn: foldResponse.data }); dialog.destroy(); @@ -592,8 +591,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { openFileById({ id, - hasContext: !foldResponse.data, - action: [Constants.CB_GET_FOCUS], + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], zoomIn: foldResponse.data, position: "right" }); @@ -616,8 +614,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { openFileById({ id, - hasContext: !foldResponse.data, - action: [Constants.CB_GET_FOCUS], + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], zoomIn: foldResponse.data }); dialog.destroy(); @@ -646,7 +643,7 @@ const getArticle = (options: { if (!protyle) { protyle = new Protyle(options.dialog.element.querySelector("#searchPreview") as HTMLElement, { blockId: options.id, - hasContext: !foldResponse.data, + action: foldResponse.data ? [Constants.CB_GET_HL, Constants.CB_GET_ALL] : [Constants.CB_GET_HL], key: options.k, render: { gutter: true, diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index 196cc8ff2..76249e576 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -48,7 +48,6 @@ interface IPdfAnno { interface IBackStack { id: string, scrollTop?: number, - hasContext?: boolean, callback?: string[], position?: { start: number, end: number } protyle?: IProtyle, @@ -157,7 +156,6 @@ declare interface IOpenFileOptions { position?: string, // file 或者 asset,打开位置 page?: number | string, // asset mode?: TEditorMode // file - hasContext?: boolean // file,是否带上下文 action?: string[] keepCursor?: boolean // file,是否跳转到新 tab 上 zoomIn?: boolean // 是否缩放 diff --git a/app/src/types/protyle.d.ts b/app/src/types/protyle.d.ts index 7803ea06c..52b885ec2 100644 --- a/app/src/types/protyle.d.ts +++ b/app/src/types/protyle.d.ts @@ -345,7 +345,6 @@ interface IOptions { action?: string[], mode?: TEditorMode, blockId: string - hasContext?: boolean key?: string defId?: string render?: { diff --git a/app/src/util/newFile.ts b/app/src/util/newFile.ts index 8330bb59b..1be551c51 100644 --- a/app/src/util/newFile.ts +++ b/app/src/util/newFile.ts @@ -67,7 +67,7 @@ export const newFile = (notebookId?: string, currentPath?: string, open?: boolea }, () => { /// #if !MOBILE if (open) { - openFileById({id, hasContext: true, action: [Constants.CB_GET_HL]}); + openFileById({id, action: [Constants.CB_GET_HL]}); } /// #endif }); diff --git a/app/src/util/onGetConfig.ts b/app/src/util/onGetConfig.ts index 00f9db53a..f05e962cc 100644 --- a/app/src/util/onGetConfig.ts +++ b/app/src/util/onGetConfig.ts @@ -342,7 +342,6 @@ const initWindow = () => { } openFileById({ id: url.substr(16, 22), - hasContext: true, action: [Constants.CB_GET_FOCUS], zoomIn: getSearch("focus", url) === "1" });