mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-08 00:50:05 +00:00
refactor: migrate components to use EditableText doubleClickToEdit prop
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
:model-value="node.label"
|
||||
:is-editing="isEditing"
|
||||
@edit="handleRename"
|
||||
@cancel="handleRename(node.label)"
|
||||
/>
|
||||
<slot name="after-label" :node="props.node" />
|
||||
</span>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
:is-editing="showInput"
|
||||
:model-value="editedTitle"
|
||||
@edit="onEdit"
|
||||
@cancel="onCancel"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -47,6 +48,12 @@ const titleEditorStore = useTitleEditorStore()
|
||||
const canvasStore = useCanvasStore()
|
||||
const previousCanvasDraggable = ref(true)
|
||||
|
||||
const closeEditor = () => {
|
||||
showInput.value = false
|
||||
titleEditorStore.titleEditorTarget = null
|
||||
canvasStore.canvas!.allow_dragcanvas = previousCanvasDraggable.value
|
||||
}
|
||||
|
||||
const onEdit = (newValue: string) => {
|
||||
if (titleEditorStore.titleEditorTarget && newValue?.trim()) {
|
||||
const trimmedTitle = newValue.trim()
|
||||
@@ -60,9 +67,11 @@ const onEdit = (newValue: string) => {
|
||||
|
||||
app.canvas.setDirty(true, true)
|
||||
}
|
||||
showInput.value = false
|
||||
titleEditorStore.titleEditorTarget = null
|
||||
canvasStore.canvas!.allow_dragcanvas = previousCanvasDraggable.value
|
||||
closeEditor()
|
||||
}
|
||||
|
||||
const onCancel = () => {
|
||||
closeEditor()
|
||||
}
|
||||
|
||||
watch(
|
||||
|
||||
@@ -198,13 +198,13 @@ function handleTitleCancel() {
|
||||
<h3 class="my-3.5 text-sm font-semibold line-clamp-2 cursor-default">
|
||||
<template v-if="allowTitleEdit">
|
||||
<EditableText
|
||||
v-model:is-editing="isEditing"
|
||||
:model-value="panelTitle"
|
||||
:is-editing="isEditing"
|
||||
:input-attrs="{ 'data-testid': 'node-title-input' }"
|
||||
double-click-to-edit
|
||||
class="cursor-text"
|
||||
@edit="handleTitleEdit"
|
||||
@cancel="handleTitleCancel"
|
||||
@click="isEditing = true"
|
||||
/>
|
||||
<i
|
||||
v-if="!isEditing"
|
||||
|
||||
@@ -123,13 +123,13 @@ const displayLabel = customRef((track, trigger) => {
|
||||
>
|
||||
<EditableText
|
||||
v-if="widget.name"
|
||||
v-model:is-editing="isEditing"
|
||||
:model-value="displayLabel"
|
||||
:is-editing="isEditing"
|
||||
:input-attrs="{ placeholder: widget.name }"
|
||||
double-click-to-edit
|
||||
class="text-sm leading-8 p-0 m-0 truncate pointer-events-auto cursor-text"
|
||||
@edit="displayLabel = $event"
|
||||
@cancel="isEditing = false"
|
||||
@click="isEditing = true"
|
||||
/>
|
||||
|
||||
<span
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
:is-editing="isEditing"
|
||||
:input-attrs="{ 'data-testid': 'asset-name-input' }"
|
||||
@edit="assetRename"
|
||||
@cancel="assetRename()"
|
||||
@cancel="isEditing = false"
|
||||
/>
|
||||
</h3>
|
||||
<p
|
||||
|
||||
Reference in New Issue
Block a user