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(views/geomap): display geolocation in empty menu
Elian Dorana1341e6036f1
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 4470852a9a..00cb9f2273 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1860,7 +1860,8 @@},"geo-map-context": {"open-location": "Open location",- "remove-from-map": "Remove from map"+ "remove-from-map": "Remove from map",+ "add-note": "Add a marker at this location"},"help-button": {"title": "Open the relevant help page"diff --git a/apps/client/src/widgets/view_widgets/geo_view/context_menu.ts b/apps/client/src/widgets/view_widgets/geo_view/context_menu.tsindex 410064f0f2..331beac055 100644--- a/apps/client/src/widgets/view_widgets/geo_view/context_menu.ts+++ b/apps/client/src/widgets/view_widgets/geo_view/context_menu.ts@@ -1,10 +1,11 @@-import { LeafletMouseEvent } from "leaflet";+import type { LatLng, LeafletMouseEvent } from "leaflet";import appContext from "../../../components/app_context.js";import type { ContextMenuEvent } from "../../../menus/context_menu.js";import contextMenu from "../../../menus/context_menu.js";import linkContextMenu from "../../../menus/link_context_menu.js";import { t } from "../../../services/i18n.js";import { createNewNote } from "./editing.js";+import { copyTextWithToast } from "../../../services/clipboard_ext.js";export default function openContextMenu(noteId: string, e: ContextMenuEvent) {contextMenu.show({@@ -38,6 +39,10 @@ export function openMapContextMenu(noteId: string, e: LeafletMouseEvent) {x: e.originalEvent.pageX,y: e.originalEvent.pageY,items: [+ {+ title: formatGeoLocation(e.latlng),+ handler: () => copyTextWithToast(formatGeoLocation(e.latlng, 15))+ },{ title: t("geo-map-context.add-note"), command: "addNoteToMap", uiIcon: "bx bx-plus" }],selectMenuItemHandler: ({ command }) => {@@ -51,3 +56,7 @@ export function openMapContextMenu(noteId: string, e: LeafletMouseEvent) {}});}++function formatGeoLocation(latlng: LatLng, precision: number = 6) {+ return `${latlng.lat.toFixed(precision)}, ${latlng.lng.toFixed(precision)}`;+}