@wordpress/block-editor 12.15.0 → 12.16.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 +2 -0
- package/README.md +9 -4
- package/build/components/block-canvas/index.js +22 -6
- package/build/components/block-canvas/index.js.map +1 -1
- package/build/components/block-card/index.js +1 -1
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-controls/hook.js +3 -23
- package/build/components/block-controls/hook.js.map +1 -1
- package/build/components/block-edit/context.js +5 -1
- package/build/components/block-edit/context.js.map +1 -1
- package/build/components/block-edit/index.js +18 -9
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-info-slot-fill/index.js +3 -4
- package/build/components/block-info-slot-fill/index.js.map +1 -1
- package/build/components/block-list/block.js +28 -9
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +14 -5
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +61 -18
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js +4 -29
- package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build/components/block-list/use-block-props/use-is-hovered.js +4 -14
- package/build/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js +4 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build/components/block-patterns-list/index.js +1 -1
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +2 -9
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-rename/modal.js +3 -0
- package/build/components/block-rename/modal.js.map +1 -1
- package/build/components/block-settings/container.native.js +6 -4
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-styles/index.js +1 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-styles/index.native.js +3 -2
- package/build/components/block-styles/index.native.js.map +1 -1
- package/build/components/block-toolbar/index.js +89 -27
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-toolbar-breadcrumb.js +49 -0
- package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -0
- package/build/components/block-tools/block-toolbar-popover.js +86 -0
- package/build/components/block-tools/block-toolbar-popover.js.map +1 -0
- package/build/components/block-tools/index.js +27 -24
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-types-list/index.native.js +4 -3
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/block-variation-picker/index.native.js +2 -1
- package/build/components/block-variation-picker/index.native.js.map +1 -1
- package/build/components/colors-gradients/control.js +28 -17
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/duotone-control/index.js +1 -4
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/global-styles/color-panel.js +22 -20
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +9 -3
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +20 -31
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/image-link-destinations/index.native.js +118 -0
- package/build/components/image-link-destinations/index.native.js.map +1 -0
- package/build/components/index.native.js +8 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/media-tab/media-panel.js +2 -2
- package/build/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build/components/inserter/menu.js +14 -7
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/preview-panel.js +2 -2
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inserter-button/index.native.js +98 -0
- package/build/components/inserter-button/index.native.js.map +1 -0
- package/build/components/inserter-button/sparkles.js +23 -0
- package/build/components/inserter-button/sparkles.js.map +1 -0
- package/build/components/inserter-draggable-blocks/index.js +8 -4
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/inspector-controls/fill.js +3 -3
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/inspector-controls/fill.native.js +3 -3
- package/build/components/inspector-controls/fill.native.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +2 -2
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/preview-options/index.js +6 -62
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/rich-text/content.js +26 -23
- package/build/components/rich-text/content.js.map +1 -1
- package/build/components/rich-text/get-rich-text-values.js +2 -1
- package/build/components/rich-text/get-rich-text-values.js.map +1 -1
- package/build/components/rich-text/index.js +2 -30
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +9 -16
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/native/get-format-colors.native.js +22 -24
- package/build/components/rich-text/native/get-format-colors.native.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +7 -34
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/components/rich-text/use-input-rules.js +5 -1
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/rich-text/with-deprecations.js +50 -0
- package/build/components/rich-text/with-deprecations.js.map +1 -0
- package/build/components/use-block-drop-zone/index.js +70 -8
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +1 -1
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/use-resize-canvas/index.js +4 -1
- package/build/components/use-resize-canvas/index.js.map +1 -1
- package/build/components/use-settings/index.js +14 -0
- package/build/components/use-settings/index.js.map +1 -1
- package/build/hooks/align.js +20 -68
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/align.native.js +11 -1
- package/build/hooks/align.native.js.map +1 -1
- package/build/hooks/anchor.js +13 -29
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/background.js +28 -31
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-hooks.js +24 -32
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-renaming.js +18 -22
- package/build/hooks/block-renaming.js.map +1 -1
- package/build/hooks/border.js +58 -80
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +76 -89
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +29 -29
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/custom-class-name.js +12 -29
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/custom-fields.js +24 -38
- package/build/hooks/custom-fields.js.map +1 -1
- package/build/hooks/dimensions.js +21 -17
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +31 -61
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/font-family.js +16 -25
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +51 -119
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/index.js +25 -14
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +10 -3
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/layout-child.js +68 -0
- package/build/hooks/layout-child.js.map +1 -0
- package/build/hooks/layout.js +16 -101
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/padding.js +2 -2
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/position.js +40 -62
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +51 -88
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/typography.js +34 -14
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +154 -7
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +0 -2
- package/build/private-apis.js.map +1 -1
- package/build/store/private-actions.js +8 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +34 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +8 -0
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +10 -60
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +66 -0
- package/build/store/utils.js.map +1 -0
- package/build/utils/object.js +21 -61
- package/build/utils/object.js.map +1 -1
- package/build/utils/selection.js +9 -1
- package/build/utils/selection.js.map +1 -1
- package/build-module/components/block-canvas/index.js +23 -7
- package/build-module/components/block-canvas/index.js.map +1 -1
- package/build-module/components/block-card/index.js +1 -1
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-controls/hook.js +4 -24
- package/build-module/components/block-controls/hook.js.map +1 -1
- package/build-module/components/block-edit/context.js +2 -0
- package/build-module/components/block-edit/context.js.map +1 -1
- package/build-module/components/block-edit/index.js +19 -10
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-info-slot-fill/index.js +3 -3
- package/build-module/components/block-info-slot-fill/index.js.map +1 -1
- package/build-module/components/block-list/block.js +29 -10
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +14 -5
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +62 -19
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js +4 -29
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-is-hovered.js +4 -14
- package/build-module/components/block-list/use-block-props/use-is-hovered.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js +4 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +1 -1
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +3 -10
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-rename/modal.js +3 -0
- package/build-module/components/block-rename/modal.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +4 -2
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-styles/index.js +1 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-styles/index.native.js +3 -2
- package/build-module/components/block-styles/index.native.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +88 -25
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js +41 -0
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -0
- package/build-module/components/block-tools/block-toolbar-popover.js +76 -0
- package/build-module/components/block-tools/block-toolbar-popover.js.map +1 -0
- package/build-module/components/block-tools/index.js +27 -24
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +2 -1
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/block-variation-picker/index.native.js +2 -1
- package/build-module/components/block-variation-picker/index.native.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +29 -18
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/duotone-control/index.js +1 -4
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +23 -21
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +10 -4
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +20 -31
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/image-link-destinations/index.native.js +109 -0
- package/build-module/components/image-link-destinations/index.native.js.map +1 -0
- package/build-module/components/index.native.js +1 -0
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-panel.js +1 -1
- package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build-module/components/inserter/menu.js +14 -7
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +2 -2
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inserter-button/index.native.js +89 -0
- package/build-module/components/inserter-button/index.native.js.map +1 -0
- package/build-module/components/inserter-button/sparkles.js +15 -0
- package/build-module/components/inserter-button/sparkles.js.map +1 -0
- package/build-module/components/inserter-draggable-blocks/index.js +9 -5
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +3 -3
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/inspector-controls/fill.native.js +3 -3
- package/build-module/components/inspector-controls/fill.native.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +2 -2
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/preview-options/index.js +6 -62
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/rich-text/content.js +25 -21
- package/build-module/components/rich-text/content.js.map +1 -1
- package/build-module/components/rich-text/get-rich-text-values.js +2 -1
- package/build-module/components/rich-text/get-rich-text-values.js.map +1 -1
- package/build-module/components/rich-text/index.js +4 -32
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +10 -18
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/get-format-colors.native.js +22 -24
- package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +7 -34
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-input-rules.js +5 -1
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/rich-text/with-deprecations.js +42 -0
- package/build-module/components/rich-text/with-deprecations.js.map +1 -0
- package/build-module/components/use-block-drop-zone/index.js +69 -8
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +1 -1
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/use-resize-canvas/index.js +4 -1
- package/build-module/components/use-resize-canvas/index.js.map +1 -1
- package/build-module/components/use-settings/index.js +13 -1
- package/build-module/components/use-settings/index.js.map +1 -1
- package/build-module/hooks/align.js +19 -66
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/align.native.js +1 -0
- package/build-module/hooks/align.native.js.map +1 -1
- package/build-module/hooks/anchor.js +11 -26
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/background.js +26 -28
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-hooks.js +22 -30
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-renaming.js +17 -21
- package/build-module/hooks/block-renaming.js.map +1 -1
- package/build-module/hooks/border.js +57 -78
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +74 -86
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +27 -27
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +11 -27
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/custom-fields.js +20 -39
- package/build-module/hooks/custom-fields.js.map +1 -1
- package/build-module/hooks/dimensions.js +21 -16
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +30 -61
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/font-family.js +14 -23
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +49 -119
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/index.js +18 -14
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/index.native.js +5 -3
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/layout-child.js +60 -0
- package/build-module/hooks/layout-child.js.map +1 -0
- package/build-module/hooks/layout.js +13 -98
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/padding.js +2 -2
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/position.js +38 -59
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +51 -84
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/typography.js +33 -12
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +149 -6
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +0 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/private-actions.js +7 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +33 -1
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +8 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +3 -53
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +56 -0
- package/build-module/store/utils.js.map +1 -0
- package/build-module/utils/object.js +21 -60
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/selection.js +9 -1
- package/build-module/utils/selection.js.map +1 -1
- package/build-style/style-rtl.css +113 -293
- package/build-style/style.css +113 -293
- package/package.json +31 -31
- package/src/components/block-canvas/index.js +31 -17
- package/src/components/block-caption/README.md +2 -2
- package/src/components/block-card/index.js +5 -3
- package/src/components/block-card/style.scss +7 -3
- package/src/components/block-controls/hook.js +8 -30
- package/src/components/block-controls/test/index.js +3 -3
- package/src/components/block-edit/context.js +3 -0
- package/src/components/block-edit/index.js +36 -10
- package/src/components/block-info-slot-fill/index.js +6 -3
- package/src/components/block-inspector/style.scss +0 -4
- package/src/components/block-list/block.js +39 -5
- package/src/components/block-list/block.native.js +18 -4
- package/src/components/block-list/use-block-props/index.js +74 -21
- package/src/components/block-list/use-block-props/use-focus-first-element.js +1 -34
- package/src/components/block-list/use-block-props/use-is-hovered.js +2 -13
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +1 -5
- package/src/components/block-patterns-list/index.js +1 -1
- package/src/components/block-removal-warning-modal/index.js +7 -14
- package/src/components/block-rename/modal.js +7 -1
- package/src/components/block-settings/container.native.js +3 -5
- package/src/components/block-styles/index.js +1 -1
- package/src/components/block-styles/index.native.js +4 -2
- package/src/components/block-styles/style.scss +0 -11
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +3 -1
- package/src/components/block-toolbar/index.js +180 -95
- package/src/components/block-toolbar/style.scss +50 -66
- package/src/components/block-tools/block-toolbar-breadcrumb.js +46 -0
- package/src/components/block-tools/block-toolbar-popover.js +90 -0
- package/src/components/block-tools/index.js +42 -29
- package/src/components/block-tools/style.scss +60 -172
- package/src/components/block-types-list/index.native.js +2 -1
- package/src/components/block-variation-picker/index.native.js +1 -1
- package/src/components/colors-gradients/control.js +49 -30
- package/src/components/colors-gradients/style.scss +0 -7
- package/src/components/duotone-control/index.js +2 -5
- package/src/components/duotone-control/style.scss +1 -6
- package/src/components/global-styles/color-panel.js +34 -25
- package/src/components/global-styles/filters-panel.js +8 -4
- package/src/components/global-styles/typography-panel.js +23 -43
- package/src/components/image-link-destinations/index.native.js +152 -0
- package/src/components/image-link-destinations/style.native.scss +16 -0
- package/src/components/index.native.js +1 -0
- package/src/components/inner-blocks/README.md +13 -2
- package/src/components/inserter/media-tab/media-panel.js +1 -1
- package/src/components/inserter/menu.js +16 -8
- package/src/components/inserter/preview-panel.js +2 -2
- package/src/components/inserter/style.scss +15 -17
- package/src/components/inserter-button/README.md +62 -0
- package/src/components/inserter-button/index.native.js +116 -0
- package/src/components/inserter-button/sparkles.js +15 -0
- package/src/components/inserter-button/style.native.scss +72 -0
- package/src/components/inserter-draggable-blocks/index.js +18 -5
- package/src/components/inspector-controls/fill.js +6 -3
- package/src/components/inspector-controls/fill.native.js +6 -3
- package/src/components/link-control/style.scss +1 -1
- package/src/components/link-control/test/index.js +1 -1
- package/src/components/navigable-toolbar/README.md +2 -0
- package/src/components/navigable-toolbar/index.js +2 -2
- package/src/components/preview-options/index.js +6 -86
- package/src/components/rich-text/content.js +27 -20
- package/src/components/rich-text/get-rich-text-values.js +6 -1
- package/src/components/rich-text/index.js +5 -46
- package/src/components/rich-text/index.native.js +8 -25
- package/src/components/rich-text/native/get-format-colors.native.js +33 -40
- package/src/components/rich-text/native/index.native.js +7 -48
- package/src/components/rich-text/use-input-rules.js +6 -1
- package/src/components/rich-text/with-deprecations.js +51 -0
- package/src/components/use-block-drop-zone/index.js +114 -14
- package/src/components/use-on-block-drop/index.js +2 -1
- package/src/components/use-resize-canvas/README.md +3 -3
- package/src/components/use-resize-canvas/index.js +4 -1
- package/src/components/use-settings/index.js +15 -1
- package/src/hooks/align.js +15 -76
- package/src/hooks/align.native.js +1 -0
- package/src/hooks/anchor.js +13 -33
- package/src/hooks/background.js +28 -23
- package/src/hooks/block-hooks.js +22 -51
- package/src/hooks/block-renaming.js +23 -37
- package/src/hooks/border.js +67 -118
- package/src/hooks/color.js +100 -132
- package/src/hooks/content-lock-ui.js +110 -122
- package/src/hooks/custom-class-name.js +8 -40
- package/src/hooks/custom-fields.js +20 -47
- package/src/hooks/dimensions.js +20 -16
- package/src/hooks/duotone.js +70 -127
- package/src/hooks/font-family.js +10 -29
- package/src/hooks/font-size.js +66 -162
- package/src/hooks/index.js +42 -14
- package/src/hooks/index.native.js +6 -3
- package/src/hooks/layout-child.js +53 -0
- package/src/hooks/layout.js +13 -102
- package/src/hooks/padding.js +2 -2
- package/src/hooks/position.js +50 -90
- package/src/hooks/style.js +117 -187
- package/src/hooks/test/align.js +1 -178
- package/src/hooks/typography.js +20 -16
- package/src/hooks/utils.js +187 -6
- package/src/private-apis.js +0 -2
- package/src/store/private-actions.js +8 -0
- package/src/store/private-selectors.js +45 -0
- package/src/store/reducer.js +8 -0
- package/src/store/selectors.js +5 -69
- package/src/store/utils.js +74 -0
- package/src/style.scss +0 -2
- package/src/utils/object.js +18 -69
- package/src/utils/selection.js +9 -2
- package/build/components/block-list/use-block-props/use-block-class-names.js +0 -67
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +0 -1
- package/build/components/block-list/use-block-props/use-block-custom-class-name.js +0 -46
- package/build/components/block-list/use-block-props/use-block-custom-class-name.js.map +0 -1
- package/build/components/block-list/use-block-props/use-block-default-class-name.js +0 -37
- package/build/components/block-list/use-block-props/use-block-default-class-name.js.map +0 -1
- package/build/components/block-tools/back-compat.js +0 -45
- package/build/components/block-tools/back-compat.js.map +0 -1
- package/build/components/block-tools/block-contextual-toolbar.js +0 -91
- package/build/components/block-tools/block-contextual-toolbar.js.map +0 -1
- package/build/components/block-tools/selected-block-tools.js +0 -113
- package/build/components/block-tools/selected-block-tools.js.map +0 -1
- package/build/components/inserter/hooks/use-debounced-input.js +0 -22
- package/build/components/inserter/hooks/use-debounced-input.js.map +0 -1
- package/build/components/use-display-block-controls/index.js +0 -39
- package/build/components/use-display-block-controls/index.js.map +0 -1
- package/build/components/use-display-block-controls/index.native.js +0 -39
- package/build/components/use-display-block-controls/index.native.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +0 -60
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js +0 -40
- package/build-module/components/block-list/use-block-props/use-block-custom-class-name.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-block-default-class-name.js +0 -31
- package/build-module/components/block-list/use-block-props/use-block-default-class-name.js.map +0 -1
- package/build-module/components/block-tools/back-compat.js +0 -35
- package/build-module/components/block-tools/back-compat.js.map +0 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +0 -83
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +0 -1
- package/build-module/components/block-tools/selected-block-tools.js +0 -105
- package/build-module/components/block-tools/selected-block-tools.js.map +0 -1
- package/build-module/components/inserter/hooks/use-debounced-input.js +0 -15
- package/build-module/components/inserter/hooks/use-debounced-input.js.map +0 -1
- package/build-module/components/use-display-block-controls/index.js +0 -32
- package/build-module/components/use-display-block-controls/index.js.map +0 -1
- package/build-module/components/use-display-block-controls/index.native.js +0 -32
- package/build-module/components/use-display-block-controls/index.native.js.map +0 -1
- package/src/components/block-list/use-block-props/use-block-class-names.js +0 -66
- package/src/components/block-list/use-block-props/use-block-custom-class-name.js +0 -44
- package/src/components/block-list/use-block-props/use-block-default-class-name.js +0 -35
- package/src/components/block-parent-selector/style.scss +0 -11
- package/src/components/block-tools/back-compat.js +0 -35
- package/src/components/block-tools/block-contextual-toolbar.js +0 -100
- package/src/components/block-tools/selected-block-tools.js +0 -127
- package/src/components/inserter/hooks/use-debounced-input.js +0 -18
- package/src/components/preview-options/README.md +0 -94
- package/src/components/preview-options/style.scss +0 -64
- package/src/components/use-display-block-controls/index.js +0 -36
- package/src/components/use-display-block-controls/index.native.js +0 -37
- package/src/hooks/test/color.js +0 -112
|
@@ -5,50 +5,43 @@ import { getColorObjectByAttributeValues } from '../../../components/colors';
|
|
|
5
5
|
|
|
6
6
|
const FORMAT_TYPE = 'core/text-color';
|
|
7
7
|
const REGEX_TO_MATCH = /^has-(.*)-color$/;
|
|
8
|
-
const TAGS_TO_SEARCH = /\<mark/;
|
|
9
8
|
|
|
10
|
-
export function getFormatColors(
|
|
11
|
-
|
|
12
|
-
const newFormats = formats.slice();
|
|
9
|
+
export function getFormatColors( formats, colors ) {
|
|
10
|
+
const newFormats = formats.slice();
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
// We are looping through a sparse array where empty indices will be
|
|
13
|
+
// skipped.
|
|
14
|
+
newFormats.forEach( ( format ) => {
|
|
15
|
+
format.forEach( ( currentFormat ) => {
|
|
16
|
+
if ( currentFormat?.type === FORMAT_TYPE ) {
|
|
17
|
+
const className = currentFormat?.attributes?.class;
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
currentStyles,
|
|
42
|
-
].join( ';' );
|
|
43
|
-
}
|
|
19
|
+
className?.split( ' ' ).forEach( ( currentClass ) => {
|
|
20
|
+
const match = currentClass.match( REGEX_TO_MATCH );
|
|
21
|
+
if ( match ) {
|
|
22
|
+
const [ , colorSlug ] =
|
|
23
|
+
currentClass.match( REGEX_TO_MATCH );
|
|
24
|
+
const colorObject = getColorObjectByAttributeValues(
|
|
25
|
+
colors,
|
|
26
|
+
colorSlug
|
|
27
|
+
);
|
|
28
|
+
const currentStyles = currentFormat?.attributes?.style;
|
|
29
|
+
if (
|
|
30
|
+
colorObject &&
|
|
31
|
+
( ! currentStyles ||
|
|
32
|
+
currentStyles?.indexOf( colorObject.color ) ===
|
|
33
|
+
-1 )
|
|
34
|
+
) {
|
|
35
|
+
currentFormat.attributes.style = [
|
|
36
|
+
`color: ${ colorObject.color }`,
|
|
37
|
+
currentStyles,
|
|
38
|
+
].join( ';' );
|
|
44
39
|
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
40
|
+
}
|
|
41
|
+
} );
|
|
42
|
+
}
|
|
48
43
|
} );
|
|
44
|
+
} );
|
|
49
45
|
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return formats;
|
|
46
|
+
return newFormats;
|
|
54
47
|
}
|
|
@@ -105,27 +105,11 @@ const DEFAULT_FONT_SIZE = 16;
|
|
|
105
105
|
const MIN_LINE_HEIGHT = 1;
|
|
106
106
|
|
|
107
107
|
export class RichText extends Component {
|
|
108
|
-
constructor( {
|
|
109
|
-
value,
|
|
110
|
-
selectionStart,
|
|
111
|
-
selectionEnd,
|
|
112
|
-
__unstableMultilineTag: multiline,
|
|
113
|
-
} ) {
|
|
108
|
+
constructor( { value, selectionStart, selectionEnd } ) {
|
|
114
109
|
super( ...arguments );
|
|
115
110
|
|
|
116
|
-
this.isMultiline = false;
|
|
117
|
-
if ( multiline === true || multiline === 'p' || multiline === 'li' ) {
|
|
118
|
-
this.multilineTag = multiline === true ? 'p' : multiline;
|
|
119
|
-
this.isMultiline = true;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if ( this.multilineTag === 'li' ) {
|
|
123
|
-
this.multilineWrapperTags = [ 'ul', 'ol' ];
|
|
124
|
-
}
|
|
125
|
-
|
|
126
111
|
this.isIOS = Platform.OS === 'ios';
|
|
127
112
|
this.createRecord = this.createRecord.bind( this );
|
|
128
|
-
this.restoreParagraphTags = this.restoreParagraphTags.bind( this );
|
|
129
113
|
this.onChangeFromAztec = this.onChangeFromAztec.bind( this );
|
|
130
114
|
this.onKeyDown = this.onKeyDown.bind( this );
|
|
131
115
|
this.handleEnter = this.handleEnter.bind( this );
|
|
@@ -196,7 +180,7 @@ export class RichText extends Component {
|
|
|
196
180
|
|
|
197
181
|
const { formats, replacements, text } = currentValue;
|
|
198
182
|
const { activeFormats } = this.state;
|
|
199
|
-
const newFormats = getFormatColors(
|
|
183
|
+
const newFormats = getFormatColors( formats, colorPalette );
|
|
200
184
|
|
|
201
185
|
return {
|
|
202
186
|
formats: newFormats,
|
|
@@ -223,8 +207,6 @@ export class RichText extends Component {
|
|
|
223
207
|
...create( {
|
|
224
208
|
html: this.value,
|
|
225
209
|
range: null,
|
|
226
|
-
multilineTag: this.multilineTag,
|
|
227
|
-
multilineWrapperTags: this.multilineWrapperTags,
|
|
228
210
|
preserveWhiteSpace,
|
|
229
211
|
} ),
|
|
230
212
|
};
|
|
@@ -235,12 +217,7 @@ export class RichText extends Component {
|
|
|
235
217
|
|
|
236
218
|
valueToFormat( value ) {
|
|
237
219
|
// Remove the outer root tags.
|
|
238
|
-
return this.removeRootTagsProducedByAztec(
|
|
239
|
-
toHTMLString( {
|
|
240
|
-
value,
|
|
241
|
-
multilineTag: this.multilineTag,
|
|
242
|
-
} )
|
|
243
|
-
);
|
|
220
|
+
return this.removeRootTagsProducedByAztec( toHTMLString( { value } ) );
|
|
244
221
|
}
|
|
245
222
|
|
|
246
223
|
getActiveFormatNames( record ) {
|
|
@@ -357,29 +334,15 @@ export class RichText extends Component {
|
|
|
357
334
|
const contentWithoutRootTag = this.removeRootTagsProducedByAztec(
|
|
358
335
|
unescapeSpaces( event.nativeEvent.text )
|
|
359
336
|
);
|
|
360
|
-
let formattedContent = contentWithoutRootTag;
|
|
361
|
-
if ( ! this.isIOS ) {
|
|
362
|
-
formattedContent = this.restoreParagraphTags(
|
|
363
|
-
contentWithoutRootTag,
|
|
364
|
-
this.multilineTag
|
|
365
|
-
);
|
|
366
|
-
}
|
|
367
337
|
|
|
368
338
|
this.debounceCreateUndoLevel();
|
|
369
|
-
const refresh = this.value !==
|
|
370
|
-
this.value =
|
|
339
|
+
const refresh = this.value !== contentWithoutRootTag;
|
|
340
|
+
this.value = contentWithoutRootTag;
|
|
371
341
|
|
|
372
342
|
// We don't want to refresh if our goal is just to create a record.
|
|
373
343
|
if ( refresh ) {
|
|
374
|
-
this.props.onChange(
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
restoreParagraphTags( value, tag ) {
|
|
379
|
-
if ( tag === 'p' && ( ! value || ! value.startsWith( '<p>' ) ) ) {
|
|
380
|
-
return '<p>' + value + '</p>';
|
|
344
|
+
this.props.onChange( contentWithoutRootTag );
|
|
381
345
|
}
|
|
382
|
-
return value;
|
|
383
346
|
}
|
|
384
347
|
|
|
385
348
|
/*
|
|
@@ -739,8 +702,6 @@ export class RichText extends Component {
|
|
|
739
702
|
if ( Array.isArray( value ) ) {
|
|
740
703
|
return create( {
|
|
741
704
|
html: childrenBlock.toHTML( value ),
|
|
742
|
-
multilineTag: this.multilineTag,
|
|
743
|
-
multilineWrapperTags: this.multilineWrapperTags,
|
|
744
705
|
preserveWhiteSpace,
|
|
745
706
|
} );
|
|
746
707
|
}
|
|
@@ -748,8 +709,6 @@ export class RichText extends Component {
|
|
|
748
709
|
if ( this.props.format === 'string' ) {
|
|
749
710
|
return create( {
|
|
750
711
|
html: value,
|
|
751
|
-
multilineTag: this.multilineTag,
|
|
752
|
-
multilineWrapperTags: this.multilineWrapperTags,
|
|
753
712
|
preserveWhiteSpace,
|
|
754
713
|
} );
|
|
755
714
|
}
|
|
@@ -1323,7 +1282,7 @@ export class RichText extends Component {
|
|
|
1323
1282
|
fontWeight={ this.props.fontWeight }
|
|
1324
1283
|
fontStyle={ this.props.fontStyle }
|
|
1325
1284
|
disableEditingMenu={ disableEditingMenu }
|
|
1326
|
-
isMultiline={
|
|
1285
|
+
isMultiline={ false }
|
|
1327
1286
|
textAlign={ this.props.textAlign }
|
|
1328
1287
|
{ ...( this.isIOS ? { maxWidth } : {} ) }
|
|
1329
1288
|
minWidth={ minWidth }
|
|
@@ -28,7 +28,12 @@ function findSelection( blocks ) {
|
|
|
28
28
|
if ( attributeKey ) {
|
|
29
29
|
blocks[ i ].attributes[ attributeKey ] = blocks[ i ].attributes[
|
|
30
30
|
attributeKey
|
|
31
|
-
]
|
|
31
|
+
]
|
|
32
|
+
// To do: refactor this to use rich text's selection instead, so
|
|
33
|
+
// we no longer have to use on this hack inserting a special
|
|
34
|
+
// character.
|
|
35
|
+
.toString()
|
|
36
|
+
.replace( START_OF_SELECTED_AREA, '' );
|
|
32
37
|
return [ blocks[ i ].clientId, attributeKey, 0, 0 ];
|
|
33
38
|
}
|
|
34
39
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { forwardRef } from '@wordpress/element';
|
|
5
|
+
import { children as childrenSource } from '@wordpress/blocks';
|
|
6
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
7
|
+
import { __unstableCreateElement } from '@wordpress/rich-text';
|
|
8
|
+
import deprecated from '@wordpress/deprecated';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import RichTextMultiline from './multiline';
|
|
14
|
+
|
|
15
|
+
export function withDeprecations( Component ) {
|
|
16
|
+
return forwardRef( ( props, ref ) => {
|
|
17
|
+
let value = props.value;
|
|
18
|
+
let onChange = props.onChange;
|
|
19
|
+
|
|
20
|
+
// Handle deprecated format.
|
|
21
|
+
if ( Array.isArray( value ) ) {
|
|
22
|
+
deprecated( 'wp.blockEditor.RichText value prop as children type', {
|
|
23
|
+
since: '6.1',
|
|
24
|
+
version: '6.3',
|
|
25
|
+
alternative: 'value prop as string',
|
|
26
|
+
link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/',
|
|
27
|
+
} );
|
|
28
|
+
|
|
29
|
+
value = childrenSource.toHTML( props.value );
|
|
30
|
+
onChange = ( newValue ) =>
|
|
31
|
+
props.onChange(
|
|
32
|
+
childrenSource.fromDOM(
|
|
33
|
+
__unstableCreateElement( document, newValue ).childNodes
|
|
34
|
+
)
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const NewComponent = props.multiline ? RichTextMultiline : Component;
|
|
39
|
+
const instanceId = useInstanceId( NewComponent );
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<NewComponent
|
|
43
|
+
{ ...props }
|
|
44
|
+
identifier={ props.identifier || instanceId }
|
|
45
|
+
value={ value }
|
|
46
|
+
onChange={ onChange }
|
|
47
|
+
ref={ ref }
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
} );
|
|
51
|
+
}
|
|
@@ -20,6 +20,10 @@ import {
|
|
|
20
20
|
} from '../../utils/math';
|
|
21
21
|
import { store as blockEditorStore } from '../../store';
|
|
22
22
|
|
|
23
|
+
const THRESHOLD_DISTANCE = 30;
|
|
24
|
+
const MINIMUM_HEIGHT_FOR_THRESHOLD = 120;
|
|
25
|
+
const MINIMUM_WIDTH_FOR_THRESHOLD = 120;
|
|
26
|
+
|
|
23
27
|
/** @typedef {import('../../utils/math').WPPoint} WPPoint */
|
|
24
28
|
/** @typedef {import('../use-on-block-drop/types').WPDropOperation} WPDropOperation */
|
|
25
29
|
|
|
@@ -48,24 +52,86 @@ import { store as blockEditorStore } from '../../store';
|
|
|
48
52
|
* @param {WPBlockData[]} blocksData The block data list.
|
|
49
53
|
* @param {WPPoint} position The position of the item being dragged.
|
|
50
54
|
* @param {WPBlockListOrientation} orientation The orientation of the block list.
|
|
55
|
+
* @param {Object} options Additional options.
|
|
51
56
|
* @return {[number, WPDropOperation]} The drop target position.
|
|
52
57
|
*/
|
|
53
58
|
export function getDropTargetPosition(
|
|
54
59
|
blocksData,
|
|
55
60
|
position,
|
|
56
|
-
orientation = 'vertical'
|
|
61
|
+
orientation = 'vertical',
|
|
62
|
+
options = {}
|
|
57
63
|
) {
|
|
58
64
|
const allowedEdges =
|
|
59
65
|
orientation === 'horizontal'
|
|
60
66
|
? [ 'left', 'right' ]
|
|
61
67
|
: [ 'top', 'bottom' ];
|
|
62
68
|
|
|
63
|
-
const isRightToLeft = isRTL();
|
|
64
|
-
|
|
65
69
|
let nearestIndex = 0;
|
|
66
70
|
let insertPosition = 'before';
|
|
67
71
|
let minDistance = Infinity;
|
|
68
72
|
|
|
73
|
+
const {
|
|
74
|
+
dropZoneElement,
|
|
75
|
+
parentBlockOrientation,
|
|
76
|
+
rootBlockIndex = 0,
|
|
77
|
+
} = options;
|
|
78
|
+
|
|
79
|
+
// Allow before/after when dragging over the top/bottom edges of the drop zone.
|
|
80
|
+
if ( dropZoneElement && parentBlockOrientation !== 'horizontal' ) {
|
|
81
|
+
const rect = dropZoneElement.getBoundingClientRect();
|
|
82
|
+
const [ distance, edge ] = getDistanceToNearestEdge( position, rect, [
|
|
83
|
+
'top',
|
|
84
|
+
'bottom',
|
|
85
|
+
] );
|
|
86
|
+
|
|
87
|
+
// If dragging over the top or bottom of the drop zone, insert the block
|
|
88
|
+
// before or after the parent block. This only applies to blocks that use
|
|
89
|
+
// a drop zone element, typically container blocks such as Group or Cover.
|
|
90
|
+
if (
|
|
91
|
+
rect.height > MINIMUM_HEIGHT_FOR_THRESHOLD &&
|
|
92
|
+
distance < THRESHOLD_DISTANCE
|
|
93
|
+
) {
|
|
94
|
+
if ( edge === 'top' ) {
|
|
95
|
+
return [ rootBlockIndex, 'before' ];
|
|
96
|
+
}
|
|
97
|
+
if ( edge === 'bottom' ) {
|
|
98
|
+
return [ rootBlockIndex + 1, 'after' ];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const isRightToLeft = isRTL();
|
|
104
|
+
|
|
105
|
+
// Allow before/after when dragging over the left/right edges of the drop zone.
|
|
106
|
+
if ( dropZoneElement && parentBlockOrientation === 'horizontal' ) {
|
|
107
|
+
const rect = dropZoneElement.getBoundingClientRect();
|
|
108
|
+
const [ distance, edge ] = getDistanceToNearestEdge( position, rect, [
|
|
109
|
+
'left',
|
|
110
|
+
'right',
|
|
111
|
+
] );
|
|
112
|
+
|
|
113
|
+
// If dragging over the left or right of the drop zone, insert the block
|
|
114
|
+
// before or after the parent block. This only applies to blocks that use
|
|
115
|
+
// a drop zone element, typically container blocks such as Group.
|
|
116
|
+
if (
|
|
117
|
+
rect.width > MINIMUM_WIDTH_FOR_THRESHOLD &&
|
|
118
|
+
distance < THRESHOLD_DISTANCE
|
|
119
|
+
) {
|
|
120
|
+
if (
|
|
121
|
+
( isRightToLeft && edge === 'right' ) ||
|
|
122
|
+
( ! isRightToLeft && edge === 'left' )
|
|
123
|
+
) {
|
|
124
|
+
return [ rootBlockIndex, 'before' ];
|
|
125
|
+
}
|
|
126
|
+
if (
|
|
127
|
+
( isRightToLeft && edge === 'left' ) ||
|
|
128
|
+
( ! isRightToLeft && edge === 'right' )
|
|
129
|
+
) {
|
|
130
|
+
return [ rootBlockIndex + 1, 'after' ];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
69
135
|
blocksData.forEach(
|
|
70
136
|
( { isUnmodifiedDefaultBlock, getBoundingClientRect, blockIndex } ) => {
|
|
71
137
|
const rect = getBoundingClientRect();
|
|
@@ -150,19 +216,27 @@ export default function useBlockDropZone( {
|
|
|
150
216
|
operation: 'insert',
|
|
151
217
|
} );
|
|
152
218
|
|
|
153
|
-
const isDisabled = useSelect(
|
|
219
|
+
const { isDisabled, parentBlockClientId, rootBlockIndex } = useSelect(
|
|
154
220
|
( select ) => {
|
|
155
221
|
const {
|
|
156
222
|
__unstableIsWithinBlockOverlay,
|
|
157
223
|
__unstableHasActiveBlockOverlayActive,
|
|
224
|
+
getBlockIndex,
|
|
225
|
+
getBlockParents,
|
|
158
226
|
getBlockEditingMode,
|
|
159
227
|
} = select( blockEditorStore );
|
|
160
228
|
const blockEditingMode = getBlockEditingMode( targetRootClientId );
|
|
161
|
-
return
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
229
|
+
return {
|
|
230
|
+
parentBlockClientId:
|
|
231
|
+
getBlockParents( targetRootClientId, true )[ 0 ] || '',
|
|
232
|
+
rootBlockIndex: getBlockIndex( targetRootClientId ),
|
|
233
|
+
isDisabled:
|
|
234
|
+
blockEditingMode !== 'default' ||
|
|
235
|
+
__unstableHasActiveBlockOverlayActive(
|
|
236
|
+
targetRootClientId
|
|
237
|
+
) ||
|
|
238
|
+
__unstableIsWithinBlockOverlay( targetRootClientId ),
|
|
239
|
+
};
|
|
166
240
|
},
|
|
167
241
|
[ targetRootClientId ]
|
|
168
242
|
);
|
|
@@ -172,9 +246,15 @@ export default function useBlockDropZone( {
|
|
|
172
246
|
const { showInsertionPoint, hideInsertionPoint } =
|
|
173
247
|
useDispatch( blockEditorStore );
|
|
174
248
|
|
|
175
|
-
const onBlockDrop = useOnBlockDrop(
|
|
176
|
-
operation
|
|
177
|
-
|
|
249
|
+
const onBlockDrop = useOnBlockDrop(
|
|
250
|
+
dropTarget.operation === 'before' || dropTarget.operation === 'after'
|
|
251
|
+
? parentBlockClientId
|
|
252
|
+
: targetRootClientId,
|
|
253
|
+
dropTarget.index,
|
|
254
|
+
{
|
|
255
|
+
operation: dropTarget.operation,
|
|
256
|
+
}
|
|
257
|
+
);
|
|
178
258
|
const throttled = useThrottle(
|
|
179
259
|
useCallback(
|
|
180
260
|
( event, ownerDocument ) => {
|
|
@@ -211,7 +291,16 @@ export default function useBlockDropZone( {
|
|
|
211
291
|
const [ targetIndex, operation ] = getDropTargetPosition(
|
|
212
292
|
blocksData,
|
|
213
293
|
{ x: event.clientX, y: event.clientY },
|
|
214
|
-
getBlockListSettings( targetRootClientId )?.orientation
|
|
294
|
+
getBlockListSettings( targetRootClientId )?.orientation,
|
|
295
|
+
{
|
|
296
|
+
dropZoneElement,
|
|
297
|
+
parentBlockClientId,
|
|
298
|
+
parentBlockOrientation: parentBlockClientId
|
|
299
|
+
? getBlockListSettings( parentBlockClientId )
|
|
300
|
+
?.orientation
|
|
301
|
+
: undefined,
|
|
302
|
+
rootBlockIndex,
|
|
303
|
+
}
|
|
215
304
|
);
|
|
216
305
|
|
|
217
306
|
registry.batch( () => {
|
|
@@ -219,18 +308,29 @@ export default function useBlockDropZone( {
|
|
|
219
308
|
index: targetIndex,
|
|
220
309
|
operation,
|
|
221
310
|
} );
|
|
222
|
-
|
|
311
|
+
|
|
312
|
+
const insertionPointClientId = [
|
|
313
|
+
'before',
|
|
314
|
+
'after',
|
|
315
|
+
].includes( operation )
|
|
316
|
+
? parentBlockClientId
|
|
317
|
+
: targetRootClientId;
|
|
318
|
+
|
|
319
|
+
showInsertionPoint( insertionPointClientId, targetIndex, {
|
|
223
320
|
operation,
|
|
224
321
|
} );
|
|
225
322
|
} );
|
|
226
323
|
},
|
|
227
324
|
[
|
|
325
|
+
dropZoneElement,
|
|
228
326
|
getBlocks,
|
|
229
327
|
targetRootClientId,
|
|
230
328
|
getBlockListSettings,
|
|
231
329
|
registry,
|
|
232
330
|
showInsertionPoint,
|
|
233
331
|
getBlockIndex,
|
|
332
|
+
parentBlockClientId,
|
|
333
|
+
rootBlockIndex,
|
|
234
334
|
]
|
|
235
335
|
),
|
|
236
336
|
200
|
|
@@ -292,9 +292,10 @@ export default function useOnBlockDrop(
|
|
|
292
292
|
operation,
|
|
293
293
|
getBlockOrder,
|
|
294
294
|
getBlocksByClientId,
|
|
295
|
-
insertBlocks,
|
|
296
295
|
moveBlocksToPosition,
|
|
296
|
+
registry,
|
|
297
297
|
removeBlocks,
|
|
298
|
+
replaceBlocks,
|
|
298
299
|
targetBlockIndex,
|
|
299
300
|
targetRootClientId,
|
|
300
301
|
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# useResizeCanvas
|
|
2
2
|
|
|
3
|
-
This React hook generates inline CSS suitable for resizing a container to fit a device's dimensions. It adjusts the CSS according to the current device dimensions.
|
|
3
|
+
This React hook generates inline CSS suitable for resizing a container to fit a device's dimensions. It adjusts the CSS according to the current device dimensions.
|
|
4
4
|
|
|
5
5
|
On-page CSS media queries are also updated to match the width of the device.
|
|
6
6
|
|
|
@@ -14,14 +14,14 @@ Note that this is currently experimental, and is available as `__experimentalUse
|
|
|
14
14
|
|
|
15
15
|
### Usage
|
|
16
16
|
|
|
17
|
-
The hook returns a style object which can be applied to a container. It is passed the current device type, which can be obtained from `
|
|
17
|
+
The hook returns a style object which can be applied to a container. It is passed the current device type, which can be obtained from `getDeviceType`.
|
|
18
18
|
|
|
19
19
|
```jsx
|
|
20
20
|
import { __experimentalUseResizeCanvas as useResizeCanvas } from '@wordpress/block-editor';
|
|
21
21
|
|
|
22
22
|
function ResizedContainer() {
|
|
23
23
|
const deviceType = useSelect( ( select ) => {
|
|
24
|
-
return select( 'core/
|
|
24
|
+
return select( 'core/editor' ).getDeviceType();
|
|
25
25
|
}, [] );
|
|
26
26
|
const inlineStyles = useResizeCanvas( deviceType );
|
|
27
27
|
|
|
@@ -103,7 +103,7 @@ const removeCustomPrefixes = ( path ) => {
|
|
|
103
103
|
* @param {Object} value Object to merge
|
|
104
104
|
* @return {Array} Array of merged items
|
|
105
105
|
*/
|
|
106
|
-
function mergeOrigins( value ) {
|
|
106
|
+
export function mergeOrigins( value ) {
|
|
107
107
|
let result = mergeCache.get( value );
|
|
108
108
|
if ( ! result ) {
|
|
109
109
|
result = [ 'default', 'theme', 'custom' ].flatMap(
|
|
@@ -115,6 +115,20 @@ function mergeOrigins( value ) {
|
|
|
115
115
|
}
|
|
116
116
|
const mergeCache = new WeakMap();
|
|
117
117
|
|
|
118
|
+
/**
|
|
119
|
+
* For settings like `color.palette`, which have a value that is an object
|
|
120
|
+
* with `default`, `theme`, `custom`, with field values that are arrays of
|
|
121
|
+
* items, see if any of the three origins have values.
|
|
122
|
+
*
|
|
123
|
+
* @param {Object} value Object to check
|
|
124
|
+
* @return {boolean} Whether the object has values in any of the three origins
|
|
125
|
+
*/
|
|
126
|
+
export function hasMergedOrigins( value ) {
|
|
127
|
+
return [ 'default', 'theme', 'custom' ].some(
|
|
128
|
+
( key ) => value?.[ key ]?.length
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
118
132
|
/**
|
|
119
133
|
* Hook that retrieves the given settings for the block instance in use.
|
|
120
134
|
*
|
package/src/hooks/align.js
CHANGED
|
@@ -6,7 +6,6 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
10
9
|
import { addFilter } from '@wordpress/hooks';
|
|
11
10
|
import {
|
|
12
11
|
getBlockSupport,
|
|
@@ -108,9 +107,9 @@ export function addAttribute( settings ) {
|
|
|
108
107
|
return settings;
|
|
109
108
|
}
|
|
110
109
|
|
|
111
|
-
function
|
|
112
|
-
blockName,
|
|
113
|
-
|
|
110
|
+
function BlockEditAlignmentToolbarControlsPure( {
|
|
111
|
+
name: blockName,
|
|
112
|
+
align,
|
|
114
113
|
setAttributes,
|
|
115
114
|
} ) {
|
|
116
115
|
// Compute the block valid alignments by taking into account,
|
|
@@ -144,7 +143,7 @@ function BlockEditAlignmentToolbarControls( {
|
|
|
144
143
|
return (
|
|
145
144
|
<BlockControls group="block" __experimentalShareWithChildBlocks>
|
|
146
145
|
<BlockAlignmentControl
|
|
147
|
-
value={
|
|
146
|
+
value={ align }
|
|
148
147
|
onChange={ updateAlignment }
|
|
149
148
|
controls={ validAlignments }
|
|
150
149
|
/>
|
|
@@ -152,80 +151,30 @@ function BlockEditAlignmentToolbarControls( {
|
|
|
152
151
|
);
|
|
153
152
|
}
|
|
154
153
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
*/
|
|
163
|
-
export const withAlignmentControls = createHigherOrderComponent(
|
|
164
|
-
( BlockEdit ) => ( props ) => {
|
|
165
|
-
const hasAlignmentSupport = hasBlockSupport(
|
|
166
|
-
props.name,
|
|
167
|
-
'align',
|
|
168
|
-
false
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
return (
|
|
172
|
-
<>
|
|
173
|
-
{ hasAlignmentSupport && (
|
|
174
|
-
<BlockEditAlignmentToolbarControls
|
|
175
|
-
blockName={ props.name }
|
|
176
|
-
attributes={ props.attributes }
|
|
177
|
-
setAttributes={ props.setAttributes }
|
|
178
|
-
/>
|
|
179
|
-
) }
|
|
180
|
-
<BlockEdit key="edit" { ...props } />
|
|
181
|
-
</>
|
|
182
|
-
);
|
|
154
|
+
export default {
|
|
155
|
+
shareWithChildBlocks: true,
|
|
156
|
+
edit: BlockEditAlignmentToolbarControlsPure,
|
|
157
|
+
useBlockProps,
|
|
158
|
+
attributeKeys: [ 'align' ],
|
|
159
|
+
hasSupport( name ) {
|
|
160
|
+
return hasBlockSupport( name, 'align', false );
|
|
183
161
|
},
|
|
184
|
-
|
|
185
|
-
);
|
|
162
|
+
};
|
|
186
163
|
|
|
187
|
-
function
|
|
188
|
-
const { name, attributes } = props;
|
|
189
|
-
const { align } = attributes;
|
|
164
|
+
function useBlockProps( { name, align } ) {
|
|
190
165
|
const blockAllowedAlignments = getValidAlignments(
|
|
191
166
|
getBlockSupport( name, 'align' ),
|
|
192
167
|
hasBlockSupport( name, 'alignWide', true )
|
|
193
168
|
);
|
|
194
169
|
const validAlignments = useAvailableAlignments( blockAllowedAlignments );
|
|
195
170
|
|
|
196
|
-
let wrapperProps = props.wrapperProps;
|
|
197
171
|
if ( validAlignments.some( ( alignment ) => alignment.name === align ) ) {
|
|
198
|
-
|
|
172
|
+
return { 'data-align': align };
|
|
199
173
|
}
|
|
200
174
|
|
|
201
|
-
return
|
|
175
|
+
return {};
|
|
202
176
|
}
|
|
203
177
|
|
|
204
|
-
/**
|
|
205
|
-
* Override the default block element to add alignment wrapper props.
|
|
206
|
-
*
|
|
207
|
-
* @param {Function} BlockListBlock Original component.
|
|
208
|
-
*
|
|
209
|
-
* @return {Function} Wrapped component.
|
|
210
|
-
*/
|
|
211
|
-
export const withDataAlign = createHigherOrderComponent(
|
|
212
|
-
( BlockListBlock ) => ( props ) => {
|
|
213
|
-
// If an alignment is not assigned, there's no need to go through the
|
|
214
|
-
// effort to validate or assign its value.
|
|
215
|
-
if ( props.attributes.align === undefined ) {
|
|
216
|
-
return <BlockListBlock { ...props } />;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
return (
|
|
220
|
-
<BlockListBlockWithDataAlign
|
|
221
|
-
block={ BlockListBlock }
|
|
222
|
-
props={ props }
|
|
223
|
-
/>
|
|
224
|
-
);
|
|
225
|
-
},
|
|
226
|
-
'withDataAlign'
|
|
227
|
-
);
|
|
228
|
-
|
|
229
178
|
/**
|
|
230
179
|
* Override props assigned to save component to inject alignment class name if
|
|
231
180
|
* block supports it.
|
|
@@ -260,16 +209,6 @@ addFilter(
|
|
|
260
209
|
'core/editor/align/addAttribute',
|
|
261
210
|
addAttribute
|
|
262
211
|
);
|
|
263
|
-
addFilter(
|
|
264
|
-
'editor.BlockListBlock',
|
|
265
|
-
'core/editor/align/with-data-align',
|
|
266
|
-
withDataAlign
|
|
267
|
-
);
|
|
268
|
-
addFilter(
|
|
269
|
-
'editor.BlockEdit',
|
|
270
|
-
'core/editor/align/with-toolbar-controls',
|
|
271
|
-
withAlignmentControls
|
|
272
|
-
);
|
|
273
212
|
addFilter(
|
|
274
213
|
'blocks.getSaveContent.extraProps',
|
|
275
214
|
'core/editor/align/addAssignedAlign',
|