| 1 |
import { MainButton } from '@library/components/MainButton'; |
| 2 |
import { Modal } from '@library/components/Modal'; |
| 3 |
import { render } from '@shared/lib/dom'; |
| 4 |
import '@library/library.css'; |
| 5 |
import { whenEditorIsReady } from '@shared/lib/wp'; |
| 6 |
|
| 7 |
whenEditorIsReady().then(() => { |
| 8 |
const id = 'extendify-library-btn'; |
| 9 |
const className = 'extendify-library'; |
| 10 |
const page = '.editor-document-tools'; |
| 11 |
// const fse = '.edit-site-header-edit-mode__start'; |
| 12 |
|
| 13 |
if (document.getElementById(id)) return; |
| 14 |
const btnWrap = document.createElement('div'); |
| 15 |
const btn = Object.assign(btnWrap, { id, className }); |
| 16 |
render(<MainButton />, btn); |
| 17 |
setTimeout(() => { |
| 18 |
document.querySelector(page)?.after(btn); |
| 19 |
// document.querySelector(fse)?.append(btn); |
| 20 |
}, 300); |
| 21 |
|
| 22 |
const mdl = 'extendify-library-modal'; |
| 23 |
if (document.getElementById(mdl)) return; |
| 24 |
const modalWrap = document.createElement('div'); |
| 25 |
const modal = Object.assign(modalWrap, { id: mdl, className }); |
| 26 |
document.body.append(modal); |
| 27 |
render(<Modal />, modal); |
| 28 |
}); |
| 29 |
|