show text

This commit is contained in:
zombieyang
2025-05-01 15:24:03 +08:00
parent e61214b0cb
commit e005b716f6
5 changed files with 83 additions and 41 deletions
+25 -7
View File
@@ -250,18 +250,36 @@ export default function (sdppp) {
}
});
sdppp.widgetable.add("ShowText|pysssss", {
formatter: (node) => {
return {
title: getTitle(node),
widgets: [{
value: node.widgets[1]?.value || '',
outputType: "string"
}]
}
}
})
sdppp.widgetable.add('__DEFAULT__', {
formatter: (node) => {
return {
id: node.id,
title: getTitle(node),
widgets: node.widgets.map((widget) => ({
name: widget.label || widget.name,
outputType: widget.type || "string",
value: widget.value,
options: widget.options,
uiWeight: widget.uiWeight || 12
}))
widgets: node.widgets.map((widget) => {
const ret = {
outputType: widget.type || "string",
value: widget.value,
options: widget.options,
uiWeight: widget.uiWeight || 12
}
if (node.widgets.length != 1) {
ret.name = widget.label || widget.name;
}
return ret;
})
};
}
})
+33 -33
View File
@@ -427,45 +427,45 @@ def define_comfyui_nodes(sdpppServer):
return (output_mask, )
class SendTextToLayerNode:
RETURN_TYPES = ("DOCUMENT",)
OUTPUT_NODE = True
FUNCTION = "action"
CATEGORY = "SD-PPP"
# class SendTextToLayerNode:
# RETURN_TYPES = ("DOCUMENT",)
# OUTPUT_NODE = True
# FUNCTION = "action"
# CATEGORY = "SD-PPP"
@classmethod
def IS_CHANGED(self, **kwargs):
return np.random.rand()
# @classmethod
# def IS_CHANGED(self, **kwargs):
# return np.random.rand()
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"text": ('STRING', {"sdppp_type": "STRING"}),
"layer": ('LAYER', {"default": None, "sdppp_type": "LAYER"}),
},
"optional": SDPPPOptional({}, {
"sdppp": ("STRING", {"default": ""})
}),
"hidden": {
"unique_id": "UNIQUE_ID",
"prompt": "PROMPT",
}
}
# @classmethod
# def INPUT_TYPES(cls):
# return {
# "required": {
# "text": ('STRING', {"sdppp_type": "STRING"}),
# "layer": ('LAYER', {"default": None, "sdppp_type": "LAYER"}),
# },
# "optional": SDPPPOptional({}, {
# "sdppp": ("STRING", {"default": ""})
# }),
# "hidden": {
# "unique_id": "UNIQUE_ID",
# "prompt": "PROMPT",
# }
# }
def action(self, text, layer, **kwargs):
sdpppServer.has_ps_instance(throw_error=True)
# def action(self, text, layer, **kwargs):
# sdpppServer.has_ps_instance(throw_error=True)
document = layer['document']
# document = layer['document']
call_async_func_in_server_thread(ProtocolPhotoshop.send_text(
instance_id=document['instance_id'],
document_identify=document['identify'],
text=text,
layer_identify=layer['layer_identify'],
), True)
# call_async_func_in_server_thread(ProtocolPhotoshop.send_text(
# instance_id=document['instance_id'],
# document_identify=document['identify'],
# text=text,
# layer_identify=layer['layer_identify'],
# ), True)
return (document, )
# return (document, )
class GetTextFromLayerNode:
RETURN_TYPES = ("STRING",)
+21
View File
@@ -13,6 +13,7 @@ import WebSocket, { WebSocketServer } from 'ws';
import { join } from 'path';
import { typescriptSrcRoot } from './lib.ts';
import { globSync } from 'glob';
let wss: WebSocketServer | null = null;
let clients = new Set<WebSocket>();
if (process.env.NODE_ENV === 'development') {
@@ -105,6 +106,26 @@ async function main() {
notifyClients(result);
}
// Add stdin listener for Enter key press
if (process.env.NODE_ENV === 'development') {
process.stdin.setRawMode(true);
process.stdin.resume();
process.stdin.setEncoding('utf8');
console.log('Press Enter to trigger client notification, or Ctrl+C to exit');
process.stdin.on('data', (data) => {
const key = data.toString();
if (key === '\r' || key === '\n') {
console.log('Enter pressed, notifying clients...');
notifyClients({ errors: [], warnings: [] });
}
// Ctrl+C handling
if (key === '\u0003') {
process.exit();
}
});
}
if (isWatchMode) {
console.log('Watch mode enabled. Watching for changes...');
for (const { context } of contexts) {
@@ -241,7 +241,7 @@ export class WorkflowEditWrap extends React.Component<{
)
return true
} else if (widget.outputType === 'string' || widget.outputType === 'customtext') {
} else if (widget.outputType === 'string' || widget.outputType === 'customtext' || widget.outputType === 'text') {
context.result.push(
<StringWidget
uiWeight={widget.uiWeight || 12}
@@ -14,6 +14,9 @@ api.addEventListener("graphChanged", () => {
}
pageStore.setWidgetTableValue(getWidgetTableValue(app.graph));
})
api.addEventListener("executed", () => {
pageStore.setWidgetTableValue(getWidgetTableValue(app.graph));
})
let lastActiveWorkflowID: number = 0;