♻️ context

This commit is contained in:
Vanessa 2022-08-07 09:26:08 +08:00
parent 3ef5731cb9
commit 65821e57de
22 changed files with 50 additions and 45 deletions

View file

@ -51,6 +51,7 @@ export abstract class Constants {
public static readonly CB_GET_ALL = "cb-get-all"; // 获取所有块 public static readonly CB_GET_ALL = "cb-get-all"; // 获取所有块
public static readonly CB_GET_UNUNDO = "cb-get-unundo"; // 不需要记录历史 public static readonly CB_GET_UNUNDO = "cb-get-unundo"; // 不需要记录历史
public static readonly CB_GET_SCROLL = "cb-get-scroll"; // 滚动到指定位置 public static readonly CB_GET_SCROLL = "cb-get-scroll"; // 滚动到指定位置
public static readonly CB_GET_CONTEXT = "cb-get-context"; // 包含上下文
// localstorage // localstorage
public static readonly LOCAL_SEARCHEDATA = "local-searchedata"; public static readonly LOCAL_SEARCHEDATA = "local-searchedata";

View file

@ -198,7 +198,7 @@ const switchEditor = (editor: Editor, options: IOpenFileOptions, allModels: IMod
if ((!nodeElement || nodeElement?.clientHeight === 0) && options.id !== options.rootID) { if ((!nodeElement || nodeElement?.clientHeight === 0) && options.id !== options.rootID) {
fetchPost("/api/filetree/getDoc", { fetchPost("/api/filetree/getDoc", {
id: options.id, 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, size: Constants.SIZE_GET,
}, getResponse => { }, getResponse => {
onGet(getResponse, editor.editor.protyle, options.action); onGet(getResponse, editor.editor.protyle, options.action);

View file

@ -334,7 +334,7 @@ export class Wnd {
} else { } else {
openFileById({ openFileById({
id: keepCursorId, id: keepCursorId,
action: [Constants.CB_GET_FOCUS] action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]
}); });
} }
currentTab.headElement.removeAttribute("keep-cursor"); currentTab.headElement.removeAttribute("keep-cursor");

View file

@ -137,27 +137,28 @@ export class Backlinks extends Model {
click(element: HTMLElement) { click(element: HTMLElement) {
openFileById({ openFileById({
id: element.getAttribute("data-node-id"), id: element.getAttribute("data-node-id"),
action: [Constants.CB_GET_FOCUS] action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]
}); });
}, },
ctrlClick(element: HTMLElement) { ctrlClick(element: HTMLElement) {
openFileById({ openFileById({
id: element.getAttribute("data-node-id"), id: element.getAttribute("data-node-id"),
keepCursor: true, keepCursor: true,
action: [Constants.CB_GET_CONTEXT]
}); });
}, },
altClick(element: HTMLElement) { altClick(element: HTMLElement) {
openFileById({ openFileById({
id: element.getAttribute("data-node-id"), id: element.getAttribute("data-node-id"),
position: "right", position: "right",
action: [Constants.CB_GET_FOCUS] action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]
}); });
}, },
shiftClick(element: HTMLElement) { shiftClick(element: HTMLElement) {
openFileById({ openFileById({
id: element.getAttribute("data-node-id"), id: element.getAttribute("data-node-id"),
position: "bottom", 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 { } else {
openFileById({ openFileById({
id: element.getAttribute("data-node-id"), 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({ openFileById({
id: element.getAttribute("data-node-id"), id: element.getAttribute("data-node-id"),
keepCursor: true, keepCursor: true,
action: [Constants.CB_GET_CONTEXT]
}); });
}, },
altClick(element: HTMLElement) { altClick(element: HTMLElement) {
openFileById({ openFileById({
id: element.getAttribute("data-node-id"), id: element.getAttribute("data-node-id"),
position: "right", position: "right",
action: [Constants.CB_GET_FOCUS] action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]
}); });
}, },
shiftClick(element: HTMLElement) { shiftClick(element: HTMLElement) {
openFileById({ openFileById({
id: element.getAttribute("data-node-id"), id: element.getAttribute("data-node-id"),
position: "bottom", position: "bottom",
action: [Constants.CB_GET_FOCUS] action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]
}); });
}, },
blockExtHTML: `<span class="b3-list-item__action b3-tooltips b3-tooltips__nw" aria-label="${window.siyuan.languages.more}"><svg><use xlink:href="#iconMore"></use></svg></span>` blockExtHTML: `<span class="b3-list-item__action b3-tooltips b3-tooltips__nw" aria-label="${window.siyuan.languages.more}"><svg><use xlink:href="#iconMore"></use></svg></span>`

View file

@ -80,7 +80,7 @@ export class Bookmark extends Model {
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
openFileById({ openFileById({
id, 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({ openFileById({
id: element.getAttribute("data-node-id"), id: element.getAttribute("data-node-id"),
keepCursor: true, keepCursor: true,
action: [Constants.CB_GET_CONTEXT]
}); });
}, },
altClick(element: HTMLElement) { altClick(element: HTMLElement) {
openFileById({ openFileById({
id: element.getAttribute("data-node-id"), id: element.getAttribute("data-node-id"),
position: "right", position: "right",
action: [Constants.CB_GET_FOCUS] action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]
}); });
}, },
shiftClick(element: HTMLElement) { shiftClick(element: HTMLElement) {
openFileById({ openFileById({
id: element.getAttribute("data-node-id"), id: element.getAttribute("data-node-id"),
position: "bottom", position: "bottom",
action: [Constants.CB_GET_FOCUS] action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]
}); });
} }
}); });

View file

@ -598,13 +598,13 @@ export class Graph extends Model {
openFileById({ openFileById({
id: node.id, id: node.id,
position: "bottom", position: "bottom",
action: [Constants.CB_GET_FOCUS] action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]
}); });
} else if (window.siyuan.altIsPressed) { } else if (window.siyuan.altIsPressed) {
openFileById({ openFileById({
id: node.id, id: node.id,
position: "right", position: "right",
action: [Constants.CB_GET_FOCUS] action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]
}); });
} else if (window.siyuan.ctrlIsPressed) { } else if (window.siyuan.ctrlIsPressed) {
window.siyuan.blockPanels.push(new BlockPanel({ window.siyuan.blockPanels.push(new BlockPanel({
@ -612,7 +612,7 @@ export class Graph extends Model {
nodeIds: [node.id], nodeIds: [node.id],
})); }));
} else { } else {
openFileById({id: node.id, action: [Constants.CB_GET_FOCUS]}); openFileById({id: node.id, action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]});
} }
}); });
}, 1000); }, 1000);

