@wordpress/block-editor 11.3.6 → 11.5.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 +3 -1
- package/build/components/block-lock/modal.js +1 -0
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-popover/inbetween.js +10 -33
- package/build/components/block-popover/inbetween.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-styles/index.js +2 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-types-list/index.native.js +2 -0
- package/build/components/block-types-list/index.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/colors-gradients/control.js +6 -3
- package/build/components/colors-gradients/control.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/font-appearance-control/index.js +0 -3
- package/build/components/font-appearance-control/index.js.map +1 -1
- 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 +142 -45
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +38 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +434 -0
- package/build/components/global-styles/typography-panel.js.map +1 -0
- package/build/components/global-styles/use-global-styles-output.js +7 -3
- 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/iframe/index.js +17 -11
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js +2 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build/components/image-size-control/index.js +6 -11
- package/build/components/image-size-control/index.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/block-patterns-tab.js +9 -15
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.native.js +4 -1
- package/build/components/inserter/block-types-tab.native.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js +4 -1
- package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build/components/inserter/search-results.native.js +4 -1
- package/build/components/inserter/search-results.native.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 +55 -28
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/settings-drawer.js +72 -30
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/link-control/settings.js +53 -0
- package/build/components/link-control/settings.js.map +1 -0
- package/build/components/list-view/block.js +4 -2
- package/build/components/list-view/block.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/index.js +6 -1
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +5 -10
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +3 -2
- package/build/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +1 -0
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +7 -3
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/leaf-more-menu.js +24 -4
- package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build/components/off-canvas-editor/link-ui.js +2 -0
- package/build/components/off-canvas-editor/link-ui.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/index.js +9 -45
- 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/url-input/index.js +2 -2
- package/build/components/url-input/index.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/dimensions.js +78 -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/font-family.js +2 -76
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +3 -51
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/gap.js +0 -201
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +14 -5
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/line-height.js +0 -42
- package/build/hooks/line-height.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/typography.js +98 -128
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +75 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/flex.js +1 -0
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +24 -12
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +53 -47
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +22 -1
- package/build/store/selectors.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +36 -3
- package/build/utils/parse-css-unit-to-px.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-popover/inbetween.js +10 -33
- package/build-module/components/block-popover/inbetween.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-styles/index.js +2 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +2 -0
- package/build-module/components/block-types-list/index.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/colors-gradients/control.js +6 -3
- package/build-module/components/colors-gradients/control.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/font-appearance-control/index.js +2 -1
- package/build-module/components/font-appearance-control/index.js.map +1 -1
- 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 +138 -46
- 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 +415 -0
- package/build-module/components/global-styles/typography-panel.js.map +1 -0
- package/build-module/components/global-styles/use-global-styles-output.js +7 -3
- 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/iframe/index.js +17 -11
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js +2 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build-module/components/image-size-control/index.js +7 -12
- package/build-module/components/image-size-control/index.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/block-patterns-tab.js +9 -15
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.native.js +3 -1
- package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js +3 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build-module/components/inserter/search-results.native.js +3 -1
- package/build-module/components/inserter/search-results.native.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 +56 -28
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +68 -30
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/link-control/settings.js +44 -0
- package/build-module/components/link-control/settings.js.map +1 -0
- package/build-module/components/list-view/block.js +4 -2
- package/build-module/components/list-view/block.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/index.js +6 -1
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +5 -10
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +3 -2
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +1 -0
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +7 -3
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/leaf-more-menu.js +27 -7
- package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build-module/components/off-canvas-editor/link-ui.js +2 -0
- package/build-module/components/off-canvas-editor/link-ui.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/index.js +9 -45
- 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/url-input/index.js +2 -2
- package/build-module/components/url-input/index.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/dimensions.js +81 -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/font-family.js +3 -69
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +6 -47
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/gap.js +0 -182
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +14 -5
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/line-height.js +0 -38
- package/build-module/hooks/line-height.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/typography.js +97 -123
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +70 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/flex.js +1 -0
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +24 -12
- package/build-module/store/actions.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 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +36 -3
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-style/style-rtl.css +54 -64
- package/build-style/style.css +54 -64
- package/package.json +31 -31
- package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +24 -24
- 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 +15 -15
- package/src/components/block-popover/inbetween.js +21 -53
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/src/components/block-styles/index.js +5 -1
- package/src/components/block-types-list/index.native.js +2 -0
- package/src/components/child-layout-control/index.js +106 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/colors-gradients/control.js +3 -0
- package/src/components/date-format-picker/index.js +6 -8
- package/src/components/date-format-picker/style.scss +0 -5
- package/src/components/font-appearance-control/index.js +1 -1
- package/src/components/global-styles/dimensions-panel.js +627 -0
- package/src/components/global-styles/hooks.js +229 -66
- package/src/components/global-styles/index.js +9 -0
- package/src/components/global-styles/typography-panel.js +428 -0
- package/src/components/global-styles/use-global-styles-output.js +10 -5
- package/src/components/global-styles/utils.js +2 -0
- package/src/components/iframe/index.js +20 -18
- package/src/components/image-editor/aspect-ratio-dropdown.js +1 -0
- package/src/components/image-size-control/index.js +10 -12
- package/src/components/image-size-control/style.scss +3 -21
- package/src/components/index.native.js +5 -0
- package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
- package/src/components/inserter/block-patterns-tab.js +9 -23
- package/src/components/inserter/block-types-tab.native.js +2 -0
- package/src/components/inserter/reusable-blocks-tab.native.js +2 -0
- package/src/components/inserter/search-results.native.js +2 -0
- 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 +69 -34
- package/src/components/link-control/settings-drawer.js +85 -29
- package/src/components/link-control/settings.js +42 -0
- package/src/components/link-control/style.scss +63 -37
- package/src/components/link-control/test/index.js +347 -9
- package/src/components/list-view/block.js +7 -1
- package/src/components/list-view/expander.js +1 -0
- package/src/components/list-view/index.js +5 -0
- package/src/components/media-replace-flow/style.scss +7 -9
- package/src/components/media-replace-flow/test/index.js +1 -1
- package/src/components/off-canvas-editor/appender.js +13 -16
- package/src/components/off-canvas-editor/block-contents.js +2 -1
- package/src/components/off-canvas-editor/branch.js +1 -0
- package/src/components/off-canvas-editor/index.js +8 -2
- package/src/components/off-canvas-editor/leaf-more-menu.js +52 -15
- package/src/components/off-canvas-editor/link-ui.js +2 -0
- package/src/components/responsive-block-control/index.js +1 -0
- package/src/components/rich-text/index.js +8 -46
- package/src/components/rich-text/use-delete.js +59 -0
- package/src/components/rich-text/use-input-rules.js +13 -5
- package/src/components/url-input/index.js +3 -2
- package/src/components/url-popover/stories/index.js +1 -0
- package/src/components/writing-flow/use-selection-observer.js +5 -1
- package/src/hooks/align.js +1 -1
- package/src/hooks/dimensions.js +97 -269
- package/src/hooks/duotone.js +100 -30
- package/src/hooks/font-family.js +0 -58
- package/src/hooks/font-size.js +1 -36
- package/src/hooks/gap.js +0 -201
- package/src/hooks/index.js +1 -0
- package/src/hooks/layout.js +19 -6
- package/src/hooks/line-height.js +0 -33
- package/src/hooks/margin.js +1 -164
- package/src/hooks/padding.js +1 -163
- package/src/hooks/test/__snapshots__/align.native.js.snap +24 -24
- package/src/hooks/test/duotone.js +102 -0
- package/src/hooks/typography.js +112 -213
- package/src/hooks/utils.js +90 -0
- package/src/layouts/flex.js +1 -0
- package/src/store/actions.js +12 -4
- package/src/store/reducer.js +68 -43
- package/src/store/selectors.js +20 -1
- package/src/store/test/actions.js +4 -2
- package/src/utils/parse-css-unit-to-px.js +35 -5
- package/src/utils/test/parse-css-unit-to-px.js +12 -0
- package/build/hooks/child-layout.js +0 -213
- package/build/hooks/child-layout.js.map +0 -1
- package/build/hooks/font-appearance.js +0 -188
- package/build/hooks/font-appearance.js.map +0 -1
- package/build/hooks/letter-spacing.js +0 -129
- package/build/hooks/letter-spacing.js.map +0 -1
- package/build/hooks/min-height.js +0 -139
- package/build/hooks/min-height.js.map +0 -1
- package/build/hooks/text-decoration.js +0 -130
- package/build/hooks/text-decoration.js.map +0 -1
- package/build/hooks/text-transform.js +0 -130
- package/build/hooks/text-transform.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/font-appearance.js +0 -161
- package/build-module/hooks/font-appearance.js.map +0 -1
- package/build-module/hooks/letter-spacing.js +0 -107
- package/build-module/hooks/letter-spacing.js.map +0 -1
- package/build-module/hooks/min-height.js +0 -116
- package/build-module/hooks/min-height.js.map +0 -1
- package/build-module/hooks/text-decoration.js +0 -108
- package/build-module/hooks/text-decoration.js.map +0 -1
- package/build-module/hooks/text-transform.js +0 -108
- package/build-module/hooks/text-transform.js.map +0 -1
- package/src/hooks/child-layout.js +0 -195
- package/src/hooks/font-appearance.js +0 -146
- package/src/hooks/letter-spacing.js +0 -101
- package/src/hooks/min-height.js +0 -104
- package/src/hooks/text-decoration.js +0 -102
- package/src/hooks/text-transform.js +0 -101
|
@@ -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"],"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,iBAF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P;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\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');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/duotone.js"],"names":["classnames","extend","namesPlugin","getBlockSupport","hasBlockSupport","createHigherOrderComponent","useInstanceId","addFilter","useMemo","useContext","createPortal","useSelect","BlockControls","__experimentalDuotoneControl","DuotoneControl","useSetting","BlockList","__unstableDuotoneFilter","DuotoneFilter","__unstableDuotoneStylesheet","DuotoneStylesheet","__unstableDuotoneUnsetStylesheet","DuotoneUnsetStylesheet","store","blockEditorStore","EMPTY_ARRAY","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","__unstableGetContentLockingParent","clientId","scopeSelector","scope","scopes","split","selectors","selectorsScoped","forEach","outer","inner","push","trim","join","withDuotoneStyles","BlockListBlock","duotoneSupport","selectorsGroup","className","element","__unstableElementContext"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,MAAT,QAAuB,QAAvB;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AAEA;AACA;AACA;;AACA,SAASC,eAAT,EAA0BC,eAA1B,QAAiD,mBAAjD;AACA,SAASC,0BAAT,EAAqCC,aAArC,QAA0D,oBAA1D;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,OAAT,EAAkBC,UAAlB,EAA8BC,YAA9B,QAAkD,oBAAlD;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,SACCC,aADD,EAECC,4BAA4B,IAAIC,cAFjC,EAGCC,UAHD,QAIO,eAJP;AAKA,OAAOC,SAAP,MAAsB,0BAAtB;AACA,SACCC,uBAAuB,IAAIC,aAD5B,EAECC,2BAA2B,IAAIC,iBAFhC,EAGCC,gCAAgC,IAAIC,sBAHrC,QAIO,uBAJP;AAKA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,UAA1C;AAEA,MAAMC,WAAW,GAAG,EAApB;AAEAxB,MAAM,CAAE,CAAEC,WAAF,CAAF,CAAN;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASwB,aAAT,OAAmD;AAAA,MAA3B;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,EAAZ;AAAgBC,IAAAA;AAAhB,GAA2B;;AAClD,MAAKA,MAAM,KAAK,OAAhB,EAA0B;AACzB,WAAO,cAAC,sBAAD;AAAwB,MAAA,QAAQ,EAAGF;AAAnC,MAAP;AACA;;AAED,SACC,8BACC,cAAC,aAAD;AAAe,IAAA,EAAE,EAAGC,EAApB;AAAyB,IA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AER,oCAFQ,EAGR2C,oBAHQ,CAAT;AAKA3C,SAAS,CACR,kBADQ,EAER,0CAFQ,EAGRgD,mBAHQ,CAAT;AAKAhD,SAAS,CACR,uBADQ,EAER,iCAFQ,EAGRqE,iBAHQ,CAAT","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":["classnames","extend","namesPlugin","getBlockSupport","hasBlockSupport","createHigherOrderComponent","useInstanceId","addFilter","useMemo","useContext","createPortal","useSelect","BlockControls","__experimentalDuotoneControl","DuotoneControl","useSetting","BlockList","__unstableDuotoneFilter","DuotoneFilter","__unstableDuotoneStylesheet","DuotoneStylesheet","__unstableDuotoneUnsetStylesheet","DuotoneUnsetStylesheet","store","blockEditorStore","EMPTY_ARRAY","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","__unstableGetContentLockingParent","clientId","scopeSelector","scope","scopes","split","selectors","selectorsScoped","forEach","outer","inner","push","trim","join","BlockDuotoneStyles","element","__unstableElementContext","duotoneSupportSelectors","selectorsGroup","withDuotoneStyles","BlockListBlock","duotoneSupport","className"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,MAAT,QAAuB,QAAvB;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AAEA;AACA;AACA;;AACA,SAASC,eAAT,EAA0BC,eAA1B,QAAiD,mBAAjD;AACA,SAASC,0BAAT,EAAqCC,aAArC,QAA0D,oBA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G,uBAAiClB,OAAtD,CAVkC,CAYlC;AACA;AACA;AACA;;AACA,SACC,8BACG4D,cAAc,IAAI3C,YAAlB,IACD,cAAC,kBAAD;AACC,IAAA,IAAI,EAAGiB,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEE,IADf;AAEC,IAAA,YAAY,EAAGnB,YAFhB;AAGC,IAAA,EAAE,EAAG3B;AAHN,IAFF,EAQC,cAAC,cAAD,eAAqB4C,KAArB;AAA6B,IAAA,SAAS,EAAG2B;AAAzC,KARD,CADD;AAYA,CA7BkD,EA8BnD,mBA9BmD,CAApD;AAiCA5F,SAAS,CACR,0BADQ,EAER,oCAFQ,EAGR0D,oBAHQ,CAAT;AAKA1D,SAAS,CACR,kBADQ,EAER,0CAFQ,EAGR+D,mBAHQ,CAAT;AAKA/D,SAAS,CACR,uBADQ,EAER,iCAFQ,EAGRyF,iBAHQ,CAAT","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"]}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* External dependencies
|
|
5
3
|
*/
|
|
@@ -15,8 +13,6 @@ import TokenList from '@wordpress/token-list';
|
|
|
15
13
|
* Internal dependencies
|
|
16
14
|
*/
|
|
17
15
|
|
|
18
|
-
import useSetting from '../components/use-setting';
|
|
19
|
-
import FontFamilyControl from '../components/font-family';
|
|
20
16
|
import { shouldSkipSerialization } from './utils';
|
|
21
17
|
import { TYPOGRAPHY_SUPPORT_KEY } from './typography';
|
|
22
18
|
export const FONT_FAMILY_SUPPORT_KEY = 'typography.__experimentalFontFamily';
|
|
@@ -103,69 +99,6 @@ function addEditProps(settings) {
|
|
|
103
99
|
|
|
104
100
|
return settings;
|
|
105
101
|
}
|
|
106
|
-
|
|
107
|
-
export function FontFamilyEdit(_ref) {
|
|
108
|
-
var _fontFamilies$find;
|
|
109
|
-
|
|
110
|
-
let {
|
|
111
|
-
setAttributes,
|
|
112
|
-
attributes: {
|
|
113
|
-
fontFamily
|
|
114
|
-
}
|
|
115
|
-
} = _ref;
|
|
116
|
-
const fontFamilies = useSetting('typography.fontFamilies');
|
|
117
|
-
const value = fontFamilies === null || fontFamilies === void 0 ? void 0 : (_fontFamilies$find = fontFamilies.find(_ref2 => {
|
|
118
|
-
let {
|
|
119
|
-
slug
|
|
120
|
-
} = _ref2;
|
|
121
|
-
return fontFamily === slug;
|
|
122
|
-
})) === null || _fontFamilies$find === void 0 ? void 0 : _fontFamilies$find.fontFamily;
|
|
123
|
-
|
|
124
|
-
function onChange(newValue) {
|
|
125
|
-
const predefinedFontFamily = fontFamilies === null || fontFamilies === void 0 ? void 0 : fontFamilies.find(_ref3 => {
|
|
126
|
-
let {
|
|
127
|
-
fontFamily: f
|
|
128
|
-
} = _ref3;
|
|
129
|
-
return f === newValue;
|
|
130
|
-
});
|
|
131
|
-
setAttributes({
|
|
132
|
-
fontFamily: predefinedFontFamily === null || predefinedFontFamily === void 0 ? void 0 : predefinedFontFamily.slug
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return createElement(FontFamilyControl, {
|
|
137
|
-
className: "block-editor-hooks-font-family-control",
|
|
138
|
-
fontFamilies: fontFamilies,
|
|
139
|
-
value: value,
|
|
140
|
-
onChange: onChange,
|
|
141
|
-
size: "__unstable-large",
|
|
142
|
-
__nextHasNoMarginBottom: true
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Custom hook that checks if font-family functionality is disabled.
|
|
147
|
-
*
|
|
148
|
-
* @param {string} name The name of the block.
|
|
149
|
-
* @return {boolean} Whether setting is disabled.
|
|
150
|
-
*/
|
|
151
|
-
|
|
152
|
-
export function useIsFontFamilyDisabled(_ref4) {
|
|
153
|
-
let {
|
|
154
|
-
name
|
|
155
|
-
} = _ref4;
|
|
156
|
-
const fontFamilies = useSetting('typography.fontFamilies');
|
|
157
|
-
return !fontFamilies || fontFamilies.length === 0 || !hasBlockSupport(name, FONT_FAMILY_SUPPORT_KEY);
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Checks if there is a current value set for the font family block support.
|
|
161
|
-
*
|
|
162
|
-
* @param {Object} props Block props.
|
|
163
|
-
* @return {boolean} Whether or not the block has a font family value set.
|
|
164
|
-
*/
|
|
165
|
-
|
|
166
|
-
export function hasFontFamilyValue(props) {
|
|
167
|
-
return !!props.attributes.fontFamily;
|
|
168
|
-
}
|
|
169
102
|
/**
|
|
170
103
|
* Resets the font family block support attribute. This can be used when
|
|
171
104
|
* disabling the font family support controls for a block via a progressive
|
|
@@ -175,10 +108,11 @@ export function hasFontFamilyValue(props) {
|
|
|
175
108
|
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
176
109
|
*/
|
|
177
110
|
|
|
178
|
-
|
|
111
|
+
|
|
112
|
+
export function resetFontFamily(_ref) {
|
|
179
113
|
let {
|
|
180
114
|
setAttributes
|
|
181
|
-
} =
|
|
115
|
+
} = _ref;
|
|
182
116
|
setAttributes({
|
|
183
117
|
fontFamily: undefined
|
|
184
118
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/font-family.js"],"names":["kebabCase","addFilter","hasBlockSupport","TokenList","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/font-family.js"],"names":["kebabCase","addFilter","hasBlockSupport","TokenList","shouldSkipSerialization","TYPOGRAPHY_SUPPORT_KEY","FONT_FAMILY_SUPPORT_KEY","addAttributes","settings","attributes","fontFamily","Object","assign","type","addSaveProps","props","blockType","classes","className","add","newClassName","value","undefined","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","resetFontFamily","setAttributes"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;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Ad,CAA4B,cAA1D;AACA,QAAMU,YAAY,GAAGH,OAAO,CAACI,KAA7B;AACAN,EAAAA,KAAK,CAACG,SAAN,GAAkBE,YAAY,GAAGA,YAAH,GAAkBE,SAAhD;AAEA,SAAOP,KAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASQ,YAAT,CAAuBf,QAAvB,EAAkC;AACjC,MAAK,CAAEN,eAAe,CAAEM,QAAF,EAAYF,uBAAZ,CAAtB,EAA8D;AAC7D,WAAOE,QAAP;AACA;;AAED,QAAMgB,2BAA2B,GAAGhB,QAAQ,CAACiB,mBAA7C;;AACAjB,EAAAA,QAAQ,CAACiB,mBAAT,GAAiChB,UAAF,IAAkB;AAChD,QAAIM,KAAK,GAAG,EAAZ;;AACA,QAAKS,2BAAL,EAAmC;AAClCT,MAAAA,KAAK,GAAGS,2BAA2B,CAAEf,UAAF,CAAnC;AACA;;AACD,WAAOK,YAAY,CAAEC,KAAF,EAASP,QAAT,EAAmBC,UAAnB,CAAnB;AACA,GAND;;AAQA,SAAOD,QAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASkB,eAAT,OAA8C;AAAA,MAApB;AAAEC,IAAAA;AAAF,GAAoB;AACpDA,EAAAA,aAAa,CAAE;AAAEjB,IAAAA,UAAU,EAAEY;AAAd,GAAF,CAAb;AACA;AAEDrB,SAAS,CACR,0BADQ,EAER,8BAFQ,EAGRM,aAHQ,CAAT;AAMAN,SAAS,CACR,kCADQ,EAER,8BAFQ,EAGRa,YAHQ,CAAT;AAMAb,SAAS,CACR,0BADQ,EAER,8BAFQ,EAGRsB,YAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport TokenList from '@wordpress/token-list';\n\n/**\n * Internal dependencies\n */\nimport { shouldSkipSerialization } from './utils';\nimport { TYPOGRAPHY_SUPPORT_KEY } from './typography';\n\nexport const FONT_FAMILY_SUPPORT_KEY = 'typography.__experimentalFontFamily';\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `fontFamily` attribute.\n *\n * @param {Object} settings Original block settings\n * @return {Object} Filtered block settings\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, FONT_FAMILY_SUPPORT_KEY ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify a default value if needed.\n\tif ( ! settings.attributes.fontFamily ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tfontFamily: {\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 font family.\n *\n * @param {Object} props Additional props applied to save element\n * @param {Object} blockType Block type\n * @param {Object} attributes Block attributes\n * @return {Object} Filtered props applied to save element\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif ( ! hasBlockSupport( blockType, FONT_FAMILY_SUPPORT_KEY ) ) {\n\t\treturn props;\n\t}\n\n\tif (\n\t\tshouldSkipSerialization(\n\t\t\tblockType,\n\t\t\tTYPOGRAPHY_SUPPORT_KEY,\n\t\t\t'fontFamily'\n\t\t)\n\t) {\n\t\treturn props;\n\t}\n\n\tif ( ! attributes?.fontFamily ) {\n\t\treturn props;\n\t}\n\n\t// Use TokenList to dedupe classes.\n\tconst classes = new TokenList( props.className );\n\tclasses.add( `has-${ kebabCase( attributes?.fontFamily ) }-font-family` );\n\tconst newClassName = classes.value;\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Filters registered block settings to expand the block edit wrapper\n * by applying the desired styles and classnames.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addEditProps( settings ) {\n\tif ( ! hasBlockSupport( settings, FONT_FAMILY_SUPPORT_KEY ) ) {\n\t\treturn settings;\n\t}\n\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\n/**\n * Resets the font family block support attribute. This can be used when\n * disabling the font family support controls for a block via a progressive\n * discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetFontFamily( { setAttributes } ) {\n\tsetAttributes( { fontFamily: undefined } );\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/fontFamily/addAttribute',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/fontFamily/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/fontFamily/addEditProps',\n\taddEditProps\n);\n"]}
|
|
@@ -143,49 +143,6 @@ export function FontSizeEdit(props) {
|
|
|
143
143
|
__nextHasNoMarginBottom: true
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
|
-
/**
|
|
147
|
-
* Checks if there is a current value set for the font size block support.
|
|
148
|
-
*
|
|
149
|
-
* @param {Object} props Block props.
|
|
150
|
-
* @return {boolean} Whether or not the block has a font size value set.
|
|
151
|
-
*/
|
|
152
|
-
|
|
153
|
-
export function hasFontSizeValue(props) {
|
|
154
|
-
var _style$typography3;
|
|
155
|
-
|
|
156
|
-
const {
|
|
157
|
-
fontSize,
|
|
158
|
-
style
|
|
159
|
-
} = props.attributes;
|
|
160
|
-
return !!fontSize || !!(style !== null && style !== void 0 && (_style$typography3 = style.typography) !== null && _style$typography3 !== void 0 && _style$typography3.fontSize);
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Resets the font size block support attribute. This can be used when
|
|
164
|
-
* disabling the font size support controls for a block via a progressive
|
|
165
|
-
* discovery panel.
|
|
166
|
-
*
|
|
167
|
-
* @param {Object} props Block props.
|
|
168
|
-
* @param {Object} props.attributes Block's attributes.
|
|
169
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
170
|
-
*/
|
|
171
|
-
|
|
172
|
-
export function resetFontSize(_ref) {
|
|
173
|
-
let {
|
|
174
|
-
attributes = {},
|
|
175
|
-
setAttributes
|
|
176
|
-
} = _ref;
|
|
177
|
-
const {
|
|
178
|
-
style
|
|
179
|
-
} = attributes;
|
|
180
|
-
setAttributes({
|
|
181
|
-
fontSize: undefined,
|
|
182
|
-
style: cleanEmptyObject({ ...style,
|
|
183
|
-
typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
|
|
184
|
-
fontSize: undefined
|
|
185
|
-
}
|
|
186
|
-
})
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
146
|
/**
|
|
190
147
|
* Custom hook that checks if font-size settings have been disabled.
|
|
191
148
|
*
|
|
@@ -212,7 +169,7 @@ export function useIsFontSizeDisabled() {
|
|
|
212
169
|
*/
|
|
213
170
|
|
|
214
171
|
const withFontSizeInlineStyles = createHigherOrderComponent(BlockListBlock => props => {
|
|
215
|
-
var _style$
|
|
172
|
+
var _style$typography3, _style$typography4;
|
|
216
173
|
|
|
217
174
|
const fontSizes = useSetting('typography.fontSizes');
|
|
218
175
|
const {
|
|
@@ -227,11 +184,11 @@ const withFontSizeInlineStyles = createHigherOrderComponent(BlockListBlock => pr
|
|
|
227
184
|
// doesn't already have an inline font size,
|
|
228
185
|
// and does have a class to extract the font size from.
|
|
229
186
|
|
|
230
|
-
if (!hasBlockSupport(blockName, FONT_SIZE_SUPPORT_KEY) || shouldSkipSerialization(blockName, TYPOGRAPHY_SUPPORT_KEY, 'fontSize') || !fontSize || style !== null && style !== void 0 && (_style$
|
|
187
|
+
if (!hasBlockSupport(blockName, FONT_SIZE_SUPPORT_KEY) || shouldSkipSerialization(blockName, TYPOGRAPHY_SUPPORT_KEY, 'fontSize') || !fontSize || style !== null && style !== void 0 && (_style$typography3 = style.typography) !== null && _style$typography3 !== void 0 && _style$typography3.fontSize) {
|
|
231
188
|
return createElement(BlockListBlock, props);
|
|
232
189
|
}
|
|
233
190
|
|
|
234
|
-
const fontSizeValue = getFontSize(fontSizes, fontSize, style === null || style === void 0 ? void 0 : (_style$
|
|
191
|
+
const fontSizeValue = getFontSize(fontSizes, fontSize, style === null || style === void 0 ? void 0 : (_style$typography4 = style.typography) === null || _style$typography4 === void 0 ? void 0 : _style$typography4.fontSize).size;
|
|
235
192
|
const newProps = { ...props,
|
|
236
193
|
wrapperProps: { ...wrapperProps,
|
|
237
194
|
style: {
|
|
@@ -245,7 +202,8 @@ const withFontSizeInlineStyles = createHigherOrderComponent(BlockListBlock => pr
|
|
|
245
202
|
const MIGRATION_PATHS = {
|
|
246
203
|
fontSize: [['fontSize'], ['style', 'typography', 'fontSize']]
|
|
247
204
|
};
|
|
248
|
-
|
|
205
|
+
|
|
206
|
+
function addTransforms(result, source, index, results) {
|
|
249
207
|
const destinationBlockType = result.name;
|
|
250
208
|
const activeSupports = {
|
|
251
209
|
fontSize: hasBlockSupport(destinationBlockType, FONT_SIZE_SUPPORT_KEY)
|
|
@@ -267,6 +225,7 @@ export function addTransforms(result, source, index, results) {
|
|
|
267
225
|
* @param {Object} blockType Block settings object.
|
|
268
226
|
*/
|
|
269
227
|
|
|
228
|
+
|
|
270
229
|
function addEditPropsForFluidCustomFontSizes(blockType) {
|
|
271
230
|
if (!hasBlockSupport(blockType, FONT_SIZE_SUPPORT_KEY) || shouldSkipSerialization(blockType, TYPOGRAPHY_SUPPORT_KEY, 'fontSize')) {
|
|
272
231
|
return blockType;
|