@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,116 +0,0 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* WordPress dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { getBlockSupport } from '@wordpress/blocks';
|
|
7
|
-
import { __ } from '@wordpress/i18n';
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import useSetting from '../components/use-setting';
|
|
13
|
-
import HeightControl from '../components/height-control';
|
|
14
|
-
import { DIMENSIONS_SUPPORT_KEY } from './dimensions';
|
|
15
|
-
import { cleanEmptyObject } from './utils';
|
|
16
|
-
/**
|
|
17
|
-
* Determines if there is minHeight support.
|
|
18
|
-
*
|
|
19
|
-
* @param {string|Object} blockType Block name or Block Type object.
|
|
20
|
-
* @return {boolean} Whether there is support.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
export function hasMinHeightSupport(blockType) {
|
|
24
|
-
const support = getBlockSupport(blockType, DIMENSIONS_SUPPORT_KEY);
|
|
25
|
-
return !!(true === support || support !== null && support !== void 0 && support.minHeight);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Checks if there is a current value in the minHeight block support attributes.
|
|
29
|
-
*
|
|
30
|
-
* @param {Object} props Block props.
|
|
31
|
-
* @return {boolean} Whether or not the block has a minHeight value set.
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
export function hasMinHeightValue(props) {
|
|
35
|
-
var _props$attributes$sty, _props$attributes$sty2;
|
|
36
|
-
|
|
37
|
-
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;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Resets the minHeight block support attributes. This can be used when disabling
|
|
41
|
-
* the padding support controls for a block via a `ToolsPanel`.
|
|
42
|
-
*
|
|
43
|
-
* @param {Object} props Block props.
|
|
44
|
-
* @param {Object} props.attributes Block's attributes.
|
|
45
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
export function resetMinHeight(_ref) {
|
|
49
|
-
let {
|
|
50
|
-
attributes = {},
|
|
51
|
-
setAttributes
|
|
52
|
-
} = _ref;
|
|
53
|
-
const {
|
|
54
|
-
style
|
|
55
|
-
} = attributes;
|
|
56
|
-
setAttributes({
|
|
57
|
-
style: cleanEmptyObject({ ...style,
|
|
58
|
-
dimensions: { ...(style === null || style === void 0 ? void 0 : style.dimensions),
|
|
59
|
-
minHeight: undefined
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Custom hook that checks if minHeight controls have been disabled.
|
|
66
|
-
*
|
|
67
|
-
* @param {string} name The name of the block.
|
|
68
|
-
* @return {boolean} Whether minHeight control is disabled.
|
|
69
|
-
*/
|
|
70
|
-
|
|
71
|
-
export function useIsMinHeightDisabled() {
|
|
72
|
-
let {
|
|
73
|
-
name: blockName
|
|
74
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
75
|
-
const isDisabled = !useSetting('dimensions.minHeight');
|
|
76
|
-
return !hasMinHeightSupport(blockName) || isDisabled;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Inspector control panel containing the minHeight related configuration.
|
|
80
|
-
*
|
|
81
|
-
* @param {Object} props Block props.
|
|
82
|
-
* @return {WPElement} Edit component for height.
|
|
83
|
-
*/
|
|
84
|
-
|
|
85
|
-
export function MinHeightEdit(props) {
|
|
86
|
-
var _style$dimensions;
|
|
87
|
-
|
|
88
|
-
const {
|
|
89
|
-
attributes: {
|
|
90
|
-
style
|
|
91
|
-
},
|
|
92
|
-
setAttributes
|
|
93
|
-
} = props;
|
|
94
|
-
|
|
95
|
-
if (useIsMinHeightDisabled(props)) {
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const onChange = next => {
|
|
100
|
-
const newStyle = { ...style,
|
|
101
|
-
dimensions: { ...(style === null || style === void 0 ? void 0 : style.dimensions),
|
|
102
|
-
minHeight: next
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
setAttributes({
|
|
106
|
-
style: cleanEmptyObject(newStyle)
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
return createElement(HeightControl, {
|
|
111
|
-
label: __('Min. height'),
|
|
112
|
-
value: style === null || style === void 0 ? void 0 : (_style$dimensions = style.dimensions) === null || _style$dimensions === void 0 ? void 0 : _style$dimensions.minHeight,
|
|
113
|
-
onChange: onChange
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
//# sourceMappingURL=min-height.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/min-height.js"],"names":["getBlockSupport","__","useSetting","HeightControl","DIMENSIONS_SUPPORT_KEY","cleanEmptyObject","hasMinHeightSupport","blockType","support","minHeight","hasMinHeightValue","props","attributes","style","dimensions","undefined","resetMinHeight","setAttributes","useIsMinHeightDisabled","name","blockName","isDisabled","MinHeightEdit","onChange","next","newStyle"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,mBAAhC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,2BAAvB;AACA,OAAOC,aAAP,MAA0B,8BAA1B;AACA,SAASC,sBAAT,QAAuC,cAAvC;AACA,SAASC,gBAAT,QAAiC,SAAjC;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,mBAAT,CAA8BC,SAA9B,EAA0C;AAChD,QAAMC,OAAO,GAAGR,eAAe,CAAEO,SAAF,EAAaH,sBAAb,CAA/B;AACA,SAAO,CAAC,EAAI,SAASI,OAAT,IAAoBA,OAApB,aAAoBA,OAApB,eAAoBA,OAAO,CAAEC,SAAjC,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,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;;AACA,OAAO,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,EAAER,gBAAgB,CAAE,EACxB,GAAGQ,KADqB;AAExBC,MAAAA,UAAU,EAAE,EACX,IAAGD,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEC,UAAV,CADW;AAEXL,QAAAA,SAAS,EAAEM;AAFA;AAFY,KAAF;AADT,GAAF,CAAb;AASA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASG,sBAAT,GAA4D;AAAA,MAA3B;AAAEC,IAAAA,IAAI,EAAEC;AAAR,GAA2B,uEAAL,EAAK;AAClE,QAAMC,UAAU,GAAG,CAAEnB,UAAU,CAAE,sBAAF,CAA/B;AACA,SAAO,CAAEI,mBAAmB,CAAEc,SAAF,CAArB,IAAsCC,UAA7C;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,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,EAAER,gBAAgB,CAAEoB,QAAF;AAAzB,KAAF,CAAb;AACA,GAVD;;AAYA,SACC,cAAC,aAAD;AACC,IAAA,KAAK,EAAGxB,EAAE,CAAE,aAAF,CADX;AAEC,IAAA,KAAK,EAAGY,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,108 +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 TextDecorationControl from '../components/text-decoration-control';
|
|
12
|
-
import useSetting from '../components/use-setting';
|
|
13
|
-
import { cleanEmptyObject } from './utils';
|
|
14
|
-
/**
|
|
15
|
-
* Key within block settings' supports array indicating support for text
|
|
16
|
-
* decorations e.g. settings found in `block.json`.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
export const TEXT_DECORATION_SUPPORT_KEY = 'typography.__experimentalTextDecoration';
|
|
20
|
-
/**
|
|
21
|
-
* Inspector control panel containing the text decoration options.
|
|
22
|
-
*
|
|
23
|
-
* @param {Object} props Block properties.
|
|
24
|
-
*
|
|
25
|
-
* @return {WPElement} Text decoration edit element.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
export function TextDecorationEdit(props) {
|
|
29
|
-
var _style$typography;
|
|
30
|
-
|
|
31
|
-
const {
|
|
32
|
-
attributes: {
|
|
33
|
-
style
|
|
34
|
-
},
|
|
35
|
-
setAttributes
|
|
36
|
-
} = props;
|
|
37
|
-
|
|
38
|
-
function onChange(newDecoration) {
|
|
39
|
-
setAttributes({
|
|
40
|
-
style: cleanEmptyObject({ ...style,
|
|
41
|
-
typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
|
|
42
|
-
textDecoration: newDecoration
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return createElement(TextDecorationControl, {
|
|
49
|
-
value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.textDecoration,
|
|
50
|
-
onChange: onChange,
|
|
51
|
-
size: "__unstable-large"
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Checks if text-decoration settings have been disabled.
|
|
56
|
-
*
|
|
57
|
-
* @param {string} name Name of the block.
|
|
58
|
-
*
|
|
59
|
-
* @return {boolean} Whether or not the setting is disabled.
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
export function useIsTextDecorationDisabled() {
|
|
63
|
-
let {
|
|
64
|
-
name: blockName
|
|
65
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
66
|
-
const notSupported = !hasBlockSupport(blockName, TEXT_DECORATION_SUPPORT_KEY);
|
|
67
|
-
const hasTextDecoration = useSetting('typography.textDecoration');
|
|
68
|
-
return notSupported || !hasTextDecoration;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Checks if there is a current value set for the text decoration block support.
|
|
72
|
-
*
|
|
73
|
-
* @param {Object} props Block props.
|
|
74
|
-
* @return {boolean} Whether or not the block has a text decoration set.
|
|
75
|
-
*/
|
|
76
|
-
|
|
77
|
-
export function hasTextDecorationValue(props) {
|
|
78
|
-
var _props$attributes$sty, _props$attributes$sty2;
|
|
79
|
-
|
|
80
|
-
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);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Resets the text decoration block support attribute. This can be used when
|
|
84
|
-
* disabling the text decoration support controls for a block via a progressive
|
|
85
|
-
* discovery panel.
|
|
86
|
-
*
|
|
87
|
-
* @param {Object} props Block props.
|
|
88
|
-
* @param {Object} props.attributes Block's attributes.
|
|
89
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
export function resetTextDecoration(_ref) {
|
|
93
|
-
let {
|
|
94
|
-
attributes = {},
|
|
95
|
-
setAttributes
|
|
96
|
-
} = _ref;
|
|
97
|
-
const {
|
|
98
|
-
style
|
|
99
|
-
} = attributes;
|
|
100
|
-
setAttributes({
|
|
101
|
-
style: cleanEmptyObject({ ...style,
|
|
102
|
-
typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
|
|
103
|
-
textDecoration: undefined
|
|
104
|
-
}
|
|
105
|
-
})
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
//# sourceMappingURL=text-decoration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/text-decoration.js"],"names":["hasBlockSupport","TextDecorationControl","useSetting","cleanEmptyObject","TEXT_DECORATION_SUPPORT_KEY","TextDecorationEdit","props","attributes","style","setAttributes","onChange","newDecoration","typography","textDecoration","useIsTextDecorationDisabled","name","blockName","notSupported","hasTextDecoration","hasTextDecorationValue","resetTextDecoration","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;;AACA,OAAO,MAAMC,2BAA2B,GACvC,yCADM;AAGP;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,WAASI,QAAT,CAAmBC,aAAnB,EAAmC;AAClCF,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,cAAc,EAAEF;AAFL;AAFY,OAAF;AADT,KAAF,CAAb;AASA;;AAED,SACC,cAAC,qBAAD;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;;AACA,OAAO,SAASI,2BAAT,GAAiE;AAAA,MAA3B;AAAEC,IAAAA,IAAI,EAAEC;AAAR,GAA2B,uEAAL,EAAK;AACvE,QAAMC,YAAY,GAAG,CAAEjB,eAAe,CACrCgB,SADqC,EAErCZ,2BAFqC,CAAtC;AAIA,QAAMc,iBAAiB,GAAGhB,UAAU,CAAE,2BAAF,CAApC;AAEA,SAAOe,YAAY,IAAI,CAAEC,iBAAzB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,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;;AACA,OAAO,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,EAAEL,gBAAgB,CAAE,EACxB,GAAGK,KADqB;AAExBI,MAAAA,UAAU,EAAE,EACX,IAAGJ,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEI,UAAV,CADW;AAEXC,QAAAA,cAAc,EAAEQ;AAFL;AAFY,KAAF;AADT,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"]}
|
|
@@ -1,108 +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 TextTransformControl from '../components/text-transform-control';
|
|
12
|
-
import useSetting from '../components/use-setting';
|
|
13
|
-
import { cleanEmptyObject } from './utils';
|
|
14
|
-
/**
|
|
15
|
-
* Key within block settings' supports array indicating support for text
|
|
16
|
-
* transforms e.g. settings found in `block.json`.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
export const TEXT_TRANSFORM_SUPPORT_KEY = 'typography.__experimentalTextTransform';
|
|
20
|
-
/**
|
|
21
|
-
* Inspector control panel containing the text transform options.
|
|
22
|
-
*
|
|
23
|
-
* @param {Object} props Block properties.
|
|
24
|
-
*
|
|
25
|
-
* @return {WPElement} Text transform edit element.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
export function TextTransformEdit(props) {
|
|
29
|
-
var _style$typography;
|
|
30
|
-
|
|
31
|
-
const {
|
|
32
|
-
attributes: {
|
|
33
|
-
style
|
|
34
|
-
},
|
|
35
|
-
setAttributes
|
|
36
|
-
} = props;
|
|
37
|
-
|
|
38
|
-
function onChange(newTransform) {
|
|
39
|
-
setAttributes({
|
|
40
|
-
style: cleanEmptyObject({ ...style,
|
|
41
|
-
typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
|
|
42
|
-
textTransform: newTransform
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return createElement(TextTransformControl, {
|
|
49
|
-
value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.textTransform,
|
|
50
|
-
onChange: onChange,
|
|
51
|
-
size: "__unstable-large"
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Checks if text-transform settings have been disabled.
|
|
56
|
-
*
|
|
57
|
-
* @param {string} name Name of the block.
|
|
58
|
-
*
|
|
59
|
-
* @return {boolean} Whether or not the setting is disabled.
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
export function useIsTextTransformDisabled() {
|
|
63
|
-
let {
|
|
64
|
-
name: blockName
|
|
65
|
-
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
66
|
-
const notSupported = !hasBlockSupport(blockName, TEXT_TRANSFORM_SUPPORT_KEY);
|
|
67
|
-
const hasTextTransforms = useSetting('typography.textTransform');
|
|
68
|
-
return notSupported || !hasTextTransforms;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Checks if there is a current value set for the text transform block support.
|
|
72
|
-
*
|
|
73
|
-
* @param {Object} props Block props.
|
|
74
|
-
* @return {boolean} Whether or not the block has a text transform set.
|
|
75
|
-
*/
|
|
76
|
-
|
|
77
|
-
export function hasTextTransformValue(props) {
|
|
78
|
-
var _props$attributes$sty, _props$attributes$sty2;
|
|
79
|
-
|
|
80
|
-
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);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Resets the text transform block support attribute. This can be used when
|
|
84
|
-
* disabling the text transform support controls for a block via a progressive
|
|
85
|
-
* discovery panel.
|
|
86
|
-
*
|
|
87
|
-
* @param {Object} props Block props.
|
|
88
|
-
* @param {Object} props.attributes Block's attributes.
|
|
89
|
-
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
90
|
-
*/
|
|
91
|
-
|
|
92
|
-
export function resetTextTransform(_ref) {
|
|
93
|
-
let {
|
|
94
|
-
attributes = {},
|
|
95
|
-
setAttributes
|
|
96
|
-
} = _ref;
|
|
97
|
-
const {
|
|
98
|
-
style
|
|
99
|
-
} = attributes;
|
|
100
|
-
setAttributes({
|
|
101
|
-
style: cleanEmptyObject({ ...style,
|
|
102
|
-
typography: { ...(style === null || style === void 0 ? void 0 : style.typography),
|
|
103
|
-
textTransform: undefined
|
|
104
|
-
}
|
|
105
|
-
})
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
//# sourceMappingURL=text-transform.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/text-transform.js"],"names":["hasBlockSupport","TextTransformControl","useSetting","cleanEmptyObject","TEXT_TRANSFORM_SUPPORT_KEY","TextTransformEdit","props","attributes","style","setAttributes","onChange","newTransform","typography","textTransform","useIsTextTransformDisabled","name","blockName","notSupported","hasTextTransforms","hasTextTransformValue","resetTextTransform","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;;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,YAAnB,EAAkC;AACjCF,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,IAAI,EAAC;AAHN,IADD;AAOA;AAED;AACA;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,iBAAiB,GAAGhB,UAAU,CAAE,0BAAF,CAApC;AACA,SAAOe,YAAY,IAAI,CAAEC,iBAAzB;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 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,195 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import {
|
|
5
|
-
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
6
|
-
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
7
|
-
__experimentalUnitControl as UnitControl,
|
|
8
|
-
} from '@wordpress/components';
|
|
9
|
-
import { __ } from '@wordpress/i18n';
|
|
10
|
-
import { useEffect } from '@wordpress/element';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
import useSetting from '../components/use-setting';
|
|
16
|
-
|
|
17
|
-
function helpText( selfStretch, parentLayout ) {
|
|
18
|
-
const { orientation = 'horizontal' } = parentLayout;
|
|
19
|
-
|
|
20
|
-
if ( selfStretch === 'fill' ) {
|
|
21
|
-
return __( 'Stretch to fill available space.' );
|
|
22
|
-
}
|
|
23
|
-
if ( selfStretch === 'fixed' ) {
|
|
24
|
-
if ( orientation === 'horizontal' ) {
|
|
25
|
-
return __( 'Specify a fixed width.' );
|
|
26
|
-
}
|
|
27
|
-
return __( 'Specify a fixed height.' );
|
|
28
|
-
}
|
|
29
|
-
return __( 'Fit contents.' );
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Inspector controls containing the child layout related configuration.
|
|
34
|
-
*
|
|
35
|
-
* @param {Object} props Block props.
|
|
36
|
-
* @param {Object} props.attributes Block attributes.
|
|
37
|
-
* @param {Object} props.setAttributes Function to set block attributes.
|
|
38
|
-
* @param {Object} props.__unstableParentLayout
|
|
39
|
-
*
|
|
40
|
-
* @return {WPElement} child layout edit element.
|
|
41
|
-
*/
|
|
42
|
-
export function ChildLayoutEdit( {
|
|
43
|
-
attributes,
|
|
44
|
-
setAttributes,
|
|
45
|
-
__unstableParentLayout: parentLayout,
|
|
46
|
-
} ) {
|
|
47
|
-
const { style = {} } = attributes;
|
|
48
|
-
const { layout: childLayout = {} } = style;
|
|
49
|
-
const { selfStretch, flexSize } = childLayout;
|
|
50
|
-
|
|
51
|
-
useEffect( () => {
|
|
52
|
-
if ( selfStretch === 'fixed' && ! flexSize ) {
|
|
53
|
-
setAttributes( {
|
|
54
|
-
style: {
|
|
55
|
-
...style,
|
|
56
|
-
layout: {
|
|
57
|
-
...childLayout,
|
|
58
|
-
selfStretch: 'fit',
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
} );
|
|
62
|
-
}
|
|
63
|
-
}, [] );
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<>
|
|
67
|
-
<ToggleGroupControl
|
|
68
|
-
__nextHasNoMarginBottom
|
|
69
|
-
size={ '__unstable-large' }
|
|
70
|
-
label={ childLayoutOrientation( parentLayout ) }
|
|
71
|
-
value={ selfStretch || 'fit' }
|
|
72
|
-
help={ helpText( selfStretch, parentLayout ) }
|
|
73
|
-
onChange={ ( value ) => {
|
|
74
|
-
const newFlexSize = value !== 'fixed' ? null : flexSize;
|
|
75
|
-
setAttributes( {
|
|
76
|
-
style: {
|
|
77
|
-
...style,
|
|
78
|
-
layout: {
|
|
79
|
-
...childLayout,
|
|
80
|
-
selfStretch: value,
|
|
81
|
-
flexSize: newFlexSize,
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
} );
|
|
85
|
-
} }
|
|
86
|
-
isBlock={ true }
|
|
87
|
-
>
|
|
88
|
-
<ToggleGroupControlOption
|
|
89
|
-
key={ 'fit' }
|
|
90
|
-
value={ 'fit' }
|
|
91
|
-
label={ __( 'Fit' ) }
|
|
92
|
-
/>
|
|
93
|
-
<ToggleGroupControlOption
|
|
94
|
-
key={ 'fill' }
|
|
95
|
-
value={ 'fill' }
|
|
96
|
-
label={ __( 'Fill' ) }
|
|
97
|
-
/>
|
|
98
|
-
<ToggleGroupControlOption
|
|
99
|
-
key={ 'fixed' }
|
|
100
|
-
value={ 'fixed' }
|
|
101
|
-
label={ __( 'Fixed' ) }
|
|
102
|
-
/>
|
|
103
|
-
</ToggleGroupControl>
|
|
104
|
-
{ selfStretch === 'fixed' && (
|
|
105
|
-
<UnitControl
|
|
106
|
-
size={ '__unstable-large' }
|
|
107
|
-
onChange={ ( value ) => {
|
|
108
|
-
setAttributes( {
|
|
109
|
-
style: {
|
|
110
|
-
...style,
|
|
111
|
-
layout: {
|
|
112
|
-
...childLayout,
|
|
113
|
-
flexSize: value,
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
} );
|
|
117
|
-
} }
|
|
118
|
-
value={ flexSize }
|
|
119
|
-
/>
|
|
120
|
-
) }
|
|
121
|
-
</>
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Determines if there is child layout support.
|
|
127
|
-
*
|
|
128
|
-
* @param {Object} props Block Props object.
|
|
129
|
-
* @param {Object} props.__unstableParentLayout Parent layout.
|
|
130
|
-
*
|
|
131
|
-
* @return {boolean} Whether there is support.
|
|
132
|
-
*/
|
|
133
|
-
export function hasChildLayoutSupport( {
|
|
134
|
-
__unstableParentLayout: parentLayout = {},
|
|
135
|
-
} ) {
|
|
136
|
-
const {
|
|
137
|
-
type: parentLayoutType = 'default',
|
|
138
|
-
default: { type: defaultParentLayoutType = 'default' } = {},
|
|
139
|
-
allowSizingOnChildren = false,
|
|
140
|
-
} = parentLayout;
|
|
141
|
-
|
|
142
|
-
const support =
|
|
143
|
-
( defaultParentLayoutType === 'flex' || parentLayoutType === 'flex' ) &&
|
|
144
|
-
allowSizingOnChildren;
|
|
145
|
-
|
|
146
|
-
return support;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Checks if there is a current value in the child layout attributes.
|
|
151
|
-
*
|
|
152
|
-
* @param {Object} props Block props.
|
|
153
|
-
* @return {boolean} Whether or not the block has a child layout value set.
|
|
154
|
-
*/
|
|
155
|
-
export function hasChildLayoutValue( props ) {
|
|
156
|
-
return props.attributes.style?.layout !== undefined;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Resets the child layout attribute. This can be used when disabling
|
|
161
|
-
* child layout controls for a block via a progressive discovery panel.
|
|
162
|
-
*
|
|
163
|
-
* @param {Object} props Block props.
|
|
164
|
-
* @param {Object} props.attributes Block attributes.
|
|
165
|
-
* @param {Object} props.setAttributes Function to set block attributes.
|
|
166
|
-
*/
|
|
167
|
-
export function resetChildLayout( { attributes = {}, setAttributes } ) {
|
|
168
|
-
const { style } = attributes;
|
|
169
|
-
|
|
170
|
-
setAttributes( {
|
|
171
|
-
style: {
|
|
172
|
-
...style,
|
|
173
|
-
layout: undefined,
|
|
174
|
-
},
|
|
175
|
-
} );
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Custom hook that checks if child layout settings have been disabled.
|
|
180
|
-
*
|
|
181
|
-
* @param {Object} props Block props.
|
|
182
|
-
*
|
|
183
|
-
* @return {boolean} Whether the child layout setting is disabled.
|
|
184
|
-
*/
|
|
185
|
-
export function useIsChildLayoutDisabled( props ) {
|
|
186
|
-
const isDisabled = ! useSetting( 'layout' );
|
|
187
|
-
|
|
188
|
-
return ! hasChildLayoutSupport( props ) || isDisabled;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
export function childLayoutOrientation( parentLayout ) {
|
|
192
|
-
const { orientation = 'horizontal' } = parentLayout;
|
|
193
|
-
|
|
194
|
-
return orientation === 'horizontal' ? __( 'Width' ) : __( 'Height' );
|
|
195
|
-
}
|