11<script  setup>
2- import  { ref  } from  ' vue' 
2+ import  { h ,  ref  } from  ' vue' 
33import  { VueFlow , useVueFlow  } from  ' @vue-flow/core' 
44import  { Background  } from  ' @vue-flow/background' 
55import  { useDialog  } from  ' ./useDialog' 
@@ -10,16 +10,26 @@ const { onConnect, addEdges, onNodesChange, onEdgesChange, applyNodeChanges, app
1010const  dialog  =  useDialog ()
1111
1212const  nodes  =  ref ([
13-   { id:  ' 1'  , type:  ' input'  , label:  ' Node 1'  , position:  { x:  250 , y:  5  }, class:  ' light'   }, 
14-   { id:  ' 2'  , label:  ' Node 2'  , position:  { x:  100 , y:  100  }, class:  ' light'   }, 
15-   { id:  ' 3'  , label:  ' Node 3'  , position:  { x:  400 , y:  100  }, class:  ' light'   }, 
16-   { id:  ' 4'  , label:  ' Node 4'  , position:  { x:  400 , y:  200  }, class:  ' light'   }, 
13+   { id:  ' 1'  , type:  ' input'  , data:  { label:  ' Click me and'   }, position:  { x:  0 , y:  0  } }, 
14+   { id:  ' 2'  , data:  { label:  ` press 'Backspace' to delete me`   }, position:  { x:  0 , y:  100  } }, 
1715]) 
1816
19- const  edges  =  ref ([
20-   { id:  ' e1-2'  , source:  ' 1'  , target:  ' 2'  , animated:  true  }, 
21-   { id:  ' e1-3'  , source:  ' 1'  , target:  ' 3'   }, 
22- ]) 
17+ const  edges  =  ref ([{ id:  ' e1-2'  , source:  ' 1'  , target:  ' 2'   }])
18+ 
19+ function  dialogMsg (id ) {
20+   return  h ( 
21+     ' span'  , 
22+     { 
23+       style:  { 
24+         display:  ' flex'  , 
25+         flexDirection:  ' column'  , 
26+         alignItems:  ' center'  , 
27+         gap:  ' 8px'  , 
28+       }, 
29+     }, 
30+     [` Are you sure?`  , h (' br'  ), h (' span'  , ` [ELEMENT_ID: ${ id}  ]`  )], 
31+   ) 
32+ } 
2333
2434onConnect (addEdges)
2535
@@ -28,7 +38,7 @@ onNodesChange(async (changes) => {
2838
2939  for  (const  change  of  changes) { 
3040    if  (change .type  ===  ' remove'  ) { 
31-       const  isConfirmed  =  await  dialog .confirm (` Do you really want to delete this node:  ${ change .id } ? `  ) 
41+       const  isConfirmed  =  await  dialog .confirm (dialogMsg ( change .id ) ) 
3242
3343      if  (isConfirmed) { 
3444        nextChanges .push (change) 
@@ -46,7 +56,7 @@ onEdgesChange(async (changes) => {
4656
4757  for  (const  change  of  changes) { 
4858    if  (change .type  ===  ' remove'  ) { 
49-       const  isConfirmed  =  await  dialog .confirm (` Do you really want to delete this edge:  ${ change .id } ? `  ) 
59+       const  isConfirmed  =  await  dialog .confirm (dialogMsg ( change .id ) ) 
5060
5161      if  (isConfirmed) { 
5262        nextChanges .push (change) 
@@ -61,7 +71,7 @@ onEdgesChange(async (changes) => {
6171 </script >
6272
6373<template >
64-   <VueFlow  :nodes =" nodes"   :edges =" edges"   :apply-default =" false"   fit-view-on-init  class =" vue -flow-basic-example "  >
74+   <VueFlow  :nodes =" nodes"   :edges =" edges"   :apply-default =" false"   fit-view-on-init  class =" confirm -flow"  >
6575    <Background  />
6676
6777    <Dialog  />
0 commit comments