mirror of
https://github.com/zadam/trilium.git
synced 2025-12-03 22:14:24 +01:00
feat(mobile/split): hide split button if split is already open
This commit is contained in:
parent
bfb143bb51
commit
f5940cbf70
@ -21,22 +21,29 @@ export default function MobileDetailMenu() {
|
|||||||
if (!ntxId) return;
|
if (!ntxId) return;
|
||||||
|
|
||||||
const noteContext = appContext.tabManager.getNoteContextById(ntxId);
|
const noteContext = appContext.tabManager.getNoteContextById(ntxId);
|
||||||
|
const subContexts = noteContext.getMainContext().getSubContexts();
|
||||||
|
const isMainContext = noteContext?.isMainContext();
|
||||||
const note = noteContext.note;
|
const note = noteContext.note;
|
||||||
|
|
||||||
const items: (MenuItem<keyof CommandMappings> | false)[] = [
|
const items: (MenuItem<keyof CommandMappings>)[] = [
|
||||||
{ title: t("mobile_detail_menu.insert_child_note"), command: "insertChildNote", uiIcon: "bx bx-plus", enabled: note?.type !== "search" },
|
{ title: t("mobile_detail_menu.insert_child_note"), command: "insertChildNote", uiIcon: "bx bx-plus", enabled: note?.type !== "search" },
|
||||||
{ title: t("mobile_detail_menu.delete_this_note"), command: "delete", uiIcon: "bx bx-trash", enabled: note?.noteId !== "root" },
|
{ title: t("mobile_detail_menu.delete_this_note"), command: "delete", uiIcon: "bx bx-trash", enabled: note?.noteId !== "root" },
|
||||||
{ kind: "separator" },
|
{ kind: "separator" },
|
||||||
{ title: t("mobile_detail_menu.note_revisions"), command: "showRevisions", uiIcon: "bx bx-history" },
|
{ title: t("mobile_detail_menu.note_revisions"), command: "showRevisions", uiIcon: "bx bx-history" },
|
||||||
{ kind: "separator" },
|
{ kind: "separator" },
|
||||||
{ title: t("create_pane_button.create_new_split"), command: "openNewNoteSplit", uiIcon: "bx bx-dock-right" },
|
subContexts.length < 2 && { title: t("create_pane_button.create_new_split"), command: "openNewNoteSplit", uiIcon: "bx bx-dock-right" },
|
||||||
!noteContext?.isMainContext() && { title: t("close_pane_button.close_this_pane"), command: "closeThisNoteSplit", uiIcon: "bx bx-x" }
|
!isMainContext && { title: t("close_pane_button.close_this_pane"), command: "closeThisNoteSplit", uiIcon: "bx bx-x" }
|
||||||
];
|
].filter(i => !!i) as MenuItem<keyof CommandMappings>[];
|
||||||
|
|
||||||
|
const lastItem = items.at(-1);
|
||||||
|
if (lastItem && "kind" in lastItem && lastItem.kind === "separator") {
|
||||||
|
items.pop();
|
||||||
|
}
|
||||||
|
|
||||||
contextMenu.show<keyof CommandMappings>({
|
contextMenu.show<keyof CommandMappings>({
|
||||||
x: e.pageX,
|
x: e.pageX,
|
||||||
y: e.pageY,
|
y: e.pageY,
|
||||||
items: items.filter(i => !!i),
|
items,
|
||||||
selectMenuItemHandler: async ({ command }) => {
|
selectMenuItemHandler: async ({ command }) => {
|
||||||
if (command === "insertChildNote") {
|
if (command === "insertChildNote") {
|
||||||
note_create.createNote(appContext.tabManager.getActiveContextNotePath() ?? undefined);
|
note_create.createNote(appContext.tabManager.getActiveContextNotePath() ?? undefined);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user