diff --git a/packages/base-styles/_z-index.scss b/packages/base-styles/_z-index.scss index 52476cd03228f6..55ad2f9c6313f3 100644 --- a/packages/base-styles/_z-index.scss +++ b/packages/base-styles/_z-index.scss @@ -10,8 +10,7 @@ $z-layers: ( ".block-library-classic__toolbar": 31, // When scrolled to top this toolbar needs to sit over block-editor-block-toolbar ".block-editor-block-list__block-selection-button": 22, ".components-form-toggle__input": 1, - ".edit-post-text-editor__toolbar": 1, - ".edit-site-code-editor__toolbar": 1, + ".editor-text-editor__toolbar": 1, // These next three share a stacking context ".block-library-template-part__selection-search": 2, // higher sticky element diff --git a/packages/edit-post/src/components/layout/index.js b/packages/edit-post/src/components/layout/index.js index 6db95b6694a686..fde9319a348daf 100644 --- a/packages/edit-post/src/components/layout/index.js +++ b/packages/edit-post/src/components/layout/index.js @@ -38,7 +38,6 @@ import { addQueryArgs } from '@wordpress/url'; /** * Internal dependencies */ -import TextEditor from '../text-editor'; import VisualEditor from '../visual-editor'; import EditPostKeyboardShortcuts from '../keyboard-shortcuts'; import InitPatternModal from '../init-pattern-modal'; @@ -62,6 +61,7 @@ const { InterfaceSkeleton, interfaceStore, Sidebar, + TextEditor, } = unlock( editorPrivateApis ); const { BlockKeyboardShortcuts } = unlock( blockLibraryPrivateApis ); diff --git a/packages/edit-post/src/components/text-editor/index.js b/packages/edit-post/src/components/text-editor/index.js deleted file mode 100644 index af3818e1778859..00000000000000 --- a/packages/edit-post/src/components/text-editor/index.js +++ /dev/null @@ -1,63 +0,0 @@ -/** - * WordPress dependencies - */ -import { - PostTextEditor, - PostTitleRaw, - store as editorStore, -} from '@wordpress/editor'; -import { Button } from '@wordpress/components'; -import { useDispatch, useSelect } from '@wordpress/data'; -import { __ } from '@wordpress/i18n'; -import { displayShortcut } from '@wordpress/keycodes'; -import { useEffect, useRef } from '@wordpress/element'; - -/** - * Internal dependencies - */ -import { store as editPostStore } from '../../store'; - -export default function TextEditor() { - const isRichEditingEnabled = useSelect( ( select ) => { - return select( editorStore ).getEditorSettings().richEditingEnabled; - }, [] ); - const { switchEditorMode } = useDispatch( editorStore ); - - const { isWelcomeGuideVisible } = useSelect( ( select ) => { - const { isFeatureActive } = select( editPostStore ); - - return { - isWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ), - }; - }, [] ); - - const titleRef = useRef(); - - useEffect( () => { - if ( isWelcomeGuideVisible ) { - return; - } - titleRef?.current?.focus(); - }, [ isWelcomeGuideVisible ] ); - - return ( -
- { isRichEditingEnabled && ( -
-

{ __( 'Editing code' ) }

- -
- ) } -
- - -
-
- ); -} diff --git a/packages/edit-post/src/components/visual-editor/index.js b/packages/edit-post/src/components/visual-editor/index.js index 43ee2458ceba24..f6686b5977dd4e 100644 --- a/packages/edit-post/src/components/visual-editor/index.js +++ b/packages/edit-post/src/components/visual-editor/index.js @@ -22,7 +22,7 @@ import { store as editPostStore } from '../../store'; import { unlock } from '../../lock-unlock'; import { usePaddingAppender } from './use-padding-appender'; -const { EditorCanvas } = unlock( editorPrivateApis ); +const { VisualEditor: VisualEditorRoot } = unlock( editorPrivateApis ); const isGutenbergPlugin = globalThis.IS_GUTENBERG_PLUGIN ? true : false; const DESIGN_POST_TYPES = [ @@ -105,7 +105,7 @@ export default function VisualEditor( { styles } ) { 'has-inline-canvas': ! isToBeIframed, } ) } > - { const { getCanvasMode } = unlock( select( editSiteStore ) ); @@ -95,7 +95,7 @@ function EditorCanvas( { settings, children } ) { ); return ( - - { children } - + /> ); } diff --git a/packages/edit-site/src/components/code-editor/index.js b/packages/edit-site/src/components/code-editor/index.js deleted file mode 100644 index 8c27a48b01cec9..00000000000000 --- a/packages/edit-site/src/components/code-editor/index.js +++ /dev/null @@ -1,94 +0,0 @@ -/** - * External dependencies - */ -import Textarea from 'react-autosize-textarea'; - -/** - * WordPress dependencies - */ -import { __unstableSerializeAndClean } from '@wordpress/blocks'; -import { store as coreStore } from '@wordpress/core-data'; -import { useSelect, useDispatch } from '@wordpress/data'; -import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts'; -import { __ } from '@wordpress/i18n'; -import { Button, VisuallyHidden } from '@wordpress/components'; -import { useMemo } from '@wordpress/element'; -import { useInstanceId } from '@wordpress/compose'; -import { store as editorStore } from '@wordpress/editor'; - -/** - * Internal dependencies - */ -import { store as editSiteStore } from '../../store'; - -export default function CodeEditor() { - const instanceId = useInstanceId( CodeEditor ); - const { shortcut, content, blocks, type, id } = useSelect( ( select ) => { - const { getEditedEntityRecord } = select( coreStore ); - const { getEditedPostType, getEditedPostId } = select( editSiteStore ); - const { getShortcutRepresentation } = select( keyboardShortcutsStore ); - const _type = getEditedPostType(); - const _id = getEditedPostId(); - const editedRecord = getEditedEntityRecord( 'postType', _type, _id ); - - return { - shortcut: getShortcutRepresentation( 'core/editor/toggle-mode' ), - content: editedRecord?.content, - blocks: editedRecord?.blocks, - type: _type, - id: _id, - }; - }, [] ); - const { editEntityRecord } = useDispatch( coreStore ); - // Replicates the logic found in getEditedPostContent(). - const realContent = useMemo( () => { - if ( content instanceof Function ) { - return content( { blocks } ); - } else if ( blocks ) { - // If we have parsed blocks already, they should be our source of truth. - // Parsing applies block deprecations and legacy block conversions that - // unparsed content will not have. - return __unstableSerializeAndClean( blocks ); - } - return content; - }, [ content, blocks ] ); - - const { switchEditorMode } = useDispatch( editorStore ); - return ( -
-
-

{ __( 'Editing code' ) }

- -
-
- - { __( 'Type text or HTML' ) } - -