PluginProbe
Extendify / 1.1.0
Extendify v1.1.0
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 1.1.0, at src/Library/app.js

46 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 import './app.css'
10
11 window?.wp?.domReady(() => {
12 // Insert into the editor (note: Modal opens in a portal)
13 const extendify = Object.assign(document.createElement('div'), {
14 id: 'extendify-root',
15 })
16 document.body.append(extendify)
17 render(<ExtendifyLibrary />, extendify)
18
19 // Add an extra div to use for utility modals, etc
20 extendify.parentNode.insertBefore(
21 Object.assign(document.createElement('div'), {
22 id: 'extendify-util',
23 }),
24 extendify.nextSibling,
25 )
26
27 // Insert a template on page load if it exists in localstorage
28 // Note 6/28/21 - this was moved to after the render to possibly
29 // fix a bug where imports would go from 3->0.
30 if (useWantedTemplateStore.getState().importOnLoad) {
31 const template = useWantedTemplateStore.getState().wantedTemplate
32 setTimeout(() => {
33 injectTemplateBlocks(
34 rawHandler({ HTML: template.fields.code }),
35 template,
36 )
37 }, 0)
38 }
39
40 // Reset template state after checking if we need an import
41 useWantedTemplateStore.setState({
42 importOnLoad: false,
43 wantedTemplate: {},
44 })
45 })
46