|
|
@ -2,7 +2,7 @@
|
|
|
|
const container = document.getElementById("container");
|
|
|
|
const container = document.getElementById("container");
|
|
|
|
const editor = document.getElementById("editor");
|
|
|
|
const editor = document.getElementById("editor");
|
|
|
|
|
|
|
|
|
|
|
|
const textForm = document.getElementById("text-form");
|
|
|
|
const textForm = document.getElementsByClassName("text-input")[0];
|
|
|
|
const input = document.getElementById("input");
|
|
|
|
const input = document.getElementById("input");
|
|
|
|
const insert = document.getElementById("insert");
|
|
|
|
const insert = document.getElementById("insert");
|
|
|
|
const cancel = document.getElementById("cancel");
|
|
|
|
const cancel = document.getElementById("cancel");
|
|
|
@ -96,12 +96,18 @@ function drawLabel() {
|
|
|
|
|
|
|
|
|
|
|
|
if (width > minimumSizeX && height > minimumSizeY) {
|
|
|
|
if (width > minimumSizeX && height > minimumSizeY) {
|
|
|
|
// Create a label and push it into the array of labels
|
|
|
|
// Create a label and push it into the array of labels
|
|
|
|
|
|
|
|
let temporaryLabel = createLabel(minX, minY, width, height, labels.length);
|
|
|
|
|
|
|
|
temporaryLabel.classList.add("temporary");
|
|
|
|
|
|
|
|
temporaryLabel.id = "temporary-label";
|
|
|
|
|
|
|
|
container.appendChild(temporaryLabel);
|
|
|
|
|
|
|
|
|
|
|
|
new Promise(function (resolve, reject) {
|
|
|
|
new Promise(function (resolve, reject) {
|
|
|
|
// TODO: show the modal for text input in overlay
|
|
|
|
// TODO: show the modal for text input in overlay
|
|
|
|
// TODO: temp editor freeze before the label is created
|
|
|
|
|
|
|
|
// then if the user click insert and there is a value in the input-- > resolve the promise and return the text input to create the label,
|
|
|
|
// then if the user click insert and there is a value in the input-- > resolve the promise and return the text input to create the label,
|
|
|
|
// if the user click cancel-- > reject the promise and don't create the label
|
|
|
|
// if the user click cancel-- > reject the promise and don't create the label
|
|
|
|
|
|
|
|
textForm.classList.add("visible");
|
|
|
|
|
|
|
|
|
|
|
|
input.focus();
|
|
|
|
input.focus();
|
|
|
|
|
|
|
|
|
|
|
|
// Insert button
|
|
|
|
// Insert button
|
|
|
@ -116,6 +122,7 @@ function drawLabel() {
|
|
|
|
cancel.addEventListener("click", (e) => {
|
|
|
|
cancel.addEventListener("click", (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
e.preventDefault();
|
|
|
|
reject("no input");
|
|
|
|
reject("no input");
|
|
|
|
|
|
|
|
textForm.classList.remove("visible");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}).then(() => {
|
|
|
|
}).then(() => {
|
|
|
|
// Create the label
|
|
|
|
// Create the label
|
|
|
@ -127,12 +134,15 @@ function drawLabel() {
|
|
|
|
text.innerHTML = input.value;
|
|
|
|
text.innerHTML = input.value;
|
|
|
|
label.appendChild(text);
|
|
|
|
label.appendChild(text);
|
|
|
|
|
|
|
|
|
|
|
|
// labels.push(label);
|
|
|
|
labels.push(label);
|
|
|
|
container.appendChild(label);
|
|
|
|
container.appendChild(label);
|
|
|
|
|
|
|
|
|
|
|
|
// Reset the modal
|
|
|
|
// Reset the modal
|
|
|
|
input.value = "";
|
|
|
|
input.value = "";
|
|
|
|
input.blur();
|
|
|
|
input.blur();
|
|
|
|
|
|
|
|
let tempLabel = document.getElementById("temporary-label");
|
|
|
|
|
|
|
|
container.removeChild(tempLabel);
|
|
|
|
|
|
|
|
textForm.classList.remove("visible");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|