-
Notifications
You must be signed in to change notification settings - Fork 63
/
editor.tsx
45 lines (42 loc) · 1.3 KB
/
editor.tsx
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
import '@wordpress/format-library'; // Enables text formatting capabilities
import { useSelect } from '@wordpress/data';
import { StrictMode, createRoot } from '@wordpress/element';
import { SlotFillProvider } from '@wordpress/components';
import { ShortcutProvider } from '@wordpress/keyboard-shortcuts';
import { EntityProvider } from '@wordpress/core-data';
import { initBlocks } from './blocks';
import { BlockEditor } from './components/block-editor';
import { createStore, storeName } from './store';
import { initHooks } from './hooks';
import { KeyboardShortcuts } from './components/keybord-shortcuts';
function Editor() {
const { postId } = useSelect(
(select) => ({
postId: select(storeName).getEmailPostId(),
}),
[],
);
return (
<StrictMode>
<ShortcutProvider>
<SlotFillProvider>
<KeyboardShortcuts />
<EntityProvider kind="postType" type="mailpoet_email" id={postId}>
<BlockEditor />
</EntityProvider>
</SlotFillProvider>
</ShortcutProvider>
</StrictMode>
);
}
export function initialize(elementId: string) {
const container = document.getElementById(elementId);
if (!container) {
return;
}
createStore();
initBlocks();
initHooks();
const root = createRoot(container);
root.render(<Editor />);
}