-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Double click node title to trigger edit (#655)
* Update litegraph * Double click edit node title * Update * Auto select all * Update litegraph * Add playwright test * Update readme * Update test expectations [skip ci] --------- Co-authored-by: github-actions <github-actions@github.com>
- Loading branch information
Showing
10 changed files
with
218 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ | ||
"last_node_id": 9, | ||
"last_link_id": 13, | ||
"nodes": [ | ||
{ | ||
"id": 3, | ||
"type": "KSampler", | ||
"pos": [ | ||
0, | ||
30 | ||
], | ||
"size": { | ||
"0": 315, | ||
"1": 262 | ||
}, | ||
"flags": {}, | ||
"order": 0, | ||
"mode": 0, | ||
"inputs": [ | ||
{ | ||
"name": "model", | ||
"type": "MODEL", | ||
"link": null | ||
}, | ||
{ | ||
"name": "positive", | ||
"type": "CONDITIONING", | ||
"link": null | ||
}, | ||
{ | ||
"name": "negative", | ||
"type": "CONDITIONING", | ||
"link": null | ||
}, | ||
{ | ||
"name": "latent_image", | ||
"type": "LATENT", | ||
"link": null | ||
} | ||
], | ||
"outputs": [ | ||
{ | ||
"name": "LATENT", | ||
"type": "LATENT", | ||
"links": [], | ||
"slot_index": 0 | ||
} | ||
], | ||
"properties": { | ||
"Node name for S&R": "KSampler" | ||
}, | ||
"widgets_values": [ | ||
156680208700286, | ||
"randomize", | ||
20, | ||
8, | ||
"euler", | ||
"normal", | ||
1 | ||
] | ||
} | ||
], | ||
"links": [], | ||
"groups": [], | ||
"config": {}, | ||
"extra": { | ||
"ds": { | ||
"scale": 1, | ||
"offset": [ | ||
0, | ||
0 | ||
] | ||
} | ||
}, | ||
"version": 0.4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+58 KB
browser_tests/interaction.spec.ts-snapshots/node-title-edited-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<template> | ||
<div v-if="showInput" class="node-title-editor" :style="inputStyle"> | ||
<EditableText | ||
:isEditing="showInput" | ||
:modelValue="editedTitle" | ||
@edit="onEdit" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref, onMounted, CSSProperties } from 'vue' | ||
import { app } from '@/scripts/app' | ||
import { LGraphNode } from '@comfyorg/litegraph' | ||
import { ComfyExtension } from '@/types/comfy' | ||
import EditableText from '@/components/common/EditableText.vue' | ||
import { LiteGraph } from '@comfyorg/litegraph' | ||
const showInput = ref(false) | ||
const editedTitle = ref('') | ||
const inputStyle = ref<CSSProperties>({ | ||
position: 'fixed', | ||
left: '0px', | ||
top: '0px', | ||
width: '200px', | ||
height: '20px' | ||
}) | ||
const currentNode = ref<LGraphNode | null>(null) | ||
const onEdit = (newValue: string) => { | ||
if (currentNode.value && newValue.trim() !== '') { | ||
currentNode.value.title = newValue.trim() | ||
app.graph.setDirtyCanvas(true, true) | ||
} | ||
showInput.value = false | ||
} | ||
const extension: ComfyExtension = { | ||
name: 'Comfy.NodeTitleEditor', | ||
nodeCreated(node: LGraphNode) { | ||
// Store the original callback | ||
const originalCallback = node.onNodeTitleDblClick | ||
node.onNodeTitleDblClick = function (e: MouseEvent, ...args: any[]) { | ||
currentNode.value = this | ||
editedTitle.value = this.title | ||
showInput.value = true | ||
const [x1, y1, x2, y2] = this.getBounding() | ||
const [nodeWidth, nodeHeight] = this.size | ||
const canvasWidth = nodeWidth | ||
const canvasHeight = LiteGraph.NODE_TITLE_HEIGHT | ||
const [left, top] = app.canvasPosToClientPos([x1, y1]) | ||
inputStyle.value.left = `${left}px` | ||
inputStyle.value.top = `${top}px` | ||
const width = canvasWidth * app.canvas.ds.scale | ||
const height = canvasHeight * app.canvas.ds.scale | ||
inputStyle.value.width = `${width}px` | ||
inputStyle.value.height = `${height}px` | ||
// Call the original callback if it exists | ||
if (typeof originalCallback === 'function') { | ||
originalCallback.call(this, e, ...args) | ||
} | ||
} | ||
} | ||
} | ||
onMounted(() => { | ||
app.registerExtension(extension) | ||
}) | ||
</script> | ||
|
||
<style scoped> | ||
.node-title-editor { | ||
z-index: 9999; | ||
padding: 0.25rem; | ||
} | ||
:deep(.editable-text) { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
:deep(.editable-text input) { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50b4181
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😱