From f336028364aaa8804f2cb0397fae69554c26d894 Mon Sep 17 00:00:00 2001 From: John Godley Date: Mon, 12 Jul 2021 10:40:42 +0100 Subject: [PATCH 1/3] Add a fill slot for the toolbar This allows custom components to be inserted into the toolbar area --- src/components/block-editor-toolbar/index.js | 3 +++ src/components/block-editor-toolbar/slot.js | 17 +++++++++++++++++ src/index.js | 3 ++- 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/components/block-editor-toolbar/slot.js diff --git a/src/components/block-editor-toolbar/index.js b/src/components/block-editor-toolbar/index.js index 169c19374..76c71d175 100644 --- a/src/components/block-editor-toolbar/index.js +++ b/src/components/block-editor-toolbar/index.js @@ -14,6 +14,7 @@ import { useSelect, useDispatch } from '@wordpress/data'; import MoreMenu from './more-menu'; import HeaderToolbar from './header-toolbar'; import Inspector from './inspector'; +import ToolbarSlot from './slot'; import './style.scss'; /** @typedef {import('../../store/editor/reducer').EditorMode} EditorMode */ @@ -57,6 +58,8 @@ const BlockEditorToolbar = ( props ) => {
+ + { inspector && ( + , document.querySelector( '#editor' ) ); diff --git a/src/components/block-editor-toolbar/slot.js b/src/components/block-editor-toolbar/slot.js index 1f1e59417..cc8def2ab 100644 --- a/src/components/block-editor-toolbar/slot.js +++ b/src/components/block-editor-toolbar/slot.js @@ -6,6 +6,13 @@ import { __ } from '@wordpress/i18n'; const { Fill, Slot } = createSlotFill( 'IsolatedToolbar' ); +/** + * A Toolbar slot/fill + * + * @param {object} props Component props + * @param {object} props.children Child components to insert in the toolbar slot + * @returns object + */ const ToolbarSlot = ( { children } ) => { return { children }; };