diff --git a/src/dialogs/dialogs/label-editor.js b/src/dialogs/dialogs/label-editor.js index 6c7aaf10..cf242fb4 100644 --- a/src/dialogs/dialogs/label-editor.js +++ b/src/dialogs/dialogs/label-editor.js @@ -14,6 +14,8 @@ export function open({el}) { closeDialogs(); if (!layerIsOn("toggleLabels")) toggleLayer("toggleLabels"); + const lineGen = d3.line().curve(d3.curveBundle.beta(1)); + const textPath = el.parentNode; const text = textPath.parentNode; elSelected = d3.select(text).call(d3.drag().on("start", dragLabel)).classed("draggable", true); @@ -123,8 +125,6 @@ export function open({el}) { redrawLabelPath(); } - const lineGen = d3.line().curve(d3.curveBundle.beta(1)); - function redrawLabelPath() { const path = byId("textPath_" + elSelected.attr("id")); const points = []; @@ -308,26 +308,12 @@ export function open({el}) { function changeText() { const input = byId("labelText").value; const el = elSelected.select("textPath").node(); - const example = d3 - .select(elSelected.node().parentNode) - .append("text") - .attr("x", 0) - .attr("x", 0) - .attr("font-size", el.getAttribute("font-size")) - .node(); const lines = input.split("|"); const top = (lines.length - 1) / -2; // y offset - const inner = lines - .map((l, d) => { - example.innerHTML = l; - const left = example.getBBox().width / -2; // x offset - return `${l}`; - }) - .join(""); + const inner = lines.map((l, d) => `${l}`).join(""); el.innerHTML = inner; - example.remove(); if (elSelected.attr("id").slice(0, 10) === "stateLabel") tip("Use States Editor to change an actual state name, not just a label", false, "warning");