From b6f959097b3bbe212fa5f65b765be243afd779c0 Mon Sep 17 00:00:00 2001 From: NineKey Date: Sun, 13 Sep 2026 00:41:23 +0800 Subject: [PATCH] Hide legacy prompt DOM widgets across workflow switches --- web/dynamic_loader.js | 24 +++++++++--------------- web/dynamic_utils.js | 28 ++-------------------------- 2 files changed, 11 insertions(+), 41 deletions(-) diff --git a/web/dynamic_loader.js b/web/dynamic_loader.js index a640bd2..3b0212c 100644 --- a/web/dynamic_loader.js +++ b/web/dynamic_loader.js @@ -6,6 +6,7 @@ function ensureComposerStyles() { const style = document.createElement("style"); style.id = "dynamic-tag-composer-style"; style.textContent = ` + .dynamic-tag-storage-widget { display: none !important; } .dynamic-tag-composer-host { position: relative; box-sizing: border-box; width: 100%; height: 100%; min-height: 96px; } .dynamic-tag-composer { position: relative; z-index: 1; box-sizing: border-box; width: 100%; height: 100%; min-height: 96px; padding: 7px; overflow: auto; color: #e8e8e8; background: #171725; border: 1px solid #3b3b5b; border-radius: 5px; @@ -42,6 +43,10 @@ app.registerExtension({ const settingsWidget = node.widgets.find(w => w.name === "tag_settings"); if (settingsWidget) { settingsWidget.type = "hidden"; + settingsWidget.hidden = true; + settingsWidget.options ??= {}; + settingsWidget.options.hidden = true; + settingsWidget.element?.classList.add("dynamic-tag-storage-widget"); settingsWidget.computeSize = () => [0, -4]; } const textInputWidget = node.widgets.find(w => w.name === "text_input"); @@ -49,6 +54,10 @@ app.registerExtension({ for (const widget of [textInputWidget, inlinePromptWidget]) { if (widget) { widget.type = "hidden"; + widget.hidden = true; + widget.options ??= {}; + widget.options.hidden = true; + widget.element?.classList.add("dynamic-tag-storage-widget"); widget.computeSize = () => [0, -4]; } } @@ -727,24 +736,9 @@ app.registerExtension({ const originalOnRemoved = node.onRemoved; const originalWidgetOnRemove = composerWidget.onRemove; let composerDisposed = false; - const healComposerHeight = () => { - if (!composerDisposed) node._healRunawayHeight?.(); - }; - const composerResizeObserver = new ResizeObserver(healComposerHeight); - composerResizeObserver.observe(composerHost); - const originalOnSelected = node.onSelected; - node.onSelected = function() { - const result = originalOnSelected?.apply(this, arguments); - requestAnimationFrame(healComposerHeight); - return result; - }; - requestAnimationFrame(healComposerHeight); - setTimeout(healComposerHeight, 0); - setTimeout(healComposerHeight, 250); const disposeComposer = () => { if (composerDisposed) return; composerDisposed = true; - composerResizeObserver.disconnect(); closeMenu(); menu.remove(); document.removeEventListener("pointerdown", closeMenuOutside, true); diff --git a/web/dynamic_utils.js b/web/dynamic_utils.js index f9d8b6f..78ef3da 100644 --- a/web/dynamic_utils.js +++ b/web/dynamic_utils.js @@ -59,32 +59,15 @@ export function getDynamicGroupMenu(index, totalLength, moveCallback, moveAbsCal * 2. 防止新增項目時擠壓現有組件 (Growth Logic) */ export function setupSizeManager(node) { - const MAX_RESTORED_EXTRA_HEIGHT = 480; - const MAX_RESTORED_HEIGHT = 900; - const initialMinHeight = node.computeSize?.()[1] || 0; node._userMinHeight = 0; node._isResizing = false; - const isRunawayHeight = height => height > MAX_RESTORED_HEIGHT - && height > initialMinHeight + MAX_RESTORED_EXTRA_HEIGHT; - node._healRunawayHeight = function() { - const height = node.size?.[1] || 0; - if (node._isResizing || !isRunawayHeight(height)) return false; - node._isResizing = true; - node._userMinHeight = 0; - node.setSize([node.size[0], initialMinHeight]); - node._isResizing = false; - node.setDirtyCanvas(true, true); - return true; - }; // 1. 攔截讀取工作流配置 const originalOnConfigure = node.onConfigure; node.onConfigure = function(data) { if (originalOnConfigure) originalOnConfigure.apply(this, arguments); if (data && data.size) { - const restoredHeight = data.size[1]; - node._userMinHeight = restoredHeight; - node._healRunawayHeight(); + node._userMinHeight = data.size[1]; } }; @@ -94,7 +77,6 @@ export function setupSizeManager(node) { if (originalOnResize) originalOnResize.apply(this, arguments); if (!node._isResizing) { node._userMinHeight = size[1]; - node._healRunawayHeight(); } }; @@ -151,13 +133,7 @@ export function setupSizeManager(node) { */ node.triggerAutoSize = function() { const contentMinHeight = node.computeSize()[1]; - const restoredHeight = node._userMinHeight || 0; - const runawayHeight = restoredHeight > MAX_RESTORED_HEIGHT - && restoredHeight > contentMinHeight + MAX_RESTORED_EXTRA_HEIGHT; - const targetHeight = runawayHeight - ? contentMinHeight - : Math.max(contentMinHeight, restoredHeight); - if (runawayHeight) node._userMinHeight = targetHeight; + const targetHeight = Math.max(contentMinHeight, node._userMinHeight || 0); node._isResizing = true; node.setSize([node.size[0], targetHeight]);