[backport core/1.32] Feat: Show Progress Text on Vue Nodes, Markdown for Preview as Text (#6857)

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>
This commit is contained in:
Comfy Org PR Bot
2025-11-24 04:20:20 +09:00
committed by GitHub
parent 55f842f4cb
commit 0507d333fe
5 changed files with 20 additions and 12 deletions

View File

@@ -17,10 +17,10 @@ useExtensionService().registerExtension({
nodeType.prototype.onNodeCreated = function () {
onNodeCreated ? onNodeCreated.apply(this, []) : undefined
const showValueWidget = ComfyWidgets['STRING'](
const showValueWidget = ComfyWidgets['MARKDOWN'](
this,
'preview',
['STRING', { multiline: true }],
['MARKDOWN', {}],
app
).widget as DOMWidget<HTMLTextAreaElement, string>

View File

@@ -57,7 +57,7 @@ const renderedHtml = computed(() => {
// Methods
const startEditing = async () => {
if (isEditing.value) return
if (isEditing.value || widget.options?.read_only) return
isEditing.value = true
await nextTick()

View File

@@ -6,6 +6,7 @@ import type { InputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2'
import { ComponentWidgetImpl, addWidget } from '@/scripts/domWidget'
import type { ComponentWidgetStandardProps } from '@/scripts/domWidget'
import type { ComfyWidgetConstructorV2 } from '@/scripts/widgets'
import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets'
type TextPreviewCustomProps = Omit<
InstanceType<typeof TextPreviewWidget>['$props'],
@@ -14,15 +15,15 @@ type TextPreviewCustomProps = Omit<
const PADDING = 16
export const useTextPreviewWidget = (
export function useTextPreviewWidget(
options: {
minHeight?: number
} = {}
) => {
const widgetConstructor: ComfyWidgetConstructorV2 = (
): ComfyWidgetConstructorV2 {
function widgetConstructor(
node: LGraphNode,
inputSpec: InputSpec
) => {
): IBaseWidget {
const widgetValue = ref<string>('')
const widget = new ComponentWidgetImpl<
string | object,
@@ -41,8 +42,10 @@ export const useTextPreviewWidget = (
widgetValue.value = typeof value === 'string' ? value : String(value)
},
getMinHeight: () => options.minHeight ?? 42 + PADDING,
serialize: false
}
serialize: false,
read_only: true
},
type: inputSpec.type
})
addWidget(node, widget)
return widget

View File

@@ -134,7 +134,11 @@ const coreWidgetDefinitions: Array<[string, WidgetDefinition]> = [
],
[
'markdown',
{ component: WidgetMarkdown, aliases: ['MARKDOWN'], essential: false }
{
component: WidgetMarkdown,
aliases: ['MARKDOWN', 'progressText'],
essential: false
}
],
['legacy', { component: WidgetLegacy, aliases: [], essential: true }],
[

View File

@@ -303,10 +303,11 @@ export class ComponentWidgetImpl<
inputSpec: InputSpec
props?: P
options: DOMWidgetOptions<V>
type?: string
}) {
super({
...obj,
type: 'custom'
type: 'custom',
...obj
})
this.component = obj.component
this.inputSpec = obj.inputSpec