diff --git a/packages/js/email-editor/src/components/block-editor/visual-editor/visual-editor.tsx b/packages/js/email-editor/src/components/block-editor/visual-editor/visual-editor.tsx index 41bb227966..8f23f3d060 100644 --- a/packages/js/email-editor/src/components/block-editor/visual-editor/visual-editor.tsx +++ b/packages/js/email-editor/src/components/block-editor/visual-editor/visual-editor.tsx @@ -9,8 +9,6 @@ import { // @ts-expect-error No types for this exist yet. RecursionProvider, // @ts-expect-error No types for this exist yet. - privateApis as blockEditorPrivateApis, - // @ts-expect-error No types for this exist yet. __experimentalUseResizeCanvas as useResizeCanvas, // eslint-disable-line } from '@wordpress/block-editor'; import { useRef } from '@wordpress/element'; @@ -18,22 +16,22 @@ import { useSelect } from '@wordpress/data'; import { useMergeRefs } from '@wordpress/compose'; import { store as editorStore } from '@wordpress/editor'; +/** + * WordPress private dependencies + */ +import { BlockCanvas } from '../../../private-apis'; + /** * Internal dependencies */ import EditTemplateBlocksNotification from './edit-template-blocks-notification'; import useSelectNearestEditableBlock from './use-select-nearest-editable-block'; -import { unlock } from '../../../lock-unlock'; export const TEMPLATE_POST_TYPE = 'wp_template'; export const TEMPLATE_PART_POST_TYPE = 'wp_template_part'; export const PATTERN_POST_TYPE = 'wp_block'; export const NAVIGATION_POST_TYPE = 'wp_navigation'; -const { ExperimentalBlockCanvas: BlockCanvas } = unlock( - blockEditorPrivateApis -); - /** * These post types have a special editor where they don't allow you to fill the title * and they don't apply the layout styles. diff --git a/packages/js/email-editor/src/private-apis/index.ts b/packages/js/email-editor/src/private-apis/index.ts new file mode 100644 index 0000000000..b3abc77aec --- /dev/null +++ b/packages/js/email-editor/src/private-apis/index.ts @@ -0,0 +1,16 @@ +import { unlock } from './lock-unlock'; +import { + // @ts-expect-error No types for this exist yet. + privateApis as blockEditorPrivateApis, +} from '@wordpress/block-editor'; + +/** + * We use the experimental block canvas to render the block editor's canvas. + * Currently this is needed because we use contentRef property which is not available in the stable BlockCanvas + * The property is used for handling clicks for selecting block to edit and to display modal for switching between email and template. + */ +const { ExperimentalBlockCanvas: BlockCanvas } = unlock( + blockEditorPrivateApis +); + +export { BlockCanvas }; diff --git a/packages/js/email-editor/src/private-apis/lock-unlock.js b/packages/js/email-editor/src/private-apis/lock-unlock.js new file mode 100644 index 0000000000..20bb58e012 --- /dev/null +++ b/packages/js/email-editor/src/private-apis/lock-unlock.js @@ -0,0 +1,10 @@ +/** + * WordPress dependencies + */ +import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis'; + +export const { lock, unlock } = + __dangerousOptInToUnstableAPIsOnlyForCoreModules( + 'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', + '@wordpress/edit-post' // The module name must be in the list of allowed, so for now I used the package name of the post editor + );