mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 10:42:44 +00:00
[upstream] Upstream PreviewAny from rgthree-comfy (#3640)
This commit is contained in:
@@ -10,6 +10,7 @@ import './load3d'
|
|||||||
import './maskeditor'
|
import './maskeditor'
|
||||||
import './nodeTemplates'
|
import './nodeTemplates'
|
||||||
import './noteNode'
|
import './noteNode'
|
||||||
|
import './previewAny'
|
||||||
import './rerouteNode'
|
import './rerouteNode'
|
||||||
import './saveImageExtraOutput'
|
import './saveImageExtraOutput'
|
||||||
import './saveMesh'
|
import './saveMesh'
|
||||||
|
|||||||
50
src/extensions/core/previewAny.ts
Normal file
50
src/extensions/core/previewAny.ts
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
Preview Any - original implement from
|
||||||
|
https://github.com/rgthree/rgthree-comfy/blob/main/py/display_any.py
|
||||||
|
upstream requested in https://github.com/Kosinkadink/rfcs/blob/main/rfcs/0000-corenodes.md#preview-nodes
|
||||||
|
*/
|
||||||
|
import { IWidget } from '@comfyorg/litegraph'
|
||||||
|
|
||||||
|
import { DOMWidget } from '@/scripts/domWidget'
|
||||||
|
import { ComfyWidgets } from '@/scripts/widgets'
|
||||||
|
import { useExtensionService } from '@/services/extensionService'
|
||||||
|
|
||||||
|
useExtensionService().registerExtension({
|
||||||
|
name: 'Comfy.PreviewAny',
|
||||||
|
async beforeRegisterNodeDef(nodeType, nodeData) {
|
||||||
|
if (nodeData.name === 'PreviewAny') {
|
||||||
|
const onNodeCreated = nodeType.prototype.onNodeCreated
|
||||||
|
|
||||||
|
nodeType.prototype.onNodeCreated = function () {
|
||||||
|
onNodeCreated ? onNodeCreated.apply(this, []) : undefined
|
||||||
|
|
||||||
|
const showValueWidget = ComfyWidgets['STRING'](
|
||||||
|
this,
|
||||||
|
'preview',
|
||||||
|
['STRING', { multiline: true }],
|
||||||
|
app
|
||||||
|
).widget as DOMWidget<any, any>
|
||||||
|
|
||||||
|
showValueWidget.element.readOnly = true
|
||||||
|
|
||||||
|
showValueWidget.serialize = false
|
||||||
|
}
|
||||||
|
|
||||||
|
const onExecuted = nodeType.prototype.onExecuted
|
||||||
|
|
||||||
|
nodeType.prototype.onExecuted = function (message) {
|
||||||
|
onExecuted === null || onExecuted === void 0
|
||||||
|
? void 0
|
||||||
|
: onExecuted.apply(this, [message])
|
||||||
|
|
||||||
|
const previewWidget = this.widgets?.find(
|
||||||
|
(w: IWidget) => w.name === 'preview'
|
||||||
|
)
|
||||||
|
|
||||||
|
if (previewWidget) {
|
||||||
|
previewWidget.value = message.text[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user