@wordpress/block-editor 12.17.0 → 12.18.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 +4 -0
- package/README.md +32 -0
- package/build/components/block-draggable/index.js +11 -3
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-edit/context.js +3 -1
- package/build/components/block-edit/context.js.map +1 -1
- package/build/components/block-edit/index.js +4 -2
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-editing-mode/index.js +6 -3
- package/build/components/block-editing-mode/index.js.map +1 -1
- package/build/components/block-inspector/index.js +5 -2
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block.js +4 -3
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +9 -5
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.js +30 -4
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list/private-block-context.js +1 -1
- package/build/components/block-list/private-block-context.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +1 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-lock/toolbar.js +8 -2
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-popover/inbetween.js +15 -3
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-preview/auto.js +1 -1
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +3 -2
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -4
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.js +12 -1
- package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build/components/block-switcher/index.js +119 -90
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +10 -3
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +7 -1
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/global-styles/border-panel.js +5 -14
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +7 -1
- package/build/components/global-styles/effects-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +3 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +31 -14
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/iframe/get-compatibility-styles.js +99 -0
- package/build/components/iframe/get-compatibility-styles.js.map +1 -0
- package/build/components/iframe/index.js +2 -3
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.js +16 -2
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +16 -2
- package/build/components/index.native.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js +3 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build/components/link-control/link-preview.js +30 -26
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -9
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/list-view/block-contents.js +3 -1
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block.js +10 -1
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +29 -8
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +100 -32
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +52 -4
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +2 -2
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-list-view-block-indexes.js +30 -0
- package/build/components/list-view/use-list-view-block-indexes.js.map +1 -0
- package/build/components/list-view/use-list-view-drop-zone.js +56 -5
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/list-view/utils.js +92 -0
- package/build/components/list-view/utils.js.map +1 -1
- package/build/components/provider/index.js +1 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/recursion-provider/index.js +21 -0
- package/build/components/recursion-provider/index.js.map +1 -1
- package/build/components/rich-text/index.js +30 -6
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +9 -9
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +30 -7
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +50 -8
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/hooks/block-hooks.js +5 -14
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/content-lock-ui.js +17 -42
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/effects.js +66 -0
- package/build/hooks/effects.js.map +1 -0
- package/build/hooks/index.js +15 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +13 -0
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/style.js +6 -2
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/supports.js +2 -1
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.native.js +2 -2
- package/build/hooks/typography.native.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +115 -0
- package/build/hooks/use-bindings-attributes.js.map +1 -0
- package/build/hooks/use-shadow-props.js +46 -0
- package/build/hooks/use-shadow-props.js.map +1 -0
- package/build/hooks/utils.js +11 -7
- package/build/hooks/utils.js.map +1 -1
- package/build/index.js +14 -0
- package/build/index.js.map +1 -1
- package/build/store/actions.js +10 -6
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +2 -0
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +37 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +60 -9
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +44 -3
- package/build/store/reducer.js.map +1 -1
- package/build/store/resolvers.js +27 -0
- package/build/store/resolvers.js.map +1 -0
- package/build/store/selectors.js +94 -56
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +5 -26
- package/build/store/utils.js.map +1 -1
- package/build/utils/index.js +0 -16
- package/build/utils/index.js.map +1 -1
- package/build/utils/math.js +13 -0
- package/build/utils/math.js.map +1 -1
- package/build/utils/object.js +17 -0
- package/build/utils/object.js.map +1 -1
- package/build/utils/transform-styles/index.js +37 -27
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build-module/components/block-draggable/index.js +11 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-edit/context.js +1 -0
- package/build-module/components/block-edit/context.js.map +1 -1
- package/build-module/components/block-edit/index.js +5 -3
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-editing-mode/index.js +7 -4
- package/build-module/components/block-editing-mode/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +5 -2
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block.js +6 -5
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +11 -7
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.js +31 -5
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list/private-block-context.js +1 -1
- package/build-module/components/block-list/private-block-context.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +8 -2
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +15 -3
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-preview/auto.js +3 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +3 -2
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -4
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.js +12 -1
- package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build-module/components/block-switcher/index.js +116 -86
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +10 -3
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +7 -1
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +5 -14
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +7 -1
- package/build-module/components/global-styles/effects-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +3 -2
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +32 -15
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/iframe/get-compatibility-styles.js +93 -0
- package/build-module/components/iframe/get-compatibility-styles.js.map +1 -0
- package/build-module/components/iframe/index.js +2 -3
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/index.js +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +3 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +32 -28
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -8
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +3 -1
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block.js +10 -1
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +30 -9
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +99 -32
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +54 -6
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +2 -2
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-list-view-block-indexes.js +23 -0
- package/build-module/components/list-view/use-list-view-block-indexes.js.map +1 -0
- package/build-module/components/list-view/use-list-view-drop-zone.js +58 -7
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/list-view/utils.js +91 -0
- package/build-module/components/list-view/utils.js.map +1 -1
- package/build-module/components/provider/index.js +1 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/recursion-provider/index.js +17 -0
- package/build-module/components/recursion-provider/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +30 -6
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +9 -9
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +31 -8
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +51 -9
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/hooks/block-hooks.js +5 -14
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +19 -43
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/effects.js +51 -0
- package/build-module/hooks/effects.js.map +1 -0
- package/build-module/hooks/index.js +3 -2
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/index.native.js +1 -0
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/style.js +6 -2
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/supports.js +2 -1
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.native.js +2 -2
- package/build-module/hooks/typography.native.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +112 -0
- package/build-module/hooks/use-bindings-attributes.js.map +1 -0
- package/build-module/hooks/use-shadow-props.js +39 -0
- package/build-module/hooks/use-shadow-props.js.map +1 -0
- package/build-module/hooks/utils.js +13 -9
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +10 -6
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +2 -0
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +35 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +53 -8
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +43 -3
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/resolvers.js +20 -0
- package/build-module/store/resolvers.js.map +1 -0
- package/build-module/store/selectors.js +89 -52
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +3 -23
- package/build-module/store/utils.js.map +1 -1
- package/build-module/utils/index.js +0 -1
- package/build-module/utils/index.js.map +1 -1
- package/build-module/utils/math.js +12 -0
- package/build-module/utils/math.js.map +1 -1
- package/build-module/utils/object.js +16 -0
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +36 -27
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-style/content-rtl.css +33 -16
- package/build-style/content.css +33 -16
- package/build-style/default-editor-styles-rtl.css +1 -1
- package/build-style/default-editor-styles.css +1 -1
- package/build-style/style-rtl.css +169 -114
- package/build-style/style.css +169 -114
- package/package.json +31 -31
- package/src/components/block-canvas/style.scss +8 -1
- package/src/components/block-draggable/index.js +16 -5
- package/src/components/block-edit/context.js +1 -0
- package/src/components/block-edit/index.js +4 -0
- package/src/components/block-editing-mode/index.js +12 -7
- package/src/components/block-inspector/index.js +5 -2
- package/src/components/block-list/block.js +5 -4
- package/src/components/block-list/block.native.js +13 -3
- package/src/components/block-list/content.scss +34 -5
- package/src/components/block-list/index.js +52 -16
- package/src/components/block-list/private-block-context.js +1 -1
- package/src/components/block-list/use-in-between-inserter.js +1 -2
- package/src/components/block-lock/toolbar.js +10 -2
- package/src/components/block-popover/inbetween.js +22 -2
- package/src/components/block-preview/auto.js +3 -3
- package/src/components/block-removal-warning-modal/index.js +3 -2
- package/src/components/block-settings-menu/block-settings-dropdown.js +2 -7
- package/src/components/block-switcher/block-transformations-menu.js +18 -1
- package/src/components/block-switcher/index.js +133 -111
- package/src/components/block-switcher/style.scss +6 -4
- package/src/components/block-switcher/test/index.js +113 -230
- package/src/components/block-toolbar/style.scss +22 -18
- package/src/components/block-tools/insertion-point.js +15 -2
- package/src/components/block-tools/style.scss +8 -7
- package/src/components/font-sizes/fluid-utils.js +8 -2
- package/src/components/font-sizes/test/fluid-utils.js +9 -0
- package/src/components/global-styles/border-panel.js +7 -17
- package/src/components/global-styles/effects-panel.js +16 -1
- package/src/components/global-styles/hooks.js +2 -0
- package/src/components/global-styles/typography-panel.js +45 -13
- package/src/components/iframe/get-compatibility-styles.js +120 -0
- package/src/components/iframe/index.js +2 -3
- package/src/components/index.js +4 -2
- package/src/components/index.native.js +4 -2
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +1 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +2 -0
- package/src/components/link-control/link-preview.js +31 -55
- package/src/components/link-control/search-input.js +1 -9
- package/src/components/link-control/style.scss +31 -85
- package/src/components/link-control/test/index.js +2 -1
- package/src/components/list-view/block-contents.js +5 -1
- package/src/components/list-view/block.js +9 -0
- package/src/components/list-view/branch.js +30 -10
- package/src/components/list-view/drop-indicator.js +139 -46
- package/src/components/list-view/index.js +74 -3
- package/src/components/list-view/leaf.js +2 -2
- package/src/components/list-view/style.scss +102 -13
- package/src/components/list-view/test/use-list-view-drop-zone.js +4 -0
- package/src/components/list-view/test/utils.js +218 -1
- package/src/components/list-view/use-list-view-block-indexes.js +29 -0
- package/src/components/list-view/use-list-view-drop-zone.js +78 -6
- package/src/components/list-view/utils.js +116 -0
- package/src/components/provider/index.js +3 -1
- package/src/components/recursion-provider/README.md +2 -2
- package/src/components/recursion-provider/index.js +17 -0
- package/src/components/rich-text/index.js +48 -10
- package/src/components/rich-text/native/index.native.js +10 -10
- package/src/components/use-block-drop-zone/index.js +60 -19
- package/src/components/use-block-drop-zone/test/index.js +32 -61
- package/src/components/use-on-block-drop/index.js +92 -11
- package/src/hooks/block-hooks.js +5 -17
- package/src/hooks/content-lock-ui.js +15 -55
- package/src/hooks/effects.js +57 -0
- package/src/hooks/index.js +2 -2
- package/src/hooks/index.native.js +1 -0
- package/src/hooks/style.js +8 -0
- package/src/hooks/supports.js +2 -0
- package/src/hooks/test/effects.js +39 -0
- package/src/hooks/typography.native.js +2 -2
- package/src/hooks/use-bindings-attributes.js +148 -0
- package/src/hooks/use-shadow-props.js +37 -0
- package/src/hooks/utils.js +26 -10
- package/src/index.js +2 -0
- package/src/store/actions.js +9 -4
- package/src/store/index.js +2 -0
- package/src/store/private-actions.js +32 -0
- package/src/store/private-selectors.js +78 -21
- package/src/store/reducer.js +49 -2
- package/src/store/resolvers.js +17 -0
- package/src/store/selectors.js +169 -161
- package/src/store/test/registry-selectors.js +431 -0
- package/src/store/test/selectors.js +14 -400
- package/src/store/utils.js +10 -33
- package/src/style.scss +0 -1
- package/src/utils/index.js +0 -1
- package/src/utils/math.js +12 -0
- package/src/utils/object.js +16 -0
- package/src/utils/transform-styles/index.js +52 -37
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/iframe/use-compatibility-styles.js +0 -100
- package/build/components/iframe/use-compatibility-styles.js.map +0 -1
- package/build/hooks/custom-fields.js +0 -106
- package/build/hooks/custom-fields.js.map +0 -1
- package/build/utils/block-variation-transforms.js +0 -42
- package/build/utils/block-variation-transforms.js.map +0 -1
- package/build-module/components/iframe/use-compatibility-styles.js +0 -94
- package/build-module/components/iframe/use-compatibility-styles.js.map +0 -1
- package/build-module/hooks/custom-fields.js +0 -99
- package/build-module/hooks/custom-fields.js.map +0 -1
- package/build-module/utils/block-variation-transforms.js +0 -35
- package/build-module/utils/block-variation-transforms.js.map +0 -1
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +0 -116
- package/src/components/contrast-checker/style.scss +0 -3
- package/src/components/iframe/use-compatibility-styles.js +0 -122
- package/src/hooks/custom-fields.js +0 -115
- package/src/utils/block-variation-transforms.js +0 -38
- package/src/utils/test/block-variation-transforms.js +0 -94
|
@@ -14,7 +14,7 @@ import { copy } from '@wordpress/icons';
|
|
|
14
14
|
/**
|
|
15
15
|
* Internal dependencies
|
|
16
16
|
*/
|
|
17
|
-
import { BlockSwitcher
|
|
17
|
+
import { BlockSwitcher } from '../';
|
|
18
18
|
|
|
19
19
|
jest.mock( '@wordpress/data/src/components/use-select', () => jest.fn() );
|
|
20
20
|
jest.mock( '../../block-title/use-block-display-title', () =>
|
|
@@ -22,23 +22,6 @@ jest.mock( '../../block-title/use-block-display-title', () =>
|
|
|
22
22
|
);
|
|
23
23
|
|
|
24
24
|
describe( 'BlockSwitcher', () => {
|
|
25
|
-
test( 'should not render block switcher without blocks', () => {
|
|
26
|
-
useSelect.mockImplementation( () => ( {} ) );
|
|
27
|
-
const { container } = render( <BlockSwitcher /> );
|
|
28
|
-
expect( container ).toBeEmptyDOMElement();
|
|
29
|
-
} );
|
|
30
|
-
|
|
31
|
-
test( 'should not render block switcher with null blocks', () => {
|
|
32
|
-
useSelect.mockImplementation( () => ( { blocks: [ null ] } ) );
|
|
33
|
-
const { container } = render(
|
|
34
|
-
<BlockSwitcher
|
|
35
|
-
clientIds={ [ 'a1303fd6-3e60-4fff-a770-0e0ea656c5b9' ] }
|
|
36
|
-
/>
|
|
37
|
-
);
|
|
38
|
-
expect( container ).toBeEmptyDOMElement();
|
|
39
|
-
} );
|
|
40
|
-
} );
|
|
41
|
-
describe( 'BlockSwitcherDropdownMenu', () => {
|
|
42
25
|
const headingBlock1 = {
|
|
43
26
|
attributes: {
|
|
44
27
|
content: [ 'How are you?' ],
|
|
@@ -49,66 +32,46 @@ describe( 'BlockSwitcherDropdownMenu', () => {
|
|
|
49
32
|
originalContent: '<h2>How are you?</h2>',
|
|
50
33
|
clientId: 'a1303fd6-3e60-4fff-a770-0e0ea656c5b9',
|
|
51
34
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
35
|
+
const headingBlockType = {
|
|
36
|
+
category: 'text',
|
|
37
|
+
title: 'Heading',
|
|
38
|
+
edit: () => {},
|
|
39
|
+
save: () => {},
|
|
40
|
+
transforms: {
|
|
41
|
+
to: [
|
|
42
|
+
{
|
|
43
|
+
type: 'block',
|
|
44
|
+
blocks: [ 'core/paragraph' ],
|
|
45
|
+
transform: () => {},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: 'block',
|
|
49
|
+
blocks: [ 'core/paragraph' ],
|
|
50
|
+
transform: () => {},
|
|
51
|
+
isMultiBlock: true,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
56
54
|
},
|
|
57
|
-
isValid: true,
|
|
58
|
-
name: 'core/paragraph',
|
|
59
|
-
originalContent: '<p>I am great!</p>',
|
|
60
|
-
clientId: 'b1303fdb-3e60-43faf-a770-2e1ea656c5b8',
|
|
61
55
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
const paragraphBlockType = {
|
|
57
|
+
category: 'text',
|
|
58
|
+
title: 'Paragraph',
|
|
59
|
+
edit: () => {},
|
|
60
|
+
save: () => {},
|
|
61
|
+
transforms: {
|
|
62
|
+
to: [
|
|
63
|
+
{
|
|
64
|
+
type: 'block',
|
|
65
|
+
blocks: [ 'core/heading' ],
|
|
66
|
+
transform: () => {},
|
|
67
|
+
},
|
|
68
|
+
],
|
|
67
69
|
},
|
|
68
|
-
isValid: true,
|
|
69
|
-
name: 'core/heading',
|
|
70
|
-
originalContent: '<h3>I am the greatest!</h3>',
|
|
71
|
-
clientId: 'c2403fd2-4e63-5ffa-b71c-1e0ea656c5b0',
|
|
72
70
|
};
|
|
73
71
|
|
|
74
72
|
beforeAll( () => {
|
|
75
|
-
registerBlockType( 'core/heading',
|
|
76
|
-
|
|
77
|
-
title: 'Heading',
|
|
78
|
-
edit: () => {},
|
|
79
|
-
save: () => {},
|
|
80
|
-
transforms: {
|
|
81
|
-
to: [
|
|
82
|
-
{
|
|
83
|
-
type: 'block',
|
|
84
|
-
blocks: [ 'core/paragraph' ],
|
|
85
|
-
transform: () => {},
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
type: 'block',
|
|
89
|
-
blocks: [ 'core/paragraph' ],
|
|
90
|
-
transform: () => {},
|
|
91
|
-
isMultiBlock: true,
|
|
92
|
-
},
|
|
93
|
-
],
|
|
94
|
-
},
|
|
95
|
-
} );
|
|
96
|
-
|
|
97
|
-
registerBlockType( 'core/paragraph', {
|
|
98
|
-
category: 'text',
|
|
99
|
-
title: 'Paragraph',
|
|
100
|
-
edit: () => {},
|
|
101
|
-
save: () => {},
|
|
102
|
-
transforms: {
|
|
103
|
-
to: [
|
|
104
|
-
{
|
|
105
|
-
type: 'block',
|
|
106
|
-
blocks: [ 'core/heading' ],
|
|
107
|
-
transform: () => {},
|
|
108
|
-
},
|
|
109
|
-
],
|
|
110
|
-
},
|
|
111
|
-
} );
|
|
73
|
+
registerBlockType( 'core/heading', headingBlockType );
|
|
74
|
+
registerBlockType( 'core/paragraph', paragraphBlockType );
|
|
112
75
|
} );
|
|
113
76
|
|
|
114
77
|
afterAll( () => {
|
|
@@ -116,184 +79,104 @@ describe( 'BlockSwitcherDropdownMenu', () => {
|
|
|
116
79
|
unregisterBlockType( 'core/paragraph' );
|
|
117
80
|
} );
|
|
118
81
|
|
|
119
|
-
test( 'should render switcher with
|
|
82
|
+
test( 'should render switcher with block transforms', async () => {
|
|
120
83
|
useSelect.mockImplementation( () => ( {
|
|
121
84
|
possibleBlockTransformations: [
|
|
122
|
-
{
|
|
123
|
-
|
|
85
|
+
{
|
|
86
|
+
name: 'core/heading',
|
|
87
|
+
title: headingBlockType.title,
|
|
88
|
+
frecency: 1,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'core/paragraph',
|
|
92
|
+
title: paragraphBlockType.title,
|
|
93
|
+
frecency: 1,
|
|
94
|
+
},
|
|
124
95
|
],
|
|
96
|
+
blocks: [ headingBlock1 ],
|
|
125
97
|
canRemove: true,
|
|
126
98
|
} ) );
|
|
127
|
-
const
|
|
128
|
-
|
|
99
|
+
const user = userEvent.setup();
|
|
100
|
+
render( <BlockSwitcher clientIds={ [ headingBlock1.clientId ] } /> );
|
|
101
|
+
expect(
|
|
102
|
+
screen.getByRole( 'button', {
|
|
103
|
+
name: 'Block Name',
|
|
104
|
+
expanded: false,
|
|
105
|
+
} )
|
|
106
|
+
).toBeVisible();
|
|
107
|
+
expect(
|
|
108
|
+
screen.queryByRole( 'menu', {
|
|
109
|
+
name: 'Block Name',
|
|
110
|
+
} )
|
|
111
|
+
).not.toBeInTheDocument();
|
|
112
|
+
await user.type(
|
|
113
|
+
screen.getByRole( 'button', {
|
|
114
|
+
name: 'Block Name',
|
|
115
|
+
expanded: false,
|
|
116
|
+
} ),
|
|
117
|
+
'[ArrowDown]'
|
|
129
118
|
);
|
|
130
|
-
|
|
119
|
+
await waitFor( () =>
|
|
120
|
+
expect(
|
|
121
|
+
screen.getByRole( 'button', {
|
|
122
|
+
name: 'Block Name',
|
|
123
|
+
expanded: true,
|
|
124
|
+
} )
|
|
125
|
+
).toBeVisible()
|
|
126
|
+
);
|
|
127
|
+
const dropdown = screen.getByRole( 'menu', {
|
|
128
|
+
name: 'Block Name',
|
|
129
|
+
} );
|
|
130
|
+
await waitFor( () => expect( dropdown ).toBeVisible() );
|
|
131
|
+
const items = within( dropdown ).getAllByRole( 'menuitem' );
|
|
132
|
+
expect( items ).toHaveLength( 2 );
|
|
133
|
+
expect( items[ 0 ] ).toHaveTextContent( paragraphBlockType.title );
|
|
134
|
+
expect( items[ 1 ] ).toHaveTextContent( headingBlockType.title );
|
|
131
135
|
} );
|
|
132
136
|
|
|
133
|
-
test( 'should render disabled block switcher
|
|
137
|
+
test( 'should render disabled block switcher when we have a single selected block without styles and we cannot remove it', () => {
|
|
134
138
|
useSelect.mockImplementation( () => ( {
|
|
135
|
-
|
|
139
|
+
blocks: [ headingBlock1 ],
|
|
136
140
|
icon: copy,
|
|
141
|
+
hasBlockStyles: false,
|
|
142
|
+
canRemove: false,
|
|
137
143
|
} ) );
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
render( <BlockSwitcher clientIds={ [ headingBlock1.clientId ] } /> );
|
|
145
|
+
expect(
|
|
146
|
+
screen.getByRole( 'button', {
|
|
147
|
+
name: 'Block Name',
|
|
148
|
+
} )
|
|
149
|
+
).toBeDisabled();
|
|
144
150
|
} );
|
|
145
151
|
|
|
146
|
-
test( 'should render
|
|
152
|
+
test( 'should render message for no available transforms', async () => {
|
|
147
153
|
useSelect.mockImplementation( () => ( {
|
|
148
|
-
possibleBlockTransformations: [
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
],
|
|
154
|
+
possibleBlockTransformations: [],
|
|
155
|
+
blocks: [ headingBlock1 ],
|
|
156
|
+
icon: copy,
|
|
152
157
|
canRemove: true,
|
|
153
158
|
} ) );
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
159
|
+
render( <BlockSwitcher clientIds={ [ headingBlock1.clientId ] } /> );
|
|
160
|
+
const user = userEvent.setup();
|
|
161
|
+
await user.type(
|
|
162
|
+
screen.getByRole( 'button', {
|
|
163
|
+
name: 'Block Name',
|
|
164
|
+
expanded: false,
|
|
165
|
+
} ),
|
|
166
|
+
'[ArrowDown]'
|
|
158
167
|
);
|
|
159
|
-
|
|
160
|
-
} );
|
|
161
|
-
|
|
162
|
-
describe( 'Dropdown', () => {
|
|
163
|
-
beforeAll( () => {
|
|
164
|
-
useSelect.mockImplementation( () => ( {
|
|
165
|
-
possibleBlockTransformations: [
|
|
166
|
-
{ name: 'core/paragraph', frecency: 3 },
|
|
167
|
-
],
|
|
168
|
-
canRemove: true,
|
|
169
|
-
} ) );
|
|
170
|
-
} );
|
|
171
|
-
|
|
172
|
-
test( 'should dropdown exist', () => {
|
|
173
|
-
render(
|
|
174
|
-
<BlockSwitcherDropdownMenu blocks={ [ headingBlock1 ] } />
|
|
175
|
-
);
|
|
176
|
-
|
|
168
|
+
await waitFor( () =>
|
|
177
169
|
expect(
|
|
178
170
|
screen.getByRole( 'button', {
|
|
179
171
|
name: 'Block Name',
|
|
180
|
-
expanded:
|
|
172
|
+
expanded: true,
|
|
181
173
|
} )
|
|
182
|
-
).toBeVisible()
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
<BlockSwitcherDropdownMenu blocks={ [ headingBlock1 ] } />
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
expect(
|
|
193
|
-
screen.getByRole( 'button', {
|
|
194
|
-
name: 'Block Name',
|
|
195
|
-
expanded: false,
|
|
196
|
-
} )
|
|
197
|
-
).toBeVisible();
|
|
198
|
-
expect(
|
|
199
|
-
screen.queryByRole( 'menu', {
|
|
200
|
-
name: 'Block Name',
|
|
201
|
-
} )
|
|
202
|
-
).not.toBeInTheDocument();
|
|
203
|
-
|
|
204
|
-
await user.type(
|
|
205
|
-
screen.getByRole( 'button', {
|
|
206
|
-
name: 'Block Name',
|
|
207
|
-
expanded: false,
|
|
208
|
-
} ),
|
|
209
|
-
'[ArrowDown]'
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
await waitFor( () =>
|
|
213
|
-
expect(
|
|
214
|
-
screen.getByRole( 'button', {
|
|
215
|
-
name: 'Block Name',
|
|
216
|
-
expanded: true,
|
|
217
|
-
} )
|
|
218
|
-
).toBeVisible()
|
|
219
|
-
);
|
|
220
|
-
|
|
221
|
-
await waitFor( () =>
|
|
222
|
-
expect(
|
|
223
|
-
screen.getByRole( 'menu', {
|
|
224
|
-
name: 'Block Name',
|
|
225
|
-
} )
|
|
226
|
-
).toBeVisible()
|
|
227
|
-
);
|
|
228
|
-
} );
|
|
229
|
-
|
|
230
|
-
test( 'should simulate a click event, which should call onToggle.', async () => {
|
|
231
|
-
const user = userEvent.setup();
|
|
232
|
-
|
|
233
|
-
render(
|
|
234
|
-
<BlockSwitcherDropdownMenu blocks={ [ headingBlock1 ] } />
|
|
235
|
-
);
|
|
236
|
-
|
|
237
|
-
expect(
|
|
238
|
-
screen.getByRole( 'button', {
|
|
239
|
-
name: 'Block Name',
|
|
240
|
-
expanded: false,
|
|
241
|
-
} )
|
|
242
|
-
).toBeVisible();
|
|
243
|
-
expect(
|
|
244
|
-
screen.queryByRole( 'menu', {
|
|
245
|
-
name: 'Block Name',
|
|
246
|
-
} )
|
|
247
|
-
).not.toBeInTheDocument();
|
|
248
|
-
|
|
249
|
-
await user.click(
|
|
250
|
-
screen.getByRole( 'button', {
|
|
251
|
-
name: 'Block Name',
|
|
252
|
-
expanded: false,
|
|
253
|
-
} )
|
|
254
|
-
);
|
|
255
|
-
|
|
256
|
-
await waitFor( () =>
|
|
257
|
-
expect(
|
|
258
|
-
screen.getByRole( 'button', {
|
|
259
|
-
name: 'Block Name',
|
|
260
|
-
expanded: true,
|
|
261
|
-
} )
|
|
262
|
-
).toBeVisible()
|
|
263
|
-
);
|
|
264
|
-
|
|
265
|
-
await waitFor( () =>
|
|
266
|
-
expect(
|
|
267
|
-
screen.getByRole( 'menu', {
|
|
268
|
-
name: 'Block Name',
|
|
269
|
-
} )
|
|
270
|
-
).toBeVisible()
|
|
271
|
-
);
|
|
272
|
-
} );
|
|
273
|
-
|
|
274
|
-
test( 'should create the transform items for the chosen block.', async () => {
|
|
275
|
-
const user = userEvent.setup();
|
|
276
|
-
|
|
277
|
-
render(
|
|
278
|
-
<BlockSwitcherDropdownMenu blocks={ [ headingBlock1 ] } />
|
|
279
|
-
);
|
|
280
|
-
|
|
281
|
-
await user.click(
|
|
282
|
-
screen.getByRole( 'button', {
|
|
283
|
-
name: 'Block Name',
|
|
284
|
-
expanded: false,
|
|
285
|
-
} )
|
|
286
|
-
);
|
|
287
|
-
|
|
288
|
-
await waitFor( () =>
|
|
289
|
-
expect(
|
|
290
|
-
within(
|
|
291
|
-
screen.getByRole( 'menu', {
|
|
292
|
-
name: 'Block Name',
|
|
293
|
-
} )
|
|
294
|
-
).getByRole( 'menuitem' )
|
|
295
|
-
).toBeInTheDocument()
|
|
296
|
-
);
|
|
297
|
-
} );
|
|
174
|
+
).toBeVisible()
|
|
175
|
+
);
|
|
176
|
+
expect(
|
|
177
|
+
screen.getByRole( 'menu', {
|
|
178
|
+
name: 'Block Name',
|
|
179
|
+
} )
|
|
180
|
+
).toHaveTextContent( 'No transforms.' );
|
|
298
181
|
} );
|
|
299
182
|
} );
|
|
@@ -98,6 +98,10 @@
|
|
|
98
98
|
|
|
99
99
|
.block-editor-block-parent-selector {
|
|
100
100
|
position: relative;
|
|
101
|
+
// Must use the same negative margins of the .components-toolbar-group
|
|
102
|
+
// https://github.com/WordPress/gutenberg/blob/73a4716f429b5dce0190638049f5bd30f0b242f6/packages/block-editor/src/components/block-toolbar/style.scss#L32-L33
|
|
103
|
+
margin-top: -$border-width;
|
|
104
|
+
margin-bottom: -$border-width;
|
|
101
105
|
|
|
102
106
|
// Parent selector dot divider
|
|
103
107
|
&::after {
|
|
@@ -108,11 +112,6 @@
|
|
|
108
112
|
bottom: $grid-unit-20;
|
|
109
113
|
}
|
|
110
114
|
}
|
|
111
|
-
|
|
112
|
-
.block-editor-block-parent-selector__button {
|
|
113
|
-
position: relative;
|
|
114
|
-
top: -1px;
|
|
115
|
-
}
|
|
116
115
|
}
|
|
117
116
|
|
|
118
117
|
|
|
@@ -203,6 +202,24 @@
|
|
|
203
202
|
|
|
204
203
|
.block-editor-block-mover .block-editor-block-mover__move-button-container {
|
|
205
204
|
width: auto;
|
|
205
|
+
|
|
206
|
+
@include break-small() {
|
|
207
|
+
position: relative;
|
|
208
|
+
|
|
209
|
+
&::before {
|
|
210
|
+
content: "";
|
|
211
|
+
height: $border-width;
|
|
212
|
+
width: 100%;
|
|
213
|
+
background: $gray-900;
|
|
214
|
+
position: absolute;
|
|
215
|
+
top: 50%;
|
|
216
|
+
left: 50%;
|
|
217
|
+
// With Top toolbar enabled, this separator has a smaller width. Translating the
|
|
218
|
+
// X axis allows to make the separator always centered regardless of its width.
|
|
219
|
+
transform: translate(-50%, 0);
|
|
220
|
+
margin-top: -$border-width * 0.5;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
206
223
|
}
|
|
207
224
|
|
|
208
225
|
.block-editor-block-mover.is-horizontal {
|
|
@@ -231,19 +248,6 @@
|
|
|
231
248
|
padding-right: $grid-unit-15;
|
|
232
249
|
}
|
|
233
250
|
|
|
234
|
-
@include break-small() {
|
|
235
|
-
// Specificity override for https://github.com/WordPress/gutenberg/blob/try/block-toolbar-labels/packages/block-editor/src/components/block-mover/style.scss#L69
|
|
236
|
-
.is-up-button.is-up-button.is-up-button {
|
|
237
|
-
margin-right: 0;
|
|
238
|
-
border-radius: 0;
|
|
239
|
-
order: 1;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
.is-down-button.is-down-button.is-down-button {
|
|
243
|
-
order: 2;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
251
|
.block-editor-block-contextual-toolbar .block-editor-block-mover.is-horizontal .block-editor-block-mover-button.block-editor-block-mover-button {
|
|
248
252
|
width: auto;
|
|
249
253
|
}
|
|
@@ -24,6 +24,8 @@ export const InsertionPointOpenRef = createContext();
|
|
|
24
24
|
function InbetweenInsertionPointPopover( {
|
|
25
25
|
__unstablePopoverSlot,
|
|
26
26
|
__unstableContentRef,
|
|
27
|
+
operation = 'insert',
|
|
28
|
+
nearestSide = 'right',
|
|
27
29
|
} ) {
|
|
28
30
|
const { selectBlock, hideInsertionPoint } = useDispatch( blockEditorStore );
|
|
29
31
|
const openRef = useContext( InsertionPointOpenRef );
|
|
@@ -138,9 +140,14 @@ function InbetweenInsertionPointPopover( {
|
|
|
138
140
|
return null;
|
|
139
141
|
}
|
|
140
142
|
|
|
143
|
+
const orientationClassname =
|
|
144
|
+
orientation === 'horizontal' || operation === 'group'
|
|
145
|
+
? 'is-horizontal'
|
|
146
|
+
: 'is-vertical';
|
|
147
|
+
|
|
141
148
|
const className = classnames(
|
|
142
149
|
'block-editor-block-list__insertion-point',
|
|
143
|
-
|
|
150
|
+
orientationClassname
|
|
144
151
|
);
|
|
145
152
|
|
|
146
153
|
return (
|
|
@@ -149,6 +156,8 @@ function InbetweenInsertionPointPopover( {
|
|
|
149
156
|
nextClientId={ nextClientId }
|
|
150
157
|
__unstablePopoverSlot={ __unstablePopoverSlot }
|
|
151
158
|
__unstableContentRef={ __unstableContentRef }
|
|
159
|
+
operation={ operation }
|
|
160
|
+
nearestSide={ nearestSide }
|
|
152
161
|
>
|
|
153
162
|
<motion.div
|
|
154
163
|
layout={ ! disableMotion }
|
|
@@ -236,6 +245,10 @@ export default function InsertionPoint( props ) {
|
|
|
236
245
|
{ ...props }
|
|
237
246
|
/>
|
|
238
247
|
) : (
|
|
239
|
-
<InbetweenInsertionPointPopover
|
|
248
|
+
<InbetweenInsertionPointPopover
|
|
249
|
+
operation={ insertionPoint.operation }
|
|
250
|
+
nearestSide={ insertionPoint.nearestSide }
|
|
251
|
+
{ ...props }
|
|
252
|
+
/>
|
|
240
253
|
);
|
|
241
254
|
}
|
|
@@ -235,6 +235,11 @@
|
|
|
235
235
|
padding-right: 6px;
|
|
236
236
|
padding-left: 6px;
|
|
237
237
|
background-color: $white;
|
|
238
|
+
|
|
239
|
+
.show-icon-labels & {
|
|
240
|
+
padding-right: $grid-unit-15;
|
|
241
|
+
padding-left: $grid-unit-15;
|
|
242
|
+
}
|
|
238
243
|
}
|
|
239
244
|
}
|
|
240
245
|
|
|
@@ -242,15 +247,11 @@
|
|
|
242
247
|
.show-icon-labels & {
|
|
243
248
|
|
|
244
249
|
.block-editor-block-parent-selector {
|
|
245
|
-
position:
|
|
246
|
-
|
|
250
|
+
position: relative;
|
|
251
|
+
left: auto;
|
|
247
252
|
margin-left: -$border-width;
|
|
248
|
-
margin-bottom: -$border-width;
|
|
249
|
-
|
|
250
|
-
.block-editor-block-parent-selector__button {
|
|
251
|
-
position: static;
|
|
252
|
-
}
|
|
253
253
|
}
|
|
254
|
+
|
|
254
255
|
.block-editor-block-mover__move-button-container,
|
|
255
256
|
.block-editor-block-toolbar__block-controls .block-editor-block-mover {
|
|
256
257
|
border-left: 1px solid $gray-900;
|
|
@@ -181,6 +181,13 @@ export function getComputedFluidTypographyValue( {
|
|
|
181
181
|
return null;
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
+
// Calculates the linear factor denominator. If it's 0, we cannot calculate a fluid value.
|
|
185
|
+
const linearDenominator =
|
|
186
|
+
maximumViewportWidthParsed.value - minimumViewportWidthParsed.value;
|
|
187
|
+
if ( ! linearDenominator ) {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
|
|
184
191
|
// Build CSS rule.
|
|
185
192
|
// Borrowed from https://websemantics.uk/tools/responsive-font-calculator/.
|
|
186
193
|
const minViewportWidthOffsetValue = roundToPrecision(
|
|
@@ -193,8 +200,7 @@ export function getComputedFluidTypographyValue( {
|
|
|
193
200
|
const linearFactor =
|
|
194
201
|
100 *
|
|
195
202
|
( ( maximumFontSizeParsed.value - minimumFontSizeParsed.value ) /
|
|
196
|
-
|
|
197
|
-
minimumViewportWidthParsed.value ) );
|
|
203
|
+
linearDenominator );
|
|
198
204
|
const linearFactorScaled = roundToPrecision(
|
|
199
205
|
( linearFactor || 1 ) * scaleFactor,
|
|
200
206
|
3
|
|
@@ -64,6 +64,15 @@ describe( 'getComputedFluidTypographyValue()', () => {
|
|
|
64
64
|
);
|
|
65
65
|
} );
|
|
66
66
|
|
|
67
|
+
it( 'should return `null` when maximum and minimum viewport width are equal', () => {
|
|
68
|
+
const fluidTypographyValues = getComputedFluidTypographyValue( {
|
|
69
|
+
fontSize: '30px',
|
|
70
|
+
minimumViewportWidth: '500px',
|
|
71
|
+
maximumViewportWidth: '500px',
|
|
72
|
+
} );
|
|
73
|
+
expect( fluidTypographyValues ).toBeNull();
|
|
74
|
+
} );
|
|
75
|
+
|
|
67
76
|
it( 'should return a fluid font size when given a scale factor', () => {
|
|
68
77
|
const fluidTypographyValues = getComputedFluidTypographyValue( {
|
|
69
78
|
fontSize: '30px',
|
|
@@ -85,8 +85,10 @@ export default function BorderPanel( {
|
|
|
85
85
|
defaultControls = DEFAULT_CONTROLS,
|
|
86
86
|
} ) {
|
|
87
87
|
const colors = useColorsPerOrigin( settings );
|
|
88
|
-
const decodeValue = (
|
|
89
|
-
getValueFromVariable( { settings }, '', rawValue )
|
|
88
|
+
const decodeValue = useCallback(
|
|
89
|
+
( rawValue ) => getValueFromVariable( { settings }, '', rawValue ),
|
|
90
|
+
[ settings ]
|
|
91
|
+
);
|
|
90
92
|
const encodeColorValue = ( colorValue ) => {
|
|
91
93
|
const allColors = colors.flatMap(
|
|
92
94
|
( { colors: originColors } ) => originColors
|
|
@@ -98,25 +100,13 @@ export default function BorderPanel( {
|
|
|
98
100
|
? 'var:preset|color|' + colorObject.slug
|
|
99
101
|
: colorValue;
|
|
100
102
|
};
|
|
101
|
-
const decodeColorValue = useCallback(
|
|
102
|
-
( colorValue ) => {
|
|
103
|
-
const allColors = colors.flatMap(
|
|
104
|
-
( { colors: originColors } ) => originColors
|
|
105
|
-
);
|
|
106
|
-
const colorObject = allColors.find(
|
|
107
|
-
( { slug } ) => colorValue === 'var:preset|color|' + slug
|
|
108
|
-
);
|
|
109
|
-
return colorObject ? colorObject.color : colorValue;
|
|
110
|
-
},
|
|
111
|
-
[ colors ]
|
|
112
|
-
);
|
|
113
103
|
const border = useMemo( () => {
|
|
114
104
|
if ( hasSplitBorders( inheritedValue?.border ) ) {
|
|
115
105
|
const borderValue = { ...inheritedValue?.border };
|
|
116
106
|
[ 'top', 'right', 'bottom', 'left' ].forEach( ( side ) => {
|
|
117
107
|
borderValue[ side ] = {
|
|
118
108
|
...borderValue[ side ],
|
|
119
|
-
color:
|
|
109
|
+
color: decodeValue( borderValue[ side ]?.color ),
|
|
120
110
|
};
|
|
121
111
|
} );
|
|
122
112
|
return borderValue;
|
|
@@ -124,10 +114,10 @@ export default function BorderPanel( {
|
|
|
124
114
|
return {
|
|
125
115
|
...inheritedValue?.border,
|
|
126
116
|
color: inheritedValue?.border?.color
|
|
127
|
-
?
|
|
117
|
+
? decodeValue( inheritedValue?.border?.color )
|
|
128
118
|
: undefined,
|
|
129
119
|
};
|
|
130
|
-
}, [ inheritedValue?.border,
|
|
120
|
+
}, [ inheritedValue?.border, decodeValue ] );
|
|
131
121
|
const setBorder = ( newBorder ) =>
|
|
132
122
|
onChange( { ...value, border: newBorder } );
|
|
133
123
|
const showBorderColor = useHasBorderColorControl( settings );
|
|
@@ -26,6 +26,7 @@ import { shadow as shadowIcon, Icon, check } from '@wordpress/icons';
|
|
|
26
26
|
/**
|
|
27
27
|
* Internal dependencies
|
|
28
28
|
*/
|
|
29
|
+
import { mergeOrigins } from '../use-settings';
|
|
29
30
|
import { getValueFromVariable, TOOLSPANEL_DROPDOWNMENU_PROPS } from './utils';
|
|
30
31
|
import { setImmutably } from '../../utils/object';
|
|
31
32
|
|
|
@@ -81,8 +82,22 @@ export default function EffectsPanel( {
|
|
|
81
82
|
// Shadow
|
|
82
83
|
const hasShadowEnabled = useHasShadowControl( settings );
|
|
83
84
|
const shadow = decodeValue( inheritedValue?.shadow );
|
|
85
|
+
const shadowPresets = settings?.shadow?.presets;
|
|
86
|
+
const mergedShadowPresets = shadowPresets
|
|
87
|
+
? mergeOrigins( shadowPresets )
|
|
88
|
+
: [];
|
|
84
89
|
const setShadow = ( newValue ) => {
|
|
85
|
-
|
|
90
|
+
const slug = mergedShadowPresets?.find(
|
|
91
|
+
( { shadow: shadowName } ) => shadowName === newValue
|
|
92
|
+
)?.slug;
|
|
93
|
+
|
|
94
|
+
onChange(
|
|
95
|
+
setImmutably(
|
|
96
|
+
value,
|
|
97
|
+
[ 'shadow' ],
|
|
98
|
+
slug ? `var:preset|shadow|${ slug }` : newValue || undefined
|
|
99
|
+
)
|
|
100
|
+
);
|
|
86
101
|
};
|
|
87
102
|
const hasShadow = () => !! value?.shadow;
|
|
88
103
|
const resetShadow = () => setShadow( undefined );
|
|
@@ -66,6 +66,7 @@ const VALID_SETTINGS = [
|
|
|
66
66
|
'spacing.units',
|
|
67
67
|
'typography.fluid',
|
|
68
68
|
'typography.customFontSize',
|
|
69
|
+
'typography.defaultFontSizes',
|
|
69
70
|
'typography.dropCap',
|
|
70
71
|
'typography.fontFamilies',
|
|
71
72
|
'typography.fontSizes',
|
|
@@ -238,6 +239,7 @@ export function useSettingsForBlockElement(
|
|
|
238
239
|
...updatedSettings.typography,
|
|
239
240
|
fontSizes: {},
|
|
240
241
|
customFontSize: false,
|
|
242
|
+
defaultFontSizes: false,
|
|
241
243
|
};
|
|
242
244
|
}
|
|
243
245
|
|