diff --git a/packages/slate-editor/src/extensions/coverage/components/CoverageElement.tsx b/packages/slate-editor/src/extensions/coverage/components/CoverageElement.tsx index cc8ad0720..79afea370 100644 --- a/packages/slate-editor/src/extensions/coverage/components/CoverageElement.tsx +++ b/packages/slate-editor/src/extensions/coverage/components/CoverageElement.tsx @@ -60,6 +60,16 @@ export function CoverageElement({ } } + useEffect(() => { + function handleCoverageUpdated({ coverage }: { coverage: Pick}) { + if (element.coverage.id === coverage.id) { + loadCoverage(); + } + } + + return EventsEditor.addEventListener(editor, 'coverage-updated', handleCoverageUpdated); + }, []); + return ( ( diff --git a/packages/slate-editor/src/modules/events/types.ts b/packages/slate-editor/src/modules/events/types.ts index 7c8125998..08df06555 100644 --- a/packages/slate-editor/src/modules/events/types.ts +++ b/packages/slate-editor/src/modules/events/types.ts @@ -74,6 +74,9 @@ export type EditorEventMap = { 'coverage-placeholder-submitted': { coverage: Pick; }; + 'coverage-updated': { + coverage: Pick; + }; 'coverage-removed': { uuid: string; };