66 registerCoreBlocks ,
77 __experimentalRegisterExperimentalCoreBlocks ,
88} from '@wordpress/block-library' ;
9- import { render , unmountComponentAtNode } from '@wordpress/element' ;
9+ import { createRoot } from '@wordpress/element' ;
1010import { dispatch , select } from '@wordpress/data' ;
1111import { addFilter } from '@wordpress/hooks' ;
1212import { store as preferencesStore } from '@wordpress/preferences' ;
@@ -19,49 +19,6 @@ import './plugins';
1919import Editor from './editor' ;
2020import { store as editPostStore } from './store' ;
2121
22- /**
23- * Reinitializes the editor after the user chooses to reboot the editor after
24- * an unhandled error occurs, replacing previously mounted editor element using
25- * an initial state from prior to the crash.
26- *
27- * @param {Object } postType Post type of the post to edit.
28- * @param {Object } postId ID of the post to edit.
29- * @param {Element } target DOM node in which editor is rendered.
30- * @param {?Object } settings Editor settings object.
31- * @param {Object } initialEdits Programmatic edits to apply initially, to be
32- * considered as non-user-initiated (bypass for
33- * unsaved changes prompt).
34- */
35- export function reinitializeEditor (
36- postType ,
37- postId ,
38- target ,
39- settings ,
40- initialEdits
41- ) {
42- unmountComponentAtNode ( target ) ;
43- const reboot = reinitializeEditor . bind (
44- null ,
45- postType ,
46- postId ,
47- target ,
48- settings ,
49- initialEdits
50- ) ;
51-
52- render (
53- < Editor
54- settings = { settings }
55- onError = { reboot }
56- postId = { postId }
57- postType = { postType }
58- initialEdits = { initialEdits }
59- recovery
60- /> ,
61- target
62- ) ;
63- }
64-
6522/**
6623 * Initializes and returns an instance of Editor.
6724 *
@@ -81,14 +38,6 @@ export function initializeEditor(
8138 initialEdits
8239) {
8340 const target = document . getElementById ( id ) ;
84- const reboot = reinitializeEditor . bind (
85- null ,
86- postType ,
87- postId ,
88- target ,
89- settings ,
90- initialEdits
91- ) ;
9241
9342 dispatch ( preferencesStore ) . setDefaults ( 'core/edit-post' , {
9443 editorMode : 'visual' ,
@@ -185,15 +134,13 @@ export function initializeEditor(
185134 window . addEventListener ( 'dragover' , ( e ) => e . preventDefault ( ) , false ) ;
186135 window . addEventListener ( 'drop' , ( e ) => e . preventDefault ( ) , false ) ;
187136
188- render (
137+ createRoot ( target ) . render (
189138 < Editor
190139 settings = { settings }
191- onError = { reboot }
192140 postId = { postId }
193141 postType = { postType }
194142 initialEdits = { initialEdits }
195- /> ,
196- target
143+ />
197144 ) ;
198145}
199146
0 commit comments