diff --git a/web/js/autosize.js b/web/js/autosize.js index 438ce7a..80882b3 100644 --- a/web/js/autosize.js +++ b/web/js/autosize.js @@ -1,6 +1,26 @@ import { app } from '../../../scripts/app.js' + +function addResizeHook(node, padding) { + let origOnCreated = node.onNodeCreated + node.onNodeCreated = function() { + let r = origOnCreated?.apply(this, arguments) + let size = this.computeSize(); + size[0] += padding || 0; + this.setSize(size); + return r + } +} + + app.registerExtension({ name: "AnimateDiffEvolved.autosize", + async beforeRegisterNodeDef(nodeType, nodeData, app) { + if (nodeData?.name?.startsWith("ADE_")) { + if (nodeData?.input?.hidden?.autosize) { + addResizeHook(nodeType.prototype, nodeData.input.hidden.autosize[1]?.padding) + } + } + }, async getCustomWidgets() { return { ADEAUTOSIZE(node, inputName, inputData) { @@ -17,14 +37,7 @@ app.registerExtension({ node.widgets = [] } node.widgets.push(w) - let origOnCreated = node.onNodeCreated - node.onNodeCreated = function() { - let r = origOnCreated?.apply(this, arguments) - let size = this.computeSize(); - size[0] += inputData[1].padding || 0; - this.setSize(size); - return r - } + addResizeHook(node, inputData[1].padding); return w; } }