mirror of
https://github.com/zadam/trilium.git
synced 2025-10-02 11:35:41 +08:00
feat(views/geomap): dragging notes that are not children
This commit is contained in:
parent
2a665dffbc
commit
63c408c45b
2 changed files with 14 additions and 4 deletions
|
@ -1,13 +1,15 @@
|
|||
import type { Map } from "leaflet";
|
||||
import type { DragData } from "../../note_tree.js";
|
||||
import { moveMarker } from "./editing";
|
||||
import froca from "../../../services/froca.js";
|
||||
import branches from "../../../services/branches.js";
|
||||
|
||||
export default function setupDragging($container: JQuery<HTMLElement>, map: Map) {
|
||||
export default function setupDragging($container: JQuery<HTMLElement>, map: Map, mapNoteId: string) {
|
||||
$container.on("dragover", (e) => {
|
||||
// Allow drag.
|
||||
e.preventDefault();
|
||||
});
|
||||
$container.on("drop", (e) => {
|
||||
$container.on("drop", async (e) => {
|
||||
if (!e.originalEvent) {
|
||||
return;
|
||||
}
|
||||
|
@ -30,7 +32,15 @@ export default function setupDragging($container: JQuery<HTMLElement>, map: Map)
|
|||
var y = e.originalEvent.clientY - (offset?.top ?? 0);
|
||||
|
||||
const latlng = map.containerPointToLatLng([ x, y ]);
|
||||
moveMarker(noteId, latlng);
|
||||
|
||||
const note = await froca.getNote(noteId, true);
|
||||
const parents = note?.getParentNoteIds();
|
||||
if (parents?.includes(mapNoteId)) {
|
||||
await moveMarker(noteId, latlng);
|
||||
} else {
|
||||
await branches.cloneNoteToParentNote(noteId, mapNoteId);
|
||||
await moveMarker(noteId, latlng);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn(e);
|
||||
}
|
||||
|
|
|
@ -159,7 +159,7 @@ export default class GeoView extends ViewMode<MapData> {
|
|||
map.on("zoomend", updateFn);
|
||||
map.on("click", (e) => this.#onMapClicked(e))
|
||||
map.on("contextmenu", (e) => openMapContextMenu(this.parentNote.noteId, e));
|
||||
setupDragging(this.$container, map);
|
||||
setupDragging(this.$container, map, this.parentNote.noteId);
|
||||
|
||||
this.#reloadMarkers();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue