@wordpress/block-editor 8.5.2 → 8.6.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 +2 -0
- package/build/components/block-list/block.native.js +3 -1
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-mover/button.js +4 -4
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +39 -65
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-popover/inbetween.js +183 -0
- package/build/components/block-popover/inbetween.js.map +1 -0
- package/build/components/block-popover/index.js +82 -0
- package/build/components/block-popover/index.js.map +1 -0
- package/build/components/{block-tools → block-popover}/use-popover-scroll.js +4 -1
- package/build/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build/components/block-styles/index.js +1 -10
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -2
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +4 -2
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +5 -5
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +14 -121
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -108
- package/build/components/block-tools/selected-block-popover.js.map +1 -0
- package/build/components/duotone-control/index.js +5 -1
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/inserter/index.native.js +30 -8
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/rich-text/index.js +0 -5
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +0 -4
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/use-block-display-information/index.js +3 -1
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/hooks/border.js +468 -44
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/duotone.js +66 -16
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +8 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use-border-props.js +22 -32
- package/build/hooks/use-border-props.js.map +1 -1
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/store/actions.js +14 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +0 -26
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +9 -3
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-list/block.native.js +3 -1
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-mover/button.js +5 -5
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +38 -63
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +165 -0
- package/build-module/components/block-popover/inbetween.js.map +1 -0
- package/build-module/components/block-popover/index.js +67 -0
- package/build-module/components/block-popover/index.js.map +1 -0
- package/build-module/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/build-module/components/block-popover/use-popover-scroll.js.map +1 -0
- package/build-module/components/block-styles/index.js +1 -9
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +1 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +3 -2
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +3 -3
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +16 -121
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/{block-popover.js → selected-block-popover.js} +25 -105
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -0
- package/build-module/components/duotone-control/index.js +4 -1
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/inserter/index.native.js +31 -10
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/rich-text/index.js +0 -4
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +0 -4
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +3 -1
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/hooks/border.js +458 -44
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/duotone.js +63 -16
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +2 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/use-border-props.js +21 -30
- package/build-module/hooks/use-border-props.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +14 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +0 -24
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +8 -3
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +111 -246
- package/build-style/style.css +111 -246
- package/package.json +28 -28
- package/src/components/block-list/block.native.js +2 -0
- package/src/components/block-mover/button.js +5 -7
- package/src/components/block-mover/index.js +37 -60
- package/src/components/block-mover/stories/index.js +110 -0
- package/src/components/block-mover/style.scss +48 -138
- package/src/components/block-popover/README.md +41 -0
- package/src/components/block-popover/inbetween.js +180 -0
- package/src/components/block-popover/index.js +73 -0
- package/src/components/block-popover/style.scss +24 -0
- package/src/components/{block-tools → block-popover}/use-popover-scroll.js +3 -1
- package/src/components/block-styles/index.js +1 -12
- package/src/components/block-switcher/style.scss +0 -4
- package/src/components/block-toolbar/style.scss +0 -12
- package/src/components/block-tools/back-compat.js +1 -1
- package/src/components/block-tools/block-selection-button.js +3 -1
- package/src/components/block-tools/index.js +6 -4
- package/src/components/block-tools/insertion-point.js +19 -152
- package/src/components/block-tools/{block-popover.js → selected-block-popover.js} +24 -116
- package/src/components/block-tools/style.scss +11 -123
- package/src/components/border-radius-control/style.scss +5 -2
- package/src/components/default-block-appender/style.scss +1 -2
- package/src/components/duotone-control/index.js +8 -1
- package/src/components/gradients/README.md +29 -0
- package/src/components/inserter/index.native.js +60 -25
- package/src/components/inserter/style.native.scss +24 -3
- package/src/components/navigable-toolbar/README.md +16 -0
- package/src/components/rich-text/index.js +0 -2
- package/src/components/rich-text/index.native.js +0 -4
- package/src/components/use-block-display-information/index.js +2 -0
- package/src/hooks/border.js +438 -72
- package/src/hooks/border.scss +48 -0
- package/src/hooks/duotone.js +98 -62
- package/src/hooks/index.js +2 -1
- package/src/hooks/use-border-props.js +15 -32
- package/src/index.js +1 -0
- package/src/store/actions.js +14 -2
- package/src/store/reducer.js +0 -21
- package/src/store/selectors.js +12 -3
- package/src/store/test/actions.js +0 -18
- package/src/store/test/reducer.js +0 -19
- package/src/store/test/selectors.js +0 -19
- package/src/style.scss +1 -1
- package/build/components/block-mobile-toolbar/index.js +0 -42
- package/build/components/block-mobile-toolbar/index.js.map +0 -1
- package/build/components/block-tools/block-popover.js.map +0 -1
- package/build/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build/components/list-view/appender.js +0 -93
- package/build/components/list-view/appender.js.map +0 -1
- package/build/components/list-view/list-item.js +0 -62
- package/build/components/list-view/list-item.js.map +0 -1
- package/build/components/rich-text/use-caret-in-format.js +0 -43
- package/build/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build/hooks/border-color.js +0 -302
- package/build/hooks/border-color.js.map +0 -1
- package/build/hooks/border-style.js +0 -96
- package/build/hooks/border-style.js.map +0 -1
- package/build/hooks/border-width.js +0 -162
- package/build/hooks/border-width.js.map +0 -1
- package/build-module/components/block-mobile-toolbar/index.js +0 -31
- package/build-module/components/block-mobile-toolbar/index.js.map +0 -1
- package/build-module/components/block-tools/block-popover.js.map +0 -1
- package/build-module/components/block-tools/use-popover-scroll.js.map +0 -1
- package/build-module/components/list-view/appender.js +0 -76
- package/build-module/components/list-view/appender.js.map +0 -1
- package/build-module/components/list-view/list-item.js +0 -47
- package/build-module/components/list-view/list-item.js.map +0 -1
- package/build-module/components/rich-text/use-caret-in-format.js +0 -33
- package/build-module/components/rich-text/use-caret-in-format.js.map +0 -1
- package/build-module/hooks/border-color.js +0 -276
- package/build-module/hooks/border-color.js.map +0 -1
- package/build-module/hooks/border-style.js +0 -78
- package/build-module/hooks/border-style.js.map +0 -1
- package/build-module/hooks/border-width.js +0 -143
- package/build-module/hooks/border-width.js.map +0 -1
- package/src/components/block-mobile-toolbar/index.js +0 -24
- package/src/components/block-mobile-toolbar/style.scss +0 -29
- package/src/components/list-view/appender.js +0 -82
- package/src/components/list-view/list-item.js +0 -59
- package/src/components/rich-text/use-caret-in-format.js +0 -28
- package/src/hooks/border-color.js +0 -315
- package/src/hooks/border-style.js +0 -64
- package/src/hooks/border-width.js +0 -139
|
@@ -60,28 +60,44 @@ export function getValuesFromColors() {
|
|
|
60
60
|
*/
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
63
|
+
* Stylesheet for rendering the duotone filter.
|
|
64
64
|
*
|
|
65
65
|
* @param {Object} props Duotone props.
|
|
66
66
|
* @param {string} props.selector Selector to apply the filter to.
|
|
67
67
|
* @param {string} props.id Unique id for this duotone filter.
|
|
68
|
-
* @param {Values} props.values R, G, B, and A values to filter with.
|
|
69
68
|
*
|
|
70
69
|
* @return {WPElement} Duotone element.
|
|
71
70
|
*/
|
|
72
71
|
|
|
73
|
-
function
|
|
72
|
+
function DuotoneStylesheet(_ref) {
|
|
74
73
|
let {
|
|
75
74
|
selector,
|
|
76
|
-
id
|
|
77
|
-
values
|
|
75
|
+
id
|
|
78
76
|
} = _ref;
|
|
79
|
-
const
|
|
77
|
+
const css = `
|
|
80
78
|
${selector} {
|
|
81
79
|
filter: url( #${id} );
|
|
82
80
|
}
|
|
83
81
|
`;
|
|
84
|
-
return createElement(
|
|
82
|
+
return createElement("style", null, css);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* SVG for rendering the duotone filter.
|
|
86
|
+
*
|
|
87
|
+
* @param {Object} props Duotone props.
|
|
88
|
+
* @param {string} props.id Unique id for this duotone filter.
|
|
89
|
+
* @param {Values} props.values R, G, B, and A values to filter with.
|
|
90
|
+
*
|
|
91
|
+
* @return {WPElement} Duotone element.
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
function DuotoneFilter(_ref2) {
|
|
96
|
+
let {
|
|
97
|
+
id,
|
|
98
|
+
values
|
|
99
|
+
} = _ref2;
|
|
100
|
+
return createElement(SVG, {
|
|
85
101
|
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
|
86
102
|
viewBox: "0 0 0 0",
|
|
87
103
|
width: "0",
|
|
@@ -121,18 +137,40 @@ ${selector} {
|
|
|
121
137
|
// Re-mask the image with the original transparency since the feColorMatrix above loses that information.
|
|
122
138
|
in2: "SourceGraphic",
|
|
123
139
|
operator: "in"
|
|
124
|
-
}))))
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
140
|
+
}))));
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* SVG and stylesheet needed for rendering the duotone filter.
|
|
144
|
+
*
|
|
145
|
+
* @param {Object} props Duotone props.
|
|
146
|
+
* @param {string} props.selector Selector to apply the filter to.
|
|
147
|
+
* @param {string} props.id Unique id for this duotone filter.
|
|
148
|
+
* @param {Values} props.values R, G, B, and A values to filter with.
|
|
149
|
+
*
|
|
150
|
+
* @return {WPElement} Duotone element.
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
function InlineDuotone(_ref3) {
|
|
155
|
+
let {
|
|
156
|
+
selector,
|
|
157
|
+
id,
|
|
158
|
+
values
|
|
159
|
+
} = _ref3;
|
|
160
|
+
return createElement(Fragment, null, createElement(DuotoneFilter, {
|
|
161
|
+
id: id,
|
|
162
|
+
values: values
|
|
163
|
+
}), createElement(DuotoneStylesheet, {
|
|
164
|
+
id: id,
|
|
165
|
+
selector: selector
|
|
128
166
|
}));
|
|
129
167
|
}
|
|
130
168
|
|
|
131
|
-
function useMultiOriginPresets(
|
|
169
|
+
function useMultiOriginPresets(_ref4) {
|
|
132
170
|
let {
|
|
133
171
|
presetSetting,
|
|
134
172
|
defaultSetting
|
|
135
|
-
} =
|
|
173
|
+
} = _ref4;
|
|
136
174
|
const disableDefault = !useSetting(defaultSetting);
|
|
137
175
|
const userPresets = useSetting(`${presetSetting}.custom`) || EMPTY_ARRAY;
|
|
138
176
|
const themePresets = useSetting(`${presetSetting}.theme`) || EMPTY_ARRAY;
|
|
@@ -140,13 +178,13 @@ function useMultiOriginPresets(_ref2) {
|
|
|
140
178
|
return useMemo(() => [...userPresets, ...themePresets, ...(disableDefault ? EMPTY_ARRAY : defaultPresets)], [disableDefault, userPresets, themePresets, defaultPresets]);
|
|
141
179
|
}
|
|
142
180
|
|
|
143
|
-
function DuotonePanel(
|
|
181
|
+
function DuotonePanel(_ref5) {
|
|
144
182
|
var _style$color;
|
|
145
183
|
|
|
146
184
|
let {
|
|
147
185
|
attributes,
|
|
148
186
|
setAttributes
|
|
149
|
-
} =
|
|
187
|
+
} = _ref5;
|
|
150
188
|
const style = attributes === null || attributes === void 0 ? void 0 : attributes.style;
|
|
151
189
|
const duotone = style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.duotone;
|
|
152
190
|
const duotonePalette = useMultiOriginPresets({
|
|
@@ -281,7 +319,7 @@ const withDuotoneStyles = createHigherOrderComponent(BlockListBlock => props =>
|
|
|
281
319
|
const selectorsGroup = scopeSelector(`.editor-styles-wrapper .${id}`, duotoneSupport);
|
|
282
320
|
const className = classnames(props === null || props === void 0 ? void 0 : props.className, id);
|
|
283
321
|
const element = useContext(BlockList.__unstableElementContext);
|
|
284
|
-
return createElement(Fragment, null, element && createPortal(createElement(
|
|
322
|
+
return createElement(Fragment, null, element && createPortal(createElement(InlineDuotone, {
|
|
285
323
|
selector: selectorsGroup,
|
|
286
324
|
id: id,
|
|
287
325
|
values: getValuesFromColors(values)
|
|
@@ -289,6 +327,15 @@ const withDuotoneStyles = createHigherOrderComponent(BlockListBlock => props =>
|
|
|
289
327
|
className: className
|
|
290
328
|
})));
|
|
291
329
|
}, 'withDuotoneStyles');
|
|
330
|
+
export function PresetDuotoneFilter(_ref6) {
|
|
331
|
+
let {
|
|
332
|
+
preset
|
|
333
|
+
} = _ref6;
|
|
334
|
+
return createElement(DuotoneFilter, {
|
|
335
|
+
id: `wp-duotone-${preset.slug}`,
|
|
336
|
+
values: getValuesFromColors(preset.colors)
|
|
337
|
+
});
|
|
338
|
+
}
|
|
292
339
|
addFilter('blocks.registerBlockType', 'core/editor/duotone/add-attributes', addDuotoneAttributes);
|
|
293
340
|
addFilter('editor.BlockEdit', 'core/editor/duotone/with-editor-controls', withDuotoneControls);
|
|
294
341
|
addFilter('editor.BlockListBlock', 'core/editor/duotone/with-styles', withDuotoneStyles);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/duotone.js"],"names":["classnames","colord","extend","namesPlugin","getBlockSupport","hasBlockSupport","SVG","createHigherOrderComponent","useInstanceId","addFilter","useMemo","useContext","createPortal","BlockControls","__experimentalDuotoneControl","DuotoneControl","useSetting","BlockList","EMPTY_ARRAY","getValuesFromColors","colors","values","r","g","b","a","forEach","color","rgbColor","toRgb","push","DuotoneFilter","selector","id","stylesheet","visibility","position","left","overflow","join","__html","useMultiOriginPresets","presetSetting","defaultSetting","disableDefault","userPresets","themePresets","defaultPresets","DuotonePanel","attributes","setAttributes","style","duotone","duotonePalette","colorPalette","disableCustomColors","disableCustomDuotone","length","newDuotone","newStyle","addDuotoneAttributes","settings","Object","assign","type","withDuotoneControls","BlockEdit","props","hasDuotoneSupport","name","scopeSelector","scope","scopes","split","selectors","selectorsScoped","outer","inner","trim","withDuotoneStyles","BlockListBlock","duotoneSupport","selectorsGroup","className","element","__unstableElementContext"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,MAAT,EAAiBC,MAAjB,QAA+B,QAA/B;AACA,O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,CAAT;AAKAnD,SAAS,CACR,kBADQ,EAER,0CAFQ,EAGRwD,mBAHQ,CAAT;AAKAxD,SAAS,CACR,uBADQ,EAER,iCAFQ,EAGRsE,iBAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { SVG } from '@wordpress/components';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useMemo, useContext, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockControls,\n\t__experimentalDuotoneControl as DuotoneControl,\n\tuseSetting,\n} from '../components';\nimport BlockList from '../components/block-list';\n\nconst EMPTY_ARRAY = [];\n\nextend( [ namesPlugin ] );\n\n/**\n * Convert a list of colors to an object of R, G, and B values.\n *\n * @param {string[]} colors Array of RBG color strings.\n *\n * @return {Object} R, G, and B values.\n */\nexport function getValuesFromColors( colors = [] ) {\n\tconst values = { r: [], g: [], b: [], a: [] };\n\n\tcolors.forEach( ( color ) => {\n\t\tconst rgbColor = colord( color ).toRgb();\n\t\tvalues.r.push( rgbColor.r / 255 );\n\t\tvalues.g.push( rgbColor.g / 255 );\n\t\tvalues.b.push( rgbColor.b / 255 );\n\t\tvalues.a.push( rgbColor.a );\n\t} );\n\n\treturn values;\n}\n\n/**\n * Values for the SVG `feComponentTransfer`.\n *\n * @typedef Values {Object}\n * @property {number[]} r Red values.\n * @property {number[]} g Green values.\n * @property {number[]} b Blue values.\n * @property {number[]} a Alpha values.\n */\n\n/**\n * SVG and stylesheet needed for rendering the duotone filter.\n *\n * @param {Object} props Duotone props.\n * @param {string} props.selector Selector to apply the filter to.\n * @param {string} props.id Unique id for this duotone filter.\n * @param {Values} props.values R, G, B, and A values to filter with.\n *\n * @return {WPElement} Duotone element.\n */\nfunction DuotoneFilter( { selector, id, values } ) {\n\tconst stylesheet = `\n${ selector } {\n\tfilter: url( #${ id } );\n}\n`;\n\n\treturn (\n\t\t<>\n\t\t\t<SVG\n\t\t\t\txmlnsXlink=\"http://www.w3.org/1999/xlink\"\n\t\t\t\tviewBox=\"0 0 0 0\"\n\t\t\t\twidth=\"0\"\n\t\t\t\theight=\"0\"\n\t\t\t\tfocusable=\"false\"\n\t\t\t\trole=\"none\"\n\t\t\t\tstyle={ {\n\t\t\t\t\tvisibility: 'hidden',\n\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\tleft: '-9999px',\n\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<defs>\n\t\t\t\t\t<filter id={ id }>\n\t\t\t\t\t\t<feColorMatrix\n\t\t\t\t\t\t\t// Use sRGB instead of linearRGB so transparency looks correct.\n\t\t\t\t\t\t\tcolorInterpolationFilters=\"sRGB\"\n\t\t\t\t\t\t\ttype=\"matrix\"\n\t\t\t\t\t\t\t// Use perceptual brightness to convert to grayscale.\n\t\t\t\t\t\t\tvalues=\"\n\t\t\t\t\t\t\t\t.299 .587 .114 0 0\n\t\t\t\t\t\t\t\t.299 .587 .114 0 0\n\t\t\t\t\t\t\t\t.299 .587 .114 0 0\n\t\t\t\t\t\t\t\t.299 .587 .114 0 0\n\t\t\t\t\t\t\t\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<feComponentTransfer\n\t\t\t\t\t\t\t// Use sRGB instead of linearRGB to be consistent with how CSS gradients work.\n\t\t\t\t\t\t\tcolorInterpolationFilters=\"sRGB\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<feFuncR\n\t\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\t\ttableValues={ values.r.join( ' ' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<feFuncG\n\t\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\t\ttableValues={ values.g.join( ' ' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<feFuncB\n\t\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\t\ttableValues={ values.b.join( ' ' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<feFuncA\n\t\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\t\ttableValues={ values.a.join( ' ' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</feComponentTransfer>\n\t\t\t\t\t\t<feComposite\n\t\t\t\t\t\t\t// Re-mask the image with the original transparency since the feColorMatrix above loses that information.\n\t\t\t\t\t\t\tin2=\"SourceGraphic\"\n\t\t\t\t\t\t\toperator=\"in\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</filter>\n\t\t\t\t</defs>\n\t\t\t</SVG>\n\t\t\t<style dangerouslySetInnerHTML={ { __html: stylesheet } } />\n\t\t</>\n\t);\n}\n\nfunction useMultiOriginPresets( { presetSetting, defaultSetting } ) {\n\tconst disableDefault = ! useSetting( defaultSetting );\n\tconst userPresets =\n\t\tuseSetting( `${ presetSetting }.custom` ) || EMPTY_ARRAY;\n\tconst themePresets =\n\t\tuseSetting( `${ presetSetting }.theme` ) || EMPTY_ARRAY;\n\tconst defaultPresets =\n\t\tuseSetting( `${ presetSetting }.default` ) || EMPTY_ARRAY;\n\treturn useMemo(\n\t\t() => [\n\t\t\t...userPresets,\n\t\t\t...themePresets,\n\t\t\t...( disableDefault ? EMPTY_ARRAY : defaultPresets ),\n\t\t],\n\t\t[ disableDefault, userPresets, themePresets, defaultPresets ]\n\t);\n}\n\nfunction DuotonePanel( { attributes, setAttributes } ) {\n\tconst style = attributes?.style;\n\tconst duotone = style?.color?.duotone;\n\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\tconst colorPalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.palette',\n\t\tdefaultSetting: 'color.defaultPalette',\n\t} );\n\tconst disableCustomColors = ! useSetting( 'color.custom' );\n\tconst disableCustomDuotone =\n\t\t! useSetting( 'color.customDuotone' ) ||\n\t\t( colorPalette?.length === 0 && disableCustomColors );\n\n\tif ( duotonePalette?.length === 0 && disableCustomDuotone ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t<DuotoneControl\n\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\tvalue={ duotone }\n\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t...style,\n\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t...style?.color,\n\t\t\t\t\t\t\tduotone: newDuotone,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tsetAttributes( { style: newStyle } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `duotone` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addDuotoneAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, 'color.__experimentalDuotone' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default\n\t// values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include toolbar controls for duotone if the\n * block supports duotone.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst hasDuotoneSupport = hasBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ hasDuotoneSupport && <DuotonePanel { ...props } /> }\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneControls'\n);\n\n/**\n * Function that scopes a selector with another one. This works a bit like\n * SCSS nesting except the `&` operator isn't supported.\n *\n * @example\n * ```js\n * const scope = '.a, .b .c';\n * const selector = '> .x, .y';\n * const merged = scopeSelector( scope, selector );\n * // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'\n * ```\n *\n * @param {string} scope Selector to scope to.\n * @param {string} selector Original selector.\n *\n * @return {string} Scoped selector.\n */\nfunction scopeSelector( scope, selector ) {\n\tconst scopes = scope.split( ',' );\n\tconst selectors = selector.split( ',' );\n\n\tconst selectorsScoped = [];\n\tscopes.forEach( ( outer ) => {\n\t\tselectors.forEach( ( inner ) => {\n\t\t\tselectorsScoped.push( `${ outer.trim() } ${ inner.trim() }` );\n\t\t} );\n\t} );\n\n\treturn selectorsScoped.join( ', ' );\n}\n\n/**\n * Override the default block element to include duotone styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst duotoneSupport = getBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\t\tconst values = props?.attributes?.style?.color?.duotone;\n\n\t\tif ( ! duotoneSupport || ! values ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst id = `wp-duotone-${ useInstanceId( BlockListBlock ) }`;\n\n\t\t// Extra .editor-styles-wrapper specificity is needed in the editor\n\t\t// since we're not using inline styles to apply the filter. We need to\n\t\t// override duotone applied by global styles and theme.json.\n\t\tconst selectorsGroup = scopeSelector(\n\t\t\t`.editor-styles-wrapper .${ id }`,\n\t\t\tduotoneSupport\n\t\t);\n\n\t\tconst className = classnames( props?.className, id );\n\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ element &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<DuotoneFilter\n\t\t\t\t\t\t\tselector={ selectorsGroup }\n\t\t\t\t\t\t\tid={ id }\n\t\t\t\t\t\t\tvalues={ getValuesFromColors( values ) }\n\t\t\t\t\t\t/>,\n\t\t\t\t\t\telement\n\t\t\t\t\t) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/duotone/add-attributes',\n\taddDuotoneAttributes\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/duotone/with-editor-controls',\n\twithDuotoneControls\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/duotone/with-styles',\n\twithDuotoneStyles\n);\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/duotone.js"],"names":["classnames","colord","extend","namesPlugin","getBlockSupport","hasBlockSupport","SVG","createHigherOrderComponent","useInstanceId","addFilter","useMemo","useContext","createPortal","BlockControls","__experimentalDuotoneControl","DuotoneControl","useSetting","BlockList","EMPTY_ARRAY","getValuesFromColors","colors","values","r","g","b","a","forEach","color","rgbColor","toRgb","push","DuotoneStylesheet","selector","id","css","DuotoneFilter","visibility","position","left","overflow","join","InlineDuotone","useMultiOriginPresets","presetSetting","defaultSetting","disableDefault","userPresets","themePresets","defaultPresets","DuotonePanel","attributes","setAttributes","style","duotone","duotonePalette","colorPalette","disableCustomColors","disableCustomDuotone","length","newDuotone","newStyle","addDuotoneAttributes","settings","Object","assign","type","withDuotoneControls","BlockEdit","props","hasDuotoneSupport","name","scopeSelector","scope","scopes","split","selectors","selectorsScoped","outer","inner","trim","withDuotoneStyles","BlockListBlock","duotoneSupport","selectorsGroup","className","element","__unstableElementContext","PresetDuotoneFilter","preset","slug"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,MAAT,EAAiBC,MAAjB,QAA+B,QAA/B;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AAEA;AACA;AACA;;AACA,SAASC,eAAT,EAA0BC,eAA1B,QAAiD,mBAAjD;AACA,SAASC,GAAT,QAAoB,uBAApB;AACA,SAASC,0BAAT,EAAqCC,aAArC,QAA0D,oBAA1D;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,OAAT,EAAkBC,UAAlB,EAA8BC,YAA9B,QAAkD,oBAAlD;AAEA;AACA;AACA;;AACA,SACCC,aADD,EAECC,4BAA4B,IAAIC,cAFjC,EAGCC,UAHD,QAIO,eAJP;AAKA,OAAOC,SAAP,MAAsB,0BAAtB;AAEA,MAAMC,WAAW,GAAG,EAApB;AAEAhB,MAAM,CAAE,CAAEC,WAAF,CAAF,CAAN;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASgB,mBAAT,GAA4C;AAAA,MAAdC,MAAc,uEAAL,EAAK;AAClD,QAAMC,MAAM,GAAG;AAAEC,IAAAA,CAAC,EAAE,EAAL;AAASC,IAAAA,CAAC,EAAE,EAAZ;AAAgBC,IAAAA,CAAC,EAAE,EAAnB;AAAuBC,IAAAA,CAAC,EAAE;AAA1B,GAAf;AAEAL,EAAAA,MAAM,CAACM,OAAP,CAAkBC,KAAF,IAAa;AAC5B,UAAMC,QAAQ,GAAG3B,MAAM,CAAE0B,KAAF,CAAN,CAAgBE,KAAhB,EAAjB;AACAR,IAAAA,MAAM,CAACC,CAAP,CAASQ,IAAT,CAAeF,QAAQ,CAACN,CAAT,GAAa,GAA5B;AACAD,IAAAA,MAAM,CAACE,CAAP,CAASO,IAAT,CAAeF,QAAQ,CAACL,CAAT,GAAa,GAA5B;AACAF,IAAAA,MAA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C,2BAA2BtC,EAAI,EADG,EAEnCiD,cAFmC,CAApC;AAKA,QAAME,SAAS,GAAGpF,UAAU,CAAEoE,KAAF,aAAEA,KAAF,uBAAEA,KAAK,CAAEgB,SAAT,EAAoBnD,EAApB,CAA5B;AAEA,QAAMoD,OAAO,GAAG1E,UAAU,CAAEM,SAAS,CAACqE,wBAAZ,CAA1B;AAEA,SACC,8BACGD,OAAO,IACRzE,YAAY,CACX,cAAC,aAAD;AACC,IAAA,QAAQ,EAAGuE,cADZ;AAEC,IAAA,EAAE,EAAGlD,EAFN;AAGC,IAAA,MAAM,EAAGd,mBAAmB,CAAEE,MAAF;AAH7B,IADW,EAMXgE,OANW,CAFd,EAUC,cAAC,cAAD,eAAqBjB,KAArB;AAA6B,IAAA,SAAS,EAAGgB;AAAzC,KAVD,CADD;AAcA,CAxCkD,EAyCnD,mBAzCmD,CAApD;AA4CA,OAAO,SAASG,mBAAT,QAA2C;AAAA,MAAb;AAAEC,IAAAA;AAAF,GAAa;AACjD,SACC,cAAC,aAAD;AACC,IAAA,EAAE,EAAI,cAAcA,MAAM,CAACC,IAAM,EADlC;AAEC,IAAA,MAAM,EAAGtE,mBAAmB,CAAEqE,MAAM,CAACpE,MAAT;AAF7B,IADD;AAMA;AAEDX,SAAS,CACR,0BADQ,EAER,oCAFQ,EAGRoD,oBAHQ,CAAT;AAKApD,SAAS,CACR,kBADQ,EAER,0CAFQ,EAGRyD,mBAHQ,CAAT;AAKAzD,SAAS,CACR,uBADQ,EAER,iCAFQ,EAGRuE,iBAHQ,CAAT","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { SVG } from '@wordpress/components';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useMemo, useContext, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockControls,\n\t__experimentalDuotoneControl as DuotoneControl,\n\tuseSetting,\n} from '../components';\nimport BlockList from '../components/block-list';\n\nconst EMPTY_ARRAY = [];\n\nextend( [ namesPlugin ] );\n\n/**\n * Convert a list of colors to an object of R, G, and B values.\n *\n * @param {string[]} colors Array of RBG color strings.\n *\n * @return {Object} R, G, and B values.\n */\nexport function getValuesFromColors( colors = [] ) {\n\tconst values = { r: [], g: [], b: [], a: [] };\n\n\tcolors.forEach( ( color ) => {\n\t\tconst rgbColor = colord( color ).toRgb();\n\t\tvalues.r.push( rgbColor.r / 255 );\n\t\tvalues.g.push( rgbColor.g / 255 );\n\t\tvalues.b.push( rgbColor.b / 255 );\n\t\tvalues.a.push( rgbColor.a );\n\t} );\n\n\treturn values;\n}\n\n/**\n * Values for the SVG `feComponentTransfer`.\n *\n * @typedef Values {Object}\n * @property {number[]} r Red values.\n * @property {number[]} g Green values.\n * @property {number[]} b Blue values.\n * @property {number[]} a Alpha values.\n */\n\n/**\n * Stylesheet for rendering the duotone filter.\n *\n * @param {Object} props Duotone props.\n * @param {string} props.selector Selector to apply the filter to.\n * @param {string} props.id Unique id for this duotone filter.\n *\n * @return {WPElement} Duotone element.\n */\nfunction DuotoneStylesheet( { selector, id } ) {\n\tconst css = `\n${ selector } {\n\tfilter: url( #${ id } );\n}\n`;\n\treturn <style>{ css }</style>;\n}\n\n/**\n * SVG for rendering the duotone filter.\n *\n * @param {Object} props Duotone props.\n * @param {string} props.id Unique id for this duotone filter.\n * @param {Values} props.values R, G, B, and A values to filter with.\n *\n * @return {WPElement} Duotone element.\n */\nfunction DuotoneFilter( { id, values } ) {\n\treturn (\n\t\t<SVG\n\t\t\txmlnsXlink=\"http://www.w3.org/1999/xlink\"\n\t\t\tviewBox=\"0 0 0 0\"\n\t\t\twidth=\"0\"\n\t\t\theight=\"0\"\n\t\t\tfocusable=\"false\"\n\t\t\trole=\"none\"\n\t\t\tstyle={ {\n\t\t\t\tvisibility: 'hidden',\n\t\t\t\tposition: 'absolute',\n\t\t\t\tleft: '-9999px',\n\t\t\t\toverflow: 'hidden',\n\t\t\t} }\n\t\t>\n\t\t\t<defs>\n\t\t\t\t<filter id={ id }>\n\t\t\t\t\t<feColorMatrix\n\t\t\t\t\t\t// Use sRGB instead of linearRGB so transparency looks correct.\n\t\t\t\t\t\tcolorInterpolationFilters=\"sRGB\"\n\t\t\t\t\t\ttype=\"matrix\"\n\t\t\t\t\t\t// Use perceptual brightness to convert to grayscale.\n\t\t\t\t\t\tvalues=\"\n\t\t\t\t\t\t\t.299 .587 .114 0 0\n\t\t\t\t\t\t\t.299 .587 .114 0 0\n\t\t\t\t\t\t\t.299 .587 .114 0 0\n\t\t\t\t\t\t\t.299 .587 .114 0 0\n\t\t\t\t\t\t\"\n\t\t\t\t\t/>\n\t\t\t\t\t<feComponentTransfer\n\t\t\t\t\t\t// Use sRGB instead of linearRGB to be consistent with how CSS gradients work.\n\t\t\t\t\t\tcolorInterpolationFilters=\"sRGB\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<feFuncR\n\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\ttableValues={ values.r.join( ' ' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<feFuncG\n\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\ttableValues={ values.g.join( ' ' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<feFuncB\n\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\ttableValues={ values.b.join( ' ' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<feFuncA\n\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\ttableValues={ values.a.join( ' ' ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</feComponentTransfer>\n\t\t\t\t\t<feComposite\n\t\t\t\t\t\t// Re-mask the image with the original transparency since the feColorMatrix above loses that information.\n\t\t\t\t\t\tin2=\"SourceGraphic\"\n\t\t\t\t\t\toperator=\"in\"\n\t\t\t\t\t/>\n\t\t\t\t</filter>\n\t\t\t</defs>\n\t\t</SVG>\n\t);\n}\n\n/**\n * SVG and stylesheet needed for rendering the duotone filter.\n *\n * @param {Object} props Duotone props.\n * @param {string} props.selector Selector to apply the filter to.\n * @param {string} props.id Unique id for this duotone filter.\n * @param {Values} props.values R, G, B, and A values to filter with.\n *\n * @return {WPElement} Duotone element.\n */\nfunction InlineDuotone( { selector, id, values } ) {\n\treturn (\n\t\t<>\n\t\t\t<DuotoneFilter id={ id } values={ values } />\n\t\t\t<DuotoneStylesheet id={ id } selector={ selector } />\n\t\t</>\n\t);\n}\n\nfunction useMultiOriginPresets( { presetSetting, defaultSetting } ) {\n\tconst disableDefault = ! useSetting( defaultSetting );\n\tconst userPresets =\n\t\tuseSetting( `${ presetSetting }.custom` ) || EMPTY_ARRAY;\n\tconst themePresets =\n\t\tuseSetting( `${ presetSetting }.theme` ) || EMPTY_ARRAY;\n\tconst defaultPresets =\n\t\tuseSetting( `${ presetSetting }.default` ) || EMPTY_ARRAY;\n\treturn useMemo(\n\t\t() => [\n\t\t\t...userPresets,\n\t\t\t...themePresets,\n\t\t\t...( disableDefault ? EMPTY_ARRAY : defaultPresets ),\n\t\t],\n\t\t[ disableDefault, userPresets, themePresets, defaultPresets ]\n\t);\n}\n\nfunction DuotonePanel( { attributes, setAttributes } ) {\n\tconst style = attributes?.style;\n\tconst duotone = style?.color?.duotone;\n\n\tconst duotonePalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.duotone',\n\t\tdefaultSetting: 'color.defaultDuotone',\n\t} );\n\tconst colorPalette = useMultiOriginPresets( {\n\t\tpresetSetting: 'color.palette',\n\t\tdefaultSetting: 'color.defaultPalette',\n\t} );\n\tconst disableCustomColors = ! useSetting( 'color.custom' );\n\tconst disableCustomDuotone =\n\t\t! useSetting( 'color.customDuotone' ) ||\n\t\t( colorPalette?.length === 0 && disableCustomColors );\n\n\tif ( duotonePalette?.length === 0 && disableCustomDuotone ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockControls group=\"block\" __experimentalShareWithChildBlocks>\n\t\t\t<DuotoneControl\n\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\tvalue={ duotone }\n\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t...style,\n\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t...style?.color,\n\t\t\t\t\t\t\tduotone: newDuotone,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tsetAttributes( { style: newStyle } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `duotone` attribute.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nfunction addDuotoneAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, 'color.__experimentalDuotone' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default\n\t// values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include toolbar controls for duotone if the\n * block supports duotone.\n *\n * @param {Function} BlockEdit Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst hasDuotoneSupport = hasBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ hasDuotoneSupport && <DuotonePanel { ...props } /> }\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneControls'\n);\n\n/**\n * Function that scopes a selector with another one. This works a bit like\n * SCSS nesting except the `&` operator isn't supported.\n *\n * @example\n * ```js\n * const scope = '.a, .b .c';\n * const selector = '> .x, .y';\n * const merged = scopeSelector( scope, selector );\n * // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'\n * ```\n *\n * @param {string} scope Selector to scope to.\n * @param {string} selector Original selector.\n *\n * @return {string} Scoped selector.\n */\nfunction scopeSelector( scope, selector ) {\n\tconst scopes = scope.split( ',' );\n\tconst selectors = selector.split( ',' );\n\n\tconst selectorsScoped = [];\n\tscopes.forEach( ( outer ) => {\n\t\tselectors.forEach( ( inner ) => {\n\t\t\tselectorsScoped.push( `${ outer.trim() } ${ inner.trim() }` );\n\t\t} );\n\t} );\n\n\treturn selectorsScoped.join( ', ' );\n}\n\n/**\n * Override the default block element to include duotone styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nconst withDuotoneStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst duotoneSupport = getBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\t\tconst values = props?.attributes?.style?.color?.duotone;\n\n\t\tif ( ! duotoneSupport || ! values ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst id = `wp-duotone-${ useInstanceId( BlockListBlock ) }`;\n\n\t\t// Extra .editor-styles-wrapper specificity is needed in the editor\n\t\t// since we're not using inline styles to apply the filter. We need to\n\t\t// override duotone applied by global styles and theme.json.\n\t\tconst selectorsGroup = scopeSelector(\n\t\t\t`.editor-styles-wrapper .${ id }`,\n\t\t\tduotoneSupport\n\t\t);\n\n\t\tconst className = classnames( props?.className, id );\n\n\t\tconst element = useContext( BlockList.__unstableElementContext );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ element &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<InlineDuotone\n\t\t\t\t\t\t\tselector={ selectorsGroup }\n\t\t\t\t\t\t\tid={ id }\n\t\t\t\t\t\t\tvalues={ getValuesFromColors( values ) }\n\t\t\t\t\t\t/>,\n\t\t\t\t\t\telement\n\t\t\t\t\t) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneStyles'\n);\n\nexport function PresetDuotoneFilter( { preset } ) {\n\treturn (\n\t\t<DuotoneFilter\n\t\t\tid={ `wp-duotone-${ preset.slug }` }\n\t\t\tvalues={ getValuesFromColors( preset.colors ) }\n\t\t/>\n\t);\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/duotone/add-attributes',\n\taddDuotoneAttributes\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/duotone/with-editor-controls',\n\twithDuotoneControls\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/duotone/with-styles',\n\twithDuotoneStyles\n);\n"]}
|
|
@@ -11,11 +11,12 @@ import './style';
|
|
|
11
11
|
import './color';
|
|
12
12
|
import './duotone';
|
|
13
13
|
import './font-size';
|
|
14
|
-
import './border
|
|
14
|
+
import './border';
|
|
15
15
|
import './layout';
|
|
16
16
|
export { useCustomSides } from './dimensions';
|
|
17
17
|
export { getBorderClassesAndStyles, useBorderProps } from './use-border-props';
|
|
18
18
|
export { getColorClassesAndStyles, useColorProps } from './use-color-props';
|
|
19
19
|
export { getSpacingClassesAndStyles } from './use-spacing-props';
|
|
20
20
|
export { useCachedTruthy } from './use-cached-truthy';
|
|
21
|
+
export { PresetDuotoneFilter } from './duotone';
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/index.js"],"names":["useCustomSides","getBorderClassesAndStyles","useBorderProps","getColorClassesAndStyles","useColorProps","getSpacingClassesAndStyles","useCachedTruthy"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,UAAP;AACA,OAAO,SAAP;AACA,OAAO,QAAP;AACA,OAAO,UAAP;AACA,OAAO,qBAAP;AACA,OAAO,wBAAP;AACA,OAAO,SAAP;AACA,OAAO,SAAP;AACA,OAAO,WAAP;AACA,OAAO,aAAP;AACA,OAAO,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/index.js"],"names":["useCustomSides","getBorderClassesAndStyles","useBorderProps","getColorClassesAndStyles","useColorProps","getSpacingClassesAndStyles","useCachedTruthy","PresetDuotoneFilter"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,UAAP;AACA,OAAO,SAAP;AACA,OAAO,QAAP;AACA,OAAO,UAAP;AACA,OAAO,qBAAP;AACA,OAAO,wBAAP;AACA,OAAO,SAAP;AACA,OAAO,SAAP;AACA,OAAO,WAAP;AACA,OAAO,aAAP;AACA,OAAO,UAAP;AACA,OAAO,UAAP;AAEA,SAASA,cAAT,QAA+B,cAA/B;AACA,SAASC,yBAAT,EAAoCC,cAApC,QAA0D,oBAA1D;AACA,SAASC,wBAAT,EAAmCC,aAAnC,QAAwD,mBAAxD;AACA,SAASC,0BAAT,QAA2C,qBAA3C;AACA,SAASC,eAAT,QAAgC,qBAAhC;AACA,SAASC,mBAAT,QAAoC,WAApC","sourcesContent":["/**\n * Internal dependencies\n */\nimport './compat';\nimport './align';\nimport './lock';\nimport './anchor';\nimport './custom-class-name';\nimport './generated-class-name';\nimport './style';\nimport './color';\nimport './duotone';\nimport './font-size';\nimport './border';\nimport './layout';\n\nexport { useCustomSides } from './dimensions';\nexport { getBorderClassesAndStyles, useBorderProps } from './use-border-props';\nexport { getColorClassesAndStyles, useColorProps } from './use-color-props';\nexport { getSpacingClassesAndStyles } from './use-spacing-props';\nexport { useCachedTruthy } from './use-cached-truthy';\nexport { PresetDuotoneFilter } from './duotone';\n"]}
|
|
@@ -1,46 +1,29 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import classnames from 'classnames';
|
|
5
1
|
/**
|
|
6
2
|
* Internal dependencies
|
|
7
3
|
*/
|
|
8
|
-
|
|
9
4
|
import { getInlineStyles } from './style';
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
5
|
+
import { getBorderClasses, getMultiOriginColor } from './border';
|
|
6
|
+
import useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients'; // This utility is intended to assist where the serialization of the border
|
|
12
7
|
// block support is being skipped for a block but the border related CSS classes
|
|
13
8
|
// & styles still need to be generated so they can be applied to inner elements.
|
|
14
9
|
|
|
15
|
-
const EMPTY_ARRAY = [];
|
|
16
10
|
/**
|
|
17
11
|
* Provides the CSS class names and inline styles for a block's border support
|
|
18
12
|
* attributes.
|
|
19
13
|
*
|
|
20
|
-
* @param {Object} attributes
|
|
21
|
-
* @param {string} attributes.borderColor Selected named border color.
|
|
22
|
-
* @param {Object} attributes.style Block's styles attribute.
|
|
23
|
-
*
|
|
14
|
+
* @param {Object} attributes Block attributes.
|
|
24
15
|
* @return {Object} Border block support derived CSS classes & styles.
|
|
25
16
|
*/
|
|
26
17
|
|
|
27
|
-
export function getBorderClassesAndStyles(
|
|
28
|
-
var
|
|
18
|
+
export function getBorderClassesAndStyles(attributes) {
|
|
19
|
+
var _attributes$style;
|
|
29
20
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
style
|
|
33
|
-
} = _ref;
|
|
34
|
-
const borderStyles = (style === null || style === void 0 ? void 0 : style.border) || {};
|
|
35
|
-
const borderClass = getColorClassName('border-color', borderColor);
|
|
36
|
-
const className = classnames({
|
|
37
|
-
[borderClass]: !!borderClass,
|
|
38
|
-
'has-border-color': borderColor || (style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.color)
|
|
39
|
-
});
|
|
21
|
+
const border = ((_attributes$style = attributes.style) === null || _attributes$style === void 0 ? void 0 : _attributes$style.border) || {};
|
|
22
|
+
const className = getBorderClasses(attributes);
|
|
40
23
|
return {
|
|
41
24
|
className: className || undefined,
|
|
42
25
|
style: getInlineStyles({
|
|
43
|
-
border
|
|
26
|
+
border
|
|
44
27
|
})
|
|
45
28
|
};
|
|
46
29
|
}
|
|
@@ -57,12 +40,20 @@ export function getBorderClassesAndStyles(_ref) {
|
|
|
57
40
|
*/
|
|
58
41
|
|
|
59
42
|
export function useBorderProps(attributes) {
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
43
|
+
const {
|
|
44
|
+
colors
|
|
45
|
+
} = useMultipleOriginColorsAndGradients();
|
|
46
|
+
const borderProps = getBorderClassesAndStyles(attributes);
|
|
47
|
+
const {
|
|
48
|
+
borderColor
|
|
49
|
+
} = attributes; // Force inline styles to apply named border colors when themes do not load
|
|
50
|
+
// their color stylesheets in the editor.
|
|
63
51
|
|
|
64
|
-
if (
|
|
65
|
-
const borderColorObject =
|
|
52
|
+
if (borderColor) {
|
|
53
|
+
const borderColorObject = getMultiOriginColor({
|
|
54
|
+
colors,
|
|
55
|
+
namedColor: borderColor
|
|
56
|
+
});
|
|
66
57
|
borderProps.style.borderColor = borderColorObject.color;
|
|
67
58
|
}
|
|
68
59
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/use-border-props.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/use-border-props.js"],"names":["getInlineStyles","getBorderClasses","getMultiOriginColor","useMultipleOriginColorsAndGradients","getBorderClassesAndStyles","attributes","border","style","className","undefined","useBorderProps","colors","borderProps","borderColor","borderColorObject","namedColor","color"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAT,QAAgC,SAAhC;AACA,SAASC,gBAAT,EAA2BC,mBAA3B,QAAsD,UAAtD;AACA,OAAOC,mCAAP,MAAgD,yEAAhD,C,CAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,yBAAT,CAAoCC,UAApC,EAAiD;AAAA;;AACvD,QAAMC,MAAM,GAAG,sBAAAD,UAAU,CAACE,KAAX,wEAAkBD,MAAlB,KAA4B,EAA3C;AACA,QAAME,SAAS,GAAGP,gBAAgB,CAAEI,UAAF,CAAlC;AAEA,SAAO;AACNG,IAAAA,SAAS,EAAEA,SAAS,IAAIC,SADlB;AAENF,IAAAA,KAAK,EAAEP,eAAe,CAAE;AAAEM,MAAAA;AAAF,KAAF;AAFhB,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASI,cAAT,CAAyBL,UAAzB,EAAsC;AAC5C,QAAM;AAAEM,IAAAA;AAAF,MAAaR,mCAAmC,EAAtD;AACA,QAAMS,WAAW,GAAGR,yBAAyB,CAAEC,UAAF,CAA7C;AACA,QAAM;AAAEQ,IAAAA;AAAF,MAAkBR,UAAxB,CAH4C,CAK5C;AACA;;AACA,MAAKQ,WAAL,EAAmB;AAClB,UAAMC,iBAAiB,GAAGZ,mBAAmB,CAAE;AAC9CS,MAAAA,MAD8C;AAE9CI,MAAAA,UAAU,EAAEF;AAFkC,KAAF,CAA7C;AAKAD,IAAAA,WAAW,CAACL,KAAZ,CAAkBM,WAAlB,GAAgCC,iBAAiB,CAACE,KAAlD;AACA;;AAED,SAAOJ,WAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { getInlineStyles } from './style';\nimport { getBorderClasses, getMultiOriginColor } from './border';\nimport useMultipleOriginColorsAndGradients from '../components/colors-gradients/use-multiple-origin-colors-and-gradients';\n\n// This utility is intended to assist where the serialization of the border\n// block support is being skipped for a block but the border 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 border support\n * attributes.\n *\n * @param {Object} attributes Block attributes.\n * @return {Object} Border block support derived CSS classes & styles.\n */\nexport function getBorderClassesAndStyles( attributes ) {\n\tconst border = attributes.style?.border || {};\n\tconst className = getBorderClasses( attributes );\n\n\treturn {\n\t\tclassName: className || undefined,\n\t\tstyle: getInlineStyles( { border } ),\n\t};\n}\n\n/**\n * Derives the border related props for a block from its border block support\n * 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 border block support.\n */\nexport function useBorderProps( attributes ) {\n\tconst { colors } = useMultipleOriginColorsAndGradients();\n\tconst borderProps = getBorderClassesAndStyles( attributes );\n\tconst { borderColor } = attributes;\n\n\t// Force inline styles to apply named border colors when themes do not load\n\t// their color stylesheets in the editor.\n\tif ( borderColor ) {\n\t\tconst borderColorObject = getMultiOriginColor( {\n\t\t\tcolors,\n\t\t\tnamedColor: borderColor,\n\t\t} );\n\n\t\tborderProps.style.borderColor = borderColorObject.color;\n\t}\n\n\treturn borderProps;\n}\n"]}
|
package/build-module/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import './hooks';
|
|
5
|
-
export { getBorderClassesAndStyles as __experimentalGetBorderClassesAndStyles, useBorderProps as __experimentalUseBorderProps, getColorClassesAndStyles as __experimentalGetColorClassesAndStyles, useColorProps as __experimentalUseColorProps, useCustomSides as __experimentalUseCustomSides, getSpacingClassesAndStyles as __experimentalGetSpacingClassesAndStyles, useCachedTruthy } from './hooks';
|
|
5
|
+
export { PresetDuotoneFilter as __unstablePresetDuotoneFilter, getBorderClassesAndStyles as __experimentalGetBorderClassesAndStyles, useBorderProps as __experimentalUseBorderProps, getColorClassesAndStyles as __experimentalGetColorClassesAndStyles, useColorProps as __experimentalUseColorProps, useCustomSides as __experimentalUseCustomSides, getSpacingClassesAndStyles as __experimentalGetSpacingClassesAndStyles, useCachedTruthy } from './hooks';
|
|
6
6
|
export * from './components';
|
|
7
7
|
export * from './utils';
|
|
8
8
|
export { storeConfig, store } from './store';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/index.js"],"names":["getBorderClassesAndStyles","__experimentalGetBorderClassesAndStyles","useBorderProps","__experimentalUseBorderProps","getColorClassesAndStyles","__experimentalGetColorClassesAndStyles","useColorProps","__experimentalUseColorProps","useCustomSides","__experimentalUseCustomSides","getSpacingClassesAndStyles","__experimentalGetSpacingClassesAndStyles","useCachedTruthy","storeConfig","store","SETTINGS_DEFAULTS"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,SAAP;AACA,SACCA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/index.js"],"names":["PresetDuotoneFilter","__unstablePresetDuotoneFilter","getBorderClassesAndStyles","__experimentalGetBorderClassesAndStyles","useBorderProps","__experimentalUseBorderProps","getColorClassesAndStyles","__experimentalGetColorClassesAndStyles","useColorProps","__experimentalUseColorProps","useCustomSides","__experimentalUseCustomSides","getSpacingClassesAndStyles","__experimentalGetSpacingClassesAndStyles","useCachedTruthy","storeConfig","store","SETTINGS_DEFAULTS"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,SAAP;AACA,SACCA,mBAAmB,IAAIC,6BADxB,EAECC,yBAAyB,IAAIC,uCAF9B,EAGCC,cAAc,IAAIC,4BAHnB,EAICC,wBAAwB,IAAIC,sCAJ7B,EAKCC,aAAa,IAAIC,2BALlB,EAMCC,cAAc,IAAIC,4BANnB,EAOCC,0BAA0B,IAAIC,wCAP/B,EAQCC,eARD,QASO,SATP;AAUA,cAAc,cAAd;AACA,cAAc,SAAd;AACA,SAASC,WAAT,EAAsBC,KAAtB,QAAmC,SAAnC;AACA,SAASC,iBAAT,QAAkC,kBAAlC","sourcesContent":["/**\n * Internal dependencies\n */\nimport './hooks';\nexport {\n\tPresetDuotoneFilter as __unstablePresetDuotoneFilter,\n\tgetBorderClassesAndStyles as __experimentalGetBorderClassesAndStyles,\n\tuseBorderProps as __experimentalUseBorderProps,\n\tgetColorClassesAndStyles as __experimentalGetColorClassesAndStyles,\n\tuseColorProps as __experimentalUseColorProps,\n\tuseCustomSides as __experimentalUseCustomSides,\n\tgetSpacingClassesAndStyles as __experimentalGetSpacingClassesAndStyles,\n\tuseCachedTruthy,\n} from './hooks';\nexport * from './components';\nexport * from './utils';\nexport { storeConfig, store } from './store';\nexport { SETTINGS_DEFAULTS } from './store/defaults';\n"]}
|
|
@@ -1147,23 +1147,35 @@ export function stopDraggingBlocks() {
|
|
|
1147
1147
|
/**
|
|
1148
1148
|
* Returns an action object used in signalling that the caret has entered formatted text.
|
|
1149
1149
|
*
|
|
1150
|
+
* @deprecated
|
|
1151
|
+
*
|
|
1150
1152
|
* @return {Object} Action object.
|
|
1151
1153
|
*/
|
|
1152
1154
|
|
|
1153
1155
|
export function enterFormattedText() {
|
|
1156
|
+
deprecated('wp.data.dispatch( "core/block-editor" ).enterFormattedText', {
|
|
1157
|
+
since: '6.1',
|
|
1158
|
+
version: '6.3'
|
|
1159
|
+
});
|
|
1154
1160
|
return {
|
|
1155
|
-
type: '
|
|
1161
|
+
type: 'DO_NOTHING'
|
|
1156
1162
|
};
|
|
1157
1163
|
}
|
|
1158
1164
|
/**
|
|
1159
1165
|
* Returns an action object used in signalling that the user caret has exited formatted text.
|
|
1160
1166
|
*
|
|
1167
|
+
* @deprecated
|
|
1168
|
+
*
|
|
1161
1169
|
* @return {Object} Action object.
|
|
1162
1170
|
*/
|
|
1163
1171
|
|
|
1164
1172
|
export function exitFormattedText() {
|
|
1173
|
+
deprecated('wp.data.dispatch( "core/block-editor" ).exitFormattedText', {
|
|
1174
|
+
since: '6.1',
|
|
1175
|
+
version: '6.3'
|
|
1176
|
+
});
|
|
1165
1177
|
return {
|
|
1166
|
-
type: '
|
|
1178
|
+
type: 'DO_NOTHING'
|
|
1167
1179
|
};
|
|
1168
1180
|
}
|
|
1169
1181
|
/**
|