This commit is contained in:
Vanessa 2022-06-29 10:35:35 +08:00
parent 5a206a770f
commit 968f666d19
7 changed files with 109 additions and 97 deletions

View file

@ -1,19 +1,16 @@
import {Tab} from "../layout/Tab";
import {Editor} from "./index";
import {Wnd} from "../layout/Wnd";
import {getDockByType, getInstanceById, getWndByLayout, switchWnd} from "../layout/util";
import {getDockByType, getInstanceById, getWndByLayout} from "../layout/util";
import {getAllModels} from "../layout/getAll";
import {highlightById, scrollCenter} from "../util/highlightById";
import {getDisplayName, pathPosix} from "../util/pathName";
import {Constants} from "../constants";
import {Outline} from "../layout/dock/Outline";
import {setEditMode} from "../protyle/util/setEditMode";
import {Files} from "../layout/dock/Files";
import {setPadding} from "../protyle/ui/initUI";
import {fetchPost} from "../util/fetch";
import {showMessage} from "../dialog/message";
import {Backlinks} from "../layout/dock/Backlinks";
import {Graph} from "../layout/dock/Graph";
import {focusBlock, focusByRange} from "../protyle/util/selection";
import {onGet} from "../protyle/util/onGet";
/// #if !BROWSER
@ -32,86 +29,6 @@ import {lockFile, setTitle} from "../dialog/processSystem";
import {zoomOut} from "../menus/protyle";
import {confirmDialog} from "../dialog/confirmDialog";
export const openOutline = (protyle: IProtyle) => {
const outlinePanel = getAllModels().outline.find(item => {
if (item.blockId === protyle.block.rootID && item.type === "local") {
item.parent.parent.removeTab(item.parent.id);
return true;
}
});
if (outlinePanel) {
return;
}
const newWnd = protyle.model.parent.parent.split("lr");
const tab = new Tab({
icon: "iconAlignCenter",
title: protyle.title.editElement.textContent,
callback(tab: Tab) {
tab.addModel(new Outline({
type: "local",
tab,
blockId: protyle.block.rootID,
}));
}
});
newWnd.addTab(tab);
newWnd.element.classList.remove("fn__flex-1");
newWnd.element.style.width = "200px";
switchWnd(newWnd, protyle.model.parent.parent);
};
export const openBacklink = (protyle: IProtyle) => {
const backlink = getAllModels().backlinks.find(item => {
if (item.blockId === protyle.block.id && item.type === "local") {
item.parent.parent.removeTab(item.parent.id);
return true;
}
});
if (backlink) {
return;
}
const newWnd = protyle.model.parent.parent.split("lr");
const tab = new Tab({
icon: "iconLink",
title: protyle.title.editElement.textContent,
callback(tab: Tab) {
tab.addModel(new Backlinks({
type: "local",
tab,
blockId: protyle.block.id,
rootId: protyle.block.rootID,
}));
}
});
newWnd.addTab(tab);
};
export const openGraph = (protyle: IProtyle) => {
const graph = getAllModels().graph.find(item => {
if (item.blockId === protyle.block.id && item.type === "local") {
item.parent.parent.removeTab(item.parent.id);
return true;
}
});
if (graph) {
return;
}
const wnd = protyle.model.parent.parent.split("lr");
const tab = new Tab({
icon: "iconGraph",
title: protyle.title.editElement.textContent,
callback(tab: Tab) {
tab.addModel(new Graph({
type: "local",
tab,
blockId: protyle.block.id,
rootId: protyle.block.rootID,
}));
}
});
wnd.addTab(tab);
};
export const openFileById = (options: {
id: string,
position?: string,