44 data-testid =" bounding-boxes"
55 @pointerdown.stop
66 >
7- <div
8- ref =" canvasContainer"
9- class =" relative w-full shrink-0 overflow-hidden rounded-sm border border-component-node-border bg-node-component-surface"
10- :style =" canvasStyle"
11- >
12- <canvas
13- ref =" canvasEl"
14- tabindex =" 0"
15- class =" absolute inset-0 size-full rounded-sm outline-none"
16- :style =" { cursor: canvasCursor }"
17- @pointerdown =" onPointerDown"
18- @pointermove =" onCanvasPointerMove"
19- @pointerup =" onDocPointerUp"
20- @pointercancel =" onDocPointerUp"
21- @pointerleave =" onPointerLeave"
22- @lostpointercapture =" onDocPointerUp"
23- @dblclick =" onDoubleClick"
24- @keydown =" onCanvasKeyDown"
25- @focus =" focused = true"
26- @blur =" focused = false"
27- />
28- <textarea
29- v-if =" inlineEditor"
30- ref =" inlineEditorEl"
31- v-model =" inlineEditor.value"
32- class =" absolute box-border resize-none rounded-sm border-2 bg-black/90 p-1 font-mono text-xs text-white outline-none"
33- :style =" inlineEditor.style"
34- data-capture-wheel =" true"
35- @keydown.stop =" onInlineKeyDown"
36- @blur =" commitInlineEditor"
37- />
7+ <div class =" flex flex-col" >
8+ <div
9+ class =" flex h-9 items-center gap-1 rounded-t-sm border border-b-0 border-component-node-border bg-component-node-widget-background px-2"
10+ >
11+ <Button
12+ v-tooltip .bottom =" { value: $t (' boundingBoxes.grid' ), showDelay: 300 } "
13+ variant="textonly"
14+ size="unset"
15+ :aria-pressed =" grid "
16+ :class ="
17+ cn (
18+ actionBtnClass ,
19+ grid && ' bg-component-node-widget-background-selected'
20+ )
21+ "
22+ @click =" grid = ! grid "
23+ >
24+ <i class =" icon-[lucide--grid-3x3] size-4" />
25+ <span >{{ $t('boundingBoxes.grid') }}</span >
26+ </Button >
27+ <Button
28+ v-tooltip .bottom =" {
29+ value: $t (' boundingBoxes.clearAll' ),
30+ showDelay: 300
31+ } "
32+ variant="textonly"
33+ size="unset"
34+ :class =" cn (actionBtnClass , ' ml-auto' )"
35+ @click =" clearAll "
36+ >
37+ <i class =" icon-[lucide--undo-2] size-4" />
38+ <span >{{ $t('boundingBoxes.clearAll') }}</span >
39+ </Button >
40+ </div >
41+ <div
42+ ref =" canvasContainer"
43+ class =" relative w-full shrink-0 overflow-hidden rounded-b-sm border border-t-0 border-component-node-border bg-base-background"
44+ :style =" canvasStyle"
45+ >
46+ <canvas
47+ ref =" canvasEl"
48+ tabindex =" 0"
49+ class =" absolute inset-0 size-full rounded-sm outline-none"
50+ :style =" { cursor: canvasCursor }"
51+ @pointerdown =" onPointerDown"
52+ @pointermove =" onCanvasPointerMove"
53+ @pointerup =" onDocPointerUp"
54+ @pointercancel =" onDocPointerUp"
55+ @pointerleave =" onPointerLeave"
56+ @lostpointercapture =" onDocPointerUp"
57+ @dblclick =" onDoubleClick"
58+ @keydown =" onCanvasKeyDown"
59+ @focus =" focused = true"
60+ @blur =" focused = false"
61+ />
62+ <textarea
63+ v-if =" inlineEditor"
64+ ref =" inlineEditorEl"
65+ v-model =" inlineEditor.value"
66+ class =" absolute box-border resize-none rounded-sm border-2 bg-black/90 p-1 font-mono text-xs text-white outline-none"
67+ :style =" inlineEditor.style"
68+ data-capture-wheel =" true"
69+ @keydown.stop =" onInlineKeyDown"
70+ @blur =" commitInlineEditor"
71+ />
72+ </div >
3873 </div >
3974
4075 <div
122157 <div v-else-if =" hasRegions" class =" text-node-text-muted px-1 text-xs" >
123158 {{ $t('boundingBoxes.clickRegionToEdit') }}
124159 </div >
125-
126- <Button
127- variant="secondary"
128- size="md"
129- class="gap-2 rounded-lg border border-component-node-border bg-component-node-background text-xs text-muted-foreground hover:text-base-foreground "
130- @click =" clearAll "
131- >
132- <i class =" icon-[lucide--undo-2]" />
133- {{ $t('boundingBoxes.clearAll') }}
134- </Button >
135160 </div >
136161</template >
137162
@@ -147,6 +172,9 @@ import { useBoundingBoxes } from '@/composables/boundingBoxes/useBoundingBoxes'
147172import type { BoundingBox } from ' @/types/boundingBoxes'
148173import type { NodeId } from ' @/types/nodeId'
149174
175+ const actionBtnClass =
176+ ' flex shrink-0 items-center gap-1.5 rounded-md border-0 bg-transparent px-2 py-1 text-sm text-base-foreground outline-none transition-colors hover:bg-component-node-widget-background-hovered'
177+
150178const { nodeId } = defineProps <{ nodeId: NodeId }>()
151179const modelValue = defineModel <BoundingBox []>({ default : () => [] })
152180
@@ -172,7 +200,8 @@ const {
172200 commitInlineEditor,
173201 setActiveType,
174202 clearAll,
175- syncState
203+ syncState,
204+ grid
176205} = useBoundingBoxes (nodeId , {
177206 canvasEl ,
178207 canvasContainer ,
0 commit comments