react-code-dataset / wp-calypso /apps /wpcom-block-editor /src /wpcom /features /live-preview /index.tsx
react-code-dataset / wp-calypso /apps /wpcom-block-editor /src /wpcom /features /live-preview /index.tsx
Download wp-calypso/apps/wpcom-block-editor/src/wpcom/features/live-preview/index.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 885 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/apps/wpcom-block-editor/src/wpcom/features/live-preview/index.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/apps/wpcom-block-editor/src/wpcom/features/live-preview/index.tsx
-
curl -L -o index.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/apps/wpcom-block-editor/src/wpcom/features/live-preview/index.tsx
885 Bytes
| import { useSelect } from '@wordpress/data'; | |
| import domReady from '@wordpress/dom-ready'; | |
| import { registerPlugin } from '@wordpress/plugins'; | |
| import { usePreviewingThemeSlug } from './hooks/use-previewing-theme'; | |
| import LivePreviewNoticePlugin from './live-preview-notice-plugin'; | |
| const LivePreviewPlugin = () => { | |
| const siteEditorStore = useSelect( ( select ) => select( 'core/edit-site' ), [] ); | |
| const previewingThemeSlug = usePreviewingThemeSlug(); | |
| // Do nothing outside the Site Editor context. | |
| if ( ! siteEditorStore ) { | |
| return null; | |
| } | |
| // Don't render unless the user is previewing a theme. | |
| if ( ! previewingThemeSlug ) { | |
| return null; | |
| } | |
| return <LivePreviewNoticePlugin />; | |
| }; | |
| const registerLivePreviewPlugin = () => { | |
| registerPlugin( 'wpcom-live-preview', { | |
| render: () => <LivePreviewPlugin />, | |
| } ); | |
| }; | |
| domReady( () => { | |
| registerLivePreviewPlugin(); | |
| } ); | |