♻️ rm hasContext
This commit is contained in:
parent
e40bc18d86
commit
d2a6c03d52
27 changed files with 31 additions and 92 deletions
|
@ -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: {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -333,7 +333,6 @@ export class Wnd {
|
|||
} else {
|
||||
openFileById({
|
||||
id: keepCursorId,
|
||||
hasContext: true,
|
||||
action: [Constants.CB_GET_FOCUS]
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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]
|
||||
});
|
||||
},
|
||||
|
|
|
@ -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]
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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],
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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", {
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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: '<span class="b3-list-item__action"><svg><use xlink:href="#iconMore"></use></svg></span>'
|
||||
|
|
|
@ -83,7 +83,7 @@ export class MobileBookmarks {
|
|||
});
|
||||
}
|
||||
} else {
|
||||
openMobileFileById(id, true, [Constants.CB_GET_FOCUS]);
|
||||
openMobileFileById(id, [Constants.CB_GET_FOCUS]);
|
||||
}
|
||||
},
|
||||
blockExtHTML: '<span class="b3-list-item__action" data-type="remove"><svg><use xlink:href="#iconTrashcan"></use></svg></span>',
|
||||
|
|
|
@ -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(), () => {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -506,11 +506,10 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
|
|||
}, () => {
|
||||
insertHTML(genEmptyBlock(false, false, `<span data-type="block-ref" data-id="${newSubDocId}" data-subtype="d">Untitled</span>`), protyle);
|
||||
/// #if MOBILE
|
||||
openMobileFileById(newSubDocId, true);
|
||||
openMobileFileById(newSubDocId);
|
||||
/// #else
|
||||
openFileById({
|
||||
id: newSubDocId,
|
||||
hasContext: true,
|
||||
action: [Constants.CB_GET_HL]
|
||||
});
|
||||
/// #endif
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
2
app/src/types/index.d.ts
vendored
2
app/src/types/index.d.ts
vendored
|
@ -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 // 是否缩放
|
||||
|
|
1
app/src/types/protyle.d.ts
vendored
1
app/src/types/protyle.d.ts
vendored
|
@ -345,7 +345,6 @@ interface IOptions {
|
|||
action?: string[],
|
||||
mode?: TEditorMode,
|
||||
blockId: string
|
||||
hasContext?: boolean
|
||||
key?: string
|
||||
defId?: string
|
||||
render?: {
|
||||
|
|
|
@ -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
|
||||
});
|
||||
|
|
|
@ -342,7 +342,6 @@ const initWindow = () => {
|
|||
}
|
||||
openFileById({
|
||||
id: url.substr(16, 22),
|
||||
hasContext: true,
|
||||
action: [Constants.CB_GET_FOCUS],
|
||||
zoomIn: getSearch("focus", url) === "1"
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue