Skip to content

Commit

Permalink
Add data-id attribute to the button of tab menu siyuan-note#12518 (s…
Browse files Browse the repository at this point in the history
  • Loading branch information
TCOTC authored Sep 30, 2024
1 parent bcadbdb commit 7dd4fd9
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion app/src/menus/tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const closeMenu = (tab: Tab) => {
});

window.siyuan.menus.menu.append(new MenuItem({
id: "close",
icon: "iconClose",
label: window.siyuan.languages.close,
accelerator: window.siyuan.config.keymap.general.closeTab.custom,
Expand All @@ -43,13 +44,15 @@ const closeMenu = (tab: Tab) => {
}).element);
if (tab.parent.children.length > 1) {
window.siyuan.menus.menu.append(new MenuItem({
id: "closeOthers",
label: window.siyuan.languages.closeOthers,
accelerator: window.siyuan.config.keymap.general.closeOthers.custom,
click() {
closeTabByType(tab, "closeOthers");
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({
id: "closeAll",
label: window.siyuan.languages.closeAll,
accelerator: window.siyuan.config.keymap.general.closeAll.custom,
click() {
Expand All @@ -58,6 +61,7 @@ const closeMenu = (tab: Tab) => {
}).element);
if (unmodifiedTabs.length > 0) {
window.siyuan.menus.menu.append(new MenuItem({
id: "closeUnmodified",
label: window.siyuan.languages.closeUnmodified,
accelerator: window.siyuan.config.keymap.general.closeUnmodified.custom,
click() {
Expand All @@ -67,6 +71,7 @@ const closeMenu = (tab: Tab) => {
}
if (leftTabs.length > 0) {
window.siyuan.menus.menu.append(new MenuItem({
id: "closeLeft",
label: window.siyuan.languages.closeLeft,
accelerator: window.siyuan.config.keymap.general.closeLeft.custom,
click: async () => {
Expand All @@ -76,6 +81,7 @@ const closeMenu = (tab: Tab) => {
}
if (rightTabs.length > 0) {
window.siyuan.menus.menu.append(new MenuItem({
id: "closeRight",
label: window.siyuan.languages.closeRight,
accelerator: window.siyuan.config.keymap.general.closeRight.custom,
click() {
Expand All @@ -84,11 +90,12 @@ const closeMenu = (tab: Tab) => {
}).element);
}
}
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
window.siyuan.menus.menu.append(new MenuItem({id: "separator_1", type: "separator"}).element);
};

const splitSubMenu = (app: App, tab: Tab) => {
const subMenus: IMenu[] = [{
id: "splitLR",
icon: "iconSplitLR",
accelerator: window.siyuan.config.keymap.general.splitLR.custom,
label: window.siyuan.languages.splitLR,
Expand All @@ -98,6 +105,7 @@ const splitSubMenu = (app: App, tab: Tab) => {
}];
if (tab.parent.children.length > 1) {
subMenus.push({
id: "splitMoveR",
icon: "iconLayoutRight",
accelerator: window.siyuan.config.keymap.general.splitMoveR.custom,
label: window.siyuan.languages.splitMoveR,
Expand All @@ -111,6 +119,7 @@ const splitSubMenu = (app: App, tab: Tab) => {
});
}
subMenus.push({
id: "splitTB",
icon: "iconSplitTB",
accelerator: window.siyuan.config.keymap.general.splitTB.custom,
label: window.siyuan.languages.splitTB,
Expand All @@ -121,6 +130,7 @@ const splitSubMenu = (app: App, tab: Tab) => {

if (tab.parent.children.length > 1) {
subMenus.push({
id: "splitMoveB",
icon: "iconLayoutBottom",
accelerator: window.siyuan.config.keymap.general.splitMoveB.custom,
label: window.siyuan.languages.splitMoveB,
Expand All @@ -137,6 +147,7 @@ const splitSubMenu = (app: App, tab: Tab) => {
getAllWnds(window.siyuan.layout.centerLayout, wndsTemp);
if (wndsTemp.length > 1) {
subMenus.push({
id: "unsplit",
label: window.siyuan.languages.unsplit,
accelerator: window.siyuan.config.keymap.general.unsplit.custom,
click: () => {
Expand All @@ -155,6 +166,7 @@ const splitSubMenu = (app: App, tab: Tab) => {
}
});
subMenus.push({
id: "unsplitAll",
label: window.siyuan.languages.unsplitAll,
accelerator: window.siyuan.config.keymap.general.unsplitAll.custom,
click: () => {
Expand All @@ -170,6 +182,7 @@ export const initTabMenu = (app: App, tab: Tab) => {
window.siyuan.menus.menu.remove();
closeMenu(tab);
window.siyuan.menus.menu.append(new MenuItem({
id: "split",
label: window.siyuan.languages.split,
submenu: splitSubMenu(app, tab)
}).element);
Expand All @@ -188,13 +201,15 @@ export const initTabMenu = (app: App, tab: Tab) => {
}
if (rootId) {
window.siyuan.menus.menu.append(new MenuItem({
id: "copy",
label: window.siyuan.languages.copy,
icon: "iconCopy",
type: "submenu",
submenu: copySubMenu(rootId, false)
}).element);
} else if (model && model instanceof Asset) {
window.siyuan.menus.menu.append(new MenuItem({
id: "copy",
label: window.siyuan.languages.copy,
icon: "iconCopy",
click() {
Expand All @@ -204,6 +219,7 @@ export const initTabMenu = (app: App, tab: Tab) => {
}
if (tab.headElement.classList.contains("item--pin")) {
window.siyuan.menus.menu.append(new MenuItem({
id: "unpin",
label: window.siyuan.languages.unpin,
icon: "iconUnpin",
click: () => {
Expand All @@ -212,6 +228,7 @@ export const initTabMenu = (app: App, tab: Tab) => {
}).element);
} else {
window.siyuan.menus.menu.append(new MenuItem({
id: "pin",
label: window.siyuan.languages.pin,
icon: "iconPin",
click: () => {
Expand All @@ -221,6 +238,7 @@ export const initTabMenu = (app: App, tab: Tab) => {
}
/// #if !BROWSER
window.siyuan.menus.menu.append(new MenuItem({
id: "tabToWindow",
label: window.siyuan.languages.tabToWindow,
accelerator: window.siyuan.config.keymap.general.tabToWindow.custom,
icon: "iconOpenWindow",
Expand Down

0 comments on commit 7dd4fd9

Please sign in to comment.