mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 00:50:13 +01:00
This commit is contained in:
parent
1dc5a371f6
commit
5fac682e6f
13 changed files with 120 additions and 111 deletions
|
|
@ -3,7 +3,7 @@ import * as path from "path";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {matchHotKey} from "../../protyle/util/hotKey";
|
import {matchHotKey} from "../../protyle/util/hotKey";
|
||||||
import {fetchPost} from "../../util/fetch";
|
import {fetchPost} from "../../util/fetch";
|
||||||
import {openFileById} from "../../editor/util";
|
import {checkFold, openFileById} from "../../editor/util";
|
||||||
import {Constants} from "../../constants";
|
import {Constants} from "../../constants";
|
||||||
import {newFileByName} from "../../util/newFile";
|
import {newFileByName} from "../../util/newFile";
|
||||||
import {App} from "../../index";
|
import {App} from "../../index";
|
||||||
|
|
@ -90,19 +90,18 @@ export const searchKeydown = (app: App, event: KeyboardEvent) => {
|
||||||
if (!isAsset) {
|
if (!isAsset) {
|
||||||
if (matchHotKey(window.siyuan.config.keymap.editor.general.insertRight.custom, event)) {
|
if (matchHotKey(window.siyuan.config.keymap.editor.general.insertRight.custom, event)) {
|
||||||
const id = currentList.getAttribute("data-node-id");
|
const id = currentList.getAttribute("data-node-id");
|
||||||
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
|
checkFold(id, (zoomIn, action) => {
|
||||||
openFileById({
|
openFileById({
|
||||||
app,
|
app,
|
||||||
id,
|
id,
|
||||||
position: "right",
|
position: "right",
|
||||||
action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] :
|
action,
|
||||||
(id === currentList.getAttribute("data-root-id") ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ROOTSCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]),
|
zoomIn
|
||||||
zoomIn: foldResponse.data
|
|
||||||
});
|
});
|
||||||
if (dialog) {
|
if (dialog) {
|
||||||
dialog.destroy({focus: "false"});
|
dialog.destroy({focus: "false"});
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const id = currentList.getAttribute("data-node-id");
|
const id = currentList.getAttribute("data-node-id");
|
||||||
|
|
@ -197,18 +196,17 @@ export const searchKeydown = (app: App, event: KeyboardEvent) => {
|
||||||
replace(element, config, edit, false);
|
replace(element, config, edit, false);
|
||||||
} else {
|
} else {
|
||||||
const id = currentList.getAttribute("data-node-id");
|
const id = currentList.getAttribute("data-node-id");
|
||||||
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
|
checkFold(id, (zoomIn, action) => {
|
||||||
openFileById({
|
openFileById({
|
||||||
app,
|
app,
|
||||||
id,
|
id,
|
||||||
action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] :
|
action,
|
||||||
(id === currentList.getAttribute("data-root-id") ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ROOTSCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]),
|
zoomIn
|
||||||
zoomIn: foldResponse.data
|
|
||||||
});
|
});
|
||||||
if (dialog) {
|
if (dialog) {
|
||||||
dialog.destroy({focus: "false"});
|
dialog.destroy({focus: "false"});
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
|
|
|
||||||
|
|
@ -75,9 +75,9 @@ 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_BACKLINK = "cb-get-backlink"; // 悬浮窗为传递型需展示上下文
|
public static readonly CB_GET_BACKLINK = "cb-get-backlink"; // 悬浮窗为传递型需展示上下文
|
||||||
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"; // 滚动到指定位置,用于直接打开文档,必有 rootID
|
||||||
public static readonly CB_GET_CONTEXT = "cb-get-context"; // 包含上下文
|
public static readonly CB_GET_CONTEXT = "cb-get-context"; // 包含上下文
|
||||||
public static readonly CB_GET_ROOTSCROLL = "cb-get-rootscroll"; // 如果为 rootID 就滚动到指定位置
|
public static readonly CB_GET_ROOTSCROLL = "cb-get-rootscroll"; // 如果为 rootID 就滚动到指定位置,必有 rootID
|
||||||
public static readonly CB_GET_HTML = "cb-get-html"; // 直接渲染,不需要再 /api/block/getDocInfo,否则搜索表格无法定位
|
public static readonly CB_GET_HTML = "cb-get-html"; // 直接渲染,不需要再 /api/block/getDocInfo,否则搜索表格无法定位
|
||||||
public static readonly CB_GET_HISTORY = "cb-get-history"; // 历史渲染
|
public static readonly CB_GET_HISTORY = "cb-get-history"; // 历史渲染
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ export class Editor extends Model {
|
||||||
app: App,
|
app: App,
|
||||||
tab: Tab,
|
tab: Tab,
|
||||||
blockId: string,
|
blockId: string,
|
||||||
rootId?: string, // 使用 rootId 会优先使用本地 filepositon 定位
|
rootId: string,
|
||||||
mode?: TEditorMode,
|
mode?: TEditorMode,
|
||||||
action?: string[],
|
action?: string[],
|
||||||
}) {
|
}) {
|
||||||
|
|
@ -38,7 +38,7 @@ export class Editor extends Model {
|
||||||
private initProtyle(options: {
|
private initProtyle(options: {
|
||||||
blockId: string,
|
blockId: string,
|
||||||
action?: string[]
|
action?: string[]
|
||||||
rootId?: string,
|
rootId: string,
|
||||||
mode?: TEditorMode,
|
mode?: TEditorMode,
|
||||||
}) {
|
}) {
|
||||||
this.editor = new Protyle(this.app, this.element, {
|
this.editor = new Protyle(this.app, this.element, {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,15 @@ import {Search} from "../search";
|
||||||
import {App} from "../index";
|
import {App} from "../index";
|
||||||
import {newCardModel} from "../card/newCardTab";
|
import {newCardModel} from "../card/newCardTab";
|
||||||
|
|
||||||
|
export const checkFold = (id: string, cb: (zoomIn: boolean, action: string[]) => void) => {
|
||||||
|
if (!id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
|
||||||
|
cb(foldResponse.data, foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL])
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export const openFileById = async (options: {
|
export const openFileById = async (options: {
|
||||||
app: App,
|
app: App,
|
||||||
id: string,
|
id: string,
|
||||||
|
|
@ -472,6 +481,7 @@ const newTab = (options: IOpenFileOptions) => {
|
||||||
app: options.app,
|
app: options.app,
|
||||||
tab,
|
tab,
|
||||||
blockId: options.id,
|
blockId: options.id,
|
||||||
|
rootId: options.rootID,
|
||||||
action: [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS],
|
action: [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS],
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -479,6 +489,7 @@ const newTab = (options: IOpenFileOptions) => {
|
||||||
app: options.app,
|
app: options.app,
|
||||||
tab,
|
tab,
|
||||||
blockId: options.id,
|
blockId: options.id,
|
||||||
|
rootId: options.rootID,
|
||||||
mode: options.mode,
|
mode: options.mode,
|
||||||
action: options.action,
|
action: options.action,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -466,7 +466,7 @@ export class Wnd {
|
||||||
openFileById({
|
openFileById({
|
||||||
app: this.app,
|
app: this.app,
|
||||||
id: keepCursorId,
|
id: keepCursorId,
|
||||||
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]
|
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_SCROLL]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
currentTab.headElement.removeAttribute("keep-cursor");
|
currentTab.headElement.removeAttribute("keep-cursor");
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@ import {setPanelFocus} from "../util";
|
||||||
import {getDockByType} from "../tabUtil";
|
import {getDockByType} from "../tabUtil";
|
||||||
import {fetchPost} from "../../util/fetch";
|
import {fetchPost} from "../../util/fetch";
|
||||||
import {updateHotkeyTip} from "../../protyle/util/compatibility";
|
import {updateHotkeyTip} from "../../protyle/util/compatibility";
|
||||||
import {openFileById} from "../../editor/util";
|
import {checkFold, openFileById} from "../../editor/util";
|
||||||
import {Constants} from "../../constants";
|
|
||||||
import {hasClosestByClassName} from "../../protyle/util/hasClosest";
|
import {hasClosestByClassName} from "../../protyle/util/hasClosest";
|
||||||
import {openBookmarkMenu} from "../../menus/bookmark";
|
import {openBookmarkMenu} from "../../menus/bookmark";
|
||||||
import {App} from "../../index";
|
import {App} from "../../index";
|
||||||
|
|
@ -84,44 +83,54 @@ export class Bookmark extends Model {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const id = element.getAttribute("data-node-id");
|
const id = element.getAttribute("data-node-id")
|
||||||
if (id) {
|
checkFold(id, (zoomIn, action: string[]) => {
|
||||||
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
|
|
||||||
openFileById({
|
openFileById({
|
||||||
app,
|
app,
|
||||||
id,
|
id,
|
||||||
action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL],
|
action,
|
||||||
zoomIn: foldResponse.data
|
zoomIn
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
|
||||||
},
|
},
|
||||||
rightClick: (element: HTMLElement, event: MouseEvent) => {
|
rightClick: (element: HTMLElement, event: MouseEvent) => {
|
||||||
openBookmarkMenu(element, event, this);
|
openBookmarkMenu(element, event, this);
|
||||||
},
|
},
|
||||||
ctrlClick(element: HTMLElement) {
|
ctrlClick: (element: HTMLElement) => {
|
||||||
|
const id = element.getAttribute("data-node-id")
|
||||||
|
checkFold(id, (zoomIn, action: string[]) => {
|
||||||
openFileById({
|
openFileById({
|
||||||
app,
|
app,
|
||||||
id: element.getAttribute("data-node-id"),
|
id,
|
||||||
keepCursor: true,
|
keepCursor: true,
|
||||||
action: [Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]
|
action,
|
||||||
|
zoomIn
|
||||||
});
|
});
|
||||||
|
})
|
||||||
},
|
},
|
||||||
altClick(element: HTMLElement) {
|
altClick: (element: HTMLElement,) => {
|
||||||
|
const id = element.getAttribute("data-node-id")
|
||||||
|
checkFold(id, (zoomIn, action: string[]) => {
|
||||||
openFileById({
|
openFileById({
|
||||||
app,
|
app,
|
||||||
id: element.getAttribute("data-node-id"),
|
id,
|
||||||
position: "right",
|
|
||||||
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]
|
|
||||||
});
|
|
||||||
},
|
|
||||||
shiftClick(element: HTMLElement) {
|
|
||||||
openFileById({
|
|
||||||
app,
|
|
||||||
id: element.getAttribute("data-node-id"),
|
|
||||||
position: "bottom",
|
position: "bottom",
|
||||||
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]
|
action,
|
||||||
|
zoomIn
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
},
|
||||||
|
shiftClick: (element: HTMLElement) => {
|
||||||
|
const id = element.getAttribute("data-node-id")
|
||||||
|
checkFold(id, (zoomIn, action: string[]) => {
|
||||||
|
openFileById({
|
||||||
|
app,
|
||||||
|
id,
|
||||||
|
position: "bottom",
|
||||||
|
action,
|
||||||
|
zoomIn
|
||||||
|
});
|
||||||
|
})
|
||||||
},
|
},
|
||||||
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>',
|
||||||
topExtHTML: '<span class="b3-list-item__action"><svg><use xlink:href="#iconMore"></use></svg></span>',
|
topExtHTML: '<span class="b3-list-item__action"><svg><use xlink:href="#iconMore"></use></svg></span>',
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import {addScript} from "../../protyle/util/addScript";
|
||||||
import {BlockPanel} from "../../block/Panel";
|
import {BlockPanel} from "../../block/Panel";
|
||||||
import {fullscreen} from "../../protyle/breadcrumb/action";
|
import {fullscreen} from "../../protyle/breadcrumb/action";
|
||||||
import {fetchPost} from "../../util/fetch";
|
import {fetchPost} from "../../util/fetch";
|
||||||
import {isCurrentEditor, openFileById} from "../../editor/util";
|
import {checkFold, isCurrentEditor, openFileById} from "../../editor/util";
|
||||||
import {updateHotkeyTip} from "../../protyle/util/compatibility";
|
import {updateHotkeyTip} from "../../protyle/util/compatibility";
|
||||||
import {openGlobalSearch} from "../../search/util";
|
import {openGlobalSearch} from "../../search/util";
|
||||||
import {App} from "../../index";
|
import {App} from "../../index";
|
||||||
|
|
@ -652,19 +652,25 @@ export class Graph extends Model {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (window.siyuan.shiftIsPressed) {
|
if (window.siyuan.shiftIsPressed) {
|
||||||
|
checkFold(node.id, (zoomIn, action: string[]) => {
|
||||||
openFileById({
|
openFileById({
|
||||||
app: this.app,
|
app: this.app,
|
||||||
id: node.id,
|
id: node.id,
|
||||||
position: "bottom",
|
position: "bottom",
|
||||||
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]
|
action,
|
||||||
|
zoomIn
|
||||||
});
|
});
|
||||||
|
})
|
||||||
} else if (window.siyuan.altIsPressed) {
|
} else if (window.siyuan.altIsPressed) {
|
||||||
|
checkFold(node.id, (zoomIn, action: string[]) => {
|
||||||
openFileById({
|
openFileById({
|
||||||
app: this.app,
|
app: this.app,
|
||||||
id: node.id,
|
id: node.id,
|
||||||
position: "right",
|
position: "right",
|
||||||
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]
|
action,
|
||||||
|
zoomIn
|
||||||
});
|
});
|
||||||
|
})
|
||||||
} else if (window.siyuan.ctrlIsPressed) {
|
} else if (window.siyuan.ctrlIsPressed) {
|
||||||
window.siyuan.blockPanels.push(new BlockPanel({
|
window.siyuan.blockPanels.push(new BlockPanel({
|
||||||
app: this.app,
|
app: this.app,
|
||||||
|
|
@ -674,11 +680,14 @@ export class Graph extends Model {
|
||||||
nodeIds: [node.id],
|
nodeIds: [node.id],
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
|
checkFold(node.id, (zoomIn, action: string[]) => {
|
||||||
openFileById({
|
openFileById({
|
||||||
app: this.app,
|
app: this.app,
|
||||||
id: node.id,
|
id: node.id,
|
||||||
action: [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]
|
action,
|
||||||
|
zoomIn
|
||||||
});
|
});
|
||||||
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
|
||||||
|
|
@ -235,7 +235,8 @@ export const copyTab = (app: App, tab: Tab) => {
|
||||||
model = new Editor({
|
model = new Editor({
|
||||||
app,
|
app,
|
||||||
tab: newTab,
|
tab: newTab,
|
||||||
blockId: tab.model.editor.protyle.block.id
|
blockId: tab.model.editor.protyle.block.id,
|
||||||
|
rootId: tab.model.editor.protyle.block.rootID
|
||||||
});
|
});
|
||||||
} else if (tab.model instanceof Asset) {
|
} else if (tab.model instanceof Asset) {
|
||||||
model = new Asset({
|
model = new Asset({
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ export const openMobileFileById = (app: App, id: string, action = [Constants.CB_
|
||||||
} else {
|
} else {
|
||||||
window.siyuan.mobile.editor = new Protyle(app, document.getElementById("editor"), {
|
window.siyuan.mobile.editor = new Protyle(app, document.getElementById("editor"), {
|
||||||
blockId: id,
|
blockId: id,
|
||||||
|
rootId: data.data.rootID,
|
||||||
action,
|
action,
|
||||||
render: {
|
render: {
|
||||||
scroll: true,
|
scroll: true,
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import {syncGuide} from "../../sync/syncGuide";
|
||||||
import {Inbox} from "../../layout/dock/Inbox";
|
import {Inbox} from "../../layout/dock/Inbox";
|
||||||
import {App} from "../../index";
|
import {App} from "../../index";
|
||||||
import {setTitle} from "../../dialog/processSystem";
|
import {setTitle} from "../../dialog/processSystem";
|
||||||
|
import {checkFold} from "../../editor/util";
|
||||||
|
|
||||||
export const initFramework = (app: App, isStart: boolean) => {
|
export const initFramework = (app: App, isStart: boolean) => {
|
||||||
setInlineStyle();
|
setInlineStyle();
|
||||||
|
|
@ -134,7 +135,9 @@ export const initFramework = (app: App, isStart: boolean) => {
|
||||||
} else {
|
} else {
|
||||||
fetchPost("/api/block/getRecentUpdatedBlocks", {}, (response) => {
|
fetchPost("/api/block/getRecentUpdatedBlocks", {}, (response) => {
|
||||||
if (response.data.length !== 0) {
|
if (response.data.length !== 0) {
|
||||||
openMobileFileById(app, response.data[0].id, [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]);
|
checkFold(response.data[0].id, (zoomIn) => {
|
||||||
|
openMobileFileById(app, response.data[0].id, zoomIn ? [Constants.CB_GET_ALL, Constants.CB_GET_HL] : [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
setEmpty(app);
|
setEmpty(app);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -228,44 +228,22 @@ export class Protyle {
|
||||||
removeLoading(this.protyle);
|
removeLoading(this.protyle);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const filePosition = window.siyuan.storage[Constants.LOCAL_FILEPOSITION][options.blockId] ||
|
|
||||||
window.siyuan.storage[Constants.LOCAL_FILEPOSITION][options.rootId];
|
|
||||||
if (this.protyle.options.mode !== "preview" &&
|
if (this.protyle.options.mode !== "preview" &&
|
||||||
!mergedOptions.action.includes(Constants.CB_GET_ALL) &&
|
options.rootId && window.siyuan.storage[Constants.LOCAL_FILEPOSITION][options.rootId] &&
|
||||||
(mergedOptions.action.includes(Constants.CB_GET_SCROLL) || mergedOptions.action.includes(Constants.CB_GET_ROOTSCROLL)) &&
|
(
|
||||||
filePosition) {
|
mergedOptions.action.includes(Constants.CB_GET_SCROLL) ||
|
||||||
|
(mergedOptions.action.includes(Constants.CB_GET_ROOTSCROLL) && options.rootId === options.blockId)
|
||||||
|
)
|
||||||
|
) {
|
||||||
getDocByScroll({
|
getDocByScroll({
|
||||||
protyle: this.protyle,
|
protyle: this.protyle,
|
||||||
scrollAttr: filePosition,
|
scrollAttr: window.siyuan.storage[Constants.LOCAL_FILEPOSITION][options.rootId],
|
||||||
mergedOptions,
|
mergedOptions,
|
||||||
cb: () => {
|
cb: () => {
|
||||||
this.afterOnGet(mergedOptions);
|
this.afterOnGet(mergedOptions);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (this.protyle.options.mode !== "preview" &&
|
|
||||||
(mergedOptions.action.includes(Constants.CB_GET_SCROLL) || mergedOptions.action.includes(Constants.CB_GET_ROOTSCROLL))) {
|
|
||||||
fetchPost("/api/block/getDocInfo", {
|
|
||||||
id: options.blockId
|
|
||||||
}, (response) => {
|
|
||||||
if (!mergedOptions.action.includes(Constants.CB_GET_SCROLL) &&
|
|
||||||
response.data.rootID !== options.blockId && mergedOptions.action.includes(Constants.CB_GET_ROOTSCROLL)) {
|
|
||||||
// 打开根文档保持上一次历史,否则按照原有 action 执行 https://github.com/siyuan-note/siyuan/issues/9082
|
|
||||||
this.getDoc(mergedOptions);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (window.siyuan.storage[Constants.LOCAL_FILEPOSITION][response.data.rootID]) {
|
|
||||||
getDocByScroll({
|
|
||||||
protyle: this.protyle,
|
|
||||||
scrollAttr: window.siyuan.storage[Constants.LOCAL_FILEPOSITION][response.data.rootID],
|
|
||||||
mergedOptions,
|
|
||||||
cb: () => {
|
|
||||||
this.afterOnGet(mergedOptions);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.getDoc(mergedOptions);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
this.getDoc(mergedOptions);
|
this.getDoc(mergedOptions);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import * as path from "path";
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
import {escapeAriaLabel, escapeGreat, escapeHtml} from "../util/escape";
|
import {escapeAriaLabel, escapeGreat, escapeHtml} from "../util/escape";
|
||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost} from "../util/fetch";
|
||||||
import {openFile, openFileById} from "../editor/util";
|
import {checkFold, openFile, openFileById} from "../editor/util";
|
||||||
import {showMessage} from "../dialog/message";
|
import {showMessage} from "../dialog/message";
|
||||||
import {reloadProtyle} from "../protyle/util/reload";
|
import {reloadProtyle} from "../protyle/util/reload";
|
||||||
import {MenuItem} from "../menus/Menu";
|
import {MenuItem} from "../menus/Menu";
|
||||||
|
|
@ -865,19 +865,18 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
|
||||||
} else {
|
} else {
|
||||||
if (event.altKey) {
|
if (event.altKey) {
|
||||||
const id = target.getAttribute("data-node-id");
|
const id = target.getAttribute("data-node-id");
|
||||||
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
|
checkFold(id, (zoomIn, action) => {
|
||||||
openFileById({
|
openFileById({
|
||||||
app,
|
app,
|
||||||
id,
|
id,
|
||||||
action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] :
|
action,
|
||||||
(id === target.getAttribute("data-root-id") ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ROOTSCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]),
|
zoomIn,
|
||||||
zoomIn: foldResponse.data,
|
|
||||||
position: "right"
|
position: "right"
|
||||||
});
|
});
|
||||||
if (closeCB) {
|
if (closeCB) {
|
||||||
closeCB();
|
closeCB();
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
} else if (!target.classList.contains("b3-list-item--focus")) {
|
} else if (!target.classList.contains("b3-list-item--focus")) {
|
||||||
searchPanelElement.querySelector(".b3-list-item--focus").classList.remove("b3-list-item--focus");
|
searchPanelElement.querySelector(".b3-list-item--focus").classList.remove("b3-list-item--focus");
|
||||||
target.classList.add("b3-list-item--focus");
|
target.classList.add("b3-list-item--focus");
|
||||||
|
|
@ -906,18 +905,17 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
|
||||||
/// #endif
|
/// #endif
|
||||||
} else {
|
} else {
|
||||||
const id = target.getAttribute("data-node-id");
|
const id = target.getAttribute("data-node-id");
|
||||||
fetchPost("/api/block/checkBlockFold", {id}, (foldResponse) => {
|
checkFold(id, (zoomIn, action) => {
|
||||||
openFileById({
|
openFileById({
|
||||||
app,
|
app,
|
||||||
id,
|
id,
|
||||||
action: foldResponse.data ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] :
|
action,
|
||||||
(id === target.getAttribute("data-root-id") ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ROOTSCROLL] : [Constants.CB_GET_FOCUS, Constants.CB_GET_CONTEXT]),
|
zoomIn
|
||||||
zoomIn: foldResponse.data
|
|
||||||
});
|
});
|
||||||
if (closeCB) {
|
if (closeCB) {
|
||||||
closeCB();
|
closeCB();
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.siyuan.menus.menu.remove();
|
window.siyuan.menus.menu.remove();
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ const focusStack = async (app: App, stack: IBackStack) => {
|
||||||
app: app,
|
app: app,
|
||||||
tab,
|
tab,
|
||||||
blockId: stack.zoomId || stack.protyle.block.rootID,
|
blockId: stack.zoomId || stack.protyle.block.rootID,
|
||||||
|
rootId: stack.protyle.block.rootID,
|
||||||
action: stack.zoomId ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS]
|
action: stack.zoomId ? [Constants.CB_GET_FOCUS, Constants.CB_GET_ALL] : [Constants.CB_GET_FOCUS]
|
||||||
});
|
});
|
||||||
tab.addModel(editor);
|
tab.addModel(editor);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue