From 65821e57de0df30f3d78b75e7dc631adb052b040 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sun, 7 Aug 2022 09:26:08 +0800 Subject: [PATCH] :recycle: context --- app/src/constants.ts | 1 + app/src/editor/util.ts | 2 +- app/src/layout/Wnd.ts | 2 +- app/src/layout/dock/Backlinks.ts | 14 ++++++++------ app/src/layout/dock/Bookmark.ts | 7 ++++--- app/src/layout/dock/Graph.ts | 6 +++--- app/src/layout/dock/Outline.ts | 2 +- app/src/menus/protyle.ts | 8 ++++---- app/src/mobile/editor.ts | 2 +- app/src/mobile/util/MobileBacklinks.ts | 4 ++-- app/src/mobile/util/MobileBookmarks.ts | 2 +- app/src/mobile/util/MobileOutline.ts | 2 +- app/src/mobile/util/initFramework.ts | 2 +- app/src/mobile/util/search.ts | 2 +- app/src/protyle/hint/index.ts | 4 ++-- app/src/protyle/index.ts | 2 +- app/src/protyle/wysiwyg/index.ts | 10 +++++----- app/src/protyle/wysiwyg/keydown.ts | 5 +++-- app/src/search/index.ts | 6 +++--- app/src/search/spread.ts | 8 ++++---- app/src/util/newFile.ts | 2 +- app/src/util/onGetConfig.ts | 2 +- 22 files changed, 50 insertions(+), 45 deletions(-) diff --git a/app/src/constants.ts b/app/src/constants.ts index f8f41d194..76d1848ec 100644 --- a/app/src/constants.ts +++ b/app/src/constants.ts @@ -51,6 +51,7 @@ export abstract class Constants { public static readonly CB_GET_ALL = "cb-get-all"; // 获取所有块 public static readonly CB_GET_UNUNDO = "cb-get-unundo"; // 不需要记录历史 public static readonly CB_GET_SCROLL = "cb-get-scroll"; // 滚动到指定位置 + public static readonly CB_GET_CONTEXT = "cb-get-context"; // 包含上下文 // localstorage public static readonly LOCAL_SEARCHEDATA = "local-searchedata"; diff --git a/app/src/editor/util.ts b/app/src/editor/util.ts index 7764ec1ef..04de8055c 100644 --- a/app/src/editor/util.ts +++ b/app/src/editor/util.ts @@ -198,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.action && !options.action.includes(Constants.CB_GET_ALL)) ? 3 : 0, + mode: (options.action && options.action.includes(Constants.CB_GET_CONTEXT)) ? 3 : 0, size: Constants.SIZE_GET, }, getResponse => { onGet(getResponse, editor.editor.protyle, options.action); diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts index 6ba753ea2..eeb763261 100644 --- a/app/src/layout/Wnd.ts +++ b/app/src/layout/Wnd.ts @@ -334,7 +334,7 @@ export class Wnd { } else { openFileById({ id: keepCursorId, - action: [Constants.CB_GET_FOCUS] + action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT] }); } currentTab.headElement.removeAttribute("keep-cursor"); diff --git a/app/src/layout/dock/Backlinks.ts b/app/src/layout/dock/Backlinks.ts index d7096412b..65fc6da68 100644 --- a/app/src/layout/dock/Backlinks.ts +++ b/app/src/layout/dock/Backlinks.ts @@ -137,27 +137,28 @@ export class Backlinks extends Model { click(element: HTMLElement) { openFileById({ id: element.getAttribute("data-node-id"), - action: [Constants.CB_GET_FOCUS] + action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT] }); }, ctrlClick(element: HTMLElement) { openFileById({ id: element.getAttribute("data-node-id"), keepCursor: true, + action: [Constants.CB_GET_CONTEXT] }); }, altClick(element: HTMLElement) { openFileById({ id: element.getAttribute("data-node-id"), position: "right", - action: [Constants.CB_GET_FOCUS] + action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT] }); }, shiftClick(element: HTMLElement) { openFileById({ id: element.getAttribute("data-node-id"), position: "bottom", - action: [Constants.CB_GET_FOCUS] + action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT] }); } }); @@ -187,7 +188,7 @@ export class Backlinks extends Model { } else { openFileById({ id: element.getAttribute("data-node-id"), - action: [Constants.CB_GET_FOCUS] + action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT] }); } }, @@ -195,20 +196,21 @@ export class Backlinks extends Model { openFileById({ id: element.getAttribute("data-node-id"), keepCursor: true, + action: [Constants.CB_GET_CONTEXT] }); }, altClick(element: HTMLElement) { openFileById({ id: element.getAttribute("data-node-id"), position: "right", - action: [Constants.CB_GET_FOCUS] + action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT] }); }, shiftClick(element: HTMLElement) { openFileById({ id: element.getAttribute("data-node-id"), position: "bottom", - action: [Constants.CB_GET_FOCUS] + action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT] }); }, blockExtHTML: `` diff --git a/app/src/layout/dock/Bookmark.ts b/app/src/layout/dock/Bookmark.ts index 06917c4b6..59b6fa3b5 100644 --- a/app/src/layout/dock/Bookmark.ts +++ b/app/src/layout/dock/Bookmark.ts @@ -80,7 +80,7 @@ export class Bookmark extends Model { fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { openFileById({ id, - action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT], }); }); }, @@ -152,20 +152,21 @@ export class Bookmark extends Model { openFileById({ id: element.getAttribute("data-node-id"), keepCursor: true, + action: [Constants.CB_GET_CONTEXT] }); }, altClick(element: HTMLElement) { openFileById({ id: element.getAttribute("data-node-id"), position: "right", - action: [Constants.CB_GET_FOCUS] + action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT] }); }, shiftClick(element: HTMLElement) { openFileById({ id: element.getAttribute("data-node-id"), position: "bottom", - action: [Constants.CB_GET_FOCUS] + action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT] }); } }); diff --git a/app/src/layout/dock/Graph.ts b/app/src/layout/dock/Graph.ts index 49edc6f7e..e60e7895e 100644 --- a/app/src/layout/dock/Graph.ts +++ b/app/src/layout/dock/Graph.ts @@ -598,13 +598,13 @@ export class Graph extends Model { openFileById({ id: node.id, position: "bottom", - action: [Constants.CB_GET_FOCUS] + action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT] }); } else if (window.siyuan.altIsPressed) { openFileById({ id: node.id, position: "right", - action: [Constants.CB_GET_FOCUS] + action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT] }); } else if (window.siyuan.ctrlIsPressed) { window.siyuan.blockPanels.push(new BlockPanel({ @@ -612,7 +612,7 @@ export class Graph extends Model { nodeIds: [node.id], })); } else { - openFileById({id: node.id, action: [Constants.CB_GET_FOCUS]}); + openFileById({id: node.id, action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]}); } }); }, 1000); diff --git a/app/src/layout/dock/Outline.ts b/app/src/layout/dock/Outline.ts index 5a2ddcd9d..1b25fc570 100644 --- a/app/src/layout/dock/Outline.ts +++ b/app/src/layout/dock/Outline.ts @@ -96,7 +96,7 @@ export class Outline extends Model { fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { openFileById({ id, - action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SETID], + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SETID, Constants.CB_GET_CONTEXT], }); }); } diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts index 1d9e61d94..fa45821e3 100644 --- a/app/src/menus/protyle.ts +++ b/app/src/menus/protyle.ts @@ -89,7 +89,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => { fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => { openFileById({ id: refBlockId, - action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_HL], + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT], keepCursor: true, zoomIn: foldResponse.data }); @@ -105,7 +105,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => { openFileById({ id: refBlockId, position: "right", - action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT], zoomIn: foldResponse.data }); }); @@ -120,7 +120,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => { openFileById({ id: refBlockId, position: "bottom", - action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT], zoomIn: foldResponse.data }); }); @@ -354,7 +354,7 @@ export const zoomOut = (protyle: IProtyle, id: string, focusId?: string, isPushB if (window.siyuan.mobileEditor) { window.localStorage.setItem(Constants.LOCAL_DOCINFO, JSON.stringify({ id, - action: id === protyle.block.rootID ? [Constants.CB_GET_HL] : [Constants.CB_GET_ALL] + action: id === protyle.block.rootID ? [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT] : [Constants.CB_GET_ALL] })); window.siyuan.backStack.push({ id: protyle.block.id, diff --git a/app/src/mobile/editor.ts b/app/src/mobile/editor.ts index ad7a349eb..78a54f141 100644 --- a/app/src/mobile/editor.ts +++ b/app/src/mobile/editor.ts @@ -53,7 +53,7 @@ export const openMobileFileById = (id: string, action = [Constants.CB_GET_HL], p fetchPost("/api/filetree/getDoc", { id, size: action.includes(Constants.CB_GET_ALL) ? Constants.SIZE_GET_MAX : Constants.SIZE_GET, - mode: !action.includes(Constants.CB_GET_ALL) ? 3 : 0, + mode: action.includes(Constants.CB_GET_CONTEXT) ? 3 : 0, }, getResponse => { onGet(getResponse, window.siyuan.mobileEditor.protyle, action); window.siyuan.mobileEditor.protyle.breadcrumb.render(window.siyuan.mobileEditor.protyle); diff --git a/app/src/mobile/util/MobileBacklinks.ts b/app/src/mobile/util/MobileBacklinks.ts index 0da41ac31..e8fcc490c 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"), [Constants.CB_GET_FOCUS]); + openMobileFileById(element.getAttribute("data-node-id"), [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]); } }); 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"), [Constants.CB_GET_FOCUS]); + openMobileFileById(element.getAttribute("data-node-id"), [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]); } }, blockExtHTML: '' diff --git a/app/src/mobile/util/MobileBookmarks.ts b/app/src/mobile/util/MobileBookmarks.ts index c557cdb22..c4ff716be 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, [Constants.CB_GET_FOCUS]); + openMobileFileById(id, [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]); } }, blockExtHTML: '', diff --git a/app/src/mobile/util/MobileOutline.ts b/app/src/mobile/util/MobileOutline.ts index 39c4f5d01..0a1b7c346 100644 --- a/app/src/mobile/util/MobileOutline.ts +++ b/app/src/mobile/util/MobileOutline.ts @@ -29,7 +29,7 @@ export class MobileOutline { click: (element: HTMLElement) => { const id = element.getAttribute("data-node-id"); 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]); + openMobileFileById(id, foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_SETID, Constants.CB_GET_CONTEXT]); }); } }); diff --git a/app/src/mobile/util/initFramework.ts b/app/src/mobile/util/initFramework.ts index 9b7e2993d..bef39f888 100644 --- a/app/src/mobile/util/initFramework.ts +++ b/app/src/mobile/util/initFramework.ts @@ -118,7 +118,7 @@ export const initFramework = () => { } else { fetchPost("/api/block/getRecentUpdatedBlocks", {}, (response) => { if (response.data.length !== 0) { - openMobileFileById(response.data[0].id); + openMobileFileById(response.data[0].id, [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT]); } else { setEmpty(); } diff --git a/app/src/mobile/util/search.ts b/app/src/mobile/util/search.ts index febe4b4d7..d0bb5266b 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 ? [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, Constants.CB_GET_CONTEXT]); }); closePanel(); event.preventDefault(); diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts index aa0acb820..1fed739bf 100644 --- a/app/src/protyle/hint/index.ts +++ b/app/src/protyle/hint/index.ts @@ -506,11 +506,11 @@ ${unicode2Emoji(emoji.unicode, true)}`; }, () => { insertHTML(genEmptyBlock(false, false, `Untitled`), protyle); /// #if MOBILE - openMobileFileById(newSubDocId); + openMobileFileById(newSubDocId, [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT]); /// #else openFileById({ id: newSubDocId, - action: [Constants.CB_GET_HL] + action: [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT] }); /// #endif }); diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.ts index 77a3abf68..a4a73ba8f 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.action && !options.action.includes(Constants.CB_GET_ALL)) ? 3 : 0, // 0: 仅当前 ID(默认值),1:向上 2:向下,3:上下都加载,4:加载最后 + mode: (options.action && options.action.includes(Constants.CB_GET_CONTEXT)) ? 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 9cf2f5d9b..d5a460f75 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -1357,33 +1357,33 @@ export class WYSIWYG { fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => { /// #if MOBILE - openMobileFileById(refBlockId, 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, Constants.CB_GET_CONTEXT]); /// #else if (window.siyuan.shiftIsPressed) { openFileById({ id: refBlockId, position: "bottom", - action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT], zoomIn: foldResponse.data }); } else if (window.siyuan.altIsPressed) { openFileById({ id: refBlockId, position: "right", - action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT], zoomIn: foldResponse.data }); } else if (window.siyuan.ctrlIsPressed) { openFileById({ id: refBlockId, - action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_HL], + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT], keepCursor: true, zoomIn: foldResponse.data }); } else { openFileById({ id: refBlockId, - action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT], zoomIn: foldResponse.data }); } diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index b1bdd5888..130433225 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -1533,6 +1533,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { openFileById({ id, keepCursor: true, + action: [Constants.CB_GET_CONTEXT] }); event.preventDefault(); event.stopPropagation(); @@ -1541,7 +1542,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { openFileById({ id, position: "right", - action: [Constants.CB_GET_FOCUS] + action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT] }); event.preventDefault(); event.stopPropagation(); @@ -1550,7 +1551,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { openFileById({ id, position: "bottom", - action: [Constants.CB_GET_FOCUS] + action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT] }); event.preventDefault(); event.stopPropagation(); diff --git a/app/src/search/index.ts b/app/src/search/index.ts index 8f66e9256..45e6e7a03 100644 --- a/app/src/search/index.ts +++ b/app/src/search/index.ts @@ -116,7 +116,7 @@ export class Search extends Model { fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { openFileById({ id, - action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT], zoomIn: foldResponse.data, position: "right", }); @@ -135,7 +135,7 @@ export class Search extends Model { fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { openFileById({ id, - action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT], zoomIn: foldResponse.data }); }); @@ -196,7 +196,7 @@ export class Search extends Model { } else { this.protyle = new Protyle(this.element.querySelector("#searchPreview") as HTMLElement, { blockId: id, - action: foldResponse.data ? [Constants.CB_GET_HL, Constants.CB_GET_ALL] : [Constants.CB_GET_HL], + action: foldResponse.data ? [Constants.CB_GET_HL, Constants.CB_GET_ALL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT], key: value, render: { gutter: true, diff --git a/app/src/search/spread.ts b/app/src/search/spread.ts index 71c5f2a65..eea504828 100644 --- a/app/src/search/spread.ts +++ b/app/src/search/spread.ts @@ -468,7 +468,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { openFileById({ id, - action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT], zoomIn: foldResponse.data }); dialog.destroy(); @@ -591,7 +591,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { openFileById({ id, - action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT], zoomIn: foldResponse.data, position: "right" }); @@ -614,7 +614,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { openFileById({ id, - action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS], + action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT], zoomIn: foldResponse.data }); dialog.destroy(); @@ -643,7 +643,7 @@ const getArticle = (options: { if (!protyle) { protyle = new Protyle(options.dialog.element.querySelector("#searchPreview") as HTMLElement, { blockId: options.id, - action: foldResponse.data ? [Constants.CB_GET_HL, Constants.CB_GET_ALL] : [Constants.CB_GET_HL], + action: foldResponse.data ? [Constants.CB_GET_HL, Constants.CB_GET_ALL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT], key: options.k, render: { gutter: true, diff --git a/app/src/util/newFile.ts b/app/src/util/newFile.ts index 1be551c51..44b41f4f3 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, action: [Constants.CB_GET_HL]}); + openFileById({id, action: [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT]}); } /// #endif }); diff --git a/app/src/util/onGetConfig.ts b/app/src/util/onGetConfig.ts index f05e962cc..e68cd775d 100644 --- a/app/src/util/onGetConfig.ts +++ b/app/src/util/onGetConfig.ts @@ -342,7 +342,7 @@ const initWindow = () => { } openFileById({ id: url.substr(16, 22), - action: [Constants.CB_GET_FOCUS], + action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT], zoomIn: getSearch("focus", url) === "1" }); });