feat(mobile/split): option to close split

This commit is contained in:
Elian Doran
2025-11-29 21:11:16 +02:00
parent e3a2623a53
commit 2cf6fe4352

View File

@@ -1,6 +1,6 @@
import { useContext } from "preact/hooks"; import { useContext } from "preact/hooks";
import appContext, { CommandMappings } from "../../components/app_context"; import appContext, { CommandMappings } from "../../components/app_context";
import contextMenu from "../../menus/context_menu"; import contextMenu, { MenuItem } from "../../menus/context_menu";
import branches from "../../services/branches"; import branches from "../../services/branches";
import { t } from "../../services/i18n"; import { t } from "../../services/i18n";
import note_create from "../../services/note_create"; import note_create from "../../services/note_create";
@@ -18,18 +18,22 @@ export default function MobileDetailMenu() {
text="" text=""
onClick={(e) => { onClick={(e) => {
const note = appContext.tabManager.getActiveContextNote(); const note = appContext.tabManager.getActiveContextNote();
const noteContext = appContext.tabManager.getActiveContext();
contextMenu.show<keyof CommandMappings>({ const items: (MenuItem<keyof CommandMappings> | false)[] = [
x: e.pageX,
y: e.pageY,
items: [
{ 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" }, { 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" }
];
contextMenu.show<keyof CommandMappings>({
x: e.pageX,
y: e.pageY,
items: items.filter(i => !!i),
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);