LCOV - code coverage report
Current view: top level - packages/mask-editor/src/ui - EditorToolbar.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 62.5 % 32 20
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1           16 : <template>
       2           41 :   <div class="flex w-full items-center justify-between gap-3 p-2">
       3              :     <div class="flex items-center gap-3">
       4              :       <h3 class="m-0 text-lg font-semibold">{{ t('maskEditor.title') }}</h3>
       5              : 
       6              :       <div class="flex items-center gap-4">
       7              :         <Button
       8              :           variant="outline"
       9              :           size="unset"
      10              :           class="pointer-events-auto h-7.5 w-12.5 rounded-[10px] bg-background"
      11              :           :title="t('maskEditor.undo')"
      12              :           @click="onUndo"
      13              :         >
      14              :           <svg
      15              :             viewBox="0 0 15 15"
      16              :             class="pointer-events-none size-6.25 fill-current"
      17              :           >
      18              :             <path
      19              :               d="M8.77,12.18c-.25,0-.46-.2-.46-.46s.2-.46.46-.46c1.47,0,2.67-1.2,2.67-2.67,0-1.57-1.34-2.67-3.26-2.67h-3.98l1.43,1.43c.18.18.18.47,0,.64-.18.18-.47.18-.64,0l-2.21-2.21c-.18-.18-.18-.47,0-.64l2.21-2.21c.18-.18.47-.18.64,0,.18.18.18.47,0,.64l-1.43,1.43h3.98c2.45,0,4.17,1.47,4.17,3.58,0,1.97-1.61,3.58-3.58,3.58Z"
      20              :             />
      21              :           </svg>
      22              :         </Button>
      23              : 
      24              :         <Button
      25              :           variant="outline"
      26              :           size="unset"
      27              :           class="pointer-events-auto h-7.5 w-12.5 rounded-[10px] bg-background"
      28              :           :title="t('maskEditor.redo')"
      29              :           @click="onRedo"
      30              :         >
      31              :           <svg
      32              :             viewBox="0 0 15 15"
      33              :             class="pointer-events-none size-6.25 fill-foreground"
      34              :           >
      35              :             <path
      36              :               class="cls-1"
      37              :               d="M6.23,12.18c-1.97,0-3.58-1.61-3.58-3.58,0-2.11,1.71-3.58,4.17-3.58h3.98l-1.43-1.43c-.18-.18-.18-.47,0-.64.18-.18.46-.18.64,0l2.21,2.21c.09.09.13.2.13.32s-.05.24-.13.32l-2.21,2.21c-.18.18-.47.18-.64,0-.18-.18-.18-.47,0-.64l1.43-1.43h-3.98c-1.92,0-3.26,1.1-3.26,2.67,0,1.47,1.2,2.67,2.67,2.67.25,0,.46.2.46.46s-.2.46-.46.46Z"
      38              :             />
      39              :           </svg>
      40              :         </Button>
      41              : 
      42              :         <div class="h-5 border-l" />
      43              : 
      44              :         <Button
      45              :           variant="outline"
      46              :           size="unset"
      47              :           class="pointer-events-auto h-7.5 w-12.5 rounded-[10px] bg-background"
      48              :           :title="t('maskEditor.rotateLeft')"
      49              :           @click="onRotateLeft"
      50              :         >
      51              :           <svg
      52              :             viewBox="-6 -7 15 15"
      53              :             class="pointer-events-none size-6.25 fill-foreground"
      54              :           >
      55              :             <path
      56              :               d="m2.25-2.625c.3452 0 .625.2798.625.625v5c0 .3452-.2798.625-.625.625h-5c-.3452 0-.625-.2798-.625-.625v-5c0-.3452.2798-.625.625-.625h5zm1.25.625v5c0 .6904-.5596 1.25-1.25 1.25h-5c-.6904 0-1.25-.5596-1.25-1.25v-5c0-.6904.5596-1.25 1.25-1.25h5c.6904 0 1.25.5596 1.25 1.25zm-.1673-2.3757-.4419.4419-1.5246-1.5246 1.5416-1.5417.442.4419-.7871.7872h.9373c1.3807 0 2.5 1.1193 2.5 2.5h-.625c0-1.0355-.8395-1.875-1.875-1.875h-.9375l.7702.7702z"
      57              :             />
      58              :           </svg>
      59              :         </Button>
      60              : 
      61              :         <Button
      62              :           variant="outline"
      63              :           size="unset"
      64              :           class="pointer-events-auto h-7.5 w-12.5 rounded-[10px] bg-background"
      65              :           :title="t('maskEditor.rotateRight')"
      66              :           @click="onRotateRight"
      67              :         >
      68              :           <svg
      69              :             viewBox="-9 -7 15 15"
      70              :             class="pointer-events-none size-6.25 fill-foreground"
      71              :           >
      72              :             <g transform="scale(-1, 1)">
      73              :               <path
      74              :                 d="m2.25-2.625c.3452 0 .625.2798.625.625v5c0 .3452-.2798.625-.625.625h-5c-.3452 0-.625-.2798-.625-.625v-5c0-.3452.2798-.625.625-.625h5zm1.25.625v5c0 .6904-.5596 1.25-1.25 1.25h-5c-.6904 0-1.25-.5596-1.25-1.25v-5c0-.6904.5596-1.25 1.25-1.25h5c.6904 0 1.25.5596 1.25 1.25zm-.1673-2.3757-.4419.4419-1.5246-1.5246 1.5416-1.5417.442.4419-.7871.7872h.9373c1.3807 0 2.5 1.1193 2.5 2.5h-.625c0-1.0355-.8395-1.875-1.875-1.875h-.9375l.7702.7702z"
      75              :               />
      76              :             </g>
      77              :           </svg>
      78              :         </Button>
      79              : 
      80              :         <Button
      81              :           variant="outline"
      82              :           size="unset"
      83              :           class="pointer-events-auto h-7.5 w-12.5 rounded-[10px] bg-background"
      84              :           :title="t('maskEditor.mirrorHorizontal')"
      85              :           @click="onMirrorHorizontal"
      86              :         >
      87              :           <svg
      88              :             viewBox="0 0 15 15"
      89              :             class="pointer-events-none size-6.25 fill-foreground"
      90              :           >
      91              :             <path
      92              :               d="M7.5,1.5c-.28,0-.5.22-.5.5v11c0,.28.22.5.5.5s.5-.22.5-.5v-11c0-.28-.22-.5-.5-.5Z"
      93              :             />
      94              :             <path d="M3.5,4.5l-2,3,2,3v-6ZM11.5,4.5v6l2-3-2-3Z" />
      95              :           </svg>
      96              :         </Button>
      97              : 
      98              :         <Button
      99              :           variant="outline"
     100              :           size="unset"
     101              :           class="pointer-events-auto h-7.5 w-12.5 rounded-[10px] bg-background"
     102              :           :title="t('maskEditor.mirrorVertical')"
     103              :           @click="onMirrorVertical"
     104              :         >
     105              :           <svg
     106              :             viewBox="0 0 15 15"
     107              :             class="pointer-events-none size-6.25 fill-foreground"
     108              :           >
     109              :             <path
     110              :               d="M2,7.5c0-.28.22-.5.5-.5h11c.28,0,.5.22.5.5s-.22.5-.5.5h-11c-.28,0-.5-.22-.5-.5Z"
     111              :             />
     112              :             <path d="M4.5,4.5l3-2,3,2h-6ZM4.5,10.5h6l-3,2-3-2Z" />
     113              :           </svg>
     114              :         </Button>
     115              : 
     116              :         <div class="h-5 w-px bg-border" />
     117              : 
     118              :         <Button
     119              :           variant="outline"
     120              :           size="unset"
     121              :           class="pointer-events-auto h-7.5 w-15 rounded-[10px] bg-background"
     122              :           @click="onInvert"
     123              :         >
     124              :           {{ t('maskEditor.invert') }}
     125              :         </Button>
     126              : 
     127              :         <Button
     128              :           variant="outline"
     129              :           size="unset"
     130              :           class="pointer-events-auto h-7.5 w-15 rounded-[10px] bg-background"
     131              :           @click="onClear"
     132              :         >
     133              :           {{ t('maskEditor.clear') }}
     134              :         </Button>
     135              :       </div>
     136              :     </div>
     137              : 
     138              :     <div class="flex gap-3">
     139              :       <Button variant="primary" :disabled="saving" @click="emit('save')">
     140              :         <i class="icon-[lucide--check]" />
     141              :         {{ t(saving ? 'g.saving' : 'g.save') }}
     142              :       </Button>
     143              :       <Button variant="secondary" @click="emit('cancel')">
     144              :         <i class="icon-[lucide--x]" />
     145              :         {{ t('g.cancel') }}
     146              :       </Button>
     147              :     </div>
     148              :   </div>
     149              : </template>
     150              : 
     151              : <script setup lang="ts">
     152              : import { useI18n } from 'vue-i18n'
     153              : 
     154              : import Button from '@comfyorg/design-system/button/Button.vue'
     155              : import { useCanvasTools } from '#/useCanvasTools'
     156              : import { useCanvasTransform } from '#/useCanvasTransform'
     157              : import { useMaskEditorStore } from '#/maskEditorStore'
     158              : 
     159              : const { saving } = defineProps<{ saving: boolean }>()
     160           31 : const emit = defineEmits<{
     161              :   save: []
     162              :   cancel: []
     163              : }>()
     164              : 
     165           31 : const { t } = useI18n()
     166           31 : const store = useMaskEditorStore()
     167           31 : const canvasTools = useCanvasTools()
     168           31 : const canvasTransform = useCanvasTransform()
     169              : 
     170           31 : const onUndo = () => {
     171            2 :   store.canvasHistory.undo()
     172              : }
     173              : 
     174           31 : const onRedo = () => {
     175            1 :   store.canvasHistory.redo()
     176              : }
     177              : 
     178           31 : const onRotateLeft = async () => {
     179            0 :   try {
     180            0 :     await canvasTransform.rotateCounterclockwise()
     181              :   } catch (error) {
     182            0 :     console.error('[EditorToolbar] Rotate left failed:', error)
     183              :   }
     184              : }
     185              : 
     186           31 : const onRotateRight = async () => {
     187            0 :   try {
     188            0 :     await canvasTransform.rotateClockwise()
     189              :   } catch (error) {
     190            0 :     console.error('[EditorToolbar] Rotate right failed:', error)
     191              :   }
     192              : }
     193              : 
     194           31 : const onMirrorHorizontal = async () => {
     195            0 :   try {
     196            0 :     await canvasTransform.mirrorHorizontal()
     197              :   } catch (error) {
     198            0 :     console.error('[EditorToolbar] Mirror horizontal failed:', error)
     199              :   }
     200              : }
     201              : 
     202           31 : const onMirrorVertical = async () => {
     203            0 :   try {
     204            0 :     await canvasTransform.mirrorVertical()
     205              :   } catch (error) {
     206            0 :     console.error('[EditorToolbar] Mirror vertical failed:', error)
     207              :   }
     208              : }
     209              : 
     210           31 : const onInvert = () => {
     211            1 :   canvasTools.invertMask()
     212              : }
     213              : 
     214           31 : const onClear = () => {
     215            1 :   canvasTools.clearMask()
     216            1 :   store.triggerClear()
     217              : }
     218              : </script>
        

Generated by: LCOV version 2.0-1