@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/duotone.js"],"names":["EMPTY_ARRAY","namesPlugin","InlineDuotone","selector","id","colors","useMultiOriginPresets","presetSetting","defaultSetting","disableDefault","userPresets","themePresets","defaultPresets","DuotonePanel","attributes","setAttributes","style","duotone","color","duotonePalette","colorPalette","disableCustomColors","disableCustomDuotone","length","newDuotone","newStyle","addDuotoneAttributes","settings","Object","assign","type","withDuotoneControls","BlockEdit","props","hasDuotoneSupport","name","isContentLocked","select","blockEditorStore","__unstableGetContentLockingParent","clientId","scopeSelector","scope","scopes","split","selectors","selectorsScoped","forEach","outer","inner","push","trim","join","withDuotoneStyles","BlockListBlock","duotoneSupport","selectorsGroup","className","element","BlockList","__unstableElementContext"],"mappings":";;;;AAaA;;;;AAVA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AAKA;;AAKA;;AACA;;AAKA;;AA9BA;AACA;AACA;;AAKA;AACA;AACA;;AAOA;AACA;AACA;AAcA,MAAMA,WAAW,GAAG,EAApB;AAEA,oBAAQ,CAAEC,cAAF,CAAR;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,aAAT,OAAmD;AAAA,MAA3B;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,EAAZ;AAAgBC,IAAAA;AAAhB,GAA2B;;AAClD,MAAKA,MAAM,KAAK,OAAhB,EAA0B;AACzB,WAAO,4BAAC,yCAAD;AAAwB,MAAA,QAAQ,EAAGF;AAAnC,MAAP;AACA;;AAED,SACC,qDACC,4BAAC,gCAAD;AAAe,IAAA,EAAE,EAAGC,EAApB;AAAyB,IAAA,MAAM,EAAGC;AAAlC,IADD,EAEC,4BAAC,oCAAD;AAAmB,IAAA,EAAE,EAAGD,EAAxB;AAA6B,IAAA,QAAQ,EAAGD;AAAxC,IAFD,CADD;AAMA;;AAED,SAASG,qBAAT,QAAoE;AAAA,MAApC;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA;AAAjB,GAAoC;AACnE,QAAMC,cAAc,GAAG,CAAE,4BAAYD,cAAZ,CAAzB;AACA,QAAME,WAAW,GAChB,4BAAa,GAAGH,aAAe,SAA/B,KAA6CP,WAD9C;AAEA,QAAMW,YAAY,GACjB,4BAAa,GAAGJ,aAAe,QAA/B,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O,4BAAC,cAAD,EAAqB4B,KAArB,CAAP;AACA;;AAED,QAAM7B,EAAE,GAAI,cAAc,4BAAekD,cAAf,CAAiC,EAA3D,CAXkC,CAalC;AACA;AACA;;AACA,QAAME,cAAc,GAAGf,aAAa,CAClC,2BAA2BrC,EAAI,EADG,EAEnCmD,cAFmC,CAApC;AAKA,QAAME,SAAS,GAAG,yBAAYxB,KAAZ,aAAYA,KAAZ,uBAAYA,KAAK,CAAEwB,SAAnB,EAA8BrD,EAA9B,CAAlB;AAEA,QAAMsD,OAAO,GAAG,yBAAYC,mBAAUC,wBAAtB,CAAhB;AAEA,SACC,qDACGF,OAAO,IACR,2BACC,4BAAC,aAAD;AACC,IAAA,QAAQ,EAAGF,cADZ;AAEC,IAAA,EAAE,EAAGpD,EAFN;AAGC,IAAA,MAAM,EAAGC;AAHV,IADD,EAMCqD,OAND,CAFF,EAUC,4BAAC,cAAD,6BAAqBzB,KAArB;AAA6B,IAAA,SAAS,EAAGwB;AAAzC,KAVD,CADD;AAcA,CAxCwB,EAyCzB,mBAzCyB,CAA1B;AA4CA,sBACC,0BADD,EAEC,oCAFD,EAGC/B,oBAHD;AAKA,sBACC,kBADD,EAEC,0CAFD,EAGCK,mBAHD;AAKA,sBACC,uBADD,EAEC,iCAFD,EAGCsB,iBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useMemo, useContext, createPortal } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockControls,\n\t__experimentalDuotoneControl as DuotoneControl,\n\tuseSetting,\n} from '../components';\nimport BlockList from '../components/block-list';\nimport {\n\t__unstableDuotoneFilter as DuotoneFilter,\n\t__unstableDuotoneStylesheet as DuotoneStylesheet,\n\t__unstableDuotoneUnsetStylesheet as DuotoneUnsetStylesheet,\n} from '../components/duotone';\nimport { store as blockEditorStore } from '../store';\n\nconst EMPTY_ARRAY = [];\n\nextend( [ namesPlugin ] );\n\n/**\n * SVG and stylesheet needed for rendering the duotone filter.\n *\n * @param {Object} props Duotone props.\n * @param {string} props.selector Selector to apply the filter to.\n * @param {string} props.id Unique id for this duotone filter.\n * @param {string[]|\"unset\"} props.colors Array of RGB color strings ordered from dark to light.\n *\n * @return {WPElement} Duotone element.\n */\nfunction InlineDuotone( { selector, id, colors } ) {\n\tif ( colors === 'unset' ) {\n\t\treturn <DuotoneUnsetStylesheet selector={ selector } />;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<DuotoneFilter id={ id } colors={ colors } />\n\t\t\t<DuotoneStylesheet id={ id } selector={ selector } />\n\t\t</>\n\t);\n}\n\nfunction useMultiOriginPresets( { presetSetting, defaultSetting } ) {\n\tconst disableDefault = ! useSetting( defaultSetting );\n\tconst userPresets =\n\t\tuseSetting( `${ presetSetting }.custom` ) || EMPTY_ARRAY;\n\tconst themePresets =\n\t\tuseSetting( `${ presetSetting }.theme` ) || EMPTY_ARRAY;\n\tconst defaultPresets =\n\t\tuseSetting( `${ presetSetting }.default` ) || EMPTY_ARRAY;\n\treturn useMemo(\n\t\t() => [\n\t\t\t...userPresets,\n\t\t\t...themePresets,\n\t\t\t...( disableDefault ? EMPTY_ARRAY : defaultPresets ),\n\t\t],\n\t\t[ disableDefault, userPresets, themePresets, defaultPresets ]\n\t);\n}\n\nfunction DuotonePanel( { attributes, setAttributes } ) {\n\tconst style = attributes?.style;\n\tconst duotone = style?.color?.duotone;\n\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\tconst colorPalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.palette',\n\t\tdefaultSetting: 'color.defaultPalette',\n\t} );\n\tconst disableCustomColors = ! useSetting( 'color.custom' );\n\tconst disableCustomDuotone =\n\t\t! useSetting( 'color.customDuotone' ) ||\n\t\t( colorPalette?.length === 0 && disableCustomColors );\n\n\tif ( duotonePalette?.length === 0 && disableCustomDuotone ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t<DuotoneControl\n\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\tvalue={ duotone }\n\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t...style,\n\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t...style?.color,\n\t\t\t\t\t\t\tduotone: newDuotone,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tsetAttributes( { style: newStyle } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `duotone` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addDuotoneAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, 'color.__experimentalDuotone' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default\n\t// 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 * Override the default edit UI to include toolbar controls for duotone if the\n * block supports duotone.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst hasDuotoneSupport = hasBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\t\tconst isContentLocked = useSelect(\n\t\t\t( select ) => {\n\t\t\t\treturn select(\n\t\t\t\t\tblockEditorStore\n\t\t\t\t).__unstableGetContentLockingParent( props.clientId );\n\t\t\t},\n\t\t\t[ props.clientId ]\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ hasDuotoneSupport && ! isContentLocked && (\n\t\t\t\t\t<DuotonePanel { ...props } />\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneControls'\n);\n\n/**\n * Function that scopes a selector with another one. This works a bit like\n * SCSS nesting except the `&` operator isn't supported.\n *\n * @example\n * ```js\n * const scope = '.a, .b .c';\n * const selector = '> .x, .y';\n * const merged = scopeSelector( scope, selector );\n * // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'\n * ```\n *\n * @param {string} scope Selector to scope to.\n * @param {string} selector Original selector.\n *\n * @return {string} Scoped selector.\n */\nfunction scopeSelector( scope, selector ) {\n\tconst scopes = scope.split( ',' );\n\tconst selectors = selector.split( ',' );\n\n\tconst selectorsScoped = [];\n\tscopes.forEach( ( outer ) => {\n\t\tselectors.forEach( ( inner ) => {\n\t\t\tselectorsScoped.push( `${ outer.trim() } ${ inner.trim() }` );\n\t\t} );\n\t} );\n\n\treturn selectorsScoped.join( ', ' );\n}\n\n/**\n * Override the default block element to include duotone styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst duotoneSupport = getBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\t\tconst colors = props?.attributes?.style?.color?.duotone;\n\n\t\tif ( ! duotoneSupport || ! colors ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst id = `wp-duotone-${ useInstanceId( BlockListBlock ) }`;\n\n\t\t// Extra .editor-styles-wrapper specificity is needed in the editor\n\t\t// since we're not using inline styles to apply the filter. We need to\n\t\t// override duotone applied by global styles and theme.json.\n\t\tconst selectorsGroup = scopeSelector(\n\t\t\t`.editor-styles-wrapper .${ id }`,\n\t\t\tduotoneSupport\n\t\t);\n\n\t\tconst className = classnames( props?.className, id );\n\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ element &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<InlineDuotone\n\t\t\t\t\t\t\tselector={ selectorsGroup }\n\t\t\t\t\t\t\tid={ id }\n\t\t\t\t\t\t\tcolors={ colors }\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 { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/duotone/add-attributes',\n\taddDuotoneAttributes\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/duotone/with-editor-controls',\n\twithDuotoneControls\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/duotone/with-styles',\n\twithDuotoneStyles\n);\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/duotone.js"],"names":["EMPTY_ARRAY","namesPlugin","InlineDuotone","selector","id","colors","useMultiOriginPresets","presetSetting","defaultSetting","disableDefault","userPresets","themePresets","defaultPresets","getColorsFromDuotonePreset","duotone","duotonePalette","preset","find","slug","undefined","getDuotonePresetFromColors","Array","isArray","duotonePreset","every","val","index","DuotonePanel","attributes","setAttributes","style","duotoneStyle","color","colorPalette","disableCustomColors","disableCustomDuotone","length","duotonePresetOrColors","newDuotone","maybePreset","newStyle","addDuotoneAttributes","settings","Object","assign","type","withDuotoneControls","BlockEdit","props","hasDuotoneSupport","name","isContentLocked","select","blockEditorStore","__unstableGetContentLockingParent","clientId","scopeSelector","scope","scopes","split","selectors","selectorsScoped","forEach","outer","inner","push","trim","join","BlockDuotoneStyles","element","BlockList","__unstableElementContext","duotoneSupportSelectors","selectorsGroup","withDuotoneStyles","BlockListBlock","duotoneSupport","className"],"mappings":";;;;;;;;;;AAaA;;;;AAVA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AAKA;;AAKA;;AACA;;AAKA;;AA9BA;AACA;AACA;;AAKA;AACA;AACA;;AAOA;AACA;AACA;AAcA,MAAMA,WAAW,GAAG,EAApB;AAEA,oBAAQ,CAAEC,cAAF,CAAR;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,aAAT,OAAmD;AAAA,MAA3B;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,EAAZ;AAAgBC,IAAAA;AAAhB,GAA2B;;AAClD,MAAKA,MAAM,KAAK,OAAhB,EAA0B;AACzB,WAAO,4BAAC,yCAAD;AAAwB,MAAA,QAAQ,EAAGF;AAAnC,MAAP;AACA;;AAED,SACC,qDACC,4BAAC,gCAAD;AAAe,IAAA,EAAE,EAAGC,EAApB;AAAyB,IAAA,MAAM,EAAGC;AAAlC,IADD,EAEC,4BAAC,oCAAD;AAAmB,IAAA,EAAE,EAAGD,EAAxB;AAA6B,IAAA,QAAQ,EAAGD;AAAxC,IAFD,CADD;AAMA;;AAED,SAASG,qBAAT,QAAoE;AAAA,MAApC;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA;AAAjB,GAAoC;AACnE,QAAMC,cAAc,GAAG,CAAE,4BAAYD,cAAZ,CAAzB;AACA,QAAME,WAAW,GAChB,4BAAa,GAAGH,aAAe,SAA/B,KAA6CP,WAD9C;AAEA,QAAMW,YAAY,GACjB,4BAAa,GAAGJ,aAAe,QAA/B,KAA4CP,WAD7C;AAEA,QAAMY,cAAc,GACnB,4BAAa,GAAGL,aAAe,UAA/B,KAA8CP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3B;AAHN,IAFF,EAQC,4BAAC,cAAD,6BAAqB4C,KAArB;AAA6B,IAAA,SAAS,EAAG6B;AAAzC,KARD,CADD;AAYA,CA7BwB,EA8BzB,mBA9ByB,CAA1B;AAiCA,sBACC,0BADD,EAEC,oCAFD,EAGCpC,oBAHD;AAKA,sBACC,kBADD,EAEC,0CAFD,EAGCK,mBAHD;AAKA,sBACC,uBADD,EAEC,iCAFD,EAGC4B,iBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useMemo, useContext, createPortal } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockControls,\n\t__experimentalDuotoneControl as DuotoneControl,\n\tuseSetting,\n} from '../components';\nimport BlockList from '../components/block-list';\nimport {\n\t__unstableDuotoneFilter as DuotoneFilter,\n\t__unstableDuotoneStylesheet as DuotoneStylesheet,\n\t__unstableDuotoneUnsetStylesheet as DuotoneUnsetStylesheet,\n} from '../components/duotone';\nimport { store as blockEditorStore } from '../store';\n\nconst EMPTY_ARRAY = [];\n\nextend( [ namesPlugin ] );\n\n/**\n * SVG and stylesheet needed for rendering the duotone filter.\n *\n * @param {Object} props Duotone props.\n * @param {string} props.selector Selector to apply the filter to.\n * @param {string} props.id Unique id for this duotone filter.\n * @param {string[]|\"unset\"} props.colors Array of RGB color strings ordered from dark to light.\n *\n * @return {WPElement} Duotone element.\n */\nfunction InlineDuotone( { selector, id, colors } ) {\n\tif ( colors === 'unset' ) {\n\t\treturn <DuotoneUnsetStylesheet selector={ selector } />;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<DuotoneFilter id={ id } colors={ colors } />\n\t\t\t<DuotoneStylesheet id={ id } selector={ selector } />\n\t\t</>\n\t);\n}\n\nfunction useMultiOriginPresets( { presetSetting, defaultSetting } ) {\n\tconst disableDefault = ! useSetting( defaultSetting );\n\tconst userPresets =\n\t\tuseSetting( `${ presetSetting }.custom` ) || EMPTY_ARRAY;\n\tconst themePresets =\n\t\tuseSetting( `${ presetSetting }.theme` ) || EMPTY_ARRAY;\n\tconst defaultPresets =\n\t\tuseSetting( `${ presetSetting }.default` ) || EMPTY_ARRAY;\n\treturn useMemo(\n\t\t() => [\n\t\t\t...userPresets,\n\t\t\t...themePresets,\n\t\t\t...( disableDefault ? EMPTY_ARRAY : defaultPresets ),\n\t\t],\n\t\t[ disableDefault, userPresets, themePresets, defaultPresets ]\n\t);\n}\n\nexport function getColorsFromDuotonePreset( duotone, duotonePalette ) {\n\tif ( ! duotone ) {\n\t\treturn;\n\t}\n\tconst preset = duotonePalette?.find( ( { slug } ) => {\n\t\treturn duotone === `var:preset|duotone|${ slug }`;\n\t} );\n\n\treturn preset ? preset.colors : undefined;\n}\n\nexport function getDuotonePresetFromColors( colors, duotonePalette ) {\n\tif ( ! colors || ! Array.isArray( colors ) ) {\n\t\treturn;\n\t}\n\n\tconst preset = duotonePalette?.find( ( duotonePreset ) => {\n\t\treturn duotonePreset?.colors?.every(\n\t\t\t( val, index ) => val === colors[ index ]\n\t\t);\n\t} );\n\n\treturn preset ? `var:preset|duotone|${ preset.slug }` : undefined;\n}\n\nfunction DuotonePanel( { attributes, setAttributes } ) {\n\tconst style = attributes?.style;\n\tconst duotoneStyle = style?.color?.duotone;\n\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\tconst colorPalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.palette',\n\t\tdefaultSetting: 'color.defaultPalette',\n\t} );\n\tconst disableCustomColors = ! useSetting( 'color.custom' );\n\tconst disableCustomDuotone =\n\t\t! useSetting( 'color.customDuotone' ) ||\n\t\t( colorPalette?.length === 0 && disableCustomColors );\n\n\tif ( duotonePalette?.length === 0 && disableCustomDuotone ) {\n\t\treturn null;\n\t}\n\n\tconst duotonePresetOrColors = ! Array.isArray( duotoneStyle )\n\t\t? getColorsFromDuotonePreset( duotoneStyle, duotonePalette )\n\t\t: duotoneStyle;\n\n\treturn (\n\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t<DuotoneControl\n\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\tvalue={ duotonePresetOrColors }\n\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\tconst maybePreset = getDuotonePresetFromColors(\n\t\t\t\t\t\tnewDuotone,\n\t\t\t\t\t\tduotonePalette\n\t\t\t\t\t);\n\n\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t...style,\n\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t...style?.color,\n\t\t\t\t\t\t\tduotone: maybePreset ?? newDuotone, // use preset or fallback to custom colors.\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tsetAttributes( { style: newStyle } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `duotone` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addDuotoneAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, 'color.__experimentalDuotone' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default\n\t// 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 * Override the default edit UI to include toolbar controls for duotone if the\n * block supports duotone.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst hasDuotoneSupport = hasBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\t\tconst isContentLocked = useSelect(\n\t\t\t( select ) => {\n\t\t\t\treturn select(\n\t\t\t\t\tblockEditorStore\n\t\t\t\t).__unstableGetContentLockingParent( props.clientId );\n\t\t\t},\n\t\t\t[ props.clientId ]\n\t\t);\n\n\t\t// CAUTION: code added before this line will be executed\n\t\t// for all blocks, not just those that support duotone. Code added\n\t\t// above this line should be carefully evaluated for its impact on\n\t\t// performance.\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ hasDuotoneSupport && ! isContentLocked && (\n\t\t\t\t\t<DuotonePanel { ...props } />\n\t\t\t\t) }\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneControls'\n);\n\n/**\n * Function that scopes a selector with another one. This works a bit like\n * SCSS nesting except the `&` operator isn't supported.\n *\n * @example\n * ```js\n * const scope = '.a, .b .c';\n * const selector = '> .x, .y';\n * const merged = scopeSelector( scope, selector );\n * // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'\n * ```\n *\n * @param {string} scope Selector to scope to.\n * @param {string} selector Original selector.\n *\n * @return {string} Scoped selector.\n */\nfunction scopeSelector( scope, selector ) {\n\tconst scopes = scope.split( ',' );\n\tconst selectors = selector.split( ',' );\n\n\tconst selectorsScoped = [];\n\tscopes.forEach( ( outer ) => {\n\t\tselectors.forEach( ( inner ) => {\n\t\t\tselectorsScoped.push( `${ outer.trim() } ${ inner.trim() }` );\n\t\t} );\n\t} );\n\n\treturn selectorsScoped.join( ', ' );\n}\n\nfunction BlockDuotoneStyles( { name, duotoneStyle, id } ) {\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\n\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t// Portals cannot exist without a container.\n\t// Guard against empty Duotone styles.\n\tif ( ! element || ! duotoneStyle ) {\n\t\treturn null;\n\t}\n\n\tlet colors = duotoneStyle;\n\n\tif ( ! Array.isArray( colors ) && colors !== 'unset' ) {\n\t\tcolors = getColorsFromDuotonePreset( colors, duotonePalette );\n\t}\n\n\tconst duotoneSupportSelectors = getBlockSupport(\n\t\tname,\n\t\t'color.__experimentalDuotone'\n\t);\n\n\t// Extra .editor-styles-wrapper specificity is needed in the editor\n\t// since we're not using inline styles to apply the filter. We need to\n\t// override duotone applied by global styles and theme.json.\n\tconst selectorsGroup = scopeSelector(\n\t\t`.editor-styles-wrapper .${ id }`,\n\t\tduotoneSupportSelectors\n\t);\n\n\treturn createPortal(\n\t\t<InlineDuotone\n\t\t\tselector={ selectorsGroup }\n\t\t\tid={ id }\n\t\t\tcolors={ colors }\n\t\t/>,\n\t\telement\n\t);\n}\n\n/**\n * Override the default block element to include duotone styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst duotoneSupport = getBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\n\t\tconst id = `wp-duotone-${ useInstanceId( BlockListBlock ) }`;\n\t\tconst className = duotoneSupport\n\t\t\t? classnames( props?.className, id )\n\t\t\t: props?.className;\n\t\tconst duotoneStyle = props?.attributes?.style?.color?.duotone;\n\n\t\t// CAUTION: code added before this line will be executed\n\t\t// for all blocks, not just those that support duotone. Code added\n\t\t// above this line should be carefully evaluated for its impact on\n\t\t// performance.\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ duotoneSupport && duotoneStyle && (\n\t\t\t\t\t<BlockDuotoneStyles\n\t\t\t\t\t\tname={ props?.name }\n\t\t\t\t\t\tduotoneStyle={ duotoneStyle }\n\t\t\t\t\t\tid={ id }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/duotone/add-attributes',\n\taddDuotoneAttributes\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/duotone/with-editor-controls',\n\twithDuotoneControls\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/duotone/with-styles',\n\twithDuotoneStyles\n);\n"]}
|
package/build/hooks/gap.js
CHANGED
|
@@ -1,69 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
|
-
exports.GapEdit = GapEdit;
|
|
9
6
|
exports.getGapBoxControlValueFromStyle = getGapBoxControlValueFromStyle;
|
|
10
7
|
exports.getGapCSSValue = getGapCSSValue;
|
|
11
|
-
exports.hasGapSupport = hasGapSupport;
|
|
12
|
-
exports.hasGapValue = hasGapValue;
|
|
13
|
-
exports.resetGap = resetGap;
|
|
14
|
-
exports.useIsGapDisabled = useIsGapDisabled;
|
|
15
|
-
|
|
16
|
-
var _element = require("@wordpress/element");
|
|
17
|
-
|
|
18
|
-
var _i18n = require("@wordpress/i18n");
|
|
19
|
-
|
|
20
|
-
var _blocks = require("@wordpress/blocks");
|
|
21
|
-
|
|
22
|
-
var _components = require("@wordpress/components");
|
|
23
|
-
|
|
24
|
-
var _useBlockRefs = require("../components/block-list/use-block-props/use-block-refs");
|
|
25
8
|
|
|
26
9
|
var _utils = require("../components/spacing-sizes-control/utils");
|
|
27
10
|
|
|
28
|
-
var _spacingSizesControl = _interopRequireDefault(require("../components/spacing-sizes-control"));
|
|
29
|
-
|
|
30
|
-
var _useSetting = _interopRequireDefault(require("../components/use-setting"));
|
|
31
|
-
|
|
32
|
-
var _dimensions = require("./dimensions");
|
|
33
|
-
|
|
34
|
-
var _utils2 = require("./utils");
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* WordPress dependencies
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
11
|
/**
|
|
41
12
|
* Internal dependencies
|
|
42
13
|
*/
|
|
43
14
|
|
|
44
|
-
/**
|
|
45
|
-
* Determines if there is gap support.
|
|
46
|
-
*
|
|
47
|
-
* @param {string|Object} blockType Block name or Block Type object.
|
|
48
|
-
* @return {boolean} Whether there is support.
|
|
49
|
-
*/
|
|
50
|
-
function hasGapSupport(blockType) {
|
|
51
|
-
const support = (0, _blocks.getBlockSupport)(blockType, _dimensions.SPACING_SUPPORT_KEY);
|
|
52
|
-
return !!(true === support || support !== null && support !== void 0 && support.blockGap);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Checks if there is a current value in the gap block support attributes.
|
|
56
|
-
*
|
|
57
|
-
* @param {Object} props Block props.
|
|
58
|
-
* @return {boolean} Whether or not the block has a gap value set.
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
function hasGapValue(props) {
|
|
63
|
-
var _props$attributes$sty, _props$attributes$sty2;
|
|
64
|
-
|
|
65
|
-
return ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.spacing) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.blockGap) !== undefined;
|
|
66
|
-
}
|
|
67
15
|
/**
|
|
68
16
|
* Returns a BoxControl object value from a given blockGap style value.
|
|
69
17
|
* The string check is for backwards compatibility before Gutenberg supported
|
|
@@ -72,8 +20,6 @@ function hasGapValue(props) {
|
|
|
72
20
|
* @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.
|
|
73
21
|
* @return {Object|null} A value to pass to the BoxControl component.
|
|
74
22
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
77
23
|
function getGapBoxControlValueFromStyle(blockGapValue) {
|
|
78
24
|
if (!blockGapValue) {
|
|
79
25
|
return null;
|
|
@@ -106,152 +52,4 @@ function getGapCSSValue(blockGapValue) {
|
|
|
106
52
|
const column = (0, _utils.getSpacingPresetCssVar)(blockGapBoxControlValue === null || blockGapBoxControlValue === void 0 ? void 0 : blockGapBoxControlValue.left) || defaultValue;
|
|
107
53
|
return row === column ? row : `${row} ${column}`;
|
|
108
54
|
}
|
|
109
|
-
/**
|
|
110
|
-
* Resets the gap block support attribute. This can be used when disabling
|
|
111
|
-
* the gap support controls for a block via a progressive discovery panel.
|
|
112
|
-
*
|
|
113
|
-
* @param {Object} props Block props.
|
|
114
|
-
* @param {Object} props.attributes Block's attributes.
|
|
115
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
116
|
-
*/
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
function resetGap(_ref) {
|
|
120
|
-
let {
|
|
121
|
-
attributes = {},
|
|
122
|
-
setAttributes
|
|
123
|
-
} = _ref;
|
|
124
|
-
const {
|
|
125
|
-
style
|
|
126
|
-
} = attributes;
|
|
127
|
-
setAttributes({
|
|
128
|
-
style: { ...style,
|
|
129
|
-
spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing),
|
|
130
|
-
blockGap: undefined
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Custom hook that checks if gap settings have been disabled.
|
|
137
|
-
*
|
|
138
|
-
* @param {string} name The name of the block.
|
|
139
|
-
* @return {boolean} Whether the gap setting is disabled.
|
|
140
|
-
*/
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
function useIsGapDisabled() {
|
|
144
|
-
let {
|
|
145
|
-
name: blockName
|
|
146
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
147
|
-
const isDisabled = !(0, _useSetting.default)('spacing.blockGap');
|
|
148
|
-
const isInvalid = !(0, _dimensions.useIsDimensionsSupportValid)(blockName, 'blockGap');
|
|
149
|
-
return !hasGapSupport(blockName) || isDisabled || isInvalid;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Inspector control panel containing the gap related configuration
|
|
153
|
-
*
|
|
154
|
-
* @param {Object} props
|
|
155
|
-
*
|
|
156
|
-
* @return {WPElement} Gap edit element.
|
|
157
|
-
*/
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
function GapEdit(props) {
|
|
161
|
-
var _style$spacing;
|
|
162
|
-
|
|
163
|
-
const {
|
|
164
|
-
clientId,
|
|
165
|
-
attributes: {
|
|
166
|
-
style
|
|
167
|
-
},
|
|
168
|
-
name: blockName,
|
|
169
|
-
setAttributes
|
|
170
|
-
} = props;
|
|
171
|
-
const spacingSizes = (0, _useSetting.default)('spacing.spacingSizes');
|
|
172
|
-
const units = (0, _components.__experimentalUseCustomUnits)({
|
|
173
|
-
availableUnits: (0, _useSetting.default)('spacing.units') || ['%', 'px', 'em', 'rem', 'vw']
|
|
174
|
-
});
|
|
175
|
-
const sides = (0, _dimensions.useCustomSides)(blockName, 'blockGap');
|
|
176
|
-
const ref = (0, _useBlockRefs.__unstableUseBlockRef)(clientId);
|
|
177
|
-
|
|
178
|
-
if (useIsGapDisabled(props)) {
|
|
179
|
-
return null;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const splitOnAxis = sides && sides.some(side => _dimensions.AXIAL_SIDES.includes(side));
|
|
183
|
-
|
|
184
|
-
const onChange = next => {
|
|
185
|
-
var _window;
|
|
186
|
-
|
|
187
|
-
let blockGap = next; // If splitOnAxis activated we need to return a BoxControl object to the BoxControl component.
|
|
188
|
-
|
|
189
|
-
if (!!next && splitOnAxis) {
|
|
190
|
-
blockGap = { ...getGapBoxControlValueFromStyle(next)
|
|
191
|
-
};
|
|
192
|
-
} else if (next !== null && next !== void 0 && next.hasOwnProperty('top')) {
|
|
193
|
-
// If splitOnAxis is not enabled, treat the 'top' value as the shorthand gap value.
|
|
194
|
-
blockGap = next.top;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const newStyle = { ...style,
|
|
198
|
-
spacing: { ...(style === null || style === void 0 ? void 0 : style.spacing),
|
|
199
|
-
blockGap
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
setAttributes({
|
|
203
|
-
style: (0, _utils2.cleanEmptyObject)(newStyle)
|
|
204
|
-
}); // In Safari, changing the `gap` CSS value on its own will not trigger the layout
|
|
205
|
-
// to be recalculated / re-rendered. To force the updated gap to re-render, here
|
|
206
|
-
// we replace the block's node with itself.
|
|
207
|
-
|
|
208
|
-
const isSafari = ((_window = window) === null || _window === void 0 ? void 0 : _window.navigator.userAgent) && window.navigator.userAgent.includes('Safari') && !window.navigator.userAgent.includes('Chrome ') && !window.navigator.userAgent.includes('Chromium ');
|
|
209
|
-
|
|
210
|
-
if (ref.current && isSafari) {
|
|
211
|
-
var _ref$current$parentNo;
|
|
212
|
-
|
|
213
|
-
(_ref$current$parentNo = ref.current.parentNode) === null || _ref$current$parentNo === void 0 ? void 0 : _ref$current$parentNo.replaceChild(ref.current, ref.current);
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
const gapValue = getGapBoxControlValueFromStyle(style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.blockGap); // The BoxControl component expects a full complement of side values.
|
|
218
|
-
// Gap row and column values translate to top/bottom and left/right respectively.
|
|
219
|
-
|
|
220
|
-
const boxControlGapValue = splitOnAxis ? { ...gapValue,
|
|
221
|
-
right: gapValue === null || gapValue === void 0 ? void 0 : gapValue.left,
|
|
222
|
-
bottom: gapValue === null || gapValue === void 0 ? void 0 : gapValue.top
|
|
223
|
-
} : {
|
|
224
|
-
top: gapValue === null || gapValue === void 0 ? void 0 : gapValue.top
|
|
225
|
-
};
|
|
226
|
-
return _element.Platform.select({
|
|
227
|
-
web: (0, _element.createElement)(_element.Fragment, null, (!spacingSizes || (spacingSizes === null || spacingSizes === void 0 ? void 0 : spacingSizes.length) === 0) && (splitOnAxis ? (0, _element.createElement)(_components.__experimentalBoxControl, {
|
|
228
|
-
label: (0, _i18n.__)('Block spacing'),
|
|
229
|
-
min: 0,
|
|
230
|
-
onChange: onChange,
|
|
231
|
-
units: units,
|
|
232
|
-
sides: sides,
|
|
233
|
-
values: boxControlGapValue,
|
|
234
|
-
allowReset: false,
|
|
235
|
-
splitOnAxis: splitOnAxis
|
|
236
|
-
}) : (0, _element.createElement)(_components.__experimentalUnitControl, {
|
|
237
|
-
label: (0, _i18n.__)('Block spacing'),
|
|
238
|
-
__unstableInputWidth: "80px",
|
|
239
|
-
min: 0,
|
|
240
|
-
onChange: onChange,
|
|
241
|
-
units: units // Default to `row` for combined values.
|
|
242
|
-
,
|
|
243
|
-
value: boxControlGapValue
|
|
244
|
-
})), (spacingSizes === null || spacingSizes === void 0 ? void 0 : spacingSizes.length) > 0 && (0, _element.createElement)(_spacingSizesControl.default, {
|
|
245
|
-
values: boxControlGapValue,
|
|
246
|
-
onChange: onChange,
|
|
247
|
-
label: (0, _i18n.__)('Block spacing'),
|
|
248
|
-
sides: splitOnAxis ? sides : ['top'] // Use 'top' as the shorthand property in non-axial configurations.
|
|
249
|
-
,
|
|
250
|
-
units: units,
|
|
251
|
-
allowReset: false,
|
|
252
|
-
splitOnAxis: splitOnAxis
|
|
253
|
-
})),
|
|
254
|
-
native: null
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
55
|
//# sourceMappingURL=gap.js.map
|
package/build/hooks/gap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/gap.js"],"names":["hasGapSupport","blockType","support","SPACING_SUPPORT_KEY","blockGap","hasGapValue","props","attributes","style","spacing","undefined","getGapBoxControlValueFromStyle","blockGapValue","isValueString","top","left","getGapCSSValue","defaultValue","blockGapBoxControlValue","row","column","resetGap","setAttributes","useIsGapDisabled","name","blockName","isDisabled","isInvalid","GapEdit","clientId","spacingSizes","units","availableUnits","sides","ref","splitOnAxis","some","side","AXIAL_SIDES","includes","onChange","next","hasOwnProperty","newStyle","isSafari","window","navigator","userAgent","current","parentNode","replaceChild","gapValue","boxControlGapValue","right","bottom","Platform","select","web","length","native"],"mappings":";;;;;;;;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AASA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AAzBA;AACA;AACA;;AAUA;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAT,CAAwBC,SAAxB,EAAoC;AAC1C,QAAMC,OAAO,GAAG,6BAAiBD,SAAjB,EAA4BE,+BAA5B,CAAhB;AACA,SAAO,CAAC,EAAI,SAASD,OAAT,IAAoBA,OAApB,aAAoBA,OAApB,eAAoBA,OAAO,CAAEE,QAAjC,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,WAAT,CAAsBC,KAAtB,EAA8B;AAAA;;AACpC,SAAO,0BAAAA,KAAK,CAACC,UAAN,CAAiBC,KAAjB,0GAAwBC,OAAxB,kFAAiCL,QAAjC,MAA8CM,SAArD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,8BAAT,CAAyCC,aAAzC,EAAyD;AAC/D,MAAK,CAAEA,aAAP,EAAuB;AACtB,WAAO,IAAP;AACA;;AAED,QAAMC,aAAa,GAAG,OAAOD,aAAP,KAAyB,QAA/C;AACA,SAAO;AACNE,IAAAA,GAAG,EAAED,aAAa,GAAGD,aAAH,GAAmBA,aAAnB,aAAmBA,aAAnB,uBAAmBA,aAAa,CAAEE,GAD9C;AAENC,IAAAA,IAAI,EAAEF,aAAa,GAAGD,aAAH,GAAmBA,aAAnB,aAAmBA,aAAnB,uBAAmBA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\n */\nimport { __ } from '@wordpress/i18n';\nimport { Platform } from '@wordpress/element';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport {\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalBoxControl as BoxControl,\n\t__experimentalUnitControl as UnitControl,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { __unstableUseBlockRef as useBlockRef } from '../components/block-list/use-block-props/use-block-refs';\nimport { getSpacingPresetCssVar } from '../components/spacing-sizes-control/utils';\nimport SpacingSizesControl from '../components/spacing-sizes-control';\nimport useSetting from '../components/use-setting';\nimport {\n\tAXIAL_SIDES,\n\tSPACING_SUPPORT_KEY,\n\tuseCustomSides,\n\tuseIsDimensionsSupportValid,\n} from './dimensions';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Determines if there is gap support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n * @return {boolean} Whether there is support.\n */\nexport function hasGapSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, SPACING_SUPPORT_KEY );\n\treturn !! ( true === support || support?.blockGap );\n}\n\n/**\n * Checks if there is a current value in the gap block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a gap value set.\n */\nexport function hasGapValue( props ) {\n\treturn props.attributes.style?.spacing?.blockGap !== undefined;\n}\n\n/**\n * Returns a BoxControl object value from a given blockGap style value.\n * The string check is for backwards compatibility before Gutenberg supported\n * split gap values (row and column) and the value was a string n + unit.\n *\n * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.\n * @return {Object|null} A value to pass to the BoxControl component.\n */\nexport function getGapBoxControlValueFromStyle( blockGapValue ) {\n\tif ( ! blockGapValue ) {\n\t\treturn null;\n\t}\n\n\tconst isValueString = typeof blockGapValue === 'string';\n\treturn {\n\t\ttop: isValueString ? blockGapValue : blockGapValue?.top,\n\t\tleft: isValueString ? blockGapValue : blockGapValue?.left,\n\t};\n}\n\n/**\n * Returns a CSS value for the `gap` property from a given blockGap style.\n *\n * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.\n * @param {string?} defaultValue A default gap value.\n * @return {string|null} The concatenated gap value (row and column).\n */\nexport function getGapCSSValue( blockGapValue, defaultValue = '0' ) {\n\tconst blockGapBoxControlValue =\n\t\tgetGapBoxControlValueFromStyle( blockGapValue );\n\tif ( ! blockGapBoxControlValue ) {\n\t\treturn null;\n\t}\n\n\tconst row =\n\t\tgetSpacingPresetCssVar( blockGapBoxControlValue?.top ) || defaultValue;\n\tconst column =\n\t\tgetSpacingPresetCssVar( blockGapBoxControlValue?.left ) || defaultValue;\n\n\treturn row === column ? row : `${ row } ${ column }`;\n}\n\n/**\n * Resets the gap block support attribute. This can be used when disabling\n * the gap support controls for a block via a progressive discovery panel.\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 resetGap( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: {\n\t\t\t...style,\n\t\t\tspacing: {\n\t\t\t\t...style?.spacing,\n\t\t\t\tblockGap: undefined,\n\t\t\t},\n\t\t},\n\t} );\n}\n\n/**\n * Custom hook that checks if gap settings have been disabled.\n *\n * @param {string} name The name of the block.\n * @return {boolean} Whether the gap setting is disabled.\n */\nexport function useIsGapDisabled( { name: blockName } = {} ) {\n\tconst isDisabled = ! useSetting( 'spacing.blockGap' );\n\tconst isInvalid = ! useIsDimensionsSupportValid( blockName, 'blockGap' );\n\n\treturn ! hasGapSupport( blockName ) || isDisabled || isInvalid;\n}\n\n/**\n * Inspector control panel containing the gap related configuration\n *\n * @param {Object} props\n *\n * @return {WPElement} Gap edit element.\n */\nexport function GapEdit( props ) {\n\tconst {\n\t\tclientId,\n\t\tattributes: { style },\n\t\tname: blockName,\n\t\tsetAttributes,\n\t} = props;\n\n\tconst spacingSizes = useSetting( 'spacing.spacingSizes' );\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [\n\t\t\t'%',\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vw',\n\t\t],\n\t} );\n\tconst sides = useCustomSides( blockName, 'blockGap' );\n\tconst ref = useBlockRef( clientId );\n\n\tif ( useIsGapDisabled( props ) ) {\n\t\treturn null;\n\t}\n\n\tconst splitOnAxis =\n\t\tsides && sides.some( ( side ) => AXIAL_SIDES.includes( side ) );\n\n\tconst onChange = ( next ) => {\n\t\tlet blockGap = next;\n\n\t\t// If splitOnAxis activated we need to return a BoxControl object to the BoxControl component.\n\t\tif ( !! next && splitOnAxis ) {\n\t\t\tblockGap = { ...getGapBoxControlValueFromStyle( next ) };\n\t\t} else if ( next?.hasOwnProperty( 'top' ) ) {\n\t\t\t// If splitOnAxis is not enabled, treat the 'top' value as the shorthand gap value.\n\t\t\tblockGap = next.top;\n\t\t}\n\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tspacing: {\n\t\t\t\t...style?.spacing,\n\t\t\t\tblockGap,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\n\t\t// In Safari, changing the `gap` CSS value on its own will not trigger the layout\n\t\t// to be recalculated / re-rendered. To force the updated gap to re-render, here\n\t\t// we replace the block's node with itself.\n\t\tconst isSafari =\n\t\t\twindow?.navigator.userAgent &&\n\t\t\twindow.navigator.userAgent.includes( 'Safari' ) &&\n\t\t\t! window.navigator.userAgent.includes( 'Chrome ' ) &&\n\t\t\t! window.navigator.userAgent.includes( 'Chromium ' );\n\n\t\tif ( ref.current && isSafari ) {\n\t\t\tref.current.parentNode?.replaceChild( ref.current, ref.current );\n\t\t}\n\t};\n\n\tconst gapValue = getGapBoxControlValueFromStyle( style?.spacing?.blockGap );\n\n\t// The BoxControl component expects a full complement of side values.\n\t// Gap row and column values translate to top/bottom and left/right respectively.\n\tconst boxControlGapValue = splitOnAxis\n\t\t? {\n\t\t\t\t...gapValue,\n\t\t\t\tright: gapValue?.left,\n\t\t\t\tbottom: gapValue?.top,\n\t\t }\n\t\t: {\n\t\t\t\ttop: gapValue?.top,\n\t\t };\n\n\treturn Platform.select( {\n\t\tweb: (\n\t\t\t<>\n\t\t\t\t{ ( ! spacingSizes || spacingSizes?.length === 0 ) &&\n\t\t\t\t\t( splitOnAxis ? (\n\t\t\t\t\t\t<BoxControl\n\t\t\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t\tsides={ sides }\n\t\t\t\t\t\t\tvalues={ boxControlGapValue }\n\t\t\t\t\t\t\tallowReset={ false }\n\t\t\t\t\t\t\tsplitOnAxis={ splitOnAxis }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t\t// Default to `row` for combined values.\n\t\t\t\t\t\t\tvalue={ boxControlGapValue }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t{ spacingSizes?.length > 0 && (\n\t\t\t\t\t<SpacingSizesControl\n\t\t\t\t\t\tvalues={ boxControlGapValue }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tlabel={ __( 'Block spacing' ) }\n\t\t\t\t\t\tsides={ splitOnAxis ? sides : [ 'top' ] } // Use 'top' as the shorthand property in non-axial configurations.\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\tallowReset={ false }\n\t\t\t\t\t\tsplitOnAxis={ splitOnAxis }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</>\n\t\t),\n\t\tnative: null,\n\t} );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/gap.js"],"names":["getGapBoxControlValueFromStyle","blockGapValue","isValueString","top","left","getGapCSSValue","defaultValue","blockGapBoxControlValue","row","column"],"mappings":";;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,8BAAT,CAAyCC,aAAzC,EAAyD;AAC/D,MAAK,CAAEA,aAAP,EAAuB;AACtB,WAAO,IAAP;AACA;;AAED,QAAMC,aAAa,GAAG,OAAOD,aAAP,KAAyB,QAA/C;AACA,SAAO;AACNE,IAAAA,GAAG,EAAED,aAAa,GAAGD,aAAH,GAAmBA,aAAnB,aAAmBA,aAAnB,uBAAmBA,aAAa,CAAEE,GAD9C;AAENC,IAAAA,IAAI,EAAEF,aAAa,GAAGD,aAAH,GAAmBA,aAAnB,aAAmBA,aAAnB,uBAAmBA,aAAa,CAAEG;AAF/C,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,cAAT,CAAyBJ,aAAzB,EAA6D;AAAA,MAArBK,YAAqB,uEAAN,GAAM;AACnE,QAAMC,uBAAuB,GAC5BP,8BAA8B,CAAEC,aAAF,CAD/B;;AAEA,MAAK,CAAEM,uBAAP,EAAiC;AAChC,WAAO,IAAP;AACA;;AAED,QAAMC,GAAG,GACR,mCAAwBD,uBAAxB,aAAwBA,uBAAxB,uBAAwBA,uBAAuB,CAAEJ,GAAjD,KAA0DG,YAD3D;AAEA,QAAMG,MAAM,GACX,mCAAwBF,uBAAxB,aAAwBA,uBAAxB,uBAAwBA,uBAAuB,CAAEH,IAAjD,KAA2DE,YAD5D;AAGA,SAAOE,GAAG,KAAKC,MAAR,GAAiBD,GAAjB,GAAwB,GAAGA,GAAK,IAAIC,MAAQ,EAAnD;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { getSpacingPresetCssVar } from '../components/spacing-sizes-control/utils';\n\n/**\n * Returns a BoxControl object value from a given blockGap style value.\n * The string check is for backwards compatibility before Gutenberg supported\n * split gap values (row and column) and the value was a string n + unit.\n *\n * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.\n * @return {Object|null} A value to pass to the BoxControl component.\n */\nexport function getGapBoxControlValueFromStyle( blockGapValue ) {\n\tif ( ! blockGapValue ) {\n\t\treturn null;\n\t}\n\n\tconst isValueString = typeof blockGapValue === 'string';\n\treturn {\n\t\ttop: isValueString ? blockGapValue : blockGapValue?.top,\n\t\tleft: isValueString ? blockGapValue : blockGapValue?.left,\n\t};\n}\n\n/**\n * Returns a CSS value for the `gap` property from a given blockGap style.\n *\n * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.\n * @param {string?} defaultValue A default gap value.\n * @return {string|null} The concatenated gap value (row and column).\n */\nexport function getGapCSSValue( blockGapValue, defaultValue = '0' ) {\n\tconst blockGapBoxControlValue =\n\t\tgetGapBoxControlValueFromStyle( blockGapValue );\n\tif ( ! blockGapBoxControlValue ) {\n\t\treturn null;\n\t}\n\n\tconst row =\n\t\tgetSpacingPresetCssVar( blockGapBoxControlValue?.top ) || defaultValue;\n\tconst column =\n\t\tgetSpacingPresetCssVar( blockGapBoxControlValue?.left ) || defaultValue;\n\n\treturn row === column ? row : `${ row } ${ column }`;\n}\n"]}
|
package/build/hooks/layout.js
CHANGED
|
@@ -57,7 +57,8 @@ const layoutBlockSupportKey = '__experimentalLayout';
|
|
|
57
57
|
/**
|
|
58
58
|
* Generates the utility classnames for the given block's layout attributes.
|
|
59
59
|
*
|
|
60
|
-
* @param { Object }
|
|
60
|
+
* @param { Object } blockAttributes Block attributes.
|
|
61
|
+
* @param { string } blockName Block name.
|
|
61
62
|
*
|
|
62
63
|
* @return { Array } Array of CSS classname strings.
|
|
63
64
|
*/
|
|
@@ -65,7 +66,8 @@ const layoutBlockSupportKey = '__experimentalLayout';
|
|
|
65
66
|
function useLayoutClasses() {
|
|
66
67
|
var _globalLayoutSettings, _globalLayoutSettings2;
|
|
67
68
|
|
|
68
|
-
let
|
|
69
|
+
let blockAttributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
70
|
+
let blockName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
69
71
|
const rootPaddingAlignment = (0, _data.useSelect)(select => {
|
|
70
72
|
var _getSettings$__experi;
|
|
71
73
|
|
|
@@ -75,16 +77,12 @@ function useLayoutClasses() {
|
|
|
75
77
|
return (_getSettings$__experi = getSettings().__experimentalFeatures) === null || _getSettings$__experi === void 0 ? void 0 : _getSettings$__experi.useRootPaddingAwareAlignments;
|
|
76
78
|
}, []);
|
|
77
79
|
const globalLayoutSettings = (0, _useSetting.default)('layout') || {};
|
|
78
|
-
const {
|
|
79
|
-
attributes = {},
|
|
80
|
-
name
|
|
81
|
-
} = block;
|
|
82
80
|
const {
|
|
83
81
|
layout
|
|
84
|
-
} =
|
|
82
|
+
} = blockAttributes;
|
|
85
83
|
const {
|
|
86
84
|
default: defaultBlockLayout
|
|
87
|
-
} = (0, _blocks.getBlockSupport)(
|
|
85
|
+
} = (0, _blocks.getBlockSupport)(blockName, layoutBlockSupportKey) || {};
|
|
88
86
|
const usedLayout = layout !== null && layout !== void 0 && layout.inherit || layout !== null && layout !== void 0 && layout.contentSize || layout !== null && layout !== void 0 && layout.wideSize ? { ...layout,
|
|
89
87
|
type: 'constrained'
|
|
90
88
|
} : layout || defaultBlockLayout || {};
|
|
@@ -93,7 +91,9 @@ function useLayoutClasses() {
|
|
|
93
91
|
if (globalLayoutSettings !== null && globalLayoutSettings !== void 0 && (_globalLayoutSettings = globalLayoutSettings.definitions) !== null && _globalLayoutSettings !== void 0 && (_globalLayoutSettings2 = _globalLayoutSettings[(usedLayout === null || usedLayout === void 0 ? void 0 : usedLayout.type) || 'default']) !== null && _globalLayoutSettings2 !== void 0 && _globalLayoutSettings2.className) {
|
|
94
92
|
var _globalLayoutSettings3, _globalLayoutSettings4;
|
|
95
93
|
|
|
96
|
-
|
|
94
|
+
const baseClassName = globalLayoutSettings === null || globalLayoutSettings === void 0 ? void 0 : (_globalLayoutSettings3 = globalLayoutSettings.definitions) === null || _globalLayoutSettings3 === void 0 ? void 0 : (_globalLayoutSettings4 = _globalLayoutSettings3[(usedLayout === null || usedLayout === void 0 ? void 0 : usedLayout.type) || 'default']) === null || _globalLayoutSettings4 === void 0 ? void 0 : _globalLayoutSettings4.className;
|
|
95
|
+
const compoundClassName = `wp-block-${blockName.split('/').pop()}-${baseClassName}`;
|
|
96
|
+
layoutClassnames.push(baseClassName, compoundClassName);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
if ((usedLayout !== null && usedLayout !== void 0 && usedLayout.inherit || usedLayout !== null && usedLayout !== void 0 && usedLayout.contentSize || (usedLayout === null || usedLayout === void 0 ? void 0 : usedLayout.type) === 'constrained') && rootPaddingAlignment) {
|
|
@@ -117,8 +117,9 @@ function useLayoutClasses() {
|
|
|
117
117
|
/**
|
|
118
118
|
* Generates a CSS rule with the given block's layout styles.
|
|
119
119
|
*
|
|
120
|
-
* @param { Object }
|
|
121
|
-
* @param { string }
|
|
120
|
+
* @param { Object } blockAttributes Block attributes.
|
|
121
|
+
* @param { string } blockName Block name.
|
|
122
|
+
* @param { string } selector A selector to use in generating the CSS rule.
|
|
122
123
|
*
|
|
123
124
|
* @return { string } CSS rule.
|
|
124
125
|
*/
|
|
@@ -127,16 +128,13 @@ function useLayoutClasses() {
|
|
|
127
128
|
function useLayoutStyles() {
|
|
128
129
|
var _fullLayoutType$getLa;
|
|
129
130
|
|
|
130
|
-
let
|
|
131
|
-
let
|
|
132
|
-
|
|
133
|
-
attributes = {},
|
|
134
|
-
name
|
|
135
|
-
} = block;
|
|
131
|
+
let blockAttributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
132
|
+
let blockName = arguments.length > 1 ? arguments[1] : undefined;
|
|
133
|
+
let selector = arguments.length > 2 ? arguments[2] : undefined;
|
|
136
134
|
const {
|
|
137
135
|
layout = {},
|
|
138
136
|
style = {}
|
|
139
|
-
} =
|
|
137
|
+
} = blockAttributes; // Update type for blocks using legacy layouts.
|
|
140
138
|
|
|
141
139
|
const usedLayout = layout !== null && layout !== void 0 && layout.inherit || layout !== null && layout !== void 0 && layout.contentSize || layout !== null && layout !== void 0 && layout.wideSize ? { ...layout,
|
|
142
140
|
type: 'constrained'
|
|
@@ -146,7 +144,7 @@ function useLayoutStyles() {
|
|
|
146
144
|
const blockGapSupport = (0, _useSetting.default)('spacing.blockGap');
|
|
147
145
|
const hasBlockGapSupport = blockGapSupport !== null;
|
|
148
146
|
const css = fullLayoutType === null || fullLayoutType === void 0 ? void 0 : (_fullLayoutType$getLa = fullLayoutType.getLayoutStyle) === null || _fullLayoutType$getLa === void 0 ? void 0 : _fullLayoutType$getLa.call(fullLayoutType, {
|
|
149
|
-
blockName
|
|
147
|
+
blockName,
|
|
150
148
|
selector,
|
|
151
149
|
layout,
|
|
152
150
|
layoutDefinitions: globalLayoutSettings === null || globalLayoutSettings === void 0 ? void 0 : globalLayoutSettings.definitions,
|
|
@@ -158,6 +156,7 @@ function useLayoutStyles() {
|
|
|
158
156
|
|
|
159
157
|
function LayoutPanel(_ref) {
|
|
160
158
|
let {
|
|
159
|
+
clientId,
|
|
161
160
|
setAttributes,
|
|
162
161
|
attributes,
|
|
163
162
|
name: blockName
|
|
@@ -166,12 +165,19 @@ function LayoutPanel(_ref) {
|
|
|
166
165
|
layout
|
|
167
166
|
} = attributes;
|
|
168
167
|
const defaultThemeLayout = (0, _useSetting.default)('layout');
|
|
169
|
-
const
|
|
168
|
+
const {
|
|
169
|
+
themeSupportsLayout,
|
|
170
|
+
isContentLocked
|
|
171
|
+
} = (0, _data.useSelect)(select => {
|
|
170
172
|
const {
|
|
171
|
-
getSettings
|
|
173
|
+
getSettings,
|
|
174
|
+
__unstableGetContentLockingParent
|
|
172
175
|
} = select(_store.store);
|
|
173
|
-
return
|
|
174
|
-
|
|
176
|
+
return {
|
|
177
|
+
themeSupportsLayout: getSettings().supportsLayout,
|
|
178
|
+
isContentLocked: __unstableGetContentLockingParent(clientId)
|
|
179
|
+
};
|
|
180
|
+
}, [clientId]);
|
|
175
181
|
const layoutBlockSupport = (0, _blocks.getBlockSupport)(blockName, layoutBlockSupportKey, {});
|
|
176
182
|
const {
|
|
177
183
|
allowSwitching,
|
|
@@ -222,6 +228,7 @@ function LayoutPanel(_ref) {
|
|
|
222
228
|
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components2.InspectorControls, null, (0, _element.createElement)(_components.PanelBody, {
|
|
223
229
|
title: (0, _i18n.__)('Layout')
|
|
224
230
|
}, showInheritToggle && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.ToggleControl, {
|
|
231
|
+
__nextHasNoMarginBottom: true,
|
|
225
232
|
className: "block-editor-hooks__toggle-control",
|
|
226
233
|
label: (0, _i18n.__)('Inner blocks use content width'),
|
|
227
234
|
checked: (layoutType === null || layoutType === void 0 ? void 0 : layoutType.name) === 'constrained' || hasContentSizeOrLegacySettings,
|
|
@@ -242,7 +249,7 @@ function LayoutPanel(_ref) {
|
|
|
242
249
|
layout: usedLayout,
|
|
243
250
|
onChange: onChangeLayout,
|
|
244
251
|
layoutBlockSupport: layoutBlockSupport
|
|
245
|
-
}))), !inherit && layoutType && (0, _element.createElement)(layoutType.toolBarControls, {
|
|
252
|
+
}))), !inherit && !isContentLocked && layoutType && (0, _element.createElement)(layoutType.toolBarControls, {
|
|
246
253
|
layout: usedLayout,
|
|
247
254
|
onChange: onChangeLayout,
|
|
248
255
|
layoutBlockSupport: layoutBlockSupport
|
|
@@ -324,8 +331,7 @@ exports.withInspectorControls = withInspectorControls;
|
|
|
324
331
|
const withLayoutStyles = (0, _compose.createHigherOrderComponent)(BlockListBlock => props => {
|
|
325
332
|
const {
|
|
326
333
|
name,
|
|
327
|
-
attributes
|
|
328
|
-
block
|
|
334
|
+
attributes
|
|
329
335
|
} = props;
|
|
330
336
|
const hasLayoutBlockSupport = (0, _blocks.hasBlockSupport)(name, layoutBlockSupportKey);
|
|
331
337
|
const disableLayoutStyles = (0, _data.useSelect)(select => {
|
|
@@ -347,7 +353,7 @@ const withLayoutStyles = (0, _compose.createHigherOrderComponent)(BlockListBlock
|
|
|
347
353
|
const usedLayout = layout !== null && layout !== void 0 && layout.inherit || layout !== null && layout !== void 0 && layout.contentSize || layout !== null && layout !== void 0 && layout.wideSize ? { ...layout,
|
|
348
354
|
type: 'constrained'
|
|
349
355
|
} : layout || defaultBlockLayout || {};
|
|
350
|
-
const layoutClasses = hasLayoutBlockSupport ? useLayoutClasses(
|
|
356
|
+
const layoutClasses = hasLayoutBlockSupport ? useLayoutClasses(attributes, name) : null; // Higher specificity to override defaults from theme.json.
|
|
351
357
|
|
|
352
358
|
const selector = `.wp-container-${id}.wp-container-${id}`;
|
|
353
359
|
const blockGapSupport = (0, _useSetting.default)('spacing.blockGap');
|