From 7e9e53d0581e8f21ad029fb3ffd03f43680326b1 Mon Sep 17 00:00:00 2001
From: Manzoor Wani
Date: Mon, 25 Nov 2024 02:11:31 -0800
Subject: [PATCH 01/23] Fix TS types for the editor package (#67196)
* Replace the wrong Component type with React Node/Element
* Replace the wrong Component type with React Node/Element
* Fix the optional params for store actions
* Replace the deprecated JSX.Element with React.ReactNode
* Update docs
* Fix children prop for multiple components
---
.../reference-guides/data/data-core-editor.md | 11 +-
packages/editor/README.md | 192 +++++++++---------
.../plugin-block-settings-menu-item.js | 2 +-
.../components/collab-sidebar/add-comment.js | 2 +-
.../collab-sidebar/comment-author-info.js | 2 +-
.../components/collab-sidebar/comment-form.js | 2 +-
.../src/components/collab-sidebar/comments.js | 4 +-
.../src/components/document-bar/index.js | 2 +-
.../src/components/document-outline/check.js | 6 +-
.../src/components/document-outline/index.js | 2 +-
.../src/components/editor-history/redo.js | 2 +-
.../src/components/editor-history/undo.js | 2 +-
.../src/components/editor-notices/index.js | 2 +-
.../src/components/editor-snackbars/index.js | 2 +-
.../components/entities-saved-states/index.js | 4 +-
.../src/components/page-attributes/check.js | 6 +-
.../src/components/page-attributes/order.js | 2 +-
.../src/components/page-attributes/panel.js | 2 +-
.../src/components/page-attributes/parent.js | 2 +-
.../plugin-document-setting-panel/index.js | 4 +-
.../components/plugin-more-menu-item/index.js | 3 +-
.../plugin-post-publish-panel/index.js | 4 +-
.../plugin-post-status-info/index.js | 8 +-
.../plugin-pre-publish-panel/index.js | 4 +-
.../plugin-preview-menu-item/index.js | 3 +-
.../plugin-sidebar-more-menu-item/index.js | 4 +-
.../src/components/plugin-sidebar/index.js | 1 +
.../src/components/post-author/check.js | 6 +-
.../src/components/post-author/index.js | 2 +-
.../src/components/post-author/panel.js | 2 +-
.../src/components/post-comments/index.js | 2 +-
.../src/components/post-discussion/panel.js | 2 +-
.../src/components/post-excerpt/check.js | 6 +-
.../src/components/post-excerpt/panel.js | 2 +-
.../src/components/post-excerpt/plugin.js | 8 +-
.../components/post-featured-image/check.js | 6 +-
.../components/post-featured-image/panel.js | 2 +-
.../src/components/post-format/check.js | 20 +-
.../src/components/post-format/index.js | 2 +-
.../src/components/post-format/panel.js | 2 +-
.../components/post-last-revision/check.js | 6 +-
.../components/post-last-revision/index.js | 2 +-
.../components/post-last-revision/panel.js | 2 +-
.../src/components/post-locked-modal/index.js | 2 +-
.../components/post-pending-status/check.js | 6 +-
.../components/post-pending-status/index.js | 2 +-
.../components/post-preview-button/index.js | 2 +-
.../src/components/post-schedule/check.js | 6 +-
.../src/components/post-schedule/index.js | 2 +-
.../src/components/post-schedule/label.js | 2 +-
.../src/components/post-schedule/panel.js | 2 +-
.../editor/src/components/post-slug/check.js | 6 +-
.../editor/src/components/post-slug/index.js | 2 +-
.../src/components/post-sticky/check.js | 6 +-
.../src/components/post-sticky/index.js | 2 +-
.../post-switch-to-draft-button/index.js | 2 +-
.../src/components/post-sync-status/index.js | 2 +-
.../src/components/post-taxonomies/check.js | 6 +-
.../post-taxonomies/flat-term-selector.js | 2 +-
.../src/components/post-taxonomies/panel.js | 27 +--
.../components/post-template/classic-theme.js | 4 +-
.../src/components/post-template/panel.js | 2 +-
.../src/components/post-text-editor/index.js | 2 +-
.../editor/src/components/post-title/index.js | 2 +-
.../components/post-title/post-title-raw.js | 2 +-
.../editor/src/components/post-trash/check.js | 6 +-
.../editor/src/components/post-trash/index.js | 2 +-
.../post-type-support-check/index.js | 12 +-
.../editor/src/components/post-url/check.js | 6 +-
.../editor/src/components/post-url/index.js | 2 +-
.../editor/src/components/post-url/label.js | 2 +-
.../editor/src/components/post-url/panel.js | 2 +-
.../src/components/post-visibility/check.js | 2 +-
.../src/components/post-visibility/index.js | 2 +-
.../editor/src/components/provider/index.js | 2 +-
.../src/components/table-of-contents/index.js | 2 +-
.../components/theme-support-check/index.js | 8 +-
.../src/components/time-to-read/index.js | 2 +-
.../unsaved-changes-warning/index.js | 2 +-
.../editor/src/components/word-count/index.js | 2 +-
packages/editor/src/store/actions.js | 19 +-
81 files changed, 260 insertions(+), 256 deletions(-)
diff --git a/docs/reference-guides/data/data-core-editor.md b/docs/reference-guides/data/data-core-editor.md
index 9567d8e4b954fa..44078ab284e94f 100644
--- a/docs/reference-guides/data/data-core-editor.md
+++ b/docs/reference-guides/data/data-core-editor.md
@@ -1148,7 +1148,8 @@ Action that autosaves the current post. This includes server-side autosaving (de
_Parameters_
-- _options_ `Object?`: Extra flags to identify the autosave.
+- _options_ `[Object]`: Extra flags to identify the autosave.
+- _options.local_ `[boolean]`: Whether to perform a local autosave.
### clearSelectedBlock
@@ -1204,7 +1205,7 @@ const getFeaturedMediaUrl = useSelect( ( select ) => {
_Parameters_
- _edits_ `Object`: Post attributes to edit.
-- _options_ `Object`: Options for the edit.
+- _options_ `[Object]`: Options for the edit.
_Returns_
@@ -1417,7 +1418,7 @@ Returns an action object used to signal that the blocks have been updated.
_Parameters_
- _blocks_ `Array`: Block Array.
-- _options_ `?Object`: Optional options.
+- _options_ `[Object]`: Optional options.
### resetPost
@@ -1431,7 +1432,7 @@ Action for saving the current post in the editor.
_Parameters_
-- _options_ `Object`:
+- _options_ `[Object]`:
### selectBlock
@@ -1519,7 +1520,7 @@ _Parameters_
- _post_ `Object`: Post object.
- _edits_ `Object`: Initial edited attributes object.
-- _template_ `Array?`: Block Template.
+- _template_ `[Array]`: Block Template.
### setupEditorState
diff --git a/packages/editor/README.md b/packages/editor/README.md
index bc00e15c8fb892..ac655bd1c99d8c 100644
--- a/packages/editor/README.md
+++ b/packages/editor/README.md
@@ -270,7 +270,7 @@ _Parameters_
_Returns_
-- `JSX.Element`: The rendered DocumentBar component.
+- `React.ReactNode`: The rendered DocumentBar component.
### DocumentOutline
@@ -284,7 +284,7 @@ _Parameters_
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### DocumentOutlineCheck
@@ -293,11 +293,11 @@ Component check if there are any headings (core/heading blocks) present in the d
_Parameters_
- _props_ `Object`: Props.
-- _props.children_ `Element`: Children to be rendered.
+- _props.children_ `React.ReactElement`: Children to be rendered.
_Returns_
-- `Component|null`: The component to be rendered or null if there are headings.
+- `React.ReactElement`: The component to be rendered or null if there are headings.
### EditorHistoryRedo
@@ -310,7 +310,7 @@ _Parameters_
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### EditorHistoryUndo
@@ -323,7 +323,7 @@ _Parameters_
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### EditorKeyboardShortcuts
@@ -351,7 +351,7 @@ _Usage_
_Returns_
-- `JSX.Element`: The rendered EditorNotices component.
+- `React.ReactNode`: The rendered EditorNotices component.
### EditorProvider
@@ -383,7 +383,7 @@ _Parameters_
_Returns_
-- `JSX.Element`: The rendered EditorProvider component.
+- `React.ReactNode`: The rendered EditorProvider component.
### EditorSnackbars
@@ -391,7 +391,7 @@ Renders the editor snackbars component.
_Returns_
-- `JSX.Element`: The rendered component.
+- `React.ReactNode`: The rendered component.
### EntitiesSavedStates
@@ -405,7 +405,7 @@ _Parameters_
_Returns_
-- `JSX.Element`: The rendered component.
+- `React.ReactNode`: The rendered component.
### ErrorBoundary
@@ -523,11 +523,11 @@ Wrapper component that renders its children only if the post type supports page
_Parameters_
- _props_ `Object`: - The component props.
-- _props.children_ `Element`: - The child components to render.
+- _props.children_ `React.ReactElement`: - The child components to render.
_Returns_
-- `Component|null`: The rendered child components or null if page attributes are not supported.
+- `React.ReactElement`: The rendered child components or null if page attributes are not supported.
### PageAttributesOrder
@@ -535,7 +535,7 @@ Renders the Page Attributes Order component. A number input in an editor interfa
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### PageAttributesPanel
@@ -543,7 +543,7 @@ Renders the Page Attributes Panel component.
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### PageAttributesParent
@@ -551,7 +551,7 @@ Renders the Page Attributes Parent component. A dropdown menu in an editor inter
_Returns_
-- `Component|null`: The component to be rendered. Return null if post type is not hierarchical.
+- `React.ReactNode`: The component to be rendered. Return null if post type is not hierarchical.
### PageTemplate
@@ -561,7 +561,7 @@ The dropdown menu includes a button for toggling the menu, a list of available t
_Returns_
-- `JSX.Element`: The rendered ClassicThemeControl component.
+- `React.ReactNode`: The rendered ClassicThemeControl component.
### PanelColorSettings
@@ -627,7 +627,7 @@ _Parameters_
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### PluginDocumentSettingPanel
@@ -684,11 +684,11 @@ _Parameters_
- _props.className_ `[string]`: An optional class name added to the row.
- _props.title_ `[string]`: The title of the panel
- _props.icon_ `[WPBlockTypeIconRender]`: The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar.
-- _props.children_ `Element`: Children to be rendered
+- _props.children_ `React.ReactNode`: Children to be rendered
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The component to be rendered.
### PluginMoreMenuItem
@@ -738,6 +738,7 @@ const MyButtonMoreMenuItem = () => (
_Parameters_
- _props_ `Object`: Component properties.
+- _props.children_ `[React.ReactNode]`: Children to be rendered.
- _props.href_ `[string]`: 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.
- _props.icon_ `[WPBlockTypeIconRender]`: The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label.
- _props.onClick_ `[Function]`: The callback function to be executed when the user clicks the menu item.
@@ -745,7 +746,7 @@ _Parameters_
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### PluginPostPublishPanel
@@ -776,11 +777,11 @@ _Parameters_
- _props.title_ `[string]`: Title displayed at the top of the panel.
- _props.initialOpen_ `[boolean]`: Whether to have the panel initially opened. When no title is provided it is always opened.
- _props.icon_ `[WPBlockTypeIconRender]`: The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar.
-- _props.children_ `Element`: Children to be rendered
+- _props.children_ `React.ReactNode`: Children to be rendered
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### PluginPostStatusInfo
@@ -820,11 +821,11 @@ _Parameters_
- _props_ `Object`: Component properties.
- _props.className_ `[string]`: An optional class name added to the row.
-- _props.children_ `Element`: Children to be rendered.
+- _props.children_ `React.ReactNode`: Children to be rendered.
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### PluginPrePublishPanel
@@ -855,11 +856,11 @@ _Parameters_
- _props.title_ `[string]`: Title displayed at the top of the panel.
- _props.initialOpen_ `[boolean]`: Whether to have the panel initially opened. When no title is provided it is always opened.
- _props.icon_ `[WPBlockTypeIconRender]`: The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar.
-- _props.children_ `Element`: Children to be rendered
+- _props.children_ `React.ReactNode`: Children to be rendered
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### PluginPreviewMenuItem
@@ -889,6 +890,7 @@ registerPlugin( 'external-preview-menu-item', {
_Parameters_
- _props_ `Object`: Component properties.
+- _props.children_ `[React.ReactNode]`: Children to be rendered.
- _props.href_ `[string]`: When `href` is provided, the menu item is rendered as an anchor instead of a button. It corresponds to the `href` attribute of the anchor.
- _props.icon_ `[WPBlockTypeIconRender]`: The icon to be rendered to the left of the menu item label. Can be a Dashicon slug or an SVG WP element.
- _props.onClick_ `[Function]`: The callback function to be executed when the user clicks the menu item.
@@ -896,7 +898,7 @@ _Parameters_
_Returns_
-- `Component`: The rendered menu item component.
+- `React.ReactNode`: The rendered menu item component.
### PluginSidebar
@@ -953,6 +955,7 @@ _Parameters_
- _props_ `Object`: Element props.
- _props.name_ `string`: A string identifying the sidebar. Must be unique for every sidebar registered within the scope of your plugin.
+- _props.children_ `[React.ReactNode]`: Children to be rendered.
- _props.className_ `[string]`: An optional class name added to the sidebar body.
- _props.title_ `string`: Title displayed at the top of the sidebar.
- _props.isPinnable_ `[boolean]`: Whether to allow to pin sidebar to the toolbar. When set to `true` it also automatically renders a corresponding menu item.
@@ -999,11 +1002,12 @@ _Parameters_
- _props_ `Object`: Component props.
- _props.target_ `string`: 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.
+- _props.children_ `[React.ReactNode]`: Children to be rendered.
- _props.icon_ `[WPBlockTypeIconRender]`: The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label.
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### PostAuthor
@@ -1011,7 +1015,7 @@ Renders the component for selecting the post author.
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### PostAuthorCheck
@@ -1020,11 +1024,11 @@ Wrapper component that renders its children only if the post type supports the a
_Parameters_
- _props_ `Object`: The component props.
-- _props.children_ `Element`: Children to be rendered.
+- _props.children_ `React.ReactNode`: Children to be rendered.
_Returns_
-- `Component|null`: The component to be rendered. Return `null` if the post type doesn't supports the author or if there are no authors available.
+- `React.ReactNode`: The component to be rendered. Return `null` if the post type doesn't supports the author or if there are no authors available.
### PostAuthorPanel
@@ -1032,7 +1036,7 @@ Renders the Post Author Panel component.
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### PostComments
@@ -1040,7 +1044,7 @@ A form for managing comment status.
_Returns_
-- `JSX.Element`: The rendered PostComments component.
+- `React.ReactNode`: The rendered PostComments component.
### PostDiscussionPanel
@@ -1048,7 +1052,7 @@ This component allows to update comment and pingback settings for the current po
_Returns_
-- `JSX.Element|null`: The rendered PostDiscussionPanel component.
+- `React.ReactNode`: The rendered PostDiscussionPanel component.
### PostExcerpt
@@ -1067,11 +1071,11 @@ Component for checking if the post type supports the excerpt field.
_Parameters_
- _props_ `Object`: Props.
-- _props.children_ `Element`: Children to be rendered.
+- _props.children_ `React.ReactNode`: Children to be rendered.
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### PostExcerptPanel
@@ -1079,7 +1083,7 @@ Is rendered if the post type supports excerpts and allows editing the excerpt.
_Returns_
-- `JSX.Element`: The rendered PostExcerptPanel component.
+- `React.ReactNode`: The rendered PostExcerptPanel component.
### PostFeaturedImage
@@ -1108,11 +1112,11 @@ Wrapper component that renders its children only if the post type supports a fea
_Parameters_
- _props_ `Object`: Props.
-- _props.children_ `Element`: Children to be rendered.
+- _props.children_ `React.ReactNode`: Children to be rendered.
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### PostFeaturedImagePanel
@@ -1125,7 +1129,7 @@ _Parameters_
_Returns_
-- `Component|null`: The component to be rendered. Return Null if the editor panel is disabled for featured image.
+- `React.ReactNode`: The component to be rendered. Return Null if the editor panel is disabled for featured image.
### PostFormat
@@ -1139,7 +1143,7 @@ _Usage_
_Returns_
-- `JSX.Element`: The rendered PostFormat component.
+- `React.ReactNode`: The rendered PostFormat component.
### PostFormatCheck
@@ -1148,11 +1152,11 @@ Component check if there are any post formats.
_Parameters_
- _props_ `Object`: The component props.
-- _props.children_ `Element`: The child elements to render.
+- _props.children_ `React.ReactNode`: The child elements to render.
_Returns_
-- `Component|null`: The rendered component or null if post formats are disabled.
+- `React.ReactNode`: The rendered component or null if post formats are disabled.
### PostLastRevision
@@ -1160,7 +1164,7 @@ Renders the component for displaying the last revision of a post.
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### PostLastRevisionCheck
@@ -1169,11 +1173,11 @@ Wrapper component that renders its children if the post has more than one revisi
_Parameters_
- _props_ `Object`: Props.
-- _props.children_ `Element`: Children to be rendered.
+- _props.children_ `React.ReactNode`: Children to be rendered.
_Returns_
-- `Component|null`: Rendered child components if post has more than one revision, otherwise null.
+- `React.ReactNode`: Rendered child components if post has more than one revision, otherwise null.
### PostLastRevisionPanel
@@ -1181,7 +1185,7 @@ Renders the panel for displaying the last revision of a post.
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### PostLockedModal
@@ -1189,7 +1193,7 @@ A modal component that is displayed when a post is locked for editing by another
_Returns_
-- `JSX.Element|null`: The rendered PostLockedModal component.
+- `React.ReactNode`: The rendered PostLockedModal component.
### PostPendingStatus
@@ -1197,7 +1201,7 @@ A component for displaying and toggling the pending status of a post.
_Returns_
-- `JSX.Element`: The rendered component.
+- `React.ReactNode`: The rendered component.
### PostPendingStatusCheck
@@ -1206,11 +1210,11 @@ This component checks the publishing status of the current post. If the post is
_Parameters_
- _props_ `Object`: Component properties.
-- _props.children_ `Element`: Children to be rendered.
+- _props.children_ `React.ReactElement`: Children to be rendered.
_Returns_
-- `JSX.Element|null`: The rendered child elements or null if the post is already published or the user doesn't have the capability to publish.
+- `React.ReactElement`: The rendered child elements or null if the post is already published or the user doesn't have the capability to publish.
### PostPingbacks
@@ -1231,7 +1235,7 @@ _Parameters_
_Returns_
-- `JSX.Element|null`: The rendered button component.
+- `React.ReactNode`: The rendered button component.
### PostPublishButton
@@ -1273,7 +1277,7 @@ _Parameters_
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### PostScheduleCheck
@@ -1282,11 +1286,11 @@ Wrapper component that renders its children only if post has a publish action.
_Parameters_
- _props_ `Object`: Props.
-- _props.children_ `Element`: Children to be rendered.
+- _props.children_ `React.ReactElement`: Children to be rendered.
_Returns_
-- `Component`: - The component to be rendered or null if there is no publish action.
+- `React.ReactElement`: - The component to be rendered or null if there is no publish action.
### PostScheduleLabel
@@ -1298,7 +1302,7 @@ _Parameters_
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### PostSchedulePanel
@@ -1306,7 +1310,7 @@ Renders the Post Schedule Panel component.
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### PostSlug
@@ -1314,7 +1318,7 @@ Renders the PostSlug component. It provide a control for editing the post slug.
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### PostSlugCheck
@@ -1323,11 +1327,11 @@ Wrapper component that renders its children only if the post type supports the s
_Parameters_
- _props_ `Object`: Props.
-- _props.children_ `Element`: Children to be rendered.
+- _props.children_ `React.ReactNode`: Children to be rendered.
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### PostSticky
@@ -1335,7 +1339,7 @@ Renders the PostSticky component. It provides a checkbox control for the sticky
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactNode`: The rendered component.
### PostStickyCheck
@@ -1344,11 +1348,11 @@ Wrapper component that renders its children only if post has a sticky action.
_Parameters_
- _props_ `Object`: Props.
-- _props.children_ `Element`: Children to be rendered.
+- _props.children_ `React.ReactElement`: Children to be rendered.
_Returns_
-- `Component`: The component to be rendered or null if post type is not 'post' or hasStickyAction is false.
+- `React.ReactElement`: The component to be rendered or null if post type is not 'post' or hasStickyAction is false.
### PostSwitchToDraftButton
@@ -1356,7 +1360,7 @@ Renders a button component that allows the user to switch a post to draft status
_Returns_
-- `JSX.Element`: The rendered component.
+- `React.ReactNode`: The rendered component.
### PostSyncStatus
@@ -1364,7 +1368,7 @@ Renders the sync status of a post.
_Returns_
-- `JSX.Element|null`: The rendered sync status component.
+- `React.ReactNode`: The rendered sync status component.
### PostTaxonomies
@@ -1386,11 +1390,11 @@ Renders the children components only if the current post type has taxonomies.
_Parameters_
- _props_ `Object`: The component props.
-- _props.children_ `Element`: The children components to render.
+- _props.children_ `React.ReactNode`: The children components to render.
_Returns_
-- `Component|null`: The rendered children components or null if the current post type has no taxonomies.
+- `React.ReactElement`: The rendered children components or null if the current post type has no taxonomies.
### PostTaxonomiesFlatTermSelector
@@ -1404,7 +1408,7 @@ _Parameters_
_Returns_
-- `JSX.Element`: The rendered flat term selector component.
+- `React.ReactNode`: The rendered flat term selector component.
### PostTaxonomiesHierarchicalTermSelector
@@ -1421,17 +1425,11 @@ _Returns_
### PostTaxonomiesPanel
-Renders a panel for a specific taxonomy.
-
-_Parameters_
-
-- _props_ `Object`: The component props.
-- _props.taxonomy_ `Object`: The taxonomy object.
-- _props.children_ `Element`: The child components.
+Component that renders the post taxonomies panel.
_Returns_
-- `Component`: The rendered taxonomy panel.
+- `React.ReactNode`: The rendered component.
### PostTemplatePanel
@@ -1439,7 +1437,7 @@ Displays the template controls based on the current editor settings and user per
_Returns_
-- `JSX.Element|null`: The rendered PostTemplatePanel component.
+- `React.ReactNode`: The rendered PostTemplatePanel component.
### PostTextEditor
@@ -1447,7 +1445,7 @@ Displays the Post Text Editor along with content in Visual and Text mode.
_Returns_
-- `JSX.Element|null`: The rendered PostTextEditor component.
+- `React.ReactNode`: The rendered PostTextEditor component.
### PostTitle
@@ -1460,7 +1458,7 @@ _Parameters_
_Returns_
-- `Component`: The rendered PostTitle component.
+- `React.ReactNode`: The rendered PostTitle component.
### PostTitleRaw
@@ -1476,7 +1474,7 @@ _Parameters_
_Returns_
-- `JSX.Element|null`: The rendered PostTrash component.
+- `React.ReactNode`: The rendered PostTrash component.
### PostTrashCheck
@@ -1485,11 +1483,11 @@ Wrapper component that renders its children only if the post can trashed.
_Parameters_
- _props_ `Object`: - The component props.
-- _props.children_ `Element`: - The child components to render.
+- _props.children_ `React.ReactEl`: - The child components to render.
_Returns_
-- `Component|null`: The rendered child components or null if the post can not trashed.
+- `React.ReactElement`: The rendered child components or null if the post can not trashed.
### PostTypeSupportCheck
@@ -1498,12 +1496,12 @@ A component which renders its own children only if the current editor post type
_Parameters_
- _props_ `Object`: Props.
-- _props.children_ `Element`: Children to be rendered if post type supports.
+- _props.children_ `React.ReactElement`: Children to be rendered if post type supports.
- _props.supportKeys_ `(string|string[])`: String or string array of keys to test.
_Returns_
-- `Component`: The component to be rendered.
+- `React.ReactElement`: The component to be rendered.
### PostURL
@@ -1521,7 +1519,7 @@ _Parameters_
_Returns_
-- `Component`: The rendered PostURL component.
+- `React.ReactNode`: The rendered PostURL component.
### PostURLCheck
@@ -1530,11 +1528,11 @@ Check if the post URL is valid and visible.
_Parameters_
- _props_ `Object`: The component props.
-- _props.children_ `Element`: The child components.
+- _props.children_ `React.ReactElement`: The child components.
_Returns_
-- `Component|null`: The child components if the post URL is valid and visible, otherwise null.
+- `React.ReactElement`: The child components if the post URL is valid and visible, otherwise null.
### PostURLLabel
@@ -1542,7 +1540,7 @@ Represents a label component for a post URL.
_Returns_
-- `Component`: The PostURLLabel component.
+- `React.ReactNode`: The PostURLLabel component.
### PostURLPanel
@@ -1550,7 +1548,7 @@ Renders the `PostURLPanel` component.
_Returns_
-- `JSX.Element`: The rendered PostURLPanel component.
+- `React.ReactNode`: The rendered PostURLPanel component.
### PostVisibility
@@ -1563,7 +1561,7 @@ _Parameters_
_Returns_
-- `JSX.Element`: The rendered component.
+- `React.ReactNode`: The rendered component.
### PostVisibilityCheck
@@ -1576,7 +1574,7 @@ _Parameters_
_Returns_
-- `JSX.Element`: The rendered component.
+- `React.ReactNode`: The rendered component.
### PostVisibilityLabel
@@ -1663,7 +1661,7 @@ _Parameters_
_Returns_
-- `JSX.Element`: The rendered table of contents component.
+- `React.ReactNode`: The rendered table of contents component.
### TextEditorGlobalKeyboardShortcuts
@@ -1678,12 +1676,12 @@ Checks if the current theme supports specific features and renders the children
_Parameters_
- _props_ `Object`: The component props.
-- _props.children_ `Element`: The children to render if the theme supports the specified features.
+- _props.children_ `React.ReactElement`: The children to render if the theme supports the specified features.
- _props.supportKeys_ `string|string[]`: The key(s) of the theme support(s) to check.
_Returns_
-- `JSX.Element|null`: The rendered children if the theme supports the specified features, otherwise null.
+- `React.ReactElement`: The rendered children if the theme supports the specified features, otherwise null.
### TimeToRead
@@ -1691,7 +1689,7 @@ Component for showing Time To Read in Content.
_Returns_
-- `JSX.Element`: The rendered TimeToRead component.
+- `React.ReactNode`: The rendered TimeToRead component.
### transformStyles
@@ -1727,7 +1725,7 @@ Warns the user if there are unsaved changes before leaving the editor. Compatibl
_Returns_
-- `Component`: The component.
+- `React.ReactNode`: The component.
### URLInput
@@ -1814,7 +1812,7 @@ Renders the word count of the post content.
_Returns_
-- `JSX.Element|null`: The rendered WordCount component.
+- `React.ReactNode`: The rendered WordCount component.
### WritingFlow
diff --git a/packages/editor/src/components/block-settings-menu/plugin-block-settings-menu-item.js b/packages/editor/src/components/block-settings-menu/plugin-block-settings-menu-item.js
index 59c9e9c32d4a4b..df1e75d2d0e8b5 100644
--- a/packages/editor/src/components/block-settings-menu/plugin-block-settings-menu-item.js
+++ b/packages/editor/src/components/block-settings-menu/plugin-block-settings-menu-item.js
@@ -76,7 +76,7 @@ const shouldRenderItem = ( selectedBlocks, allowedBlocks ) =>
* );
* ```
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
const PluginBlockSettingsMenuItem = ( {
allowedBlocks,
diff --git a/packages/editor/src/components/collab-sidebar/add-comment.js b/packages/editor/src/components/collab-sidebar/add-comment.js
index fce47e821e2065..2330017ac5db53 100644
--- a/packages/editor/src/components/collab-sidebar/add-comment.js
+++ b/packages/editor/src/components/collab-sidebar/add-comment.js
@@ -22,7 +22,7 @@ import CommentForm from './comment-form';
* @param {Function} props.onSubmit - A callback function to be called when the user submits a comment.
* @param {boolean} props.showCommentBoard - The function to edit the comment.
* @param {Function} props.setShowCommentBoard - The function to delete the comment.
- * @return {JSX.Element} The rendered comment input UI.
+ * @return {React.ReactNode} The rendered comment input UI.
*/
export function AddComment( {
onSubmit,
diff --git a/packages/editor/src/components/collab-sidebar/comment-author-info.js b/packages/editor/src/components/collab-sidebar/comment-author-info.js
index 89d09a2b52261f..d8b5f72a2fc25f 100644
--- a/packages/editor/src/components/collab-sidebar/comment-author-info.js
+++ b/packages/editor/src/components/collab-sidebar/comment-author-info.js
@@ -16,7 +16,7 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
* @param {string} props.name - Name of the author.
* @param {string} props.date - Date of the comment.
*
- * @return {JSX.Element} The JSX element representing the author's information.
+ * @return {React.ReactNode} The JSX element representing the author's information.
*/
function CommentAuthorInfo( { avatar, name, date } ) {
const dateSettings = getDateSettings();
diff --git a/packages/editor/src/components/collab-sidebar/comment-form.js b/packages/editor/src/components/collab-sidebar/comment-form.js
index 28622f9f52a6f8..052fd3cdd26568 100644
--- a/packages/editor/src/components/collab-sidebar/comment-form.js
+++ b/packages/editor/src/components/collab-sidebar/comment-form.js
@@ -22,7 +22,7 @@ import { sanitizeCommentString } from './utils';
* @param {Function} props.onCancel - The function to call when canceling the comment update.
* @param {Object} props.thread - The comment thread object.
* @param {string} props.submitButtonText - The text to display on the submit button.
- * @return {JSX.Element} The CommentForm component.
+ * @return {React.ReactNode} The CommentForm component.
*/
function CommentForm( { onSubmit, onCancel, thread, submitButtonText } ) {
const [ inputComment, setInputComment ] = useState(
diff --git a/packages/editor/src/components/collab-sidebar/comments.js b/packages/editor/src/components/collab-sidebar/comments.js
index 808ea0acf04b31..7a03068787c81e 100644
--- a/packages/editor/src/components/collab-sidebar/comments.js
+++ b/packages/editor/src/components/collab-sidebar/comments.js
@@ -35,7 +35,7 @@ import CommentForm from './comment-form';
* @param {Function} props.onAddReply - The function to add a reply to a comment.
* @param {Function} props.onCommentDelete - The function to delete a comment.
* @param {Function} props.onCommentResolve - The function to mark a comment as resolved.
- * @return {JSX.Element} The rendered Comments component.
+ * @return {React.ReactNode} The rendered Comments component.
*/
export function Comments( {
threads,
@@ -270,7 +270,7 @@ export function Comments( {
* @param {Function} props.onDelete - The function to delete the comment.
* @param {Function} props.onReply - The function to reply to the comment.
* @param {string} props.status - The status of the comment.
- * @return {JSX.Element} The rendered comment header.
+ * @return {React.ReactNode} The rendered comment header.
*/
function CommentHeader( {
thread,
diff --git a/packages/editor/src/components/document-bar/index.js b/packages/editor/src/components/document-bar/index.js
index 30990379fe6301..9fffba941a4355 100644
--- a/packages/editor/src/components/document-bar/index.js
+++ b/packages/editor/src/components/document-bar/index.js
@@ -49,7 +49,7 @@ const MotionButton = motion( Button );
* @param {IconType} props.icon An icon for the document, no default.
* (A default icon indicating the document post type is no longer used.)
*
- * @return {JSX.Element} The rendered DocumentBar component.
+ * @return {React.ReactNode} The rendered DocumentBar component.
*/
export default function DocumentBar( props ) {
const {
diff --git a/packages/editor/src/components/document-outline/check.js b/packages/editor/src/components/document-outline/check.js
index d0676aa9037ffe..87864cbb34a369 100644
--- a/packages/editor/src/components/document-outline/check.js
+++ b/packages/editor/src/components/document-outline/check.js
@@ -7,10 +7,10 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
/**
* Component check if there are any headings (core/heading blocks) present in the document.
*
- * @param {Object} props Props.
- * @param {Element} props.children Children to be rendered.
+ * @param {Object} props Props.
+ * @param {React.ReactElement} props.children Children to be rendered.
*
- * @return {Component|null} The component to be rendered or null if there are headings.
+ * @return {React.ReactElement} The component to be rendered or null if there are headings.
*/
export default function DocumentOutlineCheck( { children } ) {
const hasHeadings = useSelect( ( select ) => {
diff --git a/packages/editor/src/components/document-outline/index.js b/packages/editor/src/components/document-outline/index.js
index c5e59837362092..89f853798296ae 100644
--- a/packages/editor/src/components/document-outline/index.js
+++ b/packages/editor/src/components/document-outline/index.js
@@ -106,7 +106,7 @@ const isEmptyHeading = ( heading ) =>
* @param {Function} props.onSelect Function to be called when an outline item is selected
* @param {boolean} props.hasOutlineItemsDisabled Indicates whether the outline items are disabled.
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
export default function DocumentOutline( {
onSelect,
diff --git a/packages/editor/src/components/editor-history/redo.js b/packages/editor/src/components/editor-history/redo.js
index 46a263bb89926b..b2b20555f30544 100644
--- a/packages/editor/src/components/editor-history/redo.js
+++ b/packages/editor/src/components/editor-history/redo.js
@@ -50,6 +50,6 @@ function EditorHistoryRedo( props, ref ) {
* @param {Object} props - Props.
* @param {Ref} ref - Forwarded ref.
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
export default forwardRef( EditorHistoryRedo );
diff --git a/packages/editor/src/components/editor-history/undo.js b/packages/editor/src/components/editor-history/undo.js
index 6ba6055706e993..fe8cce72c4197e 100644
--- a/packages/editor/src/components/editor-history/undo.js
+++ b/packages/editor/src/components/editor-history/undo.js
@@ -46,6 +46,6 @@ function EditorHistoryUndo( props, ref ) {
* @param {Object} props - Props.
* @param {Ref} ref - Forwarded ref.
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
export default forwardRef( EditorHistoryUndo );
diff --git a/packages/editor/src/components/editor-notices/index.js b/packages/editor/src/components/editor-notices/index.js
index 28341bfda3f236..5f095ef1a813c6 100644
--- a/packages/editor/src/components/editor-notices/index.js
+++ b/packages/editor/src/components/editor-notices/index.js
@@ -18,7 +18,7 @@ import TemplateValidationNotice from '../template-validation-notice';
*
* ```
*
- * @return {JSX.Element} The rendered EditorNotices component.
+ * @return {React.ReactNode} The rendered EditorNotices component.
*/
export function EditorNotices() {
const { notices } = useSelect(
diff --git a/packages/editor/src/components/editor-snackbars/index.js b/packages/editor/src/components/editor-snackbars/index.js
index 6530e1ec7ea902..9b781ee60dcaa5 100644
--- a/packages/editor/src/components/editor-snackbars/index.js
+++ b/packages/editor/src/components/editor-snackbars/index.js
@@ -11,7 +11,7 @@ const MAX_VISIBLE_NOTICES = -3;
/**
* Renders the editor snackbars component.
*
- * @return {JSX.Element} The rendered component.
+ * @return {React.ReactNode} The rendered component.
*/
export default function EditorSnackbars() {
const notices = useSelect(
diff --git a/packages/editor/src/components/entities-saved-states/index.js b/packages/editor/src/components/entities-saved-states/index.js
index 849bd2d0d71c8c..ea05bca522941b 100644
--- a/packages/editor/src/components/entities-saved-states/index.js
+++ b/packages/editor/src/components/entities-saved-states/index.js
@@ -33,7 +33,7 @@ function identity( values ) {
* @param {Function} props.close The function to close the dialog.
* @param {Function} props.renderDialog The function to render the dialog.
*
- * @return {JSX.Element} The rendered component.
+ * @return {React.ReactNode} The rendered component.
*/
export default function EntitiesSavedStates( {
close,
@@ -64,7 +64,7 @@ export default function EntitiesSavedStates( {
* @param {Function} props.setUnselectedEntities Function to set unselected entities.
* @param {Array} props.unselectedEntities Array of unselected entities.
*
- * @return {JSX.Element} The rendered component.
+ * @return {React.ReactNode} The rendered component.
*/
export function EntitiesSavedStatesExtensible( {
additionalPrompt = undefined,
diff --git a/packages/editor/src/components/page-attributes/check.js b/packages/editor/src/components/page-attributes/check.js
index bed2b1a353842a..3c08a3d8e53514 100644
--- a/packages/editor/src/components/page-attributes/check.js
+++ b/packages/editor/src/components/page-attributes/check.js
@@ -12,10 +12,10 @@ import { store as editorStore } from '../../store';
/**
* Wrapper component that renders its children only if the post type supports page attributes.
*
- * @param {Object} props - The component props.
- * @param {Element} props.children - The child components to render.
+ * @param {Object} props - The component props.
+ * @param {React.ReactElement} props.children - The child components to render.
*
- * @return {Component|null} The rendered child components or null if page attributes are not supported.
+ * @return {React.ReactElement} The rendered child components or null if page attributes are not supported.
*/
export function PageAttributesCheck( { children } ) {
const supportsPageAttributes = useSelect( ( select ) => {
diff --git a/packages/editor/src/components/page-attributes/order.js b/packages/editor/src/components/page-attributes/order.js
index c5f02c71b613d4..04c6ce186a9701 100644
--- a/packages/editor/src/components/page-attributes/order.js
+++ b/packages/editor/src/components/page-attributes/order.js
@@ -59,7 +59,7 @@ function PageAttributesOrder() {
* for setting the order of a given page.
* The component is now not used in core but was kept for backward compatibility.
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
export default function PageAttributesOrderWithChecks() {
return (
diff --git a/packages/editor/src/components/page-attributes/panel.js b/packages/editor/src/components/page-attributes/panel.js
index 7fcaf4b90d9ffe..8ecf7f1642f718 100644
--- a/packages/editor/src/components/page-attributes/panel.js
+++ b/packages/editor/src/components/page-attributes/panel.js
@@ -33,7 +33,7 @@ function AttributesPanel() {
/**
* Renders the Page Attributes Panel component.
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
export default function PageAttributesPanel() {
return (
diff --git a/packages/editor/src/components/page-attributes/parent.js b/packages/editor/src/components/page-attributes/parent.js
index 17395589cd313b..bd2861766c334a 100644
--- a/packages/editor/src/components/page-attributes/parent.js
+++ b/packages/editor/src/components/page-attributes/parent.js
@@ -56,7 +56,7 @@ export const getItemPriority = ( name, searchValue ) => {
* Renders the Page Attributes Parent component. A dropdown menu in an editor interface
* for selecting the parent page of a given page.
*
- * @return {Component|null} The component to be rendered. Return null if post type is not hierarchical.
+ * @return {React.ReactNode} The component to be rendered. Return null if post type is not hierarchical.
*/
export function PageAttributesParent() {
const { editPost } = useDispatch( editorStore );
diff --git a/packages/editor/src/components/plugin-document-setting-panel/index.js b/packages/editor/src/components/plugin-document-setting-panel/index.js
index 7466acffc0c4b1..6408d82fe7e118 100644
--- a/packages/editor/src/components/plugin-document-setting-panel/index.js
+++ b/packages/editor/src/components/plugin-document-setting-panel/index.js
@@ -22,7 +22,7 @@ const { Fill, Slot } = createSlotFill( 'PluginDocumentSettingPanel' );
* @param {string} [props.className] An optional class name added to the row.
* @param {string} [props.title] The title of the panel
* @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar.
- * @param {Element} props.children Children to be rendered
+ * @param {React.ReactNode} props.children Children to be rendered
*
* @example
* ```js
@@ -64,7 +64,7 @@ const { Fill, Slot } = createSlotFill( 'PluginDocumentSettingPanel' );
* registerPlugin( 'document-setting-test', { render: MyDocumentSettingTest } );
* ```
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The component to be rendered.
*/
const PluginDocumentSettingPanel = ( {
name,
diff --git a/packages/editor/src/components/plugin-more-menu-item/index.js b/packages/editor/src/components/plugin-more-menu-item/index.js
index 28173c24ebcefa..1d8e124b03e604 100644
--- a/packages/editor/src/components/plugin-more-menu-item/index.js
+++ b/packages/editor/src/components/plugin-more-menu-item/index.js
@@ -10,6 +10,7 @@ import { ActionItem } from '@wordpress/interface';
* The text within the component appears as the menu item label.
*
* @param {Object} props Component properties.
+ * @param {React.ReactNode} [props.children] Children to be rendered.
* @param {string} [props.href] 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.
* @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label.
* @param {Function} [props.onClick=noop] The callback function to be executed when the user clicks the menu item.
@@ -59,7 +60,7 @@ import { ActionItem } from '@wordpress/interface';
* );
* ```
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
export default function PluginMoreMenuItem( props ) {
const context = usePluginContext();
diff --git a/packages/editor/src/components/plugin-post-publish-panel/index.js b/packages/editor/src/components/plugin-post-publish-panel/index.js
index 086045b1c1fee1..b93f0a15c237f5 100644
--- a/packages/editor/src/components/plugin-post-publish-panel/index.js
+++ b/packages/editor/src/components/plugin-post-publish-panel/index.js
@@ -15,7 +15,7 @@ const { Fill, Slot } = createSlotFill( 'PluginPostPublishPanel' );
* @param {string} [props.title] Title displayed at the top of the panel.
* @param {boolean} [props.initialOpen=false] Whether to have the panel initially opened. When no title is provided it is always opened.
* @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar.
- * @param {Element} props.children Children to be rendered
+ * @param {React.ReactNode} props.children Children to be rendered
*
* @example
* ```jsx
@@ -34,7 +34,7 @@ const { Fill, Slot } = createSlotFill( 'PluginPostPublishPanel' );
* );
* ```
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
const PluginPostPublishPanel = ( {
children,
diff --git a/packages/editor/src/components/plugin-post-status-info/index.js b/packages/editor/src/components/plugin-post-status-info/index.js
index a4a216b78ae78b..f9f3293047ddd3 100644
--- a/packages/editor/src/components/plugin-post-status-info/index.js
+++ b/packages/editor/src/components/plugin-post-status-info/index.js
@@ -14,9 +14,9 @@ const { Fill, Slot } = createSlotFill( 'PluginPostStatusInfo' );
* 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.
*
- * @param {Object} props Component properties.
- * @param {string} [props.className] An optional class name added to the row.
- * @param {Element} props.children Children to be rendered.
+ * @param {Object} props Component properties.
+ * @param {string} [props.className] An optional class name added to the row.
+ * @param {React.ReactNode} props.children Children to be rendered.
*
* @example
* ```js
@@ -50,7 +50,7 @@ const { Fill, Slot } = createSlotFill( 'PluginPostStatusInfo' );
* );
* ```
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
const PluginPostStatusInfo = ( { children, className } ) => (
diff --git a/packages/editor/src/components/plugin-pre-publish-panel/index.js b/packages/editor/src/components/plugin-pre-publish-panel/index.js
index c9f556dc534a80..412af36c5176e0 100644
--- a/packages/editor/src/components/plugin-pre-publish-panel/index.js
+++ b/packages/editor/src/components/plugin-pre-publish-panel/index.js
@@ -18,7 +18,7 @@ const { Fill, Slot } = createSlotFill( 'PluginPrePublishPanel' );
* @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/)
* icon slug string, or an SVG WP element, to be rendered when
* the sidebar is pinned to toolbar.
- * @param {Element} props.children Children to be rendered
+ * @param {React.ReactNode} props.children Children to be rendered
*
* @example
* ```jsx
@@ -37,7 +37,7 @@ const { Fill, Slot } = createSlotFill( 'PluginPrePublishPanel' );
* );
* ```
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
const PluginPrePublishPanel = ( {
children,
diff --git a/packages/editor/src/components/plugin-preview-menu-item/index.js b/packages/editor/src/components/plugin-preview-menu-item/index.js
index 8038da04595aae..949f02808a7b03 100644
--- a/packages/editor/src/components/plugin-preview-menu-item/index.js
+++ b/packages/editor/src/components/plugin-preview-menu-item/index.js
@@ -10,6 +10,7 @@ import { ActionItem } from '@wordpress/interface';
* The text within the component appears as the menu item label.
*
* @param {Object} props Component properties.
+ * @param {React.ReactNode} [props.children] Children to be rendered.
* @param {string} [props.href] When `href` is provided, the menu item is rendered as an anchor instead of a button. It corresponds to the `href` attribute of the anchor.
* @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The icon to be rendered to the left of the menu item label. Can be a Dashicon slug or an SVG WP element.
* @param {Function} [props.onClick] The callback function to be executed when the user clicks the menu item.
@@ -38,7 +39,7 @@ import { ActionItem } from '@wordpress/interface';
* } );
* ```
*
- * @return {Component} The rendered menu item component.
+ * @return {React.ReactNode} The rendered menu item component.
*/
export default function PluginPreviewMenuItem( props ) {
const context = usePluginContext();
diff --git a/packages/editor/src/components/plugin-sidebar-more-menu-item/index.js b/packages/editor/src/components/plugin-sidebar-more-menu-item/index.js
index 0d7695c9abfe12..379a0720dc8a91 100644
--- a/packages/editor/src/components/plugin-sidebar-more-menu-item/index.js
+++ b/packages/editor/src/components/plugin-sidebar-more-menu-item/index.js
@@ -10,6 +10,7 @@ import { ComplementaryAreaMoreMenuItem } from '@wordpress/interface';
*
* @param {Object} props Component props.
* @param {string} props.target 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.
+ * @param {React.ReactNode} [props.children] Children to be rendered.
* @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label.
*
* @example
@@ -48,9 +49,8 @@ import { ComplementaryAreaMoreMenuItem } from '@wordpress/interface';
* );
* ```
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
-
export default function PluginSidebarMoreMenuItem( props ) {
return (
{
diff --git a/packages/editor/src/components/post-author/panel.js b/packages/editor/src/components/post-author/panel.js
index 6c6a51918902dc..5a413aedac09cf 100644
--- a/packages/editor/src/components/post-author/panel.js
+++ b/packages/editor/src/components/post-author/panel.js
@@ -39,7 +39,7 @@ function PostAuthorToggle( { isOpen, onClick } ) {
/**
* Renders the Post Author Panel component.
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
export function PostAuthor() {
// Use internal state instead of a ref to make sure that the component
diff --git a/packages/editor/src/components/post-comments/index.js b/packages/editor/src/components/post-comments/index.js
index 1d331811b46b26..6e69f9bce4f838 100644
--- a/packages/editor/src/components/post-comments/index.js
+++ b/packages/editor/src/components/post-comments/index.js
@@ -61,6 +61,6 @@ function PostComments() {
/**
* A form for managing comment status.
*
- * @return {JSX.Element} The rendered PostComments component.
+ * @return {React.ReactNode} The rendered PostComments component.
*/
export default PostComments;
diff --git a/packages/editor/src/components/post-discussion/panel.js b/packages/editor/src/components/post-discussion/panel.js
index c539791d404dec..280ab11b0447e7 100644
--- a/packages/editor/src/components/post-discussion/panel.js
+++ b/packages/editor/src/components/post-discussion/panel.js
@@ -93,7 +93,7 @@ function PostDiscussionToggle( { isOpen, onClick } ) {
* checks whether the current post has support for the
* above and if the `discussion-panel` panel is enabled.
*
- * @return {JSX.Element|null} The rendered PostDiscussionPanel component.
+ * @return {React.ReactNode} The rendered PostDiscussionPanel component.
*/
export default function PostDiscussionPanel() {
const { isEnabled } = useSelect( ( select ) => {
diff --git a/packages/editor/src/components/post-excerpt/check.js b/packages/editor/src/components/post-excerpt/check.js
index 77436ecfed218a..c518d90e424a9b 100644
--- a/packages/editor/src/components/post-excerpt/check.js
+++ b/packages/editor/src/components/post-excerpt/check.js
@@ -6,10 +6,10 @@ import PostTypeSupportCheck from '../post-type-support-check';
/**
* Component for checking if the post type supports the excerpt field.
*
- * @param {Object} props Props.
- * @param {Element} props.children Children to be rendered.
+ * @param {Object} props Props.
+ * @param {React.ReactNode} props.children Children to be rendered.
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
function PostExcerptCheck( { children } ) {
return (
diff --git a/packages/editor/src/components/post-excerpt/panel.js b/packages/editor/src/components/post-excerpt/panel.js
index 9c09796f467040..d4f2b27126c7c1 100644
--- a/packages/editor/src/components/post-excerpt/panel.js
+++ b/packages/editor/src/components/post-excerpt/panel.js
@@ -83,7 +83,7 @@ function ExcerptPanel() {
/**
* Is rendered if the post type supports excerpts and allows editing the excerpt.
*
- * @return {JSX.Element} The rendered PostExcerptPanel component.
+ * @return {React.ReactNode} The rendered PostExcerptPanel component.
*/
export default function PostExcerptPanel() {
return (
diff --git a/packages/editor/src/components/post-excerpt/plugin.js b/packages/editor/src/components/post-excerpt/plugin.js
index 64861162a0f637..50c494c01cb6d8 100644
--- a/packages/editor/src/components/post-excerpt/plugin.js
+++ b/packages/editor/src/components/post-excerpt/plugin.js
@@ -12,9 +12,9 @@ const { Fill, Slot } = createSlotFill( 'PluginPostExcerpt' );
/**
* Renders a post excerpt panel in the post sidebar.
*
- * @param {Object} props Component properties.
- * @param {string} [props.className] An optional class name added to the row.
- * @param {Element} props.children Children to be rendered.
+ * @param {Object} props Component properties.
+ * @param {string} [props.className] An optional class name added to the row.
+ * @param {React.ReactNode} props.children Children to be rendered.
*
* @example
* ```js
@@ -46,7 +46,7 @@ const { Fill, Slot } = createSlotFill( 'PluginPostExcerpt' );
* );
* ```
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
const PluginPostExcerpt = ( { children, className } ) => {
return (
diff --git a/packages/editor/src/components/post-featured-image/check.js b/packages/editor/src/components/post-featured-image/check.js
index 823559f766bc35..700a3b8edfd032 100644
--- a/packages/editor/src/components/post-featured-image/check.js
+++ b/packages/editor/src/components/post-featured-image/check.js
@@ -8,10 +8,10 @@ import ThemeSupportCheck from '../theme-support-check';
* Wrapper component that renders its children only if the post type supports a featured image
* and the theme supports post thumbnails.
*
- * @param {Object} props Props.
- * @param {Element} props.children Children to be rendered.
+ * @param {Object} props Props.
+ * @param {React.ReactNode} props.children Children to be rendered.
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
function PostFeaturedImageCheck( { children } ) {
return (
diff --git a/packages/editor/src/components/post-featured-image/panel.js b/packages/editor/src/components/post-featured-image/panel.js
index dd2a1527152ddf..8621b2eb886337 100644
--- a/packages/editor/src/components/post-featured-image/panel.js
+++ b/packages/editor/src/components/post-featured-image/panel.js
@@ -21,7 +21,7 @@ const PANEL_NAME = 'featured-image';
* @param {Object} props Props.
* @param {boolean} props.withPanelBody Whether to include the panel body. Default true.
*
- * @return {Component|null} The component to be rendered.
+ * @return {React.ReactNode} The component to be rendered.
* Return Null if the editor panel is disabled for featured image.
*/
export default function PostFeaturedImagePanel( { withPanelBody = true } ) {
diff --git a/packages/editor/src/components/post-format/check.js b/packages/editor/src/components/post-format/check.js
index 35729770b93c40..fe791862e1cebb 100644
--- a/packages/editor/src/components/post-format/check.js
+++ b/packages/editor/src/components/post-format/check.js
@@ -9,7 +9,15 @@ import { useSelect } from '@wordpress/data';
import PostTypeSupportCheck from '../post-type-support-check';
import { store as editorStore } from '../../store';
-function PostFormatCheck( { children } ) {
+/**
+ * Component check if there are any post formats.
+ *
+ * @param {Object} props The component props.
+ * @param {React.ReactNode} props.children The child elements to render.
+ *
+ * @return {React.ReactNode} The rendered component or null if post formats are disabled.
+ */
+export default function PostFormatCheck( { children } ) {
const disablePostFormats = useSelect(
( select ) =>
select( editorStore ).getEditorSettings().disablePostFormats,
@@ -26,13 +34,3 @@ function PostFormatCheck( { children } ) {
);
}
-
-/**
- * Component check if there are any post formats.
- *
- * @param {Object} props The component props.
- * @param {Element} props.children The child elements to render.
- *
- * @return {Component|null} The rendered component or null if post formats are disabled.
- */
-export default PostFormatCheck;
diff --git a/packages/editor/src/components/post-format/index.js b/packages/editor/src/components/post-format/index.js
index 8f7423239600f2..d98720cd6fa93f 100644
--- a/packages/editor/src/components/post-format/index.js
+++ b/packages/editor/src/components/post-format/index.js
@@ -46,7 +46,7 @@ export const POST_FORMATS = [
*
* ```
*
- * @return {JSX.Element} The rendered PostFormat component.
+ * @return {React.ReactNode} The rendered PostFormat component.
*/
export default function PostFormat() {
const instanceId = useInstanceId( PostFormat );
diff --git a/packages/editor/src/components/post-format/panel.js b/packages/editor/src/components/post-format/panel.js
index faaf88b785a4b2..18704eda6fc448 100644
--- a/packages/editor/src/components/post-format/panel.js
+++ b/packages/editor/src/components/post-format/panel.js
@@ -18,7 +18,7 @@ import { store as editorStore } from '../../store';
/**
* Renders the Post Author Panel component.
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
function PostFormat() {
const { postFormat } = useSelect( ( select ) => {
diff --git a/packages/editor/src/components/post-last-revision/check.js b/packages/editor/src/components/post-last-revision/check.js
index c570f5e42cdc32..cb3c655e1b7cc3 100644
--- a/packages/editor/src/components/post-last-revision/check.js
+++ b/packages/editor/src/components/post-last-revision/check.js
@@ -12,10 +12,10 @@ import { store as editorStore } from '../../store';
/**
* Wrapper component that renders its children if the post has more than one revision.
*
- * @param {Object} props Props.
- * @param {Element} props.children Children to be rendered.
+ * @param {Object} props Props.
+ * @param {React.ReactNode} props.children Children to be rendered.
*
- * @return {Component|null} Rendered child components if post has more than one revision, otherwise null.
+ * @return {React.ReactNode} Rendered child components if post has more than one revision, otherwise null.
*/
function PostLastRevisionCheck( { children } ) {
const { lastRevisionId, revisionsCount } = useSelect( ( select ) => {
diff --git a/packages/editor/src/components/post-last-revision/index.js b/packages/editor/src/components/post-last-revision/index.js
index fd68f9703cb4e2..ac25e6cb8f30d6 100644
--- a/packages/editor/src/components/post-last-revision/index.js
+++ b/packages/editor/src/components/post-last-revision/index.js
@@ -28,7 +28,7 @@ function usePostLastRevisionInfo() {
/**
* Renders the component for displaying the last revision of a post.
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
function PostLastRevision() {
const { lastRevisionId, revisionsCount } = usePostLastRevisionInfo();
diff --git a/packages/editor/src/components/post-last-revision/panel.js b/packages/editor/src/components/post-last-revision/panel.js
index e87475cc2b34e9..55a3ba571c4b0a 100644
--- a/packages/editor/src/components/post-last-revision/panel.js
+++ b/packages/editor/src/components/post-last-revision/panel.js
@@ -12,7 +12,7 @@ import PostLastRevisionCheck from './check';
/**
* Renders the panel for displaying the last revision of a post.
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
function PostLastRevisionPanel() {
return (
diff --git a/packages/editor/src/components/post-locked-modal/index.js b/packages/editor/src/components/post-locked-modal/index.js
index 7bfa2d23fd9808..16cff5af976841 100644
--- a/packages/editor/src/components/post-locked-modal/index.js
+++ b/packages/editor/src/components/post-locked-modal/index.js
@@ -24,7 +24,7 @@ import { store as editorStore } from '../../store';
* A modal component that is displayed when a post is locked for editing by another user.
* The modal provides information about the lock status and options to take over or exit the editor.
*
- * @return {JSX.Element|null} The rendered PostLockedModal component.
+ * @return {React.ReactNode} The rendered PostLockedModal component.
*/
export default function PostLockedModal() {
const instanceId = useInstanceId( PostLockedModal );
diff --git a/packages/editor/src/components/post-pending-status/check.js b/packages/editor/src/components/post-pending-status/check.js
index 7a4ff5195041c6..9f407d8c8cd82a 100644
--- a/packages/editor/src/components/post-pending-status/check.js
+++ b/packages/editor/src/components/post-pending-status/check.js
@@ -13,10 +13,10 @@ import { store as editorStore } from '../../store';
* If the post is already published or the user doesn't have the
* capability to publish, it returns null.
*
- * @param {Object} props Component properties.
- * @param {Element} props.children Children to be rendered.
+ * @param {Object} props Component properties.
+ * @param {React.ReactElement} props.children Children to be rendered.
*
- * @return {JSX.Element|null} The rendered child elements or null if the post is already published or the user doesn't have the capability to publish.
+ * @return {React.ReactElement} The rendered child elements or null if the post is already published or the user doesn't have the capability to publish.
*/
export function PostPendingStatusCheck( { children } ) {
const { hasPublishAction, isPublished } = useSelect( ( select ) => {
diff --git a/packages/editor/src/components/post-pending-status/index.js b/packages/editor/src/components/post-pending-status/index.js
index 8363ebc715891b..352570c44a6630 100644
--- a/packages/editor/src/components/post-pending-status/index.js
+++ b/packages/editor/src/components/post-pending-status/index.js
@@ -14,7 +14,7 @@ import { store as editorStore } from '../../store';
/**
* A component for displaying and toggling the pending status of a post.
*
- * @return {JSX.Element} The rendered component.
+ * @return {React.ReactNode} The rendered component.
*/
export function PostPendingStatus() {
const status = useSelect(
diff --git a/packages/editor/src/components/post-preview-button/index.js b/packages/editor/src/components/post-preview-button/index.js
index d57143cd355d80..d1755f96b68615 100644
--- a/packages/editor/src/components/post-preview-button/index.js
+++ b/packages/editor/src/components/post-preview-button/index.js
@@ -112,7 +112,7 @@ function writeInterstitialMessage( targetDocument ) {
* @param {string} props.role The role attribute for the button.
* @param {Function} props.onPreview The callback function for preview event.
*
- * @return {JSX.Element|null} The rendered button component.
+ * @return {React.ReactNode} The rendered button component.
*/
export default function PostPreviewButton( {
className,
diff --git a/packages/editor/src/components/post-schedule/check.js b/packages/editor/src/components/post-schedule/check.js
index 28456b90371cc3..32526a977f94fa 100644
--- a/packages/editor/src/components/post-schedule/check.js
+++ b/packages/editor/src/components/post-schedule/check.js
@@ -11,10 +11,10 @@ import { store as editorStore } from '../../store';
/**
* Wrapper component that renders its children only if post has a publish action.
*
- * @param {Object} props Props.
- * @param {Element} props.children Children to be rendered.
+ * @param {Object} props Props.
+ * @param {React.ReactElement} props.children Children to be rendered.
*
- * @return {Component} - The component to be rendered or null if there is no publish action.
+ * @return {React.ReactElement} - The component to be rendered or null if there is no publish action.
*/
export default function PostScheduleCheck( { children } ) {
const hasPublishAction = useSelect( ( select ) => {
diff --git a/packages/editor/src/components/post-schedule/index.js b/packages/editor/src/components/post-schedule/index.js
index 94387ed4267fa9..c9b017bcfa80df 100644
--- a/packages/editor/src/components/post-schedule/index.js
+++ b/packages/editor/src/components/post-schedule/index.js
@@ -27,7 +27,7 @@ const { PrivatePublishDateTimePicker } = unlock( blockEditorPrivateApis );
* @param {Object} props Props.
* @param {Function} props.onClose Function to close the component.
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
export default function PostSchedule( props ) {
return (
diff --git a/packages/editor/src/components/post-schedule/label.js b/packages/editor/src/components/post-schedule/label.js
index f6cf3811db7916..2b8819747e7e0c 100644
--- a/packages/editor/src/components/post-schedule/label.js
+++ b/packages/editor/src/components/post-schedule/label.js
@@ -15,7 +15,7 @@ import { store as editorStore } from '../../store';
*
* @param {Object} props Props.
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
export default function PostScheduleLabel( props ) {
return usePostScheduleLabel( props );
diff --git a/packages/editor/src/components/post-schedule/panel.js b/packages/editor/src/components/post-schedule/panel.js
index 5d63da5e30c910..fd453a4667417f 100644
--- a/packages/editor/src/components/post-schedule/panel.js
+++ b/packages/editor/src/components/post-schedule/panel.js
@@ -31,7 +31,7 @@ const DESIGN_POST_TYPES = [
/**
* Renders the Post Schedule Panel component.
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
export default function PostSchedulePanel() {
const [ popoverAnchor, setPopoverAnchor ] = useState( null );
diff --git a/packages/editor/src/components/post-slug/check.js b/packages/editor/src/components/post-slug/check.js
index 86bf04814c934d..8ca7078a1a9e24 100644
--- a/packages/editor/src/components/post-slug/check.js
+++ b/packages/editor/src/components/post-slug/check.js
@@ -6,10 +6,10 @@ import PostTypeSupportCheck from '../post-type-support-check';
/**
* Wrapper component that renders its children only if the post type supports the slug.
*
- * @param {Object} props Props.
- * @param {Element} props.children Children to be rendered.
+ * @param {Object} props Props.
+ * @param {React.ReactNode} props.children Children to be rendered.
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
export default function PostSlugCheck( { children } ) {
return (
diff --git a/packages/editor/src/components/post-slug/index.js b/packages/editor/src/components/post-slug/index.js
index 1a4f8e93d7565c..afff7f361ea428 100644
--- a/packages/editor/src/components/post-slug/index.js
+++ b/packages/editor/src/components/post-slug/index.js
@@ -62,7 +62,7 @@ function PostSlugControl() {
/**
* Renders the PostSlug component. It provide a control for editing the post slug.
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
export default function PostSlug() {
return (
diff --git a/packages/editor/src/components/post-sticky/check.js b/packages/editor/src/components/post-sticky/check.js
index f504effca82c6b..ede5c22f3c3e32 100644
--- a/packages/editor/src/components/post-sticky/check.js
+++ b/packages/editor/src/components/post-sticky/check.js
@@ -11,10 +11,10 @@ import { store as editorStore } from '../../store';
/**
* Wrapper component that renders its children only if post has a sticky action.
*
- * @param {Object} props Props.
- * @param {Element} props.children Children to be rendered.
+ * @param {Object} props Props.
+ * @param {React.ReactElement} props.children Children to be rendered.
*
- * @return {Component} The component to be rendered or null if post type is not 'post' or hasStickyAction is false.
+ * @return {React.ReactElement} The component to be rendered or null if post type is not 'post' or hasStickyAction is false.
*/
export default function PostStickyCheck( { children } ) {
const { hasStickyAction, postType } = useSelect( ( select ) => {
diff --git a/packages/editor/src/components/post-sticky/index.js b/packages/editor/src/components/post-sticky/index.js
index 43a4bea98de26e..6f5b914cb2f352 100644
--- a/packages/editor/src/components/post-sticky/index.js
+++ b/packages/editor/src/components/post-sticky/index.js
@@ -14,7 +14,7 @@ import { store as editorStore } from '../../store';
/**
* Renders the PostSticky component. It provides a checkbox control for the sticky post feature.
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactNode} The rendered component.
*/
export default function PostSticky() {
const postSticky = useSelect( ( select ) => {
diff --git a/packages/editor/src/components/post-switch-to-draft-button/index.js b/packages/editor/src/components/post-switch-to-draft-button/index.js
index a743c7a2991ffb..6a41e1fad597a2 100644
--- a/packages/editor/src/components/post-switch-to-draft-button/index.js
+++ b/packages/editor/src/components/post-switch-to-draft-button/index.js
@@ -18,7 +18,7 @@ import { store as editorStore } from '../../store';
/**
* Renders a button component that allows the user to switch a post to draft status.
*
- * @return {JSX.Element} The rendered component.
+ * @return {React.ReactNode} The rendered component.
*/
export default function PostSwitchToDraftButton() {
deprecated( 'wp.editor.PostSwitchToDraftButton', {
diff --git a/packages/editor/src/components/post-sync-status/index.js b/packages/editor/src/components/post-sync-status/index.js
index d3e2a1a5522e89..5f965c01503f5c 100644
--- a/packages/editor/src/components/post-sync-status/index.js
+++ b/packages/editor/src/components/post-sync-status/index.js
@@ -13,7 +13,7 @@ import { store as editorStore } from '../../store';
/**
* Renders the sync status of a post.
*
- * @return {JSX.Element|null} The rendered sync status component.
+ * @return {React.ReactNode} The rendered sync status component.
*/
export default function PostSyncStatus() {
const { syncStatus, postType } = useSelect( ( select ) => {
diff --git a/packages/editor/src/components/post-taxonomies/check.js b/packages/editor/src/components/post-taxonomies/check.js
index 401b1adad7cad4..ce3db319ae2e8a 100644
--- a/packages/editor/src/components/post-taxonomies/check.js
+++ b/packages/editor/src/components/post-taxonomies/check.js
@@ -12,10 +12,10 @@ import { store as editorStore } from '../../store';
/**
* Renders the children components only if the current post type has taxonomies.
*
- * @param {Object} props The component props.
- * @param {Element} props.children The children components to render.
+ * @param {Object} props The component props.
+ * @param {React.ReactNode} props.children The children components to render.
*
- * @return {Component|null} The rendered children components or null if the current post type has no taxonomies.
+ * @return {React.ReactElement} The rendered children components or null if the current post type has no taxonomies.
*/
export default function PostTaxonomiesCheck( { children } ) {
const hasTaxonomies = useSelect( ( select ) => {
diff --git a/packages/editor/src/components/post-taxonomies/flat-term-selector.js b/packages/editor/src/components/post-taxonomies/flat-term-selector.js
index cd9377766af503..890175534c8b4a 100644
--- a/packages/editor/src/components/post-taxonomies/flat-term-selector.js
+++ b/packages/editor/src/components/post-taxonomies/flat-term-selector.js
@@ -71,7 +71,7 @@ const Wrapper = ( { children, __nextHasNoMarginBottom } ) =>
* @param {string} props.slug The slug of the taxonomy.
* @param {boolean} props.__nextHasNoMarginBottom Start opting into the new margin-free styles that will become the default in a future version, currently scheduled to be WordPress 7.0. (The prop can be safely removed once this happens.)
*
- * @return {JSX.Element} The rendered flat term selector component.
+ * @return {React.ReactNode} The rendered flat term selector component.
*/
export function FlatTermSelector( { slug, __nextHasNoMarginBottom } ) {
const [ values, setValues ] = useState( [] );
diff --git a/packages/editor/src/components/post-taxonomies/panel.js b/packages/editor/src/components/post-taxonomies/panel.js
index 760626f984db36..f75fa74cc3d2e9 100644
--- a/packages/editor/src/components/post-taxonomies/panel.js
+++ b/packages/editor/src/components/post-taxonomies/panel.js
@@ -11,6 +11,15 @@ import { store as editorStore } from '../../store';
import PostTaxonomiesForm from './index';
import PostTaxonomiesCheck from './check';
+/**
+ * Renders a panel for a specific taxonomy.
+ *
+ * @param {Object} props The component props.
+ * @param {Object} props.taxonomy The taxonomy object.
+ * @param {React.ReactNode} props.children The child components.
+ *
+ * @return {React.ReactNode} The rendered taxonomy panel.
+ */
function TaxonomyPanel( { taxonomy, children } ) {
const slug = taxonomy?.slug;
const panelName = slug ? `taxonomy-panel-${ slug }` : '';
@@ -47,7 +56,12 @@ function TaxonomyPanel( { taxonomy, children } ) {
);
}
-function PostTaxonomies() {
+/**
+ * Component that renders the post taxonomies panel.
+ *
+ * @return {React.ReactNode} The rendered component.
+ */
+export default function PostTaxonomies() {
return (
);
}
-
-/**
- * Renders a panel for a specific taxonomy.
- *
- * @param {Object} props The component props.
- * @param {Object} props.taxonomy The taxonomy object.
- * @param {Element} props.children The child components.
- *
- * @return {Component} The rendered taxonomy panel.
- */
-export default PostTaxonomies;
diff --git a/packages/editor/src/components/post-template/classic-theme.js b/packages/editor/src/components/post-template/classic-theme.js
index 4a65a9b4c75636..4345e06211c661 100644
--- a/packages/editor/src/components/post-template/classic-theme.js
+++ b/packages/editor/src/components/post-template/classic-theme.js
@@ -63,7 +63,7 @@ function PostTemplateToggle( { isOpen, onClick } ) {
* @param {Object} props The component props.
* @param {Function} props.onClose The function to close the dropdown.
*
- * @return {JSX.Element} The rendered dropdown content.
+ * @return {React.ReactNode} The rendered dropdown content.
*/
function PostTemplateDropdownContent( { onClose } ) {
const allowSwitchingTemplate = useAllowSwitchingTemplates();
@@ -235,6 +235,6 @@ function ClassicThemeControl() {
*
* The dropdown menu includes a button for toggling the menu, a list of available templates, and options for creating and editing templates.
*
- * @return {JSX.Element} The rendered ClassicThemeControl component.
+ * @return {React.ReactNode} The rendered ClassicThemeControl component.
*/
export default ClassicThemeControl;
diff --git a/packages/editor/src/components/post-template/panel.js b/packages/editor/src/components/post-template/panel.js
index b5f0d34197c686..903612ef11ed15 100644
--- a/packages/editor/src/components/post-template/panel.js
+++ b/packages/editor/src/components/post-template/panel.js
@@ -16,7 +16,7 @@ import PostPanelRow from '../post-panel-row';
/**
* Displays the template controls based on the current editor settings and user permissions.
*
- * @return {JSX.Element|null} The rendered PostTemplatePanel component.
+ * @return {React.ReactNode} The rendered PostTemplatePanel component.
*/
export default function PostTemplatePanel() {
const { templateId, isBlockTheme } = useSelect( ( select ) => {
diff --git a/packages/editor/src/components/post-text-editor/index.js b/packages/editor/src/components/post-text-editor/index.js
index c3dc61a0b4a2ef..0ae569c3e15301 100644
--- a/packages/editor/src/components/post-text-editor/index.js
+++ b/packages/editor/src/components/post-text-editor/index.js
@@ -22,7 +22,7 @@ import { store as editorStore } from '../../store';
/**
* Displays the Post Text Editor along with content in Visual and Text mode.
*
- * @return {JSX.Element|null} The rendered PostTextEditor component.
+ * @return {React.ReactNode} The rendered PostTextEditor component.
*/
export default function PostTextEditor() {
const instanceId = useInstanceId( PostTextEditor );
diff --git a/packages/editor/src/components/post-title/index.js b/packages/editor/src/components/post-title/index.js
index 7fc79eaeddffb5..090beb57f6170e 100644
--- a/packages/editor/src/components/post-title/index.js
+++ b/packages/editor/src/components/post-title/index.js
@@ -193,7 +193,7 @@ const PostTitle = forwardRef( ( _, forwardedRef ) => {
* @param {Object} _ Unused parameter.
* @param {Element} forwardedRef Forwarded ref for the component.
*
- * @return {Component} The rendered PostTitle component.
+ * @return {React.ReactNode} The rendered PostTitle component.
*/
export default forwardRef( ( _, forwardedRef ) => (
diff --git a/packages/editor/src/components/post-title/post-title-raw.js b/packages/editor/src/components/post-title/post-title-raw.js
index 66c944b45871ab..9beba1068f8ef7 100644
--- a/packages/editor/src/components/post-title/post-title-raw.js
+++ b/packages/editor/src/components/post-title/post-title-raw.js
@@ -26,7 +26,7 @@ import usePostTitle from './use-post-title';
* @param {Object} _ Unused parameter.
* @param {Element} forwardedRef Reference to the component's DOM node.
*
- * @return {Component} The rendered component.
+ * @return {React.ReactNode} The rendered component.
*/
function PostTitleRaw( _, forwardedRef ) {
const { placeholder } = useSelect( ( select ) => {
diff --git a/packages/editor/src/components/post-trash/check.js b/packages/editor/src/components/post-trash/check.js
index 7edc7c0f18c273..893d46ef9a0867 100644
--- a/packages/editor/src/components/post-trash/check.js
+++ b/packages/editor/src/components/post-trash/check.js
@@ -13,10 +13,10 @@ import { GLOBAL_POST_TYPES } from '../../store/constants';
/**
* Wrapper component that renders its children only if the post can trashed.
*
- * @param {Object} props - The component props.
- * @param {Element} props.children - The child components to render.
+ * @param {Object} props - The component props.
+ * @param {React.ReactEl} props.children - The child components to render.
*
- * @return {Component|null} The rendered child components or null if the post can not trashed.
+ * @return {React.ReactElement} The rendered child components or null if the post can not trashed.
*/
export default function PostTrashCheck( { children } ) {
const { canTrashPost } = useSelect( ( select ) => {
diff --git a/packages/editor/src/components/post-trash/index.js b/packages/editor/src/components/post-trash/index.js
index 743512e9efd7d4..2d3dd8bcb0c4b3 100644
--- a/packages/editor/src/components/post-trash/index.js
+++ b/packages/editor/src/components/post-trash/index.js
@@ -19,7 +19,7 @@ import PostTrashCheck from './check';
* Displays the Post Trash Button and Confirm Dialog in the Editor.
*
* @param {?{onActionPerformed: Object}} An object containing the onActionPerformed function.
- * @return {JSX.Element|null} The rendered PostTrash component.
+ * @return {React.ReactNode} The rendered PostTrash component.
*/
export default function PostTrash( { onActionPerformed } ) {
const registry = useRegistry();
diff --git a/packages/editor/src/components/post-type-support-check/index.js b/packages/editor/src/components/post-type-support-check/index.js
index 613fda8eb82da3..f04aea84b0e411 100644
--- a/packages/editor/src/components/post-type-support-check/index.js
+++ b/packages/editor/src/components/post-type-support-check/index.js
@@ -13,13 +13,13 @@ import { store as editorStore } from '../../store';
* A component which renders its own children only if the current editor post
* type supports one of the given `supportKeys` prop.
*
- * @param {Object} props Props.
- * @param {Element} props.children Children to be rendered if post
- * type supports.
- * @param {(string|string[])} props.supportKeys String or string array of keys
- * to test.
+ * @param {Object} props Props.
+ * @param {React.ReactElement} props.children Children to be rendered if post
+ * type supports.
+ * @param {(string|string[])} props.supportKeys String or string array of keys
+ * to test.
*
- * @return {Component} The component to be rendered.
+ * @return {React.ReactElement} The component to be rendered.
*/
function PostTypeSupportCheck( { children, supportKeys } ) {
const postType = useSelect( ( select ) => {
diff --git a/packages/editor/src/components/post-url/check.js b/packages/editor/src/components/post-url/check.js
index 7eb390472bdd7d..a80d829de23221 100644
--- a/packages/editor/src/components/post-url/check.js
+++ b/packages/editor/src/components/post-url/check.js
@@ -12,10 +12,10 @@ import { store as editorStore } from '../../store';
/**
* Check if the post URL is valid and visible.
*
- * @param {Object} props The component props.
- * @param {Element} props.children The child components.
+ * @param {Object} props The component props.
+ * @param {React.ReactElement} props.children The child components.
*
- * @return {Component|null} The child components if the post URL is valid and visible, otherwise null.
+ * @return {React.ReactElement} The child components if the post URL is valid and visible, otherwise null.
*/
export default function PostURLCheck( { children } ) {
const isVisible = useSelect( ( select ) => {
diff --git a/packages/editor/src/components/post-url/index.js b/packages/editor/src/components/post-url/index.js
index f03bdd59752a83..c72ca5825f6fe6 100644
--- a/packages/editor/src/components/post-url/index.js
+++ b/packages/editor/src/components/post-url/index.js
@@ -34,7 +34,7 @@ import { store as editorStore } from '../../store';
*
* @param {Function} onClose Callback function to be executed when the popover is closed.
*
- * @return {Component} The rendered PostURL component.
+ * @return {React.ReactNode} The rendered PostURL component.
*/
export default function PostURL( { onClose } ) {
const {
diff --git a/packages/editor/src/components/post-url/label.js b/packages/editor/src/components/post-url/label.js
index 4f03e2bce0d05f..277cc6cfc715d3 100644
--- a/packages/editor/src/components/post-url/label.js
+++ b/packages/editor/src/components/post-url/label.js
@@ -12,7 +12,7 @@ import { store as editorStore } from '../../store';
/**
* Represents a label component for a post URL.
*
- * @return {Component} The PostURLLabel component.
+ * @return {React.ReactNode} The PostURLLabel component.
*/
export default function PostURLLabel() {
return usePostURLLabel();
diff --git a/packages/editor/src/components/post-url/panel.js b/packages/editor/src/components/post-url/panel.js
index 786a12cb8e6b54..97eaa8ccb77f8d 100644
--- a/packages/editor/src/components/post-url/panel.js
+++ b/packages/editor/src/components/post-url/panel.js
@@ -19,7 +19,7 @@ import { store as editorStore } from '../../store';
/**
* Renders the `PostURLPanel` component.
*
- * @return {JSX.Element} The rendered PostURLPanel component.
+ * @return {React.ReactNode} The rendered PostURLPanel component.
*/
export default function PostURLPanel() {
const { isFrontPage } = useSelect( ( select ) => {
diff --git a/packages/editor/src/components/post-visibility/check.js b/packages/editor/src/components/post-visibility/check.js
index 19a241ae1110ae..ea04a6b739617a 100644
--- a/packages/editor/src/components/post-visibility/check.js
+++ b/packages/editor/src/components/post-visibility/check.js
@@ -15,7 +15,7 @@ import { store as editorStore } from '../../store';
* @param {Object} props The component props.
* @param {Function} props.render Function to render the component.
* Receives an object with a `canEdit` property.
- * @return {JSX.Element} The rendered component.
+ * @return {React.ReactNode} The rendered component.
*/
export default function PostVisibilityCheck( { render } ) {
const canEdit = useSelect( ( select ) => {
diff --git a/packages/editor/src/components/post-visibility/index.js b/packages/editor/src/components/post-visibility/index.js
index e47f2acd664434..3eb0c157c337ca 100644
--- a/packages/editor/src/components/post-visibility/index.js
+++ b/packages/editor/src/components/post-visibility/index.js
@@ -22,7 +22,7 @@ import { store as editorStore } from '../../store';
*
* @param {Object} props The component props.
* @param {Function} props.onClose Function to call when the popover is closed.
- * @return {JSX.Element} The rendered component.
+ * @return {React.ReactNode} The rendered component.
*/
export default function PostVisibility( { onClose } ) {
const instanceId = useInstanceId( PostVisibility );
diff --git a/packages/editor/src/components/provider/index.js b/packages/editor/src/components/provider/index.js
index 6c05e5b58235b3..996e9e68954591 100644
--- a/packages/editor/src/components/provider/index.js
+++ b/packages/editor/src/components/provider/index.js
@@ -411,7 +411,7 @@ export const ExperimentalEditorProvider = withRegistryProvider(
*
* ```
*
- * @return {JSX.Element} The rendered EditorProvider component.
+ * @return {React.ReactNode} The rendered EditorProvider component.
*/
export function EditorProvider( props ) {
return (
diff --git a/packages/editor/src/components/table-of-contents/index.js b/packages/editor/src/components/table-of-contents/index.js
index 6fd83557b13ab7..47de10b66ebdd1 100644
--- a/packages/editor/src/components/table-of-contents/index.js
+++ b/packages/editor/src/components/table-of-contents/index.js
@@ -61,6 +61,6 @@ function TableOfContents(
* @param {boolean} props.repositionDropdown Whether to reposition the dropdown.
* @param {Element.ref} ref The component's ref.
*
- * @return {JSX.Element} The rendered table of contents component.
+ * @return {React.ReactNode} The rendered table of contents component.
*/
export default forwardRef( TableOfContents );
diff --git a/packages/editor/src/components/theme-support-check/index.js b/packages/editor/src/components/theme-support-check/index.js
index 78fbde809a7088..1f29370d32199c 100644
--- a/packages/editor/src/components/theme-support-check/index.js
+++ b/packages/editor/src/components/theme-support-check/index.js
@@ -12,11 +12,11 @@ import { store as editorStore } from '../../store';
/**
* Checks if the current theme supports specific features and renders the children if supported.
*
- * @param {Object} props The component props.
- * @param {Element} props.children The children to render if the theme supports the specified features.
- * @param {string|string[]} props.supportKeys The key(s) of the theme support(s) to check.
+ * @param {Object} props The component props.
+ * @param {React.ReactElement} props.children The children to render if the theme supports the specified features.
+ * @param {string|string[]} props.supportKeys The key(s) of the theme support(s) to check.
*
- * @return {JSX.Element|null} The rendered children if the theme supports the specified features, otherwise null.
+ * @return {React.ReactElement} The rendered children if the theme supports the specified features, otherwise null.
*/
export default function ThemeSupportCheck( { children, supportKeys } ) {
const { postType, themeSupports } = useSelect( ( select ) => {
diff --git a/packages/editor/src/components/time-to-read/index.js b/packages/editor/src/components/time-to-read/index.js
index 5d748abc3049cb..21891273991a2c 100644
--- a/packages/editor/src/components/time-to-read/index.js
+++ b/packages/editor/src/components/time-to-read/index.js
@@ -23,7 +23,7 @@ const AVERAGE_READING_RATE = 189;
/**
* Component for showing Time To Read in Content.
*
- * @return {JSX.Element} The rendered TimeToRead component.
+ * @return {React.ReactNode} The rendered TimeToRead component.
*/
export default function TimeToRead() {
const content = useSelect(
diff --git a/packages/editor/src/components/unsaved-changes-warning/index.js b/packages/editor/src/components/unsaved-changes-warning/index.js
index 49e2b7edf1f293..d04b1f36abcbb3 100644
--- a/packages/editor/src/components/unsaved-changes-warning/index.js
+++ b/packages/editor/src/components/unsaved-changes-warning/index.js
@@ -10,7 +10,7 @@ import { store as coreStore } from '@wordpress/core-data';
* Warns the user if there are unsaved changes before leaving the editor.
* Compatible with Post Editor and Site Editor.
*
- * @return {Component} The component.
+ * @return {React.ReactNode} The component.
*/
export default function UnsavedChangesWarning() {
const { __experimentalGetDirtyEntityRecords } = useSelect( coreStore );
diff --git a/packages/editor/src/components/word-count/index.js b/packages/editor/src/components/word-count/index.js
index aab562b46b89ff..31eb4d6bfd8c35 100644
--- a/packages/editor/src/components/word-count/index.js
+++ b/packages/editor/src/components/word-count/index.js
@@ -13,7 +13,7 @@ import { store as editorStore } from '../../store';
/**
* Renders the word count of the post content.
*
- * @return {JSX.Element|null} The rendered WordCount component.
+ * @return {React.ReactNode} The rendered WordCount component.
*/
export default function WordCount() {
const content = useSelect(
diff --git a/packages/editor/src/store/actions.js b/packages/editor/src/store/actions.js
index 4942e50322e06e..9d0de08718cd2b 100644
--- a/packages/editor/src/store/actions.js
+++ b/packages/editor/src/store/actions.js
@@ -35,9 +35,9 @@ import { unlock } from '../lock-unlock';
* Returns an action generator used in signalling that editor has initialized with
* the specified post object and editor settings.
*
- * @param {Object} post Post object.
- * @param {Object} edits Initial edited attributes object.
- * @param {Array?} template Block Template.
+ * @param {Object} post Post object.
+ * @param {Object} edits Initial edited attributes object.
+ * @param {Array} [template] Block Template.
*/
export const setupEditor =
( post, edits, template ) =>
@@ -157,8 +157,8 @@ export function setEditedPost( postType, postId ) {
* Returns an action object used in signalling that attributes of the post have
* been edited.
*
- * @param {Object} edits Post attributes to edit.
- * @param {Object} options Options for the edit.
+ * @param {Object} edits Post attributes to edit.
+ * @param {Object} [options] Options for the edit.
*
* @example
* ```js
@@ -195,7 +195,7 @@ export const editPost =
/**
* Action for saving the current post in the editor.
*
- * @param {Object} options
+ * @param {Object} [options]
*/
export const savePost =
( options = {} ) =>
@@ -375,7 +375,8 @@ export const trashPost =
* autosaving (e.g. on the Web, the post might be committed to Session
* Storage).
*
- * @param {Object?} options Extra flags to identify the autosave.
+ * @param {Object} [options] Extra flags to identify the autosave.
+ * @param {boolean} [options.local] Whether to perform a local autosave.
*/
export const autosave =
( { local = false, ...options } = {} ) =>
@@ -598,8 +599,8 @@ export function unlockPostAutosaving( lockName ) {
/**
* Returns an action object used to signal that the blocks have been updated.
*
- * @param {Array} blocks Block Array.
- * @param {?Object} options Optional options.
+ * @param {Array} blocks Block Array.
+ * @param {Object} [options] Optional options.
*/
export const resetEditorBlocks =
( blocks, options = {} ) =>
From 21ee975dbc831588cecda74af7a93dedb615448b Mon Sep 17 00:00:00 2001
From: Sukhendu Sekhar Guria
Date: Mon, 25 Nov 2024 15:44:12 +0530
Subject: [PATCH 02/23] Fix: Preserve Display Preview State in File Block
(#67263)
Co-authored-by: Sukhendu2002
Co-authored-by: Mamaduka
Co-authored-by: MadtownLems
---
packages/block-library/src/file/edit.js | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/packages/block-library/src/file/edit.js b/packages/block-library/src/file/edit.js
index 937eb3d28eb192..838b807507d314 100644
--- a/packages/block-library/src/file/edit.js
+++ b/packages/block-library/src/file/edit.js
@@ -128,15 +128,21 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
}
const isPdf = newMedia.url.endsWith( '.pdf' );
+ const pdfAttributes = {
+ displayPreview: isPdf
+ ? attributes.displayPreview ?? true
+ : undefined,
+ previewHeight: isPdf ? attributes.previewHeight ?? 600 : undefined,
+ };
+
setAttributes( {
href: newMedia.url,
fileName: newMedia.title,
textLinkHref: newMedia.url,
id: newMedia.id,
- displayPreview: isPdf ? true : undefined,
- previewHeight: isPdf ? 600 : undefined,
fileId: `wp-block-file--media-${ clientId }`,
blob: undefined,
+ ...pdfAttributes,
} );
setTemporaryURL();
}
From a6a04bebfb96f47df6c1f238c0fe63233d6dd3f5 Mon Sep 17 00:00:00 2001
From: Bernie Reiter <96308+ockham@users.noreply.github.com>
Date: Mon, 25 Nov 2024 11:20:51 +0100
Subject: [PATCH 03/23] Terms: Respect order specified by register_taxonomy()
(#67154)
It is possible to supply a default set of `args` to `register_taxonomy()` which will be used when querying a list of terms -- for example, `orderby` in order to specify how the resulting list of terms should be sorted. This commit makes it so that the list of terms returned by the Terms REST API controller respects that order.
Co-authored-by: ockham
Co-authored-by: jsnajdr
---
backport-changelog/6.8/7848.md | 3 +++
lib/compat/wordpress-6.8/rest-api.php | 29 +++++++++++++++++++++++++++
2 files changed, 32 insertions(+)
create mode 100644 backport-changelog/6.8/7848.md
diff --git a/backport-changelog/6.8/7848.md b/backport-changelog/6.8/7848.md
new file mode 100644
index 00000000000000..84600eb4847cdb
--- /dev/null
+++ b/backport-changelog/6.8/7848.md
@@ -0,0 +1,3 @@
+https://github.com/WordPress/wordpress-develop/pull/7848
+
+* https://github.com/WordPress/gutenberg/pull/67154
diff --git a/lib/compat/wordpress-6.8/rest-api.php b/lib/compat/wordpress-6.8/rest-api.php
index da1b657cda0783..080e4003f57b38 100644
--- a/lib/compat/wordpress-6.8/rest-api.php
+++ b/lib/compat/wordpress-6.8/rest-api.php
@@ -20,3 +20,32 @@ function gutenberg_add_post_type_rendering_mode() {
}
}
add_action( 'rest_api_init', 'gutenberg_add_post_type_rendering_mode' );
+
+// When querying terms for a given taxonomy in the REST API, respect the default
+// query arguments set for that taxonomy upon registration.
+function gutenberg_respect_taxonomy_default_args_in_rest_api( $args ) {
+ // If a `post` argument is provided, the Terms controller will use
+ // `wp_get_object_terms`, which respects the default query arguments,
+ // so we don't need to do anything.
+ if ( ! empty( $args['post'] ) ) {
+ return $args;
+ }
+
+ $t = get_taxonomy( $args['taxonomy'] );
+ if ( isset( $t->args ) && is_array( $t->args ) ) {
+ $args = array_merge( $args, $t->args );
+ }
+ return $args;
+}
+add_action(
+ 'registered_taxonomy',
+ function ( $taxonomy ) {
+ add_filter( "rest_{$taxonomy}_query", 'gutenberg_respect_taxonomy_default_args_in_rest_api' );
+ }
+);
+add_action(
+ 'unregistered_taxonomy',
+ function ( $taxonomy ) {
+ remove_filter( "rest_{$taxonomy}_query", 'gutenberg_respect_taxonomy_default_args_in_rest_api' );
+ }
+);
From 814bb4e380293ab79704682a067ff980d24c6a8c Mon Sep 17 00:00:00 2001
From: George Mamadashvili
Date: Mon, 25 Nov 2024 14:45:29 +0400
Subject: [PATCH 04/23] Editor: Update focus return handler for the Featured
Image (#67236)
Co-authored-by: Mamaduka
Co-authored-by: afercia
---
.../components/post-featured-image/index.js | 30 +++++++++----------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/packages/editor/src/components/post-featured-image/index.js b/packages/editor/src/components/post-featured-image/index.js
index 46a194f311a5e7..acf366506cc41e 100644
--- a/packages/editor/src/components/post-featured-image/index.js
+++ b/packages/editor/src/components/post-featured-image/index.js
@@ -18,7 +18,7 @@ import {
Notice,
} from '@wordpress/components';
import { isBlobURL } from '@wordpress/blob';
-import { useState, useRef, useEffect } from '@wordpress/element';
+import { useState, useRef } from '@wordpress/element';
import { compose } from '@wordpress/compose';
import { useSelect, withDispatch, withSelect } from '@wordpress/data';
import {
@@ -102,17 +102,10 @@ function PostFeaturedImage( {
noticeOperations,
isRequestingFeaturedImageMedia,
} ) {
- const toggleRef = useRef();
+ const returnsFocusRef = useRef( false );
const [ isLoading, setIsLoading ] = useState( false );
const { getSettings } = useSelect( blockEditorStore );
const { mediaSourceUrl } = getMediaDetails( media, currentPostId );
- const toggleFocusTimerRef = useRef();
-
- useEffect( () => {
- return () => {
- clearTimeout( toggleFocusTimerRef.current );
- };
- }, [] );
function onDropFiles( filesList ) {
getSettings().mediaUpload( {
@@ -164,6 +157,13 @@ function PostFeaturedImage( {
);
}
+ function returnFocus( node ) {
+ if ( returnsFocusRef.current && node ) {
+ node.focus();
+ returnsFocusRef.current = false;
+ }
+ }
+
const isMissingMedia =
! isRequestingFeaturedImageMedia && !! featuredImageId && ! media;
@@ -203,7 +203,7 @@ function PostFeaturedImage( {
) : (
+
+
+
+ comment
+
+
+
+
🍒
@@ -289,6 +304,21 @@ exports[`recordToDom should preserve emoji in formatting 1`] = `
+
+
+
+ /funky
+
+
+
+
test test
diff --git a/packages/rich-text/src/test/helpers/index.js b/packages/rich-text/src/test/helpers/index.js
index f246ab956db3a7..7658ede7e37737 100644
--- a/packages/rich-text/src/test/helpers/index.js
+++ b/packages/rich-text/src/test/helpers/index.js
@@ -551,6 +551,58 @@ export const spec = [
text: '\ufffc',
},
},
+ {
+ description: 'should preserve comments',
+ html: '',
+ createRange: ( element ) => ( {
+ startOffset: 0,
+ startContainer: element,
+ endOffset: 1,
+ endContainer: element,
+ } ),
+ startPath: [ 0, 0 ],
+ endPath: [ 2, 0 ],
+ record: {
+ start: 0,
+ end: 1,
+ formats: [ , ],
+ replacements: [
+ {
+ attributes: {
+ 'data-rich-text-comment': 'comment',
+ },
+ type: '#comment',
+ },
+ ],
+ text: '\ufffc',
+ },
+ },
+ {
+ description: 'should preserve funky comments',
+ html: '/funky>',
+ createRange: ( element ) => ( {
+ startOffset: 0,
+ startContainer: element,
+ endOffset: 1,
+ endContainer: element,
+ } ),
+ startPath: [ 0, 0 ],
+ endPath: [ 2, 0 ],
+ record: {
+ start: 0,
+ end: 1,
+ formats: [ , ],
+ replacements: [
+ {
+ attributes: {
+ 'data-rich-text-comment': '/funky',
+ },
+ type: '#comment',
+ },
+ ],
+ text: '\ufffc',
+ },
+ },
];
export const specWithRegistration = [
diff --git a/packages/rich-text/src/to-dom.js b/packages/rich-text/src/to-dom.js
index e7288e4ba16332..ac8308c7274b58 100644
--- a/packages/rich-text/src/to-dom.js
+++ b/packages/rich-text/src/to-dom.js
@@ -68,10 +68,16 @@ function append( element, child ) {
const { type, attributes } = child;
if ( type ) {
- child = element.ownerDocument.createElement( type );
+ if ( type === '#comment' ) {
+ child = element.ownerDocument.createComment(
+ attributes[ 'data-rich-text-comment' ]
+ );
+ } else {
+ child = element.ownerDocument.createElement( type );
- for ( const key in attributes ) {
- child.setAttribute( key, attributes[ key ] );
+ for ( const key in attributes ) {
+ child.setAttribute( key, attributes[ key ] );
+ }
}
}
diff --git a/packages/rich-text/src/to-html-string.js b/packages/rich-text/src/to-html-string.js
index f770dfdefc128a..a4c12b4c47f00d 100644
--- a/packages/rich-text/src/to-html-string.js
+++ b/packages/rich-text/src/to-html-string.js
@@ -88,6 +88,15 @@ function remove( object ) {
}
function createElementHTML( { type, attributes, object, children } ) {
+ if ( type === '#comment' ) {
+ // We can't restore the original comment delimiters, because once parsed
+ // into DOM nodes, we don't have the information. But in the future we
+ // could allow comment handlers to specify custom delimiters, for
+ // example `{comment-content}>` for Bits, where `comment-content`
+ // would be `/{bit-name}` or `__{translatable-string}` (TBD).
+ return ``;
+ }
+
let attributeString = '';
for ( const key in attributes ) {
diff --git a/packages/rich-text/src/to-tree.js b/packages/rich-text/src/to-tree.js
index 46671c951bc09d..0e3caad4f70c83 100644
--- a/packages/rich-text/src/to-tree.js
+++ b/packages/rich-text/src/to-tree.js
@@ -229,7 +229,20 @@ export function toTree( {
const { type, attributes, innerHTML } = replacement;
const formatType = getFormatType( type );
- if ( ! isEditableTree && type === 'script' ) {
+ if ( isEditableTree && type === '#comment' ) {
+ pointer = append( getParent( pointer ), {
+ type: 'span',
+ attributes: {
+ contenteditable: 'false',
+ 'data-rich-text-comment':
+ attributes[ 'data-rich-text-comment' ],
+ },
+ } );
+ append(
+ append( pointer, { type: 'span' } ),
+ attributes[ 'data-rich-text-comment' ].trim()
+ );
+ } else if ( ! isEditableTree && type === 'script' ) {
pointer = append(
getParent( pointer ),
fromFormat( {
From 2215a045c3e3fb9c1bd65abbf1c2a53b2887c513 Mon Sep 17 00:00:00 2001
From: Alex Lende
Date: Mon, 25 Nov 2024 11:20:06 -0600
Subject: [PATCH 11/23] Zoom in/out to correct location (#67126)
Co-authored-by: jeryj
Co-authored-by: ajlende
Co-authored-by: stokesman
Co-authored-by: ndiego
Co-authored-by: richtabor
Co-authored-by: draganescu
Co-authored-by: colorful-tones
Co-authored-by: getdave
Co-authored-by: priethor
Co-authored-by: annezazu
Co-authored-by: ellatrix
Co-authored-by: cbravobernal
---
.../src/components/iframe/content.scss | 19 +-
.../src/components/iframe/index.js | 231 ++++++++++++++----
test/e2e/specs/site-editor/zoom-out.spec.js | 168 +++++++++++++
3 files changed, 371 insertions(+), 47 deletions(-)
diff --git a/packages/block-editor/src/components/iframe/content.scss b/packages/block-editor/src/components/iframe/content.scss
index 596c177eab2f32..5e390800719949 100644
--- a/packages/block-editor/src/components/iframe/content.scss
+++ b/packages/block-editor/src/components/iframe/content.scss
@@ -7,13 +7,26 @@
// We don't want to animate the transform of the translateX because it is used
// to "center" the canvas. Leaving it on causes the canvas to slide around in
// odd ways.
- @include editor-canvas-resize-animation(transform 0s, scale 0s, padding 0s);
+ @include editor-canvas-resize-animation( transform 0s, scale 0s, padding 0s, translate 0s);
&.zoom-out-animation {
- // we only want to animate the scaling when entering zoom out. When sidebars
+ $scroll-top: var(--wp-block-editor-iframe-zoom-out-scroll-top, 0);
+ $scroll-top-next: var(--wp-block-editor-iframe-zoom-out-scroll-top-next, 0);
+
+ position: fixed;
+ left: 0;
+ right: 0;
+ top: calc(-1 * #{$scroll-top});
+ bottom: 0;
+ translate: 0 calc(#{$scroll-top} - #{$scroll-top-next});
+ // Force preserving a scrollbar gutter as scrollbar-gutter isn't supported in all browsers yet,
+ // and removing the scrollbar causes the content to shift.
+ overflow-y: scroll;
+
+ // We only want to animate the scaling when entering zoom out. When sidebars
// are toggled, the resizing of the iframe handles scaling the canvas as well,
// and the doubled animations cause very odd animations.
- @include editor-canvas-resize-animation(transform 0s);
+ @include editor-canvas-resize-animation( transform 0s, top 0s, bottom 0s, right 0s, left 0s );
}
}
diff --git a/packages/block-editor/src/components/iframe/index.js b/packages/block-editor/src/components/iframe/index.js
index 76d2e09dfb7a30..f8b7c25084e38d 100644
--- a/packages/block-editor/src/components/iframe/index.js
+++ b/packages/block-editor/src/components/iframe/index.js
@@ -20,6 +20,7 @@ import {
useMergeRefs,
useRefEffect,
useDisabled,
+ useReducedMotion,
} from '@wordpress/compose';
import { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
@@ -121,6 +122,7 @@ function Iframe( {
};
}, [] );
const { styles = '', scripts = '' } = resolvedAssets;
+ /** @type {[Document, import('react').Dispatch]} */
const [ iframeDocument, setIframeDocument ] = useState();
const initialContainerWidthRef = useRef( 0 );
const [ bodyClasses, setBodyClasses ] = useState( [] );
@@ -130,6 +132,7 @@ function Iframe( {
useResizeObserver();
const [ containerResizeListener, { width: containerWidth } ] =
useResizeObserver();
+ const prefersReducedMotion = useReducedMotion();
const setRef = useRefEffect( ( node ) => {
node._load = () => {
@@ -268,6 +271,19 @@ function Iframe( {
containerWidth
);
+ const frameSizeValue = parseInt( frameSize );
+
+ const maxWidth = 750;
+ const scaleValue =
+ scale === 'auto-scaled'
+ ? ( Math.min( containerWidth, maxWidth ) - frameSizeValue * 2 ) /
+ scaleContainerWidth
+ : scale;
+
+ const prevScaleRef = useRef( scaleValue );
+ const prevFrameSizeRef = useRef( frameSizeValue );
+ const prevClientHeightRef = useRef( /* Initialized in the useEffect. */ );
+
const disabledRef = useDisabled( { isDisabled: ! readonly } );
const bodyRef = useMergeRefs( [
useBubbleEvents( iframeDocument ),
@@ -320,47 +336,176 @@ function Iframe( {
useEffect( () => cleanup, [ cleanup ] );
- const zoomOutAnimationClassnameRef = useRef( null );
-
- // Toggle zoom out CSS Classes only when zoom out mode changes. We could add these into the useEffect
- // that controls settings the CSS variables, but then we would need to do more work to ensure we're
- // only toggling these when the zoom out mode changes, as that useEffect is also triggered by a large
- // number of dependencies.
useEffect( () => {
- if ( ! iframeDocument || ! isZoomedOut ) {
+ if (
+ ! iframeDocument ||
+ // HACK: Checking if isZoomedOut differs from prevIsZoomedOut here
+ // instead of the dependency array to appease the linter.
+ ( scaleValue === 1 ) === ( prevScaleRef.current === 1 )
+ ) {
return;
}
- const handleZoomOutAnimationClassname = () => {
- clearTimeout( zoomOutAnimationClassnameRef.current );
+ // Unscaled height of the current iframe container.
+ const clientHeight = iframeDocument.documentElement.clientHeight;
+
+ // Scaled height of the current iframe content.
+ const scrollHeight = iframeDocument.documentElement.scrollHeight;
+
+ // Previous scale value.
+ const prevScale = prevScaleRef.current;
+
+ // Unscaled size of the previous padding around the iframe content.
+ const prevFrameSize = prevFrameSizeRef.current;
+
+ // Unscaled height of the previous iframe container.
+ const prevClientHeight = prevClientHeightRef.current ?? clientHeight;
+
+ // We can't trust the set value from contentHeight, as it was measured
+ // before the zoom out mode was changed. After zoom out mode is changed,
+ // appenders may appear or disappear, so we need to get the height from
+ // the iframe at this point when we're about to animate the zoom out.
+ // The iframe scrollTop, scrollHeight, and clientHeight will all be
+ // accurate. The client height also does change when the zoom out mode
+ // is toggled, as the bottom bar about selecting the template is
+ // added/removed when toggling zoom out mode.
+ const scrollTop = iframeDocument.documentElement.scrollTop;
+
+ // Step 0: Start with the current scrollTop.
+ let scrollTopNext = scrollTop;
+
+ // Step 1: Undo the effects of the previous scale and frame around the
+ // midpoint of the visible area.
+ scrollTopNext =
+ ( scrollTopNext + prevClientHeight / 2 - prevFrameSize ) /
+ prevScale -
+ prevClientHeight / 2;
+
+ // Step 2: Apply the new scale and frame around the midpoint of the
+ // visible area.
+ scrollTopNext =
+ ( scrollTopNext + clientHeight / 2 ) * scaleValue +
+ frameSizeValue -
+ clientHeight / 2;
+
+ // Step 3: Handle an edge case so that you scroll to the top of the
+ // iframe if the top of the iframe content is visible in the container.
+ // The same edge case for the bottom is skipped because changing content
+ // makes calculating it impossible.
+ scrollTopNext = scrollTop <= prevFrameSize ? 0 : scrollTopNext;
+
+ // This is the scrollTop value if you are scrolled to the bottom of the
+ // iframe. We can't just let the browser handle it because we need to
+ // animate the scaling.
+ const maxScrollTop =
+ scrollHeight * ( scaleValue / prevScale ) +
+ frameSizeValue * 2 -
+ clientHeight;
+
+ // Step 4: Clamp the scrollTopNext between the minimum and maximum
+ // possible scrollTop positions. Round the value to avoid subpixel
+ // truncation by the browser which sometimes causes a 1px error.
+ scrollTopNext = Math.round(
+ Math.min(
+ Math.max( 0, scrollTopNext ),
+ Math.max( 0, maxScrollTop )
+ )
+ );
- iframeDocument.documentElement.classList.add(
+ iframeDocument.documentElement.style.setProperty(
+ '--wp-block-editor-iframe-zoom-out-scroll-top',
+ `${ scrollTop }px`
+ );
+
+ iframeDocument.documentElement.style.setProperty(
+ '--wp-block-editor-iframe-zoom-out-scroll-top-next',
+ `${ scrollTopNext }px`
+ );
+
+ iframeDocument.documentElement.classList.add( 'zoom-out-animation' );
+
+ function onZoomOutTransitionEnd() {
+ // Remove the position fixed for the animation.
+ iframeDocument.documentElement.classList.remove(
'zoom-out-animation'
);
- zoomOutAnimationClassnameRef.current = setTimeout( () => {
- iframeDocument.documentElement.classList.remove(
- 'zoom-out-animation'
+ // Update previous values.
+ prevClientHeightRef.current = clientHeight;
+ prevFrameSizeRef.current = frameSizeValue;
+ prevScaleRef.current = scaleValue;
+
+ // Set the final scroll position that was just animated to.
+ // Disable reason: Eslint isn't smart enough to know that this is a
+ // DOM element. https://github.com/facebook/react/issues/31483
+ // eslint-disable-next-line react-compiler/react-compiler
+ iframeDocument.documentElement.scrollTop = scrollTopNext;
+ }
+
+ let raf;
+ if ( prefersReducedMotion ) {
+ // Hack: Wait for the window values to recalculate.
+ raf = iframeDocument.defaultView.requestAnimationFrame(
+ onZoomOutTransitionEnd
+ );
+ } else {
+ iframeDocument.documentElement.addEventListener(
+ 'transitionend',
+ onZoomOutTransitionEnd,
+ { once: true }
+ );
+ }
+
+ return () => {
+ iframeDocument.documentElement.style.removeProperty(
+ '--wp-block-editor-iframe-zoom-out-scroll-top'
+ );
+ iframeDocument.documentElement.style.removeProperty(
+ '--wp-block-editor-iframe-zoom-out-scroll-top-next'
+ );
+ iframeDocument.documentElement.classList.remove(
+ 'zoom-out-animation'
+ );
+ if ( prefersReducedMotion ) {
+ iframeDocument.defaultView.cancelAnimationFrame( raf );
+ } else {
+ iframeDocument.documentElement.removeEventListener(
+ 'transitionend',
+ onZoomOutTransitionEnd
);
- }, 400 ); // 400ms should match the animation speed used in components/iframe/content.scss
+ }
};
+ }, [ iframeDocument, scaleValue, frameSizeValue, prefersReducedMotion ] );
- handleZoomOutAnimationClassname();
- iframeDocument.documentElement.classList.add( 'is-zoomed-out' );
+ // Toggle zoom out CSS Classes only when zoom out mode changes. We could add these into the useEffect
+ // that controls settings the CSS variables, but then we would need to do more work to ensure we're
+ // only toggling these when the zoom out mode changes, as that useEffect is also triggered by a large
+ // number of dependencies.
+ useEffect( () => {
+ if ( ! iframeDocument ) {
+ return;
+ }
- return () => {
- handleZoomOutAnimationClassname();
+ if ( isZoomedOut ) {
+ iframeDocument.documentElement.classList.add( 'is-zoomed-out' );
+ } else {
+ // HACK: Since we can't remove this in the cleanup, we need to do it here.
iframeDocument.documentElement.classList.remove( 'is-zoomed-out' );
+ }
+
+ return () => {
+ // HACK: Skipping cleanup because it causes issues with the zoom out
+ // animation. More refactoring is needed to fix this properly.
+ // iframeDocument.documentElement.classList.remove( 'is-zoomed-out' );
};
}, [ iframeDocument, isZoomedOut ] );
// Calculate the scaling and CSS variables for the zoom out canvas
useEffect( () => {
- if ( ! iframeDocument || ! isZoomedOut ) {
+ if ( ! iframeDocument ) {
return;
}
- const maxWidth = 750;
// Note: When we initialize the zoom out when the canvas is smaller (sidebars open),
// initialContainerWidthRef will be smaller than the full page, and reflow will happen
// when the canvas area becomes larger due to sidebars closing. This is a known but
@@ -371,11 +516,7 @@ function Iframe( {
// but calc( 100px / 2px ) is not.
iframeDocument.documentElement.style.setProperty(
'--wp-block-editor-iframe-zoom-out-scale',
- scale === 'auto-scaled'
- ? ( Math.min( containerWidth, maxWidth ) -
- parseInt( frameSize ) * 2 ) /
- scaleContainerWidth
- : scale
+ scaleValue
);
// frameSize has to be a px value for the scaling and frame size to be computed correctly.
@@ -401,27 +542,29 @@ function Iframe( {
);
return () => {
- iframeDocument.documentElement.style.removeProperty(
- '--wp-block-editor-iframe-zoom-out-scale'
- );
- iframeDocument.documentElement.style.removeProperty(
- '--wp-block-editor-iframe-zoom-out-frame-size'
- );
- iframeDocument.documentElement.style.removeProperty(
- '--wp-block-editor-iframe-zoom-out-content-height'
- );
- iframeDocument.documentElement.style.removeProperty(
- '--wp-block-editor-iframe-zoom-out-inner-height'
- );
- iframeDocument.documentElement.style.removeProperty(
- '--wp-block-editor-iframe-zoom-out-container-width'
- );
- iframeDocument.documentElement.style.removeProperty(
- '--wp-block-editor-iframe-zoom-out-scale-container-width'
- );
+ // HACK: Skipping cleanup because it causes issues with the zoom out
+ // animation. More refactoring is needed to fix this properly.
+ // iframeDocument.documentElement.style.removeProperty(
+ // '--wp-block-editor-iframe-zoom-out-scale'
+ // );
+ // iframeDocument.documentElement.style.removeProperty(
+ // '--wp-block-editor-iframe-zoom-out-frame-size'
+ // );
+ // iframeDocument.documentElement.style.removeProperty(
+ // '--wp-block-editor-iframe-zoom-out-content-height'
+ // );
+ // iframeDocument.documentElement.style.removeProperty(
+ // '--wp-block-editor-iframe-zoom-out-inner-height'
+ // );
+ // iframeDocument.documentElement.style.removeProperty(
+ // '--wp-block-editor-iframe-zoom-out-container-width'
+ // );
+ // iframeDocument.documentElement.style.removeProperty(
+ // '--wp-block-editor-iframe-zoom-out-scale-container-width'
+ // );
};
}, [
- scale,
+ scaleValue,
frameSize,
iframeDocument,
iframeWindowInnerHeight,
diff --git a/test/e2e/specs/site-editor/zoom-out.spec.js b/test/e2e/specs/site-editor/zoom-out.spec.js
index 464bd4a4a4efad..e698a94b7cf0dc 100644
--- a/test/e2e/specs/site-editor/zoom-out.spec.js
+++ b/test/e2e/specs/site-editor/zoom-out.spec.js
@@ -3,6 +3,63 @@
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );
+const EDITOR_ZOOM_OUT_CONTENT = `
+
+
+
First Section Start
+
+
+
+
First Section Center
+
+
+
+
First Section End
+
+
+
+
+
+
Second Section Start
+
+
+
+
Second Section Center
+
+
+
+
Second Section End
+
+
+
+
+
+
Third Section Start
+
+
+
+
Third Section Center
+
+
+
+
Third Section End
+
+
+
+
+
+
Fourth Section Start
+
+
+
+
Fourth Section Center
+
+
+
+
Fourth Section End
+
+`;
+
test.describe( 'Zoom Out', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'twentytwentyfour' );
@@ -47,4 +104,115 @@ test.describe( 'Zoom Out', () => {
expect( htmlRect.y + paddingTop ).toBeGreaterThan( iframeRect.y );
expect( htmlRect.x ).toBeGreaterThan( iframeRect.x );
} );
+
+ test( 'Toggling zoom state should keep content centered', async ( {
+ page,
+ editor,
+ } ) => {
+ // Add some patterns into the page.
+ await editor.setContent( EDITOR_ZOOM_OUT_CONTENT );
+ // Find the scroll container element
+ await page.evaluate( () => {
+ const { activeElement } =
+ document.activeElement?.contentDocument ?? document;
+ window.scrollContainer =
+ window.wp.dom.getScrollContainer( activeElement );
+ return window.scrollContainer;
+ } );
+
+ // Test: Test from top of page (scrollTop 0)
+ // Enter Zoom Out
+ await page.getByRole( 'button', { name: 'Zoom Out' } ).click();
+
+ const scrollTopZoomed = await page.evaluate( () => {
+ return window.scrollContainer.scrollTop;
+ } );
+
+ expect( scrollTopZoomed ).toBe( 0 );
+
+ // Exit Zoom Out
+ await page.getByRole( 'button', { name: 'Zoom Out' } ).click();
+
+ const scrollTopNoZoom = await page.evaluate( () => {
+ return window.scrollContainer.scrollTop;
+ } );
+
+ expect( scrollTopNoZoom ).toBe( 0 );
+
+ // Test: Should center the scroll position when zooming out/in
+ const firstSectionEnd = editor.canvas.locator(
+ 'text=First Section End'
+ );
+ const secondSectionStart = editor.canvas.locator(
+ 'text=Second Section Start'
+ );
+ const secondSectionCenter = editor.canvas.locator(
+ 'text=Second Section Center'
+ );
+ const secondSectionEnd = editor.canvas.locator(
+ 'text=Second Section End'
+ );
+ const thirdSectionStart = editor.canvas.locator(
+ 'text=Third Section Start'
+ );
+ const thirdSectionCenter = editor.canvas.locator(
+ 'text=Third Section Center'
+ );
+ const thirdSectionEnd = editor.canvas.locator(
+ 'text=Third Section End'
+ );
+ const fourthSectionStart = editor.canvas.locator(
+ 'text=Fourth Section Start'
+ );
+
+ // Test for second section
+ // Playwright scrolls it to the center of the viewport, so this is what we scroll to.
+ await secondSectionCenter.scrollIntoViewIfNeeded();
+
+ // Because the text is spread with a group height of 100vh, they should both be visible.
+ await expect( firstSectionEnd ).not.toBeInViewport();
+ await expect( secondSectionStart ).toBeInViewport();
+ await expect( secondSectionEnd ).toBeInViewport();
+ await expect( thirdSectionStart ).not.toBeInViewport();
+
+ // After zooming, if we zoomed out with the correct central point, they should both still be visible when toggling zoom out state
+ // Enter Zoom Out
+ await page.getByRole( 'button', { name: 'Zoom Out' } ).click();
+ await expect( firstSectionEnd ).toBeInViewport();
+ await expect( secondSectionStart ).toBeInViewport();
+ await expect( secondSectionEnd ).toBeInViewport();
+ await expect( thirdSectionStart ).toBeInViewport();
+
+ // Exit Zoom Out
+ await page.getByRole( 'button', { name: 'Zoom Out' } ).click();
+ await expect( firstSectionEnd ).not.toBeInViewport();
+ await expect( secondSectionStart ).toBeInViewport();
+ await expect( secondSectionEnd ).toBeInViewport();
+ await expect( thirdSectionStart ).not.toBeInViewport();
+
+ // Test for third section
+ // Playwright scrolls it to the center of the viewport, so this is what we scroll to.
+ await thirdSectionCenter.scrollIntoViewIfNeeded();
+
+ // Because the text is spread with a group height of 100vh, they should both be visible.
+ await expect( secondSectionEnd ).not.toBeInViewport();
+ await expect( thirdSectionStart ).toBeInViewport();
+ await expect( thirdSectionEnd ).toBeInViewport();
+ await expect( fourthSectionStart ).not.toBeInViewport();
+
+ // After zooming, if we zoomed out with the correct central point, they should both still be visible when toggling zoom out state
+ // Enter Zoom Out
+ await page.getByRole( 'button', { name: 'Zoom Out' } ).click();
+ await expect( secondSectionEnd ).toBeInViewport();
+ await expect( thirdSectionStart ).toBeInViewport();
+ await expect( thirdSectionEnd ).toBeInViewport();
+ await expect( fourthSectionStart ).toBeInViewport();
+
+ // Exit Zoom Out
+ await page.getByRole( 'button', { name: 'Zoom Out' } ).click();
+ await expect( secondSectionEnd ).not.toBeInViewport();
+ await expect( thirdSectionStart ).toBeInViewport();
+ await expect( thirdSectionEnd ).toBeInViewport();
+ await expect( fourthSectionStart ).not.toBeInViewport();
+ } );
} );
From 98b3ec03395836887ba3327cf9a16b279296b6c4 Mon Sep 17 00:00:00 2001
From: Lena Morita
Date: Tue, 26 Nov 2024 03:07:57 +0900
Subject: [PATCH 12/23] BorderBoxControl: Suppress redundant warnings for
deprecated 36px size (#67213)
* BorderControl: Add support for warning suppression
* BorderBoxControl: Suppress redundant warnings for deprecated 36px size
* Add changelog
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: tyxla
---
packages/components/CHANGELOG.md | 1 +
.../border-box-control-split-controls/component.tsx | 1 +
.../border-box-control/border-box-control/component.tsx | 1 +
.../components/src/border-control/border-control/hook.ts | 2 ++
packages/components/src/border-control/types.ts | 7 +++++++
5 files changed, 12 insertions(+)
diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md
index 29e746c905f8d4..ad7896f99f570e 100644
--- a/packages/components/CHANGELOG.md
+++ b/packages/components/CHANGELOG.md
@@ -38,6 +38,7 @@
- `SlotFill`: fix dependencies of `Fill` registration effects ([#67071](https://github.com/WordPress/gutenberg/pull/67071)).
- `SlotFill`: rewrite the `Slot` component from class component to functional ([#67153](https://github.com/WordPress/gutenberg/pull/67153)).
- `Menu.ItemHelpText`: Fix text wrapping to prevent unintended word breaks ([#67011](https://github.com/WordPress/gutenberg/pull/67011)).
+- `BorderBoxControl`: Suppress redundant warnings for deprecated 36px size ([#67213](https://github.com/WordPress/gutenberg/pull/67213)).
## 28.12.0 (2024-11-16)
diff --git a/packages/components/src/border-box-control/border-box-control-split-controls/component.tsx b/packages/components/src/border-box-control/border-box-control-split-controls/component.tsx
index 8f125cdb8f9261..0c887ab5f701c3 100644
--- a/packages/components/src/border-box-control/border-box-control-split-controls/component.tsx
+++ b/packages/components/src/border-box-control/border-box-control-split-controls/component.tsx
@@ -67,6 +67,7 @@ const BorderBoxControlSplitControls = (
isCompact: true,
__experimentalIsRenderedInSidebar,
size,
+ __shouldNotWarnDeprecated36pxSize: true,
};
const mergedRef = useMergeRefs( [ setPopoverAnchor, forwardedRef ] );
diff --git a/packages/components/src/border-box-control/border-box-control/component.tsx b/packages/components/src/border-box-control/border-box-control/component.tsx
index d2d77adc69eb89..0e84c7b56ee483 100644
--- a/packages/components/src/border-box-control/border-box-control/component.tsx
+++ b/packages/components/src/border-box-control/border-box-control/component.tsx
@@ -118,6 +118,7 @@ const UnconnectedBorderBoxControl = (
__experimentalIsRenderedInSidebar={
__experimentalIsRenderedInSidebar
}
+ __shouldNotWarnDeprecated36pxSize
size={ size }
/>
) : (
diff --git a/packages/components/src/border-control/border-control/hook.ts b/packages/components/src/border-control/border-control/hook.ts
index 67af7ce42416c3..9b0f064c51921f 100644
--- a/packages/components/src/border-control/border-control/hook.ts
+++ b/packages/components/src/border-control/border-control/hook.ts
@@ -38,6 +38,7 @@ export function useBorderControl(
width,
__experimentalIsRenderedInSidebar = false,
__next40pxDefaultSize,
+ __shouldNotWarnDeprecated36pxSize,
...otherProps
} = useContextSystem( props, 'BorderControl' );
@@ -45,6 +46,7 @@ export function useBorderControl(
componentName: 'BorderControl',
__next40pxDefaultSize,
size,
+ __shouldNotWarnDeprecated36pxSize,
} );
const computedSize =
diff --git a/packages/components/src/border-control/types.ts b/packages/components/src/border-control/types.ts
index 8ab614907684d2..ecd3f67c9be08d 100644
--- a/packages/components/src/border-control/types.ts
+++ b/packages/components/src/border-control/types.ts
@@ -116,6 +116,13 @@ export type BorderControlProps = ColorProps &
* @default false
*/
__next40pxDefaultSize?: boolean;
+ /**
+ * Do not throw a warning for the deprecated 36px default size.
+ * For internal components of other components that already throw the warning.
+ *
+ * @ignore
+ */
+ __shouldNotWarnDeprecated36pxSize?: boolean;
};
export type DropdownProps = ColorProps &
From 338161387c660ac3b16eba9aa973a066d8db0aa4 Mon Sep 17 00:00:00 2001
From: Vipul Gupta <55375170+vipul0425@users.noreply.github.com>
Date: Tue, 26 Nov 2024 03:08:03 +0530
Subject: [PATCH 13/23] Feat: Adds the deprecation warning for 36px default
size in range control. (#66721)
* feat: Adds the deprecation warning for range control.
* docs: Adds deprecation changelog.
* feat: Suppress the redundant warnings.
* refactor: Supress redundant warnings.
---------
Co-authored-by: vipul0425
Co-authored-by: mirka <0mirka00@git.wordpress.org>
---
packages/components/CHANGELOG.md | 1 +
.../src/border-control/border-control/component.tsx | 1 +
.../components/src/box-control/all-input-control.tsx | 1 +
.../src/box-control/axial-input-controls.tsx | 1 +
.../components/src/box-control/input-controls.tsx | 1 +
packages/components/src/font-size-picker/index.tsx | 1 +
packages/components/src/range-control/README.md | 7 ++++---
packages/components/src/range-control/index.tsx | 11 +++++++++++
.../src/range-control/stories/index.story.tsx | 7 +++++++
packages/components/src/range-control/test/index.tsx | 8 +++++++-
packages/components/src/range-control/types.ts | 7 +++++++
11 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md
index ad7896f99f570e..9f547859fa5a99 100644
--- a/packages/components/CHANGELOG.md
+++ b/packages/components/CHANGELOG.md
@@ -9,6 +9,7 @@
- `FontSizePicker`: Deprecate 36px default size ([#66920](https://github.com/WordPress/gutenberg/pull/66920)).
- `ComboboxControl`: Deprecate 36px default size ([#66900](https://github.com/WordPress/gutenberg/pull/66900)).
- `ToggleGroupControl`: Deprecate 36px default size ([#66747](https://github.com/WordPress/gutenberg/pull/66747)).
+- `RangeControl`: Deprecate 36px default size ([#66721](https://github.com/WordPress/gutenberg/pull/66721)).
### Bug Fixes
diff --git a/packages/components/src/border-control/border-control/component.tsx b/packages/components/src/border-control/border-control/component.tsx
index 31eeb166a2d60f..2ba338c2bb30cb 100644
--- a/packages/components/src/border-control/border-control/component.tsx
+++ b/packages/components/src/border-control/border-control/component.tsx
@@ -122,6 +122,7 @@ const UnconnectedBorderControl = (
value={ widthValue || undefined }
withInputField={ false }
__next40pxDefaultSize={ __next40pxDefaultSize }
+ __shouldNotWarnDeprecated36pxSize
/>
) }
diff --git a/packages/components/src/box-control/all-input-control.tsx b/packages/components/src/box-control/all-input-control.tsx
index e9166ff7f692e8..057cf3c15d8c38 100644
--- a/packages/components/src/box-control/all-input-control.tsx
+++ b/packages/components/src/box-control/all-input-control.tsx
@@ -91,6 +91,7 @@ export default function AllInputControl( {
{
const [ columns, setColumns ] = useState( 2 );
- return(
+ return (
setColumns( value ) }
@@ -153,7 +154,6 @@ Disables the `input`, preventing new values from being applied.
- Required: No
- Platform: Web
-
### `help`: `string|Element`
If this property is added, a help text will be generated using help property as the content.
@@ -165,7 +165,7 @@ If this property is added, a help text will be generated using help property as
Provides control over whether the label will only be visible to screen readers.
-- Required: No
+- Required: No
### `icon`: `string`
@@ -334,6 +334,7 @@ The minimum amount by which `value` changes. It is also a factor in validation a
- Required: No
- Platform: Web
+
### `trackColor`: `CSSProperties[ 'color' ]`
CSS color string to customize the track element's background.
diff --git a/packages/components/src/range-control/index.tsx b/packages/components/src/range-control/index.tsx
index c9fbdc0055c855..916571c3ee0e05 100644
--- a/packages/components/src/range-control/index.tsx
+++ b/packages/components/src/range-control/index.tsx
@@ -38,6 +38,7 @@ import {
import type { RangeControlProps } from './types';
import type { WordPressComponentProps } from '../context';
import { space } from '../utils/space';
+import { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';
const noop = () => {};
@@ -96,6 +97,7 @@ function UnforwardedRangeControl(
trackColor,
value: valueProp,
withInputField = true,
+ __shouldNotWarnDeprecated36pxSize,
...otherProps
} = props;
@@ -229,6 +231,14 @@ function UnforwardedRangeControl(
[ isRTL() ? 'right' : 'left' ]: fillValueOffset,
};
+ // Add default size deprecation warning.
+ maybeWarnDeprecated36pxSize( {
+ componentName: 'RangeControl',
+ __next40pxDefaultSize,
+ size: undefined,
+ __shouldNotWarnDeprecated36pxSize,
+ } );
+
return (
= ( { onChange, ...args } ) => {
export const Default: StoryFn< typeof RangeControl > = Template.bind( {} );
Default.args = {
__nextHasNoMarginBottom: true,
+ __next40pxDefaultSize: true,
help: 'Please select how transparent you would like this.',
initialPosition: 50,
label: 'Opacity',
@@ -107,6 +108,7 @@ export const WithAnyStep: StoryFn< typeof RangeControl > = ( {
};
WithAnyStep.args = {
__nextHasNoMarginBottom: true,
+ __next40pxDefaultSize: true,
label: 'Brightness',
step: 'any',
};
@@ -171,6 +173,7 @@ export const WithIntegerStepAndMarks: StoryFn< typeof RangeControl > =
WithIntegerStepAndMarks.args = {
__nextHasNoMarginBottom: true,
+ __next40pxDefaultSize: true,
label: 'Integer Step',
marks: marksBase,
max: 10,
@@ -188,6 +191,7 @@ export const WithDecimalStepAndMarks: StoryFn< typeof RangeControl > =
WithDecimalStepAndMarks.args = {
__nextHasNoMarginBottom: true,
+ __next40pxDefaultSize: true,
marks: [
...marksBase,
{ value: 3.5, label: '3.5' },
@@ -208,6 +212,7 @@ export const WithNegativeMinimumAndMarks: StoryFn< typeof RangeControl > =
WithNegativeMinimumAndMarks.args = {
__nextHasNoMarginBottom: true,
+ __next40pxDefaultSize: true,
marks: marksWithNegatives,
max: 10,
min: -10,
@@ -224,6 +229,7 @@ export const WithNegativeRangeAndMarks: StoryFn< typeof RangeControl > =
WithNegativeRangeAndMarks.args = {
__nextHasNoMarginBottom: true,
+ __next40pxDefaultSize: true,
marks: marksWithNegatives,
max: -1,
min: -10,
@@ -240,6 +246,7 @@ export const WithAnyStepAndMarks: StoryFn< typeof RangeControl > =
WithAnyStepAndMarks.args = {
__nextHasNoMarginBottom: true,
+ __next40pxDefaultSize: true,
marks: marksBase,
max: 10,
min: 0,
diff --git a/packages/components/src/range-control/test/index.tsx b/packages/components/src/range-control/test/index.tsx
index 3ce741867d0dbc..3d2db30eea186f 100644
--- a/packages/components/src/range-control/test/index.tsx
+++ b/packages/components/src/range-control/test/index.tsx
@@ -18,7 +18,13 @@ const fireChangeEvent = ( input: HTMLInputElement, value?: number | string ) =>
const RangeControl = (
props: React.ComponentProps< typeof _RangeControl >
) => {
- return <_RangeControl { ...props } __nextHasNoMarginBottom />;
+ return (
+ <_RangeControl
+ { ...props }
+ __nextHasNoMarginBottom
+ __next40pxDefaultSize
+ />
+ );
};
describe( 'RangeControl', () => {
diff --git a/packages/components/src/range-control/types.ts b/packages/components/src/range-control/types.ts
index a427ab4f942af6..e4792296f83144 100644
--- a/packages/components/src/range-control/types.ts
+++ b/packages/components/src/range-control/types.ts
@@ -233,6 +233,13 @@ export type RangeControlProps = Pick<
* @default true
*/
withInputField?: boolean;
+ /**
+ * Do not throw a warning for the deprecated 36px default size.
+ * For internal components of other components that already throw the warning.
+ *
+ * @ignore
+ */
+ __shouldNotWarnDeprecated36pxSize?: boolean;
};
export type RailProps = MarksProps & {
From 08d8b8661a602ce42742b9f7e71ca42c389ee169 Mon Sep 17 00:00:00 2001
From: Lena Morita
Date: Tue, 26 Nov 2024 07:10:45 +0900
Subject: [PATCH 14/23] ComboboxControl: Update reset button size (#67215)
* ComboboxControl: Update reset button size
* Add changelog
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: tyxla
---
packages/components/CHANGELOG.md | 1 +
.../components/src/combobox-control/index.tsx | 24 +++++++++----------
.../src/combobox-control/style.scss | 6 -----
3 files changed, 12 insertions(+), 19 deletions(-)
diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md
index 9f547859fa5a99..81e325c8d9b3ff 100644
--- a/packages/components/CHANGELOG.md
+++ b/packages/components/CHANGELOG.md
@@ -27,6 +27,7 @@
### Enhancements
- `ColorPicker`: Update sizes of color format select and copy button ([#67093](https://github.com/WordPress/gutenberg/pull/67093)).
+- `ComboboxControl`: Update reset button size ([#67215](https://github.com/WordPress/gutenberg/pull/67215)).
- `Autocomplete`: Increase option height ([#67214](https://github.com/WordPress/gutenberg/pull/67214)).
### Experimental
diff --git a/packages/components/src/combobox-control/index.tsx b/packages/components/src/combobox-control/index.tsx
index 86fa4f4467318c..28510c8653d02e 100644
--- a/packages/components/src/combobox-control/index.tsx
+++ b/packages/components/src/combobox-control/index.tsx
@@ -26,7 +26,7 @@ import TokenInput from '../form-token-field/token-input';
import SuggestionsList from '../form-token-field/suggestions-list';
import BaseControl from '../base-control';
import Button from '../button';
-import { FlexBlock, FlexItem } from '../flex';
+import { FlexBlock } from '../flex';
import withFocusOutside from '../higher-order/with-focus-outside';
import { useControlledValue } from '../utils/hooks';
import { normalizeTextString } from '../utils/strings';
@@ -363,18 +363,16 @@ function ComboboxControl( props: ComboboxControlProps ) {
/>
{ allowReset && (
-
-
-
+
) }
{ isExpanded && (
diff --git a/packages/components/src/combobox-control/style.scss b/packages/components/src/combobox-control/style.scss
index 8bd4c2fb156a9f..c8fd8a168c0fb7 100644
--- a/packages/components/src/combobox-control/style.scss
+++ b/packages/components/src/combobox-control/style.scss
@@ -38,9 +38,3 @@ input.components-combobox-control__input[type="text"] {
}
}
-.components-combobox-control__reset.components-button {
- display: flex;
- height: $grid-unit-20;
- min-width: $grid-unit-20;
- padding: 0;
-}
From 9b0e2d96679ab6c82033946bead9521529e6b29a Mon Sep 17 00:00:00 2001
From: Aki Hamano <54422211+t-hamano@users.noreply.github.com>
Date: Tue, 26 Nov 2024 12:50:39 +0900
Subject: [PATCH 15/23] Block Manager: Make it a private component in the block
editor package (#67255)
* Block Manager: Make it a private component in the block editor package
* Move style import statement
Co-authored-by: t-hamano
Co-authored-by: ramonjd
Co-authored-by: youknowriad
---
packages/base-styles/_z-index.scss | 4 +--
.../src/components/block-manager/category.js | 6 ++--
.../src/components/block-manager/checklist.js | 10 +++++--
.../src/components/block-manager/index.js | 10 +++----
.../src/components/block-manager/style.scss | 28 +++++++++----------
packages/block-editor/src/private-apis.js | 2 ++
packages/block-editor/src/style.scss | 1 +
.../preferences-modal/block-visibility.js | 4 ++-
packages/editor/src/style.scss | 1 -
9 files changed, 37 insertions(+), 29 deletions(-)
rename packages/{editor => block-editor}/src/components/block-manager/category.js (91%)
rename packages/{editor => block-editor}/src/components/block-manager/checklist.js (75%)
rename packages/{editor => block-editor}/src/components/block-manager/index.js (92%)
rename packages/{editor => block-editor}/src/components/block-manager/style.scss (65%)
diff --git a/packages/base-styles/_z-index.scss b/packages/base-styles/_z-index.scss
index e4d6ce4ce1b1c9..167af583ed9ddb 100644
--- a/packages/base-styles/_z-index.scss
+++ b/packages/base-styles/_z-index.scss
@@ -165,9 +165,9 @@ $z-layers: (
".components-resizable-box__corner-handle": 2,
// Make sure block manager sticky category titles appear above the options
- ".editor-block-manager__category-title": 1,
+ ".block-editor-block-manager__category-title": 1,
// And block manager sticky disabled block count is higher still
- ".editor-block-manager__disabled-blocks-count": 2,
+ ".block-editor-block-manager__disabled-blocks-count": 2,
// Needs to appear below other color circular picker related UI elements.
".components-circular-option-picker__option-wrapper::before": -1,
diff --git a/packages/editor/src/components/block-manager/category.js b/packages/block-editor/src/components/block-manager/category.js
similarity index 91%
rename from packages/editor/src/components/block-manager/category.js
rename to packages/block-editor/src/components/block-manager/category.js
index 341584fee03b96..79d5896b4502e4 100644
--- a/packages/editor/src/components/block-manager/category.js
+++ b/packages/block-editor/src/components/block-manager/category.js
@@ -71,7 +71,7 @@ function BlockManagerCategory( {
)
);
- const titleId = 'editor-block-manager__category-title-' + instanceId;
+ const titleId = 'block-editor-block-manager__category-title-' + instanceId;
const isAllChecked = checkedBlockNames.length === blockTypes.length;
const isIndeterminate = ! isAllChecked && checkedBlockNames.length > 0;
@@ -80,13 +80,13 @@ function BlockManagerCategory( {
{ title } }
/>
diff --git a/packages/editor/src/components/block-manager/checklist.js b/packages/block-editor/src/components/block-manager/checklist.js
similarity index 75%
rename from packages/editor/src/components/block-manager/checklist.js
rename to packages/block-editor/src/components/block-manager/checklist.js
index 2839e2c9e14c14..d5456a14355efb 100644
--- a/packages/editor/src/components/block-manager/checklist.js
+++ b/packages/block-editor/src/components/block-manager/checklist.js
@@ -1,16 +1,20 @@
/**
* WordPress dependencies
*/
-import { BlockIcon } from '@wordpress/block-editor';
import { CheckboxControl } from '@wordpress/components';
+/**
+ * Internal dependencies
+ */
+import BlockIcon from '../block-icon';
+
function BlockTypesChecklist( { blockTypes, value, onItemChange } ) {
return (
-
+
{ blockTypes.map( ( blockType ) => (
+
{ !! numberOfHiddenBlocks && (
-
+
{ sprintf(
/* translators: %d: number of blocks. */
_n(
@@ -88,16 +88,16 @@ export default function BlockManager( {
placeholder={ __( 'Search for a block' ) }
value={ search }
onChange={ ( nextSearch ) => setSearch( nextSearch ) }
- className="editor-block-manager__search"
+ className="block-editor-block-manager__search"
/>