mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
♻️
This commit is contained in:
parent
5a206a770f
commit
968f666d19
7 changed files with 109 additions and 97 deletions
|
|
@ -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,
|
||||
|
|
|
|||
86
app/src/layout/dock/util.ts
Normal file
86
app/src/layout/dock/util.ts
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
import {getAllModels} from "../getAll";
|
||||
import {Tab} from "../Tab";
|
||||
import {Backlinks} from "./Backlinks";
|
||||
import {Graph} from "./Graph";
|
||||
import {Outline} from "./Outline";
|
||||
import {switchWnd} from "../util";
|
||||
|
||||
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 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);
|
||||
};
|
||||
|
|
@ -752,24 +752,31 @@ export const openMenu = (src: string, onlyMenu = false) => {
|
|||
});
|
||||
/// #endif
|
||||
} else {
|
||||
/// #if !BROWSER
|
||||
submenu.push({
|
||||
label: window.siyuan.languages.useDefault,
|
||||
accelerator: "Click",
|
||||
click: () => {
|
||||
/// #if !BROWSER
|
||||
shell.openExternal(src).catch((e) => {
|
||||
console.log("openExternal error:" + e);
|
||||
showMessage(e);
|
||||
});
|
||||
/// #else
|
||||
}
|
||||
});
|
||||
/// #endif
|
||||
}
|
||||
/// #if BROWSER
|
||||
submenu.push({
|
||||
label: window.siyuan.languages.useBrowserView,
|
||||
accelerator: "Click",
|
||||
click: () => {
|
||||
if (window.siyuan.config.system.container === "ios") {
|
||||
window.location.href = src;
|
||||
} else {
|
||||
window.open(src);
|
||||
}
|
||||
/// #endif
|
||||
}
|
||||
});
|
||||
}
|
||||
/// #endif
|
||||
if (onlyMenu) {
|
||||
return submenu;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,13 +18,14 @@ import {matchHotKey} from "../util/hotKey";
|
|||
import {updateHotkeyTip, writeText} from "../util/compatibility";
|
||||
import {setPanelFocus} from "../../layout/util";
|
||||
import {escapeHtml} from "../../util/escape";
|
||||
import {deleteFile, openBacklink, openGraph, openOutline, updatePanelByEditor} from "../../editor/util";
|
||||
import {deleteFile, updatePanelByEditor} from "../../editor/util";
|
||||
import * as dayjs from "dayjs";
|
||||
import {setTitle} from "../../dialog/processSystem";
|
||||
import {getNoContainerElement} from "../wysiwyg/getBlock";
|
||||
import {commonHotkey} from "../wysiwyg/commonHotkey";
|
||||
import {setPosition} from "../../util/setPosition";
|
||||
import {code160to32} from "../util/code160to32";
|
||||
import {openBacklink, openGraph, openOutline} from "../../layout/dock/util";
|
||||
|
||||
export class Title {
|
||||
public element: HTMLElement;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ export class Preview {
|
|||
} else {
|
||||
/// #if !BROWSER
|
||||
shell.openExternal(linkAddress).catch((e) => {
|
||||
console.log("openExternal error:" + e);
|
||||
showMessage(e);
|
||||
});
|
||||
/// #else
|
||||
window.open(linkAddress);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import {matchHotKey} from "../util/hotKey";
|
||||
import {fetchPost} from "../../util/fetch";
|
||||
import {writeText} from "../util/compatibility";
|
||||
import {openBacklink, openGraph, openOutline} from "../../editor/util";
|
||||
import {focusByOffset, getSelectionOffset} from "../util/selection";
|
||||
import {fullscreen} from "../breadcrumb/action";
|
||||
import {addLoading, setPadding} from "../ui/initUI";
|
||||
import {Constants} from "../../constants";
|
||||
import {onGet} from "../util/onGet";
|
||||
import {openBacklink, openGraph, openOutline} from "../../layout/dock/util";
|
||||
|
||||
export const commonHotkey = (protyle: IProtyle, event: KeyboardEvent) => {
|
||||
const target = event.target as HTMLElement;
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ import {fetchPost} from "../../util/fetch";
|
|||
import {onGet} from "../util/onGet";
|
||||
import {setTableAlign} from "../util/table";
|
||||
import {countBlockWord, countSelectWord} from "../../layout/status";
|
||||
import {showMessage} from "../../dialog/message";
|
||||
|
||||
export class WYSIWYG {
|
||||
public lastHTMLs: { [key: string]: string } = {};
|
||||
|
|
@ -1463,7 +1464,7 @@ export class WYSIWYG {
|
|||
} else {
|
||||
/// #if !BROWSER
|
||||
shell.openExternal(linkAddress).catch((e) => {
|
||||
console.log("openExternal error:" + e);
|
||||
showMessage(e);
|
||||
});
|
||||
/// #else
|
||||
if (window.siyuan.config.system.container === "ios") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue