| 1 |
import { select, subscribe } from '@wordpress/data' |
| 2 |
|
| 3 |
export function whenEditorIsReady() { |
| 4 |
return new Promise((resolve) => { |
| 5 |
const unsubscribe = subscribe(() => { |
| 6 |
// This will trigger after the initial render blocking, before the window load event |
| 7 |
// This seems currently more reliable than using __unstableIsEditorReady |
| 8 |
if ( |
| 9 |
select('core/editor').isCleanNewPost() || |
| 10 |
select('core/block-editor').getBlockCount() > 0 |
| 11 |
) { |
| 12 |
unsubscribe() |
| 13 |
resolve() |
| 14 |
} |
| 15 |
}) |
| 16 |
}) |
| 17 |
} |
| 18 |
|