@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/layout.js"],"names":["layoutBlockSupportKey","useLayoutClasses","blockAttributes","blockName","rootPaddingAlignment","select","getSettings","blockEditorStore","__experimentalFeatures","useRootPaddingAwareAlignments","globalLayoutSettings","layout","default","defaultBlockLayout","usedLayout","inherit","contentSize","wideSize","type","layoutClassnames","definitions","className","baseClassName","compoundClassName","split","pop","push","orientation","justifyContent","flexWrap","useLayoutStyles","selector","style","fullLayoutType","blockGapSupport","hasBlockGapSupport","css","getLayoutStyle","layoutDefinitions","LayoutPanel","clientId","setAttributes","attributes","name","defaultThemeLayout","themeSupportsLayout","isContentLocked","__unstableGetContentLockingParent","supportsLayout","layoutBlockSupport","allowSwitching","allowEditing","allowInheriting","showInheritToggle","layoutType","constrainedType","displayControlsForLegacyLayouts","hasContentSizeOrLegacySettings","onChangeType","newType","onChangeLayout","newLayout","LayoutTypeSwitcher","onChange","map","label","addAttribute","settings","withInspectorControls","BlockEdit","props","supportLayout","withLayoutStyles","BlockListBlock","hasLayoutBlockSupport","disableLayoutStyles","shouldRenderLayoutStyles","id","element","BlockList","__unstableElementContext","layoutClasses","layoutClassNames","withChildLayoutStyles","selfStretch","flexSize","hasChildLayout","shouldRenderChildLayoutStyles"],"mappings":";;;;;;;;;;;;AAoBA;;;;A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ACGmD,6BAA6B,IAC9BT,OADC,IAED,CAAC,CAAE1C,GAFF,IAGD,2BAAc,2CAASA,GAAT,CAAd,EAAsC0C,OAAtC,CAJF,EAKC,4BAAC,cAAD,6BAAqBR,KAArB;AAA6B,IAAA,SAAS,EAAGjD;AAAzC,KALD,CADD;AASA,CA7CmC,CAA9B;;AAgDP,sBACC,0BADD,EAEC,0BAFD,EAGC6C,YAHD;AAKA,sBACC,uBADD,EAEC,uCAFD,EAGCM,gBAHD;AAKA,sBACC,uBADD,EAEC,6CAFD,EAGCW,qBAHD;AAKA,sBACC,kBADD,EAEC,4CAFD,EAGCf,qBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tButton,\n\tButtonGroup,\n\tToggleControl,\n\tPanelBody,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useContext, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport useSetting from '../components/use-setting';\nimport { LayoutStyle } from '../components/block-list/layout';\nimport BlockList from '../components/block-list';\nimport { getLayoutType, getLayoutTypes } from '../layouts';\n\nconst layoutBlockSupportKey = '__experimentalLayout';\n\n/**\n * Generates the utility classnames for the given block's layout attributes.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n *\n * @return { Array } Array of CSS classname strings.\n */\nexport function useLayoutClasses( blockAttributes = {}, blockName = '' ) {\n\tconst rootPaddingAlignment = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalFeatures\n\t\t\t?.useRootPaddingAwareAlignments;\n\t}, [] );\n\tconst globalLayoutSettings = useSetting( 'layout' ) || {};\n\n\tconst { layout } = blockAttributes;\n\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( blockName, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst layoutClassnames = [];\n\n\tif (\n\t\tglobalLayoutSettings?.definitions?.[ usedLayout?.type || 'default' ]\n\t\t\t?.className\n\t) {\n\t\tconst baseClassName =\n\t\t\tglobalLayoutSettings?.definitions?.[ usedLayout?.type || 'default' ]\n\t\t\t\t?.className;\n\t\tconst compoundClassName = `wp-block-${ blockName\n\t\t\t.split( '/' )\n\t\t\t.pop() }-${ baseClassName }`;\n\t\tlayoutClassnames.push( baseClassName, compoundClassName );\n\t}\n\n\tif (\n\t\t( usedLayout?.inherit ||\n\t\t\tusedLayout?.contentSize ||\n\t\t\tusedLayout?.type === 'constrained' ) &&\n\t\trootPaddingAlignment\n\t) {\n\t\tlayoutClassnames.push( 'has-global-padding' );\n\t}\n\n\tif ( usedLayout?.orientation ) {\n\t\tlayoutClassnames.push( `is-${ kebabCase( usedLayout.orientation ) }` );\n\t}\n\n\tif ( usedLayout?.justifyContent ) {\n\t\tlayoutClassnames.push(\n\t\t\t`is-content-justification-${ kebabCase(\n\t\t\t\tusedLayout.justifyContent\n\t\t\t) }`\n\t\t);\n\t}\n\n\tif ( usedLayout?.flexWrap && usedLayout.flexWrap === 'nowrap' ) {\n\t\tlayoutClassnames.push( 'is-nowrap' );\n\t}\n\n\treturn layoutClassnames;\n}\n\n/**\n * Generates a CSS rule with the given block's layout styles.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n * @param { string } selector A selector to use in generating the CSS rule.\n *\n * @return { string } CSS rule.\n */\nexport function useLayoutStyles( blockAttributes = {}, blockName, selector ) {\n\tconst { layout = {}, style = {} } = blockAttributes;\n\t// Update type for blocks using legacy layouts.\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || {};\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst globalLayoutSettings = useSetting( 'layout' ) || {};\n\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\tconst css = fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName,\n\t\tselector,\n\t\tlayout,\n\t\tlayoutDefinitions: globalLayoutSettings?.definitions,\n\t\tstyle,\n\t\thasBlockGapSupport,\n\t} );\n\treturn css;\n}\n\nfunction LayoutPanel( {\n\tclientId,\n\tsetAttributes,\n\tattributes,\n\tname: blockName,\n} ) {\n\tconst { layout } = attributes;\n\tconst defaultThemeLayout = useSetting( 'layout' );\n\tconst { themeSupportsLayout, isContentLocked } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, __unstableGetContentLockingParent } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn {\n\t\t\t\tthemeSupportsLayout: getSettings().supportsLayout,\n\t\t\t\tisContentLocked: __unstableGetContentLockingParent( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst layoutBlockSupport = getBlockSupport(\n\t\tblockName,\n\t\tlayoutBlockSupportKey,\n\t\t{}\n\t);\n\tconst {\n\t\tallowSwitching,\n\t\tallowEditing = true,\n\t\tallowInheriting = true,\n\t\tdefault: defaultBlockLayout,\n\t} = layoutBlockSupport;\n\n\tif ( ! allowEditing ) {\n\t\treturn null;\n\t}\n\n\t// Only show the inherit toggle if it's supported,\n\t// a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values),\n\t// and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other.\n\tconst showInheritToggle = !! (\n\t\tallowInheriting &&\n\t\t!! defaultThemeLayout &&\n\t\t( ! layout?.type ||\n\t\t\tlayout?.type === 'default' ||\n\t\t\tlayout?.type === 'constrained' ||\n\t\t\tlayout?.inherit )\n\t);\n\n\tconst usedLayout = layout || defaultBlockLayout || {};\n\tconst {\n\t\tinherit = false,\n\t\ttype = 'default',\n\t\tcontentSize = null,\n\t} = usedLayout;\n\t/**\n\t * `themeSupportsLayout` is only relevant to the `default/flow` or\n\t * `constrained` layouts and it should not be taken into account when other\n\t * `layout` types are used.\n\t */\n\tif (\n\t\t( type === 'default' || type === 'constrained' ) &&\n\t\t! themeSupportsLayout\n\t) {\n\t\treturn null;\n\t}\n\tconst layoutType = getLayoutType( type );\n\tconst constrainedType = getLayoutType( 'constrained' );\n\tconst displayControlsForLegacyLayouts =\n\t\t! usedLayout.type && ( contentSize || inherit );\n\tconst hasContentSizeOrLegacySettings = !! inherit || !! contentSize;\n\n\tconst onChangeType = ( newType ) =>\n\t\tsetAttributes( { layout: { type: newType } } );\n\tconst onChangeLayout = ( newLayout ) =>\n\t\tsetAttributes( { layout: newLayout } );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Layout' ) }>\n\t\t\t\t\t{ showInheritToggle && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tclassName=\"block-editor-hooks__toggle-control\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Inner blocks use content width' ) }\n\t\t\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t\t\ttype:\n\t\t\t\t\t\t\t\t\t\t\t\tlayoutType?.name ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t'constrained' ||\n\t\t\t\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'default'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: 'constrained',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks use content width with options for full and wide widths.'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks will fill the width of this container. Toggle to constrain.'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ ! inherit && allowSwitching && (\n\t\t\t\t\t\t<LayoutTypeSwitcher\n\t\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\t\tonChange={ onChangeType }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ layoutType && layoutType.name !== 'default' && (\n\t\t\t\t\t\t<layoutType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ constrainedType && displayControlsForLegacyLayouts && (\n\t\t\t\t\t\t<constrainedType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ ! inherit && ! isContentLocked && layoutType && (\n\t\t\t\t<layoutType.toolBarControls\n\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction LayoutTypeSwitcher( { type, onChange } ) {\n\treturn (\n\t\t<ButtonGroup>\n\t\t\t{ getLayoutTypes().map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tisPressed={ type === name }\n\t\t\t\t\t\tonClick={ () => onChange( name ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</Button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ButtonGroup>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( 'type' in ( settings.attributes?.layout ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, layoutBlockSupportKey ) ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include layout controls\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withInspectorControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name: blockName } = props;\n\t\tconst supportLayout = hasBlockSupport(\n\t\t\tblockName,\n\t\t\tlayoutBlockSupportKey\n\t\t);\n\n\t\treturn [\n\t\t\tsupportLayout && <LayoutPanel key=\"layout\" { ...props } />,\n\t\t\t<BlockEdit key=\"edit\" { ...props } />,\n\t\t];\n\t},\n\t'withInspectorControls'\n);\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst hasLayoutBlockSupport = hasBlockSupport(\n\t\t\tname,\n\t\t\tlayoutBlockSupportKey\n\t\t);\n\t\tconst disableLayoutStyles = useSelect( ( select ) => {\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\treturn !! getSettings().disableLayoutStyles;\n\t\t} );\n\t\tconst shouldRenderLayoutStyles =\n\t\t\thasLayoutBlockSupport && ! disableLayoutStyles;\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst defaultThemeLayout = useSetting( 'layout' ) || {};\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\t\tconst { layout } = attributes;\n\t\tconst { default: defaultBlockLayout } =\n\t\t\tgetBlockSupport( name, layoutBlockSupportKey ) || {};\n\t\tconst usedLayout =\n\t\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t\t: layout || defaultBlockLayout || {};\n\t\tconst layoutClasses = hasLayoutBlockSupport\n\t\t\t? useLayoutClasses( attributes, name )\n\t\t\t: null;\n\t\t// Higher specificity to override defaults from theme.json.\n\t\tconst selector = `.wp-container-${ id }.wp-container-${ id }`;\n\t\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\t\tconst hasBlockGapSupport = blockGapSupport !== null;\n\n\t\t// Get CSS string for the current layout type.\n\t\t// The CSS and `style` element is only output if it is not empty.\n\t\tlet css;\n\t\tif ( shouldRenderLayoutStyles ) {\n\t\t\tconst fullLayoutType = getLayoutType(\n\t\t\t\tusedLayout?.type || 'default'\n\t\t\t);\n\t\t\tcss = fullLayoutType?.getLayoutStyle?.( {\n\t\t\t\tblockName: name,\n\t\t\t\tselector,\n\t\t\t\tlayout: usedLayout,\n\t\t\t\tlayoutDefinitions: defaultThemeLayout?.definitions,\n\t\t\t\tstyle: attributes?.style,\n\t\t\t\thasBlockGapSupport,\n\t\t\t} );\n\t\t}\n\n\t\t// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.\n\t\tconst layoutClassNames = classnames(\n\t\t\t{\n\t\t\t\t[ `wp-container-${ id }` ]: shouldRenderLayoutStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t\t},\n\t\t\tlayoutClasses\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ shouldRenderLayoutStyles &&\n\t\t\t\t\telement &&\n\t\t\t\t\t!! css &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\tblockName={ name }\n\t\t\t\t\t\t\tselector={ selector }\n\t\t\t\t\t\t\tcss={ css }\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tstyle={ attributes?.style }\n\t\t\t\t\t\t/>,\n\t\t\t\t\t\telement\n\t\t\t\t\t) }\n\t\t\t\t<BlockListBlock\n\t\t\t\t\t{ ...props }\n\t\t\t\t\t__unstableLayoutClassNames={ layoutClassNames }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t}\n);\n\n/**\n * Override the default block element to add the child layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withChildLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { attributes } = props;\n\t\tconst { style: { layout = {} } = {} } = attributes;\n\t\tconst { selfStretch, flexSize } = layout;\n\t\tconst hasChildLayout = selfStretch || flexSize;\n\t\tconst disableLayoutStyles = useSelect( ( select ) => {\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\treturn !! getSettings().disableLayoutStyles;\n\t\t} );\n\t\tconst shouldRenderChildLayoutStyles =\n\t\t\thasChildLayout && ! disableLayoutStyles;\n\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst selector = `.wp-container-content-${ id }`;\n\n\t\tlet css = '';\n\n\t\tif ( selfStretch === 'fixed' && flexSize ) {\n\t\t\tcss += `${ selector } {\n\t\t\t\tflex-basis: ${ flexSize };\n\t\t\t\tbox-sizing: border-box;\n\t\t\t}`;\n\t\t} else if ( selfStretch === 'fill' ) {\n\t\t\tcss += `${ selector } {\n\t\t\t\tflex-grow: 1;\n\t\t\t}`;\n\t\t}\n\n\t\t// Attach a `wp-container-content` id-based classname.\n\t\tconst className = classnames( props?.className, {\n\t\t\t[ `wp-container-content-${ id }` ]:\n\t\t\t\tshouldRenderChildLayoutStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t} );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ shouldRenderChildLayoutStyles &&\n\t\t\t\t\telement &&\n\t\t\t\t\t!! css &&\n\t\t\t\t\tcreatePortal( <style>{ css }</style>, element ) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/layout/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-layout-styles',\n\twithLayoutStyles\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-child-layout-styles',\n\twithChildLayoutStyles\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/layout/with-inspector-controls',\n\twithInspectorControls\n);\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/layout.js"],"names":["layoutBlockSupportKey","useLayoutClasses","blockAttributes","blockName","rootPaddingAlignment","select","getSettings","blockEditorStore","__experimentalFeatures","useRootPaddingAwareAlignments","globalLayoutSettings","layout","default","defaultBlockLayout","usedLayout","inherit","contentSize","wideSize","type","layoutClassnames","definitions","className","baseClassName","compoundClassName","split","pop","push","orientation","justifyContent","flexWrap","useLayoutStyles","selector","style","fullLayoutType","blockGapSupport","hasBlockGapSupport","css","getLayoutStyle","layoutDefinitions","LayoutPanel","setAttributes","attributes","name","defaultThemeLayout","themeSupportsLayout","supportsLayout","blockEditingMode","layoutBlockSupport","allowSwitching","allowEditing","allowInheriting","showInheritToggle","layoutType","constrainedType","displayControlsForLegacyLayouts","hasContentSizeOrLegacySettings","onChangeType","newType","onChangeLayout","newLayout","LayoutTypeSwitcher","onChange","map","label","addAttribute","settings","withInspectorControls","BlockEdit","props","supportLayout","withLayoutStyles","BlockListBlock","hasLayoutBlockSupport","disableLayoutStyles","shouldRenderLayoutStyles","id","element","BlockList","__unstableElementContext","layoutClasses","layoutClassNames","withChildLayoutStyles","selfStretch","flexSize","hasChildLayout","shouldRenderChildLayoutStyles"],"mappings":";;;;;;;;;;;;AAoBA;;;;AAjBA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA/BA;AACA;AACA;;AAIA;AACA;AACA;;AAcA;AACA;AACA;AASA,MAAMA,qBAAqB,GAAG,sBAA9B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,gBAAT,GAAkE;AAAA;;AAAA,MAAvCC,eAAuC,uEAArB,EAAqB;AAAA,MAAjBC,SAAiB,uEAAL,EAAK;AACxE,QAAMC,oBAAoB,GAAG,qBAAaC,MAAF,IAAc;AAAA;;AACrD,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MAAM,CAAEE,YAAF,CAA9B;AACA,oCAAOD,WAAW,GAAGE,sBAArB,0DAAO,sBACJC,6BADH;AAEA,GAJ4B,EAI1B,EAJ0B,CAA7B;AAKA,QAAMC,oBAAoB,GAAG,yBAAY,QAAZ,KAA0B,EAAvD;AAEA,QAAM;AAAEC,IAAAA;AAAF,MAAaT,eAAnB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C,EAAI,EAA/C;AAEA,MAAIvC,GAAG,GAAG,EAAV;;AAEA,MAAK8C,WAAW,KAAK,OAAhB,IAA2BC,QAAhC,EAA2C;AAC1C/C,IAAAA,GAAG,IAAK,GAAGL,QAAU;AACxB,kBAAmBoD,QAAU;AAC7B;AACA,KAHG;AAIA,GALD,MAKO,IAAKD,WAAW,KAAK,MAArB,EAA8B;AACpC9C,IAAAA,GAAG,IAAK,GAAGL,QAAU;AACxB;AACA,KAFG;AAGA,GA3BiC,CA6BlC;;;AACA,QAAMV,SAAS,GAAG,yBAAY+C,KAAZ,aAAYA,KAAZ,uBAAYA,KAAK,CAAE/C,SAAnB,EAA8B;AAC/C,KAAG,wBAAwBsD,EAAI,EAA/B,GACCU,6BAA6B,IAAI,CAAC,CAAEjD,GAFU,CAEL;;AAFK,GAA9B,CAAlB;AAKA,SACC,qDACGiD,6BAA6B,IAC9BT,OADC,IAED,CAAC,CAAExC,GAFF,IAGD,2BAAc,2CAASA,GAAT,CAAd,EAAsCwC,OAAtC,CAJF,EAKC,4BAAC,cAAD,6BAAqBR,KAArB;AAA6B,IAAA,SAAS,EAAG/C;AAAzC,KALD,CADD;AASA,CA7CmC,EA8CpC,uBA9CoC,CAA9B;;AAiDP,sBACC,0BADD,EAEC,0BAFD,EAGC2C,YAHD;AAKA,sBACC,uBADD,EAEC,uCAFD,EAGCM,gBAHD;AAKA,sBACC,uBADD,EAEC,6CAFD,EAGCW,qBAHD;AAKA,sBACC,kBADD,EAEC,4CAFD,EAGCf,qBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tButton,\n\tButtonGroup,\n\tToggleControl,\n\tPanelBody,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useContext, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport useSetting from '../components/use-setting';\nimport { LayoutStyle } from '../components/block-list/layout';\nimport BlockList from '../components/block-list';\nimport { getLayoutType, getLayoutTypes } from '../layouts';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\nconst layoutBlockSupportKey = '__experimentalLayout';\n\n/**\n * Generates the utility classnames for the given block's layout attributes.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n *\n * @return { Array } Array of CSS classname strings.\n */\nexport function useLayoutClasses( blockAttributes = {}, blockName = '' ) {\n\tconst rootPaddingAlignment = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalFeatures\n\t\t\t?.useRootPaddingAwareAlignments;\n\t}, [] );\n\tconst globalLayoutSettings = useSetting( 'layout' ) || {};\n\n\tconst { layout } = blockAttributes;\n\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( blockName, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst layoutClassnames = [];\n\n\tif (\n\t\tglobalLayoutSettings?.definitions?.[ usedLayout?.type || 'default' ]\n\t\t\t?.className\n\t) {\n\t\tconst baseClassName =\n\t\t\tglobalLayoutSettings?.definitions?.[ usedLayout?.type || 'default' ]\n\t\t\t\t?.className;\n\t\tconst compoundClassName = `wp-block-${ blockName\n\t\t\t.split( '/' )\n\t\t\t.pop() }-${ baseClassName }`;\n\t\tlayoutClassnames.push( baseClassName, compoundClassName );\n\t}\n\n\tif (\n\t\t( usedLayout?.inherit ||\n\t\t\tusedLayout?.contentSize ||\n\t\t\tusedLayout?.type === 'constrained' ) &&\n\t\trootPaddingAlignment\n\t) {\n\t\tlayoutClassnames.push( 'has-global-padding' );\n\t}\n\n\tif ( usedLayout?.orientation ) {\n\t\tlayoutClassnames.push( `is-${ kebabCase( usedLayout.orientation ) }` );\n\t}\n\n\tif ( usedLayout?.justifyContent ) {\n\t\tlayoutClassnames.push(\n\t\t\t`is-content-justification-${ kebabCase(\n\t\t\t\tusedLayout.justifyContent\n\t\t\t) }`\n\t\t);\n\t}\n\n\tif ( usedLayout?.flexWrap && usedLayout.flexWrap === 'nowrap' ) {\n\t\tlayoutClassnames.push( 'is-nowrap' );\n\t}\n\n\treturn layoutClassnames;\n}\n\n/**\n * Generates a CSS rule with the given block's layout styles.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n * @param { string } selector A selector to use in generating the CSS rule.\n *\n * @return { string } CSS rule.\n */\nexport function useLayoutStyles( blockAttributes = {}, blockName, selector ) {\n\tconst { layout = {}, style = {} } = blockAttributes;\n\t// Update type for blocks using legacy layouts.\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || {};\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst globalLayoutSettings = useSetting( 'layout' ) || {};\n\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\tconst css = fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName,\n\t\tselector,\n\t\tlayout,\n\t\tlayoutDefinitions: globalLayoutSettings?.definitions,\n\t\tstyle,\n\t\thasBlockGapSupport,\n\t} );\n\treturn css;\n}\n\nfunction LayoutPanel( { setAttributes, attributes, name: blockName } ) {\n\tconst { layout } = attributes;\n\tconst defaultThemeLayout = useSetting( 'layout' );\n\tconst { themeSupportsLayout } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\tthemeSupportsLayout: getSettings().supportsLayout,\n\t\t};\n\t}, [] );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst layoutBlockSupport = getBlockSupport(\n\t\tblockName,\n\t\tlayoutBlockSupportKey,\n\t\t{}\n\t);\n\tconst {\n\t\tallowSwitching,\n\t\tallowEditing = true,\n\t\tallowInheriting = true,\n\t\tdefault: defaultBlockLayout,\n\t} = layoutBlockSupport;\n\n\tif ( ! allowEditing ) {\n\t\treturn null;\n\t}\n\n\t// Only show the inherit toggle if it's supported,\n\t// a default theme layout is set (e.g. one that provides `contentSize` and/or `wideSize` values),\n\t// and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other.\n\tconst showInheritToggle = !! (\n\t\tallowInheriting &&\n\t\t!! defaultThemeLayout &&\n\t\t( ! layout?.type ||\n\t\t\tlayout?.type === 'default' ||\n\t\t\tlayout?.type === 'constrained' ||\n\t\t\tlayout?.inherit )\n\t);\n\n\tconst usedLayout = layout || defaultBlockLayout || {};\n\tconst {\n\t\tinherit = false,\n\t\ttype = 'default',\n\t\tcontentSize = null,\n\t} = usedLayout;\n\t/**\n\t * `themeSupportsLayout` is only relevant to the `default/flow` or\n\t * `constrained` layouts and it should not be taken into account when other\n\t * `layout` types are used.\n\t */\n\tif (\n\t\t( type === 'default' || type === 'constrained' ) &&\n\t\t! themeSupportsLayout\n\t) {\n\t\treturn null;\n\t}\n\tconst layoutType = getLayoutType( type );\n\tconst constrainedType = getLayoutType( 'constrained' );\n\tconst displayControlsForLegacyLayouts =\n\t\t! usedLayout.type && ( contentSize || inherit );\n\tconst hasContentSizeOrLegacySettings = !! inherit || !! contentSize;\n\n\tconst onChangeType = ( newType ) =>\n\t\tsetAttributes( { layout: { type: newType } } );\n\tconst onChangeLayout = ( newLayout ) =>\n\t\tsetAttributes( { layout: newLayout } );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Layout' ) }>\n\t\t\t\t\t{ showInheritToggle && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tclassName=\"block-editor-hooks__toggle-control\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Inner blocks use content width' ) }\n\t\t\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t\t\ttype:\n\t\t\t\t\t\t\t\t\t\t\t\tlayoutType?.name ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t'constrained' ||\n\t\t\t\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'default'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: 'constrained',\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks use content width with options for full and wide widths.'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks will fill the width of this container. Toggle to constrain.'\n\t\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ ! inherit && allowSwitching && (\n\t\t\t\t\t\t<LayoutTypeSwitcher\n\t\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\t\tonChange={ onChangeType }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ layoutType && layoutType.name !== 'default' && (\n\t\t\t\t\t\t<layoutType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ constrainedType && displayControlsForLegacyLayouts && (\n\t\t\t\t\t\t<constrainedType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ ! inherit && blockEditingMode === 'default' && layoutType && (\n\t\t\t\t<layoutType.toolBarControls\n\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction LayoutTypeSwitcher( { type, onChange } ) {\n\treturn (\n\t\t<ButtonGroup>\n\t\t\t{ getLayoutTypes().map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tisPressed={ type === name }\n\t\t\t\t\t\tonClick={ () => onChange( name ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</Button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ButtonGroup>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( 'type' in ( settings.attributes?.layout ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, layoutBlockSupportKey ) ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include layout controls\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withInspectorControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name: blockName } = props;\n\t\tconst supportLayout = hasBlockSupport(\n\t\t\tblockName,\n\t\t\tlayoutBlockSupportKey\n\t\t);\n\n\t\treturn [\n\t\t\tsupportLayout && <LayoutPanel key=\"layout\" { ...props } />,\n\t\t\t<BlockEdit key=\"edit\" { ...props } />,\n\t\t];\n\t},\n\t'withInspectorControls'\n);\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst hasLayoutBlockSupport = hasBlockSupport(\n\t\t\tname,\n\t\t\tlayoutBlockSupportKey\n\t\t);\n\t\tconst disableLayoutStyles = useSelect( ( select ) => {\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\treturn !! getSettings().disableLayoutStyles;\n\t\t} );\n\t\tconst shouldRenderLayoutStyles =\n\t\t\thasLayoutBlockSupport && ! disableLayoutStyles;\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst defaultThemeLayout = useSetting( 'layout' ) || {};\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\t\tconst { layout } = attributes;\n\t\tconst { default: defaultBlockLayout } =\n\t\t\tgetBlockSupport( name, layoutBlockSupportKey ) || {};\n\t\tconst usedLayout =\n\t\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t\t: layout || defaultBlockLayout || {};\n\t\tconst layoutClasses = hasLayoutBlockSupport\n\t\t\t? useLayoutClasses( attributes, name )\n\t\t\t: null;\n\t\t// Higher specificity to override defaults from theme.json.\n\t\tconst selector = `.wp-container-${ id }.wp-container-${ id }`;\n\t\tconst blockGapSupport = useSetting( 'spacing.blockGap' );\n\t\tconst hasBlockGapSupport = blockGapSupport !== null;\n\n\t\t// Get CSS string for the current layout type.\n\t\t// The CSS and `style` element is only output if it is not empty.\n\t\tlet css;\n\t\tif ( shouldRenderLayoutStyles ) {\n\t\t\tconst fullLayoutType = getLayoutType(\n\t\t\t\tusedLayout?.type || 'default'\n\t\t\t);\n\t\t\tcss = fullLayoutType?.getLayoutStyle?.( {\n\t\t\t\tblockName: name,\n\t\t\t\tselector,\n\t\t\t\tlayout: usedLayout,\n\t\t\t\tlayoutDefinitions: defaultThemeLayout?.definitions,\n\t\t\t\tstyle: attributes?.style,\n\t\t\t\thasBlockGapSupport,\n\t\t\t} );\n\t\t}\n\n\t\t// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.\n\t\tconst layoutClassNames = classnames(\n\t\t\t{\n\t\t\t\t[ `wp-container-${ id }` ]: shouldRenderLayoutStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t\t},\n\t\t\tlayoutClasses\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ shouldRenderLayoutStyles &&\n\t\t\t\t\telement &&\n\t\t\t\t\t!! css &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\tblockName={ name }\n\t\t\t\t\t\t\tselector={ selector }\n\t\t\t\t\t\t\tcss={ css }\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tstyle={ attributes?.style }\n\t\t\t\t\t\t/>,\n\t\t\t\t\t\telement\n\t\t\t\t\t) }\n\t\t\t\t<BlockListBlock\n\t\t\t\t\t{ ...props }\n\t\t\t\t\t__unstableLayoutClassNames={ layoutClassNames }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n\t'withLayoutStyles'\n);\n\n/**\n * Override the default block element to add the child layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withChildLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { attributes } = props;\n\t\tconst { style: { layout = {} } = {} } = attributes;\n\t\tconst { selfStretch, flexSize } = layout;\n\t\tconst hasChildLayout = selfStretch || flexSize;\n\t\tconst disableLayoutStyles = useSelect( ( select ) => {\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\treturn !! getSettings().disableLayoutStyles;\n\t\t} );\n\t\tconst shouldRenderChildLayoutStyles =\n\t\t\thasChildLayout && ! disableLayoutStyles;\n\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst selector = `.wp-container-content-${ id }`;\n\n\t\tlet css = '';\n\n\t\tif ( selfStretch === 'fixed' && flexSize ) {\n\t\t\tcss += `${ selector } {\n\t\t\t\tflex-basis: ${ flexSize };\n\t\t\t\tbox-sizing: border-box;\n\t\t\t}`;\n\t\t} else if ( selfStretch === 'fill' ) {\n\t\t\tcss += `${ selector } {\n\t\t\t\tflex-grow: 1;\n\t\t\t}`;\n\t\t}\n\n\t\t// Attach a `wp-container-content` id-based classname.\n\t\tconst className = classnames( props?.className, {\n\t\t\t[ `wp-container-content-${ id }` ]:\n\t\t\t\tshouldRenderChildLayoutStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t} );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ shouldRenderChildLayoutStyles &&\n\t\t\t\t\telement &&\n\t\t\t\t\t!! css &&\n\t\t\t\t\tcreatePortal( <style>{ css }</style>, element ) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withChildLayoutStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/layout/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-layout-styles',\n\twithLayoutStyles\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-child-layout-styles',\n\twithChildLayoutStyles\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/layout/with-inspector-controls',\n\twithInspectorControls\n);\n"]}
|
package/build/hooks/position.js
CHANGED
|
@@ -396,7 +396,7 @@ const withPositionStyles = (0, _compose.createHigherOrderComponent)(BlockListBlo
|
|
|
396
396
|
return (0, _element.createElement)(_element.Fragment, null, allowPositionStyles && element && !!css && (0, _element.createPortal)((0, _element.createElement)("style", null, css), element), (0, _element.createElement)(BlockListBlock, (0, _extends2.default)({}, props, {
|
|
397
397
|
className: className
|
|
398
398
|
})));
|
|
399
|
-
});
|
|
399
|
+
}, 'withPositionStyles');
|
|
400
400
|
exports.withPositionStyles = withPositionStyles;
|
|
401
401
|
(0, _hooks.addFilter)('editor.BlockListBlock', 'core/editor/position/with-position-styles', withPositionStyles);
|
|
402
402
|
(0, _hooks.addFilter)('editor.BlockEdit', 'core/editor/position/with-inspector-controls', withInspectorControls);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/position.js"],"names":["CustomSelectControl","componentsPrivateApis","POSITION_SUPPORT_KEY","OPTION_CLASSNAME","DEFAULT_OPTION","key","value","name","className","STICKY_OPTION","__experimentalHint","FIXED_OPTION","POSITION_SIDES","VALID_POSITION_TYPES","getPositionCSS","selector","style","output","type","positionType","position","includes","forEach","side","undefined","hasStickyPositionSupport","blockType","support","sticky","hasFixedPositionSupport","fixed","hasPositionSupport","hasPositionValue","props","attributes","hasStickyOrFixedPositionValue","resetPosition","setAttributes","top","right","bottom","left","useIsPositionDisabled","blockName","allowFixed","allowSticky","isDisabled","PositionPanel","clientId","hasParents","select","getBlockParents","blockEditorStore","parents","length","options","availableOptions","push","onChangeType","next","placementValue","newStyle","selectedOption","find","option","Platform","web","selectedItem","native","withInspectorControls","BlockEdit","positionSupport","showPositionControls","withPositionStyles","BlockListBlock","hasPositionBlockSupport","allowPositionStyles","id","element","BlockList","__unstableElementContext","positionSelector","css"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA;;;;AAbA;;AAKA;;AACA;;AACA;;AAIA;;AACA;;AAOA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAhCA;AACA;AACA;;AAGA;AACA;AACA;;AAiBA;AACA;AACA;AAQA,MAAM;AAAEA,EAAAA;AAAF,IAA0B,wBAAQC,uBAAR,CAAhC;AAEA,MAAMC,oBAAoB,GAAG,UAA7B;AAEA,MAAMC,gBAAgB,GACrB,gEADD;AAGA,MAAMC,cAAc,GAAG;AACtBC,EAAAA,GAAG,EAAE,SADiB;AAEtBC,EAAAA,KAAK,EAAE,EAFe;AAGtBC,EAAAA,IAAI,EAAE,cAAI,SAAJ,CAHgB;AAItBC,EAAAA,SAAS,EAAEL;AAJW,CAAvB;AAOA,MAAMM,aAAa,GAAG;AACrBJ,EAAAA,GAAG,EAAE,QADgB;AAErBC,EAAAA,KAAK,EAAE,QAFc;AAGrBC,EAAAA,IAAI,EAAE,cAAI,QAAJ,EAAc,iDAAd,CAHe;AAIrBC,EAAAA,SAAS,EAAEL,gBAJU;AAKrBO,EAAAA,kBAAkB,EAAE,cACnB,qEADmB;AALC,CAAtB;AAUA,MAAMC,YAAY,GAAG;AACpBN,EAAAA,GAAG,EAAE,OADe;AAEpBC,EAAAA,KAAK,EAAE,OAFa;AAGpBC,EAAAA,IAAI,EAAE,cAAI,OAAJ,EAAa,iDAAb,CAHc;AAIpBC,EAAAA,SAAS,EAAEL,gBAJS;AAKpBO,EAAAA,kBAAkB,EAAE,cACnB,oDADmB;AALA,CAArB;AAUA,MAAME,cAAc,GAAG,CAAE,KAAF,EAAS,OAAT,EAAkB,QAAlB,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GADH,IAEA,CAAC,EAAEhD,UAAF,aAAEA,UAAF,qCAAEA,UAAU,CAAElB,KAAd,wEAAE,mBAAmBI,QAArB,kDAAE,sBAA6BF,IAA/B;AAL6C,GAA9B,CAAlB;AAQA,SACC,qDACG0D,mBAAmB,IACpBE,OADC,IAED,CAAC,CAAEI,GAFF,IAGD,2BAAc,2CAASA,GAAT,CAAd,EAAsCJ,OAAtC,CAJF,EAKC,4BAAC,cAAD,6BAAqB7C,KAArB;AAA6B,IAAA,SAAS,EAAGzB;AAAzC,KALD,CADD;AASA,CA5CgC,CAA3B;;AA+CP,sBACC,uBADD,EAEC,2CAFD,EAGCiE,kBAHD;AAKA,sBACC,kBADD,EAEC,8CAFD,EAGCJ,qBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport {\n\tBaseControl,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseContext,\n\tuseMemo,\n\tcreatePortal,\n\tPlatform,\n} from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport BlockList from '../components/block-list';\nimport useSetting from '../components/use-setting';\nimport InspectorControls from '../components/inspector-controls';\nimport { cleanEmptyObject } from './utils';\nimport { unlock } from '../lock-unlock';\nimport { store as blockEditorStore } from '../store';\n\nconst { CustomSelectControl } = unlock( componentsPrivateApis );\n\nconst POSITION_SUPPORT_KEY = 'position';\n\nconst OPTION_CLASSNAME =\n\t'block-editor-hooks__position-selection__select-control__option';\n\nconst DEFAULT_OPTION = {\n\tkey: 'default',\n\tvalue: '',\n\tname: __( 'Default' ),\n\tclassName: OPTION_CLASSNAME,\n};\n\nconst STICKY_OPTION = {\n\tkey: 'sticky',\n\tvalue: 'sticky',\n\tname: _x( 'Sticky', 'Name for the value of the CSS position property' ),\n\tclassName: OPTION_CLASSNAME,\n\t__experimentalHint: __(\n\t\t'The block will stick to the top of the window instead of scrolling.'\n\t),\n};\n\nconst FIXED_OPTION = {\n\tkey: 'fixed',\n\tvalue: 'fixed',\n\tname: _x( 'Fixed', 'Name for the value of the CSS position property' ),\n\tclassName: OPTION_CLASSNAME,\n\t__experimentalHint: __(\n\t\t'The block will not move when the page is scrolled.'\n\t),\n};\n\nconst POSITION_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nconst VALID_POSITION_TYPES = [ 'sticky', 'fixed' ];\n\n/**\n * Get calculated position CSS.\n *\n * @param {Object} props Component props.\n * @param {string} props.selector Selector to use.\n * @param {Object} props.style Style object.\n * @return {string} The generated CSS rules.\n */\nexport function getPositionCSS( { selector, style } ) {\n\tlet output = '';\n\n\tconst { type: positionType } = style?.position || {};\n\n\tif ( ! VALID_POSITION_TYPES.includes( positionType ) ) {\n\t\treturn output;\n\t}\n\n\toutput += `${ selector } {`;\n\toutput += `position: ${ positionType };`;\n\n\tPOSITION_SIDES.forEach( ( side ) => {\n\t\tif ( style?.position?.[ side ] !== undefined ) {\n\t\t\toutput += `${ side }: ${ style.position[ side ] };`;\n\t\t}\n\t} );\n\n\tif ( positionType === 'sticky' || positionType === 'fixed' ) {\n\t\t// TODO: Replace hard-coded z-index value with a z-index preset approach in theme.json.\n\t\toutput += `z-index: 10`;\n\t}\n\toutput += `}`;\n\n\treturn output;\n}\n\n/**\n * Determines if there is sticky position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasStickyPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.sticky );\n}\n\n/**\n * Determines if there is fixed position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasFixedPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.fixed );\n}\n\n/**\n * Determines if there is position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! support;\n}\n\n/**\n * Checks if there is a current value in the position block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a position value set.\n */\nexport function hasPositionValue( props ) {\n\treturn props.attributes.style?.position?.type !== undefined;\n}\n\n/**\n * Checks if the block is currently set to a sticky or fixed position.\n * This check is helpful for determining how to position block toolbars or other elements.\n *\n * @param {Object} attributes Block attributes.\n * @return {boolean} Whether or not the block is set to a sticky or fixed position.\n */\nexport function hasStickyOrFixedPositionValue( attributes ) {\n\tconst positionType = attributes.style?.position?.type;\n\treturn positionType === 'sticky' || positionType === 'fixed';\n}\n\n/**\n * Resets the position block support attributes. This can be used when disabling\n * the position support controls for a block via a `ToolsPanel`.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetPosition( { attributes = {}, setAttributes } ) {\n\tconst { style = {} } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: undefined,\n\t\t\t\ttop: undefined,\n\t\t\t\tright: undefined,\n\t\t\t\tbottom: undefined,\n\t\t\t\tleft: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if position settings have been disabled.\n *\n * @param {string} name The name of the block.\n *\n * @return {boolean} Whether padding setting is disabled.\n */\nexport function useIsPositionDisabled( { name: blockName } = {} ) {\n\tconst allowFixed = useSetting( 'position.fixed' );\n\tconst allowSticky = useSetting( 'position.sticky' );\n\tconst isDisabled = ! allowFixed && ! allowSticky;\n\n\treturn ! hasPositionSupport( blockName ) || isDisabled;\n}\n\n/*\n * Position controls rendered in an inspector control panel.\n *\n * @param {Object} props\n *\n * @return {WPElement} Position panel.\n */\nexport function PositionPanel( props ) {\n\tconst {\n\t\tattributes: { style = {} },\n\t\tclientId,\n\t\tname: blockName,\n\t\tsetAttributes,\n\t} = props;\n\n\tconst allowFixed = hasFixedPositionSupport( blockName );\n\tconst allowSticky = hasStickyPositionSupport( blockName );\n\tconst value = style?.position?.type;\n\n\tconst { hasParents } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParents } = select( blockEditorStore );\n\t\t\tconst parents = getBlockParents( clientId );\n\t\t\treturn {\n\t\t\t\thasParents: parents.length,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst options = useMemo( () => {\n\t\tconst availableOptions = [ DEFAULT_OPTION ];\n\t\t// Only display sticky option if the block has no parents (is at the root of the document),\n\t\t// or if the block already has a sticky position value set.\n\t\tif (\n\t\t\t( allowSticky && ! hasParents ) ||\n\t\t\tvalue === STICKY_OPTION.value\n\t\t) {\n\t\t\tavailableOptions.push( STICKY_OPTION );\n\t\t}\n\t\tif ( allowFixed || value === FIXED_OPTION.value ) {\n\t\t\tavailableOptions.push( FIXED_OPTION );\n\t\t}\n\t\treturn availableOptions;\n\t}, [ allowFixed, allowSticky, hasParents, value ] );\n\n\tconst onChangeType = ( next ) => {\n\t\t// For now, use a hard-coded `0px` value for the position.\n\t\t// `0px` is preferred over `0` as it can be used in `calc()` functions.\n\t\t// In the future, it could be useful to allow for an offset value.\n\t\tconst placementValue = '0px';\n\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: next,\n\t\t\t\ttop:\n\t\t\t\t\tnext === 'sticky' || next === 'fixed'\n\t\t\t\t\t\t? placementValue\n\t\t\t\t\t\t: undefined,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\tconst selectedOption = value\n\t\t? options.find( ( option ) => option.value === value ) || DEFAULT_OPTION\n\t\t: DEFAULT_OPTION;\n\n\t// Only display position controls if there is at least one option to choose from.\n\treturn Platform.select( {\n\t\tweb:\n\t\t\toptions.length > 1 ? (\n\t\t\t\t<InspectorControls group=\"position\">\n\t\t\t\t\t<BaseControl className=\"block-editor-hooks__position-selection\">\n\t\t\t\t\t\t<CustomSelectControl\n\t\t\t\t\t\t\t__nextUnconstrainedWidth\n\t\t\t\t\t\t\t__next36pxDefaultSize\n\t\t\t\t\t\t\tclassName=\"block-editor-hooks__position-selection__select-control\"\n\t\t\t\t\t\t\tlabel={ __( 'Position' ) }\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\tdescribedBy={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Currently selected position.\n\t\t\t\t\t\t\t\t__( 'Currently selected position: %s' ),\n\t\t\t\t\t\t\t\tselectedOption.name\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\toptions={ options }\n\t\t\t\t\t\t\tvalue={ selectedOption }\n\t\t\t\t\t\t\t__experimentalShowSelectedHint\n\t\t\t\t\t\t\tonChange={ ( { selectedItem } ) => {\n\t\t\t\t\t\t\t\tonChangeType( selectedItem.value );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BaseControl>\n\t\t\t\t</InspectorControls>\n\t\t\t) : null,\n\t\tnative: null,\n\t} );\n}\n\n/**\n * Override the default edit UI to include position controls.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withInspectorControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name: blockName } = props;\n\t\tconst positionSupport = hasBlockSupport(\n\t\t\tblockName,\n\t\t\tPOSITION_SUPPORT_KEY\n\t\t);\n\t\tconst showPositionControls =\n\t\t\tpositionSupport && ! useIsPositionDisabled( props );\n\n\t\treturn [\n\t\t\tshowPositionControls && (\n\t\t\t\t<PositionPanel key=\"position\" { ...props } />\n\t\t\t),\n\t\t\t<BlockEdit key=\"edit\" { ...props } />,\n\t\t];\n\t},\n\t'withInspectorControls'\n);\n\n/**\n * Override the default block element to add the position styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withPositionStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst hasPositionBlockSupport = hasBlockSupport(\n\t\t\tname,\n\t\t\tPOSITION_SUPPORT_KEY\n\t\t);\n\t\tconst allowPositionStyles =\n\t\t\thasPositionBlockSupport && ! useIsPositionDisabled( props );\n\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t\t// Higher specificity to override defaults in editor UI.\n\t\tconst positionSelector = `.wp-container-${ id }.wp-container-${ id }`;\n\n\t\t// Get CSS string for the current position values.\n\t\tlet css;\n\t\tif ( allowPositionStyles ) {\n\t\t\tcss =\n\t\t\t\tgetPositionCSS( {\n\t\t\t\t\tselector: positionSelector,\n\t\t\t\t\tstyle: attributes?.style,\n\t\t\t\t} ) || '';\n\t\t}\n\n\t\t// Attach a `wp-container-` id-based class name.\n\t\tconst className = classnames( props?.className, {\n\t\t\t[ `wp-container-${ id }` ]: allowPositionStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t\t[ `is-position-${ attributes?.style?.position?.type }` ]:\n\t\t\t\tallowPositionStyles &&\n\t\t\t\t!! css &&\n\t\t\t\t!! attributes?.style?.position?.type,\n\t\t} );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ allowPositionStyles &&\n\t\t\t\t\telement &&\n\t\t\t\t\t!! css &&\n\t\t\t\t\tcreatePortal( <style>{ css }</style>, element ) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t}\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/position/with-position-styles',\n\twithPositionStyles\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/position/with-inspector-controls',\n\twithInspectorControls\n);\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/position.js"],"names":["CustomSelectControl","componentsPrivateApis","POSITION_SUPPORT_KEY","OPTION_CLASSNAME","DEFAULT_OPTION","key","value","name","className","STICKY_OPTION","__experimentalHint","FIXED_OPTION","POSITION_SIDES","VALID_POSITION_TYPES","getPositionCSS","selector","style","output","type","positionType","position","includes","forEach","side","undefined","hasStickyPositionSupport","blockType","support","sticky","hasFixedPositionSupport","fixed","hasPositionSupport","hasPositionValue","props","attributes","hasStickyOrFixedPositionValue","resetPosition","setAttributes","top","right","bottom","left","useIsPositionDisabled","blockName","allowFixed","allowSticky","isDisabled","PositionPanel","clientId","hasParents","select","getBlockParents","blockEditorStore","parents","length","options","availableOptions","push","onChangeType","next","placementValue","newStyle","selectedOption","find","option","Platform","web","selectedItem","native","withInspectorControls","BlockEdit","positionSupport","showPositionControls","withPositionStyles","BlockListBlock","hasPositionBlockSupport","allowPositionStyles","id","element","BlockList","__unstableElementContext","positionSelector","css"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA;;;;AAbA;;AAKA;;AACA;;AACA;;AAIA;;AACA;;AAOA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAhCA;AACA;AACA;;AAGA;AACA;AACA;;AAiBA;AACA;AACA;AAQA,MAAM;AAAEA,EAAAA;AAAF,IAA0B,wBAAQC,uBAAR,CAAhC;AAEA,MAAMC,oBAAoB,GAAG,UAA7B;AAEA,MAAMC,gBAAgB,GACrB,gEADD;AAGA,MAAMC,cAAc,GAAG;AACtBC,EAAAA,GAAG,EAAE,SADiB;AAEtBC,EAAAA,KAAK,EAAE,EAFe;AAGtBC,EAAAA,IAAI,EAAE,cAAI,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bkC,CAelC;;AACA,MAAIK,GAAJ;;AACA,MAAKN,mBAAL,EAA2B;AAC1BM,IAAAA,GAAG,GACFpE,cAAc,CAAE;AACfC,MAAAA,QAAQ,EAAEkE,gBADK;AAEfjE,MAAAA,KAAK,EAAEkB,UAAF,aAAEA,UAAF,uBAAEA,UAAU,CAAElB;AAFJ,KAAF,CAAd,IAGO,EAJR;AAKA,GAvBiC,CAyBlC;;;AACA,QAAMR,SAAS,GAAG,yBAAYyB,KAAZ,aAAYA,KAAZ,uBAAYA,KAAK,CAAEzB,SAAnB,EAA8B;AAC/C,KAAG,gBAAgBqE,EAAI,EAAvB,GAA4BD,mBAAmB,IAAI,CAAC,CAAEM,GADP;AACY;AAC3D,KAAG,eAAehD,UAAhB,aAAgBA,UAAhB,6CAAgBA,UAAU,CAAElB,KAA5B,gFAAgB,mBAAmBI,QAAnC,0DAAgB,sBAA6BF,IAAM,EAArD,GACC0D,mBAAmB,IACnB,CAAC,CAAEM,GADH,IAEA,CAAC,EAAEhD,UAAF,aAAEA,UAAF,qCAAEA,UAAU,CAAElB,KAAd,wEAAE,mBAAmBI,QAArB,kDAAE,sBAA6BF,IAA/B;AAL6C,GAA9B,CAAlB;AAQA,SACC,qDACG0D,mBAAmB,IACpBE,OADC,IAED,CAAC,CAAEI,GAFF,IAGD,2BAAc,2CAASA,GAAT,CAAd,EAAsCJ,OAAtC,CAJF,EAKC,4BAAC,cAAD,6BAAqB7C,KAArB;AAA6B,IAAA,SAAS,EAAGzB;AAAzC,KALD,CADD;AASA,CA5CgC,EA6CjC,oBA7CiC,CAA3B;;AAgDP,sBACC,uBADD,EAEC,2CAFD,EAGCiE,kBAHD;AAKA,sBACC,kBADD,EAEC,8CAFD,EAGCJ,qBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport {\n\tBaseControl,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseContext,\n\tuseMemo,\n\tcreatePortal,\n\tPlatform,\n} from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport BlockList from '../components/block-list';\nimport useSetting from '../components/use-setting';\nimport InspectorControls from '../components/inspector-controls';\nimport { cleanEmptyObject } from './utils';\nimport { unlock } from '../lock-unlock';\nimport { store as blockEditorStore } from '../store';\n\nconst { CustomSelectControl } = unlock( componentsPrivateApis );\n\nconst POSITION_SUPPORT_KEY = 'position';\n\nconst OPTION_CLASSNAME =\n\t'block-editor-hooks__position-selection__select-control__option';\n\nconst DEFAULT_OPTION = {\n\tkey: 'default',\n\tvalue: '',\n\tname: __( 'Default' ),\n\tclassName: OPTION_CLASSNAME,\n};\n\nconst STICKY_OPTION = {\n\tkey: 'sticky',\n\tvalue: 'sticky',\n\tname: _x( 'Sticky', 'Name for the value of the CSS position property' ),\n\tclassName: OPTION_CLASSNAME,\n\t__experimentalHint: __(\n\t\t'The block will stick to the top of the window instead of scrolling.'\n\t),\n};\n\nconst FIXED_OPTION = {\n\tkey: 'fixed',\n\tvalue: 'fixed',\n\tname: _x( 'Fixed', 'Name for the value of the CSS position property' ),\n\tclassName: OPTION_CLASSNAME,\n\t__experimentalHint: __(\n\t\t'The block will not move when the page is scrolled.'\n\t),\n};\n\nconst POSITION_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nconst VALID_POSITION_TYPES = [ 'sticky', 'fixed' ];\n\n/**\n * Get calculated position CSS.\n *\n * @param {Object} props Component props.\n * @param {string} props.selector Selector to use.\n * @param {Object} props.style Style object.\n * @return {string} The generated CSS rules.\n */\nexport function getPositionCSS( { selector, style } ) {\n\tlet output = '';\n\n\tconst { type: positionType } = style?.position || {};\n\n\tif ( ! VALID_POSITION_TYPES.includes( positionType ) ) {\n\t\treturn output;\n\t}\n\n\toutput += `${ selector } {`;\n\toutput += `position: ${ positionType };`;\n\n\tPOSITION_SIDES.forEach( ( side ) => {\n\t\tif ( style?.position?.[ side ] !== undefined ) {\n\t\t\toutput += `${ side }: ${ style.position[ side ] };`;\n\t\t}\n\t} );\n\n\tif ( positionType === 'sticky' || positionType === 'fixed' ) {\n\t\t// TODO: Replace hard-coded z-index value with a z-index preset approach in theme.json.\n\t\toutput += `z-index: 10`;\n\t}\n\toutput += `}`;\n\n\treturn output;\n}\n\n/**\n * Determines if there is sticky position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasStickyPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.sticky );\n}\n\n/**\n * Determines if there is fixed position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasFixedPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.fixed );\n}\n\n/**\n * Determines if there is position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! support;\n}\n\n/**\n * Checks if there is a current value in the position block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a position value set.\n */\nexport function hasPositionValue( props ) {\n\treturn props.attributes.style?.position?.type !== undefined;\n}\n\n/**\n * Checks if the block is currently set to a sticky or fixed position.\n * This check is helpful for determining how to position block toolbars or other elements.\n *\n * @param {Object} attributes Block attributes.\n * @return {boolean} Whether or not the block is set to a sticky or fixed position.\n */\nexport function hasStickyOrFixedPositionValue( attributes ) {\n\tconst positionType = attributes.style?.position?.type;\n\treturn positionType === 'sticky' || positionType === 'fixed';\n}\n\n/**\n * Resets the position block support attributes. This can be used when disabling\n * the position support controls for a block via a `ToolsPanel`.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetPosition( { attributes = {}, setAttributes } ) {\n\tconst { style = {} } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: undefined,\n\t\t\t\ttop: undefined,\n\t\t\t\tright: undefined,\n\t\t\t\tbottom: undefined,\n\t\t\t\tleft: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if position settings have been disabled.\n *\n * @param {string} name The name of the block.\n *\n * @return {boolean} Whether padding setting is disabled.\n */\nexport function useIsPositionDisabled( { name: blockName } = {} ) {\n\tconst allowFixed = useSetting( 'position.fixed' );\n\tconst allowSticky = useSetting( 'position.sticky' );\n\tconst isDisabled = ! allowFixed && ! allowSticky;\n\n\treturn ! hasPositionSupport( blockName ) || isDisabled;\n}\n\n/*\n * Position controls rendered in an inspector control panel.\n *\n * @param {Object} props\n *\n * @return {WPElement} Position panel.\n */\nexport function PositionPanel( props ) {\n\tconst {\n\t\tattributes: { style = {} },\n\t\tclientId,\n\t\tname: blockName,\n\t\tsetAttributes,\n\t} = props;\n\n\tconst allowFixed = hasFixedPositionSupport( blockName );\n\tconst allowSticky = hasStickyPositionSupport( blockName );\n\tconst value = style?.position?.type;\n\n\tconst { hasParents } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParents } = select( blockEditorStore );\n\t\t\tconst parents = getBlockParents( clientId );\n\t\t\treturn {\n\t\t\t\thasParents: parents.length,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst options = useMemo( () => {\n\t\tconst availableOptions = [ DEFAULT_OPTION ];\n\t\t// Only display sticky option if the block has no parents (is at the root of the document),\n\t\t// or if the block already has a sticky position value set.\n\t\tif (\n\t\t\t( allowSticky && ! hasParents ) ||\n\t\t\tvalue === STICKY_OPTION.value\n\t\t) {\n\t\t\tavailableOptions.push( STICKY_OPTION );\n\t\t}\n\t\tif ( allowFixed || value === FIXED_OPTION.value ) {\n\t\t\tavailableOptions.push( FIXED_OPTION );\n\t\t}\n\t\treturn availableOptions;\n\t}, [ allowFixed, allowSticky, hasParents, value ] );\n\n\tconst onChangeType = ( next ) => {\n\t\t// For now, use a hard-coded `0px` value for the position.\n\t\t// `0px` is preferred over `0` as it can be used in `calc()` functions.\n\t\t// In the future, it could be useful to allow for an offset value.\n\t\tconst placementValue = '0px';\n\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: next,\n\t\t\t\ttop:\n\t\t\t\t\tnext === 'sticky' || next === 'fixed'\n\t\t\t\t\t\t? placementValue\n\t\t\t\t\t\t: undefined,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\tconst selectedOption = value\n\t\t? options.find( ( option ) => option.value === value ) || DEFAULT_OPTION\n\t\t: DEFAULT_OPTION;\n\n\t// Only display position controls if there is at least one option to choose from.\n\treturn Platform.select( {\n\t\tweb:\n\t\t\toptions.length > 1 ? (\n\t\t\t\t<InspectorControls group=\"position\">\n\t\t\t\t\t<BaseControl className=\"block-editor-hooks__position-selection\">\n\t\t\t\t\t\t<CustomSelectControl\n\t\t\t\t\t\t\t__nextUnconstrainedWidth\n\t\t\t\t\t\t\t__next36pxDefaultSize\n\t\t\t\t\t\t\tclassName=\"block-editor-hooks__position-selection__select-control\"\n\t\t\t\t\t\t\tlabel={ __( 'Position' ) }\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\tdescribedBy={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Currently selected position.\n\t\t\t\t\t\t\t\t__( 'Currently selected position: %s' ),\n\t\t\t\t\t\t\t\tselectedOption.name\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\toptions={ options }\n\t\t\t\t\t\t\tvalue={ selectedOption }\n\t\t\t\t\t\t\t__experimentalShowSelectedHint\n\t\t\t\t\t\t\tonChange={ ( { selectedItem } ) => {\n\t\t\t\t\t\t\t\tonChangeType( selectedItem.value );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BaseControl>\n\t\t\t\t</InspectorControls>\n\t\t\t) : null,\n\t\tnative: null,\n\t} );\n}\n\n/**\n * Override the default edit UI to include position controls.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withInspectorControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name: blockName } = props;\n\t\tconst positionSupport = hasBlockSupport(\n\t\t\tblockName,\n\t\t\tPOSITION_SUPPORT_KEY\n\t\t);\n\t\tconst showPositionControls =\n\t\t\tpositionSupport && ! useIsPositionDisabled( props );\n\n\t\treturn [\n\t\t\tshowPositionControls && (\n\t\t\t\t<PositionPanel key=\"position\" { ...props } />\n\t\t\t),\n\t\t\t<BlockEdit key=\"edit\" { ...props } />,\n\t\t];\n\t},\n\t'withInspectorControls'\n);\n\n/**\n * Override the default block element to add the position styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withPositionStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst hasPositionBlockSupport = hasBlockSupport(\n\t\t\tname,\n\t\t\tPOSITION_SUPPORT_KEY\n\t\t);\n\t\tconst allowPositionStyles =\n\t\t\thasPositionBlockSupport && ! useIsPositionDisabled( props );\n\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t\t// Higher specificity to override defaults in editor UI.\n\t\tconst positionSelector = `.wp-container-${ id }.wp-container-${ id }`;\n\n\t\t// Get CSS string for the current position values.\n\t\tlet css;\n\t\tif ( allowPositionStyles ) {\n\t\t\tcss =\n\t\t\t\tgetPositionCSS( {\n\t\t\t\t\tselector: positionSelector,\n\t\t\t\t\tstyle: attributes?.style,\n\t\t\t\t} ) || '';\n\t\t}\n\n\t\t// Attach a `wp-container-` id-based class name.\n\t\tconst className = classnames( props?.className, {\n\t\t\t[ `wp-container-${ id }` ]: allowPositionStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t\t[ `is-position-${ attributes?.style?.position?.type }` ]:\n\t\t\t\tallowPositionStyles &&\n\t\t\t\t!! css &&\n\t\t\t\t!! attributes?.style?.position?.type,\n\t\t} );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ allowPositionStyles &&\n\t\t\t\t\telement &&\n\t\t\t\t\t!! css &&\n\t\t\t\t\tcreatePortal( <style>{ css }</style>, element ) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withPositionStyles'\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/position/with-position-styles',\n\twithPositionStyles\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/position/with-inspector-controls',\n\twithInspectorControls\n);\n"]}
|
package/build/hooks/style.js
CHANGED
|
@@ -401,7 +401,7 @@ const withElementsStyles = (0, _compose.createHigherOrderComponent)(BlockListBlo
|
|
|
401
401
|
}), element), (0, _element.createElement)(BlockListBlock, (0, _extends2.default)({}, props, {
|
|
402
402
|
className: (_props$attributes$sty7 = props.attributes.style) !== null && _props$attributes$sty7 !== void 0 && _props$attributes$sty7.elements ? (0, _classnames.default)(props.className, blockElementsContainerIdentifier) : props.className
|
|
403
403
|
})));
|
|
404
|
-
});
|
|
404
|
+
}, 'withElementsStyles');
|
|
405
405
|
(0, _hooks.addFilter)('blocks.registerBlockType', 'core/style/addAttribute', addAttribute);
|
|
406
406
|
(0, _hooks.addFilter)('blocks.getSaveContent.extraProps', 'core/style/addSaveProps', addSaveProps);
|
|
407
407
|
(0, _hooks.addFilter)('blocks.registerBlockType', 'core/style/addEditProps', addEditProps);
|
package/build/hooks/style.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/style.js"],"names":["styleSupportKeys","TYPOGRAPHY_SUPPORT_KEYS","BORDER_SUPPORT_KEY","COLOR_SUPPORT_KEY","DIMENSIONS_SUPPORT_KEY","SPACING_SUPPORT_KEY","hasStyleSupport","blockType","some","key","getInlineStyles","styles","output","forEach","rule","value","addAttribute","settings","attributes","style","Object","assign","type","skipSerializationPathsEdit","TYPOGRAPHY_SUPPORT_KEY","skipSerializationPathsSave","renamedFeatures","gradients","omitStyle","paths","preserveReference","newStyle","JSON","parse","stringify","Array","isArray","path","split","length","firstSubpath","restPath","addSaveProps","props","skipPaths","entries","indicator","skipSerialization","featureName","feature","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBlockControls","BlockEdit","shouldDisplayControls","withElementsStyles","BlockListBlock","blockElementsContainerIdentifier","skipLinkColorSerialization","name","elements","link","undefined","selector","ELEMENTS","elementCssRules","elementStyles","cssRule","push","join","element","BlockList","__unstableElementContext","__html","className"],"mappings":";;;;;;;;;;;;;AAQA;;;;AALA;;AAMA;;AACA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AAKA;;AACA;;AAnCA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;AAiBA,MAAMA,gBAAgB,GAAG,CACxB,GAAGC,mCADqB,EAExBC,0BAFwB,EAGxBC,wBAHwB,EAIxBC,kCAJwB,EAKxBC,+BALwB,CAAzB;;AAQA,MAAMC,eAAe,GAAKC,SAAF,IACvBP,gBAAgB,CAACQ,IAAjB,CAAyBC,GAAF,IAAW,6BAAiBF,SAAjB,EAA4BE,GAA5B,CAAlC,CADD;AAGA;AACA;AACA;AACA;AACA;AACA;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B,GAAgC,CAAE,kBAAF;AAFE,CAAnC;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMqB,eAAe,GAAG;AAAEC,EAAAA,SAAS,EAAE;AAAb,CAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,SAAT,CAAoBT,KAApB,EAA2BU,KAA3B,EAA8D;AAAA,MAA5BC,iBAA4B,uEAAR,KAAQ;;AACpE,MAAK,CAAEX,KAAP,EAAe;AACd,WAAOA,KAAP;AACA;;AAED,MAAIY,QAAQ,GAAGZ,KAAf;;AACA,MAAK,CAAEW,iBAAP,EAA2B;AAC1BC,IAAAA,QAAQ,GAAGC,IAAI,CAACC,KAAL,CAAYD,IAAI,CAACE,SAAL,CAAgBf,KAAhB,CAAZ,CAAX;AACA;;AAED,MAAK,CAAEgB,KAAK,CAACC,OAAN,CAAeP,KAAf,CAAP,EAAgC;AAC/BA,IAAAA,KAAK,GAAG,CAAEA,KAAF,CAAR;AACA;;AAEDA,EAAAA,KAAK,CAAChB,OAAN,CAAiBwB,IAAF,IAAY;AAC1B,QAAK,CAAEF,KAAK,CAACC,OAAN,CAAeC,IAAf,CAAP,EAA+B;AAC9BA,MAAAA,IAAI,GAAGA,IAAI,CAACC,KAAL,CAAY,GAAZ,CAAP;AACA;;AAED,QA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ADf,2DACF,uBAAwB0C,QADtB,EAEFH,gCAFE,EAGFC,0BAHE,CA9BY,CAAf;AAoCA,QAAMY,OAAO,GAAG,yBAAYC,mBAAUC,wBAAtB,CAAhB;AAEA,SACC,qDACG9D,MAAM,IACP4D,OADC,IAED,2BACC;AACC,IAAA,uBAAuB,EAAG;AACzBG,MAAAA,MAAM,EAAE/D;AADiB;AAD3B,IADD,EAMC4D,OAND,CAHF,EAYC,4BAAC,cAAD,6BACM5B,KADN;AAEC,IAAA,SAAS,EACR,0BAAAA,KAAK,CAACzB,UAAN,CAAiBC,KAAjB,0EAAwB0C,QAAxB,GACG,yBACAlB,KAAK,CAACgC,SADN,EAEAjB,gCAFA,CADH,GAKGf,KAAK,CAACgC;AARX,KAZD,CADD;AA0BA,CA5EyB,CAA3B;AA+EA,sBACC,0BADD,EAEC,yBAFD,EAGC3D,YAHD;AAMA,sBACC,kCADD,EAEC,yBAFD,EAGC0B,YAHD;AAMA,sBACC,0BADD,EAEC,yBAFD,EAGCQ,YAHD;AAMA,sBACC,kBADD,EAEC,gCAFD,EAGCG,iBAHD;AAMA,sBACC,uBADD,EAEC,kCAFD,EAGCG,kBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useContext, useMemo, createPortal } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\nimport {\n\tgetBlockSupport,\n\thasBlockSupport,\n\t__EXPERIMENTAL_ELEMENTS as ELEMENTS,\n} from '@wordpress/blocks';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { getCSSRules, compileCSS } from '@wordpress/style-engine';\n\n/**\n * Internal dependencies\n */\nimport BlockList from '../components/block-list';\nimport { BORDER_SUPPORT_KEY, BorderPanel } from './border';\nimport { COLOR_SUPPORT_KEY, ColorEdit } from './color';\nimport {\n\tTypographyPanel,\n\tTYPOGRAPHY_SUPPORT_KEY,\n\tTYPOGRAPHY_SUPPORT_KEYS,\n} from './typography';\nimport {\n\tDIMENSIONS_SUPPORT_KEY,\n\tSPACING_SUPPORT_KEY,\n\tDimensionsPanel,\n} from './dimensions';\nimport useDisplayBlockControls from '../components/use-display-block-controls';\nimport { shouldSkipSerialization } from './utils';\n\nconst styleSupportKeys = [\n\t...TYPOGRAPHY_SUPPORT_KEYS,\n\tBORDER_SUPPORT_KEY,\n\tCOLOR_SUPPORT_KEY,\n\tDIMENSIONS_SUPPORT_KEY,\n\tSPACING_SUPPORT_KEY,\n];\n\nconst hasStyleSupport = ( blockType ) =>\n\tstyleSupportKeys.some( ( key ) => hasBlockSupport( blockType, key ) );\n\n/**\n * Returns the inline styles to add depending on the style object\n *\n * @param {Object} styles Styles configuration.\n *\n * @return {Object} Flattened CSS variables declaration.\n */\nexport function getInlineStyles( styles = {} ) {\n\tconst output = {};\n\t// The goal is to move everything to server side generated engine styles\n\t// This is temporary as we absorb more and more styles into the engine.\n\tgetCSSRules( styles ).forEach( ( rule ) => {\n\t\toutput[ rule.key ] = rule.value;\n\t} );\n\n\treturn output;\n}\n\n/**\n * Filters registered block settings, extending attributes to include `style` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttribute( settings ) {\n\tif ( ! hasStyleSupport( settings ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * A dictionary of paths to flag skipping block support serialization as the key,\n * with values providing the style paths to be omitted from serialization.\n *\n * @constant\n * @type {Record<string, string[]>}\n */\nconst skipSerializationPathsEdit = {\n\t[ `${ BORDER_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [ 'border' ],\n\t[ `${ COLOR_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tCOLOR_SUPPORT_KEY,\n\t],\n\t[ `${ TYPOGRAPHY_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tTYPOGRAPHY_SUPPORT_KEY,\n\t],\n\t[ `${ DIMENSIONS_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tDIMENSIONS_SUPPORT_KEY,\n\t],\n\t[ `${ SPACING_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tSPACING_SUPPORT_KEY,\n\t],\n};\n\n/**\n * A dictionary of paths to flag skipping block support serialization as the key,\n * with values providing the style paths to be omitted from serialization.\n *\n * Extends the Edit skip paths to enable skipping additional paths in just\n * the Save component. This allows a block support to be serialized within the\n * editor, while using an alternate approach, such as server-side rendering, when\n * the support is saved.\n *\n * @constant\n * @type {Record<string, string[]>}\n */\nconst skipSerializationPathsSave = {\n\t...skipSerializationPathsEdit,\n\t[ `${ SPACING_SUPPORT_KEY }` ]: [ 'spacing.blockGap' ],\n};\n\n/**\n * A dictionary used to normalize feature names between support flags, style\n * object properties and __experimentSkipSerialization configuration arrays.\n *\n * This allows not having to provide a migration for a support flag and possible\n * backwards compatibility bridges, while still achieving consistency between\n * the support flag and the skip serialization array.\n *\n * @constant\n * @type {Record<string, string>}\n */\nconst renamedFeatures = { gradients: 'gradient' };\n\n/**\n * A utility function used to remove one or more paths from a style object.\n * Works in a way similar to Lodash's `omit()`. See unit tests and examples below.\n *\n * It supports a single string path:\n *\n * ```\n * omitStyle( { color: 'red' }, 'color' ); // {}\n * ```\n *\n * or an array of paths:\n *\n * ```\n * omitStyle( { color: 'red', background: '#fff' }, [ 'color', 'background' ] ); // {}\n * ```\n *\n * It also allows you to specify paths at multiple levels in a string.\n *\n * ```\n * omitStyle( { typography: { textDecoration: 'underline' } }, 'typography.textDecoration' ); // {}\n * ```\n *\n * You can remove multiple paths at the same time:\n *\n * ```\n * omitStyle(\n * \t\t{\n * \t\t\ttypography: {\n * \t\t\t\ttextDecoration: 'underline',\n * \t\t\t\ttextTransform: 'uppercase',\n * \t\t\t}\n *\t\t},\n *\t\t[\n * \t\t\t'typography.textDecoration',\n * \t\t\t'typography.textTransform',\n *\t\t]\n * );\n * // {}\n * ```\n *\n * You can also specify nested paths as arrays:\n *\n * ```\n * omitStyle(\n * \t\t{\n * \t\t\ttypography: {\n * \t\t\t\ttextDecoration: 'underline',\n * \t\t\t\ttextTransform: 'uppercase',\n * \t\t\t}\n *\t\t},\n *\t\t[\n * \t\t\t[ 'typography', 'textDecoration' ],\n * \t\t\t[ 'typography', 'textTransform' ],\n *\t\t]\n * );\n * // {}\n * ```\n *\n * With regards to nesting of styles, infinite depth is supported:\n *\n * ```\n * omitStyle(\n * \t\t{\n * \t\t\tborder: {\n * \t\t\t\tradius: {\n * \t\t\t\t\ttopLeft: '10px',\n * \t\t\t\t\ttopRight: '0.5rem',\n * \t\t\t\t}\n * \t\t\t}\n *\t\t},\n *\t\t[\n * \t\t\t[ 'border', 'radius', 'topRight' ],\n *\t\t]\n * );\n * // { border: { radius: { topLeft: '10px' } } }\n * ```\n *\n * The third argument, `preserveReference`, defines how to treat the input style object.\n * It is mostly necessary to properly handle mutation when recursively handling the style object.\n * Defaulting to `false`, this will always create a new object, avoiding to mutate `style`.\n * However, when recursing, we change that value to `true` in order to work with a single copy\n * of the original style object.\n *\n * @see https://lodash.com/docs/4.17.15#omit\n *\n * @param {Object} style Styles object.\n * @param {Array|string} paths Paths to remove.\n * @param {boolean} preserveReference True to mutate the `style` object, false otherwise.\n * @return {Object} Styles object with the specified paths removed.\n */\nexport function omitStyle( style, paths, preserveReference = false ) {\n\tif ( ! style ) {\n\t\treturn style;\n\t}\n\n\tlet newStyle = style;\n\tif ( ! preserveReference ) {\n\t\tnewStyle = JSON.parse( JSON.stringify( style ) );\n\t}\n\n\tif ( ! Array.isArray( paths ) ) {\n\t\tpaths = [ paths ];\n\t}\n\n\tpaths.forEach( ( path ) => {\n\t\tif ( ! Array.isArray( path ) ) {\n\t\t\tpath = path.split( '.' );\n\t\t}\n\n\t\tif ( path.length > 1 ) {\n\t\t\tconst [ firstSubpath, ...restPath ] = path;\n\t\t\tomitStyle( newStyle[ firstSubpath ], [ restPath ], true );\n\t\t} else if ( path.length === 1 ) {\n\t\t\tdelete newStyle[ path[ 0 ] ];\n\t\t}\n\t} );\n\n\treturn newStyle;\n}\n\n/**\n * Override props assigned to save component to inject the CSS variables definition.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n * @param {?Record<string, string[]>} skipPaths An object of keys and paths to skip serialization.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps(\n\tprops,\n\tblockType,\n\tattributes,\n\tskipPaths = skipSerializationPathsSave\n) {\n\tif ( ! hasStyleSupport( blockType ) ) {\n\t\treturn props;\n\t}\n\n\tlet { style } = attributes;\n\tObject.entries( skipPaths ).forEach( ( [ indicator, path ] ) => {\n\t\tconst skipSerialization = getBlockSupport( blockType, indicator );\n\n\t\tif ( skipSerialization === true ) {\n\t\t\tstyle = omitStyle( style, path );\n\t\t}\n\n\t\tif ( Array.isArray( skipSerialization ) ) {\n\t\t\tskipSerialization.forEach( ( featureName ) => {\n\t\t\t\tconst feature = renamedFeatures[ featureName ] || featureName;\n\t\t\t\tstyle = omitStyle( style, [ [ ...path, feature ] ] );\n\t\t\t} );\n\t\t}\n\t} );\n\n\tprops.style = {\n\t\t...getInlineStyles( style ),\n\t\t...props.style,\n\t};\n\n\treturn props;\n}\n\n/**\n * Filters registered block settings to extend the block edit wrapper\n * to apply the desired styles and classnames properly.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object}.Filtered block settings.\n */\nexport function addEditProps( settings ) {\n\tif ( ! hasStyleSupport( settings ) ) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\n\t\treturn addSaveProps(\n\t\t\tprops,\n\t\t\tsettings,\n\t\t\tattributes,\n\t\t\tskipSerializationPathsEdit\n\t\t);\n\t};\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include new inspector controls for\n * all the custom styles configs.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withBlockControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst shouldDisplayControls = useDisplayBlockControls();\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ shouldDisplayControls && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<ColorEdit { ...props } />\n\t\t\t\t\t\t<TypographyPanel { ...props } />\n\t\t\t\t\t\t<BorderPanel { ...props } />\n\t\t\t\t\t\t<DimensionsPanel { ...props } />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withToolbarControls'\n);\n\n/**\n * Override the default block element to include elements styles.\n *\n * @param {Function} BlockListBlock Original component\n * @return {Function} Wrapped component\n */\nconst withElementsStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst blockElementsContainerIdentifier = `wp-elements-${ useInstanceId(\n\t\t\tBlockListBlock\n\t\t) }`;\n\n\t\tconst skipLinkColorSerialization = shouldSkipSerialization(\n\t\t\tprops.name,\n\t\t\tCOLOR_SUPPORT_KEY,\n\t\t\t'link'\n\t\t);\n\n\t\tconst styles = useMemo( () => {\n\t\t\t// The .editor-styles-wrapper selector is required on elements styles. As it is\n\t\t\t// added to all other editor styles, not providing it causes reset and global\n\t\t\t// styles to override element styles because of higher specificity.\n\t\t\tconst elements = [\n\t\t\t\t{\n\t\t\t\t\tstyles: ! skipLinkColorSerialization\n\t\t\t\t\t\t? props.attributes.style?.elements?.link\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tselector: `.editor-styles-wrapper .${ blockElementsContainerIdentifier } ${ ELEMENTS.link }`,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tstyles: ! skipLinkColorSerialization\n\t\t\t\t\t\t? props.attributes.style?.elements?.link?.[ ':hover' ]\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tselector: `.editor-styles-wrapper .${ blockElementsContainerIdentifier } ${ ELEMENTS.link }:hover`,\n\t\t\t\t},\n\t\t\t];\n\t\t\tconst elementCssRules = [];\n\t\t\tfor ( const { styles: elementStyles, selector } of elements ) {\n\t\t\t\tif ( elementStyles ) {\n\t\t\t\t\tconst cssRule = compileCSS( elementStyles, {\n\t\t\t\t\t\tselector,\n\t\t\t\t\t} );\n\t\t\t\t\telementCssRules.push( cssRule );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn elementCssRules.length > 0\n\t\t\t\t? elementCssRules.join( '' )\n\t\t\t\t: undefined;\n\t\t}, [\n\t\t\tprops.attributes.style?.elements,\n\t\t\tblockElementsContainerIdentifier,\n\t\t\tskipLinkColorSerialization,\n\t\t] );\n\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ styles &&\n\t\t\t\t\telement &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<style\n\t\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t\t__html: styles,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>,\n\t\t\t\t\t\telement\n\t\t\t\t\t) }\n\n\t\t\t\t<BlockListBlock\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tclassName={\n\t\t\t\t\t\tprops.attributes.style?.elements\n\t\t\t\t\t\t\t? classnames(\n\t\t\t\t\t\t\t\t\tprops.className,\n\t\t\t\t\t\t\t\t\tblockElementsContainerIdentifier\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: props.className\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/style/addAttribute',\n\taddAttribute\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/style/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/style/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/style/with-block-controls',\n\twithBlockControls\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/with-elements-styles',\n\twithElementsStyles\n);\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/style.js"],"names":["styleSupportKeys","TYPOGRAPHY_SUPPORT_KEYS","BORDER_SUPPORT_KEY","COLOR_SUPPORT_KEY","DIMENSIONS_SUPPORT_KEY","SPACING_SUPPORT_KEY","hasStyleSupport","blockType","some","key","getInlineStyles","styles","output","forEach","rule","value","addAttribute","settings","attributes","style","Object","assign","type","skipSerializationPathsEdit","TYPOGRAPHY_SUPPORT_KEY","skipSerializationPathsSave","renamedFeatures","gradients","omitStyle","paths","preserveReference","newStyle","JSON","parse","stringify","Array","isArray","path","split","length","firstSubpath","restPath","addSaveProps","props","skipPaths","entries","indicator","skipSerialization","featureName","feature","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","withBlockControls","BlockEdit","shouldDisplayControls","withElementsStyles","BlockListBlock","blockElementsContainerIdentifier","skipLinkColorSerialization","name","elements","link","undefined","selector","ELEMENTS","elementCssRules","elementStyles","cssRule","push","join","element","BlockList","__unstableElementContext","__html","className"],"mappings":";;;;;;;;;;;;;AAQA;;;;AALA;;AAMA;;AACA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AAKA;;AACA;;AAnCA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;AAiBA,MAAMA,gBAAgB,GAAG,CACxB,GAAGC,mCADqB,EAExBC,0BAFwB,EAGxBC,wBAHwB,EAIxBC,kCAJwB,EAKxBC,+BALwB,CAAzB;;AAQA,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CAAnC;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMoB,0BAA0B,GAAG,EAClC,GAAGF,0BAD+B;AAElC,GAAG,GAAGlB,+BAAqB,EAA3B,GAAgC,CAAE,kBAAF;AAFE,CAAnC;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMqB,eAAe,GAAG;AAAEC,EAAAA,SAAS,EAAE;AAAb,CAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,SAAT,CAAoBT,KAApB,EAA2BU,KAA3B,EAA8D;AAAA,MAA5BC,iBAA4B,uEAAR,KAAQ;;AACpE,MAAK,CAAEX,KAAP,EAAe;AACd,WAAOA,KAAP;AACA;;AAED,MAAIY,QAAQ,GAAGZ,KAAf;;AACA,MAAK,CAAEW,iBAAP,EAA2B;AAC1BC,IAAAA,QAAQ,GAAGC,IAAI,CAACC,KAAL,CAAYD,IAAI,CAACE,SAAL,CAAgBf,KAAhB,CAAZ,CAAX;AACA;;AAED,MAAK,CAAEgB,KAAK,CAACC,OAAN,CAAeP,KAAf,CAAP,EAAgC;AAC/BA,IAAAA,KAAK,GAAG,CAAEA,KAAF,CAAR;AACA;;AAEDA,EAAAA,KAAK,CAAChB,OAAN,CAAiBwB,IAAF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,CAAC3B,MAAhB,GAAyB,CAAzB,GACJ2B,eAAe,CAACI,IAAhB,CAAsB,EAAtB,CADI,GAEJP,SAFH;AAGA,GA9Bc,EA8BZ,2BACFpB,KAAK,CAACzB,UAAN,CAAiBC,KADf,2DACF,uBAAwB0C,QADtB,EAEFH,gCAFE,EAGFC,0BAHE,CA9BY,CAAf;AAoCA,QAAMY,OAAO,GAAG,yBAAYC,mBAAUC,wBAAtB,CAAhB;AAEA,SACC,qDACG9D,MAAM,IACP4D,OADC,IAED,2BACC;AACC,IAAA,uBAAuB,EAAG;AACzBG,MAAAA,MAAM,EAAE/D;AADiB;AAD3B,IADD,EAMC4D,OAND,CAHF,EAYC,4BAAC,cAAD,6BACM5B,KADN;AAEC,IAAA,SAAS,EACR,0BAAAA,KAAK,CAACzB,UAAN,CAAiBC,KAAjB,0EAAwB0C,QAAxB,GACG,yBACAlB,KAAK,CAACgC,SADN,EAEAjB,gCAFA,CADH,GAKGf,KAAK,CAACgC;AARX,KAZD,CADD;AA0BA,CA5EyB,EA6E1B,oBA7E0B,CAA3B;AAgFA,sBACC,0BADD,EAEC,yBAFD,EAGC3D,YAHD;AAMA,sBACC,kCADD,EAEC,yBAFD,EAGC0B,YAHD;AAMA,sBACC,0BADD,EAEC,yBAFD,EAGCQ,YAHD;AAMA,sBACC,kBADD,EAEC,gCAFD,EAGCG,iBAHD;AAMA,sBACC,uBADD,EAEC,kCAFD,EAGCG,kBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useContext, useMemo, createPortal } from '@wordpress/element';\nimport { addFilter } from '@wordpress/hooks';\nimport {\n\tgetBlockSupport,\n\thasBlockSupport,\n\t__EXPERIMENTAL_ELEMENTS as ELEMENTS,\n} from '@wordpress/blocks';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { getCSSRules, compileCSS } from '@wordpress/style-engine';\n\n/**\n * Internal dependencies\n */\nimport BlockList from '../components/block-list';\nimport { BORDER_SUPPORT_KEY, BorderPanel } from './border';\nimport { COLOR_SUPPORT_KEY, ColorEdit } from './color';\nimport {\n\tTypographyPanel,\n\tTYPOGRAPHY_SUPPORT_KEY,\n\tTYPOGRAPHY_SUPPORT_KEYS,\n} from './typography';\nimport {\n\tDIMENSIONS_SUPPORT_KEY,\n\tSPACING_SUPPORT_KEY,\n\tDimensionsPanel,\n} from './dimensions';\nimport useDisplayBlockControls from '../components/use-display-block-controls';\nimport { shouldSkipSerialization } from './utils';\n\nconst styleSupportKeys = [\n\t...TYPOGRAPHY_SUPPORT_KEYS,\n\tBORDER_SUPPORT_KEY,\n\tCOLOR_SUPPORT_KEY,\n\tDIMENSIONS_SUPPORT_KEY,\n\tSPACING_SUPPORT_KEY,\n];\n\nconst hasStyleSupport = ( blockType ) =>\n\tstyleSupportKeys.some( ( key ) => hasBlockSupport( blockType, key ) );\n\n/**\n * Returns the inline styles to add depending on the style object\n *\n * @param {Object} styles Styles configuration.\n *\n * @return {Object} Flattened CSS variables declaration.\n */\nexport function getInlineStyles( styles = {} ) {\n\tconst output = {};\n\t// The goal is to move everything to server side generated engine styles\n\t// This is temporary as we absorb more and more styles into the engine.\n\tgetCSSRules( styles ).forEach( ( rule ) => {\n\t\toutput[ rule.key ] = rule.value;\n\t} );\n\n\treturn output;\n}\n\n/**\n * Filters registered block settings, extending attributes to include `style` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttribute( settings ) {\n\tif ( ! hasStyleSupport( settings ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * A dictionary of paths to flag skipping block support serialization as the key,\n * with values providing the style paths to be omitted from serialization.\n *\n * @constant\n * @type {Record<string, string[]>}\n */\nconst skipSerializationPathsEdit = {\n\t[ `${ BORDER_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [ 'border' ],\n\t[ `${ COLOR_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tCOLOR_SUPPORT_KEY,\n\t],\n\t[ `${ TYPOGRAPHY_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tTYPOGRAPHY_SUPPORT_KEY,\n\t],\n\t[ `${ DIMENSIONS_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tDIMENSIONS_SUPPORT_KEY,\n\t],\n\t[ `${ SPACING_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [\n\t\tSPACING_SUPPORT_KEY,\n\t],\n};\n\n/**\n * A dictionary of paths to flag skipping block support serialization as the key,\n * with values providing the style paths to be omitted from serialization.\n *\n * Extends the Edit skip paths to enable skipping additional paths in just\n * the Save component. This allows a block support to be serialized within the\n * editor, while using an alternate approach, such as server-side rendering, when\n * the support is saved.\n *\n * @constant\n * @type {Record<string, string[]>}\n */\nconst skipSerializationPathsSave = {\n\t...skipSerializationPathsEdit,\n\t[ `${ SPACING_SUPPORT_KEY }` ]: [ 'spacing.blockGap' ],\n};\n\n/**\n * A dictionary used to normalize feature names between support flags, style\n * object properties and __experimentSkipSerialization configuration arrays.\n *\n * This allows not having to provide a migration for a support flag and possible\n * backwards compatibility bridges, while still achieving consistency between\n * the support flag and the skip serialization array.\n *\n * @constant\n * @type {Record<string, string>}\n */\nconst renamedFeatures = { gradients: 'gradient' };\n\n/**\n * A utility function used to remove one or more paths from a style object.\n * Works in a way similar to Lodash's `omit()`. See unit tests and examples below.\n *\n * It supports a single string path:\n *\n * ```\n * omitStyle( { color: 'red' }, 'color' ); // {}\n * ```\n *\n * or an array of paths:\n *\n * ```\n * omitStyle( { color: 'red', background: '#fff' }, [ 'color', 'background' ] ); // {}\n * ```\n *\n * It also allows you to specify paths at multiple levels in a string.\n *\n * ```\n * omitStyle( { typography: { textDecoration: 'underline' } }, 'typography.textDecoration' ); // {}\n * ```\n *\n * You can remove multiple paths at the same time:\n *\n * ```\n * omitStyle(\n * \t\t{\n * \t\t\ttypography: {\n * \t\t\t\ttextDecoration: 'underline',\n * \t\t\t\ttextTransform: 'uppercase',\n * \t\t\t}\n *\t\t},\n *\t\t[\n * \t\t\t'typography.textDecoration',\n * \t\t\t'typography.textTransform',\n *\t\t]\n * );\n * // {}\n * ```\n *\n * You can also specify nested paths as arrays:\n *\n * ```\n * omitStyle(\n * \t\t{\n * \t\t\ttypography: {\n * \t\t\t\ttextDecoration: 'underline',\n * \t\t\t\ttextTransform: 'uppercase',\n * \t\t\t}\n *\t\t},\n *\t\t[\n * \t\t\t[ 'typography', 'textDecoration' ],\n * \t\t\t[ 'typography', 'textTransform' ],\n *\t\t]\n * );\n * // {}\n * ```\n *\n * With regards to nesting of styles, infinite depth is supported:\n *\n * ```\n * omitStyle(\n * \t\t{\n * \t\t\tborder: {\n * \t\t\t\tradius: {\n * \t\t\t\t\ttopLeft: '10px',\n * \t\t\t\t\ttopRight: '0.5rem',\n * \t\t\t\t}\n * \t\t\t}\n *\t\t},\n *\t\t[\n * \t\t\t[ 'border', 'radius', 'topRight' ],\n *\t\t]\n * );\n * // { border: { radius: { topLeft: '10px' } } }\n * ```\n *\n * The third argument, `preserveReference`, defines how to treat the input style object.\n * It is mostly necessary to properly handle mutation when recursively handling the style object.\n * Defaulting to `false`, this will always create a new object, avoiding to mutate `style`.\n * However, when recursing, we change that value to `true` in order to work with a single copy\n * of the original style object.\n *\n * @see https://lodash.com/docs/4.17.15#omit\n *\n * @param {Object} style Styles object.\n * @param {Array|string} paths Paths to remove.\n * @param {boolean} preserveReference True to mutate the `style` object, false otherwise.\n * @return {Object} Styles object with the specified paths removed.\n */\nexport function omitStyle( style, paths, preserveReference = false ) {\n\tif ( ! style ) {\n\t\treturn style;\n\t}\n\n\tlet newStyle = style;\n\tif ( ! preserveReference ) {\n\t\tnewStyle = JSON.parse( JSON.stringify( style ) );\n\t}\n\n\tif ( ! Array.isArray( paths ) ) {\n\t\tpaths = [ paths ];\n\t}\n\n\tpaths.forEach( ( path ) => {\n\t\tif ( ! Array.isArray( path ) ) {\n\t\t\tpath = path.split( '.' );\n\t\t}\n\n\t\tif ( path.length > 1 ) {\n\t\t\tconst [ firstSubpath, ...restPath ] = path;\n\t\t\tomitStyle( newStyle[ firstSubpath ], [ restPath ], true );\n\t\t} else if ( path.length === 1 ) {\n\t\t\tdelete newStyle[ path[ 0 ] ];\n\t\t}\n\t} );\n\n\treturn newStyle;\n}\n\n/**\n * Override props assigned to save component to inject the CSS variables definition.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n * @param {?Record<string, string[]>} skipPaths An object of keys and paths to skip serialization.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps(\n\tprops,\n\tblockType,\n\tattributes,\n\tskipPaths = skipSerializationPathsSave\n) {\n\tif ( ! hasStyleSupport( blockType ) ) {\n\t\treturn props;\n\t}\n\n\tlet { style } = attributes;\n\tObject.entries( skipPaths ).forEach( ( [ indicator, path ] ) => {\n\t\tconst skipSerialization = getBlockSupport( blockType, indicator );\n\n\t\tif ( skipSerialization === true ) {\n\t\t\tstyle = omitStyle( style, path );\n\t\t}\n\n\t\tif ( Array.isArray( skipSerialization ) ) {\n\t\t\tskipSerialization.forEach( ( featureName ) => {\n\t\t\t\tconst feature = renamedFeatures[ featureName ] || featureName;\n\t\t\t\tstyle = omitStyle( style, [ [ ...path, feature ] ] );\n\t\t\t} );\n\t\t}\n\t} );\n\n\tprops.style = {\n\t\t...getInlineStyles( style ),\n\t\t...props.style,\n\t};\n\n\treturn props;\n}\n\n/**\n * Filters registered block settings to extend the block edit wrapper\n * to apply the desired styles and classnames properly.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object}.Filtered block settings.\n */\nexport function addEditProps( settings ) {\n\tif ( ! hasStyleSupport( settings ) ) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\n\t\treturn addSaveProps(\n\t\t\tprops,\n\t\t\tsettings,\n\t\t\tattributes,\n\t\t\tskipSerializationPathsEdit\n\t\t);\n\t};\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include new inspector controls for\n * all the custom styles configs.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withBlockControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst shouldDisplayControls = useDisplayBlockControls();\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ shouldDisplayControls && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<ColorEdit { ...props } />\n\t\t\t\t\t\t<TypographyPanel { ...props } />\n\t\t\t\t\t\t<BorderPanel { ...props } />\n\t\t\t\t\t\t<DimensionsPanel { ...props } />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withToolbarControls'\n);\n\n/**\n * Override the default block element to include elements styles.\n *\n * @param {Function} BlockListBlock Original component\n * @return {Function} Wrapped component\n */\nconst withElementsStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst blockElementsContainerIdentifier = `wp-elements-${ useInstanceId(\n\t\t\tBlockListBlock\n\t\t) }`;\n\n\t\tconst skipLinkColorSerialization = shouldSkipSerialization(\n\t\t\tprops.name,\n\t\t\tCOLOR_SUPPORT_KEY,\n\t\t\t'link'\n\t\t);\n\n\t\tconst styles = useMemo( () => {\n\t\t\t// The .editor-styles-wrapper selector is required on elements styles. As it is\n\t\t\t// added to all other editor styles, not providing it causes reset and global\n\t\t\t// styles to override element styles because of higher specificity.\n\t\t\tconst elements = [\n\t\t\t\t{\n\t\t\t\t\tstyles: ! skipLinkColorSerialization\n\t\t\t\t\t\t? props.attributes.style?.elements?.link\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tselector: `.editor-styles-wrapper .${ blockElementsContainerIdentifier } ${ ELEMENTS.link }`,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tstyles: ! skipLinkColorSerialization\n\t\t\t\t\t\t? props.attributes.style?.elements?.link?.[ ':hover' ]\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tselector: `.editor-styles-wrapper .${ blockElementsContainerIdentifier } ${ ELEMENTS.link }:hover`,\n\t\t\t\t},\n\t\t\t];\n\t\t\tconst elementCssRules = [];\n\t\t\tfor ( const { styles: elementStyles, selector } of elements ) {\n\t\t\t\tif ( elementStyles ) {\n\t\t\t\t\tconst cssRule = compileCSS( elementStyles, {\n\t\t\t\t\t\tselector,\n\t\t\t\t\t} );\n\t\t\t\t\telementCssRules.push( cssRule );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn elementCssRules.length > 0\n\t\t\t\t? elementCssRules.join( '' )\n\t\t\t\t: undefined;\n\t\t}, [\n\t\t\tprops.attributes.style?.elements,\n\t\t\tblockElementsContainerIdentifier,\n\t\t\tskipLinkColorSerialization,\n\t\t] );\n\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ styles &&\n\t\t\t\t\telement &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<style\n\t\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t\t__html: styles,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>,\n\t\t\t\t\t\telement\n\t\t\t\t\t) }\n\n\t\t\t\t<BlockListBlock\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tclassName={\n\t\t\t\t\t\tprops.attributes.style?.elements\n\t\t\t\t\t\t\t? classnames(\n\t\t\t\t\t\t\t\t\tprops.className,\n\t\t\t\t\t\t\t\t\tblockElementsContainerIdentifier\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: props.className\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n\t'withElementsStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/style/addAttribute',\n\taddAttribute\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/style/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/style/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/style/with-block-controls',\n\twithBlockControls\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/with-elements-styles',\n\twithElementsStyles\n);\n"]}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useEditorWrapperStyles = useEditorWrapperStyles;
|
|
9
|
+
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
|
|
12
|
+
var _element = require("@wordpress/element");
|
|
13
|
+
|
|
14
|
+
var _components = require("@wordpress/components");
|
|
15
|
+
|
|
16
|
+
var _useEditorWrapperStyles = _interopRequireDefault(require("./use-editor-wrapper-styles.scss"));
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* External dependencies
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* WordPress dependencies
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Internal dependencies
|
|
28
|
+
*/
|
|
29
|
+
const ALIGNMENT_MAX_WIDTH = {
|
|
30
|
+
full: '100%',
|
|
31
|
+
wide: 1054,
|
|
32
|
+
wideMedium: 770,
|
|
33
|
+
wideLandscape: 662
|
|
34
|
+
};
|
|
35
|
+
const BLOCK_DEFAULT_MARGIN = 16;
|
|
36
|
+
/**
|
|
37
|
+
* Get the styles for the wide width alignment.
|
|
38
|
+
*
|
|
39
|
+
* @param {Object} [options] The options for the helper.
|
|
40
|
+
* @param {string} options.align The alignment value.
|
|
41
|
+
* @param {boolean} options.isLandscape Whether the screen is in landscape mode.
|
|
42
|
+
* @param {number} options.width The width of the screen.
|
|
43
|
+
* @return {Object} An object containing the styles for the wide width alignment.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
function getWideWidthStyles() {
|
|
47
|
+
let {
|
|
48
|
+
align,
|
|
49
|
+
isLandscape,
|
|
50
|
+
width
|
|
51
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
52
|
+
|
|
53
|
+
if (align !== _components.WIDE_ALIGNMENTS.alignments.wide) {
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (isLandscape && width < _components.ALIGNMENT_BREAKPOINTS.large) {
|
|
58
|
+
return {
|
|
59
|
+
maxWidth: ALIGNMENT_MAX_WIDTH.wideLandscape
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (width <= _components.ALIGNMENT_BREAKPOINTS.small) {
|
|
64
|
+
return {
|
|
65
|
+
maxWidth: width
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (width >= _components.ALIGNMENT_BREAKPOINTS.medium && width < _components.ALIGNMENT_BREAKPOINTS.wide) {
|
|
70
|
+
return {
|
|
71
|
+
maxWidth: ALIGNMENT_MAX_WIDTH.wideMedium
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
maxWidth: ALIGNMENT_MAX_WIDTH.wide
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get the styles for the full width alignment.
|
|
81
|
+
*
|
|
82
|
+
* @param {Object} [options] The options for the helper.
|
|
83
|
+
* @param {string} options.align The alignment value.
|
|
84
|
+
* @param {string} options.blockName The name of the block.
|
|
85
|
+
* @param {boolean} options.hasParents Whether the block has parents.
|
|
86
|
+
* @param {string} options.parentBlockName The name of the parent block.
|
|
87
|
+
* @return {Object} An object containing the styles for the full width alignment.
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
function getFullWidthStyles() {
|
|
92
|
+
let {
|
|
93
|
+
align,
|
|
94
|
+
blockName,
|
|
95
|
+
hasParents,
|
|
96
|
+
parentBlockName
|
|
97
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
98
|
+
const {
|
|
99
|
+
isContainerRelated,
|
|
100
|
+
isFullWidth
|
|
101
|
+
} = _components.alignmentHelpers;
|
|
102
|
+
const fullWidthStyles = isFullWidth(align) ? {
|
|
103
|
+
maxWidth: ALIGNMENT_MAX_WIDTH.full
|
|
104
|
+
} : {};
|
|
105
|
+
|
|
106
|
+
if (!align && hasParents && !isContainerRelated(parentBlockName) && isContainerRelated(blockName)) {
|
|
107
|
+
fullWidthStyles.paddingHorizontal = BLOCK_DEFAULT_MARGIN;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return fullWidthStyles;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get the block margin based on various conditions.
|
|
114
|
+
*
|
|
115
|
+
* @param {Object} [options] The options for the helper.
|
|
116
|
+
* @param {string} options.align The alignment value.
|
|
117
|
+
* @param {string} options.blockName The name of the block.
|
|
118
|
+
* @param {number} options.blockWidth The width of the block.
|
|
119
|
+
* @param {boolean} options.hasParents Whether the block has parents.
|
|
120
|
+
* @param {number} options.marginHorizontal Default horizontal margin.
|
|
121
|
+
* @param {string} options.parentBlockAlignment The alignment of the parent block.
|
|
122
|
+
* @param {string} options.parentBlockName The name of the parent block.
|
|
123
|
+
* @param {number} options.parentWidth The width of the parent block.
|
|
124
|
+
* @param {number} options.width The width of the screen.
|
|
125
|
+
* @return {number} The calculated block margin.
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
function getBlockMargin() {
|
|
130
|
+
let {
|
|
131
|
+
align,
|
|
132
|
+
blockName,
|
|
133
|
+
blockWidth,
|
|
134
|
+
hasParents,
|
|
135
|
+
marginHorizontal,
|
|
136
|
+
parentBlockAlignment,
|
|
137
|
+
parentBlockName,
|
|
138
|
+
parentWidth,
|
|
139
|
+
width
|
|
140
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
141
|
+
const {
|
|
142
|
+
isContainerRelated,
|
|
143
|
+
isWider,
|
|
144
|
+
isWideWidth,
|
|
145
|
+
isFullWidth
|
|
146
|
+
} = _components.alignmentHelpers;
|
|
147
|
+
|
|
148
|
+
if (isFullWidth(align)) {
|
|
149
|
+
if (!hasParents) {
|
|
150
|
+
return 0;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return marginHorizontal;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (isWideWidth(align)) {
|
|
157
|
+
return marginHorizontal;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (isFullWidth(parentBlockAlignment) && !isWider(blockWidth, 'medium')) {
|
|
161
|
+
if (isContainerRelated(blockName) || isWider(width, 'mobile')) {
|
|
162
|
+
return marginHorizontal;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return marginHorizontal * 2;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (isContainerRelated(parentBlockName) && !isContainerRelated(blockName)) {
|
|
169
|
+
const isScreenWidthEqual = parentWidth === width;
|
|
170
|
+
|
|
171
|
+
if (isScreenWidthEqual || isWider(width, 'mobile')) {
|
|
172
|
+
return marginHorizontal;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return marginHorizontal;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Custom hook to get the styles and margin for the editor wrapper.
|
|
180
|
+
*
|
|
181
|
+
* @param {Object} [props] The props for the hook.
|
|
182
|
+
* @param {string} props.align The alignment value.
|
|
183
|
+
* @param {string} props.blockName The name of the block.
|
|
184
|
+
* @param {number} props.blockWidth The width of the block.
|
|
185
|
+
* @param {string} props.contentResizeMode The content resize mode.
|
|
186
|
+
* @param {boolean} props.hasParents Whether the block has parents.
|
|
187
|
+
* @param {number} props.marginHorizontal Default horizontal margin.
|
|
188
|
+
* @param {string} props.parentBlockAlignment The alignment of the parent block.
|
|
189
|
+
* @param {string} props.parentBlockName The name of the parent block.
|
|
190
|
+
* @param {number} props.parentWidth The width of the parent block.
|
|
191
|
+
* @param {boolean} [props.reversed=false] Whether the flex direction should be reversed.
|
|
192
|
+
* @return {[Array, number]} An array containing the wrapper styles and block margin.
|
|
193
|
+
*/
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
function useEditorWrapperStyles() {
|
|
197
|
+
let {
|
|
198
|
+
align,
|
|
199
|
+
blockName,
|
|
200
|
+
blockWidth,
|
|
201
|
+
contentResizeMode,
|
|
202
|
+
hasParents,
|
|
203
|
+
marginHorizontal,
|
|
204
|
+
parentBlockAlignment,
|
|
205
|
+
parentBlockName,
|
|
206
|
+
parentWidth,
|
|
207
|
+
reversed = false
|
|
208
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
209
|
+
const {
|
|
210
|
+
width,
|
|
211
|
+
height
|
|
212
|
+
} = (0, _reactNative.useWindowDimensions)();
|
|
213
|
+
const isLandscape = width >= height;
|
|
214
|
+
const blockMargin = (0, _element.useMemo)(() => getBlockMargin({
|
|
215
|
+
align,
|
|
216
|
+
blockName,
|
|
217
|
+
blockWidth,
|
|
218
|
+
hasParents,
|
|
219
|
+
marginHorizontal,
|
|
220
|
+
parentBlockAlignment,
|
|
221
|
+
parentBlockName,
|
|
222
|
+
parentWidth,
|
|
223
|
+
width
|
|
224
|
+
}), [align, blockName, blockWidth, hasParents, marginHorizontal, parentBlockAlignment, parentBlockName, parentWidth, width]);
|
|
225
|
+
const wrapperStyles = (0, _element.useMemo)(() => {
|
|
226
|
+
let canvasStyles;
|
|
227
|
+
|
|
228
|
+
if (contentResizeMode === 'stretch') {
|
|
229
|
+
// For these cases, no width constraints should be added.
|
|
230
|
+
canvasStyles = {
|
|
231
|
+
flex: 1
|
|
232
|
+
};
|
|
233
|
+
} else if (reversed) {
|
|
234
|
+
canvasStyles = _useEditorWrapperStyles.default['use-editor-wrapper-styles--reversed'];
|
|
235
|
+
} else {
|
|
236
|
+
canvasStyles = _useEditorWrapperStyles.default['use-editor-wrapper-styles'];
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const alignmentStyles = { ...getWideWidthStyles({
|
|
240
|
+
align,
|
|
241
|
+
isLandscape,
|
|
242
|
+
width
|
|
243
|
+
}),
|
|
244
|
+
...getFullWidthStyles({
|
|
245
|
+
align,
|
|
246
|
+
blockName,
|
|
247
|
+
hasParents,
|
|
248
|
+
parentBlockName
|
|
249
|
+
})
|
|
250
|
+
};
|
|
251
|
+
return [canvasStyles, alignmentStyles];
|
|
252
|
+
}, [align, blockName, hasParents, parentBlockName, isLandscape, width, contentResizeMode, reversed]);
|
|
253
|
+
return [wrapperStyles, blockMargin];
|
|
254
|
+
}
|
|
255
|
+
//# sourceMappingURL=use-editor-wrapper-styles.native.js.map
|