diff --git a/src/editor-sidebar/global-styles-json-editor-modal.js b/src/editor-sidebar/global-styles-json-editor-modal.js new file mode 100644 index 00000000..e4d8c0ee --- /dev/null +++ b/src/editor-sidebar/global-styles-json-editor-modal.js @@ -0,0 +1,72 @@ +/** + * External dependencies + */ +import CodeMirror from '@uiw/react-codemirror'; +import { json } from '@codemirror/lang-json'; + +/** + * WordPress dependencies + */ +import { __, sprintf } from '@wordpress/i18n'; +import { Modal } from '@wordpress/components'; +import { useSelect } from '@wordpress/data'; +import { store as coreStore } from '@wordpress/core-data'; + +const GlobalStylesJsonEditorModal = ( { onRequestClose } ) => { + const themeName = useSelect( ( select ) => + select( 'core' ).getCurrentTheme() + )?.name?.raw; + + const { record: globalStylesRecord } = useSelect( ( select ) => { + const { + __experimentalGetCurrentGlobalStylesId, + getEditedEntityRecord, + } = select( coreStore ); + const globalStylesId = __experimentalGetCurrentGlobalStylesId(); + const record = getEditedEntityRecord( + 'root', + 'globalStyles', + globalStylesId + ); + return { + record, + }; + } ); + + const globalStyles = { + ...( globalStylesRecord?.styles && { + styles: globalStylesRecord.styles, + } ), + ...( globalStylesRecord?.settings && { + settings: globalStylesRecord.settings, + } ), + }; + + const globalStylesAsString = globalStyles + ? JSON.stringify( globalStyles, null, 4 ) + : ''; + + const handleSave = () => {}; + + return ( + + + + ); +}; + +export default GlobalStylesJsonEditorModal; diff --git a/src/plugin-sidebar.js b/src/plugin-sidebar.js index 1c65631a..25b5f860 100644 --- a/src/plugin-sidebar.js +++ b/src/plugin-sidebar.js @@ -47,6 +47,7 @@ import { */ import { CreateThemePanel } from './editor-sidebar/create-panel'; import ThemeJsonEditorModal from './editor-sidebar/json-editor-modal'; +import GlobalStylesJsonEditorModal from './editor-sidebar/global-styles-json-editor-modal'; import { SaveThemePanel } from './editor-sidebar/save-panel'; import { CreateVariationPanel } from './editor-sidebar/create-variation-panel'; import { ThemeMetadataEditorModal } from './editor-sidebar/metadata-editor-modal'; @@ -59,6 +60,8 @@ import './plugin-styles.scss'; const CreateBlockThemePlugin = () => { const [ isEditorOpen, setIsEditorOpen ] = useState( false ); + const [ isGlobalStylesEditorOpen, setIsGlobalStylesEditorOpen ] = + useState( false ); const [ isMetadataEditorOpen, setIsMetadataEditorOpen ] = useState( false ); @@ -155,6 +158,17 @@ const CreateBlockThemePlugin = () => { 'create-block-theme' ) } +