mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
Backport of #6805 to `core/1.32` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6857-backport-core-1-32-Feat-Show-Progress-Text-on-Vue-Nodes-Markdown-for-Preview-as-Text-2b46d73d3650817691d3d5ce30e7d4e3) by [Unito](https://www.unito.io) Co-authored-by: Alexander Brown <drjkl@comfy.org>
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
/*
|
|
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 { app } from '@/scripts/app'
|
|
import { type 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['MARKDOWN'](
|
|
this,
|
|
'preview',
|
|
['MARKDOWN', {}],
|
|
app
|
|
).widget as DOMWidget<HTMLTextAreaElement, string>
|
|
|
|
showValueWidget.options.read_only = true
|
|
|
|
showValueWidget.element.readOnly = true
|
|
showValueWidget.element.disabled = 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) => w.name === 'preview')
|
|
|
|
if (previewWidget) {
|
|
previewWidget.value = message.text[0]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|