@wordpress/block-editor 8.0.2 → 8.0.6
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/colors/with-colors.js +6 -4
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/colors-gradients/control.js +4 -2
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +29 -25
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- 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/color.js +29 -21
- 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 +13 -4
- 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/colors/with-colors.js +6 -4
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +4 -2
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +30 -26
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/gradients/use-gradient.js +8 -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/color.js +30 -22
- 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 +11 -3
- 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 +72 -68
- package/build-style/style.css +72 -68
- package/package.json +3 -3
- package/src/components/block-list-appender/style.scss +0 -42
- package/src/components/block-preview/auto.js +3 -0
- package/src/components/block-preview/style.scss +5 -0
- package/src/components/button-block-appender/style.scss +0 -17
- package/src/components/colors/with-colors.js +11 -5
- package/src/components/colors-gradients/control.js +2 -0
- package/src/components/colors-gradients/panel-color-gradient-settings.js +58 -25
- package/src/components/default-block-appender/style.scss +90 -16
- package/src/components/gradients/use-gradient.js +16 -7
- package/src/components/inner-blocks/style.scss +4 -10
- package/src/components/use-setting/index.js +2 -2
- package/src/hooks/color.js +58 -26
- package/src/hooks/typography.js +1 -1
- package/src/hooks/use-color-props.js +23 -4
- package/src/store/selectors.js +14 -26
package/build/hooks/color.js
CHANGED
|
@@ -50,7 +50,6 @@ var _useSetting = _interopRequireDefault(require("../components/use-setting"));
|
|
|
50
50
|
*/
|
|
51
51
|
const COLOR_SUPPORT_KEY = 'color';
|
|
52
52
|
exports.COLOR_SUPPORT_KEY = COLOR_SUPPORT_KEY;
|
|
53
|
-
const EMPTY_ARRAY = [];
|
|
54
53
|
|
|
55
54
|
const hasColorSupport = blockType => {
|
|
56
55
|
const colorSupport = (0, _blocks.getBlockSupport)(blockType, COLOR_SUPPORT_KEY);
|
|
@@ -219,19 +218,25 @@ function immutableSet(object, path, value) {
|
|
|
219
218
|
|
|
220
219
|
|
|
221
220
|
function ColorEdit(props) {
|
|
222
|
-
var _style$color6, _style$color7, _style$color8, _style$elements2, _style$elements2$link, _style$elements2$link2, _style$elements3, _style$elements3$link, _style$elements3$link2;
|
|
221
|
+
var _solidsPerOrigin$them, _gradientsPerOrigin$t, _style$color6, _style$color7, _style$color8, _style$elements2, _style$elements2$link, _style$elements2$link2, _style$elements3, _style$elements3$link, _style$elements3$link2;
|
|
223
222
|
|
|
224
223
|
const {
|
|
225
224
|
name: blockName,
|
|
226
225
|
attributes
|
|
227
226
|
} = props;
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
227
|
+
const {
|
|
228
|
+
palette: solidsPerOrigin,
|
|
229
|
+
gradients: gradientsPerOrigin,
|
|
230
|
+
customGradient: areCustomGradientsEnabled,
|
|
231
|
+
custom: areCustomSolidsEnabled,
|
|
232
|
+
text: isTextEnabled,
|
|
233
|
+
background: isBackgroundEnabled,
|
|
234
|
+
link: isLinkEnabled
|
|
235
|
+
} = (0, _useSetting.default)('color') || {};
|
|
236
|
+
const solidsEnabled = areCustomSolidsEnabled || !(solidsPerOrigin !== null && solidsPerOrigin !== void 0 && solidsPerOrigin.theme) || (solidsPerOrigin === null || solidsPerOrigin === void 0 ? void 0 : (_solidsPerOrigin$them = solidsPerOrigin.theme) === null || _solidsPerOrigin$them === void 0 ? void 0 : _solidsPerOrigin$them.length) > 0;
|
|
237
|
+
const gradientsEnabled = areCustomGradientsEnabled || !(gradientsPerOrigin !== null && gradientsPerOrigin !== void 0 && gradientsPerOrigin.theme) || (gradientsPerOrigin === null || gradientsPerOrigin === void 0 ? void 0 : (_gradientsPerOrigin$t = gradientsPerOrigin.theme) === null || _gradientsPerOrigin$t === void 0 ? void 0 : _gradientsPerOrigin$t.length) > 0;
|
|
238
|
+
const allSolids = (0, _element.useMemo)(() => [...((solidsPerOrigin === null || solidsPerOrigin === void 0 ? void 0 : solidsPerOrigin.custom) || []), ...((solidsPerOrigin === null || solidsPerOrigin === void 0 ? void 0 : solidsPerOrigin.theme) || []), ...((solidsPerOrigin === null || solidsPerOrigin === void 0 ? void 0 : solidsPerOrigin.default) || [])], [solidsPerOrigin]);
|
|
239
|
+
const allGradients = (0, _element.useMemo)(() => [...((gradientsPerOrigin === null || gradientsPerOrigin === void 0 ? void 0 : gradientsPerOrigin.custom) || []), ...((gradientsPerOrigin === null || gradientsPerOrigin === void 0 ? void 0 : gradientsPerOrigin.theme) || []), ...((gradientsPerOrigin === null || gradientsPerOrigin === void 0 ? void 0 : gradientsPerOrigin.default) || [])], [gradientsPerOrigin]); // Shouldn't be needed but right now the ColorGradientsPanel
|
|
235
240
|
// can trigger both onChangeColor and onChangeBackground
|
|
236
241
|
// synchronously causing our two callbacks to override changes
|
|
237
242
|
// from each other.
|
|
@@ -245,10 +250,10 @@ function ColorEdit(props) {
|
|
|
245
250
|
return null;
|
|
246
251
|
}
|
|
247
252
|
|
|
248
|
-
const hasLinkColor = hasLinkColorSupport(blockName) && isLinkEnabled &&
|
|
249
|
-
const hasTextColor = hasTextColorSupport(blockName) && isTextEnabled &&
|
|
250
|
-
const hasBackgroundColor = hasBackgroundColorSupport(blockName) && isBackgroundEnabled &&
|
|
251
|
-
const hasGradientColor = hasGradientSupport(blockName) &&
|
|
253
|
+
const hasLinkColor = hasLinkColorSupport(blockName) && isLinkEnabled && solidsEnabled;
|
|
254
|
+
const hasTextColor = hasTextColorSupport(blockName) && isTextEnabled && solidsEnabled;
|
|
255
|
+
const hasBackgroundColor = hasBackgroundColorSupport(blockName) && isBackgroundEnabled && solidsEnabled;
|
|
256
|
+
const hasGradientColor = hasGradientSupport(blockName) && gradientsEnabled;
|
|
252
257
|
|
|
253
258
|
if (!hasLinkColor && !hasTextColor && !hasBackgroundColor && !hasGradientColor) {
|
|
254
259
|
return null;
|
|
@@ -263,7 +268,7 @@ function ColorEdit(props) {
|
|
|
263
268
|
let gradientValue;
|
|
264
269
|
|
|
265
270
|
if (hasGradientColor && gradient) {
|
|
266
|
-
gradientValue = (0, _gradients.getGradientValueBySlug)(
|
|
271
|
+
gradientValue = (0, _gradients.getGradientValueBySlug)(allGradients, gradient);
|
|
267
272
|
} else if (hasGradientColor) {
|
|
268
273
|
var _style$color5;
|
|
269
274
|
|
|
@@ -273,7 +278,7 @@ function ColorEdit(props) {
|
|
|
273
278
|
const onChangeColor = name => value => {
|
|
274
279
|
var _localAttributes$curr, _localAttributes$curr2;
|
|
275
280
|
|
|
276
|
-
const colorObject = (0, _colors.getColorObjectByColorValue)(
|
|
281
|
+
const colorObject = (0, _colors.getColorObjectByColorValue)(allSolids, value);
|
|
277
282
|
const attributeName = name + 'Color';
|
|
278
283
|
const newStyle = { ...localAttributes.current.style,
|
|
279
284
|
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),
|
|
@@ -292,7 +297,7 @@ function ColorEdit(props) {
|
|
|
292
297
|
};
|
|
293
298
|
|
|
294
299
|
const onChangeGradient = value => {
|
|
295
|
-
const slug = (0, _gradients.getGradientSlugByValue)(
|
|
300
|
+
const slug = (0, _gradients.getGradientSlugByValue)(allGradients, value);
|
|
296
301
|
let newAttributes;
|
|
297
302
|
|
|
298
303
|
if (slug) {
|
|
@@ -328,7 +333,7 @@ function ColorEdit(props) {
|
|
|
328
333
|
};
|
|
329
334
|
|
|
330
335
|
const onChangeLinkColor = value => {
|
|
331
|
-
const colorObject = (0, _colors.getColorObjectByColorValue)(
|
|
336
|
+
const colorObject = (0, _colors.getColorObjectByColorValue)(allSolids, value);
|
|
332
337
|
const newLinkColorValue = colorObject !== null && colorObject !== void 0 && colorObject.slug ? `var:preset|color|${colorObject.slug}` : value;
|
|
333
338
|
const newStyle = (0, _utils.cleanEmptyObject)(immutableSet(style, ['elements', 'link', 'color', 'text'], newLinkColorValue));
|
|
334
339
|
props.setAttributes({
|
|
@@ -343,17 +348,17 @@ function ColorEdit(props) {
|
|
|
343
348
|
settings: [...(hasTextColor ? [{
|
|
344
349
|
label: (0, _i18n.__)('Text color'),
|
|
345
350
|
onColorChange: onChangeColor('text'),
|
|
346
|
-
colorValue: (0, _colors.getColorObjectByAttributeValues)(
|
|
351
|
+
colorValue: (0, _colors.getColorObjectByAttributeValues)(allSolids, textColor, style === null || style === void 0 ? void 0 : (_style$color7 = style.color) === null || _style$color7 === void 0 ? void 0 : _style$color7.text).color
|
|
347
352
|
}] : []), ...(hasBackgroundColor || hasGradientColor ? [{
|
|
348
353
|
label: (0, _i18n.__)('Background color'),
|
|
349
354
|
onColorChange: hasBackgroundColor ? onChangeColor('background') : undefined,
|
|
350
|
-
colorValue: (0, _colors.getColorObjectByAttributeValues)(
|
|
355
|
+
colorValue: (0, _colors.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,
|
|
351
356
|
gradientValue,
|
|
352
357
|
onGradientChange: hasGradientColor ? onChangeGradient : undefined
|
|
353
358
|
}] : []), ...(hasLinkColor ? [{
|
|
354
359
|
label: (0, _i18n.__)('Link Color'),
|
|
355
360
|
onColorChange: onChangeLinkColor,
|
|
356
|
-
colorValue: getLinkColorFromAttributeValue(
|
|
361
|
+
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),
|
|
357
362
|
clearable: !!(style !== null && style !== void 0 && (_style$elements3 = style.elements) !== null && _style$elements3 !== void 0 && (_style$elements3$link = _style$elements3.link) !== null && _style$elements3$link !== void 0 && (_style$elements3$link2 = _style$elements3$link.color) !== null && _style$elements3$link2 !== void 0 && _style$elements3$link2.text)
|
|
358
363
|
}] : [])]
|
|
359
364
|
});
|
|
@@ -379,7 +384,10 @@ const withColorPaletteStyles = (0, _compose.createHigherOrderComponent)(BlockLis
|
|
|
379
384
|
backgroundColor,
|
|
380
385
|
textColor
|
|
381
386
|
} = attributes;
|
|
382
|
-
const
|
|
387
|
+
const {
|
|
388
|
+
palette: solidsPerOrigin
|
|
389
|
+
} = (0, _useSetting.default)('color') || {};
|
|
390
|
+
const colors = (0, _element.useMemo)(() => [...((solidsPerOrigin === null || solidsPerOrigin === void 0 ? void 0 : solidsPerOrigin.custom) || []), ...((solidsPerOrigin === null || solidsPerOrigin === void 0 ? void 0 : solidsPerOrigin.theme) || []), ...((solidsPerOrigin === null || solidsPerOrigin === void 0 ? void 0 : solidsPerOrigin.default) || [])], [solidsPerOrigin]);
|
|
383
391
|
|
|
384
392
|
if (!hasColorSupport(name) || shouldSkipSerialization(name)) {
|
|
385
393
|
return (0, _element.createElement)(BlockListBlock, props);
|
package/build/hooks/color.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/color.js"],"names":["COLOR_SUPPORT_KEY","EMPTY_ARRAY","hasColorSupport","blockType","colorSupport","link","gradient","background","text","shouldSkipSerialization","__experimentalSkipSerialization","hasLinkColorSupport","Platform","OS","hasGradientSupport","gradients","hasBackgroundColorSupport","hasTextColorSupport","addAttributes","settings","attributes","backgroundColor","Object","assign","type","textColor","addSaveProps","props","hasGradient","style","backgroundClass","gradientClass","textClass","newClassName","className","color","elements","undefined","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","getLinkColorFromAttributeValue","colors","value","attributeParsed","exec","immutableSet","object","path","clone","ColorEdit","name","blockName","solids","areCustomSolidsEnabled","areCustomGradientsEnabled","isLinkEnabled","isTextEnabled","isBackgroundEnabled","localAttributes","current","hasLinkColor","length","hasTextColor","hasBackgroundColor","hasGradientColor","gradientValue","onChangeColor","colorObject","attributeName","newStyle","slug","newNamedColor","newAttributes","setAttributes","onChangeGradient","onChangeLinkColor","newLinkColorValue","clientId","label","onColorChange","colorValue","onGradientChange","clearable","withColorPaletteStyles","BlockListBlock","extraStyles","wrapperProps"],"mappings":";;;;;;;;;;;;;AAYA;;;;AATA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AAKA;;AAKA;;AAKA;;AACA;;AACA;;AA9BA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;AAeO,MAAMA,iB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AAAA,eAAe,EAAEA,eAAe,6BAC7B,6CAAiCqB,MAAjC,EAAyCrB,eAAzC,CAD6B,2DAC7B,uBACEc,KAF2B,GAG7BE;AAPgB,GAApB;AAUA,MAAIkD,YAAY,GAAG5D,KAAK,CAAC4D,YAAzB;AACAA,EAAAA,YAAY,GAAG,EACd,GAAG5D,KAAK,CAAC4D,YADK;AAEd1D,IAAAA,KAAK,EAAE,EACN,GAAGyD,WADG;AAEN,iCAAG3D,KAAK,CAAC4D,YAAT,wDAAG,oBAAoB1D,KAAvB;AAFM;AAFO,GAAf;AAQA,SAAO,4BAAC,cAAD,6BAAqBF,KAArB;AAA6B,IAAA,YAAY,EAAG4D;AAA5C,KAAP;AACA,CA7BoC,CAA/B;;AAgCP,sBACC,0BADD,EAEC,yBAFD,EAGCrE,aAHD;AAMA,sBACC,kCADD,EAEC,yBAFD,EAGCQ,YAHD;AAMA,sBACC,0BADD,EAEC,yBAFD,EAGCY,YAHD;AAMA,sBACC,uBADD,EAEC,sCAFD,EAGC8C,sBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { isObject, setWith, clone } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useEffect, 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 { cleanEmptyObject } from './utils';\nimport ColorPanel from './color-panel';\nimport useSetting from '../components/use-setting';\n\nexport const COLOR_SUPPORT_KEY = 'color';\nconst EMPTY_ARRAY = [];\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 shouldSkipSerialization = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport?.__experimentalSkipSerialization;\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 isObject( colorSupport ) && !! colorSupport.link;\n};\n\nconst hasGradientSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn isObject( colorSupport ) && !! colorSupport.gradients;\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 )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst hasGradient = hasGradientSupport( blockType );\n\n\t// I'd have prefered to avoid the \"style\" attribute usage here\n\tconst { backgroundColor, textColor, gradient, style } = attributes;\n\n\tconst backgroundClass = getColorClassName(\n\t\t'background-color',\n\t\tbackgroundColor\n\t);\n\tconst gradientClass = __experimentalGetGradientClass( gradient );\n\tconst textClass = getColorClassName( 'color', textColor );\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': textColor || style?.color?.text,\n\t\t\t'has-background':\n\t\t\t\tbackgroundColor ||\n\t\t\t\tstyle?.color?.background ||\n\t\t\t\t( hasGradient && ( gradient || style?.color?.gradient ) ),\n\t\t\t'has-link-color': 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 extand 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 )\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\nfunction immutableSet( object, path, value ) {\n\treturn setWith( object ? clone( object ) : {}, path, value, clone );\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\tconst solids = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\tconst gradients = useSetting( 'color.gradients' ) || EMPTY_ARRAY;\n\tconst areCustomSolidsEnabled = useSetting( 'color.custom' );\n\tconst areCustomGradientsEnabled = useSetting( 'color.customGradient' );\n\tconst isLinkEnabled = useSetting( 'color.link' );\n\tconst isTextEnabled = useSetting( 'color.text' );\n\tconst isBackgroundEnabled = useSetting( 'color.background' );\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 ) &&\n\t\tisLinkEnabled &&\n\t\t( solids.length > 0 || areCustomSolidsEnabled );\n\tconst hasTextColor =\n\t\thasTextColorSupport( blockName ) &&\n\t\tisTextEnabled &&\n\t\t( solids.length > 0 || areCustomSolidsEnabled );\n\tconst hasBackgroundColor =\n\t\thasBackgroundColorSupport( blockName ) &&\n\t\tisBackgroundEnabled &&\n\t\t( solids.length > 0 || areCustomSolidsEnabled );\n\tconst hasGradientColor =\n\t\thasGradientSupport( blockName ) &&\n\t\t( gradients.length > 0 || areCustomGradientsEnabled );\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( gradients, 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( solids, 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( gradients, 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( solids, 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\tstyle,\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};\n\n\treturn (\n\t\t<ColorPanel\n\t\t\tenableContrastChecking={\n\t\t\t\t// Turn on contrast checker for web only since it's not supported on mobile yet.\n\t\t\t\tPlatform.OS === 'web' && ! gradient && ! style?.color?.gradient\n\t\t\t}\n\t\t\tclientId={ props.clientId }\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 color' ),\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\tsolids,\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},\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 color' ),\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\tsolids,\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},\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 Color' ),\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\tsolids,\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\tclearable: !! style?.elements?.link?.color\n\t\t\t\t\t\t\t\t\t?.text,\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 colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\t\tif ( ! hasColorSupport( name ) || shouldSkipSerialization( name ) ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst extraStyles = {\n\t\t\tcolor: textColor\n\t\t\t\t? getColorObjectByAttributeValues( colors, textColor )?.color\n\t\t\t\t: undefined,\n\t\t\tbackgroundColor: backgroundColor\n\t\t\t\t? getColorObjectByAttributeValues( colors, backgroundColor )\n\t\t\t\t\t\t?.color\n\t\t\t\t: undefined,\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\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"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/color.js"],"names":["COLOR_SUPPORT_KEY","hasColorSupport","blockType","colorSupport","link","gradient","background","text","shouldSkipSerialization","__experimentalSkipSerialization","hasLinkColorSupport","Platform","OS","hasGradientSupport","gradients","hasBackgroundColorSupport","hasTextColorSupport","addAttributes","settings","attributes","backgroundColor","Object","assign","type","textColor","addSaveProps","props","hasGradient","style","backgroundClass","gradientClass","textClass","newClassName","className","color","elements","undefined","addEditProps","existingGetEditWrapperProps","getEditWrapperProps","getLinkColorFromAttributeValue","colors","value","attributeParsed","exec","immutableSet","object","path","clone","ColorEdit","name","blockName","palette","solidsPerOrigin","gradientsPerOrigin","customGradient","areCustomGradientsEnabled","custom","areCustomSolidsEnabled","isTextEnabled","isBackgroundEnabled","isLinkEnabled","solidsEnabled","theme","length","gradientsEnabled","allSolids","default","allGradients","localAttributes","current","hasLinkColor","hasTextColor","hasBackgroundColor","hasGradientColor","gradientValue","onChangeColor","colorObject","attributeName","newStyle","slug","newNamedColor","newAttributes","setAttributes","onChangeGradient","onChangeLinkColor","newLinkColorValue","clientId","label","onColorChange","colorValue","onGradientChange","clearable","withColorPaletteStyles","BlockListBlock","extraStyles","wrapperProps"],"mappings":";;;;;;;;;;;;;AAYA;;;;AATA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AAKA;;AAKA;;AAKA;;AACA;;AACA;;AA9BA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;AAeO,MAAMA,iBAAiB,GAAG,OAA1B;;;AAEP,MAAMC,eAAe,GAAKC,SAAF,IAAiB;AACxC,QAAMC,YAAY,GAAG,6BAAiBD,SAAjB,EAA4BF,iBAA5B,CAArB;AACA,SACCG,YAAY,KACVA,YAAY,CAACC,IAAb,KAAsB,IAAtB,IACDD,YAAY,CAACE,QAAb,KAA0B,IADzB,IAEDF,YAAY,CAACG,UAAb,KAA4B,KAF3B,IAGDH,YAAY,CAACI,IAAb,KAAsB,KAJX,CADb;AAOA,CATD;;AAWA,MAAMC,uBAAuB,GAAKN,SAAF,IAAiB;AAChD,QAAMC,YAAY,GAAG,6BAAiBD,SAAjB,EAA4BF,iBAA5B,CAArB;AAEA,SAAOG,YAAP,aAAOA,YAAP,uBAAOA,YAAY,CAAEM,+BAArB;AACA,CAJD;;AAMA,MAAMC,mBAAmB,GAAKR,SAAF,IAAiB;AAC5C,MAAKS,kBAASC,EAAT,KAAgB,KAArB,EAA6B;AAC5B,WAA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,kCADD,EAEC,yBAFD,EAGCQ,YAHD;AAMA,sBACC,0BADD,EAEC,yBAFD,EAGCY,YAHD;AAMA,sBACC,uBADD,EAEC,sCAFD,EAGCwD,sBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { isObject, setWith, clone } from 'lodash';\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 { cleanEmptyObject } 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 shouldSkipSerialization = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn colorSupport?.__experimentalSkipSerialization;\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 isObject( colorSupport ) && !! colorSupport.link;\n};\n\nconst hasGradientSupport = ( blockType ) => {\n\tconst colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );\n\n\treturn isObject( colorSupport ) && !! colorSupport.gradients;\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 )\n\t) {\n\t\treturn props;\n\t}\n\n\tconst hasGradient = hasGradientSupport( blockType );\n\n\t// I'd have prefered to avoid the \"style\" attribute usage here\n\tconst { backgroundColor, textColor, gradient, style } = attributes;\n\n\tconst backgroundClass = getColorClassName(\n\t\t'background-color',\n\t\tbackgroundColor\n\t);\n\tconst gradientClass = __experimentalGetGradientClass( gradient );\n\tconst textClass = getColorClassName( 'color', textColor );\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': textColor || style?.color?.text,\n\t\t\t'has-background':\n\t\t\t\tbackgroundColor ||\n\t\t\t\tstyle?.color?.background ||\n\t\t\t\t( hasGradient && ( gradient || style?.color?.gradient ) ),\n\t\t\t'has-link-color': 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 extand 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 )\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\nfunction immutableSet( object, path, value ) {\n\treturn setWith( object ? clone( object ) : {}, path, value, clone );\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\tconst {\n\t\tpalette: solidsPerOrigin,\n\t\tgradients: gradientsPerOrigin,\n\t\tcustomGradient: areCustomGradientsEnabled,\n\t\tcustom: areCustomSolidsEnabled,\n\t\ttext: isTextEnabled,\n\t\tbackground: isBackgroundEnabled,\n\t\tlink: isLinkEnabled,\n\t} = useSetting( 'color' ) || {};\n\n\tconst solidsEnabled =\n\t\tareCustomSolidsEnabled ||\n\t\t! solidsPerOrigin?.theme ||\n\t\tsolidsPerOrigin?.theme?.length > 0;\n\n\tconst gradientsEnabled =\n\t\tareCustomGradientsEnabled ||\n\t\t! gradientsPerOrigin?.theme ||\n\t\tgradientsPerOrigin?.theme?.length > 0;\n\n\tconst allSolids = useMemo(\n\t\t() => [\n\t\t\t...( solidsPerOrigin?.custom || [] ),\n\t\t\t...( solidsPerOrigin?.theme || [] ),\n\t\t\t...( solidsPerOrigin?.default || [] ),\n\t\t],\n\t\t[ solidsPerOrigin ]\n\t);\n\n\tconst allGradients = useMemo(\n\t\t() => [\n\t\t\t...( gradientsPerOrigin?.custom || [] ),\n\t\t\t...( gradientsPerOrigin?.theme || [] ),\n\t\t\t...( gradientsPerOrigin?.default || [] ),\n\t\t],\n\t\t[ gradientsPerOrigin ]\n\t);\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\tstyle,\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};\n\n\treturn (\n\t\t<ColorPanel\n\t\t\tenableContrastChecking={\n\t\t\t\t// Turn on contrast checker for web only since it's not supported on mobile yet.\n\t\t\t\tPlatform.OS === 'web' && ! gradient && ! style?.color?.gradient\n\t\t\t}\n\t\t\tclientId={ props.clientId }\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 color' ),\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},\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 color' ),\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},\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 Color' ),\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\tclearable: !! style?.elements?.link?.color\n\t\t\t\t\t\t\t\t\t?.text,\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 { palette: solidsPerOrigin } = useSetting( 'color' ) || {};\n\t\tconst colors = useMemo(\n\t\t\t() => [\n\t\t\t\t...( solidsPerOrigin?.custom || [] ),\n\t\t\t\t...( solidsPerOrigin?.theme || [] ),\n\t\t\t\t...( solidsPerOrigin?.default || [] ),\n\t\t\t],\n\t\t\t[ solidsPerOrigin ]\n\t\t);\n\t\tif ( ! hasColorSupport( name ) || shouldSkipSerialization( name ) ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst extraStyles = {\n\t\t\tcolor: textColor\n\t\t\t\t? getColorObjectByAttributeValues( colors, textColor )?.color\n\t\t\t\t: undefined,\n\t\t\tbackgroundColor: backgroundColor\n\t\t\t\t? getColorObjectByAttributeValues( colors, backgroundColor )\n\t\t\t\t\t\t?.color\n\t\t\t\t: undefined,\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\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"]}
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.TYPOGRAPHY_SUPPORT_KEYS = exports.TYPOGRAPHY_SUPPORT_KEY = void 0;
|
|
9
9
|
exports.TypographyPanel = TypographyPanel;
|
|
10
|
+
exports.hasTypographySupport = void 0;
|
|
10
11
|
|
|
11
12
|
var _element = require("@wordpress/element");
|
|
12
13
|
|
|
@@ -163,6 +164,8 @@ const hasTypographySupport = blockName => {
|
|
|
163
164
|
return TYPOGRAPHY_SUPPORT_KEYS.some(key => (0, _blocks.hasBlockSupport)(blockName, key));
|
|
164
165
|
};
|
|
165
166
|
|
|
167
|
+
exports.hasTypographySupport = hasTypographySupport;
|
|
168
|
+
|
|
166
169
|
function useIsTypographyDisabled() {
|
|
167
170
|
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
168
171
|
const configs = [(0, _fontAppearance.useIsFontAppearanceDisabled)(props), (0, _fontSize.useIsFontSizeDisabled)(props), (0, _lineHeight.useIsLineHeightDisabled)(props), (0, _fontFamily.useIsFontFamilyDisabled)(props), (0, _textDecoration.useIsTextDecorationDisabled)(props), (0, _textTransform.useIsTextTransformDisabled)(props), (0, _letterSpacing.useIsLetterSpacingDisabled)(props)];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/typography.js"],"names":["TYPOGRAPHY_SUPPORT_KEY","TYPOGRAPHY_SUPPORT_KEYS","LINE_HEIGHT_SUPPORT_KEY","FONT_SIZE_SUPPORT_KEY","FONT_STYLE_SUPPORT_KEY","FONT_WEIGHT_SUPPORT_KEY","FONT_FAMILY_SUPPORT_KEY","TEXT_DECORATION_SUPPORT_KEY","TEXT_TRANSFORM_SUPPORT_KEY","LETTER_SPACING_SUPPORT_KEY","TypographyPanel","props","clientId","isFontFamilyDisabled","isFontSizeDisabled","isFontAppearanceDisabled","isLineHeightDisabled","isTextDecorationDisabled","isTextTransformDisabled","isLetterSpacingDisabled","hasFontStyles","hasFontWeights","isDisabled","useIsTypographyDisabled","isSupported","hasTypographySupport","name","defaultControls","createResetAllFilter","attribute","newAttributes","style","typography","undefined","fontFamily","fontSize","fontAppearance","fontStyle","fontWeight","lineHeight","textDecoration","textTransform","letterSpacing","blockName","some","key","configs","filter","Boolean","length"],"mappings":";;;;;;;;;;;;AAGA;;AACA;;AACA;;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AAc,EAAGd,oBAAoB,CAAE,eAAF,CANtC;AAOC,IAAA,OAAO,EAAGhB;AAPX,KASC,4BAAC,gCAAD,EAAwBD,KAAxB,CATD,CAxGF,CADD;AAuHA;;AAED,MAAMc,oBAAoB,GAAKkB,SAAF,IAAiB;AAC7C,SAAO1C,uBAAuB,CAAC2C,IAAxB,CAAgCC,GAAF,IACpC,6BAAiBF,SAAjB,EAA4BE,GAA5B,CADM,CAAP;AAGA,CAJD;;AAMA,SAAStB,uBAAT,GAA+C;AAAA,MAAbZ,KAAa,uEAAL,EAAK;AAC9C,QAAMmC,OAAO,GAAG,CACf,iDAA6BnC,KAA7B,CADe,EAEf,qCAAuBA,KAAvB,CAFe,EAGf,yCAAyBA,KAAzB,CAHe,EAIf,yCAAyBA,KAAzB,CAJe,EAKf,iDAA6BA,KAA7B,CALe,EAMf,+CAA4BA,KAA5B,CANe,EAOf,+CAA4BA,KAA5B,CAPe,CAAhB;AAUA,SAAOmC,OAAO,CAACC,MAAR,CAAgBC,OAAhB,EAA0BC,MAA1B,KAAqCH,OAAO,CAACG,MAApD;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport { getFontAppearanceLabel } from '../components/font-appearance-control';\n\nimport {\n\tLINE_HEIGHT_SUPPORT_KEY,\n\tLineHeightEdit,\n\thasLineHeightValue,\n\tresetLineHeight,\n\tuseIsLineHeightDisabled,\n} from './line-height';\nimport {\n\tFONT_STYLE_SUPPORT_KEY,\n\tFONT_WEIGHT_SUPPORT_KEY,\n\tFontAppearanceEdit,\n\thasFontAppearanceValue,\n\tresetFontAppearance,\n\tuseIsFontAppearanceDisabled,\n\tuseIsFontStyleDisabled,\n\tuseIsFontWeightDisabled,\n} from './font-appearance';\nimport {\n\tFONT_FAMILY_SUPPORT_KEY,\n\tFontFamilyEdit,\n\thasFontFamilyValue,\n\tresetFontFamily,\n\tuseIsFontFamilyDisabled,\n} from './font-family';\nimport {\n\tFONT_SIZE_SUPPORT_KEY,\n\tFontSizeEdit,\n\thasFontSizeValue,\n\tresetFontSize,\n\tuseIsFontSizeDisabled,\n} from './font-size';\nimport {\n\tTEXT_DECORATION_SUPPORT_KEY,\n\tTextDecorationEdit,\n\thasTextDecorationValue,\n\tresetTextDecoration,\n\tuseIsTextDecorationDisabled,\n} from './text-decoration';\nimport {\n\tTEXT_TRANSFORM_SUPPORT_KEY,\n\tTextTransformEdit,\n\thasTextTransformValue,\n\tresetTextTransform,\n\tuseIsTextTransformDisabled,\n} from './text-transform';\nimport {\n\tLETTER_SPACING_SUPPORT_KEY,\n\tLetterSpacingEdit,\n\thasLetterSpacingValue,\n\tresetLetterSpacing,\n\tuseIsLetterSpacingDisabled,\n} from './letter-spacing';\n\nexport const TYPOGRAPHY_SUPPORT_KEY = 'typography';\nexport const TYPOGRAPHY_SUPPORT_KEYS = [\n\tLINE_HEIGHT_SUPPORT_KEY,\n\tFONT_SIZE_SUPPORT_KEY,\n\tFONT_STYLE_SUPPORT_KEY,\n\tFONT_WEIGHT_SUPPORT_KEY,\n\tFONT_FAMILY_SUPPORT_KEY,\n\tTEXT_DECORATION_SUPPORT_KEY,\n\tTEXT_TRANSFORM_SUPPORT_KEY,\n\tLETTER_SPACING_SUPPORT_KEY,\n];\n\nexport function TypographyPanel( props ) {\n\tconst { clientId } = props;\n\tconst isFontFamilyDisabled = useIsFontFamilyDisabled( props );\n\tconst isFontSizeDisabled = useIsFontSizeDisabled( props );\n\tconst isFontAppearanceDisabled = useIsFontAppearanceDisabled( props );\n\tconst isLineHeightDisabled = useIsLineHeightDisabled( props );\n\tconst isTextDecorationDisabled = useIsTextDecorationDisabled( props );\n\tconst isTextTransformDisabled = useIsTextTransformDisabled( props );\n\tconst isLetterSpacingDisabled = useIsLetterSpacingDisabled( props );\n\n\tconst hasFontStyles = ! useIsFontStyleDisabled( props );\n\tconst hasFontWeights = ! useIsFontWeightDisabled( props );\n\n\tconst isDisabled = useIsTypographyDisabled( props );\n\tconst isSupported = hasTypographySupport( props.name );\n\n\tif ( isDisabled || ! isSupported ) return null;\n\n\tconst defaultControls = getBlockSupport( props.name, [\n\t\tTYPOGRAPHY_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\tconst createResetAllFilter = ( attribute ) => ( newAttributes ) => ( {\n\t\t...newAttributes,\n\t\tstyle: {\n\t\t\t...newAttributes.style,\n\t\t\ttypography: {\n\t\t\t\t...newAttributes.style?.typography,\n\t\t\t\t[ attribute ]: undefined,\n\t\t\t},\n\t\t},\n\t} );\n\n\treturn (\n\t\t<InspectorControls __experimentalGroup=\"typography\">\n\t\t\t{ ! isFontFamilyDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasFontFamilyValue( props ) }\n\t\t\t\t\tlabel={ __( 'Font family' ) }\n\t\t\t\t\tonDeselect={ () => resetFontFamily( props ) }\n\t\t\t\t\tisShownByDefault={ defaultControls?.fontFamily }\n\t\t\t\t\tresetAllFilter={ ( newAttributes ) => ( {\n\t\t\t\t\t\t...newAttributes,\n\t\t\t\t\t\tfontFamily: undefined,\n\t\t\t\t\t} ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<FontFamilyEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isFontSizeDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasFontSizeValue( props ) }\n\t\t\t\t\tlabel={ __( 'Font size' ) }\n\t\t\t\t\tonDeselect={ () => resetFontSize( props ) }\n\t\t\t\t\tisShownByDefault={ defaultControls?.fontSize }\n\t\t\t\t\tresetAllFilter={ ( newAttributes ) => ( {\n\t\t\t\t\t\t...newAttributes,\n\t\t\t\t\t\tfontSize: undefined,\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t...newAttributes.style,\n\t\t\t\t\t\t\ttypography: {\n\t\t\t\t\t\t\t\t...newAttributes.style?.typography,\n\t\t\t\t\t\t\t\tfontSize: undefined,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t} ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<FontSizeEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isFontAppearanceDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\thasValue={ () => hasFontAppearanceValue( props ) }\n\t\t\t\t\tlabel={ getFontAppearanceLabel(\n\t\t\t\t\t\thasFontStyles,\n\t\t\t\t\t\thasFontWeights\n\t\t\t\t\t) }\n\t\t\t\t\tonDeselect={ () => resetFontAppearance( props ) }\n\t\t\t\t\tisShownByDefault={ defaultControls?.fontAppearance }\n\t\t\t\t\tresetAllFilter={ ( newAttributes ) => ( {\n\t\t\t\t\t\t...newAttributes,\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t...newAttributes.style,\n\t\t\t\t\t\t\ttypography: {\n\t\t\t\t\t\t\t\t...newAttributes.style?.typography,\n\t\t\t\t\t\t\t\tfontStyle: undefined,\n\t\t\t\t\t\t\t\tfontWeight: undefined,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t} ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<FontAppearanceEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isLineHeightDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\thasValue={ () => hasLineHeightValue( props ) }\n\t\t\t\t\tlabel={ __( 'Line height' ) }\n\t\t\t\t\tonDeselect={ () => resetLineHeight( props ) }\n\t\t\t\t\tisShownByDefault={ defaultControls?.lineHeight }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'lineHeight' ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<LineHeightEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isTextDecorationDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\thasValue={ () => hasTextDecorationValue( props ) }\n\t\t\t\t\tlabel={ __( 'Decoration' ) }\n\t\t\t\t\tonDeselect={ () => resetTextDecoration( props ) }\n\t\t\t\t\tisShownByDefault={ defaultControls?.textDecoration }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'textDecoration' ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<TextDecorationEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isTextTransformDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\thasValue={ () => hasTextTransformValue( props ) }\n\t\t\t\t\tlabel={ __( 'Letter case' ) }\n\t\t\t\t\tonDeselect={ () => resetTextTransform( props ) }\n\t\t\t\t\tisShownByDefault={ defaultControls?.textTransform }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'textTransform' ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<TextTransformEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isLetterSpacingDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\thasValue={ () => hasLetterSpacingValue( props ) }\n\t\t\t\t\tlabel={ __( 'Letter-spacing' ) }\n\t\t\t\t\tonDeselect={ () => resetLetterSpacing( props ) }\n\t\t\t\t\tisShownByDefault={ defaultControls?.letterSpacing }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'letterSpacing' ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<LetterSpacingEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n}\n\nconst hasTypographySupport = ( blockName ) => {\n\treturn TYPOGRAPHY_SUPPORT_KEYS.some( ( key ) =>\n\t\thasBlockSupport( blockName, key )\n\t);\n};\n\nfunction useIsTypographyDisabled( props = {} ) {\n\tconst configs = [\n\t\tuseIsFontAppearanceDisabled( props ),\n\t\tuseIsFontSizeDisabled( props ),\n\t\tuseIsLineHeightDisabled( props ),\n\t\tuseIsFontFamilyDisabled( props ),\n\t\tuseIsTextDecorationDisabled( props ),\n\t\tuseIsTextTransformDisabled( props ),\n\t\tuseIsLetterSpacingDisabled( props ),\n\t];\n\n\treturn configs.filter( Boolean ).length === configs.length;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/typography.js"],"names":["TYPOGRAPHY_SUPPORT_KEY","TYPOGRAPHY_SUPPORT_KEYS","LINE_HEIGHT_SUPPORT_KEY","FONT_SIZE_SUPPORT_KEY","FONT_STYLE_SUPPORT_KEY","FONT_WEIGHT_SUPPORT_KEY","FONT_FAMILY_SUPPORT_KEY","TEXT_DECORATION_SUPPORT_KEY","TEXT_TRANSFORM_SUPPORT_KEY","LETTER_SPACING_SUPPORT_KEY","TypographyPanel","props","clientId","isFontFamilyDisabled","isFontSizeDisabled","isFontAppearanceDisabled","isLineHeightDisabled","isTextDecorationDisabled","isTextTransformDisabled","isLetterSpacingDisabled","hasFontStyles","hasFontWeights","isDisabled","useIsTypographyDisabled","isSupported","hasTypographySupport","name","defaultControls","createResetAllFilter","attribute","newAttributes","style","typography","undefined","fontFamily","fontSize","fontAppearance","fontStyle","fontWeight","lineHeight","textDecoration","textTransform","letterSpacing","blockName","some","key","configs","filter","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A,eAAH,uBAAGA,eAAe,CAAEe,aALrC;AAMC,IAAA,cAAc,EAAGd,oBAAoB,CAAE,eAAF,CANtC;AAOC,IAAA,OAAO,EAAGhB;AAPX,KASC,4BAAC,gCAAD,EAAwBD,KAAxB,CATD,CAxGF,CADD;AAuHA;;AAEM,MAAMc,oBAAoB,GAAKkB,SAAF,IAAiB;AACpD,SAAO1C,uBAAuB,CAAC2C,IAAxB,CAAgCC,GAAF,IACpC,6BAAiBF,SAAjB,EAA4BE,GAA5B,CADM,CAAP;AAGA,CAJM;;;;AAMP,SAAStB,uBAAT,GAA+C;AAAA,MAAbZ,KAAa,uEAAL,EAAK;AAC9C,QAAMmC,OAAO,GAAG,CACf,iDAA6BnC,KAA7B,CADe,EAEf,qCAAuBA,KAAvB,CAFe,EAGf,yCAAyBA,KAAzB,CAHe,EAIf,yCAAyBA,KAAzB,CAJe,EAKf,iDAA6BA,KAA7B,CALe,EAMf,+CAA4BA,KAA5B,CANe,EAOf,+CAA4BA,KAA5B,CAPe,CAAhB;AAUA,SAAOmC,OAAO,CAACC,MAAR,CAAgBC,OAAhB,EAA0BC,MAA1B,KAAqCH,OAAO,CAACG,MAApD;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { __experimentalToolsPanelItem as ToolsPanelItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport { getFontAppearanceLabel } from '../components/font-appearance-control';\n\nimport {\n\tLINE_HEIGHT_SUPPORT_KEY,\n\tLineHeightEdit,\n\thasLineHeightValue,\n\tresetLineHeight,\n\tuseIsLineHeightDisabled,\n} from './line-height';\nimport {\n\tFONT_STYLE_SUPPORT_KEY,\n\tFONT_WEIGHT_SUPPORT_KEY,\n\tFontAppearanceEdit,\n\thasFontAppearanceValue,\n\tresetFontAppearance,\n\tuseIsFontAppearanceDisabled,\n\tuseIsFontStyleDisabled,\n\tuseIsFontWeightDisabled,\n} from './font-appearance';\nimport {\n\tFONT_FAMILY_SUPPORT_KEY,\n\tFontFamilyEdit,\n\thasFontFamilyValue,\n\tresetFontFamily,\n\tuseIsFontFamilyDisabled,\n} from './font-family';\nimport {\n\tFONT_SIZE_SUPPORT_KEY,\n\tFontSizeEdit,\n\thasFontSizeValue,\n\tresetFontSize,\n\tuseIsFontSizeDisabled,\n} from './font-size';\nimport {\n\tTEXT_DECORATION_SUPPORT_KEY,\n\tTextDecorationEdit,\n\thasTextDecorationValue,\n\tresetTextDecoration,\n\tuseIsTextDecorationDisabled,\n} from './text-decoration';\nimport {\n\tTEXT_TRANSFORM_SUPPORT_KEY,\n\tTextTransformEdit,\n\thasTextTransformValue,\n\tresetTextTransform,\n\tuseIsTextTransformDisabled,\n} from './text-transform';\nimport {\n\tLETTER_SPACING_SUPPORT_KEY,\n\tLetterSpacingEdit,\n\thasLetterSpacingValue,\n\tresetLetterSpacing,\n\tuseIsLetterSpacingDisabled,\n} from './letter-spacing';\n\nexport const TYPOGRAPHY_SUPPORT_KEY = 'typography';\nexport const TYPOGRAPHY_SUPPORT_KEYS = [\n\tLINE_HEIGHT_SUPPORT_KEY,\n\tFONT_SIZE_SUPPORT_KEY,\n\tFONT_STYLE_SUPPORT_KEY,\n\tFONT_WEIGHT_SUPPORT_KEY,\n\tFONT_FAMILY_SUPPORT_KEY,\n\tTEXT_DECORATION_SUPPORT_KEY,\n\tTEXT_TRANSFORM_SUPPORT_KEY,\n\tLETTER_SPACING_SUPPORT_KEY,\n];\n\nexport function TypographyPanel( props ) {\n\tconst { clientId } = props;\n\tconst isFontFamilyDisabled = useIsFontFamilyDisabled( props );\n\tconst isFontSizeDisabled = useIsFontSizeDisabled( props );\n\tconst isFontAppearanceDisabled = useIsFontAppearanceDisabled( props );\n\tconst isLineHeightDisabled = useIsLineHeightDisabled( props );\n\tconst isTextDecorationDisabled = useIsTextDecorationDisabled( props );\n\tconst isTextTransformDisabled = useIsTextTransformDisabled( props );\n\tconst isLetterSpacingDisabled = useIsLetterSpacingDisabled( props );\n\n\tconst hasFontStyles = ! useIsFontStyleDisabled( props );\n\tconst hasFontWeights = ! useIsFontWeightDisabled( props );\n\n\tconst isDisabled = useIsTypographyDisabled( props );\n\tconst isSupported = hasTypographySupport( props.name );\n\n\tif ( isDisabled || ! isSupported ) return null;\n\n\tconst defaultControls = getBlockSupport( props.name, [\n\t\tTYPOGRAPHY_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\tconst createResetAllFilter = ( attribute ) => ( newAttributes ) => ( {\n\t\t...newAttributes,\n\t\tstyle: {\n\t\t\t...newAttributes.style,\n\t\t\ttypography: {\n\t\t\t\t...newAttributes.style?.typography,\n\t\t\t\t[ attribute ]: undefined,\n\t\t\t},\n\t\t},\n\t} );\n\n\treturn (\n\t\t<InspectorControls __experimentalGroup=\"typography\">\n\t\t\t{ ! isFontFamilyDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasFontFamilyValue( props ) }\n\t\t\t\t\tlabel={ __( 'Font family' ) }\n\t\t\t\t\tonDeselect={ () => resetFontFamily( props ) }\n\t\t\t\t\tisShownByDefault={ defaultControls?.fontFamily }\n\t\t\t\t\tresetAllFilter={ ( newAttributes ) => ( {\n\t\t\t\t\t\t...newAttributes,\n\t\t\t\t\t\tfontFamily: undefined,\n\t\t\t\t\t} ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<FontFamilyEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isFontSizeDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => hasFontSizeValue( props ) }\n\t\t\t\t\tlabel={ __( 'Font size' ) }\n\t\t\t\t\tonDeselect={ () => resetFontSize( props ) }\n\t\t\t\t\tisShownByDefault={ defaultControls?.fontSize }\n\t\t\t\t\tresetAllFilter={ ( newAttributes ) => ( {\n\t\t\t\t\t\t...newAttributes,\n\t\t\t\t\t\tfontSize: undefined,\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t...newAttributes.style,\n\t\t\t\t\t\t\ttypography: {\n\t\t\t\t\t\t\t\t...newAttributes.style?.typography,\n\t\t\t\t\t\t\t\tfontSize: undefined,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t} ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<FontSizeEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isFontAppearanceDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\thasValue={ () => hasFontAppearanceValue( props ) }\n\t\t\t\t\tlabel={ getFontAppearanceLabel(\n\t\t\t\t\t\thasFontStyles,\n\t\t\t\t\t\thasFontWeights\n\t\t\t\t\t) }\n\t\t\t\t\tonDeselect={ () => resetFontAppearance( props ) }\n\t\t\t\t\tisShownByDefault={ defaultControls?.fontAppearance }\n\t\t\t\t\tresetAllFilter={ ( newAttributes ) => ( {\n\t\t\t\t\t\t...newAttributes,\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t...newAttributes.style,\n\t\t\t\t\t\t\ttypography: {\n\t\t\t\t\t\t\t\t...newAttributes.style?.typography,\n\t\t\t\t\t\t\t\tfontStyle: undefined,\n\t\t\t\t\t\t\t\tfontWeight: undefined,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t} ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<FontAppearanceEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isLineHeightDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\thasValue={ () => hasLineHeightValue( props ) }\n\t\t\t\t\tlabel={ __( 'Line height' ) }\n\t\t\t\t\tonDeselect={ () => resetLineHeight( props ) }\n\t\t\t\t\tisShownByDefault={ defaultControls?.lineHeight }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'lineHeight' ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<LineHeightEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isTextDecorationDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\thasValue={ () => hasTextDecorationValue( props ) }\n\t\t\t\t\tlabel={ __( 'Decoration' ) }\n\t\t\t\t\tonDeselect={ () => resetTextDecoration( props ) }\n\t\t\t\t\tisShownByDefault={ defaultControls?.textDecoration }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'textDecoration' ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<TextDecorationEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isTextTransformDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\thasValue={ () => hasTextTransformValue( props ) }\n\t\t\t\t\tlabel={ __( 'Letter case' ) }\n\t\t\t\t\tonDeselect={ () => resetTextTransform( props ) }\n\t\t\t\t\tisShownByDefault={ defaultControls?.textTransform }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'textTransform' ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<TextTransformEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ ! isLetterSpacingDisabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\thasValue={ () => hasLetterSpacingValue( props ) }\n\t\t\t\t\tlabel={ __( 'Letter-spacing' ) }\n\t\t\t\t\tonDeselect={ () => resetLetterSpacing( props ) }\n\t\t\t\t\tisShownByDefault={ defaultControls?.letterSpacing }\n\t\t\t\t\tresetAllFilter={ createResetAllFilter( 'letterSpacing' ) }\n\t\t\t\t\tpanelId={ clientId }\n\t\t\t\t>\n\t\t\t\t\t<LetterSpacingEdit { ...props } />\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n}\n\nexport const hasTypographySupport = ( blockName ) => {\n\treturn TYPOGRAPHY_SUPPORT_KEYS.some( ( key ) =>\n\t\thasBlockSupport( blockName, key )\n\t);\n};\n\nfunction useIsTypographyDisabled( props = {} ) {\n\tconst configs = [\n\t\tuseIsFontAppearanceDisabled( props ),\n\t\tuseIsFontSizeDisabled( props ),\n\t\tuseIsLineHeightDisabled( props ),\n\t\tuseIsFontFamilyDisabled( props ),\n\t\tuseIsTextDecorationDisabled( props ),\n\t\tuseIsTextTransformDisabled( props ),\n\t\tuseIsLetterSpacingDisabled( props ),\n\t];\n\n\treturn configs.filter( Boolean ).length === configs.length;\n}\n"]}
|
|
@@ -10,6 +10,8 @@ exports.useColorProps = useColorProps;
|
|
|
10
10
|
|
|
11
11
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
12
|
|
|
13
|
+
var _element = require("@wordpress/element");
|
|
14
|
+
|
|
13
15
|
var _style = require("./style");
|
|
14
16
|
|
|
15
17
|
var _colors = require("../components/colors");
|
|
@@ -22,6 +24,10 @@ var _useSetting = _interopRequireDefault(require("../components/use-setting"));
|
|
|
22
24
|
* External dependencies
|
|
23
25
|
*/
|
|
24
26
|
|
|
27
|
+
/**
|
|
28
|
+
* WordPress dependencies
|
|
29
|
+
*/
|
|
30
|
+
|
|
25
31
|
/**
|
|
26
32
|
* Internal dependencies
|
|
27
33
|
*/
|
|
@@ -31,7 +37,7 @@ var _useSetting = _interopRequireDefault(require("../components/use-setting"));
|
|
|
31
37
|
// This utility is intended to assist where the serialization of the colors
|
|
32
38
|
// block support is being skipped for a block but the color related CSS classes
|
|
33
39
|
// & styles still need to be generated so they can be applied to inner elements.
|
|
34
|
-
|
|
40
|
+
|
|
35
41
|
/**
|
|
36
42
|
* Provides the CSS class names and inline styles for a block's color support
|
|
37
43
|
* attributes.
|
|
@@ -40,7 +46,6 @@ const EMPTY_ARRAY = [];
|
|
|
40
46
|
*
|
|
41
47
|
* @return {Object} Color block support derived CSS classes & styles.
|
|
42
48
|
*/
|
|
43
|
-
|
|
44
49
|
function getColorClassesAndStyles(attributes) {
|
|
45
50
|
var _style$color, _style$color2, _style$color3, _style$color4, _style$elements, _style$elements$link;
|
|
46
51
|
|
|
@@ -92,8 +97,12 @@ function useColorProps(attributes) {
|
|
|
92
97
|
textColor,
|
|
93
98
|
gradient
|
|
94
99
|
} = attributes;
|
|
95
|
-
const
|
|
96
|
-
|
|
100
|
+
const {
|
|
101
|
+
palette: solidsPerOrigin,
|
|
102
|
+
gradients: gradientsPerOrigin
|
|
103
|
+
} = (0, _useSetting.default)('color') || {};
|
|
104
|
+
const colors = (0, _element.useMemo)(() => [...((solidsPerOrigin === null || solidsPerOrigin === void 0 ? void 0 : solidsPerOrigin.custom) || []), ...((solidsPerOrigin === null || solidsPerOrigin === void 0 ? void 0 : solidsPerOrigin.theme) || []), ...((solidsPerOrigin === null || solidsPerOrigin === void 0 ? void 0 : solidsPerOrigin.default) || [])], [solidsPerOrigin]);
|
|
105
|
+
const gradients = (0, _element.useMemo)(() => [...((gradientsPerOrigin === null || gradientsPerOrigin === void 0 ? void 0 : gradientsPerOrigin.custom) || []), ...((gradientsPerOrigin === null || gradientsPerOrigin === void 0 ? void 0 : gradientsPerOrigin.theme) || []), ...((gradientsPerOrigin === null || gradientsPerOrigin === void 0 ? void 0 : gradientsPerOrigin.default) || [])], [gradientsPerOrigin]);
|
|
97
106
|
const colorProps = getColorClassesAndStyles(attributes); // Force inline styles to apply colors when themes do not load their color
|
|
98
107
|
// stylesheets in the editor.
|
|
99
108
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/use-color-props.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/use-color-props.js"],"names":["getColorClassesAndStyles","attributes","backgroundColor","textColor","gradient","style","backgroundClass","textClass","gradientClass","hasGradient","color","className","text","background","elements","link","colorStyles","styleProp","undefined","useColorProps","palette","solidsPerOrigin","gradients","gradientsPerOrigin","colors","custom","theme","default","colorProps","backgroundColorObject","textColorObject"],"mappings":";;;;;;;;;;AAGA;;AAKA;;AAKA;;AACA;;AAIA;;AAIA;;AAtBA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAYA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,wBAAT,CAAmCC,UAAnC,EAAgD;AAAA;;AACtD,QAAM;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA,SAAnB;AAA8BC,IAAAA,QAA9B;AAAwCC,IAAAA;AAAxC,MAAkDJ,UAAxD,CADsD,CAGtD;;AACA,QAAMK,eAAe,GAAG,+BACvB,kBADuB,EAEvBJ,eAFuB,CAAxB;AAIA,QAAMK,SAAS,GAAG,+BAAmB,OAAnB,EAA4BJ,SAA5B,CAAlB;AAEA,QAAMK,aAAa,GAAG,+CAAgCJ,QAAhC,CAAtB;AACA,QAAMK,WAAW,GAAGD,aAAa,KAAIH,KAAJ,aAAIA,KAAJ,uCAAIA,KAAK,CAAEK,KAAX,iDAAI,aAAcN,QAAlB,CAAjC,CAXsD,CAatD;;AACA,QAAMO,SAAS,GAAG,yBAAYJ,SAAZ,EAAuBC,aAAvB,EAAsC;AACvD;AACA,KAAEF,eAAF,GAAqB,CAAEG,WAAF,IAAiB,CAAC,CAAEH,eAFc;AAGvD,sBAAkBH,SAAS,KAAIE,KAAJ,aAAIA,KAAJ,wCAAIA,KAAK,CAAEK,KAAX,kDAAI,cAAcE,IAAlB,CAH4B;AAIvD,sBACC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,EAAjC,CAHK,CADQ,EAMd,CAAEN,eAAF,CANc,CAAf;AAQA,QAAMC,SAAS,GAAG,sBACjB,MAAM,CACL,IAAK,CAAAC,kBAAkB,SAAlB,IAAAA,kBAAkB,WAAlB,YAAAA,kBAAkB,CAAEE,MAApB,KAA8B,EAAnC,CADK,EAEL,IAAK,CAAAF,kBAAkB,SAAlB,IAAAA,kBAAkB,WAAlB,YAAAA,kBAAkB,CAAEG,KAApB,KAA6B,EAAlC,CAFK,EAGL,IAAK,CAAAH,kBAAkB,SAAlB,IAAAA,kBAAkB,WAAlB,YAAAA,kBAAkB,CAAEI,OAApB,KAA+B,EAApC,CAHK,CADW,EAMjB,CAAEJ,kBAAF,CANiB,CAAlB;AASA,QAAMK,UAAU,GAAG5B,wBAAwB,CAAEC,UAAF,CAA3C,CAtB2C,CAwB3C;AACA;;AACA,MAAKC,eAAL,EAAuB;AACtB,UAAM2B,qBAAqB,GAAG,6CAC7BL,MAD6B,EAE7BtB,eAF6B,CAA9B;AAKA0B,IAAAA,UAAU,CAACvB,KAAX,CAAiBH,eAAjB,GAAmC2B,qBAAqB,CAACnB,KAAzD;AACA;;AAED,MAAKN,QAAL,EAAgB;AACfwB,IAAAA,UAAU,CAACvB,KAAX,CAAiBQ,UAAjB,GAA8B,uCAC7BS,SAD6B,EAE7BlB,QAF6B,CAA9B;AAIA;;AAED,MAAKD,SAAL,EAAiB;AAChB,UAAM2B,eAAe,GAAG,6CACvBN,MADuB,EAEvBrB,SAFuB,CAAxB;AAKAyB,IAAAA,UAAU,CAACvB,KAAX,CAAiBK,KAAjB,GAAyBoB,eAAe,CAACpB,KAAzC;AACA;;AAED,SAAOkB,UAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { getInlineStyles } from './style';\nimport {\n\tgetColorClassName,\n\tgetColorObjectByAttributeValues,\n} from '../components/colors';\nimport {\n\t__experimentalGetGradientClass,\n\tgetGradientValueBySlug,\n} from '../components/gradients';\nimport useSetting from '../components/use-setting';\n\n// The code in this file has largely been lifted from the color block support\n// hook.\n//\n// This utility is intended to assist where the serialization of the colors\n// block support is being skipped for a block but the color related CSS classes\n// & styles still need to be generated so they can be applied to inner elements.\n\n/**\n * Provides the CSS class names and inline styles for a block's color support\n * attributes.\n *\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} Color block support derived CSS classes & styles.\n */\nexport function getColorClassesAndStyles( attributes ) {\n\tconst { backgroundColor, textColor, gradient, style } = attributes;\n\n\t// Collect color CSS classes.\n\tconst backgroundClass = getColorClassName(\n\t\t'background-color',\n\t\tbackgroundColor\n\t);\n\tconst textClass = getColorClassName( 'color', textColor );\n\n\tconst gradientClass = __experimentalGetGradientClass( gradient );\n\tconst hasGradient = gradientClass || style?.color?.gradient;\n\n\t// Determine color CSS class name list.\n\tconst className = classnames( textClass, gradientClass, {\n\t\t// Don't apply the background class if there's a gradient.\n\t\t[ backgroundClass ]: ! hasGradient && !! backgroundClass,\n\t\t'has-text-color': textColor || style?.color?.text,\n\t\t'has-background':\n\t\t\tbackgroundColor ||\n\t\t\tstyle?.color?.background ||\n\t\t\tgradient ||\n\t\t\tstyle?.color?.gradient,\n\t\t'has-link-color': style?.elements?.link?.color,\n\t} );\n\n\t// Collect inline styles for colors.\n\tconst colorStyles = style?.color || {};\n\tconst styleProp = getInlineStyles( { color: colorStyles } );\n\n\treturn {\n\t\tclassName: className || undefined,\n\t\tstyle: styleProp,\n\t};\n}\n\n/**\n * Determines the color related props for a block derived from its color block\n * support attributes.\n *\n * Inline styles are forced for named colors to ensure these selections are\n * reflected when themes do not load their color stylesheets in the editor.\n *\n * @param {Object} attributes Block attributes.\n *\n * @return {Object} ClassName & style props from colors block support.\n */\nexport function useColorProps( attributes ) {\n\tconst { backgroundColor, textColor, gradient } = attributes;\n\n\tconst { palette: solidsPerOrigin, gradients: gradientsPerOrigin } =\n\t\tuseSetting( 'color' ) || {};\n\tconst colors = useMemo(\n\t\t() => [\n\t\t\t...( solidsPerOrigin?.custom || [] ),\n\t\t\t...( solidsPerOrigin?.theme || [] ),\n\t\t\t...( solidsPerOrigin?.default || [] ),\n\t\t],\n\t\t[ solidsPerOrigin ]\n\t);\n\tconst gradients = useMemo(\n\t\t() => [\n\t\t\t...( gradientsPerOrigin?.custom || [] ),\n\t\t\t...( gradientsPerOrigin?.theme || [] ),\n\t\t\t...( gradientsPerOrigin?.default || [] ),\n\t\t],\n\t\t[ gradientsPerOrigin ]\n\t);\n\n\tconst colorProps = getColorClassesAndStyles( attributes );\n\n\t// Force inline styles to apply colors when themes do not load their color\n\t// stylesheets in the editor.\n\tif ( backgroundColor ) {\n\t\tconst backgroundColorObject = getColorObjectByAttributeValues(\n\t\t\tcolors,\n\t\t\tbackgroundColor\n\t\t);\n\n\t\tcolorProps.style.backgroundColor = backgroundColorObject.color;\n\t}\n\n\tif ( gradient ) {\n\t\tcolorProps.style.background = getGradientValueBySlug(\n\t\t\tgradients,\n\t\t\tgradient\n\t\t);\n\t}\n\n\tif ( textColor ) {\n\t\tconst textColorObject = getColorObjectByAttributeValues(\n\t\t\tcolors,\n\t\t\ttextColor\n\t\t);\n\n\t\tcolorProps.style.color = textColorObject.color;\n\t}\n\n\treturn colorProps;\n}\n"]}
|
package/build/store/selectors.js
CHANGED
|
@@ -1741,38 +1741,33 @@ const getInserterItems = (0, _rememo.default)(function (state) {
|
|
|
1741
1741
|
};
|
|
1742
1742
|
|
|
1743
1743
|
const blockTypeInserterItems = (0, _blocks.getBlockTypes)().filter(blockType => canIncludeBlockTypeInInserter(state, blockType, rootClientId)).map(buildBlockTypeInserterItem);
|
|
1744
|
-
const reusableBlockInserterItems = canInsertBlockTypeUnmemoized(state, 'core/block', rootClientId) ? getReusableBlocks(state).map(buildReusableBlockInserterItem) : [];
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
const visibleBlockTypeInserterItems = blockTypeInserterItems.filter(_ref4 => {
|
|
1748
|
-
let {
|
|
1744
|
+
const reusableBlockInserterItems = canInsertBlockTypeUnmemoized(state, 'core/block', rootClientId) ? getReusableBlocks(state).map(buildReusableBlockInserterItem) : [];
|
|
1745
|
+
const items = blockTypeInserterItems.reduce((accumulator, item) => {
|
|
1746
|
+
const {
|
|
1749
1747
|
variations = []
|
|
1750
|
-
} =
|
|
1751
|
-
|
|
1748
|
+
} = item; // Exclude any block type item that is to be replaced by a default variation
|
|
1749
|
+
|
|
1750
|
+
if (!variations.some(_ref4 => {
|
|
1752
1751
|
let {
|
|
1753
1752
|
isDefault
|
|
1754
|
-
} =
|
|
1753
|
+
} = _ref4;
|
|
1755
1754
|
return isDefault;
|
|
1756
|
-
})
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
for (const item of blockTypeInserterItems) {
|
|
1761
|
-
const {
|
|
1762
|
-
variations = []
|
|
1763
|
-
} = item;
|
|
1755
|
+
})) {
|
|
1756
|
+
accumulator.push(item);
|
|
1757
|
+
}
|
|
1764
1758
|
|
|
1765
1759
|
if (variations.length) {
|
|
1766
1760
|
const variationMapper = getItemFromVariation(state, item);
|
|
1767
|
-
|
|
1761
|
+
accumulator.push(...variations.map(variationMapper));
|
|
1768
1762
|
}
|
|
1769
|
-
|
|
1763
|
+
|
|
1764
|
+
return accumulator;
|
|
1765
|
+
}, []); // Ensure core blocks are prioritized in the returned results,
|
|
1770
1766
|
// because third party blocks can be registered earlier than
|
|
1771
1767
|
// the core blocks (usually by using the `init` action),
|
|
1772
1768
|
// thus affecting the display order.
|
|
1773
1769
|
// We don't sort reusable blocks as they are handled differently.
|
|
1774
1770
|
|
|
1775
|
-
|
|
1776
1771
|
const groupByType = (blocks, block) => {
|
|
1777
1772
|
const {
|
|
1778
1773
|
core,
|
|
@@ -1783,15 +1778,14 @@ const getInserterItems = (0, _rememo.default)(function (state) {
|
|
|
1783
1778
|
return blocks;
|
|
1784
1779
|
};
|
|
1785
1780
|
|
|
1786
|
-
const
|
|
1787
|
-
core:
|
|
1788
|
-
noncore:
|
|
1789
|
-
}
|
|
1790
|
-
const variations = blockVariations.reduce(groupByType, {
|
|
1781
|
+
const {
|
|
1782
|
+
core: coreItems,
|
|
1783
|
+
noncore: nonCoreItems
|
|
1784
|
+
} = items.reduce(groupByType, {
|
|
1791
1785
|
core: [],
|
|
1792
1786
|
noncore: []
|
|
1793
1787
|
});
|
|
1794
|
-
const sortedBlockTypes = [...
|
|
1788
|
+
const sortedBlockTypes = [...coreItems, ...nonCoreItems];
|
|
1795
1789
|
return [...sortedBlockTypes, ...reusableBlockInserterItems];
|
|
1796
1790
|
}, (state, rootClientId) => [state.blockListSettings[rootClientId], state.blocks.byClientId, state.blocks.order, state.preferences.insertUsage, state.settings.allowedBlockTypes, state.settings.templateLock, getReusableBlocks(state), (0, _blocks.getBlockTypes)()]);
|
|
1797
1791
|
/**
|
|
@@ -1827,10 +1821,10 @@ const getBlockTransformItems = (0, _rememo.default)(function (state, blocks) {
|
|
|
1827
1821
|
buildScope: 'transform'
|
|
1828
1822
|
});
|
|
1829
1823
|
const blockTypeTransformItems = (0, _blocks.getBlockTypes)().filter(blockType => canIncludeBlockTypeInInserter(state, blockType, rootClientId)).map(buildBlockTypeTransformItem);
|
|
1830
|
-
const itemsByName = (0, _lodash.mapKeys)(blockTypeTransformItems,
|
|
1824
|
+
const itemsByName = (0, _lodash.mapKeys)(blockTypeTransformItems, _ref5 => {
|
|
1831
1825
|
let {
|
|
1832
1826
|
name
|
|
1833
|
-
} =
|
|
1827
|
+
} = _ref5;
|
|
1834
1828
|
return name;
|
|
1835
1829
|
});
|
|
1836
1830
|
const possibleTransforms = (0, _blocks.getPossibleBlockTransformations)(blocks).reduce((accumulator, block) => {
|
|
@@ -1948,10 +1942,10 @@ const checkAllowListRecursive = (blocks, allowedBlockTypes) => {
|
|
|
1948
1942
|
|
|
1949
1943
|
const __experimentalGetParsedPattern = (0, _rememo.default)((state, patternName) => {
|
|
1950
1944
|
const patterns = state.settings.__experimentalBlockPatterns;
|
|
1951
|
-
const pattern = patterns.find(
|
|
1945
|
+
const pattern = patterns.find(_ref6 => {
|
|
1952
1946
|
let {
|
|
1953
1947
|
name
|
|
1954
|
-
} =
|
|
1948
|
+
} = _ref6;
|
|
1955
1949
|
return name === patternName;
|
|
1956
1950
|
});
|
|
1957
1951
|
|
|
@@ -1970,21 +1964,21 @@ const getAllAllowedPatterns = (0, _rememo.default)(state => {
|
|
|
1970
1964
|
const {
|
|
1971
1965
|
allowedBlockTypes
|
|
1972
1966
|
} = getSettings(state);
|
|
1973
|
-
const parsedPatterns = patterns.filter(
|
|
1967
|
+
const parsedPatterns = patterns.filter(_ref7 => {
|
|
1974
1968
|
let {
|
|
1975
1969
|
inserter = true
|
|
1976
|
-
} =
|
|
1970
|
+
} = _ref7;
|
|
1977
1971
|
return !!inserter;
|
|
1978
|
-
}).map(
|
|
1972
|
+
}).map(_ref8 => {
|
|
1979
1973
|
let {
|
|
1980
1974
|
name
|
|
1981
|
-
} =
|
|
1975
|
+
} = _ref8;
|
|
1982
1976
|
return __experimentalGetParsedPattern(state, name);
|
|
1983
1977
|
});
|
|
1984
|
-
const allowedPatterns = parsedPatterns.filter(
|
|
1978
|
+
const allowedPatterns = parsedPatterns.filter(_ref9 => {
|
|
1985
1979
|
let {
|
|
1986
1980
|
blocks
|
|
1987
|
-
} =
|
|
1981
|
+
} = _ref9;
|
|
1988
1982
|
return checkAllowListRecursive(blocks, allowedBlockTypes);
|
|
1989
1983
|
});
|
|
1990
1984
|
return allowedPatterns;
|
|
@@ -2001,14 +1995,14 @@ const getAllAllowedPatterns = (0, _rememo.default)(state => {
|
|
|
2001
1995
|
const __experimentalGetAllowedPatterns = (0, _rememo.default)(function (state) {
|
|
2002
1996
|
let rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
2003
1997
|
const availableParsedPatterns = getAllAllowedPatterns(state);
|
|
2004
|
-
const patternsAllowed = (0, _lodash.filter)(availableParsedPatterns,
|
|
1998
|
+
const patternsAllowed = (0, _lodash.filter)(availableParsedPatterns, _ref10 => {
|
|
2005
1999
|
let {
|
|
2006
2000
|
blocks
|
|
2007
|
-
} =
|
|
2008
|
-
return blocks.every(
|
|
2001
|
+
} = _ref10;
|
|
2002
|
+
return blocks.every(_ref11 => {
|
|
2009
2003
|
let {
|
|
2010
2004
|
name
|
|
2011
|
-
} =
|
|
2005
|
+
} = _ref11;
|
|
2012
2006
|
return canInsertBlockType(state, name, rootClientId);
|
|
2013
2007
|
});
|
|
2014
2008
|
});
|
|
@@ -2076,21 +2070,21 @@ const __experimentalGetPatternTransformItems = (0, _rememo.default)(function (st
|
|
|
2076
2070
|
* to check for this case too.
|
|
2077
2071
|
*/
|
|
2078
2072
|
|
|
2079
|
-
if (blocks.some(
|
|
2073
|
+
if (blocks.some(_ref12 => {
|
|
2080
2074
|
let {
|
|
2081
2075
|
clientId,
|
|
2082
2076
|
innerBlocks
|
|
2083
|
-
} =
|
|
2077
|
+
} = _ref12;
|
|
2084
2078
|
return innerBlocks.length || areInnerBlocksControlled(state, clientId);
|
|
2085
2079
|
})) {
|
|
2086
2080
|
return EMPTY_ARRAY;
|
|
2087
2081
|
} // Create a Set of the selected block names that is used in patterns filtering.
|
|
2088
2082
|
|
|
2089
2083
|
|
|
2090
|
-
const selectedBlockNames = Array.from(new Set(blocks.map(
|
|
2084
|
+
const selectedBlockNames = Array.from(new Set(blocks.map(_ref13 => {
|
|
2091
2085
|
let {
|
|
2092
2086
|
name
|
|
2093
|
-
} =
|
|
2087
|
+
} = _ref13;
|
|
2094
2088
|
return name;
|
|
2095
2089
|
})));
|
|
2096
2090
|
/**
|