View file

@ -96,7 +96,7 @@ export class Outline extends Model {
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
openFileById({ openFileById({
id, 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],
}); });
}); });
} }

View file

@ -89,7 +89,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => { fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => {
openFileById({ openFileById({
id: refBlockId, 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, keepCursor: true,
zoomIn: foldResponse.data zoomIn: foldResponse.data
}); });
@ -105,7 +105,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
openFileById({ openFileById({
id: refBlockId, id: refBlockId,
position: "right", 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 zoomIn: foldResponse.data
}); });
}); });
@ -120,7 +120,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
openFileById({ openFileById({
id: refBlockId, id: refBlockId,
position: "bottom", 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 zoomIn: foldResponse.data
}); });
}); });
@ -354,7 +354,7 @@ export const zoomOut = (protyle: IProtyle, id: string, focusId?: string, isPushB
if (window.siyuan.mobileEditor) { if (window.siyuan.mobileEditor) {
window.localStorage.setItem(Constants.LOCAL_DOCINFO, JSON.stringify({ window.localStorage.setItem(Constants.LOCAL_DOCINFO, JSON.stringify({
id, 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({ window.siyuan.backStack.push({
id: protyle.block.id, id: protyle.block.id,

View file

@ -53,7 +53,7 @@ export const openMobileFileById = (id: string, action = [Constants.CB_GET_HL], p
fetchPost("/api/filetree/getDoc", { fetchPost("/api/filetree/getDoc", {
id, 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 : Constants.SIZE_GET,
mode: !action.includes(Constants.CB_GET_ALL) ? 3 : 0, mode: action.includes(Constants.CB_GET_CONTEXT) ? 3 : 0,
}, getResponse => { }, getResponse => {
onGet(getResponse, window.siyuan.mobileEditor.protyle, action); onGet(getResponse, window.siyuan.mobileEditor.protyle, action);
window.siyuan.mobileEditor.protyle.breadcrumb.render(window.siyuan.mobileEditor.protyle); window.siyuan.mobileEditor.protyle.breadcrumb.render(window.siyuan.mobileEditor.protyle);

View file

@ -46,7 +46,7 @@ export class MobileBacklinks {
element: this.element.querySelector(".backlinkList") as HTMLElement, element: this.element.querySelector(".backlinkList") as HTMLElement,
data: null, data: null,
click(element: HTMLElement) { 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({ this.mTree = new Tree({
@ -73,7 +73,7 @@ export class MobileBacklinks {
}).element); }).element);
window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY}); window.siyuan.menus.menu.popup({x: event.clientX, y: event.clientY});
} else { } 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: '<span class="b3-list-item__action"><svg><use xlink:href="#iconMore"></use></svg></span>' blockExtHTML: '<span class="b3-list-item__action"><svg><use xlink:href="#iconMore"></use></svg></span>'

View file

@ -83,7 +83,7 @@ export class MobileBookmarks {
}); });
} }
} else { } else {
openMobileFileById(id, [Constants.CB_GET_FOCUS]); openMobileFileById(id, [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]);
} }
}, },
blockExtHTML: '<span class="b3-list-item__action" data-type="remove"><svg><use xlink:href="#iconTrashcan"></use></svg></span>', blockExtHTML: '<span class="b3-list-item__action" data-type="remove"><svg><use xlink:href="#iconTrashcan"></use></svg></span>',

View file

@ -29,7 +29,7 @@ export class MobileOutline {
click: (element: HTMLElement) => { click: (element: HTMLElement) => {
const id = element.getAttribute("data-node-id"); const id = element.getAttribute("data-node-id");
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { 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]);
}); });
} }
}); });

