@wordpress/block-editor 8.0.4 → 8.0.8
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/build/components/block-preview/auto.js +1 -0
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +7 -1
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/colors/with-colors.js +9 -4
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/colors-gradients/control.js +6 -2
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +11 -70
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/colors-gradients/use-common-single-multiple-selects.js +21 -0
- package/build/components/colors-gradients/use-common-single-multiple-selects.js.map +1 -0
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +98 -0
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -0
- package/build/components/gradients/use-gradient.js +7 -6
- package/build/components/gradients/use-gradient.js.map +1 -1
- package/build/components/use-setting/index.js +1 -1
- package/build/components/use-setting/index.js.map +1 -1
- package/build/hooks/border-color.js +12 -12
- package/build/hooks/border-color.js.map +1 -1
- package/build/hooks/color-panel.js +2 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +45 -23
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/typography.js +3 -0
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/use-color-props.js +19 -6
- package/build/hooks/use-color-props.js.map +1 -1
- package/build/store/selectors.js +37 -43
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-preview/auto.js +1 -0
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +7 -1
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/colors/with-colors.js +9 -4
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +6 -2
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +10 -72
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/colors-gradients/use-common-single-multiple-selects.js +11 -0
- package/build-module/components/colors-gradients/use-common-single-multiple-selects.js.map +1 -0
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +85 -0
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -0
- package/build-module/components/gradients/use-gradient.js +7 -6
- package/build-module/components/gradients/use-gradient.js.map +1 -1
- package/build-module/components/use-setting/index.js +1 -1
- package/build-module/components/use-setting/index.js.map +1 -1
- package/build-module/hooks/border-color.js +11 -12
- package/build-module/hooks/border-color.js.map +1 -1
- package/build-module/hooks/color-panel.js +2 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +46 -24
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/typography.js +1 -2
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/use-color-props.js +16 -4
- package/build-module/hooks/use-color-props.js.map +1 -1
- package/build-module/store/selectors.js +37 -43
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +8 -1
- package/build-style/style.css +8 -1
- package/package.json +3 -3
- package/src/components/block-preview/auto.js +3 -0
- package/src/components/block-preview/style.scss +5 -0
- package/src/components/block-tools/block-selection-button.js +5 -1
- package/src/components/colors/with-colors.js +16 -5
- package/src/components/colors-gradients/control.js +6 -0
- package/src/components/colors-gradients/panel-color-gradient-settings.js +8 -92
- package/src/components/colors-gradients/use-common-single-multiple-selects.js +11 -0
- package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +107 -0
- package/src/components/gradients/use-gradient.js +18 -7
- package/src/components/link-control/style.scss +6 -2
- package/src/components/use-setting/index.js +1 -1
- package/src/hooks/border-color.js +15 -9
- package/src/hooks/color-panel.js +1 -0
- package/src/hooks/color.js +71 -31
- package/src/hooks/test/color.js +109 -0
- package/src/hooks/typography.js +1 -1
- package/src/hooks/use-color-props.js +30 -4
- package/src/store/selectors.js +14 -26
|
@@ -1184,6 +1184,10 @@
|
|
|
1184
1184
|
display: none;
|
|
1185
1185
|
}
|
|
1186
1186
|
|
|
1187
|
+
.block-editor-block-preview__content-iframe .block-list-appender {
|
|
1188
|
+
display: none;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1187
1191
|
.block-editor-block-settings-menu__popover .components-dropdown-menu__menu {
|
|
1188
1192
|
padding: 0;
|
|
1189
1193
|
}
|
|
@@ -2106,7 +2110,10 @@
|
|
|
2106
2110
|
align-items: flex-start;
|
|
2107
2111
|
margin-left: 8px;
|
|
2108
2112
|
white-space: pre-wrap;
|
|
2109
|
-
|
|
2113
|
+
overflow-wrap: break-word;
|
|
2114
|
+
}
|
|
2115
|
+
.block-editor-link-control__search-item .block-editor-link-control__search-item-header .block-editor-link-control__search-item-info {
|
|
2116
|
+
word-break: break-all;
|
|
2110
2117
|
}
|
|
2111
2118
|
.block-editor-link-control__search-item.is-preview .block-editor-link-control__search-item-header {
|
|
2112
2119
|
display: flex;
|
package/build-style/style.css
CHANGED
|
@@ -1184,6 +1184,10 @@
|
|
|
1184
1184
|
display: none;
|
|
1185
1185
|
}
|
|
1186
1186
|
|
|
1187
|
+
.block-editor-block-preview__content-iframe .block-list-appender {
|
|
1188
|
+
display: none;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1187
1191
|
.block-editor-block-settings-menu__popover .components-dropdown-menu__menu {
|
|
1188
1192
|
padding: 0;
|
|
1189
1193
|
}
|
|
@@ -2106,7 +2110,10 @@
|
|
|
2106
2110
|
align-items: flex-start;
|
|
2107
2111
|
margin-right: 8px;
|
|
2108
2112
|
white-space: pre-wrap;
|
|
2109
|
-
|
|
2113
|
+
overflow-wrap: break-word;
|
|
2114
|
+
}
|
|
2115
|
+
.block-editor-link-control__search-item .block-editor-link-control__search-item-header .block-editor-link-control__search-item-info {
|
|
2116
|
+
word-break: break-all;
|
|
2110
2117
|
}
|
|
2111
2118
|
.block-editor-link-control__search-item.is-preview .block-editor-link-control__search-item-header {
|
|
2112
2119
|
display: flex;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.8",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@wordpress/blob": "^3.2.2",
|
|
39
39
|
"@wordpress/block-serialization-default-parser": "^4.2.3",
|
|
40
40
|
"@wordpress/blocks": "^11.1.4",
|
|
41
|
-
"@wordpress/components": "^19.
|
|
41
|
+
"@wordpress/components": "^19.1.2",
|
|
42
42
|
"@wordpress/compose": "^5.0.6",
|
|
43
43
|
"@wordpress/data": "^6.1.4",
|
|
44
44
|
"@wordpress/deprecated": "^3.2.3",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"publishConfig": {
|
|
76
76
|
"access": "public"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "34b76b2f9397215e5afb8443f5b3073c83913102"
|
|
79
79
|
}
|
|
@@ -50,6 +50,9 @@ function AutoBlockPreview( { viewportWidth, __experimentalPadding } ) {
|
|
|
50
50
|
const {
|
|
51
51
|
ownerDocument: { documentElement },
|
|
52
52
|
} = bodyElement;
|
|
53
|
+
documentElement.classList.add(
|
|
54
|
+
'block-editor-block-preview__content-iframe'
|
|
55
|
+
);
|
|
53
56
|
documentElement.style.position = 'absolute';
|
|
54
57
|
documentElement.style.width = '100%';
|
|
55
58
|
bodyElement.style.padding =
|
|
@@ -100,6 +100,7 @@ function BlockSelectionButton( { clientId, rootClientId, blockElement } ) {
|
|
|
100
100
|
getMultiSelectedBlocksEndClientId,
|
|
101
101
|
getPreviousBlockClientId,
|
|
102
102
|
getNextBlockClientId,
|
|
103
|
+
isNavigationMode,
|
|
103
104
|
} = useSelect( blockEditorStore );
|
|
104
105
|
const {
|
|
105
106
|
selectBlock,
|
|
@@ -157,7 +158,10 @@ function BlockSelectionButton( { clientId, rootClientId, blockElement } ) {
|
|
|
157
158
|
selectedBlockClientId;
|
|
158
159
|
}
|
|
159
160
|
const startingBlockClientId = hasBlockMovingClientId();
|
|
160
|
-
|
|
161
|
+
if ( isEscape && isNavigationMode() ) {
|
|
162
|
+
clearSelectedBlock();
|
|
163
|
+
event.preventDefault();
|
|
164
|
+
}
|
|
161
165
|
if ( isEscape && startingBlockClientId && ! event.defaultPrevented ) {
|
|
162
166
|
setBlockMovingClientId( null );
|
|
163
167
|
event.preventDefault();
|
|
@@ -6,7 +6,7 @@ import { isString, kebabCase, reduce, upperFirst } from 'lodash';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { Component } from '@wordpress/element';
|
|
9
|
+
import { useMemo, Component } from '@wordpress/element';
|
|
10
10
|
import { compose, createHigherOrderComponent } from '@wordpress/compose';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -20,8 +20,6 @@ import {
|
|
|
20
20
|
} from './utils';
|
|
21
21
|
import useSetting from '../use-setting';
|
|
22
22
|
|
|
23
|
-
const DEFAULT_COLORS = [];
|
|
24
|
-
|
|
25
23
|
/**
|
|
26
24
|
* Higher order component factory for injecting the `colorsArray` argument as
|
|
27
25
|
* the colors prop in the `withCustomColors` HOC.
|
|
@@ -47,8 +45,21 @@ const withCustomColorPalette = ( colorsArray ) =>
|
|
|
47
45
|
const withEditorColorPalette = () =>
|
|
48
46
|
createHigherOrderComponent(
|
|
49
47
|
( WrappedComponent ) => ( props ) => {
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
// Some color settings have a special handling for deprecated flags in `useSetting`,
|
|
49
|
+
// so we can't unwrap them by doing const { ... } = useSetting('color')
|
|
50
|
+
// until https://github.com/WordPress/gutenberg/issues/37094 is fixed.
|
|
51
|
+
const userPalette = useSetting( 'color.palette.custom' );
|
|
52
|
+
const themePalette = useSetting( 'color.palette.theme' );
|
|
53
|
+
const defaultPalette = useSetting( 'color.palette.default' );
|
|
54
|
+
const allColors = useMemo(
|
|
55
|
+
() => [
|
|
56
|
+
...( userPalette || [] ),
|
|
57
|
+
...( themePalette || [] ),
|
|
58
|
+
...( defaultPalette || [] ),
|
|
59
|
+
],
|
|
60
|
+
[ userPalette, themePalette, defaultPalette ]
|
|
61
|
+
);
|
|
62
|
+
return <WrappedComponent { ...props } colors={ allColors } />;
|
|
52
63
|
},
|
|
53
64
|
'withEditorColorPalette'
|
|
54
65
|
);
|
|
@@ -36,6 +36,7 @@ function ColorGradientControlInner( {
|
|
|
36
36
|
disableCustomColors,
|
|
37
37
|
disableCustomGradients,
|
|
38
38
|
__experimentalHasMultipleOrigins,
|
|
39
|
+
__experimentalIsRenderedInSidebar,
|
|
39
40
|
className,
|
|
40
41
|
label,
|
|
41
42
|
onColorChange,
|
|
@@ -44,6 +45,7 @@ function ColorGradientControlInner( {
|
|
|
44
45
|
gradientValue,
|
|
45
46
|
clearable,
|
|
46
47
|
showTitle = true,
|
|
48
|
+
enableAlpha,
|
|
47
49
|
} ) {
|
|
48
50
|
const canChooseAColor =
|
|
49
51
|
onColorChange && ( ! isEmpty( colors ) || ! disableCustomColors );
|
|
@@ -108,7 +110,11 @@ function ColorGradientControlInner( {
|
|
|
108
110
|
__experimentalHasMultipleOrigins={
|
|
109
111
|
__experimentalHasMultipleOrigins
|
|
110
112
|
}
|
|
113
|
+
__experimentalIsRenderedInSidebar={
|
|
114
|
+
__experimentalIsRenderedInSidebar
|
|
115
|
+
}
|
|
111
116
|
clearable={ clearable }
|
|
117
|
+
enableAlpha={ enableAlpha }
|
|
112
118
|
/>
|
|
113
119
|
) }
|
|
114
120
|
{ ( currentTab === 'gradient' || ! canChooseAColor ) && (
|
|
@@ -8,8 +8,7 @@ import { every, isEmpty } from 'lodash';
|
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
10
|
import { PanelBody, ColorIndicator } from '@wordpress/components';
|
|
11
|
-
import { sprintf, __
|
|
12
|
-
import { useMemo } from '@wordpress/element';
|
|
11
|
+
import { sprintf, __ } from '@wordpress/i18n';
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* Internal dependencies
|
|
@@ -18,6 +17,8 @@ import ColorGradientControl from './control';
|
|
|
18
17
|
import { getColorObjectByColorValue } from '../colors';
|
|
19
18
|
import { __experimentalGetGradientObjectByGradientValue } from '../gradients';
|
|
20
19
|
import useSetting from '../use-setting';
|
|
20
|
+
import useCommonSingleMultipleSelects from './use-common-single-multiple-selects';
|
|
21
|
+
import useMultipleOriginColorsAndGradients from './use-multiple-origin-colors-and-gradients';
|
|
21
22
|
|
|
22
23
|
// translators: first %s: The type of color or gradient (e.g. background, overlay...), second %s: the color name or value (e.g. red or #ff0000)
|
|
23
24
|
const colorIndicatorAriaLabel = __( '(%s: color %s)' );
|
|
@@ -92,6 +93,8 @@ export const PanelColorGradientSettingsInner = ( {
|
|
|
92
93
|
title,
|
|
93
94
|
showTitle = true,
|
|
94
95
|
__experimentalHasMultipleOrigins,
|
|
96
|
+
__experimentalIsRenderedInSidebar,
|
|
97
|
+
enableAlpha,
|
|
95
98
|
...props
|
|
96
99
|
} ) => {
|
|
97
100
|
if (
|
|
@@ -143,6 +146,8 @@ export const PanelColorGradientSettingsInner = ( {
|
|
|
143
146
|
disableCustomColors,
|
|
144
147
|
disableCustomGradients,
|
|
145
148
|
__experimentalHasMultipleOrigins,
|
|
149
|
+
__experimentalIsRenderedInSidebar,
|
|
150
|
+
enableAlpha,
|
|
146
151
|
...setting,
|
|
147
152
|
} }
|
|
148
153
|
/>
|
|
@@ -152,13 +157,6 @@ export const PanelColorGradientSettingsInner = ( {
|
|
|
152
157
|
);
|
|
153
158
|
};
|
|
154
159
|
|
|
155
|
-
function useCommonSingleMultipleSelects() {
|
|
156
|
-
return {
|
|
157
|
-
disableCustomColors: ! useSetting( 'color.custom' ),
|
|
158
|
-
disableCustomGradients: ! useSetting( 'color.customGradient' ),
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
|
|
162
160
|
const PanelColorGradientSettingsSingleSelect = ( props ) => {
|
|
163
161
|
const colorGradientSettings = useCommonSingleMultipleSelects();
|
|
164
162
|
colorGradientSettings.colors = useSetting( 'color.palette' );
|
|
@@ -171,89 +169,7 @@ const PanelColorGradientSettingsSingleSelect = ( props ) => {
|
|
|
171
169
|
};
|
|
172
170
|
|
|
173
171
|
const PanelColorGradientSettingsMultipleSelect = ( props ) => {
|
|
174
|
-
const colorGradientSettings =
|
|
175
|
-
const customColors = useSetting( 'color.palette.user' );
|
|
176
|
-
const themeColors = useSetting( 'color.palette.theme' );
|
|
177
|
-
const defaultColors = useSetting( 'color.palette.default' );
|
|
178
|
-
const shouldDisplayDefaultColors = useSetting( 'color.defaultPalette' );
|
|
179
|
-
|
|
180
|
-
colorGradientSettings.colors = useMemo( () => {
|
|
181
|
-
const result = [];
|
|
182
|
-
if ( themeColors && themeColors.length ) {
|
|
183
|
-
result.push( {
|
|
184
|
-
name: _x(
|
|
185
|
-
'Theme',
|
|
186
|
-
'Indicates this palette comes from the theme.'
|
|
187
|
-
),
|
|
188
|
-
colors: themeColors,
|
|
189
|
-
} );
|
|
190
|
-
}
|
|
191
|
-
if (
|
|
192
|
-
shouldDisplayDefaultColors &&
|
|
193
|
-
defaultColors &&
|
|
194
|
-
defaultColors.length
|
|
195
|
-
) {
|
|
196
|
-
result.push( {
|
|
197
|
-
name: _x(
|
|
198
|
-
'Default',
|
|
199
|
-
'Indicates this palette comes from WordPress.'
|
|
200
|
-
),
|
|
201
|
-
colors: defaultColors,
|
|
202
|
-
} );
|
|
203
|
-
}
|
|
204
|
-
if ( customColors && customColors.length ) {
|
|
205
|
-
result.push( {
|
|
206
|
-
name: _x(
|
|
207
|
-
'Custom',
|
|
208
|
-
'Indicates this palette comes from the theme.'
|
|
209
|
-
),
|
|
210
|
-
colors: customColors,
|
|
211
|
-
} );
|
|
212
|
-
}
|
|
213
|
-
return result;
|
|
214
|
-
}, [ defaultColors, themeColors, customColors ] );
|
|
215
|
-
|
|
216
|
-
const customGradients = useSetting( 'color.gradients.user' );
|
|
217
|
-
const themeGradients = useSetting( 'color.gradients.theme' );
|
|
218
|
-
const defaultGradients = useSetting( 'color.gradients.default' );
|
|
219
|
-
const shouldDisplayDefaultGradients = useSetting(
|
|
220
|
-
'color.defaultGradients'
|
|
221
|
-
);
|
|
222
|
-
colorGradientSettings.gradients = useMemo( () => {
|
|
223
|
-
const result = [];
|
|
224
|
-
if ( themeGradients && themeGradients.length ) {
|
|
225
|
-
result.push( {
|
|
226
|
-
name: _x(
|
|
227
|
-
'Theme',
|
|
228
|
-
'Indicates this palette comes from the theme.'
|
|
229
|
-
),
|
|
230
|
-
gradients: themeGradients,
|
|
231
|
-
} );
|
|
232
|
-
}
|
|
233
|
-
if (
|
|
234
|
-
shouldDisplayDefaultGradients &&
|
|
235
|
-
defaultGradients &&
|
|
236
|
-
defaultGradients.length
|
|
237
|
-
) {
|
|
238
|
-
result.push( {
|
|
239
|
-
name: _x(
|
|
240
|
-
'Default',
|
|
241
|
-
'Indicates this palette comes from WordPress.'
|
|
242
|
-
),
|
|
243
|
-
gradients: defaultGradients,
|
|
244
|
-
} );
|
|
245
|
-
}
|
|
246
|
-
if ( customGradients && customGradients.length ) {
|
|
247
|
-
result.push( {
|
|
248
|
-
name: _x(
|
|
249
|
-
'Custom',
|
|
250
|
-
'Indicates this palette is created by the user.'
|
|
251
|
-
),
|
|
252
|
-
gradients: customGradients,
|
|
253
|
-
} );
|
|
254
|
-
}
|
|
255
|
-
return result;
|
|
256
|
-
}, [ customGradients, themeGradients, defaultGradients ] );
|
|
172
|
+
const colorGradientSettings = useMultipleOriginColorsAndGradients();
|
|
257
173
|
return (
|
|
258
174
|
<PanelColorGradientSettingsInner
|
|
259
175
|
{ ...{ ...colorGradientSettings, ...props } }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import useSetting from '../use-setting';
|
|
5
|
+
|
|
6
|
+
export default function useCommonSingleMultipleSelects() {
|
|
7
|
+
return {
|
|
8
|
+
disableCustomColors: ! useSetting( 'color.custom' ),
|
|
9
|
+
disableCustomGradients: ! useSetting( 'color.customGradient' ),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useMemo } from '@wordpress/element';
|
|
5
|
+
import { _x } from '@wordpress/i18n';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import useSetting from '../use-setting';
|
|
11
|
+
import useCommonSingleMultipleSelects from './use-common-single-multiple-selects';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves color and gradient related settings.
|
|
15
|
+
*
|
|
16
|
+
* The arrays for colors and gradients are made up of color palettes from each
|
|
17
|
+
* origin i.e. "Core", "Theme", and "User".
|
|
18
|
+
*
|
|
19
|
+
* @return {Object} Color and gradient related settings.
|
|
20
|
+
*/
|
|
21
|
+
export default function useMultipleOriginColorsAndGradients() {
|
|
22
|
+
const colorGradientSettings = useCommonSingleMultipleSelects();
|
|
23
|
+
const customColors = useSetting( 'color.palette.custom' );
|
|
24
|
+
const themeColors = useSetting( 'color.palette.theme' );
|
|
25
|
+
const defaultColors = useSetting( 'color.palette.default' );
|
|
26
|
+
const shouldDisplayDefaultColors = useSetting( 'color.defaultPalette' );
|
|
27
|
+
|
|
28
|
+
colorGradientSettings.colors = useMemo( () => {
|
|
29
|
+
const result = [];
|
|
30
|
+
if ( themeColors && themeColors.length ) {
|
|
31
|
+
result.push( {
|
|
32
|
+
name: _x(
|
|
33
|
+
'Theme',
|
|
34
|
+
'Indicates this palette comes from the theme.'
|
|
35
|
+
),
|
|
36
|
+
colors: themeColors,
|
|
37
|
+
} );
|
|
38
|
+
}
|
|
39
|
+
if (
|
|
40
|
+
shouldDisplayDefaultColors &&
|
|
41
|
+
defaultColors &&
|
|
42
|
+
defaultColors.length
|
|
43
|
+
) {
|
|
44
|
+
result.push( {
|
|
45
|
+
name: _x(
|
|
46
|
+
'Default',
|
|
47
|
+
'Indicates this palette comes from WordPress.'
|
|
48
|
+
),
|
|
49
|
+
colors: defaultColors,
|
|
50
|
+
} );
|
|
51
|
+
}
|
|
52
|
+
if ( customColors && customColors.length ) {
|
|
53
|
+
result.push( {
|
|
54
|
+
name: _x(
|
|
55
|
+
'Custom',
|
|
56
|
+
'Indicates this palette comes from the theme.'
|
|
57
|
+
),
|
|
58
|
+
colors: customColors,
|
|
59
|
+
} );
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}, [ defaultColors, themeColors, customColors ] );
|
|
63
|
+
|
|
64
|
+
const customGradients = useSetting( 'color.gradients.custom' );
|
|
65
|
+
const themeGradients = useSetting( 'color.gradients.theme' );
|
|
66
|
+
const defaultGradients = useSetting( 'color.gradients.default' );
|
|
67
|
+
const shouldDisplayDefaultGradients = useSetting(
|
|
68
|
+
'color.defaultGradients'
|
|
69
|
+
);
|
|
70
|
+
colorGradientSettings.gradients = useMemo( () => {
|
|
71
|
+
const result = [];
|
|
72
|
+
if ( themeGradients && themeGradients.length ) {
|
|
73
|
+
result.push( {
|
|
74
|
+
name: _x(
|
|
75
|
+
'Theme',
|
|
76
|
+
'Indicates this palette comes from the theme.'
|
|
77
|
+
),
|
|
78
|
+
gradients: themeGradients,
|
|
79
|
+
} );
|
|
80
|
+
}
|
|
81
|
+
if (
|
|
82
|
+
shouldDisplayDefaultGradients &&
|
|
83
|
+
defaultGradients &&
|
|
84
|
+
defaultGradients.length
|
|
85
|
+
) {
|
|
86
|
+
result.push( {
|
|
87
|
+
name: _x(
|
|
88
|
+
'Default',
|
|
89
|
+
'Indicates this palette comes from WordPress.'
|
|
90
|
+
),
|
|
91
|
+
gradients: defaultGradients,
|
|
92
|
+
} );
|
|
93
|
+
}
|
|
94
|
+
if ( customGradients && customGradients.length ) {
|
|
95
|
+
result.push( {
|
|
96
|
+
name: _x(
|
|
97
|
+
'Custom',
|
|
98
|
+
'Indicates this palette is created by the user.'
|
|
99
|
+
),
|
|
100
|
+
gradients: customGradients,
|
|
101
|
+
} );
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
}, [ customGradients, themeGradients, defaultGradients ] );
|
|
105
|
+
|
|
106
|
+
return colorGradientSettings;
|
|
107
|
+
}
|
|
@@ -6,7 +6,7 @@ import { find } from 'lodash';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { useCallback } from '@wordpress/element';
|
|
9
|
+
import { useCallback, useMemo } from '@wordpress/element';
|
|
10
10
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -16,8 +16,6 @@ import { useBlockEditContext } from '../block-edit';
|
|
|
16
16
|
import useSetting from '../use-setting';
|
|
17
17
|
import { store as blockEditorStore } from '../../store';
|
|
18
18
|
|
|
19
|
-
const EMPTY_ARRAY = [];
|
|
20
|
-
|
|
21
19
|
export function __experimentalGetGradientClass( gradientSlug ) {
|
|
22
20
|
if ( ! gradientSlug ) {
|
|
23
21
|
return undefined;
|
|
@@ -61,13 +59,23 @@ export function getGradientSlugByValue( gradients, value ) {
|
|
|
61
59
|
return gradient && gradient.slug;
|
|
62
60
|
}
|
|
63
61
|
|
|
62
|
+
const EMPTY_OBJECT = {};
|
|
63
|
+
|
|
64
64
|
export function __experimentalUseGradient( {
|
|
65
65
|
gradientAttribute = 'gradient',
|
|
66
66
|
customGradientAttribute = 'customGradient',
|
|
67
67
|
} = {} ) {
|
|
68
68
|
const { clientId } = useBlockEditContext();
|
|
69
69
|
|
|
70
|
-
const
|
|
70
|
+
const gradientsPerOrigin = useSetting( 'color.gradients' ) || EMPTY_OBJECT;
|
|
71
|
+
const allGradients = useMemo(
|
|
72
|
+
() => [
|
|
73
|
+
...( gradientsPerOrigin?.custom || [] ),
|
|
74
|
+
...( gradientsPerOrigin?.theme || [] ),
|
|
75
|
+
...( gradientsPerOrigin?.default || [] ),
|
|
76
|
+
],
|
|
77
|
+
[ gradientsPerOrigin ]
|
|
78
|
+
);
|
|
71
79
|
const { gradient, customGradient } = useSelect(
|
|
72
80
|
( select ) => {
|
|
73
81
|
const { getBlockAttributes } = select( blockEditorStore );
|
|
@@ -83,7 +91,10 @@ export function __experimentalUseGradient( {
|
|
|
83
91
|
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
84
92
|
const setGradient = useCallback(
|
|
85
93
|
( newGradientValue ) => {
|
|
86
|
-
const slug = getGradientSlugByValue(
|
|
94
|
+
const slug = getGradientSlugByValue(
|
|
95
|
+
allGradients,
|
|
96
|
+
newGradientValue
|
|
97
|
+
);
|
|
87
98
|
if ( slug ) {
|
|
88
99
|
updateBlockAttributes( clientId, {
|
|
89
100
|
[ gradientAttribute ]: slug,
|
|
@@ -96,13 +107,13 @@ export function __experimentalUseGradient( {
|
|
|
96
107
|
[ customGradientAttribute ]: newGradientValue,
|
|
97
108
|
} );
|
|
98
109
|
},
|
|
99
|
-
[
|
|
110
|
+
[ allGradients, clientId, updateBlockAttributes ]
|
|
100
111
|
);
|
|
101
112
|
|
|
102
113
|
const gradientClass = __experimentalGetGradientClass( gradient );
|
|
103
114
|
let gradientValue;
|
|
104
115
|
if ( gradient ) {
|
|
105
|
-
gradientValue = getGradientValueBySlug(
|
|
116
|
+
gradientValue = getGradientValueBySlug( allGradients, gradient );
|
|
106
117
|
} else {
|
|
107
118
|
gradientValue = customGradient;
|
|
108
119
|
}
|
|
@@ -197,12 +197,16 @@ $preview-image-height: 140px;
|
|
|
197
197
|
// of text, particular those with no spaces.
|
|
198
198
|
// See: https://github.com/WordPress/gutenberg/issues/33586#issuecomment-888921188
|
|
199
199
|
white-space: pre-wrap;
|
|
200
|
-
|
|
200
|
+
overflow-wrap: break-word;
|
|
201
|
+
|
|
202
|
+
.block-editor-link-control__search-item-info {
|
|
203
|
+
word-break: break-all;
|
|
204
|
+
}
|
|
201
205
|
}
|
|
202
206
|
|
|
203
207
|
&.is-preview .block-editor-link-control__search-item-header {
|
|
204
208
|
display: flex;
|
|
205
|
-
flex: 1; //
|
|
209
|
+
flex: 1; // Fill available space.
|
|
206
210
|
}
|
|
207
211
|
|
|
208
212
|
&.is-error .block-editor-link-control__search-item-header {
|
|
@@ -117,7 +117,7 @@ export default function useSetting( path ) {
|
|
|
117
117
|
if ( experimentalFeaturesResult !== undefined ) {
|
|
118
118
|
if ( PATHS_WITH_MERGE[ normalizedPath ] ) {
|
|
119
119
|
return (
|
|
120
|
-
experimentalFeaturesResult.
|
|
120
|
+
experimentalFeaturesResult.custom ??
|
|
121
121
|
experimentalFeaturesResult.theme ??
|
|
122
122
|
experimentalFeaturesResult.default
|
|
123
123
|
);
|
|
@@ -15,6 +15,7 @@ import { useState } from '@wordpress/element';
|
|
|
15
15
|
* Internal dependencies
|
|
16
16
|
*/
|
|
17
17
|
import ColorGradientControl from '../components/colors-gradients/control';
|
|
18
|
+
import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';
|
|
18
19
|
import {
|
|
19
20
|
getColorClassName,
|
|
20
21
|
getColorObjectByColorValue,
|
|
@@ -46,13 +47,15 @@ export function BorderColorEdit( props ) {
|
|
|
46
47
|
attributes: { borderColor, style },
|
|
47
48
|
setAttributes,
|
|
48
49
|
} = props;
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
50
|
+
const colorGradientSettings = useMultipleOriginColorsAndGradients();
|
|
51
|
+
const availableColors = colorGradientSettings.colors.reduce(
|
|
52
|
+
( colors, origin ) => colors.concat( origin.colors ),
|
|
53
|
+
[]
|
|
54
|
+
);
|
|
52
55
|
const [ colorValue, setColorValue ] = useState(
|
|
53
56
|
() =>
|
|
54
57
|
getColorObjectByAttributeValues(
|
|
55
|
-
|
|
58
|
+
availableColors,
|
|
56
59
|
borderColor,
|
|
57
60
|
style?.border?.color
|
|
58
61
|
)?.color
|
|
@@ -61,7 +64,10 @@ export function BorderColorEdit( props ) {
|
|
|
61
64
|
const onChangeColor = ( value ) => {
|
|
62
65
|
setColorValue( value );
|
|
63
66
|
|
|
64
|
-
const colorObject = getColorObjectByColorValue(
|
|
67
|
+
const colorObject = getColorObjectByColorValue(
|
|
68
|
+
availableColors,
|
|
69
|
+
value
|
|
70
|
+
);
|
|
65
71
|
const newStyle = {
|
|
66
72
|
...style,
|
|
67
73
|
border: {
|
|
@@ -83,11 +89,11 @@ export function BorderColorEdit( props ) {
|
|
|
83
89
|
<ColorGradientControl
|
|
84
90
|
label={ __( 'Color' ) }
|
|
85
91
|
colorValue={ colorValue }
|
|
86
|
-
colors={ colors }
|
|
87
|
-
gradients={ undefined }
|
|
88
|
-
disableCustomColors={ disableCustomColors }
|
|
89
|
-
disableCustomGradients={ disableCustomGradients }
|
|
90
92
|
onColorChange={ onChangeColor }
|
|
93
|
+
clearable={ false }
|
|
94
|
+
__experimentalHasMultipleOrigins
|
|
95
|
+
__experimentalIsRenderedInSidebar
|
|
96
|
+
{ ...colorGradientSettings }
|
|
91
97
|
/>
|
|
92
98
|
);
|
|
93
99
|
}
|