mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 17:51:24 +01:00
v1.4.36
This commit is contained in:
parent
f14ca97fb4
commit
f424f242da
7 changed files with 231 additions and 212 deletions
|
|
@ -5,6 +5,18 @@ function editNotes(id, name) {
|
|||
select.options.length = 0;
|
||||
for (const note of notes) {select.options.add(new Option(note.id, note.id));}
|
||||
|
||||
// initiate pell (html editor)
|
||||
const editor = Pell.init({
|
||||
element: document.getElementById("notesText"),
|
||||
onChange: html => {
|
||||
const id = document.getElementById("notesSelect").value;
|
||||
const note = notes.find(note => note.id === id);
|
||||
if (!note) return;
|
||||
note.legend = html;
|
||||
showNote(note);
|
||||
}
|
||||
});
|
||||
|
||||
// select an object
|
||||
if (notes.length || id) {
|
||||
if (!id) id = notes[0].id;
|
||||
|
|
@ -17,18 +29,18 @@ function editNotes(id, name) {
|
|||
}
|
||||
select.value = id;
|
||||
notesName.value = note.name;
|
||||
notesText.value = note.legend;
|
||||
editor.content.innerHTML = note.legend;
|
||||
showNote(note);
|
||||
} else {
|
||||
const value = "There are no added notes. Click on element (e.g. label) and add a free text note";
|
||||
document.getElementById("notesText").value = value;
|
||||
editor.content.innerHTML = "There are no added notes. Click on element (e.g. label) and add a free text note";
|
||||
document.getElementById("notesName").value = "";
|
||||
}
|
||||
|
||||
// open a dialog
|
||||
$("#notesEditor").dialog({
|
||||
title: "Notes Editor", minWidth: "40em",
|
||||
position: {my: "center", at: "center", of: "svg"}
|
||||
position: {my: "center", at: "center", of: "svg"},
|
||||
close: () => notesText.innerHTML = ""
|
||||
});
|
||||
|
||||
if (modules.editNotes) return;
|
||||
|
|
@ -37,7 +49,6 @@ function editNotes(id, name) {
|
|||
// add listeners
|
||||
document.getElementById("notesSelect").addEventListener("change", changeObject);
|
||||
document.getElementById("notesName").addEventListener("input", changeName);
|
||||
document.getElementById("notesText").addEventListener("input", changeText);
|
||||
document.getElementById("notesPin").addEventListener("click", () => options.pinNotes = !options.pinNotes);
|
||||
document.getElementById("notesFocus").addEventListener("click", validateHighlightElement);
|
||||
document.getElementById("notesDownload").addEventListener("click", downloadLegends);
|
||||
|
|
@ -55,7 +66,7 @@ function editNotes(id, name) {
|
|||
const note = notes.find(note => note.id === this.value);
|
||||
if (!note) return;
|
||||
notesName.value = note.name;
|
||||
notesText.value = note.legend;
|
||||
editor.content.innerHTML = note.legend;
|
||||
}
|
||||
|
||||
function changeName() {
|
||||
|
|
@ -66,14 +77,6 @@ function editNotes(id, name) {
|
|||
showNote(note);
|
||||
}
|
||||
|
||||
function changeText() {
|
||||
const id = document.getElementById("notesSelect").value;
|
||||
const note = notes.find(note => note.id === id);
|
||||
if (!note) return;
|
||||
note.legend = this.value;
|
||||
showNote(note);
|
||||
}
|
||||
|
||||
function validateHighlightElement() {
|
||||
const select = document.getElementById("notesSelect");
|
||||
const element = document.getElementById(select.value);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue