@wordpress/block-editor 11.6.0 → 11.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +4 -0
- package/build/components/block-list/block-html.js +1 -3
- package/build/components/block-list/block-html.js.map +1 -1
- package/build/components/block-preview/auto.js +6 -23
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/editor-styles/index.js +20 -2
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/global-styles/color-panel.js +583 -0
- package/build/components/global-styles/color-panel.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +8 -30
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/get-block-css-selector.js +129 -0
- package/build/components/global-styles/get-block-css-selector.js.map +1 -0
- package/build/components/global-styles/hooks.js +53 -1
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +18 -2
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +9 -35
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +160 -86
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/image-size-control/index.js +8 -5
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js +43 -7
- package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build/components/line-height-control/index.js +15 -1
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/list-view/appender.js +105 -0
- package/build/components/list-view/appender.js.map +1 -0
- package/build/components/list-view/block.js +5 -5
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +25 -5
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +37 -13
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +13 -4
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/rich-text/format-edit.js +2 -30
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/writing-flow/use-input.js +4 -8
- package/build/components/writing-flow/use-input.js.map +1 -1
- package/build/hooks/border.js +0 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +92 -229
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +4 -2
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/{color-panel.js → contrast-checker.js} +11 -49
- package/build/hooks/contrast-checker.js.map +1 -0
- package/build/hooks/dimensions.js +0 -1
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +3 -1
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/position.js +2 -2
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +23 -26
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/typography.js +0 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +25 -76
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/grid.js +165 -0
- package/build/layouts/grid.js.map +1 -0
- package/build/layouts/index.js +3 -1
- package/build/layouts/index.js.map +1 -1
- package/build/private-apis.js +4 -1
- package/build/private-apis.js.map +1 -1
- package/build/utils/object.js +76 -0
- package/build/utils/object.js.map +1 -0
- package/build-module/components/block-list/block-html.js +1 -3
- package/build-module/components/block-list/block-html.js.map +1 -1
- package/build-module/components/block-preview/auto.js +6 -22
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/editor-styles/index.js +19 -2
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +554 -0
- package/build-module/components/global-styles/color-panel.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +7 -30
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/get-block-css-selector.js +120 -0
- package/build-module/components/global-styles/get-block-css-selector.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +51 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +3 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +8 -35
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +161 -87
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/image-size-control/index.js +8 -5
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js +42 -7
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build-module/components/line-height-control/index.js +15 -1
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/list-view/appender.js +88 -0
- package/build-module/components/list-view/appender.js.map +1 -0
- package/build-module/components/list-view/block.js +5 -4
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +22 -5
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +32 -12
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +12 -4
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +3 -31
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/writing-flow/use-input.js +4 -8
- package/build-module/components/writing-flow/use-input.js.map +1 -1
- package/build-module/hooks/border.js +0 -1
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +90 -232
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +4 -2
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/{color-panel.js → contrast-checker.js} +10 -44
- package/build-module/hooks/contrast-checker.js.map +1 -0
- package/build-module/hooks/dimensions.js +0 -1
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +4 -2
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/position.js +3 -3
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +23 -26
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/typography.js +0 -1
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +23 -73
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/grid.js +151 -0
- package/build-module/layouts/grid.js.map +1 -0
- package/build-module/layouts/index.js +2 -1
- package/build-module/layouts/index.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/utils/object.js +69 -0
- package/build-module/utils/object.js.map +1 -0
- package/build-style/style-rtl.css +26 -6
- package/build-style/style.css +26 -6
- package/package.json +31 -31
- package/src/components/block-draggable/content.scss +1 -1
- package/src/components/block-list/block-html.js +1 -1
- package/src/components/block-preview/auto.js +2 -17
- package/src/components/colors-gradients/style.scss +8 -8
- package/src/components/editor-styles/index.js +29 -1
- package/src/components/global-styles/color-panel.js +706 -0
- package/src/components/global-styles/dimensions-panel.js +13 -42
- package/src/components/global-styles/get-block-css-selector.js +129 -0
- package/src/components/global-styles/hooks.js +80 -0
- package/src/components/global-styles/index.js +2 -1
- package/src/components/global-styles/test/use-global-styles-output.js +30 -1
- package/src/components/global-styles/typography-panel.js +26 -51
- package/src/components/global-styles/use-global-styles-output.js +163 -80
- package/src/components/global-styles/utils.js +3 -0
- package/src/components/image-size-control/index.js +4 -3
- package/src/components/image-size-control/test/index.js +2 -2
- package/src/components/inner-blocks/README.md +1 -1
- package/src/components/inspector-controls-tabs/position-controls-panel.js +40 -9
- package/src/components/line-height-control/index.js +10 -1
- package/src/components/list-view/appender.js +101 -0
- package/src/components/list-view/block.js +5 -4
- package/src/components/list-view/branch.js +30 -1
- package/src/components/list-view/index.js +43 -10
- package/src/components/list-view/style.scss +19 -0
- package/src/components/media-replace-flow/index.js +36 -24
- package/src/components/media-replace-flow/style.scss +5 -2
- package/src/components/rich-text/format-edit.js +2 -32
- package/src/components/writing-flow/use-input.js +4 -5
- package/src/hooks/border.js +0 -1
- package/src/hooks/color.js +120 -296
- package/src/hooks/content-lock-ui.js +6 -2
- package/src/hooks/{color-panel.js → contrast-checker.js} +10 -46
- package/src/hooks/dimensions.js +0 -1
- package/src/hooks/duotone.js +8 -5
- package/src/hooks/position.js +3 -3
- package/src/hooks/style.js +29 -28
- package/src/hooks/test/utils.js +0 -104
- package/src/hooks/typography.js +0 -1
- package/src/hooks/utils.js +27 -70
- package/src/layouts/grid.js +172 -0
- package/src/layouts/index.js +2 -1
- package/src/layouts/test/grid.js +21 -0
- package/src/private-apis.js +2 -0
- package/src/utils/object.js +69 -0
- package/src/utils/test/object.js +107 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/hooks/color-panel.js.map +0 -1
- package/build-module/hooks/color-panel.js.map +0 -1
|
@@ -11,18 +11,19 @@ import classnames from 'classnames';
|
|
|
11
11
|
|
|
12
12
|
import { addFilter } from '@wordpress/hooks';
|
|
13
13
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
14
|
-
import {
|
|
15
|
-
import { useRef, useEffect, useMemo, Platform } from '@wordpress/element';
|
|
14
|
+
import { useMemo, Platform, useCallback } from '@wordpress/element';
|
|
16
15
|
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
17
16
|
/**
|
|
18
17
|
* Internal dependencies
|
|
19
18
|
*/
|
|
20
19
|
|
|
21
|
-
import { getColorClassName,
|
|
22
|
-
import { __experimentalGetGradientClass
|
|
23
|
-
import { cleanEmptyObject, transformStyles,
|
|
24
|
-
import ColorPanel from './color-panel';
|
|
20
|
+
import { getColorClassName, getColorObjectByAttributeValues } from '../components/colors';
|
|
21
|
+
import { __experimentalGetGradientClass } from '../components/gradients';
|
|
22
|
+
import { cleanEmptyObject, transformStyles, shouldSkipSerialization, useBlockSettings } from './utils';
|
|
25
23
|
import useSetting from '../components/use-setting';
|
|
24
|
+
import InspectorControls from '../components/inspector-controls';
|
|
25
|
+
import { useHasColorPanel, default as StylesColorPanel } from '../components/global-styles/color-panel';
|
|
26
|
+
import BlockColorContrastChecker from './contrast-checker';
|
|
26
27
|
export const COLOR_SUPPORT_KEY = 'color';
|
|
27
28
|
|
|
28
29
|
const hasColorSupport = blockType => {
|
|
@@ -53,62 +54,6 @@ const hasTextColorSupport = blockType => {
|
|
|
53
54
|
const colorSupport = getBlockSupport(blockType, COLOR_SUPPORT_KEY);
|
|
54
55
|
return colorSupport && colorSupport.text !== false;
|
|
55
56
|
};
|
|
56
|
-
/**
|
|
57
|
-
* Clears a single color property from a style object.
|
|
58
|
-
*
|
|
59
|
-
* @param {Array} path Path to color property to clear within styles object.
|
|
60
|
-
* @param {Object} style Block attributes style object.
|
|
61
|
-
* @return {Object} Styles with the color property omitted.
|
|
62
|
-
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const clearColorFromStyles = (path, style) => cleanEmptyObject(immutableSet(style, path, undefined));
|
|
66
|
-
/**
|
|
67
|
-
* Clears text color related properties from supplied attributes.
|
|
68
|
-
*
|
|
69
|
-
* @param {Object} attributes Block attributes.
|
|
70
|
-
* @return {Object} Update block attributes with text color properties omitted.
|
|
71
|
-
*/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const resetAllTextFilter = attributes => ({
|
|
75
|
-
textColor: undefined,
|
|
76
|
-
style: clearColorFromStyles(['color', 'text'], attributes.style)
|
|
77
|
-
});
|
|
78
|
-
/**
|
|
79
|
-
* Clears link color related properties from supplied attributes.
|
|
80
|
-
*
|
|
81
|
-
* @param {Object} attributes Block attributes.
|
|
82
|
-
* @return {Object} Update block attributes with link color properties omitted.
|
|
83
|
-
*/
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const resetAllLinkFilter = attributes => ({
|
|
87
|
-
style: clearColorFromStyles(['elements', 'link', 'color', 'text'], attributes.style)
|
|
88
|
-
});
|
|
89
|
-
/**
|
|
90
|
-
* Clears all background color related properties including gradients from
|
|
91
|
-
* supplied block attributes.
|
|
92
|
-
*
|
|
93
|
-
* @param {Object} attributes Block attributes.
|
|
94
|
-
* @return {Object} Block attributes with background and gradient omitted.
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const clearBackgroundAndGradient = attributes => {
|
|
99
|
-
var _attributes$style;
|
|
100
|
-
|
|
101
|
-
return {
|
|
102
|
-
backgroundColor: undefined,
|
|
103
|
-
gradient: undefined,
|
|
104
|
-
style: { ...attributes.style,
|
|
105
|
-
color: { ...((_attributes$style = attributes.style) === null || _attributes$style === void 0 ? void 0 : _attributes$style.color),
|
|
106
|
-
background: undefined,
|
|
107
|
-
gradient: undefined
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
57
|
/**
|
|
113
58
|
* Filters registered block settings, extending attributes to include
|
|
114
59
|
* `backgroundColor` and `textColor` attribute.
|
|
@@ -227,191 +172,104 @@ export function addEditProps(settings) {
|
|
|
227
172
|
return settings;
|
|
228
173
|
}
|
|
229
174
|
|
|
230
|
-
|
|
231
|
-
|
|
175
|
+
function styleToAttributes(style) {
|
|
176
|
+
var _style$color5, _style$color6, _style$color7;
|
|
232
177
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
178
|
+
const textColorValue = style === null || style === void 0 ? void 0 : (_style$color5 = style.color) === null || _style$color5 === void 0 ? void 0 : _style$color5.text;
|
|
179
|
+
const textColorSlug = textColorValue !== null && textColorValue !== void 0 && textColorValue.startsWith('var:preset|color|') ? textColorValue.substring('var:preset|color|'.length) : undefined;
|
|
180
|
+
const backgroundColorValue = style === null || style === void 0 ? void 0 : (_style$color6 = style.color) === null || _style$color6 === void 0 ? void 0 : _style$color6.background;
|
|
181
|
+
const backgroundColorSlug = backgroundColorValue !== null && backgroundColorValue !== void 0 && backgroundColorValue.startsWith('var:preset|color|') ? backgroundColorValue.substring('var:preset|color|'.length) : undefined;
|
|
182
|
+
const gradientValue = style === null || style === void 0 ? void 0 : (_style$color7 = style.color) === null || _style$color7 === void 0 ? void 0 : _style$color7.gradient;
|
|
183
|
+
const gradientSlug = gradientValue !== null && gradientValue !== void 0 && gradientValue.startsWith('var:preset|gradient|') ? gradientValue.substring('var:preset|gradient|'.length) : undefined;
|
|
184
|
+
const updatedStyle = { ...style
|
|
185
|
+
};
|
|
186
|
+
updatedStyle.color = { ...updatedStyle.color,
|
|
187
|
+
text: textColorSlug ? undefined : textColorValue,
|
|
188
|
+
background: backgroundColorSlug ? undefined : backgroundColorValue,
|
|
189
|
+
gradient: gradientSlug ? undefined : gradientValue
|
|
190
|
+
};
|
|
191
|
+
return {
|
|
192
|
+
style: cleanEmptyObject(updatedStyle),
|
|
193
|
+
textColor: textColorSlug,
|
|
194
|
+
backgroundColor: backgroundColorSlug,
|
|
195
|
+
gradient: gradientSlug
|
|
196
|
+
};
|
|
197
|
+
}
|
|
236
198
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Inspector control panel containing the color related configuration
|
|
241
|
-
*
|
|
242
|
-
* @param {Object} props
|
|
243
|
-
*
|
|
244
|
-
* @return {WPElement} Color edit element.
|
|
245
|
-
*/
|
|
199
|
+
function attributesToStyle(attributes) {
|
|
200
|
+
var _attributes$style, _attributes$style2, _attributes$style2$co, _attributes$style3, _attributes$style3$co, _attributes$style4, _attributes$style4$co;
|
|
246
201
|
|
|
202
|
+
return { ...attributes.style,
|
|
203
|
+
color: { ...((_attributes$style = attributes.style) === null || _attributes$style === void 0 ? void 0 : _attributes$style.color),
|
|
204
|
+
text: attributes.textColor ? 'var:preset|color|' + attributes.textColor : (_attributes$style2 = attributes.style) === null || _attributes$style2 === void 0 ? void 0 : (_attributes$style2$co = _attributes$style2.color) === null || _attributes$style2$co === void 0 ? void 0 : _attributes$style2$co.text,
|
|
205
|
+
background: attributes.backgroundColor ? 'var:preset|color|' + attributes.backgroundColor : (_attributes$style3 = attributes.style) === null || _attributes$style3 === void 0 ? void 0 : (_attributes$style3$co = _attributes$style3.color) === null || _attributes$style3$co === void 0 ? void 0 : _attributes$style3$co.background,
|
|
206
|
+
gradient: attributes.gradient ? 'var:preset|gradient|' + attributes.gradient : (_attributes$style4 = attributes.style) === null || _attributes$style4 === void 0 ? void 0 : (_attributes$style4$co = _attributes$style4.color) === null || _attributes$style4$co === void 0 ? void 0 : _attributes$style4$co.gradient
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function ColorInspectorControl(_ref) {
|
|
212
|
+
let {
|
|
213
|
+
children,
|
|
214
|
+
resetAllFilter
|
|
215
|
+
} = _ref;
|
|
216
|
+
const attributesResetAllFilter = useCallback(attributes => {
|
|
217
|
+
const existingStyle = attributesToStyle(attributes);
|
|
218
|
+
const updatedStyle = resetAllFilter(existingStyle);
|
|
219
|
+
return { ...attributes,
|
|
220
|
+
...styleToAttributes(updatedStyle)
|
|
221
|
+
};
|
|
222
|
+
}, [resetAllFilter]);
|
|
223
|
+
return createElement(InspectorControls, {
|
|
224
|
+
group: "color",
|
|
225
|
+
resetAllFilter: attributesResetAllFilter
|
|
226
|
+
}, children);
|
|
227
|
+
}
|
|
247
228
|
|
|
248
229
|
export function ColorEdit(props) {
|
|
249
|
-
var
|
|
230
|
+
var _value$color, _settings$color, _settings$color2;
|
|
250
231
|
|
|
251
232
|
const {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const
|
|
259
|
-
const
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
const areCustomGradientsEnabled = useSetting('color.customGradient');
|
|
268
|
-
const isBackgroundEnabled = useSetting('color.background');
|
|
269
|
-
const isLinkEnabled = useSetting('color.link');
|
|
270
|
-
const isTextEnabled = useSetting('color.text');
|
|
271
|
-
const solidsEnabled = areCustomSolidsEnabled || !themePalette || (themePalette === null || themePalette === void 0 ? void 0 : themePalette.length) > 0;
|
|
272
|
-
const gradientsEnabled = areCustomGradientsEnabled || !themeGradientPalette || (themeGradientPalette === null || themeGradientPalette === void 0 ? void 0 : themeGradientPalette.length) > 0; // Shouldn't be needed but right now the ColorGradientsPanel
|
|
273
|
-
// can trigger both onChangeColor and onChangeBackground
|
|
274
|
-
// synchronously causing our two callbacks to override changes
|
|
275
|
-
// from each other.
|
|
276
|
-
|
|
277
|
-
const localAttributes = useRef(attributes);
|
|
278
|
-
useEffect(() => {
|
|
279
|
-
localAttributes.current = attributes;
|
|
280
|
-
}, [attributes]);
|
|
281
|
-
|
|
282
|
-
if (!hasColorSupport(blockName)) {
|
|
283
|
-
return null;
|
|
284
|
-
}
|
|
233
|
+
clientId,
|
|
234
|
+
name,
|
|
235
|
+
attributes,
|
|
236
|
+
setAttributes
|
|
237
|
+
} = props;
|
|
238
|
+
const settings = useBlockSettings(name);
|
|
239
|
+
const isEnabled = useHasColorPanel(settings);
|
|
240
|
+
const value = useMemo(() => {
|
|
241
|
+
return attributesToStyle({
|
|
242
|
+
style: attributes.style,
|
|
243
|
+
textColor: attributes.textColor,
|
|
244
|
+
backgroundColor: attributes.backgroundColor,
|
|
245
|
+
gradient: attributes.gradient
|
|
246
|
+
});
|
|
247
|
+
}, [attributes.style, attributes.textColor, attributes.backgroundColor, attributes.gradient]);
|
|
285
248
|
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
const hasGradientColor = hasGradientSupport(blockName) && gradientsEnabled;
|
|
249
|
+
const onChange = newStyle => {
|
|
250
|
+
setAttributes(styleToAttributes(newStyle));
|
|
251
|
+
};
|
|
290
252
|
|
|
291
|
-
if (!
|
|
253
|
+
if (!isEnabled) {
|
|
292
254
|
return null;
|
|
293
255
|
}
|
|
294
256
|
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
textColor,
|
|
298
|
-
backgroundColor,
|
|
299
|
-
gradient
|
|
300
|
-
} = attributes;
|
|
301
|
-
let gradientValue;
|
|
302
|
-
|
|
303
|
-
if (hasGradientColor && gradient) {
|
|
304
|
-
gradientValue = getGradientValueBySlug(allGradients, gradient);
|
|
305
|
-
} else if (hasGradientColor) {
|
|
306
|
-
var _style$color5;
|
|
307
|
-
|
|
308
|
-
gradientValue = style === null || style === void 0 ? void 0 : (_style$color5 = style.color) === null || _style$color5 === void 0 ? void 0 : _style$color5.gradient;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
const onChangeColor = name => value => {
|
|
312
|
-
var _localAttributes$curr, _localAttributes$curr2;
|
|
313
|
-
|
|
314
|
-
const colorObject = getColorObjectByColorValue(allSolids, value);
|
|
315
|
-
const attributeName = name + 'Color';
|
|
316
|
-
const newStyle = { ...localAttributes.current.style,
|
|
317
|
-
color: { ...((_localAttributes$curr = localAttributes.current) === null || _localAttributes$curr === void 0 ? void 0 : (_localAttributes$curr2 = _localAttributes$curr.style) === null || _localAttributes$curr2 === void 0 ? void 0 : _localAttributes$curr2.color),
|
|
318
|
-
[name]: colorObject !== null && colorObject !== void 0 && colorObject.slug ? undefined : value
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
const newNamedColor = colorObject !== null && colorObject !== void 0 && colorObject.slug ? colorObject.slug : undefined;
|
|
322
|
-
const newAttributes = {
|
|
323
|
-
style: cleanEmptyObject(newStyle),
|
|
324
|
-
[attributeName]: newNamedColor
|
|
325
|
-
};
|
|
326
|
-
props.setAttributes(newAttributes);
|
|
327
|
-
localAttributes.current = { ...localAttributes.current,
|
|
328
|
-
...newAttributes
|
|
329
|
-
};
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
const onChangeGradient = value => {
|
|
333
|
-
const slug = getGradientSlugByValue(allGradients, value);
|
|
334
|
-
let newAttributes;
|
|
335
|
-
|
|
336
|
-
if (slug) {
|
|
337
|
-
var _localAttributes$curr3, _localAttributes$curr4, _localAttributes$curr5;
|
|
338
|
-
|
|
339
|
-
const newStyle = { ...((_localAttributes$curr3 = localAttributes.current) === null || _localAttributes$curr3 === void 0 ? void 0 : _localAttributes$curr3.style),
|
|
340
|
-
color: { ...((_localAttributes$curr4 = localAttributes.current) === null || _localAttributes$curr4 === void 0 ? void 0 : (_localAttributes$curr5 = _localAttributes$curr4.style) === null || _localAttributes$curr5 === void 0 ? void 0 : _localAttributes$curr5.color),
|
|
341
|
-
gradient: undefined
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
newAttributes = {
|
|
345
|
-
style: cleanEmptyObject(newStyle),
|
|
346
|
-
gradient: slug
|
|
347
|
-
};
|
|
348
|
-
} else {
|
|
349
|
-
var _localAttributes$curr6, _localAttributes$curr7, _localAttributes$curr8;
|
|
350
|
-
|
|
351
|
-
const newStyle = { ...((_localAttributes$curr6 = localAttributes.current) === null || _localAttributes$curr6 === void 0 ? void 0 : _localAttributes$curr6.style),
|
|
352
|
-
color: { ...((_localAttributes$curr7 = localAttributes.current) === null || _localAttributes$curr7 === void 0 ? void 0 : (_localAttributes$curr8 = _localAttributes$curr7.style) === null || _localAttributes$curr8 === void 0 ? void 0 : _localAttributes$curr8.color),
|
|
353
|
-
gradient: value
|
|
354
|
-
}
|
|
355
|
-
};
|
|
356
|
-
newAttributes = {
|
|
357
|
-
style: cleanEmptyObject(newStyle),
|
|
358
|
-
gradient: undefined
|
|
359
|
-
};
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
props.setAttributes(newAttributes);
|
|
363
|
-
localAttributes.current = { ...localAttributes.current,
|
|
364
|
-
...newAttributes
|
|
365
|
-
};
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
const onChangeLinkColor = value => {
|
|
369
|
-
var _localAttributes$curr9;
|
|
370
|
-
|
|
371
|
-
const colorObject = getColorObjectByColorValue(allSolids, value);
|
|
372
|
-
const newLinkColorValue = colorObject !== null && colorObject !== void 0 && colorObject.slug ? `var:preset|color|${colorObject.slug}` : value;
|
|
373
|
-
const newStyle = cleanEmptyObject(immutableSet((_localAttributes$curr9 = localAttributes.current) === null || _localAttributes$curr9 === void 0 ? void 0 : _localAttributes$curr9.style, ['elements', 'link', 'color', 'text'], newLinkColorValue));
|
|
374
|
-
props.setAttributes({
|
|
375
|
-
style: newStyle
|
|
376
|
-
});
|
|
377
|
-
localAttributes.current = { ...localAttributes.current,
|
|
378
|
-
...{
|
|
379
|
-
style: newStyle
|
|
380
|
-
}
|
|
381
|
-
};
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
const defaultColorControls = getBlockSupport(props.name, [COLOR_SUPPORT_KEY, '__experimentalDefaultControls']);
|
|
385
|
-
const enableContrastChecking = Platform.OS === 'web' && !gradient && !(style !== null && style !== void 0 && (_style$color6 = style.color) !== null && _style$color6 !== void 0 && _style$color6.gradient) && hasBackgroundColor && (hasLinkColor || hasTextColor) && // Contrast checking is enabled by default.
|
|
257
|
+
const defaultControls = getBlockSupport(props.name, [COLOR_SUPPORT_KEY, '__experimentalDefaultControls']);
|
|
258
|
+
const enableContrastChecking = Platform.OS === 'web' && !(value !== null && value !== void 0 && (_value$color = value.color) !== null && _value$color !== void 0 && _value$color.gradient) && ((settings === null || settings === void 0 ? void 0 : (_settings$color = settings.color) === null || _settings$color === void 0 ? void 0 : _settings$color.text) || (settings === null || settings === void 0 ? void 0 : (_settings$color2 = settings.color) === null || _settings$color2 === void 0 ? void 0 : _settings$color2.link)) && // Contrast checking is enabled by default.
|
|
386
259
|
// Deactivating it requires `enableContrastChecker` to have
|
|
387
260
|
// an explicit value of `false`.
|
|
388
261
|
false !== getBlockSupport(props.name, [COLOR_SUPPORT_KEY, 'enableContrastChecker']);
|
|
389
|
-
return createElement(
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
label: __('Background'),
|
|
401
|
-
onColorChange: hasBackgroundColor ? onChangeColor('background') : undefined,
|
|
402
|
-
colorValue: getColorObjectByAttributeValues(allSolids, backgroundColor, style === null || style === void 0 ? void 0 : (_style$color8 = style.color) === null || _style$color8 === void 0 ? void 0 : _style$color8.background).color,
|
|
403
|
-
gradientValue,
|
|
404
|
-
onGradientChange: hasGradientColor ? onChangeGradient : undefined,
|
|
405
|
-
isShownByDefault: defaultColorControls === null || defaultColorControls === void 0 ? void 0 : defaultColorControls.background,
|
|
406
|
-
resetAllFilter: clearBackgroundAndGradient
|
|
407
|
-
}] : []), ...(hasLinkColor ? [{
|
|
408
|
-
label: __('Link'),
|
|
409
|
-
onColorChange: onChangeLinkColor,
|
|
410
|
-
colorValue: getLinkColorFromAttributeValue(allSolids, style === null || style === void 0 ? void 0 : (_style$elements2 = style.elements) === null || _style$elements2 === void 0 ? void 0 : (_style$elements2$link = _style$elements2.link) === null || _style$elements2$link === void 0 ? void 0 : (_style$elements2$link2 = _style$elements2$link.color) === null || _style$elements2$link2 === void 0 ? void 0 : _style$elements2$link2.text),
|
|
411
|
-
isShownByDefault: defaultColorControls === null || defaultColorControls === void 0 ? void 0 : defaultColorControls.link,
|
|
412
|
-
resetAllFilter: resetAllLinkFilter
|
|
413
|
-
}] : [])]
|
|
414
|
-
});
|
|
262
|
+
return createElement(StylesColorPanel, {
|
|
263
|
+
as: ColorInspectorControl,
|
|
264
|
+
panelId: clientId,
|
|
265
|
+
settings: settings,
|
|
266
|
+
value: value,
|
|
267
|
+
onChange: onChange,
|
|
268
|
+
defaultControls: defaultControls,
|
|
269
|
+
enableContrastChecker: false !== getBlockSupport(props.name, [COLOR_SUPPORT_KEY, 'enableContrastChecker'])
|
|
270
|
+
}, enableContrastChecking && createElement(BlockColorContrastChecker, {
|
|
271
|
+
clientId: clientId
|
|
272
|
+
}));
|
|
415
273
|
}
|
|
416
274
|
/**
|
|
417
275
|
* This adds inline styles for color palette colors.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/color.js"],"names":["classnames","addFilter","getBlockSupport","__","useRef","useEffect","useMemo","Platform","createHigherOrderComponent","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","__experimentalGetGradientClass","getGradientValueBySlug","getGradientSlugByValue","cleanEmptyObject","transformStyles","immutableSet","shouldSkipSerialization","ColorPanel","useSetting","COLOR_SUPPORT_KEY","hasColorSupport","blockType","colorSupport","link","gradient","background","text","hasLinkColorSupport","OS","hasGradientSupport","gradients","hasBackgroundColorSupport","hasTextColorSupport","clearColorFromStyles","path","style","undefined","resetAllTextFilter","attributes","textColor","resetAllLinkFilter","clearBackgroundAndGradient","backgroundColor","color","addAttributes","settings","Object","assign","type","addSaveProps","props","hasGradient","shouldSerialize","feature","textClass","gradientClass","backgroundClass","serializeHasBackground","hasBackground","newClassName","className","elements","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","getLinkColorFromAttributeValue","colors","value","attributeParsed","exec","ColorEdit","name","blockName","userPalette","themePalette","defaultPalette","allSolids","userGradientPalette","themeGradientPalette","defaultGradientPalette","allGradients","areCustomSolidsEnabled","areCustomGradientsEnabled","isBackgroundEnabled","isLinkEnabled","isTextEnabled","solidsEnabled","length","gradientsEnabled","localAttributes","current","hasLinkColor","hasTextColor","hasBackgroundColor","hasGradientColor","gradientValue","onChangeColor","colorObject","attributeName","newStyle","slug","newNamedColor","newAttributes","setAttributes","onChangeGradient","onChangeLinkColor","newLinkColorValue","defaultColorControls","enableContrastChecking","clientId","label","onColorChange","colorValue","isShownByDefault","resetAllFilter","onGradientChange","withColorPaletteStyles","BlockListBlock","extraStyles","wrapperProps","MIGRATION_PATHS","linkColor","addTransforms","result","source","index","results","destinationBlockType","activeSupports"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,EAAT,QAAmB,iBAAnB;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OAAF,EAAW,OAAX,EAAoB,UAApB,CAAlB;AAPa,CAAxB;AAUA,OAAO,SAASkG,aAAT,CAAwBC,MAAxB,EAAgCC,MAAhC,EAAwCC,KAAxC,EAA+CC,OAA/C,EAAyD;AAC/D,QAAMC,oBAAoB,GAAGJ,MAAM,CAACpD,IAApC;AACA,QAAMyD,cAAc,GAAG;AACtBP,IAAAA,SAAS,EAAE9F,mBAAmB,CAAEoG,oBAAF,CADR;AAEtBxF,IAAAA,SAAS,EAAEP,mBAAmB,CAAE+F,oBAAF,CAFR;AAGtBrF,IAAAA,eAAe,EAAEX,yBAAyB,CAAEgG,oBAAF,CAHpB;AAItBvG,IAAAA,QAAQ,EAAEK,kBAAkB,CAAEkG,oBAAF;AAJN,GAAvB;AAMA,SAAOjH,eAAe,CACrBkH,cADqB,EAErBR,eAFqB,EAGrBG,MAHqB,EAIrBC,MAJqB,EAKrBC,KALqB,EAMrBC,OANqB,CAAtB;AAQA;AAED/H,SAAS,CACR,0BADQ,EAER,yBAFQ,EAGR6C,aAHQ,CAAT;AAMA7C,SAAS,CACR,kCADQ,EAER,yBAFQ,EAGRkD,YAHQ,CAAT;AAMAlD,SAAS,CACR,0BADQ,EAER,yBAFQ,EAGR+D,YAHQ,CAAT;AAMA/D,SAAS,CACR,uBADQ,EAER,sCAFQ,EAGRqH,sBAHQ,CAAT;AAMArH,SAAS,CACR,2CADQ,EAER,0BAFQ,EAGR2H,aAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useEffect, useMemo, Platform } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n} from '../components/colors';\nimport {\n\t__experimentalGetGradientClass,\n\tgetGradientValueBySlug,\n\tgetGradientSlugByValue,\n} from '../components/gradients';\nimport {\n\tcleanEmptyObject,\n\ttransformStyles,\n\timmutableSet,\n\tshouldSkipSerialization,\n} from './utils';\nimport ColorPanel from './color-panel';\nimport useSetting from '../components/use-setting';\n\nexport const COLOR_SUPPORT_KEY = 'color';\n\nconst hasColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\treturn (\n\t\tcolorSupport &&\n\t\t( colorSupport.link === true ||\n\t\t\tcolorSupport.gradient === true ||\n\t\t\tcolorSupport.background !== false ||\n\t\t\tcolorSupport.text !== false )\n\t);\n};\n\nconst hasLinkColorSupport = ( blockType ) => {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn (\n\t\tcolorSupport !== null &&\n\t\ttypeof colorSupport === 'object' &&\n\t\t!! colorSupport.link\n\t);\n};\n\nconst hasGradientSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn (\n\t\tcolorSupport !== null &&\n\t\ttypeof colorSupport === 'object' &&\n\t\t!! colorSupport.gradients\n\t);\n};\n\nconst hasBackgroundColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport && colorSupport.background !== false;\n};\n\nconst hasTextColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport && colorSupport.text !== false;\n};\n\n/**\n * Clears a single color property from a style object.\n *\n * @param {Array} path Path to color property to clear within styles object.\n * @param {Object} style Block attributes style object.\n * @return {Object} Styles with the color property omitted.\n */\nconst clearColorFromStyles = ( path, style ) =>\n\tcleanEmptyObject( immutableSet( style, path, undefined ) );\n\n/**\n * Clears text color related properties from supplied attributes.\n *\n * @param {Object} attributes Block attributes.\n * @return {Object} Update block attributes with text color properties omitted.\n */\nconst resetAllTextFilter = ( attributes ) => ( {\n\ttextColor: undefined,\n\tstyle: clearColorFromStyles( [ 'color', 'text' ], attributes.style ),\n} );\n\n/**\n * Clears link color related properties from supplied attributes.\n *\n * @param {Object} attributes Block attributes.\n * @return {Object} Update block attributes with link color properties omitted.\n */\nconst resetAllLinkFilter = ( attributes ) => ( {\n\tstyle: clearColorFromStyles(\n\t\t[ 'elements', 'link', 'color', 'text' ],\n\t\tattributes.style\n\t),\n} );\n\n/**\n * Clears all background color related properties including gradients from\n * supplied block attributes.\n *\n * @param {Object} attributes Block attributes.\n * @return {Object} Block attributes with background and gradient omitted.\n */\nconst clearBackgroundAndGradient = ( attributes ) => ( {\n\tbackgroundColor: undefined,\n\tgradient: undefined,\n\tstyle: {\n\t\t...attributes.style,\n\t\tcolor: {\n\t\t\t...attributes.style?.color,\n\t\t\tbackground: undefined,\n\t\t\tgradient: undefined,\n\t\t},\n\t},\n} );\n\n/**\n * Filters registered block settings, extending attributes to include\n * `backgroundColor` and `textColor` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasColorSupport( settings ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( ! settings.attributes.backgroundColor ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tbackgroundColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\tif ( ! settings.attributes.textColor ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\ttextColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\n\tif ( hasGradientSupport( settings ) && ! settings.attributes.gradient ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tgradient: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override props assigned to save component to inject colors classnames.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasColorSupport( blockType ) ||\n\t\tshouldSkipSerialization( blockType, COLOR_SUPPORT_KEY )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst hasGradient = hasGradientSupport( blockType );\n\n\t// I'd have preferred to avoid the \"style\" attribute usage here\n\tconst { backgroundColor, textColor, gradient, style } = attributes;\n\n\tconst shouldSerialize = ( feature ) =>\n\t\t! shouldSkipSerialization( blockType, COLOR_SUPPORT_KEY, feature );\n\n\t// Primary color classes must come before the `has-text-color`,\n\t// `has-background` and `has-link-color` classes to maintain backwards\n\t// compatibility and avoid block invalidations.\n\tconst textClass = shouldSerialize( 'text' )\n\t\t? getColorClassName( 'color', textColor )\n\t\t: undefined;\n\n\tconst gradientClass = shouldSerialize( 'gradients' )\n\t\t? __experimentalGetGradientClass( gradient )\n\t\t: undefined;\n\n\tconst backgroundClass = shouldSerialize( 'background' )\n\t\t? getColorClassName( 'background-color', backgroundColor )\n\t\t: undefined;\n\n\tconst serializeHasBackground =\n\t\tshouldSerialize( 'background' ) || shouldSerialize( 'gradients' );\n\tconst hasBackground =\n\t\tbackgroundColor ||\n\t\tstyle?.color?.background ||\n\t\t( hasGradient && ( gradient || style?.color?.gradient ) );\n\n\tconst newClassName = classnames(\n\t\tprops.className,\n\t\ttextClass,\n\t\tgradientClass,\n\t\t{\n\t\t\t// Don't apply the background class if there's a custom gradient.\n\t\t\t[ backgroundClass ]:\n\t\t\t\t( ! hasGradient || ! style?.color?.gradient ) &&\n\t\t\t\t!! backgroundClass,\n\t\t\t'has-text-color':\n\t\t\t\tshouldSerialize( 'text' ) &&\n\t\t\t\t( textColor || style?.color?.text ),\n\t\t\t'has-background': serializeHasBackground && hasBackground,\n\t\t\t'has-link-color':\n\t\t\t\tshouldSerialize( 'link' ) && style?.elements?.link?.color,\n\t\t}\n\t);\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Filters registered block settings to extend the block edit wrapper\n * to apply the desired styles and classnames properly.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addEditProps( settings ) {\n\tif (\n\t\t! hasColorSupport( settings ) ||\n\t\tshouldSkipSerialization( settings, COLOR_SUPPORT_KEY )\n\t) {\n\t\treturn settings;\n\t}\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\nconst getLinkColorFromAttributeValue = ( colors, value ) => {\n\tconst attributeParsed = /var:preset\\|color\\|(.+)/.exec( value );\n\tif ( attributeParsed && attributeParsed[ 1 ] ) {\n\t\treturn getColorObjectByAttributeValues( colors, attributeParsed[ 1 ] )\n\t\t\t.color;\n\t}\n\treturn value;\n};\n\n/**\n * Inspector control panel containing the color related configuration\n *\n * @param {Object} props\n *\n * @return {WPElement} Color edit element.\n */\nexport function ColorEdit( props ) {\n\tconst { name: blockName, attributes } = props;\n\t// Some color settings have a special handling for deprecated flags in `useSetting`,\n\t// so we can't unwrap them by doing const { ... } = useSetting('color')\n\t// until https://github.com/WordPress/gutenberg/issues/37094 is fixed.\n\tconst userPalette = useSetting( 'color.palette.custom' );\n\tconst themePalette = useSetting( 'color.palette.theme' );\n\tconst defaultPalette = useSetting( 'color.palette.default' );\n\tconst allSolids = useMemo(\n\t\t() => [\n\t\t\t...( userPalette || [] ),\n\t\t\t...( themePalette || [] ),\n\t\t\t...( defaultPalette || [] ),\n\t\t],\n\t\t[ userPalette, themePalette, defaultPalette ]\n\t);\n\tconst userGradientPalette = useSetting( 'color.gradients.custom' );\n\tconst themeGradientPalette = useSetting( 'color.gradients.theme' );\n\tconst defaultGradientPalette = useSetting( 'color.gradients.default' );\n\tconst allGradients = useMemo(\n\t\t() => [\n\t\t\t...( userGradientPalette || [] ),\n\t\t\t...( themeGradientPalette || [] ),\n\t\t\t...( defaultGradientPalette || [] ),\n\t\t],\n\t\t[ userGradientPalette, themeGradientPalette, defaultGradientPalette ]\n\t);\n\tconst areCustomSolidsEnabled = useSetting( 'color.custom' );\n\tconst areCustomGradientsEnabled = useSetting( 'color.customGradient' );\n\tconst isBackgroundEnabled = useSetting( 'color.background' );\n\tconst isLinkEnabled = useSetting( 'color.link' );\n\tconst isTextEnabled = useSetting( 'color.text' );\n\n\tconst solidsEnabled =\n\t\tareCustomSolidsEnabled || ! themePalette || themePalette?.length > 0;\n\n\tconst gradientsEnabled =\n\t\tareCustomGradientsEnabled ||\n\t\t! themeGradientPalette ||\n\t\tthemeGradientPalette?.length > 0;\n\n\t// Shouldn't be needed but right now the ColorGradientsPanel\n\t// can trigger both onChangeColor and onChangeBackground\n\t// synchronously causing our two callbacks to override changes\n\t// from each other.\n\tconst localAttributes = useRef( attributes );\n\tuseEffect( () => {\n\t\tlocalAttributes.current = attributes;\n\t}, [ attributes ] );\n\n\tif ( ! hasColorSupport( blockName ) ) {\n\t\treturn null;\n\t}\n\n\tconst hasLinkColor =\n\t\thasLinkColorSupport( blockName ) && isLinkEnabled && solidsEnabled;\n\tconst hasTextColor =\n\t\thasTextColorSupport( blockName ) && isTextEnabled && solidsEnabled;\n\tconst hasBackgroundColor =\n\t\thasBackgroundColorSupport( blockName ) &&\n\t\tisBackgroundEnabled &&\n\t\tsolidsEnabled;\n\tconst hasGradientColor =\n\t\thasGradientSupport( blockName ) && gradientsEnabled;\n\n\tif (\n\t\t! hasLinkColor &&\n\t\t! hasTextColor &&\n\t\t! hasBackgroundColor &&\n\t\t! hasGradientColor\n\t) {\n\t\treturn null;\n\t}\n\n\tconst { style, textColor, backgroundColor, gradient } = attributes;\n\tlet gradientValue;\n\tif ( hasGradientColor && gradient ) {\n\t\tgradientValue = getGradientValueBySlug( allGradients, gradient );\n\t} else if ( hasGradientColor ) {\n\t\tgradientValue = style?.color?.gradient;\n\t}\n\n\tconst onChangeColor = ( name ) => ( value ) => {\n\t\tconst colorObject = getColorObjectByColorValue( allSolids, value );\n\t\tconst attributeName = name + 'Color';\n\t\tconst newStyle = {\n\t\t\t...localAttributes.current.style,\n\t\t\tcolor: {\n\t\t\t\t...localAttributes.current?.style?.color,\n\t\t\t\t[ name ]: colorObject?.slug ? undefined : value,\n\t\t\t},\n\t\t};\n\n\t\tconst newNamedColor = colorObject?.slug ? colorObject.slug : undefined;\n\t\tconst newAttributes = {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t[ attributeName ]: newNamedColor,\n\t\t};\n\n\t\tprops.setAttributes( newAttributes );\n\t\tlocalAttributes.current = {\n\t\t\t...localAttributes.current,\n\t\t\t...newAttributes,\n\t\t};\n\t};\n\n\tconst onChangeGradient = ( value ) => {\n\t\tconst slug = getGradientSlugByValue( allGradients, value );\n\t\tlet newAttributes;\n\t\tif ( slug ) {\n\t\t\tconst newStyle = {\n\t\t\t\t...localAttributes.current?.style,\n\t\t\t\tcolor: {\n\t\t\t\t\t...localAttributes.current?.style?.color,\n\t\t\t\t\tgradient: undefined,\n\t\t\t\t},\n\t\t\t};\n\t\t\tnewAttributes = {\n\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t\tgradient: slug,\n\t\t\t};\n\t\t} else {\n\t\t\tconst newStyle = {\n\t\t\t\t...localAttributes.current?.style,\n\t\t\t\tcolor: {\n\t\t\t\t\t...localAttributes.current?.style?.color,\n\t\t\t\t\tgradient: value,\n\t\t\t\t},\n\t\t\t};\n\t\t\tnewAttributes = {\n\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t\tgradient: undefined,\n\t\t\t};\n\t\t}\n\t\tprops.setAttributes( newAttributes );\n\t\tlocalAttributes.current = {\n\t\t\t...localAttributes.current,\n\t\t\t...newAttributes,\n\t\t};\n\t};\n\n\tconst onChangeLinkColor = ( value ) => {\n\t\tconst colorObject = getColorObjectByColorValue( allSolids, value );\n\t\tconst newLinkColorValue = colorObject?.slug\n\t\t\t? `var:preset|color|${ colorObject.slug }`\n\t\t\t: value;\n\n\t\tconst newStyle = cleanEmptyObject(\n\t\t\timmutableSet(\n\t\t\t\tlocalAttributes.current?.style,\n\t\t\t\t[ 'elements', 'link', 'color', 'text' ],\n\t\t\t\tnewLinkColorValue\n\t\t\t)\n\t\t);\n\t\tprops.setAttributes( { style: newStyle } );\n\t\tlocalAttributes.current = {\n\t\t\t...localAttributes.current,\n\t\t\t...{ style: newStyle },\n\t\t};\n\t};\n\n\tconst defaultColorControls = getBlockSupport( props.name, [\n\t\tCOLOR_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\tconst enableContrastChecking =\n\t\tPlatform.OS === 'web' &&\n\t\t! gradient &&\n\t\t! style?.color?.gradient &&\n\t\thasBackgroundColor &&\n\t\t( hasLinkColor || hasTextColor ) &&\n\t\t// Contrast checking is enabled by default.\n\t\t// Deactivating it requires `enableContrastChecker` to have\n\t\t// an explicit value of `false`.\n\t\tfalse !==\n\t\t\tgetBlockSupport( props.name, [\n\t\t\t\tCOLOR_SUPPORT_KEY,\n\t\t\t\t'enableContrastChecker',\n\t\t\t] );\n\n\treturn (\n\t\t<ColorPanel\n\t\t\tenableContrastChecking={ enableContrastChecking }\n\t\t\tclientId={ props.clientId }\n\t\t\tenableAlpha={ true }\n\t\t\tsettings={ [\n\t\t\t\t...( hasTextColor\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Text' ),\n\t\t\t\t\t\t\t\tonColorChange: onChangeColor( 'text' ),\n\t\t\t\t\t\t\t\tcolorValue: getColorObjectByAttributeValues(\n\t\t\t\t\t\t\t\t\tallSolids,\n\t\t\t\t\t\t\t\t\ttextColor,\n\t\t\t\t\t\t\t\t\tstyle?.color?.text\n\t\t\t\t\t\t\t\t).color,\n\t\t\t\t\t\t\t\tisShownByDefault: defaultColorControls?.text,\n\t\t\t\t\t\t\t\tresetAllFilter: resetAllTextFilter,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [] ),\n\t\t\t\t...( hasBackgroundColor || hasGradientColor\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Background' ),\n\t\t\t\t\t\t\t\tonColorChange: hasBackgroundColor\n\t\t\t\t\t\t\t\t\t? onChangeColor( 'background' )\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\tcolorValue: getColorObjectByAttributeValues(\n\t\t\t\t\t\t\t\t\tallSolids,\n\t\t\t\t\t\t\t\t\tbackgroundColor,\n\t\t\t\t\t\t\t\t\tstyle?.color?.background\n\t\t\t\t\t\t\t\t).color,\n\t\t\t\t\t\t\t\tgradientValue,\n\t\t\t\t\t\t\t\tonGradientChange: hasGradientColor\n\t\t\t\t\t\t\t\t\t? onChangeGradient\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t\tisShownByDefault:\n\t\t\t\t\t\t\t\t\tdefaultColorControls?.background,\n\t\t\t\t\t\t\t\tresetAllFilter: clearBackgroundAndGradient,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [] ),\n\t\t\t\t...( hasLinkColor\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Link' ),\n\t\t\t\t\t\t\t\tonColorChange: onChangeLinkColor,\n\t\t\t\t\t\t\t\tcolorValue: getLinkColorFromAttributeValue(\n\t\t\t\t\t\t\t\t\tallSolids,\n\t\t\t\t\t\t\t\t\tstyle?.elements?.link?.color?.text\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tisShownByDefault: defaultColorControls?.link,\n\t\t\t\t\t\t\t\tresetAllFilter: resetAllLinkFilter,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t ]\n\t\t\t\t\t: [] ),\n\t\t\t] }\n\t\t/>\n\t);\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { backgroundColor, textColor } = attributes;\n\t\tconst userPalette = useSetting( 'color.palette.custom' );\n\t\tconst themePalette = useSetting( 'color.palette.theme' );\n\t\tconst defaultPalette = useSetting( 'color.palette.default' );\n\t\tconst colors = useMemo(\n\t\t\t() => [\n\t\t\t\t...( userPalette || [] ),\n\t\t\t\t...( themePalette || [] ),\n\t\t\t\t...( defaultPalette || [] ),\n\t\t\t],\n\t\t\t[ userPalette, themePalette, defaultPalette ]\n\t\t);\n\t\tif (\n\t\t\t! hasColorSupport( name ) ||\n\t\t\tshouldSkipSerialization( name, COLOR_SUPPORT_KEY )\n\t\t) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\t\tconst extraStyles = {};\n\n\t\tif (\n\t\t\ttextColor &&\n\t\t\t! shouldSkipSerialization( name, COLOR_SUPPORT_KEY, 'text' )\n\t\t) {\n\t\t\textraStyles.color = getColorObjectByAttributeValues(\n\t\t\t\tcolors,\n\t\t\t\ttextColor\n\t\t\t)?.color;\n\t\t}\n\t\tif (\n\t\t\tbackgroundColor &&\n\t\t\t! shouldSkipSerialization( name, COLOR_SUPPORT_KEY, 'background' )\n\t\t) {\n\t\t\textraStyles.backgroundColor = getColorObjectByAttributeValues(\n\t\t\t\tcolors,\n\t\t\t\tbackgroundColor\n\t\t\t)?.color;\n\t\t}\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...extraStyles,\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\nconst MIGRATION_PATHS = {\n\tlinkColor: [ [ 'style', 'elements', 'link', 'color', 'text' ] ],\n\ttextColor: [ [ 'textColor' ], [ 'style', 'color', 'text' ] ],\n\tbackgroundColor: [\n\t\t[ 'backgroundColor' ],\n\t\t[ 'style', 'color', 'background' ],\n\t],\n\tgradient: [ [ 'gradient' ], [ 'style', 'color', 'gradient' ] ],\n};\n\nexport function addTransforms( result, source, index, results ) {\n\tconst destinationBlockType = result.name;\n\tconst activeSupports = {\n\t\tlinkColor: hasLinkColorSupport( destinationBlockType ),\n\t\ttextColor: hasTextColorSupport( destinationBlockType ),\n\t\tbackgroundColor: hasBackgroundColorSupport( destinationBlockType ),\n\t\tgradient: hasGradientSupport( destinationBlockType ),\n\t};\n\treturn transformStyles(\n\t\tactiveSupports,\n\t\tMIGRATION_PATHS,\n\t\tresult,\n\t\tsource,\n\t\tindex,\n\t\tresults\n\t);\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/color/addAttribute',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/color/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/color/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/color/with-color-palette-styles',\n\twithColorPaletteStyles\n);\n\naddFilter(\n\t'blocks.switchToBlockType.transformedBlock',\n\t'core/color/addTransforms',\n\taddTransforms\n);\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/color.js"],"names":["classnames","addFilter","getBlockSupport","useMemo","Platform","useCallback","createHigherOrderComponent","getColorClassName","getColorObjectByAttributeValues","__experimentalGetGradientClass","cleanEmptyObject","transformStyles","shouldSkipSerialization","useBlockSettings","useSetting","InspectorControls","useHasColorPanel","default","StylesColorPanel","BlockColorContrastChecker","COLOR_SUPPORT_KEY","hasColorSupport","blockType","colorSupport","link","gradient","background","text","hasLinkColorSupport","OS","hasGradientSupport","gradients","hasBackgroundColorSupport","hasTextColorSupport","addAttributes","settings","attributes","backgroundColor","Object","assign","type","textColor","addSaveProps","props","hasGradient","style","shouldSerialize","feature","textClass","undefined","gradientClass","backgroundClass","serializeHasBackground","hasBackground","color","newClassName","className","elements","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","styleToAttributes","textColorValue","textColorSlug","startsWith","substring","length","backgroundColorValue","backgroundColorSlug","gradientValue","gradientSlug","updatedStyle","attributesToStyle","ColorInspectorControl","children","resetAllFilter","attributesResetAllFilter","existingStyle","ColorEdit","clientId","name","setAttributes","isEnabled","value","onChange","newStyle","defaultControls","enableContrastChecking","withColorPaletteStyles","BlockListBlock","userPalette","themePalette","defaultPalette","colors","extraStyles","wrapperProps","MIGRATION_PATHS","linkColor","addTransforms","result","source","index","results","destinationBlockType","activeSupports"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,OAAT,EAAkBC,QAAlB,EAA4BC,WAA5B,QAA+C,oBAA/C;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AAEA;AACA;AACA;;AACA,SACCC,iBADD,EAECC,+BAFD,QAGO,sBAHP;AAIA,SAASC,8BAAT,QAA+C,yBAA/C;AACA,SACCC,gBADD,EAECC,eAFD,EAGCC,uBAHD,EAICC,gBAJD,QAKO,SALP;AAMA,OAAOC,UAAP,MAAuB,2BAAvB;AACA,OAAOC,iBAAP,MAA8B,kCAA9B;AACA,SACCC,gBADD,EAECC,OAAO,IAAIC,gBAFZ,QAGO,yCAHP;AAIA,OAAOC,yBAAP,MAAsC,oBAAtC;AAEA,OAAO,MAAMC,iB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AUA,OAAO,SAASyE,aAAT,CAAwBC,MAAxB,EAAgCC,MAAhC,EAAwCC,KAAxC,EAA+CC,OAA/C,EAAyD;AAC/D,QAAMC,oBAAoB,GAAGJ,MAAM,CAACnB,IAApC;AACA,QAAMwB,cAAc,GAAG;AACtBP,IAAAA,SAAS,EAAErE,mBAAmB,CAAE2E,oBAAF,CADR;AAEtB9D,IAAAA,SAAS,EAAER,mBAAmB,CAAEsE,oBAAF,CAFR;AAGtBlE,IAAAA,eAAe,EAAEL,yBAAyB,CAAEuE,oBAAF,CAHpB;AAItB9E,IAAAA,QAAQ,EAAEK,kBAAkB,CAAEyE,oBAAF;AAJN,GAAvB;AAMA,SAAO5F,eAAe,CACrB6F,cADqB,EAErBR,eAFqB,EAGrBG,MAHqB,EAIrBC,MAJqB,EAKrBC,KALqB,EAMrBC,OANqB,CAAtB;AAQA;AAEDrG,SAAS,CACR,0BADQ,EAER,yBAFQ,EAGRiC,aAHQ,CAAT;AAMAjC,SAAS,CACR,kCADQ,EAER,yBAFQ,EAGRyC,YAHQ,CAAT;AAMAzC,SAAS,CACR,0BADQ,EAER,yBAFQ,EAGRyD,YAHQ,CAAT;AAMAzD,SAAS,CACR,uBADQ,EAER,sCAFQ,EAGRuF,sBAHQ,CAAT;AAMAvF,SAAS,CACR,2CADQ,EAER,0BAFQ,EAGRiG,aAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { useMemo, Platform, useCallback } from '@wordpress/element';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetColorClassName,\n\tgetColorObjectByAttributeValues,\n} from '../components/colors';\nimport { __experimentalGetGradientClass } from '../components/gradients';\nimport {\n\tcleanEmptyObject,\n\ttransformStyles,\n\tshouldSkipSerialization,\n\tuseBlockSettings,\n} from './utils';\nimport useSetting from '../components/use-setting';\nimport InspectorControls from '../components/inspector-controls';\nimport {\n\tuseHasColorPanel,\n\tdefault as StylesColorPanel,\n} from '../components/global-styles/color-panel';\nimport BlockColorContrastChecker from './contrast-checker';\n\nexport const COLOR_SUPPORT_KEY = 'color';\n\nconst hasColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\treturn (\n\t\tcolorSupport &&\n\t\t( colorSupport.link === true ||\n\t\t\tcolorSupport.gradient === true ||\n\t\t\tcolorSupport.background !== false ||\n\t\t\tcolorSupport.text !== false )\n\t);\n};\n\nconst hasLinkColorSupport = ( blockType ) => {\n\tif ( Platform.OS !== 'web' ) {\n\t\treturn false;\n\t}\n\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn (\n\t\tcolorSupport !== null &&\n\t\ttypeof colorSupport === 'object' &&\n\t\t!! colorSupport.link\n\t);\n};\n\nconst hasGradientSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn (\n\t\tcolorSupport !== null &&\n\t\ttypeof colorSupport === 'object' &&\n\t\t!! colorSupport.gradients\n\t);\n};\n\nconst hasBackgroundColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport && colorSupport.background !== false;\n};\n\nconst hasTextColorSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport && colorSupport.text !== false;\n};\n\n/**\n * Filters registered block settings, extending attributes to include\n * `backgroundColor` and `textColor` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addAttributes( settings ) {\n\tif ( ! hasColorSupport( settings ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( ! settings.attributes.backgroundColor ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tbackgroundColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\tif ( ! settings.attributes.textColor ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\ttextColor: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\n\tif ( hasGradientSupport( settings ) && ! settings.attributes.gradient ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tgradient: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override props assigned to save component to inject colors classnames.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( props, blockType, attributes ) {\n\tif (\n\t\t! hasColorSupport( blockType ) ||\n\t\tshouldSkipSerialization( blockType, COLOR_SUPPORT_KEY )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst hasGradient = hasGradientSupport( blockType );\n\n\t// I'd have preferred to avoid the \"style\" attribute usage here\n\tconst { backgroundColor, textColor, gradient, style } = attributes;\n\n\tconst shouldSerialize = ( feature ) =>\n\t\t! shouldSkipSerialization( blockType, COLOR_SUPPORT_KEY, feature );\n\n\t// Primary color classes must come before the `has-text-color`,\n\t// `has-background` and `has-link-color` classes to maintain backwards\n\t// compatibility and avoid block invalidations.\n\tconst textClass = shouldSerialize( 'text' )\n\t\t? getColorClassName( 'color', textColor )\n\t\t: undefined;\n\n\tconst gradientClass = shouldSerialize( 'gradients' )\n\t\t? __experimentalGetGradientClass( gradient )\n\t\t: undefined;\n\n\tconst backgroundClass = shouldSerialize( 'background' )\n\t\t? getColorClassName( 'background-color', backgroundColor )\n\t\t: undefined;\n\n\tconst serializeHasBackground =\n\t\tshouldSerialize( 'background' ) || shouldSerialize( 'gradients' );\n\tconst hasBackground =\n\t\tbackgroundColor ||\n\t\tstyle?.color?.background ||\n\t\t( hasGradient && ( gradient || style?.color?.gradient ) );\n\n\tconst newClassName = classnames(\n\t\tprops.className,\n\t\ttextClass,\n\t\tgradientClass,\n\t\t{\n\t\t\t// Don't apply the background class if there's a custom gradient.\n\t\t\t[ backgroundClass ]:\n\t\t\t\t( ! hasGradient || ! style?.color?.gradient ) &&\n\t\t\t\t!! backgroundClass,\n\t\t\t'has-text-color':\n\t\t\t\tshouldSerialize( 'text' ) &&\n\t\t\t\t( textColor || style?.color?.text ),\n\t\t\t'has-background': serializeHasBackground && hasBackground,\n\t\t\t'has-link-color':\n\t\t\t\tshouldSerialize( 'link' ) && style?.elements?.link?.color,\n\t\t}\n\t);\n\tprops.className = newClassName ? newClassName : undefined;\n\n\treturn props;\n}\n\n/**\n * Filters registered block settings to extend the block edit wrapper\n * to apply the desired styles and classnames properly.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addEditProps( settings ) {\n\tif (\n\t\t! hasColorSupport( settings ) ||\n\t\tshouldSkipSerialization( settings, COLOR_SUPPORT_KEY )\n\t) {\n\t\treturn settings;\n\t}\n\tconst existingGetEditWrapperProps = settings.getEditWrapperProps;\n\tsettings.getEditWrapperProps = ( attributes ) => {\n\t\tlet props = {};\n\t\tif ( existingGetEditWrapperProps ) {\n\t\t\tprops = existingGetEditWrapperProps( attributes );\n\t\t}\n\t\treturn addSaveProps( props, settings, attributes );\n\t};\n\n\treturn settings;\n}\n\nfunction styleToAttributes( style ) {\n\tconst textColorValue = style?.color?.text;\n\tconst textColorSlug = textColorValue?.startsWith( 'var:preset|color|' )\n\t\t? textColorValue.substring( 'var:preset|color|'.length )\n\t\t: undefined;\n\tconst backgroundColorValue = style?.color?.background;\n\tconst backgroundColorSlug = backgroundColorValue?.startsWith(\n\t\t'var:preset|color|'\n\t)\n\t\t? backgroundColorValue.substring( 'var:preset|color|'.length )\n\t\t: undefined;\n\tconst gradientValue = style?.color?.gradient;\n\tconst gradientSlug = gradientValue?.startsWith( 'var:preset|gradient|' )\n\t\t? gradientValue.substring( 'var:preset|gradient|'.length )\n\t\t: undefined;\n\tconst updatedStyle = { ...style };\n\tupdatedStyle.color = {\n\t\t...updatedStyle.color,\n\t\ttext: textColorSlug ? undefined : textColorValue,\n\t\tbackground: backgroundColorSlug ? undefined : backgroundColorValue,\n\t\tgradient: gradientSlug ? undefined : gradientValue,\n\t};\n\treturn {\n\t\tstyle: cleanEmptyObject( updatedStyle ),\n\t\ttextColor: textColorSlug,\n\t\tbackgroundColor: backgroundColorSlug,\n\t\tgradient: gradientSlug,\n\t};\n}\n\nfunction attributesToStyle( attributes ) {\n\treturn {\n\t\t...attributes.style,\n\t\tcolor: {\n\t\t\t...attributes.style?.color,\n\t\t\ttext: attributes.textColor\n\t\t\t\t? 'var:preset|color|' + attributes.textColor\n\t\t\t\t: attributes.style?.color?.text,\n\t\t\tbackground: attributes.backgroundColor\n\t\t\t\t? 'var:preset|color|' + attributes.backgroundColor\n\t\t\t\t: attributes.style?.color?.background,\n\t\t\tgradient: attributes.gradient\n\t\t\t\t? 'var:preset|gradient|' + attributes.gradient\n\t\t\t\t: attributes.style?.color?.gradient,\n\t\t},\n\t};\n}\n\nfunction ColorInspectorControl( { children, resetAllFilter } ) {\n\tconst attributesResetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst existingStyle = attributesToStyle( attributes );\n\t\t\tconst updatedStyle = resetAllFilter( existingStyle );\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\t...styleToAttributes( updatedStyle ),\n\t\t\t};\n\t\t},\n\t\t[ resetAllFilter ]\n\t);\n\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"color\"\n\t\t\tresetAllFilter={ attributesResetAllFilter }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function ColorEdit( props ) {\n\tconst { clientId, name, attributes, setAttributes } = props;\n\tconst settings = useBlockSettings( name );\n\tconst isEnabled = useHasColorPanel( settings );\n\tconst value = useMemo( () => {\n\t\treturn attributesToStyle( {\n\t\t\tstyle: attributes.style,\n\t\t\ttextColor: attributes.textColor,\n\t\t\tbackgroundColor: attributes.backgroundColor,\n\t\t\tgradient: attributes.gradient,\n\t\t} );\n\t}, [\n\t\tattributes.style,\n\t\tattributes.textColor,\n\t\tattributes.backgroundColor,\n\t\tattributes.gradient,\n\t] );\n\n\tconst onChange = ( newStyle ) => {\n\t\tsetAttributes( styleToAttributes( newStyle ) );\n\t};\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultControls = getBlockSupport( props.name, [\n\t\tCOLOR_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\tconst enableContrastChecking =\n\t\tPlatform.OS === 'web' &&\n\t\t! value?.color?.gradient &&\n\t\t( settings?.color?.text || settings?.color?.link ) &&\n\t\t// Contrast checking is enabled by default.\n\t\t// Deactivating it requires `enableContrastChecker` to have\n\t\t// an explicit value of `false`.\n\t\tfalse !==\n\t\t\tgetBlockSupport( props.name, [\n\t\t\t\tCOLOR_SUPPORT_KEY,\n\t\t\t\t'enableContrastChecker',\n\t\t\t] );\n\n\treturn (\n\t\t<StylesColorPanel\n\t\t\tas={ ColorInspectorControl }\n\t\t\tpanelId={ clientId }\n\t\t\tsettings={ settings }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t\tenableContrastChecker={\n\t\t\t\tfalse !==\n\t\t\t\tgetBlockSupport( props.name, [\n\t\t\t\t\tCOLOR_SUPPORT_KEY,\n\t\t\t\t\t'enableContrastChecker',\n\t\t\t\t] )\n\t\t\t}\n\t\t>\n\t\t\t{ enableContrastChecking && (\n\t\t\t\t<BlockColorContrastChecker clientId={ clientId } />\n\t\t\t) }\n\t\t</StylesColorPanel>\n\t);\n}\n\n/**\n * This adds inline styles for color palette colors.\n * Ideally, this is not needed and themes should load their palettes on the editor.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withColorPaletteStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst { backgroundColor, textColor } = attributes;\n\t\tconst userPalette = useSetting( 'color.palette.custom' );\n\t\tconst themePalette = useSetting( 'color.palette.theme' );\n\t\tconst defaultPalette = useSetting( 'color.palette.default' );\n\t\tconst colors = useMemo(\n\t\t\t() => [\n\t\t\t\t...( userPalette || [] ),\n\t\t\t\t...( themePalette || [] ),\n\t\t\t\t...( defaultPalette || [] ),\n\t\t\t],\n\t\t\t[ userPalette, themePalette, defaultPalette ]\n\t\t);\n\t\tif (\n\t\t\t! hasColorSupport( name ) ||\n\t\t\tshouldSkipSerialization( name, COLOR_SUPPORT_KEY )\n\t\t) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\t\tconst extraStyles = {};\n\n\t\tif (\n\t\t\ttextColor &&\n\t\t\t! shouldSkipSerialization( name, COLOR_SUPPORT_KEY, 'text' )\n\t\t) {\n\t\t\textraStyles.color = getColorObjectByAttributeValues(\n\t\t\t\tcolors,\n\t\t\t\ttextColor\n\t\t\t)?.color;\n\t\t}\n\t\tif (\n\t\t\tbackgroundColor &&\n\t\t\t! shouldSkipSerialization( name, COLOR_SUPPORT_KEY, 'background' )\n\t\t) {\n\t\t\textraStyles.backgroundColor = getColorObjectByAttributeValues(\n\t\t\t\tcolors,\n\t\t\t\tbackgroundColor\n\t\t\t)?.color;\n\t\t}\n\n\t\tlet wrapperProps = props.wrapperProps;\n\t\twrapperProps = {\n\t\t\t...props.wrapperProps,\n\t\t\tstyle: {\n\t\t\t\t...extraStyles,\n\t\t\t\t...props.wrapperProps?.style,\n\t\t\t},\n\t\t};\n\n\t\treturn <BlockListBlock { ...props } wrapperProps={ wrapperProps } />;\n\t}\n);\n\nconst MIGRATION_PATHS = {\n\tlinkColor: [ [ 'style', 'elements', 'link', 'color', 'text' ] ],\n\ttextColor: [ [ 'textColor' ], [ 'style', 'color', 'text' ] ],\n\tbackgroundColor: [\n\t\t[ 'backgroundColor' ],\n\t\t[ 'style', 'color', 'background' ],\n\t],\n\tgradient: [ [ 'gradient' ], [ 'style', 'color', 'gradient' ] ],\n};\n\nexport function addTransforms( result, source, index, results ) {\n\tconst destinationBlockType = result.name;\n\tconst activeSupports = {\n\t\tlinkColor: hasLinkColorSupport( destinationBlockType ),\n\t\ttextColor: hasTextColorSupport( destinationBlockType ),\n\t\tbackgroundColor: hasBackgroundColorSupport( destinationBlockType ),\n\t\tgradient: hasGradientSupport( destinationBlockType ),\n\t};\n\treturn transformStyles(\n\t\tactiveSupports,\n\t\tMIGRATION_PATHS,\n\t\tresult,\n\t\tsource,\n\t\tindex,\n\t\tresults\n\t);\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/color/addAttribute',\n\taddAttributes\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/color/addSaveProps',\n\taddSaveProps\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/color/addEditProps',\n\taddEditProps\n);\n\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/color/with-color-palette-styles',\n\twithColorPaletteStyles\n);\n\naddFilter(\n\t'blocks.switchToBlockType.transformedBlock',\n\t'core/color/addTransforms',\n\taddTransforms\n);\n"]}
|
|
@@ -94,7 +94,9 @@ export const withBlockControls = createHigherOrderComponent(BlockEdit => props =
|
|
|
94
94
|
return createElement(BlockEdit, props);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
const showStopEditingAsBlocks = isEditingAsBlocks && !isContentLocked;
|
|
98
|
+
const showStartEditingAsBlocks = !isEditingAsBlocks && isContentLocked && props.isSelected;
|
|
99
|
+
return createElement(Fragment, null, showStopEditingAsBlocks && createElement(Fragment, null, createElement(StopEditingAsBlocksOnOutsideSelect, {
|
|
98
100
|
clientId: props.clientId,
|
|
99
101
|
stopEditingAsBlock: stopEditingAsBlock
|
|
100
102
|
}), createElement(BlockControls, {
|
|
@@ -103,7 +105,7 @@ export const withBlockControls = createHigherOrderComponent(BlockEdit => props =
|
|
|
103
105
|
onClick: () => {
|
|
104
106
|
stopEditingAsBlock();
|
|
105
107
|
}
|
|
106
|
-
}, __('Done')))),
|
|
108
|
+
}, __('Done')))), showStartEditingAsBlocks && createElement(BlockSettingsMenuControls, null, _ref2 => {
|
|
107
109
|
let {
|
|
108
110
|
onClose
|
|
109
111
|
} = _ref2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/content-lock-ui.js"],"names":["ToolbarButton","MenuItem","createHigherOrderComponent","useDispatch","useSelect","addFilter","__","useEffect","useRef","useCallback","store","blockEditorStore","BlockControls","BlockSettingsMenuControls","classnames","StopEditingAsBlocksOnOutsideSelect","clientId","stopEditingAsBlock","isBlockOrDescendantSelected","select","isBlockSelected","hasSelectedInnerBlock","withBlockControls","BlockEdit","props","getBlockListSettings","getSettings","focusModeToRevert","templateLock","isLockedByParent","isEditingAsBlocks","__unstableGetContentLockingParent","getTemplateLock","__unstableGetTemporarilyEditingAsBlocks","updateSettings","updateBlockListSettings","__unstableSetTemporarilyEditingAsBlocks","isContentLocked","__unstableMarkNextChangeAsNotPersistent","updateBlockAttributes","focusMode","current","isSelected","onClose","undefined","className"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,aAAT,EAAwBC,QAAxB,QAAwC,uBAAxC;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,EAAoBC,MAApB,EAA4BC,WAA5B,QAA+C,oBAA/C;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,UAA1C;AACA,SAASC,aAAT,EAAwBC,yBAAxB,QAAyD,eAAzD;AACA;AACA;AACA;;AACA,OAAOC,UAAP,MAA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AO,EAAG,MAAM;AACfA,MAAAA,kBAAkB;AAClB;AAHF,KAKGX,EAAE,CAAE,MAAF,CALL,CADD,CALD,CAFF,EAkBG,CAAEwB,iBAAF,IAAuBO,eAAvB,IAA0Cb,KAAK,CAACkB,UAAhD,IACD,cAAC,yBAAD,QACG;AAAA,QAAE;AAAEC,MAAAA;AAAF,KAAF;AAAA,WACD,cAAC,QAAD;AACC,MAAA,OAAO,EAAG,MAAM;AACfL,QAAAA,uCAAuC;;AACvCC,QAAAA,qBAAqB,CAAEf,KAAK,CAACR,QAAR,EAAkB;AACtCY,UAAAA,YAAY,EAAEgB;AADwB,SAAlB,CAArB;AAGAT,QAAAA,uBAAuB,CAAEX,KAAK,CAACR,QAAR,EAAkB,EACxC,GAAGS,oBAAoB,CACtBD,KAAK,CAACR,QADgB,CADiB;AAIxCY,UAAAA,YAAY,EAAE;AAJ0B,SAAlB,CAAvB;AAMAD,QAAAA,iBAAiB,CAACc,OAAlB,GACCf,WAAW,GAAGc,SADf;AAEAN,QAAAA,cAAc,CAAE;AAAEM,UAAAA,SAAS,EAAE;AAAb,SAAF,CAAd;;AACAJ,QAAAA,uCAAuC,CACtCZ,KAAK,CAACR,QADgC,CAAvC;;AAGA2B,QAAAA,OAAO;AACP;AAnBF,OAqBGrC,EAAE,CAAE,QAAF,CArBL,CADC;AAAA,GADH,CAnBF,EA+CC,cAAC,SAAD,eACMkB,KADN;AAEC,IAAA,SAAS,EAAGV,UAAU,CACrBU,KAAK,CAACqB,SADe,EAErBf,iBAAiB,IAChB,qCAHoB;AAFvB,KA/CD,CADD;AA0DA,CAzHyD,EA0H1D,qBA1H0D,CAApD;AA6HPzB,SAAS,CACR,kBADQ,EAER,0CAFQ,EAGRiB,iBAHQ,CAAT","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ToolbarButton, MenuItem } from '@wordpress/components';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { addFilter } from '@wordpress/hooks';\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, useRef, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { BlockControls, BlockSettingsMenuControls } from '../components';\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\nfunction StopEditingAsBlocksOnOutsideSelect( {\n\tclientId,\n\tstopEditingAsBlock,\n} ) {\n\tconst isBlockOrDescendantSelected = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isBlockSelected, hasSelectedInnerBlock } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn (\n\t\t\t\tisBlockSelected( clientId ) ||\n\t\t\t\thasSelectedInnerBlock( clientId, true )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\tuseEffect( () => {\n\t\tif ( ! isBlockOrDescendantSelected ) {\n\t\t\tstopEditingAsBlock();\n\t\t}\n\t}, [ isBlockOrDescendantSelected ] );\n\treturn null;\n}\n\nexport const withBlockControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { getBlockListSettings, getSettings } =\n\t\t\tuseSelect( blockEditorStore );\n\t\tconst focusModeToRevert = useRef();\n\t\tconst { templateLock, isLockedByParent, isEditingAsBlocks } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\t__unstableGetContentLockingParent,\n\t\t\t\t\tgetTemplateLock,\n\t\t\t\t\t__unstableGetTemporarilyEditingAsBlocks,\n\t\t\t\t} = select( blockEditorStore );\n\t\t\t\treturn {\n\t\t\t\t\ttemplateLock: getTemplateLock( props.clientId ),\n\t\t\t\t\tisLockedByParent: !! __unstableGetContentLockingParent(\n\t\t\t\t\t\tprops.clientId\n\t\t\t\t\t),\n\t\t\t\t\tisEditingAsBlocks:\n\t\t\t\t\t\t__unstableGetTemporarilyEditingAsBlocks() ===\n\t\t\t\t\t\tprops.clientId,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ props.clientId ]\n\t\t);\n\n\t\tconst {\n\t\t\tupdateSettings,\n\t\t\tupdateBlockListSettings,\n\t\t\t__unstableSetTemporarilyEditingAsBlocks,\n\t\t} = useDispatch( blockEditorStore );\n\t\tconst isContentLocked =\n\t\t\t! isLockedByParent && templateLock === 'contentOnly';\n\t\tconst {\n\t\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\t\tupdateBlockAttributes,\n\t\t} = useDispatch( blockEditorStore );\n\n\t\tconst stopEditingAsBlock = useCallback( () => {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateBlockAttributes( props.clientId, {\n\t\t\t\ttemplateLock: 'contentOnly',\n\t\t\t} );\n\t\t\tupdateBlockListSettings( props.clientId, {\n\t\t\t\t...getBlockListSettings( props.clientId ),\n\t\t\t\ttemplateLock: 'contentOnly',\n\t\t\t} );\n\t\t\tupdateSettings( { focusMode: focusModeToRevert.current } );\n\t\t\t__unstableSetTemporarilyEditingAsBlocks();\n\t\t}, [\n\t\t\tprops.clientId,\n\t\t\tfocusModeToRevert,\n\t\t\tupdateSettings,\n\t\t\tupdateBlockListSettings,\n\t\t\tgetBlockListSettings,\n\t\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\t\tupdateBlockAttributes,\n\t\t\t__unstableSetTemporarilyEditingAsBlocks,\n\t\t] );\n\n\t\tif ( ! isContentLocked && ! isEditingAsBlocks ) {\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ isEditingAsBlocks && ! isContentLocked && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<StopEditingAsBlocksOnOutsideSelect\n\t\t\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\t\t\tstopEditingAsBlock={ stopEditingAsBlock }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tstopEditingAsBlock();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Done' ) }\n\t\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t\t</BlockControls>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t{ ! isEditingAsBlocks && isContentLocked && props.isSelected && (\n\t\t\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\t\t\t\t\tupdateBlockAttributes( props.clientId, {\n\t\t\t\t\t\t\t\t\t\ttemplateLock: undefined,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\tupdateBlockListSettings( props.clientId, {\n\t\t\t\t\t\t\t\t\t\t...getBlockListSettings(\n\t\t\t\t\t\t\t\t\t\t\tprops.clientId\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\ttemplateLock: false,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\tfocusModeToRevert.current =\n\t\t\t\t\t\t\t\t\t\tgetSettings().focusMode;\n\t\t\t\t\t\t\t\t\tupdateSettings( { focusMode: true } );\n\t\t\t\t\t\t\t\t\t__unstableSetTemporarilyEditingAsBlocks(\n\t\t\t\t\t\t\t\t\t\tprops.clientId\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Modify' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</BlockSettingsMenuControls>\n\t\t\t\t) }\n\t\t\t\t<BlockEdit\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\tprops.className,\n\t\t\t\t\t\tisEditingAsBlocks &&\n\t\t\t\t\t\t\t'is-content-locked-editing-as-blocks'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n\t'withToolbarControls'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/content-lock-ui/with-block-controls',\n\twithBlockControls\n);\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/content-lock-ui.js"],"names":["ToolbarButton","MenuItem","createHigherOrderComponent","useDispatch","useSelect","addFilter","__","useEffect","useRef","useCallback","store","blockEditorStore","BlockControls","BlockSettingsMenuControls","classnames","StopEditingAsBlocksOnOutsideSelect","clientId","stopEditingAsBlock","isBlockOrDescendantSelected","select","isBlockSelected","hasSelectedInnerBlock","withBlockControls","BlockEdit","props","getBlockListSettings","getSettings","focusModeToRevert","templateLock","isLockedByParent","isEditingAsBlocks","__unstableGetContentLockingParent","getTemplateLock","__unstableGetTemporarilyEditingAsBlocks","updateSettings","updateBlockListSettings","__unstableSetTemporarilyEditingAsBlocks","isContentLocked","__unstableMarkNextChangeAsNotPersistent","updateBlockAttributes","focusMode","current","showStopEditingAsBlocks","showStartEditingAsBlocks","isSelected","onClose","undefined","className"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,aAAT,EAAwBC,QAAxB,QAAwC,uBAAxC;AACA,SAASC,0BAAT,QAA2C,oBAA3C;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,EAAoBC,MAApB,EAA4BC,WAA5B,QAA+C,oBAA/C;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,UAA1C;AACA,SAASC,aAAT,EAAwBC,yBAAxB,QAAyD,eAAzD;AACA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,YAAvB;;AAEA,SAASC,kCA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kB,EAAGC;AAFtB,IADD,EAKC,cAAC,aAAD;AAAe,IAAA,KAAK,EAAC;AAArB,KACC,cAAC,aAAD;AACC,IAAA,OAAO,EAAG,MAAM;AACfA,MAAAA,kBAAkB;AAClB;AAHF,KAKGX,EAAE,CAAE,MAAF,CALL,CADD,CALD,CAFF,EAkBGqC,wBAAwB,IACzB,cAAC,yBAAD,QACG;AAAA,QAAE;AAAEE,MAAAA;AAAF,KAAF;AAAA,WACD,cAAC,QAAD;AACC,MAAA,OAAO,EAAG,MAAM;AACfP,QAAAA,uCAAuC;;AACvCC,QAAAA,qBAAqB,CAAEf,KAAK,CAACR,QAAR,EAAkB;AACtCY,UAAAA,YAAY,EAAEkB;AADwB,SAAlB,CAArB;AAGAX,QAAAA,uBAAuB,CAAEX,KAAK,CAACR,QAAR,EAAkB,EACxC,GAAGS,oBAAoB,CACtBD,KAAK,CAACR,QADgB,CADiB;AAIxCY,UAAAA,YAAY,EAAE;AAJ0B,SAAlB,CAAvB;AAMAD,QAAAA,iBAAiB,CAACc,OAAlB,GACCf,WAAW,GAAGc,SADf;AAEAN,QAAAA,cAAc,CAAE;AAAEM,UAAAA,SAAS,EAAE;AAAb,SAAF,CAAd;;AACAJ,QAAAA,uCAAuC,CACtCZ,KAAK,CAACR,QADgC,CAAvC;;AAGA6B,QAAAA,OAAO;AACP;AAnBF,OAqBGvC,EAAE,CAAE,QAAF,CArBL,CADC;AAAA,GADH,CAnBF,EA+CC,cAAC,SAAD,eACMkB,KADN;AAEC,IAAA,SAAS,EAAGV,UAAU,CACrBU,KAAK,CAACuB,SADe,EAErBjB,iBAAiB,IAChB,qCAHoB;AAFvB,KA/CD,CADD;AA0DA,CA7HyD,EA8H1D,qBA9H0D,CAApD;AAiIPzB,SAAS,CACR,kBADQ,EAER,0CAFQ,EAGRiB,iBAHQ,CAAT","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ToolbarButton, MenuItem } from '@wordpress/components';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { addFilter } from '@wordpress/hooks';\nimport { __ } from '@wordpress/i18n';\nimport { useEffect, useRef, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { BlockControls, BlockSettingsMenuControls } from '../components';\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\nfunction StopEditingAsBlocksOnOutsideSelect( {\n\tclientId,\n\tstopEditingAsBlock,\n} ) {\n\tconst isBlockOrDescendantSelected = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isBlockSelected, hasSelectedInnerBlock } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn (\n\t\t\t\tisBlockSelected( clientId ) ||\n\t\t\t\thasSelectedInnerBlock( clientId, true )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\tuseEffect( () => {\n\t\tif ( ! isBlockOrDescendantSelected ) {\n\t\t\tstopEditingAsBlock();\n\t\t}\n\t}, [ isBlockOrDescendantSelected ] );\n\treturn null;\n}\n\nexport const withBlockControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { getBlockListSettings, getSettings } =\n\t\t\tuseSelect( blockEditorStore );\n\t\tconst focusModeToRevert = useRef();\n\t\tconst { templateLock, isLockedByParent, isEditingAsBlocks } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\t__unstableGetContentLockingParent,\n\t\t\t\t\tgetTemplateLock,\n\t\t\t\t\t__unstableGetTemporarilyEditingAsBlocks,\n\t\t\t\t} = select( blockEditorStore );\n\t\t\t\treturn {\n\t\t\t\t\ttemplateLock: getTemplateLock( props.clientId ),\n\t\t\t\t\tisLockedByParent: !! __unstableGetContentLockingParent(\n\t\t\t\t\t\tprops.clientId\n\t\t\t\t\t),\n\t\t\t\t\tisEditingAsBlocks:\n\t\t\t\t\t\t__unstableGetTemporarilyEditingAsBlocks() ===\n\t\t\t\t\t\tprops.clientId,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ props.clientId ]\n\t\t);\n\n\t\tconst {\n\t\t\tupdateSettings,\n\t\t\tupdateBlockListSettings,\n\t\t\t__unstableSetTemporarilyEditingAsBlocks,\n\t\t} = useDispatch( blockEditorStore );\n\t\tconst isContentLocked =\n\t\t\t! isLockedByParent && templateLock === 'contentOnly';\n\t\tconst {\n\t\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\t\tupdateBlockAttributes,\n\t\t} = useDispatch( blockEditorStore );\n\n\t\tconst stopEditingAsBlock = useCallback( () => {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateBlockAttributes( props.clientId, {\n\t\t\t\ttemplateLock: 'contentOnly',\n\t\t\t} );\n\t\t\tupdateBlockListSettings( props.clientId, {\n\t\t\t\t...getBlockListSettings( props.clientId ),\n\t\t\t\ttemplateLock: 'contentOnly',\n\t\t\t} );\n\t\t\tupdateSettings( { focusMode: focusModeToRevert.current } );\n\t\t\t__unstableSetTemporarilyEditingAsBlocks();\n\t\t}, [\n\t\t\tprops.clientId,\n\t\t\tfocusModeToRevert,\n\t\t\tupdateSettings,\n\t\t\tupdateBlockListSettings,\n\t\t\tgetBlockListSettings,\n\t\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\t\tupdateBlockAttributes,\n\t\t\t__unstableSetTemporarilyEditingAsBlocks,\n\t\t] );\n\n\t\tif ( ! isContentLocked && ! isEditingAsBlocks ) {\n\t\t\treturn <BlockEdit { ...props } />;\n\t\t}\n\n\t\tconst showStopEditingAsBlocks = isEditingAsBlocks && ! isContentLocked;\n\t\tconst showStartEditingAsBlocks =\n\t\t\t! isEditingAsBlocks && isContentLocked && props.isSelected;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ showStopEditingAsBlocks && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<StopEditingAsBlocksOnOutsideSelect\n\t\t\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\t\t\tstopEditingAsBlock={ stopEditingAsBlock }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tstopEditingAsBlock();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Done' ) }\n\t\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t\t</BlockControls>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t{ showStartEditingAsBlocks && (\n\t\t\t\t\t<BlockSettingsMenuControls>\n\t\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\t\t\t\t\tupdateBlockAttributes( props.clientId, {\n\t\t\t\t\t\t\t\t\t\ttemplateLock: undefined,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\tupdateBlockListSettings( props.clientId, {\n\t\t\t\t\t\t\t\t\t\t...getBlockListSettings(\n\t\t\t\t\t\t\t\t\t\t\tprops.clientId\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\ttemplateLock: false,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\tfocusModeToRevert.current =\n\t\t\t\t\t\t\t\t\t\tgetSettings().focusMode;\n\t\t\t\t\t\t\t\t\tupdateSettings( { focusMode: true } );\n\t\t\t\t\t\t\t\t\t__unstableSetTemporarilyEditingAsBlocks(\n\t\t\t\t\t\t\t\t\t\tprops.clientId\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Modify' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</BlockSettingsMenuControls>\n\t\t\t\t) }\n\t\t\t\t<BlockEdit\n\t\t\t\t\t{ ...props }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\tprops.className,\n\t\t\t\t\t\tisEditingAsBlocks &&\n\t\t\t\t\t\t\t'is-content-locked-editing-as-blocks'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n\t'withToolbarControls'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/content-lock-ui/with-block-controls',\n\twithBlockControls\n);\n"]}
|