diff --git a/packages/client/src/components/Block.svelte b/packages/client/src/components/Block.svelte
index 75474dfd6f..8258912e52 100644
--- a/packages/client/src/components/Block.svelte
+++ b/packages/client/src/components/Block.svelte
@@ -9,7 +9,7 @@
let structureLookupMap = {}
const registerBlockComponent = (id, order, parentId, instance) => {
- // Ensure child array exists
+ // Ensure child map exists
if (!structureLookupMap[parentId]) {
structureLookupMap[parentId] = {}
}
@@ -18,6 +18,14 @@
structureLookupMap[parentId][order] = instance
}
+ const unregisterBlockComponent = (order, parentId) => {
+ // Ensure child map exists
+ if (!structureLookupMap[parentId]) {
+ return
+ }
+ delete structureLookupMap[parentId][order]
+ }
+
const eject = () => {
// Start the new structure with the root component
let definition = structureLookupMap[$component.id][0]
@@ -73,6 +81,7 @@
// We register block components with their raw props so that we can eject
// blocks later on
registerComponent: registerBlockComponent,
+ unregisterComponent: unregisterBlockComponent,
})
onMount(() => {
diff --git a/packages/client/src/components/BlockComponent.svelte b/packages/client/src/components/BlockComponent.svelte
index 2f756ce296..0131c5f0d4 100644
--- a/packages/client/src/components/BlockComponent.svelte
+++ b/packages/client/src/components/BlockComponent.svelte
@@ -1,5 +1,5 @@