@wordpress/block-editor 12.15.0 → 12.16.1-next.79a6196f.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/LICENSE.md +1 -1
- package/README.md +12 -10
- package/build/components/block-canvas/index.js +21 -7
- package/build/components/block-canvas/index.js.map +1 -1
- package/build/components/block-card/index.js +2 -2
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-controls/hook.js +3 -23
- package/build/components/block-controls/hook.js.map +1 -1
- package/build/components/block-draggable/draggable-chip.js +6 -1
- package/build/components/block-draggable/draggable-chip.js.map +1 -1
- package/build/components/block-draggable/index.js +76 -6
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-draggable/index.native.js +0 -6
- package/build/components/block-draggable/index.native.js.map +1 -1
- package/build/components/block-draggable/use-scroll-when-dragging.native.js +1 -1
- package/build/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -1
- package/build/components/block-edit/context.js +5 -1
- package/build/components/block-edit/context.js.map +1 -1
- package/build/components/block-edit/index.js +18 -9
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-editing-mode/index.js +2 -3
- package/build/components/block-editing-mode/index.js.map +1 -1
- package/build/components/block-info-slot-fill/index.js +3 -4
- package/build/components/block-info-slot-fill/index.js.map +1 -1
- package/build/components/block-inspector/index.js +1 -1
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-list-item-cell.native.js +1 -0
- package/build/components/block-list/block-list-item-cell.native.js.map +1 -1
- package/build/components/block-list/block.js +257 -95
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +58 -23
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +3 -5
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/private-block-context.js +14 -0
- package/build/components/block-list/private-block-context.js.map +1 -0
- package/build/components/block-list/use-block-props/index.js +49 -69
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js +4 -29
- package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build/components/block-list/use-block-props/use-is-hovered.js +4 -14
- package/build/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +4 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +3 -2
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-list/use-scroll-upon-insertion.native.js +41 -0
- package/build/components/block-list/use-scroll-upon-insertion.native.js.map +1 -0
- package/build/components/block-lock/toolbar.js +21 -27
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-mover/index.js +2 -1
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +5 -5
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +2 -9
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-rename/modal.js +3 -0
- package/build/components/block-rename/modal.js.map +1 -1
- package/build/components/block-settings/container.native.js +6 -4
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-styles/index.js +1 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-styles/index.native.js +3 -2
- package/build/components/block-styles/index.native.js.map +1 -1
- package/build/components/block-switcher/index.js +4 -4
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +90 -29
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-toolbar-breadcrumb.js +49 -0
- package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -0
- package/build/components/block-tools/block-toolbar-popover.js +84 -0
- package/build/components/block-tools/block-toolbar-popover.js.map +1 -0
- package/build/components/block-tools/index.js +27 -24
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-types-list/index.native.js +4 -3
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/block-variation-picker/index.native.js +2 -1
- package/build/components/block-variation-picker/index.native.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +29 -2
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/border-radius-control/linked-button.js +1 -1
- package/build/components/border-radius-control/linked-button.js.map +1 -1
- package/build/components/colors/utils.js +10 -2
- package/build/components/colors/utils.js.map +1 -1
- package/build/components/colors/with-colors.js +6 -2
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/colors-gradients/control.js +28 -17
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/duotone-control/index.js +1 -4
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/font-sizes/utils.js +10 -2
- package/build/components/font-sizes/utils.js.map +1 -1
- package/build/components/global-styles/border-panel.js +2 -1
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +24 -21
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +4 -3
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +2 -1
- package/build/components/global-styles/effects-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +6 -3
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/get-global-styles-changes.js +192 -0
- package/build/components/global-styles/get-global-styles-changes.js.map +1 -0
- package/build/components/global-styles/hooks.js +3 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js +7 -1
- package/build/components/global-styles/image-settings-panel.js.map +1 -1
- package/build/components/global-styles/index.js +7 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +43 -36
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +22 -8
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +8 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/height-control/index.js +6 -2
- package/build/components/height-control/index.js.map +1 -1
- package/build/components/image-link-destinations/index.native.js +118 -0
- package/build/components/image-link-destinations/index.native.js.map +1 -0
- package/build/components/image-size-control/index.js +2 -2
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/index.native.js +14 -5
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/index.js +61 -22
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +18 -4
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-inner-block-template-sync.js +5 -6
- package/build/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +5 -9
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +10 -9
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/patterns-filter.js +10 -10
- package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +9 -9
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/utils.js +10 -14
- package/build/components/inserter/block-patterns-tab/utils.js.map +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js +4 -14
- package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-state.js +1 -1
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter/index.js +1 -2
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/library.js +3 -7
- package/build/components/inserter/library.js.map +1 -1
- package/build/components/inserter/media-tab/media-panel.js +2 -2
- package/build/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build/components/inserter/menu.js +26 -33
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/preview-panel.js +2 -2
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inserter/tabs.js +21 -21
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inserter-button/index.native.js +98 -0
- package/build/components/inserter-button/index.native.js.map +1 -0
- package/build/components/inserter-button/sparkles.js +23 -0
- package/build/components/inserter-button/sparkles.js.map +1 -0
- package/build/components/inserter-draggable-blocks/index.js +8 -4
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/inserter-list-item/index.js +2 -4
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +3 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls/fill.js +3 -3
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/inspector-controls/fill.native.js +3 -3
- package/build/components/inspector-controls/fill.native.js.map +1 -1
- package/build/components/inspector-controls-tabs/index.js +34 -23
- package/build/components/inspector-controls-tabs/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +4 -0
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +57 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/media-upload-progress/constants.js +19 -0
- package/build/components/media-upload-progress/constants.js.map +1 -0
- package/build/components/media-upload-progress/index.native.js +42 -17
- package/build/components/media-upload-progress/index.native.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +11 -16
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/plain-text/index.native.js +8 -3
- package/build/components/plain-text/index.native.js.map +1 -1
- package/build/components/preview-options/index.js +6 -62
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/provider/index.js +3 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/use-block-sync.js +7 -1
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/rich-text/content.js +26 -23
- package/build/components/rich-text/content.js.map +1 -1
- package/build/components/rich-text/get-rich-text-values.js +2 -1
- package/build/components/rich-text/get-rich-text-values.js.map +1 -1
- package/build/components/rich-text/index.js +19 -37
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +9 -16
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/native/get-format-colors.native.js +22 -24
- package/build/components/rich-text/native/get-format-colors.native.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +22 -57
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/components/rich-text/use-input-rules.js +7 -3
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/rich-text/use-mark-persistent.js +1 -1
- package/build/components/rich-text/use-mark-persistent.js.map +1 -1
- package/build/components/rich-text/with-deprecations.js +50 -0
- package/build/components/rich-text/with-deprecations.js.map +1 -0
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/url-input/index.js +9 -6
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-commands/index.js +14 -18
- package/build/components/use-block-commands/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +108 -17
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-moving-animation/index.js +100 -92
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +9 -12
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-resize-canvas/index.js +4 -1
- package/build/components/use-resize-canvas/index.js.map +1 -1
- package/build/components/use-settings/index.js +14 -0
- package/build/components/use-settings/index.js.map +1 -1
- package/build/components/writing-flow/index.js +0 -1
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-drag-selection.js +15 -4
- package/build/components/writing-flow/use-drag-selection.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +73 -27
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +7 -4
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/align.js +21 -69
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/align.native.js +11 -1
- package/build/hooks/align.native.js.map +1 -1
- package/build/hooks/anchor.js +14 -30
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/aria-label.js +9 -1
- package/build/hooks/aria-label.js.map +1 -1
- package/build/hooks/background.js +198 -36
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-hooks.js +24 -32
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-renaming.js +18 -22
- package/build/hooks/block-renaming.js.map +1 -1
- package/build/hooks/border.js +53 -80
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +79 -90
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +29 -29
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/custom-class-name.js +13 -30
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/custom-class-name.native.js +9 -1
- package/build/hooks/custom-class-name.native.js.map +1 -1
- package/build/hooks/dimensions.js +13 -14
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +31 -61
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/font-family.js +23 -28
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +52 -120
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/index.js +27 -16
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +15 -6
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/layout-child.js +68 -0
- package/build/hooks/layout-child.js.map +1 -0
- package/build/hooks/layout.js +25 -104
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/padding.js +2 -2
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/position.js +40 -62
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +52 -89
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/typography.js +25 -10
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/typography.native.js +43 -18
- package/build/hooks/typography.native.js.map +1 -1
- package/build/hooks/use-typography-props.js +10 -2
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/hooks/utils.js +200 -10
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +2 -6
- package/build/private-apis.js.map +1 -1
- package/build/private-apis.native.js +0 -2
- package/build/private-apis.native.js.map +1 -1
- package/build/store/actions.js +0 -16
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +54 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +46 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +18 -2
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +11 -73
- package/build/store/selectors.js.map +1 -1
- package/build/store/undo-ignore.js +12 -0
- package/build/store/undo-ignore.js.map +1 -0
- package/build/store/utils.js +66 -0
- package/build/store/utils.js.map +1 -0
- package/build/utils/get-px-from-css-unit.js +16 -0
- package/build/utils/get-px-from-css-unit.js.map +1 -0
- package/build/utils/index.js +2 -2
- package/build/utils/index.js.map +1 -1
- package/build/utils/object.js +38 -99
- package/build/utils/object.js.map +1 -1
- package/build/utils/selection.js +9 -1
- package/build/utils/selection.js.map +1 -1
- package/build/utils/use-can-block-toolbar-be-focused.js +46 -0
- package/build/utils/use-can-block-toolbar-be-focused.js.map +1 -0
- package/build-module/components/block-canvas/index.js +22 -8
- package/build-module/components/block-canvas/index.js.map +1 -1
- package/build-module/components/block-card/index.js +2 -2
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-controls/hook.js +4 -24
- package/build-module/components/block-controls/hook.js.map +1 -1
- package/build-module/components/block-draggable/draggable-chip.js +6 -1
- package/build-module/components/block-draggable/draggable-chip.js.map +1 -1
- package/build-module/components/block-draggable/index.js +76 -6
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-draggable/index.native.js +1 -7
- package/build-module/components/block-draggable/index.native.js.map +1 -1
- package/build-module/components/block-draggable/use-scroll-when-dragging.native.js +1 -1
- package/build-module/components/block-draggable/use-scroll-when-dragging.native.js.map +1 -1
- package/build-module/components/block-edit/context.js +2 -0
- package/build-module/components/block-edit/context.js.map +1 -1
- package/build-module/components/block-edit/index.js +19 -10
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-editing-mode/index.js +3 -4
- package/build-module/components/block-editing-mode/index.js.map +1 -1
- package/build-module/components/block-info-slot-fill/index.js +3 -3
- package/build-module/components/block-info-slot-fill/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +1 -1
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-list-item-cell.native.js +1 -0
- package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -1
- package/build-module/components/block-list/block.js +261 -99
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +60 -25
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +3 -5
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/private-block-context.js +6 -0
- package/build-module/components/block-list/private-block-context.js.map +1 -0
- package/build-module/components/block-list/use-block-props/index.js +50 -70
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js +4 -29
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-is-hovered.js +4 -14
- package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +4 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +3 -2
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-list/use-scroll-upon-insertion.native.js +33 -0
- package/build-module/components/block-list/use-scroll-upon-insertion.native.js.map +1 -0
- package/build-module/components/block-lock/toolbar.js +22 -28
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-mover/index.js +2 -1
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +6 -6
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +3 -10
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-rename/modal.js +3 -0
- package/build-module/components/block-rename/modal.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +4 -2
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-styles/index.js +1 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-styles/index.native.js +3 -2
- package/build-module/components/block-styles/index.native.js.map +1 -1
- package/build-module/components/block-switcher/index.js +4 -4
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +89 -27
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js +41 -0
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -0
- package/build-module/components/block-tools/block-toolbar-popover.js +74 -0
- package/build-module/components/block-tools/block-toolbar-popover.js.map +1 -0
- package/build-module/components/block-tools/index.js +27 -24
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +2 -1
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/block-variation-picker/index.native.js +2 -1
- package/build-module/components/block-variation-picker/index.native.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +30 -3
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/border-radius-control/linked-button.js +1 -1
- package/build-module/components/border-radius-control/linked-button.js.map +1 -1
- package/build-module/components/colors/utils.js +9 -1
- package/build-module/components/colors/utils.js.map +1 -1
- package/build-module/components/colors/with-colors.js +5 -1
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +29 -18
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/duotone-control/index.js +1 -4
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/font-sizes/utils.js +9 -1
- package/build-module/components/font-sizes/utils.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +3 -2
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +26 -23
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +5 -4
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +3 -2
- package/build-module/components/global-styles/effects-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +8 -5
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/get-global-styles-changes.js +184 -0
- package/build-module/components/global-styles/get-global-styles-changes.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +3 -2
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js +7 -1
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
- package/build-module/components/global-styles/index.js +1 -0
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +45 -38
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +15 -1
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +7 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/height-control/index.js +6 -2
- package/build-module/components/height-control/index.js.map +1 -1
- package/build-module/components/image-link-destinations/index.native.js +109 -0
- package/build-module/components/image-link-destinations/index.native.js.map +1 -0
- package/build-module/components/image-size-control/index.js +2 -2
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/index.native.js +3 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +62 -23
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +18 -4
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js +5 -6
- package/build-module/components/inner-blocks/use-inner-block-template-sync.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +6 -10
- package/build-module/components/inner-blocks/use-nested-settings-update.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/pattern-category-previews.js +11 -10
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js +11 -11
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +11 -11
- 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 +7 -11
- package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js +4 -14
- package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js +2 -2
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter/index.js +1 -2
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/library.js +3 -7
- package/build-module/components/inserter/library.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-panel.js +1 -1
- package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build-module/components/inserter/menu.js +26 -33
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +2 -2
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inserter/tabs.js +22 -22
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inserter-button/index.native.js +89 -0
- package/build-module/components/inserter-button/index.native.js.map +1 -0
- package/build-module/components/inserter-button/sparkles.js +15 -0
- package/build-module/components/inserter-button/sparkles.js.map +1 -0
- package/build-module/components/inserter-draggable-blocks/index.js +9 -5
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +2 -4
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +3 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +3 -3
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/inspector-controls/fill.native.js +3 -3
- package/build-module/components/inspector-controls/fill.native.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/index.js +35 -24
- package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +4 -0
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +58 -4
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/media-upload-progress/constants.js +7 -0
- package/build-module/components/media-upload-progress/constants.js.map +1 -0
- package/build-module/components/media-upload-progress/index.native.js +37 -8
- package/build-module/components/media-upload-progress/index.native.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +11 -16
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/plain-text/index.native.js +6 -1
- package/build-module/components/plain-text/index.native.js.map +1 -1
- package/build-module/components/preview-options/index.js +6 -62
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/provider/index.js +3 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +7 -1
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/rich-text/content.js +25 -21
- package/build-module/components/rich-text/content.js.map +1 -1
- package/build-module/components/rich-text/get-rich-text-values.js +2 -1
- package/build-module/components/rich-text/get-rich-text-values.js.map +1 -1
- package/build-module/components/rich-text/index.js +21 -39
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +10 -18
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/get-format-colors.native.js +22 -24
- package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +22 -56
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-input-rules.js +7 -3
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/rich-text/use-mark-persistent.js +1 -1
- package/build-module/components/rich-text/use-mark-persistent.js.map +1 -1
- package/build-module/components/rich-text/with-deprecations.js +42 -0
- package/build-module/components/rich-text/with-deprecations.js.map +1 -0
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/url-input/index.js +9 -6
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-commands/index.js +14 -18
- package/build-module/components/use-block-commands/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +107 -18
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +102 -94
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +9 -12
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-resize-canvas/index.js +4 -1
- package/build-module/components/use-resize-canvas/index.js.map +1 -1
- package/build-module/components/use-settings/index.js +13 -1
- package/build-module/components/use-settings/index.js.map +1 -1
- package/build-module/components/writing-flow/index.js +0 -1
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-drag-selection.js +15 -4
- package/build-module/components/writing-flow/use-drag-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +73 -27
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +7 -4
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/align.js +20 -67
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/align.native.js +1 -0
- package/build-module/hooks/align.native.js.map +1 -1
- package/build-module/hooks/anchor.js +12 -27
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/aria-label.js +7 -1
- package/build-module/hooks/aria-label.js.map +1 -1
- package/build-module/hooks/background.js +197 -37
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-hooks.js +22 -30
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-renaming.js +17 -21
- package/build-module/hooks/block-renaming.js.map +1 -1
- package/build-module/hooks/border.js +52 -79
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +78 -88
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +27 -27
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +12 -28
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/custom-class-name.native.js +7 -1
- package/build-module/hooks/custom-class-name.native.js.map +1 -1
- package/build-module/hooks/dimensions.js +15 -16
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +30 -61
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/font-family.js +20 -25
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +50 -120
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/index.js +20 -16
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/index.native.js +10 -6
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/layout-child.js +60 -0
- package/build-module/hooks/layout-child.js.map +1 -0
- package/build-module/hooks/layout.js +21 -100
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/padding.js +2 -2
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/position.js +38 -59
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +52 -85
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/typography.js +26 -11
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/typography.native.js +43 -17
- package/build-module/hooks/typography.native.js.map +1 -1
- package/build-module/hooks/use-typography-props.js +9 -1
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/hooks/utils.js +194 -9
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +2 -6
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-apis.native.js +0 -2
- package/build-module/private-apis.native.js.map +1 -1
- package/build-module/store/actions.js +0 -15
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +52 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +44 -1
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +18 -2
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +4 -65
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/undo-ignore.js +5 -0
- package/build-module/store/undo-ignore.js.map +1 -0
- package/build-module/store/utils.js +56 -0
- package/build-module/store/utils.js.map +1 -0
- package/build-module/utils/get-px-from-css-unit.js +9 -0
- package/build-module/utils/get-px-from-css-unit.js.map +1 -0
- package/build-module/utils/index.js +1 -1
- package/build-module/utils/index.js.map +1 -1
- package/build-module/utils/object.js +37 -97
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/selection.js +9 -1
- package/build-module/utils/selection.js.map +1 -1
- package/build-module/utils/use-can-block-toolbar-be-focused.js +40 -0
- package/build-module/utils/use-can-block-toolbar-be-focused.js.map +1 -0
- package/build-style/content-rtl.css +7 -6
- package/build-style/content.css +7 -6
- package/build-style/style-rtl.css +164 -301
- package/build-style/style.css +164 -301
- package/package.json +31 -31
- package/src/components/alignment-control/README.md +0 -5
- package/src/components/block-alignment-control/README.md +0 -5
- package/src/components/block-alignment-matrix-control/README.md +0 -10
- package/src/components/block-breadcrumb/README.md +0 -5
- package/src/components/block-canvas/index.js +29 -17
- package/src/components/block-canvas/style.scss +6 -0
- package/src/components/block-caption/README.md +2 -7
- package/src/components/block-card/README.md +0 -5
- package/src/components/block-card/index.js +6 -4
- package/src/components/block-card/style.scss +7 -3
- package/src/components/block-controls/hook.js +8 -30
- package/src/components/block-controls/test/index.js +3 -3
- package/src/components/block-draggable/draggable-chip.js +11 -1
- package/src/components/block-draggable/index.js +116 -4
- package/src/components/block-draggable/index.native.js +0 -5
- package/src/components/block-draggable/style.scss +35 -0
- package/src/components/block-draggable/test/helpers.native.js +8 -7
- package/src/components/block-draggable/use-scroll-when-dragging.native.js +1 -1
- package/src/components/block-edit/context.js +3 -0
- package/src/components/block-edit/index.js +36 -10
- package/src/components/block-editing-mode/index.js +3 -3
- package/src/components/block-icon/README.md +0 -5
- package/src/components/block-info-slot-fill/index.js +6 -3
- package/src/components/block-inspector/README.md +0 -5
- package/src/components/block-inspector/index.js +3 -1
- package/src/components/block-inspector/style.scss +0 -4
- package/src/components/block-list/block-list-item-cell.native.js +5 -1
- package/src/components/block-list/block.js +309 -104
- package/src/components/block-list/block.native.js +69 -21
- package/src/components/block-list/content.scss +14 -10
- package/src/components/block-list/index.native.js +3 -5
- package/src/components/block-list/{block-list-block-context.js → private-block-context.js} +1 -1
- package/src/components/block-list/use-block-props/index.js +43 -86
- package/src/components/block-list/use-block-props/use-focus-first-element.js +1 -34
- package/src/components/block-list/use-block-props/use-is-hovered.js +2 -13
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +1 -5
- package/src/components/block-list/use-in-between-inserter.js +4 -1
- package/src/components/block-list/use-scroll-upon-insertion.native.js +52 -0
- package/src/components/block-lock/toolbar.js +23 -34
- package/src/components/block-mover/README.md +0 -5
- package/src/components/block-mover/index.js +1 -1
- package/src/components/block-parent-selector/README.md +0 -5
- package/src/components/block-patterns-list/README.md +0 -5
- package/src/components/block-patterns-list/index.js +9 -6
- package/src/components/block-removal-warning-modal/index.js +7 -14
- package/src/components/block-rename/modal.js +7 -1
- package/src/components/block-settings/container.native.js +3 -5
- package/src/components/block-styles/index.js +1 -1
- package/src/components/block-styles/index.native.js +4 -2
- package/src/components/block-styles/style.scss +0 -11
- package/src/components/block-switcher/index.js +49 -59
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +3 -1
- package/src/components/block-toolbar/README.md +0 -5
- package/src/components/block-toolbar/index.js +179 -95
- package/src/components/block-toolbar/style.scss +50 -66
- package/src/components/block-tools/block-toolbar-breadcrumb.js +46 -0
- package/src/components/block-tools/block-toolbar-popover.js +84 -0
- package/src/components/block-tools/index.js +42 -29
- package/src/components/block-tools/style.scss +60 -172
- package/src/components/block-types-list/README.md +0 -5
- package/src/components/block-types-list/index.native.js +2 -1
- package/src/components/block-variation-picker/README.md +0 -5
- package/src/components/block-variation-picker/index.native.js +1 -1
- package/src/components/block-variation-transforms/README.md +0 -5
- package/src/components/block-variation-transforms/index.js +49 -3
- package/src/components/border-radius-control/linked-button.js +1 -1
- package/src/components/caption/README.md +0 -5
- package/src/components/color-palette/test/__snapshots__/control.js.snap +0 -1
- package/src/components/colors/utils.js +8 -1
- package/src/components/colors/with-colors.js +3 -1
- package/src/components/colors-gradients/control.js +49 -30
- package/src/components/colors-gradients/style.scss +0 -7
- package/src/components/contrast-checker/README.md +0 -4
- package/src/components/copy-handler/README.md +0 -10
- package/src/components/duotone-control/index.js +2 -5
- package/src/components/duotone-control/style.scss +1 -6
- package/src/components/font-sizes/utils.js +7 -1
- package/src/components/global-styles/border-panel.js +2 -1
- package/src/components/global-styles/color-panel.js +36 -26
- package/src/components/global-styles/dimensions-panel.js +4 -3
- package/src/components/global-styles/effects-panel.js +2 -1
- package/src/components/global-styles/filters-panel.js +6 -5
- package/src/components/global-styles/get-global-styles-changes.js +210 -0
- package/src/components/global-styles/hooks.js +5 -0
- package/src/components/global-styles/image-settings-panel.js +6 -0
- package/src/components/global-styles/index.js +1 -0
- package/src/components/global-styles/test/get-global-styles-changes.js +234 -0
- package/src/components/global-styles/typography-panel.js +60 -47
- package/src/components/global-styles/use-global-styles-output.js +9 -5
- package/src/components/global-styles/utils.js +7 -0
- package/src/components/height-control/README.md +2 -7
- package/src/components/height-control/index.js +4 -0
- package/src/components/image-link-destinations/index.native.js +152 -0
- package/src/components/image-link-destinations/style.native.scss +16 -0
- package/src/components/image-size-control/index.js +5 -2
- package/src/components/index.native.js +3 -2
- package/src/components/inner-blocks/README.md +13 -2
- package/src/components/inner-blocks/index.js +68 -29
- package/src/components/inner-blocks/index.native.js +19 -7
- package/src/components/inner-blocks/use-inner-block-template-sync.js +5 -7
- package/src/components/inner-blocks/use-nested-settings-update.js +6 -13
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +15 -15
- package/src/components/inserter/block-patterns-tab/patterns-filter.js +15 -13
- package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +15 -18
- package/src/components/inserter/block-patterns-tab/utils.js +11 -12
- package/src/components/inserter/hooks/use-block-types-state.js +9 -11
- package/src/components/inserter/hooks/use-patterns-state.js +2 -2
- package/src/components/inserter/index.js +0 -1
- package/src/components/inserter/library.js +2 -8
- package/src/components/inserter/media-tab/media-panel.js +1 -1
- package/src/components/inserter/menu.js +26 -36
- package/src/components/inserter/preview-panel.js +2 -2
- package/src/components/inserter/style.scss +21 -21
- package/src/components/inserter/tabs.js +34 -25
- package/src/components/inserter-button/README.md +62 -0
- package/src/components/inserter-button/index.native.js +116 -0
- package/src/components/inserter-button/sparkles.js +15 -0
- package/src/components/inserter-button/style.native.scss +72 -0
- package/src/components/inserter-draggable-blocks/index.js +18 -5
- package/src/components/inserter-list-item/index.js +6 -6
- package/src/components/inspector-controls/block-support-tools-panel.js +2 -0
- package/src/components/inspector-controls/fill.js +6 -3
- package/src/components/inspector-controls/fill.native.js +6 -3
- package/src/components/inspector-controls-tabs/index.js +39 -28
- package/src/components/inspector-controls-tabs/style.scss +3 -2
- package/src/components/letter-spacing-control/README.md +0 -5
- package/src/components/line-height-control/README.md +0 -5
- package/src/components/link-control/style.scss +1 -1
- package/src/components/link-control/test/index.js +1 -1
- package/src/components/list-view/README.md +0 -5
- package/src/components/list-view/block-select-button.js +4 -0
- package/src/components/list-view/block.js +73 -2
- package/src/components/list-view/style.scss +6 -0
- package/src/components/media-upload-progress/constants.js +6 -0
- package/src/components/media-upload-progress/index.native.js +66 -14
- package/src/components/media-upload-progress/test/index.native.js +2 -2
- package/src/components/multi-selection-inspector/README.md +0 -5
- package/src/components/navigable-toolbar/README.md +2 -0
- package/src/components/navigable-toolbar/index.js +15 -13
- package/src/components/plain-text/index.native.js +6 -1
- package/src/components/preview-options/index.js +6 -86
- package/src/components/provider/index.js +1 -1
- package/src/components/provider/test/use-block-sync.js +20 -17
- package/src/components/provider/use-block-sync.js +6 -0
- package/src/components/rich-text/content.js +27 -20
- package/src/components/rich-text/get-rich-text-values.js +6 -1
- package/src/components/rich-text/index.js +23 -52
- package/src/components/rich-text/index.native.js +8 -25
- package/src/components/rich-text/native/get-format-colors.native.js +33 -40
- package/src/components/rich-text/native/index.native.js +22 -71
- package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +3 -3
- package/src/components/rich-text/native/test/index.native.js +72 -5
- package/src/components/rich-text/use-input-rules.js +8 -3
- package/src/components/rich-text/use-mark-persistent.js +1 -2
- package/src/components/rich-text/with-deprecations.js +51 -0
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +1 -1
- package/src/components/text-decoration-control/README.md +40 -0
- package/src/components/text-transform-control/README.md +0 -4
- package/src/components/ungroup-button/README.md +0 -5
- package/src/components/unit-control/README.md +0 -4
- package/src/components/url-input/index.js +11 -11
- package/src/components/use-block-commands/index.js +18 -21
- package/src/components/use-block-drop-zone/index.js +181 -30
- package/src/components/use-moving-animation/index.js +107 -103
- package/src/components/use-on-block-drop/index.js +9 -24
- package/src/components/use-on-block-drop/test/index.js +12 -26
- package/src/components/use-resize-canvas/README.md +3 -7
- package/src/components/use-resize-canvas/index.js +4 -1
- package/src/components/use-settings/README.md +0 -4
- package/src/components/use-settings/index.js +15 -1
- package/src/components/writing-flow/index.js +0 -1
- package/src/components/writing-flow/use-drag-selection.js +18 -4
- package/src/components/writing-flow/use-selection-observer.js +99 -37
- package/src/components/writing-flow/use-tab-nav.js +7 -7
- package/src/hooks/align.js +16 -81
- package/src/hooks/align.native.js +1 -0
- package/src/hooks/anchor.js +14 -38
- package/src/hooks/aria-label.js +8 -5
- package/src/hooks/background.js +269 -32
- package/src/hooks/block-hooks.js +22 -51
- package/src/hooks/block-renaming.js +23 -37
- package/src/hooks/border.js +62 -124
- package/src/hooks/color.js +111 -138
- package/src/hooks/content-lock-ui.js +110 -122
- package/src/hooks/custom-class-name.js +9 -45
- package/src/hooks/custom-class-name.native.js +8 -5
- package/src/hooks/dimensions.js +14 -16
- package/src/hooks/duotone.js +70 -127
- package/src/hooks/font-family.js +14 -36
- package/src/hooks/font-size.js +67 -168
- package/src/hooks/index.js +58 -16
- package/src/hooks/index.native.js +22 -6
- package/src/hooks/layout-child.js +53 -0
- package/src/hooks/layout.js +17 -103
- package/src/hooks/padding.js +2 -2
- package/src/hooks/position.js +50 -90
- package/src/hooks/style.js +118 -193
- package/src/hooks/test/align.js +1 -178
- package/src/hooks/test/anchor.js +4 -9
- package/src/hooks/test/custom-class-name.js +3 -8
- package/src/hooks/test/style.js +4 -14
- package/src/hooks/typography.js +14 -16
- package/src/hooks/typography.native.js +31 -33
- package/src/hooks/use-typography-props.js +7 -1
- package/src/hooks/utils.js +261 -10
- package/src/private-apis.js +2 -6
- package/src/private-apis.native.js +0 -2
- package/src/store/actions.js +0 -15
- package/src/store/private-actions.js +48 -0
- package/src/store/private-selectors.js +56 -0
- package/src/store/reducer.js +20 -1
- package/src/store/selectors.js +10 -82
- package/src/store/undo-ignore.js +4 -0
- package/src/store/utils.js +74 -0
- package/src/style.scss +1 -2
- package/src/utils/get-px-from-css-unit.js +8 -0
- package/src/utils/index.js +1 -1
- package/src/utils/object.js +34 -104
- package/src/utils/selection.js +9 -2
- package/src/utils/test/object.js +1 -96
- package/src/utils/use-can-block-toolbar-be-focused.js +48 -0
- package/build/components/block-list/block-list-block-context.js +0 -14
- package/build/components/block-list/block-list-block-context.js.map +0 -1
- package/build/components/block-list/use-block-props/use-block-class-names.js +0 -67
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +0 -1
- package/build/components/block-list/use-block-props/use-block-custom-class-name.js +0 -46
- package/build/components/block-list/use-block-props/use-block-custom-class-name.js.map +0 -1
- package/build/components/block-list/use-block-props/use-block-default-class-name.js +0 -37
- package/build/components/block-list/use-block-props/use-block-default-class-name.js.map +0 -1
- package/build/components/block-tools/back-compat.js +0 -45
- package/build/components/block-tools/back-compat.js.map +0 -1
- package/build/components/block-tools/block-contextual-toolbar.js +0 -91
- package/build/components/block-tools/block-contextual-toolbar.js.map +0 -1
- package/build/components/block-tools/selected-block-tools.js +0 -113
- package/build/components/block-tools/selected-block-tools.js.map +0 -1
- package/build/components/inserter/hooks/use-debounced-input.js +0 -22
- package/build/components/inserter/hooks/use-debounced-input.js.map +0 -1
- package/build/components/use-display-block-controls/index.js +0 -39
- package/build/components/use-display-block-controls/index.js.map +0 -1
- package/build/components/use-display-block-controls/index.native.js +0 -39
- package/build/components/use-display-block-controls/index.native.js.map +0 -1
- package/build/hooks/custom-fields.js +0 -120
- package/build/hooks/custom-fields.js.map +0 -1
- package/build/utils/parse-css-unit-to-px.js +0 -302
- package/build/utils/parse-css-unit-to-px.js.map +0 -1
- package/build/utils/use-should-contextual-toolbar-show.js +0 -63
- package/build/utils/use-should-contextual-toolbar-show.js.map +0 -1
- package/build-module/components/block-list/block-list-block-context.js +0 -6
- package/build-module/components/block-list/block-list-block-context.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +0 -60
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js +0 -40
- package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-block-default-class-name.js +0 -31
- package/build-module/components/block-list/use-block-props/use-block-default-class-name.js.map +0 -1
- package/build-module/components/block-tools/back-compat.js +0 -35
- package/build-module/components/block-tools/back-compat.js.map +0 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +0 -83
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +0 -1
- package/build-module/components/block-tools/selected-block-tools.js +0 -105
- package/build-module/components/block-tools/selected-block-tools.js.map +0 -1
- package/build-module/components/inserter/hooks/use-debounced-input.js +0 -15
- package/build-module/components/inserter/hooks/use-debounced-input.js.map +0 -1
- package/build-module/components/use-display-block-controls/index.js +0 -32
- package/build-module/components/use-display-block-controls/index.js.map +0 -1
- package/build-module/components/use-display-block-controls/index.native.js +0 -32
- package/build-module/components/use-display-block-controls/index.native.js.map +0 -1
- package/build-module/hooks/custom-fields.js +0 -118
- package/build-module/hooks/custom-fields.js.map +0 -1
- package/build-module/utils/parse-css-unit-to-px.js +0 -294
- package/build-module/utils/parse-css-unit-to-px.js.map +0 -1
- package/build-module/utils/use-should-contextual-toolbar-show.js +0 -57
- package/build-module/utils/use-should-contextual-toolbar-show.js.map +0 -1
- package/src/components/block-list/use-block-props/use-block-class-names.js +0 -66
- package/src/components/block-list/use-block-props/use-block-custom-class-name.js +0 -44
- package/src/components/block-list/use-block-props/use-block-default-class-name.js +0 -35
- package/src/components/block-parent-selector/style.scss +0 -11
- package/src/components/block-tools/back-compat.js +0 -35
- package/src/components/block-tools/block-contextual-toolbar.js +0 -100
- package/src/components/block-tools/selected-block-tools.js +0 -127
- package/src/components/inserter/hooks/use-debounced-input.js +0 -18
- package/src/components/preview-options/README.md +0 -94
- package/src/components/preview-options/style.scss +0 -64
- package/src/components/use-display-block-controls/index.js +0 -36
- package/src/components/use-display-block-controls/index.native.js +0 -37
- package/src/hooks/custom-fields.js +0 -142
- package/src/hooks/test/color.js +0 -112
- package/src/utils/parse-css-unit-to-px.js +0 -329
- package/src/utils/test/parse-css-unit-to-px.js +0 -172
- package/src/utils/use-should-contextual-toolbar-show.js +0 -85
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["fastDeepEqual","useRef","useLayoutEffect","useSelect","useDispatch","synchronizeBlocksWithTemplate","store","blockEditorStore","useInnerBlockTemplateSync","clientId","template","templateLock","templateInsertUpdatesSelection","getBlocks","getSelectedBlocksInitialCaretPosition","isBlockSelected","replaceInnerBlocks","__unstableMarkNextChangeAsNotPersistent","
|
|
1
|
+
{"version":3,"names":["fastDeepEqual","useRef","useLayoutEffect","useSelect","useDispatch","synchronizeBlocksWithTemplate","store","blockEditorStore","useInnerBlockTemplateSync","clientId","innerBlocks","template","templateLock","templateInsertUpdatesSelection","getBlocks","getSelectedBlocksInitialCaretPosition","isBlockSelected","replaceInnerBlocks","__unstableMarkNextChangeAsNotPersistent","existingTemplate","isCancelled","window","queueMicrotask","currentInnerBlocks","shouldApplyTemplate","length","hasTemplateChanged","current","nextBlocks"],"sources":["@wordpress/block-editor/src/components/inner-blocks/use-inner-block-template-sync.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useLayoutEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { synchronizeBlocksWithTemplate } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * This hook makes sure that a block's inner blocks stay in sync with the given\n * block \"template\". The template is a block hierarchy to which inner blocks must\n * conform. If the blocks get \"out of sync\" with the template and the template\n * is meant to be locked (e.g. templateLock = \"all\" or templateLock = \"contentOnly\"),\n * then we replace the inner blocks with the correct value after synchronizing it with the template.\n *\n * @param {string} clientId The block client ID.\n * @param {Array} innerBlocks\n * @param {Object} template The template to match.\n * @param {string} templateLock The template lock state for the inner blocks. For\n * example, if the template lock is set to \"all\",\n * then the inner blocks will stay in sync with the\n * template. If not defined or set to false, then\n * the inner blocks will not be synchronized with\n * the given template.\n * @param {boolean} templateInsertUpdatesSelection Whether or not to update the\n * block-editor selection state when inner blocks\n * are replaced after template synchronization.\n */\nexport default function useInnerBlockTemplateSync(\n\tclientId,\n\tinnerBlocks,\n\ttemplate,\n\ttemplateLock,\n\ttemplateInsertUpdatesSelection\n) {\n\t// Instead of adding a useSelect mapping here, please add to the useSelect\n\t// mapping in InnerBlocks! Every subscription impacts performance.\n\n\tconst {\n\t\tgetBlocks,\n\t\tgetSelectedBlocksInitialCaretPosition,\n\t\tisBlockSelected,\n\t} = useSelect( blockEditorStore );\n\tconst { replaceInnerBlocks, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Maintain a reference to the previous value so we can do a deep equality check.\n\tconst existingTemplate = useRef( null );\n\n\tuseLayoutEffect( () => {\n\t\tlet isCancelled = false;\n\n\t\t// There's an implicit dependency between useInnerBlockTemplateSync and useNestedSettingsUpdate\n\t\t// The former needs to happen after the latter and since the latter is using microtasks to batch updates (performance optimization),\n\t\t// we need to schedule this one in a microtask as well.\n\t\t// Example: If you remove queueMicrotask here, ctrl + click to insert quote block won't close the inserter.\n\t\twindow.queueMicrotask( () => {\n\t\t\tif ( isCancelled ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Only synchronize innerBlocks with template if innerBlocks are empty\n\t\t\t// or a locking \"all\" or \"contentOnly\" exists directly on the block.\n\t\t\tconst currentInnerBlocks = getBlocks( clientId );\n\t\t\tconst shouldApplyTemplate =\n\t\t\t\tcurrentInnerBlocks.length === 0 ||\n\t\t\t\ttemplateLock === 'all' ||\n\t\t\t\ttemplateLock === 'contentOnly';\n\n\t\t\tconst hasTemplateChanged = ! fastDeepEqual(\n\t\t\t\ttemplate,\n\t\t\t\texistingTemplate.current\n\t\t\t);\n\n\t\t\tif ( ! shouldApplyTemplate || ! hasTemplateChanged ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\texistingTemplate.current = template;\n\t\t\tconst nextBlocks = synchronizeBlocksWithTemplate(\n\t\t\t\tcurrentInnerBlocks,\n\t\t\t\ttemplate\n\t\t\t);\n\n\t\t\tif ( ! fastDeepEqual( nextBlocks, currentInnerBlocks ) ) {\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\tclientId,\n\t\t\t\t\tnextBlocks,\n\t\t\t\t\tcurrentInnerBlocks.length === 0 &&\n\t\t\t\t\t\ttemplateInsertUpdatesSelection &&\n\t\t\t\t\t\tnextBlocks.length !== 0 &&\n\t\t\t\t\t\tisBlockSelected( clientId ),\n\t\t\t\t\t// This ensures the \"initialPosition\" doesn't change when applying the template\n\t\t\t\t\t// If we're supposed to focus the block, we'll focus the first inner block\n\t\t\t\t\t// otherwise, we won't apply any auto-focus.\n\t\t\t\t\t// This ensures for instance that the focus stays in the inserter when inserting the \"buttons\" block.\n\t\t\t\t\tgetSelectedBlocksInitialCaretPosition()\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn () => {\n\t\t\tisCancelled = true;\n\t\t};\n\t}, [ innerBlocks, template, templateLock, clientId ] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,qBAAqB;;AAE/C;AACA;AACA;AACA,SAASC,MAAM,EAAEC,eAAe,QAAQ,oBAAoB;AAC5D,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,6BAA6B,QAAQ,mBAAmB;;AAEjE;AACA;AACA;AACA,SAASC,K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L,kBAAkB,CAACE,MAAM,KAAK,CAAC,IAC9BZ,8BAA8B,IAC9Be,UAAU,CAACH,MAAM,KAAK,CAAC,IACvBT,eAAe,CAAEP,QAAS,CAAC;QAC5B;QACA;QACA;QACA;QACAM,qCAAqC,CAAC,CACvC,CAAC;MACF;IACD,CAAE,CAAC;IAEH,OAAO,MAAM;MACZK,WAAW,GAAG,IAAI;IACnB,CAAC;EACF,CAAC,EAAE,CAAEV,WAAW,EAAEC,QAAQ,EAAEC,YAAY,EAAEH,QAAQ,CAAG,CAAC;AACvD"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useLayoutEffect, useMemo, useState } from '@wordpress/element';
|
|
5
|
-
import {
|
|
5
|
+
import { useDispatch, useRegistry } from '@wordpress/data';
|
|
6
6
|
import deprecated from '@wordpress/deprecated';
|
|
7
7
|
import isShallowEqual from '@wordpress/is-shallow-equal';
|
|
8
8
|
|
|
@@ -31,6 +31,7 @@ function useShallowMemo(value) {
|
|
|
31
31
|
* came from props.
|
|
32
32
|
*
|
|
33
33
|
* @param {string} clientId The client ID of the block to update.
|
|
34
|
+
* @param {string} parentLock
|
|
34
35
|
* @param {string[]} allowedBlocks An array of block names which are permitted
|
|
35
36
|
* in inner blocks.
|
|
36
37
|
* @param {string[]} prioritizedInserterBlocks Block names and/or block variations to be prioritized in the inserter, in the format {blockName}/{variationName}.
|
|
@@ -50,19 +51,14 @@ function useShallowMemo(value) {
|
|
|
50
51
|
* should face.
|
|
51
52
|
* @param {Object} layout The layout object for the block container.
|
|
52
53
|
*/
|
|
53
|
-
export default function useNestedSettingsUpdate(clientId, allowedBlocks, prioritizedInserterBlocks, defaultBlock, directInsert, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, captureToolbars, orientation, layout) {
|
|
54
|
+
export default function useNestedSettingsUpdate(clientId, parentLock, allowedBlocks, prioritizedInserterBlocks, defaultBlock, directInsert, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, captureToolbars, orientation, layout) {
|
|
55
|
+
// Instead of adding a useSelect mapping here, please add to the useSelect
|
|
56
|
+
// mapping in InnerBlocks! Every subscription impacts performance.
|
|
57
|
+
|
|
54
58
|
const {
|
|
55
59
|
updateBlockListSettings
|
|
56
60
|
} = useDispatch(blockEditorStore);
|
|
57
61
|
const registry = useRegistry();
|
|
58
|
-
const {
|
|
59
|
-
parentLock
|
|
60
|
-
} = useSelect(select => {
|
|
61
|
-
const rootClientId = select(blockEditorStore).getBlockRootClientId(clientId);
|
|
62
|
-
return {
|
|
63
|
-
parentLock: select(blockEditorStore).getTemplateLock(rootClientId)
|
|
64
|
-
};
|
|
65
|
-
}, [clientId]);
|
|
66
62
|
|
|
67
63
|
// Implementors often pass a new array on every render,
|
|
68
64
|
// and the contents of the arrays are just strings, so the entire array
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useLayoutEffect","useMemo","useState","useSelect","useDispatch","useRegistry","deprecated","isShallowEqual","store","blockEditorStore","getLayoutType","pendingSettingsUpdates","WeakMap","useShallowMemo","value","prevValue","setPrevValue","useNestedSettingsUpdate","clientId","allowedBlocks","prioritizedInserterBlocks","defaultBlock","directInsert","__experimentalDefaultBlock","__experimentalDirectInsert","templateLock","captureToolbars","orientation","layout","updateBlockListSettings","registry","parentLock","select","rootClientId","getBlockRootClientId","getTemplateLock","_allowedBlocks","_prioritizedInserterBlocks","_templateLock","undefined","newSettings","__experimentalCaptureToolbars","layoutType","type","getOrientation","alternative","since","version","get","set","push","window","queueMicrotask","length","batch","forEach","args"],"sources":["@wordpress/block-editor/src/components/inner-blocks/use-nested-settings-update.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useMemo, useState } from '@wordpress/element';\nimport { useSelect, useDispatch, useRegistry } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getLayoutType } from '../../layouts';\n\n/** @typedef {import('../../selectors').WPDirectInsertBlock } WPDirectInsertBlock */\n\nconst pendingSettingsUpdates = new WeakMap();\n\nfunction useShallowMemo( value ) {\n\tconst [ prevValue, setPrevValue ] = useState( value );\n\tif ( ! isShallowEqual( prevValue, value ) ) {\n\t\tsetPrevValue( value );\n\t}\n\treturn prevValue;\n}\n\n/**\n * This hook is a side effect which updates the block-editor store when changes\n * happen to inner block settings. The given props are transformed into a\n * settings object, and if that is different from the current settings object in\n * the block-editor store, then the store is updated with the new settings which\n * came from props.\n *\n * @param {string} clientId The client ID of the block to update.\n * @param {string[]} allowedBlocks An array of block names which are permitted\n * in inner blocks.\n * @param {string[]} prioritizedInserterBlocks Block names and/or block variations to be prioritized in the inserter, in the format {blockName}/{variationName}.\n * @param {?WPDirectInsertBlock} defaultBlock The default block to insert: [ blockName, { blockAttributes } ].\n * @param {?Function|boolean} directInsert If a default block should be inserted directly by the appender.\n *\n * @param {?WPDirectInsertBlock} __experimentalDefaultBlock A deprecated prop for the default block to insert: [ blockName, { blockAttributes } ]. Use `defaultBlock` instead.\n *\n * @param {?Function|boolean} __experimentalDirectInsert A deprecated prop for whether a default block should be inserted directly by the appender. Use `directInsert` instead.\n *\n * @param {string} [templateLock] The template lock specified for the inner\n * blocks component. (e.g. \"all\")\n * @param {boolean} captureToolbars Whether or children toolbars should be shown\n * in the inner blocks component rather than on\n * the child block.\n * @param {string} orientation The direction in which the block\n * should face.\n * @param {Object} layout The layout object for the block container.\n */\nexport default function useNestedSettingsUpdate(\n\tclientId,\n\tallowedBlocks,\n\tprioritizedInserterBlocks,\n\tdefaultBlock,\n\tdirectInsert,\n\t__experimentalDefaultBlock,\n\t__experimentalDirectInsert,\n\ttemplateLock,\n\tcaptureToolbars,\n\torientation,\n\tlayout\n) {\n\tconst { updateBlockListSettings } = useDispatch( blockEditorStore );\n\tconst registry = useRegistry();\n\n\tconst { parentLock } = useSelect(\n\t\t( select ) => {\n\t\t\tconst rootClientId =\n\t\t\t\tselect( blockEditorStore ).getBlockRootClientId( clientId );\n\t\t\treturn {\n\t\t\t\tparentLock:\n\t\t\t\t\tselect( blockEditorStore ).getTemplateLock( rootClientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// Implementors often pass a new array on every render,\n\t// and the contents of the arrays are just strings, so the entire array\n\t// can be passed as dependencies but We need to include the length of the array,\n\t// otherwise if the arrays change length but the first elements are equal the comparison,\n\t// does not works as expected.\n\tconst _allowedBlocks = useShallowMemo( allowedBlocks );\n\n\tconst _prioritizedInserterBlocks = useMemo(\n\t\t() => prioritizedInserterBlocks,\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\tprioritizedInserterBlocks\n\t);\n\n\tconst _templateLock =\n\t\ttemplateLock === undefined || parentLock === 'contentOnly'\n\t\t\t? parentLock\n\t\t\t: templateLock;\n\n\tuseLayoutEffect( () => {\n\t\tconst newSettings = {\n\t\t\tallowedBlocks: _allowedBlocks,\n\t\t\tprioritizedInserterBlocks: _prioritizedInserterBlocks,\n\t\t\ttemplateLock: _templateLock,\n\t\t};\n\n\t\t// These values are not defined for RN, so only include them if they\n\t\t// are defined.\n\t\tif ( captureToolbars !== undefined ) {\n\t\t\tnewSettings.__experimentalCaptureToolbars = captureToolbars;\n\t\t}\n\n\t\t// Orientation depends on layout,\n\t\t// ideally the separate orientation prop should be deprecated.\n\t\tif ( orientation !== undefined ) {\n\t\t\tnewSettings.orientation = orientation;\n\t\t} else {\n\t\t\tconst layoutType = getLayoutType( layout?.type );\n\t\t\tnewSettings.orientation = layoutType.getOrientation( layout );\n\t\t}\n\n\t\tif ( __experimentalDefaultBlock !== undefined ) {\n\t\t\tdeprecated( '__experimentalDefaultBlock', {\n\t\t\t\talternative: 'defaultBlock',\n\t\t\t\tsince: '6.3',\n\t\t\t\tversion: '6.4',\n\t\t\t} );\n\t\t\tnewSettings.defaultBlock = __experimentalDefaultBlock;\n\t\t}\n\n\t\tif ( defaultBlock !== undefined ) {\n\t\t\tnewSettings.defaultBlock = defaultBlock;\n\t\t}\n\n\t\tif ( __experimentalDirectInsert !== undefined ) {\n\t\t\tdeprecated( '__experimentalDirectInsert', {\n\t\t\t\talternative: 'directInsert',\n\t\t\t\tsince: '6.3',\n\t\t\t\tversion: '6.4',\n\t\t\t} );\n\t\t\tnewSettings.directInsert = __experimentalDirectInsert;\n\t\t}\n\n\t\tif ( directInsert !== undefined ) {\n\t\t\tnewSettings.directInsert = directInsert;\n\t\t}\n\n\t\t// Batch updates to block list settings to avoid triggering cascading renders\n\t\t// for each container block included in a tree and optimize initial render.\n\t\t// To avoid triggering updateBlockListSettings for each container block\n\t\t// causing X re-renderings for X container blocks,\n\t\t// we batch all the updatedBlockListSettings in a single \"data\" batch\n\t\t// which results in a single re-render.\n\t\tif ( ! pendingSettingsUpdates.get( registry ) ) {\n\t\t\tpendingSettingsUpdates.set( registry, [] );\n\t\t}\n\t\tpendingSettingsUpdates\n\t\t\t.get( registry )\n\t\t\t.push( [ clientId, newSettings ] );\n\t\twindow.queueMicrotask( () => {\n\t\t\tif ( pendingSettingsUpdates.get( registry )?.length ) {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tpendingSettingsUpdates\n\t\t\t\t\t\t.get( registry )\n\t\t\t\t\t\t.forEach( ( args ) => {\n\t\t\t\t\t\t\tupdateBlockListSettings( ...args );\n\t\t\t\t\t\t} );\n\t\t\t\t\tpendingSettingsUpdates.set( registry, [] );\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t}, [\n\t\tclientId,\n\t\t_allowedBlocks,\n\t\t_prioritizedInserterBlocks,\n\t\t_templateLock,\n\t\tdefaultBlock,\n\t\tdirectInsert,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\tupdateBlockListSettings,\n\t\tlayout,\n\t\tregistry,\n\t] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,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,EAAE,cAAc;QAC3BC,KAAK,EAAE,KAAK;QACZC,OAAO,EAAE;MACV,CAAE,CAAC;MACHP,WAAW,CAAClB,YAAY,GAAGE,0BAA0B;IACtD;IAEA,IAAKF,YAAY,KAAKiB,SAAS,EAAG;MACjCC,WAAW,CAAClB,YAAY,GAAGA,YAAY;IACxC;;IAEA;IACA;IACA;IACA;IACA;IACA;IACA,IAAK,CAAEX,sBAAsB,CAACqC,GAAG,CAAElB,QAAS,CAAC,EAAG;MAC/CnB,sBAAsB,CAACsC,GAAG,CAAEnB,QAAQ,EAAE,EAAG,CAAC;IAC3C;IACAnB,sBAAsB,CACpBqC,GAAG,CAAElB,QAAS,CAAC,CACfoB,IAAI,CAAE,CAAEhC,QAAQ,EAAEsB,WAAW,CAAG,CAAC;IACnCW,MAAM,CAACC,cAAc,CAAE,MAAM;MAC5B,IAAKzC,sBAAsB,CAACqC,GAAG,CAAElB,QAAS,CAAC,EAAEuB,MAAM,EAAG;QACrDvB,QAAQ,CAACwB,KAAK,CAAE,MAAM;UACrB3C,sBAAsB,CACpBqC,GAAG,CAAElB,QAAS,CAAC,CACfyB,OAAO,CAAIC,IAAI,IAAM;YACrB3B,uBAAuB,CAAE,GAAG2B,IAAK,CAAC;UACnC,CAAE,CAAC;UACJ7C,sBAAsB,CAACsC,GAAG,CAAEnB,QAAQ,EAAE,EAAG,CAAC;QAC3C,CAAE,CAAC;MACJ;IACD,CAAE,CAAC;EACJ,CAAC,EAAE,CACFZ,QAAQ,EACRkB,cAAc,EACdC,0BAA0B,EAC1BC,aAAa,EACbjB,YAAY,EACZC,YAAY,EACZC,0BAA0B,EAC1BC,0BAA0B,EAC1BE,eAAe,EACfC,WAAW,EACXE,uBAAuB,EACvBD,MAAM,EACNE,QAAQ,CACP,CAAC;AACJ"}
|
|
1
|
+
{"version":3,"names":["useLayoutEffect","useMemo","useState","useDispatch","useRegistry","deprecated","isShallowEqual","store","blockEditorStore","getLayoutType","pendingSettingsUpdates","WeakMap","useShallowMemo","value","prevValue","setPrevValue","useNestedSettingsUpdate","clientId","parentLock","allowedBlocks","prioritizedInserterBlocks","defaultBlock","directInsert","__experimentalDefaultBlock","__experimentalDirectInsert","templateLock","captureToolbars","orientation","layout","updateBlockListSettings","registry","_allowedBlocks","_prioritizedInserterBlocks","_templateLock","undefined","newSettings","__experimentalCaptureToolbars","layoutType","type","getOrientation","alternative","since","version","get","set","push","window","queueMicrotask","length","batch","forEach","args"],"sources":["@wordpress/block-editor/src/components/inner-blocks/use-nested-settings-update.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useMemo, useState } from '@wordpress/element';\nimport { useDispatch, useRegistry } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getLayoutType } from '../../layouts';\n\n/** @typedef {import('../../selectors').WPDirectInsertBlock } WPDirectInsertBlock */\n\nconst pendingSettingsUpdates = new WeakMap();\n\nfunction useShallowMemo( value ) {\n\tconst [ prevValue, setPrevValue ] = useState( value );\n\tif ( ! isShallowEqual( prevValue, value ) ) {\n\t\tsetPrevValue( value );\n\t}\n\treturn prevValue;\n}\n\n/**\n * This hook is a side effect which updates the block-editor store when changes\n * happen to inner block settings. The given props are transformed into a\n * settings object, and if that is different from the current settings object in\n * the block-editor store, then the store is updated with the new settings which\n * came from props.\n *\n * @param {string} clientId The client ID of the block to update.\n * @param {string} parentLock\n * @param {string[]} allowedBlocks An array of block names which are permitted\n * in inner blocks.\n * @param {string[]} prioritizedInserterBlocks Block names and/or block variations to be prioritized in the inserter, in the format {blockName}/{variationName}.\n * @param {?WPDirectInsertBlock} defaultBlock The default block to insert: [ blockName, { blockAttributes } ].\n * @param {?Function|boolean} directInsert If a default block should be inserted directly by the appender.\n *\n * @param {?WPDirectInsertBlock} __experimentalDefaultBlock A deprecated prop for the default block to insert: [ blockName, { blockAttributes } ]. Use `defaultBlock` instead.\n *\n * @param {?Function|boolean} __experimentalDirectInsert A deprecated prop for whether a default block should be inserted directly by the appender. Use `directInsert` instead.\n *\n * @param {string} [templateLock] The template lock specified for the inner\n * blocks component. (e.g. \"all\")\n * @param {boolean} captureToolbars Whether or children toolbars should be shown\n * in the inner blocks component rather than on\n * the child block.\n * @param {string} orientation The direction in which the block\n * should face.\n * @param {Object} layout The layout object for the block container.\n */\nexport default function useNestedSettingsUpdate(\n\tclientId,\n\tparentLock,\n\tallowedBlocks,\n\tprioritizedInserterBlocks,\n\tdefaultBlock,\n\tdirectInsert,\n\t__experimentalDefaultBlock,\n\t__experimentalDirectInsert,\n\ttemplateLock,\n\tcaptureToolbars,\n\torientation,\n\tlayout\n) {\n\t// Instead of adding a useSelect mapping here, please add to the useSelect\n\t// mapping in InnerBlocks! Every subscription impacts performance.\n\n\tconst { updateBlockListSettings } = useDispatch( blockEditorStore );\n\tconst registry = useRegistry();\n\n\t// Implementors often pass a new array on every render,\n\t// and the contents of the arrays are just strings, so the entire array\n\t// can be passed as dependencies but We need to include the length of the array,\n\t// otherwise if the arrays change length but the first elements are equal the comparison,\n\t// does not works as expected.\n\tconst _allowedBlocks = useShallowMemo( allowedBlocks );\n\n\tconst _prioritizedInserterBlocks = useMemo(\n\t\t() => prioritizedInserterBlocks,\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\tprioritizedInserterBlocks\n\t);\n\n\tconst _templateLock =\n\t\ttemplateLock === undefined || parentLock === 'contentOnly'\n\t\t\t? parentLock\n\t\t\t: templateLock;\n\n\tuseLayoutEffect( () => {\n\t\tconst newSettings = {\n\t\t\tallowedBlocks: _allowedBlocks,\n\t\t\tprioritizedInserterBlocks: _prioritizedInserterBlocks,\n\t\t\ttemplateLock: _templateLock,\n\t\t};\n\n\t\t// These values are not defined for RN, so only include them if they\n\t\t// are defined.\n\t\tif ( captureToolbars !== undefined ) {\n\t\t\tnewSettings.__experimentalCaptureToolbars = captureToolbars;\n\t\t}\n\n\t\t// Orientation depends on layout,\n\t\t// ideally the separate orientation prop should be deprecated.\n\t\tif ( orientation !== undefined ) {\n\t\t\tnewSettings.orientation = orientation;\n\t\t} else {\n\t\t\tconst layoutType = getLayoutType( layout?.type );\n\t\t\tnewSettings.orientation = layoutType.getOrientation( layout );\n\t\t}\n\n\t\tif ( __experimentalDefaultBlock !== undefined ) {\n\t\t\tdeprecated( '__experimentalDefaultBlock', {\n\t\t\t\talternative: 'defaultBlock',\n\t\t\t\tsince: '6.3',\n\t\t\t\tversion: '6.4',\n\t\t\t} );\n\t\t\tnewSettings.defaultBlock = __experimentalDefaultBlock;\n\t\t}\n\n\t\tif ( defaultBlock !== undefined ) {\n\t\t\tnewSettings.defaultBlock = defaultBlock;\n\t\t}\n\n\t\tif ( __experimentalDirectInsert !== undefined ) {\n\t\t\tdeprecated( '__experimentalDirectInsert', {\n\t\t\t\talternative: 'directInsert',\n\t\t\t\tsince: '6.3',\n\t\t\t\tversion: '6.4',\n\t\t\t} );\n\t\t\tnewSettings.directInsert = __experimentalDirectInsert;\n\t\t}\n\n\t\tif ( directInsert !== undefined ) {\n\t\t\tnewSettings.directInsert = directInsert;\n\t\t}\n\n\t\t// Batch updates to block list settings to avoid triggering cascading renders\n\t\t// for each container block included in a tree and optimize initial render.\n\t\t// To avoid triggering updateBlockListSettings for each container block\n\t\t// causing X re-renderings for X container blocks,\n\t\t// we batch all the updatedBlockListSettings in a single \"data\" batch\n\t\t// which results in a single re-render.\n\t\tif ( ! pendingSettingsUpdates.get( registry ) ) {\n\t\t\tpendingSettingsUpdates.set( registry, [] );\n\t\t}\n\t\tpendingSettingsUpdates\n\t\t\t.get( registry )\n\t\t\t.push( [ clientId, newSettings ] );\n\t\twindow.queueMicrotask( () => {\n\t\t\tif ( pendingSettingsUpdates.get( registry )?.length ) {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\tpendingSettingsUpdates\n\t\t\t\t\t\t.get( registry )\n\t\t\t\t\t\t.forEach( ( args ) => {\n\t\t\t\t\t\t\tupdateBlockListSettings( ...args );\n\t\t\t\t\t\t} );\n\t\t\t\t\tpendingSettingsUpdates.set( registry, [] );\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t}, [\n\t\tclientId,\n\t\t_allowedBlocks,\n\t\t_prioritizedInserterBlocks,\n\t\t_templateLock,\n\t\tdefaultBlock,\n\t\tdirectInsert,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\tupdateBlockListSettings,\n\t\tlayout,\n\t\tregistry,\n\t] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAe,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACvE,SAASC,WAAW,EAAEC,WAAW,QAAQ,iBAAiB;AAC1D,OAAOC,UAAU,MAAM,uBAAuB;AAC9C,OAAOC,cAAc,MAAM,6BAA6B;;AAExD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,aAAa,QAAQ,eAAe;;AAE7C;;AAEA,MAAMC,sBAAsB,GAAG,IAAIC,OAAO,CAAC,CAAC;AAE5C,SAASC,cAAcA,CAAEC,KAAK,EAAG;EAChC,MAAM,CAAEC,SAAS,EAAEC,YAAY,CAAE,GAAGb,QAAQ,CAAEW,KAAM,CAAC;EACrD,IAAK,CAAEP,cAAc,CAAEQ,SAAS,EAAED,KAAM,CAAC,EAAG;IAC3CE,YAAY,CAAEF,KAAM,CAAC;EACtB;EACA,OAAOC,SAAS;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASE,uBAAuBA,CAC9CC,QAAQ,EACRC,UAAU,EACVC,aAAa,EACbC,yBAAyB,EACzBC,YAAY,EACZC,YAAY,EACZC,0BAA0B,EAC1B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from '../../inserter-listbox';
|
|
|
18
18
|
import { searchItems } from '../search-items';
|
|
19
19
|
import BlockPatternsPaging from '../../block-patterns-paging';
|
|
20
20
|
import usePatternsPaging from '../hooks/use-patterns-paging';
|
|
21
|
-
import {
|
|
21
|
+
import { INSERTER_PATTERN_TYPES, allPatternsCategory, myPatternsCategory } from '../block-patterns-tab/utils';
|
|
22
22
|
function PatternsListHeader({
|
|
23
23
|
filterValue,
|
|
24
24
|
filteredBlockPatternsLength
|
|
@@ -50,7 +50,7 @@ function PatternList({
|
|
|
50
50
|
if (selectedCategory === allPatternsCategory.name) {
|
|
51
51
|
return true;
|
|
52
52
|
}
|
|
53
|
-
if (selectedCategory === myPatternsCategory.name && pattern.type ===
|
|
53
|
+
if (selectedCategory === myPatternsCategory.name && pattern.type === INSERTER_PATTERN_TYPES.user) {
|
|
54
54
|
return true;
|
|
55
55
|
}
|
|
56
56
|
if (selectedCategory === 'uncategorized') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useEffect","useRef","useState","_n","sprintf","useDebounce","__experimentalHeading","Heading","speak","BlockPatternsList","useInsertionPoint","usePatternsState","InserterListbox","searchItems","BlockPatternsPaging","usePatternsPaging","
|
|
1
|
+
{"version":3,"names":["useMemo","useEffect","useRef","useState","_n","sprintf","useDebounce","__experimentalHeading","Heading","speak","BlockPatternsList","useInsertionPoint","usePatternsState","InserterListbox","searchItems","BlockPatternsPaging","usePatternsPaging","INSERTER_PATTERN_TYPES","allPatternsCategory","myPatternsCategory","PatternsListHeader","filterValue","filteredBlockPatternsLength","createElement","level","lineHeight","className","PatternList","searchValue","selectedCategory","patternCategories","container","debouncedSpeak","destinationRootClientId","onInsertBlocks","shouldFocusBlock","patterns","onClickPattern","registeredPatternCategories","map","patternCategory","name","filteredBlockPatterns","filteredPatterns","filter","pattern","type","user","hasKnownCategory","categories","some","category","includes","length","count","resultsFoundMessage","pagingProps","previousSearchValue","setPreviousSearchValue","changePage","hasItems","ref","Fragment","shownPatterns","categoryPatternsAsyncList","blockPatterns","categoryPatterns","isDraggable"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/pattern-list.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useEffect, useRef, useState } from '@wordpress/element';\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useDebounce } from '@wordpress/compose';\nimport { __experimentalHeading as Heading } from '@wordpress/components';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport BlockPatternsList from '../../block-patterns-list';\nimport useInsertionPoint from '../hooks/use-insertion-point';\nimport usePatternsState from '../hooks/use-patterns-state';\nimport InserterListbox from '../../inserter-listbox';\nimport { searchItems } from '../search-items';\nimport BlockPatternsPaging from '../../block-patterns-paging';\nimport usePatternsPaging from '../hooks/use-patterns-paging';\nimport {\n\tINSERTER_PATTERN_TYPES,\n\tallPatternsCategory,\n\tmyPatternsCategory,\n} from '../block-patterns-tab/utils';\n\nfunction PatternsListHeader( { filterValue, filteredBlockPatternsLength } ) {\n\tif ( ! filterValue ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Heading\n\t\t\tlevel={ 2 }\n\t\t\tlineHeight={ '48px' }\n\t\t\tclassName=\"block-editor-block-patterns-explorer__search-results-count\"\n\t\t>\n\t\t\t{ sprintf(\n\t\t\t\t/* translators: %d: number of patterns. */\n\t\t\t\t_n(\n\t\t\t\t\t'%d pattern found',\n\t\t\t\t\t'%d patterns found',\n\t\t\t\t\tfilteredBlockPatternsLength\n\t\t\t\t),\n\t\t\t\tfilteredBlockPatternsLength\n\t\t\t) }\n\t\t</Heading>\n\t);\n}\n\nfunction PatternList( { searchValue, selectedCategory, patternCategories } ) {\n\tconst container = useRef();\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {\n\t\tshouldFocusBlock: true,\n\t} );\n\tconst [ patterns, , onClickPattern ] = usePatternsState(\n\t\tonInsertBlocks,\n\t\tdestinationRootClientId\n\t);\n\n\tconst registeredPatternCategories = useMemo(\n\t\t() =>\n\t\t\tpatternCategories.map(\n\t\t\t\t( patternCategory ) => patternCategory.name\n\t\t\t),\n\t\t[ patternCategories ]\n\t);\n\n\tconst filteredBlockPatterns = useMemo( () => {\n\t\tconst filteredPatterns = patterns.filter( ( pattern ) => {\n\t\t\tif ( selectedCategory === allPatternsCategory.name ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tselectedCategory === myPatternsCategory.name &&\n\t\t\t\tpattern.type === INSERTER_PATTERN_TYPES.user\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif ( selectedCategory === 'uncategorized' ) {\n\t\t\t\tconst hasKnownCategory = pattern.categories.some(\n\t\t\t\t\t( category ) =>\n\t\t\t\t\t\tregisteredPatternCategories.includes( category )\n\t\t\t\t);\n\n\t\t\t\treturn ! pattern.categories?.length || ! hasKnownCategory;\n\t\t\t}\n\n\t\t\treturn pattern.categories?.includes( selectedCategory );\n\t\t} );\n\n\t\tif ( ! searchValue ) {\n\t\t\treturn filteredPatterns;\n\t\t}\n\n\t\treturn searchItems( filteredPatterns, searchValue );\n\t}, [\n\t\tsearchValue,\n\t\tpatterns,\n\t\tselectedCategory,\n\t\tregisteredPatternCategories,\n\t] );\n\n\t// Announce search results on change.\n\tuseEffect( () => {\n\t\tif ( ! searchValue ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = filteredBlockPatterns.length;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [ searchValue, debouncedSpeak, filteredBlockPatterns.length ] );\n\n\tconst pagingProps = usePatternsPaging(\n\t\tfilteredBlockPatterns,\n\t\tselectedCategory,\n\t\tcontainer\n\t);\n\n\t// Reset page when search value changes.\n\tconst [ previousSearchValue, setPreviousSearchValue ] =\n\t\tuseState( searchValue );\n\tif ( searchValue !== previousSearchValue ) {\n\t\tsetPreviousSearchValue( searchValue );\n\t\tpagingProps.changePage( 1 );\n\t}\n\n\tconst hasItems = !! filteredBlockPatterns?.length;\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-block-patterns-explorer__list\"\n\t\t\tref={ container }\n\t\t>\n\t\t\t<PatternsListHeader\n\t\t\t\tfilterValue={ searchValue }\n\t\t\t\tfilteredBlockPatternsLength={ filteredBlockPatterns.length }\n\t\t\t/>\n\n\t\t\t<InserterListbox>\n\t\t\t\t{ hasItems && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\t\tshownPatterns={\n\t\t\t\t\t\t\t\tpagingProps.categoryPatternsAsyncList\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tblockPatterns={ pagingProps.categoryPatterns }\n\t\t\t\t\t\t\tonClickPattern={ onClickPattern }\n\t\t\t\t\t\t\tisDraggable={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BlockPatternsPaging { ...pagingProps } />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</InserterListbox>\n\t\t</div>\n\t);\n}\n\nexport default PatternList;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AACzE,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,WAAW,QAAQ,oBAAoB;AAChD,SAASC,qBAAqB,IAAIC,OAAO,QAAQ,uBAAuB;AACxE,SAASC,KAAK,QAAQ,iBAAiB;;AAEvC;AACA;AACA;AACA,OAAOC,iBAAiB,MAAM,2BAA2B;AACzD,OAAOC,iBAAiB,MAAM,8BAA8B;AAC5D,OAAOC,gBAAgB,MAAM,6BAA6B;AAC1D,OAAOC,eAAe,MAAM,wBAAwB;AACpD,SAASC,WAAW,QAA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,IAAKA,WAAW,KAAK6B,mBAAmB,EAAG;IAC1CC,sBAAsB,CAAE9B,WAAY,CAAC;IACrC4B,WAAW,CAACG,UAAU,CAAE,CAAE,CAAC;EAC5B;EAEA,MAAMC,QAAQ,GAAG,CAAC,CAAElB,qBAAqB,EAAEW,MAAM;EACjD,OACC9B,aAAA;IACCG,SAAS,EAAC,4CAA4C;IACtDmC,GAAG,EAAG9B;EAAW,GAEjBR,aAAA,CAACH,kBAAkB;IAClBC,WAAW,EAAGO,WAAa;IAC3BN,2BAA2B,EAAGoB,qBAAqB,CAACW;EAAQ,CAC5D,CAAC,EAEF9B,aAAA,CAACV,eAAe,QACb+C,QAAQ,IACTrC,aAAA,CAAAuC,QAAA,QACCvC,aAAA,CAACb,iBAAiB;IACjBqD,aAAa,EACZP,WAAW,CAACQ,yBACZ;IACDC,aAAa,EAAGT,WAAW,CAACU,gBAAkB;IAC9C7B,cAAc,EAAGA,cAAgB;IACjC8B,WAAW,EAAG;EAAO,CACrB,CAAC,EACF5C,aAAA,CAACR,mBAAmB;IAAA,GAAMyC;EAAW,CAAI,CACxC,CAEa,CACb,CAAC;AAER;AAEA,eAAe7B,WAAW"}
|
|
@@ -14,7 +14,7 @@ import BlockPatternsList from '../../block-patterns-list';
|
|
|
14
14
|
import usePatternsPaging from '../hooks/use-patterns-paging';
|
|
15
15
|
import { PatternsFilter } from './patterns-filter';
|
|
16
16
|
import { usePatternCategories } from './use-pattern-categories';
|
|
17
|
-
import { isPatternFiltered, allPatternsCategory, myPatternsCategory,
|
|
17
|
+
import { isPatternFiltered, allPatternsCategory, myPatternsCategory, INSERTER_PATTERN_TYPES } from './utils';
|
|
18
18
|
const noop = () => {};
|
|
19
19
|
export function PatternCategoryPreviews({
|
|
20
20
|
rootClientId,
|
|
@@ -29,24 +29,25 @@ export function PatternCategoryPreviews({
|
|
|
29
29
|
const availableCategories = usePatternCategories(rootClientId, patternSourceFilter);
|
|
30
30
|
const scrollContainerRef = useRef();
|
|
31
31
|
const currentCategoryPatterns = useMemo(() => allPatterns.filter(pattern => {
|
|
32
|
-
var _pattern$categories$f;
|
|
33
32
|
if (isPatternFiltered(pattern, patternSourceFilter, patternSyncFilter)) {
|
|
34
33
|
return false;
|
|
35
34
|
}
|
|
36
35
|
if (category.name === allPatternsCategory.name) {
|
|
37
36
|
return true;
|
|
38
37
|
}
|
|
39
|
-
if (category.name === myPatternsCategory.name && pattern.type ===
|
|
38
|
+
if (category.name === myPatternsCategory.name && pattern.type === INSERTER_PATTERN_TYPES.user) {
|
|
40
39
|
return true;
|
|
41
40
|
}
|
|
42
|
-
if (category.name
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
if (category.name === 'uncategorized') {
|
|
42
|
+
// The uncategorized category should show all the patterns without any category...
|
|
43
|
+
if (!pattern.categories) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return
|
|
47
|
+
// ...or with no available category.
|
|
48
|
+
return !pattern.categories.some(catName => availableCategories.some(c => c.name === catName));
|
|
49
|
+
}
|
|
50
|
+
return pattern.categories?.includes(category.name);
|
|
50
51
|
}), [allPatterns, availableCategories, category.name, patternSourceFilter, patternSyncFilter]);
|
|
51
52
|
const pagingProps = usePatternsPaging(currentCategoryPatterns, category, scrollContainerRef);
|
|
52
53
|
const {
|
package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useState","useCallback","useRef","useEffect","__","__experimentalHStack","HStack","__experimentalVStack","VStack","__experimentalHeading","Heading","__experimentalText","Text","FlexBlock","usePatternsState","BlockPatternsList","usePatternsPaging","PatternsFilter","usePatternCategories","isPatternFiltered","allPatternsCategory","myPatternsCategory","
|
|
1
|
+
{"version":3,"names":["useMemo","useState","useCallback","useRef","useEffect","__","__experimentalHStack","HStack","__experimentalVStack","VStack","__experimentalHeading","Heading","__experimentalText","Text","FlexBlock","usePatternsState","BlockPatternsList","usePatternsPaging","PatternsFilter","usePatternCategories","isPatternFiltered","allPatternsCategory","myPatternsCategory","INSERTER_PATTERN_TYPES","noop","PatternCategoryPreviews","rootClientId","onInsert","onHover","category","showTitlesAsTooltip","allPatterns","onClickPattern","patternSyncFilter","setPatternSyncFilter","patternSourceFilter","setPatternSourceFilter","availableCategories","scrollContainerRef","currentCategoryPatterns","filter","pattern","name","type","user","categories","some","catName","c","includes","pagingProps","changePage","onSetPatternSyncFilter","value","onSetPatternSourceFilter","createElement","className","spacing","level","as","label","length","variant","ref","shownPatterns","categoryPatternsAsyncList","blockPatterns","categoryPatterns","orientation","isDraggable","patternFilter"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab/pattern-category-previews.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMemo,\n\tuseState,\n\tuseCallback,\n\tuseRef,\n\tuseEffect,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalHeading as Heading,\n\t__experimentalText as Text,\n\tFlexBlock,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport usePatternsState from '../hooks/use-patterns-state';\nimport BlockPatternsList from '../../block-patterns-list';\nimport usePatternsPaging from '../hooks/use-patterns-paging';\nimport { PatternsFilter } from './patterns-filter';\nimport { usePatternCategories } from './use-pattern-categories';\nimport {\n\tisPatternFiltered,\n\tallPatternsCategory,\n\tmyPatternsCategory,\n\tINSERTER_PATTERN_TYPES,\n} from './utils';\n\nconst noop = () => {};\n\nexport function PatternCategoryPreviews( {\n\trootClientId,\n\tonInsert,\n\tonHover = noop,\n\tcategory,\n\tshowTitlesAsTooltip,\n} ) {\n\tconst [ allPatterns, , onClickPattern ] = usePatternsState(\n\t\tonInsert,\n\t\trootClientId\n\t);\n\tconst [ patternSyncFilter, setPatternSyncFilter ] = useState( 'all' );\n\tconst [ patternSourceFilter, setPatternSourceFilter ] = useState( 'all' );\n\n\tconst availableCategories = usePatternCategories(\n\t\trootClientId,\n\t\tpatternSourceFilter\n\t);\n\tconst scrollContainerRef = useRef();\n\tconst currentCategoryPatterns = useMemo(\n\t\t() =>\n\t\t\tallPatterns.filter( ( pattern ) => {\n\t\t\t\tif (\n\t\t\t\t\tisPatternFiltered(\n\t\t\t\t\t\tpattern,\n\t\t\t\t\t\tpatternSourceFilter,\n\t\t\t\t\t\tpatternSyncFilter\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif ( category.name === allPatternsCategory.name ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tcategory.name === myPatternsCategory.name &&\n\t\t\t\t\tpattern.type === INSERTER_PATTERN_TYPES.user\n\t\t\t\t) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tif ( category.name === 'uncategorized' ) {\n\t\t\t\t\t// The uncategorized category should show all the patterns without any category...\n\t\t\t\t\tif ( ! pattern.categories ) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\n\t\t\t\t\t// ...or with no available category.\n\t\t\t\t\treturn ! pattern.categories.some( ( catName ) =>\n\t\t\t\t\t\tavailableCategories.some( ( c ) => c.name === catName )\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn pattern.categories?.includes( category.name );\n\t\t\t} ),\n\t\t[\n\t\t\tallPatterns,\n\t\t\tavailableCategories,\n\t\t\tcategory.name,\n\t\t\tpatternSourceFilter,\n\t\t\tpatternSyncFilter,\n\t\t]\n\t);\n\n\tconst pagingProps = usePatternsPaging(\n\t\tcurrentCategoryPatterns,\n\t\tcategory,\n\t\tscrollContainerRef\n\t);\n\tconst { changePage } = pagingProps;\n\n\t// Hide block pattern preview on unmount.\n\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\tuseEffect( () => () => onHover( null ), [] );\n\n\tconst onSetPatternSyncFilter = useCallback(\n\t\t( value ) => {\n\t\t\tsetPatternSyncFilter( value );\n\t\t\tchangePage( 1 );\n\t\t},\n\t\t[ setPatternSyncFilter, changePage ]\n\t);\n\tconst onSetPatternSourceFilter = useCallback(\n\t\t( value ) => {\n\t\t\tsetPatternSourceFilter( value );\n\t\t\tchangePage( 1 );\n\t\t},\n\t\t[ setPatternSourceFilter, changePage ]\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-inserter__patterns-category-panel\">\n\t\t\t<VStack\n\t\t\t\tspacing={ 2 }\n\t\t\t\tclassName=\"block-editor-inserter__patterns-category-panel-header\"\n\t\t\t>\n\t\t\t\t<HStack>\n\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t<Heading level={ 4 } as=\"div\">\n\t\t\t\t\t\t\t{ category.label }\n\t\t\t\t\t\t</Heading>\n\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t<PatternsFilter\n\t\t\t\t\t\tpatternSyncFilter={ patternSyncFilter }\n\t\t\t\t\t\tpatternSourceFilter={ patternSourceFilter }\n\t\t\t\t\t\tsetPatternSyncFilter={ onSetPatternSyncFilter }\n\t\t\t\t\t\tsetPatternSourceFilter={ onSetPatternSourceFilter }\n\t\t\t\t\t\tscrollContainerRef={ scrollContainerRef }\n\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t\t{ ! currentCategoryPatterns.length && (\n\t\t\t\t\t<Text\n\t\t\t\t\t\tvariant=\"muted\"\n\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-category-no-results\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'No results found' ) }\n\t\t\t\t\t</Text>\n\t\t\t\t) }\n\t\t\t</VStack>\n\n\t\t\t{ currentCategoryPatterns.length > 0 && (\n\t\t\t\t<BlockPatternsList\n\t\t\t\t\tref={ scrollContainerRef }\n\t\t\t\t\tshownPatterns={ pagingProps.categoryPatternsAsyncList }\n\t\t\t\t\tblockPatterns={ pagingProps.categoryPatterns }\n\t\t\t\t\tonClickPattern={ onClickPattern }\n\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\tlabel={ category.label }\n\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\tcategory={ category.name }\n\t\t\t\t\tisDraggable\n\t\t\t\t\tshowTitlesAsTooltip={ showTitlesAsTooltip }\n\t\t\t\t\tpatternFilter={ patternSourceFilter }\n\t\t\t\t\tpagingProps={ pagingProps }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,OAAO,EACPC,QAAQ,EACRC,WAAW,EACXC,MAAM,EACNC,SAAS,QACH,oBAAoB;AAC3B,SAASC,EAAE,QAAQ,iBAAiB;AAEpC,SACCC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,qBAAqB,IAAIC,OAAO,EAChCC,kBAAkB,IAAIC,IAAI,EAC1BC,SAAS,QACH,uBAAuB;;AAE9B;AACA;AACA;AACA,OAAOC,gBAAgB,MAAM,6BAA6B;AAC1D,OAAOC,iBAAiB,MAAM,2BAA2B;AACzD,OAAOC,iBAAiB,MAAM,8BAA8B;AAC5D,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,oBAAoB,QAAQ,0BAA0B;AAC/D,SACCC,iBAAiB,EACjBC,mBAAmB,EACnBC,kBAAkB,EAClBC,sBAAsB,QAChB,SAAS;AAEhB,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,OAAO,SAASC,uBAAuBA,CAAE;EACxCC,YAAY;EACZC,QAAQ;EACRC,OAAO,GAAGJ,IAAI;EACdK,QAAQ;EACRC;AACD,CAAC,EAAG;EACH,MAAM,CAAEC,WAAW,GAAIC,cAAc,CAAE,GAAGjB,gBAAgB,CACzDY,QAAQ,EACRD,YACD,CAAC;EACD,MAAM,CAAEO,iBAAiB,EAAEC,oBAAoB,CAAE,GAAGjC,QA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AAA,CAACvC,iBAAiB;IACjB+C,GAAG,EAAGzB,kBAAoB;IAC1B0B,aAAa,EAAGd,WAAW,CAACe,yBAA2B;IACvDC,aAAa,EAAGhB,WAAW,CAACiB,gBAAkB;IAC9CnC,cAAc,EAAGA,cAAgB;IACjCJ,OAAO,EAAGA,OAAS;IACnBgC,KAAK,EAAG/B,QAAQ,CAAC+B,KAAO;IACxBQ,WAAW,EAAC,UAAU;IACtBvC,QAAQ,EAAGA,QAAQ,CAACa,IAAM;IAC1B2B,WAAW;IACXvC,mBAAmB,EAAGA,mBAAqB;IAC3CwC,aAAa,EAAGnC,mBAAqB;IACrCe,WAAW,EAAGA;EAAa,CAC3B,CAEE,CAAC;AAER"}
|
|
@@ -10,8 +10,8 @@ import { useMemo, createInterpolateElement } from '@wordpress/element';
|
|
|
10
10
|
/**
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
|
-
import { myPatternsCategory,
|
|
14
|
-
const getShouldDisableSyncFilter = sourceFilter => sourceFilter !==
|
|
13
|
+
import { myPatternsCategory, INSERTER_SYNC_TYPES, INSERTER_PATTERN_TYPES } from './utils';
|
|
14
|
+
const getShouldDisableSyncFilter = sourceFilter => sourceFilter !== 'all';
|
|
15
15
|
const getShouldDisableNonUserSources = category => {
|
|
16
16
|
return category.name === myPatternsCategory.name;
|
|
17
17
|
};
|
|
@@ -27,7 +27,7 @@ export function PatternsFilter({
|
|
|
27
27
|
// we do this by deriving from props rather than calling setPatternSourceFilter otherwise
|
|
28
28
|
// the user may be confused when switching to another category if the haven't explicity set
|
|
29
29
|
// this filter themselves.
|
|
30
|
-
const currentPatternSourceFilter = category.name === myPatternsCategory.name ?
|
|
30
|
+
const currentPatternSourceFilter = category.name === myPatternsCategory.name ? INSERTER_PATTERN_TYPES.user : patternSourceFilter;
|
|
31
31
|
|
|
32
32
|
// We need to disable the sync filter option if the source filter is not 'all' or 'user'
|
|
33
33
|
// otherwise applying them will just result in no patterns being shown.
|
|
@@ -37,37 +37,37 @@ export function PatternsFilter({
|
|
|
37
37
|
// is `myPatterns` otherwise applying them will also just result in no patterns being shown.
|
|
38
38
|
const shouldDisableNonUserSources = getShouldDisableNonUserSources(category);
|
|
39
39
|
const patternSyncMenuOptions = useMemo(() => [{
|
|
40
|
-
value:
|
|
40
|
+
value: 'all',
|
|
41
41
|
label: _x('All', 'Option that shows all patterns')
|
|
42
42
|
}, {
|
|
43
|
-
value:
|
|
43
|
+
value: INSERTER_SYNC_TYPES.full,
|
|
44
44
|
label: _x('Synced', 'Option that shows all synchronized patterns'),
|
|
45
45
|
disabled: shouldDisableSyncFilter
|
|
46
46
|
}, {
|
|
47
|
-
value:
|
|
47
|
+
value: INSERTER_SYNC_TYPES.unsynced,
|
|
48
48
|
label: _x('Not synced', 'Option that shows all patterns that are not synchronized'),
|
|
49
49
|
disabled: shouldDisableSyncFilter
|
|
50
50
|
}], [shouldDisableSyncFilter]);
|
|
51
51
|
const patternSourceMenuOptions = useMemo(() => [{
|
|
52
|
-
value:
|
|
52
|
+
value: 'all',
|
|
53
53
|
label: __('All'),
|
|
54
54
|
disabled: shouldDisableNonUserSources
|
|
55
55
|
}, {
|
|
56
|
-
value:
|
|
56
|
+
value: INSERTER_PATTERN_TYPES.directory,
|
|
57
57
|
label: __('Pattern Directory'),
|
|
58
58
|
disabled: shouldDisableNonUserSources
|
|
59
59
|
}, {
|
|
60
|
-
value:
|
|
60
|
+
value: INSERTER_PATTERN_TYPES.theme,
|
|
61
61
|
label: __('Theme & Plugins'),
|
|
62
62
|
disabled: shouldDisableNonUserSources
|
|
63
63
|
}, {
|
|
64
|
-
value:
|
|
64
|
+
value: INSERTER_PATTERN_TYPES.user,
|
|
65
65
|
label: __('User')
|
|
66
66
|
}], [shouldDisableNonUserSources]);
|
|
67
67
|
function handleSetSourceFilterChange(newSourceFilter) {
|
|
68
68
|
setPatternSourceFilter(newSourceFilter);
|
|
69
69
|
if (getShouldDisableSyncFilter(newSourceFilter)) {
|
|
70
|
-
setPatternSyncFilter(
|
|
70
|
+
setPatternSyncFilter('all');
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
return createElement(Fragment, null, createElement(DropdownMenu, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SVG","Path","DropdownMenu","MenuGroup","MenuItemsChoice","ExternalLink","__","_x","Icon","useMemo","createInterpolateElement","myPatternsCategory","
|
|
1
|
+
{"version":3,"names":["SVG","Path","DropdownMenu","MenuGroup","MenuItemsChoice","ExternalLink","__","_x","Icon","useMemo","createInterpolateElement","myPatternsCategory","INSERTER_SYNC_TYPES","INSERTER_PATTERN_TYPES","getShouldDisableSyncFilter","sourceFilter","getShouldDisableNonUserSources","category","name","PatternsFilter","setPatternSyncFilter","setPatternSourceFilter","patternSyncFilter","patternSourceFilter","scrollContainerRef","currentPatternSourceFilter","user","shouldDisableSyncFilter","shouldDisableNonUserSources","patternSyncMenuOptions","value","label","full","disabled","unsynced","patternSourceMenuOptions","directory","theme","handleSetSourceFilterChange","newSourceFilter","createElement","Fragment","popoverProps","placement","icon","width","height","viewBox","fill","xmlns","d","choices","onSelect","current","scrollTo","className","Link","href"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab/patterns-filter.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tSVG,\n\tPath,\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItemsChoice,\n\tExternalLink,\n} from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { Icon } from '@wordpress/icons';\nimport { useMemo, createInterpolateElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tmyPatternsCategory,\n\tINSERTER_SYNC_TYPES,\n\tINSERTER_PATTERN_TYPES,\n} from './utils';\n\nconst getShouldDisableSyncFilter = ( sourceFilter ) => sourceFilter !== 'all';\nconst getShouldDisableNonUserSources = ( category ) => {\n\treturn category.name === myPatternsCategory.name;\n};\n\nexport function PatternsFilter( {\n\tsetPatternSyncFilter,\n\tsetPatternSourceFilter,\n\tpatternSyncFilter,\n\tpatternSourceFilter,\n\tscrollContainerRef,\n\tcategory,\n} ) {\n\t// If the category is `myPatterns` then we need to set the source filter to `user`, but\n\t// we do this by deriving from props rather than calling setPatternSourceFilter otherwise\n\t// the user may be confused when switching to another category if the haven't explicity set\n\t// this filter themselves.\n\tconst currentPatternSourceFilter =\n\t\tcategory.name === myPatternsCategory.name\n\t\t\t? INSERTER_PATTERN_TYPES.user\n\t\t\t: patternSourceFilter;\n\n\t// We need to disable the sync filter option if the source filter is not 'all' or 'user'\n\t// otherwise applying them will just result in no patterns being shown.\n\tconst shouldDisableSyncFilter = getShouldDisableSyncFilter(\n\t\tcurrentPatternSourceFilter\n\t);\n\n\t// We also need to disable the directory and theme source filter options if the category\n\t// is `myPatterns` otherwise applying them will also just result in no patterns being shown.\n\tconst shouldDisableNonUserSources =\n\t\tgetShouldDisableNonUserSources( category );\n\n\tconst patternSyncMenuOptions = useMemo(\n\t\t() => [\n\t\t\t{\n\t\t\t\tvalue: 'all',\n\t\t\t\tlabel: _x( 'All', 'Option that shows all patterns' ),\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: INSERTER_SYNC_TYPES.full,\n\t\t\t\tlabel: _x(\n\t\t\t\t\t'Synced',\n\t\t\t\t\t'Option that shows all synchronized patterns'\n\t\t\t\t),\n\t\t\t\tdisabled: shouldDisableSyncFilter,\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: INSERTER_SYNC_TYPES.unsynced,\n\t\t\t\tlabel: _x(\n\t\t\t\t\t'Not synced',\n\t\t\t\t\t'Option that shows all patterns that are not synchronized'\n\t\t\t\t),\n\t\t\t\tdisabled: shouldDisableSyncFilter,\n\t\t\t},\n\t\t],\n\t\t[ shouldDisableSyncFilter ]\n\t);\n\n\tconst patternSourceMenuOptions = useMemo(\n\t\t() => [\n\t\t\t{\n\t\t\t\tvalue: 'all',\n\t\t\t\tlabel: __( 'All' ),\n\t\t\t\tdisabled: shouldDisableNonUserSources,\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: INSERTER_PATTERN_TYPES.directory,\n\t\t\t\tlabel: __( 'Pattern Directory' ),\n\t\t\t\tdisabled: shouldDisableNonUserSources,\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: INSERTER_PATTERN_TYPES.theme,\n\t\t\t\tlabel: __( 'Theme & Plugins' ),\n\t\t\t\tdisabled: shouldDisableNonUserSources,\n\t\t\t},\n\t\t\t{\n\t\t\t\tvalue: INSERTER_PATTERN_TYPES.user,\n\t\t\t\tlabel: __( 'User' ),\n\t\t\t},\n\t\t],\n\t\t[ shouldDisableNonUserSources ]\n\t);\n\n\tfunction handleSetSourceFilterChange( newSourceFilter ) {\n\t\tsetPatternSourceFilter( newSourceFilter );\n\t\tif ( getShouldDisableSyncFilter( newSourceFilter ) ) {\n\t\t\tsetPatternSyncFilter( 'all' );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\tpopoverProps={ {\n\t\t\t\t\tplacement: 'right-end',\n\t\t\t\t} }\n\t\t\t\tlabel=\"Filter patterns\"\n\t\t\t\ticon={\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t<SVG\n\t\t\t\t\t\t\t\twidth=\"24\"\n\t\t\t\t\t\t\t\theight=\"24\"\n\t\t\t\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Path\n\t\t\t\t\t\t\t\t\td=\"M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z\"\n\t\t\t\t\t\t\t\t\tfill=\"#1E1E1E\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</SVG>\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{ () => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<MenuGroup label={ __( 'Source' ) }>\n\t\t\t\t\t\t\t<MenuItemsChoice\n\t\t\t\t\t\t\t\tchoices={ patternSourceMenuOptions }\n\t\t\t\t\t\t\t\tonSelect={ ( value ) => {\n\t\t\t\t\t\t\t\t\thandleSetSourceFilterChange( value );\n\t\t\t\t\t\t\t\t\tscrollContainerRef.current?.scrollTo(\n\t\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\t\t0\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tvalue={ currentPatternSourceFilter }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<MenuGroup label={ __( 'Type' ) }>\n\t\t\t\t\t\t\t<MenuItemsChoice\n\t\t\t\t\t\t\t\tchoices={ patternSyncMenuOptions }\n\t\t\t\t\t\t\t\tonSelect={ ( value ) => {\n\t\t\t\t\t\t\t\t\tsetPatternSyncFilter( value );\n\t\t\t\t\t\t\t\t\tscrollContainerRef.current?.scrollTo(\n\t\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\t\t0\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tvalue={ patternSyncFilter }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<div className=\"block-editor-tool-selector__help\">\n\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Patterns are available from the <Link>WordPress.org Pattern Directory</Link>, bundled in the active theme, or created by users on this site. Only patterns created on this site can be synced.'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tLink: (\n\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t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AAG,CACH;EAEH,CACD,CACI,CACJ,CAEU,CACb,CAAC;AAEL"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useMemo
|
|
4
|
+
import { useMemo } from '@wordpress/element';
|
|
5
5
|
import { _x, _n, sprintf } from '@wordpress/i18n';
|
|
6
6
|
import { speak } from '@wordpress/a11y';
|
|
7
7
|
|
|
@@ -9,27 +9,27 @@ import { speak } from '@wordpress/a11y';
|
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
11
|
import usePatternsState from '../hooks/use-patterns-state';
|
|
12
|
-
import { isPatternFiltered, allPatternsCategory, myPatternsCategory,
|
|
12
|
+
import { isPatternFiltered, allPatternsCategory, myPatternsCategory, INSERTER_PATTERN_TYPES } from './utils';
|
|
13
|
+
function hasRegisteredCategory(pattern, allCategories) {
|
|
14
|
+
if (!pattern.categories || !pattern.categories.length) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return pattern.categories.some(cat => allCategories.some(category => category.name === cat));
|
|
18
|
+
}
|
|
13
19
|
export function usePatternCategories(rootClientId, sourceFilter = 'all') {
|
|
14
20
|
const [patterns, allCategories] = usePatternsState(undefined, rootClientId);
|
|
15
21
|
const filteredPatterns = useMemo(() => sourceFilter === 'all' ? patterns : patterns.filter(pattern => !isPatternFiltered(pattern, sourceFilter)), [sourceFilter, patterns]);
|
|
16
|
-
const hasRegisteredCategory = useCallback(pattern => {
|
|
17
|
-
if (!pattern.categories || !pattern.categories.length) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
return pattern.categories.some(cat => allCategories.some(category => category.name === cat));
|
|
21
|
-
}, [allCategories]);
|
|
22
22
|
|
|
23
23
|
// Remove any empty categories.
|
|
24
24
|
const populatedCategories = useMemo(() => {
|
|
25
25
|
const categories = allCategories.filter(category => filteredPatterns.some(pattern => pattern.categories?.includes(category.name))).sort((a, b) => a.label.localeCompare(b.label));
|
|
26
|
-
if (filteredPatterns.some(pattern => !hasRegisteredCategory(pattern)) && !categories.find(category => category.name === 'uncategorized')) {
|
|
26
|
+
if (filteredPatterns.some(pattern => !hasRegisteredCategory(pattern, allCategories)) && !categories.find(category => category.name === 'uncategorized')) {
|
|
27
27
|
categories.push({
|
|
28
28
|
name: 'uncategorized',
|
|
29
29
|
label: _x('Uncategorized')
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
-
if (filteredPatterns.some(pattern => pattern.type ===
|
|
32
|
+
if (filteredPatterns.some(pattern => pattern.type === INSERTER_PATTERN_TYPES.user)) {
|
|
33
33
|
categories.unshift(myPatternsCategory);
|
|
34
34
|
}
|
|
35
35
|
if (filteredPatterns.length > 0) {
|
|
@@ -41,7 +41,7 @@ export function usePatternCategories(rootClientId, sourceFilter = 'all') {
|
|
|
41
41
|
speak(sprintf( /* translators: %d: number of categories . */
|
|
42
42
|
_n('%d category button displayed.', '%d category buttons displayed.', categories.length), categories.length));
|
|
43
43
|
return categories;
|
|
44
|
-
}, [allCategories, filteredPatterns
|
|
44
|
+
}, [allCategories, filteredPatterns]);
|
|
45
45
|
return populatedCategories;
|
|
46
46
|
}
|
|
47
47
|
//# sourceMappingURL=use-pattern-categories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","
|
|
1
|
+
{"version":3,"names":["useMemo","_x","_n","sprintf","speak","usePatternsState","isPatternFiltered","allPatternsCategory","myPatternsCategory","INSERTER_PATTERN_TYPES","hasRegisteredCategory","pattern","allCategories","categories","length","some","cat","category","name","usePatternCategories","rootClientId","sourceFilter","patterns","undefined","filteredPatterns","filter","populatedCategories","includes","sort","a","b","label","localeCompare","find","push","type","user","unshift"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab/use-pattern-categories.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { _x, _n, sprintf } from '@wordpress/i18n';\n\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport usePatternsState from '../hooks/use-patterns-state';\nimport {\n\tisPatternFiltered,\n\tallPatternsCategory,\n\tmyPatternsCategory,\n\tINSERTER_PATTERN_TYPES,\n} from './utils';\n\nfunction hasRegisteredCategory( pattern, allCategories ) {\n\tif ( ! pattern.categories || ! pattern.categories.length ) {\n\t\treturn false;\n\t}\n\n\treturn pattern.categories.some( ( cat ) =>\n\t\tallCategories.some( ( category ) => category.name === cat )\n\t);\n}\n\nexport function usePatternCategories( rootClientId, sourceFilter = 'all' ) {\n\tconst [ patterns, allCategories ] = usePatternsState(\n\t\tundefined,\n\t\trootClientId\n\t);\n\n\tconst filteredPatterns = useMemo(\n\t\t() =>\n\t\t\tsourceFilter === 'all'\n\t\t\t\t? patterns\n\t\t\t\t: patterns.filter(\n\t\t\t\t\t\t( pattern ) =>\n\t\t\t\t\t\t\t! isPatternFiltered( pattern, sourceFilter )\n\t\t\t\t ),\n\t\t[ sourceFilter, patterns ]\n\t);\n\n\t// Remove any empty categories.\n\tconst populatedCategories = useMemo( () => {\n\t\tconst categories = allCategories\n\t\t\t.filter( ( category ) =>\n\t\t\t\tfilteredPatterns.some( ( pattern ) =>\n\t\t\t\t\tpattern.categories?.includes( category.name )\n\t\t\t\t)\n\t\t\t)\n\t\t\t.sort( ( a, b ) => a.label.localeCompare( b.label ) );\n\n\t\tif (\n\t\t\tfilteredPatterns.some(\n\t\t\t\t( pattern ) => ! hasRegisteredCategory( pattern, allCategories )\n\t\t\t) &&\n\t\t\t! categories.find(\n\t\t\t\t( category ) => category.name === 'uncategorized'\n\t\t\t)\n\t\t) {\n\t\t\tcategories.push( {\n\t\t\t\tname: 'uncategorized',\n\t\t\t\tlabel: _x( 'Uncategorized' ),\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tfilteredPatterns.some(\n\t\t\t\t( pattern ) => pattern.type === INSERTER_PATTERN_TYPES.user\n\t\t\t)\n\t\t) {\n\t\t\tcategories.unshift( myPatternsCategory );\n\t\t}\n\t\tif ( filteredPatterns.length > 0 ) {\n\t\t\tcategories.unshift( {\n\t\t\t\tname: allPatternsCategory.name,\n\t\t\t\tlabel: allPatternsCategory.label,\n\t\t\t} );\n\t\t}\n\t\tspeak(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of categories . */\n\t\t\t\t_n(\n\t\t\t\t\t'%d category button displayed.',\n\t\t\t\t\t'%d category buttons displayed.',\n\t\t\t\t\tcategories.length\n\t\t\t\t),\n\t\t\t\tcategories.length\n\t\t\t)\n\t\t);\n\t\treturn categories;\n\t}, [ allCategories, filteredPatterns ] );\n\n\treturn populatedCategories;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAEjD,SAASC,KAAK,QAAQ,iBAAiB;;AAEvC;AACA;AACA;AACA,OAAOC,gBAAgB,MAAM,6BAA6B;AAC1D,SACCC,iBAAiB,EACjBC,mBAAmB,EACnBC,kBAAkB,EAClBC,sBAAsB,QAChB,SAAS;AAEhB,SAASC,qBAAqBA,CAAEC,OAAO,EAAEC,aAAa,EAAG;EACxD,IAAK,CAAED,OAAO,CAACE,UAAU,IAAI,CAAEF,OAAO,CAACE,UAAU,CAACC,MAAM,EAAG;IAC1D,OAAO,KAAK;EACb;EAEA,OAAOH,OAAO,CAACE,UAAU,CAACE,IAAI,CAAIC,GAAG,IACpCJ,aAAa,CAACG,IAAI,CAAIE,QAAQ,IAAMA,QAAQ,CAACC,IAAI,KAAKF,GAAI,CAC3D,CAAC;AACF;AAEA,OAAO,SAASG,oBAAoBA,CAAEC,YAAY,EAAEC,YAAY,GAAG,KAAK,EAAG;EAC1E,MAAM,CAAEC,QAAQ,EAAEV,aAAa,CAAE,GAAGP,gBAAgB,CACnDkB,SAAS,EACTH,YACD,CAAC;EAED,MAAMI,gBAAgB,GAAGxB,OAAO,CA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ACJ;IACA3B,KAAK,CACJD,OAAO,EACN;IACAD,EAAE,CACD,+BAA+B,EAC/B,gCAAgC,EAChCW,UAAU,CAACC,MACZ,CAAC,EACDD,UAAU,CAACC,MACZ,CACD,CAAC;IACD,OAAOD,UAAU;EAClB,CAAC,EAAE,CAAED,aAAa,EAAEY,gBAAgB,CAAG,CAAC;EAExC,OAAOE,mBAAmB;AAC3B"}
|
|
@@ -3,16 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
|
-
export const
|
|
7
|
-
all: 'all',
|
|
8
|
-
synced: 'synced',
|
|
9
|
-
unsynced: 'unsynced',
|
|
6
|
+
export const INSERTER_PATTERN_TYPES = {
|
|
10
7
|
user: 'user',
|
|
11
8
|
theme: 'theme',
|
|
12
9
|
directory: 'directory'
|
|
13
10
|
};
|
|
14
|
-
export const
|
|
15
|
-
all: 'all',
|
|
11
|
+
export const INSERTER_SYNC_TYPES = {
|
|
16
12
|
full: 'fully',
|
|
17
13
|
unsynced: 'unsynced'
|
|
18
14
|
};
|
|
@@ -30,26 +26,26 @@ export function isPatternFiltered(pattern, sourceFilter, syncFilter) {
|
|
|
30
26
|
|
|
31
27
|
// If theme source selected, filter out user created patterns and those from
|
|
32
28
|
// the core patterns directory.
|
|
33
|
-
if (sourceFilter ===
|
|
29
|
+
if (sourceFilter === INSERTER_PATTERN_TYPES.theme && (isUserPattern || isDirectoryPattern)) {
|
|
34
30
|
return true;
|
|
35
31
|
}
|
|
36
32
|
|
|
37
33
|
// If the directory source is selected, filter out user created patterns
|
|
38
34
|
// and those bundled with the theme.
|
|
39
|
-
if (sourceFilter ===
|
|
35
|
+
if (sourceFilter === INSERTER_PATTERN_TYPES.directory && (isUserPattern || !isDirectoryPattern)) {
|
|
40
36
|
return true;
|
|
41
37
|
}
|
|
42
38
|
|
|
43
39
|
// If user source selected, filter out theme patterns.
|
|
44
|
-
if (sourceFilter ===
|
|
40
|
+
if (sourceFilter === INSERTER_PATTERN_TYPES.user && pattern.type !== INSERTER_PATTERN_TYPES.user) {
|
|
45
41
|
return true;
|
|
46
42
|
}
|
|
47
43
|
|
|
48
44
|
// Filter by sync status.
|
|
49
|
-
if (syncFilter ===
|
|
45
|
+
if (syncFilter === INSERTER_SYNC_TYPES.full && pattern.syncStatus !== '') {
|
|
50
46
|
return true;
|
|
51
47
|
}
|
|
52
|
-
if (syncFilter ===
|
|
48
|
+
if (syncFilter === INSERTER_SYNC_TYPES.unsynced && pattern.syncStatus !== 'unsynced' && isUserPattern) {
|
|
53
49
|
return true;
|
|
54
50
|
}
|
|
55
51
|
return false;
|