PluginProbe
Extendify / 1.16.1
Extendify v1.16.1
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 / library.js

library.js in Extendify 1.16.1, at src/Library/library.js

34 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { createRoot } from '@wordpress/element';
2 import { registerPlugin } from '@wordpress/plugins';
3 import { MainButton } from '@library/components/MainButton';
4 import { Modal } from '@library/components/Modal';
5 import './library.css';
6
7 registerPlugin('extendify-library', {
8 render: () => {
9 if (typeof createRoot !== 'function') return;
10 const id = 'extendify-library-btn';
11 const className = 'extendify-library';
12 const page = '.edit-post-header-toolbar';
13 const fse = '.edit-site-header-edit-mode__start';
14 if (!document.querySelector(page) && !document.querySelector(fse)) {
15 return;
16 }
17 requestAnimationFrame(() => {
18 if (document.getElementById(id)) return;
19 const btnWrap = document.createElement('div');
20 const btn = Object.assign(btnWrap, { id, className });
21 document.querySelector(page)?.append(btn);
22 document.querySelector(fse)?.append(btn);
23 createRoot(btn).render(<MainButton />);
24
25 const mdl = 'extendify-library-modal';
26 if (document.getElementById(mdl)) return;
27 const modalWrap = document.createElement('div');
28 const modal = Object.assign(modalWrap, { id: mdl, className });
29 document.body.append(modal);
30 createRoot(modal).render(<Modal />);
31 });
32 },
33 });
34