@wordpress/block-editor 15.22.1-next.v.202606191442.0 → 15.22.1
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 +1 -1
- package/README.md +2 -2
- package/build/components/block-editing-mode/index.cjs +13 -7
- package/build/components/block-editing-mode/index.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +32 -16
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-rename/modal.cjs +0 -1
- package/build/components/block-rename/modal.cjs.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.cjs +14 -6
- package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs +25 -14
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/colors-gradients/dropdown.cjs +4 -1
- package/build/components/colors-gradients/dropdown.cjs.map +3 -3
- package/build/components/contrast-checker/index.cjs +22 -4
- package/build/components/contrast-checker/index.cjs.map +2 -2
- package/build/components/date-format-picker/index.cjs +0 -1
- package/build/components/date-format-picker/index.cjs.map +2 -2
- package/build/components/global-styles/background-panel.cjs +153 -25
- package/build/components/global-styles/background-panel.cjs.map +3 -3
- package/build/components/global-styles/color-gradient-dropdown-item.cjs +227 -0
- package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +7 -0
- package/build/components/global-styles/color-panel.cjs +98 -375
- package/build/components/global-styles/color-panel.cjs.map +3 -3
- package/build/components/global-styles/dimensions-panel.cjs +0 -3
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/hooks.cjs +34 -0
- package/build/components/global-styles/hooks.cjs.map +2 -2
- package/build/components/global-styles/typography-panel.cjs +82 -10
- package/build/components/global-styles/typography-panel.cjs.map +3 -3
- package/build/components/inspector-controls/groups.cjs +2 -0
- package/build/components/inspector-controls/groups.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/styles-tab.cjs +75 -31
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/link-control/index.cjs +1 -2
- package/build/components/link-control/index.cjs.map +2 -2
- package/build/components/list-view/block-select-button.cjs +1 -10
- package/build/components/list-view/block-select-button.cjs.map +3 -3
- package/build/components/provider/use-block-sync.cjs +3 -1
- package/build/components/provider/use-block-sync.cjs.map +2 -2
- package/build/components/url-popover/image-url-input-ui.cjs +0 -2
- package/build/components/url-popover/image-url-input-ui.cjs.map +2 -2
- package/build/components/use-block-display-information/index.cjs +10 -3
- package/build/components/use-block-display-information/index.cjs.map +2 -2
- package/build/hooks/anchor.cjs +0 -1
- package/build/hooks/anchor.cjs.map +2 -2
- package/build/hooks/background.cjs +124 -75
- package/build/hooks/background.cjs.map +3 -3
- package/build/hooks/color.cjs +0 -162
- package/build/hooks/color.cjs.map +3 -3
- package/build/hooks/contrast-checker.cjs +31 -28
- package/build/hooks/contrast-checker.cjs.map +3 -3
- package/build/hooks/custom-class-name.cjs +0 -1
- package/build/hooks/custom-class-name.cjs.map +2 -2
- package/build/hooks/elements.cjs +142 -0
- package/build/hooks/elements.cjs.map +7 -0
- package/build/hooks/grid-visualizer.cjs +21 -11
- package/build/hooks/grid-visualizer.cjs.map +2 -2
- package/build/hooks/layout-child.cjs +38 -8
- package/build/hooks/layout-child.cjs.map +2 -2
- package/build/hooks/layout.cjs +6 -3
- package/build/hooks/layout.cjs.map +2 -2
- package/build/hooks/states.cjs +2 -2
- package/build/hooks/states.cjs.map +2 -2
- package/build/hooks/style.cjs +8 -4
- package/build/hooks/style.cjs.map +2 -2
- package/build/hooks/typography.cjs +62 -10
- package/build/hooks/typography.cjs.map +3 -3
- package/build/layouts/flex.cjs +99 -6
- package/build/layouts/flex.cjs.map +2 -2
- package/build/utils/block-bindings.cjs +9 -9
- package/build/utils/block-bindings.cjs.map +3 -3
- package/build/utils/color-values.cjs +10 -1
- package/build/utils/color-values.cjs.map +3 -3
- package/build/utils/dom.cjs +2 -5
- package/build/utils/dom.cjs.map +3 -3
- package/build/utils/fit-text-frontend.cjs +6 -2
- package/build/utils/fit-text-frontend.cjs.map +3 -3
- package/build/utils/fit-text-utils.cjs +1 -1
- package/build/utils/fit-text-utils.cjs.map +3 -3
- package/build/utils/format-font-style.cjs +1 -1
- package/build/utils/format-font-style.cjs.map +3 -3
- package/build/utils/format-font-weight.cjs +1 -1
- package/build/utils/format-font-weight.cjs.map +3 -3
- package/build/utils/get-editor-region.cjs +4 -2
- package/build/utils/get-editor-region.cjs.map +3 -3
- package/build/utils/get-font-styles-and-weights.cjs +8 -12
- package/build/utils/get-font-styles-and-weights.cjs.map +3 -3
- package/build/utils/get-px-from-css-unit.cjs +1 -1
- package/build/utils/get-px-from-css-unit.cjs.map +1 -1
- package/build/utils/index.cjs +1 -1
- package/build/utils/index.cjs.map +1 -1
- package/build/utils/math.cjs +1 -1
- package/build/utils/math.cjs.map +3 -3
- package/build/utils/object.cjs +8 -8
- package/build/utils/object.cjs.map +3 -3
- package/build/utils/order-inserter-block-items.cjs +1 -1
- package/build/utils/order-inserter-block-items.cjs.map +3 -3
- package/build/utils/pasting.cjs +4 -2
- package/build/utils/pasting.cjs.map +3 -3
- package/build/utils/selection.cjs +2 -1
- package/build/utils/selection.cjs.map +3 -3
- package/build/utils/sorting.cjs +9 -3
- package/build/utils/sorting.cjs.map +3 -3
- package/build/utils/transform-styles/index.cjs +3 -2
- package/build/utils/transform-styles/index.cjs.map +3 -3
- package/build/utils/transform-styles/postcss-urlrebase.d.cjs +2 -0
- package/build/utils/transform-styles/postcss-urlrebase.d.cjs.map +7 -0
- package/build/utils/transform-styles/types.cjs +19 -0
- package/build/utils/transform-styles/types.cjs.map +7 -0
- package/build/utils/types.cjs +19 -0
- package/build/utils/types.cjs.map +7 -0
- package/build-module/components/block-editing-mode/index.mjs +14 -8
- package/build-module/components/block-editing-mode/index.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +32 -16
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-rename/modal.mjs +0 -1
- package/build-module/components/block-rename/modal.mjs.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs +14 -6
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +27 -15
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/colors-gradients/dropdown.mjs +4 -1
- package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
- package/build-module/components/contrast-checker/index.mjs +18 -4
- package/build-module/components/contrast-checker/index.mjs.map +2 -2
- package/build-module/components/date-format-picker/index.mjs +0 -1
- package/build-module/components/date-format-picker/index.mjs.map +2 -2
- package/build-module/components/global-styles/background-panel.mjs +155 -27
- package/build-module/components/global-styles/background-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +207 -0
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +7 -0
- package/build-module/components/global-styles/color-panel.mjs +106 -387
- package/build-module/components/global-styles/color-panel.mjs.map +3 -3
- package/build-module/components/global-styles/dimensions-panel.mjs +0 -3
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/hooks.mjs +33 -0
- package/build-module/components/global-styles/hooks.mjs.map +2 -2
- package/build-module/components/global-styles/typography-panel.mjs +84 -10
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/inspector-controls/groups.mjs +2 -0
- package/build-module/components/inspector-controls/groups.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +75 -31
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/link-control/index.mjs +1 -2
- package/build-module/components/link-control/index.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +2 -17
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/provider/use-block-sync.mjs +3 -1
- package/build-module/components/provider/use-block-sync.mjs.map +2 -2
- package/build-module/components/url-popover/image-url-input-ui.mjs +0 -2
- package/build-module/components/url-popover/image-url-input-ui.mjs.map +2 -2
- package/build-module/components/use-block-display-information/index.mjs +10 -3
- package/build-module/components/use-block-display-information/index.mjs.map +2 -2
- package/build-module/hooks/anchor.mjs +0 -1
- package/build-module/hooks/anchor.mjs.map +2 -2
- package/build-module/hooks/background.mjs +123 -75
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/color.mjs +2 -175
- package/build-module/hooks/color.mjs.map +2 -2
- package/build-module/hooks/contrast-checker.mjs +32 -19
- package/build-module/hooks/contrast-checker.mjs.map +2 -2
- package/build-module/hooks/custom-class-name.mjs +0 -1
- package/build-module/hooks/custom-class-name.mjs.map +2 -2
- package/build-module/hooks/elements.mjs +115 -0
- package/build-module/hooks/elements.mjs.map +7 -0
- package/build-module/hooks/grid-visualizer.mjs +21 -11
- package/build-module/hooks/grid-visualizer.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs +41 -8
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +6 -3
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/states.mjs +2 -2
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/hooks/style.mjs +9 -5
- package/build-module/hooks/style.mjs.map +2 -2
- package/build-module/hooks/typography.mjs +62 -10
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +105 -7
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/utils/block-bindings.mjs +9 -9
- package/build-module/utils/block-bindings.mjs.map +3 -3
- package/build-module/utils/color-values.mjs +9 -1
- package/build-module/utils/color-values.mjs.map +3 -3
- package/build-module/utils/dom.mjs +2 -5
- package/build-module/utils/dom.mjs.map +3 -3
- package/build-module/utils/fit-text-frontend.mjs +6 -2
- package/build-module/utils/fit-text-frontend.mjs.map +3 -3
- package/build-module/utils/fit-text-utils.mjs +1 -1
- package/build-module/utils/fit-text-utils.mjs.map +3 -3
- package/build-module/utils/format-font-style.mjs +1 -1
- package/build-module/utils/format-font-style.mjs.map +3 -3
- package/build-module/utils/format-font-weight.mjs +1 -1
- package/build-module/utils/format-font-weight.mjs.map +3 -3
- package/build-module/utils/get-editor-region.mjs +4 -2
- package/build-module/utils/get-editor-region.mjs.map +3 -3
- package/build-module/utils/get-font-styles-and-weights.mjs +8 -12
- package/build-module/utils/get-font-styles-and-weights.mjs.map +3 -3
- package/build-module/utils/get-px-from-css-unit.mjs +1 -1
- package/build-module/utils/get-px-from-css-unit.mjs.map +1 -1
- package/build-module/utils/index.mjs +1 -1
- package/build-module/utils/index.mjs.map +1 -1
- package/build-module/utils/math.mjs +1 -1
- package/build-module/utils/math.mjs.map +3 -3
- package/build-module/utils/object.mjs +8 -8
- package/build-module/utils/object.mjs.map +3 -3
- package/build-module/utils/order-inserter-block-items.mjs +1 -1
- package/build-module/utils/order-inserter-block-items.mjs.map +3 -3
- package/build-module/utils/pasting.mjs +4 -2
- package/build-module/utils/pasting.mjs.map +3 -3
- package/build-module/utils/selection.mjs +2 -1
- package/build-module/utils/selection.mjs.map +3 -3
- package/build-module/utils/sorting.mjs +9 -3
- package/build-module/utils/sorting.mjs.map +3 -3
- package/build-module/utils/transform-styles/index.mjs +3 -2
- package/build-module/utils/transform-styles/index.mjs.map +3 -3
- package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs +1 -0
- package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs.map +7 -0
- package/build-module/utils/transform-styles/types.mjs +1 -0
- package/build-module/utils/transform-styles/types.mjs.map +7 -0
- package/build-module/utils/types.mjs +1 -0
- package/build-module/utils/types.mjs.map +7 -0
- package/build-style/content-rtl.css +2 -0
- package/build-style/content.css +2 -0
- package/build-style/style-rtl.css +34 -41
- package/build-style/style.css +34 -41
- package/build-types/utils/block-bindings.d.ts +27 -0
- package/build-types/utils/block-bindings.d.ts.map +1 -0
- package/build-types/utils/color-values.d.ts +40 -0
- package/build-types/utils/color-values.d.ts.map +1 -0
- package/build-types/utils/dom.d.ts +19 -19
- package/build-types/utils/dom.d.ts.map +1 -1
- package/build-types/utils/fit-text-frontend.d.ts +7 -0
- package/build-types/utils/fit-text-frontend.d.ts.map +1 -0
- package/build-types/utils/fit-text-utils.d.ts +15 -0
- package/build-types/utils/fit-text-utils.d.ts.map +1 -0
- package/build-types/utils/format-font-style.d.ts +12 -0
- package/build-types/utils/format-font-style.d.ts.map +1 -0
- package/build-types/utils/format-font-weight.d.ts +12 -0
- package/build-types/utils/format-font-weight.d.ts.map +1 -0
- package/build-types/utils/get-editor-region.d.ts +9 -0
- package/build-types/utils/get-editor-region.d.ts.map +1 -0
- package/build-types/utils/get-font-styles-and-weights.d.ts +16 -0
- package/build-types/utils/get-font-styles-and-weights.d.ts.map +1 -0
- package/build-types/utils/get-px-from-css-unit.d.ts +10 -0
- package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -0
- package/build-types/utils/index.d.ts +3 -0
- package/build-types/utils/index.d.ts.map +1 -0
- package/build-types/utils/math.d.ts +61 -0
- package/build-types/utils/math.d.ts.map +1 -0
- package/build-types/utils/object.d.ts +39 -0
- package/build-types/utils/object.d.ts.map +1 -0
- package/build-types/utils/order-inserter-block-items.d.ts +13 -0
- package/build-types/utils/order-inserter-block-items.d.ts.map +1 -0
- package/build-types/utils/pasting.d.ts +28 -0
- package/build-types/utils/pasting.d.ts.map +1 -0
- package/build-types/utils/selection.d.ts +21 -0
- package/build-types/utils/selection.d.ts.map +1 -0
- package/build-types/utils/sorting.d.ts +17 -0
- package/build-types/utils/sorting.d.ts.map +1 -0
- package/build-types/utils/transform-styles/index.d.ts +15 -0
- package/build-types/utils/transform-styles/index.d.ts.map +1 -0
- package/build-types/utils/transform-styles/types.d.ts +13 -0
- package/build-types/utils/transform-styles/types.d.ts.map +1 -0
- package/build-types/utils/types.d.ts +28 -0
- package/build-types/utils/types.d.ts.map +1 -0
- package/package.json +40 -39
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -0
- package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -0
- package/src/components/block-editing-mode/index.js +17 -9
- package/src/components/block-icon/test/__snapshots__/index.js.snap +1 -0
- package/src/components/block-inspector/index.js +20 -10
- package/src/components/block-rename/modal.js +0 -1
- package/src/components/block-toolbar/block-toolbar-icon.js +22 -6
- package/src/components/block-toolbar/test/block-toolbar-icon.js +99 -0
- package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +4 -0
- package/src/components/colors-gradients/control.js +29 -12
- package/src/components/colors-gradients/dropdown.js +4 -1
- package/src/components/colors-gradients/style.scss +39 -2
- package/src/components/contrast-checker/README.md +9 -0
- package/src/components/contrast-checker/index.js +42 -3
- package/src/components/date-format-picker/index.js +0 -1
- package/src/components/default-block-appender/content.scss +3 -0
- package/src/components/global-styles/background-panel.js +201 -34
- package/src/components/global-styles/color-gradient-dropdown-item.js +258 -0
- package/src/components/global-styles/color-panel.js +125 -487
- package/src/components/global-styles/dimensions-panel.js +0 -3
- package/src/components/global-styles/hooks.js +45 -0
- package/src/components/global-styles/test/background-panel.js +56 -0
- package/src/components/global-styles/test/color-panel.js +172 -118
- package/src/components/global-styles/test/typography-panel.js +167 -0
- package/src/components/global-styles/typography-panel.js +100 -11
- package/src/components/inspector-controls/README.md +0 -2
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +74 -28
- package/src/components/link-control/index.js +0 -1
- package/src/components/link-control/test/index.js +2 -3
- package/src/components/list-view/block-select-button.js +2 -17
- package/src/components/provider/use-block-sync.js +3 -1
- package/src/components/rich-text/content.scss +2 -0
- package/src/components/url-popover/image-url-input-ui.js +0 -2
- package/src/components/use-block-display-information/index.js +15 -2
- package/src/components/use-block-display-information/test/index.js +140 -0
- package/src/hooks/anchor.js +0 -1
- package/src/hooks/background.js +210 -133
- package/src/hooks/background.scss +0 -35
- package/src/hooks/color.js +2 -205
- package/src/hooks/color.scss +3 -9
- package/src/hooks/contrast-checker.js +60 -17
- package/src/hooks/custom-class-name.js +0 -1
- package/src/hooks/elements.js +140 -0
- package/src/hooks/elements.scss +8 -0
- package/src/hooks/grid-visualizer.js +59 -45
- package/src/hooks/layout-child.js +51 -12
- package/src/hooks/layout.js +6 -3
- package/src/hooks/states.js +2 -2
- package/src/hooks/style.js +11 -7
- package/src/hooks/test/background.js +59 -0
- package/src/hooks/test/block-style-state.js +14 -14
- package/src/hooks/test/layout.js +6 -6
- package/src/hooks/test/style.js +8 -8
- package/src/hooks/typography.js +70 -6
- package/src/layouts/flex.js +118 -15
- package/src/store/test/private-selectors.js +28 -7
- package/src/store/test/reducer.js +61 -10
- package/src/style.scss +1 -0
- package/src/utils/block-bindings.ts +51 -0
- package/src/utils/color-values.ts +63 -0
- package/src/utils/{dom.js → dom.ts} +27 -27
- package/src/utils/{fit-text-frontend.js → fit-text-frontend.ts} +12 -4
- package/src/utils/{fit-text-utils.js → fit-text-utils.ts} +15 -7
- package/src/utils/{format-font-style.js → format-font-style.ts} +10 -3
- package/src/utils/{format-font-weight.js → format-font-weight.ts} +10 -3
- package/src/utils/{get-editor-region.js → get-editor-region.ts} +10 -6
- package/src/utils/{get-font-styles-and-weights.js → get-font-styles-and-weights.ts} +21 -17
- package/src/utils/{math.js → math.ts} +37 -30
- package/src/utils/object.ts +89 -0
- package/src/utils/{order-inserter-block-items.js → order-inserter-block-items.ts} +8 -5
- package/src/utils/{pasting.js → pasting.ts} +18 -11
- package/src/utils/{selection.js → selection.ts} +11 -4
- package/src/utils/sorting.ts +81 -0
- package/src/utils/test/color-values.js +44 -1
- package/src/utils/transform-styles/{index.js → index.ts} +25 -25
- package/src/utils/transform-styles/postcss-urlrebase.d.ts +15 -0
- package/src/utils/transform-styles/types.ts +13 -0
- package/src/utils/types.ts +29 -0
- package/src/utils/block-bindings.js +0 -46
- package/src/utils/color-values.js +0 -28
- package/src/utils/object.js +0 -67
- package/src/utils/sorting.js +0 -54
- /package/src/utils/{get-px-from-css-unit.js → get-px-from-css-unit.ts} +0 -0
- /package/src/utils/{index.js → index.ts} +0 -0
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
} from '@wordpress/components';
|
|
12
12
|
import { __ } from '@wordpress/i18n';
|
|
13
13
|
import { useCallback, useMemo } from '@wordpress/element';
|
|
14
|
-
import { getValueFromVariable } from '@wordpress/global-styles-engine';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Internal dependencies
|
|
@@ -25,8 +24,15 @@ import TextTransformControl from '../text-transform-control';
|
|
|
25
24
|
import TextDecorationControl from '../text-decoration-control';
|
|
26
25
|
import TextIndentControl from '../text-indent-control';
|
|
27
26
|
import WritingModeControl from '../writing-mode-control';
|
|
27
|
+
import ColorGradientDropdownItem from './color-gradient-dropdown-item';
|
|
28
|
+
import { useHasTextPanel } from './color-panel';
|
|
29
|
+
import { useColorGradientSettings } from './hooks';
|
|
28
30
|
import { useToolsPanelDropdownMenuProps } from './utils';
|
|
29
31
|
import { setImmutably } from '../../utils/object';
|
|
32
|
+
import {
|
|
33
|
+
extractPresetSlug,
|
|
34
|
+
encodeColorValueWithPalette,
|
|
35
|
+
} from '../../utils/color-values';
|
|
30
36
|
import {
|
|
31
37
|
getMergedFontFamiliesAndFontFamilyFaces,
|
|
32
38
|
findNearestStyleAndWeight,
|
|
@@ -48,6 +54,7 @@ export function useHasTypographyPanel( settings ) {
|
|
|
48
54
|
const hasWritingMode = useHasWritingModeControl( settings );
|
|
49
55
|
const hasTextColumns = useHasTextColumnsControl( settings );
|
|
50
56
|
const hasFontSize = useHasFontSizeControl( settings );
|
|
57
|
+
const hasTextColor = useHasTextPanel( settings );
|
|
51
58
|
|
|
52
59
|
return (
|
|
53
60
|
hasFontFamily ||
|
|
@@ -60,7 +67,8 @@ export function useHasTypographyPanel( settings ) {
|
|
|
60
67
|
hasTextDecoration ||
|
|
61
68
|
hasTextIndent ||
|
|
62
69
|
hasWritingMode ||
|
|
63
|
-
hasTextColumns
|
|
70
|
+
hasTextColumns ||
|
|
71
|
+
hasTextColor
|
|
64
72
|
);
|
|
65
73
|
}
|
|
66
74
|
|
|
@@ -143,7 +151,7 @@ function getMergedFontSizes( settings ) {
|
|
|
143
151
|
];
|
|
144
152
|
}
|
|
145
153
|
|
|
146
|
-
function TypographyToolsPanel( {
|
|
154
|
+
export function TypographyToolsPanel( {
|
|
147
155
|
resetAllFilter,
|
|
148
156
|
onChange,
|
|
149
157
|
value,
|
|
@@ -161,6 +169,7 @@ function TypographyToolsPanel( {
|
|
|
161
169
|
label={ __( 'Typography' ) }
|
|
162
170
|
resetAll={ resetAll }
|
|
163
171
|
panelId={ panelId }
|
|
172
|
+
__experimentalFirstVisibleItemClass="first"
|
|
164
173
|
dropdownMenuProps={ dropdownMenuProps }
|
|
165
174
|
>
|
|
166
175
|
{ children }
|
|
@@ -169,6 +178,7 @@ function TypographyToolsPanel( {
|
|
|
169
178
|
}
|
|
170
179
|
|
|
171
180
|
const DEFAULT_CONTROLS = {
|
|
181
|
+
textColor: true,
|
|
172
182
|
fontFamily: true,
|
|
173
183
|
fontSize: true,
|
|
174
184
|
fontAppearance: true,
|
|
@@ -191,9 +201,47 @@ export default function TypographyPanel( {
|
|
|
191
201
|
panelId,
|
|
192
202
|
defaultControls = DEFAULT_CONTROLS,
|
|
193
203
|
isGlobalStyles = false,
|
|
204
|
+
contrastWarning,
|
|
194
205
|
} ) {
|
|
195
|
-
const
|
|
196
|
-
|
|
206
|
+
const { colors, allColors, areCustomSolidsEnabled, decodeValue } =
|
|
207
|
+
useColorGradientSettings( settings );
|
|
208
|
+
|
|
209
|
+
// Text color. Writes to `color.text` (unchanged storage path). The
|
|
210
|
+
// control is rendered here instead of the Color panel because text
|
|
211
|
+
// color is a typographic concern.
|
|
212
|
+
const hasTextColorEnabled = useHasTextPanel( settings );
|
|
213
|
+
const textColor = decodeValue( inheritedValue?.color?.text );
|
|
214
|
+
const userTextColor = decodeValue( value?.color?.text );
|
|
215
|
+
const hasTextColorValue = () => !! value?.color?.text;
|
|
216
|
+
const setTextColor = ( newColor, newSlug ) => {
|
|
217
|
+
const encoded = encodeColorValueWithPalette(
|
|
218
|
+
allColors,
|
|
219
|
+
newColor,
|
|
220
|
+
newSlug
|
|
221
|
+
);
|
|
222
|
+
let changedObject = setImmutably( value, [ 'color', 'text' ], encoded );
|
|
223
|
+
// Keep an in-sync link color following the text color (e.g. a
|
|
224
|
+
// Button's link color tracks its text color). Compare raw encoded
|
|
225
|
+
// references (e.g. `var:preset|color|slug`), not decoded hex values.
|
|
226
|
+
// Two palette entries can share the same hex but carry different
|
|
227
|
+
// slugs (e.g. `var:preset|color|dark-background` and
|
|
228
|
+
// `var:preset|color|dark-text` both resolving to `#000`); comparing
|
|
229
|
+
// decoded values would conflate them and incorrectly force the link
|
|
230
|
+
// color to follow the text color even when the user deliberately
|
|
231
|
+
// chose a different palette slot.
|
|
232
|
+
if (
|
|
233
|
+
inheritedValue?.color?.text ===
|
|
234
|
+
inheritedValue?.elements?.link?.color?.text
|
|
235
|
+
) {
|
|
236
|
+
changedObject = setImmutably(
|
|
237
|
+
changedObject,
|
|
238
|
+
[ 'elements', 'link', 'color', 'text' ],
|
|
239
|
+
encoded
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
onChange( changedObject );
|
|
243
|
+
};
|
|
244
|
+
const resetTextColor = () => setTextColor( undefined );
|
|
197
245
|
|
|
198
246
|
// Font Family
|
|
199
247
|
const hasFontFamilyEnabled = useHasFontFamilyControl( settings );
|
|
@@ -490,12 +538,25 @@ export default function TypographyPanel( {
|
|
|
490
538
|
const hasTextAlign = () => !! value?.typography?.textAlign;
|
|
491
539
|
const resetTextAlign = () => setTextAlign( undefined );
|
|
492
540
|
|
|
493
|
-
const resetAllFilter = useCallback(
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
541
|
+
const resetAllFilter = useCallback(
|
|
542
|
+
( previousValue ) => {
|
|
543
|
+
if ( ! hasTextColorEnabled ) {
|
|
544
|
+
return {
|
|
545
|
+
...previousValue,
|
|
546
|
+
typography: {},
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
return {
|
|
550
|
+
...previousValue,
|
|
551
|
+
typography: {},
|
|
552
|
+
color: {
|
|
553
|
+
...previousValue?.color,
|
|
554
|
+
text: undefined,
|
|
555
|
+
},
|
|
556
|
+
};
|
|
557
|
+
},
|
|
558
|
+
[ hasTextColorEnabled ]
|
|
559
|
+
);
|
|
499
560
|
|
|
500
561
|
return (
|
|
501
562
|
<Wrapper
|
|
@@ -504,6 +565,34 @@ export default function TypographyPanel( {
|
|
|
504
565
|
onChange={ onChange }
|
|
505
566
|
panelId={ panelId }
|
|
506
567
|
>
|
|
568
|
+
{ hasTextColorEnabled && (
|
|
569
|
+
<ColorGradientDropdownItem
|
|
570
|
+
label={ __( 'Color' ) }
|
|
571
|
+
hasValue={ hasTextColorValue }
|
|
572
|
+
resetValue={ resetTextColor }
|
|
573
|
+
isShownByDefault={ defaultControls.textColor }
|
|
574
|
+
indicators={ [ textColor ] }
|
|
575
|
+
contrastWarning={ contrastWarning }
|
|
576
|
+
tabs={ [
|
|
577
|
+
{
|
|
578
|
+
key: 'text',
|
|
579
|
+
label: __( 'Color' ),
|
|
580
|
+
inheritedValue: textColor,
|
|
581
|
+
inheritedSlug: extractPresetSlug(
|
|
582
|
+
inheritedValue?.color?.text,
|
|
583
|
+
'color'
|
|
584
|
+
),
|
|
585
|
+
setValue: setTextColor,
|
|
586
|
+
userValue: userTextColor,
|
|
587
|
+
},
|
|
588
|
+
] }
|
|
589
|
+
colorGradientControlSettings={ {
|
|
590
|
+
colors,
|
|
591
|
+
disableCustomColors: ! areCustomSolidsEnabled,
|
|
592
|
+
} }
|
|
593
|
+
panelId={ panelId }
|
|
594
|
+
/>
|
|
595
|
+
) }
|
|
507
596
|
{ hasFontFamilyEnabled && (
|
|
508
597
|
<ToolsPanelItem
|
|
509
598
|
label={ __( 'Font' ) }
|
|
@@ -114,7 +114,6 @@ registerBlockType( 'my-plugin/inspector-controls-example', {
|
|
|
114
114
|
/>
|
|
115
115
|
|
|
116
116
|
<TextControl
|
|
117
|
-
__next40pxDefaultSize
|
|
118
117
|
label="Text Field"
|
|
119
118
|
help="Additional help text"
|
|
120
119
|
value={ textField }
|
|
@@ -204,7 +203,6 @@ function MyBlockEdit( { attributes, setAttributes } ) {
|
|
|
204
203
|
</InspectorControls>
|
|
205
204
|
<InspectorAdvancedControls>
|
|
206
205
|
<TextControl
|
|
207
|
-
__next40pxDefaultSize
|
|
208
206
|
label="HTML anchor"
|
|
209
207
|
value={ attributes.anchor }
|
|
210
208
|
onChange={ ( nextValue ) => {
|
|
@@ -16,6 +16,7 @@ const InspectorControlsDimensions = createSlotFill(
|
|
|
16
16
|
'InspectorControlsDimensions'
|
|
17
17
|
);
|
|
18
18
|
const InspectorControlsLayout = createSlotFill( 'InspectorControlsLayout' );
|
|
19
|
+
const InspectorControlsElements = createSlotFill( 'InspectorControlsElements' );
|
|
19
20
|
const InspectorControlsPosition = createSlotFill( 'InspectorControlsPosition' );
|
|
20
21
|
const InspectorControlsTypography = createSlotFill(
|
|
21
22
|
'InspectorControlsTypography'
|
|
@@ -35,6 +36,7 @@ const groups = {
|
|
|
35
36
|
content: InspectorControlsContent,
|
|
36
37
|
dimensions: InspectorControlsDimensions,
|
|
37
38
|
effects: InspectorControlsEffects,
|
|
39
|
+
elements: InspectorControlsElements,
|
|
38
40
|
filter: InspectorControlsFilter,
|
|
39
41
|
layout: InspectorControlsLayout,
|
|
40
42
|
list: InspectorControlsListView,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
|
+
import { useMemo } from '@wordpress/element';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
@@ -13,14 +14,22 @@ import PositionControls from './position-controls-panel';
|
|
|
13
14
|
import { useBorderPanelLabel } from '../../hooks/border';
|
|
14
15
|
import { useBlockSettings } from '../../hooks/utils';
|
|
15
16
|
import { store as blockEditorStore } from '../../store';
|
|
16
|
-
import {
|
|
17
|
+
import { ElementsEdit } from '../../hooks/elements';
|
|
18
|
+
import { TypographyPanel } from '../../hooks/typography';
|
|
19
|
+
import { BackgroundImagePanel } from '../../hooks/background';
|
|
17
20
|
import { ColorToolsPanel } from '../global-styles/color-panel';
|
|
21
|
+
import { TypographyToolsPanel } from '../global-styles/typography-panel';
|
|
22
|
+
import { BackgroundToolsPanel } from '../global-styles/background-panel';
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
// Section blocks present a curated subset of the normal block style panels.
|
|
25
|
+
// Their block-support fills are gated off by editing mode (see
|
|
26
|
+
// `BlockStyleControls` in hooks/style.js), so each panel is direct-rendered
|
|
27
|
+
// here rather than via the inspector slots, with settings restricted to the
|
|
28
|
+
// supports a section should expose:
|
|
29
|
+
// - Typography: text color only (font controls disabled).
|
|
30
|
+
// - Background: color + gradient only (image controls disabled).
|
|
31
|
+
// - Elements: link/heading/button/caption colors (unchanged).
|
|
32
|
+
function SectionStyleControls( { blockName, clientId, contentClientIds } ) {
|
|
24
33
|
const settings = useBlockSettings( blockName );
|
|
25
34
|
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
26
35
|
|
|
@@ -42,21 +51,51 @@ function SectionBlockColorControls( {
|
|
|
42
51
|
updateBlockAttributes( clientId, newAttributes );
|
|
43
52
|
};
|
|
44
53
|
|
|
54
|
+
const typographySettings = useMemo(
|
|
55
|
+
() => ( { ...settings, typography: {} } ),
|
|
56
|
+
[ settings ]
|
|
57
|
+
);
|
|
58
|
+
const backgroundSettings = useMemo(
|
|
59
|
+
() => ( {
|
|
60
|
+
...settings,
|
|
61
|
+
background: {
|
|
62
|
+
...settings.background,
|
|
63
|
+
backgroundImage: false,
|
|
64
|
+
backgroundSize: false,
|
|
65
|
+
},
|
|
66
|
+
} ),
|
|
67
|
+
[ settings ]
|
|
68
|
+
);
|
|
69
|
+
|
|
45
70
|
return (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
71
|
+
<>
|
|
72
|
+
<TypographyPanel
|
|
73
|
+
clientId={ clientId }
|
|
74
|
+
name={ blockName }
|
|
75
|
+
settings={ typographySettings }
|
|
76
|
+
setAttributes={ setAttributes }
|
|
77
|
+
asWrapper={ TypographyToolsPanel }
|
|
78
|
+
/>
|
|
79
|
+
<BackgroundImagePanel
|
|
80
|
+
clientId={ clientId }
|
|
81
|
+
name={ blockName }
|
|
82
|
+
settings={ backgroundSettings }
|
|
83
|
+
setAttributes={ setAttributes }
|
|
84
|
+
asWrapper={ BackgroundToolsPanel }
|
|
85
|
+
/>
|
|
86
|
+
<ElementsEdit
|
|
87
|
+
clientId={ clientId }
|
|
88
|
+
name={ blockName }
|
|
89
|
+
settings={ settings }
|
|
90
|
+
setAttributes={ setAttributes }
|
|
91
|
+
asWrapper={ ColorToolsPanel }
|
|
92
|
+
label={ __( 'Elements' ) }
|
|
93
|
+
defaultControls={ {
|
|
94
|
+
button: hasButtons,
|
|
95
|
+
heading: hasHeading,
|
|
96
|
+
} }
|
|
97
|
+
/>
|
|
98
|
+
</>
|
|
60
99
|
);
|
|
61
100
|
}
|
|
62
101
|
|
|
@@ -72,8 +111,8 @@ const StylesTab = ( {
|
|
|
72
111
|
return (
|
|
73
112
|
<>
|
|
74
113
|
{ hasBlockStyles && <BlockStyles clientId={ clientId } /> }
|
|
75
|
-
{ isSectionBlock && (
|
|
76
|
-
<
|
|
114
|
+
{ isSectionBlock && blockName !== 'core/template-part' && (
|
|
115
|
+
<SectionStyleControls
|
|
77
116
|
blockName={ blockName }
|
|
78
117
|
clientId={ clientId }
|
|
79
118
|
contentClientIds={ contentClientIds }
|
|
@@ -81,10 +120,16 @@ const StylesTab = ( {
|
|
|
81
120
|
) }
|
|
82
121
|
{
|
|
83
122
|
// Extenders have in the past always been allowed to add controls to group
|
|
84
|
-
// the restrictions are lessened for that block.
|
|
123
|
+
// the restrictions are lessened for that block. Template parts are
|
|
124
|
+
// excluded from the curated section controls above and fall through
|
|
125
|
+
// to the full panel set here.
|
|
85
126
|
}
|
|
86
127
|
{ ( ! isSectionBlock || blockName === 'core/template-part' ) && (
|
|
87
128
|
<>
|
|
129
|
+
<InspectorControls.Slot
|
|
130
|
+
group="typography"
|
|
131
|
+
label={ __( 'Typography' ) }
|
|
132
|
+
/>
|
|
88
133
|
<InspectorControls.Slot
|
|
89
134
|
group="color"
|
|
90
135
|
label={ __( 'Color' ) }
|
|
@@ -92,14 +137,10 @@ const StylesTab = ( {
|
|
|
92
137
|
/>
|
|
93
138
|
<InspectorControls.Slot
|
|
94
139
|
group="background"
|
|
95
|
-
label={ __( 'Background
|
|
140
|
+
label={ __( 'Background' ) }
|
|
96
141
|
className="background-block-support-panel__inner-wrapper"
|
|
97
142
|
/>
|
|
98
143
|
<InspectorControls.Slot group="filter" />
|
|
99
|
-
<InspectorControls.Slot
|
|
100
|
-
group="typography"
|
|
101
|
-
label={ __( 'Typography' ) }
|
|
102
|
-
/>
|
|
103
144
|
<InspectorControls.Slot
|
|
104
145
|
group="layout"
|
|
105
146
|
label={ __( 'Layout' ) }
|
|
@@ -112,6 +153,11 @@ const StylesTab = ( {
|
|
|
112
153
|
group="border"
|
|
113
154
|
label={ borderPanelLabel }
|
|
114
155
|
/>
|
|
156
|
+
<InspectorControls.Slot
|
|
157
|
+
group="elements"
|
|
158
|
+
label={ __( 'Elements' ) }
|
|
159
|
+
className="elements-block-support-panel__inner-wrapper"
|
|
160
|
+
/>
|
|
115
161
|
<PositionControls />
|
|
116
162
|
<InspectorControls.Slot group="styles" />
|
|
117
163
|
</>
|
|
@@ -1731,7 +1731,7 @@ describe( 'Selecting links', () => {
|
|
|
1731
1731
|
);
|
|
1732
1732
|
};
|
|
1733
1733
|
|
|
1734
|
-
|
|
1734
|
+
render( <LinkControlConsumer /> );
|
|
1735
1735
|
|
|
1736
1736
|
// Search Input UI.
|
|
1737
1737
|
const searchInput = screen.getByRole( 'combobox', {
|
|
@@ -1804,8 +1804,7 @@ describe( 'Selecting links', () => {
|
|
|
1804
1804
|
} );
|
|
1805
1805
|
|
|
1806
1806
|
// Make sure focus is retained after submission.
|
|
1807
|
-
|
|
1808
|
-
expect( container.firstChild ).toHaveFocus();
|
|
1807
|
+
expect( currentLinkAnchor ).toHaveFocus();
|
|
1809
1808
|
|
|
1810
1809
|
expect( currentLink ).toBeVisible();
|
|
1811
1810
|
expect(
|
|
@@ -12,15 +12,8 @@ import {
|
|
|
12
12
|
privateApis as componentsPrivateApis,
|
|
13
13
|
} from '@wordpress/components';
|
|
14
14
|
import { forwardRef } from '@wordpress/element';
|
|
15
|
-
import {
|
|
16
|
-
Icon,
|
|
17
|
-
lockSmall as lock,
|
|
18
|
-
pinSmall,
|
|
19
|
-
unseen,
|
|
20
|
-
symbol,
|
|
21
|
-
} from '@wordpress/icons';
|
|
15
|
+
import { Icon, lockSmall as lock, pinSmall, unseen } from '@wordpress/icons';
|
|
22
16
|
import { SPACE, ENTER } from '@wordpress/keycodes';
|
|
23
|
-
import { useSelect } from '@wordpress/data';
|
|
24
17
|
|
|
25
18
|
import { Tooltip } from '@wordpress/ui';
|
|
26
19
|
|
|
@@ -33,7 +26,6 @@ import useBlockDisplayTitle from '../block-title/use-block-display-title';
|
|
|
33
26
|
import ListViewExpander from './expander';
|
|
34
27
|
import { useBlockLock } from '../block-lock';
|
|
35
28
|
import useListViewImages from './use-list-view-images';
|
|
36
|
-
import { store as blockEditorStore } from '../../store';
|
|
37
29
|
import { unlock } from '../../lock-unlock';
|
|
38
30
|
|
|
39
31
|
const { Badge: WCBadge } = unlock( componentsPrivateApis );
|
|
@@ -63,13 +55,6 @@ function ListViewBlockSelectButton(
|
|
|
63
55
|
context: 'list-view',
|
|
64
56
|
} );
|
|
65
57
|
const { isLocked } = useBlockLock( clientId );
|
|
66
|
-
const hasPatternName = useSelect(
|
|
67
|
-
( select ) => {
|
|
68
|
-
const { getBlockAttributes } = unlock( select( blockEditorStore ) );
|
|
69
|
-
return !! getBlockAttributes( clientId )?.metadata?.patternName;
|
|
70
|
-
},
|
|
71
|
-
[ clientId ]
|
|
72
|
-
);
|
|
73
58
|
|
|
74
59
|
const shouldShowLockIcon = isLocked;
|
|
75
60
|
const isSticky = blockInformation?.positionType === 'sticky';
|
|
@@ -115,7 +100,7 @@ function ListViewBlockSelectButton(
|
|
|
115
100
|
>
|
|
116
101
|
<ListViewExpander onClick={ onToggleExpanded } />
|
|
117
102
|
<BlockIcon
|
|
118
|
-
icon={
|
|
103
|
+
icon={ blockInformation?.icon }
|
|
119
104
|
showColors
|
|
120
105
|
context="list-view"
|
|
121
106
|
/>
|
|
@@ -252,6 +252,7 @@ export default function useBlockSync( {
|
|
|
252
252
|
cloneBlockWithMapping( block, idMappingRef.current )
|
|
253
253
|
);
|
|
254
254
|
|
|
255
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
255
256
|
setHasControlledInnerBlocks( clientId, true );
|
|
256
257
|
|
|
257
258
|
if ( subscribedRef.current ) {
|
|
@@ -278,12 +279,13 @@ export default function useBlockSync( {
|
|
|
278
279
|
// Clean up the changes made by setControlledBlocks() when the component
|
|
279
280
|
// containing useBlockSync() unmounts.
|
|
280
281
|
const unsetControlledBlocks = () => {
|
|
281
|
-
__unstableMarkNextChangeAsNotPersistent();
|
|
282
282
|
if ( clientId ) {
|
|
283
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
283
284
|
setHasControlledInnerBlocks( clientId, false );
|
|
284
285
|
__unstableMarkNextChangeAsNotPersistent();
|
|
285
286
|
replaceInnerBlocks( clientId, [] );
|
|
286
287
|
} else {
|
|
288
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
287
289
|
resetBlocks( [] );
|
|
288
290
|
}
|
|
289
291
|
};
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
// Use opacity to work in various editor styles.
|
|
11
11
|
// We don't specify the color here, because blocks or editor styles might provide their own.
|
|
12
12
|
opacity: 0.62;
|
|
13
|
+
// Reset the text shadow from the global styles.
|
|
14
|
+
text-shadow: none;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
&:focus {
|
|
@@ -233,7 +233,6 @@ const ImageURLInputUI = ( {
|
|
|
233
233
|
checked={ linkTarget === '_blank' }
|
|
234
234
|
/>
|
|
235
235
|
<TextControl
|
|
236
|
-
__next40pxDefaultSize
|
|
237
236
|
label={ __( 'Link relation' ) }
|
|
238
237
|
value={ rel ?? '' }
|
|
239
238
|
onChange={ onSetLinkRel }
|
|
@@ -249,7 +248,6 @@ const ImageURLInputUI = ( {
|
|
|
249
248
|
) }
|
|
250
249
|
/>
|
|
251
250
|
<TextControl
|
|
252
|
-
__next40pxDefaultSize
|
|
253
251
|
label={ __( 'Link CSS class' ) }
|
|
254
252
|
value={ linkClass || '' }
|
|
255
253
|
onChange={ onSetLinkClass }
|
|
@@ -15,6 +15,8 @@ import { symbol } from '@wordpress/icons';
|
|
|
15
15
|
* Internal dependencies
|
|
16
16
|
*/
|
|
17
17
|
import { store as blockEditorStore } from '../../store';
|
|
18
|
+
import { unlock } from '../../lock-unlock';
|
|
19
|
+
import { isIsolatedEditorKey } from '../../store/private-keys';
|
|
18
20
|
|
|
19
21
|
/** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */
|
|
20
22
|
|
|
@@ -72,11 +74,13 @@ export default function useBlockDisplayInformation( clientId ) {
|
|
|
72
74
|
if ( ! clientId ) {
|
|
73
75
|
return null;
|
|
74
76
|
}
|
|
77
|
+
const blockEditorSelect = select( blockEditorStore );
|
|
75
78
|
const {
|
|
76
79
|
getBlockName,
|
|
77
80
|
getBlockAttributes,
|
|
78
81
|
__experimentalGetParsedPattern,
|
|
79
|
-
|
|
82
|
+
getSettings,
|
|
83
|
+
} = blockEditorSelect;
|
|
80
84
|
const { getBlockType, getActiveBlockVariation } =
|
|
81
85
|
select( blocksStore );
|
|
82
86
|
const blockName = getBlockName( clientId );
|
|
@@ -85,11 +89,20 @@ export default function useBlockDisplayInformation( clientId ) {
|
|
|
85
89
|
return null;
|
|
86
90
|
}
|
|
87
91
|
const attributes = getBlockAttributes( clientId );
|
|
92
|
+
const { isWithinEditedContentOnlySection } =
|
|
93
|
+
unlock( blockEditorSelect );
|
|
94
|
+
const isIsolatedEditor = !! getSettings()?.[ isIsolatedEditorKey ];
|
|
88
95
|
|
|
89
96
|
// Check if this block is a pattern
|
|
90
97
|
const patternName = attributes?.metadata?.patternName;
|
|
98
|
+
const isEditedContentOnlySection =
|
|
99
|
+
isWithinEditedContentOnlySection( clientId );
|
|
91
100
|
|
|
92
|
-
if (
|
|
101
|
+
if (
|
|
102
|
+
patternName &&
|
|
103
|
+
! isEditedContentOnlySection &&
|
|
104
|
+
! isIsolatedEditor
|
|
105
|
+
) {
|
|
93
106
|
const pattern = __experimentalGetParsedPattern( patternName );
|
|
94
107
|
const positionLabel = getPositionTypeLabel( attributes );
|
|
95
108
|
return {
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render } from '@testing-library/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useSelect } from '@wordpress/data';
|
|
10
|
+
import { useEffect } from '@wordpress/element';
|
|
11
|
+
import { symbol } from '@wordpress/icons';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
import useBlockDisplayInformation from '../';
|
|
17
|
+
import { isIsolatedEditorKey } from '../../../store/private-keys';
|
|
18
|
+
|
|
19
|
+
jest.mock( '@wordpress/data/src/components/use-select', () => jest.fn() );
|
|
20
|
+
jest.mock( '../../../lock-unlock', () => ( {
|
|
21
|
+
unlock: ( value ) => ( {
|
|
22
|
+
registerPrivateActions: jest.fn(),
|
|
23
|
+
registerPrivateSelectors: jest.fn(),
|
|
24
|
+
...value,
|
|
25
|
+
} ),
|
|
26
|
+
} ) );
|
|
27
|
+
|
|
28
|
+
const groupIcon = 'group-icon';
|
|
29
|
+
|
|
30
|
+
function TestComponent( { onChange } ) {
|
|
31
|
+
const blockInformation = useBlockDisplayInformation( 'client-id' );
|
|
32
|
+
useEffect( () => {
|
|
33
|
+
onChange( blockInformation );
|
|
34
|
+
}, [ blockInformation, onChange ] );
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function setupUseSelect( {
|
|
39
|
+
attributes = {
|
|
40
|
+
anchor: 'hero',
|
|
41
|
+
metadata: {
|
|
42
|
+
name: 'Hero pattern',
|
|
43
|
+
patternName: 'theme/hero',
|
|
44
|
+
},
|
|
45
|
+
style: {
|
|
46
|
+
position: {
|
|
47
|
+
type: 'sticky',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
blockName = 'core/group',
|
|
52
|
+
blockType = {
|
|
53
|
+
name: 'core/group',
|
|
54
|
+
title: 'Group',
|
|
55
|
+
icon: groupIcon,
|
|
56
|
+
description: 'Gather blocks in a layout container.',
|
|
57
|
+
},
|
|
58
|
+
getActiveBlockVariation = () => null,
|
|
59
|
+
settings = {},
|
|
60
|
+
isWithinEditedSection = false,
|
|
61
|
+
} = {} ) {
|
|
62
|
+
useSelect.mockImplementation( ( mapSelect ) =>
|
|
63
|
+
mapSelect( () => ( {
|
|
64
|
+
getBlockName: () => blockName,
|
|
65
|
+
getBlockAttributes: () => attributes,
|
|
66
|
+
getSettings: () => settings,
|
|
67
|
+
__experimentalGetParsedPattern: () => ( {
|
|
68
|
+
title: 'Hero pattern',
|
|
69
|
+
description: 'Pattern description.',
|
|
70
|
+
} ),
|
|
71
|
+
isWithinEditedContentOnlySection: () => isWithinEditedSection,
|
|
72
|
+
getBlockType: () => blockType,
|
|
73
|
+
getActiveBlockVariation,
|
|
74
|
+
} ) )
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
describe( 'useBlockDisplayInformation', () => {
|
|
79
|
+
beforeEach( () => {
|
|
80
|
+
jest.clearAllMocks();
|
|
81
|
+
} );
|
|
82
|
+
|
|
83
|
+
it( 'displays pattern information for a pattern section that is not being edited', () => {
|
|
84
|
+
setupUseSelect();
|
|
85
|
+
const onChange = jest.fn();
|
|
86
|
+
|
|
87
|
+
render( <TestComponent onChange={ onChange } /> );
|
|
88
|
+
|
|
89
|
+
expect( onChange ).toHaveBeenCalledWith(
|
|
90
|
+
expect.objectContaining( {
|
|
91
|
+
title: 'Pattern',
|
|
92
|
+
icon: symbol,
|
|
93
|
+
description: 'Pattern description.',
|
|
94
|
+
name: 'Hero pattern',
|
|
95
|
+
} )
|
|
96
|
+
);
|
|
97
|
+
} );
|
|
98
|
+
|
|
99
|
+
it( 'displays block information for a pattern section that is being edited', () => {
|
|
100
|
+
setupUseSelect( { isWithinEditedSection: true } );
|
|
101
|
+
const onChange = jest.fn();
|
|
102
|
+
|
|
103
|
+
render( <TestComponent onChange={ onChange } /> );
|
|
104
|
+
|
|
105
|
+
expect( onChange ).toHaveBeenCalledWith(
|
|
106
|
+
expect.objectContaining( {
|
|
107
|
+
title: 'Group',
|
|
108
|
+
icon: groupIcon,
|
|
109
|
+
description: 'Gather blocks in a layout container.',
|
|
110
|
+
name: 'Hero pattern',
|
|
111
|
+
} )
|
|
112
|
+
);
|
|
113
|
+
} );
|
|
114
|
+
|
|
115
|
+
it( 'displays block information for a pattern wrapper in an isolated editor', () => {
|
|
116
|
+
setupUseSelect( {
|
|
117
|
+
attributes: {
|
|
118
|
+
metadata: {
|
|
119
|
+
name: 'Header',
|
|
120
|
+
patternName: 'theme/header-wrapper',
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
settings: {
|
|
124
|
+
[ isIsolatedEditorKey ]: true,
|
|
125
|
+
},
|
|
126
|
+
} );
|
|
127
|
+
const onChange = jest.fn();
|
|
128
|
+
|
|
129
|
+
render( <TestComponent onChange={ onChange } /> );
|
|
130
|
+
|
|
131
|
+
expect( onChange ).toHaveBeenCalledWith(
|
|
132
|
+
expect.objectContaining( {
|
|
133
|
+
title: 'Group',
|
|
134
|
+
icon: groupIcon,
|
|
135
|
+
description: 'Gather blocks in a layout container.',
|
|
136
|
+
name: 'Header',
|
|
137
|
+
} )
|
|
138
|
+
);
|
|
139
|
+
} );
|
|
140
|
+
} );
|
package/src/hooks/anchor.js
CHANGED