@wordpress/block-editor 11.4.0 → 11.6.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 +8 -0
- package/build/components/block-inspector/index.js +11 -10
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-inspector/useBlockInspectorAnimationSettings.js +46 -0
- package/build/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
- package/build/components/block-list/block-invalid-warning.js +63 -80
- package/build/components/block-list/block-invalid-warning.js.map +1 -1
- package/build/components/block-lock/modal.js +1 -0
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +1 -1
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-styles/index.js +2 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/build/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build/components/child-layout-control/index.js +107 -0
- package/build/components/child-layout-control/index.js.map +1 -0
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
- package/build/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build/components/date-format-picker/index.js +3 -3
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +306 -0
- package/build/components/global-styles/border-panel.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +594 -0
- package/build/components/global-styles/dimensions-panel.js.map +1 -0
- package/build/components/global-styles/hooks.js +127 -37
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +36 -2
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +87 -27
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +21 -14
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -0
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/index.native.js +23 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/index.js +29 -17
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +10 -11
- package/build/components/inserter/media-tab/hooks.js.map +1 -1
- package/build/components/inserter/media-tab/media-list.js +5 -108
- package/build/components/inserter/media-tab/media-list.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +242 -0
- package/build/components/inserter/media-tab/media-preview.js.map +1 -0
- package/build/components/inserter/menu.js +1 -1
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +4 -2
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-results.js +10 -3
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +1 -1
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls/fill.js +38 -9
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/link-control/index.js +1 -1
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-item.js +5 -2
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/link-control/settings-drawer.js +1 -1
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/link-control/settings.js +1 -0
- package/build/components/link-control/settings.js.map +1 -1
- package/build/components/list-view/block.js +17 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +2 -2
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/expander.js +2 -1
- package/build/components/list-view/expander.js.map +1 -1
- package/build/components/list-view/leaf.js +10 -6
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +1 -2
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/list-view/use-list-view-scroll-into-view.js +51 -0
- package/build/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
- package/build/components/off-canvas-editor/appender.js +33 -13
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +6 -3
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +8 -2
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/leaf-more-menu.js +34 -4
- package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build/components/provider/use-block-sync.js +17 -3
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/responsive-block-control/index.js +1 -0
- package/build/components/responsive-block-control/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +0 -3
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/index.js +9 -43
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-delete.js +73 -0
- package/build/components/rich-text/use-delete.js.map +1 -0
- package/build/components/rich-text/use-input-rules.js +14 -6
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +4 -1
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/hooks/align.js +3 -1
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/border.js +91 -240
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/custom-class-name.js +4 -4
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/custom-class-name.native.js +3 -4
- package/build/hooks/custom-class-name.native.js.map +1 -1
- package/build/hooks/dimensions.js +72 -190
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +94 -25
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/gap.js +0 -202
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/layout.js +33 -27
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +7 -163
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +7 -163
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/supports.js +7 -1
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.js +52 -66
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +101 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +6 -2
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/flex.js +1 -0
- package/build/layouts/flex.js.map +1 -1
- package/build/private-apis.js +4 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +28 -14
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +28 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +53 -47
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +24 -4
- package/build/store/selectors.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +49 -10
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/components/block-inspector/index.js +9 -9
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js +37 -0
- package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
- package/build-module/components/block-list/block-invalid-warning.js +66 -78
- package/build-module/components/block-list/block-invalid-warning.js.map +1 -1
- package/build-module/components/block-lock/modal.js +1 -0
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +1 -1
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +2 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/build-module/components/block-switcher/block-transformations-menu.native.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +98 -0
- package/build-module/components/child-layout-control/index.js.map +1 -0
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js +6 -3
- package/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +4 -4
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +291 -0
- package/build-module/components/global-styles/border-panel.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +574 -0
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +123 -34
- 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 +88 -27
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +21 -14
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/index.native.js +2 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/index.js +28 -16
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +10 -11
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-list.js +6 -105
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +222 -0
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -0
- package/build-module/components/inserter/menu.js +1 -1
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +4 -2
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-results.js +10 -3
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +1 -1
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +39 -9
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/link-control/index.js +1 -1
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-item.js +4 -2
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +1 -1
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/link-control/settings.js +1 -0
- package/build-module/components/link-control/settings.js.map +1 -1
- package/build-module/components/list-view/block.js +16 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +2 -2
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/expander.js +2 -1
- package/build-module/components/list-view/expander.js.map +1 -1
- package/build-module/components/list-view/leaf.js +8 -4
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +1 -2
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/list-view/use-list-view-scroll-into-view.js +42 -0
- package/build-module/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
- package/build-module/components/off-canvas-editor/appender.js +33 -14
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +6 -3
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +8 -2
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/leaf-more-menu.js +36 -7
- package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +17 -3
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/responsive-block-control/index.js +1 -0
- package/build-module/components/responsive-block-control/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +0 -3
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/index.js +9 -43
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-delete.js +62 -0
- package/build-module/components/rich-text/use-delete.js.map +1 -0
- package/build-module/components/rich-text/use-input-rules.js +14 -6
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +4 -1
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/hooks/align.js +3 -1
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/border.js +93 -240
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +4 -4
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/custom-class-name.native.js +3 -4
- package/build-module/hooks/custom-class-name.native.js.map +1 -1
- package/build-module/hooks/dimensions.js +75 -187
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +86 -24
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/gap.js +0 -183
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/layout.js +33 -27
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +4 -143
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +4 -143
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/supports.js +7 -1
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.js +54 -66
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +96 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +6 -2
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/flex.js +1 -0
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +28 -14
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +28 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +53 -45
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +22 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +49 -10
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-style/style-rtl.css +39 -27
- package/build-style/style.css +39 -27
- package/package.json +31 -31
- package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +24 -24
- package/src/components/block-inspector/index.js +11 -14
- package/src/components/block-inspector/style.scss +3 -0
- package/src/components/block-inspector/useBlockInspectorAnimationSettings.js +53 -0
- package/src/components/block-list/block-invalid-warning.js +72 -64
- package/src/components/block-lock/modal.js +1 -0
- package/src/components/block-lock/style.scss +0 -9
- package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +20 -20
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +35 -17
- package/src/components/block-preview/test/index.js +0 -2
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/src/components/block-settings-menu-controls/index.js +2 -1
- package/src/components/block-styles/index.js +5 -1
- package/src/components/block-styles/style.scss +2 -2
- package/src/components/block-switcher/block-transformations-menu.native.js +1 -0
- package/src/components/child-layout-control/index.js +106 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +17 -15
- package/src/components/convert-to-group-buttons/use-convert-to-group-button-props.js +48 -38
- package/src/components/date-format-picker/index.js +6 -8
- package/src/components/date-format-picker/style.scss +0 -5
- package/src/components/global-styles/border-panel.js +285 -0
- package/src/components/global-styles/dimensions-panel.js +627 -0
- package/src/components/global-styles/hooks.js +160 -44
- package/src/components/global-styles/index.js +7 -1
- package/src/components/global-styles/test/use-global-styles-output.js +1 -1
- package/src/components/global-styles/typography-panel.js +81 -9
- package/src/components/global-styles/use-global-styles-output.js +17 -16
- package/src/components/global-styles/utils.js +2 -0
- package/src/components/index.native.js +5 -0
- package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
- package/src/components/inserter/index.js +30 -11
- package/src/components/inserter/media-tab/hooks.js +9 -8
- package/src/components/inserter/media-tab/media-list.js +3 -122
- package/src/components/inserter/media-tab/media-preview.js +268 -0
- package/src/components/inserter/menu.js +0 -1
- package/src/components/inserter/quick-inserter.js +2 -0
- package/src/components/inserter/search-results.js +7 -1
- package/src/components/inserter/style.scss +25 -0
- package/src/components/inserter/tabs.js +1 -9
- package/src/components/inserter/test/__snapshots__/index.native.js.snap +15 -15
- package/src/components/inspector-controls/block-support-tools-panel.js +0 -1
- package/src/components/inspector-controls/fill.js +32 -8
- package/src/components/link-control/index.js +1 -1
- package/src/components/link-control/search-item.js +3 -1
- package/src/components/link-control/settings-drawer.js +2 -1
- package/src/components/link-control/settings.js +1 -0
- package/src/components/link-control/style.scss +18 -12
- package/src/components/link-control/test/index.js +3 -5
- package/src/components/list-view/block.js +19 -1
- package/src/components/list-view/branch.js +1 -2
- package/src/components/list-view/expander.js +1 -0
- package/src/components/list-view/leaf.js +43 -29
- package/src/components/list-view/use-block-selection.js +0 -2
- package/src/components/list-view/use-list-view-scroll-into-view.js +48 -0
- package/src/components/media-replace-flow/style.scss +7 -9
- package/src/components/off-canvas-editor/appender.js +44 -21
- package/src/components/off-canvas-editor/branch.js +4 -1
- package/src/components/off-canvas-editor/index.js +7 -1
- package/src/components/off-canvas-editor/leaf-more-menu.js +57 -15
- package/src/components/provider/use-block-sync.js +21 -4
- package/src/components/responsive-block-control/index.js +1 -0
- package/src/components/rich-text/format-toolbar-container.js +1 -7
- package/src/components/rich-text/index.js +8 -44
- package/src/components/rich-text/use-delete.js +59 -0
- package/src/components/rich-text/use-input-rules.js +13 -5
- package/src/components/spacing-sizes-control/style.scss +1 -1
- package/src/components/url-popover/stories/index.js +1 -0
- package/src/components/url-popover/test/index.js +0 -2
- package/src/components/writing-flow/use-selection-observer.js +5 -1
- package/src/hooks/align.js +1 -1
- package/src/hooks/border.js +94 -225
- package/src/hooks/custom-class-name.js +4 -4
- package/src/hooks/custom-class-name.native.js +3 -4
- package/src/hooks/dimensions.js +85 -269
- package/src/hooks/duotone.js +100 -30
- package/src/hooks/gap.js +0 -208
- package/src/hooks/layout.js +38 -22
- package/src/hooks/margin.js +1 -164
- package/src/hooks/padding.js +1 -163
- package/src/hooks/supports.js +6 -0
- package/src/hooks/test/__snapshots__/align.native.js.snap +24 -24
- package/src/hooks/test/duotone.js +102 -0
- package/src/hooks/test/style.js +2 -1
- package/src/hooks/test/use-typography-props.js +2 -0
- package/src/hooks/typography.js +68 -88
- package/src/hooks/utils.js +126 -0
- package/src/layouts/constrained.js +23 -17
- package/src/layouts/flex.js +1 -0
- package/src/private-apis.js +2 -0
- package/src/store/actions.js +16 -6
- package/src/store/defaults.js +14 -1
- package/src/store/reducer.js +68 -43
- package/src/store/selectors.js +28 -4
- package/src/store/test/actions.js +4 -2
- package/src/utils/parse-css-unit-to-px.js +48 -13
- package/src/utils/test/parse-css-unit-to-px.js +13 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/hooks/border-radius.js +0 -100
- package/build/hooks/border-radius.js.map +0 -1
- package/build/hooks/child-layout.js +0 -213
- package/build/hooks/child-layout.js.map +0 -1
- package/build/hooks/min-height.js +0 -139
- package/build/hooks/min-height.js.map +0 -1
- package/build-module/hooks/border-radius.js +0 -84
- package/build-module/hooks/border-radius.js.map +0 -1
- package/build-module/hooks/child-layout.js +0 -193
- package/build-module/hooks/child-layout.js.map +0 -1
- package/build-module/hooks/min-height.js +0 -116
- package/build-module/hooks/min-height.js.map +0 -1
- package/src/hooks/border-radius.js +0 -70
- package/src/hooks/child-layout.js +0 -195
- package/src/hooks/min-height.js +0 -104
|
@@ -9,8 +9,7 @@ import classnames from 'classnames';
|
|
|
9
9
|
import { addFilter } from '@wordpress/hooks';
|
|
10
10
|
import { hasBlockSupport } from '@wordpress/blocks';
|
|
11
11
|
/**
|
|
12
|
-
* Filters registered block settings, extending attributes
|
|
13
|
-
* of the first node.
|
|
12
|
+
* Filters registered block settings, extending attributes to include `className`.
|
|
14
13
|
*
|
|
15
14
|
* @param {Object} settings Original block settings.
|
|
16
15
|
*
|
|
@@ -30,8 +29,8 @@ export function addAttribute(settings) {
|
|
|
30
29
|
return settings;
|
|
31
30
|
}
|
|
32
31
|
/**
|
|
33
|
-
* Override props assigned to save component to inject
|
|
34
|
-
* supports
|
|
32
|
+
* Override props assigned to save component to inject the className, if block
|
|
33
|
+
* supports customClassName. This is only applied if the block's save result is an
|
|
35
34
|
* element and not a markup string.
|
|
36
35
|
*
|
|
37
36
|
* @param {Object} extraProps Additional props applied to save element.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/custom-class-name.native.js"],"names":["classnames","addFilter","hasBlockSupport","addAttribute","settings","attributes","className","type","addSaveProps","extraProps","blockType"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/custom-class-name.native.js"],"names":["classnames","addFilter","hasBlockSupport","addAttribute","settings","attributes","className","type","addSaveProps","extraProps","blockType"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,YAAT,CAAuBC,QAAvB,EAAkC;AACxC,MAAKF,eAAe,CAAEE,QAAF,EAAY,iBAAZ,EAA+B,IAA/B,CAApB,EAA4D;AAC3D;AACAA,IAAAA,QAAQ,CAACC,UAAT,GAAsB,EACrB,GAAGD,QAAQ,CAACC,UADS;AAErBC,MAAAA,SAAS,EAAE;AACVC,QAAAA,IAAI,EAAE;AADI;AAFU,KAAtB;AAMA;;AAED,SAAOH,QAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,YAAT,CAAuBC,UAAvB,EAAmCC,SAAnC,EAA8CL,UAA9C,EAA2D;AACjE,MACCH,eAAe,CAAEQ,SAAF,EAAa,iBAAb,EAAgC,IAAhC,CAAf,IACAL,UAAU,CAACC,SAFZ,EAGE;AACDG,IAAAA,UAAU,CAACH,SAAX,GAAuBN,UAAU,CAChCS,UAAU,CAACH,SADqB,EAEhCD,UAAU,CAACC,SAFqB,CAAjC;AAIA;;AAED,SAAOG,UAAP;AACA;AAEDR,SAAS,CACR,0BADQ,EAER,kCAFQ,EAGRE,YAHQ,CAAT;AAKAF,SAAS,CACR,kCADQ,EAER,mCAFQ,EAGRO,YAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Filters registered block settings, extending attributes to include `className`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( hasBlockSupport( settings, 'customClassName', true ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tclassName: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override props assigned to save component to inject the className, if block\n * supports customClassName. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif (\n\t\thasBlockSupport( blockType, 'customClassName', true ) &&\n\t\tattributes.className\n\t) {\n\t\textraProps.className = classnames(\n\t\t\textraProps.className,\n\t\t\tattributes.className\n\t\t);\n\t}\n\n\treturn extraProps;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/custom-class-name/attribute',\n\taddAttribute\n);\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/custom-class-name/save-props',\n\taddSaveProps\n);\n"]}
|
|
@@ -1,229 +1,117 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { createElement, Fragment } from "@wordpress/element";
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* External dependencies
|
|
6
|
-
*/
|
|
7
|
-
import classnames from 'classnames';
|
|
8
4
|
/**
|
|
9
5
|
* WordPress dependencies
|
|
10
6
|
*/
|
|
11
|
-
|
|
12
|
-
import { __experimentalToolsPanelItem as ToolsPanelItem, __experimentalVStack as VStack } from '@wordpress/components';
|
|
13
|
-
import { Platform, useState } from '@wordpress/element';
|
|
14
|
-
import { __ } from '@wordpress/i18n';
|
|
15
|
-
import { getBlockSupport } from '@wordpress/blocks';
|
|
7
|
+
import { useState, useEffect, useCallback } from '@wordpress/element';
|
|
16
8
|
import { useDispatch } from '@wordpress/data';
|
|
9
|
+
import { getBlockSupport } from '@wordpress/blocks';
|
|
10
|
+
import deprecated from '@wordpress/deprecated';
|
|
17
11
|
/**
|
|
18
12
|
* Internal dependencies
|
|
19
13
|
*/
|
|
20
14
|
|
|
21
15
|
import InspectorControls from '../components/inspector-controls';
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import { PaddingEdit, PaddingVisualizer, hasPaddingSupport, hasPaddingValue, resetPadding, useIsPaddingDisabled } from './padding';
|
|
26
|
-
import { ChildLayoutEdit, hasChildLayoutSupport, hasChildLayoutValue, resetChildLayout, useIsChildLayoutDisabled, childLayoutOrientation } from './child-layout';
|
|
27
|
-
import useSetting from '../components/use-setting';
|
|
16
|
+
import { DimensionsPanel as StylesDimensionsPanel, useHasDimensionsPanel } from '../components/global-styles';
|
|
17
|
+
import { MarginVisualizer } from './margin';
|
|
18
|
+
import { PaddingVisualizer } from './padding';
|
|
28
19
|
import { store as blockEditorStore } from '../store';
|
|
29
20
|
import { unlock } from '../lock-unlock';
|
|
21
|
+
import { cleanEmptyObject, useBlockSettings } from './utils';
|
|
30
22
|
export const DIMENSIONS_SUPPORT_KEY = 'dimensions';
|
|
31
23
|
export const SPACING_SUPPORT_KEY = 'spacing';
|
|
32
24
|
export const ALL_SIDES = ['top', 'right', 'bottom', 'left'];
|
|
33
25
|
export const AXIAL_SIDES = ['vertical', 'horizontal'];
|
|
34
26
|
|
|
35
|
-
function
|
|
36
|
-
const [
|
|
27
|
+
function useVisualizer() {
|
|
28
|
+
const [property, setProperty] = useState(false);
|
|
37
29
|
const {
|
|
38
30
|
hideBlockInterface,
|
|
39
31
|
showBlockInterface
|
|
40
32
|
} = unlock(useDispatch(blockEditorStore));
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
e.stopPropagation();
|
|
50
|
-
showBlockInterface();
|
|
51
|
-
setIsMouseOver(false);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
isMouseOver,
|
|
56
|
-
onMouseOver,
|
|
57
|
-
onMouseOut
|
|
58
|
-
};
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!property) {
|
|
35
|
+
showBlockInterface();
|
|
36
|
+
} else {
|
|
37
|
+
hideBlockInterface();
|
|
38
|
+
}
|
|
39
|
+
}, [property, showBlockInterface, hideBlockInterface]);
|
|
40
|
+
return [property, setProperty];
|
|
59
41
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Inspector controls for dimensions support.
|
|
62
|
-
*
|
|
63
|
-
* @param {Object} props Block props.
|
|
64
|
-
*
|
|
65
|
-
* @return {WPElement} Inspector controls for dimensions and spacing support features.
|
|
66
|
-
*/
|
|
67
42
|
|
|
43
|
+
function DimensionsInspectorControl(_ref) {
|
|
44
|
+
let {
|
|
45
|
+
children,
|
|
46
|
+
resetAllFilter
|
|
47
|
+
} = _ref;
|
|
48
|
+
const attributesResetAllFilter = useCallback(attributes => {
|
|
49
|
+
const existingStyle = attributes.style;
|
|
50
|
+
const updatedStyle = resetAllFilter(existingStyle);
|
|
51
|
+
return { ...attributes,
|
|
52
|
+
style: updatedStyle
|
|
53
|
+
};
|
|
54
|
+
}, [resetAllFilter]);
|
|
55
|
+
return createElement(InspectorControls, {
|
|
56
|
+
group: "dimensions",
|
|
57
|
+
resetAllFilter: attributesResetAllFilter
|
|
58
|
+
}, children);
|
|
59
|
+
}
|
|
68
60
|
|
|
69
61
|
export function DimensionsPanel(props) {
|
|
70
|
-
|
|
71
|
-
const isPaddingDisabled = useIsPaddingDisabled(props);
|
|
72
|
-
const isMarginDisabled = useIsMarginDisabled(props);
|
|
73
|
-
const isMinHeightDisabled = useIsMinHeightDisabled(props);
|
|
74
|
-
const isChildLayoutDisabled = useIsChildLayoutDisabled(props);
|
|
75
|
-
const isDisabled = useIsDimensionsDisabled(props);
|
|
76
|
-
const isSupported = hasDimensionsSupport(props);
|
|
77
|
-
const spacingSizes = useSetting('spacing.spacingSizes');
|
|
78
|
-
const paddingMouseOver = useVisualizerMouseOver();
|
|
79
|
-
const marginMouseOver = useVisualizerMouseOver();
|
|
62
|
+
var _settings$spacing, _settings$spacing2;
|
|
80
63
|
|
|
81
|
-
|
|
64
|
+
const {
|
|
65
|
+
clientId,
|
|
66
|
+
name,
|
|
67
|
+
attributes,
|
|
68
|
+
setAttributes,
|
|
69
|
+
__unstableParentLayout
|
|
70
|
+
} = props;
|
|
71
|
+
const settings = useBlockSettings(name, __unstableParentLayout);
|
|
72
|
+
const isEnabled = useHasDimensionsPanel(settings);
|
|
73
|
+
const value = attributes.style;
|
|
74
|
+
const [visualizedProperty, setVisualizedProperty] = useVisualizer();
|
|
75
|
+
|
|
76
|
+
const onChange = newStyle => {
|
|
77
|
+
setAttributes({
|
|
78
|
+
style: cleanEmptyObject(newStyle)
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
if (!isEnabled) {
|
|
82
83
|
return null;
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
const defaultDimensionsControls = getBlockSupport(props.name, [DIMENSIONS_SUPPORT_KEY, '__experimentalDefaultControls']);
|
|
86
87
|
const defaultSpacingControls = getBlockSupport(props.name, [SPACING_SUPPORT_KEY, '__experimentalDefaultControls']);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
var _newAttributes$style;
|
|
90
|
-
|
|
91
|
-
return { ...newAttributes,
|
|
92
|
-
style: { ...newAttributes.style,
|
|
93
|
-
[featureSet]: { ...((_newAttributes$style = newAttributes.style) === null || _newAttributes$style === void 0 ? void 0 : _newAttributes$style[featureSet]),
|
|
94
|
-
[attribute]: undefined
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
};
|
|
88
|
+
const defaultControls = { ...defaultDimensionsControls,
|
|
89
|
+
...defaultSpacingControls
|
|
98
90
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
onDeselect: () => resetPadding(props),
|
|
113
|
-
resetAllFilter: createResetAllFilter('padding', 'spacing'),
|
|
114
|
-
isShownByDefault: defaultSpacingControls === null || defaultSpacingControls === void 0 ? void 0 : defaultSpacingControls.padding,
|
|
115
|
-
panelId: props.clientId
|
|
116
|
-
}, createElement(PaddingEdit, _extends({
|
|
117
|
-
onMouseOver: paddingMouseOver.onMouseOver,
|
|
118
|
-
onMouseOut: paddingMouseOver.onMouseOut
|
|
119
|
-
}, props))), !isMarginDisabled && createElement(ToolsPanelItem, {
|
|
120
|
-
className: spacingClassnames,
|
|
121
|
-
hasValue: () => hasMarginValue(props),
|
|
122
|
-
label: __('Margin'),
|
|
123
|
-
onDeselect: () => resetMargin(props),
|
|
124
|
-
resetAllFilter: createResetAllFilter('margin', 'spacing'),
|
|
125
|
-
isShownByDefault: defaultSpacingControls === null || defaultSpacingControls === void 0 ? void 0 : defaultSpacingControls.margin,
|
|
126
|
-
panelId: props.clientId
|
|
127
|
-
}, createElement(MarginEdit, _extends({
|
|
128
|
-
onMouseOver: marginMouseOver.onMouseOver,
|
|
129
|
-
onMouseOut: marginMouseOver.onMouseOut
|
|
130
|
-
}, props))), !isGapDisabled && createElement(ToolsPanelItem, {
|
|
131
|
-
className: spacingClassnames,
|
|
132
|
-
hasValue: () => hasGapValue(props),
|
|
133
|
-
label: __('Block spacing'),
|
|
134
|
-
onDeselect: () => resetGap(props),
|
|
135
|
-
resetAllFilter: createResetAllFilter('blockGap', 'spacing'),
|
|
136
|
-
isShownByDefault: defaultSpacingControls === null || defaultSpacingControls === void 0 ? void 0 : defaultSpacingControls.blockGap,
|
|
137
|
-
panelId: props.clientId
|
|
138
|
-
}, createElement(GapEdit, props)), !isMinHeightDisabled && createElement(ToolsPanelItem, {
|
|
139
|
-
hasValue: () => hasMinHeightValue(props),
|
|
140
|
-
label: __('Min. height'),
|
|
141
|
-
onDeselect: () => resetMinHeight(props),
|
|
142
|
-
resetAllFilter: createResetAllFilter('minHeight', 'dimensions'),
|
|
143
|
-
isShownByDefault: defaultDimensionsControls === null || defaultDimensionsControls === void 0 ? void 0 : defaultDimensionsControls.minHeight,
|
|
144
|
-
panelId: props.clientId
|
|
145
|
-
}, createElement(MinHeightEdit, props)), !isChildLayoutDisabled && createElement(VStack, {
|
|
146
|
-
as: ToolsPanelItem,
|
|
147
|
-
spacing: 2,
|
|
148
|
-
hasValue: () => hasChildLayoutValue(props),
|
|
149
|
-
label: childLayoutOrientation(parentLayout),
|
|
150
|
-
onDeselect: () => resetChildLayout(props),
|
|
151
|
-
resetAllFilter: createResetAllFilter('selfStretch', 'layout'),
|
|
152
|
-
isShownByDefault: false,
|
|
153
|
-
panelId: props.clientId
|
|
154
|
-
}, createElement(ChildLayoutEdit, props))), !isPaddingDisabled && createElement(PaddingVisualizer, _extends({
|
|
155
|
-
forceShow: paddingMouseOver.isMouseOver
|
|
156
|
-
}, props)), !isMarginDisabled && createElement(MarginVisualizer, _extends({
|
|
157
|
-
forceShow: marginMouseOver.isMouseOver
|
|
91
|
+
return createElement(Fragment, null, createElement(StylesDimensionsPanel, {
|
|
92
|
+
as: DimensionsInspectorControl,
|
|
93
|
+
panelId: clientId,
|
|
94
|
+
name: name,
|
|
95
|
+
settings: settings,
|
|
96
|
+
value: value,
|
|
97
|
+
onChange: onChange,
|
|
98
|
+
defaultControls: defaultControls,
|
|
99
|
+
onVisualize: setVisualizedProperty
|
|
100
|
+
}), !!(settings !== null && settings !== void 0 && (_settings$spacing = settings.spacing) !== null && _settings$spacing !== void 0 && _settings$spacing.padding) && createElement(PaddingVisualizer, _extends({
|
|
101
|
+
forceShow: visualizedProperty === 'padding'
|
|
102
|
+
}, props)), !!(settings !== null && settings !== void 0 && (_settings$spacing2 = settings.spacing) !== null && _settings$spacing2 !== void 0 && _settings$spacing2.margin) && createElement(MarginVisualizer, _extends({
|
|
103
|
+
forceShow: visualizedProperty === 'margin'
|
|
158
104
|
}, props)));
|
|
159
105
|
}
|
|
160
106
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
* @param {Object} props Block props.
|
|
164
|
-
*
|
|
165
|
-
* @return {boolean} Whether there is support.
|
|
166
|
-
*/
|
|
167
|
-
|
|
168
|
-
export function hasDimensionsSupport(props) {
|
|
169
|
-
if (Platform.OS !== 'web') {
|
|
170
|
-
return false;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const {
|
|
174
|
-
name: blockName
|
|
175
|
-
} = props;
|
|
176
|
-
return hasGapSupport(blockName) || hasMinHeightSupport(blockName) || hasPaddingSupport(blockName) || hasMarginSupport(blockName) || hasChildLayoutSupport(props);
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Determines whether dimensions support has been disabled.
|
|
180
|
-
*
|
|
181
|
-
* @param {Object} props Block properties.
|
|
182
|
-
*
|
|
183
|
-
* @return {boolean} If spacing support is completely disabled.
|
|
107
|
+
* @deprecated
|
|
184
108
|
*/
|
|
185
109
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const marginDisabled = useIsMarginDisabled(props);
|
|
192
|
-
const childLayoutDisabled = useIsChildLayoutDisabled(props);
|
|
193
|
-
return gapDisabled && minHeightDisabled && paddingDisabled && marginDisabled && childLayoutDisabled;
|
|
194
|
-
};
|
|
195
|
-
/**
|
|
196
|
-
* Custom hook to retrieve which padding/margin/blockGap is supported
|
|
197
|
-
* e.g. top, right, bottom or left.
|
|
198
|
-
*
|
|
199
|
-
* Sides are opted into by default. It is only if a specific side is set to
|
|
200
|
-
* false that it is omitted.
|
|
201
|
-
*
|
|
202
|
-
* @param {string} blockName Block name.
|
|
203
|
-
* @param {string} feature The feature custom sides relate to e.g. padding or margins.
|
|
204
|
-
*
|
|
205
|
-
* @return {string[] | undefined} Strings representing the custom sides available.
|
|
206
|
-
*/
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
export function useCustomSides(blockName, feature) {
|
|
210
|
-
var _support$feature;
|
|
211
|
-
|
|
212
|
-
const support = getBlockSupport(blockName, SPACING_SUPPORT_KEY); // Skip when setting is boolean as theme isn't setting arbitrary sides.
|
|
213
|
-
|
|
214
|
-
if (!support || typeof support[feature] === 'boolean') {
|
|
215
|
-
return;
|
|
216
|
-
} // Return if the setting is an array of sides (e.g. `[ 'top', 'bottom' ]`).
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
if (Array.isArray(support[feature])) {
|
|
220
|
-
return support[feature];
|
|
221
|
-
} // Finally, attempt to return `.sides` if the setting is an object.
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
if ((_support$feature = support[feature]) !== null && _support$feature !== void 0 && _support$feature.sides) {
|
|
225
|
-
return support[feature].sides;
|
|
226
|
-
}
|
|
110
|
+
export function useCustomSides() {
|
|
111
|
+
deprecated('wp.blockEditor.__experimentalUseCustomSides', {
|
|
112
|
+
since: '6.3',
|
|
113
|
+
version: '6.4'
|
|
114
|
+
});
|
|
227
115
|
}
|
|
228
116
|
/**
|
|
229
117
|
* Custom hook to determine whether the sides configured in the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/dimensions.js"],"names":["classnames","__experimentalToolsPanelItem","ToolsPanelItem","__experimentalVStack","VStack","Platform","useState","__","getBlockSupport","useDispatch","InspectorControls","GapEdit","hasGapSupport","hasGapValue","resetGap","useIsGapDisabled","MarginEdit","MarginVisualizer","hasMarginSupport","hasMarginValue","resetMargin","useIsMarginDisabled","MinHeightEdit","hasMinHeightSupport","hasMinHeightValue","resetMinHeight","useIsMinHeightDisabled","PaddingEdit","PaddingVisualizer","hasPaddingSupport","hasPaddingValue","resetPadding","useIsPaddingDisabled","ChildLayoutEdit","hasChildLayoutSupport","hasChildLayoutValue","resetChildLayout","useIsChildLayoutDisabled","childLayoutOrientation","useSetting","store","blockEditorStore","unlock","DIMENSIONS_SUPPORT_KEY","SPACING_SUPPORT_KEY","ALL_SIDES","AXIAL_SIDES","useVisualizerMouseOver","isMouseOver","setIsMouseOver","hideBlockInterface","showBlockInterface","onMouseOver","e","stopPropagation","onMouseOut","DimensionsPanel","props","isGapDisabled","isPaddingDisabled","isMarginDisabled","isMinHeightDisabled","isChildLayoutDisabled","isDisabled","useIsDimensionsDisabled","isSupported","hasDimensionsSupport","spacingSizes","paddingMouseOver","marginMouseOver","defaultDimensionsControls","name","defaultSpacingControls","createResetAllFilter","attribute","featureSet","newAttributes","style","undefined","spacingClassnames","length","__unstableParentLayout","parentLayout","padding","clientId","margin","blockGap","minHeight","OS","blockName","gapDisabled","minHeightDisabled","paddingDisabled","marginDisabled","childLayoutDisabled","useCustomSides","feature","support","Array","isArray","sides","useIsDimensionsSupportValid","some","side","includes","console","warn","every"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,4BAA4B,IAAIC,cADjC,EAECC,oBAAoB,IAAIC,MAFzB,QAGO,uBAHP;AAIA,SAASC,QAAT,EAAmBC,QAAnB,QAAmC,oBAAnC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,iBAAP,MAA8B,kCAA9B;AACA,SACCC,OADD,EAECC,aAFD,EAGCC,WAHD,EAICC,QAJD,EAKCC,gBALD,QAMO,OANP;AAOA,SACCC,UADD,EAECC,gBAFD,EAGCC,gBAHD,EAICC,cAJD,EAKCC,WALD,EAMCC,mBAND,QAOO,UAPP;AAQA,SACCC,aADD,EAECC,mBAFD,EAGCC,iBAHD,EAICC,cAJD,EAKCC,sBALD,QAMO,cANP;AAOA,SACCC,WADD,EAECC,iBAFD,EAGCC,iBAHD,EAICC,eAJD,EAKCC,YALD,EAMCC,oBAND,QAOO,WAPP;AAQA,SACCC,eADD,EAECC,qBAFD,EAGCC,mBAHD,EAICC,gBAJD,EAKCC,wBALD,EAMCC,sBAND,QAOO,gBAPP;AAQA,OAAOC,UAAP,MAAuB,2BAAvB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,UAA1C;AACA,SAASC,MAAT,QAAuB,gBAAvB;AAEA,OAAO,MAAMC,sBAAsB,GAAG,YAA/B;AACP,OAAO,MAAMC,mBAAmB,GAAG,SAA5B;AACP,OAAO,MAAMC,SAAS,GAAG,CAAE,KAAF,EAAS,OAAT,EAAkB,QAAlB,EAA4B,MAA5B,CAAlB;AACP,OAAO,MAAMC,WAAW,GAAG,CAAE,UAAF,EAAc,YAAd,CAApB;;AAEP,SAASC,sBAA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2C;AAC1C,WAAOC,OAAO,CAAED,OAAF,CAAd;AACA,GAXmD,CAapD;;;AACA,0BAAKC,OAAO,CAAED,OAAF,CAAZ,6CAAK,iBAAoBI,KAAzB,EAAiC;AAChC,WAAOH,OAAO,CAAED,OAAF,CAAP,CAAmBI,KAA1B;AACA;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,2BAAT,CAAsCZ,SAAtC,EAAiDO,OAAjD,EAA2D;AACjE,QAAMI,KAAK,GAAGL,cAAc,CAAEN,SAAF,EAAaO,OAAb,CAA5B;;AAEA,MACCI,KAAK,IACLA,KAAK,CAACE,IAAN,CAAcC,IAAF,IAAY1D,SAAS,CAAC2D,QAAV,CAAoBD,IAApB,CAAxB,CADA,IAEAH,KAAK,CAACE,IAAN,CAAcC,IAAF,IAAYzD,WAAW,CAAC0D,QAAZ,CAAsBD,IAAtB,CAAxB,CAHD,EAIE;AACD;AACAE,IAAAA,OAAO,CAACC,IAAR,CACE,OAAOV,OAAS,qBAAqBP,SAAW,0EADlD;AAGA,WAAO,KAAP;AACA;;AAED,MACCW,KAAK,SAAL,IAAAA,KAAK,WAAL,IAAAA,KAAK,CAAEpB,MAAP,IACAgB,OAAO,KAAK,UADZ,IAEA,CAAElD,WAAW,CAAC6D,KAAZ,CAAqBJ,IAAF,IAAYH,KAAK,CAACI,QAAN,CAAgBD,IAAhB,CAA/B,CAHH,EAIE;AACD;AACAE,IAAAA,OAAO,CAACC,IAAR,CACE,OAAOV,OAAS,qBAAqBP,SAAW,2DADlD;AAGA,WAAO,KAAP;AACA;;AAED,SAAO,IAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { Platform, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport {\n\tGapEdit,\n\thasGapSupport,\n\thasGapValue,\n\tresetGap,\n\tuseIsGapDisabled,\n} from './gap';\nimport {\n\tMarginEdit,\n\tMarginVisualizer,\n\thasMarginSupport,\n\thasMarginValue,\n\tresetMargin,\n\tuseIsMarginDisabled,\n} from './margin';\nimport {\n\tMinHeightEdit,\n\thasMinHeightSupport,\n\thasMinHeightValue,\n\tresetMinHeight,\n\tuseIsMinHeightDisabled,\n} from './min-height';\nimport {\n\tPaddingEdit,\n\tPaddingVisualizer,\n\thasPaddingSupport,\n\thasPaddingValue,\n\tresetPadding,\n\tuseIsPaddingDisabled,\n} from './padding';\nimport {\n\tChildLayoutEdit,\n\thasChildLayoutSupport,\n\thasChildLayoutValue,\n\tresetChildLayout,\n\tuseIsChildLayoutDisabled,\n\tchildLayoutOrientation,\n} from './child-layout';\nimport useSetting from '../components/use-setting';\nimport { store as blockEditorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nexport const DIMENSIONS_SUPPORT_KEY = 'dimensions';\nexport const SPACING_SUPPORT_KEY = 'spacing';\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nexport const AXIAL_SIDES = [ 'vertical', 'horizontal' ];\n\nfunction useVisualizerMouseOver() {\n\tconst [ isMouseOver, setIsMouseOver ] = useState( false );\n\tconst { hideBlockInterface, showBlockInterface } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\tconst onMouseOver = ( e ) => {\n\t\te.stopPropagation();\n\t\thideBlockInterface();\n\t\tsetIsMouseOver( true );\n\t};\n\tconst onMouseOut = ( e ) => {\n\t\te.stopPropagation();\n\t\tshowBlockInterface();\n\t\tsetIsMouseOver( false );\n\t};\n\treturn { isMouseOver, onMouseOver, onMouseOut };\n}\n\n/**\n * Inspector controls for dimensions support.\n *\n * @param {Object} props Block props.\n *\n * @return {WPElement} Inspector controls for dimensions and spacing support features.\n */\nexport function DimensionsPanel( props ) {\n\tconst isGapDisabled = useIsGapDisabled( props );\n\tconst isPaddingDisabled = useIsPaddingDisabled( props );\n\tconst isMarginDisabled = useIsMarginDisabled( props );\n\tconst isMinHeightDisabled = useIsMinHeightDisabled( props );\n\tconst isChildLayoutDisabled = useIsChildLayoutDisabled( props );\n\tconst isDisabled = useIsDimensionsDisabled( props );\n\tconst isSupported = hasDimensionsSupport( props );\n\tconst spacingSizes = useSetting( 'spacing.spacingSizes' );\n\tconst paddingMouseOver = useVisualizerMouseOver();\n\tconst marginMouseOver = useVisualizerMouseOver();\n\n\tif ( isDisabled || ! isSupported ) {\n\t\treturn null;\n\t}\n\n\tconst defaultDimensionsControls = getBlockSupport( props.name, [\n\t\tDIMENSIONS_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\tconst defaultSpacingControls = getBlockSupport( props.name, [\n\t\tSPACING_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\tconst createResetAllFilter =\n\t\t( attribute, featureSet ) => ( newAttributes ) => ( {\n\t\t\t...newAttributes,\n\t\t\tstyle: {\n\t\t\t\t...newAttributes.style,\n\t\t\t\t[ featureSet ]: {\n\t\t\t\t\t...newAttributes.style?.[ featureSet ],\n\t\t\t\t\t[ attribute ]: undefined,\n\t\t\t\t},\n\t\t\t},\n\t\t} );\n\n\tconst spacingClassnames = classnames( {\n\t\t'tools-panel-item-spacing': spacingSizes && spacingSizes.length > 0,\n\t} );\n\n\tconst { __unstableParentLayout: parentLayout } = props;\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls group=\"dimensions\">\n\t\t\t\t{ ! isPaddingDisabled && (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tclassName={ spacingClassnames }\n\t\t\t\t\t\thasValue={ () => hasPaddingValue( props ) }\n\t\t\t\t\t\tlabel={ __( 'Padding' ) }\n\t\t\t\t\t\tonDeselect={ () => resetPadding( props ) }\n\t\t\t\t\t\tresetAllFilter={ createResetAllFilter(\n\t\t\t\t\t\t\t'padding',\n\t\t\t\t\t\t\t'spacing'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tisShownByDefault={ defaultSpacingControls?.padding }\n\t\t\t\t\t\tpanelId={ props.clientId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<PaddingEdit\n\t\t\t\t\t\t\tonMouseOver={ paddingMouseOver.onMouseOver }\n\t\t\t\t\t\t\tonMouseOut={ paddingMouseOver.onMouseOut }\n\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t) }\n\t\t\t\t{ ! isMarginDisabled && (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tclassName={ spacingClassnames }\n\t\t\t\t\t\thasValue={ () => hasMarginValue( props ) }\n\t\t\t\t\t\tlabel={ __( 'Margin' ) }\n\t\t\t\t\t\tonDeselect={ () => resetMargin( props ) }\n\t\t\t\t\t\tresetAllFilter={ createResetAllFilter(\n\t\t\t\t\t\t\t'margin',\n\t\t\t\t\t\t\t'spacing'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tisShownByDefault={ defaultSpacingControls?.margin }\n\t\t\t\t\t\tpanelId={ props.clientId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<MarginEdit\n\t\t\t\t\t\t\tonMouseOver={ marginMouseOver.onMouseOver }\n\t\t\t\t\t\t\tonMouseOut={ marginMouseOver.onMouseOut }\n\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t) }\n\t\t\t\t{ ! isGapDisabled && (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\tclassName={ spacingClassnames }\n\t\t\t\t\t\thasValue={ () => hasGapValue( props ) }\n\t\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\t\tonDeselect={ () => resetGap( props ) }\n\t\t\t\t\t\tresetAllFilter={ createResetAllFilter(\n\t\t\t\t\t\t\t'blockGap',\n\t\t\t\t\t\t\t'spacing'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tisShownByDefault={ defaultSpacingControls?.blockGap }\n\t\t\t\t\t\tpanelId={ props.clientId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<GapEdit { ...props } />\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t) }\n\t\t\t\t{ ! isMinHeightDisabled && (\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => hasMinHeightValue( props ) }\n\t\t\t\t\t\tlabel={ __( 'Min. height' ) }\n\t\t\t\t\t\tonDeselect={ () => resetMinHeight( props ) }\n\t\t\t\t\t\tresetAllFilter={ createResetAllFilter(\n\t\t\t\t\t\t\t'minHeight',\n\t\t\t\t\t\t\t'dimensions'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tisShownByDefault={\n\t\t\t\t\t\t\tdefaultDimensionsControls?.minHeight\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpanelId={ props.clientId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<MinHeightEdit { ...props } />\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t) }\n\t\t\t\t{ ! isChildLayoutDisabled && (\n\t\t\t\t\t<VStack\n\t\t\t\t\t\tas={ ToolsPanelItem }\n\t\t\t\t\t\tspacing={ 2 }\n\t\t\t\t\t\thasValue={ () => hasChildLayoutValue( props ) }\n\t\t\t\t\t\tlabel={ childLayoutOrientation( parentLayout ) }\n\t\t\t\t\t\tonDeselect={ () => resetChildLayout( props ) }\n\t\t\t\t\t\tresetAllFilter={ createResetAllFilter(\n\t\t\t\t\t\t\t'selfStretch',\n\t\t\t\t\t\t\t'layout'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tisShownByDefault={ false }\n\t\t\t\t\t\tpanelId={ props.clientId }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ChildLayoutEdit { ...props } />\n\t\t\t\t\t</VStack>\n\t\t\t\t) }\n\t\t\t</InspectorControls>\n\t\t\t{ ! isPaddingDisabled && (\n\t\t\t\t<PaddingVisualizer\n\t\t\t\t\tforceShow={ paddingMouseOver.isMouseOver }\n\t\t\t\t\t{ ...props }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ! isMarginDisabled && (\n\t\t\t\t<MarginVisualizer\n\t\t\t\t\tforceShow={ marginMouseOver.isMouseOver }\n\t\t\t\t\t{ ...props }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\n/**\n * Determine whether there is dimensions related block support.\n *\n * @param {Object} props Block props.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasDimensionsSupport( props ) {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst { name: blockName } = props;\n\n\treturn (\n\t\thasGapSupport( blockName ) ||\n\t\thasMinHeightSupport( blockName ) ||\n\t\thasPaddingSupport( blockName ) ||\n\t\thasMarginSupport( blockName ) ||\n\t\thasChildLayoutSupport( props )\n\t);\n}\n\n/**\n * Determines whether dimensions support has been disabled.\n *\n * @param {Object} props Block properties.\n *\n * @return {boolean} If spacing support is completely disabled.\n */\nconst useIsDimensionsDisabled = ( props = {} ) => {\n\tconst gapDisabled = useIsGapDisabled( props );\n\tconst minHeightDisabled = useIsMinHeightDisabled( props );\n\tconst paddingDisabled = useIsPaddingDisabled( props );\n\tconst marginDisabled = useIsMarginDisabled( props );\n\tconst childLayoutDisabled = useIsChildLayoutDisabled( props );\n\n\treturn (\n\t\tgapDisabled &&\n\t\tminHeightDisabled &&\n\t\tpaddingDisabled &&\n\t\tmarginDisabled &&\n\t\tchildLayoutDisabled\n\t);\n};\n\n/**\n * Custom hook to retrieve which padding/margin/blockGap is supported\n * e.g. top, right, bottom or left.\n *\n * Sides are opted into by default. It is only if a specific side is set to\n * false that it is omitted.\n *\n * @param {string} blockName Block name.\n * @param {string} feature The feature custom sides relate to e.g. padding or margins.\n *\n * @return {string[] | undefined} Strings representing the custom sides available.\n */\nexport function useCustomSides( blockName, feature ) {\n\tconst support = getBlockSupport( blockName, SPACING_SUPPORT_KEY );\n\n\t// Skip when setting is boolean as theme isn't setting arbitrary sides.\n\tif ( ! support || typeof support[ feature ] === 'boolean' ) {\n\t\treturn;\n\t}\n\n\t// Return if the setting is an array of sides (e.g. `[ 'top', 'bottom' ]`).\n\tif ( Array.isArray( support[ feature ] ) ) {\n\t\treturn support[ feature ];\n\t}\n\n\t// Finally, attempt to return `.sides` if the setting is an object.\n\tif ( support[ feature ]?.sides ) {\n\t\treturn support[ feature ].sides;\n\t}\n}\n\n/**\n * Custom hook to determine whether the sides configured in the\n * block support are valid. A dimension property cannot declare\n * support for a mix of axial and individual sides.\n *\n * @param {string} blockName Block name.\n * @param {string} feature The feature custom sides relate to e.g. padding or margins.\n *\n * @return {boolean} If the feature has a valid configuration of sides.\n */\nexport function useIsDimensionsSupportValid( blockName, feature ) {\n\tconst sides = useCustomSides( blockName, feature );\n\n\tif (\n\t\tsides &&\n\t\tsides.some( ( side ) => ALL_SIDES.includes( side ) ) &&\n\t\tsides.some( ( side ) => AXIAL_SIDES.includes( side ) )\n\t) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t`The ${ feature } support for the \"${ blockName }\" block can not be configured to support both axial and arbitrary sides.`\n\t\t);\n\t\treturn false;\n\t}\n\n\tif (\n\t\tsides?.length &&\n\t\tfeature === 'blockGap' &&\n\t\t! AXIAL_SIDES.every( ( side ) => sides.includes( side ) )\n\t) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t`The ${ feature } support for the \"${ blockName }\" block can not be configured to support arbitrary sides.`\n\t\t);\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/dimensions.js"],"names":["useState","useEffect","useCallback","useDispatch","getBlockSupport","deprecated","InspectorControls","DimensionsPanel","StylesDimensionsPanel","useHasDimensionsPanel","MarginVisualizer","PaddingVisualizer","store","blockEditorStore","unlock","cleanEmptyObject","useBlockSettings","DIMENSIONS_SUPPORT_KEY","SPACING_SUPPORT_KEY","ALL_SIDES","AXIAL_SIDES","useVisualizer","property","setProperty","hideBlockInterface","showBlockInterface","DimensionsInspectorControl","children","resetAllFilter","attributesResetAllFilter","attributes","existingStyle","style","updatedStyle","props","clientId","name","setAttributes","__unstableParentLayout","settings","isEnabled","value","visualizedProperty","setVisualizedProperty","onChange","newStyle","defaultDimensionsControls","defaultSpacingControls","defaultControls","spacing","padding","margin","useCustomSides","since","version","useIsDimensionsSupportValid","blockName","feature","sides","some","side","includes","console","warn","length","every"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,SAAnB,EAA8BC,WAA9B,QAAiD,oBAAjD;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,iBAAP,MAA8B,kCAA9B;AACA,SACCC,eAAe,IAAIC,qBADpB,EAECC,qBAFD,QAGO,6BAHP;AAIA,SAASC,gBAAT,QAAiC,UAAjC;AACA,SAASC,iBAAT,QAAkC,WAAlC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,UAA1C;AACA,SAASC,MAAT,QAAuB,gBAAvB;AAEA,SAASC,gBAAT,EAA2BC,gBAA3B,QAAmD,SAAnD;AAEA,OAAO,MAAMC,sBAAsB,GAAG,YAA/B;AACP,OAAO,MAAMC,mBAAmB,GAAG,SAA5B;AACP,OAAO,MAAMC,SAAS,GAAG,CAAE,KAAF,EAAS,OAAT,EAAkB,QAAlB,EAA4B,MAA5B,CAAlB;AACP,OAAO,MAAMC,WAAW,GAAG,CAAE,UAAF,EAAc,YAAd,CAApB;;AAEP,SAASC,aAAT,GAAyB;AACxB,QAAM,CAAEC,QAAF,EAAYC,WAAZ,IAA4Bv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ACA;AACA;;AACA,OAAO,SAASkB,cAAT,GAA0B;AAChC/C,EAAAA,UAAU,CAAE,6CAAF,EAAiD;AAC1DgD,IAAAA,KAAK,EAAE,KADmD;AAE1DC,IAAAA,OAAO,EAAE;AAFiD,GAAjD,CAAV;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,2BAAT,CAAsCC,SAAtC,EAAiDC,OAAjD,EAA2D;AACjE,QAAMC,KAAK,GAAGN,cAAc,CAAEI,SAAF,EAAaC,OAAb,CAA5B;;AAEA,MACCC,KAAK,IACLA,KAAK,CAACC,IAAN,CAAcC,IAAF,IAAYzC,SAAS,CAAC0C,QAAV,CAAoBD,IAApB,CAAxB,CADA,IAEAF,KAAK,CAACC,IAAN,CAAcC,IAAF,IAAYxC,WAAW,CAACyC,QAAZ,CAAsBD,IAAtB,CAAxB,CAHD,EAIE;AACD;AACAE,IAAAA,OAAO,CAACC,IAAR,CACE,OAAON,OAAS,qBAAqBD,SAAW,0EADlD;AAGA,WAAO,KAAP;AACA;;AAED,MACCE,KAAK,SAAL,IAAAA,KAAK,WAAL,IAAAA,KAAK,CAAEM,MAAP,IACAP,OAAO,KAAK,UADZ,IAEA,CAAErC,WAAW,CAAC6C,KAAZ,CAAqBL,IAAF,IAAYF,KAAK,CAACG,QAAN,CAAgBD,IAAhB,CAA/B,CAHH,EAIE;AACD;AACAE,IAAAA,OAAO,CAACC,IAAR,CACE,OAAON,OAAS,qBAAqBD,SAAW,2DADlD;AAGA,WAAO,KAAP;AACA;;AAED,SAAO,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useCallback } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport {\n\tDimensionsPanel as StylesDimensionsPanel,\n\tuseHasDimensionsPanel,\n} from '../components/global-styles';\nimport { MarginVisualizer } from './margin';\nimport { PaddingVisualizer } from './padding';\nimport { store as blockEditorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nimport { cleanEmptyObject, useBlockSettings } from './utils';\n\nexport const DIMENSIONS_SUPPORT_KEY = 'dimensions';\nexport const SPACING_SUPPORT_KEY = 'spacing';\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nexport const AXIAL_SIDES = [ 'vertical', 'horizontal' ];\n\nfunction useVisualizer() {\n\tconst [ property, setProperty ] = useState( false );\n\tconst { hideBlockInterface, showBlockInterface } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\tuseEffect( () => {\n\t\tif ( ! property ) {\n\t\t\tshowBlockInterface();\n\t\t} else {\n\t\t\thideBlockInterface();\n\t\t}\n\t}, [ property, showBlockInterface, hideBlockInterface ] );\n\n\treturn [ property, setProperty ];\n}\n\nfunction DimensionsInspectorControl( { children, resetAllFilter } ) {\n\tconst attributesResetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst existingStyle = attributes.style;\n\t\t\tconst updatedStyle = resetAllFilter( existingStyle );\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\tstyle: updatedStyle,\n\t\t\t};\n\t\t},\n\t\t[ resetAllFilter ]\n\t);\n\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"dimensions\"\n\t\t\tresetAllFilter={ attributesResetAllFilter }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function DimensionsPanel( props ) {\n\tconst {\n\t\tclientId,\n\t\tname,\n\t\tattributes,\n\t\tsetAttributes,\n\t\t__unstableParentLayout,\n\t} = props;\n\tconst settings = useBlockSettings( name, __unstableParentLayout );\n\tconst isEnabled = useHasDimensionsPanel( settings );\n\tconst value = attributes.style;\n\tconst [ visualizedProperty, setVisualizedProperty ] = useVisualizer();\n\tconst onChange = ( newStyle ) => {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultDimensionsControls = getBlockSupport( props.name, [\n\t\tDIMENSIONS_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\tconst defaultSpacingControls = getBlockSupport( props.name, [\n\t\tSPACING_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\tconst defaultControls = {\n\t\t...defaultDimensionsControls,\n\t\t...defaultSpacingControls,\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<StylesDimensionsPanel\n\t\t\t\tas={ DimensionsInspectorControl }\n\t\t\t\tpanelId={ clientId }\n\t\t\t\tname={ name }\n\t\t\t\tsettings={ settings }\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tdefaultControls={ defaultControls }\n\t\t\t\tonVisualize={ setVisualizedProperty }\n\t\t\t/>\n\t\t\t{ !! settings?.spacing?.padding && (\n\t\t\t\t<PaddingVisualizer\n\t\t\t\t\tforceShow={ visualizedProperty === 'padding' }\n\t\t\t\t\t{ ...props }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ !! settings?.spacing?.margin && (\n\t\t\t\t<MarginVisualizer\n\t\t\t\t\tforceShow={ visualizedProperty === 'margin' }\n\t\t\t\t\t{ ...props }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\n/**\n * @deprecated\n */\nexport function useCustomSides() {\n\tdeprecated( 'wp.blockEditor.__experimentalUseCustomSides', {\n\t\tsince: '6.3',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * Custom hook to determine whether the sides configured in the\n * block support are valid. A dimension property cannot declare\n * support for a mix of axial and individual sides.\n *\n * @param {string} blockName Block name.\n * @param {string} feature The feature custom sides relate to e.g. padding or margins.\n *\n * @return {boolean} If the feature has a valid configuration of sides.\n */\nexport function useIsDimensionsSupportValid( blockName, feature ) {\n\tconst sides = useCustomSides( blockName, feature );\n\n\tif (\n\t\tsides &&\n\t\tsides.some( ( side ) => ALL_SIDES.includes( side ) ) &&\n\t\tsides.some( ( side ) => AXIAL_SIDES.includes( side ) )\n\t) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t`The ${ feature } support for the \"${ blockName }\" block can not be configured to support both axial and arbitrary sides.`\n\t\t);\n\t\treturn false;\n\t}\n\n\tif (\n\t\tsides?.length &&\n\t\tfeature === 'blockGap' &&\n\t\t! AXIAL_SIDES.every( ( side ) => sides.includes( side ) )\n\t) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t`The ${ feature } support for the \"${ blockName }\" block can not be configured to support arbitrary sides.`\n\t\t);\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n"]}
|
|
@@ -71,15 +71,41 @@ function useMultiOriginPresets(_ref2) {
|
|
|
71
71
|
return useMemo(() => [...userPresets, ...themePresets, ...(disableDefault ? EMPTY_ARRAY : defaultPresets)], [disableDefault, userPresets, themePresets, defaultPresets]);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
function
|
|
74
|
+
export function getColorsFromDuotonePreset(duotone, duotonePalette) {
|
|
75
|
+
if (!duotone) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const preset = duotonePalette === null || duotonePalette === void 0 ? void 0 : duotonePalette.find(_ref3 => {
|
|
80
|
+
let {
|
|
81
|
+
slug
|
|
82
|
+
} = _ref3;
|
|
83
|
+
return duotone === `var:preset|duotone|${slug}`;
|
|
84
|
+
});
|
|
85
|
+
return preset ? preset.colors : undefined;
|
|
86
|
+
}
|
|
87
|
+
export function getDuotonePresetFromColors(colors, duotonePalette) {
|
|
88
|
+
if (!colors || !Array.isArray(colors)) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const preset = duotonePalette === null || duotonePalette === void 0 ? void 0 : duotonePalette.find(duotonePreset => {
|
|
93
|
+
var _duotonePreset$colors;
|
|
94
|
+
|
|
95
|
+
return duotonePreset === null || duotonePreset === void 0 ? void 0 : (_duotonePreset$colors = duotonePreset.colors) === null || _duotonePreset$colors === void 0 ? void 0 : _duotonePreset$colors.every((val, index) => val === colors[index]);
|
|
96
|
+
});
|
|
97
|
+
return preset ? `var:preset|duotone|${preset.slug}` : undefined;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function DuotonePanel(_ref4) {
|
|
75
101
|
var _style$color;
|
|
76
102
|
|
|
77
103
|
let {
|
|
78
104
|
attributes,
|
|
79
105
|
setAttributes
|
|
80
|
-
} =
|
|
106
|
+
} = _ref4;
|
|
81
107
|
const style = attributes === null || attributes === void 0 ? void 0 : attributes.style;
|
|
82
|
-
const
|
|
108
|
+
const duotoneStyle = style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.duotone;
|
|
83
109
|
const duotonePalette = useMultiOriginPresets({
|
|
84
110
|
presetSetting: 'color.duotone',
|
|
85
111
|
defaultSetting: 'color.defaultDuotone'
|
|
@@ -95,6 +121,7 @@ function DuotonePanel(_ref3) {
|
|
|
95
121
|
return null;
|
|
96
122
|
}
|
|
97
123
|
|
|
124
|
+
const duotonePresetOrColors = !Array.isArray(duotoneStyle) ? getColorsFromDuotonePreset(duotoneStyle, duotonePalette) : duotoneStyle;
|
|
98
125
|
return createElement(BlockControls, {
|
|
99
126
|
group: "block",
|
|
100
127
|
__experimentalShareWithChildBlocks: true
|
|
@@ -103,11 +130,13 @@ function DuotonePanel(_ref3) {
|
|
|
103
130
|
colorPalette: colorPalette,
|
|
104
131
|
disableCustomDuotone: disableCustomDuotone,
|
|
105
132
|
disableCustomColors: disableCustomColors,
|
|
106
|
-
value:
|
|
133
|
+
value: duotonePresetOrColors,
|
|
107
134
|
onChange: newDuotone => {
|
|
135
|
+
const maybePreset = getDuotonePresetFromColors(newDuotone, duotonePalette);
|
|
108
136
|
const newStyle = { ...style,
|
|
109
137
|
color: { ...(style === null || style === void 0 ? void 0 : style.color),
|
|
110
|
-
duotone: newDuotone
|
|
138
|
+
duotone: maybePreset !== null && maybePreset !== void 0 ? maybePreset : newDuotone // use preset or fallback to custom colors.
|
|
139
|
+
|
|
111
140
|
}
|
|
112
141
|
};
|
|
113
142
|
setAttributes({
|
|
@@ -157,8 +186,12 @@ const withDuotoneControls = createHigherOrderComponent(BlockEdit => props => {
|
|
|
157
186
|
const hasDuotoneSupport = hasBlockSupport(props.name, 'color.__experimentalDuotone');
|
|
158
187
|
const isContentLocked = useSelect(select => {
|
|
159
188
|
return select(blockEditorStore).__unstableGetContentLockingParent(props.clientId);
|
|
160
|
-
}, [props.clientId]);
|
|
161
|
-
|
|
189
|
+
}, [props.clientId]); // CAUTION: code added before this line will be executed
|
|
190
|
+
// for all blocks, not just those that support duotone. Code added
|
|
191
|
+
// above this line should be carefully evaluated for its impact on
|
|
192
|
+
// performance.
|
|
193
|
+
|
|
194
|
+
return createElement(Fragment, null, hasDuotoneSupport && !isContentLocked && createElement(DuotonePanel, props), createElement(BlockEdit, props));
|
|
162
195
|
}, 'withDuotoneControls');
|
|
163
196
|
/**
|
|
164
197
|
* Function that scopes a selector with another one. This works a bit like
|
|
@@ -189,6 +222,41 @@ function scopeSelector(scope, selector) {
|
|
|
189
222
|
});
|
|
190
223
|
return selectorsScoped.join(', ');
|
|
191
224
|
}
|
|
225
|
+
|
|
226
|
+
function BlockDuotoneStyles(_ref5) {
|
|
227
|
+
let {
|
|
228
|
+
name,
|
|
229
|
+
duotoneStyle,
|
|
230
|
+
id
|
|
231
|
+
} = _ref5;
|
|
232
|
+
const duotonePalette = useMultiOriginPresets({
|
|
233
|
+
presetSetting: 'color.duotone',
|
|
234
|
+
defaultSetting: 'color.defaultDuotone'
|
|
235
|
+
});
|
|
236
|
+
const element = useContext(BlockList.__unstableElementContext); // Portals cannot exist without a container.
|
|
237
|
+
// Guard against empty Duotone styles.
|
|
238
|
+
|
|
239
|
+
if (!element || !duotoneStyle) {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
let colors = duotoneStyle;
|
|
244
|
+
|
|
245
|
+
if (!Array.isArray(colors) && colors !== 'unset') {
|
|
246
|
+
colors = getColorsFromDuotonePreset(colors, duotonePalette);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const duotoneSupportSelectors = getBlockSupport(name, 'color.__experimentalDuotone'); // Extra .editor-styles-wrapper specificity is needed in the editor
|
|
250
|
+
// since we're not using inline styles to apply the filter. We need to
|
|
251
|
+
// override duotone applied by global styles and theme.json.
|
|
252
|
+
|
|
253
|
+
const selectorsGroup = scopeSelector(`.editor-styles-wrapper .${id}`, duotoneSupportSelectors);
|
|
254
|
+
return createPortal(createElement(InlineDuotone, {
|
|
255
|
+
selector: selectorsGroup,
|
|
256
|
+
id: id,
|
|
257
|
+
colors: colors
|
|
258
|
+
}), element);
|
|
259
|
+
}
|
|
192
260
|
/**
|
|
193
261
|
* Override the default block element to include duotone styles.
|
|
194
262
|
*
|
|
@@ -202,24 +270,18 @@ const withDuotoneStyles = createHigherOrderComponent(BlockListBlock => props =>
|
|
|
202
270
|
var _props$attributes, _props$attributes$sty, _props$attributes$sty2;
|
|
203
271
|
|
|
204
272
|
const duotoneSupport = getBlockSupport(props.name, 'color.__experimentalDuotone');
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const id = `wp-duotone-${useInstanceId(BlockListBlock)}`; // Extra .editor-styles-wrapper specificity is needed in the editor
|
|
212
|
-
// since we're not using inline styles to apply the filter. We need to
|
|
213
|
-
// override duotone applied by global styles and theme.json.
|
|
273
|
+
const id = `wp-duotone-${useInstanceId(BlockListBlock)}`;
|
|
274
|
+
const className = duotoneSupport ? classnames(props === null || props === void 0 ? void 0 : props.className, id) : props === null || props === void 0 ? void 0 : props.className;
|
|
275
|
+
const duotoneStyle = props === null || props === void 0 ? void 0 : (_props$attributes = props.attributes) === null || _props$attributes === void 0 ? void 0 : (_props$attributes$sty = _props$attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.color) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.duotone; // CAUTION: code added before this line will be executed
|
|
276
|
+
// for all blocks, not just those that support duotone. Code added
|
|
277
|
+
// above this line should be carefully evaluated for its impact on
|
|
278
|
+
// performance.
|
|
214
279
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
id: id,
|
|
221
|
-
colors: colors
|
|
222
|
-
}), element), createElement(BlockListBlock, _extends({}, props, {
|
|
280
|
+
return createElement(Fragment, null, duotoneSupport && duotoneStyle && createElement(BlockDuotoneStyles, {
|
|
281
|
+
name: props === null || props === void 0 ? void 0 : props.name,
|
|
282
|
+
duotoneStyle: duotoneStyle,
|
|
283
|
+
id: id
|
|
284
|
+
}), createElement(BlockListBlock, _extends({}, props, {
|
|
223
285
|
className: className
|
|
224
286
|
})));
|
|
225
287
|
}, 'withDuotoneStyles');
|