| 1 |
import { |
| 2 |
getBlockType, |
| 3 |
registerBlockType, |
| 4 |
unregisterBlockType, |
| 5 |
type BlockConfiguration, |
| 6 |
} from "@wordpress/blocks"; |
| 7 |
import Edit from "./edit"; |
| 8 |
import blockMetadata from "./block.json"; |
| 9 |
|
| 10 |
// Merge full block.json so keywords, supports.inserter, and description stay in sync for the inserter/search. |
| 11 |
const { |
| 12 |
$schema: _$schema, |
| 13 |
editorScript: _$editorScript, |
| 14 |
...metadata |
| 15 |
} = blockMetadata; |
| 16 |
|
| 17 |
// If a stale registration exists (no edit / partial merge), replace it so the inserter works. |
| 18 |
if (getBlockType(metadata.name)) { |
| 19 |
unregisterBlockType(metadata.name); |
| 20 |
} |
| 21 |
|
| 22 |
registerBlockType(metadata.name, { |
| 23 |
...metadata, |
| 24 |
edit: Edit, |
| 25 |
save: () => null, |
| 26 |
} as unknown as BlockConfiguration); |
| 27 |
|