Add editor styles to product editor and iframe editor (#38168)
* Add editor styles to product editor and iframe editor * Make section title css selectors more specific * Add changelog entry * Remove additional commented component * Remove unused import
This commit is contained in:
parent
246053277e
commit
a587612934
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: minor
|
||||||
|
Type: fix
|
||||||
|
|
||||||
|
Add editor styles to product editor and iframe editor
|
|
@ -6,7 +6,7 @@
|
||||||
padding-top: 64px;
|
padding-top: 64px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__title {
|
.wp-block-woocommerce-product-section__title {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
|
|
|
@ -19,6 +19,9 @@ import {
|
||||||
EditorSettings,
|
EditorSettings,
|
||||||
EditorBlockListSettings,
|
EditorBlockListSettings,
|
||||||
ObserveTyping,
|
ObserveTyping,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore No types for this exist yet.
|
||||||
|
__unstableEditorStyles as EditorStyles,
|
||||||
} from '@wordpress/block-editor';
|
} from '@wordpress/block-editor';
|
||||||
// It doesn't seem to notice the External dependency block whn @ts-ignore is added.
|
// It doesn't seem to notice the External dependency block whn @ts-ignore is added.
|
||||||
// eslint-disable-next-line @woocommerce/dependency-group
|
// eslint-disable-next-line @woocommerce/dependency-group
|
||||||
|
@ -100,6 +103,7 @@ export function BlockEditor( {
|
||||||
onChange={ onChange }
|
onChange={ onChange }
|
||||||
settings={ settings }
|
settings={ settings }
|
||||||
>
|
>
|
||||||
|
<EditorStyles styles={ settings?.styles } />
|
||||||
<div className="editor-styles-wrapper">
|
<div className="editor-styles-wrapper">
|
||||||
{ /* eslint-disable-next-line @typescript-eslint/ban-ts-comment */ }
|
{ /* eslint-disable-next-line @typescript-eslint/ban-ts-comment */ }
|
||||||
{ /* @ts-ignore No types for this exist yet. */ }
|
{ /* @ts-ignore No types for this exist yet. */ }
|
||||||
|
|
|
@ -3,22 +3,29 @@
|
||||||
*/
|
*/
|
||||||
import { createElement, Fragment } from '@wordpress/element';
|
import { createElement, Fragment } from '@wordpress/element';
|
||||||
import {
|
import {
|
||||||
|
EditorSettings,
|
||||||
|
EditorBlockListSettings,
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore No types for this exist yet.
|
// @ts-ignore No types for this exist yet.
|
||||||
__unstableIframe as Iframe,
|
__unstableIframe as Iframe,
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore No types for this exist yet.
|
// @ts-ignore No types for this exist yet.
|
||||||
__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,
|
__unstableUseMouseMoveTypingReset as useMouseMoveTypingReset,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore No types for this exist yet.
|
||||||
|
__unstableEditorStyles as EditorStyles,
|
||||||
} from '@wordpress/block-editor';
|
} from '@wordpress/block-editor';
|
||||||
|
|
||||||
type EditorCanvasProps = {
|
type EditorCanvasProps = {
|
||||||
enableResizing: boolean;
|
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
enableResizing: boolean;
|
||||||
|
settings: Partial< EditorSettings & EditorBlockListSettings > | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function EditorCanvas( {
|
export function EditorCanvas( {
|
||||||
enableResizing,
|
|
||||||
children,
|
children,
|
||||||
|
enableResizing,
|
||||||
|
settings,
|
||||||
...props
|
...props
|
||||||
}: EditorCanvasProps ) {
|
}: EditorCanvasProps ) {
|
||||||
const mouseMoveTypingRef = useMouseMoveTypingReset();
|
const mouseMoveTypingRef = useMouseMoveTypingReset();
|
||||||
|
@ -26,6 +33,7 @@ export function EditorCanvas( {
|
||||||
<Iframe
|
<Iframe
|
||||||
head={
|
head={
|
||||||
<>
|
<>
|
||||||
|
<EditorStyles styles={ settings?.styles } />
|
||||||
<style>
|
<style>
|
||||||
{
|
{
|
||||||
// Forming a "block formatting context" to prevent margin collapsing.
|
// Forming a "block formatting context" to prevent margin collapsing.
|
||||||
|
|
|
@ -39,7 +39,7 @@ export function IframeEditor( {
|
||||||
initialBlocks = [],
|
initialBlocks = [],
|
||||||
onChange,
|
onChange,
|
||||||
onClose,
|
onClose,
|
||||||
settings,
|
settings: __settings,
|
||||||
}: IframeEditorProps ) {
|
}: IframeEditorProps ) {
|
||||||
const [ resizeObserver, sizes ] = useResizeObserver();
|
const [ resizeObserver, sizes ] = useResizeObserver();
|
||||||
const [ blocks, setBlocks ] = useState< BlockInstance[] >( initialBlocks );
|
const [ blocks, setBlocks ] = useState< BlockInstance[] >( initialBlocks );
|
||||||
|
@ -61,11 +61,13 @@ export function IframeEditor( {
|
||||||
updateSettings( productBlockEditorSettings );
|
updateSettings( productBlockEditorSettings );
|
||||||
}, [] );
|
}, [] );
|
||||||
|
|
||||||
|
const settings = __settings || parentEditorSettings;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="woocommerce-iframe-editor">
|
<div className="woocommerce-iframe-editor">
|
||||||
<BlockEditorProvider
|
<BlockEditorProvider
|
||||||
settings={ {
|
settings={ {
|
||||||
...( settings || parentEditorSettings ),
|
...settings,
|
||||||
hasFixedToolbar: true,
|
hasFixedToolbar: true,
|
||||||
templateLock: false,
|
templateLock: false,
|
||||||
} }
|
} }
|
||||||
|
@ -103,7 +105,10 @@ export function IframeEditor( {
|
||||||
// @ts-ignore This accepts numbers or strings.
|
// @ts-ignore This accepts numbers or strings.
|
||||||
height={ sizes.height ?? '100%' }
|
height={ sizes.height ?? '100%' }
|
||||||
>
|
>
|
||||||
<EditorCanvas enableResizing={ true }>
|
<EditorCanvas
|
||||||
|
enableResizing={ true }
|
||||||
|
settings={ settings }
|
||||||
|
>
|
||||||
{ resizeObserver }
|
{ resizeObserver }
|
||||||
<BlockList className="edit-site-block-editor__block-list wp-site-blocks" />
|
<BlockList className="edit-site-block-editor__block-list wp-site-blocks" />
|
||||||
</EditorCanvas>
|
</EditorCanvas>
|
||||||
|
|
Loading…
Reference in New Issue