@wordpress/block-editor 12.0.0 → 12.2.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 +6 -0
- package/README.md +1 -1
- package/build/autocompleters/block.js +13 -5
- package/build/autocompleters/block.js.map +1 -1
- package/build/components/block-breadcrumb/index.js +6 -3
- package/build/components/block-breadcrumb/index.js.map +1 -1
- 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-editing-mode/index.js +84 -0
- package/build/components/block-editing-mode/index.js.map +1 -0
- 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-block-context.js +15 -0
- package/build/components/block-list/block-list-block-context.js.map +1 -0
- 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.js +29 -37
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +347 -311
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +260 -357
- 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-list/use-block-props/index.js +2 -2
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +7 -5
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-list-appender/index.js +15 -1
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +19 -4
- 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-styles/preview-panel.js +1 -2
- package/build/components/block-styles/preview-panel.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.js +8 -0
- package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build/components/block-switcher/block-variation-transformations.js +125 -0
- package/build/components/block-switcher/block-variation-transformations.js.map +1 -0
- package/build/components/block-switcher/index.js +34 -12
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-switcher/pattern-transformations-menu.js +3 -3
- package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build/components/block-toolbar/index.js +9 -7
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +22 -65
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +11 -5
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +3 -8
- 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/convert-to-group-buttons/index.js +7 -2
- package/build/components/convert-to-group-buttons/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/index.native.js +87 -3
- package/build/components/convert-to-group-buttons/index.native.js.map +1 -1
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +23 -37
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.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/color-panel.js +4 -1
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +9 -8
- package/build/components/global-styles/dimensions-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 +1 -1
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +27 -4
- 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/iframe/index.js +14 -7
- package/build/components/iframe/index.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/inner-blocks/index.js +2 -1
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +7 -7
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-nested-settings-update.js +13 -5
- package/build/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build/components/inserter/index.js +3 -7
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +2 -4
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-results.js +19 -6
- package/build/components/inserter/search-results.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/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/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/appender.js +6 -1
- package/build/components/list-view/appender.js.map +1 -1
- package/build/components/list-view/block-contents.js +9 -2
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block-select-button.js +2 -1
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +25 -29
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +1 -3
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +43 -22
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +27 -3
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +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/multi-selection-inspector/index.js +2 -2
- package/build/components/multi-selection-inspector/index.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/publish-date-time-picker/index.js +0 -2
- package/build/components/publish-date-time-picker/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 +4 -2
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +25 -15
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-resize-canvas/index.js +8 -1
- package/build/components/use-resize-canvas/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +13 -7
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/hooks/align.js +4 -8
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/behaviors.js +115 -0
- package/build/hooks/behaviors.js.map +1 -0
- 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/dimensions.js +0 -30
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +5 -9
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +8 -0
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/layout.js +10 -11
- 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/index.native.js +31 -0
- package/build/index.native.js.map +1 -0
- package/build/private-apis.js +4 -7
- package/build/private-apis.js.map +1 -1
- package/build/store/private-actions.js +46 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +88 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +36 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +28 -18
- package/build/store/selectors.js.map +1 -1
- package/build/utils/order-inserter-block-items.js +41 -0
- package/build/utils/order-inserter-block-items.js.map +1 -0
- package/build/utils/use-should-contextual-toolbar-show.js +16 -12
- package/build/utils/use-should-contextual-toolbar-show.js.map +1 -1
- package/build-module/autocompleters/block.js +12 -5
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/components/block-breadcrumb/index.js +5 -3
- package/build-module/components/block-breadcrumb/index.js.map +1 -1
- 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-editing-mode/index.js +72 -0
- package/build-module/components/block-editing-mode/index.js.map +1 -0
- 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-block-context.js +6 -0
- package/build-module/components/block-list/block-list-block-context.js.map +1 -0
- 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.js +26 -34
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +345 -310
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +263 -355
- 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-list/use-block-props/index.js +1 -1
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +6 -5
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +15 -1
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +18 -4
- 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-styles/preview-panel.js +1 -2
- package/build-module/components/block-styles/preview-panel.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.js +7 -0
- package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build-module/components/block-switcher/block-variation-transformations.js +108 -0
- package/build-module/components/block-switcher/block-variation-transformations.js.map +1 -0
- package/build-module/components/block-switcher/index.js +33 -12
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-switcher/pattern-transformations-menu.js +3 -3
- package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +8 -7
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +22 -65
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +11 -5
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +3 -7
- 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/convert-to-group-buttons/index.js +7 -2
- package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/index.native.js +76 -1
- package/build-module/components/convert-to-group-buttons/index.native.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +22 -36
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.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/color-panel.js +5 -2
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +9 -8
- package/build-module/components/global-styles/dimensions-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 +1 -1
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +25 -4
- 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/iframe/index.js +15 -8
- package/build-module/components/iframe/index.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/inner-blocks/index.js +2 -1
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +7 -6
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-nested-settings-update.js +13 -5
- package/build-module/components/inner-blocks/use-nested-settings-update.js.map +1 -1
- package/build-module/components/inserter/index.js +3 -7
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +2 -4
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-results.js +16 -6
- package/build-module/components/inserter/search-results.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/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/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/appender.js +6 -2
- package/build-module/components/list-view/appender.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +9 -3
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +2 -1
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +24 -29
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +1 -3
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +44 -23
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +26 -3
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +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/multi-selection-inspector/index.js +2 -2
- package/build-module/components/multi-selection-inspector/index.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/publish-date-time-picker/index.js +0 -2
- package/build-module/components/publish-date-time-picker/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 +4 -2
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +25 -16
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-resize-canvas/index.js +8 -1
- package/build-module/components/use-resize-canvas/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +13 -7
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/hooks/align.js +4 -7
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/behaviors.js +97 -0
- package/build-module/hooks/behaviors.js.map +1 -0
- 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/dimensions.js +0 -28
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +4 -7
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/index.native.js +1 -0
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/layout.js +9 -11
- 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/index.native.js +6 -0
- package/build-module/index.native.js.map +1 -0
- package/build-module/private-apis.js +3 -5
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/private-actions.js +42 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +79 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +34 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +26 -17
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/order-inserter-block-items.js +32 -0
- package/build-module/utils/order-inserter-block-items.js.map +1 -0
- package/build-module/utils/use-should-contextual-toolbar-show.js +16 -12
- package/build-module/utils/use-should-contextual-toolbar-show.js.map +1 -1
- package/build-style/content-rtl.css +32 -14
- package/build-style/content.css +32 -14
- package/build-style/default-editor-styles-rtl.css +1 -1
- package/build-style/default-editor-styles.css +1 -1
- package/build-style/style-rtl.css +56 -77
- package/build-style/style.css +57 -77
- package/package.json +32 -31
- package/src/autocompleters/block.js +15 -7
- package/src/components/block-breadcrumb/index.js +11 -3
- 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-editing-mode/index.js +71 -0
- package/src/components/block-list/block-invalid-warning.native.js +17 -9
- package/src/components/block-list/block-list-block-context.js +6 -0
- 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.js +38 -56
- package/src/components/block-list/block.native.js +531 -501
- package/src/components/block-list/content.scss +5 -6
- package/src/components/block-list/index.native.js +324 -382
- 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-list/use-block-props/index.js +1 -1
- package/src/components/block-list/use-in-between-inserter.js +7 -3
- package/src/components/block-list-appender/index.js +22 -4
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +26 -1
- package/src/components/block-mover/style.scss +1 -0
- 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/preview-panel.js +1 -3
- package/src/components/block-styles/style.scss +4 -4
- package/src/components/block-switcher/block-transformations-menu.js +12 -0
- package/src/components/block-switcher/block-variation-transformations.js +115 -0
- package/src/components/block-switcher/index.js +38 -5
- package/src/components/block-switcher/pattern-transformations-menu.js +5 -5
- package/src/components/block-switcher/style.scss +6 -5
- package/src/components/block-toolbar/index.js +10 -11
- package/src/components/block-tools/block-contextual-toolbar.js +32 -67
- package/src/components/block-tools/insertion-point.js +23 -9
- package/src/components/block-tools/selected-block-popover.js +3 -5
- package/src/components/block-tools/style.scss +8 -0
- package/src/components/button-block-appender/content.scss +22 -0
- package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +16 -2
- package/src/components/convert-to-group-buttons/index.js +9 -2
- package/src/components/convert-to-group-buttons/index.native.js +79 -1
- package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +32 -38
- package/src/components/global-styles/advanced-panel.js +82 -0
- package/src/components/global-styles/color-panel.js +6 -1
- package/src/components/global-styles/dimensions-panel.js +9 -8
- 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 +17 -0
- package/src/components/global-styles/test/utils.js +57 -1
- package/src/components/global-styles/typography-panel.js +1 -1
- package/src/components/global-styles/use-global-styles-output.js +21 -3
- package/src/components/global-styles/utils.js +27 -0
- package/src/components/iframe/index.js +22 -12
- package/src/components/image-editor/use-save-image.js +20 -9
- package/src/components/inner-blocks/README.md +5 -0
- package/src/components/inner-blocks/index.js +2 -0
- package/src/components/inner-blocks/index.native.js +16 -6
- package/src/components/inner-blocks/use-nested-settings-update.js +20 -3
- package/src/components/inserter/index.js +1 -9
- package/src/components/inserter/quick-inserter.js +0 -2
- package/src/components/inserter/search-results.js +32 -6
- 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/slot.js +4 -9
- package/src/components/inspector-controls/slot.native.js +1 -1
- 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/appender.js +3 -2
- package/src/components/list-view/block-contents.js +32 -20
- package/src/components/list-view/block-select-button.js +5 -1
- package/src/components/list-view/block.js +34 -37
- package/src/components/list-view/branch.js +1 -7
- package/src/components/list-view/index.js +42 -17
- package/src/components/list-view/style.scss +7 -7
- package/src/components/list-view/test/use-list-view-drop-zone.js +88 -12
- package/src/components/list-view/use-list-view-client-ids.js +21 -4
- 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/multi-selection-inspector/index.js +2 -2
- package/src/components/preview-options/index.js +9 -2
- package/src/components/publish-date-time-picker/index.js +0 -2
- package/src/components/spacing-sizes-control/spacing-input-control.js +1 -0
- package/src/components/url-input/README.md +6 -0
- package/src/components/url-input/index.js +2 -2
- package/src/components/use-block-drop-zone/index.js +31 -17
- package/src/components/use-resize-canvas/index.js +9 -1
- package/src/components/writing-flow/test/index.js +15 -0
- package/src/components/writing-flow/use-arrow-nav.js +17 -4
- package/src/hooks/align.js +5 -12
- package/src/hooks/behaviors.js +104 -0
- 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/dimensions.js +0 -40
- package/src/hooks/duotone.js +4 -11
- package/src/hooks/index.js +1 -0
- package/src/hooks/index.native.js +1 -0
- package/src/hooks/layout.js +14 -20
- package/src/hooks/position.js +2 -1
- package/src/hooks/style.js +2 -1
- package/src/hooks/test/use-editor-wrapper-styles.native.js +282 -0
- package/src/hooks/test/use-typography-props.js +47 -2
- 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/index.native.js +6 -0
- package/src/private-apis.js +2 -4
- package/src/store/private-actions.js +39 -0
- package/src/store/private-selectors.js +95 -0
- package/src/store/reducer.js +27 -0
- package/src/store/selectors.js +25 -15
- package/src/store/test/private-actions.js +32 -1
- package/src/store/test/private-selectors.js +158 -0
- package/src/store/test/reducer.js +48 -0
- package/src/style.scss +0 -3
- package/src/utils/order-inserter-block-items.js +26 -0
- package/src/utils/use-should-contextual-toolbar-show.js +19 -9
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-list/block-list-compact.native.js +0 -75
- package/build/components/block-list/block-list-compact.native.js.map +0 -1
- package/build/components/off-canvas-editor/appender.js +0 -125
- package/build/components/off-canvas-editor/appender.js.map +0 -1
- package/build/components/off-canvas-editor/block-contents.js +0 -141
- package/build/components/off-canvas-editor/block-contents.js.map +0 -1
- package/build/components/off-canvas-editor/block-select-button.js +0 -126
- package/build/components/off-canvas-editor/block-select-button.js.map +0 -1
- package/build/components/off-canvas-editor/block.js +0 -297
- package/build/components/off-canvas-editor/block.js.map +0 -1
- package/build/components/off-canvas-editor/branch.js +0 -197
- package/build/components/off-canvas-editor/branch.js.map +0 -1
- package/build/components/off-canvas-editor/context.js +0 -19
- package/build/components/off-canvas-editor/context.js.map +0 -1
- package/build/components/off-canvas-editor/drop-indicator.js +0 -118
- package/build/components/off-canvas-editor/drop-indicator.js.map +0 -1
- package/build/components/off-canvas-editor/expander.js +0 -41
- package/build/components/off-canvas-editor/expander.js.map +0 -1
- package/build/components/off-canvas-editor/index.js +0 -236
- package/build/components/off-canvas-editor/index.js.map +0 -1
- package/build/components/off-canvas-editor/leaf-more-menu.js +0 -146
- package/build/components/off-canvas-editor/leaf-more-menu.js.map +0 -1
- package/build/components/off-canvas-editor/leaf.js +0 -60
- package/build/components/off-canvas-editor/leaf.js.map +0 -1
- package/build/components/off-canvas-editor/link-ui.js +0 -186
- package/build/components/off-canvas-editor/link-ui.js.map +0 -1
- package/build/components/off-canvas-editor/update-attributes.js +0 -108
- package/build/components/off-canvas-editor/update-attributes.js.map +0 -1
- package/build/components/off-canvas-editor/use-block-selection.js +0 -139
- package/build/components/off-canvas-editor/use-block-selection.js.map +0 -1
- package/build/components/off-canvas-editor/use-inserted-block.js +0 -58
- package/build/components/off-canvas-editor/use-inserted-block.js.map +0 -1
- package/build/components/off-canvas-editor/use-list-view-client-ids.js +0 -33
- package/build/components/off-canvas-editor/use-list-view-client-ids.js.map +0 -1
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js +0 -235
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +0 -1
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -60
- package/build/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +0 -1
- package/build/components/off-canvas-editor/utils.js +0 -60
- package/build/components/off-canvas-editor/utils.js.map +0 -1
- package/build-module/components/block-list/block-list-compact.native.js +0 -60
- package/build-module/components/block-list/block-list-compact.native.js.map +0 -1
- package/build-module/components/off-canvas-editor/appender.js +0 -108
- package/build-module/components/off-canvas-editor/appender.js.map +0 -1
- package/build-module/components/off-canvas-editor/block-contents.js +0 -121
- package/build-module/components/off-canvas-editor/block-contents.js.map +0 -1
- package/build-module/components/off-canvas-editor/block-select-button.js +0 -107
- package/build-module/components/off-canvas-editor/block-select-button.js.map +0 -1
- package/build-module/components/off-canvas-editor/block.js +0 -273
- package/build-module/components/off-canvas-editor/block.js.map +0 -1
- package/build-module/components/off-canvas-editor/branch.js +0 -179
- package/build-module/components/off-canvas-editor/branch.js.map +0 -1
- package/build-module/components/off-canvas-editor/context.js +0 -7
- package/build-module/components/off-canvas-editor/context.js.map +0 -1
- package/build-module/components/off-canvas-editor/drop-indicator.js +0 -111
- package/build-module/components/off-canvas-editor/drop-indicator.js.map +0 -1
- package/build-module/components/off-canvas-editor/expander.js +0 -32
- package/build-module/components/off-canvas-editor/expander.js.map +0 -1
- package/build-module/components/off-canvas-editor/index.js +0 -213
- package/build-module/components/off-canvas-editor/index.js.map +0 -1
- package/build-module/components/off-canvas-editor/leaf-more-menu.js +0 -128
- package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +0 -1
- package/build-module/components/off-canvas-editor/leaf.js +0 -45
- package/build-module/components/off-canvas-editor/leaf.js.map +0 -1
- package/build-module/components/off-canvas-editor/link-ui.js +0 -166
- package/build-module/components/off-canvas-editor/link-ui.js.map +0 -1
- package/build-module/components/off-canvas-editor/update-attributes.js +0 -97
- package/build-module/components/off-canvas-editor/update-attributes.js.map +0 -1
- package/build-module/components/off-canvas-editor/use-block-selection.js +0 -124
- package/build-module/components/off-canvas-editor/use-block-selection.js.map +0 -1
- package/build-module/components/off-canvas-editor/use-inserted-block.js +0 -47
- package/build-module/components/off-canvas-editor/use-inserted-block.js.map +0 -1
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js +0 -24
- package/build-module/components/off-canvas-editor/use-list-view-client-ids.js.map +0 -1
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +0 -220
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +0 -1
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -50
- package/build-module/components/off-canvas-editor/use-list-view-expand-selected-item.js.map +0 -1
- package/build-module/components/off-canvas-editor/utils.js +0 -44
- package/build-module/components/off-canvas-editor/utils.js.map +0 -1
- package/src/components/block-list/block-list-compact.native.js +0 -63
- package/src/components/off-canvas-editor/README.md +0 -5
- package/src/components/off-canvas-editor/appender.js +0 -124
- package/src/components/off-canvas-editor/block-contents.js +0 -156
- package/src/components/off-canvas-editor/block-select-button.js +0 -128
- package/src/components/off-canvas-editor/block.js +0 -347
- package/src/components/off-canvas-editor/branch.js +0 -238
- package/src/components/off-canvas-editor/context.js +0 -8
- package/src/components/off-canvas-editor/drop-indicator.js +0 -126
- package/src/components/off-canvas-editor/expander.js +0 -26
- package/src/components/off-canvas-editor/index.js +0 -271
- package/src/components/off-canvas-editor/leaf-more-menu.js +0 -157
- package/src/components/off-canvas-editor/leaf.js +0 -52
- package/src/components/off-canvas-editor/link-ui.js +0 -167
- package/src/components/off-canvas-editor/style.scss +0 -34
- package/src/components/off-canvas-editor/test/use-inserted-block.js +0 -108
- package/src/components/off-canvas-editor/test/utils.js +0 -50
- package/src/components/off-canvas-editor/update-attributes.js +0 -99
- package/src/components/off-canvas-editor/use-block-selection.js +0 -169
- package/src/components/off-canvas-editor/use-inserted-block.js +0 -47
- package/src/components/off-canvas-editor/use-list-view-client-ids.js +0 -29
- package/src/components/off-canvas-editor/use-list-view-drop-zone.js +0 -260
- package/src/components/off-canvas-editor/use-list-view-expand-selected-item.js +0 -58
- package/src/components/off-canvas-editor/utils.js +0 -58
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { renderHook } from '@testing-library/react-native';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
|
|
10
|
+
import { registerCoreBlocks } from '@wordpress/block-library';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import { useEditorWrapperStyles } from '../use-editor-wrapper-styles';
|
|
16
|
+
|
|
17
|
+
jest.mock( '../use-editor-wrapper-styles.scss', () => ( {
|
|
18
|
+
'use-editor-wrapper-styles': {
|
|
19
|
+
width: '100%',
|
|
20
|
+
maxWidth: 580,
|
|
21
|
+
alignSelf: 'center',
|
|
22
|
+
},
|
|
23
|
+
'use-editor-wrapper-styles--reversed': {
|
|
24
|
+
flexDirection: 'column-reverse',
|
|
25
|
+
width: '100%',
|
|
26
|
+
maxWidth: 580,
|
|
27
|
+
},
|
|
28
|
+
} ) );
|
|
29
|
+
|
|
30
|
+
const defaultCanvasStyles = {
|
|
31
|
+
width: '100%',
|
|
32
|
+
maxWidth: 580,
|
|
33
|
+
alignSelf: 'center',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
describe( 'useEditorWrapperStyles', () => {
|
|
37
|
+
beforeAll( () => {
|
|
38
|
+
// Register all core blocks
|
|
39
|
+
registerCoreBlocks();
|
|
40
|
+
} );
|
|
41
|
+
|
|
42
|
+
afterAll( () => {
|
|
43
|
+
// Clean up registered blocks
|
|
44
|
+
getBlockTypes().forEach( ( block ) => {
|
|
45
|
+
unregisterBlockType( block.name );
|
|
46
|
+
} );
|
|
47
|
+
} );
|
|
48
|
+
|
|
49
|
+
it( 'should return the default wrapper styles when no props are set', () => {
|
|
50
|
+
// Arrange
|
|
51
|
+
jest.spyOn(
|
|
52
|
+
require( 'react-native' ),
|
|
53
|
+
'useWindowDimensions'
|
|
54
|
+
).mockReturnValue( { width: 900, height: 600 } );
|
|
55
|
+
|
|
56
|
+
// Act
|
|
57
|
+
const { result } = renderHook( () => useEditorWrapperStyles() );
|
|
58
|
+
|
|
59
|
+
// Assert
|
|
60
|
+
expect( result.current[ 0 ] ).toEqual( [
|
|
61
|
+
expect.objectContaining( defaultCanvasStyles ),
|
|
62
|
+
{},
|
|
63
|
+
] );
|
|
64
|
+
} );
|
|
65
|
+
|
|
66
|
+
it( 'should return the correct wrapper styles and margin for wide (medium) alignment', () => {
|
|
67
|
+
// Arrange
|
|
68
|
+
jest.spyOn(
|
|
69
|
+
require( 'react-native' ),
|
|
70
|
+
'useWindowDimensions'
|
|
71
|
+
).mockReturnValue( { width: 900, height: 600 } );
|
|
72
|
+
|
|
73
|
+
// Act
|
|
74
|
+
const { result } = renderHook( () =>
|
|
75
|
+
useEditorWrapperStyles( {
|
|
76
|
+
align: 'wide',
|
|
77
|
+
blockName: 'core/group',
|
|
78
|
+
blockWidth: 800,
|
|
79
|
+
marginHorizontal: 16,
|
|
80
|
+
} )
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
// Assert
|
|
84
|
+
expect( result.current[ 0 ] ).toEqual( [
|
|
85
|
+
expect.objectContaining( defaultCanvasStyles ),
|
|
86
|
+
expect.objectContaining( {
|
|
87
|
+
maxWidth: 770,
|
|
88
|
+
} ),
|
|
89
|
+
] );
|
|
90
|
+
expect( result.current[ 1 ] ).toEqual( 16 );
|
|
91
|
+
} );
|
|
92
|
+
|
|
93
|
+
it( 'should return the correct wrapper styles and margin for wide (landscape) alignment', () => {
|
|
94
|
+
// Arrange
|
|
95
|
+
jest.spyOn(
|
|
96
|
+
require( 'react-native' ),
|
|
97
|
+
'useWindowDimensions'
|
|
98
|
+
).mockReturnValue( { width: 800, height: 600 } );
|
|
99
|
+
|
|
100
|
+
// Act
|
|
101
|
+
const { result } = renderHook( () =>
|
|
102
|
+
useEditorWrapperStyles( {
|
|
103
|
+
align: 'wide',
|
|
104
|
+
blockName: 'core/group',
|
|
105
|
+
blockWidth: 700,
|
|
106
|
+
marginHorizontal: 16,
|
|
107
|
+
} )
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
// Assert
|
|
111
|
+
expect( result.current[ 0 ] ).toEqual( [
|
|
112
|
+
expect.objectContaining( defaultCanvasStyles ),
|
|
113
|
+
expect.objectContaining( {
|
|
114
|
+
maxWidth: 662,
|
|
115
|
+
} ),
|
|
116
|
+
] );
|
|
117
|
+
expect( result.current[ 1 ] ).toEqual( 16 );
|
|
118
|
+
} );
|
|
119
|
+
|
|
120
|
+
it( 'should return the correct wrapper styles and margin for wide alignment', () => {
|
|
121
|
+
// Arrange
|
|
122
|
+
jest.spyOn(
|
|
123
|
+
require( 'react-native' ),
|
|
124
|
+
'useWindowDimensions'
|
|
125
|
+
).mockReturnValue( { width: 1194, height: 834 } );
|
|
126
|
+
|
|
127
|
+
// Act
|
|
128
|
+
const { result } = renderHook( () =>
|
|
129
|
+
useEditorWrapperStyles( {
|
|
130
|
+
align: 'wide',
|
|
131
|
+
blockName: 'core/group',
|
|
132
|
+
blockWidth: 800,
|
|
133
|
+
marginHorizontal: 16,
|
|
134
|
+
} )
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
// Assert
|
|
138
|
+
expect( result.current[ 0 ] ).toEqual( [
|
|
139
|
+
expect.objectContaining( defaultCanvasStyles ),
|
|
140
|
+
expect.objectContaining( {
|
|
141
|
+
maxWidth: 1054,
|
|
142
|
+
} ),
|
|
143
|
+
] );
|
|
144
|
+
expect( result.current[ 1 ] ).toEqual( 16 );
|
|
145
|
+
} );
|
|
146
|
+
|
|
147
|
+
it( 'should return the correct wrapper styles and margin for full alignment', () => {
|
|
148
|
+
// Arrange
|
|
149
|
+
jest.spyOn(
|
|
150
|
+
require( 'react-native' ),
|
|
151
|
+
'useWindowDimensions'
|
|
152
|
+
).mockReturnValue( { width: 800, height: 600 } );
|
|
153
|
+
|
|
154
|
+
// Act
|
|
155
|
+
const { result } = renderHook( () =>
|
|
156
|
+
useEditorWrapperStyles( {
|
|
157
|
+
align: 'full',
|
|
158
|
+
blockName: 'core/cover',
|
|
159
|
+
blockWidth: 700,
|
|
160
|
+
marginHorizontal: 16,
|
|
161
|
+
} )
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
// Assert
|
|
165
|
+
expect( result.current[ 0 ] ).toEqual( [
|
|
166
|
+
expect.objectContaining( defaultCanvasStyles ),
|
|
167
|
+
expect.objectContaining( {
|
|
168
|
+
maxWidth: '100%',
|
|
169
|
+
} ),
|
|
170
|
+
] );
|
|
171
|
+
expect( result.current[ 1 ] ).toEqual( 0 );
|
|
172
|
+
} );
|
|
173
|
+
|
|
174
|
+
it( 'should return the correct wrapper styles and margin for left alignment', () => {
|
|
175
|
+
// Arrange
|
|
176
|
+
jest.spyOn(
|
|
177
|
+
require( 'react-native' ),
|
|
178
|
+
'useWindowDimensions'
|
|
179
|
+
).mockReturnValue( { width: 800, height: 600 } );
|
|
180
|
+
|
|
181
|
+
// Act
|
|
182
|
+
const { result } = renderHook( () =>
|
|
183
|
+
useEditorWrapperStyles( { align: 'left', marginHorizontal: 16 } )
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
// Assert
|
|
187
|
+
expect( result.current[ 0 ] ).toEqual( [
|
|
188
|
+
expect.objectContaining( defaultCanvasStyles ),
|
|
189
|
+
{},
|
|
190
|
+
] );
|
|
191
|
+
expect( result.current[ 1 ] ).toEqual( 16 );
|
|
192
|
+
} );
|
|
193
|
+
|
|
194
|
+
it( 'should return the correct wrapper styles and margin for center alignment', () => {
|
|
195
|
+
// Arrange
|
|
196
|
+
jest.spyOn(
|
|
197
|
+
require( 'react-native' ),
|
|
198
|
+
'useWindowDimensions'
|
|
199
|
+
).mockReturnValue( { width: 640, height: 960 } );
|
|
200
|
+
|
|
201
|
+
// Act
|
|
202
|
+
const { result } = renderHook( () =>
|
|
203
|
+
useEditorWrapperStyles( { align: 'center', marginHorizontal: 16 } )
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
// Assert
|
|
207
|
+
expect( result.current[ 0 ] ).toEqual( [
|
|
208
|
+
expect.objectContaining( defaultCanvasStyles ),
|
|
209
|
+
{},
|
|
210
|
+
] );
|
|
211
|
+
expect( result.current[ 1 ] ).toEqual( 16 );
|
|
212
|
+
} );
|
|
213
|
+
|
|
214
|
+
it( 'should return the correct wrapper styles and margin for right alignment', () => {
|
|
215
|
+
// Arrange
|
|
216
|
+
jest.spyOn(
|
|
217
|
+
require( 'react-native' ),
|
|
218
|
+
'useWindowDimensions'
|
|
219
|
+
).mockReturnValue( { width: 960, height: 640 } );
|
|
220
|
+
|
|
221
|
+
// Act
|
|
222
|
+
const { result } = renderHook( () =>
|
|
223
|
+
useEditorWrapperStyles( { align: 'right', marginHorizontal: 16 } )
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
// Assert
|
|
227
|
+
expect( result.current[ 0 ] ).toEqual( [
|
|
228
|
+
expect.objectContaining( defaultCanvasStyles ),
|
|
229
|
+
{},
|
|
230
|
+
] );
|
|
231
|
+
expect( result.current[ 1 ] ).toEqual( 16 );
|
|
232
|
+
} );
|
|
233
|
+
|
|
234
|
+
it( 'should return the correct wrapper styles and margin when reversed is true', () => {
|
|
235
|
+
// Arrange
|
|
236
|
+
jest.spyOn(
|
|
237
|
+
require( 'react-native' ),
|
|
238
|
+
'useWindowDimensions'
|
|
239
|
+
).mockReturnValue( { width: 800, height: 600 } );
|
|
240
|
+
|
|
241
|
+
// Act
|
|
242
|
+
const { result } = renderHook( () =>
|
|
243
|
+
useEditorWrapperStyles( { reversed: true, marginHorizontal: 16 } )
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
// Assert
|
|
247
|
+
expect( result.current[ 0 ] ).toEqual( [
|
|
248
|
+
expect.objectContaining( {
|
|
249
|
+
flexDirection: 'column-reverse',
|
|
250
|
+
width: '100%',
|
|
251
|
+
maxWidth: 580,
|
|
252
|
+
} ),
|
|
253
|
+
{},
|
|
254
|
+
] );
|
|
255
|
+
expect( result.current[ 1 ] ).toEqual( 16 );
|
|
256
|
+
} );
|
|
257
|
+
|
|
258
|
+
it( 'should return the correct wrapper styles and margin when contentResizeMode is set', () => {
|
|
259
|
+
// Arrange
|
|
260
|
+
jest.spyOn(
|
|
261
|
+
require( 'react-native' ),
|
|
262
|
+
'useWindowDimensions'
|
|
263
|
+
).mockReturnValue( { width: 800, height: 600 } );
|
|
264
|
+
|
|
265
|
+
// Act
|
|
266
|
+
const { result } = renderHook( () =>
|
|
267
|
+
useEditorWrapperStyles( {
|
|
268
|
+
contentResizeMode: 'stretch',
|
|
269
|
+
marginHorizontal: 16,
|
|
270
|
+
} )
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
// Assert
|
|
274
|
+
expect( result.current[ 0 ] ).toEqual( [
|
|
275
|
+
expect.objectContaining( {
|
|
276
|
+
flex: 1,
|
|
277
|
+
} ),
|
|
278
|
+
{},
|
|
279
|
+
] );
|
|
280
|
+
expect( result.current[ 1 ] ).toEqual( 16 );
|
|
281
|
+
} );
|
|
282
|
+
} );
|
|
@@ -39,7 +39,15 @@ describe( 'getTypographyClassesAndStyles', () => {
|
|
|
39
39
|
},
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
|
-
expect(
|
|
42
|
+
expect(
|
|
43
|
+
getTypographyClassesAndStyles( attributes, {
|
|
44
|
+
typography: {
|
|
45
|
+
fluid: {
|
|
46
|
+
minFontSize: '1rem',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
} )
|
|
50
|
+
).toEqual( {
|
|
43
51
|
className: 'has-tofu-font-family',
|
|
44
52
|
style: {
|
|
45
53
|
letterSpacing: '22px',
|
|
@@ -63,7 +71,11 @@ describe( 'getTypographyClassesAndStyles', () => {
|
|
|
63
71
|
};
|
|
64
72
|
expect(
|
|
65
73
|
getTypographyClassesAndStyles( attributes, {
|
|
66
|
-
|
|
74
|
+
typography: {
|
|
75
|
+
fluid: {
|
|
76
|
+
minFontSize: '1rem',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
67
79
|
} )
|
|
68
80
|
).toEqual( {
|
|
69
81
|
className: 'has-tofu-font-family',
|
|
@@ -75,4 +87,37 @@ describe( 'getTypographyClassesAndStyles', () => {
|
|
|
75
87
|
},
|
|
76
88
|
} );
|
|
77
89
|
} );
|
|
90
|
+
|
|
91
|
+
it( 'should use layout.wideSize for the maximum viewport value', () => {
|
|
92
|
+
const attributes = {
|
|
93
|
+
fontFamily: 'tofu',
|
|
94
|
+
style: {
|
|
95
|
+
typography: {
|
|
96
|
+
textDecoration: 'underline',
|
|
97
|
+
fontSize: '2rem',
|
|
98
|
+
textTransform: 'uppercase',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
expect(
|
|
103
|
+
getTypographyClassesAndStyles( attributes, {
|
|
104
|
+
typography: {
|
|
105
|
+
fluid: {
|
|
106
|
+
minFontSize: '1rem',
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
layout: {
|
|
110
|
+
wideSize: '1000px',
|
|
111
|
+
},
|
|
112
|
+
} )
|
|
113
|
+
).toEqual( {
|
|
114
|
+
className: 'has-tofu-font-family',
|
|
115
|
+
style: {
|
|
116
|
+
textDecoration: 'underline',
|
|
117
|
+
fontSize:
|
|
118
|
+
'clamp(1.25rem, 1.25rem + ((1vw - 0.2rem) * 1.765), 2rem)',
|
|
119
|
+
textTransform: 'uppercase',
|
|
120
|
+
},
|
|
121
|
+
} );
|
|
122
|
+
} );
|
|
78
123
|
} );
|
|
@@ -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/private-apis.js
CHANGED
|
@@ -4,14 +4,13 @@
|
|
|
4
4
|
import * as globalStyles from './components/global-styles';
|
|
5
5
|
import { ExperimentalBlockEditorProvider } from './components/provider';
|
|
6
6
|
import { lock } from './lock-unlock';
|
|
7
|
-
import OffCanvasEditor from './components/off-canvas-editor';
|
|
8
|
-
import LeafMoreMenu from './components/off-canvas-editor/leaf-more-menu';
|
|
9
7
|
import ResizableBoxPopover from './components/resizable-box-popover';
|
|
10
8
|
import { ComposedPrivateInserter as PrivateInserter } from './components/inserter';
|
|
11
9
|
import { PrivateListView } from './components/list-view';
|
|
12
10
|
import BlockInfo from './components/block-info-slot-fill';
|
|
13
11
|
import { useShouldContextualToolbarShow } from './utils/use-should-contextual-toolbar-show';
|
|
14
12
|
import { cleanEmptyObject } from './hooks/utils';
|
|
13
|
+
import { useBlockEditingMode } from './components/block-editing-mode';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Private @wordpress/block-editor APIs.
|
|
@@ -20,12 +19,11 @@ export const privateApis = {};
|
|
|
20
19
|
lock( privateApis, {
|
|
21
20
|
...globalStyles,
|
|
22
21
|
ExperimentalBlockEditorProvider,
|
|
23
|
-
LeafMoreMenu,
|
|
24
|
-
OffCanvasEditor,
|
|
25
22
|
PrivateInserter,
|
|
26
23
|
PrivateListView,
|
|
27
24
|
ResizableBoxPopover,
|
|
28
25
|
BlockInfo,
|
|
29
26
|
useShouldContextualToolbarShow,
|
|
30
27
|
cleanEmptyObject,
|
|
28
|
+
useBlockEditingMode,
|
|
31
29
|
} );
|