@wordpress/block-editor 8.5.4 → 9.0.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 +9 -0
- package/README.md +4 -2
- package/build/components/block-alignment-control/constants.js +48 -0
- package/build/components/block-alignment-control/constants.js.map +1 -0
- package/build/components/block-alignment-control/ui.js +9 -40
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-alignment-control/ui.native.js +92 -0
- package/build/components/block-alignment-control/ui.native.js.map +1 -0
- package/build/components/block-content-overlay/index.js +13 -4
- package/build/components/block-content-overlay/index.js.map +1 -1
- package/build/components/block-list/block.native.js +3 -1
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-class-names.js +1 -7
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build/components/block-lock/modal.js +34 -4
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-lock/toolbar.js +2 -1
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-lock/use-block-lock.js +4 -1
- package/build/components/block-lock/use-block-lock.js.map +1 -1
- package/build/components/block-mover/button.js +4 -4
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +39 -65
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-navigation/dropdown.js +11 -5
- package/build/components/block-navigation/dropdown.js.map +1 -1
- package/build/components/block-popover/inbetween.js +183 -0
- package/build/components/block-popover/inbetween.js.map +1 -0
- package/build/components/block-popover/index.js +97 -0
- package/build/components/block-popover/index.js.map +1 -0
- package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
- package/build/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build/components/block-styles/index.js +1 -10
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -2
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +4 -2
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +5 -5
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +14 -121
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -108
- package/build/components/block-tools/selected-block-popover.js.map +1 -0
- package/build/components/color-style-selector/index.js +9 -0
- package/build/components/color-style-selector/index.js.map +1 -1
- package/build/components/duotone-control/index.js +5 -1
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/index.js +0 -9
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/index.native.js +30 -8
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/list-view/block.js +15 -15
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +9 -13
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/context.js +1 -4
- package/build/components/list-view/context.js.map +1 -1
- package/build/components/list-view/index.js +15 -32
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/rich-text/index.js +0 -5
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +0 -4
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/url-input/index.js +7 -3
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-display-information/index.js +3 -1
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-setting/index.js +42 -18
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/border.js +468 -44
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/dimensions.js +2 -2
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/index.js +3 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/margin.js +64 -12
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +60 -12
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/settings.js +32 -0
- package/build/hooks/settings.js.map +1 -0
- package/build/hooks/use-border-props.js +22 -32
- package/build/hooks/use-border-props.js.map +1 -1
- package/build/store/actions.js +14 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +0 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +0 -26
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +47 -15
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-alignment-control/constants.js +36 -0
- package/build-module/components/block-alignment-control/constants.js.map +1 -0
- package/build-module/components/block-alignment-control/ui.js +4 -35
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.native.js +78 -0
- package/build-module/components/block-alignment-control/ui.native.js.map +1 -0
- package/build-module/components/block-content-overlay/index.js +13 -4
- package/build-module/components/block-content-overlay/index.js.map +1 -1
- package/build-module/components/block-list/block.native.js +3 -1
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +1 -7
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build-module/components/block-lock/modal.js +34 -5
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +2 -1
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-lock/use-block-lock.js +4 -1
- package/build-module/components/block-lock/use-block-lock.js.map +1 -1
- package/build-module/components/block-mover/button.js +5 -5
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +38 -63
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-navigation/dropdown.js +10 -5
- package/build-module/components/block-navigation/dropdown.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +165 -0
- package/build-module/components/block-popover/inbetween.js.map +1 -0
- package/build-module/components/block-popover/index.js +83 -0
- package/build-module/components/block-popover/index.js.map +1 -0
- package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build-module/components/block-styles/index.js +1 -9
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +1 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +3 -2
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +3 -3
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +16 -121
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -105
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
- package/build-module/components/color-style-selector/index.js +6 -0
- package/build-module/components/color-style-selector/index.js.map +1 -1
- package/build-module/components/duotone-control/index.js +4 -1
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/index.js +0 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +31 -10
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/list-view/block.js +15 -16
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +9 -13
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/context.js +1 -4
- package/build-module/components/list-view/context.js.map +1 -1
- package/build-module/components/list-view/index.js +15 -31
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +0 -4
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +0 -4
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/url-input/index.js +7 -3
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +3 -1
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-setting/index.js +43 -19
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/border.js +458 -44
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/dimensions.js +5 -5
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/index.js +2 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/margin.js +61 -13
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +57 -13
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/settings.js +29 -0
- package/build-module/hooks/settings.js.map +1 -0
- package/build-module/hooks/use-border-props.js +21 -30
- package/build-module/hooks/use-border-props.js.map +1 -1
- package/build-module/store/actions.js +14 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +0 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +0 -24
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +44 -15
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +128 -276
- package/build-style/style.css +128 -276
- package/package.json +28 -28
- package/src/components/block-alignment-control/constants.js +45 -0
- package/src/components/block-alignment-control/ui.js +69 -109
- package/src/components/block-alignment-control/ui.native.js +86 -0
- package/src/components/block-content-overlay/index.js +19 -2
- package/src/components/block-list/block.native.js +2 -0
- package/src/components/block-list/style.scss +7 -18
- package/src/components/block-list/use-block-props/use-block-class-names.js +1 -11
- package/src/components/block-lock/modal.js +42 -3
- package/src/components/block-lock/toolbar.js +2 -2
- package/src/components/block-lock/use-block-lock.js +4 -1
- package/src/components/block-mover/button.js +5 -7
- package/src/components/block-mover/index.js +37 -60
- package/src/components/block-mover/stories/index.js +110 -0
- package/src/components/block-mover/style.scss +48 -138
- package/src/components/block-navigation/dropdown.js +12 -8
- package/src/components/block-popover/README.md +41 -0
- package/src/components/block-popover/inbetween.js +180 -0
- package/src/components/block-popover/index.js +90 -0
- package/src/components/block-popover/style.scss +27 -0
- package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/src/components/block-styles/index.js +1 -12
- package/src/components/block-switcher/style.scss +0 -4
- package/src/components/block-toolbar/style.scss +0 -12
- package/src/components/block-tools/back-compat.js +1 -1
- package/src/components/block-tools/block-selection-button.js +3 -1
- package/src/components/block-tools/index.js +6 -4
- package/src/components/block-tools/insertion-point.js +19 -152
- package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -116
- package/src/components/block-tools/style.scss +11 -123
- package/src/components/border-radius-control/style.scss +5 -2
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/color-style-selector/index.js +18 -9
- package/src/components/default-block-appender/style.scss +1 -2
- package/src/components/duotone-control/index.js +8 -1
- package/src/components/gradients/README.md +29 -0
- package/src/components/image-size-control/README.md +1 -1
- package/src/components/index.js +0 -1
- package/src/components/inserter/index.native.js +60 -25
- package/src/components/inserter/style.native.scss +25 -3
- package/src/components/list-view/block.js +24 -34
- package/src/components/list-view/branch.js +10 -20
- package/src/components/list-view/context.js +1 -4
- package/src/components/list-view/index.js +11 -41
- package/src/components/navigable-toolbar/README.md +16 -0
- package/src/components/rich-text/index.js +0 -2
- package/src/components/rich-text/index.native.js +0 -4
- package/src/components/url-input/index.js +6 -3
- package/src/components/use-block-display-information/index.js +2 -0
- package/src/components/use-setting/index.js +57 -21
- package/src/hooks/border.js +438 -72
- package/src/hooks/border.scss +48 -0
- package/src/hooks/dimensions.js +44 -38
- package/src/hooks/index.js +2 -1
- package/src/hooks/margin.js +64 -15
- package/src/hooks/padding.js +60 -15
- package/src/hooks/padding.scss +12 -0
- package/src/hooks/settings.js +32 -0
- package/src/hooks/test/settings.js +48 -0
- package/src/hooks/use-border-props.js +15 -32
- package/src/store/actions.js +14 -2
- package/src/store/defaults.js +0 -1
- package/src/store/reducer.js +0 -21
- package/src/store/selectors.js +46 -15
- package/src/store/test/actions.js +0 -18
- package/src/store/test/reducer.js +0 -19
- package/src/store/test/selectors.js +17 -19
- package/src/style.scss +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-mobile-toolbar/index.js +0 -42
- package/build/components/block-mobile-toolbar/index.js.map +0 -1
- package/build/components/block-tools/block-popover.js.map +0 -1
- package/build/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build/components/border-style-control/index.js +0 -60
- package/build/components/border-style-control/index.js.map +0 -1
- package/build/components/list-view/appender.js +0 -93
- package/build/components/list-view/appender.js.map +0 -1
- package/build/components/list-view/list-item.js +0 -62
- package/build/components/list-view/list-item.js.map +0 -1
- package/build/components/rich-text/use-caret-in-format.js +0 -43
- package/build/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build/hooks/border-color.js +0 -302
- package/build/hooks/border-color.js.map +0 -1
- package/build/hooks/border-style.js +0 -96
- package/build/hooks/border-style.js.map +0 -1
- package/build/hooks/border-width.js +0 -162
- package/build/hooks/border-width.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/index.js +0 -31
- package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
- package/build-module/components/block-tools/block-popover.js.map +0 -1
- package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build-module/components/border-style-control/index.js +0 -50
- package/build-module/components/border-style-control/index.js.map +0 -1
- package/build-module/components/list-view/appender.js +0 -76
- package/build-module/components/list-view/appender.js.map +0 -1
- package/build-module/components/list-view/list-item.js +0 -47
- package/build-module/components/list-view/list-item.js.map +0 -1
- package/build-module/components/rich-text/use-caret-in-format.js +0 -33
- package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build-module/hooks/border-color.js +0 -276
- package/build-module/hooks/border-color.js.map +0 -1
- package/build-module/hooks/border-style.js +0 -78
- package/build-module/hooks/border-style.js.map +0 -1
- package/build-module/hooks/border-width.js +0 -143
- package/build-module/hooks/border-width.js.map +0 -1
- package/src/components/block-mobile-toolbar/index.js +0 -24
- package/src/components/block-mobile-toolbar/style.scss +0 -29
- package/src/components/border-style-control/index.js +0 -47
- package/src/components/border-style-control/style.scss +0 -18
- package/src/components/list-view/appender.js +0 -82
- package/src/components/list-view/list-item.js +0 -59
- package/src/components/rich-text/use-caret-in-format.js +0 -28
- package/src/hooks/border-color.js +0 -315
- package/src/hooks/border-style.js +0 -64
- package/src/hooks/border-width.js +0 -139
|
@@ -7,7 +7,10 @@ import { get } from 'lodash';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { useSelect } from '@wordpress/data';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
__EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE,
|
|
12
|
+
hasBlockSupport,
|
|
13
|
+
} from '@wordpress/blocks';
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* Internal dependencies
|
|
@@ -91,8 +94,10 @@ const removeCustomPrefixes = ( path ) => {
|
|
|
91
94
|
};
|
|
92
95
|
|
|
93
96
|
/**
|
|
94
|
-
* Hook that retrieves the
|
|
95
|
-
*
|
|
97
|
+
* Hook that retrieves the given setting for the block instance in use.
|
|
98
|
+
*
|
|
99
|
+
* It looks up the settings first in the block instance hierarchy.
|
|
100
|
+
* If none is found, it'll look it up in the block editor store.
|
|
96
101
|
*
|
|
97
102
|
* @param {string} path The path to the setting.
|
|
98
103
|
* @return {any} Returns the value defined for the setting.
|
|
@@ -102,7 +107,7 @@ const removeCustomPrefixes = ( path ) => {
|
|
|
102
107
|
* ```
|
|
103
108
|
*/
|
|
104
109
|
export default function useSetting( path ) {
|
|
105
|
-
const { name: blockName } = useBlockEditContext();
|
|
110
|
+
const { name: blockName, clientId } = useBlockEditContext();
|
|
106
111
|
|
|
107
112
|
const setting = useSelect(
|
|
108
113
|
( select ) => {
|
|
@@ -113,28 +118,59 @@ export default function useSetting( path ) {
|
|
|
113
118
|
);
|
|
114
119
|
return undefined;
|
|
115
120
|
}
|
|
116
|
-
const settings = select( blockEditorStore ).getSettings();
|
|
117
121
|
|
|
118
|
-
|
|
119
|
-
// We cascade to the all value if the block one is not available.
|
|
122
|
+
let result;
|
|
120
123
|
const normalizedPath = removeCustomPrefixes( path );
|
|
121
|
-
const defaultsPath = `__experimentalFeatures.${ normalizedPath }`;
|
|
122
|
-
const blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;
|
|
123
|
-
const experimentalFeaturesResult =
|
|
124
|
-
get( settings, blockPath ) ?? get( settings, defaultsPath );
|
|
125
124
|
|
|
126
|
-
|
|
125
|
+
// 1. Take settings from the block instance or its ancestors.
|
|
126
|
+
const candidates = [
|
|
127
|
+
...select( blockEditorStore ).getBlockParents( clientId ),
|
|
128
|
+
clientId, // The current block is added last, so it overwrites any ancestor.
|
|
129
|
+
];
|
|
130
|
+
candidates.forEach( ( candidateClientId ) => {
|
|
131
|
+
const candidateBlockName = select(
|
|
132
|
+
blockEditorStore
|
|
133
|
+
).getBlockName( candidateClientId );
|
|
134
|
+
if (
|
|
135
|
+
hasBlockSupport(
|
|
136
|
+
candidateBlockName,
|
|
137
|
+
'__experimentalSettings',
|
|
138
|
+
false
|
|
139
|
+
)
|
|
140
|
+
) {
|
|
141
|
+
const candidateAtts = select(
|
|
142
|
+
blockEditorStore
|
|
143
|
+
).getBlockAttributes( candidateClientId );
|
|
144
|
+
const candidateResult =
|
|
145
|
+
get(
|
|
146
|
+
candidateAtts,
|
|
147
|
+
`settings.blocks.${ blockName }.${ normalizedPath }`
|
|
148
|
+
) ??
|
|
149
|
+
get( candidateAtts, `settings.${ normalizedPath }` );
|
|
150
|
+
if ( candidateResult !== undefined ) {
|
|
151
|
+
result = candidateResult;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
} );
|
|
155
|
+
|
|
156
|
+
// 2. Fall back to the settings from the block editor store (__experimentalFeatures).
|
|
157
|
+
const settings = select( blockEditorStore ).getSettings();
|
|
158
|
+
if ( result === undefined ) {
|
|
159
|
+
const defaultsPath = `__experimentalFeatures.${ normalizedPath }`;
|
|
160
|
+
const blockPath = `__experimentalFeatures.blocks.${ blockName }.${ normalizedPath }`;
|
|
161
|
+
result =
|
|
162
|
+
get( settings, blockPath ) ?? get( settings, defaultsPath );
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Return if the setting was found in either the block instance or the store.
|
|
166
|
+
if ( result !== undefined ) {
|
|
127
167
|
if ( PATHS_WITH_MERGE[ normalizedPath ] ) {
|
|
128
|
-
return
|
|
129
|
-
experimentalFeaturesResult.custom ??
|
|
130
|
-
experimentalFeaturesResult.theme ??
|
|
131
|
-
experimentalFeaturesResult.default
|
|
132
|
-
);
|
|
168
|
+
return result.custom ?? result.theme ?? result.default;
|
|
133
169
|
}
|
|
134
|
-
return
|
|
170
|
+
return result;
|
|
135
171
|
}
|
|
136
172
|
|
|
137
|
-
//
|
|
173
|
+
// 3. Otherwise, use deprecated settings.
|
|
138
174
|
const deprecatedSettingsValue = deprecatedFlags[ normalizedPath ]
|
|
139
175
|
? deprecatedFlags[ normalizedPath ]( settings )
|
|
140
176
|
: undefined;
|
|
@@ -142,13 +178,13 @@ export default function useSetting( path ) {
|
|
|
142
178
|
return deprecatedSettingsValue;
|
|
143
179
|
}
|
|
144
180
|
|
|
145
|
-
//
|
|
181
|
+
// 4. Fallback for typography.dropCap:
|
|
146
182
|
// This is only necessary to support typography.dropCap.
|
|
147
183
|
// when __experimentalFeatures are not present (core without plugin).
|
|
148
184
|
// To remove when __experimentalFeatures are ported to core.
|
|
149
185
|
return normalizedPath === 'typography.dropCap' ? true : undefined;
|
|
150
186
|
},
|
|
151
|
-
[ blockName, path ]
|
|
187
|
+
[ blockName, clientId, path ]
|
|
152
188
|
);
|
|
153
189
|
|
|
154
190
|
return setting;
|
package/src/hooks/border.js
CHANGED
|
@@ -1,53 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
4
9
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
5
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
__experimentalBorderBoxControl as BorderBoxControl,
|
|
12
|
+
__experimentalHasSplitBorders as hasSplitBorders,
|
|
13
|
+
__experimentalIsDefinedBorder as isDefinedBorder,
|
|
14
|
+
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
15
|
+
} from '@wordpress/components';
|
|
16
|
+
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
6
17
|
import { Platform } from '@wordpress/element';
|
|
18
|
+
import { addFilter } from '@wordpress/hooks';
|
|
7
19
|
import { __ } from '@wordpress/i18n';
|
|
8
20
|
|
|
9
21
|
/**
|
|
10
22
|
* Internal dependencies
|
|
11
23
|
*/
|
|
12
|
-
import {
|
|
13
|
-
BorderColorEdit,
|
|
14
|
-
hasBorderColorValue,
|
|
15
|
-
resetBorderColor,
|
|
16
|
-
} from './border-color';
|
|
17
24
|
import {
|
|
18
25
|
BorderRadiusEdit,
|
|
19
26
|
hasBorderRadiusValue,
|
|
20
27
|
resetBorderRadius,
|
|
21
28
|
} from './border-radius';
|
|
22
|
-
import {
|
|
23
|
-
BorderStyleEdit,
|
|
24
|
-
hasBorderStyleValue,
|
|
25
|
-
resetBorderStyle,
|
|
26
|
-
} from './border-style';
|
|
27
|
-
import {
|
|
28
|
-
BorderWidthEdit,
|
|
29
|
-
hasBorderWidthValue,
|
|
30
|
-
resetBorderWidth,
|
|
31
|
-
} from './border-width';
|
|
29
|
+
import { getColorClassName } from '../components/colors';
|
|
32
30
|
import InspectorControls from '../components/inspector-controls';
|
|
31
|
+
import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
|
|
33
32
|
import useSetting from '../components/use-setting';
|
|
34
|
-
import { cleanEmptyObject } from './utils';
|
|
33
|
+
import { cleanEmptyObject, shouldSkipSerialization } from './utils';
|
|
35
34
|
|
|
36
35
|
export const BORDER_SUPPORT_KEY = '__experimentalBorder';
|
|
37
36
|
|
|
37
|
+
const borderSides = [ 'top', 'right', 'bottom', 'left' ];
|
|
38
|
+
|
|
39
|
+
const hasBorderValue = ( props ) => {
|
|
40
|
+
const { borderColor, style } = props.attributes;
|
|
41
|
+
return isDefinedBorder( style?.border ) || !! borderColor;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// The border color, style, and width are omitted so they get undefined. The
|
|
45
|
+
// border radius is separate and must retain its selection.
|
|
46
|
+
const resetBorder = ( { attributes = {}, setAttributes } ) => {
|
|
47
|
+
const { style } = attributes;
|
|
48
|
+
setAttributes( {
|
|
49
|
+
borderColor: undefined,
|
|
50
|
+
style: {
|
|
51
|
+
...style,
|
|
52
|
+
border: cleanEmptyObject( {
|
|
53
|
+
radius: style?.border?.radius,
|
|
54
|
+
} ),
|
|
55
|
+
},
|
|
56
|
+
} );
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const resetBorderFilter = ( newAttributes ) => ( {
|
|
60
|
+
...newAttributes,
|
|
61
|
+
borderColor: undefined,
|
|
62
|
+
style: {
|
|
63
|
+
...newAttributes.style,
|
|
64
|
+
border: {
|
|
65
|
+
radius: newAttributes.style?.border?.radius,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
} );
|
|
69
|
+
|
|
70
|
+
const getColorByProperty = ( colors, property, value ) => {
|
|
71
|
+
let matchedColor;
|
|
72
|
+
|
|
73
|
+
colors.some( ( origin ) =>
|
|
74
|
+
origin.colors.some( ( color ) => {
|
|
75
|
+
if ( color[ property ] === value ) {
|
|
76
|
+
matchedColor = color;
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return false;
|
|
81
|
+
} )
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
return matchedColor;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const getMultiOriginColor = ( { colors, namedColor, customColor } ) => {
|
|
88
|
+
// Search each origin (default, theme, or user) for matching color by name.
|
|
89
|
+
if ( namedColor ) {
|
|
90
|
+
const colorObject = getColorByProperty( colors, 'slug', namedColor );
|
|
91
|
+
if ( colorObject ) {
|
|
92
|
+
return colorObject;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Skip if no custom color or matching named color.
|
|
97
|
+
if ( ! customColor ) {
|
|
98
|
+
return { color: undefined };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Attempt to find color via custom color value or build new object.
|
|
102
|
+
const colorObject = getColorByProperty( colors, 'color', customColor );
|
|
103
|
+
return colorObject ? colorObject : { color: customColor };
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const getBorderObject = ( attributes, colors ) => {
|
|
107
|
+
const { borderColor, style } = attributes;
|
|
108
|
+
const { border: borderStyles } = style || {};
|
|
109
|
+
|
|
110
|
+
// If we have a named color for a flat border. Fetch that color object and
|
|
111
|
+
// apply that color's value to the color property within the style object.
|
|
112
|
+
if ( borderColor ) {
|
|
113
|
+
const { color } = getMultiOriginColor( {
|
|
114
|
+
colors,
|
|
115
|
+
namedColor: borderColor,
|
|
116
|
+
} );
|
|
117
|
+
|
|
118
|
+
return color ? { ...borderStyles, color } : borderStyles;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Individual side border color slugs are stored within the border style
|
|
122
|
+
// object. If we don't have a border styles object we have nothing further
|
|
123
|
+
// to hydrate.
|
|
124
|
+
if ( ! borderStyles ) {
|
|
125
|
+
return borderStyles;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// If we have named colors for the individual side borders, retrieve their
|
|
129
|
+
// related color objects and apply the real color values to the split
|
|
130
|
+
// border objects.
|
|
131
|
+
const hydratedBorderStyles = { ...borderStyles };
|
|
132
|
+
borderSides.forEach( ( side ) => {
|
|
133
|
+
const colorSlug = getColorSlugFromVariable(
|
|
134
|
+
hydratedBorderStyles[ side ]?.color
|
|
135
|
+
);
|
|
136
|
+
if ( colorSlug ) {
|
|
137
|
+
const { color } = getMultiOriginColor( {
|
|
138
|
+
colors,
|
|
139
|
+
namedColor: colorSlug,
|
|
140
|
+
} );
|
|
141
|
+
hydratedBorderStyles[ side ] = {
|
|
142
|
+
...hydratedBorderStyles[ side ],
|
|
143
|
+
color,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
} );
|
|
147
|
+
|
|
148
|
+
return hydratedBorderStyles;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
function getColorSlugFromVariable( value ) {
|
|
152
|
+
const namedColor = /var:preset\|color\|(.+)/.exec( value );
|
|
153
|
+
if ( namedColor && namedColor[ 1 ] ) {
|
|
154
|
+
return namedColor[ 1 ];
|
|
155
|
+
}
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
|
|
38
159
|
export function BorderPanel( props ) {
|
|
39
|
-
const { clientId } = props;
|
|
160
|
+
const { attributes, clientId, setAttributes } = props;
|
|
161
|
+
const { style } = attributes;
|
|
162
|
+
const { colors } = useMultipleOriginColorsAndGradients();
|
|
40
163
|
|
|
164
|
+
const isSupported = hasBorderSupport( props.name );
|
|
41
165
|
const isColorSupported =
|
|
42
166
|
useSetting( 'border.color' ) && hasBorderSupport( props.name, 'color' );
|
|
43
|
-
|
|
44
167
|
const isRadiusSupported =
|
|
45
168
|
useSetting( 'border.radius' ) &&
|
|
46
169
|
hasBorderSupport( props.name, 'radius' );
|
|
47
|
-
|
|
48
170
|
const isStyleSupported =
|
|
49
171
|
useSetting( 'border.style' ) && hasBorderSupport( props.name, 'style' );
|
|
50
|
-
|
|
51
172
|
const isWidthSupported =
|
|
52
173
|
useSetting( 'border.width' ) && hasBorderSupport( props.name, 'width' );
|
|
53
174
|
|
|
@@ -58,7 +179,7 @@ export function BorderPanel( props ) {
|
|
|
58
179
|
! isWidthSupported,
|
|
59
180
|
].every( Boolean );
|
|
60
181
|
|
|
61
|
-
if ( isDisabled ) {
|
|
182
|
+
if ( isDisabled || ! isSupported ) {
|
|
62
183
|
return null;
|
|
63
184
|
}
|
|
64
185
|
|
|
@@ -67,61 +188,103 @@ export function BorderPanel( props ) {
|
|
|
67
188
|
'__experimentalDefaultControls',
|
|
68
189
|
] );
|
|
69
190
|
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
191
|
+
const showBorderByDefault =
|
|
192
|
+
defaultBorderControls?.color || defaultBorderControls?.width;
|
|
193
|
+
|
|
194
|
+
const onBorderChange = ( newBorder ) => {
|
|
195
|
+
// Filter out named colors and apply them to appropriate block
|
|
196
|
+
// attributes so that CSS classes can be used to apply those colors.
|
|
197
|
+
// e.g. has-primary-border-top-color.
|
|
198
|
+
|
|
199
|
+
let newBorderStyles = { ...newBorder };
|
|
200
|
+
let newBorderColor;
|
|
201
|
+
|
|
202
|
+
if ( hasSplitBorders( newBorder ) ) {
|
|
203
|
+
// For each side check if the side has a color value set
|
|
204
|
+
// If so, determine if it belongs to a named color, in which case
|
|
205
|
+
// we update the color property.
|
|
206
|
+
//
|
|
207
|
+
// This deliberately overwrites `newBorderStyles` to avoid mutating
|
|
208
|
+
// the passed object which causes problems otherwise.
|
|
209
|
+
newBorderStyles = {
|
|
210
|
+
top: { ...newBorder.top },
|
|
211
|
+
right: { ...newBorder.right },
|
|
212
|
+
bottom: { ...newBorder.bottom },
|
|
213
|
+
left: { ...newBorder.left },
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
borderSides.forEach( ( side ) => {
|
|
217
|
+
if ( newBorder[ side ]?.color ) {
|
|
218
|
+
const colorObject = getMultiOriginColor( {
|
|
219
|
+
colors,
|
|
220
|
+
customColor: newBorder[ side ]?.color,
|
|
221
|
+
} );
|
|
222
|
+
|
|
223
|
+
if ( colorObject.slug ) {
|
|
224
|
+
newBorderStyles[
|
|
225
|
+
side
|
|
226
|
+
].color = `var:preset|color|${ colorObject.slug }`;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
} );
|
|
230
|
+
} else if ( newBorder?.color ) {
|
|
231
|
+
// We have a flat border configuration. Apply named color slug to
|
|
232
|
+
// `borderColor` attribute and clear color style property if found.
|
|
233
|
+
const customColor = newBorder?.color;
|
|
234
|
+
const colorObject = getMultiOriginColor( { colors, customColor } );
|
|
235
|
+
|
|
236
|
+
if ( colorObject.slug ) {
|
|
237
|
+
newBorderColor = colorObject.slug;
|
|
238
|
+
newBorderStyles.color = undefined;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Ensure previous border radius styles are maintained and clean
|
|
243
|
+
// overall result for empty objects or properties.
|
|
244
|
+
const newStyle = cleanEmptyObject( {
|
|
245
|
+
...style,
|
|
246
|
+
border: { radius: style?.border?.radius, ...newBorderStyles },
|
|
247
|
+
} );
|
|
248
|
+
|
|
249
|
+
setAttributes( {
|
|
250
|
+
style: newStyle,
|
|
251
|
+
borderColor: newBorderColor,
|
|
252
|
+
} );
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
const hydratedBorder = getBorderObject( attributes, colors );
|
|
84
256
|
|
|
85
257
|
return (
|
|
86
258
|
<InspectorControls __experimentalGroup="border">
|
|
87
|
-
{ isWidthSupported && (
|
|
259
|
+
{ ( isWidthSupported || isColorSupported ) && (
|
|
88
260
|
<ToolsPanelItem
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
resetAllFilter={ createResetAllFilter( 'width' ) }
|
|
261
|
+
hasValue={ () => hasBorderValue( props ) }
|
|
262
|
+
label={ __( 'Border' ) }
|
|
263
|
+
onDeselect={ () => resetBorder( props ) }
|
|
264
|
+
isShownByDefault={ showBorderByDefault }
|
|
265
|
+
resetAllFilter={ resetBorderFilter }
|
|
95
266
|
panelId={ clientId }
|
|
96
267
|
>
|
|
97
|
-
<
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
onDeselect={ () => resetBorderColor( props ) }
|
|
118
|
-
isShownByDefault={ defaultBorderControls?.color }
|
|
119
|
-
resetAllFilter={ createResetAllFilter( 'color', {
|
|
120
|
-
borderColor: undefined,
|
|
121
|
-
} ) }
|
|
122
|
-
panelId={ clientId }
|
|
123
|
-
>
|
|
124
|
-
<BorderColorEdit { ...props } />
|
|
268
|
+
<BorderBoxControl
|
|
269
|
+
colors={ colors }
|
|
270
|
+
enableAlpha={ true }
|
|
271
|
+
onChange={ onBorderChange }
|
|
272
|
+
popoverClassNames={ {
|
|
273
|
+
linked: 'block-editor__border-box-control__popover',
|
|
274
|
+
top:
|
|
275
|
+
'block-editor__border-box-control__popover-top',
|
|
276
|
+
right:
|
|
277
|
+
'block-editor__border-box-control__popover-right',
|
|
278
|
+
bottom:
|
|
279
|
+
'block-editor__border-box-control__popover-bottom',
|
|
280
|
+
left:
|
|
281
|
+
'block-editor__border-box-control__popover-left',
|
|
282
|
+
} }
|
|
283
|
+
showStyle={ isStyleSupported }
|
|
284
|
+
value={ hydratedBorder }
|
|
285
|
+
__experimentalHasMultipleOrigins={ true }
|
|
286
|
+
__experimentalIsRenderedInSidebar={ true }
|
|
287
|
+
/>
|
|
125
288
|
</ToolsPanelItem>
|
|
126
289
|
) }
|
|
127
290
|
{ isRadiusSupported && (
|
|
@@ -130,7 +293,16 @@ export function BorderPanel( props ) {
|
|
|
130
293
|
label={ __( 'Radius' ) }
|
|
131
294
|
onDeselect={ () => resetBorderRadius( props ) }
|
|
132
295
|
isShownByDefault={ defaultBorderControls?.radius }
|
|
133
|
-
resetAllFilter={
|
|
296
|
+
resetAllFilter={ ( newAttributes ) => ( {
|
|
297
|
+
...newAttributes,
|
|
298
|
+
style: {
|
|
299
|
+
...newAttributes.style,
|
|
300
|
+
border: {
|
|
301
|
+
...newAttributes.style?.border,
|
|
302
|
+
radius: undefined,
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
} ) }
|
|
134
306
|
panelId={ clientId }
|
|
135
307
|
>
|
|
136
308
|
<BorderRadiusEdit { ...props } />
|
|
@@ -189,3 +361,197 @@ export function removeBorderAttribute( style, attribute ) {
|
|
|
189
361
|
},
|
|
190
362
|
} );
|
|
191
363
|
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Filters registered block settings, extending attributes to include
|
|
367
|
+
* `borderColor` if needed.
|
|
368
|
+
*
|
|
369
|
+
* @param {Object} settings Original block settings.
|
|
370
|
+
*
|
|
371
|
+
* @return {Object} Updated block settings.
|
|
372
|
+
*/
|
|
373
|
+
function addAttributes( settings ) {
|
|
374
|
+
if ( ! hasBorderSupport( settings, 'color' ) ) {
|
|
375
|
+
return settings;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// Allow blocks to specify default value if needed.
|
|
379
|
+
if ( settings.attributes.borderColor ) {
|
|
380
|
+
return settings;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// Add new borderColor attribute to block settings.
|
|
384
|
+
return {
|
|
385
|
+
...settings,
|
|
386
|
+
attributes: {
|
|
387
|
+
...settings.attributes,
|
|
388
|
+
borderColor: {
|
|
389
|
+
type: 'string',
|
|
390
|
+
},
|
|
391
|
+
},
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Override props assigned to save component to inject border color.
|
|
397
|
+
*
|
|
398
|
+
* @param {Object} props Additional props applied to save element.
|
|
399
|
+
* @param {Object} blockType Block type definition.
|
|
400
|
+
* @param {Object} attributes Block's attributes.
|
|
401
|
+
*
|
|
402
|
+
* @return {Object} Filtered props to apply to save element.
|
|
403
|
+
*/
|
|
404
|
+
function addSaveProps( props, blockType, attributes ) {
|
|
405
|
+
if (
|
|
406
|
+
! hasBorderSupport( blockType, 'color' ) ||
|
|
407
|
+
shouldSkipSerialization( blockType, BORDER_SUPPORT_KEY, 'color' )
|
|
408
|
+
) {
|
|
409
|
+
return props;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
const borderClasses = getBorderClasses( attributes );
|
|
413
|
+
const newClassName = classnames( props.className, borderClasses );
|
|
414
|
+
|
|
415
|
+
// If we are clearing the last of the previous classes in `className`
|
|
416
|
+
// set it to `undefined` to avoid rendering empty DOM attributes.
|
|
417
|
+
props.className = newClassName ? newClassName : undefined;
|
|
418
|
+
|
|
419
|
+
return props;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Generates a CSS class name consisting of all the applicable border color
|
|
424
|
+
* classes given the current block attributes.
|
|
425
|
+
*
|
|
426
|
+
* @param {Object} attributes Block's attributes.
|
|
427
|
+
*
|
|
428
|
+
* @return {string} CSS class name.
|
|
429
|
+
*/
|
|
430
|
+
export function getBorderClasses( attributes ) {
|
|
431
|
+
const { borderColor, style } = attributes;
|
|
432
|
+
const borderColorClass = getColorClassName( 'border-color', borderColor );
|
|
433
|
+
|
|
434
|
+
return classnames( {
|
|
435
|
+
'has-border-color': borderColor || style?.border?.color,
|
|
436
|
+
[ borderColorClass ]: !! borderColorClass,
|
|
437
|
+
} );
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Filters the registered block settings to apply border color styles and
|
|
442
|
+
* classnames to the block edit wrapper.
|
|
443
|
+
*
|
|
444
|
+
* @param {Object} settings Original block settings.
|
|
445
|
+
*
|
|
446
|
+
* @return {Object} Filtered block settings.
|
|
447
|
+
*/
|
|
448
|
+
function addEditProps( settings ) {
|
|
449
|
+
if (
|
|
450
|
+
! hasBorderSupport( settings, 'color' ) ||
|
|
451
|
+
shouldSkipSerialization( settings, BORDER_SUPPORT_KEY, 'color' )
|
|
452
|
+
) {
|
|
453
|
+
return settings;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
const existingGetEditWrapperProps = settings.getEditWrapperProps;
|
|
457
|
+
settings.getEditWrapperProps = ( attributes ) => {
|
|
458
|
+
let props = {};
|
|
459
|
+
|
|
460
|
+
if ( existingGetEditWrapperProps ) {
|
|
461
|
+
props = existingGetEditWrapperProps( attributes );
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
return addSaveProps( props, settings, attributes );
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
return settings;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* This adds inline styles for color palette colors.
|
|
472
|
+
* Ideally, this is not needed and themes should load their palettes on the editor.
|
|
473
|
+
*
|
|
474
|
+
* @param {Function} BlockListBlock Original component.
|
|
475
|
+
*
|
|
476
|
+
* @return {Function} Wrapped component.
|
|
477
|
+
*/
|
|
478
|
+
export const withBorderColorPaletteStyles = createHigherOrderComponent(
|
|
479
|
+
( BlockListBlock ) => ( props ) => {
|
|
480
|
+
const { name, attributes } = props;
|
|
481
|
+
const { borderColor, style } = attributes;
|
|
482
|
+
const { colors } = useMultipleOriginColorsAndGradients();
|
|
483
|
+
|
|
484
|
+
if (
|
|
485
|
+
! hasBorderSupport( name, 'color' ) ||
|
|
486
|
+
shouldSkipSerialization( name, BORDER_SUPPORT_KEY, 'color' )
|
|
487
|
+
) {
|
|
488
|
+
return <BlockListBlock { ...props } />;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
const { color: borderColorValue } = getMultiOriginColor( {
|
|
492
|
+
colors,
|
|
493
|
+
namedColor: borderColor,
|
|
494
|
+
} );
|
|
495
|
+
const { color: borderTopColor } = getMultiOriginColor( {
|
|
496
|
+
colors,
|
|
497
|
+
namedColor: getColorSlugFromVariable( style?.border?.top?.color ),
|
|
498
|
+
} );
|
|
499
|
+
const { color: borderRightColor } = getMultiOriginColor( {
|
|
500
|
+
colors,
|
|
501
|
+
namedColor: getColorSlugFromVariable( style?.border?.right?.color ),
|
|
502
|
+
} );
|
|
503
|
+
|
|
504
|
+
const { color: borderBottomColor } = getMultiOriginColor( {
|
|
505
|
+
colors,
|
|
506
|
+
namedColor: getColorSlugFromVariable(
|
|
507
|
+
style?.border?.bottom?.color
|
|
508
|
+
),
|
|
509
|
+
} );
|
|
510
|
+
const { color: borderLeftColor } = getMultiOriginColor( {
|
|
511
|
+
colors,
|
|
512
|
+
namedColor: getColorSlugFromVariable( style?.border?.left?.color ),
|
|
513
|
+
} );
|
|
514
|
+
|
|
515
|
+
const extraStyles = {
|
|
516
|
+
borderTopColor: borderTopColor || borderColorValue,
|
|
517
|
+
borderRightColor: borderRightColor || borderColorValue,
|
|
518
|
+
borderBottomColor: borderBottomColor || borderColorValue,
|
|
519
|
+
borderLeftColor: borderLeftColor || borderColorValue,
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
let wrapperProps = props.wrapperProps;
|
|
523
|
+
wrapperProps = {
|
|
524
|
+
...props.wrapperProps,
|
|
525
|
+
style: {
|
|
526
|
+
...props.wrapperProps?.style,
|
|
527
|
+
...extraStyles,
|
|
528
|
+
},
|
|
529
|
+
};
|
|
530
|
+
|
|
531
|
+
return <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;
|
|
532
|
+
}
|
|
533
|
+
);
|
|
534
|
+
|
|
535
|
+
addFilter(
|
|
536
|
+
'blocks.registerBlockType',
|
|
537
|
+
'core/border/addAttributes',
|
|
538
|
+
addAttributes
|
|
539
|
+
);
|
|
540
|
+
|
|
541
|
+
addFilter(
|
|
542
|
+
'blocks.getSaveContent.extraProps',
|
|
543
|
+
'core/border/addSaveProps',
|
|
544
|
+
addSaveProps
|
|
545
|
+
);
|
|
546
|
+
|
|
547
|
+
addFilter(
|
|
548
|
+
'blocks.registerBlockType',
|
|
549
|
+
'core/border/addEditProps',
|
|
550
|
+
addEditProps
|
|
551
|
+
);
|
|
552
|
+
|
|
553
|
+
addFilter(
|
|
554
|
+
'editor.BlockListBlock',
|
|
555
|
+
'core/border/with-border-color-palette-styles',
|
|
556
|
+
withBorderColorPaletteStyles
|
|
557
|
+
);
|