PluginProbe
Extendify / 0.9.2
Extendify v0.9.2
3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 0.7.0 All 126 releases
extendify / src / Library / app.js

app.js in Extendify 0.9.2, at src/Library/app.js

45 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { rawHandler } from '@wordpress/blocks'
2 import { render } from '@wordpress/element'
3 import ExtendifyLibrary from '@library/ExtendifyLibrary'
4 import '@library/blocks/blocks'
5 import '@library/buttons'
6 import '@library/listeners'
7 import { useWantedTemplateStore } from '@library/state/Importing'
8 import { injectTemplateBlocks } from '@library/util/templateInjection'
9
10 window?.wp?.domReady(() => {
11 // Insert into the editor (note: Modal opens in a portal)
12 const extendify = Object.assign(document.createElement('div'), {
13 id: 'extendify-root',
14 })
15 document.body.append(extendify)
16 render(<ExtendifyLibrary />, extendify)
17
18 // Add an extra div to use for utility modals, etc
19 extendify.parentNode.insertBefore(
20 Object.assign(document.createElement('div'), {
21 id: 'extendify-util',
22 }),
23 extendify.nextSibling,
24 )
25
26 // Insert a template on page load if it exists in localstorage
27 // Note 6/28/21 - this was moved to after the render to possibly
28 // fix a bug where imports would go from 3->0.
29 if (useWantedTemplateStore.getState().importOnLoad) {
30 const template = useWantedTemplateStore.getState().wantedTemplate
31 setTimeout(() => {
32 injectTemplateBlocks(
33 rawHandler({ HTML: template.fields.code }),
34 template,
35 )
36 }, 0)
37 }
38
39 // Reset template state after checking if we need an import
40 useWantedTemplateStore.setState({
41 importOnLoad: false,
42 wantedTemplate: {},
43 })
44 })
45