Components
10 months ago
autoloader.js
1 year ago
edit.js
6 months ago
ic-arrow-up-right-square.svg
11 months ago
index.js
6 months ago
reach-logo.svg
11 months ago
styles.scss
1 month ago
view.js
1 month ago
autoloader.js
24 lines
| 1 | wp.domReady(() => { |
| 2 | whenEditorIsReady().then(() => { |
| 3 | let block = wp.blocks.createBlock('hostinger-reach/subscription', {}); |
| 4 | setTimeout(() => { |
| 5 | wp.data.dispatch('core/block-editor').insertBlocks(block); |
| 6 | }, 0); |
| 7 | |
| 8 | }); |
| 9 | |
| 10 | function whenEditorIsReady() { |
| 11 | return new Promise((resolve) => { |
| 12 | const unsubscribe = wp.data.subscribe(() => { |
| 13 | if (wp.data.select('core/editor').isCleanNewPost() || wp.data.select('core/block-editor').getBlockCount() > 0) { |
| 14 | unsubscribe() |
| 15 | resolve() |
| 16 | } |
| 17 | }) |
| 18 | }) |
| 19 | } |
| 20 | }); |
| 21 | |
| 22 | |
| 23 | |
| 24 |