Skip to content

Commit a8d6f7b

Browse files
authored
Feat: Show Progress Text on Vue Nodes, Markdown for Preview as Text (#6805)
## Summary Maps the progressText / text preview to a readonly Markdown widget. ## Review Focus Anything else to tweak about this while I'm in here? ## Screenshots <img width="1107" height="593" alt="image" src="https://github.com/user-attachments/assets/a445c07a-2fcb-480c-976e-bda6ff343f14" /> ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-6805-Feat-Show-Progress-Text-on-Vue-Nodes-2b26d73d3650814d93c4f2fbf0e00095) by [Unito](https://www.unito.io)
1 parent a7daa50 commit a8d6f7b

File tree

5 files changed

+20
-12
lines changed

5 files changed

+20
-12
lines changed

src/extensions/core/previewAny.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ useExtensionService().registerExtension({
1717
nodeType.prototype.onNodeCreated = function () {
1818
onNodeCreated ? onNodeCreated.apply(this, []) : undefined
1919

20-
const showValueWidget = ComfyWidgets['STRING'](
20+
const showValueWidget = ComfyWidgets['MARKDOWN'](
2121
this,
2222
'preview',
23-
['STRING', { multiline: true }],
23+
['MARKDOWN', {}],
2424
app
2525
).widget as DOMWidget<HTMLTextAreaElement, string>
2626

src/renderer/extensions/vueNodes/widgets/components/WidgetMarkdown.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const renderedHtml = computed(() => {
5757
5858
// Methods
5959
const startEditing = async () => {
60-
if (isEditing.value) return
60+
if (isEditing.value || widget.options?.read_only) return
6161
6262
isEditing.value = true
6363
await nextTick()

src/renderer/extensions/vueNodes/widgets/composables/useProgressTextWidget.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { InputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2'
66
import { ComponentWidgetImpl, addWidget } from '@/scripts/domWidget'
77
import type { ComponentWidgetStandardProps } from '@/scripts/domWidget'
88
import type { ComfyWidgetConstructorV2 } from '@/scripts/widgets'
9+
import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets'
910

1011
type TextPreviewCustomProps = Omit<
1112
InstanceType<typeof TextPreviewWidget>['$props'],
@@ -14,15 +15,15 @@ type TextPreviewCustomProps = Omit<
1415

1516
const PADDING = 16
1617

17-
export const useTextPreviewWidget = (
18+
export function useTextPreviewWidget(
1819
options: {
1920
minHeight?: number
2021
} = {}
21-
) => {
22-
const widgetConstructor: ComfyWidgetConstructorV2 = (
22+
): ComfyWidgetConstructorV2 {
23+
function widgetConstructor(
2324
node: LGraphNode,
2425
inputSpec: InputSpec
25-
) => {
26+
): IBaseWidget {
2627
const widgetValue = ref<string>('')
2728
const widget = new ComponentWidgetImpl<
2829
string | object,
@@ -41,8 +42,10 @@ export const useTextPreviewWidget = (
4142
widgetValue.value = typeof value === 'string' ? value : String(value)
4243
},
4344
getMinHeight: () => options.minHeight ?? 42 + PADDING,
44-
serialize: false
45-
}
45+
serialize: false,
46+
read_only: true
47+
},
48+
type: inputSpec.type
4649
})
4750
addWidget(node, widget)
4851
return widget

src/renderer/extensions/vueNodes/widgets/registry/widgetRegistry.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@ const coreWidgetDefinitions: Array<[string, WidgetDefinition]> = [
134134
],
135135
[
136136
'markdown',
137-
{ component: WidgetMarkdown, aliases: ['MARKDOWN'], essential: false }
137+
{
138+
component: WidgetMarkdown,
139+
aliases: ['MARKDOWN', 'progressText'],
140+
essential: false
141+
}
138142
],
139143
['legacy', { component: WidgetLegacy, aliases: [], essential: true }],
140144
[

src/scripts/domWidget.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,11 @@ export class ComponentWidgetImpl<
303303
inputSpec: InputSpec
304304
props?: P
305305
options: DOMWidgetOptions<V>
306+
type?: string
306307
}) {
307308
super({
308-
...obj,
309-
type: 'custom'
309+
type: 'custom',
310+
...obj
310311
})
311312
this.component = obj.component
312313
this.inputSpec = obj.inputSpec

0 commit comments

Comments
 (0)