@wordpress/block-editor 7.0.2 → 8.0.1
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 +11 -0
- package/README.md +45 -1
- package/build/components/autocomplete/index.js +1 -1
- package/build/components/autocomplete/index.js.map +1 -1
- package/build/components/block-actions/index.js +8 -4
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-alignment-control/ui.js +61 -14
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/use-available-alignments.js +25 -3
- package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build/components/block-controls/fill.js +2 -2
- package/build/components/block-controls/fill.js.map +1 -1
- package/build/components/block-controls/hook.js +3 -3
- package/build/components/block-controls/hook.js.map +1 -1
- package/build/components/block-icon/index.js +5 -1
- package/build/components/block-icon/index.js.map +1 -1
- package/build/components/block-icon/index.native.js +9 -11
- package/build/components/block-icon/index.native.js.map +1 -1
- package/build/components/block-inspector/index.js +8 -0
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-html.js +5 -0
- package/build/components/block-list/block-html.js.map +1 -1
- package/build/components/block-list/block.js +12 -5
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +4 -3
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +1 -1
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-block-props/use-multi-selection.js +21 -8
- package/build/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build/components/block-list-appender/index.js +9 -1
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-mover/index.js +4 -4
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-mover/index.native.js +4 -4
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-navigation/dropdown.js +0 -1
- package/build/components/block-navigation/dropdown.js.map +1 -1
- package/build/components/block-patterns-list/index.js +1 -8
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-preview/auto.js +1 -1
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-settings/container.native.js +5 -2
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +26 -5
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +10 -3
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-styles/preview.native.js +2 -2
- package/build/components/block-styles/preview.native.js.map +1 -1
- package/build/components/block-switcher/block-styles-menu.js +1 -1
- package/build/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build/components/block-switcher/index.js +10 -3
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-title/index.js +3 -2
- package/build/components/block-title/index.js.map +1 -1
- package/build/components/block-tools/block-popover.js +2 -4
- package/build/components/block-tools/block-popover.js.map +1 -1
- package/build/components/block-tools/index.js +4 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +96 -7
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/utils.js +17 -8
- package/build/components/border-radius-control/utils.js.map +1 -1
- package/build/components/colors/utils.js +11 -3
- package/build/components/colors/utils.js.map +1 -1
- package/build/components/colors-gradients/control.js +22 -57
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +83 -7
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/contrast-checker/index.js +18 -12
- package/build/components/contrast-checker/index.js.map +1 -1
- package/build/components/copy-handler/index.js +9 -3
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/default-block-appender/index.js +2 -2
- package/build/components/default-block-appender/index.js.map +1 -1
- package/build/components/duotone-control/index.js +41 -39
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/editor-styles/index.js +9 -3
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/font-appearance-control/index.js +32 -21
- package/build/components/font-appearance-control/index.js.map +1 -1
- package/build/components/iframe/index.js +6 -4
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js +126 -0
- package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -0
- package/build/components/image-editor/constants.js +16 -0
- package/build/components/image-editor/constants.js.map +1 -0
- package/build/components/image-editor/context.js +59 -0
- package/build/components/image-editor/context.js.map +1 -0
- package/build/components/image-editor/cropper.js +83 -0
- package/build/components/image-editor/cropper.js.map +1 -0
- package/build/components/image-editor/form-controls.js +36 -0
- package/build/components/image-editor/form-controls.js.map +1 -0
- package/build/components/image-editor/index.js +60 -0
- package/build/components/image-editor/index.js.map +1 -0
- package/build/components/image-editor/rotation-button.js +37 -0
- package/build/components/image-editor/rotation-button.js.map +1 -0
- package/build/components/image-editor/use-save-image.js +84 -0
- package/build/components/image-editor/use-save-image.js.map +1 -0
- package/build/components/image-editor/use-transform-image.js +135 -0
- package/build/components/image-editor/use-transform-image.js.map +1 -0
- package/build/components/image-editor/zoom-dropdown.js +55 -0
- package/build/components/image-editor/zoom-dropdown.js.map +1 -0
- package/build/components/image-size-control/use-dimension-handler.js +14 -3
- package/build/components/image-size-control/use-dimension-handler.js.map +1 -1
- package/build/components/index.js +36 -20
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +2 -2
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/button-block-appender.js +11 -1
- package/build/components/inner-blocks/button-block-appender.js.map +1 -1
- package/build/components/inner-blocks/index.js +8 -5
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +4 -3
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +24 -13
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/explorer.js +62 -0
- package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/patterns-list.js +111 -0
- package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js +78 -0
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
- package/build/components/inserter/block-patterns-tab.js +74 -35
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.native.js +3 -11
- package/build/components/inserter/block-types-tab.native.js.map +1 -1
- package/build/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
- package/build/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build/components/inserter/hooks/use-clipboard-block.native.js +5 -4
- package/build/components/inserter/hooks/use-clipboard-block.native.js.map +1 -1
- package/build/components/inserter/index.js +12 -4
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +1 -7
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/library.js +2 -0
- package/build/components/inserter/library.js.map +1 -1
- package/build/components/inserter/menu.js +2 -1
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/menu.native.js +11 -15
- package/build/components/inserter/menu.native.js.map +1 -1
- package/build/components/inserter/pattern-panel.js +19 -10
- package/build/components/inserter/pattern-panel.js.map +1 -1
- package/build/components/inserter/preview-panel.js +1 -1
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +2 -1
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js +5 -6
- package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build/components/inserter/search-results.native.js +6 -11
- package/build/components/inserter/search-results.native.js.map +1 -1
- package/build/components/inserter/utils.native.js +44 -0
- package/build/components/inserter/utils.native.js.map +1 -0
- package/build/components/inspector-controls/block-support-slot-container.js +28 -0
- package/build/components/inspector-controls/block-support-slot-container.js.map +1 -0
- package/build/components/inspector-controls/block-support-tools-panel.js +78 -0
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -0
- package/build/components/inspector-controls/fill.js +16 -1
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/inspector-controls/groups.js +5 -1
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls/slot.js +15 -0
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +9 -6
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/link-control/index.js +93 -34
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/link-preview.js +45 -15
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-input.js +25 -7
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/list-view/block-contents.js +1 -20
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block.js +54 -69
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +102 -76
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +45 -20
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +2 -2
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/list-item.js +3 -2
- package/build/components/list-view/list-item.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +13 -54
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/media-placeholder/index.js +29 -20
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +5 -3
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +1 -4
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/observe-typing/index.js +1 -1
- package/build/components/observe-typing/index.js.map +1 -1
- package/build/components/plain-text/index.native.js +30 -1
- package/build/components/plain-text/index.native.js.map +1 -1
- package/build/components/rich-text/embed-handler-picker.native.js +66 -0
- package/build/components/rich-text/embed-handler-picker.native.js.map +1 -0
- package/build/components/rich-text/format-edit.js +28 -2
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/rich-text/format-toolbar/index.js +32 -11
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/index.js +5 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +41 -2
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +28 -9
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/rich-text/utils.js +22 -0
- package/build/components/rich-text/utils.js.map +1 -1
- package/build/components/typewriter/index.js +1 -1
- package/build/components/typewriter/index.js.map +1 -1
- package/build/components/url-input/index.js +25 -11
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-moving-animation/index.js +13 -10
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +2 -1
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-setting/index.js +48 -9
- package/build/components/use-setting/index.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +6 -0
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +10 -1
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/align.js +13 -10
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/anchor.js +1 -1
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/border.js +5 -5
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +5 -2
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/dimensions.js +23 -27
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +60 -16
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/font-appearance.js +49 -6
- package/build/hooks/font-appearance.js.map +1 -1
- package/build/hooks/font-family.js +123 -32
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +51 -9
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/gap.js +2 -1
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/index.js +10 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +8 -0
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/letter-spacing.js +44 -7
- package/build/hooks/letter-spacing.js.map +1 -1
- package/build/hooks/line-height.js +45 -8
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/lock.js +43 -0
- package/build/hooks/lock.js.map +1 -0
- package/build/hooks/margin.js +1 -1
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +1 -1
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +7 -4
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/text-decoration.js +42 -6
- package/build/hooks/text-decoration.js.map +1 -1
- package/build/hooks/text-transform.js +42 -6
- package/build/hooks/text-transform.js.map +1 -1
- package/build/hooks/typography.js +108 -8
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/use-cached-truthy.js +29 -0
- package/build/hooks/use-cached-truthy.js.map +1 -0
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/layouts/flex.js +160 -34
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +75 -8
- package/build/layouts/flow.js.map +1 -1
- package/build/store/actions.js +323 -265
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.native.js +13 -1
- package/build/store/defaults.native.js.map +1 -1
- package/build/store/index.js +1 -3
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +33 -22
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +172 -38
- package/build/store/selectors.js.map +1 -1
- package/build/utils/index.js +10 -1
- package/build/utils/index.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +51 -1
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build/utils/transform-styles/transforms/wrap.js +16 -0
- package/build/utils/transform-styles/transforms/wrap.js.map +1 -1
- package/build-module/components/autocomplete/index.js +2 -2
- package/build-module/components/autocomplete/index.js.map +1 -1
- package/build-module/components/block-actions/index.js +8 -4
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.js +64 -17
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +25 -3
- package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build-module/components/block-controls/fill.js +2 -2
- package/build-module/components/block-controls/fill.js.map +1 -1
- package/build-module/components/block-controls/hook.js +3 -3
- package/build-module/components/block-controls/hook.js.map +1 -1
- package/build-module/components/block-icon/index.js +5 -1
- package/build-module/components/block-icon/index.js.map +1 -1
- package/build-module/components/block-icon/index.native.js +10 -11
- package/build-module/components/block-icon/index.native.js.map +1 -1
- package/build-module/components/block-inspector/index.js +8 -0
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-html.js +5 -0
- package/build-module/components/block-list/block-html.js.map +1 -1
- package/build-module/components/block-list/block.js +12 -5
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +4 -3
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +1 -1
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-multi-selection.js +21 -8
- package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +9 -1
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-mover/index.js +4 -4
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-mover/index.native.js +4 -4
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-navigation/dropdown.js +0 -1
- package/build-module/components/block-navigation/dropdown.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +1 -6
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +1 -1
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +6 -3
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +28 -7
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +10 -3
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/preview.native.js +2 -2
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/block-switcher/block-styles-menu.js +1 -1
- package/build-module/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build-module/components/block-switcher/index.js +10 -3
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-title/index.js +3 -2
- package/build-module/components/block-title/index.js.map +1 -1
- package/build-module/components/block-tools/block-popover.js +3 -5
- package/build-module/components/block-tools/block-popover.js.map +1 -1
- package/build-module/components/block-tools/index.js +4 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +96 -8
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/utils.js +16 -9
- package/build-module/components/border-radius-control/utils.js.map +1 -1
- package/build-module/components/colors/utils.js +9 -3
- package/build-module/components/colors/utils.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +26 -63
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +84 -7
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/contrast-checker/index.js +13 -10
- package/build-module/components/contrast-checker/index.js.map +1 -1
- package/build-module/components/copy-handler/index.js +9 -3
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/default-block-appender/index.js +2 -2
- package/build-module/components/default-block-appender/index.js.map +1 -1
- package/build-module/components/duotone-control/index.js +43 -39
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/editor-styles/index.js +7 -3
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/font-appearance-control/index.js +28 -21
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- package/build-module/components/iframe/index.js +6 -4
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js +115 -0
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -0
- package/build-module/components/image-editor/constants.js +7 -0
- package/build-module/components/image-editor/constants.js.map +1 -0
- package/build-module/components/image-editor/context.js +44 -0
- package/build-module/components/image-editor/context.js.map +1 -0
- package/build-module/components/image-editor/cropper.js +69 -0
- package/build-module/components/image-editor/cropper.js.map +1 -0
- package/build-module/components/image-editor/form-controls.js +26 -0
- package/build-module/components/image-editor/form-controls.js.map +1 -0
- package/build-module/components/image-editor/index.js +37 -0
- package/build-module/components/image-editor/index.js.map +1 -0
- package/build-module/components/image-editor/rotation-button.js +26 -0
- package/build-module/components/image-editor/rotation-button.js.map +1 -0
- package/build-module/components/image-editor/use-save-image.js +70 -0
- package/build-module/components/image-editor/use-save-image.js.map +1 -0
- package/build-module/components/image-editor/use-transform-image.js +127 -0
- package/build-module/components/image-editor/use-transform-image.js.map +1 -0
- package/build-module/components/image-editor/zoom-dropdown.js +43 -0
- package/build-module/components/image-editor/zoom-dropdown.js.map +1 -0
- package/build-module/components/image-size-control/use-dimension-handler.js +13 -2
- package/build-module/components/image-size-control/use-dimension-handler.js.map +1 -1
- package/build-module/components/index.js +4 -3
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/button-block-appender.js +10 -1
- package/build-module/components/inner-blocks/button-block-appender.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +9 -6
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +5 -4
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +24 -13
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/explorer.js +50 -0
- package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +92 -0
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js +69 -0
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab.js +75 -36
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.native.js +2 -10
- package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js +4 -7
- package/build-module/components/inserter/hooks/use-block-type-impressions.native.js.map +1 -1
- package/build-module/components/inserter/hooks/use-clipboard-block.native.js +5 -4
- package/build-module/components/inserter/hooks/use-clipboard-block.native.js.map +1 -1
- package/build-module/components/inserter/index.js +12 -4
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +1 -7
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/library.js +2 -0
- package/build-module/components/inserter/library.js.map +1 -1
- package/build-module/components/inserter/menu.js +2 -1
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/menu.native.js +10 -15
- package/build-module/components/inserter/menu.native.js.map +1 -1
- package/build-module/components/inserter/pattern-panel.js +21 -13
- package/build-module/components/inserter/pattern-panel.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +1 -1
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +2 -1
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js +4 -5
- package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build-module/components/inserter/search-results.native.js +5 -10
- package/build-module/components/inserter/search-results.native.js.map +1 -1
- package/build-module/components/inserter/utils.native.js +35 -0
- package/build-module/components/inserter/utils.native.js.map +1 -0
- package/build-module/components/inspector-controls/block-support-slot-container.js +18 -0
- package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -0
- package/build-module/components/inspector-controls/block-support-tools-panel.js +67 -0
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -0
- package/build-module/components/inspector-controls/fill.js +16 -2
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +5 -1
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +13 -0
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +9 -6
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +93 -35
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +46 -17
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-input.js +24 -7
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +1 -18
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block.js +56 -71
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +102 -78
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +48 -23
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +2 -2
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/list-item.js +3 -2
- package/build-module/components/list-view/list-item.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +13 -54
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +29 -20
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +5 -3
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +1 -4
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/observe-typing/index.js +1 -1
- package/build-module/components/observe-typing/index.js.map +1 -1
- package/build-module/components/plain-text/index.native.js +29 -2
- package/build-module/components/plain-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/embed-handler-picker.native.js +54 -0
- package/build-module/components/rich-text/embed-handler-picker.native.js.map +1 -0
- package/build-module/components/rich-text/format-edit.js +28 -3
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js +29 -11
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +4 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +41 -3
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +28 -9
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/rich-text/utils.js +20 -0
- package/build-module/components/rich-text/utils.js.map +1 -1
- package/build-module/components/typewriter/index.js +1 -1
- package/build-module/components/typewriter/index.js.map +1 -1
- package/build-module/components/url-input/index.js +25 -11
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +13 -10
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +3 -2
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +48 -9
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +6 -0
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +10 -1
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/align.js +13 -10
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/anchor.js +1 -1
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/border.js +5 -5
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +6 -3
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/dimensions.js +24 -27
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +59 -16
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/font-appearance.js +45 -6
- package/build-module/hooks/font-appearance.js.map +1 -1
- package/build-module/hooks/font-family.js +117 -33
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +47 -9
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/gap.js +2 -1
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/index.js +2 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/index.native.js +1 -0
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/letter-spacing.js +40 -7
- package/build-module/hooks/letter-spacing.js.map +1 -1
- package/build-module/hooks/line-height.js +41 -8
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/lock.js +33 -0
- package/build-module/hooks/lock.js.map +1 -0
- package/build-module/hooks/margin.js +1 -1
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +1 -1
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +7 -4
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/text-decoration.js +38 -6
- package/build-module/hooks/text-decoration.js.map +1 -1
- package/build-module/hooks/text-transform.js +38 -6
- package/build-module/hooks/text-transform.js.map +1 -1
- package/build-module/hooks/typography.js +117 -17
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/use-cached-truthy.js +21 -0
- package/build-module/hooks/use-cached-truthy.js.map +1 -0
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/flex.js +163 -38
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +74 -8
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/store/actions.js +286 -241
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.native.js +12 -1
- package/build-module/store/defaults.native.js.map +1 -1
- package/build-module/store/index.js +1 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +33 -22
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +160 -34
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/index.js +1 -0
- package/build-module/utils/index.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +48 -1
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/utils/transform-styles/transforms/wrap.js +16 -0
- package/build-module/utils/transform-styles/transforms/wrap.js.map +1 -1
- package/build-style/style-rtl.css +267 -144
- package/build-style/style.css +267 -144
- package/package.json +28 -27
- package/src/components/autocomplete/index.js +5 -2
- package/src/components/block-actions/index.js +9 -5
- package/src/components/block-alignment-control/style.scss +5 -0
- package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +15 -1
- package/src/components/block-alignment-control/test/index.native.js +37 -0
- package/src/components/block-alignment-control/ui.js +98 -27
- package/src/components/block-alignment-control/use-available-alignments.js +31 -10
- package/src/components/block-controls/fill.js +5 -2
- package/src/components/block-controls/hook.js +3 -3
- package/src/components/block-draggable/style.scss +19 -4
- package/src/components/block-icon/index.js +4 -1
- package/src/components/block-icon/index.native.js +10 -16
- package/src/components/block-inspector/index.js +10 -0
- package/src/components/block-list/block-html.js +5 -0
- package/src/components/block-list/block.js +11 -3
- package/src/components/block-list/block.native.js +5 -3
- package/src/components/block-list/index.native.js +1 -1
- package/src/components/block-list/style.scss +15 -0
- package/src/components/block-list/use-block-props/use-multi-selection.js +27 -7
- package/src/components/block-list-appender/index.js +8 -0
- package/src/components/block-mover/index.js +4 -4
- package/src/components/block-mover/index.native.js +4 -4
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +10 -6
- package/src/components/block-mover/test/index.native.js +26 -28
- package/src/components/block-navigation/dropdown.js +0 -1
- package/src/components/block-patterns-list/index.js +1 -8
- package/src/components/block-patterns-list/style.scss +22 -12
- package/src/components/block-preview/README.md +1 -1
- package/src/components/block-preview/auto.js +1 -1
- package/src/components/block-preview/style.scss +0 -17
- package/src/components/block-settings/container.native.js +7 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +26 -13
- package/src/components/block-settings-menu-controls/index.js +9 -6
- package/src/components/block-styles/preview.native.js +2 -2
- package/src/components/block-switcher/block-styles-menu.js +1 -1
- package/src/components/block-switcher/index.js +7 -3
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +1 -1
- package/src/components/block-switcher/test/index.js +3 -0
- package/src/components/block-title/index.js +5 -2
- package/src/components/block-tools/block-popover.js +3 -5
- package/src/components/block-tools/index.js +5 -2
- package/src/components/block-tools/insertion-point.js +97 -9
- package/src/components/block-tools/style.scss +4 -35
- package/src/components/block-types-list/style.scss +0 -3
- package/src/components/border-radius-control/index.js +1 -0
- package/src/components/border-radius-control/test/utils.js +216 -0
- package/src/components/border-radius-control/utils.js +18 -10
- package/src/components/color-palette/test/__snapshots__/control.js.snap +128 -71
- package/src/components/colors/test/utils.js +41 -0
- package/src/components/colors/utils.js +9 -5
- package/src/components/colors-gradients/control.js +70 -110
- package/src/components/colors-gradients/panel-color-gradient-settings.js +79 -7
- package/src/components/colors-gradients/style.scss +10 -18
- package/src/components/colors-gradients/test/control.js +41 -66
- package/src/components/contrast-checker/index.js +14 -10
- package/src/components/copy-handler/index.js +6 -1
- package/src/components/default-block-appender/index.js +2 -2
- package/src/components/default-block-appender/test/__snapshots__/index.js.snap +3 -3
- package/src/components/duotone-control/index.js +49 -41
- package/src/components/duotone-control/style.scss +27 -12
- package/src/components/editor-styles/index.js +7 -4
- package/src/components/font-appearance-control/index.js +41 -33
- package/src/components/font-appearance-control/style.scss +1 -1
- package/src/components/iframe/index.js +4 -4
- package/src/components/image-editor/aspect-ratio-dropdown.js +129 -0
- package/src/components/image-editor/constants.js +6 -0
- package/src/components/image-editor/context.js +56 -0
- package/src/components/image-editor/cropper.js +74 -0
- package/src/components/image-editor/form-controls.js +22 -0
- package/src/components/image-editor/index.js +52 -0
- package/src/components/image-editor/rotation-button.js +24 -0
- package/src/components/image-editor/use-save-image.js +97 -0
- package/src/components/image-editor/use-transform-image.js +162 -0
- package/src/components/image-editor/zoom-dropdown.js +40 -0
- package/src/components/image-size-control/use-dimension-handler.js +18 -1
- package/src/components/index.js +7 -6
- package/src/components/index.native.js +1 -4
- package/src/components/inner-blocks/button-block-appender.js +9 -0
- package/src/components/inner-blocks/index.js +8 -4
- package/src/components/inner-blocks/index.native.js +7 -4
- package/src/components/inner-blocks/use-nested-settings-update.js +26 -11
- package/src/components/inserter/block-patterns-explorer/explorer.js +50 -0
- package/src/components/inserter/block-patterns-explorer/patterns-list.js +122 -0
- package/src/components/inserter/block-patterns-explorer/sidebar.js +73 -0
- package/src/components/inserter/block-patterns-tab.js +107 -73
- package/src/components/inserter/block-types-tab.native.js +3 -15
- package/src/components/inserter/hooks/use-block-type-impressions.native.js +14 -21
- package/src/components/inserter/hooks/use-clipboard-block.native.js +3 -2
- package/src/components/inserter/index.js +15 -3
- package/src/components/inserter/index.native.js +2 -19
- package/src/components/inserter/library.js +2 -0
- package/src/components/inserter/menu.js +4 -1
- package/src/components/inserter/menu.native.js +9 -14
- package/src/components/inserter/pattern-panel.js +33 -16
- package/src/components/inserter/preview-panel.js +1 -1
- package/src/components/inserter/quick-inserter.js +1 -1
- package/src/components/inserter/reusable-blocks-tab.native.js +4 -6
- package/src/components/inserter/search-results.native.js +5 -15
- package/src/components/inserter/style.scss +80 -16
- package/src/components/inserter/test/block-types-tab.native.js +1 -1
- package/src/components/inserter/test/fixtures/index.native.js +12 -0
- package/src/components/inserter/utils.native.js +35 -0
- package/src/components/inserter-list-item/style.scss +4 -2
- package/src/components/inspector-controls/block-support-slot-container.js +10 -0
- package/src/components/inspector-controls/block-support-tools-panel.js +60 -0
- package/src/components/inspector-controls/fill.js +23 -2
- package/src/components/inspector-controls/groups.js +8 -0
- package/src/components/inspector-controls/slot.js +15 -0
- package/src/components/letter-spacing-control/index.js +12 -6
- package/src/components/link-control/README.md +47 -14
- package/src/components/link-control/index.js +102 -31
- package/src/components/link-control/link-preview.js +53 -20
- package/src/components/link-control/search-input.js +21 -7
- package/src/components/link-control/style.scss +66 -19
- package/src/components/link-control/test/index.js +311 -4
- package/src/components/list-view/block-contents.js +17 -38
- package/src/components/list-view/block.js +73 -84
- package/src/components/list-view/branch.js +123 -94
- package/src/components/list-view/index.js +82 -30
- package/src/components/list-view/leaf.js +2 -2
- package/src/components/list-view/list-item.js +5 -4
- package/src/components/list-view/style.scss +70 -33
- package/src/components/list-view/use-list-view-client-ids.js +9 -68
- package/src/components/media-placeholder/index.js +26 -19
- package/src/components/media-replace-flow/README.md +7 -0
- package/src/components/media-replace-flow/index.js +4 -1
- package/src/components/media-upload/README.md +1 -1
- package/src/components/navigable-toolbar/index.js +1 -4
- package/src/components/observe-typing/index.js +3 -2
- package/src/components/plain-text/index.native.js +26 -4
- package/src/components/rich-text/embed-handler-picker.native.js +68 -0
- package/src/components/rich-text/format-edit.js +36 -2
- package/src/components/rich-text/format-toolbar/index.js +25 -6
- package/src/components/rich-text/index.js +12 -8
- package/src/components/rich-text/index.native.js +35 -1
- package/src/components/rich-text/use-paste-handler.js +30 -12
- package/src/components/rich-text/utils.js +16 -0
- package/src/components/skip-to-selected-block/README.md +39 -0
- package/src/components/typewriter/index.js +3 -2
- package/src/components/url-input/index.js +26 -10
- package/src/components/use-moving-animation/index.js +9 -8
- package/src/components/use-on-block-drop/index.js +5 -1
- package/src/components/use-setting/index.js +49 -11
- package/src/components/writing-flow/use-multi-selection.js +6 -0
- package/src/components/writing-flow/use-tab-nav.js +17 -3
- package/src/hooks/align.js +19 -10
- package/src/hooks/anchor.js +2 -2
- package/src/hooks/border.js +8 -11
- package/src/hooks/color-panel.js +4 -1
- package/src/hooks/color.js +7 -4
- package/src/hooks/dimensions.js +48 -59
- package/src/hooks/duotone.js +68 -19
- package/src/hooks/font-appearance.js +38 -7
- package/src/hooks/font-family.js +129 -33
- package/src/hooks/font-size.js +42 -6
- package/src/hooks/gap.js +2 -1
- package/src/hooks/index.js +2 -0
- package/src/hooks/index.native.js +1 -0
- package/src/hooks/layout.scss +8 -0
- package/src/hooks/letter-spacing.js +35 -7
- package/src/hooks/line-height.js +37 -9
- package/src/hooks/lock.js +34 -0
- package/src/hooks/margin.js +1 -1
- package/src/hooks/padding.js +1 -1
- package/src/hooks/style.js +15 -11
- package/src/hooks/text-decoration.js +34 -6
- package/src/hooks/text-transform.js +34 -6
- package/src/hooks/typography.js +165 -15
- package/src/hooks/typography.scss +16 -0
- package/src/hooks/use-cached-truthy.js +20 -0
- package/src/index.js +1 -0
- package/src/layouts/flex.js +179 -50
- package/src/layouts/flow.js +54 -8
- package/src/store/actions.js +239 -377
- package/src/store/defaults.native.js +12 -0
- package/src/store/index.js +1 -2
- package/src/store/reducer.js +54 -18
- package/src/store/selectors.js +173 -47
- package/src/store/test/actions.js +407 -705
- package/src/store/test/reducer.js +22 -54
- package/src/store/test/selectors.js +79 -21
- package/src/style.scss +2 -1
- package/src/utils/index.js +1 -0
- package/src/utils/parse-css-unit-to-px.js +43 -1
- package/src/utils/test/parse-css-unit-to-px.js +148 -165
- package/src/utils/transform-styles/transforms/test/wrap.js +1 -1
- package/src/utils/transform-styles/transforms/wrap.js +16 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/duotone-control/duotone-picker-popover.js +0 -44
- package/build/components/duotone-control/duotone-picker-popover.js.map +0 -1
- package/build/components/list-view/block-slot.js +0 -121
- package/build/components/list-view/block-slot.js.map +0 -1
- package/build/components/list-view/editor.js +0 -35
- package/build/components/list-view/editor.js.map +0 -1
- package/build/components/text-decoration-and-transform/index.js +0 -39
- package/build/components/text-decoration-and-transform/index.js.map +0 -1
- package/build/store/controls.js +0 -44
- package/build/store/controls.js.map +0 -1
- package/build-module/components/duotone-control/duotone-picker-popover.js +0 -35
- package/build-module/components/duotone-control/duotone-picker-popover.js.map +0 -1
- package/build-module/components/list-view/block-slot.js +0 -96
- package/build-module/components/list-view/block-slot.js.map +0 -1
- package/build-module/components/list-view/editor.js +0 -25
- package/build-module/components/list-view/editor.js.map +0 -1
- package/build-module/components/text-decoration-and-transform/index.js +0 -30
- package/build-module/components/text-decoration-and-transform/index.js.map +0 -1
- package/build-module/store/controls.js +0 -32
- package/build-module/store/controls.js.map +0 -1
- package/src/components/duotone-control/duotone-picker-popover.js +0 -36
- package/src/components/list-view/block-slot.js +0 -120
- package/src/components/list-view/editor.js +0 -29
- package/src/components/text-decoration-and-transform/index.js +0 -36
- package/src/components/text-decoration-and-transform/style.scss +0 -3
- package/src/store/controls.js +0 -39
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/sidebar.js"],"names":["PatternCategoriesList","selectedCategory","patternCategories","onClickCategory","baseClassName","map","name","label","PatternsExplorerSearch","filterValue","setFilterValue","PatternExplorerSidebar"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,SAASA,qBAAT,CAAgC;AAC/BC,EAAAA,gBAD+B;AAE/BC,EAAAA,iBAF+B;AAG/BC,EAAAA;AAH+B,CAAhC,EAII;AACH,QAAMC,aAAa,GAAG,+CAAtB;AACA,SACC;AAAK,IAAA,SAAS,EAAI,GAAGA,aAAe;AAApC,KACGF,iBAAiB,CAACG,GAAlB,CAAuB,CAAE;AAAEC,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAAF,KAAuB;AAC/C,WACC,4BAAC,kBAAD;AACC,MAAA,GAAG,EAAGD,IADP;AAEC,MAAA,KAAK,EAAGC,KAFT;AAGC,MAAA,SAAS,EAAI,GAAGH,aAAe,yBAHhC;AAIC,MAAA,SAAS,EAAGH,gBAAgB,KAAKK,IAJlC;AAKC,MAAA,OAAO,EAAG,MAAM;AACfH,QAAAA,eAAe,CAAEG,IAAF,CAAf;AACA;AAPF,OASGC,KATH,CADD;AAaA,GAdC,CADH,CADD;AAmBA;;AAED,SAASC,sBAAT,CAAiC;AAAEC,EAAAA,WAAF;AAAeC,EAAAA;AAAf,CAAjC,EAAmE;AAClE,QAAMN,aAAa,GAAG,8CAAtB;AACA,SACC;AAAK,IAAA,SAAS,EAAGA;AAAjB,KACC,4BAAC,yBAAD;AACC,IAAA,QAAQ,EAAGM,cADZ;AAEC,IAAA,KAAK,EAAGD,WAFT;AAGC,IAAA,KAAK,EAAG,cAAI,qBAAJ,CAHT;AAIC,IAAA,WAAW,EAAG,cAAI,QAAJ;AAJf,IADD,CADD;AAUA;;AAED,SAASE,sBAAT,CAAiC;AAChCV,EAAAA,gBADgC;AAEhCC,EAAAA,iBAFgC;AAGhCC,EAAAA,eAHgC;AAIhCM,EAAAA,WAJgC;AAKhCC,EAAAA;AALgC,CAAjC,EAMI;AACH,QAAMN,aAAa,GAAG,+CAAtB;AACA,SACC;AAAK,IAAA,SAAS,EAAGA;AAAjB,KACC,4BAAC,sBAAD;AACC,IAAA,WAAW,EAAGK,WADf;AAEC,IAAA,cAAc,EAAGC;AAFlB,IADD,EAKG,CAAED,WAAF,IACD,4BAAC,qBAAD;AACC,IAAA,gBAAgB,EAAGR,gBADpB;AAEC,IAAA,iBAAiB,EAAGC,iBAFrB;AAGC,IAAA,eAAe,EAAGC;AAHnB,IANF,CADD;AAeA;;eAEcQ,sB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, SearchControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nfunction PatternCategoriesList( {\n\tselectedCategory,\n\tpatternCategories,\n\tonClickCategory,\n} ) {\n\tconst baseClassName = 'block-editor-block-patterns-explorer__sidebar';\n\treturn (\n\t\t<div className={ `${ baseClassName }__categories-list` }>\n\t\t\t{ patternCategories.map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\tclassName={ `${ baseClassName }__categories-list__item` }\n\t\t\t\t\t\tisPressed={ selectedCategory === name }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonClickCategory( name );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</Button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n\nfunction PatternsExplorerSearch( { filterValue, setFilterValue } ) {\n\tconst baseClassName = 'block-editor-block-patterns-explorer__search';\n\treturn (\n\t\t<div className={ baseClassName }>\n\t\t\t<SearchControl\n\t\t\t\tonChange={ setFilterValue }\n\t\t\t\tvalue={ filterValue }\n\t\t\t\tlabel={ __( 'Search for patterns' ) }\n\t\t\t\tplaceholder={ __( 'Search' ) }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction PatternExplorerSidebar( {\n\tselectedCategory,\n\tpatternCategories,\n\tonClickCategory,\n\tfilterValue,\n\tsetFilterValue,\n} ) {\n\tconst baseClassName = 'block-editor-block-patterns-explorer__sidebar';\n\treturn (\n\t\t<div className={ baseClassName }>\n\t\t\t<PatternsExplorerSearch\n\t\t\t\tfilterValue={ filterValue }\n\t\t\t\tsetFilterValue={ setFilterValue }\n\t\t\t/>\n\t\t\t{ ! filterValue && (\n\t\t\t\t<PatternCategoriesList\n\t\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\t\tonClickCategory={ onClickCategory }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default PatternExplorerSidebar;\n"]}
|
|
@@ -9,8 +9,6 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
-
var _lodash = require("lodash");
|
|
13
|
-
|
|
14
12
|
var _i18n = require("@wordpress/i18n");
|
|
15
13
|
|
|
16
14
|
var _compose = require("@wordpress/compose");
|
|
@@ -21,9 +19,7 @@ var _usePatternsState = _interopRequireDefault(require("./hooks/use-patterns-sta
|
|
|
21
19
|
|
|
22
20
|
var _blockPatternsList = _interopRequireDefault(require("../block-patterns-list"));
|
|
23
21
|
|
|
24
|
-
|
|
25
|
-
* External dependencies
|
|
26
|
-
*/
|
|
22
|
+
var _explorer = _interopRequireDefault(require("./block-patterns-explorer/explorer"));
|
|
27
23
|
|
|
28
24
|
/**
|
|
29
25
|
* WordPress dependencies
|
|
@@ -36,35 +32,29 @@ function BlockPatternsCategory({
|
|
|
36
32
|
rootClientId,
|
|
37
33
|
onInsert,
|
|
38
34
|
selectedCategory,
|
|
39
|
-
|
|
35
|
+
populatedCategories
|
|
40
36
|
}) {
|
|
41
|
-
const [allPatterns
|
|
42
|
-
|
|
43
|
-
const populatedCategories = (0, _element.useMemo)(() => allCategories.filter(category => allPatterns.some(pattern => {
|
|
37
|
+
const [allPatterns,, onClick] = (0, _usePatternsState.default)(onInsert, rootClientId);
|
|
38
|
+
const getPatternIndex = (0, _element.useCallback)(pattern => {
|
|
44
39
|
var _pattern$categories;
|
|
45
40
|
|
|
46
|
-
|
|
47
|
-
})), [allPatterns, allCategories]);
|
|
48
|
-
const patternCategory = selectedCategory ? selectedCategory : populatedCategories[0];
|
|
49
|
-
(0, _element.useEffect)(() => {
|
|
50
|
-
if (allPatterns.some(pattern => getPatternIndex(pattern) === Infinity) && !populatedCategories.find(category => category.name === 'uncategorized')) {
|
|
51
|
-
populatedCategories.push({
|
|
52
|
-
name: 'uncategorized',
|
|
53
|
-
label: (0, _i18n._x)('Uncategorized')
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}, [populatedCategories, allPatterns]);
|
|
57
|
-
const getPatternIndex = (0, _element.useCallback)(pattern => {
|
|
58
|
-
if (!pattern.categories || !pattern.categories.length) {
|
|
41
|
+
if (!((_pattern$categories = pattern.categories) !== null && _pattern$categories !== void 0 && _pattern$categories.length)) {
|
|
59
42
|
return Infinity;
|
|
60
43
|
}
|
|
61
44
|
|
|
62
|
-
const indexedCategories =
|
|
45
|
+
const indexedCategories = populatedCategories.reduce((accumulator, {
|
|
63
46
|
name
|
|
64
|
-
}, index) =>
|
|
47
|
+
}, index) => {
|
|
48
|
+
accumulator[name] = index;
|
|
49
|
+
return accumulator;
|
|
50
|
+
}, {});
|
|
65
51
|
return Math.min(...pattern.categories.map(cat => indexedCategories[cat] !== undefined ? indexedCategories[cat] : Infinity));
|
|
66
52
|
}, [populatedCategories]);
|
|
67
|
-
const currentCategoryPatterns = (0, _element.useMemo)(() => allPatterns.filter(pattern =>
|
|
53
|
+
const currentCategoryPatterns = (0, _element.useMemo)(() => allPatterns.filter(pattern => {
|
|
54
|
+
var _pattern$categories2;
|
|
55
|
+
|
|
56
|
+
return selectedCategory.name === 'uncategorized' ? getPatternIndex(pattern) === Infinity : (_pattern$categories2 = pattern.categories) === null || _pattern$categories2 === void 0 ? void 0 : _pattern$categories2.includes(selectedCategory.name);
|
|
57
|
+
}), [allPatterns, selectedCategory]); // Ordering the patterns is important for the async rendering.
|
|
68
58
|
|
|
69
59
|
const orderedPatterns = (0, _element.useMemo)(() => {
|
|
70
60
|
return currentCategoryPatterns.sort((a, b) => {
|
|
@@ -72,18 +62,21 @@ function BlockPatternsCategory({
|
|
|
72
62
|
});
|
|
73
63
|
}, [currentCategoryPatterns, getPatternIndex]);
|
|
74
64
|
const currentShownPatterns = (0, _compose.useAsyncList)(orderedPatterns);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
|
|
66
|
+
if (!currentCategoryPatterns.length) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return (0, _element.createElement)("div", {
|
|
71
|
+
className: "block-editor-inserter__panel-content"
|
|
79
72
|
}, (0, _element.createElement)(_blockPatternsList.default, {
|
|
80
73
|
shownPatterns: currentShownPatterns,
|
|
81
74
|
blockPatterns: currentCategoryPatterns,
|
|
82
75
|
onClickPattern: onClick,
|
|
83
|
-
label:
|
|
76
|
+
label: selectedCategory.label,
|
|
84
77
|
orientation: "vertical",
|
|
85
78
|
isDraggable: true
|
|
86
|
-
}))
|
|
79
|
+
}));
|
|
87
80
|
}
|
|
88
81
|
|
|
89
82
|
function BlockPatternsTabs({
|
|
@@ -92,12 +85,58 @@ function BlockPatternsTabs({
|
|
|
92
85
|
onClickCategory,
|
|
93
86
|
selectedCategory
|
|
94
87
|
}) {
|
|
95
|
-
|
|
88
|
+
const [showPatternsExplorer, setShowPatternsExplorer] = (0, _element.useState)(false);
|
|
89
|
+
const [allPatterns, allCategories] = (0, _usePatternsState.default)();
|
|
90
|
+
const hasRegisteredCategory = (0, _element.useCallback)(pattern => {
|
|
91
|
+
if (!pattern.categories || !pattern.categories.length) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return pattern.categories.some(cat => allCategories.some(category => category.name === cat));
|
|
96
|
+
}, [allCategories]); // Remove any empty categories
|
|
97
|
+
|
|
98
|
+
const populatedCategories = (0, _element.useMemo)(() => {
|
|
99
|
+
const categories = allCategories.filter(category => allPatterns.some(pattern => {
|
|
100
|
+
var _pattern$categories3;
|
|
101
|
+
|
|
102
|
+
return (_pattern$categories3 = pattern.categories) === null || _pattern$categories3 === void 0 ? void 0 : _pattern$categories3.includes(category.name);
|
|
103
|
+
})).sort(({
|
|
104
|
+
name: currentName
|
|
105
|
+
}, {
|
|
106
|
+
name: nextName
|
|
107
|
+
}) => {
|
|
108
|
+
if (![currentName, nextName].includes('featured')) {
|
|
109
|
+
return 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return currentName === 'featured' ? -1 : 1;
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
if (allPatterns.some(pattern => !hasRegisteredCategory(pattern)) && !categories.find(category => category.name === 'uncategorized')) {
|
|
116
|
+
categories.push({
|
|
117
|
+
name: 'uncategorized',
|
|
118
|
+
label: (0, _i18n._x)('Uncategorized')
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return categories;
|
|
123
|
+
}, [allPatterns, allCategories]);
|
|
124
|
+
const patternCategory = selectedCategory ? selectedCategory : populatedCategories[0];
|
|
125
|
+
return (0, _element.createElement)(_element.Fragment, null, !showPatternsExplorer && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_patternPanel.default, {
|
|
126
|
+
selectedCategory: patternCategory,
|
|
127
|
+
patternCategories: populatedCategories,
|
|
128
|
+
onClickCategory: onClickCategory,
|
|
129
|
+
openPatternExplorer: () => setShowPatternsExplorer(true)
|
|
130
|
+
}), (0, _element.createElement)(BlockPatternsCategory, {
|
|
96
131
|
rootClientId: rootClientId,
|
|
97
|
-
selectedCategory: selectedCategory,
|
|
98
132
|
onInsert: onInsert,
|
|
99
|
-
|
|
100
|
-
|
|
133
|
+
selectedCategory: patternCategory,
|
|
134
|
+
populatedCategories: populatedCategories
|
|
135
|
+
})), showPatternsExplorer && (0, _element.createElement)(_explorer.default, {
|
|
136
|
+
initialCategory: patternCategory,
|
|
137
|
+
patternCategories: populatedCategories,
|
|
138
|
+
onModalClose: () => setShowPatternsExplorer(false)
|
|
139
|
+
}));
|
|
101
140
|
}
|
|
102
141
|
|
|
103
142
|
var _default = BlockPatternsTabs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab.js"],"names":["BlockPatternsCategory","rootClientId","onInsert","selectedCategory","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab.js"],"names":["BlockPatternsCategory","rootClientId","onInsert","selectedCategory","populatedCategories","allPatterns","onClick","getPatternIndex","pattern","categories","length","Infinity","indexedCategories","reduce","accumulator","name","index","Math","min","map","cat","undefined","currentCategoryPatterns","filter","includes","orderedPatterns","sort","a","b","currentShownPatterns","label","BlockPatternsTabs","onClickCategory","showPatternsExplorer","setShowPatternsExplorer","allCategories","hasRegisteredCategory","some","category","currentName","nextName","find","push","patternCategory"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAKA;AACA;AACA;AAMA,SAASA,qBAAT,CAAgC;AAC/BC,EAAAA,YAD+B;AAE/BC,EAAAA,QAF+B;AAG/BC,EAAAA,gBAH+B;AAI/BC,EAAAA;AAJ+B,CAAhC,EAKI;AACH,QAAM,CAAEC,WAAF,GAAiBC,OAAjB,IAA6B,+BAClCJ,QADkC,EAElCD,YAFkC,CAAnC;AAKA,QAAMM,eAAe,GAAG,0BACrBC,OAAF,IAAe;AAAA;;AACd,QAAK,yBAAEA,OAAO,CAACC,UAAV,gDAAE,oBAAoBC,MAAtB,CAAL,EAAoC;AACnC,aAAOC,QAAP;AACA;;AACD,UAAMC,iBAAiB,GAAGR,mBAAmB,CAACS,MAApB,CACzB,CAAEC,WAAF,EAAe;AAAEC,MAAAA;AAAF,KAAf,EAAyBC,KAAzB,KAAoC;AACnCF,MAAAA,WAAW,CAAEC,IAAF,CAAX,GAAsBC,KAAtB;AACA,aAAOF,WAAP;AACA,KAJwB,EAKzB,EALyB,CAA1B;AAOA,WAAOG,IAAI,CAACC,GAAL,CACN,GAAGV,OAAO,CAACC,UAAR,CAAmBU,GAAnB,CAA0BC,GAAF,IAC1BR,iBAAiB,CAAEQ,GAAF,CAAjB,KAA6BC,SAA7B,GACGT,iBAAiB,CAAEQ,GAAF,CADpB,GAEGT,QAHD,CADG,CAAP;AAOA,GAnBsB,EAoBvB,CAAEP,mBAAF,CApBuB,CAAxB;AAuBA,QAAMkB,uBAAuB,GAAG,sBAC/B,MACCjB,WAAW,CAACkB,MAAZ,CAAsBf,OAAF;AAAA;;AAAA,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cAAI,eAAJ;AAFS,OAAjB;AAIA;;AAED,WAAOrB,UAAP;AACA,GA7B2B,EA6BzB,CAAEJ,WAAF,EAAe8B,aAAf,CA7ByB,CAA5B;AA+BA,QAAMQ,eAAe,GAAGxC,gBAAgB,GACrCA,gBADqC,GAErCC,mBAAmB,CAAE,CAAF,CAFtB;AAIA,SACC,qDACG,CAAE6B,oBAAF,IACD,qDACC,4BAAC,qBAAD;AACC,IAAA,gBAAgB,EAAGU,eADpB;AAEC,IAAA,iBAAiB,EAAGvC,mBAFrB;AAGC,IAAA,eAAe,EAAG4B,eAHnB;AAIC,IAAA,mBAAmB,EAAG,MACrBE,uBAAuB,CAAE,IAAF;AALzB,IADD,EASC,4BAAC,qBAAD;AACC,IAAA,YAAY,EAAGjC,YADhB;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,gBAAgB,EAAGyC,eAHpB;AAIC,IAAA,mBAAmB,EAAGvC;AAJvB,IATD,CAFF,EAmBG6B,oBAAoB,IACrB,4BAAC,iBAAD;AACC,IAAA,eAAe,EAAGU,eADnB;AAEC,IAAA,iBAAiB,EAAGvC,mBAFrB;AAGC,IAAA,YAAY,EAAG,MAAM8B,uBAAuB,CAAE,KAAF;AAH7C,IApBF,CADD;AA6BA;;eAEcH,iB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useState, useCallback } from '@wordpress/element';\nimport { _x } from '@wordpress/i18n';\nimport { useAsyncList } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport PatternInserterPanel from './pattern-panel';\nimport usePatternsState from './hooks/use-patterns-state';\nimport BlockPatternList from '../block-patterns-list';\nimport PatternsExplorerModal from './block-patterns-explorer/explorer';\n\nfunction BlockPatternsCategory( {\n\trootClientId,\n\tonInsert,\n\tselectedCategory,\n\tpopulatedCategories,\n} ) {\n\tconst [ allPatterns, , onClick ] = usePatternsState(\n\t\tonInsert,\n\t\trootClientId\n\t);\n\n\tconst getPatternIndex = useCallback(\n\t\t( pattern ) => {\n\t\t\tif ( ! pattern.categories?.length ) {\n\t\t\t\treturn Infinity;\n\t\t\t}\n\t\t\tconst indexedCategories = populatedCategories.reduce(\n\t\t\t\t( accumulator, { name }, index ) => {\n\t\t\t\t\taccumulator[ name ] = index;\n\t\t\t\t\treturn accumulator;\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t\treturn Math.min(\n\t\t\t\t...pattern.categories.map( ( cat ) =>\n\t\t\t\t\tindexedCategories[ cat ] !== undefined\n\t\t\t\t\t\t? indexedCategories[ cat ]\n\t\t\t\t\t\t: Infinity\n\t\t\t\t)\n\t\t\t);\n\t\t},\n\t\t[ populatedCategories ]\n\t);\n\n\tconst currentCategoryPatterns = useMemo(\n\t\t() =>\n\t\t\tallPatterns.filter( ( pattern ) =>\n\t\t\t\tselectedCategory.name === 'uncategorized'\n\t\t\t\t\t? getPatternIndex( pattern ) === Infinity\n\t\t\t\t\t: pattern.categories?.includes( selectedCategory.name )\n\t\t\t),\n\t\t[ allPatterns, selectedCategory ]\n\t);\n\n\t// Ordering the patterns is important for the async rendering.\n\tconst orderedPatterns = useMemo( () => {\n\t\treturn currentCategoryPatterns.sort( ( a, b ) => {\n\t\t\treturn getPatternIndex( a ) - getPatternIndex( b );\n\t\t} );\n\t}, [ currentCategoryPatterns, getPatternIndex ] );\n\n\tconst currentShownPatterns = useAsyncList( orderedPatterns );\n\n\tif ( ! currentCategoryPatterns.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"block-editor-inserter__panel-content\">\n\t\t\t<BlockPatternList\n\t\t\t\tshownPatterns={ currentShownPatterns }\n\t\t\t\tblockPatterns={ currentCategoryPatterns }\n\t\t\t\tonClickPattern={ onClick }\n\t\t\t\tlabel={ selectedCategory.label }\n\t\t\t\torientation=\"vertical\"\n\t\t\t\tisDraggable\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction BlockPatternsTabs( {\n\trootClientId,\n\tonInsert,\n\tonClickCategory,\n\tselectedCategory,\n} ) {\n\tconst [ showPatternsExplorer, setShowPatternsExplorer ] = useState( false );\n\tconst [ allPatterns, allCategories ] = usePatternsState();\n\n\tconst hasRegisteredCategory = useCallback(\n\t\t( pattern ) => {\n\t\t\tif ( ! pattern.categories || ! pattern.categories.length ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn pattern.categories.some( ( cat ) =>\n\t\t\t\tallCategories.some( ( category ) => category.name === cat )\n\t\t\t);\n\t\t},\n\t\t[ allCategories ]\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\tallPatterns.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( ( { name: currentName }, { name: nextName } ) => {\n\t\t\t\tif ( ! [ currentName, nextName ].includes( 'featured' ) ) {\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\treturn currentName === 'featured' ? -1 : 1;\n\t\t\t} );\n\n\t\tif (\n\t\t\tallPatterns.some(\n\t\t\t\t( pattern ) => ! hasRegisteredCategory( pattern )\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\n\t\treturn categories;\n\t}, [ allPatterns, allCategories ] );\n\n\tconst patternCategory = selectedCategory\n\t\t? selectedCategory\n\t\t: populatedCategories[ 0 ];\n\n\treturn (\n\t\t<>\n\t\t\t{ ! showPatternsExplorer && (\n\t\t\t\t<>\n\t\t\t\t\t<PatternInserterPanel\n\t\t\t\t\t\tselectedCategory={ patternCategory }\n\t\t\t\t\t\tpatternCategories={ populatedCategories }\n\t\t\t\t\t\tonClickCategory={ onClickCategory }\n\t\t\t\t\t\topenPatternExplorer={ () =>\n\t\t\t\t\t\t\tsetShowPatternsExplorer( true )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<BlockPatternsCategory\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tonInsert={ onInsert }\n\t\t\t\t\t\tselectedCategory={ patternCategory }\n\t\t\t\t\t\tpopulatedCategories={ populatedCategories }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ showPatternsExplorer && (\n\t\t\t\t<PatternsExplorerModal\n\t\t\t\t\tinitialCategory={ patternCategory }\n\t\t\t\t\tpatternCategories={ populatedCategories }\n\t\t\t\t\tonModalClose={ () => setShowPatternsExplorer( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default BlockPatternsTabs;\n"]}
|
|
@@ -19,6 +19,8 @@ var _store = require("../../store");
|
|
|
19
19
|
|
|
20
20
|
var _useBlockTypeImpressions = _interopRequireDefault(require("./hooks/use-block-type-impressions"));
|
|
21
21
|
|
|
22
|
+
var _utils = require("./utils");
|
|
23
|
+
|
|
22
24
|
/**
|
|
23
25
|
* WordPress dependencies
|
|
24
26
|
*/
|
|
@@ -26,9 +28,6 @@ var _useBlockTypeImpressions = _interopRequireDefault(require("./hooks/use-block
|
|
|
26
28
|
/**
|
|
27
29
|
* Internal dependencies
|
|
28
30
|
*/
|
|
29
|
-
const NON_BLOCK_CATEGORIES = ['reusable'];
|
|
30
|
-
const ALLOWED_EMBED_VARIATIONS = ['core/embed'];
|
|
31
|
-
|
|
32
31
|
function BlockTypesTab({
|
|
33
32
|
onSelect,
|
|
34
33
|
rootClientId,
|
|
@@ -41,14 +40,7 @@ function BlockTypesTab({
|
|
|
41
40
|
const {
|
|
42
41
|
getInserterItems
|
|
43
42
|
} = select(_store.store);
|
|
44
|
-
const
|
|
45
|
-
const blockItems = allItems.filter(({
|
|
46
|
-
id,
|
|
47
|
-
category
|
|
48
|
-
}) => !NON_BLOCK_CATEGORIES.includes(category) && ( // We don't want to show all possible embed variations
|
|
49
|
-
// as different blocks in the inserter. We'll only show a
|
|
50
|
-
// few popular ones.
|
|
51
|
-
category !== 'embed' || category === 'embed' && ALLOWED_EMBED_VARIATIONS.includes(id)));
|
|
43
|
+
const blockItems = (0, _utils.filterInserterItems)(getInserterItems(rootClientId));
|
|
52
44
|
return {
|
|
53
45
|
blockTypes: clipboardBlock ? [clipboardBlock, ...blockItems] : blockItems
|
|
54
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-types-tab.native.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/block-types-tab.native.js"],"names":["BlockTypesTab","onSelect","rootClientId","listProps","clipboardBlock","blockTypes","select","getInserterItems","blockEditorStore","blockItems","items","trackBlockTypeSelected","handleSelect","args"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAZA;AACA;AACA;;AAGA;AACA;AACA;AAOA,SAASA,aAAT,CAAwB;AAAEC,EAAAA,QAAF;AAAYC,EAAAA,YAAZ;AAA0BC,EAAAA;AAA1B,CAAxB,EAAgE;AAC/D,QAAMC,cAAc,GAAG,gCAAmBF,YAAnB,CAAvB;AAEA,QAAM;AAAEG,IAAAA;AAAF,MAAiB,qBACpBC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAAuBD,MAAM,CAAEE,YAAF,CAAnC;AACA,UAAMC,UAAU,GAAG,gCAClBF,gBAAgB,CAAEL,YAAF,CADE,CAAnB;AAIA,WAAO;AACNG,MAAAA,UAAU,EAAED,cAAc,GACvB,CAAEA,cAAF,EAAkB,GAAGK,UAArB,CADuB,GAEvBA;AAHG,KAAP;AAKA,GAZqB,EAatB,CAAEP,YAAF,CAbsB,CAAvB;AAgBA,QAAM;AAAEQ,IAAAA,KAAF;AAASC,IAAAA;AAAT,MAAoC,sCACzCN,UADyC,CAA1C;;AAIA,QAAMO,YAAY,GAAG,CAAE,GAAGC,IAAL,KAAe;AACnCF,IAAAA,sBAAsB,CAAE,GAAGE,IAAL,CAAtB;AACAZ,IAAAA,QAAQ,CAAE,GAAGY,IAAL,CAAR;AACA,GAHD;;AAKA,SACC,4BAAC,uBAAD;AACC,IAAA,IAAI,EAAC,QADN;AAEC,IAAA,KAAK,EAAGH,KAFT;AAGC,IAAA,QAAQ,EAAGE,YAHZ;AAIC,IAAA,SAAS,EAAGT;AAJb,IADD;AAQA;;eAEcH,a","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockTypesList from '../block-types-list';\nimport useClipboardBlock from './hooks/use-clipboard-block';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockTypeImpressions from './hooks/use-block-type-impressions';\nimport { filterInserterItems } from './utils';\n\nfunction BlockTypesTab( { onSelect, rootClientId, listProps } ) {\n\tconst clipboardBlock = useClipboardBlock( rootClientId );\n\n\tconst { blockTypes } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getInserterItems } = select( blockEditorStore );\n\t\t\tconst blockItems = filterInserterItems(\n\t\t\t\tgetInserterItems( rootClientId )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tblockTypes: clipboardBlock\n\t\t\t\t\t? [ clipboardBlock, ...blockItems ]\n\t\t\t\t\t: blockItems,\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\tconst { items, trackBlockTypeSelected } = useBlockTypeImpressions(\n\t\tblockTypes\n\t);\n\n\tconst handleSelect = ( ...args ) => {\n\t\ttrackBlockTypeSelected( ...args );\n\t\tonSelect( ...args );\n\t};\n\n\treturn (\n\t\t<BlockTypesList\n\t\t\tname=\"Blocks\"\n\t\t\titems={ items }\n\t\t\tonSelect={ handleSelect }\n\t\t\tlistProps={ listProps }\n\t\t/>\n\t);\n}\n\nexport default BlockTypesTab;\n"]}
|
|
@@ -20,27 +20,24 @@ var _store = require("../../../store");
|
|
|
20
20
|
*/
|
|
21
21
|
function useBlockTypeImpressions(blockTypes) {
|
|
22
22
|
const {
|
|
23
|
-
blockTypeImpressions
|
|
24
|
-
enableEditorOnboarding
|
|
23
|
+
blockTypeImpressions
|
|
25
24
|
} = (0, _data.useSelect)(select => {
|
|
26
25
|
const {
|
|
27
26
|
getSettings: getBlockEditorSettings
|
|
28
27
|
} = select(_store.store);
|
|
29
28
|
const {
|
|
30
|
-
editorOnboarding,
|
|
31
29
|
impressions
|
|
32
30
|
} = getBlockEditorSettings();
|
|
33
31
|
return {
|
|
34
|
-
blockTypeImpressions: impressions
|
|
35
|
-
enableEditorOnboarding: editorOnboarding
|
|
32
|
+
blockTypeImpressions: impressions
|
|
36
33
|
};
|
|
37
34
|
}, []);
|
|
38
35
|
const {
|
|
39
36
|
updateSettings
|
|
40
37
|
} = (0, _data.useDispatch)(_store.store);
|
|
41
|
-
const items =
|
|
38
|
+
const items = blockTypes.map(blockType => ({ ...blockType,
|
|
42
39
|
isNew: blockTypeImpressions[blockType.name] > 0
|
|
43
|
-
}))
|
|
40
|
+
}));
|
|
44
41
|
|
|
45
42
|
const trackBlockTypeSelected = ({
|
|
46
43
|
name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-block-type-impressions.native.js"],"names":["useBlockTypeImpressions","blockTypes","blockTypeImpressions","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-block-type-impressions.native.js"],"names":["useBlockTypeImpressions","blockTypes","blockTypeImpressions","select","getSettings","getBlockEditorSettings","blockEditorStore","impressions","updateSettings","items","map","blockType","isNew","name","trackBlockTypeSelected","updatedBlockTypeImpressions"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGA,SAASA,uBAAT,CAAkCC,UAAlC,EAA+C;AAC9C,QAAM;AAAEC,IAAAA;AAAF,MAA2B,qBAAaC,MAAF,IAAc;AACzD,UAAM;AAAEC,MAAAA,WAAW,EAAEC;AAAf,QAA0CF,MAAM,CACrDG,YADqD,CAAtD;AAGA,UAAM;AAAEC,MAAAA;AAAF,QAAkBF,sBAAsB,EAA9C;AAEA,WAAO;AACNH,MAAAA,oBAAoB,EAAEK;AADhB,KAAP;AAGA,GATgC,EAS9B,EAT8B,CAAjC;AAUA,QAAM;AAAEC,IAAAA;AAAF,MAAqB,uBAAaF,YAAb,CAA3B;AAEA,QAAMG,KAAK,GAAGR,UAAU,CAACS,GAAX,CAAkBC,SAAF,KAAmB,EAChD,GAAGA,SAD6C;AAEhDC,IAAAA,KAAK,EAAEV,oBAAoB,CAAES,SAAS,CAACE,IAAZ,CAApB,GAAyC;AAFA,GAAnB,CAAhB,CAAd;;AAIA,QAAMC,sBAAsB,GAAG,CAAE;AAAED,IAAAA;AAAF,GAAF,KAAgB;AAC9C,QAAKX,oBAAoB,CAAEW,IAAF,CAApB,GAA+B,CAApC,EAAwC;AACvC,YAAME,2BAA2B,GAAG,EACnC,GAAGb,oBADgC;AAEnC,SAAEW,IAAF,GAAU;AAFyB,OAApC,CADuC,CAKvC;;AACAL,MAAAA,cAAc,CAAE;AACfD,QAAAA,WAAW,EAAEQ;AADE,OAAF,CAAd,CANuC,CAUvC;;AACA,sDAAyBA,2BAAzB;AACA;AACD,GAdD;;AAgBA,SAAO;AAAEN,IAAAA,KAAF;AAASK,IAAAA;AAAT,GAAP;AACA;;eAEcd,uB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { setBlockTypeImpressions } from '@wordpress/react-native-bridge';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\n\nfunction useBlockTypeImpressions( blockTypes ) {\n\tconst { blockTypeImpressions } = useSelect( ( select ) => {\n\t\tconst { getSettings: getBlockEditorSettings } = select(\n\t\t\tblockEditorStore\n\t\t);\n\t\tconst { impressions } = getBlockEditorSettings();\n\n\t\treturn {\n\t\t\tblockTypeImpressions: impressions,\n\t\t};\n\t}, [] );\n\tconst { updateSettings } = useDispatch( blockEditorStore );\n\n\tconst items = blockTypes.map( ( blockType ) => ( {\n\t\t...blockType,\n\t\tisNew: blockTypeImpressions[ blockType.name ] > 0,\n\t} ) );\n\tconst trackBlockTypeSelected = ( { name } ) => {\n\t\tif ( blockTypeImpressions[ name ] > 0 ) {\n\t\t\tconst updatedBlockTypeImpressions = {\n\t\t\t\t...blockTypeImpressions,\n\t\t\t\t[ name ]: 0,\n\t\t\t};\n\t\t\t// Persist block type impression to JavaScript store\n\t\t\tupdateSettings( {\n\t\t\t\timpressions: updatedBlockTypeImpressions,\n\t\t\t} );\n\n\t\t\t// Persist block type impression count to native app store\n\t\t\tsetBlockTypeImpressions( updatedBlockTypeImpressions );\n\t\t}\n\t};\n\n\treturn { items, trackBlockTypeSelected };\n}\n\nexport default useBlockTypeImpressions;\n"]}
|
|
@@ -32,15 +32,16 @@ function useClipboardBlock(destinationRootClientId) {
|
|
|
32
32
|
HTML: clipboard
|
|
33
33
|
})[0];
|
|
34
34
|
const canAddClipboardBlock = canInsertBlockType(clipboardBlock === null || clipboardBlock === void 0 ? void 0 : clipboardBlock.name, destinationRootClientId);
|
|
35
|
+
const blockType = getBlockType(clipboardBlock === null || clipboardBlock === void 0 ? void 0 : clipboardBlock.name);
|
|
35
36
|
|
|
36
|
-
if (!canAddClipboardBlock) {
|
|
37
|
+
if (!canAddClipboardBlock || !blockType) {
|
|
37
38
|
return undefined;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
const {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
} =
|
|
42
|
+
name,
|
|
43
|
+
icon
|
|
44
|
+
} = blockType;
|
|
44
45
|
const {
|
|
45
46
|
attributes: initialAttributes,
|
|
46
47
|
innerBlocks
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-clipboard-block.native.js"],"names":["useClipboardBlock","destinationRootClientId","canInsertBlockType","blockEditorStore","getBlockType","blocksStore","clipboard","clipboardBlock","HTML","canAddClipboardBlock","name","undefined","icon","attributes","initialAttributes","innerBlocks","id"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGe,SAASA,iBAAT,CAA4BC,uBAA5B,EAAsD;AACpE,QAAM;AAAEC,IAAAA;AAAF,MAAyB,qBAAWC,YAAX,CAA/B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAmB,qBAAWC,aAAX,CAAzB;AAEA,QAAMC,SAAS,GAAG,+BAAlB;AACA,QAAMC,cAAc,GAAG,wBAAY;AAAEC,IAAAA,IAAI,EAAEF;AAAR,GAAZ,EAAmC,CAAnC,CAAvB;AAEA,QAAMG,oBAAoB,GAAGP,kBAAkB,CAC9CK,cAD8C,aAC9CA,cAD8C,uBAC9CA,cAAc,CAAEG,IAD8B,EAE9CT,uBAF8C,CAA/C;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/hooks/use-clipboard-block.native.js"],"names":["useClipboardBlock","destinationRootClientId","canInsertBlockType","blockEditorStore","getBlockType","blocksStore","clipboard","clipboardBlock","HTML","canAddClipboardBlock","name","blockType","undefined","icon","attributes","initialAttributes","innerBlocks","id"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGe,SAASA,iBAAT,CAA4BC,uBAA5B,EAAsD;AACpE,QAAM;AAAEC,IAAAA;AAAF,MAAyB,qBAAWC,YAAX,CAA/B;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAmB,qBAAWC,aAAX,CAAzB;AAEA,QAAMC,SAAS,GAAG,+BAAlB;AACA,QAAMC,cAAc,GAAG,wBAAY;AAAEC,IAAAA,IAAI,EAAEF;AAAR,GAAZ,EAAmC,CAAnC,CAAvB;AAEA,QAAMG,oBAAoB,GAAGP,kBAAkB,CAC9CK,cAD8C,aAC9CA,cAD8C,uBAC9CA,cAAc,CAAEG,IAD8B,EAE9CT,uBAF8C,CAA/C;AAIA,QAAMU,SAAS,GAAGP,YAAY,CAAEG,cAAF,aAAEA,cAAF,uBAAEA,cAAc,CAAEG,IAAlB,CAA9B;;AAEA,MAAK,CAAED,oBAAF,IAA0B,CAAEE,SAAjC,EAA6C;AAC5C,WAAOC,SAAP;AACA;;AAED,QAAM;AAAEF,IAAAA,IAAF;AAAQG,IAAAA;AAAR,MAAiBF,SAAvB;AACA,QAAM;AAAEG,IAAAA,UAAU,EAAEC,iBAAd;AAAiCC,IAAAA;AAAjC,MAAiDT,cAAvD;AAEA,SAAO;AACNU,IAAAA,EAAE,EAAE,WADE;AAENP,IAAAA,IAFM;AAGNG,IAAAA,IAHM;AAINE,IAAAA,iBAJM;AAKNC,IAAAA;AALM,GAAP;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { rawHandler, store as blocksStore } from '@wordpress/blocks';\nimport { getClipboard } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../../store';\n\nexport default function useClipboardBlock( destinationRootClientId ) {\n\tconst { canInsertBlockType } = useSelect( blockEditorStore );\n\tconst { getBlockType } = useSelect( blocksStore );\n\n\tconst clipboard = getClipboard();\n\tconst clipboardBlock = rawHandler( { HTML: clipboard } )[ 0 ];\n\n\tconst canAddClipboardBlock = canInsertBlockType(\n\t\tclipboardBlock?.name,\n\t\tdestinationRootClientId\n\t);\n\tconst blockType = getBlockType( clipboardBlock?.name );\n\n\tif ( ! canAddClipboardBlock || ! blockType ) {\n\t\treturn undefined;\n\t}\n\n\tconst { name, icon } = blockType;\n\tconst { attributes: initialAttributes, innerBlocks } = clipboardBlock;\n\n\treturn {\n\t\tid: 'clipboard',\n\t\tname,\n\t\ticon,\n\t\tinitialAttributes,\n\t\tinnerBlocks,\n\t};\n}\n"]}
|
|
@@ -127,6 +127,7 @@ class Inserter extends _element.Component {
|
|
|
127
127
|
disabled,
|
|
128
128
|
blockTitle,
|
|
129
129
|
hasSingleBlockType,
|
|
130
|
+
directInsertBlock,
|
|
130
131
|
toggleProps,
|
|
131
132
|
hasItems,
|
|
132
133
|
renderToggle = defaultRenderToggle
|
|
@@ -137,6 +138,7 @@ class Inserter extends _element.Component {
|
|
|
137
138
|
disabled: disabled || !hasItems,
|
|
138
139
|
blockTitle,
|
|
139
140
|
hasSingleBlockType,
|
|
141
|
+
directInsertBlock,
|
|
140
142
|
toggleProps
|
|
141
143
|
});
|
|
142
144
|
}
|
|
@@ -190,12 +192,13 @@ class Inserter extends _element.Component {
|
|
|
190
192
|
const {
|
|
191
193
|
position,
|
|
192
194
|
hasSingleBlockType,
|
|
195
|
+
directInsertBlock,
|
|
193
196
|
insertOnlyAllowedBlock,
|
|
194
197
|
__experimentalIsQuick: isQuick,
|
|
195
198
|
onSelectOrClose
|
|
196
199
|
} = this.props;
|
|
197
200
|
|
|
198
|
-
if (hasSingleBlockType) {
|
|
201
|
+
if (hasSingleBlockType || directInsertBlock !== null && directInsertBlock !== void 0 && directInsertBlock.length) {
|
|
199
202
|
return this.renderToggle({
|
|
200
203
|
onToggle: insertOnlyAllowedBlock
|
|
201
204
|
});
|
|
@@ -225,7 +228,8 @@ var _default = (0, _compose.compose)([(0, _data.withSelect)((select, {
|
|
|
225
228
|
const {
|
|
226
229
|
getBlockRootClientId,
|
|
227
230
|
hasInserterItems,
|
|
228
|
-
__experimentalGetAllowedBlocks
|
|
231
|
+
__experimentalGetAllowedBlocks,
|
|
232
|
+
__experimentalGetDirectInsertBlock
|
|
229
233
|
} = select(_store.store);
|
|
230
234
|
const {
|
|
231
235
|
getBlockVariations
|
|
@@ -234,6 +238,8 @@ var _default = (0, _compose.compose)([(0, _data.withSelect)((select, {
|
|
|
234
238
|
|
|
235
239
|
const allowedBlocks = __experimentalGetAllowedBlocks(rootClientId);
|
|
236
240
|
|
|
241
|
+
const directInsertBlock = __experimentalGetDirectInsertBlock(rootClientId);
|
|
242
|
+
|
|
237
243
|
const hasSingleBlockType = (0, _lodash.size)(allowedBlocks) === 1 && (0, _lodash.size)(getBlockVariations(allowedBlocks[0].name, 'inserter')) === 0;
|
|
238
244
|
let allowedBlockType = false;
|
|
239
245
|
|
|
@@ -246,6 +252,7 @@ var _default = (0, _compose.compose)([(0, _data.withSelect)((select, {
|
|
|
246
252
|
hasSingleBlockType,
|
|
247
253
|
blockTitle: allowedBlockType ? allowedBlockType.title : '',
|
|
248
254
|
allowedBlockType,
|
|
255
|
+
directInsertBlock,
|
|
249
256
|
rootClientId
|
|
250
257
|
};
|
|
251
258
|
}), (0, _data.withDispatch)((dispatch, ownProps, {
|
|
@@ -259,10 +266,11 @@ var _default = (0, _compose.compose)([(0, _data.withSelect)((select, {
|
|
|
259
266
|
isAppender,
|
|
260
267
|
hasSingleBlockType,
|
|
261
268
|
allowedBlockType,
|
|
269
|
+
directInsertBlock,
|
|
262
270
|
onSelectOrClose
|
|
263
271
|
} = ownProps;
|
|
264
272
|
|
|
265
|
-
if (!hasSingleBlockType) {
|
|
273
|
+
if (!hasSingleBlockType && !(directInsertBlock !== null && directInsertBlock !== void 0 && directInsertBlock.length)) {
|
|
266
274
|
return;
|
|
267
275
|
}
|
|
268
276
|
|
|
@@ -292,7 +300,7 @@ var _default = (0, _compose.compose)([(0, _data.withSelect)((select, {
|
|
|
292
300
|
const {
|
|
293
301
|
insertBlock
|
|
294
302
|
} = dispatch(_store.store);
|
|
295
|
-
const blockToInsert = (0, _blocks.createBlock)(allowedBlockType.name);
|
|
303
|
+
const blockToInsert = directInsertBlock !== null && directInsertBlock !== void 0 && directInsertBlock.length ? (0, _blocks.createBlock)(...directInsertBlock) : (0, _blocks.createBlock)(allowedBlockType.name);
|
|
296
304
|
insertBlock(blockToInsert, getInsertionIndex(), rootClientId);
|
|
297
305
|
|
|
298
306
|
if (onSelectOrClose) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/index.js"],"names":["defaultRenderToggle","onToggle","disabled","isOpen","blockTitle","hasSingleBlockType","toggleProps","label","onClick","rest","handleClick","event","plus","Inserter","Component","constructor","arguments","bind","renderToggle","renderContent","props","hasItems","onClose","rootClientId","clientId","isAppender","showInserterHelpPanel","__experimentalIsQuick","isQuick","render","position","insertOnlyAllowedBlock","onSelectOrClose","select","getBlockRootClientId","hasInserterItems","__experimentalGetAllowedBlocks","blockEditorStore","getBlockVariations","blocksStore","undefined","allowedBlocks","name","allowedBlockType","title","dispatch","ownProps","getInsertionIndex","getBlockIndex","getBlockSelectionEnd","getBlockOrder","end","length","insertBlock","blockToInsert","message"],"mappings":";;;;;;;;;AAYA;;;;AATA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAvBA;AACA;AACA;;AAIA;AACA;AACA;;AAUA;AACA;AACA;AAKA,MAAMA,mBAAmB,GAAG,CAAE;AAC7BC,EAAAA,QAD6B;AAE7BC,EAAAA,QAF6B;AAG7BC,EAAAA,MAH6B;AAI7BC,EAAAA,UAJ6B;AAK7BC,EAAAA,kBAL6B;AAM7BC,EAAAA,WAAW,GAAG;AANe,CAAF,KAOrB;AACN,MAAIC,KAAJ;;AACA,MAAKF,kBAAL,EAA0B;AACzBE,IAAAA,KAAK,GAAG,oBACP;AACA,kBAAI,QAAJ,EAAc,qCAAd,CAFO,EAGPH,UAHO,CAAR;AAKA,GAND,MAMO;AACNG,IAAAA,KAAK,GAAG,cAAI,WAAJ,EAAiB,yCAAjB,CAAR;AACA;;AAED,QAAM;AAAEC,IAAAA,OAAF;AAAW,OAAGC;AAAd,MAAuBH,WAA7B,CAZM,CAcN;;AACA,WAASI,WAAT,CAAsBC,KAAtB,EAA8B;AAC7B,QAAKV,QAAL,EAAgB;AACfA,MAAAA,QAAQ,CAAEU,KAAF,CAAR;AACA;;AACD,QAAKH,OAAL,EAAe;AACdA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,oBACf;AACA,oBAAI,gBAAJ,CAFe,EAGfZ,gBAAgB,CAACC,KAHF,CAAhB;AAKA,uBAAOW,OAAP;AACA;;AA1DK,GAAP;AA4DA,CA7DD,CAjCuB,EA+FvB;AACA;AACA,0BACC,CAAE;AAAElC,EAAAA,QAAF;AAAYI,EAAAA,UAAZ;AAAwBF,EAAAA,YAAxB;AAAsCC,EAAAA;AAAtC,CAAF,KACCH,QAAQ,IAAM,CAAEI,UAAF,IAAgB,CAAEF,YAAlB,IAAkC,CAAEC,QAFpD,CAjGuB,CAAT,EAqGVX,QArGU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { size } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { Component } from '@wordpress/element';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose, ifCondition } from '@wordpress/compose';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport InserterMenu from './menu';\nimport QuickInserter from './quick-inserter';\nimport { store as blockEditorStore } from '../../store';\n\nconst defaultRenderToggle = ( {\n\tonToggle,\n\tdisabled,\n\tisOpen,\n\tblockTitle,\n\thasSingleBlockType,\n\ttoggleProps = {},\n} ) => {\n\tlet label;\n\tif ( hasSingleBlockType ) {\n\t\tlabel = sprintf(\n\t\t\t// translators: %s: the name of the block when there is only one\n\t\t\t_x( 'Add %s', 'directly add the only allowed block' ),\n\t\t\tblockTitle\n\t\t);\n\t} else {\n\t\tlabel = _x( 'Add block', 'Generic label for block inserter button' );\n\t}\n\n\tconst { onClick, ...rest } = toggleProps;\n\n\t// Handle both onClick functions from the toggle and the parent component\n\tfunction handleClick( event ) {\n\t\tif ( onToggle ) {\n\t\t\tonToggle( event );\n\t\t}\n\t\tif ( onClick ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<Button\n\t\t\ticon={ plus }\n\t\t\tlabel={ label }\n\t\t\ttooltipPosition=\"bottom\"\n\t\t\tonClick={ handleClick }\n\t\t\tclassName=\"block-editor-inserter__toggle\"\n\t\t\taria-haspopup={ ! hasSingleBlockType ? 'true' : false }\n\t\t\taria-expanded={ ! hasSingleBlockType ? isOpen : false }\n\t\t\tdisabled={ disabled }\n\t\t\t{ ...rest }\n\t\t/>\n\t);\n};\n\nclass Inserter extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.onToggle = this.onToggle.bind( this );\n\t\tthis.renderToggle = this.renderToggle.bind( this );\n\t\tthis.renderContent = this.renderContent.bind( this );\n\t}\n\n\tonToggle( isOpen ) {\n\t\tconst { onToggle } = this.props;\n\n\t\t// Surface toggle callback to parent component\n\t\tif ( onToggle ) {\n\t\t\tonToggle( isOpen );\n\t\t}\n\t}\n\n\t/**\n\t * Render callback to display Dropdown toggle element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onToggle Callback to invoke when toggle is\n\t * pressed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {WPElement} Dropdown toggle element.\n\t */\n\trenderToggle( { onToggle, isOpen } ) {\n\t\tconst {\n\t\t\tdisabled,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\ttoggleProps,\n\t\t\thasItems,\n\t\t\trenderToggle = defaultRenderToggle,\n\t\t} = this.props;\n\n\t\treturn renderToggle( {\n\t\t\tonToggle,\n\t\t\tisOpen,\n\t\t\tdisabled: disabled || ! hasItems,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\ttoggleProps,\n\t\t} );\n\t}\n\n\t/**\n\t * Render callback to display Dropdown content element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onClose Callback to invoke when dropdown is\n\t * closed.\n\t *\n\t * @return {WPElement} Dropdown content element.\n\t */\n\trenderContent( { onClose } ) {\n\t\tconst {\n\t\t\trootClientId,\n\t\t\tclientId,\n\t\t\tisAppender,\n\t\t\tshowInserterHelpPanel,\n\n\t\t\t// This prop is experimental to give some time for the quick inserter to mature\n\t\t\t// Feel free to make them stable after a few releases.\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t} = this.props;\n\n\t\tif ( isQuick ) {\n\t\t\treturn (\n\t\t\t\t<QuickInserter\n\t\t\t\t\tonSelect={ () => {\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisAppender={ isAppender }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<InserterMenu\n\t\t\t\tonSelect={ () => {\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ isAppender }\n\t\t\t\tshowInserterHelpPanel={ showInserterHelpPanel }\n\t\t\t/>\n\t\t);\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tposition,\n\t\t\thasSingleBlockType,\n\t\t\tinsertOnlyAllowedBlock,\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tonSelectOrClose,\n\t\t} = this.props;\n\n\t\tif ( hasSingleBlockType ) {\n\t\t\treturn this.renderToggle( { onToggle: insertOnlyAllowedBlock } );\n\t\t}\n\n\t\treturn (\n\t\t\t<Dropdown\n\t\t\t\tclassName=\"block-editor-inserter\"\n\t\t\t\tcontentClassName={ classnames(\n\t\t\t\t\t'block-editor-inserter__popover',\n\t\t\t\t\t{ 'is-quick': isQuick }\n\t\t\t\t) }\n\t\t\t\tposition={ position }\n\t\t\t\tonToggle={ this.onToggle }\n\t\t\t\texpandOnMobile\n\t\t\t\theaderTitle={ __( 'Add a block' ) }\n\t\t\t\trenderToggle={ this.renderToggle }\n\t\t\t\trenderContent={ this.renderContent }\n\t\t\t\tonClose={ onSelectOrClose }\n\t\t\t/>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select, { clientId, rootClientId } ) => {\n\t\tconst {\n\t\t\tgetBlockRootClientId,\n\t\t\thasInserterItems,\n\t\t\t__experimentalGetAllowedBlocks,\n\t\t} = select( blockEditorStore );\n\t\tconst { getBlockVariations } = select( blocksStore );\n\n\t\trootClientId =\n\t\t\trootClientId || getBlockRootClientId( clientId ) || undefined;\n\n\t\tconst allowedBlocks = __experimentalGetAllowedBlocks( rootClientId );\n\n\t\tconst hasSingleBlockType =\n\t\t\tsize( allowedBlocks ) === 1 &&\n\t\t\tsize(\n\t\t\t\tgetBlockVariations( allowedBlocks[ 0 ].name, 'inserter' )\n\t\t\t) === 0;\n\n\t\tlet allowedBlockType = false;\n\t\tif ( hasSingleBlockType ) {\n\t\t\tallowedBlockType = allowedBlocks[ 0 ];\n\t\t}\n\n\t\treturn {\n\t\t\thasItems: hasInserterItems( rootClientId ),\n\t\t\thasSingleBlockType,\n\t\t\tblockTitle: allowedBlockType ? allowedBlockType.title : '',\n\t\t\tallowedBlockType,\n\t\t\trootClientId,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch, ownProps, { select } ) => {\n\t\treturn {\n\t\t\tinsertOnlyAllowedBlock() {\n\t\t\t\tconst {\n\t\t\t\t\trootClientId,\n\t\t\t\t\tclientId,\n\t\t\t\t\tisAppender,\n\t\t\t\t\thasSingleBlockType,\n\t\t\t\t\tallowedBlockType,\n\t\t\t\t\tonSelectOrClose,\n\t\t\t\t} = ownProps;\n\n\t\t\t\tif ( ! hasSingleBlockType ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tfunction getInsertionIndex() {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tgetBlockIndex,\n\t\t\t\t\t\tgetBlockSelectionEnd,\n\t\t\t\t\t\tgetBlockOrder,\n\t\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\t} = select( blockEditorStore );\n\n\t\t\t\t\t// If the clientId is defined, we insert at the position of the block.\n\t\t\t\t\tif ( clientId ) {\n\t\t\t\t\t\treturn getBlockIndex( clientId, rootClientId );\n\t\t\t\t\t}\n\n\t\t\t\t\t// If there a selected block, we insert after the selected block.\n\t\t\t\t\tconst end = getBlockSelectionEnd();\n\t\t\t\t\tif (\n\t\t\t\t\t\t! isAppender &&\n\t\t\t\t\t\tend &&\n\t\t\t\t\t\tgetBlockRootClientId( end ) === rootClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn getBlockIndex( end, rootClientId ) + 1;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Otherwise, we insert at the end of the current rootClientId\n\t\t\t\t\treturn getBlockOrder( rootClientId ).length;\n\t\t\t\t}\n\n\t\t\t\tconst { insertBlock } = dispatch( blockEditorStore );\n\n\t\t\t\tconst blockToInsert = createBlock( allowedBlockType.name );\n\n\t\t\t\tinsertBlock( blockToInsert, getInsertionIndex(), rootClientId );\n\n\t\t\t\tif ( onSelectOrClose ) {\n\t\t\t\t\tonSelectOrClose();\n\t\t\t\t}\n\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %s: the name of the block that has been added\n\t\t\t\t\t__( '%s block added' ),\n\t\t\t\t\tallowedBlockType.title\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t},\n\t\t};\n\t} ),\n\t// The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as\n\t// a way to detect the global Inserter.\n\tifCondition(\n\t\t( { hasItems, isAppender, rootClientId, clientId } ) =>\n\t\t\thasItems || ( ! isAppender && ! rootClientId && ! clientId )\n\t),\n] )( Inserter );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inserter/index.js"],"names":["defaultRenderToggle","onToggle","disabled","isOpen","blockTitle","hasSingleBlockType","toggleProps","label","onClick","rest","handleClick","event","plus","Inserter","Component","constructor","arguments","bind","renderToggle","renderContent","props","directInsertBlock","hasItems","onClose","rootClientId","clientId","isAppender","showInserterHelpPanel","__experimentalIsQuick","isQuick","render","position","insertOnlyAllowedBlock","onSelectOrClose","length","select","getBlockRootClientId","hasInserterItems","__experimentalGetAllowedBlocks","__experimentalGetDirectInsertBlock","blockEditorStore","getBlockVariations","blocksStore","undefined","allowedBlocks","name","allowedBlockType","title","dispatch","ownProps","getInsertionIndex","getBlockIndex","getBlockSelectionEnd","getBlockOrder","end","insertBlock","blockToInsert","message"],"mappings":";;;;;;;;;AAYA;;;;AATA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAvBA;AACA;AACA;;AAIA;AACA;AACA;;AAUA;AACA;AACA;AAKA,MAAMA,mBAAmB,GAAG,CAAE;AAC7BC,EAAAA,QAD6B;AAE7BC,EAAAA,QAF6B;AAG7BC,EAAAA,MAH6B;AAI7BC,EAAAA,UAJ6B;AAK7BC,EAAAA,kBAL6B;AAM7BC,EAAAA,WAAW,GAAG;AANe,CAAF,KAOrB;AACN,MAAIC,KAAJ;;AACA,MAAKF,kBAAL,EAA0B;AACzBE,IAAAA,KAAK,GAAG,oBACP;AACA,kBAAI,QAAJ,EAAc,qCAAd,CAFO,EAGPH,UAHO,CAAR;AAKA,GAND,MAMO;AACNG,IAAAA,KAAK,GAAG,cAAI,WAAJ,EAAiB,yCAAjB,CAAR;AACA;;AAED,QAAM;AAAEC,IAAAA,OAAF;AAAW,OAAGC;AAAd,MAAuBH,WAA7B,CAZM,CAcN;;AACA,WAASI,WAAT,CAAsBC,KAAtB,EAA8B;AAC7B,QAAKV,QAAL,EAAgB;AACfA,MAAAA,QAAQ,CAAEU,KAAF,CAAR;AACA;;AACD,QAAKH,OAAL,EAAe;AACdA,MAAAA,OAAO,CAAEG,KAAF,CAAP;AACA;AACD;;AAED,SACC,4BAAC,kBAAD;AACC,IAAA,IAAI,EAAGC,WADR;AAEC,IAAA,KAAK,EAAGL,KAFT;AAGC,IAAA,eAAe,EAAC,QAHjB;AAIC,IAAA,OAAO,EAAG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,iBAAiB,CAAEa,MAAnB,GACnB,yBAAa,GAAGb,iBAAhB,CADmB,GAEnB,yBAAayB,gBAAgB,CAACD,IAA9B,CAFH;AAIAU,MAAAA,WAAW,CAAEC,aAAF,EAAiBN,iBAAiB,EAAlC,EAAsC1B,YAAtC,CAAX;;AAEA,UAAKS,eAAL,EAAuB;AACtBA,QAAAA,eAAe;AACf;;AAED,YAAMwB,OAAO,GAAG,oBACf;AACA,oBAAI,gBAAJ,CAFe,EAGfX,gBAAgB,CAACC,KAHF,CAAhB;AAKA,uBAAOU,OAAP;AACA;;AA7DK,GAAP;AA+DA,CAhED,CAvCuB,EAwGvB;AACA;AACA,0BACC,CAAE;AAAEnC,EAAAA,QAAF;AAAYI,EAAAA,UAAZ;AAAwBF,EAAAA,YAAxB;AAAsCC,EAAAA;AAAtC,CAAF,KACCH,QAAQ,IAAM,CAAEI,UAAF,IAAgB,CAAEF,YAAlB,IAAkC,CAAEC,QAFpD,CA1GuB,CAAT,EA8GVZ,QA9GU,C","sourcesContent":["/**\n * External dependencies\n */\nimport { size } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { speak } from '@wordpress/a11y';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { Dropdown, Button } from '@wordpress/components';\nimport { Component } from '@wordpress/element';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose, ifCondition } from '@wordpress/compose';\nimport { createBlock, store as blocksStore } from '@wordpress/blocks';\nimport { plus } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport InserterMenu from './menu';\nimport QuickInserter from './quick-inserter';\nimport { store as blockEditorStore } from '../../store';\n\nconst defaultRenderToggle = ( {\n\tonToggle,\n\tdisabled,\n\tisOpen,\n\tblockTitle,\n\thasSingleBlockType,\n\ttoggleProps = {},\n} ) => {\n\tlet label;\n\tif ( hasSingleBlockType ) {\n\t\tlabel = sprintf(\n\t\t\t// translators: %s: the name of the block when there is only one\n\t\t\t_x( 'Add %s', 'directly add the only allowed block' ),\n\t\t\tblockTitle\n\t\t);\n\t} else {\n\t\tlabel = _x( 'Add block', 'Generic label for block inserter button' );\n\t}\n\n\tconst { onClick, ...rest } = toggleProps;\n\n\t// Handle both onClick functions from the toggle and the parent component\n\tfunction handleClick( event ) {\n\t\tif ( onToggle ) {\n\t\t\tonToggle( event );\n\t\t}\n\t\tif ( onClick ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<Button\n\t\t\ticon={ plus }\n\t\t\tlabel={ label }\n\t\t\ttooltipPosition=\"bottom\"\n\t\t\tonClick={ handleClick }\n\t\t\tclassName=\"block-editor-inserter__toggle\"\n\t\t\taria-haspopup={ ! hasSingleBlockType ? 'true' : false }\n\t\t\taria-expanded={ ! hasSingleBlockType ? isOpen : false }\n\t\t\tdisabled={ disabled }\n\t\t\t{ ...rest }\n\t\t/>\n\t);\n};\n\nclass Inserter extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.onToggle = this.onToggle.bind( this );\n\t\tthis.renderToggle = this.renderToggle.bind( this );\n\t\tthis.renderContent = this.renderContent.bind( this );\n\t}\n\n\tonToggle( isOpen ) {\n\t\tconst { onToggle } = this.props;\n\n\t\t// Surface toggle callback to parent component\n\t\tif ( onToggle ) {\n\t\t\tonToggle( isOpen );\n\t\t}\n\t}\n\n\t/**\n\t * Render callback to display Dropdown toggle element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onToggle Callback to invoke when toggle is\n\t * pressed.\n\t * @param {boolean} options.isOpen Whether dropdown is currently open.\n\t *\n\t * @return {WPElement} Dropdown toggle element.\n\t */\n\trenderToggle( { onToggle, isOpen } ) {\n\t\tconst {\n\t\t\tdisabled,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\ttoggleProps,\n\t\t\thasItems,\n\t\t\trenderToggle = defaultRenderToggle,\n\t\t} = this.props;\n\n\t\treturn renderToggle( {\n\t\t\tonToggle,\n\t\t\tisOpen,\n\t\t\tdisabled: disabled || ! hasItems,\n\t\t\tblockTitle,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\ttoggleProps,\n\t\t} );\n\t}\n\n\t/**\n\t * Render callback to display Dropdown content element.\n\t *\n\t * @param {Object} options\n\t * @param {Function} options.onClose Callback to invoke when dropdown is\n\t * closed.\n\t *\n\t * @return {WPElement} Dropdown content element.\n\t */\n\trenderContent( { onClose } ) {\n\t\tconst {\n\t\t\trootClientId,\n\t\t\tclientId,\n\t\t\tisAppender,\n\t\t\tshowInserterHelpPanel,\n\n\t\t\t// This prop is experimental to give some time for the quick inserter to mature\n\t\t\t// Feel free to make them stable after a few releases.\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t} = this.props;\n\n\t\tif ( isQuick ) {\n\t\t\treturn (\n\t\t\t\t<QuickInserter\n\t\t\t\t\tonSelect={ () => {\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisAppender={ isAppender }\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<InserterMenu\n\t\t\t\tonSelect={ () => {\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ isAppender }\n\t\t\t\tshowInserterHelpPanel={ showInserterHelpPanel }\n\t\t\t/>\n\t\t);\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tposition,\n\t\t\thasSingleBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\tinsertOnlyAllowedBlock,\n\t\t\t__experimentalIsQuick: isQuick,\n\t\t\tonSelectOrClose,\n\t\t} = this.props;\n\n\t\tif ( hasSingleBlockType || directInsertBlock?.length ) {\n\t\t\treturn this.renderToggle( { onToggle: insertOnlyAllowedBlock } );\n\t\t}\n\n\t\treturn (\n\t\t\t<Dropdown\n\t\t\t\tclassName=\"block-editor-inserter\"\n\t\t\t\tcontentClassName={ classnames(\n\t\t\t\t\t'block-editor-inserter__popover',\n\t\t\t\t\t{ 'is-quick': isQuick }\n\t\t\t\t) }\n\t\t\t\tposition={ position }\n\t\t\t\tonToggle={ this.onToggle }\n\t\t\t\texpandOnMobile\n\t\t\t\theaderTitle={ __( 'Add a block' ) }\n\t\t\t\trenderToggle={ this.renderToggle }\n\t\t\t\trenderContent={ this.renderContent }\n\t\t\t\tonClose={ onSelectOrClose }\n\t\t\t/>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select, { clientId, rootClientId } ) => {\n\t\tconst {\n\t\t\tgetBlockRootClientId,\n\t\t\thasInserterItems,\n\t\t\t__experimentalGetAllowedBlocks,\n\t\t\t__experimentalGetDirectInsertBlock,\n\t\t} = select( blockEditorStore );\n\t\tconst { getBlockVariations } = select( blocksStore );\n\n\t\trootClientId =\n\t\t\trootClientId || getBlockRootClientId( clientId ) || undefined;\n\n\t\tconst allowedBlocks = __experimentalGetAllowedBlocks( rootClientId );\n\n\t\tconst directInsertBlock = __experimentalGetDirectInsertBlock(\n\t\t\trootClientId\n\t\t);\n\n\t\tconst hasSingleBlockType =\n\t\t\tsize( allowedBlocks ) === 1 &&\n\t\t\tsize(\n\t\t\t\tgetBlockVariations( allowedBlocks[ 0 ].name, 'inserter' )\n\t\t\t) === 0;\n\n\t\tlet allowedBlockType = false;\n\t\tif ( hasSingleBlockType ) {\n\t\t\tallowedBlockType = allowedBlocks[ 0 ];\n\t\t}\n\n\t\treturn {\n\t\t\thasItems: hasInserterItems( rootClientId ),\n\t\t\thasSingleBlockType,\n\t\t\tblockTitle: allowedBlockType ? allowedBlockType.title : '',\n\t\t\tallowedBlockType,\n\t\t\tdirectInsertBlock,\n\t\t\trootClientId,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch, ownProps, { select } ) => {\n\t\treturn {\n\t\t\tinsertOnlyAllowedBlock() {\n\t\t\t\tconst {\n\t\t\t\t\trootClientId,\n\t\t\t\t\tclientId,\n\t\t\t\t\tisAppender,\n\t\t\t\t\thasSingleBlockType,\n\t\t\t\t\tallowedBlockType,\n\t\t\t\t\tdirectInsertBlock,\n\t\t\t\t\tonSelectOrClose,\n\t\t\t\t} = ownProps;\n\n\t\t\t\tif ( ! hasSingleBlockType && ! directInsertBlock?.length ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tfunction getInsertionIndex() {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tgetBlockIndex,\n\t\t\t\t\t\tgetBlockSelectionEnd,\n\t\t\t\t\t\tgetBlockOrder,\n\t\t\t\t\t\tgetBlockRootClientId,\n\t\t\t\t\t} = select( blockEditorStore );\n\n\t\t\t\t\t// If the clientId is defined, we insert at the position of the block.\n\t\t\t\t\tif ( clientId ) {\n\t\t\t\t\t\treturn getBlockIndex( clientId, rootClientId );\n\t\t\t\t\t}\n\n\t\t\t\t\t// If there a selected block, we insert after the selected block.\n\t\t\t\t\tconst end = getBlockSelectionEnd();\n\t\t\t\t\tif (\n\t\t\t\t\t\t! isAppender &&\n\t\t\t\t\t\tend &&\n\t\t\t\t\t\tgetBlockRootClientId( end ) === rootClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn getBlockIndex( end, rootClientId ) + 1;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Otherwise, we insert at the end of the current rootClientId\n\t\t\t\t\treturn getBlockOrder( rootClientId ).length;\n\t\t\t\t}\n\n\t\t\t\tconst { insertBlock } = dispatch( blockEditorStore );\n\n\t\t\t\tconst blockToInsert = directInsertBlock?.length\n\t\t\t\t\t? createBlock( ...directInsertBlock )\n\t\t\t\t\t: createBlock( allowedBlockType.name );\n\n\t\t\t\tinsertBlock( blockToInsert, getInsertionIndex(), rootClientId );\n\n\t\t\t\tif ( onSelectOrClose ) {\n\t\t\t\t\tonSelectOrClose();\n\t\t\t\t}\n\n\t\t\t\tconst message = sprintf(\n\t\t\t\t\t// translators: %s: the name of the block that has been added\n\t\t\t\t\t__( '%s block added' ),\n\t\t\t\t\tallowedBlockType.title\n\t\t\t\t);\n\t\t\t\tspeak( message );\n\t\t\t},\n\t\t};\n\t} ),\n\t// The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as\n\t// a way to detect the global Inserter.\n\tifCondition(\n\t\t( { hasItems, isAppender, rootClientId, clientId } ) =>\n\t\t\thasItems || ( ! isAppender && ! rootClientId && ! clientId )\n\t),\n] )( Inserter );\n"]}
|
|
@@ -49,20 +49,17 @@ var _store = require("../../store");
|
|
|
49
49
|
const VOICE_OVER_ANNOUNCEMENT_DELAY = 1000;
|
|
50
50
|
|
|
51
51
|
const defaultRenderToggle = ({
|
|
52
|
-
displayEditorOnboardingTooltip,
|
|
53
52
|
onToggle,
|
|
54
53
|
disabled,
|
|
55
54
|
style,
|
|
56
55
|
onLongPress
|
|
57
56
|
}) => (0, _element.createElement)(_components.ToolbarButton, {
|
|
58
|
-
title:
|
|
57
|
+
title: (0, _i18n.__)('Add block'),
|
|
59
58
|
icon: (0, _element.createElement)(_icons.Icon, {
|
|
60
59
|
icon: _icons.plusCircleFilled,
|
|
61
60
|
style: style,
|
|
62
61
|
color: style.color
|
|
63
62
|
}),
|
|
64
|
-
showTooltip: displayEditorOnboardingTooltip,
|
|
65
|
-
tooltipPosition: "top right",
|
|
66
63
|
onClick: onToggle,
|
|
67
64
|
extraProps: {
|
|
68
65
|
hint: (0, _i18n.__)('Double tap to add a block'),
|
|
@@ -225,7 +222,6 @@ class Inserter extends _element.Component {
|
|
|
225
222
|
isOpen
|
|
226
223
|
}) {
|
|
227
224
|
const {
|
|
228
|
-
displayEditorOnboardingTooltip,
|
|
229
225
|
disabled,
|
|
230
226
|
renderToggle = defaultRenderToggle,
|
|
231
227
|
getStylesFromColorScheme,
|
|
@@ -261,7 +257,6 @@ class Inserter extends _element.Component {
|
|
|
261
257
|
};
|
|
262
258
|
|
|
263
259
|
return (0, _element.createElement)(_element.Fragment, null, renderToggle({
|
|
264
|
-
displayEditorOnboardingTooltip,
|
|
265
260
|
onToggle: onPress,
|
|
266
261
|
isOpen,
|
|
267
262
|
disabled,
|
|
@@ -389,7 +384,6 @@ var _default = (0, _compose.compose)([(0, _data.withDispatch)(dispatch => {
|
|
|
389
384
|
const insertionIndexEnd = endOfRootIndex;
|
|
390
385
|
return {
|
|
391
386
|
blockTypeImpressions: getBlockEditorSettings().impressions,
|
|
392
|
-
displayEditorOnboardingTooltip: getBlockEditorSettings().editorOnboarding && getBlockEditorSettings().firstGutenbergEditorSession,
|
|
393
387
|
destinationRootClientId,
|
|
394
388
|
insertionIndexDefault: getDefaultInsertionIndex(),
|
|
395
389
|
insertionIndexBefore,
|