From e2ffb446dd5f1c90a971b4d2fa8d0fa34e29299a Mon Sep 17 00:00:00 2001 From: Azgaar Date: Thu, 7 Oct 2021 13:34:08 +0300 Subject: [PATCH] notes editor - clear on open --- modules/ui/markers-editor.js | 2 ++ modules/ui/notes-editor.js | 11 ++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/ui/markers-editor.js b/modules/ui/markers-editor.js index 907e1860..d1f1cba4 100644 --- a/modules/ui/markers-editor.js +++ b/modules/ui/markers-editor.js @@ -8,6 +8,8 @@ function editMarker(markerI) { elSelected = d3.select(element).raise().call(d3.drag().on("start", dragMarker)).classed("draggable", true); + if (document.getElementById("notesEditor").offsetParent) editNotes(element.id, element.id); + // dom elements const markerType = document.getElementById("markerType"); const markerIcon = document.getElementById("markerIcon"); diff --git a/modules/ui/notes-editor.js b/modules/ui/notes-editor.js index 24e8fa56..3ad4b979 100644 --- a/modules/ui/notes-editor.js +++ b/modules/ui/notes-editor.js @@ -1,4 +1,5 @@ "use strict"; + function editNotes(id, name) { // update list of objects const select = document.getElementById("notesSelect"); @@ -8,11 +9,12 @@ function editNotes(id, name) { } // initiate pell (html editor) + const notesText = document.getElementById("notesText"); + notesText.innerHTML = ""; const editor = Pell.init({ - element: document.getElementById("notesText"), + element: notesText, onChange: html => { - const id = document.getElementById("notesSelect").value; - const note = notes.find(note => note.id === id); + const note = notes.find(note => note.id === select.value); if (!note) return; note.legend = html; showNote(note); @@ -43,8 +45,7 @@ function editNotes(id, name) { title: "Notes Editor", minWidth: "40em", width: "50vw", - position: {my: "center", at: "center", of: "svg"}, - close: () => (notesText.innerHTML = "") + position: {my: "center", at: "center", of: "svg"} }); if (modules.editNotes) return;