mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	feat(views/geomap): dragging notes that are not children
This commit is contained in:
		| @@ -1,13 +1,15 @@ | |||||||
| import type { Map } from "leaflet"; | import type { Map } from "leaflet"; | ||||||
| import type { DragData } from "../../note_tree.js"; | import type { DragData } from "../../note_tree.js"; | ||||||
| import { moveMarker } from "./editing"; | 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) => { |     $container.on("dragover", (e) => { | ||||||
|         // Allow drag. |         // Allow drag. | ||||||
|         e.preventDefault(); |         e.preventDefault(); | ||||||
|     }); |     }); | ||||||
|     $container.on("drop", (e) => { |     $container.on("drop", async (e) => { | ||||||
|         if (!e.originalEvent) { |         if (!e.originalEvent) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| @@ -30,7 +32,15 @@ export default function setupDragging($container: JQuery<HTMLElement>, map: Map) | |||||||
|             var y = e.originalEvent.clientY - (offset?.top ?? 0); |             var y = e.originalEvent.clientY - (offset?.top ?? 0); | ||||||
|  |  | ||||||
|             const latlng = map.containerPointToLatLng([ x, y ]); |             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) { |         } catch (e) { | ||||||
|             console.warn(e); |             console.warn(e); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -159,7 +159,7 @@ export default class GeoView extends ViewMode<MapData> { | |||||||
|         map.on("zoomend", updateFn); |         map.on("zoomend", updateFn); | ||||||
|         map.on("click", (e) => this.#onMapClicked(e)) |         map.on("click", (e) => this.#onMapClicked(e)) | ||||||
|         map.on("contextmenu", (e) => openMapContextMenu(this.parentNote.noteId, e)); |         map.on("contextmenu", (e) => openMapContextMenu(this.parentNote.noteId, e)); | ||||||
|         setupDragging(this.$container, map); |         setupDragging(this.$container, map, this.parentNote.noteId); | ||||||
|  |  | ||||||
|         this.#reloadMarkers(); |         this.#reloadMarkers(); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user