@@ -56,7 +56,7 @@ const editorComponents = {
56
56
} ) ,
57
57
} ;
58
58
59
- function registerWidgetsAndEditorComponents ( config : CmsConfig ) {
59
+ async function registerWidgetsAndEditorComponents ( config : CmsConfig ) {
60
60
const usedWidgets = new Set < string > ( ) ;
61
61
const usedEditorComponents = new Set < string > ( ) ;
62
62
@@ -71,22 +71,24 @@ function registerWidgetsAndEditorComponents(config: CmsConfig) {
71
71
}
72
72
73
73
// Load and register all used editor components
74
- usedEditorComponents . values ( ) . map ( async type => {
75
- const loader = editorComponents [ type as keyof typeof editorComponents ] ;
76
- if ( loader ) {
77
- // Don't override manually registered components...
78
- if ( ! cms . getEditorComponents ( ) . has ( type ) ) {
79
- cms . registerEditorComponent ( await loader ( ) ) ;
80
- }
81
- } else {
82
- // Check if the component has been manually registered...
83
- if ( ! cms . getEditorComponents ( ) . has ( type ) ) {
84
- throw new Error (
85
- `Unknown editor component "${ type } ". If this is a custom component, make sure to register it.` ,
86
- ) ;
74
+ await Promise . all (
75
+ [ ...usedEditorComponents ] . map ( async type => {
76
+ const loader = editorComponents [ type as keyof typeof editorComponents ] ;
77
+ if ( loader ) {
78
+ // Don't override manually registered components...
79
+ if ( ! cms . getEditorComponents ( ) . has ( type ) ) {
80
+ cms . registerEditorComponent ( await loader ( ) ) ;
81
+ }
82
+ } else {
83
+ // Check if the component has been manually registered...
84
+ if ( ! cms . getEditorComponents ( ) . has ( type ) ) {
85
+ throw new Error (
86
+ `Unknown editor component "${ type } ". If this is a custom component, make sure to register it.` ,
87
+ ) ;
88
+ }
87
89
}
88
- }
89
- } ) ;
90
+ } ) ,
91
+ ) ;
90
92
91
93
// Collect widgets from editor components (like the "code" widget from the code-block)
92
94
cms
0 commit comments