mirror of
https://github.com/zadam/trilium.git
synced 2025-10-09 15:08:14 +08:00
feat(views/geomap): display geolocation in empty menu
This commit is contained in:
parent
d31af2ddc2
commit
a1341e6036
2 changed files with 12 additions and 2 deletions
|
@ -1860,7 +1860,8 @@
|
||||||
},
|
},
|
||||||
"geo-map-context": {
|
"geo-map-context": {
|
||||||
"open-location": "Open location",
|
"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": {
|
"help-button": {
|
||||||
"title": "Open the relevant help page"
|
"title": "Open the relevant help page"
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import { LeafletMouseEvent } from "leaflet";
|
import type { LatLng, LeafletMouseEvent } from "leaflet";
|
||||||
import appContext from "../../../components/app_context.js";
|
import appContext from "../../../components/app_context.js";
|
||||||
import type { ContextMenuEvent } from "../../../menus/context_menu.js";
|
import type { ContextMenuEvent } from "../../../menus/context_menu.js";
|
||||||
import contextMenu from "../../../menus/context_menu.js";
|
import contextMenu from "../../../menus/context_menu.js";
|
||||||
import linkContextMenu from "../../../menus/link_context_menu.js";
|
import linkContextMenu from "../../../menus/link_context_menu.js";
|
||||||
import { t } from "../../../services/i18n.js";
|
import { t } from "../../../services/i18n.js";
|
||||||
import { createNewNote } from "./editing.js";
|
import { createNewNote } from "./editing.js";
|
||||||
|
import { copyTextWithToast } from "../../../services/clipboard_ext.js";
|
||||||
|
|
||||||
export default function openContextMenu(noteId: string, e: ContextMenuEvent) {
|
export default function openContextMenu(noteId: string, e: ContextMenuEvent) {
|
||||||
contextMenu.show({
|
contextMenu.show({
|
||||||
|
@ -38,6 +39,10 @@ export function openMapContextMenu(noteId: string, e: LeafletMouseEvent) {
|
||||||
x: e.originalEvent.pageX,
|
x: e.originalEvent.pageX,
|
||||||
y: e.originalEvent.pageY,
|
y: e.originalEvent.pageY,
|
||||||
items: [
|
items: [
|
||||||
|
{
|
||||||
|
title: formatGeoLocation(e.latlng),
|
||||||
|
handler: () => copyTextWithToast(formatGeoLocation(e.latlng, 15))
|
||||||
|
},
|
||||||
{ title: t("geo-map-context.add-note"), command: "addNoteToMap", uiIcon: "bx bx-plus" }
|
{ title: t("geo-map-context.add-note"), command: "addNoteToMap", uiIcon: "bx bx-plus" }
|
||||||
],
|
],
|
||||||
selectMenuItemHandler: ({ command }) => {
|
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)}`;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue