@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
|
@@ -31,7 +31,11 @@ function parseUnit(cssUnit) {
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
function calculate(expression) {
|
|
34
|
-
|
|
34
|
+
try {
|
|
35
|
+
return Function(`'use strict'; return (${expression})`)();
|
|
36
|
+
} catch (err) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
35
39
|
}
|
|
36
40
|
/**
|
|
37
41
|
* Calculates the css function value for the supported css functions such as max, min, clamp and calc.
|
|
@@ -133,8 +137,10 @@ function isMathExpression(cssUnit) {
|
|
|
133
137
|
|
|
134
138
|
function evalMathExpression(cssUnit) {
|
|
135
139
|
let errorFound = false; // Convert every part of the expression to px values.
|
|
140
|
+
// The following regex matches numbers that have a following unit
|
|
141
|
+
// E.g. 5.25rem, 1vw
|
|
136
142
|
|
|
137
|
-
const cssUnitsBits = cssUnit.
|
|
143
|
+
const cssUnitsBits = cssUnit.match(/\d+\.?\d*[a-zA-Z]+|\.\d+[a-zA-Z]+/g);
|
|
138
144
|
|
|
139
145
|
for (const unit of cssUnitsBits) {
|
|
140
146
|
// Standardize the unit to px and extract the value.
|
|
@@ -147,9 +153,36 @@ function evalMathExpression(cssUnit) {
|
|
|
147
153
|
}
|
|
148
154
|
|
|
149
155
|
cssUnit = cssUnit.replace(unit, parsedUnit.value);
|
|
156
|
+
} // For mixed math expressions wrapped within CSS expressions
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
if (!errorFound && cssUnit.match(/(max|min|clamp)/g)) {
|
|
160
|
+
const values = cssUnit.split(',');
|
|
161
|
+
|
|
162
|
+
for (const currentValue of values) {
|
|
163
|
+
// Check for nested calc() and remove them to calculate the value.
|
|
164
|
+
const rawCurrentValue = currentValue.replace(/\s|calc/g, '');
|
|
165
|
+
|
|
166
|
+
if (isMathExpression(rawCurrentValue)) {
|
|
167
|
+
const calculatedExpression = calculate(rawCurrentValue);
|
|
168
|
+
|
|
169
|
+
if (calculatedExpression) {
|
|
170
|
+
const calculatedValue = calculatedExpression.toFixed(0) + 'px';
|
|
171
|
+
cssUnit = cssUnit.replace(currentValue, calculatedValue);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const parsedValue = parseUnitFunction(cssUnit);
|
|
177
|
+
return !parsedValue ? null : parsedValue.value + parsedValue.unit;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (errorFound) {
|
|
181
|
+
return null;
|
|
150
182
|
}
|
|
151
183
|
|
|
152
|
-
|
|
184
|
+
const calculatedResult = calculate(cssUnit);
|
|
185
|
+
return calculatedResult ? calculatedResult.toFixed(0) + 'px' : null;
|
|
153
186
|
}
|
|
154
187
|
/**
|
|
155
188
|
* Convert a parsedUnit object to px value.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/utils/parse-css-unit-to-px.js"],"names":["parseUnit","cssUnit","match","trim","isNaN","parseFloat","value","unit","undefined","calculate","expression","Function","getFunctionUnitValue","functionUnitValue","options","functionUnit","split","filter","Boolean","units","slice","map","getPxFromCssUnit","Math","min","max","length","parseUnitFunction","currentCssUnit","regExp","matches","exec","replace","isMathExpression","i","includes","evalMathExpression","errorFound","cssUnitsBits","parsedUnit","toFixed","convertParsedUnitToPx","PIXELS_PER_INCH","ONE_PERCENT","defaultProperties","fontSize","lineHeight","width","height","type","setOptions","Object","assign","relativeUnits","em","rem","vh","vw","vmin","vmax","ch","ex","lh","absoluteUnits","in","cm","mm","pt","pc","px","Q","Number","isFinite","cache","memoizedGetPxFromCssUnit","hash","hashOptions","hasOwnProperty"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAT,CAAoBC,OAApB,EAA8B;AAC7B,QAAMC,KAAK,GAAGD,OAAH,aAAGA,OAAH,uBAAGA,OAAO,CAClBE,IADW,GAEZD,KAFY,CAGZ,6EAHY,CAAd;;AAKA,MAAK,CAAEE,KAAK,CAAEH,OAAF,CAAP,IAAsB,CAAEG,KAAK,CAAEC,UAAU,CAAEJ,OAAF,CAAZ,CAAlC,EAA8D;AAC7D,WAAO;AAAEK,MAAAA,KAAK,EAAED,UAAU,CAAEJ,OAAF,CAAnB;AAAgCM,MAAAA,IAAI,EAAE;AAAtC,KAAP;AACA;;AACD,SAAOL,KAAK,GACT;AAAEI,IAAAA,KAAK,EAAED,UAAU,CAAEH,KAAK,CAAE,CAAF,CAAP,CAAV,IAA4BA,KAAK,CAAE,CAAF,CAA1C;AAAiDK,IAAAA,IAAI,EAAEL,KAAK,CAAE,CAAF;AAA5D,GADS,GAET;AAAEI,IAAAA,KAAK,EAAEL,OAAT;AAAkBM,IAAAA,IAAI,EAAEC;AAAxB,G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AAC+D,cAAR,CAAwB,UAAxB,CAAL,EAA4C;AAC3CF,IAAAA,IAAI,GAAG,MAAM7D,OAAO,CAACiC,KAArB;AACA;;AACD,MAAKjC,OAAO,CAAC+D,cAAR,CAAwB,YAAxB,CAAL,EAA8C;AAC7CF,IAAAA,IAAI,GAAG,MAAM7D,OAAO,CAACgC,UAArB;AACA;;AACD,MAAKhC,OAAO,CAAC+D,cAAR,CAAwB,OAAxB,CAAL,EAAyC;AACxCF,IAAAA,IAAI,GAAG,MAAM7D,OAAO,CAACiC,KAArB;AACA;;AACD,MAAKjC,OAAO,CAAC+D,cAAR,CAAwB,QAAxB,CAAL,EAA0C;AACzCF,IAAAA,IAAI,GAAG,MAAM7D,OAAO,CAACkC,MAArB;AACA;;AACD,MAAKlC,OAAO,CAAC+D,cAAR,CAAwB,MAAxB,CAAL,EAAwC;AACvCF,IAAAA,IAAI,GAAG,MAAM7D,OAAO,CAACmC,IAArB;AACA;;AACD,SAAO0B,IAAP;AACA;;AAED,eAAeD,wBAAf","sourcesContent":["/**\n * Converts string to object { value, unit }.\n *\n * @param {string} cssUnit\n * @return {Object} parsedUnit\n */\nfunction parseUnit( cssUnit ) {\n\tconst match = cssUnit\n\t\t?.trim()\n\t\t.match(\n\t\t\t/^(0?[-.]?\\d*\\.?\\d+)(r?e[m|x]|v[h|w|min|max]+|p[x|t|c]|[c|m]m|%|in|ch|Q|lh)$/\n\t\t);\n\tif ( ! isNaN( cssUnit ) && ! isNaN( parseFloat( cssUnit ) ) ) {\n\t\treturn { value: parseFloat( cssUnit ), unit: 'px' };\n\t}\n\treturn match\n\t\t? { value: parseFloat( match[ 1 ] ) || match[ 1 ], unit: match[ 2 ] }\n\t\t: { value: cssUnit, unit: undefined };\n}\n/**\n * Evaluate a math expression.\n *\n * @param {string} expression\n * @return {number} evaluated expression.\n */\nfunction calculate( expression ) {\n\treturn Function( `'use strict'; return (${ expression })` )();\n}\n\n/**\n * Calculates the css function value for the supported css functions such as max, min, clamp and calc.\n *\n * @param {string} functionUnitValue string should be in a particular format (for example min(12px,12px) ) no nested loops.\n * @param {Object} options\n * @return {string} unit containing the unit in PX.\n */\nfunction getFunctionUnitValue( functionUnitValue, options ) {\n\tconst functionUnit = functionUnitValue.split( /[(),]/g ).filter( Boolean );\n\n\tconst units = functionUnit\n\t\t.slice( 1 )\n\t\t.map( ( unit ) => parseUnit( getPxFromCssUnit( unit, options ) ).value )\n\t\t.filter( Boolean );\n\n\tswitch ( functionUnit[ 0 ] ) {\n\t\tcase 'min':\n\t\t\treturn Math.min( ...units ) + 'px';\n\t\tcase 'max':\n\t\t\treturn Math.max( ...units ) + 'px';\n\t\tcase 'clamp':\n\t\t\tif ( units.length !== 3 ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tif ( units[ 1 ] < units[ 0 ] ) {\n\t\t\t\treturn units[ 0 ] + 'px';\n\t\t\t}\n\t\t\tif ( units[ 1 ] > units[ 2 ] ) {\n\t\t\t\treturn units[ 2 ] + 'px';\n\t\t\t}\n\t\t\treturn units[ 1 ] + 'px';\n\t\tcase 'calc':\n\t\t\treturn units[ 0 ] + 'px';\n\t}\n}\n\n/**\n * Take a css function such as min, max, calc, clamp and returns parsedUnit\n *\n * How this works for the nested function is that it first replaces the inner function call.\n * Then it tackles the outer onces.\n * So for example: min( max(25px, 35px), 40px )\n * in the first pass we would replace max(25px, 35px) with 35px.\n * then we would try to evaluate min( 35px, 40px )\n * and then finally return 35px.\n *\n * @param {string} cssUnit\n * @return {Object} parsedUnit object.\n */\nfunction parseUnitFunction( cssUnit ) {\n\twhile ( true ) {\n\t\tconst currentCssUnit = cssUnit;\n\t\tconst regExp = /(max|min|calc|clamp)\\(([^()]*)\\)/g;\n\t\tconst matches = regExp.exec( cssUnit ) || [];\n\t\tif ( matches[ 0 ] ) {\n\t\t\tconst functionUnitValue = getFunctionUnitValue( matches[ 0 ] );\n\t\t\tcssUnit = cssUnit.replace( matches[ 0 ], functionUnitValue );\n\t\t}\n\n\t\t// If the unit hasn't been modified or we have a single value break free.\n\t\tif ( cssUnit === currentCssUnit || parseFloat( cssUnit ) ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn parseUnit( cssUnit );\n}\n/**\n * Return true if we think this is a math expression.\n *\n * @param {string} cssUnit the cssUnit value being evaluted.\n * @return {boolean} Whether the cssUnit is a math expression.\n */\nfunction isMathExpression( cssUnit ) {\n\tfor ( let i = 0; i < cssUnit.length; i++ ) {\n\t\tif ( [ '+', '-', '/', '*' ].includes( cssUnit[ i ] ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n/**\n * Evaluates the math expression and return a px value.\n *\n * @param {string} cssUnit the cssUnit value being evaluted.\n * @return {string} return a converfted value to px.\n */\nfunction evalMathExpression( cssUnit ) {\n\tlet errorFound = false;\n\t// Convert every part of the expression to px values.\n\tconst cssUnitsBits = cssUnit\n\t\t.split( /(?!^-)[+*\\/-](\\s?-)?/g )\n\t\t.filter( Boolean );\n\tfor ( const unit of cssUnitsBits ) {\n\t\t// Standardize the unit to px and extract the value.\n\t\tconst parsedUnit = parseUnit( getPxFromCssUnit( unit ) );\n\t\tif ( ! parseFloat( parsedUnit.value ) ) {\n\t\t\terrorFound = true;\n\t\t\t// End early since we are dealing with a null value.\n\t\t\tbreak;\n\t\t}\n\t\tcssUnit = cssUnit.replace( unit, parsedUnit.value );\n\t}\n\n\treturn errorFound ? null : calculate( cssUnit ).toFixed( 0 ) + 'px';\n}\n\n/**\n * Convert a parsedUnit object to px value.\n *\n * @param {Object} parsedUnit\n * @param {Object} options\n * @return {string} or {null} returns the converted with in a px value format.\n */\nfunction convertParsedUnitToPx( parsedUnit, options ) {\n\tconst PIXELS_PER_INCH = 96;\n\tconst ONE_PERCENT = 0.01;\n\n\tconst defaultProperties = {\n\t\tfontSize: 16,\n\t\tlineHeight: 16,\n\t\twidth: 375,\n\t\theight: 812,\n\t\ttype: 'font',\n\t};\n\n\tconst setOptions = Object.assign( {}, defaultProperties, options );\n\n\tconst relativeUnits = {\n\t\tem: setOptions.fontSize,\n\t\trem: setOptions.fontSize,\n\t\tvh: setOptions.height * ONE_PERCENT,\n\t\tvw: setOptions.width * ONE_PERCENT,\n\t\tvmin:\n\t\t\t( setOptions.width < setOptions.height\n\t\t\t\t? setOptions.width\n\t\t\t\t: setOptions.height ) * ONE_PERCENT,\n\t\tvmax:\n\t\t\t( setOptions.width > setOptions.height\n\t\t\t\t? setOptions.width\n\t\t\t\t: setOptions.height ) * ONE_PERCENT,\n\t\t'%':\n\t\t\t( setOptions.type === 'font'\n\t\t\t\t? setOptions.fontSize\n\t\t\t\t: setOptions.width ) * ONE_PERCENT,\n\t\tch: 8, // The advance measure (width) of the glyph \"0\" of the element's font. Approximate\n\t\tex: 7.15625, // X-height of the element's font. Approximate.\n\t\tlh: setOptions.lineHeight,\n\t};\n\n\tconst absoluteUnits = {\n\t\tin: PIXELS_PER_INCH,\n\t\tcm: PIXELS_PER_INCH / 2.54,\n\t\tmm: PIXELS_PER_INCH / 25.4,\n\t\tpt: PIXELS_PER_INCH / 72,\n\t\tpc: PIXELS_PER_INCH / 6,\n\t\tpx: 1,\n\t\tQ: PIXELS_PER_INCH / 2.54 / 40,\n\t};\n\n\tif ( relativeUnits[ parsedUnit.unit ] ) {\n\t\treturn (\n\t\t\t( relativeUnits[ parsedUnit.unit ] * parsedUnit.value ).toFixed(\n\t\t\t\t0\n\t\t\t) + 'px'\n\t\t);\n\t}\n\n\tif ( absoluteUnits[ parsedUnit.unit ] ) {\n\t\treturn (\n\t\t\t( absoluteUnits[ parsedUnit.unit ] * parsedUnit.value ).toFixed(\n\t\t\t\t0\n\t\t\t) + 'px'\n\t\t);\n\t}\n\n\treturn null;\n}\n\n/**\n * Returns the px value of a cssUnit.\n *\n * @param {string} cssUnit\n * @param {Object} options\n * @return {string} returns the cssUnit value in a simple px format.\n */\nexport function getPxFromCssUnit( cssUnit, options = {} ) {\n\tif ( Number.isFinite( cssUnit ) ) {\n\t\treturn cssUnit.toFixed( 0 ) + 'px';\n\t}\n\tif ( cssUnit === undefined ) {\n\t\treturn null;\n\t}\n\tlet parsedUnit = parseUnit( cssUnit );\n\n\tif ( ! parsedUnit.unit ) {\n\t\tparsedUnit = parseUnitFunction( cssUnit );\n\t}\n\n\tif ( isMathExpression( cssUnit ) && ! parsedUnit.unit ) {\n\t\treturn evalMathExpression( cssUnit );\n\t}\n\n\treturn convertParsedUnitToPx( parsedUnit, options );\n}\n\n// Use simple cache.\nconst cache = {};\n/**\n * Returns the px value of a cssUnit. The memoized version of getPxFromCssUnit;\n *\n * @param {string} cssUnit\n * @param {Object} options\n * @return {string} returns the cssUnit value in a simple px format.\n */\nfunction memoizedGetPxFromCssUnit( cssUnit, options = {} ) {\n\tconst hash = cssUnit + hashOptions( options );\n\n\tif ( ! cache[ hash ] ) {\n\t\tcache[ hash ] = getPxFromCssUnit( cssUnit, options );\n\t}\n\treturn cache[ hash ];\n}\n\nfunction hashOptions( options ) {\n\tlet hash = '';\n\tif ( options.hasOwnProperty( 'fontSize' ) ) {\n\t\thash = ':' + options.width;\n\t}\n\tif ( options.hasOwnProperty( 'lineHeight' ) ) {\n\t\thash = ':' + options.lineHeight;\n\t}\n\tif ( options.hasOwnProperty( 'width' ) ) {\n\t\thash = ':' + options.width;\n\t}\n\tif ( options.hasOwnProperty( 'height' ) ) {\n\t\thash = ':' + options.height;\n\t}\n\tif ( options.hasOwnProperty( 'type' ) ) {\n\t\thash = ':' + options.type;\n\t}\n\treturn hash;\n}\n\nexport default memoizedGetPxFromCssUnit;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/utils/parse-css-unit-to-px.js"],"names":["parseUnit","cssUnit","match","trim","isNaN","parseFloat","value","unit","undefined","calculate","expression","Function","err","getFunctionUnitValue","functionUnitValue","options","functionUnit","split","filter","Boolean","units","slice","map","getPxFromCssUnit","Math","min","max","length","parseUnitFunction","currentCssUnit","regExp","matches","exec","replace","isMathExpression","i","includes","evalMathExpression","errorFound","cssUnitsBits","parsedUnit","values","currentValue","rawCurrentValue","calculatedExpression","calculatedValue","toFixed","parsedValue","calculatedResult","convertParsedUnitToPx","PIXELS_PER_INCH","ONE_PERCENT","defaultProperties","fontSize","lineHeight","width","height","type","setOptions","Object","assign","relativeUnits","em","rem","vh","vw","vmin","vmax","ch","ex","lh","absoluteUnits","in","cm","mm","pt","pc","px","Q","Number","isFinite","cache","memoizedGetPxFromCssUnit","hash","hashOptions","hasOwnProperty"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAT,CAAoBC,OAApB,EAA8B;AAC7B,QAAMC,KAAK,GAAGD,OAAH,aAAGA,OAAH,uBAAGA,OAAO,CAClBE,IADW,GAEZD,KAFY,CAGZ,6EAHY,CAAd;;AAKA,MAAK,CAAEE,KAAK,CAAEH,OAAF,CAAP,IAAsB,CAAEG,KAAK,CAAEC,UAAU,CAAEJ,OAAF,CAAZ,CAAlC,EAA8D;AAC7D,WAAO;AAAEK,MAAAA,KAAK,EAAED,UAAU,CAAEJ,OAAF,CAAnB;AAAgCM,MAAAA,IAAI,EAAE;AAAtC,KAAP;AACA;;AACD,SAAOL,KAAK,GACT;AAAEI,IAAAA,KAAK,EAAED,UAAU,CAAEH,KAAK,CAAE,CAAF,CAAP,CAAV,IAA4BA,KAAK,CAAE,CAAF,CAA1C;AAAiDK,IAAAA,IAAI,EAAEL,KAAK,CAAE,CAAF;AAA5D,GADS,GAET;AAAEI,IAAAA,KAAK,EAAEL,OAAT;AAAkBM,IAAAA,IAAI,EAAEC;AAAxB,GAFH;AAGA;AACD;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,SAAT,CAAoBC,UAApB,EAAiC;AAChC,MAAI;AACH,WAAOC,QAAQ,CAAG,yBAAyBD,UAAY,GAAxC,CAAR,EAAP;AACA,GAFD,CAEE,OAAQE,GAAR,EAAc;AACf,WAAO,IAAP;AACA;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASC,oBAAT,CAA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O0B,IAAP;AACA;;AAED,eAAeD,wBAAf","sourcesContent":["/**\n * Converts string to object { value, unit }.\n *\n * @param {string} cssUnit\n * @return {Object} parsedUnit\n */\nfunction parseUnit( cssUnit ) {\n\tconst match = cssUnit\n\t\t?.trim()\n\t\t.match(\n\t\t\t/^(0?[-.]?\\d*\\.?\\d+)(r?e[m|x]|v[h|w|min|max]+|p[x|t|c]|[c|m]m|%|in|ch|Q|lh)$/\n\t\t);\n\tif ( ! isNaN( cssUnit ) && ! isNaN( parseFloat( cssUnit ) ) ) {\n\t\treturn { value: parseFloat( cssUnit ), unit: 'px' };\n\t}\n\treturn match\n\t\t? { value: parseFloat( match[ 1 ] ) || match[ 1 ], unit: match[ 2 ] }\n\t\t: { value: cssUnit, unit: undefined };\n}\n/**\n * Evaluate a math expression.\n *\n * @param {string} expression\n * @return {number} evaluated expression.\n */\nfunction calculate( expression ) {\n\ttry {\n\t\treturn Function( `'use strict'; return (${ expression })` )();\n\t} catch ( err ) {\n\t\treturn null;\n\t}\n}\n\n/**\n * Calculates the css function value for the supported css functions such as max, min, clamp and calc.\n *\n * @param {string} functionUnitValue string should be in a particular format (for example min(12px,12px) ) no nested loops.\n * @param {Object} options\n * @return {string} unit containing the unit in PX.\n */\nfunction getFunctionUnitValue( functionUnitValue, options ) {\n\tconst functionUnit = functionUnitValue.split( /[(),]/g ).filter( Boolean );\n\n\tconst units = functionUnit\n\t\t.slice( 1 )\n\t\t.map( ( unit ) => parseUnit( getPxFromCssUnit( unit, options ) ).value )\n\t\t.filter( Boolean );\n\n\tswitch ( functionUnit[ 0 ] ) {\n\t\tcase 'min':\n\t\t\treturn Math.min( ...units ) + 'px';\n\t\tcase 'max':\n\t\t\treturn Math.max( ...units ) + 'px';\n\t\tcase 'clamp':\n\t\t\tif ( units.length !== 3 ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tif ( units[ 1 ] < units[ 0 ] ) {\n\t\t\t\treturn units[ 0 ] + 'px';\n\t\t\t}\n\t\t\tif ( units[ 1 ] > units[ 2 ] ) {\n\t\t\t\treturn units[ 2 ] + 'px';\n\t\t\t}\n\t\t\treturn units[ 1 ] + 'px';\n\t\tcase 'calc':\n\t\t\treturn units[ 0 ] + 'px';\n\t}\n}\n\n/**\n * Take a css function such as min, max, calc, clamp and returns parsedUnit\n *\n * How this works for the nested function is that it first replaces the inner function call.\n * Then it tackles the outer onces.\n * So for example: min( max(25px, 35px), 40px )\n * in the first pass we would replace max(25px, 35px) with 35px.\n * then we would try to evaluate min( 35px, 40px )\n * and then finally return 35px.\n *\n * @param {string} cssUnit\n * @return {Object} parsedUnit object.\n */\nfunction parseUnitFunction( cssUnit ) {\n\twhile ( true ) {\n\t\tconst currentCssUnit = cssUnit;\n\t\tconst regExp = /(max|min|calc|clamp)\\(([^()]*)\\)/g;\n\t\tconst matches = regExp.exec( cssUnit ) || [];\n\t\tif ( matches[ 0 ] ) {\n\t\t\tconst functionUnitValue = getFunctionUnitValue( matches[ 0 ] );\n\t\t\tcssUnit = cssUnit.replace( matches[ 0 ], functionUnitValue );\n\t\t}\n\n\t\t// If the unit hasn't been modified or we have a single value break free.\n\t\tif ( cssUnit === currentCssUnit || parseFloat( cssUnit ) ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn parseUnit( cssUnit );\n}\n/**\n * Return true if we think this is a math expression.\n *\n * @param {string} cssUnit the cssUnit value being evaluted.\n * @return {boolean} Whether the cssUnit is a math expression.\n */\nfunction isMathExpression( cssUnit ) {\n\tfor ( let i = 0; i < cssUnit.length; i++ ) {\n\t\tif ( [ '+', '-', '/', '*' ].includes( cssUnit[ i ] ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n/**\n * Evaluates the math expression and return a px value.\n *\n * @param {string} cssUnit the cssUnit value being evaluted.\n * @return {string} return a converfted value to px.\n */\nfunction evalMathExpression( cssUnit ) {\n\tlet errorFound = false;\n\t// Convert every part of the expression to px values.\n\t// The following regex matches numbers that have a following unit\n\t// E.g. 5.25rem, 1vw\n\tconst cssUnitsBits = cssUnit.match( /\\d+\\.?\\d*[a-zA-Z]+|\\.\\d+[a-zA-Z]+/g );\n\tfor ( const unit of cssUnitsBits ) {\n\t\t// Standardize the unit to px and extract the value.\n\t\tconst parsedUnit = parseUnit( getPxFromCssUnit( unit ) );\n\t\tif ( ! parseFloat( parsedUnit.value ) ) {\n\t\t\terrorFound = true;\n\t\t\t// End early since we are dealing with a null value.\n\t\t\tbreak;\n\t\t}\n\t\tcssUnit = cssUnit.replace( unit, parsedUnit.value );\n\t}\n\n\t// For mixed math expressions wrapped within CSS expressions\n\tif ( ! errorFound && cssUnit.match( /(max|min|clamp)/g ) ) {\n\t\tconst values = cssUnit.split( ',' );\n\t\tfor ( const currentValue of values ) {\n\t\t\t// Check for nested calc() and remove them to calculate the value.\n\t\t\tconst rawCurrentValue = currentValue.replace( /\\s|calc/g, '' );\n\n\t\t\tif ( isMathExpression( rawCurrentValue ) ) {\n\t\t\t\tconst calculatedExpression = calculate( rawCurrentValue );\n\n\t\t\t\tif ( calculatedExpression ) {\n\t\t\t\t\tconst calculatedValue =\n\t\t\t\t\t\tcalculatedExpression.toFixed( 0 ) + 'px';\n\t\t\t\t\tcssUnit = cssUnit.replace( currentValue, calculatedValue );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tconst parsedValue = parseUnitFunction( cssUnit );\n\t\treturn ! parsedValue ? null : parsedValue.value + parsedValue.unit;\n\t}\n\n\tif ( errorFound ) {\n\t\treturn null;\n\t}\n\n\tconst calculatedResult = calculate( cssUnit );\n\treturn calculatedResult ? calculatedResult.toFixed( 0 ) + 'px' : null;\n}\n\n/**\n * Convert a parsedUnit object to px value.\n *\n * @param {Object} parsedUnit\n * @param {Object} options\n * @return {string} or {null} returns the converted with in a px value format.\n */\nfunction convertParsedUnitToPx( parsedUnit, options ) {\n\tconst PIXELS_PER_INCH = 96;\n\tconst ONE_PERCENT = 0.01;\n\n\tconst defaultProperties = {\n\t\tfontSize: 16,\n\t\tlineHeight: 16,\n\t\twidth: 375,\n\t\theight: 812,\n\t\ttype: 'font',\n\t};\n\n\tconst setOptions = Object.assign( {}, defaultProperties, options );\n\n\tconst relativeUnits = {\n\t\tem: setOptions.fontSize,\n\t\trem: setOptions.fontSize,\n\t\tvh: setOptions.height * ONE_PERCENT,\n\t\tvw: setOptions.width * ONE_PERCENT,\n\t\tvmin:\n\t\t\t( setOptions.width < setOptions.height\n\t\t\t\t? setOptions.width\n\t\t\t\t: setOptions.height ) * ONE_PERCENT,\n\t\tvmax:\n\t\t\t( setOptions.width > setOptions.height\n\t\t\t\t? setOptions.width\n\t\t\t\t: setOptions.height ) * ONE_PERCENT,\n\t\t'%':\n\t\t\t( setOptions.type === 'font'\n\t\t\t\t? setOptions.fontSize\n\t\t\t\t: setOptions.width ) * ONE_PERCENT,\n\t\tch: 8, // The advance measure (width) of the glyph \"0\" of the element's font. Approximate\n\t\tex: 7.15625, // X-height of the element's font. Approximate.\n\t\tlh: setOptions.lineHeight,\n\t};\n\n\tconst absoluteUnits = {\n\t\tin: PIXELS_PER_INCH,\n\t\tcm: PIXELS_PER_INCH / 2.54,\n\t\tmm: PIXELS_PER_INCH / 25.4,\n\t\tpt: PIXELS_PER_INCH / 72,\n\t\tpc: PIXELS_PER_INCH / 6,\n\t\tpx: 1,\n\t\tQ: PIXELS_PER_INCH / 2.54 / 40,\n\t};\n\n\tif ( relativeUnits[ parsedUnit.unit ] ) {\n\t\treturn (\n\t\t\t( relativeUnits[ parsedUnit.unit ] * parsedUnit.value ).toFixed(\n\t\t\t\t0\n\t\t\t) + 'px'\n\t\t);\n\t}\n\n\tif ( absoluteUnits[ parsedUnit.unit ] ) {\n\t\treturn (\n\t\t\t( absoluteUnits[ parsedUnit.unit ] * parsedUnit.value ).toFixed(\n\t\t\t\t0\n\t\t\t) + 'px'\n\t\t);\n\t}\n\n\treturn null;\n}\n\n/**\n * Returns the px value of a cssUnit.\n *\n * @param {string} cssUnit\n * @param {Object} options\n * @return {string} returns the cssUnit value in a simple px format.\n */\nexport function getPxFromCssUnit( cssUnit, options = {} ) {\n\tif ( Number.isFinite( cssUnit ) ) {\n\t\treturn cssUnit.toFixed( 0 ) + 'px';\n\t}\n\tif ( cssUnit === undefined ) {\n\t\treturn null;\n\t}\n\tlet parsedUnit = parseUnit( cssUnit );\n\n\tif ( ! parsedUnit.unit ) {\n\t\tparsedUnit = parseUnitFunction( cssUnit );\n\t}\n\n\tif ( isMathExpression( cssUnit ) && ! parsedUnit.unit ) {\n\t\treturn evalMathExpression( cssUnit );\n\t}\n\n\treturn convertParsedUnitToPx( parsedUnit, options );\n}\n\n// Use simple cache.\nconst cache = {};\n/**\n * Returns the px value of a cssUnit. The memoized version of getPxFromCssUnit;\n *\n * @param {string} cssUnit\n * @param {Object} options\n * @return {string} returns the cssUnit value in a simple px format.\n */\nfunction memoizedGetPxFromCssUnit( cssUnit, options = {} ) {\n\tconst hash = cssUnit + hashOptions( options );\n\n\tif ( ! cache[ hash ] ) {\n\t\tcache[ hash ] = getPxFromCssUnit( cssUnit, options );\n\t}\n\treturn cache[ hash ];\n}\n\nfunction hashOptions( options ) {\n\tlet hash = '';\n\tif ( options.hasOwnProperty( 'fontSize' ) ) {\n\t\thash = ':' + options.width;\n\t}\n\tif ( options.hasOwnProperty( 'lineHeight' ) ) {\n\t\thash = ':' + options.lineHeight;\n\t}\n\tif ( options.hasOwnProperty( 'width' ) ) {\n\t\thash = ':' + options.width;\n\t}\n\tif ( options.hasOwnProperty( 'height' ) ) {\n\t\thash = ':' + options.height;\n\t}\n\tif ( options.hasOwnProperty( 'type' ) ) {\n\t\thash = ':' + options.type;\n\t}\n\treturn hash;\n}\n\nexport default memoizedGetPxFromCssUnit;\n"]}
|
|
@@ -397,10 +397,6 @@
|
|
|
397
397
|
.block-editor-block-lock-modal__options-title .components-checkbox-control__label {
|
|
398
398
|
font-weight: 600;
|
|
399
399
|
}
|
|
400
|
-
.block-editor-block-lock-modal__options-title .components-base-control__field {
|
|
401
|
-
align-items: center;
|
|
402
|
-
display: flex;
|
|
403
|
-
}
|
|
404
400
|
|
|
405
401
|
.block-editor-block-lock-modal__checklist-item {
|
|
406
402
|
display: flex;
|
|
@@ -425,9 +421,6 @@
|
|
|
425
421
|
margin-top: 16px;
|
|
426
422
|
padding: 12px 0;
|
|
427
423
|
}
|
|
428
|
-
.block-editor-block-lock-modal__template-lock .components-base-control__field {
|
|
429
|
-
margin: 0;
|
|
430
|
-
}
|
|
431
424
|
|
|
432
425
|
.block-editor-block-lock-modal__actions {
|
|
433
426
|
margin-top: 24px;
|
|
@@ -1402,11 +1395,6 @@
|
|
|
1402
1395
|
margin-bottom: 16px;
|
|
1403
1396
|
}
|
|
1404
1397
|
|
|
1405
|
-
.block-editor-date-format-picker__default-format-toggle-control__hint {
|
|
1406
|
-
color: #757575;
|
|
1407
|
-
display: block;
|
|
1408
|
-
}
|
|
1409
|
-
|
|
1410
1398
|
.block-editor-date-format-picker__custom-format-select-control__custom-option {
|
|
1411
1399
|
border-top: 1px solid #ddd;
|
|
1412
1400
|
}
|
|
@@ -1455,23 +1443,9 @@
|
|
|
1455
1443
|
.block-editor-image-size-control {
|
|
1456
1444
|
margin-bottom: 1em;
|
|
1457
1445
|
}
|
|
1458
|
-
.block-editor-image-size-control .block-editor-image-size-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
}
|
|
1462
|
-
.block-editor-image-size-control .block-editor-image-size-control__row .block-editor-image-size-control__width,
|
|
1463
|
-
.block-editor-image-size-control .block-editor-image-size-control__row .block-editor-image-size-control__height {
|
|
1464
|
-
margin-bottom: 0.5em;
|
|
1465
|
-
}
|
|
1466
|
-
.block-editor-image-size-control .block-editor-image-size-control__row .block-editor-image-size-control__width input,
|
|
1467
|
-
.block-editor-image-size-control .block-editor-image-size-control__row .block-editor-image-size-control__height input {
|
|
1468
|
-
line-height: 1.25;
|
|
1469
|
-
}
|
|
1470
|
-
.block-editor-image-size-control .block-editor-image-size-control__row .block-editor-image-size-control__width {
|
|
1471
|
-
margin-left: 5px;
|
|
1472
|
-
}
|
|
1473
|
-
.block-editor-image-size-control .block-editor-image-size-control__row .block-editor-image-size-control__height {
|
|
1474
|
-
margin-right: 5px;
|
|
1446
|
+
.block-editor-image-size-control .block-editor-image-size-control__width,
|
|
1447
|
+
.block-editor-image-size-control .block-editor-image-size-control__height {
|
|
1448
|
+
margin-bottom: 1.115em;
|
|
1475
1449
|
}
|
|
1476
1450
|
|
|
1477
1451
|
.block-editor-block-types-list__list-item {
|
|
@@ -1660,6 +1634,12 @@
|
|
|
1660
1634
|
width: 90vw;
|
|
1661
1635
|
max-width: 360px;
|
|
1662
1636
|
}
|
|
1637
|
+
.show-icon-labels .block-editor-link-control .components-button.has-icon svg {
|
|
1638
|
+
display: none;
|
|
1639
|
+
}
|
|
1640
|
+
.show-icon-labels .block-editor-link-control .components-button.has-icon::before {
|
|
1641
|
+
content: attr(aria-label);
|
|
1642
|
+
}
|
|
1663
1643
|
|
|
1664
1644
|
.block-editor-link-control__search-input-wrapper {
|
|
1665
1645
|
position: relative;
|
|
@@ -1699,7 +1679,6 @@
|
|
|
1699
1679
|
width: calc(100% - 32px);
|
|
1700
1680
|
display: block;
|
|
1701
1681
|
padding: 11px 16px;
|
|
1702
|
-
padding-left: 36px;
|
|
1703
1682
|
margin: 0;
|
|
1704
1683
|
position: relative;
|
|
1705
1684
|
border: 1px solid #ddd;
|
|
@@ -1739,20 +1718,11 @@
|
|
|
1739
1718
|
}
|
|
1740
1719
|
|
|
1741
1720
|
.block-editor-link-control__search-actions {
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
* Compensate for:
|
|
1748
|
-
* - Border (1px)
|
|
1749
|
-
* - Vertically, for the difference in height between the input (40px) and
|
|
1750
|
-
* the icon buttons.
|
|
1751
|
-
* - Horizontally, pad to the minimum of: default input padding, or the
|
|
1752
|
-
* equivalent of the vertical padding.
|
|
1753
|
-
*/
|
|
1754
|
-
top: 3px;
|
|
1755
|
-
left: 19px;
|
|
1721
|
+
display: flex;
|
|
1722
|
+
flex-direction: row-reverse;
|
|
1723
|
+
justify-content: flex-start;
|
|
1724
|
+
gap: 8px;
|
|
1725
|
+
order: 20;
|
|
1756
1726
|
}
|
|
1757
1727
|
|
|
1758
1728
|
.components-button .block-editor-link-control__search-submit .has-icon {
|
|
@@ -2037,12 +2007,42 @@
|
|
|
2037
2007
|
padding: 10px;
|
|
2038
2008
|
}
|
|
2039
2009
|
|
|
2010
|
+
.block-editor-link-control__drawer {
|
|
2011
|
+
display: flex;
|
|
2012
|
+
order: 30;
|
|
2013
|
+
flex-direction: column;
|
|
2014
|
+
flex-basis: 100%;
|
|
2015
|
+
}
|
|
2016
|
+
|
|
2017
|
+
.block-editor-link-control__drawer-inner {
|
|
2018
|
+
display: flex;
|
|
2019
|
+
flex-direction: column;
|
|
2020
|
+
flex-basis: 100%;
|
|
2021
|
+
margin-top: 16px;
|
|
2022
|
+
padding-top: 16px;
|
|
2023
|
+
position: relative;
|
|
2024
|
+
}
|
|
2025
|
+
.block-editor-link-control__drawer-inner::after {
|
|
2026
|
+
content: "";
|
|
2027
|
+
display: block;
|
|
2028
|
+
height: 1px;
|
|
2029
|
+
background-color: #ddd;
|
|
2030
|
+
position: absolute;
|
|
2031
|
+
right: -16px;
|
|
2032
|
+
left: -16px;
|
|
2033
|
+
top: 0;
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2040
2036
|
.block-editor-link-control__tools {
|
|
2041
2037
|
display: flex;
|
|
2038
|
+
flex-wrap: wrap;
|
|
2042
2039
|
align-items: center;
|
|
2043
|
-
|
|
2040
|
+
justify-content: space-between;
|
|
2044
2041
|
margin: 0;
|
|
2045
2042
|
padding: 16px;
|
|
2043
|
+
margin-top: calc(var(--wp-admin-border-width-focus) * -1);
|
|
2044
|
+
padding-top: var(--wp-admin-border-width-focus);
|
|
2045
|
+
overflow: hidden;
|
|
2046
2046
|
}
|
|
2047
2047
|
|
|
2048
2048
|
.block-editor-link-control__unlink {
|
|
@@ -2054,9 +2054,6 @@
|
|
|
2054
2054
|
flex: 1;
|
|
2055
2055
|
margin: 0;
|
|
2056
2056
|
}
|
|
2057
|
-
.block-editor-link-control__settings :last-child {
|
|
2058
|
-
margin-bottom: 0;
|
|
2059
|
-
}
|
|
2060
2057
|
.is-alternate .block-editor-link-control__settings {
|
|
2061
2058
|
border-top: 1px solid #1e1e1e;
|
|
2062
2059
|
}
|
|
@@ -2064,7 +2061,7 @@
|
|
|
2064
2061
|
.block-editor-link-control__setting {
|
|
2065
2062
|
margin-bottom: 16px;
|
|
2066
2063
|
}
|
|
2067
|
-
.block-editor-link-control__setting
|
|
2064
|
+
.block-editor-link-control__setting.block-editor-link-control__setting:last-child {
|
|
2068
2065
|
margin-bottom: 0;
|
|
2069
2066
|
}
|
|
2070
2067
|
|
|
@@ -2075,14 +2072,8 @@
|
|
|
2075
2072
|
position: absolute;
|
|
2076
2073
|
right: auto;
|
|
2077
2074
|
bottom: auto;
|
|
2078
|
-
/*
|
|
2079
|
-
* Position spinner to the left of the actions.
|
|
2080
|
-
*
|
|
2081
|
-
* Compensate for:
|
|
2082
|
-
* - Input padding right ($button-size)
|
|
2083
|
-
*/
|
|
2084
2075
|
top: calc(50% - 16px / 2);
|
|
2085
|
-
left:
|
|
2076
|
+
left: 16px;
|
|
2086
2077
|
}
|
|
2087
2078
|
|
|
2088
2079
|
.block-editor-link-control__search-item-action {
|
|
@@ -2496,22 +2487,21 @@
|
|
|
2496
2487
|
margin-bottom: 8px;
|
|
2497
2488
|
}
|
|
2498
2489
|
.block-editor-media-flow__url-input .block-editor-link-control {
|
|
2499
|
-
width:
|
|
2490
|
+
width: 300px;
|
|
2500
2491
|
}
|
|
2501
2492
|
.block-editor-media-flow__url-input .block-editor-link-control .block-editor-url-input {
|
|
2502
2493
|
padding: 0;
|
|
2503
2494
|
margin: 0;
|
|
2504
2495
|
}
|
|
2505
|
-
.block-editor-media-flow__url-input .block-editor-link-control .
|
|
2506
|
-
margin-bottom: 0;
|
|
2507
|
-
}
|
|
2508
|
-
.block-editor-media-flow__url-input .block-editor-link-control .block-editor-link-control__search-item-title {
|
|
2509
|
-
max-width: 180px;
|
|
2510
|
-
white-space: nowrap;
|
|
2511
|
-
}
|
|
2496
|
+
.block-editor-media-flow__url-input .block-editor-link-control .block-editor-link-control__search-item-title,
|
|
2512
2497
|
.block-editor-media-flow__url-input .block-editor-link-control .block-editor-link-control__search-item-info {
|
|
2498
|
+
max-width: 200px;
|
|
2513
2499
|
white-space: nowrap;
|
|
2514
2500
|
}
|
|
2501
|
+
.block-editor-media-flow__url-input .block-editor-link-control .block-editor-link-control__tools {
|
|
2502
|
+
justify-content: flex-end;
|
|
2503
|
+
padding: 16px var(--wp-admin-border-width-focus) var(--wp-admin-border-width-focus);
|
|
2504
|
+
}
|
|
2515
2505
|
.block-editor-media-flow__url-input .block-editor-link-control .block-editor-link-control__search-item.is-current {
|
|
2516
2506
|
width: auto;
|
|
2517
2507
|
padding: 0;
|
package/build-style/style.css
CHANGED
|
@@ -397,10 +397,6 @@
|
|
|
397
397
|
.block-editor-block-lock-modal__options-title .components-checkbox-control__label {
|
|
398
398
|
font-weight: 600;
|
|
399
399
|
}
|
|
400
|
-
.block-editor-block-lock-modal__options-title .components-base-control__field {
|
|
401
|
-
align-items: center;
|
|
402
|
-
display: flex;
|
|
403
|
-
}
|
|
404
400
|
|
|
405
401
|
.block-editor-block-lock-modal__checklist-item {
|
|
406
402
|
display: flex;
|
|
@@ -425,9 +421,6 @@
|
|
|
425
421
|
margin-top: 16px;
|
|
426
422
|
padding: 12px 0;
|
|
427
423
|
}
|
|
428
|
-
.block-editor-block-lock-modal__template-lock .components-base-control__field {
|
|
429
|
-
margin: 0;
|
|
430
|
-
}
|
|
431
424
|
|
|
432
425
|
.block-editor-block-lock-modal__actions {
|
|
433
426
|
margin-top: 24px;
|
|
@@ -1402,11 +1395,6 @@
|
|
|
1402
1395
|
margin-bottom: 16px;
|
|
1403
1396
|
}
|
|
1404
1397
|
|
|
1405
|
-
.block-editor-date-format-picker__default-format-toggle-control__hint {
|
|
1406
|
-
color: #757575;
|
|
1407
|
-
display: block;
|
|
1408
|
-
}
|
|
1409
|
-
|
|
1410
1398
|
.block-editor-date-format-picker__custom-format-select-control__custom-option {
|
|
1411
1399
|
border-top: 1px solid #ddd;
|
|
1412
1400
|
}
|
|
@@ -1455,23 +1443,9 @@
|
|
|
1455
1443
|
.block-editor-image-size-control {
|
|
1456
1444
|
margin-bottom: 1em;
|
|
1457
1445
|
}
|
|
1458
|
-
.block-editor-image-size-control .block-editor-image-size-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
}
|
|
1462
|
-
.block-editor-image-size-control .block-editor-image-size-control__row .block-editor-image-size-control__width,
|
|
1463
|
-
.block-editor-image-size-control .block-editor-image-size-control__row .block-editor-image-size-control__height {
|
|
1464
|
-
margin-bottom: 0.5em;
|
|
1465
|
-
}
|
|
1466
|
-
.block-editor-image-size-control .block-editor-image-size-control__row .block-editor-image-size-control__width input,
|
|
1467
|
-
.block-editor-image-size-control .block-editor-image-size-control__row .block-editor-image-size-control__height input {
|
|
1468
|
-
line-height: 1.25;
|
|
1469
|
-
}
|
|
1470
|
-
.block-editor-image-size-control .block-editor-image-size-control__row .block-editor-image-size-control__width {
|
|
1471
|
-
margin-right: 5px;
|
|
1472
|
-
}
|
|
1473
|
-
.block-editor-image-size-control .block-editor-image-size-control__row .block-editor-image-size-control__height {
|
|
1474
|
-
margin-left: 5px;
|
|
1446
|
+
.block-editor-image-size-control .block-editor-image-size-control__width,
|
|
1447
|
+
.block-editor-image-size-control .block-editor-image-size-control__height {
|
|
1448
|
+
margin-bottom: 1.115em;
|
|
1475
1449
|
}
|
|
1476
1450
|
|
|
1477
1451
|
.block-editor-block-types-list__list-item {
|
|
@@ -1660,6 +1634,12 @@
|
|
|
1660
1634
|
width: 90vw;
|
|
1661
1635
|
max-width: 360px;
|
|
1662
1636
|
}
|
|
1637
|
+
.show-icon-labels .block-editor-link-control .components-button.has-icon svg {
|
|
1638
|
+
display: none;
|
|
1639
|
+
}
|
|
1640
|
+
.show-icon-labels .block-editor-link-control .components-button.has-icon::before {
|
|
1641
|
+
content: attr(aria-label);
|
|
1642
|
+
}
|
|
1663
1643
|
|
|
1664
1644
|
.block-editor-link-control__search-input-wrapper {
|
|
1665
1645
|
position: relative;
|
|
@@ -1699,7 +1679,6 @@
|
|
|
1699
1679
|
width: calc(100% - 32px);
|
|
1700
1680
|
display: block;
|
|
1701
1681
|
padding: 11px 16px;
|
|
1702
|
-
padding-right: 36px;
|
|
1703
1682
|
margin: 0;
|
|
1704
1683
|
position: relative;
|
|
1705
1684
|
border: 1px solid #ddd;
|
|
@@ -1739,20 +1718,11 @@
|
|
|
1739
1718
|
}
|
|
1740
1719
|
|
|
1741
1720
|
.block-editor-link-control__search-actions {
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
* Compensate for:
|
|
1748
|
-
* - Border (1px)
|
|
1749
|
-
* - Vertically, for the difference in height between the input (40px) and
|
|
1750
|
-
* the icon buttons.
|
|
1751
|
-
* - Horizontally, pad to the minimum of: default input padding, or the
|
|
1752
|
-
* equivalent of the vertical padding.
|
|
1753
|
-
*/
|
|
1754
|
-
top: 3px;
|
|
1755
|
-
right: 19px;
|
|
1721
|
+
display: flex;
|
|
1722
|
+
flex-direction: row-reverse;
|
|
1723
|
+
justify-content: flex-start;
|
|
1724
|
+
gap: 8px;
|
|
1725
|
+
order: 20;
|
|
1756
1726
|
}
|
|
1757
1727
|
|
|
1758
1728
|
.components-button .block-editor-link-control__search-submit .has-icon {
|
|
@@ -2037,12 +2007,42 @@
|
|
|
2037
2007
|
padding: 10px;
|
|
2038
2008
|
}
|
|
2039
2009
|
|
|
2010
|
+
.block-editor-link-control__drawer {
|
|
2011
|
+
display: flex;
|
|
2012
|
+
order: 30;
|
|
2013
|
+
flex-direction: column;
|
|
2014
|
+
flex-basis: 100%;
|
|
2015
|
+
}
|
|
2016
|
+
|
|
2017
|
+
.block-editor-link-control__drawer-inner {
|
|
2018
|
+
display: flex;
|
|
2019
|
+
flex-direction: column;
|
|
2020
|
+
flex-basis: 100%;
|
|
2021
|
+
margin-top: 16px;
|
|
2022
|
+
padding-top: 16px;
|
|
2023
|
+
position: relative;
|
|
2024
|
+
}
|
|
2025
|
+
.block-editor-link-control__drawer-inner::after {
|
|
2026
|
+
content: "";
|
|
2027
|
+
display: block;
|
|
2028
|
+
height: 1px;
|
|
2029
|
+
background-color: #ddd;
|
|
2030
|
+
position: absolute;
|
|
2031
|
+
left: -16px;
|
|
2032
|
+
right: -16px;
|
|
2033
|
+
top: 0;
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2040
2036
|
.block-editor-link-control__tools {
|
|
2041
2037
|
display: flex;
|
|
2038
|
+
flex-wrap: wrap;
|
|
2042
2039
|
align-items: center;
|
|
2043
|
-
|
|
2040
|
+
justify-content: space-between;
|
|
2044
2041
|
margin: 0;
|
|
2045
2042
|
padding: 16px;
|
|
2043
|
+
margin-top: calc(var(--wp-admin-border-width-focus) * -1);
|
|
2044
|
+
padding-top: var(--wp-admin-border-width-focus);
|
|
2045
|
+
overflow: hidden;
|
|
2046
2046
|
}
|
|
2047
2047
|
|
|
2048
2048
|
.block-editor-link-control__unlink {
|
|
@@ -2054,9 +2054,6 @@
|
|
|
2054
2054
|
flex: 1;
|
|
2055
2055
|
margin: 0;
|
|
2056
2056
|
}
|
|
2057
|
-
.block-editor-link-control__settings :last-child {
|
|
2058
|
-
margin-bottom: 0;
|
|
2059
|
-
}
|
|
2060
2057
|
.is-alternate .block-editor-link-control__settings {
|
|
2061
2058
|
border-top: 1px solid #1e1e1e;
|
|
2062
2059
|
}
|
|
@@ -2064,7 +2061,7 @@
|
|
|
2064
2061
|
.block-editor-link-control__setting {
|
|
2065
2062
|
margin-bottom: 16px;
|
|
2066
2063
|
}
|
|
2067
|
-
.block-editor-link-control__setting
|
|
2064
|
+
.block-editor-link-control__setting.block-editor-link-control__setting:last-child {
|
|
2068
2065
|
margin-bottom: 0;
|
|
2069
2066
|
}
|
|
2070
2067
|
|
|
@@ -2075,14 +2072,8 @@
|
|
|
2075
2072
|
position: absolute;
|
|
2076
2073
|
left: auto;
|
|
2077
2074
|
bottom: auto;
|
|
2078
|
-
/*
|
|
2079
|
-
* Position spinner to the left of the actions.
|
|
2080
|
-
*
|
|
2081
|
-
* Compensate for:
|
|
2082
|
-
* - Input padding right ($button-size)
|
|
2083
|
-
*/
|
|
2084
2075
|
top: calc(50% - 16px / 2);
|
|
2085
|
-
right:
|
|
2076
|
+
right: 16px;
|
|
2086
2077
|
}
|
|
2087
2078
|
|
|
2088
2079
|
.block-editor-link-control__search-item-action {
|
|
@@ -2496,22 +2487,21 @@
|
|
|
2496
2487
|
margin-bottom: 8px;
|
|
2497
2488
|
}
|
|
2498
2489
|
.block-editor-media-flow__url-input .block-editor-link-control {
|
|
2499
|
-
width:
|
|
2490
|
+
width: 300px;
|
|
2500
2491
|
}
|
|
2501
2492
|
.block-editor-media-flow__url-input .block-editor-link-control .block-editor-url-input {
|
|
2502
2493
|
padding: 0;
|
|
2503
2494
|
margin: 0;
|
|
2504
2495
|
}
|
|
2505
|
-
.block-editor-media-flow__url-input .block-editor-link-control .
|
|
2506
|
-
margin-bottom: 0;
|
|
2507
|
-
}
|
|
2508
|
-
.block-editor-media-flow__url-input .block-editor-link-control .block-editor-link-control__search-item-title {
|
|
2509
|
-
max-width: 180px;
|
|
2510
|
-
white-space: nowrap;
|
|
2511
|
-
}
|
|
2496
|
+
.block-editor-media-flow__url-input .block-editor-link-control .block-editor-link-control__search-item-title,
|
|
2512
2497
|
.block-editor-media-flow__url-input .block-editor-link-control .block-editor-link-control__search-item-info {
|
|
2498
|
+
max-width: 200px;
|
|
2513
2499
|
white-space: nowrap;
|
|
2514
2500
|
}
|
|
2501
|
+
.block-editor-media-flow__url-input .block-editor-link-control .block-editor-link-control__tools {
|
|
2502
|
+
justify-content: flex-end;
|
|
2503
|
+
padding: 16px var(--wp-admin-border-width-focus) var(--wp-admin-border-width-focus);
|
|
2504
|
+
}
|
|
2515
2505
|
.block-editor-media-flow__url-input .block-editor-link-control .block-editor-link-control__search-item.is-current {
|
|
2516
2506
|
width: auto;
|
|
2517
2507
|
padding: 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.5.0",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -33,35 +33,35 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/runtime": "^7.16.0",
|
|
35
35
|
"@react-spring/web": "^9.4.5",
|
|
36
|
-
"@wordpress/a11y": "^3.
|
|
37
|
-
"@wordpress/api-fetch": "^6.
|
|
38
|
-
"@wordpress/blob": "^3.
|
|
39
|
-
"@wordpress/blocks": "^12.
|
|
40
|
-
"@wordpress/components": "^23.
|
|
41
|
-
"@wordpress/compose": "^6.
|
|
42
|
-
"@wordpress/data": "^8.
|
|
43
|
-
"@wordpress/date": "^4.
|
|
44
|
-
"@wordpress/deprecated": "^3.
|
|
45
|
-
"@wordpress/dom": "^3.
|
|
46
|
-
"@wordpress/element": "^5.
|
|
47
|
-
"@wordpress/escape-html": "^2.
|
|
48
|
-
"@wordpress/hooks": "^3.
|
|
49
|
-
"@wordpress/html-entities": "^3.
|
|
50
|
-
"@wordpress/i18n": "^4.
|
|
51
|
-
"@wordpress/icons": "^9.
|
|
52
|
-
"@wordpress/is-shallow-equal": "^4.
|
|
53
|
-
"@wordpress/keyboard-shortcuts": "^4.
|
|
54
|
-
"@wordpress/keycodes": "^3.
|
|
55
|
-
"@wordpress/notices": "^3.
|
|
56
|
-
"@wordpress/preferences": "^3.
|
|
57
|
-
"@wordpress/private-apis": "^0.
|
|
58
|
-
"@wordpress/rich-text": "^6.
|
|
59
|
-
"@wordpress/shortcode": "^3.
|
|
60
|
-
"@wordpress/style-engine": "^1.
|
|
61
|
-
"@wordpress/token-list": "^2.
|
|
62
|
-
"@wordpress/url": "^3.
|
|
63
|
-
"@wordpress/warning": "^2.
|
|
64
|
-
"@wordpress/wordcount": "^3.
|
|
36
|
+
"@wordpress/a11y": "^3.28.0",
|
|
37
|
+
"@wordpress/api-fetch": "^6.25.0",
|
|
38
|
+
"@wordpress/blob": "^3.28.0",
|
|
39
|
+
"@wordpress/blocks": "^12.5.0",
|
|
40
|
+
"@wordpress/components": "^23.5.0",
|
|
41
|
+
"@wordpress/compose": "^6.5.0",
|
|
42
|
+
"@wordpress/data": "^8.5.0",
|
|
43
|
+
"@wordpress/date": "^4.28.0",
|
|
44
|
+
"@wordpress/deprecated": "^3.28.0",
|
|
45
|
+
"@wordpress/dom": "^3.28.0",
|
|
46
|
+
"@wordpress/element": "^5.5.0",
|
|
47
|
+
"@wordpress/escape-html": "^2.28.0",
|
|
48
|
+
"@wordpress/hooks": "^3.28.0",
|
|
49
|
+
"@wordpress/html-entities": "^3.28.0",
|
|
50
|
+
"@wordpress/i18n": "^4.28.0",
|
|
51
|
+
"@wordpress/icons": "^9.19.0",
|
|
52
|
+
"@wordpress/is-shallow-equal": "^4.28.0",
|
|
53
|
+
"@wordpress/keyboard-shortcuts": "^4.5.0",
|
|
54
|
+
"@wordpress/keycodes": "^3.28.0",
|
|
55
|
+
"@wordpress/notices": "^3.28.0",
|
|
56
|
+
"@wordpress/preferences": "^3.5.0",
|
|
57
|
+
"@wordpress/private-apis": "^0.10.0",
|
|
58
|
+
"@wordpress/rich-text": "^6.5.0",
|
|
59
|
+
"@wordpress/shortcode": "^3.28.0",
|
|
60
|
+
"@wordpress/style-engine": "^1.11.0",
|
|
61
|
+
"@wordpress/token-list": "^2.28.0",
|
|
62
|
+
"@wordpress/url": "^3.29.0",
|
|
63
|
+
"@wordpress/warning": "^2.28.0",
|
|
64
|
+
"@wordpress/wordcount": "^3.28.0",
|
|
65
65
|
"change-case": "^4.1.2",
|
|
66
66
|
"classnames": "^2.3.1",
|
|
67
67
|
"colord": "^2.7.0",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"publishConfig": {
|
|
84
84
|
"access": "public"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "d5e03a74b79e3ca84afda24375474a103a063ee4"
|
|
87
87
|
}
|