@wordpress/block-editor 14.6.0 → 14.7.1-next.082ed6819.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/block-controls/slot.js +6 -3
- package/build/components/block-controls/slot.js.map +1 -1
- package/build/components/block-inspector/index.js +1 -2
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block.js +14 -28
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-lock/modal.js +1 -1
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-manager/category.js +79 -0
- package/build/components/block-manager/category.js.map +1 -0
- package/build/components/block-manager/checklist.js +40 -0
- package/build/components/block-manager/checklist.js.map +1 -0
- package/build/components/block-manager/index.js +108 -0
- package/build/components/block-manager/index.js.map +1 -0
- package/build/components/block-patterns-list/index.js +23 -26
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-popover/index.js +1 -1
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/async.js +51 -0
- package/build/components/block-preview/async.js.map +1 -0
- package/build/components/block-preview/index.js +4 -1
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu/index.js.map +1 -1
- package/build/components/block-toolbar/change-design.js +1 -4
- package/build/components/block-toolbar/change-design.js.map +1 -1
- package/build/components/block-toolbar/index.js +7 -2
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/switch-section-style.js +105 -0
- package/build/components/block-toolbar/switch-section-style.js.map +1 -0
- package/build/components/block-tools/index.js +12 -9
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +4 -1
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/collab/block-comment-icon-slot.js +2 -6
- package/build/components/collab/block-comment-icon-slot.js.map +1 -1
- package/build/components/collab/block-comment-icon-toolbar-slot.js +2 -6
- package/build/components/collab/block-comment-icon-toolbar-slot.js.map +1 -1
- package/build/components/color-palette/with-color-context.js +4 -2
- package/build/components/color-palette/with-color-context.js.map +1 -1
- package/build/components/font-family/index.js +14 -13
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +26 -14
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +1 -1
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/iframe/get-compatibility-styles.js +4 -4
- package/build/components/iframe/get-compatibility-styles.js.map +1 -1
- package/build/components/iframe/index.js +156 -23
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/index.js +1 -2
- package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +4 -6
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +3 -0
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/utils.js +5 -1
- package/build/components/inserter/block-patterns-tab/utils.js.map +1 -1
- package/build/components/inserter/category-tabs/index.js +7 -8
- package/build/components/inserter/category-tabs/index.js.map +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-paging.js +0 -5
- package/build/components/inserter/hooks/use-patterns-paging.js.map +1 -1
- package/build/components/inserter/search-results.js +0 -2
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter-draggable-blocks/index.js +2 -1
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/inspector-controls/slot.js +7 -4
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -4
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build/components/media-placeholder/index.js +33 -25
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/rich-text/index.js +1 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/tabbed-sidebar/index.js +1 -1
- package/build/components/tabbed-sidebar/index.js.map +1 -1
- package/build/components/url-input/index.js +3 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-commands/index.js +5 -6
- package/build/components/use-block-commands/index.js.map +1 -1
- package/build/hooks/border.js +3 -3
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/dimensions.js +2 -2
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/font-family.js +1 -1
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/style.js +6 -6
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/supports.js +7 -7
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.js +6 -6
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +3 -3
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/flex.js +11 -9
- package/build/layouts/flex.js.map +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/private-apis.js +4 -4
- package/build/private-apis.js.map +1 -1
- package/build/store/private-selectors.js +3 -3
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/selectors.js +12 -8
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +5 -4
- package/build/store/utils.js.map +1 -1
- package/build/utils/dom.js +27 -22
- package/build/utils/dom.js.map +1 -1
- package/build-module/components/block-controls/slot.js +6 -3
- package/build-module/components/block-controls/slot.js.map +1 -1
- package/build-module/components/block-inspector/index.js +1 -2
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block.js +15 -27
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-lock/modal.js +1 -1
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-manager/category.js +71 -0
- package/build-module/components/block-manager/category.js.map +1 -0
- package/build-module/components/block-manager/checklist.js +32 -0
- package/build-module/components/block-manager/checklist.js.map +1 -0
- package/build-module/components/block-manager/index.js +102 -0
- package/build-module/components/block-manager/index.js.map +1 -0
- package/build-module/components/block-patterns-list/index.js +23 -26
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-popover/index.js +2 -2
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/async.js +44 -0
- package/build-module/components/block-preview/async.js.map +1 -0
- package/build-module/components/block-preview/index.js +4 -1
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu/index.js +2 -2
- package/build-module/components/block-settings-menu/index.js.map +1 -1
- package/build-module/components/block-toolbar/change-design.js +1 -4
- package/build-module/components/block-toolbar/change-design.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +7 -2
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/switch-section-style.js +97 -0
- package/build-module/components/block-toolbar/switch-section-style.js.map +1 -0
- package/build-module/components/block-tools/index.js +13 -10
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +2 -2
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +4 -1
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/collab/block-comment-icon-slot.js +2 -6
- package/build-module/components/collab/block-comment-icon-slot.js.map +1 -1
- package/build-module/components/collab/block-comment-icon-toolbar-slot.js +2 -6
- package/build-module/components/collab/block-comment-icon-toolbar-slot.js.map +1 -1
- package/build-module/components/color-palette/with-color-context.js +4 -2
- package/build-module/components/color-palette/with-color-context.js.map +1 -1
- package/build-module/components/font-family/index.js +15 -14
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +26 -14
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/iframe/get-compatibility-styles.js +4 -4
- package/build-module/components/iframe/get-compatibility-styles.js.map +1 -1
- package/build-module/components/iframe/index.js +157 -24
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/index.js +1 -2
- package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +5 -7
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +4 -1
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/utils.js +4 -0
- package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -1
- package/build-module/components/inserter/category-tabs/index.js +8 -9
- package/build-module/components/inserter/category-tabs/index.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-paging.js +1 -6
- package/build-module/components/inserter/hooks/use-patterns-paging.js.map +1 -1
- package/build-module/components/inserter/search-results.js +0 -2
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.js +2 -1
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +7 -4
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -4
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +33 -25
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +1 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/tabbed-sidebar/index.js +1 -1
- package/build-module/components/tabbed-sidebar/index.js.map +1 -1
- package/build-module/components/url-input/index.js +3 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-commands/index.js +4 -4
- package/build-module/components/use-block-commands/index.js.map +1 -1
- package/build-module/hooks/border.js +3 -3
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/dimensions.js +2 -2
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/font-family.js +1 -1
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/style.js +6 -6
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/supports.js +7 -7
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.js +6 -6
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +3 -3
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/flex.js +11 -9
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/private-apis.js +6 -6
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/private-selectors.js +3 -3
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/selectors.js +12 -8
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +3 -3
- package/build-module/store/utils.js.map +1 -1
- package/build-module/utils/dom.js +25 -21
- package/build-module/utils/dom.js.map +1 -1
- package/build-style/content-rtl.css +30 -15
- package/build-style/content.css +30 -15
- package/build-style/style-rtl.css +92 -3
- package/build-style/style.css +92 -3
- package/build-types/utils/dom.d.ts +7 -9
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +32 -31
- package/src/components/block-canvas/style.scss +1 -1
- package/src/components/block-controls/slot.js +5 -3
- package/src/components/block-inspector/index.js +0 -2
- package/src/components/block-inspector/style.scss +2 -1
- package/src/components/block-list/block.js +28 -48
- package/src/components/block-lock/modal.js +1 -1
- package/src/components/block-manager/category.js +102 -0
- package/src/components/block-manager/checklist.js +34 -0
- package/src/components/block-manager/index.js +127 -0
- package/src/components/block-manager/style.scss +82 -0
- package/src/components/block-mover/README.md +15 -8
- package/src/components/block-mover/stories/index.story.js +73 -71
- package/src/components/block-mover/style.scss +3 -0
- package/src/components/block-patterns-list/README.md +8 -8
- package/src/components/block-patterns-list/index.js +35 -51
- package/src/components/block-patterns-list/stories/index.story.js +2 -19
- package/src/components/block-popover/index.js +4 -4
- package/src/components/block-preview/async.js +43 -0
- package/src/components/block-preview/index.js +6 -1
- package/src/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/src/components/block-settings-menu/index.js +2 -2
- package/src/components/block-toolbar/change-design.js +1 -7
- package/src/components/block-toolbar/index.js +6 -0
- package/src/components/block-toolbar/switch-section-style.js +115 -0
- package/src/components/block-tools/index.js +26 -10
- package/src/components/block-tools/style.scss +12 -0
- package/src/components/block-tools/use-block-toolbar-popover-props.js +2 -2
- package/src/components/block-tools/use-show-block-tools.js +3 -1
- package/src/components/collab/block-comment-icon-slot.js +2 -6
- package/src/components/collab/block-comment-icon-toolbar-slot.js +3 -5
- package/src/components/color-palette/with-color-context.js +25 -7
- package/src/components/default-block-appender/content.scss +13 -19
- package/src/components/font-family/index.js +13 -13
- package/src/components/global-styles/dimensions-panel.js +22 -16
- package/src/components/global-styles/test/use-global-styles-output.js +1 -1
- package/src/components/global-styles/use-global-styles-output.js +1 -1
- package/src/components/iframe/content.scss +16 -3
- package/src/components/iframe/get-compatibility-styles.js +4 -9
- package/src/components/iframe/index.js +204 -44
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +3 -6
- package/src/components/inserter/block-patterns-tab/index.js +0 -1
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +15 -17
- package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +8 -0
- package/src/components/inserter/block-patterns-tab/utils.js +5 -0
- package/src/components/inserter/category-tabs/index.js +8 -9
- package/src/components/inserter/hooks/use-block-types-state.js +6 -1
- package/src/components/inserter/hooks/use-patterns-paging.js +1 -6
- package/src/components/inserter/search-results.js +0 -6
- package/src/components/inserter-draggable-blocks/index.js +10 -1
- package/src/components/inspector-controls/README.md +2 -0
- package/src/components/inspector-controls/slot.js +6 -4
- package/src/components/inspector-controls-tabs/position-controls-panel.js +1 -3
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +10 -10
- package/src/components/media-placeholder/index.js +41 -37
- package/src/components/provider/test/use-block-sync.js +3 -1
- package/src/components/rich-text/content.scss +15 -10
- package/src/components/rich-text/index.js +8 -1
- package/src/components/tabbed-sidebar/index.js +1 -1
- package/src/components/tabbed-sidebar/style.scss +1 -1
- package/src/components/url-input/index.js +3 -4
- package/src/components/use-block-commands/index.js +245 -234
- package/src/hooks/border.js +3 -9
- package/src/hooks/color.js +1 -1
- package/src/hooks/dimensions.js +2 -2
- package/src/hooks/font-family.js +1 -1
- package/src/hooks/style.js +6 -12
- package/src/hooks/supports.js +7 -7
- package/src/hooks/test/style.js +1 -2
- package/src/hooks/typography.js +6 -6
- package/src/hooks/utils.js +8 -3
- package/src/layouts/flex.js +26 -18
- package/src/private-apis.js +6 -6
- package/src/store/private-selectors.js +6 -7
- package/src/store/selectors.js +60 -45
- package/src/store/test/private-selectors.js +5 -0
- package/src/store/test/selectors.js +87 -58
- package/src/store/utils.js +12 -11
- package/src/style.scss +1 -0
- package/src/utils/dom.js +26 -21
- package/src/utils/test/dom.js +224 -0
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-info-slot-fill/index.js +0 -39
- package/build/components/block-info-slot-fill/index.js.map +0 -1
- package/build-module/components/block-info-slot-fill/index.js +0 -32
- package/build-module/components/block-info-slot-fill/index.js.map +0 -1
- package/src/components/block-info-slot-fill/index.js +0 -27
- /package/src/{lock-unlock.js → lock-unlock.ts} +0 -0
|
@@ -36,20 +36,18 @@ export function getBlockClientId(node: Node | null): string | undefined;
|
|
|
36
36
|
*/
|
|
37
37
|
export function rectUnion(rect1: DOMRect, rect2: DOMRect): DOMRect;
|
|
38
38
|
/**
|
|
39
|
-
* Returns the
|
|
40
|
-
*
|
|
41
|
-
* Visible nested elements, including elements that overflow the parent, are
|
|
42
|
-
* taken into account.
|
|
43
|
-
*
|
|
44
|
-
* This function is useful for calculating the visible area of a block that
|
|
45
|
-
* contains nested elements that overflow the block, e.g. the Navigation block,
|
|
46
|
-
* which can contain overflowing Submenu blocks.
|
|
39
|
+
* Returns the bounding rectangle of an element, with special handling for blocks
|
|
40
|
+
* that have visible overflowing children (defined in WITH_OVERFLOW_ELEMENT_BLOCKS).
|
|
47
41
|
*
|
|
42
|
+
* For blocks like Navigation that can have overflowing elements (e.g. submenus),
|
|
43
|
+
* this function calculates the combined bounds of both the parent and its visible
|
|
44
|
+
* children. The returned rect may extend beyond the viewport.
|
|
48
45
|
* The returned rect represents the full extent of the element and its visible
|
|
49
46
|
* children, which may extend beyond the viewport.
|
|
50
47
|
*
|
|
51
48
|
* @param {Element} element Element.
|
|
52
49
|
* @return {DOMRect} Bounding client rect of the element and its visible children.
|
|
53
50
|
*/
|
|
54
|
-
export function
|
|
51
|
+
export function getElementBounds(element: Element): DOMRect;
|
|
52
|
+
export const WITH_OVERFLOW_ELEMENT_BLOCKS: string[];
|
|
55
53
|
//# sourceMappingURL=dom.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/utils/dom.js"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,iCALW,OAAO,KACP,OAAO,GAEN,OAAO,CAIlB;AAED;;;;;;;;;GASG;AACH,gDANW,OAAO,WACP,OAAO,GAEN,OAAO,CAQlB;AAED;;;;;;;GAOG;AACH,uCALW,IAAI,OAAC,GAEJ,MAAM,GAAC,SAAS,CAoB3B;AAED;;;;;;GAMG;AACH,iCAJW,OAAO,SACP,OAAO,GACN,OAAO,CASlB;
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/utils/dom.js"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,iCALW,OAAO,KACP,OAAO,GAEN,OAAO,CAIlB;AAED;;;;;;;;;GASG;AACH,gDANW,OAAO,WACP,OAAO,GAEN,OAAO,CAQlB;AAED;;;;;;;GAOG;AACH,uCALW,IAAI,OAAC,GAEJ,MAAM,GAAC,SAAS,CAoB3B;AAED;;;;;;GAMG;AACH,iCAJW,OAAO,SACP,OAAO,GACN,OAAO,CASlB;AA+DD;;;;;;;;;;;;GAYG;AACH,0CAHW,OAAO,GACN,OAAO,CAoDlB;AAhED,oDAAkE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.7.1-next.082ed6819.0",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"main": "build/index.js",
|
|
27
27
|
"module": "build-module/index.js",
|
|
28
28
|
"react-native": "src/index",
|
|
29
|
+
"wpScript": true,
|
|
29
30
|
"sideEffects": [
|
|
30
31
|
"build-style/**",
|
|
31
32
|
"src/**/*.scss",
|
|
@@ -36,36 +37,37 @@
|
|
|
36
37
|
"@emotion/react": "^11.7.1",
|
|
37
38
|
"@emotion/styled": "^11.6.0",
|
|
38
39
|
"@react-spring/web": "^9.4.5",
|
|
39
|
-
"@wordpress/a11y": "
|
|
40
|
-
"@wordpress/api-fetch": "
|
|
41
|
-
"@wordpress/blob": "
|
|
42
|
-
"@wordpress/block-serialization-default-parser": "
|
|
43
|
-
"@wordpress/blocks": "
|
|
44
|
-
"@wordpress/commands": "
|
|
40
|
+
"@wordpress/a11y": "^4.12.1-next.082ed6819.0",
|
|
41
|
+
"@wordpress/api-fetch": "^7.12.1-next.082ed6819.0",
|
|
42
|
+
"@wordpress/blob": "^4.12.1-next.082ed6819.0",
|
|
43
|
+
"@wordpress/block-serialization-default-parser": "^5.12.1-next.082ed6819.0",
|
|
44
|
+
"@wordpress/blocks": "^14.1.1-next.082ed6819.0",
|
|
45
|
+
"@wordpress/commands": "^1.12.1-next.082ed6819.0",
|
|
45
46
|
"@wordpress/components": "*",
|
|
46
|
-
"@wordpress/compose": "
|
|
47
|
+
"@wordpress/compose": "^7.12.1-next.082ed6819.0",
|
|
47
48
|
"@wordpress/data": "*",
|
|
48
|
-
"@wordpress/date": "
|
|
49
|
-
"@wordpress/deprecated": "
|
|
50
|
-
"@wordpress/dom": "
|
|
51
|
-
"@wordpress/element": "
|
|
52
|
-
"@wordpress/escape-html": "
|
|
53
|
-
"@wordpress/hooks": "
|
|
54
|
-
"@wordpress/html-entities": "
|
|
55
|
-
"@wordpress/i18n": "
|
|
56
|
-
"@wordpress/icons": "
|
|
57
|
-
"@wordpress/is-shallow-equal": "
|
|
58
|
-
"@wordpress/keyboard-shortcuts": "
|
|
59
|
-
"@wordpress/keycodes": "
|
|
60
|
-
"@wordpress/notices": "
|
|
61
|
-
"@wordpress/preferences": "
|
|
62
|
-
"@wordpress/
|
|
63
|
-
"@wordpress/
|
|
64
|
-
"@wordpress/
|
|
65
|
-
"@wordpress/
|
|
66
|
-
"@wordpress/
|
|
67
|
-
"@wordpress/
|
|
68
|
-
"@wordpress/
|
|
49
|
+
"@wordpress/date": "^5.12.1-next.082ed6819.0",
|
|
50
|
+
"@wordpress/deprecated": "^4.12.1-next.082ed6819.0",
|
|
51
|
+
"@wordpress/dom": "^4.12.1-next.082ed6819.0",
|
|
52
|
+
"@wordpress/element": "^6.12.1-next.082ed6819.0",
|
|
53
|
+
"@wordpress/escape-html": "^3.12.1-next.082ed6819.0",
|
|
54
|
+
"@wordpress/hooks": "^4.12.1-next.082ed6819.0",
|
|
55
|
+
"@wordpress/html-entities": "^4.12.1-next.082ed6819.0",
|
|
56
|
+
"@wordpress/i18n": "^5.12.1-next.082ed6819.0",
|
|
57
|
+
"@wordpress/icons": "^10.12.1-next.082ed6819.0",
|
|
58
|
+
"@wordpress/is-shallow-equal": "^5.12.1-next.082ed6819.0",
|
|
59
|
+
"@wordpress/keyboard-shortcuts": "^5.12.1-next.082ed6819.0",
|
|
60
|
+
"@wordpress/keycodes": "^4.12.1-next.082ed6819.0",
|
|
61
|
+
"@wordpress/notices": "^5.12.1-next.082ed6819.0",
|
|
62
|
+
"@wordpress/preferences": "^4.12.1-next.082ed6819.0",
|
|
63
|
+
"@wordpress/priority-queue": "^3.12.1-next.082ed6819.0",
|
|
64
|
+
"@wordpress/private-apis": "^1.12.1-next.082ed6819.0",
|
|
65
|
+
"@wordpress/rich-text": "^7.12.1-next.082ed6819.0",
|
|
66
|
+
"@wordpress/style-engine": "^2.12.1-next.082ed6819.0",
|
|
67
|
+
"@wordpress/token-list": "^3.12.1-next.082ed6819.0",
|
|
68
|
+
"@wordpress/url": "^4.12.1-next.082ed6819.0",
|
|
69
|
+
"@wordpress/warning": "^3.12.1-next.082ed6819.0",
|
|
70
|
+
"@wordpress/wordcount": "^4.12.1-next.082ed6819.0",
|
|
69
71
|
"change-case": "^4.1.2",
|
|
70
72
|
"clsx": "^2.1.1",
|
|
71
73
|
"colord": "^2.7.0",
|
|
@@ -88,6 +90,5 @@
|
|
|
88
90
|
"publishConfig": {
|
|
89
91
|
"access": "public"
|
|
90
92
|
},
|
|
91
|
-
"
|
|
92
|
-
"gitHead": "dcf4613b33b0eda14e203ac30f700ed0db70347f"
|
|
93
|
+
"gitHead": "2bb7bad15ddb8e88210fab7d4a1ef1565466e424"
|
|
93
94
|
}
|
|
@@ -31,9 +31,10 @@ export default function BlockControlsSlot( { group = 'default', ...props } ) {
|
|
|
31
31
|
[ toolbarState, contextState ]
|
|
32
32
|
);
|
|
33
33
|
|
|
34
|
-
const
|
|
35
|
-
const fills = useSlotFills(
|
|
36
|
-
|
|
34
|
+
const slotFill = groups[ group ];
|
|
35
|
+
const fills = useSlotFills( slotFill.name );
|
|
36
|
+
|
|
37
|
+
if ( ! slotFill ) {
|
|
37
38
|
warning( `Unknown BlockControls group "${ group }" provided.` );
|
|
38
39
|
return null;
|
|
39
40
|
}
|
|
@@ -42,6 +43,7 @@ export default function BlockControlsSlot( { group = 'default', ...props } ) {
|
|
|
42
43
|
return null;
|
|
43
44
|
}
|
|
44
45
|
|
|
46
|
+
const { Slot } = slotFill;
|
|
45
47
|
const slot = <Slot { ...props } bubblesVirtually fillProps={ fillProps } />;
|
|
46
48
|
|
|
47
49
|
if ( group === 'default' ) {
|
|
@@ -26,7 +26,6 @@ import useInspectorControlsTabs from '../inspector-controls-tabs/use-inspector-c
|
|
|
26
26
|
import AdvancedControls from '../inspector-controls-tabs/advanced-controls-panel';
|
|
27
27
|
import PositionControls from '../inspector-controls-tabs/position-controls-panel';
|
|
28
28
|
import useBlockInspectorAnimationSettings from './useBlockInspectorAnimationSettings';
|
|
29
|
-
import BlockInfo from '../block-info-slot-fill';
|
|
30
29
|
import BlockQuickNavigation from '../block-quick-navigation';
|
|
31
30
|
import { useBorderPanelLabel } from '../../hooks/border';
|
|
32
31
|
|
|
@@ -253,7 +252,6 @@ const BlockInspectorSingleBlock = ( {
|
|
|
253
252
|
className={ blockInformation.isSynced && 'is-synced' }
|
|
254
253
|
/>
|
|
255
254
|
<BlockVariationTransforms blockClientId={ clientId } />
|
|
256
|
-
<BlockInfo.Slot />
|
|
257
255
|
{ showTabs && (
|
|
258
256
|
<InspectorControlsTabs
|
|
259
257
|
hasBlockStyles={ hasBlockStyles }
|
|
@@ -24,8 +24,8 @@ import {
|
|
|
24
24
|
isReusableBlock,
|
|
25
25
|
getBlockDefaultClassName,
|
|
26
26
|
hasBlockSupport,
|
|
27
|
+
createBlock,
|
|
27
28
|
store as blocksStore,
|
|
28
|
-
privateApis as blocksPrivateApis,
|
|
29
29
|
} from '@wordpress/blocks';
|
|
30
30
|
import { withFilters } from '@wordpress/components';
|
|
31
31
|
import { withDispatch, useDispatch, useSelect } from '@wordpress/data';
|
|
@@ -47,8 +47,6 @@ import { PrivateBlockContext } from './private-block-context';
|
|
|
47
47
|
|
|
48
48
|
import { unlock } from '../../lock-unlock';
|
|
49
49
|
|
|
50
|
-
const { isUnmodifiedBlockContent } = unlock( blocksPrivateApis );
|
|
51
|
-
|
|
52
50
|
/**
|
|
53
51
|
* Merges wrapper props with special handling for classNames and styles.
|
|
54
52
|
*
|
|
@@ -313,6 +311,7 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
|
|
|
313
311
|
function switchToDefaultOrRemove() {
|
|
314
312
|
const block = getBlock( clientId );
|
|
315
313
|
const defaultBlockName = getDefaultBlockName();
|
|
314
|
+
const defaultBlockType = getBlockType( defaultBlockName );
|
|
316
315
|
if ( getBlockName( clientId ) !== defaultBlockName ) {
|
|
317
316
|
const replacement = switchToBlockType(
|
|
318
317
|
block,
|
|
@@ -329,6 +328,15 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
|
|
|
329
328
|
selectBlock( nextBlockClientId );
|
|
330
329
|
} );
|
|
331
330
|
}
|
|
331
|
+
} else if ( defaultBlockType.merge ) {
|
|
332
|
+
const attributes = defaultBlockType.merge(
|
|
333
|
+
{},
|
|
334
|
+
block.attributes
|
|
335
|
+
);
|
|
336
|
+
replaceBlocks(
|
|
337
|
+
[ clientId ],
|
|
338
|
+
[ createBlock( defaultBlockName, attributes ) ]
|
|
339
|
+
);
|
|
332
340
|
}
|
|
333
341
|
}
|
|
334
342
|
|
|
@@ -342,6 +350,9 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
|
|
|
342
350
|
* to the moved block.
|
|
343
351
|
*/
|
|
344
352
|
function moveFirstItemUp( _clientId, changeSelection = true ) {
|
|
353
|
+
const wrapperBlockName = getBlockName( _clientId );
|
|
354
|
+
const wrapperBlockType = getBlockType( wrapperBlockName );
|
|
355
|
+
const isTextualWrapper = wrapperBlockType.category === 'text';
|
|
345
356
|
const targetRootClientId = getBlockRootClientId( _clientId );
|
|
346
357
|
const blockOrder = getBlockOrder( _clientId );
|
|
347
358
|
const [ firstClientId ] = blockOrder;
|
|
@@ -351,50 +362,14 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
|
|
|
351
362
|
isUnmodifiedBlock( getBlock( firstClientId ) )
|
|
352
363
|
) {
|
|
353
364
|
removeBlock( _clientId );
|
|
354
|
-
} else {
|
|
365
|
+
} else if ( isTextualWrapper ) {
|
|
355
366
|
registry.batch( () => {
|
|
356
|
-
const firstBlock = getBlock( firstClientId );
|
|
357
|
-
const isFirstBlockContentUnmodified =
|
|
358
|
-
isUnmodifiedBlockContent( firstBlock );
|
|
359
|
-
const defaultBlockName = getDefaultBlockName();
|
|
360
|
-
const replacement = switchToBlockType(
|
|
361
|
-
firstBlock,
|
|
362
|
-
defaultBlockName
|
|
363
|
-
);
|
|
364
|
-
const canTransformToDefaultBlock =
|
|
365
|
-
!! replacement?.length &&
|
|
366
|
-
replacement.every( ( block ) =>
|
|
367
|
-
canInsertBlockType( block.name, _clientId )
|
|
368
|
-
);
|
|
369
|
-
|
|
370
367
|
if (
|
|
371
|
-
isFirstBlockContentUnmodified &&
|
|
372
|
-
canTransformToDefaultBlock
|
|
373
|
-
) {
|
|
374
|
-
// Step 1: If the block is empty and can be transformed to the default block type.
|
|
375
|
-
replaceBlocks(
|
|
376
|
-
firstClientId,
|
|
377
|
-
replacement,
|
|
378
|
-
changeSelection
|
|
379
|
-
);
|
|
380
|
-
} else if (
|
|
381
|
-
isFirstBlockContentUnmodified &&
|
|
382
|
-
firstBlock.name === defaultBlockName
|
|
383
|
-
) {
|
|
384
|
-
// Step 2: If the block is empty and is already the default block type.
|
|
385
|
-
removeBlock( firstClientId );
|
|
386
|
-
const nextBlockClientId =
|
|
387
|
-
getNextBlockClientId( clientId );
|
|
388
|
-
if ( nextBlockClientId ) {
|
|
389
|
-
selectBlock( nextBlockClientId );
|
|
390
|
-
}
|
|
391
|
-
} else if (
|
|
392
368
|
canInsertBlockType(
|
|
393
|
-
|
|
369
|
+
getBlockName( firstClientId ),
|
|
394
370
|
targetRootClientId
|
|
395
371
|
)
|
|
396
372
|
) {
|
|
397
|
-
// Step 3: If the block can be moved up.
|
|
398
373
|
moveBlocksToPosition(
|
|
399
374
|
[ firstClientId ],
|
|
400
375
|
_clientId,
|
|
@@ -402,17 +377,21 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
|
|
|
402
377
|
getBlockIndex( _clientId )
|
|
403
378
|
);
|
|
404
379
|
} else {
|
|
405
|
-
const
|
|
406
|
-
|
|
380
|
+
const replacement = switchToBlockType(
|
|
381
|
+
getBlock( firstClientId ),
|
|
382
|
+
getDefaultBlockName()
|
|
383
|
+
);
|
|
384
|
+
|
|
385
|
+
if (
|
|
386
|
+
replacement &&
|
|
387
|
+
replacement.length &&
|
|
407
388
|
replacement.every( ( block ) =>
|
|
408
389
|
canInsertBlockType(
|
|
409
390
|
block.name,
|
|
410
391
|
targetRootClientId
|
|
411
392
|
)
|
|
412
|
-
)
|
|
413
|
-
|
|
414
|
-
if ( canLiftAndTransformToDefaultBlock ) {
|
|
415
|
-
// Step 4: If the block can be transformed to the default block type and moved up.
|
|
393
|
+
)
|
|
394
|
+
) {
|
|
416
395
|
insertBlocks(
|
|
417
396
|
replacement,
|
|
418
397
|
getBlockIndex( _clientId ),
|
|
@@ -421,7 +400,6 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
|
|
|
421
400
|
);
|
|
422
401
|
removeBlock( firstClientId, false );
|
|
423
402
|
} else {
|
|
424
|
-
// Step 5: Continue the default behavior.
|
|
425
403
|
switchToDefaultOrRemove();
|
|
426
404
|
}
|
|
427
405
|
}
|
|
@@ -433,6 +411,8 @@ const applyWithDispatch = withDispatch( ( dispatch, ownProps, registry ) => {
|
|
|
433
411
|
removeBlock( _clientId, false );
|
|
434
412
|
}
|
|
435
413
|
} );
|
|
414
|
+
} else {
|
|
415
|
+
switchToDefaultOrRemove();
|
|
436
416
|
}
|
|
437
417
|
}
|
|
438
418
|
|
|
@@ -24,7 +24,7 @@ import useBlockDisplayInformation from '../use-block-display-information';
|
|
|
24
24
|
import { store as blockEditorStore } from '../../store';
|
|
25
25
|
|
|
26
26
|
// Entity based blocks which allow edit locking
|
|
27
|
-
const ALLOWS_EDIT_LOCKING = [ 'core/
|
|
27
|
+
const ALLOWS_EDIT_LOCKING = [ 'core/navigation' ];
|
|
28
28
|
|
|
29
29
|
function getTemplateLockValue( lock ) {
|
|
30
30
|
// Prevents all operations.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useCallback } from '@wordpress/element';
|
|
5
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
6
|
+
import { CheckboxControl } from '@wordpress/components';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import BlockTypesChecklist from './checklist';
|
|
12
|
+
|
|
13
|
+
function BlockManagerCategory( {
|
|
14
|
+
title,
|
|
15
|
+
blockTypes,
|
|
16
|
+
selectedBlockTypes,
|
|
17
|
+
onChange,
|
|
18
|
+
} ) {
|
|
19
|
+
const instanceId = useInstanceId( BlockManagerCategory );
|
|
20
|
+
|
|
21
|
+
const toggleVisible = useCallback(
|
|
22
|
+
( blockType, nextIsChecked ) => {
|
|
23
|
+
if ( nextIsChecked ) {
|
|
24
|
+
onChange( [ ...selectedBlockTypes, blockType ] );
|
|
25
|
+
} else {
|
|
26
|
+
onChange(
|
|
27
|
+
selectedBlockTypes.filter(
|
|
28
|
+
( { name } ) => name !== blockType.name
|
|
29
|
+
)
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
[ selectedBlockTypes, onChange ]
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const toggleAllVisible = useCallback(
|
|
37
|
+
( nextIsChecked ) => {
|
|
38
|
+
if ( nextIsChecked ) {
|
|
39
|
+
onChange( [
|
|
40
|
+
...selectedBlockTypes,
|
|
41
|
+
...blockTypes.filter(
|
|
42
|
+
( blockType ) =>
|
|
43
|
+
! selectedBlockTypes.find(
|
|
44
|
+
( { name } ) => name === blockType.name
|
|
45
|
+
)
|
|
46
|
+
),
|
|
47
|
+
] );
|
|
48
|
+
} else {
|
|
49
|
+
onChange(
|
|
50
|
+
selectedBlockTypes.filter(
|
|
51
|
+
( selectedBlockType ) =>
|
|
52
|
+
! blockTypes.find(
|
|
53
|
+
( { name } ) => name === selectedBlockType.name
|
|
54
|
+
)
|
|
55
|
+
)
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
[ blockTypes, selectedBlockTypes, onChange ]
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
if ( ! blockTypes.length ) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const checkedBlockNames = blockTypes
|
|
67
|
+
.map( ( { name } ) => name )
|
|
68
|
+
.filter( ( type ) =>
|
|
69
|
+
( selectedBlockTypes ?? [] ).some(
|
|
70
|
+
( selectedBlockType ) => selectedBlockType.name === type
|
|
71
|
+
)
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const titleId = 'block-editor-block-manager__category-title-' + instanceId;
|
|
75
|
+
|
|
76
|
+
const isAllChecked = checkedBlockNames.length === blockTypes.length;
|
|
77
|
+
const isIndeterminate = ! isAllChecked && checkedBlockNames.length > 0;
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<div
|
|
81
|
+
role="group"
|
|
82
|
+
aria-labelledby={ titleId }
|
|
83
|
+
className="block-editor-block-manager__category"
|
|
84
|
+
>
|
|
85
|
+
<CheckboxControl
|
|
86
|
+
__nextHasNoMarginBottom
|
|
87
|
+
checked={ isAllChecked }
|
|
88
|
+
onChange={ toggleAllVisible }
|
|
89
|
+
className="block-editor-block-manager__category-title"
|
|
90
|
+
indeterminate={ isIndeterminate }
|
|
91
|
+
label={ <span id={ titleId }>{ title }</span> }
|
|
92
|
+
/>
|
|
93
|
+
<BlockTypesChecklist
|
|
94
|
+
blockTypes={ blockTypes }
|
|
95
|
+
value={ checkedBlockNames }
|
|
96
|
+
onItemChange={ toggleVisible }
|
|
97
|
+
/>
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export default BlockManagerCategory;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { CheckboxControl } from '@wordpress/components';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import BlockIcon from '../block-icon';
|
|
10
|
+
|
|
11
|
+
function BlockTypesChecklist( { blockTypes, value, onItemChange } ) {
|
|
12
|
+
return (
|
|
13
|
+
<ul className="block-editor-block-manager__checklist">
|
|
14
|
+
{ blockTypes.map( ( blockType ) => (
|
|
15
|
+
<li
|
|
16
|
+
key={ blockType.name }
|
|
17
|
+
className="block-editor-block-manager__checklist-item"
|
|
18
|
+
>
|
|
19
|
+
<CheckboxControl
|
|
20
|
+
__nextHasNoMarginBottom
|
|
21
|
+
label={ blockType.title }
|
|
22
|
+
checked={ value.includes( blockType.name ) }
|
|
23
|
+
onChange={ ( ...args ) =>
|
|
24
|
+
onItemChange( blockType, ...args )
|
|
25
|
+
}
|
|
26
|
+
/>
|
|
27
|
+
<BlockIcon icon={ blockType.icon } />
|
|
28
|
+
</li>
|
|
29
|
+
) ) }
|
|
30
|
+
</ul>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default BlockTypesChecklist;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { store as blocksStore } from '@wordpress/blocks';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { SearchControl, Button } from '@wordpress/components';
|
|
7
|
+
import { __, _n, sprintf } from '@wordpress/i18n';
|
|
8
|
+
import { useEffect, useState } from '@wordpress/element';
|
|
9
|
+
import { useDebounce } from '@wordpress/compose';
|
|
10
|
+
import { speak } from '@wordpress/a11y';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import BlockManagerCategory from './category';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Provides a list of blocks with checkboxes.
|
|
19
|
+
*
|
|
20
|
+
* @param {Object} props Props.
|
|
21
|
+
* @param {Array} props.blockTypes An array of blocks.
|
|
22
|
+
* @param {Array} props.selectedBlockTypes An array of selected blocks.
|
|
23
|
+
* @param {Function} props.onChange Function to be called when the selected blocks change.
|
|
24
|
+
*/
|
|
25
|
+
export default function BlockManager( {
|
|
26
|
+
blockTypes,
|
|
27
|
+
selectedBlockTypes,
|
|
28
|
+
onChange,
|
|
29
|
+
} ) {
|
|
30
|
+
const debouncedSpeak = useDebounce( speak, 500 );
|
|
31
|
+
const [ search, setSearch ] = useState( '' );
|
|
32
|
+
const { categories, isMatchingSearchTerm } = useSelect( ( select ) => {
|
|
33
|
+
return {
|
|
34
|
+
categories: select( blocksStore ).getCategories(),
|
|
35
|
+
isMatchingSearchTerm: select( blocksStore ).isMatchingSearchTerm,
|
|
36
|
+
};
|
|
37
|
+
}, [] );
|
|
38
|
+
|
|
39
|
+
function enableAllBlockTypes() {
|
|
40
|
+
onChange( blockTypes );
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const filteredBlockTypes = blockTypes.filter( ( blockType ) => {
|
|
44
|
+
return ! search || isMatchingSearchTerm( blockType, search );
|
|
45
|
+
} );
|
|
46
|
+
|
|
47
|
+
const numberOfHiddenBlocks = blockTypes.length - selectedBlockTypes.length;
|
|
48
|
+
|
|
49
|
+
// Announce search results on change
|
|
50
|
+
useEffect( () => {
|
|
51
|
+
if ( ! search ) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const count = filteredBlockTypes.length;
|
|
55
|
+
const resultsFoundMessage = sprintf(
|
|
56
|
+
/* translators: %d: number of results. */
|
|
57
|
+
_n( '%d result found.', '%d results found.', count ),
|
|
58
|
+
count
|
|
59
|
+
);
|
|
60
|
+
debouncedSpeak( resultsFoundMessage );
|
|
61
|
+
}, [ filteredBlockTypes?.length, search, debouncedSpeak ] );
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<div className="block-editor-block-manager__content">
|
|
65
|
+
{ !! numberOfHiddenBlocks && (
|
|
66
|
+
<div className="block-editor-block-manager__disabled-blocks-count">
|
|
67
|
+
{ sprintf(
|
|
68
|
+
/* translators: %d: number of blocks. */
|
|
69
|
+
_n(
|
|
70
|
+
'%d block is hidden.',
|
|
71
|
+
'%d blocks are hidden.',
|
|
72
|
+
numberOfHiddenBlocks
|
|
73
|
+
),
|
|
74
|
+
numberOfHiddenBlocks
|
|
75
|
+
) }
|
|
76
|
+
<Button
|
|
77
|
+
__next40pxDefaultSize
|
|
78
|
+
variant="link"
|
|
79
|
+
onClick={ enableAllBlockTypes }
|
|
80
|
+
>
|
|
81
|
+
{ __( 'Reset' ) }
|
|
82
|
+
</Button>
|
|
83
|
+
</div>
|
|
84
|
+
) }
|
|
85
|
+
<SearchControl
|
|
86
|
+
__nextHasNoMarginBottom
|
|
87
|
+
label={ __( 'Search for a block' ) }
|
|
88
|
+
placeholder={ __( 'Search for a block' ) }
|
|
89
|
+
value={ search }
|
|
90
|
+
onChange={ ( nextSearch ) => setSearch( nextSearch ) }
|
|
91
|
+
className="block-editor-block-manager__search"
|
|
92
|
+
/>
|
|
93
|
+
<div
|
|
94
|
+
tabIndex="0"
|
|
95
|
+
role="region"
|
|
96
|
+
aria-label={ __( 'Available block types' ) }
|
|
97
|
+
className="block-editor-block-manager__results"
|
|
98
|
+
>
|
|
99
|
+
{ filteredBlockTypes.length === 0 && (
|
|
100
|
+
<p className="block-editor-block-manager__no-results">
|
|
101
|
+
{ __( 'No blocks found.' ) }
|
|
102
|
+
</p>
|
|
103
|
+
) }
|
|
104
|
+
{ categories.map( ( category ) => (
|
|
105
|
+
<BlockManagerCategory
|
|
106
|
+
key={ category.slug }
|
|
107
|
+
title={ category.title }
|
|
108
|
+
blockTypes={ filteredBlockTypes.filter(
|
|
109
|
+
( blockType ) =>
|
|
110
|
+
blockType.category === category.slug
|
|
111
|
+
) }
|
|
112
|
+
selectedBlockTypes={ selectedBlockTypes }
|
|
113
|
+
onChange={ onChange }
|
|
114
|
+
/>
|
|
115
|
+
) ) }
|
|
116
|
+
<BlockManagerCategory
|
|
117
|
+
title={ __( 'Uncategorized' ) }
|
|
118
|
+
blockTypes={ filteredBlockTypes.filter(
|
|
119
|
+
( { category } ) => ! category
|
|
120
|
+
) }
|
|
121
|
+
selectedBlockTypes={ selectedBlockTypes }
|
|
122
|
+
onChange={ onChange }
|
|
123
|
+
/>
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
);
|
|
127
|
+
}
|