|
@@ -1,7 +1,7 @@
|
|
import {Tab} from "../layout/Tab";
|
|
import {Tab} from "../layout/Tab";
|
|
import {Editor} from "./index";
|
|
import {Editor} from "./index";
|
|
import {Wnd} from "../layout/Wnd";
|
|
import {Wnd} from "../layout/Wnd";
|
|
-import {getDockByType, getInstanceById, getWndByLayout, pdfIsLoading} from "../layout/util";
|
|
|
|
|
|
+import {getDockByType, getInstanceById, getWndByLayout, pdfIsLoading, resizeTabs, setPanelFocus} from "../layout/util";
|
|
import {getAllModels, getAllTabs} from "../layout/getAll";
|
|
import {getAllModels, getAllTabs} from "../layout/getAll";
|
|
import {highlightById, scrollCenter} from "../util/highlightById";
|
|
import {highlightById, scrollCenter} from "../util/highlightById";
|
|
import {getDisplayName, pathPosix} from "../util/pathName";
|
|
import {getDisplayName, pathPosix} from "../util/pathName";
|
|
@@ -24,8 +24,10 @@ import {setTitle} from "../dialog/processSystem";
|
|
import {zoomOut} from "../menus/protyle";
|
|
import {zoomOut} from "../menus/protyle";
|
|
import {countBlockWord, countSelectWord} from "../layout/status";
|
|
import {countBlockWord, countSelectWord} from "../layout/status";
|
|
import {showMessage} from "../dialog/message";
|
|
import {showMessage} from "../dialog/message";
|
|
-import {getSearch} from "../util/functions";
|
|
|
|
|
|
+import {getSearch, objEquals} from "../util/functions";
|
|
import {resize} from "../protyle/util/resize";
|
|
import {resize} from "../protyle/util/resize";
|
|
|
|
+import {newCardModel} from "../card/newCardTab";
|
|
|
|
+import {Search} from "../search";
|
|
|
|
|
|
export const openFileById = async (options: {
|
|
export const openFileById = async (options: {
|
|
id: string,
|
|
id: string,
|
|
@@ -74,7 +76,7 @@ export const openAsset = (assetPath: string, page: number | string, position?: s
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
|
|
-const openFile = (options: IOpenFileOptions) => {
|
|
|
|
|
|
+export const openFile = (options: IOpenFileOptions) => {
|
|
const allModels = getAllModels();
|
|
const allModels = getAllModels();
|
|
// 文档已打开
|
|
// 文档已打开
|
|
if (options.assetPath) {
|
|
if (options.assetPath) {
|
|
@@ -94,6 +96,32 @@ const openFile = (options: IOpenFileOptions) => {
|
|
}
|
|
}
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ } else if (options.customData) {
|
|
|
|
+ const custom = allModels.custom.find((item) => {
|
|
|
|
+ if (objEquals(item.data, options.customData)) {
|
|
|
|
+ if (!pdfIsLoading(item.parent.parent.element)) {
|
|
|
|
+ item.parent.parent.switchTab(item.parent.headElement);
|
|
|
|
+ item.parent.parent.showHeading();
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ if (custom) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ } else if (options.searchData) {
|
|
|
|
+ const search = allModels.search.find((item) => {
|
|
|
|
+ if (objEquals(item.config, options.searchData)) {
|
|
|
|
+ if (!pdfIsLoading(item.parent.parent.element)) {
|
|
|
|
+ item.parent.parent.switchTab(item.parent.headElement);
|
|
|
|
+ item.parent.parent.showHeading();
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ if (search) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
} else if (!options.position) {
|
|
} else if (!options.position) {
|
|
let editor: Editor;
|
|
let editor: Editor;
|
|
let activeEditor: Editor;
|
|
let activeEditor: Editor;
|
|
@@ -347,15 +375,39 @@ const newTab = (options: IOpenFileOptions) => {
|
|
icon,
|
|
icon,
|
|
title: getDisplayName(options.assetPath),
|
|
title: getDisplayName(options.assetPath),
|
|
callback(tab) {
|
|
callback(tab) {
|
|
- const asset = new Asset({
|
|
|
|
|
|
+ tab.addModel(new Asset({
|
|
tab,
|
|
tab,
|
|
path: options.assetPath,
|
|
path: options.assetPath,
|
|
page: options.page,
|
|
page: options.page,
|
|
- });
|
|
|
|
- tab.addModel(asset);
|
|
|
|
|
|
+ }));
|
|
|
|
+ setPanelFocus(tab.panelElement.parentElement.parentElement);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+ } else if (options.customData) {
|
|
|
|
+ tab = new Tab({
|
|
|
|
+ icon: "iconRiffCard",
|
|
|
|
+ title: window.siyuan.languages.spaceRepetition,
|
|
|
|
+ callback(tab) {
|
|
|
|
+ tab.addModel(newCardModel({
|
|
|
|
+ tab,
|
|
|
|
+ data: options.customData
|
|
|
|
+ }));
|
|
|
|
+ setPanelFocus(tab.panelElement.parentElement.parentElement);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } else if (options.searchData) {
|
|
|
|
+ tab = new Tab({
|
|
|
|
+ icon: "iconSearch",
|
|
|
|
+ title: window.siyuan.languages.search,
|
|
|
|
+ callback(tab) {
|
|
|
|
+ tab.addModel(new Search({
|
|
|
|
+ tab,
|
|
|
|
+ config: options.searchData
|
|
|
|
+ }));
|
|
|
|
+ setPanelFocus(tab.panelElement.parentElement.parentElement);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
} else {
|
|
} else {
|
|
tab = new Tab({
|
|
tab = new Tab({
|
|
title: getDisplayName(options.fileName, true, true),
|
|
title: getDisplayName(options.fileName, true, true),
|