@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/build/store/actions.js
CHANGED
|
@@ -5,32 +5,21 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.resetBlocks = resetBlocks;
|
|
9
|
-
exports.validateBlocksToTemplate = validateBlocksToTemplate;
|
|
10
8
|
exports.resetSelection = resetSelection;
|
|
11
9
|
exports.receiveBlocks = receiveBlocks;
|
|
12
10
|
exports.updateBlockAttributes = updateBlockAttributes;
|
|
13
11
|
exports.updateBlock = updateBlock;
|
|
14
12
|
exports.selectBlock = selectBlock;
|
|
15
|
-
exports.selectPreviousBlock = selectPreviousBlock;
|
|
16
|
-
exports.selectNextBlock = selectNextBlock;
|
|
17
13
|
exports.startMultiSelect = startMultiSelect;
|
|
18
14
|
exports.stopMultiSelect = stopMultiSelect;
|
|
19
|
-
exports.multiSelect = multiSelect;
|
|
20
15
|
exports.clearSelectedBlock = clearSelectedBlock;
|
|
21
16
|
exports.toggleSelection = toggleSelection;
|
|
22
|
-
exports.replaceBlocks = replaceBlocks;
|
|
23
17
|
exports.replaceBlock = replaceBlock;
|
|
24
|
-
exports.moveBlocksToPosition = moveBlocksToPosition;
|
|
25
18
|
exports.moveBlockToPosition = moveBlockToPosition;
|
|
26
19
|
exports.insertBlock = insertBlock;
|
|
27
|
-
exports.insertBlocks = insertBlocks;
|
|
28
20
|
exports.showInsertionPoint = showInsertionPoint;
|
|
29
21
|
exports.hideInsertionPoint = hideInsertionPoint;
|
|
30
22
|
exports.setTemplateValidity = setTemplateValidity;
|
|
31
|
-
exports.synchronizeTemplate = synchronizeTemplate;
|
|
32
|
-
exports.mergeBlocks = mergeBlocks;
|
|
33
|
-
exports.removeBlocks = removeBlocks;
|
|
34
23
|
exports.removeBlock = removeBlock;
|
|
35
24
|
exports.replaceInnerBlocks = replaceInnerBlocks;
|
|
36
25
|
exports.toggleBlockMode = toggleBlockMode;
|
|
@@ -47,17 +36,9 @@ exports.updateSettings = updateSettings;
|
|
|
47
36
|
exports.__unstableSaveReusableBlock = __unstableSaveReusableBlock;
|
|
48
37
|
exports.__unstableMarkLastChangeAsPersistent = __unstableMarkLastChangeAsPersistent;
|
|
49
38
|
exports.__unstableMarkNextChangeAsNotPersistent = __unstableMarkNextChangeAsNotPersistent;
|
|
50
|
-
exports.__unstableMarkAutomaticChange = __unstableMarkAutomaticChange;
|
|
51
|
-
exports.__unstableMarkAutomaticChangeFinal = __unstableMarkAutomaticChangeFinal;
|
|
52
|
-
exports.setNavigationMode = setNavigationMode;
|
|
53
|
-
exports.setBlockMovingClientId = setBlockMovingClientId;
|
|
54
|
-
exports.duplicateBlocks = duplicateBlocks;
|
|
55
|
-
exports.insertBeforeBlock = insertBeforeBlock;
|
|
56
|
-
exports.insertAfterBlock = insertAfterBlock;
|
|
57
39
|
exports.toggleBlockHighlight = toggleBlockHighlight;
|
|
58
|
-
exports.flashBlock = flashBlock;
|
|
59
40
|
exports.setHasControlledInnerBlocks = setHasControlledInnerBlocks;
|
|
60
|
-
exports.moveBlocksUp = exports.moveBlocksDown = void 0;
|
|
41
|
+
exports.flashBlock = exports.insertAfterBlock = exports.insertBeforeBlock = exports.duplicateBlocks = exports.setBlockMovingClientId = exports.setNavigationMode = exports.__unstableMarkAutomaticChange = exports.removeBlocks = exports.mergeBlocks = exports.synchronizeTemplate = exports.insertBlocks = exports.moveBlocksToPosition = exports.moveBlocksUp = exports.moveBlocksDown = exports.replaceBlocks = exports.multiSelect = exports.selectNextBlock = exports.selectPreviousBlock = exports.validateBlocksToTemplate = exports.resetBlocks = void 0;
|
|
61
42
|
|
|
62
43
|
var _lodash = require("lodash");
|
|
63
44
|
|
|
@@ -67,16 +48,10 @@ var _a11y = require("@wordpress/a11y");
|
|
|
67
48
|
|
|
68
49
|
var _i18n = require("@wordpress/i18n");
|
|
69
50
|
|
|
70
|
-
var _data = require("@wordpress/data");
|
|
71
|
-
|
|
72
51
|
var _richText = require("@wordpress/rich-text");
|
|
73
52
|
|
|
74
53
|
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
|
|
75
54
|
|
|
76
|
-
var _controls = require("../store/controls");
|
|
77
|
-
|
|
78
|
-
var _constants = require("./constants");
|
|
79
|
-
|
|
80
55
|
/**
|
|
81
56
|
* External dependencies
|
|
82
57
|
*/
|
|
@@ -86,49 +61,53 @@ var _constants = require("./constants");
|
|
|
86
61
|
*/
|
|
87
62
|
|
|
88
63
|
/**
|
|
89
|
-
*
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Generator which will yield a default block insert action if there
|
|
94
|
-
* are no other blocks at the root of the editor. This generator should be used
|
|
64
|
+
* Action which will insert a default block insert action if there
|
|
65
|
+
* are no other blocks at the root of the editor. This action should be used
|
|
95
66
|
* in actions which may result in no blocks remaining in the editor (removal,
|
|
96
67
|
* replacement, etc).
|
|
97
68
|
*/
|
|
98
|
-
|
|
99
|
-
|
|
69
|
+
const ensureDefaultBlock = () => ({
|
|
70
|
+
select,
|
|
71
|
+
dispatch
|
|
72
|
+
}) => {
|
|
73
|
+
// To avoid a focus loss when removing the last block, assure there is
|
|
100
74
|
// always a default block if the last of the blocks have been removed.
|
|
75
|
+
const count = select.getBlockCount();
|
|
101
76
|
|
|
102
|
-
if (count
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
// prevent it from being lost though.
|
|
77
|
+
if (count > 0) {
|
|
78
|
+
return;
|
|
79
|
+
} // If there's an custom appender, don't insert default block.
|
|
80
|
+
// We have to remember to manually move the focus elsewhere to
|
|
81
|
+
// prevent it from being lost though.
|
|
108
82
|
|
|
109
|
-
if (__unstableHasCustomAppender) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
83
|
|
|
113
|
-
|
|
84
|
+
const {
|
|
85
|
+
__unstableHasCustomAppender
|
|
86
|
+
} = select.getSettings();
|
|
87
|
+
|
|
88
|
+
if (__unstableHasCustomAppender) {
|
|
89
|
+
return;
|
|
114
90
|
}
|
|
115
|
-
|
|
91
|
+
|
|
92
|
+
dispatch.insertDefaultBlock();
|
|
93
|
+
};
|
|
116
94
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* content reflected as an edit in state.
|
|
95
|
+
* Action that resets blocks state to the specified array of blocks, taking precedence
|
|
96
|
+
* over any other content reflected as an edit in state.
|
|
120
97
|
*
|
|
121
98
|
* @param {Array} blocks Array of blocks.
|
|
122
99
|
*/
|
|
123
100
|
|
|
124
101
|
|
|
125
|
-
|
|
126
|
-
|
|
102
|
+
const resetBlocks = blocks => ({
|
|
103
|
+
dispatch
|
|
104
|
+
}) => {
|
|
105
|
+
dispatch({
|
|
127
106
|
type: 'RESET_BLOCKS',
|
|
128
107
|
blocks
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
}
|
|
108
|
+
});
|
|
109
|
+
dispatch(validateBlocksToTemplate(blocks));
|
|
110
|
+
};
|
|
132
111
|
/**
|
|
133
112
|
* Block validity is a function of blocks state (at the point of a
|
|
134
113
|
* reset) and the template setting. As a compromise to its placement
|
|
@@ -139,20 +118,25 @@ function* resetBlocks(blocks) {
|
|
|
139
118
|
*/
|
|
140
119
|
|
|
141
120
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
121
|
+
exports.resetBlocks = resetBlocks;
|
|
122
|
+
|
|
123
|
+
const validateBlocksToTemplate = blocks => ({
|
|
124
|
+
select,
|
|
125
|
+
dispatch
|
|
126
|
+
}) => {
|
|
127
|
+
const template = select.getTemplate();
|
|
128
|
+
const templateLock = select.getTemplateLock(); // Unlocked templates are considered always valid because they act
|
|
145
129
|
// as default values only.
|
|
146
130
|
|
|
147
131
|
const isBlocksValidToTemplate = !template || templateLock !== 'all' || (0, _blocks.doBlocksMatchTemplate)(blocks, template); // Update if validity has changed.
|
|
148
132
|
|
|
149
|
-
const isValidTemplate =
|
|
133
|
+
const isValidTemplate = select.isValidTemplate();
|
|
150
134
|
|
|
151
135
|
if (isBlocksValidToTemplate !== isValidTemplate) {
|
|
152
|
-
|
|
136
|
+
dispatch.setTemplateValidity(isBlocksValidToTemplate);
|
|
153
137
|
return isBlocksValidToTemplate;
|
|
154
138
|
}
|
|
155
|
-
}
|
|
139
|
+
};
|
|
156
140
|
/**
|
|
157
141
|
* A block selection object.
|
|
158
142
|
*
|
|
@@ -164,6 +148,8 @@ function* validateBlocksToTemplate(blocks) {
|
|
|
164
148
|
* text value. See `wp.richText.create`.
|
|
165
149
|
*/
|
|
166
150
|
|
|
151
|
+
/* eslint-disable jsdoc/valid-types */
|
|
152
|
+
|
|
167
153
|
/**
|
|
168
154
|
* Returns an action object used in signalling that selection state should be
|
|
169
155
|
* reset to the specified selection.
|
|
@@ -176,7 +162,10 @@ function* validateBlocksToTemplate(blocks) {
|
|
|
176
162
|
*/
|
|
177
163
|
|
|
178
164
|
|
|
165
|
+
exports.validateBlocksToTemplate = validateBlocksToTemplate;
|
|
166
|
+
|
|
179
167
|
function resetSelection(selectionStart, selectionEnd, initialPosition) {
|
|
168
|
+
/* eslint-enable jsdoc/valid-types */
|
|
180
169
|
return {
|
|
181
170
|
type: 'RESET_SELECTION',
|
|
182
171
|
selectionStart,
|
|
@@ -208,8 +197,7 @@ function receiveBlocks(blocks) {
|
|
|
208
197
|
};
|
|
209
198
|
}
|
|
210
199
|
/**
|
|
211
|
-
*
|
|
212
|
-
* attributes with the specified client IDs have been updated.
|
|
200
|
+
* Action that updates attributes of multiple blocks with the specified client IDs.
|
|
213
201
|
*
|
|
214
202
|
* @param {string|string[]} clientIds Block client IDs.
|
|
215
203
|
* @param {Object} attributes Block attributes to be merged. Should be keyed by clientIds if
|
|
@@ -228,8 +216,7 @@ function updateBlockAttributes(clientIds, attributes, uniqueByBlock = false) {
|
|
|
228
216
|
};
|
|
229
217
|
}
|
|
230
218
|
/**
|
|
231
|
-
*
|
|
232
|
-
* specified client ID has been updated.
|
|
219
|
+
* Action that updates the block with the specified client ID.
|
|
233
220
|
*
|
|
234
221
|
* @param {string} clientId Block client ID.
|
|
235
222
|
* @param {Object} updates Block attributes to be merged.
|
|
@@ -245,6 +232,8 @@ function updateBlock(clientId, updates) {
|
|
|
245
232
|
updates
|
|
246
233
|
};
|
|
247
234
|
}
|
|
235
|
+
/* eslint-disable jsdoc/valid-types */
|
|
236
|
+
|
|
248
237
|
/**
|
|
249
238
|
* Returns an action object used in signalling that the block with the
|
|
250
239
|
* specified client ID has been selected, optionally accepting a position
|
|
@@ -260,6 +249,7 @@ function updateBlock(clientId, updates) {
|
|
|
260
249
|
|
|
261
250
|
|
|
262
251
|
function selectBlock(clientId, initialPosition = 0) {
|
|
252
|
+
/* eslint-enable jsdoc/valid-types */
|
|
263
253
|
return {
|
|
264
254
|
type: 'SELECT_BLOCK',
|
|
265
255
|
initialPosition,
|
|
@@ -274,14 +264,16 @@ function selectBlock(clientId, initialPosition = 0) {
|
|
|
274
264
|
*/
|
|
275
265
|
|
|
276
266
|
|
|
277
|
-
|
|
278
|
-
|
|
267
|
+
const selectPreviousBlock = clientId => ({
|
|
268
|
+
select,
|
|
269
|
+
dispatch
|
|
270
|
+
}) => {
|
|
271
|
+
const previousBlockClientId = select.getPreviousBlockClientId(clientId);
|
|
279
272
|
|
|
280
273
|
if (previousBlockClientId) {
|
|
281
|
-
|
|
282
|
-
return [previousBlockClientId];
|
|
274
|
+
dispatch.selectBlock(previousBlockClientId, -1);
|
|
283
275
|
}
|
|
284
|
-
}
|
|
276
|
+
};
|
|
285
277
|
/**
|
|
286
278
|
* Yields action objects used in signalling that the block following the given
|
|
287
279
|
* clientId should be selected.
|
|
@@ -290,28 +282,34 @@ function* selectPreviousBlock(clientId) {
|
|
|
290
282
|
*/
|
|
291
283
|
|
|
292
284
|
|
|
293
|
-
|
|
294
|
-
|
|
285
|
+
exports.selectPreviousBlock = selectPreviousBlock;
|
|
286
|
+
|
|
287
|
+
const selectNextBlock = clientId => ({
|
|
288
|
+
select,
|
|
289
|
+
dispatch
|
|
290
|
+
}) => {
|
|
291
|
+
const nextBlockClientId = select.getNextBlockClientId(clientId);
|
|
295
292
|
|
|
296
293
|
if (nextBlockClientId) {
|
|
297
|
-
|
|
298
|
-
return [nextBlockClientId];
|
|
294
|
+
dispatch.selectBlock(nextBlockClientId);
|
|
299
295
|
}
|
|
300
|
-
}
|
|
296
|
+
};
|
|
301
297
|
/**
|
|
302
|
-
*
|
|
298
|
+
* Action that starts block multi-selection.
|
|
303
299
|
*
|
|
304
300
|
* @return {Object} Action object.
|
|
305
301
|
*/
|
|
306
302
|
|
|
307
303
|
|
|
304
|
+
exports.selectNextBlock = selectNextBlock;
|
|
305
|
+
|
|
308
306
|
function startMultiSelect() {
|
|
309
307
|
return {
|
|
310
308
|
type: 'START_MULTI_SELECT'
|
|
311
309
|
};
|
|
312
310
|
}
|
|
313
311
|
/**
|
|
314
|
-
*
|
|
312
|
+
* Action that stops block multi-selection.
|
|
315
313
|
*
|
|
316
314
|
* @return {Object} Action object.
|
|
317
315
|
*/
|
|
@@ -323,45 +321,50 @@ function stopMultiSelect() {
|
|
|
323
321
|
};
|
|
324
322
|
}
|
|
325
323
|
/**
|
|
326
|
-
*
|
|
324
|
+
* Action that changes block multi-selection.
|
|
327
325
|
*
|
|
328
326
|
* @param {string} start First block of the multi selection.
|
|
329
327
|
* @param {string} end Last block of the multiselection.
|
|
330
328
|
*/
|
|
331
329
|
|
|
332
330
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
331
|
+
const multiSelect = (start, end) => ({
|
|
332
|
+
select,
|
|
333
|
+
dispatch
|
|
334
|
+
}) => {
|
|
335
|
+
const startBlockRootClientId = select.getBlockRootClientId(start);
|
|
336
|
+
const endBlockRootClientId = select.getBlockRootClientId(end); // Only allow block multi-selections at the same level.
|
|
336
337
|
|
|
337
338
|
if (startBlockRootClientId !== endBlockRootClientId) {
|
|
338
339
|
return;
|
|
339
340
|
}
|
|
340
341
|
|
|
341
|
-
|
|
342
|
+
dispatch({
|
|
342
343
|
type: 'MULTI_SELECT',
|
|
343
344
|
start,
|
|
344
345
|
end
|
|
345
|
-
};
|
|
346
|
-
const blockCount =
|
|
346
|
+
});
|
|
347
|
+
const blockCount = select.getSelectedBlockCount();
|
|
347
348
|
(0, _a11y.speak)((0, _i18n.sprintf)(
|
|
348
349
|
/* translators: %s: number of selected blocks */
|
|
349
350
|
(0, _i18n._n)('%s block selected.', '%s blocks selected.', blockCount), blockCount), 'assertive');
|
|
350
|
-
}
|
|
351
|
+
};
|
|
351
352
|
/**
|
|
352
|
-
*
|
|
353
|
+
* Action that clears the block selection.
|
|
353
354
|
*
|
|
354
355
|
* @return {Object} Action object.
|
|
355
356
|
*/
|
|
356
357
|
|
|
357
358
|
|
|
359
|
+
exports.multiSelect = multiSelect;
|
|
360
|
+
|
|
358
361
|
function clearSelectedBlock() {
|
|
359
362
|
return {
|
|
360
363
|
type: 'CLEAR_SELECTED_BLOCK'
|
|
361
364
|
};
|
|
362
365
|
}
|
|
363
366
|
/**
|
|
364
|
-
*
|
|
367
|
+
* Action that enables or disables block selection.
|
|
365
368
|
*
|
|
366
369
|
* @param {boolean} [isSelectionEnabled=true] Whether block selection should
|
|
367
370
|
* be enabled.
|
|
@@ -411,9 +414,10 @@ function getBlocksWithDefaultStylesApplied(blocks, blockEditorSettings) {
|
|
|
411
414
|
};
|
|
412
415
|
});
|
|
413
416
|
}
|
|
417
|
+
/* eslint-disable jsdoc/valid-types */
|
|
418
|
+
|
|
414
419
|
/**
|
|
415
|
-
*
|
|
416
|
-
* one or more replacement blocks.
|
|
420
|
+
* Action that replaces given blocks with one or more replacement blocks.
|
|
417
421
|
*
|
|
418
422
|
* @param {(string|string[])} clientIds Block client ID(s) to replace.
|
|
419
423
|
* @param {(Object|Object[])} blocks Replacement block(s).
|
|
@@ -421,25 +425,29 @@ function getBlocksWithDefaultStylesApplied(blocks, blockEditorSettings) {
|
|
|
421
425
|
* @param {0|-1|null} initialPosition Index of caret after in the selected block after the operation.
|
|
422
426
|
* @param {?Object} meta Optional Meta values to be passed to the action object.
|
|
423
427
|
*
|
|
424
|
-
* @
|
|
428
|
+
* @return {Object} Action object.
|
|
425
429
|
*/
|
|
426
430
|
|
|
427
431
|
|
|
428
|
-
|
|
432
|
+
const replaceBlocks = (clientIds, blocks, indexToSelect, initialPosition = 0, meta) => ({
|
|
433
|
+
select,
|
|
434
|
+
dispatch
|
|
435
|
+
}) => {
|
|
436
|
+
/* eslint-enable jsdoc/valid-types */
|
|
429
437
|
clientIds = (0, _lodash.castArray)(clientIds);
|
|
430
|
-
blocks = getBlocksWithDefaultStylesApplied((0, _lodash.castArray)(blocks),
|
|
431
|
-
const rootClientId =
|
|
438
|
+
blocks = getBlocksWithDefaultStylesApplied((0, _lodash.castArray)(blocks), select.getSettings());
|
|
439
|
+
const rootClientId = select.getBlockRootClientId((0, _lodash.first)(clientIds)); // Replace is valid if the new blocks can be inserted in the root block.
|
|
432
440
|
|
|
433
441
|
for (let index = 0; index < blocks.length; index++) {
|
|
434
442
|
const block = blocks[index];
|
|
435
|
-
const canInsertBlock =
|
|
443
|
+
const canInsertBlock = select.canInsertBlockType(block.name, rootClientId);
|
|
436
444
|
|
|
437
445
|
if (!canInsertBlock) {
|
|
438
446
|
return;
|
|
439
447
|
}
|
|
440
448
|
}
|
|
441
449
|
|
|
442
|
-
|
|
450
|
+
dispatch({
|
|
443
451
|
type: 'REPLACE_BLOCKS',
|
|
444
452
|
clientIds,
|
|
445
453
|
blocks,
|
|
@@ -447,12 +455,11 @@ function* replaceBlocks(clientIds, blocks, indexToSelect, initialPosition = 0, m
|
|
|
447
455
|
indexToSelect,
|
|
448
456
|
initialPosition,
|
|
449
457
|
meta
|
|
450
|
-
};
|
|
451
|
-
|
|
452
|
-
}
|
|
458
|
+
});
|
|
459
|
+
dispatch(ensureDefaultBlock());
|
|
460
|
+
};
|
|
453
461
|
/**
|
|
454
|
-
*
|
|
455
|
-
* with one or more replacement blocks.
|
|
462
|
+
* Action that replaces a single block with one or more replacement blocks.
|
|
456
463
|
*
|
|
457
464
|
* @param {(string|string[])} clientId Block client ID to replace.
|
|
458
465
|
* @param {(Object|Object[])} block Replacement block(s).
|
|
@@ -461,6 +468,8 @@ function* replaceBlocks(clientIds, blocks, indexToSelect, initialPosition = 0, m
|
|
|
461
468
|
*/
|
|
462
469
|
|
|
463
470
|
|
|
471
|
+
exports.replaceBlocks = replaceBlocks;
|
|
472
|
+
|
|
464
473
|
function replaceBlock(clientId, block) {
|
|
465
474
|
return replaceBlocks(clientId, block);
|
|
466
475
|
}
|
|
@@ -474,86 +483,89 @@ function replaceBlock(clientId, block) {
|
|
|
474
483
|
*/
|
|
475
484
|
|
|
476
485
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
+
const createOnMove = type => (clientIds, rootClientId) => ({
|
|
487
|
+
select,
|
|
488
|
+
dispatch
|
|
489
|
+
}) => {
|
|
490
|
+
// If one of the blocks is locked or the parent is locked, we cannot move any block.
|
|
491
|
+
const canMoveBlocks = select.canMoveBlocks(clientIds, rootClientId);
|
|
492
|
+
|
|
493
|
+
if (!canMoveBlocks) {
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
dispatch({
|
|
498
|
+
type,
|
|
499
|
+
clientIds: (0, _lodash.castArray)(clientIds),
|
|
500
|
+
rootClientId
|
|
501
|
+
});
|
|
502
|
+
};
|
|
486
503
|
|
|
487
504
|
const moveBlocksDown = createOnMove('MOVE_BLOCKS_DOWN');
|
|
488
505
|
exports.moveBlocksDown = moveBlocksDown;
|
|
489
506
|
const moveBlocksUp = createOnMove('MOVE_BLOCKS_UP');
|
|
490
507
|
/**
|
|
491
|
-
*
|
|
492
|
-
* a new position.
|
|
508
|
+
* Action that moves given blocks to a new position.
|
|
493
509
|
*
|
|
494
510
|
* @param {?string} clientIds The client IDs of the blocks.
|
|
495
511
|
* @param {?string} fromRootClientId Root client ID source.
|
|
496
512
|
* @param {?string} toRootClientId Root client ID destination.
|
|
497
513
|
* @param {number} index The index to move the blocks to.
|
|
498
|
-
*
|
|
499
|
-
* @yield {Object} Action object.
|
|
500
514
|
*/
|
|
501
515
|
|
|
502
516
|
exports.moveBlocksUp = moveBlocksUp;
|
|
503
517
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
518
|
+
const moveBlocksToPosition = (clientIds, fromRootClientId = '', toRootClientId = '', index) => ({
|
|
519
|
+
select,
|
|
520
|
+
dispatch
|
|
521
|
+
}) => {
|
|
522
|
+
const canMoveBlocks = select.canMoveBlocks(clientIds, fromRootClientId); // If one of the blocks is locked or the parent is locked, we cannot move any block.
|
|
507
523
|
|
|
508
|
-
if (
|
|
524
|
+
if (!canMoveBlocks) {
|
|
509
525
|
return;
|
|
526
|
+
} // If moving inside the same root block the move is always possible.
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
if (fromRootClientId !== toRootClientId) {
|
|
530
|
+
const canRemoveBlocks = select.canRemoveBlocks(clientIds, fromRootClientId); // If we're moving to another block, it means we're deleting blocks from
|
|
531
|
+
// the original block, so we need to check if removing is possible.
|
|
532
|
+
|
|
533
|
+
if (!canRemoveBlocks) {
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
const canInsertBlocks = select.canInsertBlocks(clientIds, toRootClientId); // 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.
|
|
538
|
+
|
|
539
|
+
if (!canInsertBlocks) {
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
510
542
|
}
|
|
511
543
|
|
|
512
|
-
|
|
544
|
+
dispatch({
|
|
513
545
|
type: 'MOVE_BLOCKS_TO_POSITION',
|
|
514
546
|
fromRootClientId,
|
|
515
547
|
toRootClientId,
|
|
516
548
|
clientIds,
|
|
517
549
|
index
|
|
518
|
-
};
|
|
519
|
-
|
|
520
|
-
if (fromRootClientId === toRootClientId) {
|
|
521
|
-
yield action;
|
|
522
|
-
return;
|
|
523
|
-
} // If templateLock is insert we can not remove the block from the parent.
|
|
524
|
-
// Given that here we know that we are moving the block to a different
|
|
525
|
-
// parent, the move should not be possible if the condition is true.
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
if (templateLock === 'insert') {
|
|
529
|
-
return;
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
const canInsertBlocks = yield _data.controls.select(_constants.STORE_NAME, 'canInsertBlocks', clientIds, toRootClientId); // 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.
|
|
533
|
-
|
|
534
|
-
if (canInsertBlocks) {
|
|
535
|
-
yield action;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
550
|
+
});
|
|
551
|
+
};
|
|
538
552
|
/**
|
|
539
|
-
*
|
|
540
|
-
* new position.
|
|
553
|
+
* Action that moves given block to a new position.
|
|
541
554
|
*
|
|
542
555
|
* @param {?string} clientId The client ID of the block.
|
|
543
556
|
* @param {?string} fromRootClientId Root client ID source.
|
|
544
557
|
* @param {?string} toRootClientId Root client ID destination.
|
|
545
558
|
* @param {number} index The index to move the block to.
|
|
546
|
-
*
|
|
547
|
-
* @yield {Object} Action object.
|
|
548
559
|
*/
|
|
549
560
|
|
|
550
561
|
|
|
551
|
-
|
|
552
|
-
|
|
562
|
+
exports.moveBlocksToPosition = moveBlocksToPosition;
|
|
563
|
+
|
|
564
|
+
function moveBlockToPosition(clientId, fromRootClientId = '', toRootClientId = '', index) {
|
|
565
|
+
return moveBlocksToPosition([clientId], fromRootClientId, toRootClientId, index);
|
|
553
566
|
}
|
|
554
567
|
/**
|
|
555
|
-
*
|
|
556
|
-
* inserted, optionally at a specific index respective a root block list.
|
|
568
|
+
* Action that inserts a single block, optionally at a specific index respective a root block list.
|
|
557
569
|
*
|
|
558
570
|
* @param {Object} block Block object to insert.
|
|
559
571
|
* @param {?number} index Index at which block should be inserted.
|
|
@@ -565,12 +577,13 @@ function* moveBlockToPosition(clientId, fromRootClientId = '', toRootClientId =
|
|
|
565
577
|
*/
|
|
566
578
|
|
|
567
579
|
|
|
568
|
-
function insertBlock(block, index, rootClientId, updateSelection
|
|
580
|
+
function insertBlock(block, index, rootClientId, updateSelection, meta) {
|
|
569
581
|
return insertBlocks([block], index, rootClientId, updateSelection, 0, meta);
|
|
570
582
|
}
|
|
583
|
+
/* eslint-disable jsdoc/valid-types */
|
|
584
|
+
|
|
571
585
|
/**
|
|
572
|
-
*
|
|
573
|
-
* be inserted, optionally at a specific index respective a root block list.
|
|
586
|
+
* Action that inserts an array of blocks, optionally at a specific index respective a root block list.
|
|
574
587
|
*
|
|
575
588
|
* @param {Object[]} blocks Block objects to insert.
|
|
576
589
|
* @param {?number} index Index at which block should be inserted.
|
|
@@ -582,7 +595,11 @@ function insertBlock(block, index, rootClientId, updateSelection = true, meta) {
|
|
|
582
595
|
*/
|
|
583
596
|
|
|
584
597
|
|
|
585
|
-
|
|
598
|
+
const insertBlocks = (blocks, index, rootClientId, updateSelection = true, initialPosition = 0, meta) => ({
|
|
599
|
+
select,
|
|
600
|
+
dispatch
|
|
601
|
+
}) => {
|
|
602
|
+
/* eslint-enable jsdoc/valid-types */
|
|
586
603
|
if ((0, _lodash.isObject)(initialPosition)) {
|
|
587
604
|
meta = initialPosition;
|
|
588
605
|
initialPosition = 0;
|
|
@@ -593,11 +610,11 @@ function* insertBlocks(blocks, index, rootClientId, updateSelection = true, init
|
|
|
593
610
|
});
|
|
594
611
|
}
|
|
595
612
|
|
|
596
|
-
blocks = getBlocksWithDefaultStylesApplied((0, _lodash.castArray)(blocks),
|
|
613
|
+
blocks = getBlocksWithDefaultStylesApplied((0, _lodash.castArray)(blocks), select.getSettings());
|
|
597
614
|
const allowedBlocks = [];
|
|
598
615
|
|
|
599
616
|
for (const block of blocks) {
|
|
600
|
-
const isValid =
|
|
617
|
+
const isValid = select.canInsertBlockType(block.name, rootClientId);
|
|
601
618
|
|
|
602
619
|
if (isValid) {
|
|
603
620
|
allowedBlocks.push(block);
|
|
@@ -605,7 +622,7 @@ function* insertBlocks(blocks, index, rootClientId, updateSelection = true, init
|
|
|
605
622
|
}
|
|
606
623
|
|
|
607
624
|
if (allowedBlocks.length) {
|
|
608
|
-
|
|
625
|
+
dispatch({
|
|
609
626
|
type: 'INSERT_BLOCKS',
|
|
610
627
|
blocks: allowedBlocks,
|
|
611
628
|
index,
|
|
@@ -614,12 +631,11 @@ function* insertBlocks(blocks, index, rootClientId, updateSelection = true, init
|
|
|
614
631
|
updateSelection,
|
|
615
632
|
initialPosition: updateSelection ? initialPosition : null,
|
|
616
633
|
meta
|
|
617
|
-
};
|
|
634
|
+
});
|
|
618
635
|
}
|
|
619
|
-
}
|
|
636
|
+
};
|
|
620
637
|
/**
|
|
621
|
-
*
|
|
622
|
-
* be shown.
|
|
638
|
+
* Action that shows the insertion point.
|
|
623
639
|
*
|
|
624
640
|
* @param {?string} rootClientId Optional root client ID of block list on
|
|
625
641
|
* which to insert.
|
|
@@ -630,6 +646,8 @@ function* insertBlocks(blocks, index, rootClientId, updateSelection = true, init
|
|
|
630
646
|
*/
|
|
631
647
|
|
|
632
648
|
|
|
649
|
+
exports.insertBlocks = insertBlocks;
|
|
650
|
+
|
|
633
651
|
function showInsertionPoint(rootClientId, index, __unstableOptions = {}) {
|
|
634
652
|
const {
|
|
635
653
|
__unstableWithInserter
|
|
@@ -642,7 +660,7 @@ function showInsertionPoint(rootClientId, index, __unstableOptions = {}) {
|
|
|
642
660
|
};
|
|
643
661
|
}
|
|
644
662
|
/**
|
|
645
|
-
*
|
|
663
|
+
* Action that hides the insertion point.
|
|
646
664
|
*
|
|
647
665
|
* @return {Object} Action object.
|
|
648
666
|
*/
|
|
@@ -654,7 +672,7 @@ function hideInsertionPoint() {
|
|
|
654
672
|
};
|
|
655
673
|
}
|
|
656
674
|
/**
|
|
657
|
-
*
|
|
675
|
+
* Action that resets the template validity.
|
|
658
676
|
*
|
|
659
677
|
* @param {boolean} isValid template validity flag.
|
|
660
678
|
*
|
|
@@ -669,51 +687,59 @@ function setTemplateValidity(isValid) {
|
|
|
669
687
|
};
|
|
670
688
|
}
|
|
671
689
|
/**
|
|
672
|
-
*
|
|
690
|
+
* Action that synchronizes the template with the list of blocks.
|
|
673
691
|
*
|
|
674
692
|
* @return {Object} Action object.
|
|
675
693
|
*/
|
|
676
694
|
|
|
677
695
|
|
|
678
|
-
|
|
679
|
-
|
|
696
|
+
const synchronizeTemplate = () => ({
|
|
697
|
+
select,
|
|
698
|
+
dispatch
|
|
699
|
+
}) => {
|
|
700
|
+
dispatch({
|
|
680
701
|
type: 'SYNCHRONIZE_TEMPLATE'
|
|
681
|
-
};
|
|
682
|
-
const blocks =
|
|
683
|
-
const template =
|
|
702
|
+
});
|
|
703
|
+
const blocks = select.getBlocks();
|
|
704
|
+
const template = select.getTemplate();
|
|
684
705
|
const updatedBlockList = (0, _blocks.synchronizeBlocksWithTemplate)(blocks, template);
|
|
685
|
-
|
|
686
|
-
}
|
|
706
|
+
dispatch.resetBlocks(updatedBlockList);
|
|
707
|
+
};
|
|
687
708
|
/**
|
|
688
|
-
*
|
|
709
|
+
* Action that merges two blocks.
|
|
689
710
|
*
|
|
690
711
|
* @param {string} firstBlockClientId Client ID of the first block to merge.
|
|
691
712
|
* @param {string} secondBlockClientId Client ID of the second block to merge.
|
|
692
713
|
*/
|
|
693
714
|
|
|
694
715
|
|
|
695
|
-
|
|
716
|
+
exports.synchronizeTemplate = synchronizeTemplate;
|
|
717
|
+
|
|
718
|
+
const mergeBlocks = (firstBlockClientId, secondBlockClientId) => ({
|
|
719
|
+
select,
|
|
720
|
+
dispatch
|
|
721
|
+
}) => {
|
|
696
722
|
const blocks = [firstBlockClientId, secondBlockClientId];
|
|
697
|
-
|
|
723
|
+
dispatch({
|
|
698
724
|
type: 'MERGE_BLOCKS',
|
|
699
725
|
blocks
|
|
700
|
-
};
|
|
726
|
+
});
|
|
701
727
|
const [clientIdA, clientIdB] = blocks;
|
|
702
|
-
const blockA =
|
|
728
|
+
const blockA = select.getBlock(clientIdA);
|
|
703
729
|
const blockAType = (0, _blocks.getBlockType)(blockA.name); // Only focus the previous block if it's not mergeable
|
|
704
730
|
|
|
705
|
-
if (!blockAType.merge) {
|
|
706
|
-
|
|
731
|
+
if (blockAType && !blockAType.merge) {
|
|
732
|
+
dispatch.selectBlock(blockA.clientId);
|
|
707
733
|
return;
|
|
708
734
|
}
|
|
709
735
|
|
|
710
|
-
const blockB =
|
|
736
|
+
const blockB = select.getBlock(clientIdB);
|
|
711
737
|
const blockBType = (0, _blocks.getBlockType)(blockB.name);
|
|
712
738
|
const {
|
|
713
739
|
clientId,
|
|
714
740
|
attributeKey,
|
|
715
741
|
offset
|
|
716
|
-
} =
|
|
742
|
+
} = select.getSelectionStart();
|
|
717
743
|
const selectedBlockType = clientId === clientIdA ? blockAType : blockBType;
|
|
718
744
|
const attributeDefinition = selectedBlockType.attributes[attributeKey];
|
|
719
745
|
const canRestoreTextSelection = (clientId === clientIdA || clientId === clientIdB) && attributeKey !== undefined && offset !== undefined && // We cannot restore text selection if the RichText identifier
|
|
@@ -791,16 +817,16 @@ function* mergeBlocks(firstBlockClientId, secondBlockClientId) {
|
|
|
791
817
|
preserveWhiteSpace
|
|
792
818
|
});
|
|
793
819
|
updatedAttributes[newAttributeKey] = newHtml;
|
|
794
|
-
|
|
820
|
+
dispatch.selectionChange(blockA.clientId, newAttributeKey, newOffset, newOffset);
|
|
795
821
|
}
|
|
796
822
|
|
|
797
|
-
|
|
823
|
+
dispatch.replaceBlocks([blockA.clientId, blockB.clientId], [{ ...blockA,
|
|
798
824
|
attributes: { ...blockA.attributes,
|
|
799
825
|
...updatedAttributes
|
|
800
826
|
}
|
|
801
827
|
}, ...blocksWithTheSameType.slice(1)], 0 // If we don't pass the `indexToSelect` it will default to the last block.
|
|
802
828
|
);
|
|
803
|
-
}
|
|
829
|
+
};
|
|
804
830
|
/**
|
|
805
831
|
* Yields action objects used in signalling that the blocks corresponding to
|
|
806
832
|
* the set of specified client IDs are to be removed.
|
|
@@ -811,36 +837,36 @@ function* mergeBlocks(firstBlockClientId, secondBlockClientId) {
|
|
|
811
837
|
*/
|
|
812
838
|
|
|
813
839
|
|
|
814
|
-
|
|
840
|
+
exports.mergeBlocks = mergeBlocks;
|
|
841
|
+
|
|
842
|
+
const removeBlocks = (clientIds, selectPrevious = true) => ({
|
|
843
|
+
select,
|
|
844
|
+
dispatch
|
|
845
|
+
}) => {
|
|
815
846
|
if (!clientIds || !clientIds.length) {
|
|
816
847
|
return;
|
|
817
848
|
}
|
|
818
849
|
|
|
819
850
|
clientIds = (0, _lodash.castArray)(clientIds);
|
|
820
|
-
const rootClientId =
|
|
821
|
-
const
|
|
851
|
+
const rootClientId = select.getBlockRootClientId(clientIds[0]);
|
|
852
|
+
const canRemoveBlocks = select.canRemoveBlocks(clientIds, rootClientId);
|
|
822
853
|
|
|
823
|
-
if (
|
|
854
|
+
if (!canRemoveBlocks) {
|
|
824
855
|
return;
|
|
825
856
|
}
|
|
826
857
|
|
|
827
|
-
let previousBlockId;
|
|
828
|
-
|
|
829
858
|
if (selectPrevious) {
|
|
830
|
-
|
|
831
|
-
} else {
|
|
832
|
-
previousBlockId = yield _data.controls.select(_constants.STORE_NAME, 'getPreviousBlockClientId', clientIds[0]);
|
|
859
|
+
dispatch.selectPreviousBlock(clientIds[0]);
|
|
833
860
|
}
|
|
834
861
|
|
|
835
|
-
|
|
862
|
+
dispatch({
|
|
836
863
|
type: 'REMOVE_BLOCKS',
|
|
837
864
|
clientIds
|
|
838
|
-
}; // To avoid a focus loss when removing the last block, assure there is
|
|
865
|
+
}); // To avoid a focus loss when removing the last block, assure there is
|
|
839
866
|
// always a default block if the last of the blocks have been removed.
|
|
840
867
|
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
}
|
|
868
|
+
dispatch(ensureDefaultBlock());
|
|
869
|
+
};
|
|
844
870
|
/**
|
|
845
871
|
* Returns an action object used in signalling that the block with the
|
|
846
872
|
* specified client ID is to be removed.
|
|
@@ -853,9 +879,13 @@ function* removeBlocks(clientIds, selectPrevious = true) {
|
|
|
853
879
|
*/
|
|
854
880
|
|
|
855
881
|
|
|
882
|
+
exports.removeBlocks = removeBlocks;
|
|
883
|
+
|
|
856
884
|
function removeBlock(clientId, selectPrevious) {
|
|
857
885
|
return removeBlocks([clientId], selectPrevious);
|
|
858
886
|
}
|
|
887
|
+
/* eslint-disable jsdoc/valid-types */
|
|
888
|
+
|
|
859
889
|
/**
|
|
860
890
|
* Returns an action object used in signalling that the inner blocks with the
|
|
861
891
|
* specified client ID should be replaced.
|
|
@@ -869,6 +899,7 @@ function removeBlock(clientId, selectPrevious) {
|
|
|
869
899
|
|
|
870
900
|
|
|
871
901
|
function replaceInnerBlocks(rootClientId, blocks, updateSelection = false, initialPosition = 0) {
|
|
902
|
+
/* eslint-enable jsdoc/valid-types */
|
|
872
903
|
return {
|
|
873
904
|
type: 'REPLACE_INNER_BLOCKS',
|
|
874
905
|
rootClientId,
|
|
@@ -970,8 +1001,7 @@ function exitFormattedText() {
|
|
|
970
1001
|
};
|
|
971
1002
|
}
|
|
972
1003
|
/**
|
|
973
|
-
*
|
|
974
|
-
* position.
|
|
1004
|
+
* Action that changes the position of the user caret.
|
|
975
1005
|
*
|
|
976
1006
|
* @param {string} clientId The selected block client ID.
|
|
977
1007
|
* @param {string} attributeKey The selected block attribute key.
|
|
@@ -992,8 +1022,7 @@ function selectionChange(clientId, attributeKey, startOffset, endOffset) {
|
|
|
992
1022
|
};
|
|
993
1023
|
}
|
|
994
1024
|
/**
|
|
995
|
-
*
|
|
996
|
-
* type should be added to the block list.
|
|
1025
|
+
* Action that adds a new block of the default type to the block list.
|
|
997
1026
|
*
|
|
998
1027
|
* @param {?Object} attributes Optional attributes of the block to assign.
|
|
999
1028
|
* @param {?string} rootClientId Optional root client ID of block list on which
|
|
@@ -1016,7 +1045,7 @@ function insertDefaultBlock(attributes, rootClientId, index) {
|
|
|
1016
1045
|
return insertBlock(block, index, rootClientId);
|
|
1017
1046
|
}
|
|
1018
1047
|
/**
|
|
1019
|
-
*
|
|
1048
|
+
* Action that changes the nested settings of a given block.
|
|
1020
1049
|
*
|
|
1021
1050
|
* @param {string} clientId Client ID of the block whose nested setting are
|
|
1022
1051
|
* being received.
|
|
@@ -1034,7 +1063,7 @@ function updateBlockListSettings(clientId, settings) {
|
|
|
1034
1063
|
};
|
|
1035
1064
|
}
|
|
1036
1065
|
/**
|
|
1037
|
-
*
|
|
1066
|
+
* Action that updates the block editor settings.
|
|
1038
1067
|
*
|
|
1039
1068
|
* @param {Object} settings Updated settings
|
|
1040
1069
|
*
|
|
@@ -1049,7 +1078,7 @@ function updateSettings(settings) {
|
|
|
1049
1078
|
};
|
|
1050
1079
|
}
|
|
1051
1080
|
/**
|
|
1052
|
-
*
|
|
1081
|
+
* Action that signals that a temporary reusable block has been saved
|
|
1053
1082
|
* in order to switch its temporary id with the real id.
|
|
1054
1083
|
*
|
|
1055
1084
|
* @param {string} id Reusable block's id.
|
|
@@ -1067,7 +1096,7 @@ function __unstableSaveReusableBlock(id, updatedId) {
|
|
|
1067
1096
|
};
|
|
1068
1097
|
}
|
|
1069
1098
|
/**
|
|
1070
|
-
*
|
|
1099
|
+
* Action that marks the last block change explicitly as persistent.
|
|
1071
1100
|
*
|
|
1072
1101
|
* @return {Object} Action object.
|
|
1073
1102
|
*/
|
|
@@ -1079,7 +1108,7 @@ function __unstableMarkLastChangeAsPersistent() {
|
|
|
1079
1108
|
};
|
|
1080
1109
|
}
|
|
1081
1110
|
/**
|
|
1082
|
-
*
|
|
1111
|
+
* Action that signals that the next block change should be marked explicitly as not persistent.
|
|
1083
1112
|
*
|
|
1084
1113
|
* @return {Object} Action object.
|
|
1085
1114
|
*/
|
|
@@ -1091,151 +1120,180 @@ function __unstableMarkNextChangeAsNotPersistent() {
|
|
|
1091
1120
|
};
|
|
1092
1121
|
}
|
|
1093
1122
|
/**
|
|
1094
|
-
*
|
|
1095
|
-
*
|
|
1096
|
-
*
|
|
1097
|
-
*
|
|
1098
|
-
* it is recommended to be called at the next idle period to ensure all
|
|
1123
|
+
* Action that marks the last block change as an automatic change, meaning it was not
|
|
1124
|
+
* performed by the user, and can be undone using the `Escape` and `Backspace` keys.
|
|
1125
|
+
* This action must be called after the change was made, and any actions that are a
|
|
1126
|
+
* consequence of it, so it is recommended to be called at the next idle period to ensure all
|
|
1099
1127
|
* selection changes have been recorded.
|
|
1100
1128
|
*/
|
|
1101
1129
|
|
|
1102
1130
|
|
|
1103
|
-
|
|
1104
|
-
|
|
1131
|
+
const __unstableMarkAutomaticChange = () => ({
|
|
1132
|
+
dispatch
|
|
1133
|
+
}) => {
|
|
1134
|
+
dispatch({
|
|
1105
1135
|
type: 'MARK_AUTOMATIC_CHANGE'
|
|
1106
|
-
};
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
}
|
|
1136
|
+
});
|
|
1137
|
+
const {
|
|
1138
|
+
requestIdleCallback = cb => setTimeout(cb, 100)
|
|
1139
|
+
} = window;
|
|
1140
|
+
requestIdleCallback(() => {
|
|
1141
|
+
dispatch({
|
|
1142
|
+
type: 'MARK_AUTOMATIC_CHANGE_FINAL'
|
|
1143
|
+
});
|
|
1144
|
+
});
|
|
1145
|
+
};
|
|
1115
1146
|
/**
|
|
1116
|
-
*
|
|
1147
|
+
* Action that enables or disables the navigation mode.
|
|
1117
1148
|
*
|
|
1118
1149
|
* @param {string} isNavigationMode Enable/Disable navigation mode.
|
|
1119
1150
|
*/
|
|
1120
1151
|
|
|
1121
1152
|
|
|
1122
|
-
|
|
1123
|
-
|
|
1153
|
+
exports.__unstableMarkAutomaticChange = __unstableMarkAutomaticChange;
|
|
1154
|
+
|
|
1155
|
+
const setNavigationMode = (isNavigationMode = true) => ({
|
|
1156
|
+
dispatch
|
|
1157
|
+
}) => {
|
|
1158
|
+
dispatch({
|
|
1124
1159
|
type: 'SET_NAVIGATION_MODE',
|
|
1125
1160
|
isNavigationMode
|
|
1126
|
-
};
|
|
1161
|
+
});
|
|
1127
1162
|
|
|
1128
1163
|
if (isNavigationMode) {
|
|
1129
1164
|
(0, _a11y.speak)((0, _i18n.__)('You are currently in navigation mode. Navigate blocks using the Tab key and Arrow keys. Use Left and Right Arrow keys to move between nesting levels. To exit navigation mode and edit the selected block, press Enter.'));
|
|
1130
1165
|
} else {
|
|
1131
1166
|
(0, _a11y.speak)((0, _i18n.__)('You are currently in edit mode. To return to the navigation mode, press Escape.'));
|
|
1132
1167
|
}
|
|
1133
|
-
}
|
|
1168
|
+
};
|
|
1134
1169
|
/**
|
|
1135
|
-
*
|
|
1170
|
+
* Action that enables or disables the block moving mode.
|
|
1136
1171
|
*
|
|
1137
1172
|
* @param {string|null} hasBlockMovingClientId Enable/Disable block moving mode.
|
|
1138
1173
|
*/
|
|
1139
1174
|
|
|
1140
1175
|
|
|
1141
|
-
|
|
1142
|
-
|
|
1176
|
+
exports.setNavigationMode = setNavigationMode;
|
|
1177
|
+
|
|
1178
|
+
const setBlockMovingClientId = (hasBlockMovingClientId = null) => ({
|
|
1179
|
+
dispatch
|
|
1180
|
+
}) => {
|
|
1181
|
+
dispatch({
|
|
1143
1182
|
type: 'SET_BLOCK_MOVING_MODE',
|
|
1144
1183
|
hasBlockMovingClientId
|
|
1145
|
-
};
|
|
1184
|
+
});
|
|
1146
1185
|
|
|
1147
1186
|
if (hasBlockMovingClientId) {
|
|
1148
1187
|
(0, _a11y.speak)((0, _i18n.__)('Use the Tab key and Arrow keys to choose new block location. Use Left and Right Arrow keys to move between nesting levels. Once location is selected press Enter or Space to move the block.'));
|
|
1149
1188
|
}
|
|
1150
|
-
}
|
|
1189
|
+
};
|
|
1151
1190
|
/**
|
|
1152
|
-
*
|
|
1191
|
+
* Action that duplicates a list of blocks.
|
|
1153
1192
|
*
|
|
1154
1193
|
* @param {string[]} clientIds
|
|
1155
1194
|
* @param {boolean} updateSelection
|
|
1156
1195
|
*/
|
|
1157
1196
|
|
|
1158
1197
|
|
|
1159
|
-
|
|
1160
|
-
|
|
1198
|
+
exports.setBlockMovingClientId = setBlockMovingClientId;
|
|
1199
|
+
|
|
1200
|
+
const duplicateBlocks = (clientIds, updateSelection = true) => ({
|
|
1201
|
+
select,
|
|
1202
|
+
dispatch
|
|
1203
|
+
}) => {
|
|
1204
|
+
if (!clientIds || !clientIds.length) {
|
|
1161
1205
|
return;
|
|
1162
|
-
}
|
|
1206
|
+
} // Return early if blocks don't exist.
|
|
1163
1207
|
|
|
1164
|
-
|
|
1165
|
-
const
|
|
1208
|
+
|
|
1209
|
+
const blocks = select.getBlocksByClientId(clientIds);
|
|
1166
1210
|
|
|
1167
1211
|
if ((0, _lodash.some)(blocks, block => !block)) {
|
|
1168
1212
|
return;
|
|
1169
|
-
}
|
|
1213
|
+
} // Return early if blocks don't support multiple usage.
|
|
1170
1214
|
|
|
1171
|
-
const blockNames = blocks.map(block => block.name); // Return early if blocks don't support multiple usage.
|
|
1172
1215
|
|
|
1173
|
-
|
|
1216
|
+
const blockNames = blocks.map(block => block.name);
|
|
1217
|
+
|
|
1218
|
+
if (blockNames.some(blockName => !(0, _blocks.hasBlockSupport)(blockName, 'multiple', true))) {
|
|
1174
1219
|
return;
|
|
1175
1220
|
}
|
|
1176
1221
|
|
|
1177
|
-
const
|
|
1222
|
+
const rootClientId = select.getBlockRootClientId(clientIds[0]);
|
|
1223
|
+
const lastSelectedIndex = select.getBlockIndex((0, _lodash.last)((0, _lodash.castArray)(clientIds)), rootClientId);
|
|
1178
1224
|
const clonedBlocks = blocks.map(block => (0, _blocks.__experimentalCloneSanitizedBlock)(block));
|
|
1179
|
-
|
|
1225
|
+
dispatch.insertBlocks(clonedBlocks, lastSelectedIndex + 1, rootClientId, updateSelection);
|
|
1180
1226
|
|
|
1181
1227
|
if (clonedBlocks.length > 1 && updateSelection) {
|
|
1182
|
-
|
|
1228
|
+
dispatch.multiSelect((0, _lodash.first)(clonedBlocks).clientId, (0, _lodash.last)(clonedBlocks).clientId);
|
|
1183
1229
|
}
|
|
1184
1230
|
|
|
1185
1231
|
return clonedBlocks.map(block => block.clientId);
|
|
1186
|
-
}
|
|
1232
|
+
};
|
|
1187
1233
|
/**
|
|
1188
|
-
*
|
|
1234
|
+
* Action that inserts an empty block before a given block.
|
|
1189
1235
|
*
|
|
1190
1236
|
* @param {string} clientId
|
|
1191
1237
|
*/
|
|
1192
1238
|
|
|
1193
1239
|
|
|
1194
|
-
|
|
1240
|
+
exports.duplicateBlocks = duplicateBlocks;
|
|
1241
|
+
|
|
1242
|
+
const insertBeforeBlock = clientId => ({
|
|
1243
|
+
select,
|
|
1244
|
+
dispatch
|
|
1245
|
+
}) => {
|
|
1195
1246
|
if (!clientId) {
|
|
1196
1247
|
return;
|
|
1197
1248
|
}
|
|
1198
1249
|
|
|
1199
|
-
const rootClientId =
|
|
1200
|
-
const isLocked =
|
|
1250
|
+
const rootClientId = select.getBlockRootClientId(clientId);
|
|
1251
|
+
const isLocked = select.getTemplateLock(rootClientId);
|
|
1201
1252
|
|
|
1202
1253
|
if (isLocked) {
|
|
1203
1254
|
return;
|
|
1204
1255
|
}
|
|
1205
1256
|
|
|
1206
|
-
const firstSelectedIndex =
|
|
1207
|
-
return
|
|
1208
|
-
}
|
|
1257
|
+
const firstSelectedIndex = select.getBlockIndex(clientId, rootClientId);
|
|
1258
|
+
return dispatch.insertDefaultBlock({}, rootClientId, firstSelectedIndex);
|
|
1259
|
+
};
|
|
1209
1260
|
/**
|
|
1210
|
-
*
|
|
1261
|
+
* Action that inserts an empty block after a given block.
|
|
1211
1262
|
*
|
|
1212
1263
|
* @param {string} clientId
|
|
1213
1264
|
*/
|
|
1214
1265
|
|
|
1215
1266
|
|
|
1216
|
-
|
|
1267
|
+
exports.insertBeforeBlock = insertBeforeBlock;
|
|
1268
|
+
|
|
1269
|
+
const insertAfterBlock = clientId => ({
|
|
1270
|
+
select,
|
|
1271
|
+
dispatch
|
|
1272
|
+
}) => {
|
|
1217
1273
|
if (!clientId) {
|
|
1218
1274
|
return;
|
|
1219
1275
|
}
|
|
1220
1276
|
|
|
1221
|
-
const rootClientId =
|
|
1222
|
-
const isLocked =
|
|
1277
|
+
const rootClientId = select.getBlockRootClientId(clientId);
|
|
1278
|
+
const isLocked = select.getTemplateLock(rootClientId);
|
|
1223
1279
|
|
|
1224
1280
|
if (isLocked) {
|
|
1225
1281
|
return;
|
|
1226
1282
|
}
|
|
1227
1283
|
|
|
1228
|
-
const firstSelectedIndex =
|
|
1229
|
-
return
|
|
1230
|
-
}
|
|
1284
|
+
const firstSelectedIndex = select.getBlockIndex(clientId, rootClientId);
|
|
1285
|
+
return dispatch.insertDefaultBlock({}, rootClientId, firstSelectedIndex + 1);
|
|
1286
|
+
};
|
|
1231
1287
|
/**
|
|
1232
|
-
*
|
|
1288
|
+
* Action that toggles the highlighted block state.
|
|
1233
1289
|
*
|
|
1234
1290
|
* @param {string} clientId The block's clientId.
|
|
1235
1291
|
* @param {boolean} isHighlighted The highlight state.
|
|
1236
1292
|
*/
|
|
1237
1293
|
|
|
1238
1294
|
|
|
1295
|
+
exports.insertAfterBlock = insertAfterBlock;
|
|
1296
|
+
|
|
1239
1297
|
function toggleBlockHighlight(clientId, isHighlighted) {
|
|
1240
1298
|
return {
|
|
1241
1299
|
type: 'TOGGLE_BLOCK_HIGHLIGHT',
|
|
@@ -1244,29 +1302,29 @@ function toggleBlockHighlight(clientId, isHighlighted) {
|
|
|
1244
1302
|
};
|
|
1245
1303
|
}
|
|
1246
1304
|
/**
|
|
1247
|
-
*
|
|
1248
|
-
* given clientId should appear to "flash" by rhythmically highlighting it.
|
|
1305
|
+
* Action that "flashes" the block with a given `clientId` by rhythmically highlighting it.
|
|
1249
1306
|
*
|
|
1250
1307
|
* @param {string} clientId Target block client ID.
|
|
1251
1308
|
*/
|
|
1252
1309
|
|
|
1253
1310
|
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
}
|
|
1311
|
+
const flashBlock = clientId => async ({
|
|
1312
|
+
dispatch
|
|
1313
|
+
}) => {
|
|
1314
|
+
dispatch(toggleBlockHighlight(clientId, true));
|
|
1315
|
+
await new Promise(resolve => setTimeout(resolve, 150));
|
|
1316
|
+
dispatch(toggleBlockHighlight(clientId, false));
|
|
1317
|
+
};
|
|
1262
1318
|
/**
|
|
1263
|
-
*
|
|
1319
|
+
* Action that sets whether a block has controlled inner blocks.
|
|
1264
1320
|
*
|
|
1265
1321
|
* @param {string} clientId The block's clientId.
|
|
1266
1322
|
* @param {boolean} hasControlledInnerBlocks True if the block's inner blocks are controlled.
|
|
1267
1323
|
*/
|
|
1268
1324
|
|
|
1269
1325
|
|
|
1326
|
+
exports.flashBlock = flashBlock;
|
|
1327
|
+
|
|
1270
1328
|
function setHasControlledInnerBlocks(clientId, hasControlledInnerBlocks) {
|
|
1271
1329
|
return {
|
|
1272
1330
|
type: 'SET_HAS_CONTROLLED_INNER_BLOCKS',
|