View file

@ -118,7 +118,7 @@ export const initFramework = () => {
} else { } else {
fetchPost("/api/block/getRecentUpdatedBlocks", {}, (response) => { fetchPost("/api/block/getRecentUpdatedBlocks", {}, (response) => {
if (response.data.length !== 0) { if (response.data.length !== 0) {
openMobileFileById(response.data[0].id); openMobileFileById(response.data[0].id, [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT]);
} else { } else {
setEmpty(); setEmpty();
} }

View file

@ -80,7 +80,7 @@ export const popSearch = (modelElement: HTMLElement, modelMainElement: HTMLEleme
preventScroll(window.siyuan.mobileEditor.protyle); preventScroll(window.siyuan.mobileEditor.protyle);
} }
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { 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(); closePanel();
event.preventDefault(); event.preventDefault();

View file

@ -506,11 +506,11 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
}, () => { }, () => {
insertHTML(genEmptyBlock(false, false, `<span data-type="block-ref" data-id="${newSubDocId}" data-subtype="d">Untitled</span>`), protyle); insertHTML(genEmptyBlock(false, false, `<span data-type="block-ref" data-id="${newSubDocId}" data-subtype="d">Untitled</span>`), protyle);
/// #if MOBILE /// #if MOBILE
openMobileFileById(newSubDocId); openMobileFileById(newSubDocId, [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT]);
/// #else /// #else
openFileById({ openFileById({
id: newSubDocId, id: newSubDocId,
action: [Constants.CB_GET_HL] action: [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT]
}); });
/// #endif /// #endif
}); });

View file

@ -157,7 +157,7 @@ class Protyle {
fetchPost("/api/filetree/getDoc", { fetchPost("/api/filetree/getDoc", {
id: options.blockId, id: options.blockId,
k: options.key || "", 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, size: options.action?.includes(Constants.CB_GET_ALL) ? Constants.SIZE_GET_MAX : Constants.SIZE_GET,
}, getResponse => { }, getResponse => {
onGet(getResponse, this.protyle, options.action); onGet(getResponse, this.protyle, options.action);

View file

@ -1357,33 +1357,33 @@ export class WYSIWYG {
fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => { fetchPost("/api/block/checkBlockFold", {id: refBlockId}, (foldResponse) => {
/// #if MOBILE /// #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 /// #else
if (window.siyuan.shiftIsPressed) { if (window.siyuan.shiftIsPressed) {
openFileById({ openFileById({
id: refBlockId, id: refBlockId,
position: "bottom", 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 zoomIn: foldResponse.data
}); });
} else if (window.siyuan.altIsPressed) { } else if (window.siyuan.altIsPressed) {
openFileById({ openFileById({
id: refBlockId, id: refBlockId,
position: "right", 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 zoomIn: foldResponse.data
}); });
} else if (window.siyuan.ctrlIsPressed) { } else if (window.siyuan.ctrlIsPressed) {
openFileById({ openFileById({
id: refBlockId, 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, keepCursor: true,
zoomIn: foldResponse.data zoomIn: foldResponse.data
}); });
} else { } else {
openFileById({ openFileById({
id: refBlockId, 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 zoomIn: foldResponse.data
}); });
} }

View file

@ -1533,6 +1533,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
openFileById({ openFileById({
id, id,
keepCursor: true, keepCursor: true,
action: [Constants.CB_GET_CONTEXT]
}); });
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
@ -1541,7 +1542,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
openFileById({ openFileById({
id, id,
position: "right", position: "right",
action: [Constants.CB_GET_FOCUS] action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]
}); });
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
@ -1550,7 +1551,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
openFileById({ openFileById({
id, id,
position: "bottom", position: "bottom",
action: [Constants.CB_GET_FOCUS] action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]
}); });
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();

View file

@ -116,7 +116,7 @@ export class Search extends Model {
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
openFileById({ openFileById({
id, 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, zoomIn: foldResponse.data,
position: "right", position: "right",
}); });
@ -135,7 +135,7 @@ export class Search extends Model {
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
openFileById({ openFileById({
id, 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 zoomIn: foldResponse.data
}); });
}); });
@ -196,7 +196,7 @@ export class Search extends Model {
} else { } else {
this.protyle = new Protyle(this.element.querySelector("#searchPreview") as HTMLElement, { this.protyle = new Protyle(this.element.querySelector("#searchPreview") as HTMLElement, {
blockId: id, 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, key: value,
render: { render: {
gutter: true, gutter: true,

View file

@ -468,7 +468,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
openFileById({ openFileById({
id, 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 zoomIn: foldResponse.data
}); });
dialog.destroy(); dialog.destroy();
@ -591,7 +591,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
openFileById({ openFileById({
id, 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, zoomIn: foldResponse.data,
position: "right" position: "right"
}); });
@ -614,7 +614,7 @@ export const openSearch = async (hotkey: string, key?: string, notebookId?: stri
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => { fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
openFileById({ openFileById({
id, 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 zoomIn: foldResponse.data
}); });
dialog.destroy(); dialog.destroy();
@ -643,7 +643,7 @@ const getArticle = (options: {
if (!protyle) { if (!protyle) {
protyle = new Protyle(options.dialog.element.querySelector("#searchPreview") as HTMLElement, { protyle = new Protyle(options.dialog.element.querySelector("#searchPreview") as HTMLElement, {
blockId: options.id, 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, key: options.k,
render: { render: {
gutter: true, gutter: true,

View file

@ -67,7 +67,7 @@ export const newFile = (notebookId?: string, currentPath?: string, open?: boolea
}, () => { }, () => {
/// #if !MOBILE /// #if !MOBILE
if (open) { if (open) {
openFileById({id, action: [Constants.CB_GET_HL]}); openFileById({id, action: [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT]});
} }
/// #endif /// #endif
}); });

View file

@ -342,7 +342,7 @@ const initWindow = () => {
} }
openFileById({ openFileById({
id: url.substr(16, 22), id: url.substr(16, 22),
action: [Constants.CB_GET_FOCUS], action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT],
zoomIn: getSearch("focus", url) === "1" zoomIn: getSearch("focus", url) === "1"
}); });
}); });