mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 08:30:12 +01:00
This commit is contained in:
parent
5047d414e3
commit
b2e72fd9ab
34 changed files with 645 additions and 365 deletions
|
|
@ -1,4 +1,15 @@
|
||||||
{
|
{
|
||||||
|
"goToTab1": "Go to tab #1",
|
||||||
|
"goToTab2": "Go to tab #2",
|
||||||
|
"goToTab3": "Go to tab #3",
|
||||||
|
"goToTab4": "Go to tab #4",
|
||||||
|
"goToTab5": "Go to tab #5",
|
||||||
|
"goToTab6": "Go to tab #6",
|
||||||
|
"goToTab7": "Go to tab #7",
|
||||||
|
"goToTab8": "Go to tab #8",
|
||||||
|
"goToTab9": "Go to last tab",
|
||||||
|
"goToTabNext": "Go to next tab",
|
||||||
|
"goToTabPrev": "Go to previous tab",
|
||||||
"createdTime": "Created time",
|
"createdTime": "Created time",
|
||||||
"updatedTime": "Updated time",
|
"updatedTime": "Updated time",
|
||||||
"removeBookmark": "Remove bookmark from ${x}?",
|
"removeBookmark": "Remove bookmark from ${x}?",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,15 @@
|
||||||
{
|
{
|
||||||
|
"goToTab1": "Ir a la pestaña #1",
|
||||||
|
"goToTab2": "Ir a la pestaña #2",
|
||||||
|
"goToTab3": "Ir a la pestaña #3",
|
||||||
|
"goToTab4": "Ir a la pestaña #4",
|
||||||
|
"goToTab5": "Ir a la pestaña #5",
|
||||||
|
"goToTab6": "Ir a la pestaña #6",
|
||||||
|
"goToTab7": "Ir a la pestaña #7",
|
||||||
|
"goToTab8": "Ir a la pestaña #8",
|
||||||
|
"goToTab9": "Ir a la última pestaña",
|
||||||
|
"goToTabNext": "Ir a la siguiente pestaña",
|
||||||
|
"goToTabPrev": "Ir a la pestaña anterior",
|
||||||
"createdTime": "Hora de creación",
|
"createdTime": "Hora de creación",
|
||||||
"updatedTime": "Hora actualizada",
|
"updatedTime": "Hora actualizada",
|
||||||
"removeBookmark": "¿Eliminar marcador de ${x}?",
|
"removeBookmark": "¿Eliminar marcador de ${x}?",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,15 @@
|
||||||
{
|
{
|
||||||
|
"goToTab1": "Aller à l'onglet #1",
|
||||||
|
"goToTab2": "Aller à l'onglet #2",
|
||||||
|
"goToTab3": "Aller à l'onglet #3",
|
||||||
|
"goToTab4": "Aller à l'onglet #4",
|
||||||
|
"goToTab5": "Aller à l'onglet #5",
|
||||||
|
"goToTab6": "Aller à l'onglet #6",
|
||||||
|
"goToTab7": "Aller à l'onglet #7",
|
||||||
|
"goToTab8": "Aller à l'onglet #8",
|
||||||
|
"goToTab9": "Aller au dernier onglet",
|
||||||
|
"goToTabNext": "Aller à l'onglet suivant",
|
||||||
|
"goToTabPrev": "Aller à l'onglet précédent",
|
||||||
"createdTime": "Heure de création",
|
"createdTime": "Heure de création",
|
||||||
"updatedTime": "Heure mise à jour",
|
"updatedTime": "Heure mise à jour",
|
||||||
"removeBookmark": "Supprimer le signet de ${x} ?",
|
"removeBookmark": "Supprimer le signet de ${x} ?",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,15 @@
|
||||||
{
|
{
|
||||||
|
"goToTab1": "跳到第一個頁籤",
|
||||||
|
"goToTab2": "跳到第二個頁籤",
|
||||||
|
"goToTab3": "跳到第三個頁籤",
|
||||||
|
"goToTab4": "跳到第四個頁籤",
|
||||||
|
"goToTab5": "跳到第五個頁籤",
|
||||||
|
"goToTab6": "跳到第六個頁籤",
|
||||||
|
"goToTab7": "跳到第七個頁籤",
|
||||||
|
"goToTab8": "跳到第八個頁籤",
|
||||||
|
"goToTab9": "跳到最後一個頁籤",
|
||||||
|
"goToTabNext": "跳到下一個頁籤",
|
||||||
|
"goToTabPrev": "跳到上一個頁籤",
|
||||||
"createdTime": "建立時間",
|
"createdTime": "建立時間",
|
||||||
"updatedTime": "更新時間",
|
"updatedTime": "更新時間",
|
||||||
"removeBookmark": "移除 ${x} 中的書籤?",
|
"removeBookmark": "移除 ${x} 中的書籤?",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,15 @@
|
||||||
{
|
{
|
||||||
|
"goToTab1": "跳转到第一个页签",
|
||||||
|
"goToTab2": "跳转到第二个页签",
|
||||||
|
"goToTab3": "跳转到第三个页签",
|
||||||
|
"goToTab4": "跳转到第四个页签",
|
||||||
|
"goToTab5": "跳转到第五个页签",
|
||||||
|
"goToTab6": "跳转到第六个页签",
|
||||||
|
"goToTab7": "跳转到第七个页签",
|
||||||
|
"goToTab8": "跳转到第八个页签",
|
||||||
|
"goToTab9": "跳转到最后一个页签",
|
||||||
|
"goToTabNext": "跳转到下一个页签",
|
||||||
|
"goToTabPrev": "跳转到上一个页签",
|
||||||
"createdTime": "创建时间",
|
"createdTime": "创建时间",
|
||||||
"updatedTime": "更新时间",
|
"updatedTime": "更新时间",
|
||||||
"removeBookmark": "移除 ${x} 中的书签?",
|
"removeBookmark": "移除 ${x} 中的书签?",
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,9 @@ import {
|
||||||
import {newFile} from "../../util/newFile";
|
import {newFile} from "../../util/newFile";
|
||||||
import {Constants} from "../../constants";
|
import {Constants} from "../../constants";
|
||||||
import {openSetting} from "../../config";
|
import {openSetting} from "../../config";
|
||||||
import {copyTab, getDockByType, getInstanceById, resizeTabs} from "../../layout/util";
|
import {getInstanceById} from "../../layout/util";
|
||||||
|
import {closeTabByType, copyTab, getDockByType, resizeTabs, switchTabByIndex} from "../../layout/tabUtil";
|
||||||
|
import {getActiveTab} from "../../layout/tabUtil";
|
||||||
import {Tab} from "../../layout/Tab";
|
import {Tab} from "../../layout/Tab";
|
||||||
import {Editor} from "../../editor";
|
import {Editor} from "../../editor";
|
||||||
import {setEditMode} from "../../protyle/util/setEditMode";
|
import {setEditMode} from "../../protyle/util/setEditMode";
|
||||||
|
|
@ -156,7 +158,6 @@ const dialogArrow = (app: App, element: HTMLElement, event: KeyboardEvent) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const editKeydown = (app: App, event: KeyboardEvent) => {
|
const editKeydown = (app: App, event: KeyboardEvent) => {
|
||||||
const activeTabElement = document.querySelector(".layout__wnd--active .item--focus");
|
|
||||||
let protyle: IProtyle;
|
let protyle: IProtyle;
|
||||||
let range: Range;
|
let range: Range;
|
||||||
if (getSelection().rangeCount > 0) {
|
if (getSelection().rangeCount > 0) {
|
||||||
|
|
@ -177,14 +178,14 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!protyle && activeTabElement) {
|
const activeTab = getActiveTab()
|
||||||
const tab = getInstanceById(activeTabElement.getAttribute("data-id")) as Tab;
|
if (!protyle && activeTab) {
|
||||||
if (tab.model instanceof Editor) {
|
if (activeTab.model instanceof Editor) {
|
||||||
protyle = tab.model.editor.protyle;
|
protyle = activeTab.model.editor.protyle;
|
||||||
} else if (tab.model instanceof Search) {
|
} else if (activeTab.model instanceof Search) {
|
||||||
protyle = tab.model.edit.protyle;
|
protyle = activeTab.model.edit.protyle;
|
||||||
} else if (tab.model instanceof Custom && tab.model.data?.editor instanceof Protyle) {
|
} else if (activeTab.model instanceof Custom && activeTab.model.data?.editor instanceof Protyle) {
|
||||||
protyle = tab.model.data.editor.protyle;
|
protyle = activeTab.model.data.editor.protyle;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1338,7 +1339,7 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
|
||||||
// close tab
|
// close tab
|
||||||
if (matchHotKey(window.siyuan.config.keymap.general.closeTab.custom, event) && !event.repeat) {
|
if (matchHotKey(window.siyuan.config.keymap.general.closeTab.custom, event) && !event.repeat) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
let activeTabElement = document.querySelector(".layout__tab--active");
|
const activeTabElement = document.querySelector(".layout__tab--active");
|
||||||
if (activeTabElement && activeTabElement.getBoundingClientRect().width > 0) {
|
if (activeTabElement && activeTabElement.getBoundingClientRect().width > 0) {
|
||||||
let type = "";
|
let type = "";
|
||||||
Array.from(activeTabElement.classList).find(item => {
|
Array.from(activeTabElement.classList).find(item => {
|
||||||
|
|
@ -1352,18 +1353,131 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
activeTabElement = document.querySelector(".layout__wnd--active .item--focus");
|
const tab = getActiveTab(false);
|
||||||
if (activeTabElement) {
|
if (tab) {
|
||||||
const tab = getInstanceById(activeTabElement.getAttribute("data-id")) as Tab;
|
|
||||||
tab.parent.removeTab(tab.id);
|
tab.parent.removeTab(tab.id);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
getAllTabs().find(item => {
|
return;
|
||||||
if (item.headElement?.classList.contains("item--focus")) {
|
}
|
||||||
item.parent.removeTab(item.id);
|
|
||||||
return true;
|
if (matchHotKey(window.siyuan.config.keymap.general.goToTab1.custom, event) && !event.repeat) {
|
||||||
|
switchTabByIndex(0);
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matchHotKey(window.siyuan.config.keymap.general.goToTab2.custom, event) && !event.repeat) {
|
||||||
|
switchTabByIndex(1);
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (matchHotKey(window.siyuan.config.keymap.general.goToTab3.custom, event) && !event.repeat) {
|
||||||
|
switchTabByIndex(2);
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (matchHotKey(window.siyuan.config.keymap.general.goToTab4.custom, event) && !event.repeat) {
|
||||||
|
switchTabByIndex(3);
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (matchHotKey(window.siyuan.config.keymap.general.goToTab5.custom, event) && !event.repeat) {
|
||||||
|
switchTabByIndex(4);
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (matchHotKey(window.siyuan.config.keymap.general.goToTab6.custom, event) && !event.repeat) {
|
||||||
|
switchTabByIndex(5);
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (matchHotKey(window.siyuan.config.keymap.general.goToTab7.custom, event) && !event.repeat) {
|
||||||
|
switchTabByIndex(6);
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (matchHotKey(window.siyuan.config.keymap.general.goToTab8.custom, event) && !event.repeat) {
|
||||||
|
switchTabByIndex(7);
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (matchHotKey(window.siyuan.config.keymap.general.goToTab9.custom, event) && !event.repeat) {
|
||||||
|
switchTabByIndex(-1);
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (matchHotKey(window.siyuan.config.keymap.general.goToTabNext.custom, event) && !event.repeat) {
|
||||||
|
switchTabByIndex(-3);
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (matchHotKey(window.siyuan.config.keymap.general.goToTabPrev.custom, event) && !event.repeat) {
|
||||||
|
switchTabByIndex(-2);
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (matchHotKey(window.siyuan.config.keymap.general.closeOthers.custom, event) && !event.repeat) {
|
||||||
|
const tab = getActiveTab();
|
||||||
|
if (tab) {
|
||||||
|
closeTabByType(tab, "closeOthers");
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (matchHotKey(window.siyuan.config.keymap.general.closeAll.custom, event) && !event.repeat) {
|
||||||
|
const tab = getActiveTab();
|
||||||
|
if (tab) {
|
||||||
|
closeTabByType(tab, "closeAll");
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (matchHotKey(window.siyuan.config.keymap.general.closeUnmodified.custom, event) && !event.repeat) {
|
||||||
|
const tab = getActiveTab();
|
||||||
|
if (tab) {
|
||||||
|
const unmodifiedTabs: Tab[] = []
|
||||||
|
tab.parent.children.forEach((item: Tab) => {
|
||||||
|
const editor = item.model as Editor;
|
||||||
|
if (!editor || (editor.editor?.protyle && !editor.editor?.protyle.updated)) {
|
||||||
|
unmodifiedTabs.push(item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (unmodifiedTabs.length > 0) {
|
||||||
|
closeTabByType(tab, "other", unmodifiedTabs);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((matchHotKey(window.siyuan.config.keymap.general.closeLeft.custom, event) || matchHotKey(window.siyuan.config.keymap.general.closeRight.custom, event)) &&
|
||||||
|
!event.repeat) {
|
||||||
|
const tab = getActiveTab();
|
||||||
|
if (tab) {
|
||||||
|
const leftTabs: Tab[] = [];
|
||||||
|
const rightTabs: Tab[] = [];
|
||||||
|
let midIndex = -1;
|
||||||
|
tab.parent.children.forEach((item: Tab, index: number) => {
|
||||||
|
const editor = item.model as Editor;
|
||||||
|
if (item.id === tab.id) {
|
||||||
|
midIndex = index;
|
||||||
|
}
|
||||||
|
if (midIndex === -1) {
|
||||||
|
leftTabs.push(item);
|
||||||
|
} else if (index > midIndex) {
|
||||||
|
rightTabs.push(item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (matchHotKey(window.siyuan.config.keymap.general.closeLeft.custom, event)) {
|
||||||
|
if (leftTabs.length > 0) {
|
||||||
|
closeTabByType(tab, "other", leftTabs);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (rightTabs.length > 0) {
|
||||||
|
closeTabByType(tab, "other", rightTabs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1372,21 +1486,18 @@ export const windowKeyDown = (app: App, event: KeyboardEvent) => {
|
||||||
matchHotKey(window.siyuan.config.keymap.general.splitTB.custom, event) ||
|
matchHotKey(window.siyuan.config.keymap.general.splitTB.custom, event) ||
|
||||||
matchHotKey(window.siyuan.config.keymap.general.splitMoveB.custom, event)) && !event.repeat) {
|
matchHotKey(window.siyuan.config.keymap.general.splitMoveB.custom, event)) && !event.repeat) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const activeTabElement = document.querySelector(".layout__wnd--active .item--focus");
|
const tab = getActiveTab(false);
|
||||||
if (activeTabElement) {
|
if (tab) {
|
||||||
const tab = getInstanceById(activeTabElement.getAttribute("data-id")) as Tab;
|
if (matchHotKey(window.siyuan.config.keymap.general.splitLR.custom, event)) {
|
||||||
if (tab) {
|
tab.parent.split("lr").addTab(copyTab(app, tab));
|
||||||
if (matchHotKey(window.siyuan.config.keymap.general.splitLR.custom, event)) {
|
} else if (matchHotKey(window.siyuan.config.keymap.general.splitTB.custom, event)) {
|
||||||
tab.parent.split("lr").addTab(copyTab(app, tab));
|
tab.parent.split("tb").addTab(copyTab(app, tab));
|
||||||
} else if (matchHotKey(window.siyuan.config.keymap.general.splitTB.custom, event)) {
|
} else if (tab.parent.children.length > 1) {
|
||||||
tab.parent.split("tb").addTab(copyTab(app, tab));
|
const newWnd = tab.parent.split(matchHotKey(window.siyuan.config.keymap.general.splitMoveB.custom, event) ? "tb" : "lr");
|
||||||
} else if (tab.parent.children.length > 1) {
|
newWnd.headersElement.append(tab.headElement);
|
||||||
const newWnd = tab.parent.split(matchHotKey(window.siyuan.config.keymap.general.splitMoveB.custom, event) ? "tb" : "lr");
|
newWnd.headersElement.parentElement.classList.remove("fn__none");
|
||||||
newWnd.headersElement.append(tab.headElement);
|
newWnd.moveTab(tab);
|
||||||
newWnd.headersElement.parentElement.classList.remove("fn__none");
|
resizeTabs();
|
||||||
newWnd.moveTab(tab);
|
|
||||||
resizeTabs();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import {fetchPost} from "../../util/fetch";
|
import {fetchPost} from "../../util/fetch";
|
||||||
import {escapeHtml} from "../../util/escape";
|
import {escapeHtml} from "../../util/escape";
|
||||||
import {openCard} from "../../card/openCard";
|
import {openCard} from "../../card/openCard";
|
||||||
import {getDockByType} from "../../layout/util";
|
import {getDockByType} from "../../layout/tabUtil";
|
||||||
import {getAllTabs} from "../../layout/getAll";
|
import {getAllTabs} from "../../layout/getAll";
|
||||||
import {App} from "../../index";
|
import {App} from "../../index";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import {exportLayout, JSONToLayout, resetLayout, resizeTopbar, resizeTabs} from "../layout/util";
|
import {exportLayout, JSONToLayout, resetLayout, resizeTopBar} from "../layout/util";
|
||||||
|
import {resizeTabs} from "../layout/tabUtil";
|
||||||
import {setStorageVal} from "../protyle/util/compatibility";
|
import {setStorageVal} from "../protyle/util/compatibility";
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
import {ipcRenderer, webFrame} from "electron";
|
import {ipcRenderer, webFrame} from "electron";
|
||||||
|
|
@ -146,7 +147,7 @@ export const onGetConfig = (isStart: boolean, app: App) => {
|
||||||
window.clearTimeout(resizeTimeout);
|
window.clearTimeout(resizeTimeout);
|
||||||
resizeTimeout = window.setTimeout(() => {
|
resizeTimeout = window.setTimeout(() => {
|
||||||
resizeTabs();
|
resizeTabs();
|
||||||
resizeTopbar();
|
resizeTopBar();
|
||||||
}, 200);
|
}, 200);
|
||||||
});
|
});
|
||||||
addGA();
|
addGA();
|
||||||
|
|
|
||||||
|
|
@ -382,7 +382,7 @@ export const keymap = {
|
||||||
}
|
}
|
||||||
let hasConflict = false;
|
let hasConflict = false;
|
||||||
if (["⌘", "⇧", "⌥", "⌃"].includes(keymapStr.substr(keymapStr.length - 1, 1)) ||
|
if (["⌘", "⇧", "⌥", "⌃"].includes(keymapStr.substr(keymapStr.length - 1, 1)) ||
|
||||||
["⌘A", "⌘X", "⌘C", "⌘V", "⌘-", "⌘=", "⌘0", "⇧⌘V", "⌘/", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⇧⌘⇥", "⌃⇥", "⌘⇥", "⌃⌘⇥", "⇧⌘→", "⇧⌘←", "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦"].includes(keymapStr)) {
|
["⌘A", "⌘X", "⌘C", "⌘V", "⌘-", "⌘=", "⌘0", "⇧⌘V", "⌘/", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⌃⇧⇥", "⌃⇥", "⌘⇥", "⇧⌘⇥", "⇧⌘→", "⇧⌘←", "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦"].includes(keymapStr)) {
|
||||||
showMessage(`${window.siyuan.languages.invalid} [${adoptKeymapStr}]`);
|
showMessage(`${window.siyuan.languages.invalid} [${adoptKeymapStr}]`);
|
||||||
hasConflict = true;
|
hasConflict = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -221,7 +221,7 @@ export abstract class Constants {
|
||||||
};
|
};
|
||||||
// 冲突不使用 "⌘S/Q"
|
// 冲突不使用 "⌘S/Q"
|
||||||
// "⌘", "⇧", "⌥", "⌃"
|
// "⌘", "⇧", "⌥", "⌃"
|
||||||
// "⌘A", "⌘X", "⌘C", "⌘V", "⌘-", "⌘=", "⌘0", "⇧⌘V", "⌘/", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⇧⌘⇥", "⌃⇥", "⌘⇥", "⌃⌘⇥", "⇧⌘→", "⇧⌘←",
|
// "⌘A", "⌘X", "⌘C", "⌘V", "⌘-", "⌘=", "⌘0", "⇧⌘V", "⌘/", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⌃⇧⇥", "⌃⇥", "⌘⇥", "⇧⌘⇥", "⇧⌘→", "⇧⌘←",
|
||||||
// "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦" 不可自定义
|
// "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦" 不可自定义
|
||||||
public static readonly SIYUAN_KEYMAP: IKeymap = {
|
public static readonly SIYUAN_KEYMAP: IKeymap = {
|
||||||
general: {
|
general: {
|
||||||
|
|
@ -254,6 +254,17 @@ export abstract class Constants {
|
||||||
toggleWin: {default: "⌥M", custom: "⌥M"},
|
toggleWin: {default: "⌥M", custom: "⌥M"},
|
||||||
lockScreen: {default: "⌥N", custom: "⌥N"},
|
lockScreen: {default: "⌥N", custom: "⌥N"},
|
||||||
recentDocs: {default: "⌘E", custom: "⌘E"},
|
recentDocs: {default: "⌘E", custom: "⌘E"},
|
||||||
|
goToTab1: {default: "⌘1", custom: "⌘1"},
|
||||||
|
goToTab2: {default: "⌘2", custom: "⌘2"},
|
||||||
|
goToTab3: {default: "⌘3", custom: "⌘3"},
|
||||||
|
goToTab4: {default: "⌘4", custom: "⌘4"},
|
||||||
|
goToTab5: {default: "⌘5", custom: "⌘5"},
|
||||||
|
goToTab6: {default: "⌘6", custom: "⌘6"},
|
||||||
|
goToTab7: {default: "⌘7", custom: "⌘7"},
|
||||||
|
goToTab8: {default: "⌘8", custom: "⌘8"},
|
||||||
|
goToTab9: {default: "⌘9", custom: "⌘9"},
|
||||||
|
goToTabNext: {default: "⇧⌘]", custom: "⇧⌘]"},
|
||||||
|
goToTabPrev: {default: "⇧⌘[", custom: "⇧⌘["},
|
||||||
move: {default: "", custom: ""},
|
move: {default: "", custom: ""},
|
||||||
selectOpen1: {default: "", custom: ""},
|
selectOpen1: {default: "", custom: ""},
|
||||||
toggleDock: {default: "", custom: ""},
|
toggleDock: {default: "", custom: ""},
|
||||||
|
|
@ -261,6 +272,11 @@ export abstract class Constants {
|
||||||
splitMoveR: {default: "", custom: ""},
|
splitMoveR: {default: "", custom: ""},
|
||||||
splitTB: {default: "", custom: ""},
|
splitTB: {default: "", custom: ""},
|
||||||
splitMoveB: {default: "", custom: ""},
|
splitMoveB: {default: "", custom: ""},
|
||||||
|
closeOthers: {default: "", custom: ""},
|
||||||
|
closeAll: {default: "", custom: ""},
|
||||||
|
closeUnmodified: {default: "", custom: ""},
|
||||||
|
closeLeft: {default: "", custom: ""},
|
||||||
|
closeRight: {default: "", custom: ""},
|
||||||
},
|
},
|
||||||
editor: {
|
editor: {
|
||||||
general: {
|
general: {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
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, setPanelFocus} from "../layout/util";
|
import {getInstanceById, getWndByLayout, pdfIsLoading, setPanelFocus} from "../layout/util";
|
||||||
|
import {getDockByType} from "../layout/tabUtil";
|
||||||
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, showFileInFolder} from "../util/pathName";
|
import {getDisplayName, pathPosix, showFileInFolder} from "../util/pathName";
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
import {Files} from "../layout/dock/Files";
|
import {Files} from "../layout/dock/Files";
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
import {getDockByType} from "../layout/util";
|
import {getDockByType} from "../layout/tabUtil";
|
||||||
import {getAllModels} from "../layout/getAll";
|
import {getAllModels} from "../layout/getAll";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {setNoteBook} from "../util/pathName";
|
import {setNoteBook} from "../util/pathName";
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,7 @@ import {genUUID} from "../util/genID";
|
||||||
import {
|
import {
|
||||||
getInstanceById,
|
getInstanceById,
|
||||||
getWndByLayout, JSONToCenter,
|
getWndByLayout, JSONToCenter,
|
||||||
newCenterEmptyTab, newModelByInitData, pdfIsLoading,
|
newModelByInitData, pdfIsLoading,
|
||||||
resizeTabs,
|
|
||||||
setPanelFocus,
|
setPanelFocus,
|
||||||
switchWnd
|
switchWnd
|
||||||
} from "./util";
|
} from "./util";
|
||||||
|
|
@ -37,6 +36,7 @@ import {App} from "../index";
|
||||||
import {unicode2Emoji} from "../emoji";
|
import {unicode2Emoji} from "../emoji";
|
||||||
import {closeWindow} from "../window/closeWin";
|
import {closeWindow} from "../window/closeWin";
|
||||||
import {setTitle} from "../dialog/processSystem";
|
import {setTitle} from "../dialog/processSystem";
|
||||||
|
import {newCenterEmptyTab, resizeTabs} from "./tabUtil";
|
||||||
|
|
||||||
export class Wnd {
|
export class Wnd {
|
||||||
private app: App;
|
private app: App;
|
||||||
|
|
@ -745,6 +745,7 @@ export class Wnd {
|
||||||
});
|
});
|
||||||
if (latestHeadElement && !closeAll) {
|
if (latestHeadElement && !closeAll) {
|
||||||
this.switchTab(latestHeadElement, true, true, false);
|
this.switchTab(latestHeadElement, true, true, false);
|
||||||
|
this.showHeading();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (animate) {
|
if (animate) {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import {Tab} from "../Tab";
|
import {Tab} from "../Tab";
|
||||||
import {Model} from "../Model";
|
import {Model} from "../Model";
|
||||||
import {Tree} from "../../util/Tree";
|
import {Tree} from "../../util/Tree";
|
||||||
import {getDockByType, setPanelFocus} from "../util";
|
import {setPanelFocus} from "../util";
|
||||||
|
import {getDockByType} from "../tabUtil";
|
||||||
import {fetchPost} from "../../util/fetch";
|
import {fetchPost} from "../../util/fetch";
|
||||||
import {Constants} from "../../constants";
|
import {Constants} from "../../constants";
|
||||||
import {updateHotkeyTip} from "../../protyle/util/compatibility";
|
import {updateHotkeyTip} from "../../protyle/util/compatibility";
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import {Tab} from "../Tab";
|
import {Tab} from "../Tab";
|
||||||
import {Model} from "../Model";
|
import {Model} from "../Model";
|
||||||
import {Tree} from "../../util/Tree";
|
import {Tree} from "../../util/Tree";
|
||||||
import {getDockByType, setPanelFocus} from "../util";
|
import {setPanelFocus} from "../util";
|
||||||
|
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 {openFileById} from "../../editor/util";
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import {escapeHtml} from "../../util/escape";
|
import {escapeHtml} from "../../util/escape";
|
||||||
import {Tab} from "../Tab";
|
import {Tab} from "../Tab";
|
||||||
import {Model} from "../Model";
|
import {Model} from "../Model";
|
||||||
import {getDockByType, getInstanceById, setPanelFocus} from "../util";
|
import {getInstanceById, setPanelFocus} from "../util";
|
||||||
|
import {getDockByType} from "../tabUtil";
|
||||||
import {Constants} from "../../constants";
|
import {Constants} from "../../constants";
|
||||||
import {getDisplayName, pathPosix, setNoteBook} from "../../util/pathName";
|
import {getDisplayName, pathPosix, setNoteBook} from "../../util/pathName";
|
||||||
import {newFile} from "../../util/newFile";
|
import {newFile} from "../../util/newFile";
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import {Tab} from "../Tab";
|
import {Tab} from "../Tab";
|
||||||
import {getDockByType, setPanelFocus} from "../util";
|
import {setPanelFocus} from "../util";
|
||||||
|
import {getDockByType} from "../tabUtil";
|
||||||
import {Model} from "../Model";
|
import {Model} from "../Model";
|
||||||
import {Constants} from "../../constants";
|
import {Constants} from "../../constants";
|
||||||
import {addScript} from "../../protyle/util/addScript";
|
import {addScript} from "../../protyle/util/addScript";
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
import {Tab} from "../Tab";
|
import {Tab} from "../Tab";
|
||||||
import {getDockByType, setPanelFocus} from "../util";
|
import {setPanelFocus} from "../util";
|
||||||
|
import {getDockByType} from "../tabUtil";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {fetchPost} from "../../util/fetch";
|
import {fetchPost} from "../../util/fetch";
|
||||||
import {updateHotkeyTip} from "../../protyle/util/compatibility";
|
import {updateHotkeyTip} from "../../protyle/util/compatibility";
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import {Tab} from "../Tab";
|
import {Tab} from "../Tab";
|
||||||
import {Model} from "../Model";
|
import {Model} from "../Model";
|
||||||
import {Tree} from "../../util/Tree";
|
import {Tree} from "../../util/Tree";
|
||||||
import {getDockByType, getInstanceById, setPanelFocus} from "../util";
|
import {getInstanceById, setPanelFocus} from "../util";
|
||||||
|
import {getDockByType} from "../tabUtil";
|
||||||
import {fetchPost} from "../../util/fetch";
|
import {fetchPost} from "../../util/fetch";
|
||||||
import {getAllModels} from "../getAll";
|
import {getAllModels} from "../getAll";
|
||||||
import {hasClosestBlock, hasClosestByClassName, hasTopClosestByClassName} from "../../protyle/util/hasClosest";
|
import {hasClosestBlock, hasClosestByClassName, hasTopClosestByClassName} from "../../protyle/util/hasClosest";
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import {Tab} from "../Tab";
|
import {Tab} from "../Tab";
|
||||||
import {Model} from "../Model";
|
import {Model} from "../Model";
|
||||||
import {Tree} from "../../util/Tree";
|
import {Tree} from "../../util/Tree";
|
||||||
import {getDockByType, setPanelFocus} from "../util";
|
import {setPanelFocus} from "../util";
|
||||||
|
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 {openGlobalSearch} from "../../search/util";
|
import {openGlobalSearch} from "../../search/util";
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@ import {Bookmark} from "./Bookmark";
|
||||||
import {Tag} from "./Tag";
|
import {Tag} from "./Tag";
|
||||||
import {Graph} from "./Graph";
|
import {Graph} from "./Graph";
|
||||||
import {Model} from "../Model";
|
import {Model} from "../Model";
|
||||||
import {getDockByType, resizeTabs, setPanelFocus} from "../util";
|
import {setPanelFocus} from "../util";
|
||||||
|
import {getDockByType, resizeTabs} from "../tabUtil";
|
||||||
import {Inbox} from "./Inbox";
|
import {Inbox} from "./Inbox";
|
||||||
import {Protyle} from "../../protyle";
|
import {Protyle} from "../../protyle";
|
||||||
import {Backlink} from "./Backlink";
|
import {Backlink} from "./Backlink";
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ import {getAllModels} from "../getAll";
|
||||||
import {Tab} from "../Tab";
|
import {Tab} from "../Tab";
|
||||||
import {Graph} from "./Graph";
|
import {Graph} from "./Graph";
|
||||||
import {Outline} from "./Outline";
|
import {Outline} from "./Outline";
|
||||||
import {getInstanceById, getWndByLayout, resizeTabs, switchWnd} from "../util";
|
import {getInstanceById, getWndByLayout, switchWnd} from "../util";
|
||||||
|
import {resizeTabs} from "../tabUtil";
|
||||||
import {Backlink} from "./Backlink";
|
import {Backlink} from "./Backlink";
|
||||||
import {App} from "../../index";
|
import {App} from "../../index";
|
||||||
import {Wnd} from "../Wnd";
|
import {Wnd} from "../Wnd";
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import {Wnd} from "./Wnd";
|
import {Wnd} from "./Wnd";
|
||||||
import {genUUID} from "../util/genID";
|
import {genUUID} from "../util/genID";
|
||||||
import {addResize, resizeTabs} from "./util";
|
import {addResize} from "./util";
|
||||||
|
import {resizeTabs} from "./tabUtil";
|
||||||
/// #if MOBILE
|
/// #if MOBILE
|
||||||
// 检测移动端是否引入了桌面端的代码
|
// 检测移动端是否引入了桌面端的代码
|
||||||
console.error("Need remove unused code");
|
console.error("Need remove unused code");
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
import {getDockByType} from "./util";
|
import {getDockByType} from "./tabUtil";
|
||||||
import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
import {hasClosestByClassName} from "../protyle/util/hasClosest";
|
||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost} from "../util/fetch";
|
||||||
import {mountHelp} from "../util/mount";
|
import {mountHelp} from "../util/mount";
|
||||||
|
|
|
||||||
364
app/src/layout/tabUtil.ts
Normal file
364
app/src/layout/tabUtil.ts
Normal file
|
|
@ -0,0 +1,364 @@
|
||||||
|
import {Tab} from "./Tab";
|
||||||
|
import {getInstanceById, newModelByInitData} from "./util";
|
||||||
|
import {getAllModels, getAllTabs} from "./getAll";
|
||||||
|
import {hideAllElements, hideElements} from "../protyle/ui/hideElements";
|
||||||
|
import {pdfResize} from "../asset/renderAssets";
|
||||||
|
import {App} from "../index";
|
||||||
|
import {Model} from "./Model";
|
||||||
|
import {Editor} from "../editor";
|
||||||
|
import {saveScroll} from "../protyle/scroll/saveScroll";
|
||||||
|
import {Asset} from "../asset";
|
||||||
|
import {Graph} from "./dock/Graph";
|
||||||
|
import {Files} from "./dock/Files";
|
||||||
|
import {Outline} from "./dock/Outline";
|
||||||
|
import {Backlink} from "./dock/Backlink";
|
||||||
|
import {Bookmark} from "./dock/Bookmark";
|
||||||
|
import {Tag} from "./dock/Tag";
|
||||||
|
import {Search} from "../search";
|
||||||
|
import {Custom} from "./dock/Custom";
|
||||||
|
import {newCardModel} from "../card/newCardTab";
|
||||||
|
import {updateHotkeyTip} from "../protyle/util/compatibility";
|
||||||
|
import {openSearch} from "../search/spread";
|
||||||
|
import {openRecentDocs} from "../business/openRecentDocs";
|
||||||
|
import {openHistory} from "../history/history";
|
||||||
|
import {newFile} from "../util/newFile";
|
||||||
|
import {mountHelp, newNotebook} from "../util/mount";
|
||||||
|
|
||||||
|
export const getActiveTab = (wndActive = true) => {
|
||||||
|
const activeTabElement = document.querySelector(".layout__wnd--active .item--focus");
|
||||||
|
let tab;
|
||||||
|
if (activeTabElement) {
|
||||||
|
tab = getInstanceById(activeTabElement.getAttribute("data-id")) as Tab;
|
||||||
|
}
|
||||||
|
if (!tab && !wndActive) {
|
||||||
|
getAllTabs().find(item => {
|
||||||
|
if (item.headElement?.classList.contains("item--focus")) {
|
||||||
|
tab = item;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return tab;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const switchTabByIndex = (index: number) => {
|
||||||
|
const activeDockIcoElement = document.querySelector(".dock .dock__item--activefocus");
|
||||||
|
if (activeDockIcoElement) {
|
||||||
|
let indexElement = activeDockIcoElement.parentElement.children[index]
|
||||||
|
if (index === -1) {
|
||||||
|
// 最后一个
|
||||||
|
indexElement = activeDockIcoElement.parentElement.lastElementChild
|
||||||
|
if (!indexElement.getAttribute("data-type")) {
|
||||||
|
indexElement = indexElement.previousElementSibling
|
||||||
|
}
|
||||||
|
} else if (index === -2) {
|
||||||
|
// 上一个
|
||||||
|
indexElement = activeDockIcoElement.previousElementSibling
|
||||||
|
} else if (index === -3) {
|
||||||
|
// 下一个
|
||||||
|
indexElement = activeDockIcoElement.nextElementSibling
|
||||||
|
}
|
||||||
|
const type = indexElement?.getAttribute("data-type")
|
||||||
|
if (type) {
|
||||||
|
getDockByType(type)?.toggleModel(type, true, false);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const tab = getActiveTab(false);
|
||||||
|
if (tab) {
|
||||||
|
let indexElement = tab.parent.headersElement.children[index]
|
||||||
|
if (index === -1) {
|
||||||
|
// 最后一个
|
||||||
|
indexElement = tab.parent.headersElement.lastElementChild
|
||||||
|
} else if (index === -2) {
|
||||||
|
// 上一个
|
||||||
|
indexElement = tab.headElement.previousElementSibling
|
||||||
|
} else if (index === -3) {
|
||||||
|
// 下一个
|
||||||
|
indexElement = tab.headElement.nextElementSibling
|
||||||
|
}
|
||||||
|
if (indexElement) {
|
||||||
|
tab.parent.switchTab(indexElement as HTMLElement, true);
|
||||||
|
tab.parent.showHeading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let resizeTimeout: number;
|
||||||
|
export const resizeTabs = () => {
|
||||||
|
clearTimeout(resizeTimeout);
|
||||||
|
// .layout .fn__flex-shrink {width .15s cubic-bezier(0, 0, .2, 1) 0ms} 时需要再次计算 padding
|
||||||
|
// PDF 避免分屏多次调用后,页码跳转到1 https://github.com/siyuan-note/siyuan/issues/5646
|
||||||
|
resizeTimeout = window.setTimeout(() => {
|
||||||
|
const models = getAllModels();
|
||||||
|
models.editor.forEach((item) => {
|
||||||
|
if (item.editor && item.editor.protyle &&
|
||||||
|
item.element.parentElement && !item.element.classList.contains("fn__none")) {
|
||||||
|
item.editor.resize();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// https://github.com/siyuan-note/siyuan/issues/6250
|
||||||
|
models.backlink.forEach(item => {
|
||||||
|
const mTreeElement = item.element.querySelector(".backlinkMList") as HTMLElement;
|
||||||
|
if (mTreeElement.style.height && mTreeElement.style.height !== "0px" && item.element.clientHeight !== 0) {
|
||||||
|
mTreeElement.style.height = (item.element.clientHeight - mTreeElement.previousElementSibling.clientHeight * 2) + "px";
|
||||||
|
}
|
||||||
|
item.editors.forEach(editorItem => {
|
||||||
|
hideElements(["gutter"], editorItem.protyle);
|
||||||
|
editorItem.resize();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
models.search.forEach(item => {
|
||||||
|
item.edit.resize();
|
||||||
|
});
|
||||||
|
models.custom.forEach(item => {
|
||||||
|
if (item.resize) {
|
||||||
|
item.resize();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
pdfResize();
|
||||||
|
hideAllElements(["gutter"]);
|
||||||
|
}, 200);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getDockByType = (type: string) => {
|
||||||
|
if (!window.siyuan.layout.leftDock) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
if (window.siyuan.layout.leftDock.data[type]) {
|
||||||
|
return window.siyuan.layout.leftDock;
|
||||||
|
}
|
||||||
|
if (window.siyuan.layout.rightDock.data[type]) {
|
||||||
|
return window.siyuan.layout.rightDock;
|
||||||
|
}
|
||||||
|
if (window.siyuan.layout.bottomDock.data[type]) {
|
||||||
|
return window.siyuan.layout.bottomDock;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const newCenterEmptyTab = (app: App) => {
|
||||||
|
return new Tab({
|
||||||
|
panel: `<div class="layout__empty b3-list">
|
||||||
|
<div class="${!window.siyuan.config.readonly ? " fn__none" : ""}">
|
||||||
|
<div class="config-about__logo">
|
||||||
|
<img src="/stage/icon.png">
|
||||||
|
${window.siyuan.languages.siyuanNote}
|
||||||
|
</div>
|
||||||
|
<div class="b3-label__text">${window.siyuan.languages.slogan}</div>
|
||||||
|
</div>
|
||||||
|
<div class="fn__hr"></div>
|
||||||
|
<div class="b3-list-item" id="editorEmptySearch">
|
||||||
|
<svg class="b3-list-item__graphic"><use xlink:href="#iconSearch"></use></svg>
|
||||||
|
<span>${window.siyuan.languages.search}</span>
|
||||||
|
<span class="b3-list-item__meta">${updateHotkeyTip(window.siyuan.config.keymap.general.globalSearch.custom)}</span>
|
||||||
|
</div>
|
||||||
|
<div id="editorEmptyRecent" class="b3-list-item">
|
||||||
|
<svg class="b3-list-item__graphic"><use xlink:href="#iconList"></use></svg>
|
||||||
|
<span>${window.siyuan.languages.recentDocs}</span>
|
||||||
|
<span class="b3-list-item__meta">${updateHotkeyTip(window.siyuan.config.keymap.general.recentDocs.custom)}</span>
|
||||||
|
</div>
|
||||||
|
<div id="editorEmptyHistory" class="b3-list-item${window.siyuan.config.readonly ? " fn__none" : ""}">
|
||||||
|
<svg class="b3-list-item__graphic"><use xlink:href="#iconHistory"></use></svg>
|
||||||
|
<span>${window.siyuan.languages.dataHistory}</span>
|
||||||
|
<span class="b3-list-item__meta">${updateHotkeyTip(window.siyuan.config.keymap.general.dataHistory.custom)}</span>
|
||||||
|
</div>
|
||||||
|
<div class="b3-list-item${window.siyuan.config.readonly ? " fn__none" : ""}" id="editorEmptyFile">
|
||||||
|
<svg class="b3-list-item__graphic"><use xlink:href="#iconFile"></use></svg>
|
||||||
|
<span>${window.siyuan.languages.newFile}</span>
|
||||||
|
<span class="b3-list-item__meta">${updateHotkeyTip(window.siyuan.config.keymap.general.newFile.custom)}</span>
|
||||||
|
</div>
|
||||||
|
<div class="b3-list-item${window.siyuan.config.readonly ? " fn__none" : ""}" id="editorEmptyNewNotebook">
|
||||||
|
<svg class="b3-list-item__graphic"><use xlink:href="#iconFilesRoot"></use></svg>
|
||||||
|
<span>${window.siyuan.languages.newNotebook}</span>
|
||||||
|
</div>
|
||||||
|
<div class="b3-list-item" id="editorEmptyHelp">
|
||||||
|
<svg class="b3-list-item__graphic"><use xlink:href="#iconHelp"></use></svg>
|
||||||
|
<span>${window.siyuan.languages.help}</span>
|
||||||
|
</div>
|
||||||
|
</div>`,
|
||||||
|
callback(tab: Tab) {
|
||||||
|
tab.panelElement.addEventListener("click", (event) => {
|
||||||
|
let target = event.target as HTMLElement;
|
||||||
|
while (target && !target.isEqualNode(tab.panelElement)) {
|
||||||
|
if (target.id === "editorEmptySearch") {
|
||||||
|
openSearch({
|
||||||
|
app,
|
||||||
|
hotkey: window.siyuan.config.keymap.general.globalSearch.custom,
|
||||||
|
});
|
||||||
|
event.stopPropagation();
|
||||||
|
event.preventDefault();
|
||||||
|
break;
|
||||||
|
} else if (target.id === "editorEmptyRecent") {
|
||||||
|
const openRecentDocsDialog = window.siyuan.dialogs.find(item => {
|
||||||
|
if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.recentDocs.custom) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (openRecentDocsDialog) {
|
||||||
|
hideElements(["dialog"]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
openRecentDocs();
|
||||||
|
event.stopPropagation();
|
||||||
|
event.preventDefault();
|
||||||
|
break;
|
||||||
|
} else if (target.id === "editorEmptyHistory") {
|
||||||
|
openHistory(app);
|
||||||
|
event.stopPropagation();
|
||||||
|
event.preventDefault();
|
||||||
|
break;
|
||||||
|
} else if (target.id === "editorEmptyFile") {
|
||||||
|
newFile({
|
||||||
|
app,
|
||||||
|
useSavePath: true
|
||||||
|
});
|
||||||
|
event.stopPropagation();
|
||||||
|
event.preventDefault();
|
||||||
|
break;
|
||||||
|
} else if (target.id === "editorEmptyNewNotebook") {
|
||||||
|
newNotebook();
|
||||||
|
event.stopPropagation();
|
||||||
|
event.preventDefault();
|
||||||
|
break;
|
||||||
|
} else if (target.id === "editorEmptyHelp") {
|
||||||
|
mountHelp();
|
||||||
|
event.stopPropagation();
|
||||||
|
event.preventDefault();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
target = target.parentElement;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const copyTab = (app: App, tab: Tab) => {
|
||||||
|
return new Tab({
|
||||||
|
icon: tab.icon,
|
||||||
|
docIcon: tab.docIcon,
|
||||||
|
title: tab.title,
|
||||||
|
callback(newTab: Tab) {
|
||||||
|
let model: Model;
|
||||||
|
if (tab.model instanceof Editor) {
|
||||||
|
model = new Editor({
|
||||||
|
app,
|
||||||
|
tab: newTab,
|
||||||
|
blockId: tab.model.editor.protyle.block.id,
|
||||||
|
scrollAttr: saveScroll(tab.model.editor.protyle, true)
|
||||||
|
});
|
||||||
|
} else if (tab.model instanceof Asset) {
|
||||||
|
model = new Asset({
|
||||||
|
app,
|
||||||
|
tab: newTab,
|
||||||
|
path: tab.model.path
|
||||||
|
});
|
||||||
|
} else if (tab.model instanceof Graph) {
|
||||||
|
model = new Graph({
|
||||||
|
app,
|
||||||
|
tab: newTab,
|
||||||
|
blockId: tab.model.blockId,
|
||||||
|
rootId: tab.model.rootId,
|
||||||
|
type: tab.model.type,
|
||||||
|
});
|
||||||
|
} else if (tab.model instanceof Files) {
|
||||||
|
model = new Files({
|
||||||
|
app,
|
||||||
|
tab: newTab
|
||||||
|
});
|
||||||
|
} else if (tab.model instanceof Outline) {
|
||||||
|
model = new Outline({
|
||||||
|
app,
|
||||||
|
tab: newTab,
|
||||||
|
blockId: tab.model.blockId,
|
||||||
|
type: tab.model.type,
|
||||||
|
isPreview: tab.model.isPreview
|
||||||
|
});
|
||||||
|
} else if (tab.model instanceof Backlink) {
|
||||||
|
model = new Backlink({
|
||||||
|
app,
|
||||||
|
tab: newTab,
|
||||||
|
blockId: tab.model.blockId,
|
||||||
|
rootId: tab.model.rootId,
|
||||||
|
type: tab.model.type
|
||||||
|
});
|
||||||
|
} else if (tab.model instanceof Bookmark) {
|
||||||
|
model = new Bookmark(app, newTab);
|
||||||
|
} else if (tab.model instanceof Tag) {
|
||||||
|
model = new Tag(app, newTab);
|
||||||
|
} else if (tab.model instanceof Search) {
|
||||||
|
model = new Search({
|
||||||
|
app,
|
||||||
|
tab: newTab,
|
||||||
|
config: tab.model.config
|
||||||
|
});
|
||||||
|
} else if (tab.model instanceof Custom) {
|
||||||
|
const custom = tab.model as Custom;
|
||||||
|
if (custom.type === "siyuan-card") {
|
||||||
|
model = newCardModel({
|
||||||
|
app,
|
||||||
|
tab: newTab,
|
||||||
|
data: custom.data
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
app.plugins.find(item => {
|
||||||
|
if (item.models[custom.type]) {
|
||||||
|
model = item.models[custom.type]({
|
||||||
|
tab: newTab,
|
||||||
|
data: custom.data
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (!tab.model && tab.headElement) {
|
||||||
|
const initData = JSON.parse(tab.headElement.getAttribute("data-initdata") || "{}");
|
||||||
|
if (initData) {
|
||||||
|
// 历史数据兼容 2023-05-24
|
||||||
|
if (initData.scrollAttr) {
|
||||||
|
initData.scrollAttr.rootId = initData.rootId;
|
||||||
|
}
|
||||||
|
model = newModelByInitData(app, newTab, initData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newTab.addModel(model);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const closeTabByType = async (tab: Tab, type: "closeOthers" | "closeAll" | "other", tabs?: Tab[]) => {
|
||||||
|
if (type === "closeOthers") {
|
||||||
|
for (let index = 0; index < tab.parent.children.length; index++) {
|
||||||
|
if (tab.parent.children[index].id !== tab.id && !tab.parent.children[index].headElement.classList.contains("item--pin")) {
|
||||||
|
tab.parent.children[index].parent.removeTab(tab.parent.children[index].id, true, true, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!tab.headElement.parentElement.querySelector(".item--focus")) {
|
||||||
|
tab.parent.switchTab(tab.headElement, true);
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (type === "closeAll") {
|
||||||
|
for (let index = 0; index < tab.parent.children.length; index++) {
|
||||||
|
if (!tab.parent.children[index].headElement.classList.contains("item--pin")) {
|
||||||
|
await tab.parent.children[index].parent.removeTab(tab.parent.children[index].id, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (tab.parent.children[0].headElement.parentElement) {
|
||||||
|
tab.parent.children[0].parent.switchTab(tab.parent.children[0].headElement, true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (tabs.length > 0) {
|
||||||
|
for (let index = 0; index < tabs.length; index++) {
|
||||||
|
if (!tabs[index].headElement.classList.contains("item--pin")) {
|
||||||
|
await tabs[index].parent.removeTab(tabs[index].id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (tab.headElement.parentElement && !tab.headElement.parentElement.querySelector(".item--focus")) {
|
||||||
|
tab.parent.switchTab(tab.headElement, true);
|
||||||
|
} else if (tab.parent.children[0].headElement.parentElement) {
|
||||||
|
tab.parent.children[0].parent.switchTab(tab.parent.children[0].headElement, true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,29 +1,24 @@
|
||||||
import {Layout} from "./index";
|
import {Layout} from "./index";
|
||||||
import {Wnd} from "./Wnd";
|
import {Wnd} from "./Wnd";
|
||||||
import {mountHelp, newNotebook} from "../util/mount";
|
|
||||||
import {Tab} from "./Tab";
|
import {Tab} from "./Tab";
|
||||||
import {Model} from "./Model";
|
import {Model} from "./Model";
|
||||||
import {Graph} from "./dock/Graph";
|
import {Graph} from "./dock/Graph";
|
||||||
import {Editor} from "../editor";
|
import {Editor} from "../editor";
|
||||||
import {Files} from "./dock/Files";
|
import {Files} from "./dock/Files";
|
||||||
import {newFile} from "../util/newFile";
|
|
||||||
import {Outline} from "./dock/Outline";
|
import {Outline} from "./dock/Outline";
|
||||||
import {Bookmark} from "./dock/Bookmark";
|
import {Bookmark} from "./dock/Bookmark";
|
||||||
import {updateHotkeyTip} from "../protyle/util/compatibility";
|
|
||||||
import {Tag} from "./dock/Tag";
|
import {Tag} from "./dock/Tag";
|
||||||
import {getAllModels, getAllTabs} from "./getAll";
|
import {getAllModels, getAllTabs} from "./getAll";
|
||||||
import {Asset} from "../asset";
|
import {Asset} from "../asset";
|
||||||
import {Search} from "../search";
|
import {Search} from "../search";
|
||||||
import {Dock} from "./dock";
|
import {Dock} from "./dock";
|
||||||
import {focusByOffset, focusByRange, getSelectionOffset} from "../protyle/util/selection";
|
import {focusByOffset, focusByRange, getSelectionOffset} from "../protyle/util/selection";
|
||||||
import {hideAllElements, hideElements} from "../protyle/ui/hideElements";
|
import {hideElements} from "../protyle/ui/hideElements";
|
||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost} from "../util/fetch";
|
||||||
import {hasClosestBlock, hasClosestByClassName} from "../protyle/util/hasClosest";
|
import {hasClosestBlock, hasClosestByClassName} from "../protyle/util/hasClosest";
|
||||||
import {getContenteditableElement} from "../protyle/wysiwyg/getBlock";
|
import {getContenteditableElement} from "../protyle/wysiwyg/getBlock";
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
import {openSearch} from "../search/spread";
|
|
||||||
import {saveScroll} from "../protyle/scroll/saveScroll";
|
import {saveScroll} from "../protyle/scroll/saveScroll";
|
||||||
import {pdfResize} from "../asset/renderAssets";
|
|
||||||
import {Backlink} from "./dock/Backlink";
|
import {Backlink} from "./dock/Backlink";
|
||||||
import {openFileById} from "../editor/util";
|
import {openFileById} from "../editor/util";
|
||||||
import {isWindow} from "../util/functions";
|
import {isWindow} from "../util/functions";
|
||||||
|
|
@ -32,13 +27,12 @@ import {setTabPosition} from "../window/setHeader";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {showMessage} from "../dialog/message";
|
import {showMessage} from "../dialog/message";
|
||||||
import {getIdZoomInByPath} from "../util/pathName";
|
import {getIdZoomInByPath} from "../util/pathName";
|
||||||
import {openHistory} from "../history/history";
|
|
||||||
import {Custom} from "./dock/Custom";
|
import {Custom} from "./dock/Custom";
|
||||||
import {newCardModel} from "../card/newCardTab";
|
import {newCardModel} from "../card/newCardTab";
|
||||||
import {openRecentDocs} from "../business/openRecentDocs";
|
|
||||||
import {App} from "../index";
|
import {App} from "../index";
|
||||||
import {afterLoadPlugin} from "../plugin/loader";
|
import {afterLoadPlugin} from "../plugin/loader";
|
||||||
import {setTitle} from "../dialog/processSystem";
|
import {setTitle} from "../dialog/processSystem";
|
||||||
|
import {newCenterEmptyTab, resizeTabs} from "./tabUtil";
|
||||||
|
|
||||||
export const setPanelFocus = (element: Element) => {
|
export const setPanelFocus = (element: Element) => {
|
||||||
if (element.getAttribute("data-type") === "wnd") {
|
if (element.getAttribute("data-type") === "wnd") {
|
||||||
|
|
@ -76,21 +70,6 @@ export const setPanelFocus = (element: Element) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getDockByType = (type: string) => {
|
|
||||||
if (!window.siyuan.layout.leftDock) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
if (window.siyuan.layout.leftDock.data[type]) {
|
|
||||||
return window.siyuan.layout.leftDock;
|
|
||||||
}
|
|
||||||
if (window.siyuan.layout.rightDock.data[type]) {
|
|
||||||
return window.siyuan.layout.rightDock;
|
|
||||||
}
|
|
||||||
if (window.siyuan.layout.bottomDock.data[type]) {
|
|
||||||
return window.siyuan.layout.bottomDock;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const switchWnd = (newWnd: Wnd, targetWnd: Wnd) => {
|
export const switchWnd = (newWnd: Wnd, targetWnd: Wnd) => {
|
||||||
// DOM 移动后 range 会变化
|
// DOM 移动后 range 会变化
|
||||||
const rangeDatas: {
|
const rangeDatas: {
|
||||||
|
|
@ -449,7 +428,7 @@ export const JSONToLayout = (app: App, isStart: boolean) => {
|
||||||
tab.parent.switchTab(item, false, false);
|
tab.parent.switchTab(item, false, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
resizeTopbar();
|
resizeTopBar();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const layoutToJSON = (layout: Layout | Wnd | Tab | Model, json: any, dropEditScroll = false) => {
|
export const layoutToJSON = (layout: Layout | Wnd | Tab | Model, json: any, dropEditScroll = false) => {
|
||||||
|
|
@ -587,7 +566,7 @@ export const layoutToJSON = (layout: Layout | Wnd | Tab | Model, json: any, drop
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const resizeTopbar = () => {
|
export const resizeTopBar = () => {
|
||||||
const toolbarElement = document.querySelector("#toolbar");
|
const toolbarElement = document.querySelector("#toolbar");
|
||||||
if (!toolbarElement) {
|
if (!toolbarElement) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -647,136 +626,6 @@ export const resizeTopbar = () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
let resizeTimeout: number;
|
|
||||||
export const resizeTabs = () => {
|
|
||||||
clearTimeout(resizeTimeout);
|
|
||||||
// .layout .fn__flex-shrink {width .15s cubic-bezier(0, 0, .2, 1) 0ms} 时需要再次计算 padding
|
|
||||||
// PDF 避免分屏多次调用后,页码跳转到1 https://github.com/siyuan-note/siyuan/issues/5646
|
|
||||||
resizeTimeout = window.setTimeout(() => {
|
|
||||||
const models = getAllModels();
|
|
||||||
models.editor.forEach((item) => {
|
|
||||||
if (item.editor && item.editor.protyle &&
|
|
||||||
item.element.parentElement && !item.element.classList.contains("fn__none")) {
|
|
||||||
item.editor.resize();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// https://github.com/siyuan-note/siyuan/issues/6250
|
|
||||||
models.backlink.forEach(item => {
|
|
||||||
const mTreeElement = item.element.querySelector(".backlinkMList") as HTMLElement;
|
|
||||||
if (mTreeElement.style.height && mTreeElement.style.height !== "0px" && item.element.clientHeight !== 0) {
|
|
||||||
mTreeElement.style.height = (item.element.clientHeight - mTreeElement.previousElementSibling.clientHeight * 2) + "px";
|
|
||||||
}
|
|
||||||
item.editors.forEach(editorItem => {
|
|
||||||
hideElements(["gutter"], editorItem.protyle);
|
|
||||||
editorItem.resize();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
models.search.forEach(item => {
|
|
||||||
item.edit.resize();
|
|
||||||
});
|
|
||||||
models.custom.forEach(item => {
|
|
||||||
if (item.resize) {
|
|
||||||
item.resize();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
pdfResize();
|
|
||||||
hideAllElements(["gutter"]);
|
|
||||||
}, 200);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const copyTab = (app: App, tab: Tab) => {
|
|
||||||
return new Tab({
|
|
||||||
icon: tab.icon,
|
|
||||||
docIcon: tab.docIcon,
|
|
||||||
title: tab.title,
|
|
||||||
callback(newTab: Tab) {
|
|
||||||
let model: Model;
|
|
||||||
if (tab.model instanceof Editor) {
|
|
||||||
model = new Editor({
|
|
||||||
app,
|
|
||||||
tab: newTab,
|
|
||||||
blockId: tab.model.editor.protyle.block.id,
|
|
||||||
scrollAttr: saveScroll(tab.model.editor.protyle, true)
|
|
||||||
});
|
|
||||||
} else if (tab.model instanceof Asset) {
|
|
||||||
model = new Asset({
|
|
||||||
app,
|
|
||||||
tab: newTab,
|
|
||||||
path: tab.model.path
|
|
||||||
});
|
|
||||||
} else if (tab.model instanceof Graph) {
|
|
||||||
model = new Graph({
|
|
||||||
app,
|
|
||||||
tab: newTab,
|
|
||||||
blockId: tab.model.blockId,
|
|
||||||
rootId: tab.model.rootId,
|
|
||||||
type: tab.model.type,
|
|
||||||
});
|
|
||||||
} else if (tab.model instanceof Files) {
|
|
||||||
model = new Files({
|
|
||||||
app,
|
|
||||||
tab: newTab
|
|
||||||
});
|
|
||||||
} else if (tab.model instanceof Outline) {
|
|
||||||
model = new Outline({
|
|
||||||
app,
|
|
||||||
tab: newTab,
|
|
||||||
blockId: tab.model.blockId,
|
|
||||||
type: tab.model.type,
|
|
||||||
isPreview: tab.model.isPreview
|
|
||||||
});
|
|
||||||
} else if (tab.model instanceof Backlink) {
|
|
||||||
model = new Backlink({
|
|
||||||
app,
|
|
||||||
tab: newTab,
|
|
||||||
blockId: tab.model.blockId,
|
|
||||||
rootId: tab.model.rootId,
|
|
||||||
type: tab.model.type
|
|
||||||
});
|
|
||||||
} else if (tab.model instanceof Bookmark) {
|
|
||||||
model = new Bookmark(app, newTab);
|
|
||||||
} else if (tab.model instanceof Tag) {
|
|
||||||
model = new Tag(app, newTab);
|
|
||||||
} else if (tab.model instanceof Search) {
|
|
||||||
model = new Search({
|
|
||||||
app,
|
|
||||||
tab: newTab,
|
|
||||||
config: tab.model.config
|
|
||||||
});
|
|
||||||
} else if (tab.model instanceof Custom) {
|
|
||||||
const custom = tab.model as Custom;
|
|
||||||
if (custom.type === "siyuan-card") {
|
|
||||||
model = newCardModel({
|
|
||||||
app,
|
|
||||||
tab: newTab,
|
|
||||||
data: custom.data
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
app.plugins.find(item => {
|
|
||||||
if (item.models[custom.type]) {
|
|
||||||
model = item.models[custom.type]({
|
|
||||||
tab: newTab,
|
|
||||||
data: custom.data
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (!tab.model && tab.headElement) {
|
|
||||||
const initData = JSON.parse(tab.headElement.getAttribute("data-initdata") || "{}");
|
|
||||||
if (initData) {
|
|
||||||
// 历史数据兼容 2023-05-24
|
|
||||||
if (initData.scrollAttr) {
|
|
||||||
initData.scrollAttr.rootId = initData.rootId;
|
|
||||||
}
|
|
||||||
model = newModelByInitData(app, newTab, initData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
newTab.addModel(model);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const newModelByInitData = (app: App, tab: Tab, json: any) => {
|
export const newModelByInitData = (app: App, tab: Tab, json: any) => {
|
||||||
let model: Model;
|
let model: Model;
|
||||||
if (json.instance === "Custom") {
|
if (json.instance === "Custom") {
|
||||||
|
|
@ -959,100 +808,3 @@ export const addResize = (obj: Layout | Wnd) => {
|
||||||
obj.element.insertAdjacentElement("beforebegin", resizeElement);
|
obj.element.insertAdjacentElement("beforebegin", resizeElement);
|
||||||
resizeWnd(resizeElement, obj.resize);
|
resizeWnd(resizeElement, obj.resize);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const newCenterEmptyTab = (app: App) => {
|
|
||||||
return new Tab({
|
|
||||||
panel: `<div class="layout__empty b3-list">
|
|
||||||
<div class="${!window.siyuan.config.readonly ? " fn__none" : ""}">
|
|
||||||
<div class="config-about__logo">
|
|
||||||
<img src="/stage/icon.png">
|
|
||||||
${window.siyuan.languages.siyuanNote}
|
|
||||||
</div>
|
|
||||||
<div class="b3-label__text">${window.siyuan.languages.slogan}</div>
|
|
||||||
</div>
|
|
||||||
<div class="fn__hr"></div>
|
|
||||||
<div class="b3-list-item" id="editorEmptySearch">
|
|
||||||
<svg class="b3-list-item__graphic"><use xlink:href="#iconSearch"></use></svg>
|
|
||||||
<span>${window.siyuan.languages.search}</span>
|
|
||||||
<span class="b3-list-item__meta">${updateHotkeyTip(window.siyuan.config.keymap.general.globalSearch.custom)}</span>
|
|
||||||
</div>
|
|
||||||
<div id="editorEmptyRecent" class="b3-list-item">
|
|
||||||
<svg class="b3-list-item__graphic"><use xlink:href="#iconList"></use></svg>
|
|
||||||
<span>${window.siyuan.languages.recentDocs}</span>
|
|
||||||
<span class="b3-list-item__meta">${updateHotkeyTip(window.siyuan.config.keymap.general.recentDocs.custom)}</span>
|
|
||||||
</div>
|
|
||||||
<div id="editorEmptyHistory" class="b3-list-item${window.siyuan.config.readonly ? " fn__none" : ""}">
|
|
||||||
<svg class="b3-list-item__graphic"><use xlink:href="#iconHistory"></use></svg>
|
|
||||||
<span>${window.siyuan.languages.dataHistory}</span>
|
|
||||||
<span class="b3-list-item__meta">${updateHotkeyTip(window.siyuan.config.keymap.general.dataHistory.custom)}</span>
|
|
||||||
</div>
|
|
||||||
<div class="b3-list-item${window.siyuan.config.readonly ? " fn__none" : ""}" id="editorEmptyFile">
|
|
||||||
<svg class="b3-list-item__graphic"><use xlink:href="#iconFile"></use></svg>
|
|
||||||
<span>${window.siyuan.languages.newFile}</span>
|
|
||||||
<span class="b3-list-item__meta">${updateHotkeyTip(window.siyuan.config.keymap.general.newFile.custom)}</span>
|
|
||||||
</div>
|
|
||||||
<div class="b3-list-item${window.siyuan.config.readonly ? " fn__none" : ""}" id="editorEmptyNewNotebook">
|
|
||||||
<svg class="b3-list-item__graphic"><use xlink:href="#iconFilesRoot"></use></svg>
|
|
||||||
<span>${window.siyuan.languages.newNotebook}</span>
|
|
||||||
</div>
|
|
||||||
<div class="b3-list-item" id="editorEmptyHelp">
|
|
||||||
<svg class="b3-list-item__graphic"><use xlink:href="#iconHelp"></use></svg>
|
|
||||||
<span>${window.siyuan.languages.help}</span>
|
|
||||||
</div>
|
|
||||||
</div>`,
|
|
||||||
callback(tab: Tab) {
|
|
||||||
tab.panelElement.addEventListener("click", (event) => {
|
|
||||||
let target = event.target as HTMLElement;
|
|
||||||
while (target && !target.isEqualNode(tab.panelElement)) {
|
|
||||||
if (target.id === "editorEmptySearch") {
|
|
||||||
openSearch({
|
|
||||||
app,
|
|
||||||
hotkey: window.siyuan.config.keymap.general.globalSearch.custom,
|
|
||||||
});
|
|
||||||
event.stopPropagation();
|
|
||||||
event.preventDefault();
|
|
||||||
break;
|
|
||||||
} else if (target.id === "editorEmptyRecent") {
|
|
||||||
const openRecentDocsDialog = window.siyuan.dialogs.find(item => {
|
|
||||||
if (item.element.getAttribute("data-key") === window.siyuan.config.keymap.general.recentDocs.custom) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (openRecentDocsDialog) {
|
|
||||||
hideElements(["dialog"]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
openRecentDocs();
|
|
||||||
event.stopPropagation();
|
|
||||||
event.preventDefault();
|
|
||||||
break;
|
|
||||||
} else if (target.id === "editorEmptyHistory") {
|
|
||||||
openHistory(app);
|
|
||||||
event.stopPropagation();
|
|
||||||
event.preventDefault();
|
|
||||||
break;
|
|
||||||
} else if (target.id === "editorEmptyFile") {
|
|
||||||
newFile({
|
|
||||||
app,
|
|
||||||
useSavePath: true
|
|
||||||
});
|
|
||||||
event.stopPropagation();
|
|
||||||
event.preventDefault();
|
|
||||||
break;
|
|
||||||
} else if (target.id === "editorEmptyNewNotebook") {
|
|
||||||
newNotebook();
|
|
||||||
event.stopPropagation();
|
|
||||||
event.preventDefault();
|
|
||||||
break;
|
|
||||||
} else if (target.id === "editorEmptyHelp") {
|
|
||||||
mountHelp();
|
|
||||||
event.stopPropagation();
|
|
||||||
event.preventDefault();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
target = target.parentElement;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import {Constants} from "../constants";
|
||||||
import {newFile} from "../util/newFile";
|
import {newFile} from "../util/newFile";
|
||||||
import {hasClosestByTag} from "../protyle/util/hasClosest";
|
import {hasClosestByTag} from "../protyle/util/hasClosest";
|
||||||
import {deleteFiles} from "../editor/deleteFile";
|
import {deleteFiles} from "../editor/deleteFile";
|
||||||
import {getDockByType} from "../layout/util";
|
import {getDockByType} from "../layout/tabUtil";
|
||||||
import {Files} from "../layout/dock/Files";
|
import {Files} from "../layout/dock/Files";
|
||||||
import {openCardByData} from "../card/openCard";
|
import {openCardByData} from "../card/openCard";
|
||||||
import {viewCards} from "../card/viewCards";
|
import {viewCards} from "../card/viewCards";
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import {Tab} from "../layout/Tab";
|
import {Tab} from "../layout/Tab";
|
||||||
import {MenuItem} from "./Menu";
|
import {MenuItem} from "./Menu";
|
||||||
import {Editor} from "../editor";
|
import {Editor} from "../editor";
|
||||||
import {copyTab, resizeTabs} from "../layout/util";
|
import {closeTabByType, copyTab, resizeTabs} from "../layout/tabUtil";
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
import {openNewWindow} from "../window/openNewWindow";
|
import {openNewWindow} from "../window/openNewWindow";
|
||||||
/// #endif
|
/// #endif
|
||||||
|
|
@ -9,7 +9,6 @@ import {copySubMenu} from "./commonMenuItem";
|
||||||
import {App} from "../index";
|
import {App} from "../index";
|
||||||
|
|
||||||
const closeMenu = (tab: Tab) => {
|
const closeMenu = (tab: Tab) => {
|
||||||
const allTabs: Tab[] = [];
|
|
||||||
const unmodifiedTabs: Tab[] = [];
|
const unmodifiedTabs: Tab[] = [];
|
||||||
const leftTabs: Tab[] = [];
|
const leftTabs: Tab[] = [];
|
||||||
const rightTabs: Tab[] = [];
|
const rightTabs: Tab[] = [];
|
||||||
|
|
@ -27,7 +26,6 @@ const closeMenu = (tab: Tab) => {
|
||||||
} else if (index > midIndex) {
|
} else if (index > midIndex) {
|
||||||
rightTabs.push(item);
|
rightTabs.push(item);
|
||||||
}
|
}
|
||||||
allTabs.push(item);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
|
|
@ -38,77 +36,45 @@ const closeMenu = (tab: Tab) => {
|
||||||
tab.parent.removeTab(tab.id);
|
tab.parent.removeTab(tab.id);
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
if (allTabs.length > 1) {
|
if (tab.parent.children.length > 1) {
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.closeOthers,
|
label: window.siyuan.languages.closeOthers,
|
||||||
|
accelerator: window.siyuan.config.keymap.general.closeOthers.custom,
|
||||||
click() {
|
click() {
|
||||||
for (let index = 0; index < allTabs.length; index++) {
|
closeTabByType(tab, "closeOthers");
|
||||||
if (allTabs[index].id !== tab.id && !allTabs[index].headElement.classList.contains("item--pin")) {
|
|
||||||
allTabs[index].parent.removeTab(allTabs[index].id, true, true, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!tab.headElement.parentElement.querySelector(".item--focus")) {
|
|
||||||
tab.parent.switchTab(tab.headElement, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.closeAll,
|
label: window.siyuan.languages.closeAll,
|
||||||
click: async () => {
|
accelerator: window.siyuan.config.keymap.general.closeAll.custom,
|
||||||
for (let index = 0; index < allTabs.length; index++) {
|
click() {
|
||||||
if (!allTabs[index].headElement.classList.contains("item--pin")) {
|
closeTabByType(tab, "closeAll");
|
||||||
await allTabs[index].parent.removeTab(allTabs[index].id, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (allTabs[0].headElement.parentElement) {
|
|
||||||
allTabs[0].parent.switchTab(allTabs[0].headElement, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
if (unmodifiedTabs.length > 0) {
|
if (unmodifiedTabs.length > 0) {
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.closeUnmodified,
|
label: window.siyuan.languages.closeUnmodified,
|
||||||
click: async () => {
|
accelerator: window.siyuan.config.keymap.general.closeUnmodified.custom,
|
||||||
for (let index = 0; index < unmodifiedTabs.length; index++) {
|
click() {
|
||||||
if (!unmodifiedTabs[index].headElement.classList.contains("item--pin")) {
|
closeTabByType(tab, "other", unmodifiedTabs);
|
||||||
await unmodifiedTabs[index].parent.removeTab(unmodifiedTabs[index].id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (tab.headElement.parentElement && !tab.headElement.parentElement.querySelector(".item--focus")) {
|
|
||||||
tab.parent.switchTab(tab.headElement, true);
|
|
||||||
} else if (allTabs[0].headElement.parentElement) {
|
|
||||||
allTabs[0].parent.switchTab(allTabs[0].headElement, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
}
|
}
|
||||||
if (leftTabs.length > 0) {
|
if (leftTabs.length > 0) {
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.closeLeft,
|
label: window.siyuan.languages.closeLeft,
|
||||||
|
accelerator: window.siyuan.config.keymap.general.closeLeft.custom,
|
||||||
click: async () => {
|
click: async () => {
|
||||||
for (let index = 0; index < leftTabs.length; index++) {
|
closeTabByType(tab, "other", leftTabs);
|
||||||
if (!leftTabs[index].headElement.classList.contains("item--pin")) {
|
|
||||||
await leftTabs[index].parent.removeTab(leftTabs[index].id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!tab.headElement.parentElement.querySelector(".item--focus")) {
|
|
||||||
tab.parent.switchTab(tab.headElement, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
}
|
}
|
||||||
if (rightTabs.length > 0) {
|
if (rightTabs.length > 0) {
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
label: window.siyuan.languages.closeRight,
|
label: window.siyuan.languages.closeRight,
|
||||||
click: async () => {
|
accelerator: window.siyuan.config.keymap.general.closeRight.custom,
|
||||||
for (let index = 0; index < rightTabs.length; index++) {
|
click () {
|
||||||
if (!rightTabs[index].headElement.classList.contains("item--pin")) {
|
closeTabByType(tab, "other", rightTabs);
|
||||||
await rightTabs[index].parent.removeTab(rightTabs[index].id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!tab.headElement.parentElement.querySelector(".item--focus")) {
|
|
||||||
tab.parent.switchTab(tab.headElement, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ import {isInAndroid, isInIOS, setStorageVal, writeText} from "../protyle/util/co
|
||||||
import {openCard} from "../card/openCard";
|
import {openCard} from "../card/openCard";
|
||||||
import {openSetting} from "../config";
|
import {openSetting} from "../config";
|
||||||
import {getAllDocks} from "../layout/getAll";
|
import {getAllDocks} from "../layout/getAll";
|
||||||
import {exportLayout, getDockByType} from "../layout/util";
|
import {exportLayout} from "../layout/util";
|
||||||
|
import {getDockByType} from "../layout/tabUtil";
|
||||||
import {exitSiYuan, lockScreen} from "../dialog/processSystem";
|
import {exitSiYuan, lockScreen} from "../dialog/processSystem";
|
||||||
import {showMessage} from "../dialog/message";
|
import {showMessage} from "../dialog/message";
|
||||||
import {unicode2Emoji} from "../emoji";
|
import {unicode2Emoji} from "../emoji";
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,8 @@ import {Custom} from "../layout/dock/Custom";
|
||||||
import {getAllModels} from "../layout/getAll";
|
import {getAllModels} from "../layout/getAll";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {Tab} from "../layout/Tab";
|
import {Tab} from "../layout/Tab";
|
||||||
import {getDockByType, setPanelFocus} from "../layout/util";
|
import {setPanelFocus} from "../layout/util";
|
||||||
|
import {getDockByType} from "../layout/tabUtil";
|
||||||
import {hasClosestByAttribute} from "../protyle/util/hasClosest";
|
import {hasClosestByAttribute} from "../protyle/util/hasClosest";
|
||||||
import {BlockPanel} from "../block/Panel";
|
import {BlockPanel} from "../block/Panel";
|
||||||
import {Setting} from "./Setting";
|
import {Setting} from "./Setting";
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import {fetchSyncPost} from "../util/fetch";
|
||||||
import {App} from "../index";
|
import {App} from "../index";
|
||||||
import {Plugin} from "./index";
|
import {Plugin} from "./index";
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
import {exportLayout, resizeTopbar} from "../layout/util";
|
import {exportLayout, resizeTopBar} from "../layout/util";
|
||||||
/// #endif
|
/// #endif
|
||||||
import {API} from "./API";
|
import {API} from "./API";
|
||||||
import {getFrontend, isMobile, isWindow} from "../util/functions";
|
import {getFrontend, isMobile, isWindow} from "../util/functions";
|
||||||
|
|
@ -187,7 +187,7 @@ export const afterLoadPlugin = (plugin: Plugin) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
resizeTopbar();
|
resizeTopBar();
|
||||||
mergePluginHotkey(plugin);
|
mergePluginHotkey(plugin);
|
||||||
plugin.statusBarIcons.forEach(element => {
|
plugin.statusBarIcons.forEach(element => {
|
||||||
const statusElement = document.getElementById("status");
|
const statusElement = document.getElementById("status");
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import {App} from "../index";
|
import {App} from "../index";
|
||||||
import {Plugin} from "../plugin";
|
import {Plugin} from "../plugin";
|
||||||
import {getAllModels} from "../layout/getAll";
|
import {getAllModels} from "../layout/getAll";
|
||||||
import {exportLayout, resizeTopbar} from "../layout/util";
|
import {exportLayout, resizeTopBar} from "../layout/util";
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
|
|
||||||
export const uninstall = (app: App, name: string) => {
|
export const uninstall = (app: App, name: string) => {
|
||||||
|
|
@ -24,7 +24,7 @@ export const uninstall = (app: App, name: string) => {
|
||||||
plugin.topBarIcons.forEach(item => {
|
plugin.topBarIcons.forEach(item => {
|
||||||
item.remove();
|
item.remove();
|
||||||
});
|
});
|
||||||
resizeTopbar();
|
resizeTopBar();
|
||||||
// rm statusBar
|
// rm statusBar
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
plugin.statusBarIcons.forEach(item => {
|
plugin.statusBarIcons.forEach(item => {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import {showMessage} from "../dialog/message";
|
import {showMessage} from "../dialog/message";
|
||||||
import {getAllModels} from "../layout/getAll";
|
import {getAllModels} from "../layout/getAll";
|
||||||
import {hasClosestByClassName, hasTopClosestByTag} from "../protyle/util/hasClosest";
|
import {hasClosestByClassName, hasTopClosestByTag} from "../protyle/util/hasClosest";
|
||||||
import {getDockByType} from "../layout/util";
|
import {getDockByType} from "../layout/tabUtil";
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
import {Files} from "../layout/dock/Files";
|
import {Files} from "../layout/dock/Files";
|
||||||
import {openFileById} from "../editor/util";
|
import {openFileById} from "../editor/util";
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
import {webFrame} from "electron";
|
import {webFrame} from "electron";
|
||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost} from "../util/fetch";
|
||||||
import {getInstanceById, JSONToCenter, resizeTabs} from "../layout/util";
|
import {getInstanceById, JSONToCenter} from "../layout/util";
|
||||||
|
import {resizeTabs} from "../layout/tabUtil";
|
||||||
import {initStatus} from "../layout/status";
|
import {initStatus} from "../layout/status";
|
||||||
import {appearance} from "../config/appearance";
|
import {appearance} from "../config/appearance";
|
||||||
import {initAssets, setInlineStyle} from "../util/assets";
|
import {initAssets, setInlineStyle} from "../util/assets";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue