File tree 1 file changed +9
-1
lines changed
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import {
13
13
switchToBlockType ,
14
14
createBlock ,
15
15
serialize ,
16
+ isSharedBlock ,
16
17
getDefaultBlockForPostFormat ,
17
18
doBlocksMatchTemplate ,
18
19
synchronizeBlocksWithTemplate ,
@@ -39,6 +40,7 @@ import {
39
40
removeNotice ,
40
41
saveSharedBlock ,
41
42
insertBlock ,
43
+ removeBlocks ,
42
44
selectBlock ,
43
45
removeBlock ,
44
46
resetBlocks ,
@@ -545,7 +547,13 @@ export default {
545
547
}
546
548
547
549
const { id } = action ;
548
- const { dispatch } = store ;
550
+ const { getState, dispatch } = store ;
551
+
552
+ // Remove any blocks that reference this shared block
553
+ const allBlocks = getBlocks ( getState ( ) ) ;
554
+ const associatedBlocks = allBlocks . filter ( ( block ) => isSharedBlock ( block ) && block . attributes . ref === id ) ;
555
+ const associatedBlockUids = associatedBlocks . map ( ( block ) => block . uid ) ;
556
+ dispatch ( removeBlocks ( associatedBlockUids ) ) ;
549
557
550
558
const transactionId = uniqueId ( ) ;
551
559
You can’t perform that action at this time.
0 commit comments