diff --git a/web/sequence_prompt_builder.js b/web/sequence_prompt_builder.js index 3df1ff5..0bd5178 100644 --- a/web/sequence_prompt_builder.js +++ b/web/sequence_prompt_builder.js @@ -35,10 +35,21 @@ function configure(node) { hide(stateWidget); const panel = el("div"); panel.style.cssText = "box-sizing:border-box;width:calc(100% + 14px);margin-left:-7px;min-width:420px;padding:9px;color:#d9e3dc;background:#292929;border:1px solid #454545;border-radius:4px;font:12px Arial;pointer-events:auto"; - const host = el("div"); host.style.cssText = "pointer-events:auto;background:#292929;width:100%;margin-top:-7px;margin-bottom:-7px"; host.append(panel); + const host = el("div"); host.style.cssText = "box-sizing:border-box;pointer-events:auto;background:#292929;width:100%"; host.append(panel); ["pointerdown", "mousedown", "mouseup", "dblclick"].forEach((name) => host.addEventListener(name, (event) => event.stopPropagation())); const display = node.addDOMWidget("clip_tabs", "dumas_h3_clip_tabs", host, { serialize: false }); display.options ||= {}; display.options.serialize = false; + let panelHeight = 54; + const reservePanelSpace = (height) => { + panelHeight = Math.max(0, Math.ceil(Number(height) || 0)); + panel.style.height = `${panelHeight}px`; + const computedHeight = Number(node.computeSize?.()[1]); + const width = Number(node.size?.[0]) || 420; + if (Number.isFinite(computedHeight) && typeof node.setSize === "function" + && (Number(node.size?.[0]) !== width || Number(node.size?.[1]) !== computedHeight)) { + node.setSize([width, computedHeight]); + } + }; let active = 0; let state = readState(stateWidget, Number(countWidget.value) || 2, Number(secondsWidget.value) || 4); let promptText = null; @@ -260,11 +271,9 @@ function configure(node) { // The editor now contains chips, the prompt check and encoder summary; // the old slot-count estimate left a large blank tail in the node. // Measure the actual DOM panel instead of guessing from slot count. - const panelHeight = Math.ceil(panel.getBoundingClientRect().height || panel.scrollHeight || 0); - // LiteGraph adds roughly 7px above and below a DOM widget wrapper; - // those pixels are not part of the panel and otherwise appear as a - // vertical tail beneath/around the editor. - display.computeSize = (width) => [Math.max(420, Number(width) || 420), Math.max(0, panelHeight - 14)]; + const measuredHeight = Math.ceil(panel.getBoundingClientRect().height || panel.scrollHeight || 0); + display.computeSize = (width) => [Math.max(420, Number(width) || 420), panelHeight + 2]; + reservePanelSpace(measuredHeight); }; const refresh = () => { state = readState(stateWidget, Number(countWidget.value) || 2, Number(secondsWidget.value) || 4); render(); setState(); }; countWidget.callback = ((previous) => function(...args) { const result = previous?.apply(this, args); refresh(); return result; })(countWidget.callback);