@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,188 +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.FONT_WEIGHT_SUPPORT_KEY = exports.FONT_STYLE_SUPPORT_KEY = void 0;
|
|
9
|
-
exports.FontAppearanceEdit = FontAppearanceEdit;
|
|
10
|
-
exports.hasFontAppearanceValue = hasFontAppearanceValue;
|
|
11
|
-
exports.resetFontAppearance = resetFontAppearance;
|
|
12
|
-
exports.useIsFontAppearanceDisabled = useIsFontAppearanceDisabled;
|
|
13
|
-
exports.useIsFontStyleDisabled = useIsFontStyleDisabled;
|
|
14
|
-
exports.useIsFontWeightDisabled = useIsFontWeightDisabled;
|
|
15
|
-
|
|
16
|
-
var _element = require("@wordpress/element");
|
|
17
|
-
|
|
18
|
-
var _blocks = require("@wordpress/blocks");
|
|
19
|
-
|
|
20
|
-
var _fontAppearanceControl = _interopRequireDefault(require("../components/font-appearance-control"));
|
|
21
|
-
|
|
22
|
-
var _useSetting = _interopRequireDefault(require("../components/use-setting"));
|
|
23
|
-
|
|
24
|
-
var _utils = require("./utils");
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* WordPress dependencies
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Internal dependencies
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Key within block settings' support array indicating support for font style.
|
|
36
|
-
*/
|
|
37
|
-
const FONT_STYLE_SUPPORT_KEY = 'typography.__experimentalFontStyle';
|
|
38
|
-
/**
|
|
39
|
-
* Key within block settings' support array indicating support for font weight.
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
exports.FONT_STYLE_SUPPORT_KEY = FONT_STYLE_SUPPORT_KEY;
|
|
43
|
-
const FONT_WEIGHT_SUPPORT_KEY = 'typography.__experimentalFontWeight';
|
|
44
|
-
/**
|
|
45
|
-
* Inspector control panel containing the font appearance options.
|
|
46
|
-
*
|
|
47
|
-
* @param {Object} props Block properties.
|
|
48
|
-
*
|
|
49
|
-
* @return {WPElement} Font appearance edit element.
|
|
50
|
-
*/
|
|
51
|
-
|
|
52
|
-
exports.FONT_WEIGHT_SUPPORT_KEY = FONT_WEIGHT_SUPPORT_KEY;
|
|
53
|
-
|
|
54
|
-
function FontAppearanceEdit(props) {
|
|
55
|
-
var _style$typography, _style$typography2;
|
|
56
|
-
|
|
57
|
-
const {
|
|
58
|
-
attributes: {
|
|
59
|
-
style
|
|
60
|
-
},
|
|
61
|
-
setAttributes
|
|
62
|
-
} = props;
|
|
63
|
-
const hasFontStyles = !useIsFontStyleDisabled(props);
|
|
64
|
-
const hasFontWeights = !useIsFontWeightDisabled(props);
|
|
65
|
-
|
|
66
|
-
const onChange = newStyles => {
|
|
67
|
-
setAttributes({
|
|
68
|
-
style: (0, _utils.cleanEmptyObject)({ ...style,
|
|
69
|
-
typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
|
|
70
|
-
fontStyle: newStyles.fontStyle,
|
|
71
|
-
fontWeight: newStyles.fontWeight
|
|
72
|
-
}
|
|
73
|
-
})
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const fontStyle = style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.fontStyle;
|
|
78
|
-
const fontWeight = style === null || style === void 0 ? void 0 : (_style$typography2 = style.typography) === null || _style$typography2 === void 0 ? void 0 : _style$typography2.fontWeight;
|
|
79
|
-
return (0, _element.createElement)(_fontAppearanceControl.default, {
|
|
80
|
-
onChange: onChange,
|
|
81
|
-
hasFontStyles: hasFontStyles,
|
|
82
|
-
hasFontWeights: hasFontWeights,
|
|
83
|
-
value: {
|
|
84
|
-
fontStyle,
|
|
85
|
-
fontWeight
|
|
86
|
-
},
|
|
87
|
-
size: "__unstable-large"
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Checks if font style support has been disabled either by not opting in for
|
|
92
|
-
* support or by failing to provide preset styles.
|
|
93
|
-
*
|
|
94
|
-
* @param {Object} props Block properties.
|
|
95
|
-
* @param {string} props.name Name for the block type.
|
|
96
|
-
*
|
|
97
|
-
* @return {boolean} Whether font style support has been disabled.
|
|
98
|
-
*/
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
function useIsFontStyleDisabled() {
|
|
102
|
-
let {
|
|
103
|
-
name: blockName
|
|
104
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
105
|
-
const styleSupport = (0, _blocks.hasBlockSupport)(blockName, FONT_STYLE_SUPPORT_KEY);
|
|
106
|
-
const hasFontStyles = (0, _useSetting.default)('typography.fontStyle');
|
|
107
|
-
return !styleSupport || !hasFontStyles;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Checks if font weight support has been disabled either by not opting in for
|
|
111
|
-
* support or by failing to provide preset weights.
|
|
112
|
-
*
|
|
113
|
-
* @param {Object} props Block properties.
|
|
114
|
-
* @param {string} props.name Name for the block type.
|
|
115
|
-
*
|
|
116
|
-
* @return {boolean} Whether font weight support has been disabled.
|
|
117
|
-
*/
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
function useIsFontWeightDisabled() {
|
|
121
|
-
let {
|
|
122
|
-
name: blockName
|
|
123
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
124
|
-
const weightSupport = (0, _blocks.hasBlockSupport)(blockName, FONT_WEIGHT_SUPPORT_KEY);
|
|
125
|
-
const hasFontWeights = (0, _useSetting.default)('typography.fontWeight');
|
|
126
|
-
return !weightSupport || !hasFontWeights;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Checks if font appearance support has been disabled.
|
|
130
|
-
*
|
|
131
|
-
* @param {Object} props Block properties.
|
|
132
|
-
*
|
|
133
|
-
* @return {boolean} Whether font appearance support has been disabled.
|
|
134
|
-
*/
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
function useIsFontAppearanceDisabled(props) {
|
|
138
|
-
const stylesDisabled = useIsFontStyleDisabled(props);
|
|
139
|
-
const weightsDisabled = useIsFontWeightDisabled(props);
|
|
140
|
-
return stylesDisabled && weightsDisabled;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Checks if there is either a font style or weight value set within the
|
|
144
|
-
* typography styles.
|
|
145
|
-
*
|
|
146
|
-
* @param {Object} props Block props.
|
|
147
|
-
* @return {boolean} Whether or not the block has a font style or weight.
|
|
148
|
-
*/
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
function hasFontAppearanceValue(props) {
|
|
152
|
-
var _props$attributes$sty;
|
|
153
|
-
|
|
154
|
-
const {
|
|
155
|
-
fontStyle,
|
|
156
|
-
fontWeight
|
|
157
|
-
} = ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : _props$attributes$sty.typography) || {};
|
|
158
|
-
return !!fontStyle || !!fontWeight;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Resets the font style and weight block support attributes. This can be used
|
|
162
|
-
* when disabling the font appearance support controls for a block via a
|
|
163
|
-
* progressive discovery panel.
|
|
164
|
-
*
|
|
165
|
-
* @param {Object} props Block props.
|
|
166
|
-
* @param {Object} props.attributes Block's attributes.
|
|
167
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
168
|
-
*/
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
function resetFontAppearance(_ref) {
|
|
172
|
-
let {
|
|
173
|
-
attributes = {},
|
|
174
|
-
setAttributes
|
|
175
|
-
} = _ref;
|
|
176
|
-
const {
|
|
177
|
-
style
|
|
178
|
-
} = attributes;
|
|
179
|
-
setAttributes({
|
|
180
|
-
style: (0, _utils.cleanEmptyObject)({ ...style,
|
|
181
|
-
typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
|
|
182
|
-
fontStyle: undefined,
|
|
183
|
-
fontWeight: undefined
|
|
184
|
-
}
|
|
185
|
-
})
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
//# sourceMappingURL=font-appearance.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/font-appearance.js"],"names":["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":";;;;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AACO,MAAMA,sBAAsB,GAAG,oCAA/B;AAEP;AACA;AACA;;;AACO,MAAMC,uBAAuB,GAAG,qCAAhC;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,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,EAAE,6BAAkB,EACxB,GAAGA,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,EAAEH,SAAS,CAACG;AAHX;AAFY,OAAlB;AADO,KAAF,CAAb;AAUA,GAXD;;AAaA,QAAMD,SAAS,GAAGT,KAAH,aAAGA,KAAH,4CAAGA,KAAK,CAAEQ,UAAV,sDAAG,kBAAmBC,SAArC;AACA,QAAMC,UAAU,GAAGV,KAAH,aAAGA,KAAH,6CAAGA,KAAK,CAAEQ,UAAV,uDAAG,mBAAmBE,UAAtC;AAEA,SACC,4BAAC,8BAAD;AACC,IAAA,QAAQ,EAAGJ,QADZ;AAEC,IAAA,aAAa,EAAGJ,aAFjB;AAGC,IAAA,cAAc,EAAGE,cAHlB;AAIC,IAAA,KAAK,EAAG;AAAEK,MAAAA,SAAF;AAAaC,MAAAA;AAAb,KAJT;AAKC,IAAA,IAAI,EAAC;AALN,IADD;AASA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASP,sBAAT,GAA4D;AAAA,MAA3B;AAAEQ,IAAAA,IAAI,EAAEC;AAAR,GAA2B,uEAAL,EAAK;AAClE,QAAMC,YAAY,GAAG,6BAAiBD,SAAjB,EAA4BjB,sBAA5B,CAArB;AACA,QAAMO,aAAa,GAAG,yBAAY,sBAAZ,CAAtB;AAEA,SAAO,CAAEW,YAAF,IAAkB,CAAEX,aAA3B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,uBAAT,GAA6D;AAAA,MAA3B;AAAEM,IAAAA,IAAI,EAAEC;AAAR,GAA2B,uEAAL,EAAK;AACnE,QAAME,aAAa,GAAG,6BAAiBF,SAAjB,EAA4BhB,uBAA5B,CAAtB;AACA,QAAMQ,cAAc,GAAG,yBAAY,uBAAZ,CAAvB;AAEA,SAAO,CAAEU,aAAF,IAAmB,CAAEV,cAA5B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASW,2BAAT,CAAsCjB,KAAtC,EAA8C;AACpD,QAAMkB,cAAc,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;;;AACO,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;;;AACO,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,EAAE,6BAAkB,EACxB,GAAGA,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,KAAlB;AADO,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,129 +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.LETTER_SPACING_SUPPORT_KEY = void 0;
|
|
9
|
-
exports.LetterSpacingEdit = LetterSpacingEdit;
|
|
10
|
-
exports.hasLetterSpacingValue = hasLetterSpacingValue;
|
|
11
|
-
exports.resetLetterSpacing = resetLetterSpacing;
|
|
12
|
-
exports.useIsLetterSpacingDisabled = useIsLetterSpacingDisabled;
|
|
13
|
-
|
|
14
|
-
var _element = require("@wordpress/element");
|
|
15
|
-
|
|
16
|
-
var _blocks = require("@wordpress/blocks");
|
|
17
|
-
|
|
18
|
-
var _letterSpacingControl = _interopRequireDefault(require("../components/letter-spacing-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 letter-spacing
|
|
34
|
-
* e.g. settings found in `block.json`.
|
|
35
|
-
*/
|
|
36
|
-
const LETTER_SPACING_SUPPORT_KEY = 'typography.__experimentalLetterSpacing';
|
|
37
|
-
/**
|
|
38
|
-
* Inspector control panel containing the letter-spacing options.
|
|
39
|
-
*
|
|
40
|
-
* @param {Object} props Block properties.
|
|
41
|
-
* @return {WPElement} Letter-spacing edit element.
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
exports.LETTER_SPACING_SUPPORT_KEY = LETTER_SPACING_SUPPORT_KEY;
|
|
45
|
-
|
|
46
|
-
function LetterSpacingEdit(props) {
|
|
47
|
-
var _style$typography;
|
|
48
|
-
|
|
49
|
-
const {
|
|
50
|
-
attributes: {
|
|
51
|
-
style
|
|
52
|
-
},
|
|
53
|
-
setAttributes
|
|
54
|
-
} = props;
|
|
55
|
-
|
|
56
|
-
function onChange(newSpacing) {
|
|
57
|
-
setAttributes({
|
|
58
|
-
style: (0, _utils.cleanEmptyObject)({ ...style,
|
|
59
|
-
typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
|
|
60
|
-
letterSpacing: newSpacing
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return (0, _element.createElement)(_letterSpacingControl.default, {
|
|
67
|
-
value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.letterSpacing,
|
|
68
|
-
onChange: onChange,
|
|
69
|
-
__unstableInputWidth: '100%',
|
|
70
|
-
size: "__unstable-large"
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Checks if letter-spacing settings have been disabled.
|
|
75
|
-
*
|
|
76
|
-
* @param {string} name Name of the block.
|
|
77
|
-
* @return {boolean} Whether or not the setting is disabled.
|
|
78
|
-
*/
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
function useIsLetterSpacingDisabled() {
|
|
82
|
-
let {
|
|
83
|
-
name: blockName
|
|
84
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
85
|
-
const notSupported = !(0, _blocks.hasBlockSupport)(blockName, LETTER_SPACING_SUPPORT_KEY);
|
|
86
|
-
const hasLetterSpacing = (0, _useSetting.default)('typography.letterSpacing');
|
|
87
|
-
return notSupported || !hasLetterSpacing;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Checks if there is a current value set for the letter spacing block support.
|
|
91
|
-
*
|
|
92
|
-
* @param {Object} props Block props.
|
|
93
|
-
* @return {boolean} Whether or not the block has a letter spacing set.
|
|
94
|
-
*/
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
function hasLetterSpacingValue(props) {
|
|
98
|
-
var _props$attributes$sty, _props$attributes$sty2;
|
|
99
|
-
|
|
100
|
-
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);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Resets the letter spacing block support attribute. This can be used when
|
|
104
|
-
* disabling the letter spacing support controls for a block via a progressive
|
|
105
|
-
* discovery panel.
|
|
106
|
-
*
|
|
107
|
-
* @param {Object} props Block props.
|
|
108
|
-
* @param {Object} props.attributes Block's attributes.
|
|
109
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
110
|
-
*/
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
function resetLetterSpacing(_ref) {
|
|
114
|
-
let {
|
|
115
|
-
attributes = {},
|
|
116
|
-
setAttributes
|
|
117
|
-
} = _ref;
|
|
118
|
-
const {
|
|
119
|
-
style
|
|
120
|
-
} = attributes;
|
|
121
|
-
setAttributes({
|
|
122
|
-
style: (0, _utils.cleanEmptyObject)({ ...style,
|
|
123
|
-
typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
|
|
124
|
-
letterSpacing: undefined
|
|
125
|
-
}
|
|
126
|
-
})
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
//# sourceMappingURL=letter-spacing.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/letter-spacing.js"],"names":["LETTER_SPACING_SUPPORT_KEY","LetterSpacingEdit","props","attributes","style","setAttributes","onChange","newSpacing","typography","letterSpacing","useIsLetterSpacingDisabled","name","blockName","notSupported","hasLetterSpacing","hasLetterSpacingValue","resetLetterSpacing","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;;;;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,UAAnB,EAAgC;AAC/BF,IAAAA,aAAa,CAAE;AACdD,MAAAA,KAAK,EAAE,6BAAkB,EACxB,GAAGA,KADqB;AAExBI,QAAAA,UAAU,EAAE,EACX,IAAGJ,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEI,UAAV,CADW;AAEXC,UAAAA,aAAa,EAAEF;AAFJ;AAFY,OAAlB;AADO,KAAF,CAAb;AASA;;AAED,SACC,4BAAC,6BAAD;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;;;AACO,SAASI,0BAAT,GAAgE;AAAA,MAA3B;AAAEC,IAAAA,IAAI,EAAEC;AAAR,GAA2B,uEAAL,EAAK;AACtE,QAAMC,YAAY,GAAG,CAAE,6BACtBD,SADsB,EAEtBZ,0BAFsB,CAAvB;AAIA,QAAMc,gBAAgB,GAAG,yBAAY,0BAAZ,CAAzB;AAEA,SAAOD,YAAY,IAAI,CAAEC,gBAAzB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,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;;;AACO,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,EAAE,6BAAkB,EACxB,GAAGA,KADqB;AAExBI,MAAAA,UAAU,EAAE,EACX,IAAGJ,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEI,UAAV,CADW;AAEXC,QAAAA,aAAa,EAAEQ;AAFJ;AAFY,KAAlB;AADO,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"]}
|
|
@@ -1,139 +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.MinHeightEdit = MinHeightEdit;
|
|
9
|
-
exports.hasMinHeightSupport = hasMinHeightSupport;
|
|
10
|
-
exports.hasMinHeightValue = hasMinHeightValue;
|
|
11
|
-
exports.resetMinHeight = resetMinHeight;
|
|
12
|
-
exports.useIsMinHeightDisabled = useIsMinHeightDisabled;
|
|
13
|
-
|
|
14
|
-
var _element = require("@wordpress/element");
|
|
15
|
-
|
|
16
|
-
var _blocks = require("@wordpress/blocks");
|
|
17
|
-
|
|
18
|
-
var _i18n = require("@wordpress/i18n");
|
|
19
|
-
|
|
20
|
-
var _useSetting = _interopRequireDefault(require("../components/use-setting"));
|
|
21
|
-
|
|
22
|
-
var _heightControl = _interopRequireDefault(require("../components/height-control"));
|
|
23
|
-
|
|
24
|
-
var _dimensions = require("./dimensions");
|
|
25
|
-
|
|
26
|
-
var _utils = require("./utils");
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* WordPress dependencies
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Internal dependencies
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Determines if there is minHeight support.
|
|
38
|
-
*
|
|
39
|
-
* @param {string|Object} blockType Block name or Block Type object.
|
|
40
|
-
* @return {boolean} Whether there is support.
|
|
41
|
-
*/
|
|
42
|
-
function hasMinHeightSupport(blockType) {
|
|
43
|
-
const support = (0, _blocks.getBlockSupport)(blockType, _dimensions.DIMENSIONS_SUPPORT_KEY);
|
|
44
|
-
return !!(true === support || support !== null && support !== void 0 && support.minHeight);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Checks if there is a current value in the minHeight block support attributes.
|
|
48
|
-
*
|
|
49
|
-
* @param {Object} props Block props.
|
|
50
|
-
* @return {boolean} Whether or not the block has a minHeight value set.
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
function hasMinHeightValue(props) {
|
|
55
|
-
var _props$attributes$sty, _props$attributes$sty2;
|
|
56
|
-
|
|
57
|
-
return ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : (_props$attributes$sty2 = _props$attributes$sty.dimensions) === null || _props$attributes$sty2 === void 0 ? void 0 : _props$attributes$sty2.minHeight) !== undefined;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Resets the minHeight block support attributes. This can be used when disabling
|
|
61
|
-
* the padding support controls for a block via a `ToolsPanel`.
|
|
62
|
-
*
|
|
63
|
-
* @param {Object} props Block props.
|
|
64
|
-
* @param {Object} props.attributes Block's attributes.
|
|
65
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
function resetMinHeight(_ref) {
|
|
70
|
-
let {
|
|
71
|
-
attributes = {},
|
|
72
|
-
setAttributes
|
|
73
|
-
} = _ref;
|
|
74
|
-
const {
|
|
75
|
-
style
|
|
76
|
-
} = attributes;
|
|
77
|
-
setAttributes({
|
|
78
|
-
style: (0, _utils.cleanEmptyObject)({ ...style,
|
|
79
|
-
dimensions: { ...(style === null || style === void 0 ? void 0 : style.dimensions),
|
|
80
|
-
minHeight: undefined
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Custom hook that checks if minHeight controls have been disabled.
|
|
87
|
-
*
|
|
88
|
-
* @param {string} name The name of the block.
|
|
89
|
-
* @return {boolean} Whether minHeight control is disabled.
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
function useIsMinHeightDisabled() {
|
|
94
|
-
let {
|
|
95
|
-
name: blockName
|
|
96
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
97
|
-
const isDisabled = !(0, _useSetting.default)('dimensions.minHeight');
|
|
98
|
-
return !hasMinHeightSupport(blockName) || isDisabled;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Inspector control panel containing the minHeight related configuration.
|
|
102
|
-
*
|
|
103
|
-
* @param {Object} props Block props.
|
|
104
|
-
* @return {WPElement} Edit component for height.
|
|
105
|
-
*/
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
function MinHeightEdit(props) {
|
|
109
|
-
var _style$dimensions;
|
|
110
|
-
|
|
111
|
-
const {
|
|
112
|
-
attributes: {
|
|
113
|
-
style
|
|
114
|
-
},
|
|
115
|
-
setAttributes
|
|
116
|
-
} = props;
|
|
117
|
-
|
|
118
|
-
if (useIsMinHeightDisabled(props)) {
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const onChange = next => {
|
|
123
|
-
const newStyle = { ...style,
|
|
124
|
-
dimensions: { ...(style === null || style === void 0 ? void 0 : style.dimensions),
|
|
125
|
-
minHeight: next
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
setAttributes({
|
|
129
|
-
style: (0, _utils.cleanEmptyObject)(newStyle)
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
return (0, _element.createElement)(_heightControl.default, {
|
|
134
|
-
label: (0, _i18n.__)('Min. height'),
|
|
135
|
-
value: style === null || style === void 0 ? void 0 : (_style$dimensions = style.dimensions) === null || _style$dimensions === void 0 ? void 0 : _style$dimensions.minHeight,
|
|
136
|
-
onChange: onChange
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
//# sourceMappingURL=min-height.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/min-height.js"],"names":["hasMinHeightSupport","blockType","support","DIMENSIONS_SUPPORT_KEY","minHeight","hasMinHeightValue","props","attributes","style","dimensions","undefined","resetMinHeight","setAttributes","useIsMinHeightDisabled","name","blockName","isDisabled","MinHeightEdit","onChange","next","newStyle"],"mappings":";;;;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAZA;AACA;AACA;;AAIA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,mBAAT,CAA8BC,SAA9B,EAA0C;AAChD,QAAMC,OAAO,GAAG,6BAAiBD,SAAjB,EAA4BE,kCAA5B,CAAhB;AACA,SAAO,CAAC,EAAI,SAASD,OAAT,IAAoBA,OAApB,aAAoBA,OAApB,eAAoBA,OAAO,CAAEE,SAAjC,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,iBAAT,CAA4BC,KAA5B,EAAoC;AAAA;;AAC1C,SAAO,0BAAAA,KAAK,CAACC,UAAN,CAAiBC,KAAjB,0GAAwBC,UAAxB,kFAAoCL,SAApC,MAAkDM,SAAzD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,cAAT,OAA8D;AAAA,MAArC;AAAEJ,IAAAA,UAAU,GAAG,EAAf;AAAmBK,IAAAA;AAAnB,GAAqC;AACpE,QAAM;AAAEJ,IAAAA;AAAF,MAAYD,UAAlB;AAEAK,EAAAA,aAAa,CAAE;AACdJ,IAAAA,KAAK,EAAE,6BAAkB,EACxB,GAAGA,KADqB;AAExBC,MAAAA,UAAU,EAAE,EACX,IAAGD,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEC,UAAV,CADW;AAEXL,QAAAA,SAAS,EAAEM;AAFA;AAFY,KAAlB;AADO,GAAF,CAAb;AASA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,sBAAT,GAA4D;AAAA,MAA3B;AAAEC,IAAAA,IAAI,EAAEC;AAAR,GAA2B,uEAAL,EAAK;AAClE,QAAMC,UAAU,GAAG,CAAE,yBAAY,sBAAZ,CAArB;AACA,SAAO,CAAEhB,mBAAmB,CAAEe,SAAF,CAArB,IAAsCC,UAA7C;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,aAAT,CAAwBX,KAAxB,EAAgC;AAAA;;AACtC,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELI,IAAAA;AAFK,MAGFN,KAHJ;;AAKA,MAAKO,sBAAsB,CAAEP,KAAF,CAA3B,EAAuC;AACtC,WAAO,IAAP;AACA;;AAED,QAAMY,QAAQ,GAAKC,IAAF,IAAY;AAC5B,UAAMC,QAAQ,GAAG,EAChB,GAAGZ,KADa;AAEhBC,MAAAA,UAAU,EAAE,EACX,IAAGD,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEC,UAAV,CADW;AAEXL,QAAAA,SAAS,EAAEe;AAFA;AAFI,KAAjB;AAQAP,IAAAA,aAAa,CAAE;AAAEJ,MAAAA,KAAK,EAAE,6BAAkBY,QAAlB;AAAT,KAAF,CAAb;AACA,GAVD;;AAYA,SACC,4BAAC,sBAAD;AACC,IAAA,KAAK,EAAG,cAAI,aAAJ,CADT;AAEC,IAAA,KAAK,EAAGZ,KAAH,aAAGA,KAAH,4CAAGA,KAAK,CAAEC,UAAV,sDAAG,kBAAmBL,SAF5B;AAGC,IAAA,QAAQ,EAAGc;AAHZ,IADD;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../components/use-setting';\nimport HeightControl from '../components/height-control';\nimport { DIMENSIONS_SUPPORT_KEY } from './dimensions';\nimport { cleanEmptyObject } from './utils';\n\n/**\n * Determines if there is minHeight support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n * @return {boolean} Whether there is support.\n */\nexport function hasMinHeightSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, DIMENSIONS_SUPPORT_KEY );\n\treturn !! ( true === support || support?.minHeight );\n}\n\n/**\n * Checks if there is a current value in the minHeight block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a minHeight value set.\n */\nexport function hasMinHeightValue( props ) {\n\treturn props.attributes.style?.dimensions?.minHeight !== undefined;\n}\n\n/**\n * Resets the minHeight block support attributes. This can be used when disabling\n * the padding support controls for a block via a `ToolsPanel`.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetMinHeight( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tdimensions: {\n\t\t\t\t...style?.dimensions,\n\t\t\t\tminHeight: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if minHeight controls have been disabled.\n *\n * @param {string} name The name of the block.\n * @return {boolean} Whether minHeight control is disabled.\n */\nexport function useIsMinHeightDisabled( { name: blockName } = {} ) {\n\tconst isDisabled = ! useSetting( 'dimensions.minHeight' );\n\treturn ! hasMinHeightSupport( blockName ) || isDisabled;\n}\n\n/**\n * Inspector control panel containing the minHeight related configuration.\n *\n * @param {Object} props Block props.\n * @return {WPElement} Edit component for height.\n */\nexport function MinHeightEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tif ( useIsMinHeightDisabled( props ) ) {\n\t\treturn null;\n\t}\n\n\tconst onChange = ( next ) => {\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tdimensions: {\n\t\t\t\t...style?.dimensions,\n\t\t\t\tminHeight: next,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( { style: cleanEmptyObject( newStyle ) } );\n\t};\n\n\treturn (\n\t\t<HeightControl\n\t\t\tlabel={ __( 'Min. height' ) }\n\t\t\tvalue={ style?.dimensions?.minHeight }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -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_DECORATION_SUPPORT_KEY = void 0;
|
|
9
|
-
exports.TextDecorationEdit = TextDecorationEdit;
|
|
10
|
-
exports.hasTextDecorationValue = hasTextDecorationValue;
|
|
11
|
-
exports.resetTextDecoration = resetTextDecoration;
|
|
12
|
-
exports.useIsTextDecorationDisabled = useIsTextDecorationDisabled;
|
|
13
|
-
|
|
14
|
-
var _element = require("@wordpress/element");
|
|
15
|
-
|
|
16
|
-
var _blocks = require("@wordpress/blocks");
|
|
17
|
-
|
|
18
|
-
var _textDecorationControl = _interopRequireDefault(require("../components/text-decoration-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
|
-
* decorations e.g. settings found in `block.json`.
|
|
35
|
-
*/
|
|
36
|
-
const TEXT_DECORATION_SUPPORT_KEY = 'typography.__experimentalTextDecoration';
|
|
37
|
-
/**
|
|
38
|
-
* Inspector control panel containing the text decoration options.
|
|
39
|
-
*
|
|
40
|
-
* @param {Object} props Block properties.
|
|
41
|
-
*
|
|
42
|
-
* @return {WPElement} Text decoration edit element.
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
exports.TEXT_DECORATION_SUPPORT_KEY = TEXT_DECORATION_SUPPORT_KEY;
|
|
46
|
-
|
|
47
|
-
function TextDecorationEdit(props) {
|
|
48
|
-
var _style$typography;
|
|
49
|
-
|
|
50
|
-
const {
|
|
51
|
-
attributes: {
|
|
52
|
-
style
|
|
53
|
-
},
|
|
54
|
-
setAttributes
|
|
55
|
-
} = props;
|
|
56
|
-
|
|
57
|
-
function onChange(newDecoration) {
|
|
58
|
-
setAttributes({
|
|
59
|
-
style: (0, _utils.cleanEmptyObject)({ ...style,
|
|
60
|
-
typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
|
|
61
|
-
textDecoration: newDecoration
|
|
62
|
-
}
|
|
63
|
-
})
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return (0, _element.createElement)(_textDecorationControl.default, {
|
|
68
|
-
value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.textDecoration,
|
|
69
|
-
onChange: onChange,
|
|
70
|
-
size: "__unstable-large"
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Checks if text-decoration 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 useIsTextDecorationDisabled() {
|
|
83
|
-
let {
|
|
84
|
-
name: blockName
|
|
85
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
86
|
-
const notSupported = !(0, _blocks.hasBlockSupport)(blockName, TEXT_DECORATION_SUPPORT_KEY);
|
|
87
|
-
const hasTextDecoration = (0, _useSetting.default)('typography.textDecoration');
|
|
88
|
-
return notSupported || !hasTextDecoration;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Checks if there is a current value set for the text decoration block support.
|
|
92
|
-
*
|
|
93
|
-
* @param {Object} props Block props.
|
|
94
|
-
* @return {boolean} Whether or not the block has a text decoration set.
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
function hasTextDecorationValue(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.textDecoration);
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Resets the text decoration block support attribute. This can be used when
|
|
105
|
-
* disabling the text decoration 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 resetTextDecoration(_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
|
-
textDecoration: undefined
|
|
126
|
-
}
|
|
127
|
-
})
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
//# sourceMappingURL=text-decoration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/text-decoration.js"],"names":["TEXT_DECORATION_SUPPORT_KEY","TextDecorationEdit","props","attributes","style","setAttributes","onChange","newDecoration","typography","textDecoration","useIsTextDecorationDisabled","name","blockName","notSupported","hasTextDecoration","hasTextDecorationValue","resetTextDecoration","undefined"],"mappings":";;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACO,MAAMA,2BAA2B,GACvC,yCADM;AAGP;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASC,kBAAT,CAA6BC,KAA7B,EAAqC;AAAA;;AAC3C,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADP;AAELC,IAAAA;AAFK,MAGFH,KAHJ;;AAKA,WAASI,QAAT,CAAmBC,aAAnB,EAAmC;AAClCF,IAAAA,aAAa,CAAE;AACdD,MAAAA,KAAK,EAAE,6BAAkB,EACxB,GAAGA,KADqB;AAExBI,QAAAA,UAAU,EAAE,EACX,IAAGJ,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEI,UAAV,CADW;AAEXC,UAAAA,cAAc,EAAEF;AAFL;AAFY,OAAlB;AADO,KAAF,CAAb;AASA;;AAED,SACC,4BAAC,8BAAD;AACC,IAAA,KAAK,EAAGH,KAAH,aAAGA,KAAH,4CAAGA,KAAK,CAAEI,UAAV,sDAAG,kBAAmBC,cAD5B;AAEC,IAAA,QAAQ,EAAGH,QAFZ;AAGC,IAAA,IAAI,EAAC;AAHN,IADD;AAOA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASI,2BAAT,GAAiE;AAAA,MAA3B;AAAEC,IAAAA,IAAI,EAAEC;AAAR,GAA2B,uEAAL,EAAK;AACvE,QAAMC,YAAY,GAAG,CAAE,6BACtBD,SADsB,EAEtBZ,2BAFsB,CAAvB;AAIA,QAAMc,iBAAiB,GAAG,yBAAY,2BAAZ,CAA1B;AAEA,SAAOD,YAAY,IAAI,CAAEC,iBAAzB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,sBAAT,CAAiCb,KAAjC,EAAyC;AAAA;;AAC/C,SAAO,CAAC,2BAAEA,KAAK,CAACC,UAAN,CAAiBC,KAAnB,4EAAE,sBAAwBI,UAA1B,mDAAE,uBAAoCC,cAAtC,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASO,mBAAT,OAAmE;AAAA,MAArC;AAAEb,IAAAA,UAAU,GAAG,EAAf;AAAmBE,IAAAA;AAAnB,GAAqC;AACzE,QAAM;AAAED,IAAAA;AAAF,MAAYD,UAAlB;AAEAE,EAAAA,aAAa,CAAE;AACdD,IAAAA,KAAK,EAAE,6BAAkB,EACxB,GAAGA,KADqB;AAExBI,MAAAA,UAAU,EAAE,EACX,IAAGJ,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEI,UAAV,CADW;AAEXC,QAAAA,cAAc,EAAEQ;AAFL;AAFY,KAAlB;AADO,GAAF,CAAb;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport TextDecorationControl from '../components/text-decoration-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 * decorations e.g. settings found in `block.json`.\n */\nexport const TEXT_DECORATION_SUPPORT_KEY =\n\t'typography.__experimentalTextDecoration';\n\n/**\n * Inspector control panel containing the text decoration options.\n *\n * @param {Object} props Block properties.\n *\n * @return {WPElement} Text decoration edit element.\n */\nexport function TextDecorationEdit( props ) {\n\tconst {\n\t\tattributes: { style },\n\t\tsetAttributes,\n\t} = props;\n\n\tfunction onChange( newDecoration ) {\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\ttextDecoration: newDecoration,\n\t\t\t\t},\n\t\t\t} ),\n\t\t} );\n\t}\n\n\treturn (\n\t\t<TextDecorationControl\n\t\t\tvalue={ style?.typography?.textDecoration }\n\t\t\tonChange={ onChange }\n\t\t\tsize=\"__unstable-large\"\n\t\t/>\n\t);\n}\n\n/**\n * Checks if text-decoration 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 useIsTextDecorationDisabled( { name: blockName } = {} ) {\n\tconst notSupported = ! hasBlockSupport(\n\t\tblockName,\n\t\tTEXT_DECORATION_SUPPORT_KEY\n\t);\n\tconst hasTextDecoration = useSetting( 'typography.textDecoration' );\n\n\treturn notSupported || ! hasTextDecoration;\n}\n\n/**\n * Checks if there is a current value set for the text decoration block support.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a text decoration set.\n */\nexport function hasTextDecorationValue( props ) {\n\treturn !! props.attributes.style?.typography?.textDecoration;\n}\n\n/**\n * Resets the text decoration block support attribute. This can be used when\n * disabling the text decoration 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 resetTextDecoration( { 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\ttextDecoration: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n"]}
|