Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(relation_map): list the map's keyboard shortcuts
Elian Doran6402a8a53944
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 3f89b68332..9374b19394 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1674,7 +1674,12 @@"restore_note_pane": "Put the note back beside the map","note_color": "Note color","remove_from_map": "Remove from map",- "fit_to_view": "Fit to view"+ "fit_to_view": "Fit to view",+ "hints": {+ "title": "Relation map",+ "cancel_adding_note": "Cancel adding a note",+ "close_note_pane": "Close the note panel"+ }},"render": {"setup_title": "Display custom HTML or Preact JSX inside this note",diff --git a/apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsx b/apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsxindex 736a7b851a..d759ac56d7 100644--- a/apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsx+++ b/apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsx@@ -13,11 +13,12 @@ import { t } from "../../../services/i18n";import { goToLinkExt } from "../../../services/link";import note_create from "../../../services/note_create";import server from "../../../services/server";+import type { ShortcutHintDefinition } from "../../../services/shortcut_hints";import toast from "../../../services/toast";import { isMobile } from "../../../services/utils";-import { useEditorSpacedUpdate, useNoteLabelBoolean } from "../../react/hooks";+import { useContextualShortcutHints, useEditorSpacedUpdate, useNoteLabelBoolean } from "../../react/hooks";import { useZoomPanPinch, useZoomPanWheel } from "../../react/zoom_pan";-import { useZoomPanKeyboard } from "../../react/zoom_pan_keyboard";+import { useZoomPanKeyboard, ZOOM_PAN_HINTS } from "../../react/zoom_pan_keyboard";import ShortcutHintButton from "../../shortcut_hints/shortcut_hint_button";import { TypeWidgetProps } from "../type_widget";import RelationMapApi, { ClientRelation, MapData, MapDataNoteEntry, MapTransform } from "./api";@@ -122,6 +123,7 @@ export default function RelationMap({ note, noteContext, ntxId }: TypeWidgetPropboxesRef.current = boxes;useRevealSelectedBox({ wrapperRef, containerRef, moveBy: mapZoom.moveBy, noteId: selection?.noteId });+ useContextualShortcutHints(RELATION_MAP_HINTS);const hoveredNoteId = useHoveredBox(containerRef);const [ hoveredRelationId, setHoveredRelationId ] = useState<string | null>(null);const { relations, inverseRelations } = useRelationData(note.noteId, data, mapApiRef);@@ -293,6 +295,18 @@ export function MapViewport({ zoom, viewportRef, children }: {);}+/** The zoom and pan keys of the viewport, and the keys of placement mode and the note pane. */+const RELATION_MAP_HINTS: ShortcutHintDefinition = [+ ...ZOOM_PAN_HINTS,+ {+ titleKey: "relation_map.hints.title",+ hints: [+ { keys: [ "Escape" ], labelKey: "relation_map.hints.cancel_adding_note" },+ { keys: [ "Escape" ], labelKey: "relation_map.hints.close_note_pane" }+ ]+ }+];+/** The zoom range of the map. */const MIN_SCALE = 0.3;const MAX_SCALE = 2;diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Relation Map.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Relation Map.htmlindex d1f4179ae6..1a9c23243f 100644--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Relation Map.html+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Note Types/Relation Map.html@@ -57,7 +57,13 @@<li>To move around the map, drag an empty part of it, and zoom with the mousewheel or the buttons at the bottom-right corner. Clicking the zoom percentagegoes back to 100%, and <span class="tn-icon bx bx-scan"></span> <em>Fit to view</em> zooms- and pans so that all the notes are visible.</li>+ and pans so that all the notes are visible.+ <ul>+ <li>Once the map has been clicked, the arrow keys or <kbd>W</kbd> <kbd>A</kbd> <kbd>S</kbd> <kbd>D</kbd> pan+ it, and <kbd>+</kbd> and <kbd>-</kbd> zoom it. The <kbd>?</kbd> button at the+ top-right corner of the map lists all its keyboard shortcuts.</li>+ </ul>+ </li></ul><h2>Note panel</h2><p>When a note on the map is clicked, a panel opens to the right of the mapdiff --git a/docs/User Guide/User Guide/Note Types/Relation Map.md b/docs/User Guide/User Guide/Note Types/Relation Map.mdindex b73346314e..137f0eeab2 100644--- a/docs/User Guide/User Guide/Note Types/Relation Map.md+++ b/docs/User Guide/User Guide/Note Types/Relation Map.md@@ -20,6 +20,7 @@ Relation map is a type of note which visualizes notes and their [relations](..* To edit the title of a note, change its color or delete it (either from the map, or delete it completely), right click the note. The color picker is not shown if the map is read-only.* To rename or delete a relationship, right click it and select the corresponding option.* To move around the map, drag an empty part of it, and zoom with the mouse wheel or the buttons at the bottom-right corner. Clicking the zoom percentage goes back to 100%, and <span class="tn-icon bx bx-scan"></span> _Fit to view_ zooms and pans so that all the notes are visible.+ * Once the map has been clicked, the arrow keys or <kbd>W</kbd> <kbd>A</kbd> <kbd>S</kbd> <kbd>D</kbd> pan it, and <kbd>+</kbd> and <kbd>-</kbd> zoom it. The <kbd>?</kbd> button at the top-right corner of the map lists all its keyboard shortcuts.## Note panel