@wordpress/block-editor 12.9.1-next.5a1d1283.0 → 12.10.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 +6 -0
- package/README.md +33 -3
- package/build/components/block-canvas/index.js +107 -0
- package/build/components/block-canvas/index.js.map +1 -0
- package/build/components/block-inspector/index.js +4 -1
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +28 -8
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-patterns-paging/index.js +68 -0
- package/build/components/block-patterns-paging/index.js.map +1 -0
- package/build/components/block-settings-menu/block-settings-dropdown.js +28 -0
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +4 -7
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-styles/index.js +1 -0
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-toolbar/block-toolbar-menu.native.js +3 -7
- package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +18 -7
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +5 -1
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +1 -1
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/border-radius-control/linked-button.js +2 -4
- package/build/components/border-radius-control/linked-button.js.map +1 -1
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +8 -21
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build/components/default-block-appender/index.native.js +20 -1
- package/build/components/default-block-appender/index.native.js.map +1 -1
- package/build/components/duotone/utils.js +68 -0
- package/build/components/duotone/utils.js.map +1 -1
- package/build/components/editor-styles/index.js +28 -9
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/global-styles/hooks.js +2 -101
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js +61 -0
- package/build/components/global-styles/image-settings-panel.js.map +1 -0
- package/build/components/global-styles/index.js +11 -17
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +19 -15
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +1 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/iframe/index.js +67 -33
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +2 -5
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/image-editor/use-transform-image.js +9 -9
- package/build/components/image-editor/use-transform-image.js.map +1 -1
- package/build/components/index.js +8 -12
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +6 -5
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +13 -7
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/explorer.js +12 -6
- package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/patterns-list.js +45 -22
- package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/sidebar.js +9 -9
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build/components/inserter/block-patterns-filter.js +137 -0
- package/build/components/inserter/block-patterns-filter.js.map +1 -0
- package/build/components/inserter/block-patterns-tab.js +128 -42
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-paging.js +61 -0
- package/build/components/inserter/hooks/use-patterns-paging.js.map +1 -0
- package/build/components/inserter/hooks/use-patterns-state.js +21 -10
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter/menu.js +13 -11
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/search-results.js +4 -3
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +1 -12
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inspector-controls/block-support-slot-container.js +12 -1
- package/build/components/inspector-controls/block-support-slot-container.js.map +1 -1
- package/build/components/inspector-controls/fill.js +24 -13
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/inspector-controls/groups.js +5 -3
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls/slot.js +13 -0
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js +3 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/link-control/index.js +12 -2
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +1 -3
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +13 -1
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +29 -24
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/media-placeholder/index.js +2 -2
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-placeholder/index.native.js +11 -11
- package/build/components/media-placeholder/index.native.js.map +1 -1
- package/build/components/media-replace-flow/index.js +2 -3
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/media-upload/constants.js +30 -0
- package/build/components/media-upload/constants.js.map +1 -0
- package/build/components/media-upload/index.native.js +63 -53
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/preview-options/index.js +1 -1
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/rich-text/index.js +34 -35
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +14 -32
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/multiline.js +95 -0
- package/build/components/rich-text/multiline.js.map +1 -0
- package/build/components/rich-text/split-value.js +10 -16
- package/build/components/rich-text/split-value.js.map +1 -1
- package/build/components/rich-text/use-enter.js +31 -40
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +18 -33
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +1 -1
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/use-block-commands/index.js +30 -18
- package/build/components/use-block-commands/index.js.map +1 -1
- package/build/components/use-block-display-information/index.js +5 -2
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/hooks/background.js +263 -0
- package/build/hooks/background.js.map +1 -0
- package/build/hooks/block-hooks.js +188 -0
- package/build/hooks/block-hooks.js.map +1 -0
- package/build/hooks/block-rename-ui.js +161 -0
- package/build/hooks/block-rename-ui.js.map +1 -0
- package/build/hooks/duotone.js +29 -42
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +2 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +31 -14
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/position.js +4 -2
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +10 -3
- package/build/hooks/style.js.map +1 -1
- package/build/private-apis.js +2 -0
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +33 -10
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +42 -8
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +25 -3
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +43 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +84 -23
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +0 -4
- package/build/store/utils.js.map +1 -1
- package/build-module/components/block-canvas/index.js +97 -0
- package/build-module/components/block-canvas/index.js.map +1 -0
- package/build-module/components/block-inspector/index.js +4 -1
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +30 -10
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-patterns-paging/index.js +61 -0
- package/build-module/components/block-patterns-paging/index.js.map +1 -0
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +28 -0
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +4 -7
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +1 -0
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js +3 -7
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +18 -7
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +5 -1
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +1 -1
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/border-radius-control/linked-button.js +2 -4
- package/build-module/components/border-radius-control/linked-button.js.map +1 -1
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +8 -21
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build-module/components/default-block-appender/index.native.js +20 -1
- package/build-module/components/default-block-appender/index.native.js.map +1 -1
- package/build-module/components/duotone/utils.js +65 -0
- package/build-module/components/duotone/utils.js.map +1 -1
- package/build-module/components/editor-styles/index.js +28 -9
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +3 -100
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js +53 -0
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -0
- package/build-module/components/global-styles/index.js +2 -2
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +18 -16
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +1 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/iframe/index.js +66 -33
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +2 -5
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/image-editor/use-transform-image.js +9 -9
- package/build-module/components/image-editor/use-transform-image.js.map +1 -1
- package/build-module/components/index.js +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +2 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +14 -8
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/explorer.js +12 -6
- package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js +47 -24
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js +9 -9
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +1 -1
- package/build-module/components/inserter/block-patterns-filter.js +128 -0
- package/build-module/components/inserter/block-patterns-filter.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab.js +125 -44
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-paging.js +54 -0
- package/build-module/components/inserter/hooks/use-patterns-paging.js.map +1 -0
- package/build-module/components/inserter/hooks/use-patterns-state.js +22 -10
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter/menu.js +13 -11
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/search-results.js +4 -3
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +1 -12
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-slot-container.js +13 -2
- package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +25 -14
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +5 -3
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +15 -1
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +3 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/link-control/index.js +12 -2
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +1 -3
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +13 -1
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +30 -25
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +2 -2
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-placeholder/index.native.js +7 -7
- package/build-module/components/media-placeholder/index.native.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +2 -3
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/media-upload/constants.js +14 -0
- package/build-module/components/media-upload/constants.js.map +1 -0
- package/build-module/components/media-upload/index.native.js +53 -34
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/preview-options/index.js +1 -1
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +35 -37
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +15 -33
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/multiline.js +87 -0
- package/build-module/components/rich-text/multiline.js.map +1 -0
- package/build-module/components/rich-text/split-value.js +10 -16
- package/build-module/components/rich-text/split-value.js.map +1 -1
- package/build-module/components/rich-text/use-enter.js +33 -42
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +19 -34
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +2 -2
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/use-block-commands/index.js +28 -16
- package/build-module/components/use-block-commands/index.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +5 -2
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/hooks/background.js +249 -0
- package/build-module/hooks/background.js.map +1 -0
- package/build-module/hooks/block-hooks.js +181 -0
- package/build-module/hooks/block-hooks.js.map +1 -0
- package/build-module/hooks/block-rename-ui.js +154 -0
- package/build-module/hooks/block-rename-ui.js.map +1 -0
- package/build-module/hooks/duotone.js +26 -39
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +2 -2
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +33 -16
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/position.js +4 -2
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +10 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/private-apis.js +2 -0
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +33 -10
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +39 -8
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +23 -3
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +41 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +78 -22
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +0 -4
- package/build-module/store/utils.js.map +1 -1
- package/build-style/content-rtl.css +0 -1
- package/build-style/content.css +0 -1
- package/build-style/style-rtl.css +201 -131
- package/build-style/style.css +201 -131
- package/package.json +32 -32
- package/src/components/block-canvas/index.js +108 -0
- package/src/components/block-inspector/index.js +5 -1
- package/src/components/block-list/content.scss +0 -1
- package/src/components/block-patterns-list/index.js +53 -19
- package/src/components/block-patterns-list/style.scss +26 -9
- package/src/components/block-patterns-paging/index.js +92 -0
- package/src/components/block-patterns-paging/style.scss +45 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +44 -0
- package/src/components/block-settings-menu-controls/index.js +4 -9
- package/src/components/block-styles/index.js +1 -0
- package/src/components/block-styles/style.scss +3 -3
- package/src/components/block-toolbar/block-toolbar-menu.native.js +1 -6
- package/src/components/block-tools/block-contextual-toolbar.js +16 -5
- package/src/components/block-tools/block-selection-button.js +9 -1
- package/src/components/block-tools/style.scss +0 -98
- package/src/components/border-radius-control/input-controls.js +1 -1
- package/src/components/border-radius-control/linked-button.js +8 -11
- package/src/components/color-palette/test/__snapshots__/control.js.snap +34 -21
- package/src/components/colors/with-colors.js +3 -2
- package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +8 -35
- package/src/components/default-block-appender/index.native.js +26 -3
- package/src/components/duotone/utils.js +65 -0
- package/src/components/editor-styles/index.js +32 -23
- package/src/components/global-styles/hooks.js +4 -112
- package/src/components/global-styles/image-settings-panel.js +71 -0
- package/src/components/global-styles/index.js +4 -3
- package/src/components/global-styles/use-global-styles-output.js +25 -16
- package/src/components/global-styles/utils.js +1 -2
- package/src/components/iframe/index.js +72 -33
- package/src/components/image-editor/use-save-image.js +2 -9
- package/src/components/image-editor/use-transform-image.js +9 -9
- package/src/components/index.js +1 -1
- package/src/components/index.native.js +2 -2
- package/src/components/inner-blocks/use-nested-settings-update.js +15 -10
- package/src/components/inserter/block-patterns-explorer/explorer.js +17 -5
- package/src/components/inserter/block-patterns-explorer/patterns-list.js +68 -43
- package/src/components/inserter/block-patterns-explorer/sidebar.js +8 -8
- package/src/components/inserter/block-patterns-filter.js +183 -0
- package/src/components/inserter/block-patterns-tab.js +217 -58
- package/src/components/inserter/hooks/use-patterns-paging.js +76 -0
- package/src/components/inserter/hooks/use-patterns-state.js +27 -16
- package/src/components/inserter/menu.js +15 -17
- package/src/components/inserter/search-results.js +6 -4
- package/src/components/inserter/style.scss +36 -7
- package/src/components/inserter/tabs.js +2 -12
- package/src/components/inserter/test/index.native.js +8 -12
- package/src/components/inspector-controls/block-support-slot-container.js +19 -3
- package/src/components/inspector-controls/fill.js +28 -14
- package/src/components/inspector-controls/groups.js +6 -2
- package/src/components/inspector-controls/slot.js +28 -3
- package/src/components/inspector-controls-tabs/styles-tab.js +4 -0
- package/src/components/link-control/index.js +13 -0
- package/src/components/link-control/style.scss +23 -2
- package/src/components/link-control/test/index.js +88 -6
- package/src/components/list-view/block-select-button.js +1 -3
- package/src/components/list-view/block.js +19 -1
- package/src/components/list-view/style.scss +1 -2
- package/src/components/list-view/use-block-selection.js +38 -32
- package/src/components/media-placeholder/README.md +2 -2
- package/src/components/media-placeholder/index.js +2 -2
- package/src/components/media-placeholder/index.native.js +11 -12
- package/src/components/media-replace-flow/index.js +2 -2
- package/src/components/media-replace-flow/test/index.js +5 -23
- package/src/components/media-upload/README.md +3 -2
- package/src/components/media-upload/constants.js +15 -0
- package/src/components/media-upload/index.native.js +66 -40
- package/src/components/media-upload/style.native.scss +4 -0
- package/src/components/media-upload/test/index.native.js +2 -2
- package/src/components/preview-options/README.md +7 -0
- package/src/components/preview-options/index.js +1 -1
- package/src/components/rich-text/index.js +48 -44
- package/src/components/rich-text/index.native.js +14 -42
- package/src/components/rich-text/multiline.js +121 -0
- package/src/components/rich-text/split-value.js +10 -35
- package/src/components/rich-text/use-enter.js +32 -42
- package/src/components/rich-text/use-paste-handler.js +16 -40
- package/src/components/spacing-sizes-control/style.scss +5 -7
- package/src/components/spacing-sizes-control/utils.js +1 -2
- package/src/components/use-block-commands/index.js +28 -20
- package/src/components/use-block-display-information/index.js +3 -0
- package/src/hooks/background.js +299 -0
- package/src/hooks/background.scss +75 -0
- package/src/hooks/block-hooks.js +257 -0
- package/src/hooks/block-hooks.scss +16 -0
- package/src/hooks/block-rename-ui.js +231 -0
- package/src/hooks/block-rename-ui.scss +3 -0
- package/src/hooks/duotone.js +42 -43
- package/src/hooks/index.js +2 -2
- package/src/hooks/layout.js +31 -33
- package/src/hooks/position.js +4 -3
- package/src/hooks/style.js +11 -2
- package/src/hooks/test/align.native.js +4 -3
- package/src/private-apis.js +2 -0
- package/src/store/actions.js +52 -10
- package/src/store/private-actions.js +37 -6
- package/src/store/private-selectors.js +28 -3
- package/src/store/reducer.js +38 -0
- package/src/store/selectors.js +107 -26
- package/src/store/test/actions.js +19 -8
- package/src/store/test/private-actions.js +17 -0
- package/src/store/test/reducer.js +25 -0
- package/src/store/test/selectors.js +130 -123
- package/src/store/utils.js +3 -10
- package/src/style.scss +4 -0
- package/build/components/duotone/components.js +0 -135
- package/build/components/duotone/components.js.map +0 -1
- package/build/components/duotone/index.js +0 -38
- package/build/components/duotone/index.js.map +0 -1
- package/build/components/global-styles/behaviors-panel.js +0 -64
- package/build/components/global-styles/behaviors-panel.js.map +0 -1
- package/build/components/inserter/reusable-blocks-tab.js +0 -85
- package/build/components/inserter/reusable-blocks-tab.js.map +0 -1
- package/build/hooks/auto-inserting-blocks.js +0 -174
- package/build/hooks/auto-inserting-blocks.js.map +0 -1
- package/build/hooks/behaviors.js +0 -173
- package/build/hooks/behaviors.js.map +0 -1
- package/build-module/components/duotone/components.js +0 -126
- package/build-module/components/duotone/components.js.map +0 -1
- package/build-module/components/duotone/index.js +0 -3
- package/build-module/components/duotone/index.js.map +0 -1
- package/build-module/components/global-styles/behaviors-panel.js +0 -57
- package/build-module/components/global-styles/behaviors-panel.js.map +0 -1
- package/build-module/components/inserter/reusable-blocks-tab.js +0 -76
- package/build-module/components/inserter/reusable-blocks-tab.js.map +0 -1
- package/build-module/hooks/auto-inserting-blocks.js +0 -167
- package/build-module/hooks/auto-inserting-blocks.js.map +0 -1
- package/build-module/hooks/behaviors.js +0 -166
- package/build-module/hooks/behaviors.js.map +0 -1
- package/src/components/duotone/components.js +0 -133
- package/src/components/duotone/index.js +0 -7
- package/src/components/global-styles/behaviors-panel.js +0 -71
- package/src/components/inserter/reusable-blocks-tab.js +0 -84
- package/src/components/inserter/test/reusable-blocks-tab.js +0 -73
- package/src/hooks/auto-inserting-blocks.js +0 -232
- package/src/hooks/behaviors.js +0 -206
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { SelectControl } from '@wordpress/components';
|
|
5
|
-
import { __ } from '@wordpress/i18n';
|
|
6
|
-
|
|
7
|
-
export default function ( { onChange, value, behaviors } ) {
|
|
8
|
-
const defaultBehaviors = {
|
|
9
|
-
default: {
|
|
10
|
-
value: 'default',
|
|
11
|
-
label: __( 'Default' ),
|
|
12
|
-
},
|
|
13
|
-
noBehaviors: {
|
|
14
|
-
value: '',
|
|
15
|
-
label: __( 'No behaviors' ),
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const behaviorsOptions = Object.entries( behaviors ).map(
|
|
20
|
-
( [ behaviorName ] ) => ( {
|
|
21
|
-
value: behaviorName,
|
|
22
|
-
// Capitalize the first letter of the behavior name.
|
|
23
|
-
label: `${ behaviorName.charAt( 0 ).toUpperCase() }${ behaviorName
|
|
24
|
-
.slice( 1 )
|
|
25
|
-
.toLowerCase() }`,
|
|
26
|
-
} )
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
const options = [
|
|
30
|
-
...Object.values( defaultBehaviors ),
|
|
31
|
-
...behaviorsOptions,
|
|
32
|
-
];
|
|
33
|
-
|
|
34
|
-
const animations = [
|
|
35
|
-
{
|
|
36
|
-
value: 'zoom',
|
|
37
|
-
label: __( 'Zoom' ),
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
value: 'fade',
|
|
41
|
-
label: __( 'Fade' ),
|
|
42
|
-
},
|
|
43
|
-
];
|
|
44
|
-
return (
|
|
45
|
-
<div style={ { marginTop: '2rem' } }>
|
|
46
|
-
<SelectControl
|
|
47
|
-
label={ __( 'Behaviors' ) }
|
|
48
|
-
// At the moment we are only supporting one behavior (Lightbox)
|
|
49
|
-
value={ value }
|
|
50
|
-
options={ options }
|
|
51
|
-
onChange={ onChange }
|
|
52
|
-
hideCancelButton={ true }
|
|
53
|
-
size="__unstable-large"
|
|
54
|
-
/>
|
|
55
|
-
{ value === 'lightbox' && (
|
|
56
|
-
<SelectControl
|
|
57
|
-
label={ __( 'Animation' ) }
|
|
58
|
-
value={
|
|
59
|
-
behaviors?.lightbox.animation
|
|
60
|
-
? behaviors?.lightbox.animation
|
|
61
|
-
: ''
|
|
62
|
-
}
|
|
63
|
-
options={ animations }
|
|
64
|
-
onChange={ onChange }
|
|
65
|
-
hideCancelButton={ false }
|
|
66
|
-
size="__unstable-large"
|
|
67
|
-
/>
|
|
68
|
-
) }
|
|
69
|
-
</div>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useMemo } from '@wordpress/element';
|
|
5
|
-
import { __ } from '@wordpress/i18n';
|
|
6
|
-
import { addQueryArgs } from '@wordpress/url';
|
|
7
|
-
import { Button } from '@wordpress/components';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
12
|
-
import BlockTypesList from '../block-types-list';
|
|
13
|
-
import InserterPanel from './panel';
|
|
14
|
-
import InserterNoResults from './no-results';
|
|
15
|
-
import useBlockTypesState from './hooks/use-block-types-state';
|
|
16
|
-
import ReusableBlocksRenameHint from './reusable-block-rename-hint';
|
|
17
|
-
|
|
18
|
-
function ReusableBlocksList( { onHover, onInsert, rootClientId } ) {
|
|
19
|
-
const [ items, , , onSelectItem ] = useBlockTypesState(
|
|
20
|
-
rootClientId,
|
|
21
|
-
onInsert
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
const filteredItems = useMemo( () => {
|
|
25
|
-
return items.filter(
|
|
26
|
-
( { category, syncStatus } ) =>
|
|
27
|
-
category === 'reusable' && syncStatus !== 'unsynced'
|
|
28
|
-
);
|
|
29
|
-
}, [ items ] );
|
|
30
|
-
|
|
31
|
-
if ( filteredItems.length === 0 ) {
|
|
32
|
-
return <InserterNoResults />;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<InserterPanel title={ __( 'Synced patterns' ) }>
|
|
37
|
-
<BlockTypesList
|
|
38
|
-
items={ filteredItems }
|
|
39
|
-
onSelect={ onSelectItem }
|
|
40
|
-
onHover={ onHover }
|
|
41
|
-
label={ __( 'Synced patterns' ) }
|
|
42
|
-
/>
|
|
43
|
-
</InserterPanel>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// The unwrapped component is only exported for use by unit tests.
|
|
48
|
-
/**
|
|
49
|
-
* List of reusable blocks shown in the "Reusable" tab of the inserter.
|
|
50
|
-
*
|
|
51
|
-
* @param {Object} props Component props.
|
|
52
|
-
* @param {?string} props.rootClientId Client id of block to insert into.
|
|
53
|
-
* @param {Function} props.onInsert Callback to run when item is inserted.
|
|
54
|
-
* @param {Function} props.onHover Callback to run when item is hovered.
|
|
55
|
-
*
|
|
56
|
-
* @return {WPComponent} The component.
|
|
57
|
-
*/
|
|
58
|
-
export function ReusableBlocksTab( { rootClientId, onInsert, onHover } ) {
|
|
59
|
-
return (
|
|
60
|
-
<>
|
|
61
|
-
<div className="block-editor-inserter__hint">
|
|
62
|
-
<ReusableBlocksRenameHint />
|
|
63
|
-
</div>
|
|
64
|
-
<ReusableBlocksList
|
|
65
|
-
onHover={ onHover }
|
|
66
|
-
onInsert={ onInsert }
|
|
67
|
-
rootClientId={ rootClientId }
|
|
68
|
-
/>
|
|
69
|
-
<div className="block-editor-inserter__manage-reusable-blocks-container">
|
|
70
|
-
<Button
|
|
71
|
-
className="block-editor-inserter__manage-reusable-blocks"
|
|
72
|
-
variant="secondary"
|
|
73
|
-
href={ addQueryArgs( 'edit.php', {
|
|
74
|
-
post_type: 'wp_block',
|
|
75
|
-
} ) }
|
|
76
|
-
>
|
|
77
|
-
{ __( 'Manage my patterns' ) }
|
|
78
|
-
</Button>
|
|
79
|
-
</div>
|
|
80
|
-
</>
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export default ReusableBlocksTab;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { render, screen } from '@testing-library/react';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { registerBlockType, unregisterBlockType } from '@wordpress/blocks';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import { ReusableBlocksTab } from '../reusable-blocks-tab';
|
|
15
|
-
import items, { categories, collections } from './fixtures';
|
|
16
|
-
import useBlockTypesState from '../hooks/use-block-types-state';
|
|
17
|
-
|
|
18
|
-
jest.mock( '../hooks/use-block-types-state', () => {
|
|
19
|
-
// This allows us to tweak the returned value on each test.
|
|
20
|
-
const mock = jest.fn();
|
|
21
|
-
return mock;
|
|
22
|
-
} );
|
|
23
|
-
|
|
24
|
-
describe( 'InserterMenu', () => {
|
|
25
|
-
beforeAll( () => {
|
|
26
|
-
registerBlockType( 'core/block', {
|
|
27
|
-
save: () => {},
|
|
28
|
-
title: 'reusable block',
|
|
29
|
-
edit: () => {},
|
|
30
|
-
} );
|
|
31
|
-
} );
|
|
32
|
-
|
|
33
|
-
afterAll( () => {
|
|
34
|
-
unregisterBlockType( 'core/block' );
|
|
35
|
-
} );
|
|
36
|
-
|
|
37
|
-
beforeEach( () => {
|
|
38
|
-
useBlockTypesState.mockImplementation( () => [
|
|
39
|
-
items,
|
|
40
|
-
categories,
|
|
41
|
-
collections,
|
|
42
|
-
] );
|
|
43
|
-
} );
|
|
44
|
-
|
|
45
|
-
it( 'should show nothing if there are no items', () => {
|
|
46
|
-
const noItems = [];
|
|
47
|
-
useBlockTypesState.mockImplementation( () => [
|
|
48
|
-
noItems,
|
|
49
|
-
categories,
|
|
50
|
-
collections,
|
|
51
|
-
] );
|
|
52
|
-
|
|
53
|
-
render( <ReusableBlocksTab filterValue="random" /> );
|
|
54
|
-
|
|
55
|
-
expect( screen.queryByRole( 'option' ) ).not.toBeInTheDocument();
|
|
56
|
-
} );
|
|
57
|
-
|
|
58
|
-
it( 'should list reusable blocks', () => {
|
|
59
|
-
render( <ReusableBlocksTab /> );
|
|
60
|
-
|
|
61
|
-
expect(
|
|
62
|
-
screen.getByRole( 'option', { name: 'My reusable block' } )
|
|
63
|
-
).toBeVisible();
|
|
64
|
-
} );
|
|
65
|
-
|
|
66
|
-
it( 'should trim whitespace of search terms', () => {
|
|
67
|
-
render( <ReusableBlocksTab filterValue=" my reusable" /> );
|
|
68
|
-
|
|
69
|
-
expect(
|
|
70
|
-
screen.getByRole( 'option', { name: 'My reusable block' } )
|
|
71
|
-
).toBeVisible();
|
|
72
|
-
} );
|
|
73
|
-
} );
|
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import { addFilter } from '@wordpress/hooks';
|
|
6
|
-
import { Fragment } from '@wordpress/element';
|
|
7
|
-
import { PanelBody, ToggleControl } from '@wordpress/components';
|
|
8
|
-
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
9
|
-
import { createBlock, store as blocksStore } from '@wordpress/blocks';
|
|
10
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
import { InspectorControls } from '../components';
|
|
16
|
-
import { store as blockEditorStore } from '../store';
|
|
17
|
-
|
|
18
|
-
function AutoInsertingBlocksControl( props ) {
|
|
19
|
-
const { autoInsertedBlocksForCurrentBlock, groupedAutoInsertedBlocks } =
|
|
20
|
-
useSelect(
|
|
21
|
-
( select ) => {
|
|
22
|
-
const { getBlockTypes } = select( blocksStore );
|
|
23
|
-
const _autoInsertedBlocksForCurrentBlock =
|
|
24
|
-
getBlockTypes()?.filter(
|
|
25
|
-
( { autoInsert } ) =>
|
|
26
|
-
autoInsert && props.blockName in autoInsert
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
// Group by block namespace (i.e. prefix before the slash).
|
|
30
|
-
const _groupedAutoInsertedBlocks =
|
|
31
|
-
_autoInsertedBlocksForCurrentBlock?.reduce(
|
|
32
|
-
( groups, block ) => {
|
|
33
|
-
const [ namespace ] = block.name.split( '/' );
|
|
34
|
-
if ( ! groups[ namespace ] ) {
|
|
35
|
-
groups[ namespace ] = [];
|
|
36
|
-
}
|
|
37
|
-
groups[ namespace ].push( block );
|
|
38
|
-
return groups;
|
|
39
|
-
},
|
|
40
|
-
{}
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
autoInsertedBlocksForCurrentBlock:
|
|
45
|
-
_autoInsertedBlocksForCurrentBlock,
|
|
46
|
-
groupedAutoInsertedBlocks: _groupedAutoInsertedBlocks,
|
|
47
|
-
};
|
|
48
|
-
},
|
|
49
|
-
[ props.blockName ]
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
const {
|
|
53
|
-
autoInsertedBlockClientIds,
|
|
54
|
-
blockIndex,
|
|
55
|
-
rootClientId,
|
|
56
|
-
innerBlocksLength,
|
|
57
|
-
} = useSelect(
|
|
58
|
-
( select ) => {
|
|
59
|
-
const { getBlock, getBlockIndex, getBlockRootClientId } =
|
|
60
|
-
select( blockEditorStore );
|
|
61
|
-
const _rootClientId = getBlockRootClientId( props.clientId );
|
|
62
|
-
|
|
63
|
-
const _autoInsertedBlockClientIds =
|
|
64
|
-
autoInsertedBlocksForCurrentBlock.reduce(
|
|
65
|
-
( clientIds, block ) => {
|
|
66
|
-
const relativePosition =
|
|
67
|
-
block?.autoInsert?.[ props.blockName ];
|
|
68
|
-
let candidates;
|
|
69
|
-
|
|
70
|
-
switch ( relativePosition ) {
|
|
71
|
-
case 'before':
|
|
72
|
-
case 'after':
|
|
73
|
-
// Any of the current block's siblings (with the right block type) qualifies
|
|
74
|
-
// as an auto-inserted block (inserted `before` or `after` the current one),
|
|
75
|
-
// as the block might've been auto-inserted and then moved around a bit by the user.
|
|
76
|
-
candidates =
|
|
77
|
-
getBlock( _rootClientId )?.innerBlocks;
|
|
78
|
-
break;
|
|
79
|
-
|
|
80
|
-
case 'first_child':
|
|
81
|
-
case 'last_child':
|
|
82
|
-
// Any of the current block's child blocks (with the right block type) qualifies
|
|
83
|
-
// as an auto-inserted first or last child block, as the block might've been
|
|
84
|
-
// auto-inserted and then moved around a bit by the user.
|
|
85
|
-
candidates = getBlock(
|
|
86
|
-
props.clientId
|
|
87
|
-
).innerBlocks;
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const autoInsertedBlock = candidates?.find(
|
|
92
|
-
( { name } ) => name === block.name
|
|
93
|
-
);
|
|
94
|
-
|
|
95
|
-
if ( autoInsertedBlock ) {
|
|
96
|
-
clientIds[ block.name ] =
|
|
97
|
-
autoInsertedBlock.clientId;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// TOOD: If no auto-inserted block was found in any of its designated locations,
|
|
101
|
-
// we want to check if it's present elsewhere in the block tree.
|
|
102
|
-
// If it is, we'd consider it manually inserted and would want to remove the
|
|
103
|
-
// corresponding toggle from the block inspector panel.
|
|
104
|
-
|
|
105
|
-
return clientIds;
|
|
106
|
-
},
|
|
107
|
-
{}
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
return {
|
|
111
|
-
blockIndex: getBlockIndex( props.clientId ),
|
|
112
|
-
innerBlocksLength: getBlock( props.clientId )?.innerBlocks
|
|
113
|
-
?.length,
|
|
114
|
-
rootClientId: _rootClientId,
|
|
115
|
-
autoInsertedBlockClientIds: _autoInsertedBlockClientIds,
|
|
116
|
-
};
|
|
117
|
-
},
|
|
118
|
-
[ autoInsertedBlocksForCurrentBlock, props.blockName, props.clientId ]
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
const { insertBlock, removeBlock } = useDispatch( blockEditorStore );
|
|
122
|
-
|
|
123
|
-
if ( ! autoInsertedBlocksForCurrentBlock.length ) {
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const insertBlockIntoDesignatedLocation = ( block, relativePosition ) => {
|
|
128
|
-
switch ( relativePosition ) {
|
|
129
|
-
case 'before':
|
|
130
|
-
case 'after':
|
|
131
|
-
insertBlock(
|
|
132
|
-
block,
|
|
133
|
-
relativePosition === 'after' ? blockIndex + 1 : blockIndex,
|
|
134
|
-
rootClientId, // Insert as a child of the current block's parent
|
|
135
|
-
false
|
|
136
|
-
);
|
|
137
|
-
break;
|
|
138
|
-
|
|
139
|
-
case 'first_child':
|
|
140
|
-
case 'last_child':
|
|
141
|
-
insertBlock(
|
|
142
|
-
block,
|
|
143
|
-
// TODO: It'd be great if insertBlock() would accept negative indices for insertion.
|
|
144
|
-
relativePosition === 'first_child' ? 0 : innerBlocksLength,
|
|
145
|
-
props.clientId, // Insert as a child of the current block.
|
|
146
|
-
false
|
|
147
|
-
);
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
return (
|
|
153
|
-
<InspectorControls>
|
|
154
|
-
<PanelBody title={ __( 'Plugins' ) } initialOpen={ true }>
|
|
155
|
-
{ Object.keys( groupedAutoInsertedBlocks ).map( ( vendor ) => {
|
|
156
|
-
return (
|
|
157
|
-
<Fragment key={ vendor }>
|
|
158
|
-
<h3>{ vendor }</h3>
|
|
159
|
-
{ groupedAutoInsertedBlocks[ vendor ].map(
|
|
160
|
-
( block ) => {
|
|
161
|
-
// TODO: Display block icon.
|
|
162
|
-
// <BlockIcon icon={ block.icon } />
|
|
163
|
-
|
|
164
|
-
const checked =
|
|
165
|
-
block.name in
|
|
166
|
-
autoInsertedBlockClientIds;
|
|
167
|
-
|
|
168
|
-
return (
|
|
169
|
-
<ToggleControl
|
|
170
|
-
checked={ checked }
|
|
171
|
-
key={ block.title }
|
|
172
|
-
label={ block.title }
|
|
173
|
-
onChange={ () => {
|
|
174
|
-
if ( ! checked ) {
|
|
175
|
-
// Create and insert block.
|
|
176
|
-
const relativePosition =
|
|
177
|
-
block.autoInsert[
|
|
178
|
-
props.blockName
|
|
179
|
-
];
|
|
180
|
-
insertBlockIntoDesignatedLocation(
|
|
181
|
-
createBlock(
|
|
182
|
-
block.name
|
|
183
|
-
),
|
|
184
|
-
relativePosition
|
|
185
|
-
);
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// Remove block.
|
|
190
|
-
const clientId =
|
|
191
|
-
autoInsertedBlockClientIds[
|
|
192
|
-
block.name
|
|
193
|
-
];
|
|
194
|
-
removeBlock( clientId, false );
|
|
195
|
-
} }
|
|
196
|
-
/>
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
) }
|
|
200
|
-
</Fragment>
|
|
201
|
-
);
|
|
202
|
-
} ) }
|
|
203
|
-
</PanelBody>
|
|
204
|
-
</InspectorControls>
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export const withAutoInsertingBlocks = createHigherOrderComponent(
|
|
209
|
-
( BlockEdit ) => {
|
|
210
|
-
return ( props ) => {
|
|
211
|
-
const blockEdit = <BlockEdit key="edit" { ...props } />;
|
|
212
|
-
return (
|
|
213
|
-
<>
|
|
214
|
-
{ blockEdit }
|
|
215
|
-
<AutoInsertingBlocksControl
|
|
216
|
-
blockName={ props.name }
|
|
217
|
-
clientId={ props.clientId }
|
|
218
|
-
/>
|
|
219
|
-
</>
|
|
220
|
-
);
|
|
221
|
-
};
|
|
222
|
-
},
|
|
223
|
-
'withAutoInsertingBlocks'
|
|
224
|
-
);
|
|
225
|
-
|
|
226
|
-
if ( window?.__experimentalAutoInsertingBlocks ) {
|
|
227
|
-
addFilter(
|
|
228
|
-
'editor.BlockEdit',
|
|
229
|
-
'core/auto-inserting-blocks/with-inspector-control',
|
|
230
|
-
withAutoInsertingBlocks
|
|
231
|
-
);
|
|
232
|
-
}
|
package/src/hooks/behaviors.js
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { addFilter } from '@wordpress/hooks';
|
|
5
|
-
import { SelectControl } from '@wordpress/components';
|
|
6
|
-
import { __ } from '@wordpress/i18n';
|
|
7
|
-
import { hasBlockSupport } from '@wordpress/blocks';
|
|
8
|
-
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
9
|
-
import { useSelect } from '@wordpress/data';
|
|
10
|
-
import { useMemo } from '@wordpress/element';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
import { store as blockEditorStore } from '../store';
|
|
16
|
-
import { InspectorControls } from '../components';
|
|
17
|
-
|
|
18
|
-
function BehaviorsControl( {
|
|
19
|
-
blockName,
|
|
20
|
-
blockBehaviors,
|
|
21
|
-
onChangeBehavior,
|
|
22
|
-
onChangeAnimation,
|
|
23
|
-
disabled = false,
|
|
24
|
-
} ) {
|
|
25
|
-
const { settings } = useSelect(
|
|
26
|
-
( select ) => {
|
|
27
|
-
const { getSettings } = select( blockEditorStore );
|
|
28
|
-
return {
|
|
29
|
-
settings:
|
|
30
|
-
getSettings()?.__experimentalFeatures?.blocks?.[ blockName ]
|
|
31
|
-
?.behaviors || {},
|
|
32
|
-
};
|
|
33
|
-
},
|
|
34
|
-
[ blockName ]
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
const defaultBehaviors = {
|
|
38
|
-
default: {
|
|
39
|
-
value: 'default',
|
|
40
|
-
label: __( 'Default' ),
|
|
41
|
-
},
|
|
42
|
-
noBehaviors: {
|
|
43
|
-
value: '',
|
|
44
|
-
label: __( 'No behaviors' ),
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
const behaviorsOptions = Object.entries( settings )
|
|
48
|
-
.filter(
|
|
49
|
-
( [ behaviorName, behaviorValue ] ) =>
|
|
50
|
-
hasBlockSupport( blockName, `behaviors.${ behaviorName }` ) &&
|
|
51
|
-
behaviorValue
|
|
52
|
-
) // Filter out behaviors that are disabled.
|
|
53
|
-
.map( ( [ behaviorName ] ) => ( {
|
|
54
|
-
value: behaviorName,
|
|
55
|
-
// Capitalize the first letter of the behavior name.
|
|
56
|
-
label: `${ behaviorName.charAt( 0 ).toUpperCase() }${ behaviorName
|
|
57
|
-
.slice( 1 )
|
|
58
|
-
.toLowerCase() }`,
|
|
59
|
-
} ) );
|
|
60
|
-
const options = [
|
|
61
|
-
...Object.values( defaultBehaviors ),
|
|
62
|
-
...behaviorsOptions,
|
|
63
|
-
];
|
|
64
|
-
|
|
65
|
-
const { behaviors, behaviorsValue } = useMemo( () => {
|
|
66
|
-
const mergedBehaviors = {
|
|
67
|
-
...( blockBehaviors || {} ),
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
let value = '';
|
|
71
|
-
if ( blockBehaviors === undefined ) {
|
|
72
|
-
value = 'default';
|
|
73
|
-
}
|
|
74
|
-
if ( blockBehaviors?.lightbox.enabled ) {
|
|
75
|
-
value = 'lightbox';
|
|
76
|
-
}
|
|
77
|
-
return {
|
|
78
|
-
behaviors: mergedBehaviors,
|
|
79
|
-
behaviorsValue: value,
|
|
80
|
-
};
|
|
81
|
-
}, [ blockBehaviors ] );
|
|
82
|
-
|
|
83
|
-
// If every behavior is disabled, do not show the behaviors inspector control.
|
|
84
|
-
if ( behaviorsOptions.length === 0 ) {
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const helpText = disabled
|
|
89
|
-
? __( 'The lightbox behavior is disabled for linked images.' )
|
|
90
|
-
: '';
|
|
91
|
-
|
|
92
|
-
return (
|
|
93
|
-
<InspectorControls group="advanced">
|
|
94
|
-
<div>
|
|
95
|
-
<SelectControl
|
|
96
|
-
label={ __( 'Behaviors' ) }
|
|
97
|
-
// At the moment we are only supporting one behavior (Lightbox)
|
|
98
|
-
value={ behaviorsValue }
|
|
99
|
-
options={ options }
|
|
100
|
-
onChange={ onChangeBehavior }
|
|
101
|
-
hideCancelButton={ true }
|
|
102
|
-
help={ helpText }
|
|
103
|
-
size="__unstable-large"
|
|
104
|
-
disabled={ disabled }
|
|
105
|
-
/>
|
|
106
|
-
{ behaviorsValue === 'lightbox' && (
|
|
107
|
-
<SelectControl
|
|
108
|
-
label={ __( 'Animation' ) }
|
|
109
|
-
// At the moment we are only supporting one behavior (Lightbox)
|
|
110
|
-
value={
|
|
111
|
-
behaviors?.lightbox.animation
|
|
112
|
-
? behaviors?.lightbox.animation
|
|
113
|
-
: ''
|
|
114
|
-
}
|
|
115
|
-
options={ [
|
|
116
|
-
{
|
|
117
|
-
value: 'zoom',
|
|
118
|
-
label: __( 'Zoom' ),
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
value: 'fade',
|
|
122
|
-
label: __( 'Fade' ),
|
|
123
|
-
},
|
|
124
|
-
] }
|
|
125
|
-
onChange={ onChangeAnimation }
|
|
126
|
-
hideCancelButton={ false }
|
|
127
|
-
size="__unstable-large"
|
|
128
|
-
disabled={ disabled }
|
|
129
|
-
/>
|
|
130
|
-
) }
|
|
131
|
-
</div>
|
|
132
|
-
</InspectorControls>
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Override the default edit UI to include a new block inspector control for
|
|
138
|
-
* assigning behaviors to blocks if behaviors are enabled in the theme.json.
|
|
139
|
-
*
|
|
140
|
-
* Currently, only the `core/image` block is supported.
|
|
141
|
-
*
|
|
142
|
-
* @param {WPComponent} BlockEdit Original component.
|
|
143
|
-
*
|
|
144
|
-
* @return {WPComponent} Wrapped component.
|
|
145
|
-
*/
|
|
146
|
-
export const withBehaviors = createHigherOrderComponent( ( BlockEdit ) => {
|
|
147
|
-
return ( props ) => {
|
|
148
|
-
const blockEdit = <BlockEdit key="edit" { ...props } />;
|
|
149
|
-
// Only add behaviors to blocks with support.
|
|
150
|
-
if ( ! hasBlockSupport( props.name, 'behaviors' ) ) {
|
|
151
|
-
return blockEdit;
|
|
152
|
-
}
|
|
153
|
-
const blockHasLink =
|
|
154
|
-
typeof props.attributes?.linkDestination !== 'undefined' &&
|
|
155
|
-
props.attributes?.linkDestination !== 'none';
|
|
156
|
-
return (
|
|
157
|
-
<>
|
|
158
|
-
{ blockEdit }
|
|
159
|
-
<BehaviorsControl
|
|
160
|
-
blockName={ props.name }
|
|
161
|
-
blockBehaviors={ props.attributes.behaviors }
|
|
162
|
-
onChangeBehavior={ ( nextValue ) => {
|
|
163
|
-
if ( nextValue === 'default' ) {
|
|
164
|
-
props.setAttributes( {
|
|
165
|
-
behaviors: undefined,
|
|
166
|
-
} );
|
|
167
|
-
} else {
|
|
168
|
-
// If the user selects something, it means that they want to
|
|
169
|
-
// change the default value (true) so we save it in the attributes.
|
|
170
|
-
props.setAttributes( {
|
|
171
|
-
behaviors: {
|
|
172
|
-
lightbox: {
|
|
173
|
-
enabled: nextValue === 'lightbox',
|
|
174
|
-
animation:
|
|
175
|
-
nextValue === 'lightbox'
|
|
176
|
-
? 'zoom'
|
|
177
|
-
: '',
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
} );
|
|
181
|
-
}
|
|
182
|
-
} }
|
|
183
|
-
onChangeAnimation={ ( nextValue ) => {
|
|
184
|
-
props.setAttributes( {
|
|
185
|
-
behaviors: {
|
|
186
|
-
lightbox: {
|
|
187
|
-
enabled:
|
|
188
|
-
props.attributes.behaviors.lightbox
|
|
189
|
-
.enabled,
|
|
190
|
-
animation: nextValue,
|
|
191
|
-
},
|
|
192
|
-
},
|
|
193
|
-
} );
|
|
194
|
-
} }
|
|
195
|
-
disabled={ blockHasLink }
|
|
196
|
-
/>
|
|
197
|
-
</>
|
|
198
|
-
);
|
|
199
|
-
};
|
|
200
|
-
}, 'withBehaviors' );
|
|
201
|
-
|
|
202
|
-
addFilter(
|
|
203
|
-
'editor.BlockEdit',
|
|
204
|
-
'core/behaviors/with-inspector-control',
|
|
205
|
-
withBehaviors
|
|
206
|
-
);
|