@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
package/src/store/actions.js
CHANGED
|
@@ -19,61 +19,44 @@ import {
|
|
|
19
19
|
} from '@wordpress/blocks';
|
|
20
20
|
import { speak } from '@wordpress/a11y';
|
|
21
21
|
import { __, _n, sprintf } from '@wordpress/i18n';
|
|
22
|
-
import { controls } from '@wordpress/data';
|
|
23
22
|
import { create, insert, remove, toHTMLString } from '@wordpress/rich-text';
|
|
24
23
|
import deprecated from '@wordpress/deprecated';
|
|
25
24
|
|
|
26
25
|
/**
|
|
27
|
-
*
|
|
28
|
-
|
|
29
|
-
import { __unstableMarkAutomaticChangeFinalControl } from '../store/controls';
|
|
30
|
-
import { STORE_NAME as blockEditorStoreName } from './constants';
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Generator which will yield a default block insert action if there
|
|
34
|
-
* are no other blocks at the root of the editor. This generator should be used
|
|
26
|
+
* Action which will insert a default block insert action if there
|
|
27
|
+
* are no other blocks at the root of the editor. This action should be used
|
|
35
28
|
* in actions which may result in no blocks remaining in the editor (removal,
|
|
36
29
|
* replacement, etc).
|
|
37
30
|
*/
|
|
38
|
-
|
|
39
|
-
const count = yield controls.select(
|
|
40
|
-
blockEditorStoreName,
|
|
41
|
-
'getBlockCount'
|
|
42
|
-
);
|
|
43
|
-
|
|
31
|
+
const ensureDefaultBlock = () => ( { select, dispatch } ) => {
|
|
44
32
|
// To avoid a focus loss when removing the last block, assure there is
|
|
45
33
|
// always a default block if the last of the blocks have been removed.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
// If there's an custom appender, don't insert default block.
|
|
53
|
-
// We have to remember to manually move the focus elsewhere to
|
|
54
|
-
// prevent it from being lost though.
|
|
55
|
-
if ( __unstableHasCustomAppender ) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
34
|
+
const count = select.getBlockCount();
|
|
35
|
+
if ( count > 0 ) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
58
38
|
|
|
59
|
-
|
|
39
|
+
// If there's an custom appender, don't insert default block.
|
|
40
|
+
// We have to remember to manually move the focus elsewhere to
|
|
41
|
+
// prevent it from being lost though.
|
|
42
|
+
const { __unstableHasCustomAppender } = select.getSettings();
|
|
43
|
+
if ( __unstableHasCustomAppender ) {
|
|
44
|
+
return;
|
|
60
45
|
}
|
|
61
|
-
|
|
46
|
+
|
|
47
|
+
dispatch.insertDefaultBlock();
|
|
48
|
+
};
|
|
62
49
|
|
|
63
50
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* content reflected as an edit in state.
|
|
51
|
+
* Action that resets blocks state to the specified array of blocks, taking precedence
|
|
52
|
+
* over any other content reflected as an edit in state.
|
|
67
53
|
*
|
|
68
54
|
* @param {Array} blocks Array of blocks.
|
|
69
55
|
*/
|
|
70
|
-
export
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
};
|
|
75
|
-
return yield* validateBlocksToTemplate( blocks );
|
|
76
|
-
}
|
|
56
|
+
export const resetBlocks = ( blocks ) => ( { dispatch } ) => {
|
|
57
|
+
dispatch( { type: 'RESET_BLOCKS', blocks } );
|
|
58
|
+
dispatch( validateBlocksToTemplate( blocks ) );
|
|
59
|
+
};
|
|
77
60
|
|
|
78
61
|
/**
|
|
79
62
|
* Block validity is a function of blocks state (at the point of a
|
|
@@ -83,15 +66,12 @@ export function* resetBlocks( blocks ) {
|
|
|
83
66
|
*
|
|
84
67
|
* @param {Array} blocks Array of blocks.
|
|
85
68
|
*/
|
|
86
|
-
export
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
);
|
|
91
|
-
const templateLock =
|
|
92
|
-
blockEditorStoreName,
|
|
93
|
-
'getTemplateLock'
|
|
94
|
-
);
|
|
69
|
+
export const validateBlocksToTemplate = ( blocks ) => ( {
|
|
70
|
+
select,
|
|
71
|
+
dispatch,
|
|
72
|
+
} ) => {
|
|
73
|
+
const template = select.getTemplate();
|
|
74
|
+
const templateLock = select.getTemplateLock();
|
|
95
75
|
|
|
96
76
|
// Unlocked templates are considered always valid because they act
|
|
97
77
|
// as default values only.
|
|
@@ -101,16 +81,13 @@ export function* validateBlocksToTemplate( blocks ) {
|
|
|
101
81
|
doBlocksMatchTemplate( blocks, template );
|
|
102
82
|
|
|
103
83
|
// Update if validity has changed.
|
|
104
|
-
const isValidTemplate =
|
|
105
|
-
blockEditorStoreName,
|
|
106
|
-
'isValidTemplate'
|
|
107
|
-
);
|
|
84
|
+
const isValidTemplate = select.isValidTemplate();
|
|
108
85
|
|
|
109
86
|
if ( isBlocksValidToTemplate !== isValidTemplate ) {
|
|
110
|
-
|
|
87
|
+
dispatch.setTemplateValidity( isBlocksValidToTemplate );
|
|
111
88
|
return isBlocksValidToTemplate;
|
|
112
89
|
}
|
|
113
|
-
}
|
|
90
|
+
};
|
|
114
91
|
|
|
115
92
|
/**
|
|
116
93
|
* A block selection object.
|
|
@@ -123,6 +100,7 @@ export function* validateBlocksToTemplate( blocks ) {
|
|
|
123
100
|
* text value. See `wp.richText.create`.
|
|
124
101
|
*/
|
|
125
102
|
|
|
103
|
+
/* eslint-disable jsdoc/valid-types */
|
|
126
104
|
/**
|
|
127
105
|
* Returns an action object used in signalling that selection state should be
|
|
128
106
|
* reset to the specified selection.
|
|
@@ -138,6 +116,7 @@ export function resetSelection(
|
|
|
138
116
|
selectionEnd,
|
|
139
117
|
initialPosition
|
|
140
118
|
) {
|
|
119
|
+
/* eslint-enable jsdoc/valid-types */
|
|
141
120
|
return {
|
|
142
121
|
type: 'RESET_SELECTION',
|
|
143
122
|
selectionStart,
|
|
@@ -170,8 +149,7 @@ export function receiveBlocks( blocks ) {
|
|
|
170
149
|
}
|
|
171
150
|
|
|
172
151
|
/**
|
|
173
|
-
*
|
|
174
|
-
* attributes with the specified client IDs have been updated.
|
|
152
|
+
* Action that updates attributes of multiple blocks with the specified client IDs.
|
|
175
153
|
*
|
|
176
154
|
* @param {string|string[]} clientIds Block client IDs.
|
|
177
155
|
* @param {Object} attributes Block attributes to be merged. Should be keyed by clientIds if
|
|
@@ -193,8 +171,7 @@ export function updateBlockAttributes(
|
|
|
193
171
|
}
|
|
194
172
|
|
|
195
173
|
/**
|
|
196
|
-
*
|
|
197
|
-
* specified client ID has been updated.
|
|
174
|
+
* Action that updates the block with the specified client ID.
|
|
198
175
|
*
|
|
199
176
|
* @param {string} clientId Block client ID.
|
|
200
177
|
* @param {Object} updates Block attributes to be merged.
|
|
@@ -209,6 +186,7 @@ export function updateBlock( clientId, updates ) {
|
|
|
209
186
|
};
|
|
210
187
|
}
|
|
211
188
|
|
|
189
|
+
/* eslint-disable jsdoc/valid-types */
|
|
212
190
|
/**
|
|
213
191
|
* Returns an action object used in signalling that the block with the
|
|
214
192
|
* specified client ID has been selected, optionally accepting a position
|
|
@@ -222,6 +200,7 @@ export function updateBlock( clientId, updates ) {
|
|
|
222
200
|
* @return {Object} Action object.
|
|
223
201
|
*/
|
|
224
202
|
export function selectBlock( clientId, initialPosition = 0 ) {
|
|
203
|
+
/* eslint-enable jsdoc/valid-types */
|
|
225
204
|
return {
|
|
226
205
|
type: 'SELECT_BLOCK',
|
|
227
206
|
initialPosition,
|
|
@@ -235,18 +214,12 @@ export function selectBlock( clientId, initialPosition = 0 ) {
|
|
|
235
214
|
*
|
|
236
215
|
* @param {string} clientId Block client ID.
|
|
237
216
|
*/
|
|
238
|
-
export
|
|
239
|
-
const previousBlockClientId =
|
|
240
|
-
blockEditorStoreName,
|
|
241
|
-
'getPreviousBlockClientId',
|
|
242
|
-
clientId
|
|
243
|
-
);
|
|
244
|
-
|
|
217
|
+
export const selectPreviousBlock = ( clientId ) => ( { select, dispatch } ) => {
|
|
218
|
+
const previousBlockClientId = select.getPreviousBlockClientId( clientId );
|
|
245
219
|
if ( previousBlockClientId ) {
|
|
246
|
-
|
|
247
|
-
return [ previousBlockClientId ];
|
|
220
|
+
dispatch.selectBlock( previousBlockClientId, -1 );
|
|
248
221
|
}
|
|
249
|
-
}
|
|
222
|
+
};
|
|
250
223
|
|
|
251
224
|
/**
|
|
252
225
|
* Yields action objects used in signalling that the block following the given
|
|
@@ -254,21 +227,15 @@ export function* selectPreviousBlock( clientId ) {
|
|
|
254
227
|
*
|
|
255
228
|
* @param {string} clientId Block client ID.
|
|
256
229
|
*/
|
|
257
|
-
export
|
|
258
|
-
const nextBlockClientId =
|
|
259
|
-
blockEditorStoreName,
|
|
260
|
-
'getNextBlockClientId',
|
|
261
|
-
clientId
|
|
262
|
-
);
|
|
263
|
-
|
|
230
|
+
export const selectNextBlock = ( clientId ) => ( { select, dispatch } ) => {
|
|
231
|
+
const nextBlockClientId = select.getNextBlockClientId( clientId );
|
|
264
232
|
if ( nextBlockClientId ) {
|
|
265
|
-
|
|
266
|
-
return [ nextBlockClientId ];
|
|
233
|
+
dispatch.selectBlock( nextBlockClientId );
|
|
267
234
|
}
|
|
268
|
-
}
|
|
235
|
+
};
|
|
269
236
|
|
|
270
237
|
/**
|
|
271
|
-
*
|
|
238
|
+
* Action that starts block multi-selection.
|
|
272
239
|
*
|
|
273
240
|
* @return {Object} Action object.
|
|
274
241
|
*/
|
|
@@ -279,7 +246,7 @@ export function startMultiSelect() {
|
|
|
279
246
|
}
|
|
280
247
|
|
|
281
248
|
/**
|
|
282
|
-
*
|
|
249
|
+
* Action that stops block multi-selection.
|
|
283
250
|
*
|
|
284
251
|
* @return {Object} Action object.
|
|
285
252
|
*/
|
|
@@ -290,38 +257,23 @@ export function stopMultiSelect() {
|
|
|
290
257
|
}
|
|
291
258
|
|
|
292
259
|
/**
|
|
293
|
-
*
|
|
260
|
+
* Action that changes block multi-selection.
|
|
294
261
|
*
|
|
295
262
|
* @param {string} start First block of the multi selection.
|
|
296
263
|
* @param {string} end Last block of the multiselection.
|
|
297
264
|
*/
|
|
298
|
-
export
|
|
299
|
-
const startBlockRootClientId =
|
|
300
|
-
|
|
301
|
-
'getBlockRootClientId',
|
|
302
|
-
start
|
|
303
|
-
);
|
|
304
|
-
const endBlockRootClientId = yield controls.select(
|
|
305
|
-
blockEditorStoreName,
|
|
306
|
-
'getBlockRootClientId',
|
|
307
|
-
end
|
|
308
|
-
);
|
|
265
|
+
export const multiSelect = ( start, end ) => ( { select, dispatch } ) => {
|
|
266
|
+
const startBlockRootClientId = select.getBlockRootClientId( start );
|
|
267
|
+
const endBlockRootClientId = select.getBlockRootClientId( end );
|
|
309
268
|
|
|
310
269
|
// Only allow block multi-selections at the same level.
|
|
311
270
|
if ( startBlockRootClientId !== endBlockRootClientId ) {
|
|
312
271
|
return;
|
|
313
272
|
}
|
|
314
273
|
|
|
315
|
-
|
|
316
|
-
type: 'MULTI_SELECT',
|
|
317
|
-
start,
|
|
318
|
-
end,
|
|
319
|
-
};
|
|
274
|
+
dispatch( { type: 'MULTI_SELECT', start, end } );
|
|
320
275
|
|
|
321
|
-
const blockCount =
|
|
322
|
-
blockEditorStoreName,
|
|
323
|
-
'getSelectedBlockCount'
|
|
324
|
-
);
|
|
276
|
+
const blockCount = select.getSelectedBlockCount();
|
|
325
277
|
|
|
326
278
|
speak(
|
|
327
279
|
sprintf(
|
|
@@ -331,10 +283,10 @@ export function* multiSelect( start, end ) {
|
|
|
331
283
|
),
|
|
332
284
|
'assertive'
|
|
333
285
|
);
|
|
334
|
-
}
|
|
286
|
+
};
|
|
335
287
|
|
|
336
288
|
/**
|
|
337
|
-
*
|
|
289
|
+
* Action that clears the block selection.
|
|
338
290
|
*
|
|
339
291
|
* @return {Object} Action object.
|
|
340
292
|
*/
|
|
@@ -345,7 +297,7 @@ export function clearSelectedBlock() {
|
|
|
345
297
|
}
|
|
346
298
|
|
|
347
299
|
/**
|
|
348
|
-
*
|
|
300
|
+
* Action that enables or disables block selection.
|
|
349
301
|
*
|
|
350
302
|
* @param {boolean} [isSelectionEnabled=true] Whether block selection should
|
|
351
303
|
* be enabled.
|
|
@@ -389,9 +341,9 @@ function getBlocksWithDefaultStylesApplied( blocks, blockEditorSettings ) {
|
|
|
389
341
|
} );
|
|
390
342
|
}
|
|
391
343
|
|
|
344
|
+
/* eslint-disable jsdoc/valid-types */
|
|
392
345
|
/**
|
|
393
|
-
*
|
|
394
|
-
* one or more replacement blocks.
|
|
346
|
+
* Action that replaces given blocks with one or more replacement blocks.
|
|
395
347
|
*
|
|
396
348
|
* @param {(string|string[])} clientIds Block client ID(s) to replace.
|
|
397
349
|
* @param {(Object|Object[])} blocks Replacement block(s).
|
|
@@ -399,31 +351,26 @@ function getBlocksWithDefaultStylesApplied( blocks, blockEditorSettings ) {
|
|
|
399
351
|
* @param {0|-1|null} initialPosition Index of caret after in the selected block after the operation.
|
|
400
352
|
* @param {?Object} meta Optional Meta values to be passed to the action object.
|
|
401
353
|
*
|
|
402
|
-
* @
|
|
354
|
+
* @return {Object} Action object.
|
|
403
355
|
*/
|
|
404
|
-
export
|
|
356
|
+
export const replaceBlocks = (
|
|
405
357
|
clientIds,
|
|
406
358
|
blocks,
|
|
407
359
|
indexToSelect,
|
|
408
360
|
initialPosition = 0,
|
|
409
361
|
meta
|
|
410
|
-
) {
|
|
362
|
+
) => ( { select, dispatch } ) => {
|
|
363
|
+
/* eslint-enable jsdoc/valid-types */
|
|
411
364
|
clientIds = castArray( clientIds );
|
|
412
365
|
blocks = getBlocksWithDefaultStylesApplied(
|
|
413
366
|
castArray( blocks ),
|
|
414
|
-
|
|
415
|
-
);
|
|
416
|
-
const rootClientId = yield controls.select(
|
|
417
|
-
blockEditorStoreName,
|
|
418
|
-
'getBlockRootClientId',
|
|
419
|
-
first( clientIds )
|
|
367
|
+
select.getSettings()
|
|
420
368
|
);
|
|
369
|
+
const rootClientId = select.getBlockRootClientId( first( clientIds ) );
|
|
421
370
|
// Replace is valid if the new blocks can be inserted in the root block.
|
|
422
371
|
for ( let index = 0; index < blocks.length; index++ ) {
|
|
423
372
|
const block = blocks[ index ];
|
|
424
|
-
const canInsertBlock =
|
|
425
|
-
blockEditorStoreName,
|
|
426
|
-
'canInsertBlockType',
|
|
373
|
+
const canInsertBlock = select.canInsertBlockType(
|
|
427
374
|
block.name,
|
|
428
375
|
rootClientId
|
|
429
376
|
);
|
|
@@ -431,7 +378,7 @@ export function* replaceBlocks(
|
|
|
431
378
|
return;
|
|
432
379
|
}
|
|
433
380
|
}
|
|
434
|
-
|
|
381
|
+
dispatch( {
|
|
435
382
|
type: 'REPLACE_BLOCKS',
|
|
436
383
|
clientIds,
|
|
437
384
|
blocks,
|
|
@@ -439,13 +386,12 @@ export function* replaceBlocks(
|
|
|
439
386
|
indexToSelect,
|
|
440
387
|
initialPosition,
|
|
441
388
|
meta,
|
|
442
|
-
};
|
|
443
|
-
|
|
444
|
-
}
|
|
389
|
+
} );
|
|
390
|
+
dispatch( ensureDefaultBlock() );
|
|
391
|
+
};
|
|
445
392
|
|
|
446
393
|
/**
|
|
447
|
-
*
|
|
448
|
-
* with one or more replacement blocks.
|
|
394
|
+
* Action that replaces a single block with one or more replacement blocks.
|
|
449
395
|
*
|
|
450
396
|
* @param {(string|string[])} clientId Block client ID to replace.
|
|
451
397
|
* @param {(Object|Object[])} block Replacement block(s).
|
|
@@ -464,100 +410,91 @@ export function replaceBlock( clientId, block ) {
|
|
|
464
410
|
*
|
|
465
411
|
* @return {Function} Action creator.
|
|
466
412
|
*/
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
}
|
|
413
|
+
const createOnMove = ( type ) => ( clientIds, rootClientId ) => ( {
|
|
414
|
+
select,
|
|
415
|
+
dispatch,
|
|
416
|
+
} ) => {
|
|
417
|
+
// If one of the blocks is locked or the parent is locked, we cannot move any block.
|
|
418
|
+
const canMoveBlocks = select.canMoveBlocks( clientIds, rootClientId );
|
|
419
|
+
if ( ! canMoveBlocks ) {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
dispatch( { type, clientIds: castArray( clientIds ), rootClientId } );
|
|
424
|
+
};
|
|
476
425
|
|
|
477
426
|
export const moveBlocksDown = createOnMove( 'MOVE_BLOCKS_DOWN' );
|
|
478
427
|
export const moveBlocksUp = createOnMove( 'MOVE_BLOCKS_UP' );
|
|
479
428
|
|
|
480
429
|
/**
|
|
481
|
-
*
|
|
482
|
-
* a new position.
|
|
430
|
+
* Action that moves given blocks to a new position.
|
|
483
431
|
*
|
|
484
432
|
* @param {?string} clientIds The client IDs of the blocks.
|
|
485
433
|
* @param {?string} fromRootClientId Root client ID source.
|
|
486
434
|
* @param {?string} toRootClientId Root client ID destination.
|
|
487
435
|
* @param {number} index The index to move the blocks to.
|
|
488
|
-
*
|
|
489
|
-
* @yield {Object} Action object.
|
|
490
436
|
*/
|
|
491
|
-
export
|
|
437
|
+
export const moveBlocksToPosition = (
|
|
492
438
|
clientIds,
|
|
493
439
|
fromRootClientId = '',
|
|
494
440
|
toRootClientId = '',
|
|
495
441
|
index
|
|
496
|
-
) {
|
|
497
|
-
const
|
|
498
|
-
blockEditorStoreName,
|
|
499
|
-
'getTemplateLock',
|
|
500
|
-
fromRootClientId
|
|
501
|
-
);
|
|
442
|
+
) => ( { select, dispatch } ) => {
|
|
443
|
+
const canMoveBlocks = select.canMoveBlocks( clientIds, fromRootClientId );
|
|
502
444
|
|
|
503
|
-
// If
|
|
504
|
-
|
|
505
|
-
if ( templateLock === 'all' ) {
|
|
445
|
+
// If one of the blocks is locked or the parent is locked, we cannot move any block.
|
|
446
|
+
if ( ! canMoveBlocks ) {
|
|
506
447
|
return;
|
|
507
448
|
}
|
|
508
449
|
|
|
509
|
-
const action = {
|
|
510
|
-
type: 'MOVE_BLOCKS_TO_POSITION',
|
|
511
|
-
fromRootClientId,
|
|
512
|
-
toRootClientId,
|
|
513
|
-
clientIds,
|
|
514
|
-
index,
|
|
515
|
-
};
|
|
516
|
-
|
|
517
450
|
// If moving inside the same root block the move is always possible.
|
|
518
|
-
if ( fromRootClientId
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
451
|
+
if ( fromRootClientId !== toRootClientId ) {
|
|
452
|
+
const canRemoveBlocks = select.canRemoveBlocks(
|
|
453
|
+
clientIds,
|
|
454
|
+
fromRootClientId
|
|
455
|
+
);
|
|
522
456
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
}
|
|
457
|
+
// If we're moving to another block, it means we're deleting blocks from
|
|
458
|
+
// the original block, so we need to check if removing is possible.
|
|
459
|
+
if ( ! canRemoveBlocks ) {
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
529
462
|
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
toRootClientId
|
|
535
|
-
);
|
|
463
|
+
const canInsertBlocks = select.canInsertBlocks(
|
|
464
|
+
clientIds,
|
|
465
|
+
toRootClientId
|
|
466
|
+
);
|
|
536
467
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
468
|
+
// If moving to other parent block, the move is possible if we can insert a block of the same type inside the new parent block.
|
|
469
|
+
if ( ! canInsertBlocks ) {
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
540
472
|
}
|
|
541
|
-
|
|
473
|
+
|
|
474
|
+
dispatch( {
|
|
475
|
+
type: 'MOVE_BLOCKS_TO_POSITION',
|
|
476
|
+
fromRootClientId,
|
|
477
|
+
toRootClientId,
|
|
478
|
+
clientIds,
|
|
479
|
+
index,
|
|
480
|
+
} );
|
|
481
|
+
};
|
|
542
482
|
|
|
543
483
|
/**
|
|
544
|
-
*
|
|
545
|
-
* new position.
|
|
484
|
+
* Action that moves given block to a new position.
|
|
546
485
|
*
|
|
547
486
|
* @param {?string} clientId The client ID of the block.
|
|
548
487
|
* @param {?string} fromRootClientId Root client ID source.
|
|
549
488
|
* @param {?string} toRootClientId Root client ID destination.
|
|
550
489
|
* @param {number} index The index to move the block to.
|
|
551
|
-
*
|
|
552
|
-
* @yield {Object} Action object.
|
|
553
490
|
*/
|
|
554
|
-
export function
|
|
491
|
+
export function moveBlockToPosition(
|
|
555
492
|
clientId,
|
|
556
493
|
fromRootClientId = '',
|
|
557
494
|
toRootClientId = '',
|
|
558
495
|
index
|
|
559
496
|
) {
|
|
560
|
-
|
|
497
|
+
return moveBlocksToPosition(
|
|
561
498
|
[ clientId ],
|
|
562
499
|
fromRootClientId,
|
|
563
500
|
toRootClientId,
|
|
@@ -566,8 +503,7 @@ export function* moveBlockToPosition(
|
|
|
566
503
|
}
|
|
567
504
|
|
|
568
505
|
/**
|
|
569
|
-
*
|
|
570
|
-
* inserted, optionally at a specific index respective a root block list.
|
|
506
|
+
* Action that inserts a single block, optionally at a specific index respective a root block list.
|
|
571
507
|
*
|
|
572
508
|
* @param {Object} block Block object to insert.
|
|
573
509
|
* @param {?number} index Index at which block should be inserted.
|
|
@@ -581,7 +517,7 @@ export function insertBlock(
|
|
|
581
517
|
block,
|
|
582
518
|
index,
|
|
583
519
|
rootClientId,
|
|
584
|
-
updateSelection
|
|
520
|
+
updateSelection,
|
|
585
521
|
meta
|
|
586
522
|
) {
|
|
587
523
|
return insertBlocks(
|
|
@@ -594,9 +530,9 @@ export function insertBlock(
|
|
|
594
530
|
);
|
|
595
531
|
}
|
|
596
532
|
|
|
533
|
+
/* eslint-disable jsdoc/valid-types */
|
|
597
534
|
/**
|
|
598
|
-
*
|
|
599
|
-
* be inserted, optionally at a specific index respective a root block list.
|
|
535
|
+
* Action that inserts an array of blocks, optionally at a specific index respective a root block list.
|
|
600
536
|
*
|
|
601
537
|
* @param {Object[]} blocks Block objects to insert.
|
|
602
538
|
* @param {?number} index Index at which block should be inserted.
|
|
@@ -606,14 +542,15 @@ export function insertBlock(
|
|
|
606
542
|
* @param {?Object} meta Optional Meta values to be passed to the action object.
|
|
607
543
|
* @return {Object} Action object.
|
|
608
544
|
*/
|
|
609
|
-
export
|
|
545
|
+
export const insertBlocks = (
|
|
610
546
|
blocks,
|
|
611
547
|
index,
|
|
612
548
|
rootClientId,
|
|
613
549
|
updateSelection = true,
|
|
614
550
|
initialPosition = 0,
|
|
615
551
|
meta
|
|
616
|
-
) {
|
|
552
|
+
) => ( { select, dispatch } ) => {
|
|
553
|
+
/* eslint-enable jsdoc/valid-types */
|
|
617
554
|
if ( isObject( initialPosition ) ) {
|
|
618
555
|
meta = initialPosition;
|
|
619
556
|
initialPosition = 0;
|
|
@@ -626,22 +563,17 @@ export function* insertBlocks(
|
|
|
626
563
|
|
|
627
564
|
blocks = getBlocksWithDefaultStylesApplied(
|
|
628
565
|
castArray( blocks ),
|
|
629
|
-
|
|
566
|
+
select.getSettings()
|
|
630
567
|
);
|
|
631
568
|
const allowedBlocks = [];
|
|
632
569
|
for ( const block of blocks ) {
|
|
633
|
-
const isValid =
|
|
634
|
-
blockEditorStoreName,
|
|
635
|
-
'canInsertBlockType',
|
|
636
|
-
block.name,
|
|
637
|
-
rootClientId
|
|
638
|
-
);
|
|
570
|
+
const isValid = select.canInsertBlockType( block.name, rootClientId );
|
|
639
571
|
if ( isValid ) {
|
|
640
572
|
allowedBlocks.push( block );
|
|
641
573
|
}
|
|
642
574
|
}
|
|
643
575
|
if ( allowedBlocks.length ) {
|
|
644
|
-
|
|
576
|
+
dispatch( {
|
|
645
577
|
type: 'INSERT_BLOCKS',
|
|
646
578
|
blocks: allowedBlocks,
|
|
647
579
|
index,
|
|
@@ -650,13 +582,12 @@ export function* insertBlocks(
|
|
|
650
582
|
updateSelection,
|
|
651
583
|
initialPosition: updateSelection ? initialPosition : null,
|
|
652
584
|
meta,
|
|
653
|
-
};
|
|
585
|
+
} );
|
|
654
586
|
}
|
|
655
|
-
}
|
|
587
|
+
};
|
|
656
588
|
|
|
657
589
|
/**
|
|
658
|
-
*
|
|
659
|
-
* be shown.
|
|
590
|
+
* Action that shows the insertion point.
|
|
660
591
|
*
|
|
661
592
|
* @param {?string} rootClientId Optional root client ID of block list on
|
|
662
593
|
* which to insert.
|
|
@@ -680,7 +611,7 @@ export function showInsertionPoint(
|
|
|
680
611
|
}
|
|
681
612
|
|
|
682
613
|
/**
|
|
683
|
-
*
|
|
614
|
+
* Action that hides the insertion point.
|
|
684
615
|
*
|
|
685
616
|
* @return {Object} Action object.
|
|
686
617
|
*/
|
|
@@ -691,7 +622,7 @@ export function hideInsertionPoint() {
|
|
|
691
622
|
}
|
|
692
623
|
|
|
693
624
|
/**
|
|
694
|
-
*
|
|
625
|
+
* Action that resets the template validity.
|
|
695
626
|
*
|
|
696
627
|
* @param {boolean} isValid template validity flag.
|
|
697
628
|
*
|
|
@@ -705,61 +636,45 @@ export function setTemplateValidity( isValid ) {
|
|
|
705
636
|
}
|
|
706
637
|
|
|
707
638
|
/**
|
|
708
|
-
*
|
|
639
|
+
* Action that synchronizes the template with the list of blocks.
|
|
709
640
|
*
|
|
710
641
|
* @return {Object} Action object.
|
|
711
642
|
*/
|
|
712
|
-
export
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
const blocks = yield controls.select( blockEditorStoreName, 'getBlocks' );
|
|
717
|
-
const template = yield controls.select(
|
|
718
|
-
blockEditorStoreName,
|
|
719
|
-
'getTemplate'
|
|
720
|
-
);
|
|
643
|
+
export const synchronizeTemplate = () => ( { select, dispatch } ) => {
|
|
644
|
+
dispatch( { type: 'SYNCHRONIZE_TEMPLATE' } );
|
|
645
|
+
const blocks = select.getBlocks();
|
|
646
|
+
const template = select.getTemplate();
|
|
721
647
|
const updatedBlockList = synchronizeBlocksWithTemplate( blocks, template );
|
|
722
648
|
|
|
723
|
-
|
|
724
|
-
}
|
|
649
|
+
dispatch.resetBlocks( updatedBlockList );
|
|
650
|
+
};
|
|
725
651
|
|
|
726
652
|
/**
|
|
727
|
-
*
|
|
653
|
+
* Action that merges two blocks.
|
|
728
654
|
*
|
|
729
655
|
* @param {string} firstBlockClientId Client ID of the first block to merge.
|
|
730
656
|
* @param {string} secondBlockClientId Client ID of the second block to merge.
|
|
731
657
|
*/
|
|
732
|
-
export
|
|
658
|
+
export const mergeBlocks = ( firstBlockClientId, secondBlockClientId ) => ( {
|
|
659
|
+
select,
|
|
660
|
+
dispatch,
|
|
661
|
+
} ) => {
|
|
733
662
|
const blocks = [ firstBlockClientId, secondBlockClientId ];
|
|
734
|
-
|
|
735
|
-
type: 'MERGE_BLOCKS',
|
|
736
|
-
blocks,
|
|
737
|
-
};
|
|
663
|
+
dispatch( { type: 'MERGE_BLOCKS', blocks } );
|
|
738
664
|
|
|
739
665
|
const [ clientIdA, clientIdB ] = blocks;
|
|
740
|
-
const blockA =
|
|
741
|
-
blockEditorStoreName,
|
|
742
|
-
'getBlock',
|
|
743
|
-
clientIdA
|
|
744
|
-
);
|
|
666
|
+
const blockA = select.getBlock( clientIdA );
|
|
745
667
|
const blockAType = getBlockType( blockA.name );
|
|
746
668
|
|
|
747
669
|
// Only focus the previous block if it's not mergeable
|
|
748
|
-
if ( ! blockAType.merge ) {
|
|
749
|
-
|
|
670
|
+
if ( blockAType && ! blockAType.merge ) {
|
|
671
|
+
dispatch.selectBlock( blockA.clientId );
|
|
750
672
|
return;
|
|
751
673
|
}
|
|
752
674
|
|
|
753
|
-
const blockB =
|
|
754
|
-
blockEditorStoreName,
|
|
755
|
-
'getBlock',
|
|
756
|
-
clientIdB
|
|
757
|
-
);
|
|
675
|
+
const blockB = select.getBlock( clientIdB );
|
|
758
676
|
const blockBType = getBlockType( blockB.name );
|
|
759
|
-
const { clientId, attributeKey, offset } =
|
|
760
|
-
blockEditorStoreName,
|
|
761
|
-
'getSelectionStart'
|
|
762
|
-
);
|
|
677
|
+
const { clientId, attributeKey, offset } = select.getSelectionStart();
|
|
763
678
|
const selectedBlockType = clientId === clientIdA ? blockAType : blockBType;
|
|
764
679
|
const attributeDefinition = selectedBlockType.attributes[ attributeKey ];
|
|
765
680
|
const canRestoreTextSelection =
|
|
@@ -866,7 +781,7 @@ export function* mergeBlocks( firstBlockClientId, secondBlockClientId ) {
|
|
|
866
781
|
|
|
867
782
|
updatedAttributes[ newAttributeKey ] = newHtml;
|
|
868
783
|
|
|
869
|
-
|
|
784
|
+
dispatch.selectionChange(
|
|
870
785
|
blockA.clientId,
|
|
871
786
|
newAttributeKey,
|
|
872
787
|
newOffset,
|
|
@@ -874,7 +789,7 @@ export function* mergeBlocks( firstBlockClientId, secondBlockClientId ) {
|
|
|
874
789
|
);
|
|
875
790
|
}
|
|
876
791
|
|
|
877
|
-
|
|
792
|
+
dispatch.replaceBlocks(
|
|
878
793
|
[ blockA.clientId, blockB.clientId ],
|
|
879
794
|
[
|
|
880
795
|
{
|
|
@@ -888,7 +803,7 @@ export function* mergeBlocks( firstBlockClientId, secondBlockClientId ) {
|
|
|
888
803
|
],
|
|
889
804
|
0 // If we don't pass the `indexToSelect` it will default to the last block.
|
|
890
805
|
);
|
|
891
|
-
}
|
|
806
|
+
};
|
|
892
807
|
|
|
893
808
|
/**
|
|
894
809
|
* Yields action objects used in signalling that the blocks corresponding to
|
|
@@ -898,47 +813,32 @@ export function* mergeBlocks( firstBlockClientId, secondBlockClientId ) {
|
|
|
898
813
|
* @param {boolean} selectPrevious True if the previous block should be
|
|
899
814
|
* selected when a block is removed.
|
|
900
815
|
*/
|
|
901
|
-
export
|
|
816
|
+
export const removeBlocks = ( clientIds, selectPrevious = true ) => ( {
|
|
817
|
+
select,
|
|
818
|
+
dispatch,
|
|
819
|
+
} ) => {
|
|
902
820
|
if ( ! clientIds || ! clientIds.length ) {
|
|
903
821
|
return;
|
|
904
822
|
}
|
|
905
823
|
|
|
906
824
|
clientIds = castArray( clientIds );
|
|
907
|
-
const rootClientId =
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
);
|
|
912
|
-
const isLocked = yield controls.select(
|
|
913
|
-
blockEditorStoreName,
|
|
914
|
-
'getTemplateLock',
|
|
915
|
-
rootClientId
|
|
916
|
-
);
|
|
917
|
-
if ( isLocked ) {
|
|
825
|
+
const rootClientId = select.getBlockRootClientId( clientIds[ 0 ] );
|
|
826
|
+
const canRemoveBlocks = select.canRemoveBlocks( clientIds, rootClientId );
|
|
827
|
+
|
|
828
|
+
if ( ! canRemoveBlocks ) {
|
|
918
829
|
return;
|
|
919
830
|
}
|
|
920
831
|
|
|
921
|
-
let previousBlockId;
|
|
922
832
|
if ( selectPrevious ) {
|
|
923
|
-
|
|
924
|
-
} else {
|
|
925
|
-
previousBlockId = yield controls.select(
|
|
926
|
-
blockEditorStoreName,
|
|
927
|
-
'getPreviousBlockClientId',
|
|
928
|
-
clientIds[ 0 ]
|
|
929
|
-
);
|
|
833
|
+
dispatch.selectPreviousBlock( clientIds[ 0 ] );
|
|
930
834
|
}
|
|
931
835
|
|
|
932
|
-
|
|
933
|
-
type: 'REMOVE_BLOCKS',
|
|
934
|
-
clientIds,
|
|
935
|
-
};
|
|
836
|
+
dispatch( { type: 'REMOVE_BLOCKS', clientIds } );
|
|
936
837
|
|
|
937
838
|
// To avoid a focus loss when removing the last block, assure there is
|
|
938
839
|
// always a default block if the last of the blocks have been removed.
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
}
|
|
840
|
+
dispatch( ensureDefaultBlock() );
|
|
841
|
+
};
|
|
942
842
|
|
|
943
843
|
/**
|
|
944
844
|
* Returns an action object used in signalling that the block with the
|
|
@@ -954,6 +854,7 @@ export function removeBlock( clientId, selectPrevious ) {
|
|
|
954
854
|
return removeBlocks( [ clientId ], selectPrevious );
|
|
955
855
|
}
|
|
956
856
|
|
|
857
|
+
/* eslint-disable jsdoc/valid-types */
|
|
957
858
|
/**
|
|
958
859
|
* Returns an action object used in signalling that the inner blocks with the
|
|
959
860
|
* specified client ID should be replaced.
|
|
@@ -970,6 +871,7 @@ export function replaceInnerBlocks(
|
|
|
970
871
|
updateSelection = false,
|
|
971
872
|
initialPosition = 0
|
|
972
873
|
) {
|
|
874
|
+
/* eslint-enable jsdoc/valid-types */
|
|
973
875
|
return {
|
|
974
876
|
type: 'REPLACE_INNER_BLOCKS',
|
|
975
877
|
rootClientId,
|
|
@@ -1065,8 +967,7 @@ export function exitFormattedText() {
|
|
|
1065
967
|
}
|
|
1066
968
|
|
|
1067
969
|
/**
|
|
1068
|
-
*
|
|
1069
|
-
* position.
|
|
970
|
+
* Action that changes the position of the user caret.
|
|
1070
971
|
*
|
|
1071
972
|
* @param {string} clientId The selected block client ID.
|
|
1072
973
|
* @param {string} attributeKey The selected block attribute key.
|
|
@@ -1091,8 +992,7 @@ export function selectionChange(
|
|
|
1091
992
|
}
|
|
1092
993
|
|
|
1093
994
|
/**
|
|
1094
|
-
*
|
|
1095
|
-
* type should be added to the block list.
|
|
995
|
+
* Action that adds a new block of the default type to the block list.
|
|
1096
996
|
*
|
|
1097
997
|
* @param {?Object} attributes Optional attributes of the block to assign.
|
|
1098
998
|
* @param {?string} rootClientId Optional root client ID of block list on which
|
|
@@ -1114,7 +1014,7 @@ export function insertDefaultBlock( attributes, rootClientId, index ) {
|
|
|
1114
1014
|
}
|
|
1115
1015
|
|
|
1116
1016
|
/**
|
|
1117
|
-
*
|
|
1017
|
+
* Action that changes the nested settings of a given block.
|
|
1118
1018
|
*
|
|
1119
1019
|
* @param {string} clientId Client ID of the block whose nested setting are
|
|
1120
1020
|
* being received.
|
|
@@ -1131,7 +1031,7 @@ export function updateBlockListSettings( clientId, settings ) {
|
|
|
1131
1031
|
}
|
|
1132
1032
|
|
|
1133
1033
|
/**
|
|
1134
|
-
*
|
|
1034
|
+
* Action that updates the block editor settings.
|
|
1135
1035
|
*
|
|
1136
1036
|
* @param {Object} settings Updated settings
|
|
1137
1037
|
*
|
|
@@ -1145,7 +1045,7 @@ export function updateSettings( settings ) {
|
|
|
1145
1045
|
}
|
|
1146
1046
|
|
|
1147
1047
|
/**
|
|
1148
|
-
*
|
|
1048
|
+
* Action that signals that a temporary reusable block has been saved
|
|
1149
1049
|
* in order to switch its temporary id with the real id.
|
|
1150
1050
|
*
|
|
1151
1051
|
* @param {string} id Reusable block's id.
|
|
@@ -1162,7 +1062,7 @@ export function __unstableSaveReusableBlock( id, updatedId ) {
|
|
|
1162
1062
|
}
|
|
1163
1063
|
|
|
1164
1064
|
/**
|
|
1165
|
-
*
|
|
1065
|
+
* Action that marks the last block change explicitly as persistent.
|
|
1166
1066
|
*
|
|
1167
1067
|
* @return {Object} Action object.
|
|
1168
1068
|
*/
|
|
@@ -1171,7 +1071,7 @@ export function __unstableMarkLastChangeAsPersistent() {
|
|
|
1171
1071
|
}
|
|
1172
1072
|
|
|
1173
1073
|
/**
|
|
1174
|
-
*
|
|
1074
|
+
* Action that signals that the next block change should be marked explicitly as not persistent.
|
|
1175
1075
|
*
|
|
1176
1076
|
* @return {Object} Action object.
|
|
1177
1077
|
*/
|
|
@@ -1180,34 +1080,29 @@ export function __unstableMarkNextChangeAsNotPersistent() {
|
|
|
1180
1080
|
}
|
|
1181
1081
|
|
|
1182
1082
|
/**
|
|
1183
|
-
*
|
|
1184
|
-
*
|
|
1185
|
-
*
|
|
1186
|
-
*
|
|
1187
|
-
* it is recommended to be called at the next idle period to ensure all
|
|
1083
|
+
* Action that marks the last block change as an automatic change, meaning it was not
|
|
1084
|
+
* performed by the user, and can be undone using the `Escape` and `Backspace` keys.
|
|
1085
|
+
* This action must be called after the change was made, and any actions that are a
|
|
1086
|
+
* consequence of it, so it is recommended to be called at the next idle period to ensure all
|
|
1188
1087
|
* selection changes have been recorded.
|
|
1189
1088
|
*/
|
|
1190
|
-
export
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
type: 'MARK_AUTOMATIC_CHANGE_FINAL',
|
|
1198
|
-
};
|
|
1199
|
-
}
|
|
1089
|
+
export const __unstableMarkAutomaticChange = () => ( { dispatch } ) => {
|
|
1090
|
+
dispatch( { type: 'MARK_AUTOMATIC_CHANGE' } );
|
|
1091
|
+
const { requestIdleCallback = ( cb ) => setTimeout( cb, 100 ) } = window;
|
|
1092
|
+
requestIdleCallback( () => {
|
|
1093
|
+
dispatch( { type: 'MARK_AUTOMATIC_CHANGE_FINAL' } );
|
|
1094
|
+
} );
|
|
1095
|
+
};
|
|
1200
1096
|
|
|
1201
1097
|
/**
|
|
1202
|
-
*
|
|
1098
|
+
* Action that enables or disables the navigation mode.
|
|
1203
1099
|
*
|
|
1204
1100
|
* @param {string} isNavigationMode Enable/Disable navigation mode.
|
|
1205
1101
|
*/
|
|
1206
|
-
export
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
};
|
|
1102
|
+
export const setNavigationMode = ( isNavigationMode = true ) => ( {
|
|
1103
|
+
dispatch,
|
|
1104
|
+
} ) => {
|
|
1105
|
+
dispatch( { type: 'SET_NAVIGATION_MODE', isNavigationMode } );
|
|
1211
1106
|
|
|
1212
1107
|
if ( isNavigationMode ) {
|
|
1213
1108
|
speak(
|
|
@@ -1222,18 +1117,17 @@ export function* setNavigationMode( isNavigationMode = true ) {
|
|
|
1222
1117
|
)
|
|
1223
1118
|
);
|
|
1224
1119
|
}
|
|
1225
|
-
}
|
|
1120
|
+
};
|
|
1226
1121
|
|
|
1227
1122
|
/**
|
|
1228
|
-
*
|
|
1123
|
+
* Action that enables or disables the block moving mode.
|
|
1229
1124
|
*
|
|
1230
1125
|
* @param {string|null} hasBlockMovingClientId Enable/Disable block moving mode.
|
|
1231
1126
|
*/
|
|
1232
|
-
export
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
};
|
|
1127
|
+
export const setBlockMovingClientId = ( hasBlockMovingClientId = null ) => ( {
|
|
1128
|
+
dispatch,
|
|
1129
|
+
} ) => {
|
|
1130
|
+
dispatch( { type: 'SET_BLOCK_MOVING_MODE', hasBlockMovingClientId } );
|
|
1237
1131
|
|
|
1238
1132
|
if ( hasBlockMovingClientId ) {
|
|
1239
1133
|
speak(
|
|
@@ -1242,133 +1136,105 @@ export function* setBlockMovingClientId( hasBlockMovingClientId = null ) {
|
|
|
1242
1136
|
)
|
|
1243
1137
|
);
|
|
1244
1138
|
}
|
|
1245
|
-
}
|
|
1139
|
+
};
|
|
1246
1140
|
|
|
1247
1141
|
/**
|
|
1248
|
-
*
|
|
1142
|
+
* Action that duplicates a list of blocks.
|
|
1249
1143
|
*
|
|
1250
1144
|
* @param {string[]} clientIds
|
|
1251
1145
|
* @param {boolean} updateSelection
|
|
1252
1146
|
*/
|
|
1253
|
-
export
|
|
1254
|
-
|
|
1147
|
+
export const duplicateBlocks = ( clientIds, updateSelection = true ) => ( {
|
|
1148
|
+
select,
|
|
1149
|
+
dispatch,
|
|
1150
|
+
} ) => {
|
|
1151
|
+
if ( ! clientIds || ! clientIds.length ) {
|
|
1255
1152
|
return;
|
|
1256
1153
|
}
|
|
1257
|
-
|
|
1258
|
-
blockEditorStoreName,
|
|
1259
|
-
'getBlocksByClientId',
|
|
1260
|
-
clientIds
|
|
1261
|
-
);
|
|
1262
|
-
const rootClientId = yield controls.select(
|
|
1263
|
-
blockEditorStoreName,
|
|
1264
|
-
'getBlockRootClientId',
|
|
1265
|
-
clientIds[ 0 ]
|
|
1266
|
-
);
|
|
1154
|
+
|
|
1267
1155
|
// Return early if blocks don't exist.
|
|
1156
|
+
const blocks = select.getBlocksByClientId( clientIds );
|
|
1268
1157
|
if ( some( blocks, ( block ) => ! block ) ) {
|
|
1269
1158
|
return;
|
|
1270
1159
|
}
|
|
1271
|
-
|
|
1160
|
+
|
|
1272
1161
|
// Return early if blocks don't support multiple usage.
|
|
1162
|
+
const blockNames = blocks.map( ( block ) => block.name );
|
|
1273
1163
|
if (
|
|
1274
|
-
some(
|
|
1275
|
-
blockNames,
|
|
1164
|
+
blockNames.some(
|
|
1276
1165
|
( blockName ) => ! hasBlockSupport( blockName, 'multiple', true )
|
|
1277
1166
|
)
|
|
1278
1167
|
) {
|
|
1279
1168
|
return;
|
|
1280
1169
|
}
|
|
1281
1170
|
|
|
1282
|
-
const
|
|
1283
|
-
|
|
1284
|
-
'getBlockIndex',
|
|
1171
|
+
const rootClientId = select.getBlockRootClientId( clientIds[ 0 ] );
|
|
1172
|
+
const lastSelectedIndex = select.getBlockIndex(
|
|
1285
1173
|
last( castArray( clientIds ) ),
|
|
1286
1174
|
rootClientId
|
|
1287
1175
|
);
|
|
1288
1176
|
const clonedBlocks = blocks.map( ( block ) =>
|
|
1289
1177
|
__experimentalCloneSanitizedBlock( block )
|
|
1290
1178
|
);
|
|
1291
|
-
|
|
1179
|
+
dispatch.insertBlocks(
|
|
1292
1180
|
clonedBlocks,
|
|
1293
1181
|
lastSelectedIndex + 1,
|
|
1294
1182
|
rootClientId,
|
|
1295
1183
|
updateSelection
|
|
1296
1184
|
);
|
|
1297
1185
|
if ( clonedBlocks.length > 1 && updateSelection ) {
|
|
1298
|
-
|
|
1186
|
+
dispatch.multiSelect(
|
|
1299
1187
|
first( clonedBlocks ).clientId,
|
|
1300
1188
|
last( clonedBlocks ).clientId
|
|
1301
1189
|
);
|
|
1302
1190
|
}
|
|
1303
1191
|
return clonedBlocks.map( ( block ) => block.clientId );
|
|
1304
|
-
}
|
|
1192
|
+
};
|
|
1305
1193
|
|
|
1306
1194
|
/**
|
|
1307
|
-
*
|
|
1195
|
+
* Action that inserts an empty block before a given block.
|
|
1308
1196
|
*
|
|
1309
1197
|
* @param {string} clientId
|
|
1310
1198
|
*/
|
|
1311
|
-
export
|
|
1199
|
+
export const insertBeforeBlock = ( clientId ) => ( { select, dispatch } ) => {
|
|
1312
1200
|
if ( ! clientId ) {
|
|
1313
1201
|
return;
|
|
1314
1202
|
}
|
|
1315
|
-
const rootClientId =
|
|
1316
|
-
|
|
1317
|
-
'getBlockRootClientId',
|
|
1318
|
-
clientId
|
|
1319
|
-
);
|
|
1320
|
-
const isLocked = yield controls.select(
|
|
1321
|
-
blockEditorStoreName,
|
|
1322
|
-
'getTemplateLock',
|
|
1323
|
-
rootClientId
|
|
1324
|
-
);
|
|
1203
|
+
const rootClientId = select.getBlockRootClientId( clientId );
|
|
1204
|
+
const isLocked = select.getTemplateLock( rootClientId );
|
|
1325
1205
|
if ( isLocked ) {
|
|
1326
1206
|
return;
|
|
1327
1207
|
}
|
|
1328
1208
|
|
|
1329
|
-
const firstSelectedIndex =
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
clientId,
|
|
1333
|
-
rootClientId
|
|
1334
|
-
);
|
|
1335
|
-
return yield insertDefaultBlock( {}, rootClientId, firstSelectedIndex );
|
|
1336
|
-
}
|
|
1209
|
+
const firstSelectedIndex = select.getBlockIndex( clientId, rootClientId );
|
|
1210
|
+
return dispatch.insertDefaultBlock( {}, rootClientId, firstSelectedIndex );
|
|
1211
|
+
};
|
|
1337
1212
|
|
|
1338
1213
|
/**
|
|
1339
|
-
*
|
|
1214
|
+
* Action that inserts an empty block after a given block.
|
|
1340
1215
|
*
|
|
1341
1216
|
* @param {string} clientId
|
|
1342
1217
|
*/
|
|
1343
|
-
export
|
|
1218
|
+
export const insertAfterBlock = ( clientId ) => ( { select, dispatch } ) => {
|
|
1344
1219
|
if ( ! clientId ) {
|
|
1345
1220
|
return;
|
|
1346
1221
|
}
|
|
1347
|
-
const rootClientId =
|
|
1348
|
-
|
|
1349
|
-
'getBlockRootClientId',
|
|
1350
|
-
clientId
|
|
1351
|
-
);
|
|
1352
|
-
const isLocked = yield controls.select(
|
|
1353
|
-
blockEditorStoreName,
|
|
1354
|
-
'getTemplateLock',
|
|
1355
|
-
rootClientId
|
|
1356
|
-
);
|
|
1222
|
+
const rootClientId = select.getBlockRootClientId( clientId );
|
|
1223
|
+
const isLocked = select.getTemplateLock( rootClientId );
|
|
1357
1224
|
if ( isLocked ) {
|
|
1358
1225
|
return;
|
|
1359
1226
|
}
|
|
1360
1227
|
|
|
1361
|
-
const firstSelectedIndex =
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1228
|
+
const firstSelectedIndex = select.getBlockIndex( clientId, rootClientId );
|
|
1229
|
+
return dispatch.insertDefaultBlock(
|
|
1230
|
+
{},
|
|
1231
|
+
rootClientId,
|
|
1232
|
+
firstSelectedIndex + 1
|
|
1366
1233
|
);
|
|
1367
|
-
|
|
1368
|
-
}
|
|
1234
|
+
};
|
|
1369
1235
|
|
|
1370
1236
|
/**
|
|
1371
|
-
*
|
|
1237
|
+
* Action that toggles the highlighted block state.
|
|
1372
1238
|
*
|
|
1373
1239
|
* @param {string} clientId The block's clientId.
|
|
1374
1240
|
* @param {boolean} isHighlighted The highlight state.
|
|
@@ -1382,22 +1248,18 @@ export function toggleBlockHighlight( clientId, isHighlighted ) {
|
|
|
1382
1248
|
}
|
|
1383
1249
|
|
|
1384
1250
|
/**
|
|
1385
|
-
*
|
|
1386
|
-
* given clientId should appear to "flash" by rhythmically highlighting it.
|
|
1251
|
+
* Action that "flashes" the block with a given `clientId` by rhythmically highlighting it.
|
|
1387
1252
|
*
|
|
1388
1253
|
* @param {string} clientId Target block client ID.
|
|
1389
1254
|
*/
|
|
1390
|
-
export
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
};
|
|
1396
|
-
yield toggleBlockHighlight( clientId, false );
|
|
1397
|
-
}
|
|
1255
|
+
export const flashBlock = ( clientId ) => async ( { dispatch } ) => {
|
|
1256
|
+
dispatch( toggleBlockHighlight( clientId, true ) );
|
|
1257
|
+
await new Promise( ( resolve ) => setTimeout( resolve, 150 ) );
|
|
1258
|
+
dispatch( toggleBlockHighlight( clientId, false ) );
|
|
1259
|
+
};
|
|
1398
1260
|
|
|
1399
1261
|
/**
|
|
1400
|
-
*
|
|
1262
|
+
* Action that sets whether a block has controlled inner blocks.
|
|
1401
1263
|
*
|
|
1402
1264
|
* @param {string} clientId The block's clientId.
|
|
1403
1265
|
* @param {boolean} hasControlledInnerBlocks True if the block's inner blocks are controlled.
|