| 1 |
import { useEffect } from '@wordpress/element'; |
| 2 |
import { select } from '@wordpress/data'; |
| 3 |
|
| 4 |
const usePreviewDeviceType = (setAttributes, attributeName = 'resOption', dependencies = []) => { |
| 5 |
useEffect(() => { |
| 6 |
const editorType = window?.betterDocsBlocksHelper?.editorType ?? 'core/edit-post'; |
| 7 |
setAttributes({ |
| 8 |
[attributeName]: select( editorType ).__experimentalGetPreviewDeviceType(), |
| 9 |
}); |
| 10 |
}, dependencies); |
| 11 |
} |
| 12 |
|
| 13 |
export default usePreviewDeviceType |
| 14 |
|