File tree Expand file tree Collapse file tree 3 files changed +10
-9
lines changed Expand file tree Collapse file tree 3 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -230,7 +230,7 @@ const contextMenuOptions: ContextMenuOption[] = [
230
230
{
231
231
label: " Delete" ,
232
232
action : () => {
233
- block . value . getParentBlock ()?. removeChild (block .value );
233
+ store . activeCanvas ?. removeBlock (block .value );
234
234
},
235
235
condition : () => {
236
236
return (
Original file line number Diff line number Diff line change @@ -643,8 +643,8 @@ class Block implements BlockOptions {
643
643
setInnerHTML ( innerHTML : string ) {
644
644
this . innerHTML = innerHTML ;
645
645
}
646
- toggleVisibility ( ) {
647
- if ( this . getStyle ( "display" ) === "none" ) {
646
+ toggleVisibility ( show : boolean | null = null ) {
647
+ if ( this . getStyle ( "display" ) === "none" || show === false ) {
648
648
this . setStyle ( "display" , this . getStyle ( "__last_display" ) || "flex" ) ;
649
649
this . setStyle ( "__last_display" , null ) ;
650
650
} else {
Original file line number Diff line number Diff line change @@ -228,25 +228,26 @@ export function useCanvasUtils(
228
228
return null ;
229
229
}
230
230
231
- function removeBlock ( block : Block ) {
231
+ function removeBlock ( block : Block , force : boolean = false ) {
232
232
if ( block . blockId === "root" ) {
233
233
toast . warning ( "Warning" , {
234
234
description : "Cannot delete root block" ,
235
235
} ) ;
236
236
return ;
237
237
}
238
238
if ( block . isChildOfComponentBlock ( ) ) {
239
- toast . warning ( "Warning" , {
240
- description : "Cannot delete block inside component" ,
241
- } ) ;
242
- return ;
239
+ block . toggleVisibility ( false ) ;
243
240
}
244
241
const parentBlock = block . parentBlock ;
245
242
if ( ! parentBlock ) {
246
243
return ;
247
244
}
248
245
const index = parentBlock . children . indexOf ( block ) ;
249
- parentBlock . removeChild ( block ) ;
246
+ if ( store . activeBreakpoint === "desktop" || force ) {
247
+ parentBlock . removeChild ( block ) ;
248
+ } else {
249
+ block . toggleVisibility ( false ) ;
250
+ }
250
251
nextTick ( ( ) => {
251
252
if ( parentBlock . children . length ) {
252
253
const nextSibling = parentBlock . children [ index ] || parentBlock . children [ index - 1 ] ;
You can’t perform that action at this time.
0 commit comments