mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 01:41:22 +01:00
notes editor - clear on open
This commit is contained in:
parent
648c0ac0c9
commit
e2ffb446dd
2 changed files with 8 additions and 5 deletions
|
|
@ -8,6 +8,8 @@ function editMarker(markerI) {
|
||||||
|
|
||||||
elSelected = d3.select(element).raise().call(d3.drag().on("start", dragMarker)).classed("draggable", true);
|
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
|
// dom elements
|
||||||
const markerType = document.getElementById("markerType");
|
const markerType = document.getElementById("markerType");
|
||||||
const markerIcon = document.getElementById("markerIcon");
|
const markerIcon = document.getElementById("markerIcon");
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function editNotes(id, name) {
|
function editNotes(id, name) {
|
||||||
// update list of objects
|
// update list of objects
|
||||||
const select = document.getElementById("notesSelect");
|
const select = document.getElementById("notesSelect");
|
||||||
|
|
@ -8,11 +9,12 @@ function editNotes(id, name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// initiate pell (html editor)
|
// initiate pell (html editor)
|
||||||
|
const notesText = document.getElementById("notesText");
|
||||||
|
notesText.innerHTML = "";
|
||||||
const editor = Pell.init({
|
const editor = Pell.init({
|
||||||
element: document.getElementById("notesText"),
|
element: notesText,
|
||||||
onChange: html => {
|
onChange: html => {
|
||||||
const id = document.getElementById("notesSelect").value;
|
const note = notes.find(note => note.id === select.value);
|
||||||
const note = notes.find(note => note.id === id);
|
|
||||||
if (!note) return;
|
if (!note) return;
|
||||||
note.legend = html;
|
note.legend = html;
|
||||||
showNote(note);
|
showNote(note);
|
||||||
|
|
@ -43,8 +45,7 @@ function editNotes(id, name) {
|
||||||
title: "Notes Editor",
|
title: "Notes Editor",
|
||||||
minWidth: "40em",
|
minWidth: "40em",
|
||||||
width: "50vw",
|
width: "50vw",
|
||||||
position: {my: "center", at: "center", of: "svg"},
|
position: {my: "center", at: "center", of: "svg"}
|
||||||
close: () => (notesText.innerHTML = "")
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (modules.editNotes) return;
|
if (modules.editNotes) return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue