diff --git a/apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsx b/apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsx index c342d257d..06b224202 100644 --- a/apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsx +++ b/apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsx @@ -360,7 +360,7 @@ function NoteBox({ noteId, x, y, mapApiRef }: MapDataNoteEntry & { mapApiRef: Re return note && ( diff --git a/apps/client/src/widgets/type_widgets/relation_map/api.ts b/apps/client/src/widgets/type_widgets/relation_map/api.ts index e80fcab0a..16b25a634 100644 --- a/apps/client/src/widgets/type_widgets/relation_map/api.ts +++ b/apps/client/src/widgets/type_widgets/relation_map/api.ts @@ -1,4 +1,5 @@ import FNote from "../../../entities/fnote"; +import { t } from "../../../services/i18n"; import server from "../../../services/server"; import utils from "../../../services/utils"; @@ -65,4 +66,17 @@ export default class RelationMapApi { } } + moveNote(noteId: string, x: number, y: number) { + const note = this.data?.notes.find((note) => note.noteId === noteId); + + if (!note) { + logError(t("relation_map.note_not_found", { noteId })); + return; + } + + note.x = x; + note.y = y; + this.onDataChange(false); + } + } diff --git a/apps/client/src/widgets/type_widgets_old/relation_map.ts b/apps/client/src/widgets/type_widgets_old/relation_map.ts index 82a272961..41a9a728d 100644 --- a/apps/client/src/widgets/type_widgets_old/relation_map.ts +++ b/apps/client/src/widgets/type_widgets_old/relation_map.ts @@ -215,32 +215,6 @@ export default class RelationMapTypeWidget extends TypeWidget { } async createNoteBox(noteId: string, title: string, x: number, y: number) { - if (!this.jsPlumbInstance) { - return; - } - - this.jsPlumbInstance.getContainer().appendChild($noteBox[0]); - - this.jsPlumbInstance.draggable($noteBox[0], { - start: (params) => {}, - drag: (params) => {}, - stop: (params) => { - const noteId = this.idToNoteId(params.el.id); - - const note = this.mapData?.notes.find((note) => note.noteId === noteId); - - if (!note) { - logError(t("relation_map.note_not_found", { noteId })); - return; - } - - //@ts-expect-error TODO: Check if this is still valid. - [note.x, note.y] = params.finalPos; - - this.saveData(); - } - }); - this.jsPlumbInstance.makeSource($noteBox[0], { filter: ".endpoint", anchor: "Continuous",