diff --git a/modules/dynamic/hierarchy-tree.js b/modules/dynamic/hierarchy-tree.js index 95093790..6cd25f0e 100644 --- a/modules/dynamic/hierarchy-tree.js +++ b/modules/dynamic/hierarchy-tree.js @@ -68,13 +68,27 @@ function appendStyleSheet() { margin: 0 2px; } - .hierarchyTree_selectedButton { + #hierarchyTree { + display: flex; + flex-direction: column; + justify-content: space-between; + } + + #hierarchyTree > svg { + height: 100%; + } + + .hierarchyTree_selectedOrigins { + margin-right: 15px; + } + + .hierarchyTree_selectedOrigin { border: 1px solid #aaa; background: none; padding: 1px 4px; } - .hierarchyTree_selectedButton:hover { + .hierarchyTree_selectedOrigin:hover { border: 1px solid #333; } @@ -88,6 +102,10 @@ function appendStyleSheet() { color: #333; } + #hierarchyTree_originSelector { + display: none; + } + #hierarchyTree_originSelector > form > div { padding: 0.3em; margin: 1px 0; @@ -147,8 +165,8 @@ function insertHtml() { . Abbreviation: Origins: - - + +
@@ -237,12 +255,18 @@ function renderTree(root, treeLayout) { .call(d3.drag().on("start", dragToReorigin)); node - .append("path") - .attr("d", ({data}) => shapesMap[getShape(data)]) + .selectAll("path") + .data(d => [d]) + .join("path") + .attr("d", d => shapesMap[getShape(d.data)]) .attr("fill", d => d.data.color || "#ffffff") .attr("stroke-dasharray", d => (d.data.cells ? "none" : "1")); - node.append("text").text(d => d.data.code || ""); + node + .selectAll("text") + .data(d => [d]) + .join("text") + .text(d => d.data.code || ""); } function mapCoords(newRoot, prevRoot) { @@ -320,6 +344,7 @@ function updateTree() { function selectElement(d) { const dataElement = d.data; + if (d.id == 0) return; const node = nodes.select(`g[data-id="${d.id}"]`); nodes.selectAll("g").style("outline", "none"); @@ -453,6 +478,8 @@ function handleNodeExit(d) { } function dragToReorigin(from) { + if (from.id == 0) return; + dragLine.attr("d", `M${from.x},${from.y}L${from.x},${from.y}`); d3.event.on("drag", () => { diff --git a/modules/dynamic/supporters.js b/modules/dynamic/supporters.js index 35a22313..038da4d8 100644 --- a/modules/dynamic/supporters.js +++ b/modules/dynamic/supporters.js @@ -40,5 +40,5 @@ export const supporters = format(` Jordan,William Markus,Sidr Dim,Alexander Whittaker,The Next Level,Patrick Valverde,Markus Peham,Daniel Cooper,the Beagles of Neorbus,Marley Moule, Maximilian Schielke,Johnathan Xavier Hutchinson,Ele,Rita,Randy Ross,John Wick,RedSpaz,cameron cannon,Ian Grau-Fay,Kyle Barrett,Charlotte Wiland, David Kaul,E. Jason Davis,Cyberate,Atenfox,Sea Wolf,Holly Loveless,Roekai,Alden Z,angel carrillo,Sam Spoerle,S A Rudy,Bird Law Expert,Mira Cyr, - Aaron Blair,Neyimadd,RLKZ1022,DerWolf,Kenji Yamada,Zion + Aaron Blair,Neyimadd,RLKZ1022,DerWolf,Kenji Yamada,Zion,Robert Rinne,Actual_Dio,Kyarou `); diff --git a/modules/ui/hotkeys.js b/modules/ui/hotkeys.js index 2c5a9a3a..d8fcaaf8 100644 --- a/modules/ui/hotkeys.js +++ b/modules/ui/hotkeys.js @@ -4,6 +4,8 @@ document.addEventListener("keydown", handleKeydown); document.addEventListener("keyup", handleKeyup); function handleKeydown(event) { + if (!allowHotkeys()) return; // in some cases (e.g. in a textarea) hotkeys are not allowed + const {code, ctrlKey, altKey} = event; if (altKey && !ctrlKey) event.preventDefault(); // disallow alt key combinations if (ctrlKey && ["KeyS", "KeyC"].includes(code)) event.preventDefault(); // disallow CTRL + S and CTRL + C @@ -12,11 +14,8 @@ function handleKeydown(event) { function handleKeyup(event) { if (!modules.editors) return; // if editors are not loaded, do nothing + if (!allowHotkeys()) return; // in some cases (e.g. in a textarea) hotkeys are not allowed - const {tagName, contentEditable} = document.activeElement; - if (["INPUT", "SELECT", "TEXTAREA"].includes(tagName)) return; // don't trigger if user inputs text - if (tagName === "DIV" && contentEditable === "true") return; // don't trigger if user inputs a text - if (document.getSelection().toString()) return; // don't trigger if user selects text event.stopPropagation(); const {code, key, ctrlKey, metaKey, shiftKey, altKey} = event; @@ -110,6 +109,14 @@ function handleKeyup(event) { else if (ctrl) toggleMode(); } +function allowHotkeys() { + const {tagName, contentEditable} = document.activeElement; + if (["INPUT", "SELECT", "TEXTAREA"].includes(tagName)) return false; + if (tagName === "DIV" && contentEditable === "true") return false; + if (document.getSelection().toString()) return false; + return true; +} + function pressNumpadSign(key) { const change = key === "+" ? 1 : -1; let brush = null; diff --git a/modules/ui/options.js b/modules/ui/options.js index ddbc7a5f..0683a694 100644 --- a/modules/ui/options.js +++ b/modules/ui/options.js @@ -76,7 +76,7 @@ document // show popup with a list of Patreon supportes (updated manually) async function showSupporters() { - const {supporters} = await import("../dynamic/supporters.js?v=01062022"); + const {supporters} = await import("../dynamic/supporters.js?v=19062022"); alertMessage.innerHTML = ""; $("#alert").dialog({