@wordpress/block-editor 11.8.0 → 12.1.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 +10 -0
- package/README.md +16 -4
- package/build/components/block-controls/slot.js +12 -4
- package/build/components/block-controls/slot.js.map +1 -1
- package/build/components/block-controls/slot.native.js +10 -1
- package/build/components/block-controls/slot.native.js.map +1 -1
- package/build/components/block-draggable/index.js +11 -7
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-draggable/use-scroll-when-dragging.js +2 -2
- package/build/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
- package/build/components/block-info-slot-fill/index.js +47 -0
- package/build/components/block-info-slot-fill/index.js.map +1 -0
- package/build/components/block-inspector/index.js +4 -2
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block-invalid-warning.native.js +15 -7
- package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build/components/block-list/block-list-item-cell.native.js +15 -2
- package/build/components/block-list/block-list-item-cell.native.js.map +1 -1
- package/build/components/block-list/block-list-item.native.js +158 -195
- package/build/components/block-list/block-list-item.native.js.map +1 -1
- package/build/components/block-list/block-outline.native.js +57 -0
- package/build/components/block-list/block-outline.native.js.map +1 -0
- package/build/components/block-list/block.native.js +343 -300
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +202 -298
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/insertion-point.native.js +4 -2
- package/build/components/block-list/insertion-point.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +8 -10
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +15 -4
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +2 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +40 -11
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +8 -30
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +3 -2
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build/components/editor-styles/index.js +4 -3
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +21 -14
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/global-styles/advanced-panel.js +86 -0
- package/build/components/global-styles/advanced-panel.js.map +1 -0
- package/build/components/global-styles/border-panel.js +2 -32
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +16 -13
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.native.js +174 -0
- package/build/components/global-styles/color-panel.native.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +12 -12
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +1 -1
- package/build/components/global-styles/effects-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +78 -14
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +1 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +24 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +10 -10
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +114 -81
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +30 -0
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/image-editor/use-save-image.js +24 -8
- package/build/components/image-editor/use-save-image.js.map +1 -1
- package/build/components/index.js +7 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +12 -7
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/index.js +2 -1
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter-draggable-blocks/index.js +5 -0
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/inspector-controls/fill.js +1 -1
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/inspector-controls/fill.native.js +1 -1
- package/build/components/inspector-controls/fill.native.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls/slot.js +3 -6
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/inspector-controls/slot.native.js +1 -1
- package/build/components/inspector-controls/slot.native.js.map +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js +2 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/line-height-control/index.js +7 -2
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/use-internal-input-value.js +9 -8
- package/build/components/link-control/use-internal-input-value.js.map +1 -1
- package/build/components/list-view/block-contents.js +7 -2
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block-select-button.js +9 -3
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +16 -25
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +37 -10
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +38 -18
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +2 -1
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +1 -1
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +163 -11
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/media-placeholder/index.js +68 -7
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +5 -5
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/multi-selection-inspector/index.js +2 -2
- package/build/components/multi-selection-inspector/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +12 -4
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +2 -7
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/leaf-more-menu.js +3 -1
- package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build/components/preview-options/index.js +6 -1
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/components/url-input/index.js +1 -2
- package/build/components/url-input/index.js.map +1 -1
- package/build/hooks/align.js +1 -1
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/border.js +1 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +8 -12
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/duotone.js +29 -4
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.native.js +8 -0
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/layout.js +2 -2
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/position.js +1 -1
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +1 -1
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/use-editor-wrapper-styles.native.js +255 -0
- package/build/hooks/use-editor-wrapper-styles.native.js.map +1 -0
- package/build/hooks/use-typography-props.js +14 -10
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/hooks/utils.js +15 -3
- package/build/hooks/utils.js.map +1 -1
- package/build/index.native.js +31 -0
- package/build/index.native.js.map +1 -0
- package/build/private-apis.js +10 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +7 -0
- package/build/store/actions.js.map +1 -1
- package/build/utils/object.js +5 -5
- package/build/utils/object.js.map +1 -1
- package/build/utils/transform-styles/index.js +2 -2
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build/utils/use-should-contextual-toolbar-show.js +72 -0
- package/build/utils/use-should-contextual-toolbar-show.js.map +1 -0
- package/build-module/components/block-controls/slot.js +11 -4
- package/build-module/components/block-controls/slot.js.map +1 -1
- package/build-module/components/block-controls/slot.native.js +9 -1
- package/build-module/components/block-controls/slot.native.js.map +1 -1
- package/build-module/components/block-draggable/index.js +10 -6
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-draggable/use-scroll-when-dragging.js +2 -2
- package/build-module/components/block-draggable/use-scroll-when-dragging.js.map +1 -1
- package/build-module/components/block-info-slot-fill/index.js +34 -0
- package/build-module/components/block-info-slot-fill/index.js.map +1 -0
- package/build-module/components/block-inspector/index.js +3 -2
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block-invalid-warning.native.js +16 -8
- package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build-module/components/block-list/block-list-item-cell.native.js +13 -2
- package/build-module/components/block-list/block-list-item-cell.native.js.map +1 -1
- package/build-module/components/block-list/block-list-item.native.js +160 -190
- package/build-module/components/block-list/block-list-item.native.js.map +1 -1
- package/build-module/components/block-list/block-outline.native.js +44 -0
- package/build-module/components/block-list/block-outline.native.js.map +1 -0
- package/build-module/components/block-list/block.native.js +341 -299
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +203 -293
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/insertion-point.native.js +4 -2
- package/build-module/components/block-list/insertion-point.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +8 -9
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +13 -5
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +2 -1
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +37 -11
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +8 -29
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +3 -2
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build-module/components/editor-styles/index.js +4 -3
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +21 -14
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/global-styles/advanced-panel.js +74 -0
- package/build-module/components/global-styles/advanced-panel.js.map +1 -0
- package/build-module/components/global-styles/border-panel.js +2 -32
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +18 -15
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.native.js +150 -0
- package/build-module/components/global-styles/color-panel.native.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +13 -13
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +2 -2
- package/build-module/components/global-styles/effects-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +78 -16
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +1 -2
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +3 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +11 -11
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +112 -81
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +25 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/image-editor/use-save-image.js +24 -8
- package/build-module/components/image-editor/use-save-image.js.map +1 -1
- package/build-module/components/index.js +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +12 -6
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/index.js +2 -1
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.js +4 -0
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +1 -1
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/inspector-controls/fill.native.js +1 -1
- package/build-module/components/inspector-controls/fill.native.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +4 -7
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/inspector-controls/slot.native.js +1 -1
- package/build-module/components/inspector-controls/slot.native.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +2 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/line-height-control/index.js +7 -2
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/use-internal-input-value.js +9 -8
- package/build-module/components/link-control/use-internal-input-value.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +7 -3
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +9 -3
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +18 -26
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +36 -10
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +39 -19
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +2 -1
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +1 -1
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +160 -11
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +66 -7
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +5 -5
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/multi-selection-inspector/index.js +2 -2
- package/build-module/components/multi-selection-inspector/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +12 -4
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +1 -5
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/leaf-more-menu.js +3 -1
- package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build-module/components/preview-options/index.js +7 -2
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/components/url-input/index.js +1 -2
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/hooks/align.js +1 -1
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/border.js +1 -1
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +8 -11
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/duotone.js +28 -5
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.native.js +1 -0
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/layout.js +2 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/position.js +1 -1
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +1 -1
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/use-editor-wrapper-styles.native.js +242 -0
- package/build-module/hooks/use-editor-wrapper-styles.native.js.map +1 -0
- package/build-module/hooks/use-typography-props.js +14 -10
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/hooks/utils.js +16 -4
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/index.native.js +6 -0
- package/build-module/index.native.js.map +1 -0
- package/build-module/private-apis.js +7 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +7 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/utils/object.js +4 -4
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +2 -2
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-module/utils/use-should-contextual-toolbar-show.js +60 -0
- package/build-module/utils/use-should-contextual-toolbar-show.js.map +1 -0
- package/build-style/content-rtl.css +9 -7
- package/build-style/content.css +9 -7
- package/build-style/style-rtl.css +257 -56
- package/build-style/style.css +257 -56
- package/package.json +32 -32
- package/src/components/block-breadcrumb/style.scss +2 -1
- package/src/components/block-controls/slot.js +8 -4
- package/src/components/block-controls/slot.native.js +6 -1
- package/src/components/block-draggable/index.js +10 -6
- package/src/components/block-draggable/use-scroll-when-dragging.js +8 -2
- package/src/components/block-info-slot-fill/index.js +24 -0
- package/src/components/block-inspector/index.js +3 -0
- package/src/components/block-list/block-invalid-warning.native.js +17 -9
- package/src/components/block-list/block-list-item-cell.native.js +10 -1
- package/src/components/block-list/block-list-item.native.js +180 -208
- package/src/components/block-list/block-outline.native.js +58 -0
- package/src/components/block-list/block.native.js +564 -524
- package/src/components/block-list/content.scss +16 -16
- package/src/components/block-list/index.native.js +229 -298
- package/src/components/block-list/insertion-point.native.js +2 -2
- package/src/components/block-list/test/block-invalid-warning.native.js +48 -0
- package/src/components/block-list/test/index.native.js +205 -0
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +3 -1
- package/src/components/block-mobile-toolbar/test/block-actions-menu.native.js +9 -9
- package/src/components/block-mover/style.scss +10 -4
- package/src/components/block-mover/test/index.native.js +4 -4
- package/src/components/block-pattern-setup/style.scss +1 -4
- package/src/components/block-patterns-list/style.scss +1 -4
- package/src/components/block-settings-menu/block-settings-dropdown.js +10 -17
- package/src/components/block-settings-menu-controls/index.js +24 -4
- package/src/components/block-styles/style.scss +4 -4
- package/src/components/block-toolbar/index.js +4 -3
- package/src/components/block-toolbar/style.scss +56 -33
- package/src/components/block-tools/block-contextual-toolbar.js +64 -15
- package/src/components/block-tools/selected-block-popover.js +11 -46
- package/src/components/block-tools/style.scss +165 -3
- package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +16 -2
- package/src/components/editor-styles/index.js +9 -5
- package/src/components/font-sizes/fluid-utils.js +31 -14
- package/src/components/font-sizes/test/fluid-utils.js +5 -16
- package/src/components/global-styles/advanced-panel.js +82 -0
- package/src/components/global-styles/border-panel.js +1 -30
- package/src/components/global-styles/color-panel.js +19 -14
- package/src/components/global-styles/color-panel.native.js +207 -0
- package/src/components/global-styles/dimensions-panel.js +23 -13
- package/src/components/global-styles/effects-panel.js +2 -2
- package/src/components/global-styles/filters-panel.js +90 -17
- package/src/components/global-styles/hooks.js +1 -5
- package/src/components/global-styles/index.js +6 -1
- package/src/components/global-styles/style.scss +16 -1
- package/src/components/global-styles/test/typography-utils.js +63 -22
- package/src/components/global-styles/test/use-global-styles-output.js +126 -4
- package/src/components/global-styles/test/utils.js +57 -1
- package/src/components/global-styles/typography-panel.js +38 -12
- package/src/components/global-styles/use-global-styles-output.js +85 -67
- package/src/components/global-styles/utils.js +27 -0
- package/src/components/image-editor/use-save-image.js +20 -9
- package/src/components/index.js +1 -0
- package/src/components/inserter/block-types-tab.js +9 -6
- package/src/components/inserter/index.js +1 -1
- package/src/components/inserter-draggable-blocks/index.js +4 -0
- package/src/components/inspector-controls/fill.js +1 -1
- package/src/components/inspector-controls/fill.native.js +1 -1
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls/slot.js +4 -9
- package/src/components/inspector-controls/slot.native.js +1 -1
- package/src/components/inspector-controls-tabs/styles-tab.js +1 -0
- package/src/components/line-height-control/index.js +7 -2
- package/src/components/line-height-control/stories/index.js +1 -1
- package/src/components/link-control/test/index.js +42 -0
- package/src/components/link-control/use-internal-input-value.js +8 -7
- package/src/components/list-view/block-contents.js +26 -20
- package/src/components/list-view/block-select-button.js +11 -2
- package/src/components/list-view/block.js +28 -33
- package/src/components/list-view/drop-indicator.js +67 -22
- package/src/components/list-view/index.js +33 -14
- package/src/components/list-view/leaf.js +1 -0
- package/src/components/list-view/style.scss +18 -3
- package/src/components/list-view/test/use-list-view-drop-zone.js +88 -12
- package/src/components/list-view/use-block-selection.js +1 -1
- package/src/components/list-view/use-list-view-drop-zone.js +194 -11
- package/src/components/media-placeholder/index.js +74 -1
- package/src/components/media-replace-flow/README.md +3 -2
- package/src/components/media-replace-flow/index.js +4 -5
- package/src/components/multi-selection-inspector/index.js +2 -2
- package/src/components/navigable-toolbar/index.js +12 -3
- package/src/components/off-canvas-editor/appender.js +1 -4
- package/src/components/off-canvas-editor/leaf-more-menu.js +2 -1
- package/src/components/preview-options/index.js +9 -2
- package/src/components/spacing-sizes-control/spacing-input-control.js +1 -0
- package/src/components/url-input/index.js +1 -2
- package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -3
- package/src/hooks/align.js +2 -1
- package/src/hooks/border.js +2 -1
- package/src/hooks/color.js +2 -1
- package/src/hooks/content-lock-ui.js +3 -15
- package/src/hooks/duotone.js +47 -25
- package/src/hooks/index.native.js +1 -0
- package/src/hooks/layout.js +4 -2
- package/src/hooks/position.js +2 -1
- package/src/hooks/style.js +2 -1
- package/src/hooks/test/anchor.js +113 -0
- package/src/hooks/test/color.js +0 -9
- package/src/hooks/test/use-editor-wrapper-styles.native.js +282 -0
- package/src/hooks/test/use-typography-props.js +49 -4
- package/src/hooks/test/utils.js +20 -101
- package/src/hooks/use-editor-wrapper-styles.native.js +250 -0
- package/src/hooks/use-editor-wrapper-styles.native.scss +11 -0
- package/src/hooks/use-typography-props.js +10 -11
- package/src/hooks/utils.js +20 -3
- package/src/index.native.js +6 -0
- package/src/private-apis.js +6 -0
- package/src/store/actions.js +7 -0
- package/src/utils/object.js +4 -4
- package/src/utils/test/object.js +21 -21
- package/src/utils/transform-styles/index.js +2 -2
- package/src/utils/use-should-contextual-toolbar-show.js +85 -0
- package/tsconfig.json +2 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/hooks/color-panel.native.js +0 -77
- package/build/hooks/color-panel.native.js.map +0 -1
- package/build-module/hooks/color-panel.native.js +0 -62
- package/build-module/hooks/color-panel.native.js.map +0 -1
- package/src/hooks/color-panel.native.js +0 -63
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useWindowDimensions } from 'react-native';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useMemo } from '@wordpress/element';
|
|
10
|
+
import {
|
|
11
|
+
ALIGNMENT_BREAKPOINTS,
|
|
12
|
+
WIDE_ALIGNMENTS,
|
|
13
|
+
alignmentHelpers,
|
|
14
|
+
} from '@wordpress/components';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
import styles from './use-editor-wrapper-styles.scss';
|
|
20
|
+
|
|
21
|
+
const ALIGNMENT_MAX_WIDTH = {
|
|
22
|
+
full: '100%',
|
|
23
|
+
wide: 1054,
|
|
24
|
+
wideMedium: 770,
|
|
25
|
+
wideLandscape: 662,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const BLOCK_DEFAULT_MARGIN = 16;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Get the styles for the wide width alignment.
|
|
32
|
+
*
|
|
33
|
+
* @param {Object} [options] The options for the helper.
|
|
34
|
+
* @param {string} options.align The alignment value.
|
|
35
|
+
* @param {boolean} options.isLandscape Whether the screen is in landscape mode.
|
|
36
|
+
* @param {number} options.width The width of the screen.
|
|
37
|
+
* @return {Object} An object containing the styles for the wide width alignment.
|
|
38
|
+
*/
|
|
39
|
+
function getWideWidthStyles( { align, isLandscape, width } = {} ) {
|
|
40
|
+
if ( align !== WIDE_ALIGNMENTS.alignments.wide ) {
|
|
41
|
+
return {};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if ( isLandscape && width < ALIGNMENT_BREAKPOINTS.large ) {
|
|
45
|
+
return { maxWidth: ALIGNMENT_MAX_WIDTH.wideLandscape };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if ( width <= ALIGNMENT_BREAKPOINTS.small ) {
|
|
49
|
+
return { maxWidth: width };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (
|
|
53
|
+
width >= ALIGNMENT_BREAKPOINTS.medium &&
|
|
54
|
+
width < ALIGNMENT_BREAKPOINTS.wide
|
|
55
|
+
) {
|
|
56
|
+
return { maxWidth: ALIGNMENT_MAX_WIDTH.wideMedium };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return { maxWidth: ALIGNMENT_MAX_WIDTH.wide };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Get the styles for the full width alignment.
|
|
64
|
+
*
|
|
65
|
+
* @param {Object} [options] The options for the helper.
|
|
66
|
+
* @param {string} options.align The alignment value.
|
|
67
|
+
* @param {string} options.blockName The name of the block.
|
|
68
|
+
* @param {boolean} options.hasParents Whether the block has parents.
|
|
69
|
+
* @param {string} options.parentBlockName The name of the parent block.
|
|
70
|
+
* @return {Object} An object containing the styles for the full width alignment.
|
|
71
|
+
*/
|
|
72
|
+
function getFullWidthStyles( {
|
|
73
|
+
align,
|
|
74
|
+
blockName,
|
|
75
|
+
hasParents,
|
|
76
|
+
parentBlockName,
|
|
77
|
+
} = {} ) {
|
|
78
|
+
const { isContainerRelated, isFullWidth } = alignmentHelpers;
|
|
79
|
+
const fullWidthStyles = isFullWidth( align )
|
|
80
|
+
? { maxWidth: ALIGNMENT_MAX_WIDTH.full }
|
|
81
|
+
: {};
|
|
82
|
+
|
|
83
|
+
if (
|
|
84
|
+
! align &&
|
|
85
|
+
hasParents &&
|
|
86
|
+
! isContainerRelated( parentBlockName ) &&
|
|
87
|
+
isContainerRelated( blockName )
|
|
88
|
+
) {
|
|
89
|
+
fullWidthStyles.paddingHorizontal = BLOCK_DEFAULT_MARGIN;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return fullWidthStyles;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Get the block margin based on various conditions.
|
|
97
|
+
*
|
|
98
|
+
* @param {Object} [options] The options for the helper.
|
|
99
|
+
* @param {string} options.align The alignment value.
|
|
100
|
+
* @param {string} options.blockName The name of the block.
|
|
101
|
+
* @param {number} options.blockWidth The width of the block.
|
|
102
|
+
* @param {boolean} options.hasParents Whether the block has parents.
|
|
103
|
+
* @param {number} options.marginHorizontal Default horizontal margin.
|
|
104
|
+
* @param {string} options.parentBlockAlignment The alignment of the parent block.
|
|
105
|
+
* @param {string} options.parentBlockName The name of the parent block.
|
|
106
|
+
* @param {number} options.parentWidth The width of the parent block.
|
|
107
|
+
* @param {number} options.width The width of the screen.
|
|
108
|
+
* @return {number} The calculated block margin.
|
|
109
|
+
*/
|
|
110
|
+
function getBlockMargin( {
|
|
111
|
+
align,
|
|
112
|
+
blockName,
|
|
113
|
+
blockWidth,
|
|
114
|
+
hasParents,
|
|
115
|
+
marginHorizontal,
|
|
116
|
+
parentBlockAlignment,
|
|
117
|
+
parentBlockName,
|
|
118
|
+
parentWidth,
|
|
119
|
+
width,
|
|
120
|
+
} = {} ) {
|
|
121
|
+
const { isContainerRelated, isWider, isWideWidth, isFullWidth } =
|
|
122
|
+
alignmentHelpers;
|
|
123
|
+
|
|
124
|
+
if ( isFullWidth( align ) ) {
|
|
125
|
+
if ( ! hasParents ) {
|
|
126
|
+
return 0;
|
|
127
|
+
}
|
|
128
|
+
return marginHorizontal;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if ( isWideWidth( align ) ) {
|
|
132
|
+
return marginHorizontal;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (
|
|
136
|
+
isFullWidth( parentBlockAlignment ) &&
|
|
137
|
+
! isWider( blockWidth, 'medium' )
|
|
138
|
+
) {
|
|
139
|
+
if ( isContainerRelated( blockName ) || isWider( width, 'mobile' ) ) {
|
|
140
|
+
return marginHorizontal;
|
|
141
|
+
}
|
|
142
|
+
return marginHorizontal * 2;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (
|
|
146
|
+
isContainerRelated( parentBlockName ) &&
|
|
147
|
+
! isContainerRelated( blockName )
|
|
148
|
+
) {
|
|
149
|
+
const isScreenWidthEqual = parentWidth === width;
|
|
150
|
+
if ( isScreenWidthEqual || isWider( width, 'mobile' ) ) {
|
|
151
|
+
return marginHorizontal;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return marginHorizontal;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Custom hook to get the styles and margin for the editor wrapper.
|
|
160
|
+
*
|
|
161
|
+
* @param {Object} [props] The props for the hook.
|
|
162
|
+
* @param {string} props.align The alignment value.
|
|
163
|
+
* @param {string} props.blockName The name of the block.
|
|
164
|
+
* @param {number} props.blockWidth The width of the block.
|
|
165
|
+
* @param {string} props.contentResizeMode The content resize mode.
|
|
166
|
+
* @param {boolean} props.hasParents Whether the block has parents.
|
|
167
|
+
* @param {number} props.marginHorizontal Default horizontal margin.
|
|
168
|
+
* @param {string} props.parentBlockAlignment The alignment of the parent block.
|
|
169
|
+
* @param {string} props.parentBlockName The name of the parent block.
|
|
170
|
+
* @param {number} props.parentWidth The width of the parent block.
|
|
171
|
+
* @param {boolean} [props.reversed=false] Whether the flex direction should be reversed.
|
|
172
|
+
* @return {[Array, number]} An array containing the wrapper styles and block margin.
|
|
173
|
+
*/
|
|
174
|
+
export function useEditorWrapperStyles( {
|
|
175
|
+
align,
|
|
176
|
+
blockName,
|
|
177
|
+
blockWidth,
|
|
178
|
+
contentResizeMode,
|
|
179
|
+
hasParents,
|
|
180
|
+
marginHorizontal,
|
|
181
|
+
parentBlockAlignment,
|
|
182
|
+
parentBlockName,
|
|
183
|
+
parentWidth,
|
|
184
|
+
reversed = false,
|
|
185
|
+
} = {} ) {
|
|
186
|
+
const { width, height } = useWindowDimensions();
|
|
187
|
+
const isLandscape = width >= height;
|
|
188
|
+
|
|
189
|
+
const blockMargin = useMemo(
|
|
190
|
+
() =>
|
|
191
|
+
getBlockMargin( {
|
|
192
|
+
align,
|
|
193
|
+
blockName,
|
|
194
|
+
blockWidth,
|
|
195
|
+
hasParents,
|
|
196
|
+
marginHorizontal,
|
|
197
|
+
parentBlockAlignment,
|
|
198
|
+
parentBlockName,
|
|
199
|
+
parentWidth,
|
|
200
|
+
width,
|
|
201
|
+
} ),
|
|
202
|
+
[
|
|
203
|
+
align,
|
|
204
|
+
blockName,
|
|
205
|
+
blockWidth,
|
|
206
|
+
hasParents,
|
|
207
|
+
marginHorizontal,
|
|
208
|
+
parentBlockAlignment,
|
|
209
|
+
parentBlockName,
|
|
210
|
+
parentWidth,
|
|
211
|
+
width,
|
|
212
|
+
]
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
const wrapperStyles = useMemo( () => {
|
|
216
|
+
let canvasStyles;
|
|
217
|
+
|
|
218
|
+
if ( contentResizeMode === 'stretch' ) {
|
|
219
|
+
// For these cases, no width constraints should be added.
|
|
220
|
+
canvasStyles = { flex: 1 };
|
|
221
|
+
} else if ( reversed ) {
|
|
222
|
+
canvasStyles = styles[ 'use-editor-wrapper-styles--reversed' ];
|
|
223
|
+
} else {
|
|
224
|
+
canvasStyles = styles[ 'use-editor-wrapper-styles' ];
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const alignmentStyles = {
|
|
228
|
+
...getWideWidthStyles( { align, isLandscape, width } ),
|
|
229
|
+
...getFullWidthStyles( {
|
|
230
|
+
align,
|
|
231
|
+
blockName,
|
|
232
|
+
hasParents,
|
|
233
|
+
parentBlockName,
|
|
234
|
+
} ),
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
return [ canvasStyles, alignmentStyles ];
|
|
238
|
+
}, [
|
|
239
|
+
align,
|
|
240
|
+
blockName,
|
|
241
|
+
hasParents,
|
|
242
|
+
parentBlockName,
|
|
243
|
+
isLandscape,
|
|
244
|
+
width,
|
|
245
|
+
contentResizeMode,
|
|
246
|
+
reversed,
|
|
247
|
+
] );
|
|
248
|
+
|
|
249
|
+
return [ wrapperStyles, blockMargin ];
|
|
250
|
+
}
|
|
@@ -11,25 +11,23 @@ import { getInlineStyles } from './style';
|
|
|
11
11
|
import { getFontSizeClass } from '../components/font-sizes';
|
|
12
12
|
import { getComputedFluidTypographyValue } from '../components/font-sizes/fluid-utils';
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
/*
|
|
15
|
+
* This utility is intended to assist where the serialization of the typography
|
|
16
|
+
* block support is being skipped for a block but the typography related CSS
|
|
17
|
+
* styles still need to be generated so they can be applied to inner elements.
|
|
18
|
+
*/
|
|
18
19
|
/**
|
|
19
20
|
* Provides the CSS class names and inline styles for a block's typography support
|
|
20
21
|
* attributes.
|
|
21
22
|
*
|
|
22
|
-
* @param {Object} attributes
|
|
23
|
-
* @param {Object|boolean}
|
|
24
|
-
* otherwise an object containing theme fluid typography settings.
|
|
23
|
+
* @param {Object} attributes Block attributes.
|
|
24
|
+
* @param {Object|boolean} settings Merged theme.json settings
|
|
25
25
|
*
|
|
26
26
|
* @return {Object} Typography block support derived CSS classes & styles.
|
|
27
27
|
*/
|
|
28
|
-
export function getTypographyClassesAndStyles(
|
|
29
|
-
attributes,
|
|
30
|
-
fluidTypographySettings
|
|
31
|
-
) {
|
|
28
|
+
export function getTypographyClassesAndStyles( attributes, settings ) {
|
|
32
29
|
let typographyStyles = attributes?.style?.typography || {};
|
|
30
|
+
const fluidTypographySettings = settings?.typography?.fluid;
|
|
33
31
|
|
|
34
32
|
if (
|
|
35
33
|
!! fluidTypographySettings &&
|
|
@@ -40,6 +38,7 @@ export function getTypographyClassesAndStyles(
|
|
|
40
38
|
getComputedFluidTypographyValue( {
|
|
41
39
|
fontSize: attributes?.style?.typography?.fontSize,
|
|
42
40
|
minimumFontSizeLimit: fluidTypographySettings?.minFontSize,
|
|
41
|
+
maximumViewPortWidth: settings?.layout?.wideSize,
|
|
43
42
|
} ) || attributes?.style?.typography?.fontSize;
|
|
44
43
|
typographyStyles = {
|
|
45
44
|
...typographyStyles,
|
package/src/hooks/utils.js
CHANGED
|
@@ -14,7 +14,7 @@ import { useMemo } from '@wordpress/element';
|
|
|
14
14
|
*/
|
|
15
15
|
import { useSetting } from '../components';
|
|
16
16
|
import { useSettingsForBlockElement } from '../components/global-styles/hooks';
|
|
17
|
-
import {
|
|
17
|
+
import { setImmutably } from '../utils/object';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Removed falsy values from nested object.
|
|
@@ -33,7 +33,7 @@ export const cleanEmptyObject = ( object ) => {
|
|
|
33
33
|
const cleanedNestedObjects = Object.fromEntries(
|
|
34
34
|
Object.entries( object )
|
|
35
35
|
.map( ( [ key, value ] ) => [ key, cleanEmptyObject( value ) ] )
|
|
36
|
-
.filter( ( [ , value ] ) =>
|
|
36
|
+
.filter( ( [ , value ] ) => value !== undefined )
|
|
37
37
|
);
|
|
38
38
|
return isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;
|
|
39
39
|
};
|
|
@@ -82,7 +82,7 @@ export function transformStyles(
|
|
|
82
82
|
if ( styleValue ) {
|
|
83
83
|
returnBlock = {
|
|
84
84
|
...returnBlock,
|
|
85
|
-
attributes:
|
|
85
|
+
attributes: setImmutably(
|
|
86
86
|
returnBlock.attributes,
|
|
87
87
|
path,
|
|
88
88
|
styleValue
|
|
@@ -150,9 +150,14 @@ export function useBlockSettings( name, parentLayout ) {
|
|
|
150
150
|
const borderWidth = useSetting( 'border.width' );
|
|
151
151
|
const customColorsEnabled = useSetting( 'color.custom' );
|
|
152
152
|
const customColors = useSetting( 'color.palette.custom' );
|
|
153
|
+
const customDuotone = useSetting( 'color.customDuotone' );
|
|
153
154
|
const themeColors = useSetting( 'color.palette.theme' );
|
|
154
155
|
const defaultColors = useSetting( 'color.palette.default' );
|
|
155
156
|
const defaultPalette = useSetting( 'color.defaultPalette' );
|
|
157
|
+
const defaultDuotone = useSetting( 'color.defaultDuotone' );
|
|
158
|
+
const userDuotonePalette = useSetting( 'color.duotone.custom' );
|
|
159
|
+
const themeDuotonePalette = useSetting( 'color.duotone.theme' );
|
|
160
|
+
const defaultDuotonePalette = useSetting( 'color.duotone.default' );
|
|
156
161
|
const userGradientPalette = useSetting( 'color.gradients.custom' );
|
|
157
162
|
const themeGradientPalette = useSetting( 'color.gradients.theme' );
|
|
158
163
|
const defaultGradientPalette = useSetting( 'color.gradients.default' );
|
|
@@ -175,10 +180,17 @@ export function useBlockSettings( name, parentLayout ) {
|
|
|
175
180
|
theme: themeGradientPalette,
|
|
176
181
|
default: defaultGradientPalette,
|
|
177
182
|
},
|
|
183
|
+
duotone: {
|
|
184
|
+
custom: userDuotonePalette,
|
|
185
|
+
theme: themeDuotonePalette,
|
|
186
|
+
default: defaultDuotonePalette,
|
|
187
|
+
},
|
|
178
188
|
defaultGradients,
|
|
179
189
|
defaultPalette,
|
|
190
|
+
defaultDuotone,
|
|
180
191
|
custom: customColorsEnabled,
|
|
181
192
|
customGradient: areCustomGradientsEnabled,
|
|
193
|
+
customDuotone,
|
|
182
194
|
background: isBackgroundEnabled,
|
|
183
195
|
link: isLinkEnabled,
|
|
184
196
|
text: isTextEnabled,
|
|
@@ -245,9 +257,14 @@ export function useBlockSettings( name, parentLayout ) {
|
|
|
245
257
|
borderWidth,
|
|
246
258
|
customColorsEnabled,
|
|
247
259
|
customColors,
|
|
260
|
+
customDuotone,
|
|
248
261
|
themeColors,
|
|
249
262
|
defaultColors,
|
|
250
263
|
defaultPalette,
|
|
264
|
+
defaultDuotone,
|
|
265
|
+
userDuotonePalette,
|
|
266
|
+
themeDuotonePalette,
|
|
267
|
+
defaultDuotonePalette,
|
|
251
268
|
userGradientPalette,
|
|
252
269
|
themeGradientPalette,
|
|
253
270
|
defaultGradientPalette,
|
package/src/private-apis.js
CHANGED
|
@@ -9,6 +9,9 @@ import LeafMoreMenu from './components/off-canvas-editor/leaf-more-menu';
|
|
|
9
9
|
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
|
+
import BlockInfo from './components/block-info-slot-fill';
|
|
13
|
+
import { useShouldContextualToolbarShow } from './utils/use-should-contextual-toolbar-show';
|
|
14
|
+
import { cleanEmptyObject } from './hooks/utils';
|
|
12
15
|
|
|
13
16
|
/**
|
|
14
17
|
* Private @wordpress/block-editor APIs.
|
|
@@ -22,4 +25,7 @@ lock( privateApis, {
|
|
|
22
25
|
PrivateInserter,
|
|
23
26
|
PrivateListView,
|
|
24
27
|
ResizableBoxPopover,
|
|
28
|
+
BlockInfo,
|
|
29
|
+
useShouldContextualToolbarShow,
|
|
30
|
+
cleanEmptyObject,
|
|
25
31
|
} );
|
package/src/store/actions.js
CHANGED
|
@@ -543,6 +543,9 @@ export function moveBlockToPosition(
|
|
|
543
543
|
/**
|
|
544
544
|
* Action that inserts a single block, optionally at a specific index respective a root block list.
|
|
545
545
|
*
|
|
546
|
+
* Only allowed blocks are inserted. The action may fail silently for blocks that are not allowed or if
|
|
547
|
+
* a templateLock is active on the block list.
|
|
548
|
+
*
|
|
546
549
|
* @param {Object} block Block object to insert.
|
|
547
550
|
* @param {?number} index Index at which block should be inserted.
|
|
548
551
|
* @param {?string} rootClientId Optional root client ID of block list on which to insert.
|
|
@@ -572,12 +575,16 @@ export function insertBlock(
|
|
|
572
575
|
/**
|
|
573
576
|
* Action that inserts an array of blocks, optionally at a specific index respective a root block list.
|
|
574
577
|
*
|
|
578
|
+
* Only allowed blocks are inserted. The action may fail silently for blocks that are not allowed or if
|
|
579
|
+
* a templateLock is active on the block list.
|
|
580
|
+
*
|
|
575
581
|
* @param {Object[]} blocks Block objects to insert.
|
|
576
582
|
* @param {?number} index Index at which block should be inserted.
|
|
577
583
|
* @param {?string} rootClientId Optional root client ID of block list on which to insert.
|
|
578
584
|
* @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to true.
|
|
579
585
|
* @param {0|-1|null} initialPosition Initial focus position. Setting it to null prevent focusing the inserted block.
|
|
580
586
|
* @param {?Object} meta Optional Meta values to be passed to the action object.
|
|
587
|
+
*
|
|
581
588
|
* @return {Object} Action object.
|
|
582
589
|
*/
|
|
583
590
|
export const insertBlocks =
|
package/src/utils/object.js
CHANGED
|
@@ -42,16 +42,16 @@ function cloneObject( object ) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
45
|
+
* Immutably sets a value inside an object. Like `lodash#set`, but returning a
|
|
46
|
+
* new object. Treats nullish initial values as empty objects. Clones any
|
|
47
|
+
* nested objects.
|
|
48
48
|
*
|
|
49
49
|
* @param {Object} object Object to set a value in.
|
|
50
50
|
* @param {number|string|Array} path Path in the object to modify.
|
|
51
51
|
* @param {*} value New value to set.
|
|
52
52
|
* @return {Object} Cloned object with the new value set.
|
|
53
53
|
*/
|
|
54
|
-
export function
|
|
54
|
+
export function setImmutably( object, path, value ) {
|
|
55
55
|
const normalizedPath = normalizePath( path );
|
|
56
56
|
const newObject = object ? cloneObject( object ) : {};
|
|
57
57
|
|
package/src/utils/test/object.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { setImmutably } from '../object';
|
|
5
5
|
|
|
6
|
-
describe( '
|
|
6
|
+
describe( 'setImmutably', () => {
|
|
7
7
|
describe( 'handling falsy values properly', () => {
|
|
8
8
|
it( 'should create a new object if `undefined` is passed', () => {
|
|
9
|
-
const result =
|
|
9
|
+
const result = setImmutably( undefined, 'test', 1 );
|
|
10
10
|
|
|
11
11
|
expect( result ).toEqual( { test: 1 } );
|
|
12
12
|
} );
|
|
13
13
|
|
|
14
14
|
it( 'should create a new object if `null` is passed', () => {
|
|
15
|
-
const result =
|
|
15
|
+
const result = setImmutably( null, 'test', 1 );
|
|
16
16
|
|
|
17
17
|
expect( result ).toEqual( { test: 1 } );
|
|
18
18
|
} );
|
|
19
19
|
|
|
20
20
|
it( 'should create a new object if `false` is passed', () => {
|
|
21
|
-
const result =
|
|
21
|
+
const result = setImmutably( false, 'test', 1 );
|
|
22
22
|
|
|
23
23
|
expect( result ).toEqual( { test: 1 } );
|
|
24
24
|
} );
|
|
25
25
|
|
|
26
26
|
it( 'should create a new object if `0` is passed', () => {
|
|
27
|
-
const result =
|
|
27
|
+
const result = setImmutably( 0, 'test', 1 );
|
|
28
28
|
|
|
29
29
|
expect( result ).toEqual( { test: 1 } );
|
|
30
30
|
} );
|
|
31
31
|
|
|
32
32
|
it( 'should create a new object if an empty string is passed', () => {
|
|
33
|
-
const result =
|
|
33
|
+
const result = setImmutably( '', 'test', 1 );
|
|
34
34
|
|
|
35
35
|
expect( result ).toEqual( { test: 1 } );
|
|
36
36
|
} );
|
|
37
37
|
|
|
38
38
|
it( 'should create a new object if a NaN is passed', () => {
|
|
39
|
-
const result =
|
|
39
|
+
const result = setImmutably( NaN, 'test', 1 );
|
|
40
40
|
|
|
41
41
|
expect( result ).toEqual( { test: 1 } );
|
|
42
42
|
} );
|
|
@@ -44,26 +44,26 @@ describe( 'immutableSet', () => {
|
|
|
44
44
|
|
|
45
45
|
describe( 'manages data assignment properly', () => {
|
|
46
46
|
it( 'assigns value properly when it does not exist', () => {
|
|
47
|
-
const result =
|
|
47
|
+
const result = setImmutably( {}, 'test', 1 );
|
|
48
48
|
|
|
49
49
|
expect( result ).toEqual( { test: 1 } );
|
|
50
50
|
} );
|
|
51
51
|
|
|
52
52
|
it( 'overrides existing values', () => {
|
|
53
|
-
const result =
|
|
53
|
+
const result = setImmutably( { test: 1 }, 'test', 2 );
|
|
54
54
|
|
|
55
55
|
expect( result ).toEqual( { test: 2 } );
|
|
56
56
|
} );
|
|
57
57
|
|
|
58
58
|
describe( 'with array notation access', () => {
|
|
59
59
|
it( 'assigns values at deeper levels', () => {
|
|
60
|
-
const result =
|
|
60
|
+
const result = setImmutably( {}, [ 'foo', 'bar', 'baz' ], 5 );
|
|
61
61
|
|
|
62
62
|
expect( result ).toEqual( { foo: { bar: { baz: 5 } } } );
|
|
63
63
|
} );
|
|
64
64
|
|
|
65
65
|
it( 'overrides existing values at deeper levels', () => {
|
|
66
|
-
const result =
|
|
66
|
+
const result = setImmutably(
|
|
67
67
|
{ foo: { bar: { baz: 1 } } },
|
|
68
68
|
[ 'foo', 'bar', 'baz' ],
|
|
69
69
|
5
|
|
@@ -73,7 +73,7 @@ describe( 'immutableSet', () => {
|
|
|
73
73
|
} );
|
|
74
74
|
|
|
75
75
|
it( 'keeps other properties intact', () => {
|
|
76
|
-
const result =
|
|
76
|
+
const result = setImmutably(
|
|
77
77
|
{ foo: { bar: { baz: 1 } } },
|
|
78
78
|
[ 'foo', 'bar', 'test' ],
|
|
79
79
|
5
|
|
@@ -87,37 +87,37 @@ describe( 'immutableSet', () => {
|
|
|
87
87
|
|
|
88
88
|
describe( 'for nested falsey values', () => {
|
|
89
89
|
it( 'overwrites undefined values', () => {
|
|
90
|
-
const result =
|
|
90
|
+
const result = setImmutably( { test: undefined }, 'test', 1 );
|
|
91
91
|
|
|
92
92
|
expect( result ).toEqual( { test: 1 } );
|
|
93
93
|
} );
|
|
94
94
|
|
|
95
95
|
it( 'overwrites null values', () => {
|
|
96
|
-
const result =
|
|
96
|
+
const result = setImmutably( { test: null }, 'test', 1 );
|
|
97
97
|
|
|
98
98
|
expect( result ).toEqual( { test: 1 } );
|
|
99
99
|
} );
|
|
100
100
|
|
|
101
101
|
it( 'overwrites false values', () => {
|
|
102
|
-
const result =
|
|
102
|
+
const result = setImmutably( { test: false }, 'test', 1 );
|
|
103
103
|
|
|
104
104
|
expect( result ).toEqual( { test: 1 } );
|
|
105
105
|
} );
|
|
106
106
|
|
|
107
107
|
it( 'overwrites `0` values', () => {
|
|
108
|
-
const result =
|
|
108
|
+
const result = setImmutably( { test: 0 }, 'test', 1 );
|
|
109
109
|
|
|
110
110
|
expect( result ).toEqual( { test: 1 } );
|
|
111
111
|
} );
|
|
112
112
|
|
|
113
113
|
it( 'overwrites empty string values', () => {
|
|
114
|
-
const result =
|
|
114
|
+
const result = setImmutably( { test: '' }, 'test', 1 );
|
|
115
115
|
|
|
116
116
|
expect( result ).toEqual( { test: 1 } );
|
|
117
117
|
} );
|
|
118
118
|
|
|
119
119
|
it( 'overwrites NaN values', () => {
|
|
120
|
-
const result =
|
|
120
|
+
const result = setImmutably( { test: NaN }, 'test', 1 );
|
|
121
121
|
|
|
122
122
|
expect( result ).toEqual( { test: 1 } );
|
|
123
123
|
} );
|
|
@@ -127,14 +127,14 @@ describe( 'immutableSet', () => {
|
|
|
127
127
|
describe( 'does not mutate the original object', () => {
|
|
128
128
|
it( 'clones the object at the first level', () => {
|
|
129
129
|
const input = {};
|
|
130
|
-
const result =
|
|
130
|
+
const result = setImmutably( input, 'test', 1 );
|
|
131
131
|
|
|
132
132
|
expect( result ).not.toBe( input );
|
|
133
133
|
} );
|
|
134
134
|
|
|
135
135
|
it( 'clones the object at deeper levels', () => {
|
|
136
136
|
const input = { foo: { bar: { baz: 1 } } };
|
|
137
|
-
const result =
|
|
137
|
+
const result = setImmutably( input, [ 'foo', 'bar', 'baz' ], 2 );
|
|
138
138
|
|
|
139
139
|
expect( result ).not.toBe( input );
|
|
140
140
|
expect( result.foo ).not.toBe( input.foo );
|
|
@@ -13,8 +13,8 @@ import wrap from './transforms/wrap';
|
|
|
13
13
|
/**
|
|
14
14
|
* Applies a series of CSS rule transforms to wrap selectors inside a given class and/or rewrite URLs depending on the parameters passed.
|
|
15
15
|
*
|
|
16
|
-
* @param {Array}
|
|
17
|
-
* @param {string}
|
|
16
|
+
* @param {Object|Array} styles CSS rules.
|
|
17
|
+
* @param {string} wrapperClassName Wrapper Class Name.
|
|
18
18
|
* @return {Array} converted rules.
|
|
19
19
|
*/
|
|
20
20
|
const transformStyles = ( styles, wrapperClassName = '' ) => {
|