| 1 |
import domReady from '@wordpress/dom-ready'; |
| 2 |
import { render } from '@shared/lib/dom'; |
| 3 |
import { isOnLaunch } from '@shared/lib/utils'; |
| 4 |
import { Agent } from '@agent/Agent.jsx'; |
| 5 |
import '@agent/agent.css'; |
| 6 |
import '@agent/buttons'; |
| 7 |
import { GuidedTour } from '@agent/components/GuidedTour'; |
| 8 |
import { ReOpenToolTip } from '@agent/components/tooltip/ReOpenToolTip'; |
| 9 |
|
| 10 |
const isInsideIframe = () => !!document.querySelector('#plugin-information'); |
| 11 |
|
| 12 |
domReady(() => { |
| 13 |
const bg = |
| 14 |
// admin area |
| 15 |
document.getElementById('wpwrap') || |
| 16 |
// TODO: is this on all block themes? |
| 17 |
document.querySelector('.wp-site-blocks'); |
| 18 |
if (isOnLaunch() || isInsideIframe() || !bg) return; |
| 19 |
const id = 'extendify-agent-main'; |
| 20 |
if (document.getElementById(id)) return; |
| 21 |
const agent = Object.assign(document.createElement('div'), { |
| 22 |
className: 'extendify-agent', |
| 23 |
id, |
| 24 |
}); |
| 25 |
document.body.appendChild(agent); |
| 26 |
render(<Agent />, agent); |
| 27 |
// tours |
| 28 |
const tourId = 'extendify-agent-tour'; |
| 29 |
if (document.getElementById(tourId)) return; |
| 30 |
const tour = Object.assign(document.createElement('div'), { |
| 31 |
className: 'extendify-agent-tour', |
| 32 |
id: tourId, |
| 33 |
}); |
| 34 |
render(<GuidedTour />, tour); |
| 35 |
|
| 36 |
// tooltip |
| 37 |
const div = Object.assign(document.createElement('div'), { |
| 38 |
id: 'extendify-agent-modal-tooltip', |
| 39 |
}); |
| 40 |
document.body.appendChild(div); |
| 41 |
render(<ReOpenToolTip />, div); |
| 42 |
}); |
| 43 |
|