PluginProbe
Parse.ly / 3.20.2
Parse.ly v3.20.2
3.24.1 3.24.0 3.23.7 3.23.6 3.23.5 3.23.4 3.23.3 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.17.0 3.18.0 3.18.1 3.19.0 3.19.1 3.19.2 3.19.3 3.2.0 3.2.1 3.20.0 3.20.1 3.20.2 3.20.3 All 105 releases
wp-parsely / src / @types / gutenberg / wrapper.ts

wrapper.ts in Parse.ly 3.20.2, at src/@types/gutenberg/wrapper.ts

41 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * This file is used to wrap original Gutenberg components to avoid TypeScript errors.
3 *
4 * The original Gutenberg components are imported conditionally based on the environment.
5 * This is needed since these Gutenberg components have changed their location to a different package in WordPress 6.6.
6 *
7 * @since 3.17.0
8 *
9 * @see https://make.wordpress.org/core/2024/06/18/editor-unified-extensibility-apis-in-6-6/
10 */
11 // eslint-disable-next-line @typescript-eslint/no-explicit-any
12 import type { ComponentType } from 'react';
13
14 // Import the original Gutenberg components.
15 import {
16 PluginDocumentSettingPanel as OriginalPluginDocumentSettingPanel,
17 PluginSidebar as OriginalPluginSidebar,
18 } from '@wordpress/edit-post';
19
20 // Define the types for the props of the original Gutenberg components.
21 type PluginDocumentSettingPanelProps = React.ComponentProps<typeof OriginalPluginDocumentSettingPanel>;
22 type PluginSidebarProps = React.ComponentProps<typeof OriginalPluginSidebar>;
23
24 // Define the types for the original Gutenberg components.
25 let PluginDocumentSettingPanel: ComponentType<PluginDocumentSettingPanelProps>;
26 let PluginSidebar: ComponentType<PluginSidebarProps>;
27
28 // Use the correct Gutenberg components based on the environment.
29 if ( typeof window.wp !== 'undefined' ) {
30 PluginDocumentSettingPanel = window.wp.editor?.PluginDocumentSettingPanel ??
31 ( window.wp.editPost?.PluginDocumentSettingPanel ?? window.wp.editSite?.PluginDocumentSettingPanel );
32 PluginSidebar = window.wp.editor?.PluginSidebar ??
33 ( window.wp.editPost?.PluginSidebar ?? window.wp.editSite?.PluginSidebar );
34 }
35
36 // Export the wrapped Gutenberg components.
37 export {
38 PluginDocumentSettingPanel,
39 PluginSidebar,
40 };
41