Simplify the VisualEditor component
We don't support post-only mode for emails, so I was able to remove more core related to that mode. The post-only mode is used in the template-mode, but it is a designPostType so the code was not used anyway. [MAILPOET-6249]
This commit is contained in:
committed by
Jan Lysý
parent
60525198c5
commit
3ef305facd
@@ -4,7 +4,6 @@
|
|||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import {
|
import {
|
||||||
BlockList,
|
BlockList,
|
||||||
store as blockEditorStore,
|
|
||||||
// @ts-expect-error No types for this exist yet.
|
// @ts-expect-error No types for this exist yet.
|
||||||
__unstableUseTypewriter as useTypewriter,
|
__unstableUseTypewriter as useTypewriter,
|
||||||
// @ts-expect-error No types for this exist yet.
|
// @ts-expect-error No types for this exist yet.
|
||||||
@@ -31,11 +30,9 @@ export const TEMPLATE_PART_POST_TYPE = 'wp_template_part';
|
|||||||
export const PATTERN_POST_TYPE = 'wp_block';
|
export const PATTERN_POST_TYPE = 'wp_block';
|
||||||
export const NAVIGATION_POST_TYPE = 'wp_navigation';
|
export const NAVIGATION_POST_TYPE = 'wp_navigation';
|
||||||
|
|
||||||
const {
|
const { ExperimentalBlockCanvas: BlockCanvas, useFlashEditableBlocks } = unlock(
|
||||||
useLayoutClasses,
|
blockEditorPrivateApis,
|
||||||
ExperimentalBlockCanvas: BlockCanvas,
|
);
|
||||||
useFlashEditableBlocks,
|
|
||||||
} = unlock(blockEditorPrivateApis);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These post types have a special editor where they don't allow you to fill the title
|
* These post types have a special editor where they don't allow you to fill the title
|
||||||
@@ -59,7 +56,7 @@ const DESIGN_POST_TYPES = [
|
|||||||
* @todo Need to fix layout so that we support Align settings properly
|
* @todo Need to fix layout so that we support Align settings properly
|
||||||
*/
|
*/
|
||||||
export function VisualEditor({
|
export function VisualEditor({
|
||||||
// Ideally as we unify post and site editors, we won't need these propss
|
// Ideally as we unify post and site editors, we won't need these props
|
||||||
styles,
|
styles,
|
||||||
disableIframe = false,
|
disableIframe = false,
|
||||||
iframeProps,
|
iframeProps,
|
||||||
@@ -72,7 +69,6 @@ export function VisualEditor({
|
|||||||
wrapperUniqueId,
|
wrapperUniqueId,
|
||||||
deviceType,
|
deviceType,
|
||||||
isFocusedEntity,
|
isFocusedEntity,
|
||||||
isDesignPostType,
|
|
||||||
layout,
|
layout,
|
||||||
} = useSelect((select) => {
|
} = useSelect((select) => {
|
||||||
const {
|
const {
|
||||||
@@ -116,29 +112,8 @@ export function VisualEditor({
|
|||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const { themeSupportsLayout } = useSelect((select) => {
|
|
||||||
const { getSettings } = select(blockEditorStore);
|
|
||||||
const checkSettings = getSettings();
|
|
||||||
return {
|
|
||||||
// @ts-expect-error No types for this exist yet.
|
|
||||||
themeSupportsLayout: checkSettings.supportsLayout,
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const deviceStyles = useResizeCanvas(deviceType);
|
const deviceStyles = useResizeCanvas(deviceType);
|
||||||
|
|
||||||
const postContentLayoutClasses = useLayoutClasses(
|
|
||||||
{ layout, align: '' },
|
|
||||||
'core/post-content',
|
|
||||||
) as string[];
|
|
||||||
|
|
||||||
const blockListLayoutClass = classnames(
|
|
||||||
{
|
|
||||||
'is-layout-flow': !themeSupportsLayout,
|
|
||||||
},
|
|
||||||
themeSupportsLayout && postContentLayoutClasses,
|
|
||||||
);
|
|
||||||
|
|
||||||
// We want to use the same layout.
|
// We want to use the same layout.
|
||||||
const blockListLayout = layout;
|
const blockListLayout = layout;
|
||||||
|
|
||||||
@@ -204,9 +179,7 @@ export function VisualEditor({
|
|||||||
<BlockList
|
<BlockList
|
||||||
className={classnames(
|
className={classnames(
|
||||||
`is-${deviceType.toLowerCase()}-preview`,
|
`is-${deviceType.toLowerCase()}-preview`,
|
||||||
renderingMode !== 'post-only' || isDesignPostType
|
'wp-site-blocks',
|
||||||
? 'wp-site-blocks'
|
|
||||||
: `${blockListLayoutClass} wp-block-post-content`, // Ensure root level blocks receive default/flow blockGap styling rules.
|
|
||||||
)}
|
)}
|
||||||
// @ts-expect-error No types for this exist yet.
|
// @ts-expect-error No types for this exist yet.
|
||||||
layout={blockListLayout}
|
layout={blockListLayout}
|
||||||
|
Reference in New Issue
Block a user