Skip to content

Build your personal knowledge base with Trilium Notes

refactor(client): show the mobile note map in the quick-edit popup

Elian Doran46fdc71bb764
diff --git a/apps/client/src/components/app_context.ts b/apps/client/src/components/app_context.ts
index c5b3c1c9c3..95ad3d8cc1 100644
--- a/apps/client/src/components/app_context.ts
+++ b/apps/client/src/components/app_context.ts
@@ -163,8 +163,6 @@ export type CommandMappings = {
showLeftPane: CommandData;
showAttachments: CommandData;
showNoteAttributes: CommandData;
- /** Shows the note map as a modal, for the layouts with no right pane to put it in. */
- showNoteMap: CommandData;
showSearchHistory: CommandData;
showShareSubtree: CommandData;
hoistNote: CommandData & { noteId: string };
diff --git a/apps/client/src/components/root_command_executor.ts b/apps/client/src/components/root_command_executor.ts
index 1318618264..7f008d168e 100644
--- a/apps/client/src/components/root_command_executor.ts
+++ b/apps/client/src/components/root_command_executor.ts
@@ -196,11 +196,15 @@ export default class RootCommandExecutor extends Component {
}
async toggleRibbonTabNoteMapCommand(data: CommandListenerData<"toggleRibbonTabNoteMap">) {
- // A phone has neither the ribbon the map was a tab of nor the pane it is a card of, so the menu
- // it is asked from is where it is asked from and a modal is where it is shown — as the note's
- // attributes, its backlinks and its paths already are.
+ // A phone has neither the ribbon the map was a tab of nor the pane it is a card of, so it is
+ // shown the way the pane's card shows it expanded: as the quick-edit popup, which is the map at
+ // the size of the window wherever there is no card to expand from. The popup carries the note's
+ // title, steps aside when a note of the map is pressed, and can be taken on to a tab.
if (utils.isMobile()) {
- this.triggerEvent("showNoteMap", data);
+ const notePath = appContext.tabManager.getActiveContext()?.notePath;
+ if (notePath) {
+ void appContext.triggerCommand("openInPopup", { noteIdOrPath: notePath, viewScope: { viewMode: "note-map" } });
+ }
return;
}
diff --git a/apps/client/src/layouts/layout_commons.tsx b/apps/client/src/layouts/layout_commons.tsx
index 169ffc73d3..907197bb46 100644
--- a/apps/client/src/layouts/layout_commons.tsx
+++ b/apps/client/src/layouts/layout_commons.tsx
@@ -38,8 +38,6 @@ export function applyModals(rootContainer: RootContainer) {
.child(<LazyDialog triggerEvents={["showOptions"]} loader={() => import("../widgets/dialogs/OptionsDialog.jsx")} />)
.child(<LazyDialog triggerEvents={["showOcrTextDialog"]} loader={() => import("../widgets/dialogs/ocr_text.js")} />)
.child(<LazyDialog triggerEvents={["showNoteAttributes"]} loader={() => import("../widgets/dialogs/note_attributes.jsx")} />)
- // Lazily loaded above all: the map is drawn by force-graph, kept out of the boot bundle.
- .child(<LazyDialog triggerEvents={["showNoteMap"]} loader={() => import("../widgets/dialogs/note_map.jsx")} />)
.child(<LazyDialog triggerEvents={["showUploadAttachmentsDialog"]} loader={() => import("../widgets/dialogs/upload_attachments.js")} />)
.child(<LazyDialog triggerEvents={["openInTreePopup"]} loader={() => import("../widgets/dialogs/TreePopupEditor.jsx")} />)
// The following three are deliberately eager (not wrapped in LazyDialog):
diff --git a/apps/client/src/widgets/dialogs/note_map.css b/apps/client/src/widgets/dialogs/note_map.css
deleted file mode 100644
index 53251f2d43..0000000000
--- a/apps/client/src/widgets/dialogs/note_map.css
+++ /dev/null
@@ -1,25 +0,0 @@
-.modal.note-map-modal {
- .modal-body {
- /* The map is drawn to whatever box it is given and keeps to it, so the body is a frame around
- it rather than a page to scroll. */
- padding: 0;
- display: flex;
- flex-direction: column;
- }
-
- .note-map-modal-body {
- /* Anchors the map's floating buttons (map type, fix nodes), same as the ribbon wrapper. */
- position: relative;
- flex: 1;
- /* A modal that is not the whole screen is as tall as what is in it, so the map has to bring a
- height of its own; where it is the whole screen the rule below hands that back. */
- min-height: 70vh;
- overflow: hidden;
- }
-}
-
-/* The whole screen leaves the map what the header does not take, rather than a share of the viewport
- measured without it — which would overflow the modal by the height of its own title. */
-body.mobile .modal.note-map-modal .modal-dialog-full-page-on-mobile .note-map-modal-body {
- min-height: 0;
-}
diff --git a/apps/client/src/widgets/dialogs/note_map.tsx b/apps/client/src/widgets/dialogs/note_map.tsx
deleted file mode 100644
index 88fee281e5..0000000000
--- a/apps/client/src/widgets/dialogs/note_map.tsx
+++ /dev/null
@@ -1,51 +0,0 @@
-import "./note_map.css";
-
-import { useRef, useState } from "preact/hooks";
-
-import { t } from "../../services/i18n";
-import NoteMap from "../note_map/NoteMap";
-import { useActiveNoteContext, useTriliumEvent } from "../react/hooks";
-import Modal from "../react/Modal";
-
-/**
- * The note map as a modal, for the layouts with no right pane to put it in — the mobile one, where it
- * is summoned from the note's own menu. The map follows the note being read, so the modal is summoned
- * without being told which note it is about.
- *
- * Drawn as the connections card's map expanded is drawn, which is what this is a phone's answer to:
- * the same two maps to choose between, remembered the same way.
- */
-export default function NoteMapDialog() {
- const [ shown, setShown ] = useState(false);
-
- useTriliumEvent("showNoteMap", () => setShown(true));
-
- return (
- <Modal
- className="note-map-modal"
- // Named as the menu entry that summons it names it.
- title={t("note_map.title")}
- size="lg"
- show={shown}
- onHidden={() => setShown(false)}
- isFullPageOnMobile
- >
- <NoteMapBody />
- </Modal>
- );
-}
-
-function NoteMapBody() {
- const { note } = useActiveNoteContext();
- const containerRef = useRef<HTMLDivElement>(null);
-
- if (!note) {
- return null;
- }
-
- return (
- <div class="note-map-modal-body" ref={containerRef}>
- <NoteMap note={note} widgetMode="expanded" parentRef={containerRef} />
- </div>
- );
-}