@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
package/src/hooks/utils.js
CHANGED
|
@@ -2,17 +2,28 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
5
|
-
import { useMemo, useEffect, useId } from '@wordpress/element';
|
|
5
|
+
import { useMemo, useEffect, useId, useState } from '@wordpress/element';
|
|
6
6
|
import { useDispatch } from '@wordpress/data';
|
|
7
|
+
import { createHigherOrderComponent, pure } from '@wordpress/compose';
|
|
8
|
+
import { addFilter } from '@wordpress/hooks';
|
|
7
9
|
|
|
8
10
|
/**
|
|
9
11
|
* Internal dependencies
|
|
10
12
|
*/
|
|
13
|
+
import {
|
|
14
|
+
useBlockEditContext,
|
|
15
|
+
mayDisplayControlsKey,
|
|
16
|
+
mayDisplayParentControlsKey,
|
|
17
|
+
} from '../components/block-edit/context';
|
|
11
18
|
import { useSettings } from '../components';
|
|
12
19
|
import { useSettingsForBlockElement } from '../components/global-styles/hooks';
|
|
13
20
|
import { getValueFromObjectPath, setImmutably } from '../utils/object';
|
|
14
21
|
import { store as blockEditorStore } from '../store';
|
|
15
22
|
import { unlock } from '../lock-unlock';
|
|
23
|
+
/**
|
|
24
|
+
* External dependencies
|
|
25
|
+
*/
|
|
26
|
+
import classnames from 'classnames';
|
|
16
27
|
|
|
17
28
|
/**
|
|
18
29
|
* Removed falsy values from nested object.
|
|
@@ -101,14 +112,18 @@ export function transformStyles(
|
|
|
101
112
|
* Check whether serialization of specific block support feature or set should
|
|
102
113
|
* be skipped.
|
|
103
114
|
*
|
|
104
|
-
* @param {string|Object}
|
|
105
|
-
* @param {string} featureSet
|
|
106
|
-
* @param {string} feature
|
|
115
|
+
* @param {string|Object} blockNameOrType Block name or block type object.
|
|
116
|
+
* @param {string} featureSet Name of block support feature set.
|
|
117
|
+
* @param {string} feature Name of the individual feature to check.
|
|
107
118
|
*
|
|
108
119
|
* @return {boolean} Whether serialization should occur.
|
|
109
120
|
*/
|
|
110
|
-
export function shouldSkipSerialization(
|
|
111
|
-
|
|
121
|
+
export function shouldSkipSerialization(
|
|
122
|
+
blockNameOrType,
|
|
123
|
+
featureSet,
|
|
124
|
+
feature
|
|
125
|
+
) {
|
|
126
|
+
const support = getBlockSupport( blockNameOrType, featureSet );
|
|
112
127
|
const skipSerialization = support?.__experimentalSkipSerialization;
|
|
113
128
|
|
|
114
129
|
if ( Array.isArray( skipSerialization ) ) {
|
|
@@ -362,3 +377,169 @@ export function useBlockSettings( name, parentLayout ) {
|
|
|
362
377
|
|
|
363
378
|
return useSettingsForBlockElement( rawSettings, name );
|
|
364
379
|
}
|
|
380
|
+
|
|
381
|
+
export function createBlockEditFilter( features ) {
|
|
382
|
+
// We don't want block controls to re-render when typing inside a block.
|
|
383
|
+
// `pure` will prevent re-renders unless props change, so only pass the
|
|
384
|
+
// needed props and not the whole attributes object.
|
|
385
|
+
features = features.map( ( settings ) => {
|
|
386
|
+
return { ...settings, Edit: pure( settings.edit ) };
|
|
387
|
+
} );
|
|
388
|
+
const withBlockEditHooks = createHigherOrderComponent(
|
|
389
|
+
( OriginalBlockEdit ) => ( props ) => {
|
|
390
|
+
const context = useBlockEditContext();
|
|
391
|
+
// CAUTION: code added before this line will be executed for all
|
|
392
|
+
// blocks, not just those that support the feature! Code added
|
|
393
|
+
// above this line should be carefully evaluated for its impact on
|
|
394
|
+
// performance.
|
|
395
|
+
return [
|
|
396
|
+
...features.map( ( feature, i ) => {
|
|
397
|
+
const {
|
|
398
|
+
Edit,
|
|
399
|
+
hasSupport,
|
|
400
|
+
attributeKeys = [],
|
|
401
|
+
shareWithChildBlocks,
|
|
402
|
+
} = feature;
|
|
403
|
+
const shouldDisplayControls =
|
|
404
|
+
context[ mayDisplayControlsKey ] ||
|
|
405
|
+
( context[ mayDisplayParentControlsKey ] &&
|
|
406
|
+
shareWithChildBlocks );
|
|
407
|
+
|
|
408
|
+
if (
|
|
409
|
+
! shouldDisplayControls ||
|
|
410
|
+
! hasSupport( props.name )
|
|
411
|
+
) {
|
|
412
|
+
return null;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
const neededProps = {};
|
|
416
|
+
for ( const key of attributeKeys ) {
|
|
417
|
+
if ( props.attributes[ key ] ) {
|
|
418
|
+
neededProps[ key ] = props.attributes[ key ];
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return (
|
|
422
|
+
<Edit
|
|
423
|
+
// We can use the index because the array length
|
|
424
|
+
// is fixed per page load right now.
|
|
425
|
+
key={ i }
|
|
426
|
+
name={ props.name }
|
|
427
|
+
clientId={ props.clientId }
|
|
428
|
+
setAttributes={ props.setAttributes }
|
|
429
|
+
__unstableParentLayout={
|
|
430
|
+
props.__unstableParentLayout
|
|
431
|
+
}
|
|
432
|
+
// This component is pure, so only pass needed
|
|
433
|
+
// props!!!
|
|
434
|
+
{ ...neededProps }
|
|
435
|
+
/>
|
|
436
|
+
);
|
|
437
|
+
} ),
|
|
438
|
+
<OriginalBlockEdit key="edit" { ...props } />,
|
|
439
|
+
];
|
|
440
|
+
},
|
|
441
|
+
'withBlockEditHooks'
|
|
442
|
+
);
|
|
443
|
+
addFilter( 'editor.BlockEdit', 'core/editor/hooks', withBlockEditHooks );
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function BlockProps( { index, useBlockProps, setAllWrapperProps, ...props } ) {
|
|
447
|
+
const wrapperProps = useBlockProps( props );
|
|
448
|
+
const setWrapperProps = ( next ) =>
|
|
449
|
+
setAllWrapperProps( ( prev ) => {
|
|
450
|
+
const nextAll = [ ...prev ];
|
|
451
|
+
nextAll[ index ] = next;
|
|
452
|
+
return nextAll;
|
|
453
|
+
} );
|
|
454
|
+
// Setting state after every render is fine because this component is
|
|
455
|
+
// pure and will only re-render when needed props change.
|
|
456
|
+
useEffect( () => {
|
|
457
|
+
// We could shallow compare the props, but since this component only
|
|
458
|
+
// changes when needed attributes change, the benefit is probably small.
|
|
459
|
+
setWrapperProps( wrapperProps );
|
|
460
|
+
return () => {
|
|
461
|
+
setWrapperProps( undefined );
|
|
462
|
+
};
|
|
463
|
+
} );
|
|
464
|
+
return null;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
const BlockPropsPure = pure( BlockProps );
|
|
468
|
+
|
|
469
|
+
export function createBlockListBlockFilter( features ) {
|
|
470
|
+
const withBlockListBlockHooks = createHigherOrderComponent(
|
|
471
|
+
( BlockListBlock ) => ( props ) => {
|
|
472
|
+
const [ allWrapperProps, setAllWrapperProps ] = useState(
|
|
473
|
+
Array( features.length ).fill( undefined )
|
|
474
|
+
);
|
|
475
|
+
return [
|
|
476
|
+
...features.map( ( feature, i ) => {
|
|
477
|
+
const {
|
|
478
|
+
hasSupport,
|
|
479
|
+
attributeKeys = [],
|
|
480
|
+
useBlockProps,
|
|
481
|
+
} = feature;
|
|
482
|
+
|
|
483
|
+
const neededProps = {};
|
|
484
|
+
for ( const key of attributeKeys ) {
|
|
485
|
+
if ( props.attributes[ key ] ) {
|
|
486
|
+
neededProps[ key ] = props.attributes[ key ];
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
if (
|
|
491
|
+
! hasSupport( props.name ) ||
|
|
492
|
+
// Skip rendering if none of the needed attributes are
|
|
493
|
+
// set.
|
|
494
|
+
! Object.keys( neededProps ).length
|
|
495
|
+
) {
|
|
496
|
+
return null;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
return (
|
|
500
|
+
<BlockPropsPure
|
|
501
|
+
// We can use the index because the array length
|
|
502
|
+
// is fixed per page load right now.
|
|
503
|
+
key={ i }
|
|
504
|
+
index={ i }
|
|
505
|
+
useBlockProps={ useBlockProps }
|
|
506
|
+
// This component is pure, so we must pass a stable
|
|
507
|
+
// function reference.
|
|
508
|
+
setAllWrapperProps={ setAllWrapperProps }
|
|
509
|
+
name={ props.name }
|
|
510
|
+
// This component is pure, so only pass needed
|
|
511
|
+
// props!!!
|
|
512
|
+
{ ...neededProps }
|
|
513
|
+
/>
|
|
514
|
+
);
|
|
515
|
+
} ),
|
|
516
|
+
<BlockListBlock
|
|
517
|
+
key="edit"
|
|
518
|
+
{ ...props }
|
|
519
|
+
wrapperProps={ allWrapperProps
|
|
520
|
+
.filter( Boolean )
|
|
521
|
+
.reduce( ( acc, wrapperProps ) => {
|
|
522
|
+
return {
|
|
523
|
+
...acc,
|
|
524
|
+
...wrapperProps,
|
|
525
|
+
className: classnames(
|
|
526
|
+
acc.className,
|
|
527
|
+
wrapperProps.className
|
|
528
|
+
),
|
|
529
|
+
style: {
|
|
530
|
+
...acc.style,
|
|
531
|
+
...wrapperProps.style,
|
|
532
|
+
},
|
|
533
|
+
};
|
|
534
|
+
}, props.wrapperProps || {} ) }
|
|
535
|
+
/>,
|
|
536
|
+
];
|
|
537
|
+
},
|
|
538
|
+
'withBlockListBlockHooks'
|
|
539
|
+
);
|
|
540
|
+
addFilter(
|
|
541
|
+
'editor.BlockListBlock',
|
|
542
|
+
'core/editor/hooks',
|
|
543
|
+
withBlockListBlockHooks
|
|
544
|
+
);
|
|
545
|
+
}
|
package/src/private-apis.js
CHANGED
|
@@ -10,7 +10,6 @@ import ResizableBoxPopover from './components/resizable-box-popover';
|
|
|
10
10
|
import { ComposedPrivateInserter as PrivateInserter } from './components/inserter';
|
|
11
11
|
import { PrivateListView } from './components/list-view';
|
|
12
12
|
import BlockInfo from './components/block-info-slot-fill';
|
|
13
|
-
import BlockContextualToolbar from './components/block-tools/block-contextual-toolbar';
|
|
14
13
|
import { useShouldContextualToolbarShow } from './utils/use-should-contextual-toolbar-show';
|
|
15
14
|
import { cleanEmptyObject, useStyleOverride } from './hooks/utils';
|
|
16
15
|
import BlockQuickNavigation from './components/block-quick-navigation';
|
|
@@ -42,7 +41,6 @@ lock( privateApis, {
|
|
|
42
41
|
PrivateListView,
|
|
43
42
|
ResizableBoxPopover,
|
|
44
43
|
BlockInfo,
|
|
45
|
-
BlockContextualToolbar,
|
|
46
44
|
useShouldContextualToolbarShow,
|
|
47
45
|
cleanEmptyObject,
|
|
48
46
|
useStyleOverride,
|
|
@@ -290,3 +290,11 @@ export function deleteStyleOverride( id ) {
|
|
|
290
290
|
id,
|
|
291
291
|
};
|
|
292
292
|
}
|
|
293
|
+
|
|
294
|
+
export function syncDerivedBlockAttributes( clientId, attributes ) {
|
|
295
|
+
return {
|
|
296
|
+
type: 'SYNC_DERIVED_BLOCK_ATTRIBUTES',
|
|
297
|
+
clientIds: [ clientId ],
|
|
298
|
+
attributes,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
@@ -10,7 +10,12 @@ import {
|
|
|
10
10
|
getBlockOrder,
|
|
11
11
|
getBlockParents,
|
|
12
12
|
getBlockEditingMode,
|
|
13
|
+
getSettings,
|
|
14
|
+
__experimentalGetParsedPattern,
|
|
15
|
+
canInsertBlockType,
|
|
16
|
+
__experimentalGetAllowedPatterns,
|
|
13
17
|
} from './selectors';
|
|
18
|
+
import { getUserPatterns, checkAllowListRecursive } from './utils';
|
|
14
19
|
|
|
15
20
|
/**
|
|
16
21
|
* Returns true if the block interface is hidden, or false otherwise.
|
|
@@ -236,3 +241,43 @@ export const getInserterMediaCategories = createSelector(
|
|
|
236
241
|
state.registeredInserterMediaCategories,
|
|
237
242
|
]
|
|
238
243
|
);
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Returns whether there is at least one allowed pattern for inner blocks children.
|
|
247
|
+
* This is useful for deferring the parsing of all patterns until needed.
|
|
248
|
+
*
|
|
249
|
+
* @param {Object} state Editor state.
|
|
250
|
+
* @param {string} [rootClientId=null] Target root client ID.
|
|
251
|
+
*
|
|
252
|
+
* @return {boolean} If there is at least one allowed pattern.
|
|
253
|
+
*/
|
|
254
|
+
export const hasAllowedPatterns = createSelector(
|
|
255
|
+
( state, rootClientId = null ) => {
|
|
256
|
+
const patterns = state.settings.__experimentalBlockPatterns;
|
|
257
|
+
const userPatterns = getUserPatterns( state );
|
|
258
|
+
const { allowedBlockTypes } = getSettings( state );
|
|
259
|
+
return [ ...userPatterns, ...patterns ].some(
|
|
260
|
+
( { name, inserter = true } ) => {
|
|
261
|
+
if ( ! inserter ) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
const { blocks } = __experimentalGetParsedPattern(
|
|
265
|
+
state,
|
|
266
|
+
name
|
|
267
|
+
);
|
|
268
|
+
return (
|
|
269
|
+
checkAllowListRecursive( blocks, allowedBlockTypes ) &&
|
|
270
|
+
blocks.every( ( { name: blockName } ) =>
|
|
271
|
+
canInsertBlockType( state, blockName, rootClientId )
|
|
272
|
+
)
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
);
|
|
276
|
+
},
|
|
277
|
+
( state, rootClientId ) => [
|
|
278
|
+
...__experimentalGetAllowedPatterns.getDependants(
|
|
279
|
+
state,
|
|
280
|
+
rootClientId
|
|
281
|
+
),
|
|
282
|
+
]
|
|
283
|
+
);
|
package/src/store/reducer.js
CHANGED
|
@@ -283,6 +283,7 @@ const withBlockTree =
|
|
|
283
283
|
false
|
|
284
284
|
);
|
|
285
285
|
break;
|
|
286
|
+
case 'SYNC_DERIVED_BLOCK_ATTRIBUTES':
|
|
286
287
|
case 'UPDATE_BLOCK_ATTRIBUTES': {
|
|
287
288
|
newState.tree = new Map( newState.tree );
|
|
288
289
|
action.clientIds.forEach( ( clientId ) => {
|
|
@@ -456,6 +457,12 @@ function withPersistentBlockChange( reducer ) {
|
|
|
456
457
|
return ( state, action ) => {
|
|
457
458
|
let nextState = reducer( state, action );
|
|
458
459
|
|
|
460
|
+
if ( action.type === 'SYNC_DERIVED_BLOCK_ATTRIBUTES' ) {
|
|
461
|
+
return nextState.isPersistentChange
|
|
462
|
+
? { ...nextState, isPersistentChange: false }
|
|
463
|
+
: nextState;
|
|
464
|
+
}
|
|
465
|
+
|
|
459
466
|
const isExplicitPersistentChange =
|
|
460
467
|
action.type === 'MARK_LAST_CHANGE_AS_PERSISTENT' ||
|
|
461
468
|
markNextChangeAsNotPersistent;
|
|
@@ -860,6 +867,7 @@ export const blocks = pipe(
|
|
|
860
867
|
return newState;
|
|
861
868
|
}
|
|
862
869
|
|
|
870
|
+
case 'SYNC_DERIVED_BLOCK_ATTRIBUTES':
|
|
863
871
|
case 'UPDATE_BLOCK_ATTRIBUTES': {
|
|
864
872
|
// Avoid a state change if none of the block IDs are known.
|
|
865
873
|
if ( action.clientIds.every( ( id ) => ! state.get( id ) ) ) {
|
package/src/store/selectors.js
CHANGED
|
@@ -26,8 +26,12 @@ import { createRegistrySelector } from '@wordpress/data';
|
|
|
26
26
|
/**
|
|
27
27
|
* Internal dependencies
|
|
28
28
|
*/
|
|
29
|
+
import {
|
|
30
|
+
getUserPatterns,
|
|
31
|
+
checkAllowListRecursive,
|
|
32
|
+
checkAllowList,
|
|
33
|
+
} from './utils';
|
|
29
34
|
import { orderBy } from '../utils/sorting';
|
|
30
|
-
import { PATTERN_TYPES } from '../components/inserter/block-patterns-tab/utils';
|
|
31
35
|
|
|
32
36
|
/**
|
|
33
37
|
* A block selection object.
|
|
@@ -1481,22 +1485,6 @@ export function getTemplateLock( state, rootClientId ) {
|
|
|
1481
1485
|
return getBlockListSettings( state, rootClientId )?.templateLock ?? false;
|
|
1482
1486
|
}
|
|
1483
1487
|
|
|
1484
|
-
const checkAllowList = ( list, item, defaultResult = null ) => {
|
|
1485
|
-
if ( typeof list === 'boolean' ) {
|
|
1486
|
-
return list;
|
|
1487
|
-
}
|
|
1488
|
-
if ( Array.isArray( list ) ) {
|
|
1489
|
-
// TODO: when there is a canonical way to detect that we are editing a post
|
|
1490
|
-
// the following check should be changed to something like:
|
|
1491
|
-
// if ( list.includes( 'core/post-content' ) && getEditorMode() === 'post-content' && item === null )
|
|
1492
|
-
if ( list.includes( 'core/post-content' ) && item === null ) {
|
|
1493
|
-
return true;
|
|
1494
|
-
}
|
|
1495
|
-
return list.includes( item );
|
|
1496
|
-
}
|
|
1497
|
-
return defaultResult;
|
|
1498
|
-
};
|
|
1499
|
-
|
|
1500
1488
|
/**
|
|
1501
1489
|
* Determines if the given block type is allowed to be inserted into the block list.
|
|
1502
1490
|
* This function is not exported and not memoized because using a memoized selector
|
|
@@ -2249,58 +2237,6 @@ export const __experimentalGetDirectInsertBlock = createSelector(
|
|
|
2249
2237
|
]
|
|
2250
2238
|
);
|
|
2251
2239
|
|
|
2252
|
-
const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {
|
|
2253
|
-
if ( typeof allowedBlockTypes === 'boolean' ) {
|
|
2254
|
-
return allowedBlockTypes;
|
|
2255
|
-
}
|
|
2256
|
-
|
|
2257
|
-
const blocksQueue = [ ...blocks ];
|
|
2258
|
-
while ( blocksQueue.length > 0 ) {
|
|
2259
|
-
const block = blocksQueue.shift();
|
|
2260
|
-
|
|
2261
|
-
const isAllowed = checkAllowList(
|
|
2262
|
-
allowedBlockTypes,
|
|
2263
|
-
block.name || block.blockName,
|
|
2264
|
-
true
|
|
2265
|
-
);
|
|
2266
|
-
if ( ! isAllowed ) {
|
|
2267
|
-
return false;
|
|
2268
|
-
}
|
|
2269
|
-
|
|
2270
|
-
block.innerBlocks?.forEach( ( innerBlock ) => {
|
|
2271
|
-
blocksQueue.push( innerBlock );
|
|
2272
|
-
} );
|
|
2273
|
-
}
|
|
2274
|
-
|
|
2275
|
-
return true;
|
|
2276
|
-
};
|
|
2277
|
-
|
|
2278
|
-
function getUserPatterns( state ) {
|
|
2279
|
-
const userPatterns =
|
|
2280
|
-
state?.settings?.__experimentalReusableBlocks ?? EMPTY_ARRAY;
|
|
2281
|
-
const userPatternCategories =
|
|
2282
|
-
state?.settings?.__experimentalUserPatternCategories ?? [];
|
|
2283
|
-
const categories = new Map();
|
|
2284
|
-
userPatternCategories.forEach( ( userCategory ) =>
|
|
2285
|
-
categories.set( userCategory.id, userCategory )
|
|
2286
|
-
);
|
|
2287
|
-
return userPatterns.map( ( userPattern ) => {
|
|
2288
|
-
return {
|
|
2289
|
-
name: `core/block/${ userPattern.id }`,
|
|
2290
|
-
id: userPattern.id,
|
|
2291
|
-
type: PATTERN_TYPES.user,
|
|
2292
|
-
title: userPattern.title.raw,
|
|
2293
|
-
categories: userPattern.wp_pattern_category.map( ( catId ) =>
|
|
2294
|
-
categories && categories.get( catId )
|
|
2295
|
-
? categories.get( catId ).slug
|
|
2296
|
-
: catId
|
|
2297
|
-
),
|
|
2298
|
-
content: userPattern.content.raw,
|
|
2299
|
-
syncStatus: userPattern.wp_pattern_sync_status,
|
|
2300
|
-
};
|
|
2301
|
-
} );
|
|
2302
|
-
}
|
|
2303
|
-
|
|
2304
2240
|
export const __experimentalUserPatternCategories = createSelector(
|
|
2305
2241
|
( state ) => {
|
|
2306
2242
|
return state?.settings?.__experimentalUserPatternCategories;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { PATTERN_TYPES } from '../components/inserter/block-patterns-tab/utils';
|
|
5
|
+
|
|
6
|
+
const EMPTY_ARRAY = [];
|
|
7
|
+
|
|
8
|
+
export function getUserPatterns( state ) {
|
|
9
|
+
const userPatterns =
|
|
10
|
+
state?.settings?.__experimentalReusableBlocks ?? EMPTY_ARRAY;
|
|
11
|
+
const userPatternCategories =
|
|
12
|
+
state?.settings?.__experimentalUserPatternCategories ?? [];
|
|
13
|
+
const categories = new Map();
|
|
14
|
+
userPatternCategories.forEach( ( userCategory ) =>
|
|
15
|
+
categories.set( userCategory.id, userCategory )
|
|
16
|
+
);
|
|
17
|
+
return userPatterns.map( ( userPattern ) => {
|
|
18
|
+
return {
|
|
19
|
+
name: `core/block/${ userPattern.id }`,
|
|
20
|
+
id: userPattern.id,
|
|
21
|
+
type: PATTERN_TYPES.user,
|
|
22
|
+
title: userPattern.title.raw,
|
|
23
|
+
categories: userPattern.wp_pattern_category.map( ( catId ) =>
|
|
24
|
+
categories && categories.get( catId )
|
|
25
|
+
? categories.get( catId ).slug
|
|
26
|
+
: catId
|
|
27
|
+
),
|
|
28
|
+
content: userPattern.content.raw,
|
|
29
|
+
syncStatus: userPattern.wp_pattern_sync_status,
|
|
30
|
+
};
|
|
31
|
+
} );
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const checkAllowList = ( list, item, defaultResult = null ) => {
|
|
35
|
+
if ( typeof list === 'boolean' ) {
|
|
36
|
+
return list;
|
|
37
|
+
}
|
|
38
|
+
if ( Array.isArray( list ) ) {
|
|
39
|
+
// TODO: when there is a canonical way to detect that we are editing a post
|
|
40
|
+
// the following check should be changed to something like:
|
|
41
|
+
// if ( list.includes( 'core/post-content' ) && getEditorMode() === 'post-content' && item === null )
|
|
42
|
+
if ( list.includes( 'core/post-content' ) && item === null ) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
return list.includes( item );
|
|
46
|
+
}
|
|
47
|
+
return defaultResult;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {
|
|
51
|
+
if ( typeof allowedBlockTypes === 'boolean' ) {
|
|
52
|
+
return allowedBlockTypes;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const blocksQueue = [ ...blocks ];
|
|
56
|
+
while ( blocksQueue.length > 0 ) {
|
|
57
|
+
const block = blocksQueue.shift();
|
|
58
|
+
|
|
59
|
+
const isAllowed = checkAllowList(
|
|
60
|
+
allowedBlockTypes,
|
|
61
|
+
block.name || block.blockName,
|
|
62
|
+
true
|
|
63
|
+
);
|
|
64
|
+
if ( ! isAllowed ) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
block.innerBlocks?.forEach( ( innerBlock ) => {
|
|
69
|
+
blocksQueue.push( innerBlock );
|
|
70
|
+
} );
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return true;
|
|
74
|
+
};
|
package/src/style.scss
CHANGED
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
@import "./components/block-draggable/style.scss";
|
|
11
11
|
@import "./components/block-mover/style.scss";
|
|
12
12
|
@import "./components/block-navigation/style.scss";
|
|
13
|
-
@import "./components/block-parent-selector/style.scss";
|
|
14
13
|
@import "./components/block-patterns-list/style.scss";
|
|
15
14
|
@import "./components/block-patterns-paging/style.scss";
|
|
16
15
|
@import "./components/block-popover/style.scss";
|
|
@@ -60,7 +59,6 @@
|
|
|
60
59
|
|
|
61
60
|
@import "./components/block-toolbar/style.scss";
|
|
62
61
|
@import "./components/inserter/style.scss";
|
|
63
|
-
@import "./components/preview-options/style.scss";
|
|
64
62
|
@import "./components/spacing-sizes-control/style.scss";
|
|
65
63
|
|
|
66
64
|
@include wordpress-admin-schemes();
|
package/src/utils/object.js
CHANGED
|
@@ -2,28 +2,6 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { paramCase } from 'change-case';
|
|
5
|
-
import memoize from 'memize';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Converts a path to an array of its fragments.
|
|
9
|
-
* Supports strings, numbers and arrays:
|
|
10
|
-
*
|
|
11
|
-
* 'foo' => [ 'foo' ]
|
|
12
|
-
* 2 => [ '2' ]
|
|
13
|
-
* [ 'foo', 'bar' ] => [ 'foo', 'bar' ]
|
|
14
|
-
*
|
|
15
|
-
* @param {string|number|Array} path Path
|
|
16
|
-
* @return {Array} Normalized path.
|
|
17
|
-
*/
|
|
18
|
-
function normalizePath( path ) {
|
|
19
|
-
if ( Array.isArray( path ) ) {
|
|
20
|
-
return path;
|
|
21
|
-
} else if ( typeof path === 'number' ) {
|
|
22
|
-
return [ path.toString() ];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return [ path ];
|
|
26
|
-
}
|
|
27
5
|
|
|
28
6
|
/**
|
|
29
7
|
* Converts any string to kebab case.
|
|
@@ -55,33 +33,6 @@ export function kebabCase( str ) {
|
|
|
55
33
|
} );
|
|
56
34
|
}
|
|
57
35
|
|
|
58
|
-
/**
|
|
59
|
-
* Clones an object.
|
|
60
|
-
* Arrays are also cloned as arrays.
|
|
61
|
-
* Non-object values are returned unchanged.
|
|
62
|
-
*
|
|
63
|
-
* @param {*} object Object to clone.
|
|
64
|
-
* @return {*} Cloned object, or original literal non-object value.
|
|
65
|
-
*/
|
|
66
|
-
function cloneObject( object ) {
|
|
67
|
-
if ( Array.isArray( object ) ) {
|
|
68
|
-
return object.map( cloneObject );
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if ( object && typeof object === 'object' ) {
|
|
72
|
-
return {
|
|
73
|
-
...Object.fromEntries(
|
|
74
|
-
Object.entries( object ).map( ( [ key, value ] ) => [
|
|
75
|
-
key,
|
|
76
|
-
cloneObject( value ),
|
|
77
|
-
] )
|
|
78
|
-
),
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return object;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
36
|
/**
|
|
86
37
|
* Immutably sets a value inside an object. Like `lodash#set`, but returning a
|
|
87
38
|
* new object. Treats nullish initial values as empty objects. Clones any
|
|
@@ -93,27 +44,25 @@ function cloneObject( object ) {
|
|
|
93
44
|
* @return {Object} Cloned object with the new value set.
|
|
94
45
|
*/
|
|
95
46
|
export function setImmutably( object, path, value ) {
|
|
96
|
-
|
|
97
|
-
|
|
47
|
+
// Normalize path
|
|
48
|
+
path = Array.isArray( path ) ? [ ...path ] : [ path ];
|
|
98
49
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if ( Number.isInteger( path[ i + 1 ] ) ) {
|
|
102
|
-
acc[ key ] = [];
|
|
103
|
-
} else {
|
|
104
|
-
acc[ key ] = {};
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if ( i === normalizedPath.length - 1 ) {
|
|
108
|
-
acc[ key ] = value;
|
|
109
|
-
}
|
|
110
|
-
return acc[ key ];
|
|
111
|
-
}, newObject );
|
|
50
|
+
// Shallowly clone the base of the object
|
|
51
|
+
object = Array.isArray( object ) ? [ ...object ] : { ...object };
|
|
112
52
|
|
|
113
|
-
|
|
114
|
-
|
|
53
|
+
const leaf = path.pop();
|
|
54
|
+
|
|
55
|
+
// Traverse object from root to leaf, shallowly cloning at each level
|
|
56
|
+
let prev = object;
|
|
57
|
+
for ( const key of path ) {
|
|
58
|
+
const lvl = prev[ key ];
|
|
59
|
+
prev = prev[ key ] = Array.isArray( lvl ) ? [ ...lvl ] : { ...lvl };
|
|
60
|
+
}
|
|
115
61
|
|
|
116
|
-
|
|
62
|
+
prev[ leaf ] = value;
|
|
63
|
+
|
|
64
|
+
return object;
|
|
65
|
+
}
|
|
117
66
|
|
|
118
67
|
/**
|
|
119
68
|
* Helper util to return a value from a certain path of the object.
|
|
@@ -128,9 +77,9 @@ const stringToPath = memoize( ( path ) => path.split( '.' ) );
|
|
|
128
77
|
* @return {*} Value of the object property at the specified path.
|
|
129
78
|
*/
|
|
130
79
|
export const getValueFromObjectPath = ( object, path, defaultValue ) => {
|
|
131
|
-
const
|
|
80
|
+
const arrayPath = Array.isArray( path ) ? path : path.split( '.' );
|
|
132
81
|
let value = object;
|
|
133
|
-
|
|
82
|
+
arrayPath.forEach( ( fieldName ) => {
|
|
134
83
|
value = value?.[ fieldName ];
|
|
135
84
|
} );
|
|
136
85
|
return value ?? defaultValue;
|
package/src/utils/selection.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { RichTextData } from '@wordpress/rich-text';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* A robust way to retain selection position through various
|
|
3
8
|
* transforms is to insert a special character at the position and
|
|
@@ -19,8 +24,10 @@ export function retrieveSelectedAttribute( blockAttributes ) {
|
|
|
19
24
|
return Object.keys( blockAttributes ).find( ( name ) => {
|
|
20
25
|
const value = blockAttributes[ name ];
|
|
21
26
|
return (
|
|
22
|
-
typeof value === 'string' &&
|
|
23
|
-
|
|
27
|
+
( typeof value === 'string' || value instanceof RichTextData ) &&
|
|
28
|
+
// To do: refactor this to use rich text's selection instead, so we
|
|
29
|
+
// no longer have to use on this hack inserting a special character.
|
|
30
|
+
value.toString().indexOf( START_OF_SELECTED_AREA ) !== -1
|
|
24
31
|
);
|
|
25
32
|
} );
|
|
26
33
|
}
|