@wordpress/block-editor 12.5.0 → 12.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +2 -6
- package/build/autocompleters/block.js +6 -2
- package/build/autocompleters/block.js.map +1 -1
- package/build/components/block-draggable/index.js +6 -3
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-draggable/index.native.js +2 -2
- package/build/components/block-draggable/index.native.js.map +1 -1
- package/build/components/block-edit/edit.js +25 -13
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-editing-mode/index.js +1 -1
- package/build/components/block-editing-mode/index.js.map +1 -1
- package/build/components/block-list/block-outline.native.js +14 -18
- package/build/components/block-list/block-outline.native.js.map +1 -1
- package/build/components/block-list/block.js +4 -2
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +21 -42
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.js +2 -4
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-mover/index.native.js +1 -1
- package/build/components/block-mover/index.native.js.map +1 -1
- package/build/components/block-parent-selector/index.js +6 -21
- package/build/components/block-parent-selector/index.js.map +1 -1
- package/build/components/block-preview/auto.js +6 -1
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +1 -4
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-settings/button.native.js +2 -2
- package/build/components/block-settings/button.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +3 -17
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +7 -5
- package/build/components/block-toolbar/block-toolbar-menu.native.js.map +1 -0
- package/build/components/block-toolbar/index.js +4 -33
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/index.native.js +62 -3
- package/build/components/block-toolbar/index.native.js.map +1 -1
- package/build/components/block-toolbar/utils.js +56 -51
- package/build/components/block-toolbar/utils.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +4 -2
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-variation-picker/index.native.js +10 -20
- package/build/components/block-variation-picker/index.native.js.map +1 -1
- package/build/components/colors-gradients/control.js +4 -2
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/editor-styles/index.js +2 -2
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +11 -11
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/global-styles/behaviors-panel.js +66 -0
- package/build/components/global-styles/behaviors-panel.js.map +1 -0
- package/build/components/global-styles/color-panel.js +21 -15
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +13 -2
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/get-block-css-selector.js +4 -8
- package/build/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build/components/global-styles/hooks.js +131 -27
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +20 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +18 -3
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/typography-utils.js +4 -4
- package/build/components/global-styles/typography-utils.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +12 -18
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +7 -7
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/iframe/index.js +36 -48
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/iframe/use-compatibility-styles.js +5 -0
- package/build/components/iframe/use-compatibility-styles.js.map +1 -1
- package/build/components/index.js +1 -10
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +3 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +3 -1
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +33 -7
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js +6 -2
- package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build/components/inserter/hooks/use-debounced-input.js +5 -7
- package/build/components/inserter/hooks/use-debounced-input.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-state.js +3 -2
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter/index.js +2 -4
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/index.native.js +21 -32
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/reusable-block-rename-hint.js +23 -3
- package/build/components/inserter/reusable-block-rename-hint.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.js +3 -2
- package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build/components/inserter-list-item/index.js +1 -1
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/link-control/index.js +51 -7
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/link-preview.js +3 -3
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-item.js +1 -1
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +2 -2
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +6 -1
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/media-placeholder/index.native.js +65 -31
- package/build/components/media-placeholder/index.native.js.map +1 -1
- package/build/components/media-replace-flow/index.native.js +15 -3
- package/build/components/media-replace-flow/index.native.js.map +1 -1
- package/build/components/preview-options/index.js +2 -2
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/rich-text/content.js +0 -36
- package/build/components/rich-text/content.js.map +1 -1
- package/build/components/rich-text/format-edit.js +57 -28
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/rich-text/get-rich-text-values.js +111 -0
- package/build/components/rich-text/get-rich-text-values.js.map +1 -0
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/axial.js +6 -2
- package/build/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/separated.js +5 -1
- package/build/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/single.js +5 -1
- package/build/components/spacing-sizes-control/input-controls/single.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +2 -2
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/use-block-display-information/index.js +7 -3
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.native.js +49 -8
- package/build/components/use-block-drop-zone/index.native.js.map +1 -1
- package/build/components/use-setting/index.js +5 -9
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/behaviors.js +5 -12
- package/build/hooks/behaviors.js.map +1 -1
- package/build/hooks/border.js +2 -1
- package/build/hooks/border.js.map +1 -1
- 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 +11 -2
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/utils.js +1 -7
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +10 -3
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +3 -4
- package/build/store/actions.js.map +1 -1
- package/build/store/private-selectors.js +5 -6
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +0 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +23 -79
- package/build/store/selectors.js.map +1 -1
- package/build/utils/object.js +38 -2
- package/build/utils/object.js.map +1 -1
- package/build-module/autocompleters/block.js +7 -3
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/components/block-draggable/index.js +6 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-draggable/index.native.js +2 -2
- package/build-module/components/block-draggable/index.native.js.map +1 -1
- package/build-module/components/block-edit/edit.js +27 -10
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-editing-mode/index.js +1 -1
- package/build-module/components/block-editing-mode/index.js.map +1 -1
- package/build-module/components/block-list/block-outline.native.js +14 -18
- package/build-module/components/block-list/block-outline.native.js.map +1 -1
- package/build-module/components/block-list/block.js +4 -2
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +24 -43
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.js +2 -3
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-mover/index.native.js +3 -3
- package/build-module/components/block-mover/index.native.js.map +1 -1
- package/build-module/components/block-parent-selector/index.js +7 -22
- package/build-module/components/block-parent-selector/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +6 -1
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +1 -4
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-settings/button.native.js +3 -3
- package/build-module/components/block-settings/button.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +4 -18
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +9 -7
- package/build-module/components/block-toolbar/block-toolbar-menu.native.js.map +1 -0
- package/build-module/components/block-toolbar/index.js +6 -35
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.native.js +60 -4
- package/build-module/components/block-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-toolbar/utils.js +54 -49
- package/build-module/components/block-toolbar/utils.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +4 -2
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-variation-picker/index.native.js +13 -23
- package/build-module/components/block-variation-picker/index.native.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +3 -2
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/editor-styles/index.js +2 -2
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +11 -11
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/global-styles/behaviors-panel.js +57 -0
- package/build-module/components/global-styles/behaviors-panel.js.map +1 -0
- package/build-module/components/global-styles/color-panel.js +21 -15
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +13 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/get-block-css-selector.js +4 -8
- package/build-module/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +127 -27
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +2 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +18 -3
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-utils.js +4 -4
- package/build-module/components/global-styles/typography-utils.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +13 -18
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +6 -6
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/iframe/index.js +37 -49
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/iframe/use-compatibility-styles.js +5 -0
- package/build-module/components/iframe/use-compatibility-styles.js.map +1 -1
- package/build-module/components/index.js +0 -5
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +3 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +3 -1
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +30 -7
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js +7 -3
- package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build-module/components/inserter/hooks/use-debounced-input.js +5 -7
- package/build-module/components/inserter/hooks/use-debounced-input.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js +3 -2
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter/index.js +2 -4
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +22 -33
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/reusable-block-rename-hint.js +22 -3
- package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.js +3 -2
- package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +1 -1
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/link-control/index.js +49 -7
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +3 -3
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-item.js +1 -1
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +2 -2
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +6 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/media-placeholder/index.native.js +66 -33
- package/build-module/components/media-placeholder/index.native.js.map +1 -1
- package/build-module/components/media-replace-flow/index.native.js +15 -3
- package/build-module/components/media-replace-flow/index.native.js.map +1 -1
- package/build-module/components/preview-options/index.js +2 -2
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/rich-text/content.js +1 -36
- package/build-module/components/rich-text/content.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +51 -26
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/rich-text/get-rich-text-values.js +100 -0
- package/build-module/components/rich-text/get-rich-text-values.js.map +1 -0
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/axial.js +7 -3
- package/build-module/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/separated.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/single.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls/single.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +2 -2
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +7 -3
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.native.js +50 -8
- package/build-module/components/use-block-drop-zone/index.native.js.map +1 -1
- package/build-module/components/use-setting/index.js +5 -9
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/behaviors.js +5 -12
- package/build-module/hooks/behaviors.js.map +1 -1
- package/build-module/hooks/border.js +2 -1
- package/build-module/hooks/border.js.map +1 -1
- 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 +11 -2
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/utils.js +2 -7
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +7 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +4 -5
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-selectors.js +3 -3
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +0 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +20 -75
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/object.js +34 -2
- package/build-module/utils/object.js.map +1 -1
- package/build-style/content-rtl.css +2 -1
- package/build-style/content.css +2 -1
- package/build-style/style-rtl.css +25 -6
- package/build-style/style.css +25 -6
- package/package.json +32 -32
- package/src/autocompleters/block.js +21 -6
- package/src/components/block-controls/README.md +89 -0
- package/src/components/block-draggable/index.js +13 -4
- package/src/components/block-draggable/index.native.js +7 -3
- package/src/components/block-draggable/test/index.native.js +2 -57
- package/src/components/block-edit/edit.js +26 -9
- package/src/components/block-edit/test/edit.js +1 -1
- package/src/components/block-editing-mode/index.js +1 -1
- package/src/components/block-list/block-outline.native.js +26 -25
- package/src/components/block-list/block.js +6 -1
- package/src/components/block-list/block.native.js +24 -38
- package/src/components/block-list/block.native.scss +18 -40
- package/src/components/block-list/index.js +3 -6
- package/src/components/block-list/style.native.scss +3 -3
- package/src/components/block-list/test/block-invalid-warning.native.js +8 -1
- package/src/components/block-mover/index.native.js +3 -3
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +40 -6
- package/src/components/block-parent-selector/index.js +30 -42
- package/src/components/block-preview/auto.js +8 -1
- package/src/components/block-preview/style.scss +2 -1
- package/src/components/block-removal-warning-modal/index.js +0 -3
- package/src/components/block-settings/button.native.js +12 -6
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -13
- package/src/components/{block-mobile-toolbar/block-actions-menu.native.js → block-toolbar/block-toolbar-menu.native.js} +15 -10
- package/src/components/block-toolbar/index.js +36 -64
- package/src/components/block-toolbar/index.native.js +86 -6
- package/src/components/{block-mobile-toolbar/test/block-actions-menu.native.js → block-toolbar/test/block-toolbar-menu.native.js} +20 -54
- package/src/components/block-toolbar/test/index.native.js +42 -0
- package/src/components/block-toolbar/utils.js +57 -45
- package/src/components/block-tools/block-contextual-toolbar.js +43 -35
- package/src/components/block-tools/style.scss +17 -5
- package/src/components/block-variation-picker/index.native.js +52 -72
- package/src/components/button-block-appender/styles.native.scss +2 -2
- package/src/components/caption/README.md +49 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/colors-gradients/control.js +3 -2
- package/src/components/editor-styles/index.js +2 -2
- package/src/components/font-sizes/fluid-utils.js +17 -17
- package/src/components/font-sizes/test/fluid-utils.js +6 -6
- package/src/components/global-styles/behaviors-panel.js +71 -0
- package/src/components/global-styles/color-panel.js +23 -16
- package/src/components/global-styles/dimensions-panel.js +8 -2
- package/src/components/global-styles/get-block-css-selector.js +5 -9
- package/src/components/global-styles/hooks.js +134 -31
- package/src/components/global-styles/index.js +3 -0
- package/src/components/global-styles/test/typography-utils.js +6 -6
- package/src/components/global-styles/typography-panel.js +17 -5
- package/src/components/global-styles/typography-utils.js +4 -4
- package/src/components/global-styles/use-global-styles-output.js +36 -18
- package/src/components/global-styles/utils.js +17 -7
- package/src/components/iframe/index.js +30 -56
- package/src/components/iframe/use-compatibility-styles.js +5 -0
- package/src/components/index.js +0 -5
- package/src/components/inner-blocks/README.md +10 -0
- package/src/components/inner-blocks/index.js +4 -0
- package/src/components/inner-blocks/index.native.js +4 -0
- package/src/components/inner-blocks/use-nested-settings-update.js +32 -5
- package/src/components/inserter/hooks/use-block-types-state.js +15 -6
- package/src/components/inserter/hooks/use-debounced-input.js +8 -7
- package/src/components/inserter/hooks/use-patterns-state.js +2 -1
- package/src/components/inserter/index.js +2 -3
- package/src/components/inserter/index.native.js +17 -36
- package/src/components/inserter/reusable-block-rename-hint.js +18 -1
- package/src/components/inserter/reusable-blocks-tab.js +4 -1
- package/src/components/inserter/style.native.scss +10 -15
- package/src/components/inserter-list-item/index.js +3 -1
- package/src/components/link-control/README.md +12 -3
- package/src/components/link-control/index.js +47 -7
- package/src/components/link-control/link-preview.js +6 -4
- package/src/components/link-control/search-item.js +1 -1
- package/src/components/link-control/style.scss +11 -3
- package/src/components/link-control/test/index.js +28 -1
- package/src/components/list-view/use-list-view-client-ids.js +2 -2
- package/src/components/list-view/use-list-view-drop-zone.js +5 -1
- package/src/components/media-placeholder/index.native.js +108 -59
- package/src/components/media-placeholder/styles.native.scss +59 -24
- package/src/components/media-replace-flow/index.native.js +12 -3
- package/src/components/media-upload/test/index.native.js +1 -0
- package/src/components/preview-options/README.md +18 -17
- package/src/components/preview-options/index.js +2 -2
- package/src/components/rich-text/content.js +1 -46
- package/src/components/rich-text/format-edit.js +62 -38
- package/src/components/rich-text/get-rich-text-values.js +99 -0
- package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/src/components/spacing-sizes-control/input-controls/axial.js +17 -2
- package/src/components/spacing-sizes-control/input-controls/separated.js +17 -2
- package/src/components/spacing-sizes-control/input-controls/single.js +12 -2
- package/src/components/spacing-sizes-control/test/utils.js +9 -1
- package/src/components/spacing-sizes-control/utils.js +2 -2
- package/src/components/text-transform-control/README.md +44 -0
- package/src/components/use-block-display-information/index.js +12 -5
- package/src/components/use-block-drop-zone/index.native.js +65 -28
- package/src/components/use-setting/index.js +8 -8
- package/src/hooks/behaviors.js +10 -16
- package/src/hooks/border.js +2 -1
- package/src/hooks/margin.js +4 -1
- package/src/hooks/padding.js +4 -1
- package/src/hooks/style.js +7 -3
- package/src/hooks/utils.js +5 -7
- package/src/private-apis.js +9 -1
- package/src/store/actions.js +23 -30
- package/src/store/private-selectors.js +3 -6
- package/src/store/reducer.js +0 -1
- package/src/store/selectors.js +36 -85
- package/src/store/test/actions.js +3 -0
- package/src/store/test/private-selectors.js +5 -5
- package/src/store/test/reducer.js +14 -7
- package/src/store/test/selectors.js +8 -7
- package/src/utils/object.js +32 -2
- package/src/utils/test/object.js +36 -0
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +0 -1
- package/build/components/block-mobile-toolbar/index.native.js +0 -135
- package/build/components/block-mobile-toolbar/index.native.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +0 -116
- package/build-module/components/block-mobile-toolbar/index.native.js.map +0 -1
- package/src/components/block-mobile-toolbar/index.native.js +0 -127
- package/src/components/block-mobile-toolbar/style.native.scss +0 -16
- /package/src/components/{block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap → block-toolbar/test/__snapshots__/block-toolbar-menu.native.js.snap} +0 -0
|
@@ -28,23 +28,24 @@ const MyPreviewOptions = () => (
|
|
|
28
28
|
className="edit-post-post-preview-dropdown"
|
|
29
29
|
deviceType={ deviceType }
|
|
30
30
|
setDeviceType={ setPreviewDeviceType }
|
|
31
|
-
>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
31
|
+
> { ( { onClose } ) => (
|
|
32
|
+
<MenuGroup>
|
|
33
|
+
<div className="edit-post-header-preview__grouping-external">
|
|
34
|
+
<PostPreviewButton
|
|
35
|
+
className="edit-post-header-preview__button-external"
|
|
36
|
+
role="menuitem"
|
|
37
|
+
forceIsAutosaveable={ hasActiveMetaboxes }
|
|
38
|
+
textContent={
|
|
39
|
+
<>
|
|
40
|
+
{ __( 'Preview in new tab' ) }
|
|
41
|
+
<Icon icon={ external } />
|
|
42
|
+
</>
|
|
43
|
+
}
|
|
44
|
+
onPreview={ onClose }
|
|
45
|
+
/>
|
|
46
|
+
</div>
|
|
47
|
+
</MenuGroup>
|
|
48
|
+
) }
|
|
48
49
|
</PreviewOptions>
|
|
49
50
|
);
|
|
50
51
|
```
|
|
@@ -54,7 +54,7 @@ export default function PreviewOptions( {
|
|
|
54
54
|
icon={ deviceIcons[ deviceType.toLowerCase() ] }
|
|
55
55
|
label={ label || __( 'Preview' ) }
|
|
56
56
|
>
|
|
57
|
-
{ () => (
|
|
57
|
+
{ ( renderProps ) => (
|
|
58
58
|
<>
|
|
59
59
|
<MenuGroup>
|
|
60
60
|
<MenuItem
|
|
@@ -79,7 +79,7 @@ export default function PreviewOptions( {
|
|
|
79
79
|
{ __( 'Mobile' ) }
|
|
80
80
|
</MenuItem>
|
|
81
81
|
</MenuGroup>
|
|
82
|
-
{ children }
|
|
82
|
+
{ children( renderProps ) }
|
|
83
83
|
</>
|
|
84
84
|
) }
|
|
85
85
|
</DropdownMenu>
|
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { RawHTML } from '@wordpress/element';
|
|
5
|
-
import {
|
|
6
|
-
children as childrenSource,
|
|
7
|
-
getSaveElement,
|
|
8
|
-
__unstableGetBlockProps as getBlockProps,
|
|
9
|
-
} from '@wordpress/blocks';
|
|
5
|
+
import { children as childrenSource } from '@wordpress/blocks';
|
|
10
6
|
import deprecated from '@wordpress/deprecated';
|
|
11
7
|
|
|
12
8
|
/**
|
|
@@ -42,44 +38,3 @@ export const Content = ( { value, tagName: Tag, multiline, ...props } ) => {
|
|
|
42
38
|
|
|
43
39
|
return content;
|
|
44
40
|
};
|
|
45
|
-
|
|
46
|
-
Content.__unstableIsRichTextContent = {};
|
|
47
|
-
|
|
48
|
-
function findContent( blocks, richTextValues = [] ) {
|
|
49
|
-
if ( ! Array.isArray( blocks ) ) {
|
|
50
|
-
blocks = [ blocks ];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
for ( const block of blocks ) {
|
|
54
|
-
if (
|
|
55
|
-
block?.type?.__unstableIsRichTextContent ===
|
|
56
|
-
Content.__unstableIsRichTextContent
|
|
57
|
-
) {
|
|
58
|
-
richTextValues.push( block.props.value );
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if ( block?.props?.children ) {
|
|
63
|
-
findContent( block.props.children, richTextValues );
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return richTextValues;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function _getSaveElement( { name, attributes, innerBlocks } ) {
|
|
71
|
-
return getSaveElement(
|
|
72
|
-
name,
|
|
73
|
-
attributes,
|
|
74
|
-
innerBlocks.map( _getSaveElement )
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function getRichTextValues( blocks = [] ) {
|
|
79
|
-
getBlockProps.skipFilters = true;
|
|
80
|
-
const values = findContent(
|
|
81
|
-
( Array.isArray( blocks ) ? blocks : [ blocks ] ).map( _getSaveElement )
|
|
82
|
-
);
|
|
83
|
-
getBlockProps.skipFilters = false;
|
|
84
|
-
return values;
|
|
85
|
-
}
|
|
@@ -2,43 +2,67 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { getActiveFormat, getActiveObject } from '@wordpress/rich-text';
|
|
5
|
+
import { useContext, useMemo } from '@wordpress/element';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import BlockContext from '../block-context';
|
|
11
|
+
|
|
12
|
+
const DEFAULT_BLOCK_CONTEXT = {};
|
|
13
|
+
|
|
14
|
+
export const usesContextKey = Symbol( 'usesContext' );
|
|
15
|
+
|
|
16
|
+
function Edit( { onChange, onFocus, value, forwardedRef, settings } ) {
|
|
17
|
+
const {
|
|
18
|
+
name,
|
|
19
|
+
edit: EditFunction,
|
|
20
|
+
[ usesContextKey ]: usesContext,
|
|
21
|
+
} = settings;
|
|
22
|
+
|
|
23
|
+
const blockContext = useContext( BlockContext );
|
|
24
|
+
|
|
25
|
+
// Assign context values using the block type's declared context needs.
|
|
26
|
+
const context = useMemo( () => {
|
|
27
|
+
return usesContext
|
|
28
|
+
? Object.fromEntries(
|
|
29
|
+
Object.entries( blockContext ).filter( ( [ key ] ) =>
|
|
30
|
+
usesContext.includes( key )
|
|
31
|
+
)
|
|
32
|
+
)
|
|
33
|
+
: DEFAULT_BLOCK_CONTEXT;
|
|
34
|
+
}, [ usesContext, blockContext ] );
|
|
35
|
+
|
|
36
|
+
if ( ! EditFunction ) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const activeFormat = getActiveFormat( value, name );
|
|
41
|
+
const isActive = activeFormat !== undefined;
|
|
42
|
+
const activeObject = getActiveObject( value );
|
|
43
|
+
const isObjectActive =
|
|
44
|
+
activeObject !== undefined && activeObject.type === name;
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<EditFunction
|
|
48
|
+
key={ name }
|
|
49
|
+
isActive={ isActive }
|
|
50
|
+
activeAttributes={ isActive ? activeFormat.attributes || {} : {} }
|
|
51
|
+
isObjectActive={ isObjectActive }
|
|
52
|
+
activeObjectAttributes={
|
|
53
|
+
isObjectActive ? activeObject.attributes || {} : {}
|
|
54
|
+
}
|
|
55
|
+
value={ value }
|
|
56
|
+
onChange={ onChange }
|
|
57
|
+
onFocus={ onFocus }
|
|
58
|
+
contentRef={ forwardedRef }
|
|
59
|
+
context={ context }
|
|
60
|
+
/>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default function FormatEdit( { formatTypes, ...props } ) {
|
|
65
|
+
return formatTypes.map( ( settings ) => (
|
|
66
|
+
<Edit settings={ settings } { ...props } key={ settings.name } />
|
|
67
|
+
) );
|
|
44
68
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { RawHTML, StrictMode, Fragment } from '@wordpress/element';
|
|
5
|
+
import {
|
|
6
|
+
getSaveElement,
|
|
7
|
+
__unstableGetBlockProps as getBlockProps,
|
|
8
|
+
} from '@wordpress/blocks';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import InnerBlocks from '../inner-blocks';
|
|
14
|
+
import { Content } from './content';
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* This function is similar to `@wordpress/element`'s `renderToString` function,
|
|
18
|
+
* except that it does not render the elements to a string, but instead collects
|
|
19
|
+
* the values of all rich text `Content` elements.
|
|
20
|
+
*/
|
|
21
|
+
function addValuesForElement( element, values, innerBlocks ) {
|
|
22
|
+
if ( null === element || undefined === element || false === element ) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if ( Array.isArray( element ) ) {
|
|
27
|
+
return addValuesForElements( element, values, innerBlocks );
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
switch ( typeof element ) {
|
|
31
|
+
case 'string':
|
|
32
|
+
case 'number':
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const { type, props } = element;
|
|
37
|
+
|
|
38
|
+
switch ( type ) {
|
|
39
|
+
case StrictMode:
|
|
40
|
+
case Fragment:
|
|
41
|
+
return addValuesForElements( props.children, values, innerBlocks );
|
|
42
|
+
case RawHTML:
|
|
43
|
+
return;
|
|
44
|
+
case InnerBlocks.Content:
|
|
45
|
+
return addValuesForBlocks( values, innerBlocks );
|
|
46
|
+
case Content:
|
|
47
|
+
values.push( props.value );
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
switch ( typeof type ) {
|
|
52
|
+
case 'string':
|
|
53
|
+
if ( typeof props.children !== 'undefined' ) {
|
|
54
|
+
return addValuesForElements(
|
|
55
|
+
props.children,
|
|
56
|
+
values,
|
|
57
|
+
innerBlocks
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
return;
|
|
61
|
+
case 'function':
|
|
62
|
+
const el =
|
|
63
|
+
type.prototype && typeof type.prototype.render === 'function'
|
|
64
|
+
? new type( props ).render()
|
|
65
|
+
: type( props );
|
|
66
|
+
return addValuesForElement( el, values, innerBlocks );
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function addValuesForElements( children, ...args ) {
|
|
71
|
+
children = Array.isArray( children ) ? children : [ children ];
|
|
72
|
+
|
|
73
|
+
for ( let i = 0; i < children.length; i++ ) {
|
|
74
|
+
addValuesForElement( children[ i ], ...args );
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function addValuesForBlocks( values, blocks ) {
|
|
79
|
+
for ( let i = 0; i < blocks.length; i++ ) {
|
|
80
|
+
const { name, attributes, innerBlocks } = blocks[ i ];
|
|
81
|
+
const saveElement = getSaveElement(
|
|
82
|
+
name,
|
|
83
|
+
attributes,
|
|
84
|
+
// Instead of letting save elements use `useInnerBlocksProps.save`,
|
|
85
|
+
// force them to use InnerBlocks.Content instead so we can intercept
|
|
86
|
+
// a single component.
|
|
87
|
+
<InnerBlocks.Content />
|
|
88
|
+
);
|
|
89
|
+
addValuesForElement( saveElement, values, innerBlocks );
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function getRichTextValues( blocks = [] ) {
|
|
94
|
+
getBlockProps.skipFilters = true;
|
|
95
|
+
const values = [];
|
|
96
|
+
addValuesForBlocks( values, blocks );
|
|
97
|
+
getBlockProps.skipFilters = false;
|
|
98
|
+
return values;
|
|
99
|
+
}
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import SpacingInputControl from './spacing-input-control';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
LABELS,
|
|
7
|
+
ICONS,
|
|
8
|
+
getPresetValueFromCustomValue,
|
|
9
|
+
hasAxisSupport,
|
|
10
|
+
} from '../utils';
|
|
6
11
|
|
|
7
12
|
const groupedSides = [ 'vertical', 'horizontal' ];
|
|
8
13
|
|
|
@@ -20,7 +25,17 @@ export default function AxialInputControls( {
|
|
|
20
25
|
if ( ! onChange ) {
|
|
21
26
|
return;
|
|
22
27
|
}
|
|
23
|
-
|
|
28
|
+
|
|
29
|
+
// Encode the existing value into the preset value if the passed in value matches the value of one of the spacingSizes.
|
|
30
|
+
const nextValues = {
|
|
31
|
+
...Object.keys( values ).reduce( ( acc, key ) => {
|
|
32
|
+
acc[ key ] = getPresetValueFromCustomValue(
|
|
33
|
+
values[ key ],
|
|
34
|
+
spacingSizes
|
|
35
|
+
);
|
|
36
|
+
return acc;
|
|
37
|
+
}, {} ),
|
|
38
|
+
};
|
|
24
39
|
|
|
25
40
|
if ( side === 'vertical' ) {
|
|
26
41
|
nextValues.top = next;
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import SpacingInputControl from './spacing-input-control';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ALL_SIDES,
|
|
7
|
+
LABELS,
|
|
8
|
+
ICONS,
|
|
9
|
+
getPresetValueFromCustomValue,
|
|
10
|
+
} from '../utils';
|
|
6
11
|
|
|
7
12
|
export default function SeparatedInputControls( {
|
|
8
13
|
minimumCustomValue,
|
|
@@ -20,7 +25,17 @@ export default function SeparatedInputControls( {
|
|
|
20
25
|
: ALL_SIDES;
|
|
21
26
|
|
|
22
27
|
const createHandleOnChange = ( side ) => ( next ) => {
|
|
23
|
-
|
|
28
|
+
// Encode the existing value into the preset value if the passed in value matches the value of one of the spacingSizes.
|
|
29
|
+
const nextValues = {
|
|
30
|
+
...Object.keys( values ).reduce( ( acc, key ) => {
|
|
31
|
+
acc[ key ] = getPresetValueFromCustomValue(
|
|
32
|
+
values[ key ],
|
|
33
|
+
spacingSizes
|
|
34
|
+
);
|
|
35
|
+
return acc;
|
|
36
|
+
}, {} ),
|
|
37
|
+
};
|
|
38
|
+
|
|
24
39
|
nextValues[ side ] = next;
|
|
25
40
|
|
|
26
41
|
onChange( nextValues );
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import SpacingInputControl from './spacing-input-control';
|
|
5
|
-
import { LABELS } from '../utils';
|
|
5
|
+
import { LABELS, getPresetValueFromCustomValue } from '../utils';
|
|
6
6
|
|
|
7
7
|
export default function SingleInputControl( {
|
|
8
8
|
minimumCustomValue,
|
|
@@ -16,7 +16,17 @@ export default function SingleInputControl( {
|
|
|
16
16
|
values,
|
|
17
17
|
} ) {
|
|
18
18
|
const createHandleOnChange = ( currentSide ) => ( next ) => {
|
|
19
|
-
|
|
19
|
+
// Encode the existing value into the preset value if the passed in value matches the value of one of the spacingSizes.
|
|
20
|
+
const nextValues = {
|
|
21
|
+
...Object.keys( values ).reduce( ( acc, key ) => {
|
|
22
|
+
acc[ key ] = getPresetValueFromCustomValue(
|
|
23
|
+
values[ key ],
|
|
24
|
+
spacingSizes
|
|
25
|
+
);
|
|
26
|
+
return acc;
|
|
27
|
+
}, {} ),
|
|
28
|
+
};
|
|
29
|
+
|
|
20
30
|
nextValues[ currentSide ] = next;
|
|
21
31
|
|
|
22
32
|
onChange( nextValues );
|
|
@@ -49,7 +49,15 @@ describe( 'getCustomValueFromPreset', () => {
|
|
|
49
49
|
} );
|
|
50
50
|
|
|
51
51
|
describe( 'getPresetValueFromCustomValue', () => {
|
|
52
|
-
const spacingSizes = [
|
|
52
|
+
const spacingSizes = [
|
|
53
|
+
{ name: 'Default', slug: 'default', size: undefined },
|
|
54
|
+
{ name: 'Small', slug: 20, size: '8px' },
|
|
55
|
+
];
|
|
56
|
+
it( 'should return undefined even if an undefined value exist in spacing sizes as occurs if spacingSizes has > 7 entries', () => {
|
|
57
|
+
expect( getPresetValueFromCustomValue( undefined, spacingSizes ) ).toBe(
|
|
58
|
+
undefined
|
|
59
|
+
);
|
|
60
|
+
} );
|
|
53
61
|
it( 'should return original value if a string in spacing presets var format', () => {
|
|
54
62
|
expect(
|
|
55
63
|
getPresetValueFromCustomValue(
|
|
@@ -101,8 +101,8 @@ export function getCustomValueFromPreset( value, spacingSizes ) {
|
|
|
101
101
|
* @return {string} The preset value if it can be found.
|
|
102
102
|
*/
|
|
103
103
|
export function getPresetValueFromCustomValue( value, spacingSizes ) {
|
|
104
|
-
// Return value as-is if it is already a preset;
|
|
105
|
-
if ( isValueSpacingPreset( value ) ) {
|
|
104
|
+
// Return value as-is if it is undefined or is already a preset, or '0';
|
|
105
|
+
if ( ! value || isValueSpacingPreset( value ) || value === '0' ) {
|
|
106
106
|
return value;
|
|
107
107
|
}
|
|
108
108
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# TextTransformControl
|
|
2
|
+
|
|
3
|
+
The `TextTransformControl` component is responsible for rendering a control element that allows users to select and apply text transformation options to blocks or elements in the Gutenberg editor. It provides an intuitive interface for changing the text appearance by applying different transformations such as `none`, `uppercase`, `lowercase`, `capitalize`.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Table of contents
|
|
8
|
+
|
|
9
|
+
1. [Development guidelines](#development-guidelines)
|
|
10
|
+
|
|
11
|
+
## Development guidelines
|
|
12
|
+
|
|
13
|
+
### Usage
|
|
14
|
+
|
|
15
|
+
Renders the Text Transform Component with `none`, `uppercase`, `lowercase`, `capitalize` options.
|
|
16
|
+
|
|
17
|
+
```jsx
|
|
18
|
+
import { TextTransformControl } from '@wordpress/block-editor';
|
|
19
|
+
|
|
20
|
+
const MyTextTransformControlComponent = () => (
|
|
21
|
+
<TextTransformControl
|
|
22
|
+
value={ textTransform }
|
|
23
|
+
onChange={ ( value ) => {
|
|
24
|
+
setAttributes( { textTransform: value } );
|
|
25
|
+
} }
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Props
|
|
31
|
+
|
|
32
|
+
### `value`
|
|
33
|
+
|
|
34
|
+
- **Type:** `String`
|
|
35
|
+
- **Default:** `none`
|
|
36
|
+
- **Options:** `none`, `uppercase`, `lowercase`, `capitalize`
|
|
37
|
+
|
|
38
|
+
The current value of the Text Transform setting. You may only choose from the `Options` listed above.
|
|
39
|
+
|
|
40
|
+
### `onChange`
|
|
41
|
+
|
|
42
|
+
- **Type:** `Function`
|
|
43
|
+
|
|
44
|
+
A callback function invoked when the Text Transform value is changed via an interaction with any of the buttons. Called with the Text Transform value (`none`, `uppercase`, `lowercase`, `capitalize`) as the only argument.
|
|
@@ -67,8 +67,11 @@ export default function useBlockDisplayInformation( clientId ) {
|
|
|
67
67
|
return useSelect(
|
|
68
68
|
( select ) => {
|
|
69
69
|
if ( ! clientId ) return null;
|
|
70
|
-
const {
|
|
71
|
-
|
|
70
|
+
const {
|
|
71
|
+
getBlockName,
|
|
72
|
+
getBlockAttributes,
|
|
73
|
+
__experimentalGetReusableBlockTitle,
|
|
74
|
+
} = select( blockEditorStore );
|
|
72
75
|
const { getBlockType, getActiveBlockVariation } =
|
|
73
76
|
select( blocksStore );
|
|
74
77
|
const blockName = getBlockName( clientId );
|
|
@@ -76,12 +79,16 @@ export default function useBlockDisplayInformation( clientId ) {
|
|
|
76
79
|
if ( ! blockType ) return null;
|
|
77
80
|
const attributes = getBlockAttributes( clientId );
|
|
78
81
|
const match = getActiveBlockVariation( blockName, attributes );
|
|
79
|
-
const
|
|
80
|
-
|
|
82
|
+
const isReusable = isReusableBlock( blockType );
|
|
83
|
+
const resusableTitle = isReusable
|
|
84
|
+
? __experimentalGetReusableBlockTitle( attributes.ref )
|
|
85
|
+
: undefined;
|
|
86
|
+
const title = resusableTitle || blockType.title;
|
|
87
|
+
const isSynced = isReusable || isTemplatePart( blockType );
|
|
81
88
|
const positionLabel = getPositionTypeLabel( attributes );
|
|
82
89
|
const blockTypeInfo = {
|
|
83
90
|
isSynced,
|
|
84
|
-
title
|
|
91
|
+
title,
|
|
85
92
|
icon: blockType.icon,
|
|
86
93
|
description: blockType.description,
|
|
87
94
|
anchor: attributes?.anchor,
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
runOnJS,
|
|
6
|
+
useDerivedValue,
|
|
7
|
+
useSharedValue,
|
|
8
|
+
} from 'react-native-reanimated';
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
11
|
* WordPress dependencies
|
|
8
12
|
*/
|
|
9
13
|
import { useSelect } from '@wordpress/data';
|
|
10
14
|
import { useCallback } from '@wordpress/element';
|
|
11
|
-
import { useThrottle } from '@wordpress/compose';
|
|
12
15
|
|
|
13
16
|
/**
|
|
14
17
|
* Internal dependencies
|
|
@@ -18,6 +21,8 @@ import { useBlockListContext } from '../block-list/block-list-context';
|
|
|
18
21
|
import { getDistanceToNearestEdge } from '../../utils/math';
|
|
19
22
|
import useOnBlockDrop from '../use-on-block-drop';
|
|
20
23
|
|
|
24
|
+
const UPDATE_TARGET_BLOCK_INDEX_THRESHOLD = 20; // In pixels
|
|
25
|
+
|
|
21
26
|
/** @typedef {import('../../utils/math').WPPoint} WPPoint */
|
|
22
27
|
|
|
23
28
|
/**
|
|
@@ -111,6 +116,14 @@ export default function useBlockDropZone( {
|
|
|
111
116
|
rootClientId: targetRootClientId = '',
|
|
112
117
|
} = {} ) {
|
|
113
118
|
const targetBlockIndex = useSharedValue( null );
|
|
119
|
+
const dragPosition = {
|
|
120
|
+
x: useSharedValue( 0 ),
|
|
121
|
+
y: useSharedValue( 0 ),
|
|
122
|
+
};
|
|
123
|
+
const prevDragPosition = {
|
|
124
|
+
x: useSharedValue( 0 ),
|
|
125
|
+
y: useSharedValue( 0 ),
|
|
126
|
+
};
|
|
114
127
|
|
|
115
128
|
const { getBlockListSettings, getSettings } = useSelect( blockEditorStore );
|
|
116
129
|
const { blocksLayouts, getBlockLayoutsOrderedByYCoord } =
|
|
@@ -118,43 +131,67 @@ export default function useBlockDropZone( {
|
|
|
118
131
|
|
|
119
132
|
const getSortedBlocksLayouts = useCallback( () => {
|
|
120
133
|
return getBlockLayoutsOrderedByYCoord( blocksLayouts.current );
|
|
134
|
+
// We use the value of `blocksLayouts` as the dependency.
|
|
135
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
121
136
|
}, [ blocksLayouts.current ] );
|
|
122
137
|
|
|
123
138
|
const isRTL = getSettings().isRTL;
|
|
124
139
|
|
|
125
140
|
const onBlockDrop = useOnBlockDrop();
|
|
126
141
|
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
),
|
|
149
|
-
200
|
|
142
|
+
const updateTargetBlockIndex = useCallback(
|
|
143
|
+
( event ) => {
|
|
144
|
+
const sortedBlockLayouts = getSortedBlocksLayouts();
|
|
145
|
+
|
|
146
|
+
const targetIndex = getNearestBlockIndex(
|
|
147
|
+
sortedBlockLayouts,
|
|
148
|
+
{ x: event.x, y: event.y },
|
|
149
|
+
getBlockListSettings( targetRootClientId )?.orientation,
|
|
150
|
+
isRTL
|
|
151
|
+
);
|
|
152
|
+
if ( targetIndex !== null ) {
|
|
153
|
+
targetBlockIndex.value = targetIndex ?? 0;
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
[
|
|
157
|
+
getSortedBlocksLayouts,
|
|
158
|
+
getBlockListSettings,
|
|
159
|
+
targetRootClientId,
|
|
160
|
+
isRTL,
|
|
161
|
+
targetBlockIndex,
|
|
162
|
+
]
|
|
150
163
|
);
|
|
151
164
|
|
|
165
|
+
useDerivedValue( () => {
|
|
166
|
+
const x = dragPosition.x.value;
|
|
167
|
+
const y = dragPosition.y.value;
|
|
168
|
+
const prevX = prevDragPosition.x.value;
|
|
169
|
+
const prevY = prevDragPosition.y.value;
|
|
170
|
+
// `updateTargetBlockIndex` performs expensive calculations, so we throttle
|
|
171
|
+
// the call using a offset threshold based on the dragging position.
|
|
172
|
+
if (
|
|
173
|
+
Math.abs( x - prevX ) >= UPDATE_TARGET_BLOCK_INDEX_THRESHOLD ||
|
|
174
|
+
Math.abs( y - prevY ) >= UPDATE_TARGET_BLOCK_INDEX_THRESHOLD
|
|
175
|
+
) {
|
|
176
|
+
runOnJS( updateTargetBlockIndex )( { x, y } );
|
|
177
|
+
prevDragPosition.x.value = x;
|
|
178
|
+
prevDragPosition.y.value = y;
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
return false;
|
|
182
|
+
} );
|
|
183
|
+
|
|
152
184
|
return {
|
|
153
|
-
onBlockDragOver(
|
|
154
|
-
|
|
185
|
+
onBlockDragOver( { x, y } ) {
|
|
186
|
+
dragPosition.x.value = x;
|
|
187
|
+
dragPosition.y.value = y;
|
|
188
|
+
},
|
|
189
|
+
onBlockDragOverWorklet( { x, y } ) {
|
|
190
|
+
'worklet';
|
|
191
|
+
dragPosition.x.value = x;
|
|
192
|
+
dragPosition.y.value = y;
|
|
155
193
|
},
|
|
156
194
|
onBlockDragEnd() {
|
|
157
|
-
throttled.cancel();
|
|
158
195
|
targetBlockIndex.value = null;
|
|
159
196
|
},
|
|
160
197
|
onBlockDrop: ( event ) => {
|