[@wordpress/edit-post] add new definitions (#36875)

This commit is contained in:
Derek Sifford
2019-07-15 18:38:33 -04:00
committed by Andrew Branch
parent 8ec58b7a7d
commit 08331a0e65
14 changed files with 994 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
import { ComponentType, MouseEventHandler } from '@wordpress/element';
import { Dashicon } from '@wordpress/components';
declare namespace PluginBlockSettingsMenuItem {
interface Props {
/**
* An array containing a list of block names for which the item should be shown. If not present,
* it'll be rendered for any block. If multiple blocks are selected, it'll be shown if and only if
* all of them are in the whitelist.
*/
allowedBlocks?: string[];
/**
* A dashicon slug, or a custom JSX element.
* @defaultValue `"admin-plugins"`
*/
icon?: JSX.Element | Dashicon.Icon;
/**
* The menu item text.
*/
label: string;
/**
* Callback function to be executed when the user click the menu item.
*/
onClick: MouseEventHandler<HTMLButtonElement>;
/**
* If it should be rendered smaller. (This is undocumented).
*/
small?: boolean;
}
}
/**
* Renders a new item in the block settings menu.
*
* @example
* ```jsx
* import { PluginBlockSettingsMenuItem } from wp.editPost;
*
* const MyPluginBlockSettingsMenuItem = () => (
* <PluginBlockSettingsMenuItem
* allowedBlocks={['core/paragraph']}
* icon="carrot"
* label="Menu item text"
* onClick={() => console.log('clicked')}
* />
* );
* ```
*/
declare const PluginBlockSettingsMenuItem: ComponentType<PluginBlockSettingsMenuItem.Props>;
export default PluginBlockSettingsMenuItem;

View File

@@ -0,0 +1,45 @@
import { Dashicon, MenuItem } from '@wordpress/components';
import { ComponentType, ReactNode } from '@wordpress/element';
declare namespace PluginMoreMenuItem {
interface Props extends Omit<MenuItem.Props, 'href'> {
children: ReactNode;
/**
* When `href` is provided then the menu item is represented as an anchor rather than
* button. It corresponds to the `href` attribute of the anchor.
*/
href?: string;
/**
* A Dashicon slug or a custom JSX element to be rendered to the left of the menu item
* label.
*/
icon?: Dashicon.Icon | JSX.Element;
/**
* The callback function to be executed when the user clicks the menu item.
*/
onClick?(): void;
}
}
/**
* Renders a menu item in `Plugins` group in `More Menu` drop down, and can be used to as a button
* or link depending on the props provided. The text within the component appears as the menu item
* label.
*
* @example
* ```jsx
* const { PluginMoreMenuItem } = wp.editPost;
*
* const MyButtonMoreMenuItem = () => (
* <PluginMoreMenuItem
* icon="smiley"
* onClick={() => console.log('clicked!')}
* >
* My button title
* </PluginMoreMenuItem>
* );
* ```
*/
declare const PluginMoreMenuItem: ComponentType<PluginMoreMenuItem.Props>;
export default PluginMoreMenuItem;

View File

@@ -0,0 +1,41 @@
import { Dashicon } from '@wordpress/components';
import { ComponentType, ReactNode } from '@wordpress/element';
declare namespace PluginSidebarMoreMenuItem {
interface Props {
children: ReactNode;
/**
* A string identifying the target sidebar you wish to be activated by this menu item. Must
* be the same as the `name` prop you have given to that sidebar.
*/
target: string;
/**
* A Dashicon slug or a custom JSX element to be rendered to the left of the menu item
* label.
*/
icon?: Dashicon.Icon | JSX.Element;
}
}
/**
* Renders a menu item in `Plugins` group in `More Menu` drop down, and can be used to activate the
* corresponding `PluginSidebar` component. The text within the component appears as the menu item
* label.
*
* @example
* ```jsx
* const { PluginSidebarMoreMenuItem } = wp.editPost;
*
* const MySidebarMoreMenuItem = () => (
* <PluginSidebarMoreMenuItem
* target="my-sidebar"
* icon="smiley"
* >
* My sidebar title
* </PluginSidebarMoreMenuItem>
* );
* ```
*/
declare const PluginSidebarMoreMenuItem: ComponentType<PluginSidebarMoreMenuItem.Props>;
export default PluginSidebarMoreMenuItem;

View File

@@ -0,0 +1,49 @@
import { Dashicon, Slot } from '@wordpress/components';
import { FC, ReactNode } from '@wordpress/element';
declare namespace PluginDocumentSettingPanel {
interface Props {
children: ReactNode;
/**
* The machine-friendly name for the panel.
*/
name?: string;
/**
* An optional class name added to the row.
*/
className?: string;
/**
* The title of the panel.
*/
title?: string;
/**
* A Dashicon slug or a custom JSX element to be rendered when the sidebar is pinned to
* toolbar.
*/
icon?: Dashicon.Icon | JSX.Element;
}
}
/**
* Renders items below the Status & Availability panel in the Document Sidebar.
*
* @example
* ```jsx
* const { registerPlugin } = wp.plugins;
* const { PluginDocumentSettingPanel } = wp.editPost;
*
* const MyDocumentSettingTest = () => (
* <PluginDocumentSettingPanel className="my-document-setting-plugin" title="My Panel">
* <p>My Document Setting Panel</p>
* </PluginDocumentSettingPanel>
* );
*
* registerPlugin( 'document-setting-test', { render: MyDocumentSettingTest } );
* ```
*/
declare const PluginDocumentSettingPanel: {
(props: PluginDocumentSettingPanel.Props): JSX.Element;
Slot: FC<Omit<Slot.Props, 'name'>>;
};
export default PluginDocumentSettingPanel;

View File

@@ -0,0 +1,48 @@
import { Slot } from '@wordpress/components';
import { FC, ReactNode } from '@wordpress/element';
declare namespace PluginPostPublishPanel {
interface Props {
children: ReactNode;
/**
* An optional class name added to the panel.
*/
className?: string;
/**
* Title displayed at the top of the panel.
*/
title?: string;
/**
* Whether to have the panel initially opened. When no title is provided it is always
* opened.
* @defaultValue `false`
*/
initialOpen?: boolean;
}
}
/**
* Renders provided content to the post-publish panel in the publish flow (side panel that opens
* after a user publishes the post).
*
* @example
* ```jsx
* const { PluginPostPublishPanel } = wp.editPost;
*
* const MyPluginPostPublishPanel = () => (
* <PluginPostPublishPanel
* className="my-plugin-post-publish-panel"
* title="My panel title"
* initialOpen={true}
* >
* My panel content
* </PluginPostPublishPanel>
* );
* ```
*/
declare const PluginPostPublishPanel: {
(props: PluginPostPublishPanel.Props): JSX.Element;
Slot: FC<Omit<Slot.Props, 'name'>>;
};
export default PluginPostPublishPanel;

View File

@@ -0,0 +1,35 @@
import { Slot } from '@wordpress/components';
import { FC, ReactNode } from '@wordpress/element';
declare namespace PluginPostStatusInfo {
interface Props {
children: ReactNode;
/**
* An optional class name added to the row.
*/
className?: string;
}
}
/**
* Renders a row in the Status & Visibility panel of the Document sidebar.
* It should be noted that this is named and implemented around the function it serves
* and not its location, which may change in future iterations.
*
* @example
* ```jsx
* const { PluginPostStatusInfo } = wp.editPost;
*
* const MyPluginPostStatusInfo = () => (
* <PluginPostStatusInfo className="my-plugin-post-status-info">
* My post status info
* </PluginPostStatusInfo>
* );
* ```
*/
declare const PluginPostStatusInfo: {
(props: PluginPostStatusInfo.Props): JSX.Element;
Slot: FC<Omit<Slot.Props, 'name'>>;
};
export default PluginPostStatusInfo;

View File

@@ -0,0 +1,48 @@
import { Slot } from '@wordpress/components';
import { FC, ReactNode } from '@wordpress/element';
declare namespace PluginPrePublishPanel {
interface Props {
children: ReactNode;
/**
* An optional class name added to the panel.
*/
className?: string;
/**
* Whether to have the panel initially opened. When no title is provided it is always
* opened.
* @defaultValue `false`
*/
initialOpen?: boolean;
/**
* Title displayed at the top of the panel.
*/
title?: string;
}
}
/**
* Renders provided content to the pre-publish side panel in the publish flow (side panel that opens
* when a user first pushes "Publish" from the main editor).
*
* @example
* ```jsx
* const { PluginPrePublishPanel } = wp.editPost;
*
* const MyPluginPrePublishPanel = () => (
* <PluginPrePublishPanel
* className="my-plugin-pre-publish-panel"
* title="My panel title"
* initialOpen={true}
* >
* My panel content
* </PluginPrePublishPanel>
* );
* ```
*/
declare const PluginPrePublishPanel: {
(props: PluginPrePublishPanel.Props): JSX.Element;
Slot: FC<Omit<Slot.Props, 'name'>>;
};
export default PluginPrePublishPanel;

View File

@@ -0,0 +1,63 @@
import { Dashicon } from '@wordpress/components';
import { ComponentType, ReactNode } from '@wordpress/element';
declare namespace PluginSidebar {
interface Props {
children: ReactNode;
/**
* An optional class name added to the sidebar body.
*/
className?: string;
/**
* A Dashicon slug or a custom JSX element to be rendered when the sidebar is pinned to
* toolbar.
*/
icon?: Dashicon.Icon | JSX.Element;
/**
* Whether to allow to pin sidebar to toolbar.
* @defaultValue `true`
*/
isPinnable?: boolean;
/**
* A string identifying the sidebar. Must be unique for every sidebar registered within the
* scope of your plugin.
*/
name: string;
/**
* Title displayed at the top of the sidebar.
*/
title: string;
}
}
/**
* Renders a sidebar when activated. The contents within the `PluginSidebar` will appear as content
* within the sidebar.
*
* @see {@link PluginSidebarMoreMenuItem }
*
* @example
* ```jsx
* const { PanelBody } = wp.components;
* const { PluginSidebar } = wp.editPost;
*
* const MyPluginSidebar = () => (
* <PluginSidebar
* name="my-sidebar"
* title="My sidebar title"
* icon="smiley"
* >
* <PanelBody>
* My sidebar content
* </PanelBody>
* </PluginSidebar>
* );
*
* // If you wish to display the sidebar, you can with use the
* // `PluginSidebarMoreMenuItem` component or the `wp.data.dispatch` API
* wp.data.dispatch('core/edit-post').openGeneralSidebar('plugin-name/my-sidebar');
* ```
*/
declare const PluginSidebar: ComponentType<PluginSidebar.Props>;
export default PluginSidebar;

199
types/wordpress__edit-post/index.d.ts vendored Normal file
View File

@@ -0,0 +1,199 @@
// Type definitions for @wordpress/edit-post 3.5
// Project: https://github.com/WordPress/gutenberg/tree/master/packages/edit-post/README.md
// Definitions by: Derek Sifford <https://github.com/dsifford>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.5
import { dispatch, select } from '@wordpress/data';
declare module '@wordpress/data' {
function dispatch(key: 'core/edit-post'): typeof import('./store/actions');
function select(key: 'core/edit-post'): typeof import('./store/selectors');
}
export type MetaboxLocation = 'advanced' | 'normal' | 'side';
// FIXME: move this to @wordpress/block-editor when types are created for that package.
export type EditorMode = 'text' | 'visual';
// FIXME: move this to @wordpress/block-editor when types are created for that package.
export interface EditorSettings {
/**
* Enable/Disable Wide/Full Alignments
* @defaultValue `false`
*/
alignWide: boolean;
/**
* Array of allowed block types, `true` for all blocks, or `false` for no blocks.
* @defaultValue `true`
*/
allowedBlockTypes: string[] | boolean;
/**
* Mapping of extension:mimetype
* @example
* ```js
* {
* "jpg|jpeg|jpe": "image/jpeg",
* }
* ```
*/
allowedMimeTypes: Record<string, string> | null;
autosaveInterval: number;
/**
* Array of objects representing the legacy widgets available.
*/
availableLegacyWidgets: Array<{
description: string;
isCallbackWidget: boolean;
isHidden: boolean;
name: string;
}>;
// FIXME: it is unclear what this value should be.
availableTemplates: any[];
/**
* Empty post placeholder.
* @defaultValue `"Start writing or type / to choose a block"`
*/
bodyPlaceholder: string;
/**
* Whether or not the user can switch to the code editor.
*/
codeEditingEnabled: boolean;
/**
* Palette colors.
*/
colors: Array<{
color: string;
name: string;
slug: string;
}>;
/**
* Whether or not the custom colors are disabled.
*/
disableCustomColors: boolean;
/**
* Whether or not the custom font sizes are disabled.
*/
disableCustomFontSizes: boolean;
/**
* Whether or not the custom post formats are disabled.
*/
disablePostFormats: boolean;
/**
* Whether or not the custom fields are enabled.
*/
enableCustomFields: boolean;
/**
* Whether the focus mode is enabled or not.
*/
focusMode: boolean;
/**
* Array of available font sizes.
*/
fontSizes: Array<{
name: string;
size: number;
slug: string;
}>;
/**
* Whether or not the editor toolbar is fixed.
*/
hasFixedToolbar: boolean;
/**
* Whether or not the user is able to manage widgets.
*/
hasPermissionsToManageWidgets: boolean;
/**
* Available image sizes.
*/
imageSizes: Array<{
name: string;
slug: string;
}>;
/**
* Whether the editor is in RTL mode.
*/
isRTL: boolean;
maxUploadFileSize: number;
/**
* Max width to constraint resizing.
*/
maxWidth: number;
postLock: {
isLocked: boolean;
user: null | string;
};
postLockUtils: {
nonce: string;
unlockNonce: string;
ajaxUrl: string;
};
richEditingEnabled: boolean;
styles: Array<{
css: string;
}>;
/**
* Empty title placeholder.
* @defaultValue `"Add title"`
*/
titlePlaceholder: string;
}
export interface MetaboxDescriptor {
id: string;
title: string;
}
/**
* Initializes and returns an instance of Editor.
*
* The return value of this function is not necessary if we change where we
* call initializeEditor(). This is due to metaBox timing.
*
* @param id - Unique identifier for editor instance.
* @param postType - Post type of the post to edit.
* @param postId - ID of the post to edit.
* @param settings - Editor settings object.
* @param initialEdits - Programmatic edits to apply initially, to be considered as
* non-user-initiated (bypass for unsaved changes prompt).
*/
export function initializeEditor(
id: string,
postType: string,
postId: string | number,
settings?: Partial<EditorSettings>,
// FIXME: it is unclear what this is
initialEdits?: object
): void;
/**
* Reinitializes the editor after the user chooses to reboot the editor after
* an unhandled error occurs, replacing previously mounted editor element using
* an initial state from prior to the crash.
*
* @param postType - Post type of the post to edit.
* @param postId - ID of the post to edit.
* @param target - DOM node in which editor is rendered.
* @param settings - Editor settings object.
* @param initialEdits - Programmatic edits to apply initially, to be considered as
* non-user-initiated (bypass for unsaved changes prompt).
*/
export function reinitializeEditor(
postType: string,
postId: string | number,
target: Element,
settings?: Partial<EditorSettings>,
// FIXME: it is unclear what this is
initialEdits?: object
): void;
export {
default as PluginBlockSettingsMenuItem,
} from './components/block-settings-menu/plugin-block-settings-menu-item';
export { default as PluginDocumentSettingPanel } from './components/sidebar/plugin-document-setting-panel';
export { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';
export { default as PluginPostPublishPanel } from './components/sidebar/plugin-post-publish-panel';
export { default as PluginPostStatusInfo } from './components/sidebar/plugin-post-status-info';
export { default as PluginPrePublishPanel } from './components/sidebar/plugin-pre-publish-panel';
export { default as PluginSidebar } from './components/sidebar/plugin-sidebar';
export { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';

View File

@@ -0,0 +1,111 @@
/**
* Signals that the user closed the sidebar.
*/
export function closeGeneralSidebar(): void;
/**
* Signals that the user closed a modal.
*/
export function closeModal(): void;
/**
* Signals that the user closed the publish sidebar.
*/
export function closePublishSidebar(): void;
/**
* Signals that block types by the given name(s) should be hidden.
*
* @param blockNames - Names of block types to hide.
*/
export function hideBlockTypes(blockNames: string | string[]): void;
/**
* Signals a successful meta box update.
*/
export function metaBoxUpdatesSuccess(): void;
/**
* Signals that the user opened an editor sidebar.
*
* @param name - Sidebar name to be opened.
*/
export function openGeneralSidebar(name: string): void;
/**
* Signals that the user opened a modal.
*
* @param name - A string that uniquely identifies the modal.
*/
export function openModal(name: string): void;
/**
* Signals that the user opened the publish sidebar.
*/
export function openPublishSidebar(): void;
/**
* Remove a panel from the editor.
*
* @param panelName - A string that identifies the panel to remove.
*/
export function removeEditorPanel(panelName: string): void;
/**
* Request meta box updates.
*/
export function requestMetaBoxUpdates(): void;
/**
* Signals what Meta boxes are available in which location.
*
* @param metaBoxesPerLocation - Meta boxes per location.
*/
export function setAvailableMetaBoxesPerLocation(metaBoxesPerLocation: object): void;
/**
* Signals that block types by the given name(s) should be shown.
*
* @param blockNames - Names of block types to show.
*/
export function showBlockTypes(blockNames: string | string[]): void;
/**
* Switches editor mode.
*
* @param mode - The mode to switch to.
*/
export function switchEditorMode(mode: 'text' | 'visual'): void;
/**
* Enables or disables a panel in the editor.
*
* @param panelName - A string that identifies the panel to enable or disable.
*/
export function toggleEditorPanelEnabled(panelName: string): void;
/**
* Opens or closes a panel in the editor.
*
* @param panelName - A string that identifies the panel to open or close.
*/
export function toggleEditorPanelOpened(panelName: string): void;
/**
* Toggles a feature flag.
*
* @param feature - Feature name.
*/
export function toggleFeature(feature: string): void;
/**
* Toggles a pinned plugin item.
*
* @param pluginName - Plugin name.
*/
export function togglePinnedPluginItem(pluginName: string): void;
/**
* Signals that the user toggled the publish sidebar.
*/
export function togglePublishSidebar(): void;

View File

@@ -0,0 +1,136 @@
import { EditorMode, MetaboxDescriptor, MetaboxLocation } from '../';
/**
* Returns the current active general sidebar name, or `null` if there is no general sidebar active.
*
* @remarks
* The active general sidebar is a unique name to identify either an editor or plugin sidebar.
*
* Examples:
* - `edit-post/document`
* - `my-plugin/insert-image-sidebar`
*/
export function getActiveGeneralSidebarName(): string | null;
/**
* Returns an array of active meta box locations.
*/
export function getActiveMetaBoxLocations(): MetaboxLocation[];
/**
* Returns the list of all the available meta boxes.
*/
export function getAllMetaBoxes(): MetaboxDescriptor[];
/**
* Returns the current editing mode.
*/
export function getEditorMode(): EditorMode;
/**
* Returns the list of all the available meta boxes for a given location.
*
* @param location - Meta box location to test.
*/
export function getMetaBoxesPerLocation(location: MetaboxLocation): MetaboxDescriptor[] | undefined;
/**
* Returns the value of a given preference.
*
* @param preferenceKey - Preference Key.
* @param [defaultValue] - Default Value.
*/
export function getPreference<T = unknown>(preferenceKey: string): T | undefined; // tslint:disable-line:no-unnecessary-generics
export function getPreference<T>(
preferenceKey: string,
defaultValue: T
): T extends string ? string : T extends number ? number : T;
/**
* Returns the preferences (these preferences are persisted locally).
*/
export function getPreferences(): Record<string, any>;
/**
* Returns `true` if the post is using Meta Boxes, `false` otherwise.
*/
export function hasMetaBoxes(): boolean;
/**
* Returns `true` if the given panel is enabled, or `false` otherwise. Panels are enabled by
* default.
*
* @param panelName - A string that identifies the panel.
*/
export function isEditorPanelEnabled(panelName: string): boolean;
/**
* Returns `true` if the given panel is open, or `false` otherwise. Panels are closed by default.
*
* @param panelName - A string that identifies the panel.
*/
export function isEditorPanelOpened(panelName: string): boolean;
/**
* Returns `true` if the given panel was programmatically removed, or `false` otherwise. All panels
* are not removed by default.
*
* @param panelName - A string that identifies the panel.
*/
export function isEditorPanelRemoved(panelName: string): boolean;
/**
* Returns `true` if the editor sidebar is opened, `false` otherwise.
*/
export function isEditorSidebarOpened(): boolean;
/**
* Returns whether the given feature is enabled or not.
*
* @param feature - Feature slug.
*/
export function isFeatureActive(feature: string): boolean;
/**
* Returns `true` if there is an active meta box in the given location, or `false` otherwise.
*
* @param location - Meta box location to test.
*/
export function isMetaBoxLocationActive(location: MetaboxLocation): boolean;
/**
* Returns `true` if a metabox location is active and visible, `false` otherwise.
*
* @param location - Meta box location to test.
*/
export function isMetaBoxLocationVisible(location: MetaboxLocation): boolean;
/**
* Returns `true` if a modal is active, or `false` otherwise.
*
* @param modalName - A string that uniquely identifies the modal.
*/
export function isModalActive(modalName: string): boolean;
/**
* Returns `true` if the plugin item is pinned to the header. When the value is not set it defaults
* to `true`.
*
* @param pluginName - Plugin item name.
*/
export function isPluginItemPinned(pluginName: string): boolean;
/**
* Returns `true` if the plugin sidebar is opened, `false` otherwise.
*/
export function isPluginSidebarOpened(): boolean;
/**
* Returns `true` if the publish sidebar is opened, `false` otherwise.
*/
export function isPublishSidebarOpened(): boolean;
/**
* Returns `true` if the Meta Boxes are being saved, `false` otherwise.
*/
export function isSavingMetaBoxes(): boolean;

View File

@@ -0,0 +1,38 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["dom", "es6"],
"jsx": "preserve",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"paths": {
"@wordpress/data": ["wordpress__data"],
"@wordpress/components": ["wordpress__components"],
"@wordpress/edit-post": ["wordpress__edit-post"],
"@wordpress/element": ["wordpress__element"],
"@wordpress/notices": ["wordpress__notices"],
"@wordpress/rich-text": ["wordpress__rich-text"]
}
},
"files": [
"components/block-settings-menu/plugin-block-settings-menu-item.d.ts",
"components/header/plugin-more-menu-item.d.ts",
"components/header/plugin-sidebar-more-menu-item.d.ts",
"components/sidebar/plugin-document-setting-panel.d.ts",
"components/sidebar/plugin-post-publish-panel.d.ts",
"components/sidebar/plugin-post-status-info.d.ts",
"components/sidebar/plugin-pre-publish-panel.d.ts",
"components/sidebar/plugin-sidebar.d.ts",
"index.d.ts",
"store/actions.d.ts",
"store/selectors.d.ts",
"wordpress__edit-post-tests.tsx"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@@ -0,0 +1,129 @@
import { dispatch, select } from '@wordpress/data';
import * as ep from '@wordpress/edit-post';
// $ExpectType void
ep.initializeEditor('abc', 'post', '123');
// $ExpectType void
ep.initializeEditor('abc', 'post', 123, {});
// $ExpectType void
ep.initializeEditor('abc', 'post', '123', { alignWide: true, disableCustomColors: true }, { foo: 'bar' });
// $ExpectType void
ep.reinitializeEditor('post', '123', document.createElement('div'));
// $ExpectType void
ep.reinitializeEditor('post', 123, document.createElement('div'), {});
// $ExpectType void
ep.reinitializeEditor('post', 123, document.createElement('div'), { codeEditingEnabled: true });
//
// PluginBlockSettingsMenuItem
//
<ep.PluginBlockSettingsMenuItem
allowedBlocks={['core/paragraph']}
icon="carrot"
label="Menu item text"
onClick={() => console.log('clicked')}
/>;
<ep.PluginBlockSettingsMenuItem label="Menu item text" onClick={() => console.log('clicked')} />;
//
// PluginDocumentSettingPanel
//
<ep.PluginDocumentSettingPanel className="my-document-setting-plugin" title="My Panel">
<p>My Document Setting Panel</p>
</ep.PluginDocumentSettingPanel>;
<ep.PluginDocumentSettingPanel>
<p>My Document Setting Panel</p>
</ep.PluginDocumentSettingPanel>;
//
// PluginMoreMenuItem
//
<ep.PluginMoreMenuItem icon="smiley" onClick={() => console.log('clicked!')}>
My button title
</ep.PluginMoreMenuItem>;
<ep.PluginMoreMenuItem href="https://foo.bar">My anchor title</ep.PluginMoreMenuItem>;
//
// PluginPostPublishPanel
//
<ep.PluginPostPublishPanel className="my-plugin-post-publish-panel" title="My panel title" initialOpen={true}>
My panel content
</ep.PluginPostPublishPanel>;
<ep.PluginPostPublishPanel>My panel content</ep.PluginPostPublishPanel>;
//
// PluginPostStatusInfo
//
<ep.PluginPostStatusInfo className="my-plugin-post-status-info">My post status info</ep.PluginPostStatusInfo>;
<ep.PluginPostStatusInfo>My post status info</ep.PluginPostStatusInfo>;
//
// PluginPrePublishPanel
//
<ep.PluginPrePublishPanel className="my-plugin-pre-publish-panel" title="My panel title" initialOpen={true}>
My panel content
</ep.PluginPrePublishPanel>;
<ep.PluginPrePublishPanel>My panel content</ep.PluginPrePublishPanel>;
//
// PluginSidebar
//
<ep.PluginSidebar name="my-sidebar" isPinnable={false} title="My sidebar title" icon={<i>foo</i>}>
My sidebar content
</ep.PluginSidebar>;
<ep.PluginSidebar name="my-sidebar" title="My sidebar title">
My sidebar content
</ep.PluginSidebar>;
//
// PluginSidebarMoreMenuItem
//
<ep.PluginSidebarMoreMenuItem target="my-sidebar" icon="smiley">
My sidebar title
</ep.PluginSidebarMoreMenuItem>;
<ep.PluginSidebarMoreMenuItem target="my-sidebar">My sidebar title</ep.PluginSidebarMoreMenuItem>;
//
// store
//
// $ExpectType void
dispatch('core/edit-post').hideBlockTypes('foo');
// $ExpectType void
dispatch('core/edit-post').hideBlockTypes(['foo', 'bar']);
// $ExpectType void
dispatch('core/edit-post').switchEditorMode('visual');
// $ExpectType void
dispatch('core/edit-post').toggleFeature('foo');
// $ExpectType string | null
select('core/edit-post').getActiveGeneralSidebarName();
// $ExpectType MetaboxLocation[]
select('core/edit-post').getActiveMetaBoxLocations();
// $ExpectType unknown
select('core/edit-post').getPreference('foo');
// $ExpectType string | undefined
select('core/edit-post').getPreference<string>('foo');
// $ExpectType number
select('core/edit-post').getPreference('foo', 123);
// $ExpectType boolean
select('core/edit-post').isMetaBoxLocationActive('advanced');
// $ExpectType MetaboxDescriptor[]
select('core/edit-post').getAllMetaBoxes();