forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
87 lines (78 loc) · 3.22 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
* WordPress dependencies
*/
import '@wordpress/core-data';
import '@wordpress/editor';
import '@wordpress/nux';
import '@wordpress/viewport';
import { registerCoreBlocks } from '@wordpress/block-library';
import { render, unmountComponentAtNode } from '@wordpress/element';
import { dispatch } from '@wordpress/data';
/**
* Internal dependencies
*/
import './assets/stylesheets/main.scss';
import './hooks';
import './plugins';
import store from './store';
import { initializeMetaBoxState } from './store/actions';
import Editor from './editor';
/**
* Reinitializes the editor after the user chooses to reboot the editor after
* an unhandled error occurs, replacing previously mounted editor element using
* an initial state from prior to the crash.
*
* @param {Object} postType Post type of the post to edit.
* @param {Object} postId ID of the post to edit.
* @param {Element} target DOM node in which editor is rendered.
* @param {?Object} settings Editor settings object.
* @param {Object} overridePost Post properties to override.
*/
export function reinitializeEditor( postType, postId, target, settings, overridePost ) {
unmountComponentAtNode( target );
const reboot = reinitializeEditor.bind( null, postType, postId, target, settings, overridePost );
render(
<Editor settings={ settings } onError={ reboot } postId={ postId } postType={ postType } overridePost={ overridePost } recovery />,
target
);
}
/**
* Initializes and returns an instance of Editor.
*
* The return value of this function is not necessary if we change where we
* call initializeEditor(). This is due to metaBox timing.
*
* @param {string} id Unique identifier for editor instance.
* @param {Object} postType Post type of the post to edit.
* @param {Object} postId ID of the post to edit.
* @param {?Object} settings Editor settings object.
* @param {Object} overridePost Post properties to override.
*
* @return {Object} Editor interface.
*/
export function initializeEditor( id, postType, postId, settings, overridePost ) {
const target = document.getElementById( id );
const reboot = reinitializeEditor.bind( null, postType, postId, target, settings, overridePost );
registerCoreBlocks();
dispatch( 'core/nux' ).triggerGuide( [
'core/editor.inserter',
'core/editor.settings',
'core/editor.preview',
'core/editor.publish',
] );
render(
<Editor settings={ settings } onError={ reboot } postId={ postId } postType={ postType } overridePost={ overridePost } />,
target
);
return {
initializeMetaBoxes( metaBoxes ) {
store.dispatch( initializeMetaBoxState( metaBoxes ) );
},
};
}
export { default as PluginBlockSettingsMenuItem } from './components/block-settings-menu/plugin-block-settings-menu-item';
export { default as PluginPostPublishPanel } from './components/sidebar/plugin-post-publish-panel';
export { default as PluginPostStatusInfo } from './components/sidebar/plugin-post-status-info';
export { default as PluginPrePublishPanel } from './components/sidebar/plugin-pre-publish-panel';
export { default as PluginSidebar } from './components/sidebar/plugin-sidebar';
export { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';