@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,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.TEXT_TRANSFORM_SUPPORT_KEY = void 0;
|
|
9
|
-
exports.TextTransformEdit = TextTransformEdit;
|
|
10
|
-
exports.hasTextTransformValue = hasTextTransformValue;
|
|
11
|
-
exports.resetTextTransform = resetTextTransform;
|
|
12
|
-
exports.useIsTextTransformDisabled = useIsTextTransformDisabled;
|
|
13
|
-
|
|
14
|
-
var _element = require("@wordpress/element");
|
|
15
|
-
|
|
16
|
-
var _blocks = require("@wordpress/blocks");
|
|
17
|
-
|
|
18
|
-
var _textTransformControl = _interopRequireDefault(require("../components/text-transform-control"));
|
|
19
|
-
|
|
20
|
-
var _useSetting = _interopRequireDefault(require("../components/use-setting"));
|
|
21
|
-
|
|
22
|
-
var _utils = require("./utils");
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* WordPress dependencies
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Internal dependencies
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Key within block settings' supports array indicating support for text
|
|
34
|
-
* transforms e.g. settings found in `block.json`.
|
|
35
|
-
*/
|
|
36
|
-
const TEXT_TRANSFORM_SUPPORT_KEY = 'typography.__experimentalTextTransform';
|
|
37
|
-
/**
|
|
38
|
-
* Inspector control panel containing the text transform options.
|
|
39
|
-
*
|
|
40
|
-
* @param {Object} props Block properties.
|
|
41
|
-
*
|
|
42
|
-
* @return {WPElement} Text transform edit element.
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
exports.TEXT_TRANSFORM_SUPPORT_KEY = TEXT_TRANSFORM_SUPPORT_KEY;
|
|
46
|
-
|
|
47
|
-
function TextTransformEdit(props) {
|
|
48
|
-
var _style$typography;
|
|
49
|
-
|
|
50
|
-
const {
|
|
51
|
-
attributes: {
|
|
52
|
-
style
|
|
53
|
-
},
|
|
54
|
-
setAttributes
|
|
55
|
-
} = props;
|
|
56
|
-
|
|
57
|
-
function onChange(newTransform) {
|
|
58
|
-
setAttributes({
|
|
59
|
-
style: (0, _utils.cleanEmptyObject)({ ...style,
|
|
60
|
-
typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
|
|
61
|
-
textTransform: newTransform
|
|
62
|
-
}
|
|
63
|
-
})
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return (0, _element.createElement)(_textTransformControl.default, {
|
|
68
|
-
value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.textTransform,
|
|
69
|
-
onChange: onChange,
|
|
70
|
-
size: "__unstable-large"
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Checks if text-transform settings have been disabled.
|
|
75
|
-
*
|
|
76
|
-
* @param {string} name Name of the block.
|
|
77
|
-
*
|
|
78
|
-
* @return {boolean} Whether or not the setting is disabled.
|
|
79
|
-
*/
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
function useIsTextTransformDisabled() {
|
|
83
|
-
let {
|
|
84
|
-
name: blockName
|
|
85
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
86
|
-
const notSupported = !(0, _blocks.hasBlockSupport)(blockName, TEXT_TRANSFORM_SUPPORT_KEY);
|
|
87
|
-
const hasTextTransforms = (0, _useSetting.default)('typography.textTransform');
|
|
88
|
-
return notSupported || !hasTextTransforms;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Checks if there is a current value set for the text transform block support.
|
|
92
|
-
*
|
|
93
|
-
* @param {Object} props Block props.
|
|
94
|
-
* @return {boolean} Whether or not the block has a text transform set.
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
function hasTextTransformValue(props) {
|
|
99
|
-
var _props$attributes$sty, _props$attributes$sty2;
|
|
100
|
-
|
|
101
|
-
return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.typography) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.textTransform);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Resets the text transform block support attribute. This can be used when
|
|
105
|
-
* disabling the text transform support controls for a block via a progressive
|
|
106
|
-
* discovery panel.
|
|
107
|
-
*
|
|
108
|
-
* @param {Object} props Block props.
|
|
109
|
-
* @param {Object} props.attributes Block's attributes.
|
|
110
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
111
|
-
*/
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
function resetTextTransform(_ref) {
|
|
115
|
-
let {
|
|
116
|
-
attributes = {},
|
|
117
|
-
setAttributes
|
|
118
|
-
} = _ref;
|
|
119
|
-
const {
|
|
120
|
-
style
|
|
121
|
-
} = attributes;
|
|
122
|
-
setAttributes({
|
|
123
|
-
style: (0, _utils.cleanEmptyObject)({ ...style,
|
|
124
|
-
typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
|
|
125
|
-
textTransform: undefined
|
|
126
|
-
}
|
|
127
|
-
})
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
//# sourceMappingURL=text-transform.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/text-transform.js"],"names":["TEXT_TRANSFORM_SUPPORT_KEY","TextTransformEdit","props","attributes","style","setAttributes","onChange","newTransform","typography","textTransform","useIsTextTransformDisabled","name","blockName","notSupported","hasTextTransforms","hasTextTransformValue","resetTextTransform","undefined"],"mappings":";;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACO,MAAMA,0BAA0B,GACtC,wCADM;AAGP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASC,iBAAT,CAA4BC,KAA5B,EAAoC;AAAA;;AAC1C,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELC,IAAAA;AAFK,MAGFH,KAHJ;;AAKA,WAASI,QAAT,CAAmBC,YAAnB,EAAkC;AACjCF,IAAAA,aAAa,CAAE;AACdD,MAAAA,KAAK,EAAE,6BAAkB,EACxB,GAAGA,KADqB;AAExBI,QAAAA,UAAU,EAAE,EACX,IAAGJ,KAAH,aAAGA,KAAH,uBAAGA,KAAK,C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encies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport TextTransformControl from '../components/text-transform-control';\nimport useSetting from '../components/use-setting';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Key within block settings' supports array indicating support for text\n * transforms e.g. settings found in `block.json`.\n */\nexport const TEXT_TRANSFORM_SUPPORT_KEY =\n\t'typography.__experimentalTextTransform';\n\n/**\n * Inspector control panel containing the text transform options.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Text transform edit element.\n */\nexport function TextTransformEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tfunction onChange( newTransform ) {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\ttypography: {\n\t\t\t\t\t...style?.typography,\n\t\t\t\t\ttextTransform: newTransform,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<TextTransformControl\n\t\t\tvalue={ style?.typography?.textTransform }\n\t\t\tonChange={ onChange }\n\t\t\tsize=\"__unstable-large\"\n\t\t/>\n\t);\n}\n\n/**\n * Checks if text-transform settings have been disabled.\n *\n * @param {string} name Name of the block.\n *\n * @return {boolean} Whether or not the setting is disabled.\n */\nexport function useIsTextTransformDisabled( { name: blockName } = {} ) {\n\tconst notSupported = ! hasBlockSupport(\n\t\tblockName,\n\t\tTEXT_TRANSFORM_SUPPORT_KEY\n\t);\n\tconst hasTextTransforms = useSetting( 'typography.textTransform' );\n\treturn notSupported || ! hasTextTransforms;\n}\n\n/**\n * Checks if there is a current value set for the text transform block support.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a text transform set.\n */\nexport function hasTextTransformValue( props ) {\n\treturn !! props.attributes.style?.typography?.textTransform;\n}\n\n/**\n * Resets the text transform block support attribute. This can be used when\n * disabling the text transform support controls for a block via a progressive\n * 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 resetTextTransform( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\ttypography: {\n\t\t\t\t...style?.typography,\n\t\t\t\ttextTransform: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n"]}
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* WordPress dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, __experimentalUnitControl as UnitControl } from '@wordpress/components';
|
|
7
|
-
import { __ } from '@wordpress/i18n';
|
|
8
|
-
import { useEffect } from '@wordpress/element';
|
|
9
|
-
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import useSetting from '../components/use-setting';
|
|
14
|
-
|
|
15
|
-
function helpText(selfStretch, parentLayout) {
|
|
16
|
-
const {
|
|
17
|
-
orientation = 'horizontal'
|
|
18
|
-
} = parentLayout;
|
|
19
|
-
|
|
20
|
-
if (selfStretch === 'fill') {
|
|
21
|
-
return __('Stretch to fill available space.');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (selfStretch === 'fixed') {
|
|
25
|
-
if (orientation === 'horizontal') {
|
|
26
|
-
return __('Specify a fixed width.');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return __('Specify a fixed height.');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return __('Fit contents.');
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Inspector controls containing the child layout related configuration.
|
|
36
|
-
*
|
|
37
|
-
* @param {Object} props Block props.
|
|
38
|
-
* @param {Object} props.attributes Block attributes.
|
|
39
|
-
* @param {Object} props.setAttributes Function to set block attributes.
|
|
40
|
-
* @param {Object} props.__unstableParentLayout
|
|
41
|
-
*
|
|
42
|
-
* @return {WPElement} child layout edit element.
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
export function ChildLayoutEdit(_ref) {
|
|
47
|
-
let {
|
|
48
|
-
attributes,
|
|
49
|
-
setAttributes,
|
|
50
|
-
__unstableParentLayout: parentLayout
|
|
51
|
-
} = _ref;
|
|
52
|
-
const {
|
|
53
|
-
style = {}
|
|
54
|
-
} = attributes;
|
|
55
|
-
const {
|
|
56
|
-
layout: childLayout = {}
|
|
57
|
-
} = style;
|
|
58
|
-
const {
|
|
59
|
-
selfStretch,
|
|
60
|
-
flexSize
|
|
61
|
-
} = childLayout;
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
if (selfStretch === 'fixed' && !flexSize) {
|
|
64
|
-
setAttributes({
|
|
65
|
-
style: { ...style,
|
|
66
|
-
layout: { ...childLayout,
|
|
67
|
-
selfStretch: 'fit'
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}, []);
|
|
73
|
-
return createElement(Fragment, null, createElement(ToggleGroupControl, {
|
|
74
|
-
__nextHasNoMarginBottom: true,
|
|
75
|
-
size: '__unstable-large',
|
|
76
|
-
label: childLayoutOrientation(parentLayout),
|
|
77
|
-
value: selfStretch || 'fit',
|
|
78
|
-
help: helpText(selfStretch, parentLayout),
|
|
79
|
-
onChange: value => {
|
|
80
|
-
const newFlexSize = value !== 'fixed' ? null : flexSize;
|
|
81
|
-
setAttributes({
|
|
82
|
-
style: { ...style,
|
|
83
|
-
layout: { ...childLayout,
|
|
84
|
-
selfStretch: value,
|
|
85
|
-
flexSize: newFlexSize
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
},
|
|
90
|
-
isBlock: true
|
|
91
|
-
}, createElement(ToggleGroupControlOption, {
|
|
92
|
-
key: 'fit',
|
|
93
|
-
value: 'fit',
|
|
94
|
-
label: __('Fit')
|
|
95
|
-
}), createElement(ToggleGroupControlOption, {
|
|
96
|
-
key: 'fill',
|
|
97
|
-
value: 'fill',
|
|
98
|
-
label: __('Fill')
|
|
99
|
-
}), createElement(ToggleGroupControlOption, {
|
|
100
|
-
key: 'fixed',
|
|
101
|
-
value: 'fixed',
|
|
102
|
-
label: __('Fixed')
|
|
103
|
-
})), selfStretch === 'fixed' && createElement(UnitControl, {
|
|
104
|
-
size: '__unstable-large',
|
|
105
|
-
onChange: value => {
|
|
106
|
-
setAttributes({
|
|
107
|
-
style: { ...style,
|
|
108
|
-
layout: { ...childLayout,
|
|
109
|
-
flexSize: value
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
},
|
|
114
|
-
value: flexSize
|
|
115
|
-
}));
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Determines if there is child layout support.
|
|
119
|
-
*
|
|
120
|
-
* @param {Object} props Block Props object.
|
|
121
|
-
* @param {Object} props.__unstableParentLayout Parent layout.
|
|
122
|
-
*
|
|
123
|
-
* @return {boolean} Whether there is support.
|
|
124
|
-
*/
|
|
125
|
-
|
|
126
|
-
export function hasChildLayoutSupport(_ref2) {
|
|
127
|
-
let {
|
|
128
|
-
__unstableParentLayout: parentLayout = {}
|
|
129
|
-
} = _ref2;
|
|
130
|
-
const {
|
|
131
|
-
type: parentLayoutType = 'default',
|
|
132
|
-
default: {
|
|
133
|
-
type: defaultParentLayoutType = 'default'
|
|
134
|
-
} = {},
|
|
135
|
-
allowSizingOnChildren = false
|
|
136
|
-
} = parentLayout;
|
|
137
|
-
const support = (defaultParentLayoutType === 'flex' || parentLayoutType === 'flex') && allowSizingOnChildren;
|
|
138
|
-
return support;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Checks if there is a current value in the child layout attributes.
|
|
142
|
-
*
|
|
143
|
-
* @param {Object} props Block props.
|
|
144
|
-
* @return {boolean} Whether or not the block has a child layout value set.
|
|
145
|
-
*/
|
|
146
|
-
|
|
147
|
-
export function hasChildLayoutValue(props) {
|
|
148
|
-
var _props$attributes$sty;
|
|
149
|
-
|
|
150
|
-
return ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : _props$attributes$sty.layout) !== undefined;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Resets the child layout attribute. This can be used when disabling
|
|
154
|
-
* child layout controls for a block via a progressive discovery panel.
|
|
155
|
-
*
|
|
156
|
-
* @param {Object} props Block props.
|
|
157
|
-
* @param {Object} props.attributes Block attributes.
|
|
158
|
-
* @param {Object} props.setAttributes Function to set block attributes.
|
|
159
|
-
*/
|
|
160
|
-
|
|
161
|
-
export function resetChildLayout(_ref3) {
|
|
162
|
-
let {
|
|
163
|
-
attributes = {},
|
|
164
|
-
setAttributes
|
|
165
|
-
} = _ref3;
|
|
166
|
-
const {
|
|
167
|
-
style
|
|
168
|
-
} = attributes;
|
|
169
|
-
setAttributes({
|
|
170
|
-
style: { ...style,
|
|
171
|
-
layout: undefined
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Custom hook that checks if child layout settings have been disabled.
|
|
177
|
-
*
|
|
178
|
-
* @param {Object} props Block props.
|
|
179
|
-
*
|
|
180
|
-
* @return {boolean} Whether the child layout setting is disabled.
|
|
181
|
-
*/
|
|
182
|
-
|
|
183
|
-
export function useIsChildLayoutDisabled(props) {
|
|
184
|
-
const isDisabled = !useSetting('layout');
|
|
185
|
-
return !hasChildLayoutSupport(props) || isDisabled;
|
|
186
|
-
}
|
|
187
|
-
export function childLayoutOrientation(parentLayout) {
|
|
188
|
-
const {
|
|
189
|
-
orientation = 'horizontal'
|
|
190
|
-
} = parentLayout;
|
|
191
|
-
return orientation === 'horizontal' ? __('Width') : __('Height');
|
|
192
|
-
}
|
|
193
|
-
//# sourceMappingURL=child-layout.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/child-layout.js"],"names":["__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOption","ToggleGroupControlOption","__experimentalUnitControl","UnitControl","__","useEffect","useSetting","helpText","selfStretch","parentLayout","orientation","ChildLayoutEdit","attributes","setAttributes","__unstableParentLayout","style","layout","childLayout","flexSize","childLayoutOrientation","value","newFlexSize","hasChildLayoutSupport","type","parentLayoutType","default","defaultParentLayoutType","allowSizingOnChildren","support","hasChildLayoutValue","props","undefined","resetChildLayout","useIsChildLayoutDisabled","isDisabled"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,gCAAgC,IAAIC,kBADrC,EAECC,sCAAsC,IAAIC,wBAF3C,EAGCC,yBAAyB,IAAIC,WAH9B,QAIO,uBAJP;AAKA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,2BAAvB;;AAEA,SAASC,QAAT,CAAmBC,WAAnB,EAAgCC,YAAhC,EAA+C;AAC9C,QAAM;AAAEC,IAAAA,WAAW,GAAG;AAAhB,MAAiCD,YAAvC;;AAEA,MAAKD,WAAW,KAAK,MAArB,EAA8B;AAC7B,WAAOJ,EAAE,CAAE,kCAAF,CAAT;AACA;;AACD,MAAKI,WAAW,KAAK,OAArB,EAA+B;AAC9B,QAAKE,WAAW,KAAK,YAArB,EAAoC;AACnC,aAAON,EAAE,CAAE,wBAAF,CAAT;AACA;;AACD,WAAOA,EAAE,CAAE,yBAAF,CAAT;AACA;;AACD,SAAOA,EAAE,CAAE,eAAF,CAAT;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,OAAO,SAASO,eAAT,OAIH;AAAA,MAJ6B;AAChCC,IAAAA,UADgC;AAEhCC,IAAAA,aAFgC;AAGhCC,IAAAA,sBAAsB,EAAEL;AAHQ,GAI7B;AAC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AxB,MAAmCe,SAA1C;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,gBAAT,QAAgE;AAAA,MAArC;AAAEpB,IAAAA,UAAU,GAAG,EAAf;AAAmBC,IAAAA;AAAnB,GAAqC;AACtE,QAAM;AAAEE,IAAAA;AAAF,MAAYH,UAAlB;AAEAC,EAAAA,aAAa,CAAE;AACdE,IAAAA,KAAK,EAAE,EACN,GAAGA,KADG;AAENC,MAAAA,MAAM,EAAEe;AAFF;AADO,GAAF,CAAb;AAMA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,wBAAT,CAAmCH,KAAnC,EAA2C;AACjD,QAAMI,UAAU,GAAG,CAAE5B,UAAU,CAAE,QAAF,CAA/B;AAEA,SAAO,CAAEgB,qBAAqB,CAAEQ,KAAF,CAAvB,IAAoCI,UAA3C;AACA;AAED,OAAO,SAASf,sBAAT,CAAiCV,YAAjC,EAAgD;AACtD,QAAM;AAAEC,IAAAA,WAAW,GAAG;AAAhB,MAAiCD,YAAvC;AAEA,SAAOC,WAAW,KAAK,YAAhB,GAA+BN,EAAE,CAAE,OAAF,CAAjC,GAA+CA,EAAE,CAAE,QAAF,CAAxD;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalUnitControl as UnitControl,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../components/use-setting';\n\nfunction helpText( selfStretch, parentLayout ) {\n\tconst { orientation = 'horizontal' } = parentLayout;\n\n\tif ( selfStretch === 'fill' ) {\n\t\treturn __( 'Stretch to fill available space.' );\n\t}\n\tif ( selfStretch === 'fixed' ) {\n\t\tif ( orientation === 'horizontal' ) {\n\t\t\treturn __( 'Specify a fixed width.' );\n\t\t}\n\t\treturn __( 'Specify a fixed height.' );\n\t}\n\treturn __( 'Fit contents.' );\n}\n\n/**\n * Inspector controls containing the child layout related configuration.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block attributes.\n * @param {Object} props.setAttributes Function to set block attributes.\n * @param {Object} props.__unstableParentLayout\n *\n * @return {WPElement} child layout edit element.\n */\nexport function ChildLayoutEdit( {\n\tattributes,\n\tsetAttributes,\n\t__unstableParentLayout: parentLayout,\n} ) {\n\tconst { style = {} } = attributes;\n\tconst { layout: childLayout = {} } = style;\n\tconst { selfStretch, flexSize } = childLayout;\n\n\tuseEffect( () => {\n\t\tif ( selfStretch === 'fixed' && ! flexSize ) {\n\t\t\tsetAttributes( {\n\t\t\t\tstyle: {\n\t\t\t\t\t...style,\n\t\t\t\t\tlayout: {\n\t\t\t\t\t\t...childLayout,\n\t\t\t\t\t\tselfStretch: 'fit',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<>\n\t\t\t<ToggleGroupControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\tlabel={ childLayoutOrientation( parentLayout ) }\n\t\t\t\tvalue={ selfStretch || 'fit' }\n\t\t\t\thelp={ helpText( selfStretch, parentLayout ) }\n\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\tconst newFlexSize = value !== 'fixed' ? null : flexSize;\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t...childLayout,\n\t\t\t\t\t\t\t\tselfStretch: value,\n\t\t\t\t\t\t\t\tflexSize: newFlexSize,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tisBlock={ true }\n\t\t\t>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey={ 'fit' }\n\t\t\t\t\tvalue={ 'fit' }\n\t\t\t\t\tlabel={ __( 'Fit' ) }\n\t\t\t\t/>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey={ 'fill' }\n\t\t\t\t\tvalue={ 'fill' }\n\t\t\t\t\tlabel={ __( 'Fill' ) }\n\t\t\t\t/>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey={ 'fixed' }\n\t\t\t\t\tvalue={ 'fixed' }\n\t\t\t\t\tlabel={ __( 'Fixed' ) }\n\t\t\t\t/>\n\t\t\t</ToggleGroupControl>\n\t\t\t{ selfStretch === 'fixed' && (\n\t\t\t\t<UnitControl\n\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t...childLayout,\n\t\t\t\t\t\t\t\t\tflexSize: value,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ flexSize }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\n/**\n * Determines if there is child layout support.\n *\n * @param {Object} props Block Props object.\n * @param {Object} props.__unstableParentLayout Parent layout.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasChildLayoutSupport( {\n\t__unstableParentLayout: parentLayout = {},\n} ) {\n\tconst {\n\t\ttype: parentLayoutType = 'default',\n\t\tdefault: { type: defaultParentLayoutType = 'default' } = {},\n\t\tallowSizingOnChildren = false,\n\t} = parentLayout;\n\n\tconst support =\n\t\t( defaultParentLayoutType === 'flex' || parentLayoutType === 'flex' ) &&\n\t\tallowSizingOnChildren;\n\n\treturn support;\n}\n\n/**\n * Checks if there is a current value in the child layout attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a child layout value set.\n */\nexport function hasChildLayoutValue( props ) {\n\treturn props.attributes.style?.layout !== undefined;\n}\n\n/**\n * Resets the child layout attribute. This can be used when disabling\n * child layout controls for a block via a progressive discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block attributes.\n * @param {Object} props.setAttributes Function to set block attributes.\n */\nexport function resetChildLayout( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: {\n\t\t\t...style,\n\t\t\tlayout: undefined,\n\t\t},\n\t} );\n}\n\n/**\n * Custom hook that checks if child layout settings have been disabled.\n *\n * @param {Object} props Block props.\n *\n * @return {boolean} Whether the child layout setting is disabled.\n */\nexport function useIsChildLayoutDisabled( props ) {\n\tconst isDisabled = ! useSetting( 'layout' );\n\n\treturn ! hasChildLayoutSupport( props ) || isDisabled;\n}\n\nexport function childLayoutOrientation( parentLayout ) {\n\tconst { orientation = 'horizontal' } = parentLayout;\n\n\treturn orientation === 'horizontal' ? __( 'Width' ) : __( 'Height' );\n}\n"]}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* WordPress dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { hasBlockSupport } from '@wordpress/blocks';
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import FontAppearanceControl from '../components/font-appearance-control';
|
|
12
|
-
import useSetting from '../components/use-setting';
|
|
13
|
-
import { cleanEmptyObject } from './utils';
|
|
14
|
-
/**
|
|
15
|
-
* Key within block settings' support array indicating support for font style.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
export const FONT_STYLE_SUPPORT_KEY = 'typography.__experimentalFontStyle';
|
|
19
|
-
/**
|
|
20
|
-
* Key within block settings' support array indicating support for font weight.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
export const FONT_WEIGHT_SUPPORT_KEY = 'typography.__experimentalFontWeight';
|
|
24
|
-
/**
|
|
25
|
-
* Inspector control panel containing the font appearance options.
|
|
26
|
-
*
|
|
27
|
-
* @param {Object} props Block properties.
|
|
28
|
-
*
|
|
29
|
-
* @return {WPElement} Font appearance edit element.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
export function FontAppearanceEdit(props) {
|
|
33
|
-
var _style$typography, _style$typography2;
|
|
34
|
-
|
|
35
|
-
const {
|
|
36
|
-
attributes: {
|
|
37
|
-
style
|
|
38
|
-
},
|
|
39
|
-
setAttributes
|
|
40
|
-
} = props;
|
|
41
|
-
const hasFontStyles = !useIsFontStyleDisabled(props);
|
|
42
|
-
const hasFontWeights = !useIsFontWeightDisabled(props);
|
|
43
|
-
|
|
44
|
-
const onChange = newStyles => {
|
|
45
|
-
setAttributes({
|
|
46
|
-
style: cleanEmptyObject({ ...style,
|
|
47
|
-
typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
|
|
48
|
-
fontStyle: newStyles.fontStyle,
|
|
49
|
-
fontWeight: newStyles.fontWeight
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const fontStyle = style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.fontStyle;
|
|
56
|
-
const fontWeight = style === null || style === void 0 ? void 0 : (_style$typography2 = style.typography) === null || _style$typography2 === void 0 ? void 0 : _style$typography2.fontWeight;
|
|
57
|
-
return createElement(FontAppearanceControl, {
|
|
58
|
-
onChange: onChange,
|
|
59
|
-
hasFontStyles: hasFontStyles,
|
|
60
|
-
hasFontWeights: hasFontWeights,
|
|
61
|
-
value: {
|
|
62
|
-
fontStyle,
|
|
63
|
-
fontWeight
|
|
64
|
-
},
|
|
65
|
-
size: "__unstable-large"
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Checks if font style support has been disabled either by not opting in for
|
|
70
|
-
* support or by failing to provide preset styles.
|
|
71
|
-
*
|
|
72
|
-
* @param {Object} props Block properties.
|
|
73
|
-
* @param {string} props.name Name for the block type.
|
|
74
|
-
*
|
|
75
|
-
* @return {boolean} Whether font style support has been disabled.
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
export function useIsFontStyleDisabled() {
|
|
79
|
-
let {
|
|
80
|
-
name: blockName
|
|
81
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
82
|
-
const styleSupport = hasBlockSupport(blockName, FONT_STYLE_SUPPORT_KEY);
|
|
83
|
-
const hasFontStyles = useSetting('typography.fontStyle');
|
|
84
|
-
return !styleSupport || !hasFontStyles;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Checks if font weight support has been disabled either by not opting in for
|
|
88
|
-
* support or by failing to provide preset weights.
|
|
89
|
-
*
|
|
90
|
-
* @param {Object} props Block properties.
|
|
91
|
-
* @param {string} props.name Name for the block type.
|
|
92
|
-
*
|
|
93
|
-
* @return {boolean} Whether font weight support has been disabled.
|
|
94
|
-
*/
|
|
95
|
-
|
|
96
|
-
export function useIsFontWeightDisabled() {
|
|
97
|
-
let {
|
|
98
|
-
name: blockName
|
|
99
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
100
|
-
const weightSupport = hasBlockSupport(blockName, FONT_WEIGHT_SUPPORT_KEY);
|
|
101
|
-
const hasFontWeights = useSetting('typography.fontWeight');
|
|
102
|
-
return !weightSupport || !hasFontWeights;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Checks if font appearance support has been disabled.
|
|
106
|
-
*
|
|
107
|
-
* @param {Object} props Block properties.
|
|
108
|
-
*
|
|
109
|
-
* @return {boolean} Whether font appearance support has been disabled.
|
|
110
|
-
*/
|
|
111
|
-
|
|
112
|
-
export function useIsFontAppearanceDisabled(props) {
|
|
113
|
-
const stylesDisabled = useIsFontStyleDisabled(props);
|
|
114
|
-
const weightsDisabled = useIsFontWeightDisabled(props);
|
|
115
|
-
return stylesDisabled && weightsDisabled;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Checks if there is either a font style or weight value set within the
|
|
119
|
-
* typography styles.
|
|
120
|
-
*
|
|
121
|
-
* @param {Object} props Block props.
|
|
122
|
-
* @return {boolean} Whether or not the block has a font style or weight.
|
|
123
|
-
*/
|
|
124
|
-
|
|
125
|
-
export function hasFontAppearanceValue(props) {
|
|
126
|
-
var _props$attributes$sty;
|
|
127
|
-
|
|
128
|
-
const {
|
|
129
|
-
fontStyle,
|
|
130
|
-
fontWeight
|
|
131
|
-
} = ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : _props$attributes$sty.typography) || {};
|
|
132
|
-
return !!fontStyle || !!fontWeight;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Resets the font style and weight block support attributes. This can be used
|
|
136
|
-
* when disabling the font appearance support controls for a block via a
|
|
137
|
-
* progressive discovery panel.
|
|
138
|
-
*
|
|
139
|
-
* @param {Object} props Block props.
|
|
140
|
-
* @param {Object} props.attributes Block's attributes.
|
|
141
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
142
|
-
*/
|
|
143
|
-
|
|
144
|
-
export function resetFontAppearance(_ref) {
|
|
145
|
-
let {
|
|
146
|
-
attributes = {},
|
|
147
|
-
setAttributes
|
|
148
|
-
} = _ref;
|
|
149
|
-
const {
|
|
150
|
-
style
|
|
151
|
-
} = attributes;
|
|
152
|
-
setAttributes({
|
|
153
|
-
style: cleanEmptyObject({ ...style,
|
|
154
|
-
typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
|
|
155
|
-
fontStyle: undefined,
|
|
156
|
-
fontWeight: undefined
|
|
157
|
-
}
|
|
158
|
-
})
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
//# sourceMappingURL=font-appearance.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/font-appearance.js"],"names":["hasBlockSupport","FontAppearanceControl","useSetting","cleanEmptyObject","FONT_STYLE_SUPPORT_KEY","FONT_WEIGHT_SUPPORT_KEY","FontAppearanceEdit","props","attributes","style","setAttributes","hasFontStyles","useIsFontStyleDisabled","hasFontWeights","useIsFontWeightDisabled","onChange","newStyles","typography","fontStyle","fontWeight","name","blockName","styleSupport","weightSupport","useIsFontAppearanceDisabled","stylesDisabled","weightsDisabled","hasFontAppearanceValue","resetFontAppearance","undefined"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,qBAAP,MAAkC,uCAAlC;AACA,OAAOC,UAAP,MAAuB,2BAAvB;AACA,SAASC,gBAAT,QAAiC,SAAjC;AAEA;AACA;AACA;;AACA,OAAO,MAAMC,sBAAsB,GAAG,oCAA/B;AAEP;AACA;AACA;;AACA,OAAO,MAAMC,uBAAuB,GAAG,qCAAhC;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,kBAAT,CAA6BC,KAA7B,EAAqC;AAAA;;AAC3C,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELC,IAAAA;AAFK,MAGFH,KAHJ;AAKA,QAAMI,aAAa,GAAG,CAAEC,sBAAsB,CAAEL,KAAF,CAA9C;AACA,QAAMM,cAAc,GAAG,CAAEC,uBAAuB,CAAEP,KAAF,CAAhD;;AAEA,QAAMQ,QAAQ,GAAKC,SAAF,IAAiB;AACjCN,IAAAA,aAAa,CAAE;AACdD,MAAAA,KAAK,EAAEN,gBAAgB,CAAE,EACxB,GAAGM,KADqB;AAExBQ,QAAAA,UAAU,EAAE,EACX,IAAGR,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEQ,UAAV,CADW;AAEXC,UAAAA,SAAS,EAAEF,SAAS,CAACE,SAFV;AAGXC,UAAAA,UAAU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,GAAGb,sBAAsB,CAAEL,KAAF,CAA7C;AACA,QAAMmB,eAAe,GAAGZ,uBAAuB,CAAEP,KAAF,CAA/C;AAEA,SAAOkB,cAAc,IAAIC,eAAzB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,sBAAT,CAAiCpB,KAAjC,EAAyC;AAAA;;AAC/C,QAAM;AAAEW,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA4B,0BAAAZ,KAAK,CAACC,UAAN,CAAiBC,KAAjB,gFAAwBQ,UAAxB,KAAsC,EAAxE;AACA,SAAO,CAAC,CAAEC,SAAH,IAAgB,CAAC,CAAEC,UAA1B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASS,mBAAT,OAAmE;AAAA,MAArC;AAAEpB,IAAAA,UAAU,GAAG,EAAf;AAAmBE,IAAAA;AAAnB,GAAqC;AACzE,QAAM;AAAED,IAAAA;AAAF,MAAYD,UAAlB;AAEAE,EAAAA,aAAa,CAAE;AACdD,IAAAA,KAAK,EAAEN,gBAAgB,CAAE,EACxB,GAAGM,KADqB;AAExBQ,MAAAA,UAAU,EAAE,EACX,IAAGR,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEQ,UAAV,CADW;AAEXC,QAAAA,SAAS,EAAEW,SAFA;AAGXV,QAAAA,UAAU,EAAEU;AAHD;AAFY,KAAF;AADT,GAAF,CAAb;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport FontAppearanceControl from '../components/font-appearance-control';\nimport useSetting from '../components/use-setting';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Key within block settings' support array indicating support for font style.\n */\nexport const FONT_STYLE_SUPPORT_KEY = 'typography.__experimentalFontStyle';\n\n/**\n * Key within block settings' support array indicating support for font weight.\n */\nexport const FONT_WEIGHT_SUPPORT_KEY = 'typography.__experimentalFontWeight';\n\n/**\n * Inspector control panel containing the font appearance options.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Font appearance edit element.\n */\nexport function FontAppearanceEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tconst hasFontStyles = ! useIsFontStyleDisabled( props );\n\tconst hasFontWeights = ! useIsFontWeightDisabled( props );\n\n\tconst onChange = ( newStyles ) => {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\ttypography: {\n\t\t\t\t\t...style?.typography,\n\t\t\t\t\tfontStyle: newStyles.fontStyle,\n\t\t\t\t\tfontWeight: newStyles.fontWeight,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t};\n\n\tconst fontStyle = style?.typography?.fontStyle;\n\tconst fontWeight = style?.typography?.fontWeight;\n\n\treturn (\n\t\t<FontAppearanceControl\n\t\t\tonChange={ onChange }\n\t\t\thasFontStyles={ hasFontStyles }\n\t\t\thasFontWeights={ hasFontWeights }\n\t\t\tvalue={ { fontStyle, fontWeight } }\n\t\t\tsize=\"__unstable-large\"\n\t\t/>\n\t);\n}\n\n/**\n * Checks if font style support has been disabled either by not opting in for\n * support or by failing to provide preset styles.\n *\n * @param {Object} props Block properties.\n * @param {string} props.name Name for the block type.\n *\n * @return {boolean} Whether font style support has been disabled.\n */\nexport function useIsFontStyleDisabled( { name: blockName } = {} ) {\n\tconst styleSupport = hasBlockSupport( blockName, FONT_STYLE_SUPPORT_KEY );\n\tconst hasFontStyles = useSetting( 'typography.fontStyle' );\n\n\treturn ! styleSupport || ! hasFontStyles;\n}\n\n/**\n * Checks if font weight support has been disabled either by not opting in for\n * support or by failing to provide preset weights.\n *\n * @param {Object} props Block properties.\n * @param {string} props.name Name for the block type.\n *\n * @return {boolean} Whether font weight support has been disabled.\n */\nexport function useIsFontWeightDisabled( { name: blockName } = {} ) {\n\tconst weightSupport = hasBlockSupport( blockName, FONT_WEIGHT_SUPPORT_KEY );\n\tconst hasFontWeights = useSetting( 'typography.fontWeight' );\n\n\treturn ! weightSupport || ! hasFontWeights;\n}\n\n/**\n * Checks if font appearance support has been disabled.\n *\n * @param {Object} props Block properties.\n *\n * @return {boolean} Whether font appearance support has been disabled.\n */\nexport function useIsFontAppearanceDisabled( props ) {\n\tconst stylesDisabled = useIsFontStyleDisabled( props );\n\tconst weightsDisabled = useIsFontWeightDisabled( props );\n\n\treturn stylesDisabled && weightsDisabled;\n}\n\n/**\n * Checks if there is either a font style or weight value set within the\n * typography styles.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a font style or weight.\n */\nexport function hasFontAppearanceValue( props ) {\n\tconst { fontStyle, fontWeight } = props.attributes.style?.typography || {};\n\treturn !! fontStyle || !! fontWeight;\n}\n\n/**\n * Resets the font style and weight block support attributes. This can be used\n * when disabling the font appearance support controls for a block via a\n * 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 resetFontAppearance( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\ttypography: {\n\t\t\t\t...style?.typography,\n\t\t\t\tfontStyle: undefined,\n\t\t\t\tfontWeight: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n"]}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* WordPress dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { hasBlockSupport } from '@wordpress/blocks';
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import LetterSpacingControl from '../components/letter-spacing-control';
|
|
12
|
-
import useSetting from '../components/use-setting';
|
|
13
|
-
import { cleanEmptyObject } from './utils';
|
|
14
|
-
/**
|
|
15
|
-
* Key within block settings' supports array indicating support for letter-spacing
|
|
16
|
-
* e.g. settings found in `block.json`.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
export const LETTER_SPACING_SUPPORT_KEY = 'typography.__experimentalLetterSpacing';
|
|
20
|
-
/**
|
|
21
|
-
* Inspector control panel containing the letter-spacing options.
|
|
22
|
-
*
|
|
23
|
-
* @param {Object} props Block properties.
|
|
24
|
-
* @return {WPElement} Letter-spacing edit element.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
export function LetterSpacingEdit(props) {
|
|
28
|
-
var _style$typography;
|
|
29
|
-
|
|
30
|
-
const {
|
|
31
|
-
attributes: {
|
|
32
|
-
style
|
|
33
|
-
},
|
|
34
|
-
setAttributes
|
|
35
|
-
} = props;
|
|
36
|
-
|
|
37
|
-
function onChange(newSpacing) {
|
|
38
|
-
setAttributes({
|
|
39
|
-
style: cleanEmptyObject({ ...style,
|
|
40
|
-
typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
|
|
41
|
-
letterSpacing: newSpacing
|
|
42
|
-
}
|
|
43
|
-
})
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return createElement(LetterSpacingControl, {
|
|
48
|
-
value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.letterSpacing,
|
|
49
|
-
onChange: onChange,
|
|
50
|
-
__unstableInputWidth: '100%',
|
|
51
|
-
size: "__unstable-large"
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Checks if letter-spacing settings have been disabled.
|
|
56
|
-
*
|
|
57
|
-
* @param {string} name Name of the block.
|
|
58
|
-
* @return {boolean} Whether or not the setting is disabled.
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
export function useIsLetterSpacingDisabled() {
|
|
62
|
-
let {
|
|
63
|
-
name: blockName
|
|
64
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
65
|
-
const notSupported = !hasBlockSupport(blockName, LETTER_SPACING_SUPPORT_KEY);
|
|
66
|
-
const hasLetterSpacing = useSetting('typography.letterSpacing');
|
|
67
|
-
return notSupported || !hasLetterSpacing;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Checks if there is a current value set for the letter spacing block support.
|
|
71
|
-
*
|
|
72
|
-
* @param {Object} props Block props.
|
|
73
|
-
* @return {boolean} Whether or not the block has a letter spacing set.
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
|
-
export function hasLetterSpacingValue(props) {
|
|
77
|
-
var _props$attributes$sty, _props$attributes$sty2;
|
|
78
|
-
|
|
79
|
-
return !!((_props$attributes$sty = props.attributes.style) !== null && _props$attributes$sty !== void 0 && (_props$attributes$sty2 = _props$attributes$sty.typography) !== null && _props$attributes$sty2 !== void 0 && _props$attributes$sty2.letterSpacing);
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Resets the letter spacing block support attribute. This can be used when
|
|
83
|
-
* disabling the letter spacing support controls for a block via a progressive
|
|
84
|
-
* discovery panel.
|
|
85
|
-
*
|
|
86
|
-
* @param {Object} props Block props.
|
|
87
|
-
* @param {Object} props.attributes Block's attributes.
|
|
88
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
89
|
-
*/
|
|
90
|
-
|
|
91
|
-
export function resetLetterSpacing(_ref) {
|
|
92
|
-
let {
|
|
93
|
-
attributes = {},
|
|
94
|
-
setAttributes
|
|
95
|
-
} = _ref;
|
|
96
|
-
const {
|
|
97
|
-
style
|
|
98
|
-
} = attributes;
|
|
99
|
-
setAttributes({
|
|
100
|
-
style: cleanEmptyObject({ ...style,
|
|
101
|
-
typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
|
|
102
|
-
letterSpacing: undefined
|
|
103
|
-
}
|
|
104
|
-
})
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
//# sourceMappingURL=letter-spacing.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/letter-spacing.js"],"names":["hasBlockSupport","LetterSpacingControl","useSetting","cleanEmptyObject","LETTER_SPACING_SUPPORT_KEY","LetterSpacingEdit","props","attributes","style","setAttributes","onChange","newSpacing","typography","letterSpacing","useIsLetterSpacingDisabled","name","blockName","notSupported","hasLetterSpacing","hasLetterSpacingValue","resetLetterSpacing","undefined"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,mBAAhC;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,sCAAjC;AACA,OAAOC,UAAP,MAAuB,2BAAvB;AACA,SAASC,gBAAT,QAAiC,SAAjC;AAEA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,0BAA0B,GACtC,wCADM;AAGP;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,iBAAT,CAA4BC,KAA5B,EAAoC;AAAA;;AAC1C,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELC,IAAAA;AAFK,MAGFH,KAHJ;;AAKA,WAASI,QAAT,CAAmBC,UAAnB,EAAgC;AAC/BF,IAAAA,aAAa,CAAE;AACdD,MAAAA,KAAK,EAAEL,gBAAgB,CAAE,EACxB,GAAGK,KADqB;AAExBI,QAAAA,UAAU,EAAE,EACX,IAAGJ,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEI,UAAV,CADW;AAEXC,UAAAA,aAAa,EAAEF;AAFJ;AAFY,OAAF;AADT,KAAF,CAAb;AASA;;AAED,SACC,cAAC,oBAAD;AACC,IAAA,KAAK,EAAGH,KAAH,aAAGA,KAAH,4CAAGA,KAAK,CAAEI,UAAV,sDAAG,kBAAmBC,aAD5B;AAEC,IAAA,QAAQ,EAAGH,QAFZ;AAGC,IAAA,oBAAoB,EAAG,MAHxB;AAIC,IAAA,IAAI,EAAC;AAJN,IADD;AAQA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,0BAAT,GAAgE;AAAA,MAA3B;AAAEC,IAAAA,IAAI,EAAEC;AAAR,GAA2B,uEAAL,EAAK;AACtE,QAAMC,YAAY,GAAG,CAAEjB,eAAe,CACrCgB,SADqC,EAErCZ,0BAFqC,CAAtC;AAIA,QAAMc,gBAAgB,GAAGhB,UAAU,CAAE,0BAAF,CAAnC;AAEA,SAAOe,YAAY,IAAI,CAAEC,gBAAzB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,qBAAT,CAAgCb,KAAhC,EAAwC;AAAA;;AAC9C,SAAO,CAAC,2BAAEA,KAAK,CAACC,UAAN,CAAiBC,KAAnB,4EAAE,sBAAwBI,UAA1B,mDAAE,uBAAoCC,aAAtC,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASO,kBAAT,OAAkE;AAAA,MAArC;AAAEb,IAAAA,UAAU,GAAG,EAAf;AAAmBE,IAAAA;AAAnB,GAAqC;AACxE,QAAM;AAAED,IAAAA;AAAF,MAAYD,UAAlB;AAEAE,EAAAA,aAAa,CAAE;AACdD,IAAAA,KAAK,EAAEL,gBAAgB,CAAE,EACxB,GAAGK,KADqB;AAExBI,MAAAA,UAAU,EAAE,EACX,IAAGJ,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEI,UAAV,CADW;AAEXC,QAAAA,aAAa,EAAEQ;AAFJ;AAFY,KAAF;AADT,GAAF,CAAb;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport LetterSpacingControl from '../components/letter-spacing-control';\nimport useSetting from '../components/use-setting';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Key within block settings' supports array indicating support for letter-spacing\n * e.g. settings found in `block.json`.\n */\nexport const LETTER_SPACING_SUPPORT_KEY =\n\t'typography.__experimentalLetterSpacing';\n\n/**\n * Inspector control panel containing the letter-spacing options.\n *\n * @param {Object} props Block properties.\n * @return {WPElement} Letter-spacing edit element.\n */\nexport function LetterSpacingEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tfunction onChange( newSpacing ) {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t...style,\n\t\t\t\ttypography: {\n\t\t\t\t\t...style?.typography,\n\t\t\t\t\tletterSpacing: newSpacing,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<LetterSpacingControl\n\t\t\tvalue={ style?.typography?.letterSpacing }\n\t\t\tonChange={ onChange }\n\t\t\t__unstableInputWidth={ '100%' }\n\t\t\tsize=\"__unstable-large\"\n\t\t/>\n\t);\n}\n\n/**\n * Checks if letter-spacing settings have been disabled.\n *\n * @param {string} name Name of the block.\n * @return {boolean} Whether or not the setting is disabled.\n */\nexport function useIsLetterSpacingDisabled( { name: blockName } = {} ) {\n\tconst notSupported = ! hasBlockSupport(\n\t\tblockName,\n\t\tLETTER_SPACING_SUPPORT_KEY\n\t);\n\tconst hasLetterSpacing = useSetting( 'typography.letterSpacing' );\n\n\treturn notSupported || ! hasLetterSpacing;\n}\n\n/**\n * Checks if there is a current value set for the letter spacing block support.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a letter spacing set.\n */\nexport function hasLetterSpacingValue( props ) {\n\treturn !! props.attributes.style?.typography?.letterSpacing;\n}\n\n/**\n * Resets the letter spacing block support attribute. This can be used when\n * disabling the letter spacing support controls for a block via a progressive\n * 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 resetLetterSpacing( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\ttypography: {\n\t\t\t\t...style?.typography,\n\t\t\t\tletterSpacing: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n"]}
|