Move BlockCanvas to private APIs

[MAILPOET-6319]
This commit is contained in:
Rostislav Wolny
2024-11-22 11:21:46 +01:00
committed by Oluwaseun Olorunsola
parent c72b0b6f79
commit fbdfc61eaa
3 changed files with 31 additions and 7 deletions

View File

@@ -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.

View File

@@ -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 };

View File

@@ -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
);