changeset 21 | 48c4eec2b7e6 |
parent 19 | 3d72ae0968f4 |
child 22 | 8c2e4d02f4ef |
20:7b1b88e27a20 | 21:48c4eec2b7e6 |
---|---|
1 /******/ (function() { // webpackBootstrap |
1 /******/ (() => { // webpackBootstrap |
2 /******/ var __webpack_modules__ = ({ |
2 /******/ var __webpack_modules__ = ({ |
3 |
3 |
4 /***/ 9756: |
4 /***/ 7734: |
5 /***/ (function(module) { |
5 /***/ ((module) => { |
6 |
6 |
7 /** |
7 "use strict"; |
8 * Memize options object. |
8 |
9 * |
9 |
10 * @typedef MemizeOptions |
10 // do not edit .js files directly - edit src/index.jst |
11 * |
11 |
12 * @property {number} [maxSize] Maximum size of the cache. |
12 |
13 */ |
13 var envHasBigInt64Array = typeof BigInt64Array !== 'undefined'; |
14 |
14 |
15 /** |
15 |
16 * Internal cache entry. |
16 module.exports = function equal(a, b) { |
17 * |
17 if (a === b) return true; |
18 * @typedef MemizeCacheNode |
18 |
19 * |
19 if (a && b && typeof a == 'object' && typeof b == 'object') { |
20 * @property {?MemizeCacheNode|undefined} [prev] Previous node. |
20 if (a.constructor !== b.constructor) return false; |
21 * @property {?MemizeCacheNode|undefined} [next] Next node. |
21 |
22 * @property {Array<*>} args Function arguments for cache |
22 var length, i, keys; |
23 * entry. |
23 if (Array.isArray(a)) { |
24 * @property {*} val Function result. |
24 length = a.length; |
25 */ |
25 if (length != b.length) return false; |
26 |
26 for (i = length; i-- !== 0;) |
27 /** |
27 if (!equal(a[i], b[i])) return false; |
28 * Properties of the enhanced function for controlling cache. |
28 return true; |
29 * |
29 } |
30 * @typedef MemizeMemoizedFunction |
30 |
31 * |
31 |
32 * @property {()=>void} clear Clear the cache. |
32 if ((a instanceof Map) && (b instanceof Map)) { |
33 */ |
33 if (a.size !== b.size) return false; |
34 |
34 for (i of a.entries()) |
35 /** |
35 if (!b.has(i[0])) return false; |
36 * Accepts a function to be memoized, and returns a new memoized function, with |
36 for (i of a.entries()) |
37 * optional options. |
37 if (!equal(i[1], b.get(i[0]))) return false; |
38 * |
38 return true; |
39 * @template {Function} F |
39 } |
40 * |
40 |
41 * @param {F} fn Function to memoize. |
41 if ((a instanceof Set) && (b instanceof Set)) { |
42 * @param {MemizeOptions} [options] Options object. |
42 if (a.size !== b.size) return false; |
43 * |
43 for (i of a.entries()) |
44 * @return {F & MemizeMemoizedFunction} Memoized function. |
44 if (!b.has(i[0])) return false; |
45 */ |
45 return true; |
46 function memize( fn, options ) { |
46 } |
47 var size = 0; |
47 |
48 |
48 if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) { |
49 /** @type {?MemizeCacheNode|undefined} */ |
49 length = a.length; |
50 var head; |
50 if (length != b.length) return false; |
51 |
51 for (i = length; i-- !== 0;) |
52 /** @type {?MemizeCacheNode|undefined} */ |
52 if (a[i] !== b[i]) return false; |
53 var tail; |
53 return true; |
54 |
54 } |
55 options = options || {}; |
55 |
56 |
56 |
57 function memoized( /* ...args */ ) { |
57 if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags; |
58 var node = head, |
58 if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf(); |
59 len = arguments.length, |
59 if (a.toString !== Object.prototype.toString) return a.toString() === b.toString(); |
60 args, i; |
60 |
61 |
61 keys = Object.keys(a); |
62 searchCache: while ( node ) { |
62 length = keys.length; |
63 // Perform a shallow equality test to confirm that whether the node |
63 if (length !== Object.keys(b).length) return false; |
64 // under test is a candidate for the arguments passed. Two arrays |
64 |
65 // are shallowly equal if their length matches and each entry is |
65 for (i = length; i-- !== 0;) |
66 // strictly equal between the two sets. Avoid abstracting to a |
66 if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false; |
67 // function which could incur an arguments leaking deoptimization. |
67 |
68 |
68 for (i = length; i-- !== 0;) { |
69 // Check whether node arguments match arguments length |
69 var key = keys[i]; |
70 if ( node.args.length !== arguments.length ) { |
70 |
71 node = node.next; |
71 if (!equal(a[key], b[key])) return false; |
72 continue; |
72 } |
73 } |
73 |
74 |
74 return true; |
75 // Check whether node arguments match arguments values |
75 } |
76 for ( i = 0; i < len; i++ ) { |
76 |
77 if ( node.args[ i ] !== arguments[ i ] ) { |
77 // true if both NaN, false otherwise |
78 node = node.next; |
78 return a!==a && b!==b; |
79 continue searchCache; |
79 }; |
80 } |
|
81 } |
|
82 |
|
83 // At this point we can assume we've found a match |
|
84 |
|
85 // Surface matched node to head if not already |
|
86 if ( node !== head ) { |
|
87 // As tail, shift to previous. Must only shift if not also |
|
88 // head, since if both head and tail, there is no previous. |
|
89 if ( node === tail ) { |
|
90 tail = node.prev; |
|
91 } |
|
92 |
|
93 // Adjust siblings to point to each other. If node was tail, |
|
94 // this also handles new tail's empty `next` assignment. |
|
95 /** @type {MemizeCacheNode} */ ( node.prev ).next = node.next; |
|
96 if ( node.next ) { |
|
97 node.next.prev = node.prev; |
|
98 } |
|
99 |
|
100 node.next = head; |
|
101 node.prev = null; |
|
102 /** @type {MemizeCacheNode} */ ( head ).prev = node; |
|
103 head = node; |
|
104 } |
|
105 |
|
106 // Return immediately |
|
107 return node.val; |
|
108 } |
|
109 |
|
110 // No cached value found. Continue to insertion phase: |
|
111 |
|
112 // Create a copy of arguments (avoid leaking deoptimization) |
|
113 args = new Array( len ); |
|
114 for ( i = 0; i < len; i++ ) { |
|
115 args[ i ] = arguments[ i ]; |
|
116 } |
|
117 |
|
118 node = { |
|
119 args: args, |
|
120 |
|
121 // Generate the result from original function |
|
122 val: fn.apply( null, args ), |
|
123 }; |
|
124 |
|
125 // Don't need to check whether node is already head, since it would |
|
126 // have been returned above already if it was |
|
127 |
|
128 // Shift existing head down list |
|
129 if ( head ) { |
|
130 head.prev = node; |
|
131 node.next = head; |
|
132 } else { |
|
133 // If no head, follows that there's no tail (at initial or reset) |
|
134 tail = node; |
|
135 } |
|
136 |
|
137 // Trim tail if we're reached max size and are pending cache insertion |
|
138 if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) { |
|
139 tail = /** @type {MemizeCacheNode} */ ( tail ).prev; |
|
140 /** @type {MemizeCacheNode} */ ( tail ).next = null; |
|
141 } else { |
|
142 size++; |
|
143 } |
|
144 |
|
145 head = node; |
|
146 |
|
147 return node.val; |
|
148 } |
|
149 |
|
150 memoized.clear = function() { |
|
151 head = null; |
|
152 tail = null; |
|
153 size = 0; |
|
154 }; |
|
155 |
|
156 if ( false ) {} |
|
157 |
|
158 // Ignore reason: There's not a clear solution to create an intersection of |
|
159 // the function with additional properties, where the goal is to retain the |
|
160 // function signature of the incoming argument and add control properties |
|
161 // on the return value. |
|
162 |
|
163 // @ts-ignore |
|
164 return memoized; |
|
165 } |
|
166 |
|
167 module.exports = memize; |
|
168 |
80 |
169 |
81 |
170 /***/ }), |
82 /***/ }), |
171 |
83 |
172 /***/ 7308: |
84 /***/ 5373: |
85 /***/ ((__unused_webpack_module, exports) => { |
|
86 |
|
87 "use strict"; |
|
88 var __webpack_unused_export__; |
|
89 /** |
|
90 * @license React |
|
91 * react-is.production.min.js |
|
92 * |
|
93 * Copyright (c) Facebook, Inc. and its affiliates. |
|
94 * |
|
95 * This source code is licensed under the MIT license found in the |
|
96 * LICENSE file in the root directory of this source tree. |
|
97 */ |
|
98 var b=Symbol.for("react.element"),c=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),e=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),g=Symbol.for("react.provider"),h=Symbol.for("react.context"),k=Symbol.for("react.server_context"),l=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),n=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),t=Symbol.for("react.offscreen"),u;u=Symbol.for("react.module.reference"); |
|
99 function v(a){if("object"===typeof a&&null!==a){var r=a.$$typeof;switch(r){case b:switch(a=a.type,a){case d:case f:case e:case m:case n:return a;default:switch(a=a&&a.$$typeof,a){case k:case h:case l:case q:case p:case g:return a;default:return r}}case c:return r}}}__webpack_unused_export__=h;__webpack_unused_export__=g;__webpack_unused_export__=b;__webpack_unused_export__=l;__webpack_unused_export__=d;__webpack_unused_export__=q;__webpack_unused_export__=p;__webpack_unused_export__=c;__webpack_unused_export__=f;__webpack_unused_export__=e;__webpack_unused_export__=m; |
|
100 __webpack_unused_export__=n;__webpack_unused_export__=function(){return!1};__webpack_unused_export__=function(){return!1};__webpack_unused_export__=function(a){return v(a)===h};__webpack_unused_export__=function(a){return v(a)===g};__webpack_unused_export__=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===b};__webpack_unused_export__=function(a){return v(a)===l};__webpack_unused_export__=function(a){return v(a)===d};__webpack_unused_export__=function(a){return v(a)===q};__webpack_unused_export__=function(a){return v(a)===p}; |
|
101 __webpack_unused_export__=function(a){return v(a)===c};__webpack_unused_export__=function(a){return v(a)===f};__webpack_unused_export__=function(a){return v(a)===e};__webpack_unused_export__=function(a){return v(a)===m};__webpack_unused_export__=function(a){return v(a)===n}; |
|
102 exports.isValidElementType=function(a){return"string"===typeof a||"function"===typeof a||a===d||a===f||a===e||a===m||a===n||a===t||"object"===typeof a&&null!==a&&(a.$$typeof===q||a.$$typeof===p||a.$$typeof===g||a.$$typeof===h||a.$$typeof===l||a.$$typeof===u||void 0!==a.getModuleId)?!0:!1};__webpack_unused_export__=v; |
|
103 |
|
104 |
|
105 /***/ }), |
|
106 |
|
107 /***/ 8529: |
|
108 /***/ ((module, __unused_webpack_exports, __webpack_require__) => { |
|
109 |
|
110 "use strict"; |
|
111 |
|
112 |
|
113 if (true) { |
|
114 module.exports = __webpack_require__(5373); |
|
115 } else {} |
|
116 |
|
117 |
|
118 /***/ }), |
|
119 |
|
120 /***/ 9681: |
|
121 /***/ ((module) => { |
|
122 |
|
123 var characterMap = { |
|
124 "À": "A", |
|
125 "Á": "A", |
|
126 "Â": "A", |
|
127 "Ã": "A", |
|
128 "Ä": "A", |
|
129 "Å": "A", |
|
130 "Ấ": "A", |
|
131 "Ắ": "A", |
|
132 "Ẳ": "A", |
|
133 "Ẵ": "A", |
|
134 "Ặ": "A", |
|
135 "Æ": "AE", |
|
136 "Ầ": "A", |
|
137 "Ằ": "A", |
|
138 "Ȃ": "A", |
|
139 "Ả": "A", |
|
140 "Ạ": "A", |
|
141 "Ẩ": "A", |
|
142 "Ẫ": "A", |
|
143 "Ậ": "A", |
|
144 "Ç": "C", |
|
145 "Ḉ": "C", |
|
146 "È": "E", |
|
147 "É": "E", |
|
148 "Ê": "E", |
|
149 "Ë": "E", |
|
150 "Ế": "E", |
|
151 "Ḗ": "E", |
|
152 "Ề": "E", |
|
153 "Ḕ": "E", |
|
154 "Ḝ": "E", |
|
155 "Ȇ": "E", |
|
156 "Ẻ": "E", |
|
157 "Ẽ": "E", |
|
158 "Ẹ": "E", |
|
159 "Ể": "E", |
|
160 "Ễ": "E", |
|
161 "Ệ": "E", |
|
162 "Ì": "I", |
|
163 "Í": "I", |
|
164 "Î": "I", |
|
165 "Ï": "I", |
|
166 "Ḯ": "I", |
|
167 "Ȋ": "I", |
|
168 "Ỉ": "I", |
|
169 "Ị": "I", |
|
170 "Ð": "D", |
|
171 "Ñ": "N", |
|
172 "Ò": "O", |
|
173 "Ó": "O", |
|
174 "Ô": "O", |
|
175 "Õ": "O", |
|
176 "Ö": "O", |
|
177 "Ø": "O", |
|
178 "Ố": "O", |
|
179 "Ṍ": "O", |
|
180 "Ṓ": "O", |
|
181 "Ȏ": "O", |
|
182 "Ỏ": "O", |
|
183 "Ọ": "O", |
|
184 "Ổ": "O", |
|
185 "Ỗ": "O", |
|
186 "Ộ": "O", |
|
187 "Ờ": "O", |
|
188 "Ở": "O", |
|
189 "Ỡ": "O", |
|
190 "Ớ": "O", |
|
191 "Ợ": "O", |
|
192 "Ù": "U", |
|
193 "Ú": "U", |
|
194 "Û": "U", |
|
195 "Ü": "U", |
|
196 "Ủ": "U", |
|
197 "Ụ": "U", |
|
198 "Ử": "U", |
|
199 "Ữ": "U", |
|
200 "Ự": "U", |
|
201 "Ý": "Y", |
|
202 "à": "a", |
|
203 "á": "a", |
|
204 "â": "a", |
|
205 "ã": "a", |
|
206 "ä": "a", |
|
207 "å": "a", |
|
208 "ấ": "a", |
|
209 "ắ": "a", |
|
210 "ẳ": "a", |
|
211 "ẵ": "a", |
|
212 "ặ": "a", |
|
213 "æ": "ae", |
|
214 "ầ": "a", |
|
215 "ằ": "a", |
|
216 "ȃ": "a", |
|
217 "ả": "a", |
|
218 "ạ": "a", |
|
219 "ẩ": "a", |
|
220 "ẫ": "a", |
|
221 "ậ": "a", |
|
222 "ç": "c", |
|
223 "ḉ": "c", |
|
224 "è": "e", |
|
225 "é": "e", |
|
226 "ê": "e", |
|
227 "ë": "e", |
|
228 "ế": "e", |
|
229 "ḗ": "e", |
|
230 "ề": "e", |
|
231 "ḕ": "e", |
|
232 "ḝ": "e", |
|
233 "ȇ": "e", |
|
234 "ẻ": "e", |
|
235 "ẽ": "e", |
|
236 "ẹ": "e", |
|
237 "ể": "e", |
|
238 "ễ": "e", |
|
239 "ệ": "e", |
|
240 "ì": "i", |
|
241 "í": "i", |
|
242 "î": "i", |
|
243 "ï": "i", |
|
244 "ḯ": "i", |
|
245 "ȋ": "i", |
|
246 "ỉ": "i", |
|
247 "ị": "i", |
|
248 "ð": "d", |
|
249 "ñ": "n", |
|
250 "ò": "o", |
|
251 "ó": "o", |
|
252 "ô": "o", |
|
253 "õ": "o", |
|
254 "ö": "o", |
|
255 "ø": "o", |
|
256 "ố": "o", |
|
257 "ṍ": "o", |
|
258 "ṓ": "o", |
|
259 "ȏ": "o", |
|
260 "ỏ": "o", |
|
261 "ọ": "o", |
|
262 "ổ": "o", |
|
263 "ỗ": "o", |
|
264 "ộ": "o", |
|
265 "ờ": "o", |
|
266 "ở": "o", |
|
267 "ỡ": "o", |
|
268 "ớ": "o", |
|
269 "ợ": "o", |
|
270 "ù": "u", |
|
271 "ú": "u", |
|
272 "û": "u", |
|
273 "ü": "u", |
|
274 "ủ": "u", |
|
275 "ụ": "u", |
|
276 "ử": "u", |
|
277 "ữ": "u", |
|
278 "ự": "u", |
|
279 "ý": "y", |
|
280 "ÿ": "y", |
|
281 "Ā": "A", |
|
282 "ā": "a", |
|
283 "Ă": "A", |
|
284 "ă": "a", |
|
285 "Ą": "A", |
|
286 "ą": "a", |
|
287 "Ć": "C", |
|
288 "ć": "c", |
|
289 "Ĉ": "C", |
|
290 "ĉ": "c", |
|
291 "Ċ": "C", |
|
292 "ċ": "c", |
|
293 "Č": "C", |
|
294 "č": "c", |
|
295 "C̆": "C", |
|
296 "c̆": "c", |
|
297 "Ď": "D", |
|
298 "ď": "d", |
|
299 "Đ": "D", |
|
300 "đ": "d", |
|
301 "Ē": "E", |
|
302 "ē": "e", |
|
303 "Ĕ": "E", |
|
304 "ĕ": "e", |
|
305 "Ė": "E", |
|
306 "ė": "e", |
|
307 "Ę": "E", |
|
308 "ę": "e", |
|
309 "Ě": "E", |
|
310 "ě": "e", |
|
311 "Ĝ": "G", |
|
312 "Ǵ": "G", |
|
313 "ĝ": "g", |
|
314 "ǵ": "g", |
|
315 "Ğ": "G", |
|
316 "ğ": "g", |
|
317 "Ġ": "G", |
|
318 "ġ": "g", |
|
319 "Ģ": "G", |
|
320 "ģ": "g", |
|
321 "Ĥ": "H", |
|
322 "ĥ": "h", |
|
323 "Ħ": "H", |
|
324 "ħ": "h", |
|
325 "Ḫ": "H", |
|
326 "ḫ": "h", |
|
327 "Ĩ": "I", |
|
328 "ĩ": "i", |
|
329 "Ī": "I", |
|
330 "ī": "i", |
|
331 "Ĭ": "I", |
|
332 "ĭ": "i", |
|
333 "Į": "I", |
|
334 "į": "i", |
|
335 "İ": "I", |
|
336 "ı": "i", |
|
337 "IJ": "IJ", |
|
338 "ij": "ij", |
|
339 "Ĵ": "J", |
|
340 "ĵ": "j", |
|
341 "Ķ": "K", |
|
342 "ķ": "k", |
|
343 "Ḱ": "K", |
|
344 "ḱ": "k", |
|
345 "K̆": "K", |
|
346 "k̆": "k", |
|
347 "Ĺ": "L", |
|
348 "ĺ": "l", |
|
349 "Ļ": "L", |
|
350 "ļ": "l", |
|
351 "Ľ": "L", |
|
352 "ľ": "l", |
|
353 "Ŀ": "L", |
|
354 "ŀ": "l", |
|
355 "Ł": "l", |
|
356 "ł": "l", |
|
357 "Ḿ": "M", |
|
358 "ḿ": "m", |
|
359 "M̆": "M", |
|
360 "m̆": "m", |
|
361 "Ń": "N", |
|
362 "ń": "n", |
|
363 "Ņ": "N", |
|
364 "ņ": "n", |
|
365 "Ň": "N", |
|
366 "ň": "n", |
|
367 "ʼn": "n", |
|
368 "N̆": "N", |
|
369 "n̆": "n", |
|
370 "Ō": "O", |
|
371 "ō": "o", |
|
372 "Ŏ": "O", |
|
373 "ŏ": "o", |
|
374 "Ő": "O", |
|
375 "ő": "o", |
|
376 "Œ": "OE", |
|
377 "œ": "oe", |
|
378 "P̆": "P", |
|
379 "p̆": "p", |
|
380 "Ŕ": "R", |
|
381 "ŕ": "r", |
|
382 "Ŗ": "R", |
|
383 "ŗ": "r", |
|
384 "Ř": "R", |
|
385 "ř": "r", |
|
386 "R̆": "R", |
|
387 "r̆": "r", |
|
388 "Ȓ": "R", |
|
389 "ȓ": "r", |
|
390 "Ś": "S", |
|
391 "ś": "s", |
|
392 "Ŝ": "S", |
|
393 "ŝ": "s", |
|
394 "Ş": "S", |
|
395 "Ș": "S", |
|
396 "ș": "s", |
|
397 "ş": "s", |
|
398 "Š": "S", |
|
399 "š": "s", |
|
400 "Ţ": "T", |
|
401 "ţ": "t", |
|
402 "ț": "t", |
|
403 "Ț": "T", |
|
404 "Ť": "T", |
|
405 "ť": "t", |
|
406 "Ŧ": "T", |
|
407 "ŧ": "t", |
|
408 "T̆": "T", |
|
409 "t̆": "t", |
|
410 "Ũ": "U", |
|
411 "ũ": "u", |
|
412 "Ū": "U", |
|
413 "ū": "u", |
|
414 "Ŭ": "U", |
|
415 "ŭ": "u", |
|
416 "Ů": "U", |
|
417 "ů": "u", |
|
418 "Ű": "U", |
|
419 "ű": "u", |
|
420 "Ų": "U", |
|
421 "ų": "u", |
|
422 "Ȗ": "U", |
|
423 "ȗ": "u", |
|
424 "V̆": "V", |
|
425 "v̆": "v", |
|
426 "Ŵ": "W", |
|
427 "ŵ": "w", |
|
428 "Ẃ": "W", |
|
429 "ẃ": "w", |
|
430 "X̆": "X", |
|
431 "x̆": "x", |
|
432 "Ŷ": "Y", |
|
433 "ŷ": "y", |
|
434 "Ÿ": "Y", |
|
435 "Y̆": "Y", |
|
436 "y̆": "y", |
|
437 "Ź": "Z", |
|
438 "ź": "z", |
|
439 "Ż": "Z", |
|
440 "ż": "z", |
|
441 "Ž": "Z", |
|
442 "ž": "z", |
|
443 "ſ": "s", |
|
444 "ƒ": "f", |
|
445 "Ơ": "O", |
|
446 "ơ": "o", |
|
447 "Ư": "U", |
|
448 "ư": "u", |
|
449 "Ǎ": "A", |
|
450 "ǎ": "a", |
|
451 "Ǐ": "I", |
|
452 "ǐ": "i", |
|
453 "Ǒ": "O", |
|
454 "ǒ": "o", |
|
455 "Ǔ": "U", |
|
456 "ǔ": "u", |
|
457 "Ǖ": "U", |
|
458 "ǖ": "u", |
|
459 "Ǘ": "U", |
|
460 "ǘ": "u", |
|
461 "Ǚ": "U", |
|
462 "ǚ": "u", |
|
463 "Ǜ": "U", |
|
464 "ǜ": "u", |
|
465 "Ứ": "U", |
|
466 "ứ": "u", |
|
467 "Ṹ": "U", |
|
468 "ṹ": "u", |
|
469 "Ǻ": "A", |
|
470 "ǻ": "a", |
|
471 "Ǽ": "AE", |
|
472 "ǽ": "ae", |
|
473 "Ǿ": "O", |
|
474 "ǿ": "o", |
|
475 "Þ": "TH", |
|
476 "þ": "th", |
|
477 "Ṕ": "P", |
|
478 "ṕ": "p", |
|
479 "Ṥ": "S", |
|
480 "ṥ": "s", |
|
481 "X́": "X", |
|
482 "x́": "x", |
|
483 "Ѓ": "Г", |
|
484 "ѓ": "г", |
|
485 "Ќ": "К", |
|
486 "ќ": "к", |
|
487 "A̋": "A", |
|
488 "a̋": "a", |
|
489 "E̋": "E", |
|
490 "e̋": "e", |
|
491 "I̋": "I", |
|
492 "i̋": "i", |
|
493 "Ǹ": "N", |
|
494 "ǹ": "n", |
|
495 "Ồ": "O", |
|
496 "ồ": "o", |
|
497 "Ṑ": "O", |
|
498 "ṑ": "o", |
|
499 "Ừ": "U", |
|
500 "ừ": "u", |
|
501 "Ẁ": "W", |
|
502 "ẁ": "w", |
|
503 "Ỳ": "Y", |
|
504 "ỳ": "y", |
|
505 "Ȁ": "A", |
|
506 "ȁ": "a", |
|
507 "Ȅ": "E", |
|
508 "ȅ": "e", |
|
509 "Ȉ": "I", |
|
510 "ȉ": "i", |
|
511 "Ȍ": "O", |
|
512 "ȍ": "o", |
|
513 "Ȑ": "R", |
|
514 "ȑ": "r", |
|
515 "Ȕ": "U", |
|
516 "ȕ": "u", |
|
517 "B̌": "B", |
|
518 "b̌": "b", |
|
519 "Č̣": "C", |
|
520 "č̣": "c", |
|
521 "Ê̌": "E", |
|
522 "ê̌": "e", |
|
523 "F̌": "F", |
|
524 "f̌": "f", |
|
525 "Ǧ": "G", |
|
526 "ǧ": "g", |
|
527 "Ȟ": "H", |
|
528 "ȟ": "h", |
|
529 "J̌": "J", |
|
530 "ǰ": "j", |
|
531 "Ǩ": "K", |
|
532 "ǩ": "k", |
|
533 "M̌": "M", |
|
534 "m̌": "m", |
|
535 "P̌": "P", |
|
536 "p̌": "p", |
|
537 "Q̌": "Q", |
|
538 "q̌": "q", |
|
539 "Ř̩": "R", |
|
540 "ř̩": "r", |
|
541 "Ṧ": "S", |
|
542 "ṧ": "s", |
|
543 "V̌": "V", |
|
544 "v̌": "v", |
|
545 "W̌": "W", |
|
546 "w̌": "w", |
|
547 "X̌": "X", |
|
548 "x̌": "x", |
|
549 "Y̌": "Y", |
|
550 "y̌": "y", |
|
551 "A̧": "A", |
|
552 "a̧": "a", |
|
553 "B̧": "B", |
|
554 "b̧": "b", |
|
555 "Ḑ": "D", |
|
556 "ḑ": "d", |
|
557 "Ȩ": "E", |
|
558 "ȩ": "e", |
|
559 "Ɛ̧": "E", |
|
560 "ɛ̧": "e", |
|
561 "Ḩ": "H", |
|
562 "ḩ": "h", |
|
563 "I̧": "I", |
|
564 "i̧": "i", |
|
565 "Ɨ̧": "I", |
|
566 "ɨ̧": "i", |
|
567 "M̧": "M", |
|
568 "m̧": "m", |
|
569 "O̧": "O", |
|
570 "o̧": "o", |
|
571 "Q̧": "Q", |
|
572 "q̧": "q", |
|
573 "U̧": "U", |
|
574 "u̧": "u", |
|
575 "X̧": "X", |
|
576 "x̧": "x", |
|
577 "Z̧": "Z", |
|
578 "z̧": "z", |
|
579 "й":"и", |
|
580 "Й":"И", |
|
581 "ё":"е", |
|
582 "Ё":"Е", |
|
583 }; |
|
584 |
|
585 var chars = Object.keys(characterMap).join('|'); |
|
586 var allAccents = new RegExp(chars, 'g'); |
|
587 var firstAccent = new RegExp(chars, ''); |
|
588 |
|
589 function matcher(match) { |
|
590 return characterMap[match]; |
|
591 } |
|
592 |
|
593 var removeAccents = function(string) { |
|
594 return string.replace(allAccents, matcher); |
|
595 }; |
|
596 |
|
597 var hasAccents = function(string) { |
|
598 return !!string.match(firstAccent); |
|
599 }; |
|
600 |
|
601 module.exports = removeAccents; |
|
602 module.exports.has = hasAccents; |
|
603 module.exports.remove = removeAccents; |
|
604 |
|
605 |
|
606 /***/ }), |
|
607 |
|
608 /***/ 1030: |
|
173 /***/ (function(module, exports, __webpack_require__) { |
609 /***/ (function(module, exports, __webpack_require__) { |
174 |
610 |
175 var __WEBPACK_AMD_DEFINE_RESULT__;;/*! showdown v 1.9.1 - 02-11-2019 */ |
611 var __WEBPACK_AMD_DEFINE_RESULT__;;/*! showdown v 1.9.1 - 02-11-2019 */ |
176 (function(){ |
612 (function(){ |
177 /** |
613 /** |
5340 /******/ return module.exports; |
5776 /******/ return module.exports; |
5341 /******/ } |
5777 /******/ } |
5342 /******/ |
5778 /******/ |
5343 /************************************************************************/ |
5779 /************************************************************************/ |
5344 /******/ /* webpack/runtime/compat get default export */ |
5780 /******/ /* webpack/runtime/compat get default export */ |
5345 /******/ !function() { |
5781 /******/ (() => { |
5346 /******/ // getDefaultExport function for compatibility with non-harmony modules |
5782 /******/ // getDefaultExport function for compatibility with non-harmony modules |
5347 /******/ __webpack_require__.n = function(module) { |
5783 /******/ __webpack_require__.n = (module) => { |
5348 /******/ var getter = module && module.__esModule ? |
5784 /******/ var getter = module && module.__esModule ? |
5349 /******/ function() { return module['default']; } : |
5785 /******/ () => (module['default']) : |
5350 /******/ function() { return module; }; |
5786 /******/ () => (module); |
5351 /******/ __webpack_require__.d(getter, { a: getter }); |
5787 /******/ __webpack_require__.d(getter, { a: getter }); |
5352 /******/ return getter; |
5788 /******/ return getter; |
5353 /******/ }; |
5789 /******/ }; |
5354 /******/ }(); |
5790 /******/ })(); |
5355 /******/ |
5791 /******/ |
5356 /******/ /* webpack/runtime/define property getters */ |
5792 /******/ /* webpack/runtime/define property getters */ |
5357 /******/ !function() { |
5793 /******/ (() => { |
5358 /******/ // define getter functions for harmony exports |
5794 /******/ // define getter functions for harmony exports |
5359 /******/ __webpack_require__.d = function(exports, definition) { |
5795 /******/ __webpack_require__.d = (exports, definition) => { |
5360 /******/ for(var key in definition) { |
5796 /******/ for(var key in definition) { |
5361 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
5797 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
5362 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
5798 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
5363 /******/ } |
5799 /******/ } |
5364 /******/ } |
5800 /******/ } |
5365 /******/ }; |
5801 /******/ }; |
5366 /******/ }(); |
5802 /******/ })(); |
5367 /******/ |
5803 /******/ |
5368 /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
5804 /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
5369 /******/ !function() { |
5805 /******/ (() => { |
5370 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
5806 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) |
5371 /******/ }(); |
5807 /******/ })(); |
5372 /******/ |
5808 /******/ |
5373 /******/ /* webpack/runtime/make namespace object */ |
5809 /******/ /* webpack/runtime/make namespace object */ |
5374 /******/ !function() { |
5810 /******/ (() => { |
5375 /******/ // define __esModule on exports |
5811 /******/ // define __esModule on exports |
5376 /******/ __webpack_require__.r = function(exports) { |
5812 /******/ __webpack_require__.r = (exports) => { |
5377 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
5813 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
5378 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
5814 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
5379 /******/ } |
5815 /******/ } |
5380 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
5816 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
5381 /******/ }; |
5817 /******/ }; |
5382 /******/ }(); |
5818 /******/ })(); |
5383 /******/ |
5819 /******/ |
5384 /************************************************************************/ |
5820 /************************************************************************/ |
5385 var __webpack_exports__ = {}; |
5821 var __webpack_exports__ = {}; |
5386 // This entry need to be wrapped in an IIFE because it need to be in strict mode. |
5822 // This entry need to be wrapped in an IIFE because it need to be in strict mode. |
5387 !function() { |
5823 (() => { |
5388 "use strict"; |
5824 "use strict"; |
5389 // ESM COMPAT FLAG |
5825 // ESM COMPAT FLAG |
5390 __webpack_require__.r(__webpack_exports__); |
5826 __webpack_require__.r(__webpack_exports__); |
5391 |
5827 |
5392 // EXPORTS |
5828 // EXPORTS |
5393 __webpack_require__.d(__webpack_exports__, { |
5829 __webpack_require__.d(__webpack_exports__, { |
5394 "__EXPERIMENTAL_ELEMENTS": function() { return /* reexport */ __EXPERIMENTAL_ELEMENTS; }, |
5830 __EXPERIMENTAL_ELEMENTS: () => (/* reexport */ __EXPERIMENTAL_ELEMENTS), |
5395 "__EXPERIMENTAL_PATHS_WITH_MERGE": function() { return /* reexport */ __EXPERIMENTAL_PATHS_WITH_MERGE; }, |
5831 __EXPERIMENTAL_PATHS_WITH_OVERRIDE: () => (/* reexport */ __EXPERIMENTAL_PATHS_WITH_OVERRIDE), |
5396 "__EXPERIMENTAL_STYLE_PROPERTY": function() { return /* reexport */ __EXPERIMENTAL_STYLE_PROPERTY; }, |
5832 __EXPERIMENTAL_STYLE_PROPERTY: () => (/* reexport */ __EXPERIMENTAL_STYLE_PROPERTY), |
5397 "__experimentalCloneSanitizedBlock": function() { return /* reexport */ __experimentalCloneSanitizedBlock; }, |
5833 __experimentalCloneSanitizedBlock: () => (/* reexport */ __experimentalCloneSanitizedBlock), |
5398 "__experimentalGetAccessibleBlockLabel": function() { return /* reexport */ getAccessibleBlockLabel; }, |
5834 __experimentalGetAccessibleBlockLabel: () => (/* reexport */ getAccessibleBlockLabel), |
5399 "__experimentalGetBlockAttributesNamesByRole": function() { return /* reexport */ __experimentalGetBlockAttributesNamesByRole; }, |
5835 __experimentalGetBlockAttributesNamesByRole: () => (/* reexport */ __experimentalGetBlockAttributesNamesByRole), |
5400 "__experimentalGetBlockLabel": function() { return /* reexport */ getBlockLabel; }, |
5836 __experimentalGetBlockLabel: () => (/* reexport */ getBlockLabel), |
5401 "__experimentalSanitizeBlockAttributes": function() { return /* reexport */ __experimentalSanitizeBlockAttributes; }, |
5837 __experimentalSanitizeBlockAttributes: () => (/* reexport */ __experimentalSanitizeBlockAttributes), |
5402 "__unstableGetBlockProps": function() { return /* reexport */ getBlockProps; }, |
5838 __unstableGetBlockProps: () => (/* reexport */ getBlockProps), |
5403 "__unstableGetInnerBlocksProps": function() { return /* reexport */ getInnerBlocksProps; }, |
5839 __unstableGetInnerBlocksProps: () => (/* reexport */ getInnerBlocksProps), |
5404 "__unstableSerializeAndClean": function() { return /* reexport */ __unstableSerializeAndClean; }, |
5840 __unstableSerializeAndClean: () => (/* reexport */ __unstableSerializeAndClean), |
5405 "children": function() { return /* reexport */ children; }, |
5841 children: () => (/* reexport */ children), |
5406 "cloneBlock": function() { return /* reexport */ cloneBlock; }, |
5842 cloneBlock: () => (/* reexport */ cloneBlock), |
5407 "createBlock": function() { return /* reexport */ createBlock; }, |
5843 createBlock: () => (/* reexport */ createBlock), |
5408 "createBlocksFromInnerBlocksTemplate": function() { return /* reexport */ createBlocksFromInnerBlocksTemplate; }, |
5844 createBlocksFromInnerBlocksTemplate: () => (/* reexport */ createBlocksFromInnerBlocksTemplate), |
5409 "doBlocksMatchTemplate": function() { return /* reexport */ doBlocksMatchTemplate; }, |
5845 doBlocksMatchTemplate: () => (/* reexport */ doBlocksMatchTemplate), |
5410 "findTransform": function() { return /* reexport */ findTransform; }, |
5846 findTransform: () => (/* reexport */ findTransform), |
5411 "getBlockAttributes": function() { return /* reexport */ getBlockAttributes; }, |
5847 getBlockAttributes: () => (/* reexport */ getBlockAttributes), |
5412 "getBlockContent": function() { return /* reexport */ getBlockInnerHTML; }, |
5848 getBlockContent: () => (/* reexport */ getBlockInnerHTML), |
5413 "getBlockDefaultClassName": function() { return /* reexport */ getBlockDefaultClassName; }, |
5849 getBlockDefaultClassName: () => (/* reexport */ getBlockDefaultClassName), |
5414 "getBlockFromExample": function() { return /* reexport */ getBlockFromExample; }, |
5850 getBlockFromExample: () => (/* reexport */ getBlockFromExample), |
5415 "getBlockMenuDefaultClassName": function() { return /* reexport */ getBlockMenuDefaultClassName; }, |
5851 getBlockMenuDefaultClassName: () => (/* reexport */ getBlockMenuDefaultClassName), |
5416 "getBlockSupport": function() { return /* reexport */ registration_getBlockSupport; }, |
5852 getBlockSupport: () => (/* reexport */ getBlockSupport), |
5417 "getBlockTransforms": function() { return /* reexport */ getBlockTransforms; }, |
5853 getBlockTransforms: () => (/* reexport */ getBlockTransforms), |
5418 "getBlockType": function() { return /* reexport */ registration_getBlockType; }, |
5854 getBlockType: () => (/* reexport */ getBlockType), |
5419 "getBlockTypes": function() { return /* reexport */ registration_getBlockTypes; }, |
5855 getBlockTypes: () => (/* reexport */ getBlockTypes), |
5420 "getBlockVariations": function() { return /* reexport */ registration_getBlockVariations; }, |
5856 getBlockVariations: () => (/* reexport */ getBlockVariations), |
5421 "getCategories": function() { return /* reexport */ categories_getCategories; }, |
5857 getCategories: () => (/* reexport */ categories_getCategories), |
5422 "getChildBlockNames": function() { return /* reexport */ registration_getChildBlockNames; }, |
5858 getChildBlockNames: () => (/* reexport */ getChildBlockNames), |
5423 "getDefaultBlockName": function() { return /* reexport */ registration_getDefaultBlockName; }, |
5859 getDefaultBlockName: () => (/* reexport */ getDefaultBlockName), |
5424 "getFreeformContentHandlerName": function() { return /* reexport */ getFreeformContentHandlerName; }, |
5860 getFreeformContentHandlerName: () => (/* reexport */ getFreeformContentHandlerName), |
5425 "getGroupingBlockName": function() { return /* reexport */ registration_getGroupingBlockName; }, |
5861 getGroupingBlockName: () => (/* reexport */ getGroupingBlockName), |
5426 "getPhrasingContentSchema": function() { return /* reexport */ deprecatedGetPhrasingContentSchema; }, |
5862 getPhrasingContentSchema: () => (/* reexport */ deprecatedGetPhrasingContentSchema), |
5427 "getPossibleBlockTransformations": function() { return /* reexport */ getPossibleBlockTransformations; }, |
5863 getPossibleBlockTransformations: () => (/* reexport */ getPossibleBlockTransformations), |
5428 "getSaveContent": function() { return /* reexport */ getSaveContent; }, |
5864 getSaveContent: () => (/* reexport */ getSaveContent), |
5429 "getSaveElement": function() { return /* reexport */ getSaveElement; }, |
5865 getSaveElement: () => (/* reexport */ getSaveElement), |
5430 "getUnregisteredTypeHandlerName": function() { return /* reexport */ getUnregisteredTypeHandlerName; }, |
5866 getUnregisteredTypeHandlerName: () => (/* reexport */ getUnregisteredTypeHandlerName), |
5431 "hasBlockSupport": function() { return /* reexport */ registration_hasBlockSupport; }, |
5867 hasBlockSupport: () => (/* reexport */ hasBlockSupport), |
5432 "hasChildBlocks": function() { return /* reexport */ registration_hasChildBlocks; }, |
5868 hasChildBlocks: () => (/* reexport */ hasChildBlocks), |
5433 "hasChildBlocksWithInserterSupport": function() { return /* reexport */ registration_hasChildBlocksWithInserterSupport; }, |
5869 hasChildBlocksWithInserterSupport: () => (/* reexport */ hasChildBlocksWithInserterSupport), |
5434 "isReusableBlock": function() { return /* reexport */ isReusableBlock; }, |
5870 isReusableBlock: () => (/* reexport */ isReusableBlock), |
5435 "isTemplatePart": function() { return /* reexport */ isTemplatePart; }, |
5871 isTemplatePart: () => (/* reexport */ isTemplatePart), |
5436 "isUnmodifiedDefaultBlock": function() { return /* reexport */ isUnmodifiedDefaultBlock; }, |
5872 isUnmodifiedBlock: () => (/* reexport */ isUnmodifiedBlock), |
5437 "isValidBlockContent": function() { return /* reexport */ isValidBlockContent; }, |
5873 isUnmodifiedDefaultBlock: () => (/* reexport */ isUnmodifiedDefaultBlock), |
5438 "isValidIcon": function() { return /* reexport */ isValidIcon; }, |
5874 isValidBlockContent: () => (/* reexport */ isValidBlockContent), |
5439 "node": function() { return /* reexport */ node; }, |
5875 isValidIcon: () => (/* reexport */ isValidIcon), |
5440 "normalizeIconObject": function() { return /* reexport */ normalizeIconObject; }, |
5876 node: () => (/* reexport */ node), |
5441 "parse": function() { return /* reexport */ parser_parse; }, |
5877 normalizeIconObject: () => (/* reexport */ normalizeIconObject), |
5442 "parseWithAttributeSchema": function() { return /* reexport */ parseWithAttributeSchema; }, |
5878 parse: () => (/* reexport */ parser_parse), |
5443 "pasteHandler": function() { return /* reexport */ pasteHandler; }, |
5879 parseWithAttributeSchema: () => (/* reexport */ parseWithAttributeSchema), |
5444 "rawHandler": function() { return /* reexport */ rawHandler; }, |
5880 pasteHandler: () => (/* reexport */ pasteHandler), |
5445 "registerBlockCollection": function() { return /* reexport */ registerBlockCollection; }, |
5881 rawHandler: () => (/* reexport */ rawHandler), |
5446 "registerBlockStyle": function() { return /* reexport */ registerBlockStyle; }, |
5882 registerBlockCollection: () => (/* reexport */ registerBlockCollection), |
5447 "registerBlockType": function() { return /* reexport */ registerBlockType; }, |
5883 registerBlockStyle: () => (/* reexport */ registerBlockStyle), |
5448 "registerBlockVariation": function() { return /* reexport */ registerBlockVariation; }, |
5884 registerBlockType: () => (/* reexport */ registerBlockType), |
5449 "serialize": function() { return /* reexport */ serializer_serialize; }, |
5885 registerBlockVariation: () => (/* reexport */ registerBlockVariation), |
5450 "serializeRawBlock": function() { return /* reexport */ serializeRawBlock; }, |
5886 serialize: () => (/* reexport */ serialize), |
5451 "setCategories": function() { return /* reexport */ categories_setCategories; }, |
5887 serializeRawBlock: () => (/* reexport */ serializeRawBlock), |
5452 "setDefaultBlockName": function() { return /* reexport */ setDefaultBlockName; }, |
5888 setCategories: () => (/* reexport */ categories_setCategories), |
5453 "setFreeformContentHandlerName": function() { return /* reexport */ setFreeformContentHandlerName; }, |
5889 setDefaultBlockName: () => (/* reexport */ setDefaultBlockName), |
5454 "setGroupingBlockName": function() { return /* reexport */ setGroupingBlockName; }, |
5890 setFreeformContentHandlerName: () => (/* reexport */ setFreeformContentHandlerName), |
5455 "setUnregisteredTypeHandlerName": function() { return /* reexport */ setUnregisteredTypeHandlerName; }, |
5891 setGroupingBlockName: () => (/* reexport */ setGroupingBlockName), |
5456 "store": function() { return /* reexport */ store; }, |
5892 setUnregisteredTypeHandlerName: () => (/* reexport */ setUnregisteredTypeHandlerName), |
5457 "switchToBlockType": function() { return /* reexport */ switchToBlockType; }, |
5893 store: () => (/* reexport */ store), |
5458 "synchronizeBlocksWithTemplate": function() { return /* reexport */ synchronizeBlocksWithTemplate; }, |
5894 switchToBlockType: () => (/* reexport */ switchToBlockType), |
5459 "unregisterBlockStyle": function() { return /* reexport */ unregisterBlockStyle; }, |
5895 synchronizeBlocksWithTemplate: () => (/* reexport */ synchronizeBlocksWithTemplate), |
5460 "unregisterBlockType": function() { return /* reexport */ unregisterBlockType; }, |
5896 unregisterBlockStyle: () => (/* reexport */ unregisterBlockStyle), |
5461 "unregisterBlockVariation": function() { return /* reexport */ unregisterBlockVariation; }, |
5897 unregisterBlockType: () => (/* reexport */ unregisterBlockType), |
5462 "unstable__bootstrapServerSideBlockDefinitions": function() { return /* reexport */ unstable__bootstrapServerSideBlockDefinitions; }, |
5898 unregisterBlockVariation: () => (/* reexport */ unregisterBlockVariation), |
5463 "updateCategory": function() { return /* reexport */ categories_updateCategory; }, |
5899 unstable__bootstrapServerSideBlockDefinitions: () => (/* reexport */ unstable__bootstrapServerSideBlockDefinitions), |
5464 "validateBlock": function() { return /* reexport */ validateBlock; }, |
5900 updateCategory: () => (/* reexport */ categories_updateCategory), |
5465 "withBlockContentContext": function() { return /* reexport */ withBlockContentContext; } |
5901 validateBlock: () => (/* reexport */ validateBlock), |
5902 withBlockContentContext: () => (/* reexport */ withBlockContentContext) |
|
5466 }); |
5903 }); |
5467 |
5904 |
5468 // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/selectors.js |
5905 // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/selectors.js |
5469 var selectors_namespaceObject = {}; |
5906 var selectors_namespaceObject = {}; |
5470 __webpack_require__.r(selectors_namespaceObject); |
5907 __webpack_require__.r(selectors_namespaceObject); |
5471 __webpack_require__.d(selectors_namespaceObject, { |
5908 __webpack_require__.d(selectors_namespaceObject, { |
5472 "__experimentalGetUnprocessedBlockTypes": function() { return __experimentalGetUnprocessedBlockTypes; }, |
5909 __experimentalHasContentRoleAttribute: () => (__experimentalHasContentRoleAttribute), |
5473 "getActiveBlockVariation": function() { return getActiveBlockVariation; }, |
5910 getActiveBlockVariation: () => (getActiveBlockVariation), |
5474 "getBlockStyles": function() { return getBlockStyles; }, |
5911 getBlockStyles: () => (getBlockStyles), |
5475 "getBlockSupport": function() { return getBlockSupport; }, |
5912 getBlockSupport: () => (selectors_getBlockSupport), |
5476 "getBlockType": function() { return getBlockType; }, |
5913 getBlockType: () => (selectors_getBlockType), |
5477 "getBlockTypes": function() { return getBlockTypes; }, |
5914 getBlockTypes: () => (selectors_getBlockTypes), |
5478 "getBlockVariations": function() { return getBlockVariations; }, |
5915 getBlockVariations: () => (selectors_getBlockVariations), |
5479 "getCategories": function() { return getCategories; }, |
5916 getCategories: () => (getCategories), |
5480 "getChildBlockNames": function() { return getChildBlockNames; }, |
5917 getChildBlockNames: () => (selectors_getChildBlockNames), |
5481 "getCollections": function() { return getCollections; }, |
5918 getCollections: () => (getCollections), |
5482 "getDefaultBlockName": function() { return getDefaultBlockName; }, |
5919 getDefaultBlockName: () => (selectors_getDefaultBlockName), |
5483 "getDefaultBlockVariation": function() { return getDefaultBlockVariation; }, |
5920 getDefaultBlockVariation: () => (getDefaultBlockVariation), |
5484 "getFreeformFallbackBlockName": function() { return getFreeformFallbackBlockName; }, |
5921 getFreeformFallbackBlockName: () => (getFreeformFallbackBlockName), |
5485 "getGroupingBlockName": function() { return getGroupingBlockName; }, |
5922 getGroupingBlockName: () => (selectors_getGroupingBlockName), |
5486 "getUnregisteredFallbackBlockName": function() { return getUnregisteredFallbackBlockName; }, |
5923 getUnregisteredFallbackBlockName: () => (getUnregisteredFallbackBlockName), |
5487 "hasBlockSupport": function() { return hasBlockSupport; }, |
5924 hasBlockSupport: () => (selectors_hasBlockSupport), |
5488 "hasChildBlocks": function() { return hasChildBlocks; }, |
5925 hasChildBlocks: () => (selectors_hasChildBlocks), |
5489 "hasChildBlocksWithInserterSupport": function() { return hasChildBlocksWithInserterSupport; }, |
5926 hasChildBlocksWithInserterSupport: () => (selectors_hasChildBlocksWithInserterSupport), |
5490 "isMatchingSearchTerm": function() { return isMatchingSearchTerm; } |
5927 isMatchingSearchTerm: () => (isMatchingSearchTerm) |
5928 }); |
|
5929 |
|
5930 // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/private-selectors.js |
|
5931 var private_selectors_namespaceObject = {}; |
|
5932 __webpack_require__.r(private_selectors_namespaceObject); |
|
5933 __webpack_require__.d(private_selectors_namespaceObject, { |
|
5934 getAllBlockBindingsSources: () => (getAllBlockBindingsSources), |
|
5935 getBlockBindingsSource: () => (getBlockBindingsSource), |
|
5936 getBootstrappedBlockType: () => (getBootstrappedBlockType), |
|
5937 getSupportedStyles: () => (getSupportedStyles), |
|
5938 getUnprocessedBlockTypes: () => (getUnprocessedBlockTypes) |
|
5491 }); |
5939 }); |
5492 |
5940 |
5493 // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/actions.js |
5941 // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/actions.js |
5494 var actions_namespaceObject = {}; |
5942 var actions_namespaceObject = {}; |
5495 __webpack_require__.r(actions_namespaceObject); |
5943 __webpack_require__.r(actions_namespaceObject); |
5496 __webpack_require__.d(actions_namespaceObject, { |
5944 __webpack_require__.d(actions_namespaceObject, { |
5497 "__experimentalReapplyBlockTypeFilters": function() { return __experimentalReapplyBlockTypeFilters; }, |
5945 __experimentalReapplyBlockFilters: () => (__experimentalReapplyBlockFilters), |
5498 "__experimentalRegisterBlockType": function() { return __experimentalRegisterBlockType; }, |
5946 addBlockCollection: () => (addBlockCollection), |
5499 "addBlockCollection": function() { return addBlockCollection; }, |
5947 addBlockStyles: () => (addBlockStyles), |
5500 "addBlockStyles": function() { return addBlockStyles; }, |
5948 addBlockTypes: () => (addBlockTypes), |
5501 "addBlockTypes": function() { return addBlockTypes; }, |
5949 addBlockVariations: () => (addBlockVariations), |
5502 "addBlockVariations": function() { return addBlockVariations; }, |
5950 reapplyBlockTypeFilters: () => (reapplyBlockTypeFilters), |
5503 "removeBlockCollection": function() { return removeBlockCollection; }, |
5951 removeBlockCollection: () => (removeBlockCollection), |
5504 "removeBlockStyles": function() { return removeBlockStyles; }, |
5952 removeBlockStyles: () => (removeBlockStyles), |
5505 "removeBlockTypes": function() { return removeBlockTypes; }, |
5953 removeBlockTypes: () => (removeBlockTypes), |
5506 "removeBlockVariations": function() { return removeBlockVariations; }, |
5954 removeBlockVariations: () => (removeBlockVariations), |
5507 "setCategories": function() { return setCategories; }, |
5955 setCategories: () => (setCategories), |
5508 "setDefaultBlockName": function() { return actions_setDefaultBlockName; }, |
5956 setDefaultBlockName: () => (actions_setDefaultBlockName), |
5509 "setFreeformFallbackBlockName": function() { return setFreeformFallbackBlockName; }, |
5957 setFreeformFallbackBlockName: () => (setFreeformFallbackBlockName), |
5510 "setGroupingBlockName": function() { return actions_setGroupingBlockName; }, |
5958 setGroupingBlockName: () => (actions_setGroupingBlockName), |
5511 "setUnregisteredFallbackBlockName": function() { return setUnregisteredFallbackBlockName; }, |
5959 setUnregisteredFallbackBlockName: () => (setUnregisteredFallbackBlockName), |
5512 "updateCategory": function() { return updateCategory; } |
5960 updateCategory: () => (updateCategory) |
5513 }); |
5961 }); |
5514 |
5962 |
5963 // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/private-actions.js |
|
5964 var private_actions_namespaceObject = {}; |
|
5965 __webpack_require__.r(private_actions_namespaceObject); |
|
5966 __webpack_require__.d(private_actions_namespaceObject, { |
|
5967 addBootstrappedBlockType: () => (addBootstrappedBlockType), |
|
5968 addUnprocessedBlockType: () => (addUnprocessedBlockType), |
|
5969 registerBlockBindingsSource: () => (registerBlockBindingsSource) |
|
5970 }); |
|
5971 |
|
5515 ;// CONCATENATED MODULE: external ["wp","data"] |
5972 ;// CONCATENATED MODULE: external ["wp","data"] |
5516 var external_wp_data_namespaceObject = window["wp"]["data"]; |
5973 const external_wp_data_namespaceObject = window["wp"]["data"]; |
5517 ;// CONCATENATED MODULE: external "lodash" |
5974 ;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs |
5518 var external_lodash_namespaceObject = window["lodash"]; |
5975 /****************************************************************************** |
5976 Copyright (c) Microsoft Corporation. |
|
5977 |
|
5978 Permission to use, copy, modify, and/or distribute this software for any |
|
5979 purpose with or without fee is hereby granted. |
|
5980 |
|
5981 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH |
|
5982 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
|
5983 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, |
|
5984 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM |
|
5985 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR |
|
5986 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
|
5987 PERFORMANCE OF THIS SOFTWARE. |
|
5988 ***************************************************************************** */ |
|
5989 /* global Reflect, Promise, SuppressedError, Symbol */ |
|
5990 |
|
5991 var extendStatics = function(d, b) { |
|
5992 extendStatics = Object.setPrototypeOf || |
|
5993 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
|
5994 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; |
|
5995 return extendStatics(d, b); |
|
5996 }; |
|
5997 |
|
5998 function __extends(d, b) { |
|
5999 if (typeof b !== "function" && b !== null) |
|
6000 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); |
|
6001 extendStatics(d, b); |
|
6002 function __() { this.constructor = d; } |
|
6003 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
|
6004 } |
|
6005 |
|
6006 var __assign = function() { |
|
6007 __assign = Object.assign || function __assign(t) { |
|
6008 for (var s, i = 1, n = arguments.length; i < n; i++) { |
|
6009 s = arguments[i]; |
|
6010 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; |
|
6011 } |
|
6012 return t; |
|
6013 } |
|
6014 return __assign.apply(this, arguments); |
|
6015 } |
|
6016 |
|
6017 function __rest(s, e) { |
|
6018 var t = {}; |
|
6019 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) |
|
6020 t[p] = s[p]; |
|
6021 if (s != null && typeof Object.getOwnPropertySymbols === "function") |
|
6022 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { |
|
6023 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) |
|
6024 t[p[i]] = s[p[i]]; |
|
6025 } |
|
6026 return t; |
|
6027 } |
|
6028 |
|
6029 function __decorate(decorators, target, key, desc) { |
|
6030 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; |
|
6031 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); |
|
6032 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; |
|
6033 return c > 3 && r && Object.defineProperty(target, key, r), r; |
|
6034 } |
|
6035 |
|
6036 function __param(paramIndex, decorator) { |
|
6037 return function (target, key) { decorator(target, key, paramIndex); } |
|
6038 } |
|
6039 |
|
6040 function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { |
|
6041 function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } |
|
6042 var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; |
|
6043 var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; |
|
6044 var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); |
|
6045 var _, done = false; |
|
6046 for (var i = decorators.length - 1; i >= 0; i--) { |
|
6047 var context = {}; |
|
6048 for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; |
|
6049 for (var p in contextIn.access) context.access[p] = contextIn.access[p]; |
|
6050 context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; |
|
6051 var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); |
|
6052 if (kind === "accessor") { |
|
6053 if (result === void 0) continue; |
|
6054 if (result === null || typeof result !== "object") throw new TypeError("Object expected"); |
|
6055 if (_ = accept(result.get)) descriptor.get = _; |
|
6056 if (_ = accept(result.set)) descriptor.set = _; |
|
6057 if (_ = accept(result.init)) initializers.unshift(_); |
|
6058 } |
|
6059 else if (_ = accept(result)) { |
|
6060 if (kind === "field") initializers.unshift(_); |
|
6061 else descriptor[key] = _; |
|
6062 } |
|
6063 } |
|
6064 if (target) Object.defineProperty(target, contextIn.name, descriptor); |
|
6065 done = true; |
|
6066 }; |
|
6067 |
|
6068 function __runInitializers(thisArg, initializers, value) { |
|
6069 var useValue = arguments.length > 2; |
|
6070 for (var i = 0; i < initializers.length; i++) { |
|
6071 value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); |
|
6072 } |
|
6073 return useValue ? value : void 0; |
|
6074 }; |
|
6075 |
|
6076 function __propKey(x) { |
|
6077 return typeof x === "symbol" ? x : "".concat(x); |
|
6078 }; |
|
6079 |
|
6080 function __setFunctionName(f, name, prefix) { |
|
6081 if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; |
|
6082 return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); |
|
6083 }; |
|
6084 |
|
6085 function __metadata(metadataKey, metadataValue) { |
|
6086 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); |
|
6087 } |
|
6088 |
|
6089 function __awaiter(thisArg, _arguments, P, generator) { |
|
6090 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
|
6091 return new (P || (P = Promise))(function (resolve, reject) { |
|
6092 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } |
|
6093 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } |
|
6094 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } |
|
6095 step((generator = generator.apply(thisArg, _arguments || [])).next()); |
|
6096 }); |
|
6097 } |
|
6098 |
|
6099 function __generator(thisArg, body) { |
|
6100 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; |
|
6101 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; |
|
6102 function verb(n) { return function (v) { return step([n, v]); }; } |
|
6103 function step(op) { |
|
6104 if (f) throw new TypeError("Generator is already executing."); |
|
6105 while (g && (g = 0, op[0] && (_ = 0)), _) try { |
|
6106 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; |
|
6107 if (y = 0, t) op = [op[0] & 2, t.value]; |
|
6108 switch (op[0]) { |
|
6109 case 0: case 1: t = op; break; |
|
6110 case 4: _.label++; return { value: op[1], done: false }; |
|
6111 case 5: _.label++; y = op[1]; op = [0]; continue; |
|
6112 case 7: op = _.ops.pop(); _.trys.pop(); continue; |
|
6113 default: |
|
6114 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } |
|
6115 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } |
|
6116 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } |
|
6117 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } |
|
6118 if (t[2]) _.ops.pop(); |
|
6119 _.trys.pop(); continue; |
|
6120 } |
|
6121 op = body.call(thisArg, _); |
|
6122 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } |
|
6123 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; |
|
6124 } |
|
6125 } |
|
6126 |
|
6127 var __createBinding = Object.create ? (function(o, m, k, k2) { |
|
6128 if (k2 === undefined) k2 = k; |
|
6129 var desc = Object.getOwnPropertyDescriptor(m, k); |
|
6130 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { |
|
6131 desc = { enumerable: true, get: function() { return m[k]; } }; |
|
6132 } |
|
6133 Object.defineProperty(o, k2, desc); |
|
6134 }) : (function(o, m, k, k2) { |
|
6135 if (k2 === undefined) k2 = k; |
|
6136 o[k2] = m[k]; |
|
6137 }); |
|
6138 |
|
6139 function __exportStar(m, o) { |
|
6140 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); |
|
6141 } |
|
6142 |
|
6143 function __values(o) { |
|
6144 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; |
|
6145 if (m) return m.call(o); |
|
6146 if (o && typeof o.length === "number") return { |
|
6147 next: function () { |
|
6148 if (o && i >= o.length) o = void 0; |
|
6149 return { value: o && o[i++], done: !o }; |
|
6150 } |
|
6151 }; |
|
6152 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); |
|
6153 } |
|
6154 |
|
6155 function __read(o, n) { |
|
6156 var m = typeof Symbol === "function" && o[Symbol.iterator]; |
|
6157 if (!m) return o; |
|
6158 var i = m.call(o), r, ar = [], e; |
|
6159 try { |
|
6160 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); |
|
6161 } |
|
6162 catch (error) { e = { error: error }; } |
|
6163 finally { |
|
6164 try { |
|
6165 if (r && !r.done && (m = i["return"])) m.call(i); |
|
6166 } |
|
6167 finally { if (e) throw e.error; } |
|
6168 } |
|
6169 return ar; |
|
6170 } |
|
6171 |
|
6172 /** @deprecated */ |
|
6173 function __spread() { |
|
6174 for (var ar = [], i = 0; i < arguments.length; i++) |
|
6175 ar = ar.concat(__read(arguments[i])); |
|
6176 return ar; |
|
6177 } |
|
6178 |
|
6179 /** @deprecated */ |
|
6180 function __spreadArrays() { |
|
6181 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; |
|
6182 for (var r = Array(s), k = 0, i = 0; i < il; i++) |
|
6183 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) |
|
6184 r[k] = a[j]; |
|
6185 return r; |
|
6186 } |
|
6187 |
|
6188 function __spreadArray(to, from, pack) { |
|
6189 if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { |
|
6190 if (ar || !(i in from)) { |
|
6191 if (!ar) ar = Array.prototype.slice.call(from, 0, i); |
|
6192 ar[i] = from[i]; |
|
6193 } |
|
6194 } |
|
6195 return to.concat(ar || Array.prototype.slice.call(from)); |
|
6196 } |
|
6197 |
|
6198 function __await(v) { |
|
6199 return this instanceof __await ? (this.v = v, this) : new __await(v); |
|
6200 } |
|
6201 |
|
6202 function __asyncGenerator(thisArg, _arguments, generator) { |
|
6203 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); |
|
6204 var g = generator.apply(thisArg, _arguments || []), i, q = []; |
|
6205 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; |
|
6206 function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } |
|
6207 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } |
|
6208 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } |
|
6209 function fulfill(value) { resume("next", value); } |
|
6210 function reject(value) { resume("throw", value); } |
|
6211 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } |
|
6212 } |
|
6213 |
|
6214 function __asyncDelegator(o) { |
|
6215 var i, p; |
|
6216 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; |
|
6217 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; } |
|
6218 } |
|
6219 |
|
6220 function __asyncValues(o) { |
|
6221 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); |
|
6222 var m = o[Symbol.asyncIterator], i; |
|
6223 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); |
|
6224 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } |
|
6225 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } |
|
6226 } |
|
6227 |
|
6228 function __makeTemplateObject(cooked, raw) { |
|
6229 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } |
|
6230 return cooked; |
|
6231 }; |
|
6232 |
|
6233 var __setModuleDefault = Object.create ? (function(o, v) { |
|
6234 Object.defineProperty(o, "default", { enumerable: true, value: v }); |
|
6235 }) : function(o, v) { |
|
6236 o["default"] = v; |
|
6237 }; |
|
6238 |
|
6239 function __importStar(mod) { |
|
6240 if (mod && mod.__esModule) return mod; |
|
6241 var result = {}; |
|
6242 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); |
|
6243 __setModuleDefault(result, mod); |
|
6244 return result; |
|
6245 } |
|
6246 |
|
6247 function __importDefault(mod) { |
|
6248 return (mod && mod.__esModule) ? mod : { default: mod }; |
|
6249 } |
|
6250 |
|
6251 function __classPrivateFieldGet(receiver, state, kind, f) { |
|
6252 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); |
|
6253 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); |
|
6254 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); |
|
6255 } |
|
6256 |
|
6257 function __classPrivateFieldSet(receiver, state, value, kind, f) { |
|
6258 if (kind === "m") throw new TypeError("Private method is not writable"); |
|
6259 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); |
|
6260 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); |
|
6261 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; |
|
6262 } |
|
6263 |
|
6264 function __classPrivateFieldIn(state, receiver) { |
|
6265 if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object"); |
|
6266 return typeof state === "function" ? receiver === state : state.has(receiver); |
|
6267 } |
|
6268 |
|
6269 function __addDisposableResource(env, value, async) { |
|
6270 if (value !== null && value !== void 0) { |
|
6271 if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); |
|
6272 var dispose; |
|
6273 if (async) { |
|
6274 if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); |
|
6275 dispose = value[Symbol.asyncDispose]; |
|
6276 } |
|
6277 if (dispose === void 0) { |
|
6278 if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); |
|
6279 dispose = value[Symbol.dispose]; |
|
6280 } |
|
6281 if (typeof dispose !== "function") throw new TypeError("Object not disposable."); |
|
6282 env.stack.push({ value: value, dispose: dispose, async: async }); |
|
6283 } |
|
6284 else if (async) { |
|
6285 env.stack.push({ async: true }); |
|
6286 } |
|
6287 return value; |
|
6288 } |
|
6289 |
|
6290 var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { |
|
6291 var e = new Error(message); |
|
6292 return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; |
|
6293 }; |
|
6294 |
|
6295 function __disposeResources(env) { |
|
6296 function fail(e) { |
|
6297 env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; |
|
6298 env.hasError = true; |
|
6299 } |
|
6300 function next() { |
|
6301 while (env.stack.length) { |
|
6302 var rec = env.stack.pop(); |
|
6303 try { |
|
6304 var result = rec.dispose && rec.dispose.call(rec.value); |
|
6305 if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); |
|
6306 } |
|
6307 catch (e) { |
|
6308 fail(e); |
|
6309 } |
|
6310 } |
|
6311 if (env.hasError) throw env.error; |
|
6312 } |
|
6313 return next(); |
|
6314 } |
|
6315 |
|
6316 /* harmony default export */ const tslib_es6 = ({ |
|
6317 __extends, |
|
6318 __assign, |
|
6319 __rest, |
|
6320 __decorate, |
|
6321 __param, |
|
6322 __metadata, |
|
6323 __awaiter, |
|
6324 __generator, |
|
6325 __createBinding, |
|
6326 __exportStar, |
|
6327 __values, |
|
6328 __read, |
|
6329 __spread, |
|
6330 __spreadArrays, |
|
6331 __spreadArray, |
|
6332 __await, |
|
6333 __asyncGenerator, |
|
6334 __asyncDelegator, |
|
6335 __asyncValues, |
|
6336 __makeTemplateObject, |
|
6337 __importStar, |
|
6338 __importDefault, |
|
6339 __classPrivateFieldGet, |
|
6340 __classPrivateFieldSet, |
|
6341 __classPrivateFieldIn, |
|
6342 __addDisposableResource, |
|
6343 __disposeResources, |
|
6344 }); |
|
6345 |
|
6346 ;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js |
|
6347 /** |
|
6348 * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt |
|
6349 */ |
|
6350 var SUPPORTED_LOCALE = { |
|
6351 tr: { |
|
6352 regexp: /\u0130|\u0049|\u0049\u0307/g, |
|
6353 map: { |
|
6354 İ: "\u0069", |
|
6355 I: "\u0131", |
|
6356 İ: "\u0069", |
|
6357 }, |
|
6358 }, |
|
6359 az: { |
|
6360 regexp: /\u0130/g, |
|
6361 map: { |
|
6362 İ: "\u0069", |
|
6363 I: "\u0131", |
|
6364 İ: "\u0069", |
|
6365 }, |
|
6366 }, |
|
6367 lt: { |
|
6368 regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g, |
|
6369 map: { |
|
6370 I: "\u0069\u0307", |
|
6371 J: "\u006A\u0307", |
|
6372 Į: "\u012F\u0307", |
|
6373 Ì: "\u0069\u0307\u0300", |
|
6374 Í: "\u0069\u0307\u0301", |
|
6375 Ĩ: "\u0069\u0307\u0303", |
|
6376 }, |
|
6377 }, |
|
6378 }; |
|
6379 /** |
|
6380 * Localized lower case. |
|
6381 */ |
|
6382 function localeLowerCase(str, locale) { |
|
6383 var lang = SUPPORTED_LOCALE[locale.toLowerCase()]; |
|
6384 if (lang) |
|
6385 return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; })); |
|
6386 return lowerCase(str); |
|
6387 } |
|
6388 /** |
|
6389 * Lower case as a function. |
|
6390 */ |
|
6391 function lowerCase(str) { |
|
6392 return str.toLowerCase(); |
|
6393 } |
|
6394 |
|
6395 ;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js |
|
6396 |
|
6397 // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case"). |
|
6398 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; |
|
6399 // Remove all non-word characters. |
|
6400 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; |
|
6401 /** |
|
6402 * Normalize the string into something other libraries can manipulate easier. |
|
6403 */ |
|
6404 function noCase(input, options) { |
|
6405 if (options === void 0) { options = {}; } |
|
6406 var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d; |
|
6407 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0"); |
|
6408 var start = 0; |
|
6409 var end = result.length; |
|
6410 // Trim the delimiter from around the output string. |
|
6411 while (result.charAt(start) === "\0") |
|
6412 start++; |
|
6413 while (result.charAt(end - 1) === "\0") |
|
6414 end--; |
|
6415 // Transform each token independently. |
|
6416 return result.slice(start, end).split("\0").map(transform).join(delimiter); |
|
6417 } |
|
6418 /** |
|
6419 * Replace `re` in the input string with the replacement value. |
|
6420 */ |
|
6421 function replace(input, re, value) { |
|
6422 if (re instanceof RegExp) |
|
6423 return input.replace(re, value); |
|
6424 return re.reduce(function (input, re) { return input.replace(re, value); }, input); |
|
6425 } |
|
6426 |
|
6427 ;// CONCATENATED MODULE: ./node_modules/pascal-case/dist.es2015/index.js |
|
6428 |
|
6429 |
|
6430 function pascalCaseTransform(input, index) { |
|
6431 var firstChar = input.charAt(0); |
|
6432 var lowerChars = input.substr(1).toLowerCase(); |
|
6433 if (index > 0 && firstChar >= "0" && firstChar <= "9") { |
|
6434 return "_" + firstChar + lowerChars; |
|
6435 } |
|
6436 return "" + firstChar.toUpperCase() + lowerChars; |
|
6437 } |
|
6438 function dist_es2015_pascalCaseTransformMerge(input) { |
|
6439 return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase(); |
|
6440 } |
|
6441 function pascalCase(input, options) { |
|
6442 if (options === void 0) { options = {}; } |
|
6443 return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options)); |
|
6444 } |
|
6445 |
|
6446 ;// CONCATENATED MODULE: ./node_modules/camel-case/dist.es2015/index.js |
|
6447 |
|
6448 |
|
6449 function camelCaseTransform(input, index) { |
|
6450 if (index === 0) |
|
6451 return input.toLowerCase(); |
|
6452 return pascalCaseTransform(input, index); |
|
6453 } |
|
6454 function camelCaseTransformMerge(input, index) { |
|
6455 if (index === 0) |
|
6456 return input.toLowerCase(); |
|
6457 return pascalCaseTransformMerge(input); |
|
6458 } |
|
6459 function camelCase(input, options) { |
|
6460 if (options === void 0) { options = {}; } |
|
6461 return pascalCase(input, __assign({ transform: camelCaseTransform }, options)); |
|
6462 } |
|
6463 |
|
5519 ;// CONCATENATED MODULE: external ["wp","i18n"] |
6464 ;// CONCATENATED MODULE: external ["wp","i18n"] |
5520 var external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
6465 const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
5521 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/reducer.js |
|
5522 /** |
|
5523 * External dependencies |
|
5524 */ |
|
5525 |
|
5526 /** |
|
5527 * WordPress dependencies |
|
5528 */ |
|
5529 |
|
5530 |
|
5531 |
|
5532 /** |
|
5533 * @typedef {Object} WPBlockCategory |
|
5534 * |
|
5535 * @property {string} slug Unique category slug. |
|
5536 * @property {string} title Category label, for display in user interface. |
|
5537 */ |
|
5538 |
|
5539 /** |
|
5540 * Default set of categories. |
|
5541 * |
|
5542 * @type {WPBlockCategory[]} |
|
5543 */ |
|
5544 |
|
5545 const DEFAULT_CATEGORIES = [{ |
|
5546 slug: 'text', |
|
5547 title: (0,external_wp_i18n_namespaceObject.__)('Text') |
|
5548 }, { |
|
5549 slug: 'media', |
|
5550 title: (0,external_wp_i18n_namespaceObject.__)('Media') |
|
5551 }, { |
|
5552 slug: 'design', |
|
5553 title: (0,external_wp_i18n_namespaceObject.__)('Design') |
|
5554 }, { |
|
5555 slug: 'widgets', |
|
5556 title: (0,external_wp_i18n_namespaceObject.__)('Widgets') |
|
5557 }, { |
|
5558 slug: 'theme', |
|
5559 title: (0,external_wp_i18n_namespaceObject.__)('Theme') |
|
5560 }, { |
|
5561 slug: 'embed', |
|
5562 title: (0,external_wp_i18n_namespaceObject.__)('Embeds') |
|
5563 }, { |
|
5564 slug: 'reusable', |
|
5565 title: (0,external_wp_i18n_namespaceObject.__)('Reusable blocks') |
|
5566 }]; |
|
5567 /** |
|
5568 * Reducer managing the unprocessed block types in a form passed when registering the by block. |
|
5569 * It's for internal use only. It allows recomputing the processed block types on-demand after block type filters |
|
5570 * get added or removed. |
|
5571 * |
|
5572 * @param {Object} state Current state. |
|
5573 * @param {Object} action Dispatched action. |
|
5574 * |
|
5575 * @return {Object} Updated state. |
|
5576 */ |
|
5577 |
|
5578 function unprocessedBlockTypes() { |
|
5579 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
5580 let action = arguments.length > 1 ? arguments[1] : undefined; |
|
5581 |
|
5582 switch (action.type) { |
|
5583 case 'ADD_UNPROCESSED_BLOCK_TYPE': |
|
5584 return { ...state, |
|
5585 [action.blockType.name]: action.blockType |
|
5586 }; |
|
5587 |
|
5588 case 'REMOVE_BLOCK_TYPES': |
|
5589 return (0,external_lodash_namespaceObject.omit)(state, action.names); |
|
5590 } |
|
5591 |
|
5592 return state; |
|
5593 } |
|
5594 /** |
|
5595 * Reducer managing the processed block types with all filters applied. |
|
5596 * The state is derived from the `unprocessedBlockTypes` reducer. |
|
5597 * |
|
5598 * @param {Object} state Current state. |
|
5599 * @param {Object} action Dispatched action. |
|
5600 * |
|
5601 * @return {Object} Updated state. |
|
5602 */ |
|
5603 |
|
5604 function blockTypes() { |
|
5605 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
5606 let action = arguments.length > 1 ? arguments[1] : undefined; |
|
5607 |
|
5608 switch (action.type) { |
|
5609 case 'ADD_BLOCK_TYPES': |
|
5610 return { ...state, |
|
5611 ...(0,external_lodash_namespaceObject.keyBy)(action.blockTypes, 'name') |
|
5612 }; |
|
5613 |
|
5614 case 'REMOVE_BLOCK_TYPES': |
|
5615 return (0,external_lodash_namespaceObject.omit)(state, action.names); |
|
5616 } |
|
5617 |
|
5618 return state; |
|
5619 } |
|
5620 /** |
|
5621 * Reducer managing the block style variations. |
|
5622 * |
|
5623 * @param {Object} state Current state. |
|
5624 * @param {Object} action Dispatched action. |
|
5625 * |
|
5626 * @return {Object} Updated state. |
|
5627 */ |
|
5628 |
|
5629 function blockStyles() { |
|
5630 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
5631 let action = arguments.length > 1 ? arguments[1] : undefined; |
|
5632 |
|
5633 switch (action.type) { |
|
5634 case 'ADD_BLOCK_TYPES': |
|
5635 return { ...state, |
|
5636 ...(0,external_lodash_namespaceObject.mapValues)((0,external_lodash_namespaceObject.keyBy)(action.blockTypes, 'name'), blockType => { |
|
5637 return (0,external_lodash_namespaceObject.uniqBy)([...(0,external_lodash_namespaceObject.get)(blockType, ['styles'], []).map(style => ({ ...style, |
|
5638 source: 'block' |
|
5639 })), ...(0,external_lodash_namespaceObject.get)(state, [blockType.name], []).filter(_ref => { |
|
5640 let { |
|
5641 source |
|
5642 } = _ref; |
|
5643 return 'block' !== source; |
|
5644 })], style => style.name); |
|
5645 }) |
|
5646 }; |
|
5647 |
|
5648 case 'ADD_BLOCK_STYLES': |
|
5649 return { ...state, |
|
5650 [action.blockName]: (0,external_lodash_namespaceObject.uniqBy)([...(0,external_lodash_namespaceObject.get)(state, [action.blockName], []), ...action.styles], style => style.name) |
|
5651 }; |
|
5652 |
|
5653 case 'REMOVE_BLOCK_STYLES': |
|
5654 return { ...state, |
|
5655 [action.blockName]: (0,external_lodash_namespaceObject.filter)((0,external_lodash_namespaceObject.get)(state, [action.blockName], []), style => action.styleNames.indexOf(style.name) === -1) |
|
5656 }; |
|
5657 } |
|
5658 |
|
5659 return state; |
|
5660 } |
|
5661 /** |
|
5662 * Reducer managing the block variations. |
|
5663 * |
|
5664 * @param {Object} state Current state. |
|
5665 * @param {Object} action Dispatched action. |
|
5666 * |
|
5667 * @return {Object} Updated state. |
|
5668 */ |
|
5669 |
|
5670 function blockVariations() { |
|
5671 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
5672 let action = arguments.length > 1 ? arguments[1] : undefined; |
|
5673 |
|
5674 switch (action.type) { |
|
5675 case 'ADD_BLOCK_TYPES': |
|
5676 return { ...state, |
|
5677 ...(0,external_lodash_namespaceObject.mapValues)((0,external_lodash_namespaceObject.keyBy)(action.blockTypes, 'name'), blockType => { |
|
5678 return (0,external_lodash_namespaceObject.uniqBy)([...(0,external_lodash_namespaceObject.get)(blockType, ['variations'], []).map(variation => ({ ...variation, |
|
5679 source: 'block' |
|
5680 })), ...(0,external_lodash_namespaceObject.get)(state, [blockType.name], []).filter(_ref2 => { |
|
5681 let { |
|
5682 source |
|
5683 } = _ref2; |
|
5684 return 'block' !== source; |
|
5685 })], variation => variation.name); |
|
5686 }) |
|
5687 }; |
|
5688 |
|
5689 case 'ADD_BLOCK_VARIATIONS': |
|
5690 return { ...state, |
|
5691 [action.blockName]: (0,external_lodash_namespaceObject.uniqBy)([...(0,external_lodash_namespaceObject.get)(state, [action.blockName], []), ...action.variations], variation => variation.name) |
|
5692 }; |
|
5693 |
|
5694 case 'REMOVE_BLOCK_VARIATIONS': |
|
5695 return { ...state, |
|
5696 [action.blockName]: (0,external_lodash_namespaceObject.filter)((0,external_lodash_namespaceObject.get)(state, [action.blockName], []), variation => action.variationNames.indexOf(variation.name) === -1) |
|
5697 }; |
|
5698 } |
|
5699 |
|
5700 return state; |
|
5701 } |
|
5702 /** |
|
5703 * Higher-order Reducer creating a reducer keeping track of given block name. |
|
5704 * |
|
5705 * @param {string} setActionType Action type. |
|
5706 * |
|
5707 * @return {Function} Reducer. |
|
5708 */ |
|
5709 |
|
5710 function createBlockNameSetterReducer(setActionType) { |
|
5711 return function () { |
|
5712 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; |
|
5713 let action = arguments.length > 1 ? arguments[1] : undefined; |
|
5714 |
|
5715 switch (action.type) { |
|
5716 case 'REMOVE_BLOCK_TYPES': |
|
5717 if (action.names.indexOf(state) !== -1) { |
|
5718 return null; |
|
5719 } |
|
5720 |
|
5721 return state; |
|
5722 |
|
5723 case setActionType: |
|
5724 return action.name || null; |
|
5725 } |
|
5726 |
|
5727 return state; |
|
5728 }; |
|
5729 } |
|
5730 const defaultBlockName = createBlockNameSetterReducer('SET_DEFAULT_BLOCK_NAME'); |
|
5731 const freeformFallbackBlockName = createBlockNameSetterReducer('SET_FREEFORM_FALLBACK_BLOCK_NAME'); |
|
5732 const unregisteredFallbackBlockName = createBlockNameSetterReducer('SET_UNREGISTERED_FALLBACK_BLOCK_NAME'); |
|
5733 const groupingBlockName = createBlockNameSetterReducer('SET_GROUPING_BLOCK_NAME'); |
|
5734 /** |
|
5735 * Reducer managing the categories |
|
5736 * |
|
5737 * @param {WPBlockCategory[]} state Current state. |
|
5738 * @param {Object} action Dispatched action. |
|
5739 * |
|
5740 * @return {WPBlockCategory[]} Updated state. |
|
5741 */ |
|
5742 |
|
5743 function categories() { |
|
5744 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_CATEGORIES; |
|
5745 let action = arguments.length > 1 ? arguments[1] : undefined; |
|
5746 |
|
5747 switch (action.type) { |
|
5748 case 'SET_CATEGORIES': |
|
5749 return action.categories || []; |
|
5750 |
|
5751 case 'UPDATE_CATEGORY': |
|
5752 { |
|
5753 if (!action.category || (0,external_lodash_namespaceObject.isEmpty)(action.category)) { |
|
5754 return state; |
|
5755 } |
|
5756 |
|
5757 const categoryToChange = (0,external_lodash_namespaceObject.find)(state, ['slug', action.slug]); |
|
5758 |
|
5759 if (categoryToChange) { |
|
5760 return (0,external_lodash_namespaceObject.map)(state, category => { |
|
5761 if (category.slug === action.slug) { |
|
5762 return { ...category, |
|
5763 ...action.category |
|
5764 }; |
|
5765 } |
|
5766 |
|
5767 return category; |
|
5768 }); |
|
5769 } |
|
5770 } |
|
5771 } |
|
5772 |
|
5773 return state; |
|
5774 } |
|
5775 function collections() { |
|
5776 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
5777 let action = arguments.length > 1 ? arguments[1] : undefined; |
|
5778 |
|
5779 switch (action.type) { |
|
5780 case 'ADD_BLOCK_COLLECTION': |
|
5781 return { ...state, |
|
5782 [action.namespace]: { |
|
5783 title: action.title, |
|
5784 icon: action.icon |
|
5785 } |
|
5786 }; |
|
5787 |
|
5788 case 'REMOVE_BLOCK_COLLECTION': |
|
5789 return (0,external_lodash_namespaceObject.omit)(state, action.namespace); |
|
5790 } |
|
5791 |
|
5792 return state; |
|
5793 } |
|
5794 /* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ |
|
5795 unprocessedBlockTypes, |
|
5796 blockTypes, |
|
5797 blockStyles, |
|
5798 blockVariations, |
|
5799 defaultBlockName, |
|
5800 freeformFallbackBlockName, |
|
5801 unregisteredFallbackBlockName, |
|
5802 groupingBlockName, |
|
5803 categories, |
|
5804 collections |
|
5805 })); |
|
5806 |
|
5807 ;// CONCATENATED MODULE: ./node_modules/rememo/es/rememo.js |
|
5808 |
|
5809 |
|
5810 var LEAF_KEY, hasWeakMap; |
|
5811 |
|
5812 /** |
|
5813 * Arbitrary value used as key for referencing cache object in WeakMap tree. |
|
5814 * |
|
5815 * @type {Object} |
|
5816 */ |
|
5817 LEAF_KEY = {}; |
|
5818 |
|
5819 /** |
|
5820 * Whether environment supports WeakMap. |
|
5821 * |
|
5822 * @type {boolean} |
|
5823 */ |
|
5824 hasWeakMap = typeof WeakMap !== 'undefined'; |
|
5825 |
|
5826 /** |
|
5827 * Returns the first argument as the sole entry in an array. |
|
5828 * |
|
5829 * @param {*} value Value to return. |
|
5830 * |
|
5831 * @return {Array} Value returned as entry in array. |
|
5832 */ |
|
5833 function arrayOf( value ) { |
|
5834 return [ value ]; |
|
5835 } |
|
5836 |
|
5837 /** |
|
5838 * Returns true if the value passed is object-like, or false otherwise. A value |
|
5839 * is object-like if it can support property assignment, e.g. object or array. |
|
5840 * |
|
5841 * @param {*} value Value to test. |
|
5842 * |
|
5843 * @return {boolean} Whether value is object-like. |
|
5844 */ |
|
5845 function isObjectLike( value ) { |
|
5846 return !! value && 'object' === typeof value; |
|
5847 } |
|
5848 |
|
5849 /** |
|
5850 * Creates and returns a new cache object. |
|
5851 * |
|
5852 * @return {Object} Cache object. |
|
5853 */ |
|
5854 function createCache() { |
|
5855 var cache = { |
|
5856 clear: function() { |
|
5857 cache.head = null; |
|
5858 }, |
|
5859 }; |
|
5860 |
|
5861 return cache; |
|
5862 } |
|
5863 |
|
5864 /** |
|
5865 * Returns true if entries within the two arrays are strictly equal by |
|
5866 * reference from a starting index. |
|
5867 * |
|
5868 * @param {Array} a First array. |
|
5869 * @param {Array} b Second array. |
|
5870 * @param {number} fromIndex Index from which to start comparison. |
|
5871 * |
|
5872 * @return {boolean} Whether arrays are shallowly equal. |
|
5873 */ |
|
5874 function isShallowEqual( a, b, fromIndex ) { |
|
5875 var i; |
|
5876 |
|
5877 if ( a.length !== b.length ) { |
|
5878 return false; |
|
5879 } |
|
5880 |
|
5881 for ( i = fromIndex; i < a.length; i++ ) { |
|
5882 if ( a[ i ] !== b[ i ] ) { |
|
5883 return false; |
|
5884 } |
|
5885 } |
|
5886 |
|
5887 return true; |
|
5888 } |
|
5889 |
|
5890 /** |
|
5891 * Returns a memoized selector function. The getDependants function argument is |
|
5892 * called before the memoized selector and is expected to return an immutable |
|
5893 * reference or array of references on which the selector depends for computing |
|
5894 * its own return value. The memoize cache is preserved only as long as those |
|
5895 * dependant references remain the same. If getDependants returns a different |
|
5896 * reference(s), the cache is cleared and the selector value regenerated. |
|
5897 * |
|
5898 * @param {Function} selector Selector function. |
|
5899 * @param {Function} getDependants Dependant getter returning an immutable |
|
5900 * reference or array of reference used in |
|
5901 * cache bust consideration. |
|
5902 * |
|
5903 * @return {Function} Memoized selector. |
|
5904 */ |
|
5905 /* harmony default export */ function rememo(selector, getDependants ) { |
|
5906 var rootCache, getCache; |
|
5907 |
|
5908 // Use object source as dependant if getter not provided |
|
5909 if ( ! getDependants ) { |
|
5910 getDependants = arrayOf; |
|
5911 } |
|
5912 |
|
5913 /** |
|
5914 * Returns the root cache. If WeakMap is supported, this is assigned to the |
|
5915 * root WeakMap cache set, otherwise it is a shared instance of the default |
|
5916 * cache object. |
|
5917 * |
|
5918 * @return {(WeakMap|Object)} Root cache object. |
|
5919 */ |
|
5920 function getRootCache() { |
|
5921 return rootCache; |
|
5922 } |
|
5923 |
|
5924 /** |
|
5925 * Returns the cache for a given dependants array. When possible, a WeakMap |
|
5926 * will be used to create a unique cache for each set of dependants. This |
|
5927 * is feasible due to the nature of WeakMap in allowing garbage collection |
|
5928 * to occur on entries where the key object is no longer referenced. Since |
|
5929 * WeakMap requires the key to be an object, this is only possible when the |
|
5930 * dependant is object-like. The root cache is created as a hierarchy where |
|
5931 * each top-level key is the first entry in a dependants set, the value a |
|
5932 * WeakMap where each key is the next dependant, and so on. This continues |
|
5933 * so long as the dependants are object-like. If no dependants are object- |
|
5934 * like, then the cache is shared across all invocations. |
|
5935 * |
|
5936 * @see isObjectLike |
|
5937 * |
|
5938 * @param {Array} dependants Selector dependants. |
|
5939 * |
|
5940 * @return {Object} Cache object. |
|
5941 */ |
|
5942 function getWeakMapCache( dependants ) { |
|
5943 var caches = rootCache, |
|
5944 isUniqueByDependants = true, |
|
5945 i, dependant, map, cache; |
|
5946 |
|
5947 for ( i = 0; i < dependants.length; i++ ) { |
|
5948 dependant = dependants[ i ]; |
|
5949 |
|
5950 // Can only compose WeakMap from object-like key. |
|
5951 if ( ! isObjectLike( dependant ) ) { |
|
5952 isUniqueByDependants = false; |
|
5953 break; |
|
5954 } |
|
5955 |
|
5956 // Does current segment of cache already have a WeakMap? |
|
5957 if ( caches.has( dependant ) ) { |
|
5958 // Traverse into nested WeakMap. |
|
5959 caches = caches.get( dependant ); |
|
5960 } else { |
|
5961 // Create, set, and traverse into a new one. |
|
5962 map = new WeakMap(); |
|
5963 caches.set( dependant, map ); |
|
5964 caches = map; |
|
5965 } |
|
5966 } |
|
5967 |
|
5968 // We use an arbitrary (but consistent) object as key for the last item |
|
5969 // in the WeakMap to serve as our running cache. |
|
5970 if ( ! caches.has( LEAF_KEY ) ) { |
|
5971 cache = createCache(); |
|
5972 cache.isUniqueByDependants = isUniqueByDependants; |
|
5973 caches.set( LEAF_KEY, cache ); |
|
5974 } |
|
5975 |
|
5976 return caches.get( LEAF_KEY ); |
|
5977 } |
|
5978 |
|
5979 // Assign cache handler by availability of WeakMap |
|
5980 getCache = hasWeakMap ? getWeakMapCache : getRootCache; |
|
5981 |
|
5982 /** |
|
5983 * Resets root memoization cache. |
|
5984 */ |
|
5985 function clear() { |
|
5986 rootCache = hasWeakMap ? new WeakMap() : createCache(); |
|
5987 } |
|
5988 |
|
5989 // eslint-disable-next-line jsdoc/check-param-names |
|
5990 /** |
|
5991 * The augmented selector call, considering first whether dependants have |
|
5992 * changed before passing it to underlying memoize function. |
|
5993 * |
|
5994 * @param {Object} source Source object for derivation. |
|
5995 * @param {...*} extraArgs Additional arguments to pass to selector. |
|
5996 * |
|
5997 * @return {*} Selector result. |
|
5998 */ |
|
5999 function callSelector( /* source, ...extraArgs */ ) { |
|
6000 var len = arguments.length, |
|
6001 cache, node, i, args, dependants; |
|
6002 |
|
6003 // Create copy of arguments (avoid leaking deoptimization). |
|
6004 args = new Array( len ); |
|
6005 for ( i = 0; i < len; i++ ) { |
|
6006 args[ i ] = arguments[ i ]; |
|
6007 } |
|
6008 |
|
6009 dependants = getDependants.apply( null, args ); |
|
6010 cache = getCache( dependants ); |
|
6011 |
|
6012 // If not guaranteed uniqueness by dependants (primitive type or lack |
|
6013 // of WeakMap support), shallow compare against last dependants and, if |
|
6014 // references have changed, destroy cache to recalculate result. |
|
6015 if ( ! cache.isUniqueByDependants ) { |
|
6016 if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) { |
|
6017 cache.clear(); |
|
6018 } |
|
6019 |
|
6020 cache.lastDependants = dependants; |
|
6021 } |
|
6022 |
|
6023 node = cache.head; |
|
6024 while ( node ) { |
|
6025 // Check whether node arguments match arguments |
|
6026 if ( ! isShallowEqual( node.args, args, 1 ) ) { |
|
6027 node = node.next; |
|
6028 continue; |
|
6029 } |
|
6030 |
|
6031 // At this point we can assume we've found a match |
|
6032 |
|
6033 // Surface matched node to head if not already |
|
6034 if ( node !== cache.head ) { |
|
6035 // Adjust siblings to point to each other. |
|
6036 node.prev.next = node.next; |
|
6037 if ( node.next ) { |
|
6038 node.next.prev = node.prev; |
|
6039 } |
|
6040 |
|
6041 node.next = cache.head; |
|
6042 node.prev = null; |
|
6043 cache.head.prev = node; |
|
6044 cache.head = node; |
|
6045 } |
|
6046 |
|
6047 // Return immediately |
|
6048 return node.val; |
|
6049 } |
|
6050 |
|
6051 // No cached value found. Continue to insertion phase: |
|
6052 |
|
6053 node = { |
|
6054 // Generate the result from original function |
|
6055 val: selector.apply( null, args ), |
|
6056 }; |
|
6057 |
|
6058 // Avoid including the source object in the cache. |
|
6059 args[ 0 ] = null; |
|
6060 node.args = args; |
|
6061 |
|
6062 // Don't need to check whether node is already head, since it would |
|
6063 // have been returned above already if it was |
|
6064 |
|
6065 // Shift existing head down list |
|
6066 if ( cache.head ) { |
|
6067 cache.head.prev = node; |
|
6068 node.next = cache.head; |
|
6069 } |
|
6070 |
|
6071 cache.head = node; |
|
6072 |
|
6073 return node.val; |
|
6074 } |
|
6075 |
|
6076 callSelector.getDependants = getDependants; |
|
6077 callSelector.clear = clear; |
|
6078 clear(); |
|
6079 |
|
6080 return callSelector; |
|
6081 } |
|
6082 |
|
6083 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/selectors.js |
|
6084 /** |
|
6085 * External dependencies |
|
6086 */ |
|
6087 |
|
6088 |
|
6089 /** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */ |
|
6090 |
|
6091 /** @typedef {import('../api/registration').WPBlockVariationScope} WPBlockVariationScope */ |
|
6092 |
|
6093 /** @typedef {import('./reducer').WPBlockCategory} WPBlockCategory */ |
|
6094 |
|
6095 /** |
|
6096 * Given a block name or block type object, returns the corresponding |
|
6097 * normalized block type object. |
|
6098 * |
|
6099 * @param {Object} state Blocks state. |
|
6100 * @param {(string|Object)} nameOrType Block name or type object |
|
6101 * |
|
6102 * @return {Object} Block type object. |
|
6103 */ |
|
6104 |
|
6105 const getNormalizedBlockType = (state, nameOrType) => 'string' === typeof nameOrType ? getBlockType(state, nameOrType) : nameOrType; |
|
6106 /** |
|
6107 * Returns all the unprocessed block types as passed during the registration. |
|
6108 * |
|
6109 * @param {Object} state Data state. |
|
6110 * |
|
6111 * @return {Array} Unprocessed block types. |
|
6112 */ |
|
6113 |
|
6114 |
|
6115 function __experimentalGetUnprocessedBlockTypes(state) { |
|
6116 return state.unprocessedBlockTypes; |
|
6117 } |
|
6118 /** |
|
6119 * Returns all the available block types. |
|
6120 * |
|
6121 * @param {Object} state Data state. |
|
6122 * |
|
6123 * @return {Array} Block Types. |
|
6124 */ |
|
6125 |
|
6126 const getBlockTypes = rememo(state => Object.values(state.blockTypes), state => [state.blockTypes]); |
|
6127 /** |
|
6128 * Returns a block type by name. |
|
6129 * |
|
6130 * @param {Object} state Data state. |
|
6131 * @param {string} name Block type name. |
|
6132 * |
|
6133 * @return {Object?} Block Type. |
|
6134 */ |
|
6135 |
|
6136 function getBlockType(state, name) { |
|
6137 return state.blockTypes[name]; |
|
6138 } |
|
6139 /** |
|
6140 * Returns block styles by block name. |
|
6141 * |
|
6142 * @param {Object} state Data state. |
|
6143 * @param {string} name Block type name. |
|
6144 * |
|
6145 * @return {Array?} Block Styles. |
|
6146 */ |
|
6147 |
|
6148 function getBlockStyles(state, name) { |
|
6149 return state.blockStyles[name]; |
|
6150 } |
|
6151 /** |
|
6152 * Returns block variations by block name. |
|
6153 * |
|
6154 * @param {Object} state Data state. |
|
6155 * @param {string} blockName Block type name. |
|
6156 * @param {WPBlockVariationScope} [scope] Block variation scope name. |
|
6157 * |
|
6158 * @return {(WPBlockVariation[]|void)} Block variations. |
|
6159 */ |
|
6160 |
|
6161 const getBlockVariations = rememo((state, blockName, scope) => { |
|
6162 const variations = state.blockVariations[blockName]; |
|
6163 |
|
6164 if (!variations || !scope) { |
|
6165 return variations; |
|
6166 } |
|
6167 |
|
6168 return variations.filter(variation => { |
|
6169 // For backward compatibility reasons, variation's scope defaults to |
|
6170 // `block` and `inserter` when not set. |
|
6171 return (variation.scope || ['block', 'inserter']).includes(scope); |
|
6172 }); |
|
6173 }, (state, blockName) => [state.blockVariations[blockName]]); |
|
6174 /** |
|
6175 * Returns the active block variation for a given block based on its attributes. |
|
6176 * Variations are determined by their `isActive` property. |
|
6177 * Which is either an array of block attribute keys or a function. |
|
6178 * |
|
6179 * In case of an array of block attribute keys, the `attributes` are compared |
|
6180 * to the variation's attributes using strict equality check. |
|
6181 * |
|
6182 * In case of function type, the function should accept a block's attributes |
|
6183 * and the variation's attributes and determines if a variation is active. |
|
6184 * A function that accepts a block's attributes and the variation's attributes and determines if a variation is active. |
|
6185 * |
|
6186 * @param {Object} state Data state. |
|
6187 * @param {string} blockName Name of block (example: “core/columns”). |
|
6188 * @param {Object} attributes Block attributes used to determine active variation. |
|
6189 * @param {WPBlockVariationScope} [scope] Block variation scope name. |
|
6190 * |
|
6191 * @return {(WPBlockVariation|undefined)} Active block variation. |
|
6192 */ |
|
6193 |
|
6194 function getActiveBlockVariation(state, blockName, attributes, scope) { |
|
6195 const variations = getBlockVariations(state, blockName, scope); |
|
6196 const match = variations === null || variations === void 0 ? void 0 : variations.find(variation => { |
|
6197 var _variation$isActive; |
|
6198 |
|
6199 if (Array.isArray(variation.isActive)) { |
|
6200 const blockType = getBlockType(state, blockName); |
|
6201 const attributeKeys = Object.keys((blockType === null || blockType === void 0 ? void 0 : blockType.attributes) || {}); |
|
6202 const definedAttributes = variation.isActive.filter(attribute => attributeKeys.includes(attribute)); |
|
6203 |
|
6204 if (definedAttributes.length === 0) { |
|
6205 return false; |
|
6206 } |
|
6207 |
|
6208 return definedAttributes.every(attribute => attributes[attribute] === variation.attributes[attribute]); |
|
6209 } |
|
6210 |
|
6211 return (_variation$isActive = variation.isActive) === null || _variation$isActive === void 0 ? void 0 : _variation$isActive.call(variation, attributes, variation.attributes); |
|
6212 }); |
|
6213 return match; |
|
6214 } |
|
6215 /** |
|
6216 * Returns the default block variation for the given block type. |
|
6217 * When there are multiple variations annotated as the default one, |
|
6218 * the last added item is picked. This simplifies registering overrides. |
|
6219 * When there is no default variation set, it returns the first item. |
|
6220 * |
|
6221 * @param {Object} state Data state. |
|
6222 * @param {string} blockName Block type name. |
|
6223 * @param {WPBlockVariationScope} [scope] Block variation scope name. |
|
6224 * |
|
6225 * @return {?WPBlockVariation} The default block variation. |
|
6226 */ |
|
6227 |
|
6228 function getDefaultBlockVariation(state, blockName, scope) { |
|
6229 const variations = getBlockVariations(state, blockName, scope); |
|
6230 return (0,external_lodash_namespaceObject.findLast)(variations, 'isDefault') || (0,external_lodash_namespaceObject.first)(variations); |
|
6231 } |
|
6232 /** |
|
6233 * Returns all the available categories. |
|
6234 * |
|
6235 * @param {Object} state Data state. |
|
6236 * |
|
6237 * @return {WPBlockCategory[]} Categories list. |
|
6238 */ |
|
6239 |
|
6240 function getCategories(state) { |
|
6241 return state.categories; |
|
6242 } |
|
6243 /** |
|
6244 * Returns all the available collections. |
|
6245 * |
|
6246 * @param {Object} state Data state. |
|
6247 * |
|
6248 * @return {Object} Collections list. |
|
6249 */ |
|
6250 |
|
6251 function getCollections(state) { |
|
6252 return state.collections; |
|
6253 } |
|
6254 /** |
|
6255 * Returns the name of the default block name. |
|
6256 * |
|
6257 * @param {Object} state Data state. |
|
6258 * |
|
6259 * @return {string?} Default block name. |
|
6260 */ |
|
6261 |
|
6262 function getDefaultBlockName(state) { |
|
6263 return state.defaultBlockName; |
|
6264 } |
|
6265 /** |
|
6266 * Returns the name of the block for handling non-block content. |
|
6267 * |
|
6268 * @param {Object} state Data state. |
|
6269 * |
|
6270 * @return {string?} Name of the block for handling non-block content. |
|
6271 */ |
|
6272 |
|
6273 function getFreeformFallbackBlockName(state) { |
|
6274 return state.freeformFallbackBlockName; |
|
6275 } |
|
6276 /** |
|
6277 * Returns the name of the block for handling unregistered blocks. |
|
6278 * |
|
6279 * @param {Object} state Data state. |
|
6280 * |
|
6281 * @return {string?} Name of the block for handling unregistered blocks. |
|
6282 */ |
|
6283 |
|
6284 function getUnregisteredFallbackBlockName(state) { |
|
6285 return state.unregisteredFallbackBlockName; |
|
6286 } |
|
6287 /** |
|
6288 * Returns the name of the block for handling unregistered blocks. |
|
6289 * |
|
6290 * @param {Object} state Data state. |
|
6291 * |
|
6292 * @return {string?} Name of the block for handling unregistered blocks. |
|
6293 */ |
|
6294 |
|
6295 function getGroupingBlockName(state) { |
|
6296 return state.groupingBlockName; |
|
6297 } |
|
6298 /** |
|
6299 * Returns an array with the child blocks of a given block. |
|
6300 * |
|
6301 * @param {Object} state Data state. |
|
6302 * @param {string} blockName Block type name. |
|
6303 * |
|
6304 * @return {Array} Array of child block names. |
|
6305 */ |
|
6306 |
|
6307 const getChildBlockNames = rememo((state, blockName) => { |
|
6308 return (0,external_lodash_namespaceObject.map)((0,external_lodash_namespaceObject.filter)(state.blockTypes, blockType => { |
|
6309 return (0,external_lodash_namespaceObject.includes)(blockType.parent, blockName); |
|
6310 }), _ref => { |
|
6311 let { |
|
6312 name |
|
6313 } = _ref; |
|
6314 return name; |
|
6315 }); |
|
6316 }, state => [state.blockTypes]); |
|
6317 /** |
|
6318 * Returns the block support value for a feature, if defined. |
|
6319 * |
|
6320 * @param {Object} state Data state. |
|
6321 * @param {(string|Object)} nameOrType Block name or type object |
|
6322 * @param {Array|string} feature Feature to retrieve |
|
6323 * @param {*} defaultSupports Default value to return if not |
|
6324 * explicitly defined |
|
6325 * |
|
6326 * @return {?*} Block support value |
|
6327 */ |
|
6328 |
|
6329 const getBlockSupport = (state, nameOrType, feature, defaultSupports) => { |
|
6330 const blockType = getNormalizedBlockType(state, nameOrType); |
|
6331 |
|
6332 if (!(blockType !== null && blockType !== void 0 && blockType.supports)) { |
|
6333 return defaultSupports; |
|
6334 } |
|
6335 |
|
6336 return (0,external_lodash_namespaceObject.get)(blockType.supports, feature, defaultSupports); |
|
6337 }; |
|
6338 /** |
|
6339 * Returns true if the block defines support for a feature, or false otherwise. |
|
6340 * |
|
6341 * @param {Object} state Data state. |
|
6342 * @param {(string|Object)} nameOrType Block name or type object. |
|
6343 * @param {string} feature Feature to test. |
|
6344 * @param {boolean} defaultSupports Whether feature is supported by |
|
6345 * default if not explicitly defined. |
|
6346 * |
|
6347 * @return {boolean} Whether block supports feature. |
|
6348 */ |
|
6349 |
|
6350 function hasBlockSupport(state, nameOrType, feature, defaultSupports) { |
|
6351 return !!getBlockSupport(state, nameOrType, feature, defaultSupports); |
|
6352 } |
|
6353 /** |
|
6354 * Returns true if the block type by the given name or object value matches a |
|
6355 * search term, or false otherwise. |
|
6356 * |
|
6357 * @param {Object} state Blocks state. |
|
6358 * @param {(string|Object)} nameOrType Block name or type object. |
|
6359 * @param {string} searchTerm Search term by which to filter. |
|
6360 * |
|
6361 * @return {Object[]} Whether block type matches search term. |
|
6362 */ |
|
6363 |
|
6364 function isMatchingSearchTerm(state, nameOrType, searchTerm) { |
|
6365 const blockType = getNormalizedBlockType(state, nameOrType); |
|
6366 const getNormalizedSearchTerm = (0,external_lodash_namespaceObject.flow)([// Disregard diacritics. |
|
6367 // Input: "média" |
|
6368 external_lodash_namespaceObject.deburr, // Lowercase. |
|
6369 // Input: "MEDIA" |
|
6370 term => term.toLowerCase(), // Strip leading and trailing whitespace. |
|
6371 // Input: " media " |
|
6372 term => term.trim()]); |
|
6373 const normalizedSearchTerm = getNormalizedSearchTerm(searchTerm); |
|
6374 const isSearchMatch = (0,external_lodash_namespaceObject.flow)([getNormalizedSearchTerm, normalizedCandidate => (0,external_lodash_namespaceObject.includes)(normalizedCandidate, normalizedSearchTerm)]); |
|
6375 return isSearchMatch(blockType.title) || (0,external_lodash_namespaceObject.some)(blockType.keywords, isSearchMatch) || isSearchMatch(blockType.category) || isSearchMatch(blockType.description); |
|
6376 } |
|
6377 /** |
|
6378 * Returns a boolean indicating if a block has child blocks or not. |
|
6379 * |
|
6380 * @param {Object} state Data state. |
|
6381 * @param {string} blockName Block type name. |
|
6382 * |
|
6383 * @return {boolean} True if a block contains child blocks and false otherwise. |
|
6384 */ |
|
6385 |
|
6386 const hasChildBlocks = (state, blockName) => { |
|
6387 return getChildBlockNames(state, blockName).length > 0; |
|
6388 }; |
|
6389 /** |
|
6390 * Returns a boolean indicating if a block has at least one child block with inserter support. |
|
6391 * |
|
6392 * @param {Object} state Data state. |
|
6393 * @param {string} blockName Block type name. |
|
6394 * |
|
6395 * @return {boolean} True if a block contains at least one child blocks with inserter support |
|
6396 * and false otherwise. |
|
6397 */ |
|
6398 |
|
6399 const hasChildBlocksWithInserterSupport = (state, blockName) => { |
|
6400 return (0,external_lodash_namespaceObject.some)(getChildBlockNames(state, blockName), childBlockName => { |
|
6401 return hasBlockSupport(state, childBlockName, 'inserter', true); |
|
6402 }); |
|
6403 }; |
|
6404 |
|
6405 ;// CONCATENATED MODULE: external ["wp","hooks"] |
|
6406 var external_wp_hooks_namespaceObject = window["wp"]["hooks"]; |
|
6407 ;// CONCATENATED MODULE: ./node_modules/colord/index.mjs |
6466 ;// CONCATENATED MODULE: ./node_modules/colord/index.mjs |
6408 var r={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n+0},e=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},u=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},a=function(r){return{r:e(r.r,0,255),g:e(r.g,0,255),b:e(r.b,0,255),a:e(r.a)}},o=function(r){return{r:n(r.r),g:n(r.g),b:n(r.b),a:n(r.a,3)}},i=/^#([0-9a-f]{3,8})$/i,s=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},h=function(r){var t=r.r,n=r.g,e=r.b,u=r.a,a=Math.max(t,n,e),o=a-Math.min(t,n,e),i=o?a===t?(n-e)/o:a===n?2+(e-t)/o:4+(t-n)/o:0;return{h:60*(i<0?i+6:i),s:a?o/a*100:0,v:a/255*100,a:u}},b=function(r){var t=r.h,n=r.s,e=r.v,u=r.a;t=t/360*6,n/=100,e/=100;var a=Math.floor(t),o=e*(1-n),i=e*(1-(t-a)*n),s=e*(1-(1-t+a)*n),h=a%6;return{r:255*[e,i,o,o,s,e][h],g:255*[s,e,e,i,o,o][h],b:255*[o,o,s,e,e,i][h],a:u}},g=function(r){return{h:u(r.h),s:e(r.s,0,100),l:e(r.l,0,100),a:e(r.a)}},d=function(r){return{h:n(r.h),s:n(r.s),l:n(r.l),a:n(r.a,3)}},f=function(r){return b((n=(t=r).s,{h:t.h,s:(n*=((e=t.l)<50?e:100-e)/100)>0?2*n/(e+n)*100:0,v:e+n,a:t.a}));var t,n,e},c=function(r){return{h:(t=h(r)).h,s:(u=(200-(n=t.s))*(e=t.v)/100)>0&&u<200?n*e/100/(u<=100?u:200-u)*100:0,l:u/2,a:t.a};var t,n,e,u},l=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,p=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,v=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,m=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y={string:[[function(r){var t=i.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:4===r.length?n(parseInt(r[3]+r[3],16)/255,2):1}:6===r.length||8===r.length?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:8===r.length?n(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=v.exec(r)||m.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:a({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:void 0===t[7]?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(t){var n=l.exec(t)||p.exec(t);if(!n)return null;var e,u,a=g({h:(e=n[1],u=n[2],void 0===u&&(u="deg"),Number(e)*(r[u]||1)),s:Number(n[3]),l:Number(n[4]),a:void 0===n[5]?1:Number(n[5])/(n[6]?100:1)});return f(a)},"hsl"]],object:[[function(r){var n=r.r,e=r.g,u=r.b,o=r.a,i=void 0===o?1:o;return t(n)&&t(e)&&t(u)?a({r:Number(n),g:Number(e),b:Number(u),a:Number(i)}):null},"rgb"],[function(r){var n=r.h,e=r.s,u=r.l,a=r.a,o=void 0===a?1:a;if(!t(n)||!t(e)||!t(u))return null;var i=g({h:Number(n),s:Number(e),l:Number(u),a:Number(o)});return f(i)},"hsl"],[function(r){var n=r.h,a=r.s,o=r.v,i=r.a,s=void 0===i?1:i;if(!t(n)||!t(a)||!t(o))return null;var h=function(r){return{h:u(r.h),s:e(r.s,0,100),v:e(r.v,0,100),a:e(r.a)}}({h:Number(n),s:Number(a),v:Number(o),a:Number(s)});return b(h)},"hsv"]]},N=function(r,t){for(var n=0;n<t.length;n++){var e=t[n][0](r);if(e)return[e,t[n][1]]}return[null,void 0]},x=function(r){return"string"==typeof r?N(r.trim(),y.string):"object"==typeof r&&null!==r?N(r,y.object):[null,void 0]},I=function(r){return x(r)[1]},M=function(r,t){var n=c(r);return{h:n.h,s:e(n.s+100*t,0,100),l:n.l,a:n.a}},H=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},$=function(r,t){var n=c(r);return{h:n.h,s:n.s,l:e(n.l+100*t,0,100),a:n.a}},j=function(){function r(r){this.parsed=x(r)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return null!==this.parsed},r.prototype.brightness=function(){return n(H(this.rgba),2)},r.prototype.isDark=function(){return H(this.rgba)<.5},r.prototype.isLight=function(){return H(this.rgba)>=.5},r.prototype.toHex=function(){return r=o(this.rgba),t=r.r,e=r.g,u=r.b,i=(a=r.a)<1?s(n(255*a)):"","#"+s(t)+s(e)+s(u)+i;var r,t,e,u,a,i},r.prototype.toRgb=function(){return o(this.rgba)},r.prototype.toRgbString=function(){return r=o(this.rgba),t=r.r,n=r.g,e=r.b,(u=r.a)<1?"rgba("+t+", "+n+", "+e+", "+u+")":"rgb("+t+", "+n+", "+e+")";var r,t,n,e,u},r.prototype.toHsl=function(){return d(c(this.rgba))},r.prototype.toHslString=function(){return r=d(c(this.rgba)),t=r.h,n=r.s,e=r.l,(u=r.a)<1?"hsla("+t+", "+n+"%, "+e+"%, "+u+")":"hsl("+t+", "+n+"%, "+e+"%)";var r,t,n,e,u},r.prototype.toHsv=function(){return r=h(this.rgba),{h:n(r.h),s:n(r.s),v:n(r.v),a:n(r.a,3)};var r},r.prototype.invert=function(){return w({r:255-(r=this.rgba).r,g:255-r.g,b:255-r.b,a:r.a});var r},r.prototype.saturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,r))},r.prototype.desaturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,-r))},r.prototype.grayscale=function(){return w(M(this.rgba,-1))},r.prototype.lighten=function(r){return void 0===r&&(r=.1),w($(this.rgba,r))},r.prototype.darken=function(r){return void 0===r&&(r=.1),w($(this.rgba,-r))},r.prototype.rotate=function(r){return void 0===r&&(r=15),this.hue(this.hue()+r)},r.prototype.alpha=function(r){return"number"==typeof r?w({r:(t=this.rgba).r,g:t.g,b:t.b,a:r}):n(this.rgba.a,3);var t},r.prototype.hue=function(r){var t=c(this.rgba);return"number"==typeof r?w({h:r,s:t.s,l:t.l,a:t.a}):n(t.h)},r.prototype.isEqual=function(r){return this.toHex()===w(r).toHex()},r}(),w=function(r){return r instanceof j?r:new j(r)},S=[],k=function(r){r.forEach(function(r){S.indexOf(r)<0&&(r(j,y),S.push(r))})},E=function(){return new j({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})}; |
6467 var r={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n+0},e=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},u=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},a=function(r){return{r:e(r.r,0,255),g:e(r.g,0,255),b:e(r.b,0,255),a:e(r.a)}},o=function(r){return{r:n(r.r),g:n(r.g),b:n(r.b),a:n(r.a,3)}},i=/^#([0-9a-f]{3,8})$/i,s=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},h=function(r){var t=r.r,n=r.g,e=r.b,u=r.a,a=Math.max(t,n,e),o=a-Math.min(t,n,e),i=o?a===t?(n-e)/o:a===n?2+(e-t)/o:4+(t-n)/o:0;return{h:60*(i<0?i+6:i),s:a?o/a*100:0,v:a/255*100,a:u}},b=function(r){var t=r.h,n=r.s,e=r.v,u=r.a;t=t/360*6,n/=100,e/=100;var a=Math.floor(t),o=e*(1-n),i=e*(1-(t-a)*n),s=e*(1-(1-t+a)*n),h=a%6;return{r:255*[e,i,o,o,s,e][h],g:255*[s,e,e,i,o,o][h],b:255*[o,o,s,e,e,i][h],a:u}},g=function(r){return{h:u(r.h),s:e(r.s,0,100),l:e(r.l,0,100),a:e(r.a)}},d=function(r){return{h:n(r.h),s:n(r.s),l:n(r.l),a:n(r.a,3)}},f=function(r){return b((n=(t=r).s,{h:t.h,s:(n*=((e=t.l)<50?e:100-e)/100)>0?2*n/(e+n)*100:0,v:e+n,a:t.a}));var t,n,e},c=function(r){return{h:(t=h(r)).h,s:(u=(200-(n=t.s))*(e=t.v)/100)>0&&u<200?n*e/100/(u<=100?u:200-u)*100:0,l:u/2,a:t.a};var t,n,e,u},l=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,p=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,v=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,m=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y={string:[[function(r){var t=i.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:4===r.length?n(parseInt(r[3]+r[3],16)/255,2):1}:6===r.length||8===r.length?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:8===r.length?n(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=v.exec(r)||m.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:a({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:void 0===t[7]?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(t){var n=l.exec(t)||p.exec(t);if(!n)return null;var e,u,a=g({h:(e=n[1],u=n[2],void 0===u&&(u="deg"),Number(e)*(r[u]||1)),s:Number(n[3]),l:Number(n[4]),a:void 0===n[5]?1:Number(n[5])/(n[6]?100:1)});return f(a)},"hsl"]],object:[[function(r){var n=r.r,e=r.g,u=r.b,o=r.a,i=void 0===o?1:o;return t(n)&&t(e)&&t(u)?a({r:Number(n),g:Number(e),b:Number(u),a:Number(i)}):null},"rgb"],[function(r){var n=r.h,e=r.s,u=r.l,a=r.a,o=void 0===a?1:a;if(!t(n)||!t(e)||!t(u))return null;var i=g({h:Number(n),s:Number(e),l:Number(u),a:Number(o)});return f(i)},"hsl"],[function(r){var n=r.h,a=r.s,o=r.v,i=r.a,s=void 0===i?1:i;if(!t(n)||!t(a)||!t(o))return null;var h=function(r){return{h:u(r.h),s:e(r.s,0,100),v:e(r.v,0,100),a:e(r.a)}}({h:Number(n),s:Number(a),v:Number(o),a:Number(s)});return b(h)},"hsv"]]},N=function(r,t){for(var n=0;n<t.length;n++){var e=t[n][0](r);if(e)return[e,t[n][1]]}return[null,void 0]},x=function(r){return"string"==typeof r?N(r.trim(),y.string):"object"==typeof r&&null!==r?N(r,y.object):[null,void 0]},I=function(r){return x(r)[1]},M=function(r,t){var n=c(r);return{h:n.h,s:e(n.s+100*t,0,100),l:n.l,a:n.a}},H=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},$=function(r,t){var n=c(r);return{h:n.h,s:n.s,l:e(n.l+100*t,0,100),a:n.a}},j=function(){function r(r){this.parsed=x(r)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return null!==this.parsed},r.prototype.brightness=function(){return n(H(this.rgba),2)},r.prototype.isDark=function(){return H(this.rgba)<.5},r.prototype.isLight=function(){return H(this.rgba)>=.5},r.prototype.toHex=function(){return r=o(this.rgba),t=r.r,e=r.g,u=r.b,i=(a=r.a)<1?s(n(255*a)):"","#"+s(t)+s(e)+s(u)+i;var r,t,e,u,a,i},r.prototype.toRgb=function(){return o(this.rgba)},r.prototype.toRgbString=function(){return r=o(this.rgba),t=r.r,n=r.g,e=r.b,(u=r.a)<1?"rgba("+t+", "+n+", "+e+", "+u+")":"rgb("+t+", "+n+", "+e+")";var r,t,n,e,u},r.prototype.toHsl=function(){return d(c(this.rgba))},r.prototype.toHslString=function(){return r=d(c(this.rgba)),t=r.h,n=r.s,e=r.l,(u=r.a)<1?"hsla("+t+", "+n+"%, "+e+"%, "+u+")":"hsl("+t+", "+n+"%, "+e+"%)";var r,t,n,e,u},r.prototype.toHsv=function(){return r=h(this.rgba),{h:n(r.h),s:n(r.s),v:n(r.v),a:n(r.a,3)};var r},r.prototype.invert=function(){return w({r:255-(r=this.rgba).r,g:255-r.g,b:255-r.b,a:r.a});var r},r.prototype.saturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,r))},r.prototype.desaturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,-r))},r.prototype.grayscale=function(){return w(M(this.rgba,-1))},r.prototype.lighten=function(r){return void 0===r&&(r=.1),w($(this.rgba,r))},r.prototype.darken=function(r){return void 0===r&&(r=.1),w($(this.rgba,-r))},r.prototype.rotate=function(r){return void 0===r&&(r=15),this.hue(this.hue()+r)},r.prototype.alpha=function(r){return"number"==typeof r?w({r:(t=this.rgba).r,g:t.g,b:t.b,a:r}):n(this.rgba.a,3);var t},r.prototype.hue=function(r){var t=c(this.rgba);return"number"==typeof r?w({h:r,s:t.s,l:t.l,a:t.a}):n(t.h)},r.prototype.isEqual=function(r){return this.toHex()===w(r).toHex()},r}(),w=function(r){return r instanceof j?r:new j(r)},S=[],k=function(r){r.forEach(function(r){S.indexOf(r)<0&&(r(j,y),S.push(r))})},E=function(){return new j({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})}; |
6409 |
6468 |
6410 ;// CONCATENATED MODULE: ./node_modules/colord/plugins/names.mjs |
6469 ;// CONCATENATED MODULE: ./node_modules/colord/plugins/names.mjs |
6411 /* harmony default export */ function names(e,f){var a={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},r={};for(var d in a)r[a[d]]=d;var l={};e.prototype.toName=function(f){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var d,i,n=r[this.toHex()];if(n)return n;if(null==f?void 0:f.closest){var o=this.toRgb(),t=1/0,b="black";if(!l.length)for(var c in a)l[c]=new e(a[c]).toRgb();for(var g in a){var u=(d=o,i=l[g],Math.pow(d.r-i.r,2)+Math.pow(d.g-i.g,2)+Math.pow(d.b-i.b,2));u<t&&(t=u,b=g)}return b}};f.string.push([function(f){var r=f.toLowerCase(),d="transparent"===r?"#0000":a[r];return d?new e(d).toRgb():null},"name"])} |
6470 /* harmony default export */ function names(e,f){var a={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},r={};for(var d in a)r[a[d]]=d;var l={};e.prototype.toName=function(f){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var d,i,n=r[this.toHex()];if(n)return n;if(null==f?void 0:f.closest){var o=this.toRgb(),t=1/0,b="black";if(!l.length)for(var c in a)l[c]=new e(a[c]).toRgb();for(var g in a){var u=(d=o,i=l[g],Math.pow(d.r-i.r,2)+Math.pow(d.g-i.g,2)+Math.pow(d.b-i.b,2));u<t&&(t=u,b=g)}return b}};f.string.push([function(f){var r=f.toLowerCase(),d="transparent"===r?"#0000":a[r];return d?new e(d).toRgb():null},"name"])} |
6412 |
6471 |
6413 ;// CONCATENATED MODULE: ./node_modules/colord/plugins/a11y.mjs |
6472 ;// CONCATENATED MODULE: ./node_modules/colord/plugins/a11y.mjs |
6414 var a11y_o=function(o){var t=o/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},a11y_t=function(t){return.2126*a11y_o(t.r)+.7152*a11y_o(t.g)+.0722*a11y_o(t.b)};/* harmony default export */ function a11y(o){o.prototype.luminance=function(){return o=a11y_t(this.rgba),void 0===(r=2)&&(r=0),void 0===n&&(n=Math.pow(10,r)),Math.round(n*o)/n+0;var o,r,n},o.prototype.contrast=function(r){void 0===r&&(r="#FFF");var n,a,i,e,v,u,d,c=r instanceof o?r:new o(r);return e=this.rgba,v=c.toRgb(),u=a11y_t(e),d=a11y_t(v),n=u>d?(u+.05)/(d+.05):(d+.05)/(u+.05),void 0===(a=2)&&(a=0),void 0===i&&(i=Math.pow(10,a)),Math.floor(i*n)/i+0},o.prototype.isReadable=function(o,t){return void 0===o&&(o="#FFF"),void 0===t&&(t={}),this.contrast(o)>=(e=void 0===(i=(r=t).size)?"normal":i,"AAA"===(a=void 0===(n=r.level)?"AA":n)&&"normal"===e?7:"AA"===a&&"large"===e?3:4.5);var r,n,a,i,e}} |
6473 var a11y_o=function(o){var t=o/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},a11y_t=function(t){return.2126*a11y_o(t.r)+.7152*a11y_o(t.g)+.0722*a11y_o(t.b)};/* harmony default export */ function a11y(o){o.prototype.luminance=function(){return o=a11y_t(this.rgba),void 0===(r=2)&&(r=0),void 0===n&&(n=Math.pow(10,r)),Math.round(n*o)/n+0;var o,r,n},o.prototype.contrast=function(r){void 0===r&&(r="#FFF");var n,a,i,e,v,u,d,c=r instanceof o?r:new o(r);return e=this.rgba,v=c.toRgb(),u=a11y_t(e),d=a11y_t(v),n=u>d?(u+.05)/(d+.05):(d+.05)/(u+.05),void 0===(a=2)&&(a=0),void 0===i&&(i=Math.pow(10,a)),Math.floor(i*n)/i+0},o.prototype.isReadable=function(o,t){return void 0===o&&(o="#FFF"),void 0===t&&(t={}),this.contrast(o)>=(e=void 0===(i=(r=t).size)?"normal":i,"AAA"===(a=void 0===(n=r.level)?"AA":n)&&"normal"===e?7:"AA"===a&&"large"===e?3:4.5);var r,n,a,i,e}} |
6415 |
6474 |
6416 ;// CONCATENATED MODULE: external ["wp","element"] |
6475 ;// CONCATENATED MODULE: external ["wp","element"] |
6417 var external_wp_element_namespaceObject = window["wp"]["element"]; |
6476 const external_wp_element_namespaceObject = window["wp"]["element"]; |
6418 ;// CONCATENATED MODULE: external ["wp","dom"] |
6477 ;// CONCATENATED MODULE: external ["wp","dom"] |
6419 var external_wp_dom_namespaceObject = window["wp"]["dom"]; |
6478 const external_wp_dom_namespaceObject = window["wp"]["dom"]; |
6479 ;// CONCATENATED MODULE: external ["wp","richText"] |
|
6480 const external_wp_richText_namespaceObject = window["wp"]["richText"]; |
|
6420 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/constants.js |
6481 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/constants.js |
6421 const BLOCK_ICON_DEFAULT = 'block-default'; |
6482 const BLOCK_ICON_DEFAULT = 'block-default'; |
6483 |
|
6422 /** |
6484 /** |
6423 * Array of valid keys in a block type settings deprecation object. |
6485 * Array of valid keys in a block type settings deprecation object. |
6424 * |
6486 * |
6425 * @type {string[]} |
6487 * @type {string[]} |
6426 */ |
6488 */ |
6427 |
|
6428 const DEPRECATED_ENTRY_KEYS = ['attributes', 'supports', 'save', 'migrate', 'isEligible', 'apiVersion']; |
6489 const DEPRECATED_ENTRY_KEYS = ['attributes', 'supports', 'save', 'migrate', 'isEligible', 'apiVersion']; |
6429 const __EXPERIMENTAL_STYLE_PROPERTY = { |
6490 const __EXPERIMENTAL_STYLE_PROPERTY = { |
6430 // Kept for back-compatibility purposes. |
6491 // Kept for back-compatibility purposes. |
6431 '--wp--style--color--link': { |
6492 '--wp--style--color--link': { |
6432 value: ['color', 'link'], |
6493 value: ['color', 'link'], |
6433 support: ['color', 'link'] |
6494 support: ['color', 'link'] |
6434 }, |
6495 }, |
6496 aspectRatio: { |
|
6497 value: ['dimensions', 'aspectRatio'], |
|
6498 support: ['dimensions', 'aspectRatio'], |
|
6499 useEngine: true |
|
6500 }, |
|
6435 background: { |
6501 background: { |
6436 value: ['color', 'gradient'], |
6502 value: ['color', 'gradient'], |
6437 support: ['color', 'gradients'] |
6503 support: ['color', 'gradients'], |
6504 useEngine: true |
|
6438 }, |
6505 }, |
6439 backgroundColor: { |
6506 backgroundColor: { |
6440 value: ['color', 'background'], |
6507 value: ['color', 'background'], |
6441 support: ['color', 'background'], |
6508 support: ['color', 'background'], |
6442 requiresOptOut: true |
6509 requiresOptOut: true, |
6510 useEngine: true |
|
6511 }, |
|
6512 backgroundImage: { |
|
6513 value: ['background', 'backgroundImage'], |
|
6514 support: ['background', 'backgroundImage'], |
|
6515 useEngine: true |
|
6516 }, |
|
6517 backgroundRepeat: { |
|
6518 value: ['background', 'backgroundRepeat'], |
|
6519 support: ['background', 'backgroundRepeat'], |
|
6520 useEngine: true |
|
6521 }, |
|
6522 backgroundSize: { |
|
6523 value: ['background', 'backgroundSize'], |
|
6524 support: ['background', 'backgroundSize'], |
|
6525 useEngine: true |
|
6526 }, |
|
6527 backgroundPosition: { |
|
6528 value: ['background', 'backgroundPosition'], |
|
6529 support: ['background', 'backgroundPosition'], |
|
6530 useEngine: true |
|
6443 }, |
6531 }, |
6444 borderColor: { |
6532 borderColor: { |
6445 value: ['border', 'color'], |
6533 value: ['border', 'color'], |
6446 support: ['__experimentalBorder', 'color'] |
6534 support: ['__experimentalBorder', 'color'], |
6535 useEngine: true |
|
6447 }, |
6536 }, |
6448 borderRadius: { |
6537 borderRadius: { |
6449 value: ['border', 'radius'], |
6538 value: ['border', 'radius'], |
6450 support: ['__experimentalBorder', 'radius'], |
6539 support: ['__experimentalBorder', 'radius'], |
6451 properties: { |
6540 properties: { |
6452 borderTopLeftRadius: 'topLeft', |
6541 borderTopLeftRadius: 'topLeft', |
6453 borderTopRightRadius: 'topRight', |
6542 borderTopRightRadius: 'topRight', |
6454 borderBottomLeftRadius: 'bottomLeft', |
6543 borderBottomLeftRadius: 'bottomLeft', |
6455 borderBottomRightRadius: 'bottomRight' |
6544 borderBottomRightRadius: 'bottomRight' |
6456 } |
6545 }, |
6546 useEngine: true |
|
6457 }, |
6547 }, |
6458 borderStyle: { |
6548 borderStyle: { |
6459 value: ['border', 'style'], |
6549 value: ['border', 'style'], |
6460 support: ['__experimentalBorder', 'style'] |
6550 support: ['__experimentalBorder', 'style'], |
6551 useEngine: true |
|
6461 }, |
6552 }, |
6462 borderWidth: { |
6553 borderWidth: { |
6463 value: ['border', 'width'], |
6554 value: ['border', 'width'], |
6464 support: ['__experimentalBorder', 'width'] |
6555 support: ['__experimentalBorder', 'width'], |
6556 useEngine: true |
|
6557 }, |
|
6558 borderTopColor: { |
|
6559 value: ['border', 'top', 'color'], |
|
6560 support: ['__experimentalBorder', 'color'], |
|
6561 useEngine: true |
|
6562 }, |
|
6563 borderTopStyle: { |
|
6564 value: ['border', 'top', 'style'], |
|
6565 support: ['__experimentalBorder', 'style'], |
|
6566 useEngine: true |
|
6567 }, |
|
6568 borderTopWidth: { |
|
6569 value: ['border', 'top', 'width'], |
|
6570 support: ['__experimentalBorder', 'width'], |
|
6571 useEngine: true |
|
6572 }, |
|
6573 borderRightColor: { |
|
6574 value: ['border', 'right', 'color'], |
|
6575 support: ['__experimentalBorder', 'color'], |
|
6576 useEngine: true |
|
6577 }, |
|
6578 borderRightStyle: { |
|
6579 value: ['border', 'right', 'style'], |
|
6580 support: ['__experimentalBorder', 'style'], |
|
6581 useEngine: true |
|
6582 }, |
|
6583 borderRightWidth: { |
|
6584 value: ['border', 'right', 'width'], |
|
6585 support: ['__experimentalBorder', 'width'], |
|
6586 useEngine: true |
|
6587 }, |
|
6588 borderBottomColor: { |
|
6589 value: ['border', 'bottom', 'color'], |
|
6590 support: ['__experimentalBorder', 'color'], |
|
6591 useEngine: true |
|
6592 }, |
|
6593 borderBottomStyle: { |
|
6594 value: ['border', 'bottom', 'style'], |
|
6595 support: ['__experimentalBorder', 'style'], |
|
6596 useEngine: true |
|
6597 }, |
|
6598 borderBottomWidth: { |
|
6599 value: ['border', 'bottom', 'width'], |
|
6600 support: ['__experimentalBorder', 'width'], |
|
6601 useEngine: true |
|
6602 }, |
|
6603 borderLeftColor: { |
|
6604 value: ['border', 'left', 'color'], |
|
6605 support: ['__experimentalBorder', 'color'], |
|
6606 useEngine: true |
|
6607 }, |
|
6608 borderLeftStyle: { |
|
6609 value: ['border', 'left', 'style'], |
|
6610 support: ['__experimentalBorder', 'style'], |
|
6611 useEngine: true |
|
6612 }, |
|
6613 borderLeftWidth: { |
|
6614 value: ['border', 'left', 'width'], |
|
6615 support: ['__experimentalBorder', 'width'], |
|
6616 useEngine: true |
|
6465 }, |
6617 }, |
6466 color: { |
6618 color: { |
6467 value: ['color', 'text'], |
6619 value: ['color', 'text'], |
6468 support: ['color', 'text'], |
6620 support: ['color', 'text'], |
6469 requiresOptOut: true |
6621 requiresOptOut: true, |
6622 useEngine: true |
|
6623 }, |
|
6624 columnCount: { |
|
6625 value: ['typography', 'textColumns'], |
|
6626 support: ['typography', 'textColumns'], |
|
6627 useEngine: true |
|
6470 }, |
6628 }, |
6471 filter: { |
6629 filter: { |
6472 value: ['filter', 'duotone'], |
6630 value: ['filter', 'duotone'], |
6473 support: ['color', '__experimentalDuotone'] |
6631 support: ['filter', 'duotone'] |
6474 }, |
6632 }, |
6475 linkColor: { |
6633 linkColor: { |
6476 value: ['elements', 'link', 'color', 'text'], |
6634 value: ['elements', 'link', 'color', 'text'], |
6477 support: ['color', 'link'] |
6635 support: ['color', 'link'] |
6478 }, |
6636 }, |
6637 captionColor: { |
|
6638 value: ['elements', 'caption', 'color', 'text'], |
|
6639 support: ['color', 'caption'] |
|
6640 }, |
|
6641 buttonColor: { |
|
6642 value: ['elements', 'button', 'color', 'text'], |
|
6643 support: ['color', 'button'] |
|
6644 }, |
|
6645 buttonBackgroundColor: { |
|
6646 value: ['elements', 'button', 'color', 'background'], |
|
6647 support: ['color', 'button'] |
|
6648 }, |
|
6649 headingColor: { |
|
6650 value: ['elements', 'heading', 'color', 'text'], |
|
6651 support: ['color', 'heading'] |
|
6652 }, |
|
6653 headingBackgroundColor: { |
|
6654 value: ['elements', 'heading', 'color', 'background'], |
|
6655 support: ['color', 'heading'] |
|
6656 }, |
|
6479 fontFamily: { |
6657 fontFamily: { |
6480 value: ['typography', 'fontFamily'], |
6658 value: ['typography', 'fontFamily'], |
6481 support: ['typography', '__experimentalFontFamily'] |
6659 support: ['typography', '__experimentalFontFamily'], |
6660 useEngine: true |
|
6482 }, |
6661 }, |
6483 fontSize: { |
6662 fontSize: { |
6484 value: ['typography', 'fontSize'], |
6663 value: ['typography', 'fontSize'], |
6485 support: ['typography', 'fontSize'] |
6664 support: ['typography', 'fontSize'], |
6665 useEngine: true |
|
6486 }, |
6666 }, |
6487 fontStyle: { |
6667 fontStyle: { |
6488 value: ['typography', 'fontStyle'], |
6668 value: ['typography', 'fontStyle'], |
6489 support: ['typography', '__experimentalFontStyle'] |
6669 support: ['typography', '__experimentalFontStyle'], |
6670 useEngine: true |
|
6490 }, |
6671 }, |
6491 fontWeight: { |
6672 fontWeight: { |
6492 value: ['typography', 'fontWeight'], |
6673 value: ['typography', 'fontWeight'], |
6493 support: ['typography', '__experimentalFontWeight'] |
6674 support: ['typography', '__experimentalFontWeight'], |
6675 useEngine: true |
|
6494 }, |
6676 }, |
6495 lineHeight: { |
6677 lineHeight: { |
6496 value: ['typography', 'lineHeight'], |
6678 value: ['typography', 'lineHeight'], |
6497 support: ['typography', 'lineHeight'] |
6679 support: ['typography', 'lineHeight'], |
6680 useEngine: true |
|
6498 }, |
6681 }, |
6499 margin: { |
6682 margin: { |
6500 value: ['spacing', 'margin'], |
6683 value: ['spacing', 'margin'], |
6501 support: ['spacing', 'margin'], |
6684 support: ['spacing', 'margin'], |
6502 properties: { |
6685 properties: { |
6503 marginTop: 'top', |
6686 marginTop: 'top', |
6504 marginRight: 'right', |
6687 marginRight: 'right', |
6505 marginBottom: 'bottom', |
6688 marginBottom: 'bottom', |
6506 marginLeft: 'left' |
6689 marginLeft: 'left' |
6507 }, |
6690 }, |
6691 useEngine: true |
|
6692 }, |
|
6693 minHeight: { |
|
6694 value: ['dimensions', 'minHeight'], |
|
6695 support: ['dimensions', 'minHeight'], |
|
6508 useEngine: true |
6696 useEngine: true |
6509 }, |
6697 }, |
6510 padding: { |
6698 padding: { |
6511 value: ['spacing', 'padding'], |
6699 value: ['spacing', 'padding'], |
6512 support: ['spacing', 'padding'], |
6700 support: ['spacing', 'padding'], |
6516 paddingBottom: 'bottom', |
6704 paddingBottom: 'bottom', |
6517 paddingLeft: 'left' |
6705 paddingLeft: 'left' |
6518 }, |
6706 }, |
6519 useEngine: true |
6707 useEngine: true |
6520 }, |
6708 }, |
6709 textAlign: { |
|
6710 value: ['typography', 'textAlign'], |
|
6711 support: ['typography', 'textAlign'], |
|
6712 useEngine: false |
|
6713 }, |
|
6521 textDecoration: { |
6714 textDecoration: { |
6522 value: ['typography', 'textDecoration'], |
6715 value: ['typography', 'textDecoration'], |
6523 support: ['typography', '__experimentalTextDecoration'] |
6716 support: ['typography', '__experimentalTextDecoration'], |
6717 useEngine: true |
|
6524 }, |
6718 }, |
6525 textTransform: { |
6719 textTransform: { |
6526 value: ['typography', 'textTransform'], |
6720 value: ['typography', 'textTransform'], |
6527 support: ['typography', '__experimentalTextTransform'] |
6721 support: ['typography', '__experimentalTextTransform'], |
6722 useEngine: true |
|
6528 }, |
6723 }, |
6529 letterSpacing: { |
6724 letterSpacing: { |
6530 value: ['typography', 'letterSpacing'], |
6725 value: ['typography', 'letterSpacing'], |
6531 support: ['typography', '__experimentalLetterSpacing'] |
6726 support: ['typography', '__experimentalLetterSpacing'], |
6727 useEngine: true |
|
6532 }, |
6728 }, |
6533 '--wp--style--block-gap': { |
6729 writingMode: { |
6534 value: ['spacing', 'blockGap'], |
6730 value: ['typography', 'writingMode'], |
6535 support: ['spacing', 'blockGap'] |
6731 support: ['typography', '__experimentalWritingMode'], |
6732 useEngine: true |
|
6733 }, |
|
6734 '--wp--style--root--padding': { |
|
6735 value: ['spacing', 'padding'], |
|
6736 support: ['spacing', 'padding'], |
|
6737 properties: { |
|
6738 '--wp--style--root--padding-top': 'top', |
|
6739 '--wp--style--root--padding-right': 'right', |
|
6740 '--wp--style--root--padding-bottom': 'bottom', |
|
6741 '--wp--style--root--padding-left': 'left' |
|
6742 }, |
|
6743 rootOnly: true |
|
6536 } |
6744 } |
6537 }; |
6745 }; |
6538 const __EXPERIMENTAL_ELEMENTS = { |
6746 const __EXPERIMENTAL_ELEMENTS = { |
6539 link: 'a', |
6747 link: 'a:where(:not(.wp-element-button))', |
6748 heading: 'h1, h2, h3, h4, h5, h6', |
|
6540 h1: 'h1', |
6749 h1: 'h1', |
6541 h2: 'h2', |
6750 h2: 'h2', |
6542 h3: 'h3', |
6751 h3: 'h3', |
6543 h4: 'h4', |
6752 h4: 'h4', |
6544 h5: 'h5', |
6753 h5: 'h5', |
6545 h6: 'h6' |
6754 h6: 'h6', |
6755 button: '.wp-element-button, .wp-block-button__link', |
|
6756 caption: '.wp-element-caption, .wp-block-audio figcaption, .wp-block-embed figcaption, .wp-block-gallery figcaption, .wp-block-image figcaption, .wp-block-table figcaption, .wp-block-video figcaption', |
|
6757 cite: 'cite' |
|
6546 }; |
6758 }; |
6547 const __EXPERIMENTAL_PATHS_WITH_MERGE = { |
6759 |
6760 // These paths may have three origins, custom, theme, and default, |
|
6761 // and are expected to override other origins with custom, theme, |
|
6762 // and default priority. |
|
6763 const __EXPERIMENTAL_PATHS_WITH_OVERRIDE = { |
|
6548 'color.duotone': true, |
6764 'color.duotone': true, |
6549 'color.gradients': true, |
6765 'color.gradients': true, |
6550 'color.palette': true, |
6766 'color.palette': true, |
6551 'typography.fontFamilies': true, |
6767 'dimensions.aspectRatios': true, |
6552 'typography.fontSizes': true |
6768 'typography.fontSizes': true, |
6769 'spacing.spacingSizes': true |
|
6553 }; |
6770 }; |
6771 |
|
6772 ;// CONCATENATED MODULE: external ["wp","privateApis"] |
|
6773 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"]; |
|
6774 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/lock-unlock.js |
|
6775 /** |
|
6776 * WordPress dependencies |
|
6777 */ |
|
6778 |
|
6779 const { |
|
6780 lock, |
|
6781 unlock |
|
6782 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/blocks'); |
|
6554 |
6783 |
6555 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/registration.js |
6784 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/registration.js |
6556 /* eslint no-console: [ 'error', { allow: [ 'error', 'warn' ] } ] */ |
6785 /* eslint no-console: [ 'error', { allow: [ 'error', 'warn' ] } ] */ |
6557 |
6786 |
6558 /** |
6787 /** |
6559 * External dependencies |
|
6560 */ |
|
6561 |
|
6562 /** |
|
6563 * WordPress dependencies |
6788 * WordPress dependencies |
6564 */ |
6789 */ |
6565 |
6790 |
6566 |
6791 |
6567 |
6792 |
6568 /** |
6793 /** |
6569 * Internal dependencies |
6794 * Internal dependencies |
6570 */ |
6795 */ |
6571 |
|
6572 const i18nBlockSchema = { |
6796 const i18nBlockSchema = { |
6573 title: "block title", |
6797 title: "block title", |
6574 description: "block description", |
6798 description: "block description", |
6575 keywords: ["block keyword"], |
6799 keywords: ["block keyword"], |
6576 styles: [{ |
6800 styles: [{ |
6582 keywords: ["block variation keyword"] |
6806 keywords: ["block variation keyword"] |
6583 }] |
6807 }] |
6584 }; |
6808 }; |
6585 |
6809 |
6586 |
6810 |
6811 |
|
6587 /** |
6812 /** |
6588 * An icon type definition. One of a Dashicon slug, an element, |
6813 * An icon type definition. One of a Dashicon slug, an element, |
6589 * or a component. |
6814 * or a component. |
6590 * |
6815 * |
6591 * @typedef {(string|WPElement|WPComponent)} WPIcon |
6816 * @typedef {(string|Element|Component)} WPIcon |
6592 * |
6817 * |
6593 * @see https://developer.wordpress.org/resource/dashicons/ |
6818 * @see https://developer.wordpress.org/resource/dashicons/ |
6594 */ |
6819 */ |
6595 |
6820 |
6596 /** |
6821 /** |
6681 * block types by category. |
6906 * block types by category. |
6682 * @property {WPBlockTypeIcon} [icon] Block type icon. |
6907 * @property {WPBlockTypeIcon} [icon] Block type icon. |
6683 * @property {string[]} [keywords] Additional keywords to produce block |
6908 * @property {string[]} [keywords] Additional keywords to produce block |
6684 * type as result in search interfaces. |
6909 * type as result in search interfaces. |
6685 * @property {Object} [attributes] Block type attributes. |
6910 * @property {Object} [attributes] Block type attributes. |
6686 * @property {WPComponent} [save] Optional component describing |
6911 * @property {Component} [save] Optional component describing |
6687 * serialized markup structure of a |
6912 * serialized markup structure of a |
6688 * block type. |
6913 * block type. |
6689 * @property {WPComponent} edit Component rendering an element to |
6914 * @property {Component} edit Component rendering an element to |
6690 * manipulate the attributes of a block |
6915 * manipulate the attributes of a block |
6691 * in the context of an editor. |
6916 * in the context of an editor. |
6692 * @property {WPBlockVariation[]} [variations] The list of block variations. |
6917 * @property {WPBlockVariation[]} [variations] The list of block variations. |
6693 * @property {Object} [example] Example provides structured data for |
6918 * @property {Object} [example] Example provides structured data for |
6694 * the block preview. When not defined |
6919 * the block preview. When not defined |
6695 * then no preview is shown. |
6920 * then no preview is shown. |
6696 */ |
6921 */ |
6697 |
6922 |
6698 const serverSideBlockDefinitions = {}; |
6923 function isObject(object) { |
6924 return object !== null && typeof object === 'object'; |
|
6925 } |
|
6926 |
|
6699 /** |
6927 /** |
6700 * Sets the server side block definition of blocks. |
6928 * Sets the server side block definition of blocks. |
6701 * |
6929 * |
6702 * @param {Object} definitions Server-side block definitions |
6930 * @param {Object} definitions Server-side block definitions |
6703 */ |
6931 */ |
6704 // eslint-disable-next-line camelcase |
6932 // eslint-disable-next-line camelcase |
6705 |
|
6706 function unstable__bootstrapServerSideBlockDefinitions(definitions) { |
6933 function unstable__bootstrapServerSideBlockDefinitions(definitions) { |
6707 for (const blockName of Object.keys(definitions)) { |
6934 const { |
6708 // Don't overwrite if already set. It covers the case when metadata |
6935 addBootstrappedBlockType |
6709 // was initialized from the server. |
6936 } = unlock((0,external_wp_data_namespaceObject.dispatch)(store)); |
6710 if (serverSideBlockDefinitions[blockName]) { |
6937 for (const [name, blockType] of Object.entries(definitions)) { |
6711 // We still need to polyfill `apiVersion` for WordPress version |
6938 addBootstrappedBlockType(name, blockType); |
6712 // lower than 5.7. If it isn't present in the definition shared |
6939 } |
6713 // from the server, we try to fallback to the definition passed. |
6940 } |
6714 // @see https://github.com/WordPress/gutenberg/pull/29279 |
6941 |
6715 if (serverSideBlockDefinitions[blockName].apiVersion === undefined && definitions[blockName].apiVersion) { |
|
6716 serverSideBlockDefinitions[blockName].apiVersion = definitions[blockName].apiVersion; |
|
6717 } // The `ancestor` prop is not included in the definitions shared |
|
6718 // from the server yet, so it needs to be polyfilled as well. |
|
6719 // @see https://github.com/WordPress/gutenberg/pull/39894 |
|
6720 |
|
6721 |
|
6722 if (serverSideBlockDefinitions[blockName].ancestor === undefined && definitions[blockName].ancestor) { |
|
6723 serverSideBlockDefinitions[blockName].ancestor = definitions[blockName].ancestor; |
|
6724 } |
|
6725 |
|
6726 continue; |
|
6727 } |
|
6728 |
|
6729 serverSideBlockDefinitions[blockName] = (0,external_lodash_namespaceObject.mapKeys)((0,external_lodash_namespaceObject.pickBy)(definitions[blockName], value => !(0,external_lodash_namespaceObject.isNil)(value)), (value, key) => (0,external_lodash_namespaceObject.camelCase)(key)); |
|
6730 } |
|
6731 } |
|
6732 /** |
6942 /** |
6733 * Gets block settings from metadata loaded from `block.json` file. |
6943 * Gets block settings from metadata loaded from `block.json` file. |
6734 * |
6944 * |
6735 * @param {Object} metadata Block metadata loaded from `block.json`. |
6945 * @param {Object} metadata Block metadata loaded from `block.json`. |
6736 * @param {string} metadata.textdomain Textdomain to use with translations. |
6946 * @param {string} metadata.textdomain Textdomain to use with translations. |
6737 * |
6947 * |
6738 * @return {Object} Block settings. |
6948 * @return {Object} Block settings. |
6739 */ |
6949 */ |
6740 |
6950 function getBlockSettingsFromMetadata({ |
6741 function getBlockSettingsFromMetadata(_ref) { |
6951 textdomain, |
6742 let { |
6952 ...metadata |
6743 textdomain, |
6953 }) { |
6744 ...metadata |
6954 const allowedFields = ['apiVersion', 'title', 'category', 'parent', 'ancestor', 'icon', 'description', 'keywords', 'attributes', 'providesContext', 'usesContext', 'selectors', 'supports', 'styles', 'example', 'variations', 'blockHooks', 'allowedBlocks']; |
6745 } = _ref; |
6955 const settings = Object.fromEntries(Object.entries(metadata).filter(([key]) => allowedFields.includes(key))); |
6746 const allowedFields = ['apiVersion', 'title', 'category', 'parent', 'ancestor', 'icon', 'description', 'keywords', 'attributes', 'providesContext', 'usesContext', 'supports', 'styles', 'example', 'variations']; |
|
6747 const settings = (0,external_lodash_namespaceObject.pick)(metadata, allowedFields); |
|
6748 |
|
6749 if (textdomain) { |
6956 if (textdomain) { |
6750 Object.keys(i18nBlockSchema).forEach(key => { |
6957 Object.keys(i18nBlockSchema).forEach(key => { |
6751 if (!settings[key]) { |
6958 if (!settings[key]) { |
6752 return; |
6959 return; |
6753 } |
6960 } |
6754 |
|
6755 settings[key] = translateBlockSettingUsingI18nSchema(i18nBlockSchema[key], settings[key], textdomain); |
6961 settings[key] = translateBlockSettingUsingI18nSchema(i18nBlockSchema[key], settings[key], textdomain); |
6756 }); |
6962 }); |
6757 } |
6963 } |
6758 |
|
6759 return settings; |
6964 return settings; |
6760 } |
6965 } |
6966 |
|
6761 /** |
6967 /** |
6762 * Registers a new block provided a unique name and an object defining its |
6968 * Registers a new block provided a unique name and an object defining its |
6763 * behavior. Once registered, the block is made available as an option to any |
6969 * behavior. Once registered, the block is made available as an option to any |
6764 * editor interface where blocks are implemented. |
6970 * editor interface where blocks are implemented. |
6765 * |
6971 * |
6972 * For more in-depth information on registering a custom block see the |
|
6973 * [Create a block tutorial](https://developer.wordpress.org/block-editor/getting-started/create-block/). |
|
6974 * |
|
6766 * @param {string|Object} blockNameOrMetadata Block type name or its metadata. |
6975 * @param {string|Object} blockNameOrMetadata Block type name or its metadata. |
6767 * @param {Object} settings Block settings. |
6976 * @param {Object} settings Block settings. |
6768 * |
6977 * |
6769 * @return {?WPBlockType} The block, if it has been successfully registered; |
6978 * @example |
6979 * ```js |
|
6980 * import { __ } from '@wordpress/i18n'; |
|
6981 * import { registerBlockType } from '@wordpress/blocks' |
|
6982 * |
|
6983 * registerBlockType( 'namespace/block-name', { |
|
6984 * title: __( 'My First Block' ), |
|
6985 * edit: () => <div>{ __( 'Hello from the editor!' ) }</div>, |
|
6986 * save: () => <div>Hello from the saved content!</div>, |
|
6987 * } ); |
|
6988 * ``` |
|
6989 * |
|
6990 * @return {WPBlockType | undefined} The block, if it has been successfully registered; |
|
6770 * otherwise `undefined`. |
6991 * otherwise `undefined`. |
6771 */ |
6992 */ |
6772 |
|
6773 |
|
6774 function registerBlockType(blockNameOrMetadata, settings) { |
6993 function registerBlockType(blockNameOrMetadata, settings) { |
6775 const name = (0,external_lodash_namespaceObject.isObject)(blockNameOrMetadata) ? blockNameOrMetadata.name : blockNameOrMetadata; |
6994 const name = isObject(blockNameOrMetadata) ? blockNameOrMetadata.name : blockNameOrMetadata; |
6776 |
|
6777 if (typeof name !== 'string') { |
6995 if (typeof name !== 'string') { |
6778 console.error('Block names must be strings.'); |
6996 console.error('Block names must be strings.'); |
6779 return; |
6997 return; |
6780 } |
6998 } |
6781 |
|
6782 if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(name)) { |
6999 if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(name)) { |
6783 console.error('Block names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-block'); |
7000 console.error('Block names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-block'); |
6784 return; |
7001 return; |
6785 } |
7002 } |
6786 |
|
6787 if ((0,external_wp_data_namespaceObject.select)(store).getBlockType(name)) { |
7003 if ((0,external_wp_data_namespaceObject.select)(store).getBlockType(name)) { |
6788 console.error('Block "' + name + '" is already registered.'); |
7004 console.error('Block "' + name + '" is already registered.'); |
6789 return; |
7005 return; |
6790 } |
7006 } |
6791 |
7007 const { |
6792 if ((0,external_lodash_namespaceObject.isObject)(blockNameOrMetadata)) { |
7008 addBootstrappedBlockType, |
6793 unstable__bootstrapServerSideBlockDefinitions({ |
7009 addUnprocessedBlockType |
6794 [name]: getBlockSettingsFromMetadata(blockNameOrMetadata) |
7010 } = unlock((0,external_wp_data_namespaceObject.dispatch)(store)); |
6795 }); |
7011 if (isObject(blockNameOrMetadata)) { |
6796 } |
7012 const metadata = getBlockSettingsFromMetadata(blockNameOrMetadata); |
6797 |
7013 addBootstrappedBlockType(name, metadata); |
7014 } |
|
7015 addUnprocessedBlockType(name, settings); |
|
7016 return (0,external_wp_data_namespaceObject.select)(store).getBlockType(name); |
|
7017 } |
|
7018 |
|
7019 /** |
|
7020 * Translates block settings provided with metadata using the i18n schema. |
|
7021 * |
|
7022 * @param {string|string[]|Object[]} i18nSchema I18n schema for the block setting. |
|
7023 * @param {string|string[]|Object[]} settingValue Value for the block setting. |
|
7024 * @param {string} textdomain Textdomain to use with translations. |
|
7025 * |
|
7026 * @return {string|string[]|Object[]} Translated setting. |
|
7027 */ |
|
7028 function translateBlockSettingUsingI18nSchema(i18nSchema, settingValue, textdomain) { |
|
7029 if (typeof i18nSchema === 'string' && typeof settingValue === 'string') { |
|
7030 // eslint-disable-next-line @wordpress/i18n-no-variables, @wordpress/i18n-text-domain |
|
7031 return (0,external_wp_i18n_namespaceObject._x)(settingValue, i18nSchema, textdomain); |
|
7032 } |
|
7033 if (Array.isArray(i18nSchema) && i18nSchema.length && Array.isArray(settingValue)) { |
|
7034 return settingValue.map(value => translateBlockSettingUsingI18nSchema(i18nSchema[0], value, textdomain)); |
|
7035 } |
|
7036 if (isObject(i18nSchema) && Object.entries(i18nSchema).length && isObject(settingValue)) { |
|
7037 return Object.keys(settingValue).reduce((accumulator, key) => { |
|
7038 if (!i18nSchema[key]) { |
|
7039 accumulator[key] = settingValue[key]; |
|
7040 return accumulator; |
|
7041 } |
|
7042 accumulator[key] = translateBlockSettingUsingI18nSchema(i18nSchema[key], settingValue[key], textdomain); |
|
7043 return accumulator; |
|
7044 }, {}); |
|
7045 } |
|
7046 return settingValue; |
|
7047 } |
|
7048 |
|
7049 /** |
|
7050 * Registers a new block collection to group blocks in the same namespace in the inserter. |
|
7051 * |
|
7052 * @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace. |
|
7053 * @param {Object} settings The block collection settings. |
|
7054 * @param {string} settings.title The title to display in the block inserter. |
|
7055 * @param {Object} [settings.icon] The icon to display in the block inserter. |
|
7056 * |
|
7057 * @example |
|
7058 * ```js |
|
7059 * import { __ } from '@wordpress/i18n'; |
|
7060 * import { registerBlockCollection, registerBlockType } from '@wordpress/blocks'; |
|
7061 * |
|
7062 * // Register the collection. |
|
7063 * registerBlockCollection( 'my-collection', { |
|
7064 * title: __( 'Custom Collection' ), |
|
7065 * } ); |
|
7066 * |
|
7067 * // Register a block in the same namespace to add it to the collection. |
|
7068 * registerBlockType( 'my-collection/block-name', { |
|
7069 * title: __( 'My First Block' ), |
|
7070 * edit: () => <div>{ __( 'Hello from the editor!' ) }</div>, |
|
7071 * save: () => <div>'Hello from the saved content!</div>, |
|
7072 * } ); |
|
7073 * ``` |
|
7074 */ |
|
7075 function registerBlockCollection(namespace, { |
|
7076 title, |
|
7077 icon |
|
7078 }) { |
|
7079 (0,external_wp_data_namespaceObject.dispatch)(store).addBlockCollection(namespace, title, icon); |
|
7080 } |
|
7081 |
|
7082 /** |
|
7083 * Unregisters a block collection |
|
7084 * |
|
7085 * @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace |
|
7086 * |
|
7087 * @example |
|
7088 * ```js |
|
7089 * import { unregisterBlockCollection } from '@wordpress/blocks'; |
|
7090 * |
|
7091 * unregisterBlockCollection( 'my-collection' ); |
|
7092 * ``` |
|
7093 */ |
|
7094 function unregisterBlockCollection(namespace) { |
|
7095 dispatch(blocksStore).removeBlockCollection(namespace); |
|
7096 } |
|
7097 |
|
7098 /** |
|
7099 * Unregisters a block. |
|
7100 * |
|
7101 * @param {string} name Block name. |
|
7102 * |
|
7103 * @example |
|
7104 * ```js |
|
7105 * import { __ } from '@wordpress/i18n'; |
|
7106 * import { unregisterBlockType } from '@wordpress/blocks'; |
|
7107 * |
|
7108 * const ExampleComponent = () => { |
|
7109 * return ( |
|
7110 * <Button |
|
7111 * onClick={ () => |
|
7112 * unregisterBlockType( 'my-collection/block-name' ) |
|
7113 * } |
|
7114 * > |
|
7115 * { __( 'Unregister my custom block.' ) } |
|
7116 * </Button> |
|
7117 * ); |
|
7118 * }; |
|
7119 * ``` |
|
7120 * |
|
7121 * @return {WPBlockType | undefined} The previous block value, if it has been successfully |
|
7122 * unregistered; otherwise `undefined`. |
|
7123 */ |
|
7124 function unregisterBlockType(name) { |
|
7125 const oldBlock = (0,external_wp_data_namespaceObject.select)(store).getBlockType(name); |
|
7126 if (!oldBlock) { |
|
7127 console.error('Block "' + name + '" is not registered.'); |
|
7128 return; |
|
7129 } |
|
7130 (0,external_wp_data_namespaceObject.dispatch)(store).removeBlockTypes(name); |
|
7131 return oldBlock; |
|
7132 } |
|
7133 |
|
7134 /** |
|
7135 * Assigns name of block for handling non-block content. |
|
7136 * |
|
7137 * @param {string} blockName Block name. |
|
7138 */ |
|
7139 function setFreeformContentHandlerName(blockName) { |
|
7140 (0,external_wp_data_namespaceObject.dispatch)(store).setFreeformFallbackBlockName(blockName); |
|
7141 } |
|
7142 |
|
7143 /** |
|
7144 * Retrieves name of block handling non-block content, or undefined if no |
|
7145 * handler has been defined. |
|
7146 * |
|
7147 * @return {?string} Block name. |
|
7148 */ |
|
7149 function getFreeformContentHandlerName() { |
|
7150 return (0,external_wp_data_namespaceObject.select)(store).getFreeformFallbackBlockName(); |
|
7151 } |
|
7152 |
|
7153 /** |
|
7154 * Retrieves name of block used for handling grouping interactions. |
|
7155 * |
|
7156 * @return {?string} Block name. |
|
7157 */ |
|
7158 function getGroupingBlockName() { |
|
7159 return (0,external_wp_data_namespaceObject.select)(store).getGroupingBlockName(); |
|
7160 } |
|
7161 |
|
7162 /** |
|
7163 * Assigns name of block handling unregistered block types. |
|
7164 * |
|
7165 * @param {string} blockName Block name. |
|
7166 */ |
|
7167 function setUnregisteredTypeHandlerName(blockName) { |
|
7168 (0,external_wp_data_namespaceObject.dispatch)(store).setUnregisteredFallbackBlockName(blockName); |
|
7169 } |
|
7170 |
|
7171 /** |
|
7172 * Retrieves name of block handling unregistered block types, or undefined if no |
|
7173 * handler has been defined. |
|
7174 * |
|
7175 * @return {?string} Block name. |
|
7176 */ |
|
7177 function getUnregisteredTypeHandlerName() { |
|
7178 return (0,external_wp_data_namespaceObject.select)(store).getUnregisteredFallbackBlockName(); |
|
7179 } |
|
7180 |
|
7181 /** |
|
7182 * Assigns the default block name. |
|
7183 * |
|
7184 * @param {string} name Block name. |
|
7185 * |
|
7186 * @example |
|
7187 * ```js |
|
7188 * import { setDefaultBlockName } from '@wordpress/blocks'; |
|
7189 * |
|
7190 * const ExampleComponent = () => { |
|
7191 * |
|
7192 * return ( |
|
7193 * <Button onClick={ () => setDefaultBlockName( 'core/heading' ) }> |
|
7194 * { __( 'Set the default block to Heading' ) } |
|
7195 * </Button> |
|
7196 * ); |
|
7197 * }; |
|
7198 * ``` |
|
7199 */ |
|
7200 function setDefaultBlockName(name) { |
|
7201 (0,external_wp_data_namespaceObject.dispatch)(store).setDefaultBlockName(name); |
|
7202 } |
|
7203 |
|
7204 /** |
|
7205 * Assigns name of block for handling block grouping interactions. |
|
7206 * |
|
7207 * This function lets you select a different block to group other blocks in instead of the |
|
7208 * default `core/group` block. This function must be used in a component or when the DOM is fully |
|
7209 * loaded. See https://developer.wordpress.org/block-editor/reference-guides/packages/packages-dom-ready/ |
|
7210 * |
|
7211 * @param {string} name Block name. |
|
7212 * |
|
7213 * @example |
|
7214 * ```js |
|
7215 * import { setGroupingBlockName } from '@wordpress/blocks'; |
|
7216 * |
|
7217 * const ExampleComponent = () => { |
|
7218 * |
|
7219 * return ( |
|
7220 * <Button onClick={ () => setGroupingBlockName( 'core/columns' ) }> |
|
7221 * { __( 'Wrap in columns' ) } |
|
7222 * </Button> |
|
7223 * ); |
|
7224 * }; |
|
7225 * ``` |
|
7226 */ |
|
7227 function setGroupingBlockName(name) { |
|
7228 (0,external_wp_data_namespaceObject.dispatch)(store).setGroupingBlockName(name); |
|
7229 } |
|
7230 |
|
7231 /** |
|
7232 * Retrieves the default block name. |
|
7233 * |
|
7234 * @return {?string} Block name. |
|
7235 */ |
|
7236 function getDefaultBlockName() { |
|
7237 return (0,external_wp_data_namespaceObject.select)(store).getDefaultBlockName(); |
|
7238 } |
|
7239 |
|
7240 /** |
|
7241 * Returns a registered block type. |
|
7242 * |
|
7243 * @param {string} name Block name. |
|
7244 * |
|
7245 * @return {?Object} Block type. |
|
7246 */ |
|
7247 function getBlockType(name) { |
|
7248 return (0,external_wp_data_namespaceObject.select)(store)?.getBlockType(name); |
|
7249 } |
|
7250 |
|
7251 /** |
|
7252 * Returns all registered blocks. |
|
7253 * |
|
7254 * @return {Array} Block settings. |
|
7255 */ |
|
7256 function getBlockTypes() { |
|
7257 return (0,external_wp_data_namespaceObject.select)(store).getBlockTypes(); |
|
7258 } |
|
7259 |
|
7260 /** |
|
7261 * Returns the block support value for a feature, if defined. |
|
7262 * |
|
7263 * @param {(string|Object)} nameOrType Block name or type object |
|
7264 * @param {string} feature Feature to retrieve |
|
7265 * @param {*} defaultSupports Default value to return if not |
|
7266 * explicitly defined |
|
7267 * |
|
7268 * @return {?*} Block support value |
|
7269 */ |
|
7270 function getBlockSupport(nameOrType, feature, defaultSupports) { |
|
7271 return (0,external_wp_data_namespaceObject.select)(store).getBlockSupport(nameOrType, feature, defaultSupports); |
|
7272 } |
|
7273 |
|
7274 /** |
|
7275 * Returns true if the block defines support for a feature, or false otherwise. |
|
7276 * |
|
7277 * @param {(string|Object)} nameOrType Block name or type object. |
|
7278 * @param {string} feature Feature to test. |
|
7279 * @param {boolean} defaultSupports Whether feature is supported by |
|
7280 * default if not explicitly defined. |
|
7281 * |
|
7282 * @return {boolean} Whether block supports feature. |
|
7283 */ |
|
7284 function hasBlockSupport(nameOrType, feature, defaultSupports) { |
|
7285 return (0,external_wp_data_namespaceObject.select)(store).hasBlockSupport(nameOrType, feature, defaultSupports); |
|
7286 } |
|
7287 |
|
7288 /** |
|
7289 * Determines whether or not the given block is a reusable block. This is a |
|
7290 * special block type that is used to point to a global block stored via the |
|
7291 * API. |
|
7292 * |
|
7293 * @param {Object} blockOrType Block or Block Type to test. |
|
7294 * |
|
7295 * @return {boolean} Whether the given block is a reusable block. |
|
7296 */ |
|
7297 function isReusableBlock(blockOrType) { |
|
7298 return blockOrType?.name === 'core/block'; |
|
7299 } |
|
7300 |
|
7301 /** |
|
7302 * Determines whether or not the given block is a template part. This is a |
|
7303 * special block type that allows composing a page template out of reusable |
|
7304 * design elements. |
|
7305 * |
|
7306 * @param {Object} blockOrType Block or Block Type to test. |
|
7307 * |
|
7308 * @return {boolean} Whether the given block is a template part. |
|
7309 */ |
|
7310 function isTemplatePart(blockOrType) { |
|
7311 return blockOrType?.name === 'core/template-part'; |
|
7312 } |
|
7313 |
|
7314 /** |
|
7315 * Returns an array with the child blocks of a given block. |
|
7316 * |
|
7317 * @param {string} blockName Name of block (example: “latest-posts”). |
|
7318 * |
|
7319 * @return {Array} Array of child block names. |
|
7320 */ |
|
7321 const getChildBlockNames = blockName => { |
|
7322 return (0,external_wp_data_namespaceObject.select)(store).getChildBlockNames(blockName); |
|
7323 }; |
|
7324 |
|
7325 /** |
|
7326 * Returns a boolean indicating if a block has child blocks or not. |
|
7327 * |
|
7328 * @param {string} blockName Name of block (example: “latest-posts”). |
|
7329 * |
|
7330 * @return {boolean} True if a block contains child blocks and false otherwise. |
|
7331 */ |
|
7332 const hasChildBlocks = blockName => { |
|
7333 return (0,external_wp_data_namespaceObject.select)(store).hasChildBlocks(blockName); |
|
7334 }; |
|
7335 |
|
7336 /** |
|
7337 * Returns a boolean indicating if a block has at least one child block with inserter support. |
|
7338 * |
|
7339 * @param {string} blockName Block type name. |
|
7340 * |
|
7341 * @return {boolean} True if a block contains at least one child blocks with inserter support |
|
7342 * and false otherwise. |
|
7343 */ |
|
7344 const hasChildBlocksWithInserterSupport = blockName => { |
|
7345 return (0,external_wp_data_namespaceObject.select)(store).hasChildBlocksWithInserterSupport(blockName); |
|
7346 }; |
|
7347 |
|
7348 /** |
|
7349 * Registers a new block style for the given block types. |
|
7350 * |
|
7351 * For more information on connecting the styles with CSS |
|
7352 * [the official documentation](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-styles/#styles). |
|
7353 * |
|
7354 * @param {string|Array} blockNames Name of blocks e.g. “core/latest-posts” or `["core/group", "core/columns"]`. |
|
7355 * @param {Object} styleVariation Object containing `name` which is the class name applied to the block and `label` which identifies the variation to the user. |
|
7356 * |
|
7357 * @example |
|
7358 * ```js |
|
7359 * import { __ } from '@wordpress/i18n'; |
|
7360 * import { registerBlockStyle } from '@wordpress/blocks'; |
|
7361 * import { Button } from '@wordpress/components'; |
|
7362 * |
|
7363 * |
|
7364 * const ExampleComponent = () => { |
|
7365 * return ( |
|
7366 * <Button |
|
7367 * onClick={ () => { |
|
7368 * registerBlockStyle( 'core/quote', { |
|
7369 * name: 'fancy-quote', |
|
7370 * label: __( 'Fancy Quote' ), |
|
7371 * } ); |
|
7372 * } } |
|
7373 * > |
|
7374 * { __( 'Add a new block style for core/quote' ) } |
|
7375 * </Button> |
|
7376 * ); |
|
7377 * }; |
|
7378 * ``` |
|
7379 */ |
|
7380 const registerBlockStyle = (blockNames, styleVariation) => { |
|
7381 (0,external_wp_data_namespaceObject.dispatch)(store).addBlockStyles(blockNames, styleVariation); |
|
7382 }; |
|
7383 |
|
7384 /** |
|
7385 * Unregisters a block style for the given block. |
|
7386 * |
|
7387 * @param {string} blockName Name of block (example: “core/latest-posts”). |
|
7388 * @param {string} styleVariationName Name of class applied to the block. |
|
7389 * |
|
7390 * @example |
|
7391 * ```js |
|
7392 * import { __ } from '@wordpress/i18n'; |
|
7393 * import { unregisterBlockStyle } from '@wordpress/blocks'; |
|
7394 * import { Button } from '@wordpress/components'; |
|
7395 * |
|
7396 * const ExampleComponent = () => { |
|
7397 * return ( |
|
7398 * <Button |
|
7399 * onClick={ () => { |
|
7400 * unregisterBlockStyle( 'core/quote', 'plain' ); |
|
7401 * } } |
|
7402 * > |
|
7403 * { __( 'Remove the "Plain" block style for core/quote' ) } |
|
7404 * </Button> |
|
7405 * ); |
|
7406 * }; |
|
7407 * ``` |
|
7408 */ |
|
7409 const unregisterBlockStyle = (blockName, styleVariationName) => { |
|
7410 (0,external_wp_data_namespaceObject.dispatch)(store).removeBlockStyles(blockName, styleVariationName); |
|
7411 }; |
|
7412 |
|
7413 /** |
|
7414 * Returns an array with the variations of a given block type. |
|
7415 * Ignored from documentation as the recommended usage is via useSelect from @wordpress/data. |
|
7416 * |
|
7417 * @ignore |
|
7418 * |
|
7419 * @param {string} blockName Name of block (example: “core/columns”). |
|
7420 * @param {WPBlockVariationScope} [scope] Block variation scope name. |
|
7421 * |
|
7422 * @return {(WPBlockVariation[]|void)} Block variations. |
|
7423 */ |
|
7424 const getBlockVariations = (blockName, scope) => { |
|
7425 return (0,external_wp_data_namespaceObject.select)(store).getBlockVariations(blockName, scope); |
|
7426 }; |
|
7427 |
|
7428 /** |
|
7429 * Registers a new block variation for the given block type. |
|
7430 * |
|
7431 * For more information on block variations see |
|
7432 * [the official documentation ](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-variations/). |
|
7433 * |
|
7434 * @param {string} blockName Name of the block (example: “core/columns”). |
|
7435 * @param {WPBlockVariation} variation Object describing a block variation. |
|
7436 * |
|
7437 * @example |
|
7438 * ```js |
|
7439 * import { __ } from '@wordpress/i18n'; |
|
7440 * import { registerBlockVariation } from '@wordpress/blocks'; |
|
7441 * import { Button } from '@wordpress/components'; |
|
7442 * |
|
7443 * const ExampleComponent = () => { |
|
7444 * return ( |
|
7445 * <Button |
|
7446 * onClick={ () => { |
|
7447 * registerBlockVariation( 'core/embed', { |
|
7448 * name: 'custom', |
|
7449 * title: __( 'My Custom Embed' ), |
|
7450 * attributes: { providerNameSlug: 'custom' }, |
|
7451 * } ); |
|
7452 * } } |
|
7453 * > |
|
7454 * __( 'Add a custom variation for core/embed' ) } |
|
7455 * </Button> |
|
7456 * ); |
|
7457 * }; |
|
7458 * ``` |
|
7459 */ |
|
7460 const registerBlockVariation = (blockName, variation) => { |
|
7461 if (typeof variation.name !== 'string') { |
|
7462 console.warn('Variation names must be unique strings.'); |
|
7463 } |
|
7464 (0,external_wp_data_namespaceObject.dispatch)(store).addBlockVariations(blockName, variation); |
|
7465 }; |
|
7466 |
|
7467 /** |
|
7468 * Unregisters a block variation defined for the given block type. |
|
7469 * |
|
7470 * @param {string} blockName Name of the block (example: “core/columns”). |
|
7471 * @param {string} variationName Name of the variation defined for the block. |
|
7472 * |
|
7473 * @example |
|
7474 * ```js |
|
7475 * import { __ } from '@wordpress/i18n'; |
|
7476 * import { unregisterBlockVariation } from '@wordpress/blocks'; |
|
7477 * import { Button } from '@wordpress/components'; |
|
7478 * |
|
7479 * const ExampleComponent = () => { |
|
7480 * return ( |
|
7481 * <Button |
|
7482 * onClick={ () => { |
|
7483 * unregisterBlockVariation( 'core/embed', 'youtube' ); |
|
7484 * } } |
|
7485 * > |
|
7486 * { __( 'Remove the YouTube variation from core/embed' ) } |
|
7487 * </Button> |
|
7488 * ); |
|
7489 * }; |
|
7490 * ``` |
|
7491 */ |
|
7492 const unregisterBlockVariation = (blockName, variationName) => { |
|
7493 (0,external_wp_data_namespaceObject.dispatch)(store).removeBlockVariations(blockName, variationName); |
|
7494 }; |
|
7495 |
|
7496 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/utils.js |
|
7497 /** |
|
7498 * External dependencies |
|
7499 */ |
|
7500 |
|
7501 |
|
7502 |
|
7503 |
|
7504 /** |
|
7505 * WordPress dependencies |
|
7506 */ |
|
7507 |
|
7508 |
|
7509 |
|
7510 |
|
7511 |
|
7512 /** |
|
7513 * Internal dependencies |
|
7514 */ |
|
7515 |
|
7516 |
|
7517 k([names, a11y]); |
|
7518 |
|
7519 /** |
|
7520 * Array of icon colors containing a color to be used if the icon color |
|
7521 * was not explicitly set but the icon background color was. |
|
7522 * |
|
7523 * @type {Object} |
|
7524 */ |
|
7525 const ICON_COLORS = ['#191e23', '#f8f9f9']; |
|
7526 |
|
7527 /** |
|
7528 * Determines whether the block's attributes are equal to the default attributes |
|
7529 * which means the block is unmodified. |
|
7530 * |
|
7531 * @param {WPBlock} block Block Object |
|
7532 * |
|
7533 * @return {boolean} Whether the block is an unmodified block. |
|
7534 */ |
|
7535 function isUnmodifiedBlock(block) { |
|
7536 var _getBlockType$attribu; |
|
7537 return Object.entries((_getBlockType$attribu = getBlockType(block.name)?.attributes) !== null && _getBlockType$attribu !== void 0 ? _getBlockType$attribu : {}).every(([key, definition]) => { |
|
7538 const value = block.attributes[key]; |
|
7539 |
|
7540 // Every attribute that has a default must match the default. |
|
7541 if (definition.hasOwnProperty('default')) { |
|
7542 return value === definition.default; |
|
7543 } |
|
7544 |
|
7545 // The rich text type is a bit different from the rest because it |
|
7546 // has an implicit default value of an empty RichTextData instance, |
|
7547 // so check the length of the value. |
|
7548 if (definition.type === 'rich-text') { |
|
7549 return !value?.length; |
|
7550 } |
|
7551 |
|
7552 // Every attribute that doesn't have a default should be undefined. |
|
7553 return value === undefined; |
|
7554 }); |
|
7555 } |
|
7556 |
|
7557 /** |
|
7558 * Determines whether the block is a default block and its attributes are equal |
|
7559 * to the default attributes which means the block is unmodified. |
|
7560 * |
|
7561 * @param {WPBlock} block Block Object |
|
7562 * |
|
7563 * @return {boolean} Whether the block is an unmodified default block. |
|
7564 */ |
|
7565 function isUnmodifiedDefaultBlock(block) { |
|
7566 return block.name === getDefaultBlockName() && isUnmodifiedBlock(block); |
|
7567 } |
|
7568 |
|
7569 /** |
|
7570 * Function that checks if the parameter is a valid icon. |
|
7571 * |
|
7572 * @param {*} icon Parameter to be checked. |
|
7573 * |
|
7574 * @return {boolean} True if the parameter is a valid icon and false otherwise. |
|
7575 */ |
|
7576 |
|
7577 function isValidIcon(icon) { |
|
7578 return !!icon && (typeof icon === 'string' || (0,external_wp_element_namespaceObject.isValidElement)(icon) || typeof icon === 'function' || icon instanceof external_wp_element_namespaceObject.Component); |
|
7579 } |
|
7580 |
|
7581 /** |
|
7582 * Function that receives an icon as set by the blocks during the registration |
|
7583 * and returns a new icon object that is normalized so we can rely on just on possible icon structure |
|
7584 * in the codebase. |
|
7585 * |
|
7586 * @param {WPBlockTypeIconRender} icon Render behavior of a block type icon; |
|
7587 * one of a Dashicon slug, an element, or a |
|
7588 * component. |
|
7589 * |
|
7590 * @return {WPBlockTypeIconDescriptor} Object describing the icon. |
|
7591 */ |
|
7592 function normalizeIconObject(icon) { |
|
7593 icon = icon || BLOCK_ICON_DEFAULT; |
|
7594 if (isValidIcon(icon)) { |
|
7595 return { |
|
7596 src: icon |
|
7597 }; |
|
7598 } |
|
7599 if ('background' in icon) { |
|
7600 const colordBgColor = w(icon.background); |
|
7601 const getColorContrast = iconColor => colordBgColor.contrast(iconColor); |
|
7602 const maxContrast = Math.max(...ICON_COLORS.map(getColorContrast)); |
|
7603 return { |
|
7604 ...icon, |
|
7605 foreground: icon.foreground ? icon.foreground : ICON_COLORS.find(iconColor => getColorContrast(iconColor) === maxContrast), |
|
7606 shadowColor: colordBgColor.alpha(0.3).toRgbString() |
|
7607 }; |
|
7608 } |
|
7609 return icon; |
|
7610 } |
|
7611 |
|
7612 /** |
|
7613 * Normalizes block type passed as param. When string is passed then |
|
7614 * it converts it to the matching block type object. |
|
7615 * It passes the original object otherwise. |
|
7616 * |
|
7617 * @param {string|Object} blockTypeOrName Block type or name. |
|
7618 * |
|
7619 * @return {?Object} Block type. |
|
7620 */ |
|
7621 function normalizeBlockType(blockTypeOrName) { |
|
7622 if (typeof blockTypeOrName === 'string') { |
|
7623 return getBlockType(blockTypeOrName); |
|
7624 } |
|
7625 return blockTypeOrName; |
|
7626 } |
|
7627 |
|
7628 /** |
|
7629 * Get the label for the block, usually this is either the block title, |
|
7630 * or the value of the block's `label` function when that's specified. |
|
7631 * |
|
7632 * @param {Object} blockType The block type. |
|
7633 * @param {Object} attributes The values of the block's attributes. |
|
7634 * @param {Object} context The intended use for the label. |
|
7635 * |
|
7636 * @return {string} The block label. |
|
7637 */ |
|
7638 function getBlockLabel(blockType, attributes, context = 'visual') { |
|
7639 const { |
|
7640 __experimentalLabel: getLabel, |
|
7641 title |
|
7642 } = blockType; |
|
7643 const label = getLabel && getLabel(attributes, { |
|
7644 context |
|
7645 }); |
|
7646 if (!label) { |
|
7647 return title; |
|
7648 } |
|
7649 if (label.toPlainText) { |
|
7650 return label.toPlainText(); |
|
7651 } |
|
7652 |
|
7653 // Strip any HTML (i.e. RichText formatting) before returning. |
|
7654 return (0,external_wp_dom_namespaceObject.__unstableStripHTML)(label); |
|
7655 } |
|
7656 |
|
7657 /** |
|
7658 * Get a label for the block for use by screenreaders, this is more descriptive |
|
7659 * than the visual label and includes the block title and the value of the |
|
7660 * `getLabel` function if it's specified. |
|
7661 * |
|
7662 * @param {?Object} blockType The block type. |
|
7663 * @param {Object} attributes The values of the block's attributes. |
|
7664 * @param {?number} position The position of the block in the block list. |
|
7665 * @param {string} [direction='vertical'] The direction of the block layout. |
|
7666 * |
|
7667 * @return {string} The block label. |
|
7668 */ |
|
7669 function getAccessibleBlockLabel(blockType, attributes, position, direction = 'vertical') { |
|
7670 // `title` is already localized, `label` is a user-supplied value. |
|
7671 const title = blockType?.title; |
|
7672 const label = blockType ? getBlockLabel(blockType, attributes, 'accessibility') : ''; |
|
7673 const hasPosition = position !== undefined; |
|
7674 |
|
7675 // getBlockLabel returns the block title as a fallback when there's no label, |
|
7676 // if it did return the title, this function needs to avoid adding the |
|
7677 // title twice within the accessible label. Use this `hasLabel` boolean to |
|
7678 // handle that. |
|
7679 const hasLabel = label && label !== title; |
|
7680 if (hasPosition && direction === 'vertical') { |
|
7681 if (hasLabel) { |
|
7682 return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. 1: The block title. 2: The block row number. 3: The block label.. */ |
|
7683 (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Row %2$d. %3$s'), title, position, label); |
|
7684 } |
|
7685 return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. 1: The block title. 2: The block row number. */ |
|
7686 (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Row %2$d'), title, position); |
|
7687 } else if (hasPosition && direction === 'horizontal') { |
|
7688 if (hasLabel) { |
|
7689 return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. 1: The block title. 2: The block column number. 3: The block label.. */ |
|
7690 (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Column %2$d. %3$s'), title, position, label); |
|
7691 } |
|
7692 return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. 1: The block title. 2: The block column number. */ |
|
7693 (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Column %2$d'), title, position); |
|
7694 } |
|
7695 if (hasLabel) { |
|
7696 return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. %1: The block title. %2: The block label. */ |
|
7697 (0,external_wp_i18n_namespaceObject.__)('%1$s Block. %2$s'), title, label); |
|
7698 } |
|
7699 return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. %s: The block title. */ |
|
7700 (0,external_wp_i18n_namespaceObject.__)('%s Block'), title); |
|
7701 } |
|
7702 function getDefault(attributeSchema) { |
|
7703 if (attributeSchema.default !== undefined) { |
|
7704 return attributeSchema.default; |
|
7705 } |
|
7706 if (attributeSchema.type === 'rich-text') { |
|
7707 return new external_wp_richText_namespaceObject.RichTextData(); |
|
7708 } |
|
7709 } |
|
7710 |
|
7711 /** |
|
7712 * Ensure attributes contains only values defined by block type, and merge |
|
7713 * default values for missing attributes. |
|
7714 * |
|
7715 * @param {string} name The block's name. |
|
7716 * @param {Object} attributes The block's attributes. |
|
7717 * @return {Object} The sanitized attributes. |
|
7718 */ |
|
7719 function __experimentalSanitizeBlockAttributes(name, attributes) { |
|
7720 // Get the type definition associated with a registered block. |
|
7721 const blockType = getBlockType(name); |
|
7722 if (undefined === blockType) { |
|
7723 throw new Error(`Block type '${name}' is not registered.`); |
|
7724 } |
|
7725 return Object.entries(blockType.attributes).reduce((accumulator, [key, schema]) => { |
|
7726 const value = attributes[key]; |
|
7727 if (undefined !== value) { |
|
7728 if (schema.type === 'rich-text') { |
|
7729 if (value instanceof external_wp_richText_namespaceObject.RichTextData) { |
|
7730 accumulator[key] = value; |
|
7731 } else if (typeof value === 'string') { |
|
7732 accumulator[key] = external_wp_richText_namespaceObject.RichTextData.fromHTMLString(value); |
|
7733 } |
|
7734 } else if (schema.type === 'string' && value instanceof external_wp_richText_namespaceObject.RichTextData) { |
|
7735 accumulator[key] = value.toHTMLString(); |
|
7736 } else { |
|
7737 accumulator[key] = value; |
|
7738 } |
|
7739 } else { |
|
7740 const _default = getDefault(schema); |
|
7741 if (undefined !== _default) { |
|
7742 accumulator[key] = _default; |
|
7743 } |
|
7744 } |
|
7745 if (['node', 'children'].indexOf(schema.source) !== -1) { |
|
7746 // Ensure value passed is always an array, which we're expecting in |
|
7747 // the RichText component to handle the deprecated value. |
|
7748 if (typeof accumulator[key] === 'string') { |
|
7749 accumulator[key] = [accumulator[key]]; |
|
7750 } else if (!Array.isArray(accumulator[key])) { |
|
7751 accumulator[key] = []; |
|
7752 } |
|
7753 } |
|
7754 return accumulator; |
|
7755 }, {}); |
|
7756 } |
|
7757 |
|
7758 /** |
|
7759 * Filter block attributes by `role` and return their names. |
|
7760 * |
|
7761 * @param {string} name Block attribute's name. |
|
7762 * @param {string} role The role of a block attribute. |
|
7763 * |
|
7764 * @return {string[]} The attribute names that have the provided role. |
|
7765 */ |
|
7766 function __experimentalGetBlockAttributesNamesByRole(name, role) { |
|
7767 const attributes = getBlockType(name)?.attributes; |
|
7768 if (!attributes) { |
|
7769 return []; |
|
7770 } |
|
7771 const attributesNames = Object.keys(attributes); |
|
7772 if (!role) { |
|
7773 return attributesNames; |
|
7774 } |
|
7775 return attributesNames.filter(attributeName => attributes[attributeName]?.__experimentalRole === role); |
|
7776 } |
|
7777 |
|
7778 /** |
|
7779 * Return a new object with the specified keys omitted. |
|
7780 * |
|
7781 * @param {Object} object Original object. |
|
7782 * @param {Array} keys Keys to be omitted. |
|
7783 * |
|
7784 * @return {Object} Object with omitted keys. |
|
7785 */ |
|
7786 function omit(object, keys) { |
|
7787 return Object.fromEntries(Object.entries(object).filter(([key]) => !keys.includes(key))); |
|
7788 } |
|
7789 |
|
7790 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/reducer.js |
|
7791 /** |
|
7792 * External dependencies |
|
7793 */ |
|
7794 |
|
7795 |
|
7796 /** |
|
7797 * WordPress dependencies |
|
7798 */ |
|
7799 |
|
7800 |
|
7801 |
|
7802 /** |
|
7803 * Internal dependencies |
|
7804 */ |
|
7805 |
|
7806 |
|
7807 /** |
|
7808 * @typedef {Object} WPBlockCategory |
|
7809 * |
|
7810 * @property {string} slug Unique category slug. |
|
7811 * @property {string} title Category label, for display in user interface. |
|
7812 */ |
|
7813 |
|
7814 /** |
|
7815 * Default set of categories. |
|
7816 * |
|
7817 * @type {WPBlockCategory[]} |
|
7818 */ |
|
7819 const DEFAULT_CATEGORIES = [{ |
|
7820 slug: 'text', |
|
7821 title: (0,external_wp_i18n_namespaceObject.__)('Text') |
|
7822 }, { |
|
7823 slug: 'media', |
|
7824 title: (0,external_wp_i18n_namespaceObject.__)('Media') |
|
7825 }, { |
|
7826 slug: 'design', |
|
7827 title: (0,external_wp_i18n_namespaceObject.__)('Design') |
|
7828 }, { |
|
7829 slug: 'widgets', |
|
7830 title: (0,external_wp_i18n_namespaceObject.__)('Widgets') |
|
7831 }, { |
|
7832 slug: 'theme', |
|
7833 title: (0,external_wp_i18n_namespaceObject.__)('Theme') |
|
7834 }, { |
|
7835 slug: 'embed', |
|
7836 title: (0,external_wp_i18n_namespaceObject.__)('Embeds') |
|
7837 }, { |
|
7838 slug: 'reusable', |
|
7839 title: (0,external_wp_i18n_namespaceObject.__)('Reusable blocks') |
|
7840 }]; |
|
7841 |
|
7842 // Key block types by their name. |
|
7843 function keyBlockTypesByName(types) { |
|
7844 return types.reduce((newBlockTypes, block) => ({ |
|
7845 ...newBlockTypes, |
|
7846 [block.name]: block |
|
7847 }), {}); |
|
7848 } |
|
7849 |
|
7850 // Filter items to ensure they're unique by their name. |
|
7851 function getUniqueItemsByName(items) { |
|
7852 return items.reduce((acc, currentItem) => { |
|
7853 if (!acc.some(item => item.name === currentItem.name)) { |
|
7854 acc.push(currentItem); |
|
7855 } |
|
7856 return acc; |
|
7857 }, []); |
|
7858 } |
|
7859 function bootstrappedBlockTypes(state = {}, action) { |
|
7860 switch (action.type) { |
|
7861 case 'ADD_BOOTSTRAPPED_BLOCK_TYPE': |
|
7862 const { |
|
7863 name, |
|
7864 blockType |
|
7865 } = action; |
|
7866 const serverDefinition = state[name]; |
|
7867 let newDefinition; |
|
7868 // Don't overwrite if already set. It covers the case when metadata |
|
7869 // was initialized from the server. |
|
7870 if (serverDefinition) { |
|
7871 // The `blockHooks` prop is not yet included in the server provided |
|
7872 // definitions and needs to be polyfilled. This can be removed when the |
|
7873 // minimum supported WordPress is >= 6.4. |
|
7874 if (serverDefinition.blockHooks === undefined && blockType.blockHooks) { |
|
7875 newDefinition = { |
|
7876 ...serverDefinition, |
|
7877 ...newDefinition, |
|
7878 blockHooks: blockType.blockHooks |
|
7879 }; |
|
7880 } |
|
7881 |
|
7882 // The `allowedBlocks` prop is not yet included in the server provided |
|
7883 // definitions and needs to be polyfilled. This can be removed when the |
|
7884 // minimum supported WordPress is >= 6.5. |
|
7885 if (serverDefinition.allowedBlocks === undefined && blockType.allowedBlocks) { |
|
7886 newDefinition = { |
|
7887 ...serverDefinition, |
|
7888 ...newDefinition, |
|
7889 allowedBlocks: blockType.allowedBlocks |
|
7890 }; |
|
7891 } |
|
7892 } else { |
|
7893 newDefinition = Object.fromEntries(Object.entries(blockType).filter(([, value]) => value !== null && value !== undefined).map(([key, value]) => [camelCase(key), value])); |
|
7894 newDefinition.name = name; |
|
7895 } |
|
7896 if (newDefinition) { |
|
7897 return { |
|
7898 ...state, |
|
7899 [name]: newDefinition |
|
7900 }; |
|
7901 } |
|
7902 return state; |
|
7903 case 'REMOVE_BLOCK_TYPES': |
|
7904 return omit(state, action.names); |
|
7905 } |
|
7906 return state; |
|
7907 } |
|
7908 |
|
7909 /** |
|
7910 * Reducer managing the unprocessed block types in a form passed when registering the by block. |
|
7911 * It's for internal use only. It allows recomputing the processed block types on-demand after block type filters |
|
7912 * get added or removed. |
|
7913 * |
|
7914 * @param {Object} state Current state. |
|
7915 * @param {Object} action Dispatched action. |
|
7916 * |
|
7917 * @return {Object} Updated state. |
|
7918 */ |
|
7919 function unprocessedBlockTypes(state = {}, action) { |
|
7920 switch (action.type) { |
|
7921 case 'ADD_UNPROCESSED_BLOCK_TYPE': |
|
7922 return { |
|
7923 ...state, |
|
7924 [action.name]: action.blockType |
|
7925 }; |
|
7926 case 'REMOVE_BLOCK_TYPES': |
|
7927 return omit(state, action.names); |
|
7928 } |
|
7929 return state; |
|
7930 } |
|
7931 |
|
7932 /** |
|
7933 * Reducer managing the processed block types with all filters applied. |
|
7934 * The state is derived from the `unprocessedBlockTypes` reducer. |
|
7935 * |
|
7936 * @param {Object} state Current state. |
|
7937 * @param {Object} action Dispatched action. |
|
7938 * |
|
7939 * @return {Object} Updated state. |
|
7940 */ |
|
7941 function blockTypes(state = {}, action) { |
|
7942 switch (action.type) { |
|
7943 case 'ADD_BLOCK_TYPES': |
|
7944 return { |
|
7945 ...state, |
|
7946 ...keyBlockTypesByName(action.blockTypes) |
|
7947 }; |
|
7948 case 'REMOVE_BLOCK_TYPES': |
|
7949 return omit(state, action.names); |
|
7950 } |
|
7951 return state; |
|
7952 } |
|
7953 |
|
7954 /** |
|
7955 * Reducer managing the block styles. |
|
7956 * |
|
7957 * @param {Object} state Current state. |
|
7958 * @param {Object} action Dispatched action. |
|
7959 * |
|
7960 * @return {Object} Updated state. |
|
7961 */ |
|
7962 function blockStyles(state = {}, action) { |
|
7963 var _state$action$blockNa; |
|
7964 switch (action.type) { |
|
7965 case 'ADD_BLOCK_TYPES': |
|
7966 return { |
|
7967 ...state, |
|
7968 ...Object.fromEntries(Object.entries(keyBlockTypesByName(action.blockTypes)).map(([name, blockType]) => { |
|
7969 var _blockType$styles, _state$blockType$name; |
|
7970 return [name, getUniqueItemsByName([...((_blockType$styles = blockType.styles) !== null && _blockType$styles !== void 0 ? _blockType$styles : []).map(style => ({ |
|
7971 ...style, |
|
7972 source: 'block' |
|
7973 })), ...((_state$blockType$name = state[blockType.name]) !== null && _state$blockType$name !== void 0 ? _state$blockType$name : []).filter(({ |
|
7974 source |
|
7975 }) => 'block' !== source)])]; |
|
7976 })) |
|
7977 }; |
|
7978 case 'ADD_BLOCK_STYLES': |
|
7979 const updatedStyles = {}; |
|
7980 action.blockNames.forEach(blockName => { |
|
7981 var _state$blockName; |
|
7982 updatedStyles[blockName] = getUniqueItemsByName([...((_state$blockName = state[blockName]) !== null && _state$blockName !== void 0 ? _state$blockName : []), ...action.styles]); |
|
7983 }); |
|
7984 return { |
|
7985 ...state, |
|
7986 ...updatedStyles |
|
7987 }; |
|
7988 case 'REMOVE_BLOCK_STYLES': |
|
7989 return { |
|
7990 ...state, |
|
7991 [action.blockName]: ((_state$action$blockNa = state[action.blockName]) !== null && _state$action$blockNa !== void 0 ? _state$action$blockNa : []).filter(style => action.styleNames.indexOf(style.name) === -1) |
|
7992 }; |
|
7993 } |
|
7994 return state; |
|
7995 } |
|
7996 |
|
7997 /** |
|
7998 * Reducer managing the block variations. |
|
7999 * |
|
8000 * @param {Object} state Current state. |
|
8001 * @param {Object} action Dispatched action. |
|
8002 * |
|
8003 * @return {Object} Updated state. |
|
8004 */ |
|
8005 function blockVariations(state = {}, action) { |
|
8006 var _state$action$blockNa2, _state$action$blockNa3; |
|
8007 switch (action.type) { |
|
8008 case 'ADD_BLOCK_TYPES': |
|
8009 return { |
|
8010 ...state, |
|
8011 ...Object.fromEntries(Object.entries(keyBlockTypesByName(action.blockTypes)).map(([name, blockType]) => { |
|
8012 var _blockType$variations, _state$blockType$name2; |
|
8013 return [name, getUniqueItemsByName([...((_blockType$variations = blockType.variations) !== null && _blockType$variations !== void 0 ? _blockType$variations : []).map(variation => ({ |
|
8014 ...variation, |
|
8015 source: 'block' |
|
8016 })), ...((_state$blockType$name2 = state[blockType.name]) !== null && _state$blockType$name2 !== void 0 ? _state$blockType$name2 : []).filter(({ |
|
8017 source |
|
8018 }) => 'block' !== source)])]; |
|
8019 })) |
|
8020 }; |
|
8021 case 'ADD_BLOCK_VARIATIONS': |
|
8022 return { |
|
8023 ...state, |
|
8024 [action.blockName]: getUniqueItemsByName([...((_state$action$blockNa2 = state[action.blockName]) !== null && _state$action$blockNa2 !== void 0 ? _state$action$blockNa2 : []), ...action.variations]) |
|
8025 }; |
|
8026 case 'REMOVE_BLOCK_VARIATIONS': |
|
8027 return { |
|
8028 ...state, |
|
8029 [action.blockName]: ((_state$action$blockNa3 = state[action.blockName]) !== null && _state$action$blockNa3 !== void 0 ? _state$action$blockNa3 : []).filter(variation => action.variationNames.indexOf(variation.name) === -1) |
|
8030 }; |
|
8031 } |
|
8032 return state; |
|
8033 } |
|
8034 |
|
8035 /** |
|
8036 * Higher-order Reducer creating a reducer keeping track of given block name. |
|
8037 * |
|
8038 * @param {string} setActionType Action type. |
|
8039 * |
|
8040 * @return {Function} Reducer. |
|
8041 */ |
|
8042 function createBlockNameSetterReducer(setActionType) { |
|
8043 return (state = null, action) => { |
|
8044 switch (action.type) { |
|
8045 case 'REMOVE_BLOCK_TYPES': |
|
8046 if (action.names.indexOf(state) !== -1) { |
|
8047 return null; |
|
8048 } |
|
8049 return state; |
|
8050 case setActionType: |
|
8051 return action.name || null; |
|
8052 } |
|
8053 return state; |
|
8054 }; |
|
8055 } |
|
8056 const defaultBlockName = createBlockNameSetterReducer('SET_DEFAULT_BLOCK_NAME'); |
|
8057 const freeformFallbackBlockName = createBlockNameSetterReducer('SET_FREEFORM_FALLBACK_BLOCK_NAME'); |
|
8058 const unregisteredFallbackBlockName = createBlockNameSetterReducer('SET_UNREGISTERED_FALLBACK_BLOCK_NAME'); |
|
8059 const groupingBlockName = createBlockNameSetterReducer('SET_GROUPING_BLOCK_NAME'); |
|
8060 |
|
8061 /** |
|
8062 * Reducer managing the categories |
|
8063 * |
|
8064 * @param {WPBlockCategory[]} state Current state. |
|
8065 * @param {Object} action Dispatched action. |
|
8066 * |
|
8067 * @return {WPBlockCategory[]} Updated state. |
|
8068 */ |
|
8069 function categories(state = DEFAULT_CATEGORIES, action) { |
|
8070 switch (action.type) { |
|
8071 case 'SET_CATEGORIES': |
|
8072 return action.categories || []; |
|
8073 case 'UPDATE_CATEGORY': |
|
8074 { |
|
8075 if (!action.category || !Object.keys(action.category).length) { |
|
8076 return state; |
|
8077 } |
|
8078 const categoryToChange = state.find(({ |
|
8079 slug |
|
8080 }) => slug === action.slug); |
|
8081 if (categoryToChange) { |
|
8082 return state.map(category => { |
|
8083 if (category.slug === action.slug) { |
|
8084 return { |
|
8085 ...category, |
|
8086 ...action.category |
|
8087 }; |
|
8088 } |
|
8089 return category; |
|
8090 }); |
|
8091 } |
|
8092 } |
|
8093 } |
|
8094 return state; |
|
8095 } |
|
8096 function collections(state = {}, action) { |
|
8097 switch (action.type) { |
|
8098 case 'ADD_BLOCK_COLLECTION': |
|
8099 return { |
|
8100 ...state, |
|
8101 [action.namespace]: { |
|
8102 title: action.title, |
|
8103 icon: action.icon |
|
8104 } |
|
8105 }; |
|
8106 case 'REMOVE_BLOCK_COLLECTION': |
|
8107 return omit(state, action.namespace); |
|
8108 } |
|
8109 return state; |
|
8110 } |
|
8111 function blockBindingsSources(state = {}, action) { |
|
8112 if (action.type === 'REGISTER_BLOCK_BINDINGS_SOURCE') { |
|
8113 return { |
|
8114 ...state, |
|
8115 [action.sourceName]: { |
|
8116 label: action.sourceLabel, |
|
8117 getValue: action.getValue, |
|
8118 setValue: action.setValue, |
|
8119 setValues: action.setValues, |
|
8120 getPlaceholder: action.getPlaceholder, |
|
8121 canUserEditValue: action.canUserEditValue || (() => false) |
|
8122 } |
|
8123 }; |
|
8124 } |
|
8125 return state; |
|
8126 } |
|
8127 /* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ |
|
8128 bootstrappedBlockTypes, |
|
8129 unprocessedBlockTypes, |
|
8130 blockTypes, |
|
8131 blockStyles, |
|
8132 blockVariations, |
|
8133 defaultBlockName, |
|
8134 freeformFallbackBlockName, |
|
8135 unregisteredFallbackBlockName, |
|
8136 groupingBlockName, |
|
8137 categories, |
|
8138 collections, |
|
8139 blockBindingsSources |
|
8140 })); |
|
8141 |
|
8142 // EXTERNAL MODULE: ./node_modules/remove-accents/index.js |
|
8143 var remove_accents = __webpack_require__(9681); |
|
8144 var remove_accents_default = /*#__PURE__*/__webpack_require__.n(remove_accents); |
|
8145 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/utils.js |
|
8146 /** |
|
8147 * Helper util to return a value from a certain path of the object. |
|
8148 * Path is specified as either: |
|
8149 * - a string of properties, separated by dots, for example: "x.y". |
|
8150 * - an array of properties, for example `[ 'x', 'y' ]`. |
|
8151 * You can also specify a default value in case the result is nullish. |
|
8152 * |
|
8153 * @param {Object} object Input object. |
|
8154 * @param {string|Array} path Path to the object property. |
|
8155 * @param {*} defaultValue Default value if the value at the specified path is nullish. |
|
8156 * @return {*} Value of the object property at the specified path. |
|
8157 */ |
|
8158 const getValueFromObjectPath = (object, path, defaultValue) => { |
|
8159 var _value; |
|
8160 const normalizedPath = Array.isArray(path) ? path : path.split('.'); |
|
8161 let value = object; |
|
8162 normalizedPath.forEach(fieldName => { |
|
8163 value = value?.[fieldName]; |
|
8164 }); |
|
8165 return (_value = value) !== null && _value !== void 0 ? _value : defaultValue; |
|
8166 }; |
|
8167 function utils_isObject(candidate) { |
|
8168 return typeof candidate === 'object' && candidate.constructor === Object && candidate !== null; |
|
8169 } |
|
8170 |
|
8171 /** |
|
8172 * Determine whether a set of object properties matches a given object. |
|
8173 * |
|
8174 * Given an object of block attributes and an object of variation attributes, |
|
8175 * this function checks recursively whether all the variation attributes are |
|
8176 * present in the block attributes object. |
|
8177 * |
|
8178 * @param {Object} blockAttributes The object to inspect. |
|
8179 * @param {Object} variationAttributes The object of property values to match. |
|
8180 * @return {boolean} Whether the block attributes match the variation attributes. |
|
8181 */ |
|
8182 function matchesAttributes(blockAttributes, variationAttributes) { |
|
8183 if (utils_isObject(blockAttributes) && utils_isObject(variationAttributes)) { |
|
8184 return Object.entries(variationAttributes).every(([key, value]) => matchesAttributes(blockAttributes?.[key], value)); |
|
8185 } |
|
8186 return blockAttributes === variationAttributes; |
|
8187 } |
|
8188 |
|
8189 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/selectors.js |
|
8190 /** |
|
8191 * External dependencies |
|
8192 */ |
|
8193 |
|
8194 |
|
8195 /** |
|
8196 * WordPress dependencies |
|
8197 */ |
|
8198 |
|
8199 |
|
8200 |
|
8201 /** |
|
8202 * Internal dependencies |
|
8203 */ |
|
8204 |
|
8205 |
|
8206 /** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */ |
|
8207 /** @typedef {import('../api/registration').WPBlockVariationScope} WPBlockVariationScope */ |
|
8208 /** @typedef {import('./reducer').WPBlockCategory} WPBlockCategory */ |
|
8209 |
|
8210 /** |
|
8211 * Given a block name or block type object, returns the corresponding |
|
8212 * normalized block type object. |
|
8213 * |
|
8214 * @param {Object} state Blocks state. |
|
8215 * @param {(string|Object)} nameOrType Block name or type object |
|
8216 * |
|
8217 * @return {Object} Block type object. |
|
8218 */ |
|
8219 const getNormalizedBlockType = (state, nameOrType) => 'string' === typeof nameOrType ? selectors_getBlockType(state, nameOrType) : nameOrType; |
|
8220 |
|
8221 /** |
|
8222 * Returns all the available block types. |
|
8223 * |
|
8224 * @param {Object} state Data state. |
|
8225 * |
|
8226 * @example |
|
8227 * ```js |
|
8228 * import { store as blocksStore } from '@wordpress/blocks'; |
|
8229 * import { useSelect } from '@wordpress/data'; |
|
8230 * |
|
8231 * const ExampleComponent = () => { |
|
8232 * const blockTypes = useSelect( |
|
8233 * ( select ) => select( blocksStore ).getBlockTypes(), |
|
8234 * [] |
|
8235 * ); |
|
8236 * |
|
8237 * return ( |
|
8238 * <ul> |
|
8239 * { blockTypes.map( ( block ) => ( |
|
8240 * <li key={ block.name }>{ block.title }</li> |
|
8241 * ) ) } |
|
8242 * </ul> |
|
8243 * ); |
|
8244 * }; |
|
8245 * ``` |
|
8246 * |
|
8247 * @return {Array} Block Types. |
|
8248 */ |
|
8249 const selectors_getBlockTypes = (0,external_wp_data_namespaceObject.createSelector)(state => Object.values(state.blockTypes), state => [state.blockTypes]); |
|
8250 |
|
8251 /** |
|
8252 * Returns a block type by name. |
|
8253 * |
|
8254 * @param {Object} state Data state. |
|
8255 * @param {string} name Block type name. |
|
8256 * |
|
8257 * @example |
|
8258 * ```js |
|
8259 * import { store as blocksStore } from '@wordpress/blocks'; |
|
8260 * import { useSelect } from '@wordpress/data'; |
|
8261 * |
|
8262 * const ExampleComponent = () => { |
|
8263 * const paragraphBlock = useSelect( ( select ) => |
|
8264 * ( select ) => select( blocksStore ).getBlockType( 'core/paragraph' ), |
|
8265 * [] |
|
8266 * ); |
|
8267 * |
|
8268 * return ( |
|
8269 * <ul> |
|
8270 * { paragraphBlock && |
|
8271 * Object.entries( paragraphBlock.supports ).map( |
|
8272 * ( blockSupportsEntry ) => { |
|
8273 * const [ propertyName, value ] = blockSupportsEntry; |
|
8274 * return ( |
|
8275 * <li |
|
8276 * key={ propertyName } |
|
8277 * >{ `${ propertyName } : ${ value }` }</li> |
|
8278 * ); |
|
8279 * } |
|
8280 * ) } |
|
8281 * </ul> |
|
8282 * ); |
|
8283 * }; |
|
8284 * ``` |
|
8285 * |
|
8286 * @return {Object?} Block Type. |
|
8287 */ |
|
8288 function selectors_getBlockType(state, name) { |
|
8289 return state.blockTypes[name]; |
|
8290 } |
|
8291 |
|
8292 /** |
|
8293 * Returns block styles by block name. |
|
8294 * |
|
8295 * @param {Object} state Data state. |
|
8296 * @param {string} name Block type name. |
|
8297 * |
|
8298 * @example |
|
8299 * ```js |
|
8300 * import { store as blocksStore } from '@wordpress/blocks'; |
|
8301 * import { useSelect } from '@wordpress/data'; |
|
8302 * |
|
8303 * const ExampleComponent = () => { |
|
8304 * const buttonBlockStyles = useSelect( ( select ) => |
|
8305 * select( blocksStore ).getBlockStyles( 'core/button' ), |
|
8306 * [] |
|
8307 * ); |
|
8308 * |
|
8309 * return ( |
|
8310 * <ul> |
|
8311 * { buttonBlockStyles && |
|
8312 * buttonBlockStyles.map( ( style ) => ( |
|
8313 * <li key={ style.name }>{ style.label }</li> |
|
8314 * ) ) } |
|
8315 * </ul> |
|
8316 * ); |
|
8317 * }; |
|
8318 * ``` |
|
8319 * |
|
8320 * @return {Array?} Block Styles. |
|
8321 */ |
|
8322 function getBlockStyles(state, name) { |
|
8323 return state.blockStyles[name]; |
|
8324 } |
|
8325 |
|
8326 /** |
|
8327 * Returns block variations by block name. |
|
8328 * |
|
8329 * @param {Object} state Data state. |
|
8330 * @param {string} blockName Block type name. |
|
8331 * @param {WPBlockVariationScope} [scope] Block variation scope name. |
|
8332 * |
|
8333 * @example |
|
8334 * ```js |
|
8335 * import { store as blocksStore } from '@wordpress/blocks'; |
|
8336 * import { useSelect } from '@wordpress/data'; |
|
8337 * |
|
8338 * const ExampleComponent = () => { |
|
8339 * const socialLinkVariations = useSelect( ( select ) => |
|
8340 * select( blocksStore ).getBlockVariations( 'core/social-link' ), |
|
8341 * [] |
|
8342 * ); |
|
8343 * |
|
8344 * return ( |
|
8345 * <ul> |
|
8346 * { socialLinkVariations && |
|
8347 * socialLinkVariations.map( ( variation ) => ( |
|
8348 * <li key={ variation.name }>{ variation.title }</li> |
|
8349 * ) ) } |
|
8350 * </ul> |
|
8351 * ); |
|
8352 * }; |
|
8353 * ``` |
|
8354 * |
|
8355 * @return {(WPBlockVariation[]|void)} Block variations. |
|
8356 */ |
|
8357 const selectors_getBlockVariations = (0,external_wp_data_namespaceObject.createSelector)((state, blockName, scope) => { |
|
8358 const variations = state.blockVariations[blockName]; |
|
8359 if (!variations || !scope) { |
|
8360 return variations; |
|
8361 } |
|
8362 return variations.filter(variation => { |
|
8363 // For backward compatibility reasons, variation's scope defaults to |
|
8364 // `block` and `inserter` when not set. |
|
8365 return (variation.scope || ['block', 'inserter']).includes(scope); |
|
8366 }); |
|
8367 }, (state, blockName) => [state.blockVariations[blockName]]); |
|
8368 |
|
8369 /** |
|
8370 * Returns the active block variation for a given block based on its attributes. |
|
8371 * Variations are determined by their `isActive` property. |
|
8372 * Which is either an array of block attribute keys or a function. |
|
8373 * |
|
8374 * In case of an array of block attribute keys, the `attributes` are compared |
|
8375 * to the variation's attributes using strict equality check. |
|
8376 * |
|
8377 * In case of function type, the function should accept a block's attributes |
|
8378 * and the variation's attributes and determines if a variation is active. |
|
8379 * A function that accepts a block's attributes and the variation's attributes and determines if a variation is active. |
|
8380 * |
|
8381 * @param {Object} state Data state. |
|
8382 * @param {string} blockName Name of block (example: “core/columns”). |
|
8383 * @param {Object} attributes Block attributes used to determine active variation. |
|
8384 * @param {WPBlockVariationScope} [scope] Block variation scope name. |
|
8385 * |
|
8386 * @example |
|
8387 * ```js |
|
8388 * import { __ } from '@wordpress/i18n'; |
|
8389 * import { store as blocksStore } from '@wordpress/blocks'; |
|
8390 * import { store as blockEditorStore } from '@wordpress/block-editor'; |
|
8391 * import { useSelect } from '@wordpress/data'; |
|
8392 * |
|
8393 * const ExampleComponent = () => { |
|
8394 * // This example assumes that a core/embed block is the first block in the Block Editor. |
|
8395 * const activeBlockVariation = useSelect( ( select ) => { |
|
8396 * // Retrieve the list of blocks. |
|
8397 * const [ firstBlock ] = select( blockEditorStore ).getBlocks() |
|
8398 * |
|
8399 * // Return the active block variation for the first block. |
|
8400 * return select( blocksStore ).getActiveBlockVariation( |
|
8401 * firstBlock.name, |
|
8402 * firstBlock.attributes |
|
8403 * ); |
|
8404 * }, [] ); |
|
8405 * |
|
8406 * return activeBlockVariation && activeBlockVariation.name === 'spotify' ? ( |
|
8407 * <p>{ __( 'Spotify variation' ) }</p> |
|
8408 * ) : ( |
|
8409 * <p>{ __( 'Other variation' ) }</p> |
|
8410 * ); |
|
8411 * }; |
|
8412 * ``` |
|
8413 * |
|
8414 * @return {(WPBlockVariation|undefined)} Active block variation. |
|
8415 */ |
|
8416 function getActiveBlockVariation(state, blockName, attributes, scope) { |
|
8417 const variations = selectors_getBlockVariations(state, blockName, scope); |
|
8418 if (!variations) { |
|
8419 return variations; |
|
8420 } |
|
8421 const blockType = selectors_getBlockType(state, blockName); |
|
8422 const attributeKeys = Object.keys(blockType?.attributes || {}); |
|
8423 let match; |
|
8424 let maxMatchedAttributes = 0; |
|
8425 for (const variation of variations) { |
|
8426 if (Array.isArray(variation.isActive)) { |
|
8427 const definedAttributes = variation.isActive.filter(attribute => { |
|
8428 // We support nested attribute paths, e.g. `layout.type`. |
|
8429 // In this case, we need to check if the part before the |
|
8430 // first dot is a known attribute. |
|
8431 const topLevelAttribute = attribute.split('.')[0]; |
|
8432 return attributeKeys.includes(topLevelAttribute); |
|
8433 }); |
|
8434 const definedAttributesLength = definedAttributes.length; |
|
8435 if (definedAttributesLength === 0) { |
|
8436 continue; |
|
8437 } |
|
8438 const isMatch = definedAttributes.every(attribute => { |
|
8439 const variationAttributeValue = getValueFromObjectPath(variation.attributes, attribute); |
|
8440 if (variationAttributeValue === undefined) { |
|
8441 return false; |
|
8442 } |
|
8443 let blockAttributeValue = getValueFromObjectPath(attributes, attribute); |
|
8444 if (blockAttributeValue instanceof external_wp_richText_namespaceObject.RichTextData) { |
|
8445 blockAttributeValue = blockAttributeValue.toHTMLString(); |
|
8446 } |
|
8447 return matchesAttributes(blockAttributeValue, variationAttributeValue); |
|
8448 }); |
|
8449 if (isMatch && definedAttributesLength > maxMatchedAttributes) { |
|
8450 match = variation; |
|
8451 maxMatchedAttributes = definedAttributesLength; |
|
8452 } |
|
8453 } else if (variation.isActive?.(attributes, variation.attributes)) { |
|
8454 // If isActive is a function, we cannot know how many attributes it matches. |
|
8455 // This means that we cannot compare the specificity of our matches, |
|
8456 // and simply return the best match we have found. |
|
8457 return match || variation; |
|
8458 } |
|
8459 } |
|
8460 return match; |
|
8461 } |
|
8462 |
|
8463 /** |
|
8464 * Returns the default block variation for the given block type. |
|
8465 * When there are multiple variations annotated as the default one, |
|
8466 * the last added item is picked. This simplifies registering overrides. |
|
8467 * When there is no default variation set, it returns the first item. |
|
8468 * |
|
8469 * @param {Object} state Data state. |
|
8470 * @param {string} blockName Block type name. |
|
8471 * @param {WPBlockVariationScope} [scope] Block variation scope name. |
|
8472 * |
|
8473 * @example |
|
8474 * ```js |
|
8475 * import { __, sprintf } from '@wordpress/i18n'; |
|
8476 * import { store as blocksStore } from '@wordpress/blocks'; |
|
8477 * import { useSelect } from '@wordpress/data'; |
|
8478 * |
|
8479 * const ExampleComponent = () => { |
|
8480 * const defaultEmbedBlockVariation = useSelect( ( select ) => |
|
8481 * select( blocksStore ).getDefaultBlockVariation( 'core/embed' ), |
|
8482 * [] |
|
8483 * ); |
|
8484 * |
|
8485 * return ( |
|
8486 * defaultEmbedBlockVariation && ( |
|
8487 * <p> |
|
8488 * { sprintf( |
|
8489 * __( 'core/embed default variation: %s' ), |
|
8490 * defaultEmbedBlockVariation.title |
|
8491 * ) } |
|
8492 * </p> |
|
8493 * ) |
|
8494 * ); |
|
8495 * }; |
|
8496 * ``` |
|
8497 * |
|
8498 * @return {?WPBlockVariation} The default block variation. |
|
8499 */ |
|
8500 function getDefaultBlockVariation(state, blockName, scope) { |
|
8501 const variations = selectors_getBlockVariations(state, blockName, scope); |
|
8502 const defaultVariation = [...variations].reverse().find(({ |
|
8503 isDefault |
|
8504 }) => !!isDefault); |
|
8505 return defaultVariation || variations[0]; |
|
8506 } |
|
8507 |
|
8508 /** |
|
8509 * Returns all the available block categories. |
|
8510 * |
|
8511 * @param {Object} state Data state. |
|
8512 * |
|
8513 * @example |
|
8514 * ```js |
|
8515 * import { store as blocksStore } from '@wordpress/blocks'; |
|
8516 * import { useSelect, } from '@wordpress/data'; |
|
8517 * |
|
8518 * const ExampleComponent = () => { |
|
8519 * const blockCategories = useSelect( ( select ) => |
|
8520 * select( blocksStore ).getCategories(), |
|
8521 * [] |
|
8522 * ); |
|
8523 * |
|
8524 * return ( |
|
8525 * <ul> |
|
8526 * { blockCategories.map( ( category ) => ( |
|
8527 * <li key={ category.slug }>{ category.title }</li> |
|
8528 * ) ) } |
|
8529 * </ul> |
|
8530 * ); |
|
8531 * }; |
|
8532 * ``` |
|
8533 * |
|
8534 * @return {WPBlockCategory[]} Categories list. |
|
8535 */ |
|
8536 function getCategories(state) { |
|
8537 return state.categories; |
|
8538 } |
|
8539 |
|
8540 /** |
|
8541 * Returns all the available collections. |
|
8542 * |
|
8543 * @param {Object} state Data state. |
|
8544 * |
|
8545 * @example |
|
8546 * ```js |
|
8547 * import { store as blocksStore } from '@wordpress/blocks'; |
|
8548 * import { useSelect } from '@wordpress/data'; |
|
8549 * |
|
8550 * const ExampleComponent = () => { |
|
8551 * const blockCollections = useSelect( ( select ) => |
|
8552 * select( blocksStore ).getCollections(), |
|
8553 * [] |
|
8554 * ); |
|
8555 * |
|
8556 * return ( |
|
8557 * <ul> |
|
8558 * { Object.values( blockCollections ).length > 0 && |
|
8559 * Object.values( blockCollections ).map( ( collection ) => ( |
|
8560 * <li key={ collection.title }>{ collection.title }</li> |
|
8561 * ) ) } |
|
8562 * </ul> |
|
8563 * ); |
|
8564 * }; |
|
8565 * ``` |
|
8566 * |
|
8567 * @return {Object} Collections list. |
|
8568 */ |
|
8569 function getCollections(state) { |
|
8570 return state.collections; |
|
8571 } |
|
8572 |
|
8573 /** |
|
8574 * Returns the name of the default block name. |
|
8575 * |
|
8576 * @param {Object} state Data state. |
|
8577 * |
|
8578 * @example |
|
8579 * ```js |
|
8580 * import { __, sprintf } from '@wordpress/i18n'; |
|
8581 * import { store as blocksStore } from '@wordpress/blocks'; |
|
8582 * import { useSelect } from '@wordpress/data'; |
|
8583 * |
|
8584 * const ExampleComponent = () => { |
|
8585 * const defaultBlockName = useSelect( ( select ) => |
|
8586 * select( blocksStore ).getDefaultBlockName(), |
|
8587 * [] |
|
8588 * ); |
|
8589 * |
|
8590 * return ( |
|
8591 * defaultBlockName && ( |
|
8592 * <p> |
|
8593 * { sprintf( __( 'Default block name: %s' ), defaultBlockName ) } |
|
8594 * </p> |
|
8595 * ) |
|
8596 * ); |
|
8597 * }; |
|
8598 * ``` |
|
8599 * |
|
8600 * @return {string?} Default block name. |
|
8601 */ |
|
8602 function selectors_getDefaultBlockName(state) { |
|
8603 return state.defaultBlockName; |
|
8604 } |
|
8605 |
|
8606 /** |
|
8607 * Returns the name of the block for handling non-block content. |
|
8608 * |
|
8609 * @param {Object} state Data state. |
|
8610 * |
|
8611 * @example |
|
8612 * ```js |
|
8613 * import { __, sprintf } from '@wordpress/i18n'; |
|
8614 * import { store as blocksStore } from '@wordpress/blocks'; |
|
8615 * import { useSelect } from '@wordpress/data'; |
|
8616 * |
|
8617 * const ExampleComponent = () => { |
|
8618 * const freeformFallbackBlockName = useSelect( ( select ) => |
|
8619 * select( blocksStore ).getFreeformFallbackBlockName(), |
|
8620 * [] |
|
8621 * ); |
|
8622 * |
|
8623 * return ( |
|
8624 * freeformFallbackBlockName && ( |
|
8625 * <p> |
|
8626 * { sprintf( __( |
|
8627 * 'Freeform fallback block name: %s' ), |
|
8628 * freeformFallbackBlockName |
|
8629 * ) } |
|
8630 * </p> |
|
8631 * ) |
|
8632 * ); |
|
8633 * }; |
|
8634 * ``` |
|
8635 * |
|
8636 * @return {string?} Name of the block for handling non-block content. |
|
8637 */ |
|
8638 function getFreeformFallbackBlockName(state) { |
|
8639 return state.freeformFallbackBlockName; |
|
8640 } |
|
8641 |
|
8642 /** |
|
8643 * Returns the name of the block for handling unregistered blocks. |
|
8644 * |
|
8645 * @param {Object} state Data state. |
|
8646 * |
|
8647 * @example |
|
8648 * ```js |
|
8649 * import { __, sprintf } from '@wordpress/i18n'; |
|
8650 * import { store as blocksStore } from '@wordpress/blocks'; |
|
8651 * import { useSelect } from '@wordpress/data'; |
|
8652 * |
|
8653 * const ExampleComponent = () => { |
|
8654 * const unregisteredFallbackBlockName = useSelect( ( select ) => |
|
8655 * select( blocksStore ).getUnregisteredFallbackBlockName(), |
|
8656 * [] |
|
8657 * ); |
|
8658 * |
|
8659 * return ( |
|
8660 * unregisteredFallbackBlockName && ( |
|
8661 * <p> |
|
8662 * { sprintf( __( |
|
8663 * 'Unregistered fallback block name: %s' ), |
|
8664 * unregisteredFallbackBlockName |
|
8665 * ) } |
|
8666 * </p> |
|
8667 * ) |
|
8668 * ); |
|
8669 * }; |
|
8670 * ``` |
|
8671 * |
|
8672 * @return {string?} Name of the block for handling unregistered blocks. |
|
8673 */ |
|
8674 function getUnregisteredFallbackBlockName(state) { |
|
8675 return state.unregisteredFallbackBlockName; |
|
8676 } |
|
8677 |
|
8678 /** |
|
8679 * Returns the name of the block for handling the grouping of blocks. |
|
8680 * |
|
8681 * @param {Object} state Data state. |
|
8682 * |
|
8683 * @example |
|
8684 * ```js |
|
8685 * import { __, sprintf } from '@wordpress/i18n'; |
|
8686 * import { store as blocksStore } from '@wordpress/blocks'; |
|
8687 * import { useSelect } from '@wordpress/data'; |
|
8688 * |
|
8689 * const ExampleComponent = () => { |
|
8690 * const groupingBlockName = useSelect( ( select ) => |
|
8691 * select( blocksStore ).getGroupingBlockName(), |
|
8692 * [] |
|
8693 * ); |
|
8694 * |
|
8695 * return ( |
|
8696 * groupingBlockName && ( |
|
8697 * <p> |
|
8698 * { sprintf( |
|
8699 * __( 'Default grouping block name: %s' ), |
|
8700 * groupingBlockName |
|
8701 * ) } |
|
8702 * </p> |
|
8703 * ) |
|
8704 * ); |
|
8705 * }; |
|
8706 * ``` |
|
8707 * |
|
8708 * @return {string?} Name of the block for handling the grouping of blocks. |
|
8709 */ |
|
8710 function selectors_getGroupingBlockName(state) { |
|
8711 return state.groupingBlockName; |
|
8712 } |
|
8713 |
|
8714 /** |
|
8715 * Returns an array with the child blocks of a given block. |
|
8716 * |
|
8717 * @param {Object} state Data state. |
|
8718 * @param {string} blockName Block type name. |
|
8719 * |
|
8720 * @example |
|
8721 * ```js |
|
8722 * import { store as blocksStore } from '@wordpress/blocks'; |
|
8723 * import { useSelect } from '@wordpress/data'; |
|
8724 * |
|
8725 * const ExampleComponent = () => { |
|
8726 * const childBlockNames = useSelect( ( select ) => |
|
8727 * select( blocksStore ).getChildBlockNames( 'core/navigation' ), |
|
8728 * [] |
|
8729 * ); |
|
8730 * |
|
8731 * return ( |
|
8732 * <ul> |
|
8733 * { childBlockNames && |
|
8734 * childBlockNames.map( ( child ) => ( |
|
8735 * <li key={ child }>{ child }</li> |
|
8736 * ) ) } |
|
8737 * </ul> |
|
8738 * ); |
|
8739 * }; |
|
8740 * ``` |
|
8741 * |
|
8742 * @return {Array} Array of child block names. |
|
8743 */ |
|
8744 const selectors_getChildBlockNames = (0,external_wp_data_namespaceObject.createSelector)((state, blockName) => { |
|
8745 return selectors_getBlockTypes(state).filter(blockType => { |
|
8746 return blockType.parent?.includes(blockName); |
|
8747 }).map(({ |
|
8748 name |
|
8749 }) => name); |
|
8750 }, state => [state.blockTypes]); |
|
8751 |
|
8752 /** |
|
8753 * Returns the block support value for a feature, if defined. |
|
8754 * |
|
8755 * @param {Object} state Data state. |
|
8756 * @param {(string|Object)} nameOrType Block name or type object |
|
8757 * @param {Array|string} feature Feature to retrieve |
|
8758 * @param {*} defaultSupports Default value to return if not |
|
8759 * explicitly defined |
|
8760 * |
|
8761 * @example |
|
8762 * ```js |
|
8763 * import { __, sprintf } from '@wordpress/i18n'; |
|
8764 * import { store as blocksStore } from '@wordpress/blocks'; |
|
8765 * import { useSelect } from '@wordpress/data'; |
|
8766 * |
|
8767 * const ExampleComponent = () => { |
|
8768 * const paragraphBlockSupportValue = useSelect( ( select ) => |
|
8769 * select( blocksStore ).getBlockSupport( 'core/paragraph', 'anchor' ), |
|
8770 * [] |
|
8771 * ); |
|
8772 * |
|
8773 * return ( |
|
8774 * <p> |
|
8775 * { sprintf( |
|
8776 * __( 'core/paragraph supports.anchor value: %s' ), |
|
8777 * paragraphBlockSupportValue |
|
8778 * ) } |
|
8779 * </p> |
|
8780 * ); |
|
8781 * }; |
|
8782 * ``` |
|
8783 * |
|
8784 * @return {?*} Block support value |
|
8785 */ |
|
8786 const selectors_getBlockSupport = (state, nameOrType, feature, defaultSupports) => { |
|
8787 const blockType = getNormalizedBlockType(state, nameOrType); |
|
8788 if (!blockType?.supports) { |
|
8789 return defaultSupports; |
|
8790 } |
|
8791 return getValueFromObjectPath(blockType.supports, feature, defaultSupports); |
|
8792 }; |
|
8793 |
|
8794 /** |
|
8795 * Returns true if the block defines support for a feature, or false otherwise. |
|
8796 * |
|
8797 * @param {Object} state Data state. |
|
8798 * @param {(string|Object)} nameOrType Block name or type object. |
|
8799 * @param {string} feature Feature to test. |
|
8800 * @param {boolean} defaultSupports Whether feature is supported by |
|
8801 * default if not explicitly defined. |
|
8802 * |
|
8803 * @example |
|
8804 * ```js |
|
8805 * import { __, sprintf } from '@wordpress/i18n'; |
|
8806 * import { store as blocksStore } from '@wordpress/blocks'; |
|
8807 * import { useSelect } from '@wordpress/data'; |
|
8808 * |
|
8809 * const ExampleComponent = () => { |
|
8810 * const paragraphBlockSupportClassName = useSelect( ( select ) => |
|
8811 * select( blocksStore ).hasBlockSupport( 'core/paragraph', 'className' ), |
|
8812 * [] |
|
8813 * ); |
|
8814 * |
|
8815 * return ( |
|
8816 * <p> |
|
8817 * { sprintf( |
|
8818 * __( 'core/paragraph supports custom class name?: %s' ), |
|
8819 * paragraphBlockSupportClassName |
|
8820 * ) } |
|
8821 * /p> |
|
8822 * ); |
|
8823 * }; |
|
8824 * ``` |
|
8825 * |
|
8826 * @return {boolean} Whether block supports feature. |
|
8827 */ |
|
8828 function selectors_hasBlockSupport(state, nameOrType, feature, defaultSupports) { |
|
8829 return !!selectors_getBlockSupport(state, nameOrType, feature, defaultSupports); |
|
8830 } |
|
8831 |
|
8832 /** |
|
8833 * Normalizes a search term string: removes accents, converts to lowercase, removes extra whitespace. |
|
8834 * |
|
8835 * @param {string|null|undefined} term Search term to normalize. |
|
8836 * @return {string} Normalized search term. |
|
8837 */ |
|
8838 function getNormalizedSearchTerm(term) { |
|
8839 return remove_accents_default()(term !== null && term !== void 0 ? term : '').toLowerCase().trim(); |
|
8840 } |
|
8841 |
|
8842 /** |
|
8843 * Returns true if the block type by the given name or object value matches a |
|
8844 * search term, or false otherwise. |
|
8845 * |
|
8846 * @param {Object} state Blocks state. |
|
8847 * @param {(string|Object)} nameOrType Block name or type object. |
|
8848 * @param {string} searchTerm Search term by which to filter. |
|
8849 * |
|
8850 * @example |
|
8851 * ```js |
|
8852 * import { __, sprintf } from '@wordpress/i18n'; |
|
8853 * import { store as blocksStore } from '@wordpress/blocks'; |
|
8854 * import { useSelect } from '@wordpress/data'; |
|
8855 * |
|
8856 * const ExampleComponent = () => { |
|
8857 * const termFound = useSelect( |
|
8858 * ( select ) => |
|
8859 * select( blocksStore ).isMatchingSearchTerm( |
|
8860 * 'core/navigation', |
|
8861 * 'theme' |
|
8862 * ), |
|
8863 * [] |
|
8864 * ); |
|
8865 * |
|
8866 * return ( |
|
8867 * <p> |
|
8868 * { sprintf( |
|
8869 * __( |
|
8870 * 'Search term was found in the title, keywords, category or description in block.json: %s' |
|
8871 * ), |
|
8872 * termFound |
|
8873 * ) } |
|
8874 * </p> |
|
8875 * ); |
|
8876 * }; |
|
8877 * ``` |
|
8878 * |
|
8879 * @return {Object[]} Whether block type matches search term. |
|
8880 */ |
|
8881 function isMatchingSearchTerm(state, nameOrType, searchTerm = '') { |
|
8882 const blockType = getNormalizedBlockType(state, nameOrType); |
|
8883 const normalizedSearchTerm = getNormalizedSearchTerm(searchTerm); |
|
8884 const isSearchMatch = candidate => getNormalizedSearchTerm(candidate).includes(normalizedSearchTerm); |
|
8885 return isSearchMatch(blockType.title) || blockType.keywords?.some(isSearchMatch) || isSearchMatch(blockType.category) || typeof blockType.description === 'string' && isSearchMatch(blockType.description); |
|
8886 } |
|
8887 |
|
8888 /** |
|
8889 * Returns a boolean indicating if a block has child blocks or not. |
|
8890 * |
|
8891 * @param {Object} state Data state. |
|
8892 * @param {string} blockName Block type name. |
|
8893 * |
|
8894 * @example |
|
8895 * ```js |
|
8896 * import { __, sprintf } from '@wordpress/i18n'; |
|
8897 * import { store as blocksStore } from '@wordpress/blocks'; |
|
8898 * import { useSelect } from '@wordpress/data'; |
|
8899 * |
|
8900 * const ExampleComponent = () => { |
|
8901 * const navigationBlockHasChildBlocks = useSelect( ( select ) => |
|
8902 * select( blocksStore ).hasChildBlocks( 'core/navigation' ), |
|
8903 * [] |
|
8904 * ); |
|
8905 * |
|
8906 * return ( |
|
8907 * <p> |
|
8908 * { sprintf( |
|
8909 * __( 'core/navigation has child blocks: %s' ), |
|
8910 * navigationBlockHasChildBlocks |
|
8911 * ) } |
|
8912 * </p> |
|
8913 * ); |
|
8914 * }; |
|
8915 * ``` |
|
8916 * |
|
8917 * @return {boolean} True if a block contains child blocks and false otherwise. |
|
8918 */ |
|
8919 const selectors_hasChildBlocks = (state, blockName) => { |
|
8920 return selectors_getChildBlockNames(state, blockName).length > 0; |
|
8921 }; |
|
8922 |
|
8923 /** |
|
8924 * Returns a boolean indicating if a block has at least one child block with inserter support. |
|
8925 * |
|
8926 * @param {Object} state Data state. |
|
8927 * @param {string} blockName Block type name. |
|
8928 * |
|
8929 * @example |
|
8930 * ```js |
|
8931 * import { __, sprintf } from '@wordpress/i18n'; |
|
8932 * import { store as blocksStore } from '@wordpress/blocks'; |
|
8933 * import { useSelect } from '@wordpress/data'; |
|
8934 * |
|
8935 * const ExampleComponent = () => { |
|
8936 * const navigationBlockHasChildBlocksWithInserterSupport = useSelect( ( select ) => |
|
8937 * select( blocksStore ).hasChildBlocksWithInserterSupport( |
|
8938 * 'core/navigation' |
|
8939 * ), |
|
8940 * [] |
|
8941 * ); |
|
8942 * |
|
8943 * return ( |
|
8944 * <p> |
|
8945 * { sprintf( |
|
8946 * __( 'core/navigation has child blocks with inserter support: %s' ), |
|
8947 * navigationBlockHasChildBlocksWithInserterSupport |
|
8948 * ) } |
|
8949 * </p> |
|
8950 * ); |
|
8951 * }; |
|
8952 * ``` |
|
8953 * |
|
8954 * @return {boolean} True if a block contains at least one child blocks with inserter support |
|
8955 * and false otherwise. |
|
8956 */ |
|
8957 const selectors_hasChildBlocksWithInserterSupport = (state, blockName) => { |
|
8958 return selectors_getChildBlockNames(state, blockName).some(childBlockName => { |
|
8959 return selectors_hasBlockSupport(state, childBlockName, 'inserter', true); |
|
8960 }); |
|
8961 }; |
|
8962 |
|
8963 /** |
|
8964 * DO-NOT-USE in production. |
|
8965 * This selector is created for internal/experimental only usage and may be |
|
8966 * removed anytime without any warning, causing breakage on any plugin or theme invoking it. |
|
8967 */ |
|
8968 const __experimentalHasContentRoleAttribute = (0,external_wp_data_namespaceObject.createSelector)((state, blockTypeName) => { |
|
8969 const blockType = selectors_getBlockType(state, blockTypeName); |
|
8970 if (!blockType) { |
|
8971 return false; |
|
8972 } |
|
8973 return Object.entries(blockType.attributes).some(([, { |
|
8974 __experimentalRole |
|
8975 }]) => __experimentalRole === 'content'); |
|
8976 }, (state, blockTypeName) => [state.blockTypes[blockTypeName]?.attributes]); |
|
8977 |
|
8978 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/private-selectors.js |
|
8979 /** |
|
8980 * WordPress dependencies |
|
8981 */ |
|
8982 |
|
8983 |
|
8984 /** |
|
8985 * Internal dependencies |
|
8986 */ |
|
8987 |
|
8988 |
|
8989 |
|
8990 const ROOT_BLOCK_SUPPORTS = ['background', 'backgroundColor', 'color', 'linkColor', 'captionColor', 'buttonColor', 'headingColor', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight', 'lineHeight', 'padding', 'contentSize', 'wideSize', 'blockGap', 'textDecoration', 'textTransform', 'letterSpacing']; |
|
8991 |
|
8992 /** |
|
8993 * Filters the list of supported styles for a given element. |
|
8994 * |
|
8995 * @param {string[]} blockSupports list of supported styles. |
|
8996 * @param {string|undefined} name block name. |
|
8997 * @param {string|undefined} element element name. |
|
8998 * |
|
8999 * @return {string[]} filtered list of supported styles. |
|
9000 */ |
|
9001 function filterElementBlockSupports(blockSupports, name, element) { |
|
9002 return blockSupports.filter(support => { |
|
9003 if (support === 'fontSize' && element === 'heading') { |
|
9004 return false; |
|
9005 } |
|
9006 |
|
9007 // This is only available for links |
|
9008 if (support === 'textDecoration' && !name && element !== 'link') { |
|
9009 return false; |
|
9010 } |
|
9011 |
|
9012 // This is only available for heading, button, caption and text |
|
9013 if (support === 'textTransform' && !name && !(['heading', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(element) || element === 'button' || element === 'caption' || element === 'text')) { |
|
9014 return false; |
|
9015 } |
|
9016 |
|
9017 // This is only available for heading, button, caption and text |
|
9018 if (support === 'letterSpacing' && !name && !(['heading', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(element) || element === 'button' || element === 'caption' || element === 'text')) { |
|
9019 return false; |
|
9020 } |
|
9021 |
|
9022 // Text columns is only available for blocks. |
|
9023 if (support === 'textColumns' && !name) { |
|
9024 return false; |
|
9025 } |
|
9026 return true; |
|
9027 }); |
|
9028 } |
|
9029 |
|
9030 /** |
|
9031 * Returns the list of supported styles for a given block name and element. |
|
9032 */ |
|
9033 const getSupportedStyles = (0,external_wp_data_namespaceObject.createSelector)((state, name, element) => { |
|
9034 if (!name) { |
|
9035 return filterElementBlockSupports(ROOT_BLOCK_SUPPORTS, name, element); |
|
9036 } |
|
9037 const blockType = selectors_getBlockType(state, name); |
|
9038 if (!blockType) { |
|
9039 return []; |
|
9040 } |
|
9041 const supportKeys = []; |
|
9042 |
|
9043 // Check for blockGap support. |
|
9044 // Block spacing support doesn't map directly to a single style property, so needs to be handled separately. |
|
9045 if (blockType?.supports?.spacing?.blockGap) { |
|
9046 supportKeys.push('blockGap'); |
|
9047 } |
|
9048 |
|
9049 // check for shadow support |
|
9050 if (blockType?.supports?.shadow) { |
|
9051 supportKeys.push('shadow'); |
|
9052 } |
|
9053 Object.keys(__EXPERIMENTAL_STYLE_PROPERTY).forEach(styleName => { |
|
9054 if (!__EXPERIMENTAL_STYLE_PROPERTY[styleName].support) { |
|
9055 return; |
|
9056 } |
|
9057 |
|
9058 // Opting out means that, for certain support keys like background color, |
|
9059 // blocks have to explicitly set the support value false. If the key is |
|
9060 // unset, we still enable it. |
|
9061 if (__EXPERIMENTAL_STYLE_PROPERTY[styleName].requiresOptOut) { |
|
9062 if (__EXPERIMENTAL_STYLE_PROPERTY[styleName].support[0] in blockType.supports && getValueFromObjectPath(blockType.supports, __EXPERIMENTAL_STYLE_PROPERTY[styleName].support) !== false) { |
|
9063 supportKeys.push(styleName); |
|
9064 return; |
|
9065 } |
|
9066 } |
|
9067 if (getValueFromObjectPath(blockType.supports, __EXPERIMENTAL_STYLE_PROPERTY[styleName].support, false)) { |
|
9068 supportKeys.push(styleName); |
|
9069 } |
|
9070 }); |
|
9071 return filterElementBlockSupports(supportKeys, name, element); |
|
9072 }, (state, name) => [state.blockTypes[name]]); |
|
9073 |
|
9074 /** |
|
9075 * Returns the bootstrapped block type metadata for a give block name. |
|
9076 * |
|
9077 * @param {Object} state Data state. |
|
9078 * @param {string} name Block name. |
|
9079 * |
|
9080 * @return {Object} Bootstrapped block type metadata for a block. |
|
9081 */ |
|
9082 function getBootstrappedBlockType(state, name) { |
|
9083 return state.bootstrappedBlockTypes[name]; |
|
9084 } |
|
9085 |
|
9086 /** |
|
9087 * Returns all the unprocessed (before applying the `registerBlockType` filter) |
|
9088 * block type settings as passed during block registration. |
|
9089 * |
|
9090 * @param {Object} state Data state. |
|
9091 * |
|
9092 * @return {Array} Unprocessed block type settings for all blocks. |
|
9093 */ |
|
9094 function getUnprocessedBlockTypes(state) { |
|
9095 return state.unprocessedBlockTypes; |
|
9096 } |
|
9097 |
|
9098 /** |
|
9099 * Returns all the block bindings sources registered. |
|
9100 * |
|
9101 * @param {Object} state Data state. |
|
9102 * |
|
9103 * @return {Object} All the registered sources and their properties. |
|
9104 */ |
|
9105 function getAllBlockBindingsSources(state) { |
|
9106 return state.blockBindingsSources; |
|
9107 } |
|
9108 |
|
9109 /** |
|
9110 * Returns a specific block bindings source. |
|
9111 * |
|
9112 * @param {Object} state Data state. |
|
9113 * @param {string} sourceName Name of the source to get. |
|
9114 * |
|
9115 * @return {Object} The specific block binding source and its properties. |
|
9116 */ |
|
9117 function getBlockBindingsSource(state, sourceName) { |
|
9118 return state.blockBindingsSources[sourceName]; |
|
9119 } |
|
9120 |
|
9121 ;// CONCATENATED MODULE: external ["wp","deprecated"] |
|
9122 const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"]; |
|
9123 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject); |
|
9124 ;// CONCATENATED MODULE: ./node_modules/is-plain-object/dist/is-plain-object.mjs |
|
9125 /*! |
|
9126 * is-plain-object <https://github.com/jonschlinkert/is-plain-object> |
|
9127 * |
|
9128 * Copyright (c) 2014-2017, Jon Schlinkert. |
|
9129 * Released under the MIT License. |
|
9130 */ |
|
9131 |
|
9132 function is_plain_object_isObject(o) { |
|
9133 return Object.prototype.toString.call(o) === '[object Object]'; |
|
9134 } |
|
9135 |
|
9136 function isPlainObject(o) { |
|
9137 var ctor,prot; |
|
9138 |
|
9139 if (is_plain_object_isObject(o) === false) return false; |
|
9140 |
|
9141 // If has modified constructor |
|
9142 ctor = o.constructor; |
|
9143 if (ctor === undefined) return true; |
|
9144 |
|
9145 // If has modified prototype |
|
9146 prot = ctor.prototype; |
|
9147 if (is_plain_object_isObject(prot) === false) return false; |
|
9148 |
|
9149 // If constructor does not have an Object-specific method |
|
9150 if (prot.hasOwnProperty('isPrototypeOf') === false) { |
|
9151 return false; |
|
9152 } |
|
9153 |
|
9154 // Most likely a plain Object |
|
9155 return true; |
|
9156 } |
|
9157 |
|
9158 |
|
9159 |
|
9160 // EXTERNAL MODULE: ./node_modules/react-is/index.js |
|
9161 var react_is = __webpack_require__(8529); |
|
9162 ;// CONCATENATED MODULE: external ["wp","hooks"] |
|
9163 const external_wp_hooks_namespaceObject = window["wp"]["hooks"]; |
|
9164 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/process-block-type.js |
|
9165 /** |
|
9166 * External dependencies |
|
9167 */ |
|
9168 |
|
9169 |
|
9170 |
|
9171 /** |
|
9172 * WordPress dependencies |
|
9173 */ |
|
9174 |
|
9175 |
|
9176 |
|
9177 /** |
|
9178 * Internal dependencies |
|
9179 */ |
|
9180 |
|
9181 |
|
9182 |
|
9183 /** @typedef {import('../api/registration').WPBlockType} WPBlockType */ |
|
9184 |
|
9185 const error = (...args) => window?.console?.error?.(...args); |
|
9186 const warn = (...args) => window?.console?.warn?.(...args); |
|
9187 |
|
9188 /** |
|
9189 * Mapping of legacy category slugs to their latest normal values, used to |
|
9190 * accommodate updates of the default set of block categories. |
|
9191 * |
|
9192 * @type {Record<string,string>} |
|
9193 */ |
|
9194 const LEGACY_CATEGORY_MAPPING = { |
|
9195 common: 'text', |
|
9196 formatting: 'text', |
|
9197 layout: 'design' |
|
9198 }; |
|
9199 |
|
9200 /** |
|
9201 * Merge block variations bootstrapped from the server and client. |
|
9202 * |
|
9203 * When a variation is registered in both places, its properties are merged. |
|
9204 * |
|
9205 * @param {Array} bootstrappedVariations - A block type variations from the server. |
|
9206 * @param {Array} clientVariations - A block type variations from the client. |
|
9207 * @return {Array} The merged array of block variations. |
|
9208 */ |
|
9209 function mergeBlockVariations(bootstrappedVariations = [], clientVariations = []) { |
|
9210 const result = [...bootstrappedVariations]; |
|
9211 clientVariations.forEach(clientVariation => { |
|
9212 const index = result.findIndex(bootstrappedVariation => bootstrappedVariation.name === clientVariation.name); |
|
9213 if (index !== -1) { |
|
9214 result[index] = { |
|
9215 ...result[index], |
|
9216 ...clientVariation |
|
9217 }; |
|
9218 } else { |
|
9219 result.push(clientVariation); |
|
9220 } |
|
9221 }); |
|
9222 return result; |
|
9223 } |
|
9224 |
|
9225 /** |
|
9226 * Takes the unprocessed block type settings, merges them with block type metadata |
|
9227 * and applies all the existing filters for the registered block type. |
|
9228 * Next, it validates all the settings and performs additional processing to the block type definition. |
|
9229 * |
|
9230 * @param {string} name Block name. |
|
9231 * @param {WPBlockType} blockSettings Unprocessed block type settings. |
|
9232 * |
|
9233 * @return {WPBlockType | undefined} The block, if it has been processed and can be registered; otherwise `undefined`. |
|
9234 */ |
|
9235 const processBlockType = (name, blockSettings) => ({ |
|
9236 select |
|
9237 }) => { |
|
9238 const bootstrappedBlockType = select.getBootstrappedBlockType(name); |
|
6798 const blockType = { |
9239 const blockType = { |
6799 name, |
9240 name, |
6800 icon: BLOCK_ICON_DEFAULT, |
9241 icon: BLOCK_ICON_DEFAULT, |
6801 keywords: [], |
9242 keywords: [], |
6802 attributes: {}, |
9243 attributes: {}, |
6803 providesContext: {}, |
9244 providesContext: {}, |
6804 usesContext: [], |
9245 usesContext: [], |
9246 selectors: {}, |
|
6805 supports: {}, |
9247 supports: {}, |
6806 styles: [], |
9248 styles: [], |
6807 variations: [], |
9249 blockHooks: {}, |
6808 save: () => null, |
9250 save: () => null, |
6809 ...(serverSideBlockDefinitions === null || serverSideBlockDefinitions === void 0 ? void 0 : serverSideBlockDefinitions[name]), |
9251 ...bootstrappedBlockType, |
6810 ...settings |
9252 ...blockSettings, |
9253 variations: mergeBlockVariations(bootstrappedBlockType?.variations, blockSettings?.variations) |
|
6811 }; |
9254 }; |
6812 |
9255 const settings = (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.registerBlockType', blockType, name, null); |
6813 (0,external_wp_data_namespaceObject.dispatch)(store).__experimentalRegisterBlockType(blockType); |
9256 if (settings.description && typeof settings.description !== 'string') { |
6814 |
9257 external_wp_deprecated_default()('Declaring non-string block descriptions', { |
6815 return (0,external_wp_data_namespaceObject.select)(store).getBlockType(name); |
9258 since: '6.2' |
6816 } |
9259 }); |
6817 /** |
9260 } |
6818 * Translates block settings provided with metadata using the i18n schema. |
9261 if (settings.deprecated) { |
6819 * |
9262 settings.deprecated = settings.deprecated.map(deprecation => Object.fromEntries(Object.entries( |
6820 * @param {string|string[]|Object[]} i18nSchema I18n schema for the block setting. |
9263 // Only keep valid deprecation keys. |
6821 * @param {string|string[]|Object[]} settingValue Value for the block setting. |
9264 (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.registerBlockType', |
6822 * @param {string} textdomain Textdomain to use with translations. |
9265 // Merge deprecation keys with pre-filter settings |
6823 * |
9266 // so that filters that depend on specific keys being |
6824 * @return {string|string[]|Object[]} Translated setting. |
9267 // present don't fail. |
6825 */ |
9268 { |
6826 |
9269 // Omit deprecation keys here so that deprecations |
6827 function translateBlockSettingUsingI18nSchema(i18nSchema, settingValue, textdomain) { |
9270 // can opt out of specific keys like "supports". |
6828 if ((0,external_lodash_namespaceObject.isString)(i18nSchema) && (0,external_lodash_namespaceObject.isString)(settingValue)) { |
9271 ...omit(blockType, DEPRECATED_ENTRY_KEYS), |
6829 // eslint-disable-next-line @wordpress/i18n-no-variables, @wordpress/i18n-text-domain |
9272 ...deprecation |
6830 return (0,external_wp_i18n_namespaceObject._x)(settingValue, i18nSchema, textdomain); |
9273 }, blockType.name, deprecation)).filter(([key]) => DEPRECATED_ENTRY_KEYS.includes(key)))); |
6831 } |
9274 } |
6832 |
9275 if (!isPlainObject(settings)) { |
6833 if ((0,external_lodash_namespaceObject.isArray)(i18nSchema) && !(0,external_lodash_namespaceObject.isEmpty)(i18nSchema) && (0,external_lodash_namespaceObject.isArray)(settingValue)) { |
9276 error('Block settings must be a valid object.'); |
6834 return settingValue.map(value => translateBlockSettingUsingI18nSchema(i18nSchema[0], value, textdomain)); |
9277 return; |
6835 } |
9278 } |
6836 |
9279 if (typeof settings.save !== 'function') { |
6837 if ((0,external_lodash_namespaceObject.isObject)(i18nSchema) && !(0,external_lodash_namespaceObject.isEmpty)(i18nSchema) && (0,external_lodash_namespaceObject.isObject)(settingValue)) { |
9280 error('The "save" property must be a valid function.'); |
6838 return Object.keys(settingValue).reduce((accumulator, key) => { |
9281 return; |
6839 if (!i18nSchema[key]) { |
9282 } |
6840 accumulator[key] = settingValue[key]; |
9283 if ('edit' in settings && !(0,react_is.isValidElementType)(settings.edit)) { |
6841 return accumulator; |
9284 error('The "edit" property must be a valid component.'); |
9285 return; |
|
9286 } |
|
9287 |
|
9288 // Canonicalize legacy categories to equivalent fallback. |
|
9289 if (LEGACY_CATEGORY_MAPPING.hasOwnProperty(settings.category)) { |
|
9290 settings.category = LEGACY_CATEGORY_MAPPING[settings.category]; |
|
9291 } |
|
9292 if ('category' in settings && !select.getCategories().some(({ |
|
9293 slug |
|
9294 }) => slug === settings.category)) { |
|
9295 warn('The block "' + name + '" is registered with an invalid category "' + settings.category + '".'); |
|
9296 delete settings.category; |
|
9297 } |
|
9298 if (!('title' in settings) || settings.title === '') { |
|
9299 error('The block "' + name + '" must have a title.'); |
|
9300 return; |
|
9301 } |
|
9302 if (typeof settings.title !== 'string') { |
|
9303 error('Block titles must be strings.'); |
|
9304 return; |
|
9305 } |
|
9306 settings.icon = normalizeIconObject(settings.icon); |
|
9307 if (!isValidIcon(settings.icon.src)) { |
|
9308 error('The icon passed is invalid. ' + 'The icon should be a string, an element, a function, or an object following the specifications documented in https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#icon-optional'); |
|
9309 return; |
|
9310 } |
|
9311 return settings; |
|
9312 }; |
|
9313 |
|
9314 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/actions.js |
|
9315 /** |
|
9316 * WordPress dependencies |
|
9317 */ |
|
9318 |
|
9319 |
|
9320 /** |
|
9321 * Internal dependencies |
|
9322 */ |
|
9323 |
|
9324 |
|
9325 /** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */ |
|
9326 /** @typedef {import('../api/registration').WPBlockType} WPBlockType */ |
|
9327 /** @typedef {import('./reducer').WPBlockCategory} WPBlockCategory */ |
|
9328 |
|
9329 /** |
|
9330 * Returns an action object used in signalling that block types have been added. |
|
9331 * Ignored from documentation as the recommended usage for this action through registerBlockType from @wordpress/blocks. |
|
9332 * |
|
9333 * @ignore |
|
9334 * |
|
9335 * @param {WPBlockType|WPBlockType[]} blockTypes Object or array of objects representing blocks to added. |
|
9336 * |
|
9337 * |
|
9338 * @return {Object} Action object. |
|
9339 */ |
|
9340 function addBlockTypes(blockTypes) { |
|
9341 return { |
|
9342 type: 'ADD_BLOCK_TYPES', |
|
9343 blockTypes: Array.isArray(blockTypes) ? blockTypes : [blockTypes] |
|
9344 }; |
|
9345 } |
|
9346 |
|
9347 /** |
|
9348 * Signals that all block types should be computed again. |
|
9349 * It uses stored unprocessed block types and all the most recent list of registered filters. |
|
9350 * |
|
9351 * It addresses the issue where third party block filters get registered after third party blocks. A sample sequence: |
|
9352 * 1. Filter A. |
|
9353 * 2. Block B. |
|
9354 * 3. Block C. |
|
9355 * 4. Filter D. |
|
9356 * 5. Filter E. |
|
9357 * 6. Block F. |
|
9358 * 7. Filter G. |
|
9359 * In this scenario some filters would not get applied for all blocks because they are registered too late. |
|
9360 */ |
|
9361 function reapplyBlockTypeFilters() { |
|
9362 return ({ |
|
9363 dispatch, |
|
9364 select |
|
9365 }) => { |
|
9366 const processedBlockTypes = []; |
|
9367 for (const [name, settings] of Object.entries(select.getUnprocessedBlockTypes())) { |
|
9368 const result = dispatch(processBlockType(name, settings)); |
|
9369 if (result) { |
|
9370 processedBlockTypes.push(result); |
|
6842 } |
9371 } |
6843 |
9372 } |
6844 accumulator[key] = translateBlockSettingUsingI18nSchema(i18nSchema[key], settingValue[key], textdomain); |
9373 if (!processedBlockTypes.length) { |
6845 return accumulator; |
9374 return; |
6846 }, {}); |
9375 } |
6847 } |
9376 dispatch.addBlockTypes(processedBlockTypes); |
6848 |
9377 }; |
6849 return settingValue; |
9378 } |
6850 } |
9379 function __experimentalReapplyBlockFilters() { |
6851 /** |
9380 external_wp_deprecated_default()('wp.data.dispatch( "core/blocks" ).__experimentalReapplyBlockFilters', { |
6852 * Registers a new block collection to group blocks in the same namespace in the inserter. |
9381 since: '6.4', |
6853 * |
9382 alternative: 'reapplyBlockFilters' |
6854 * @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace. |
9383 }); |
6855 * @param {Object} settings The block collection settings. |
9384 return reapplyBlockTypeFilters(); |
6856 * @param {string} settings.title The title to display in the block inserter. |
9385 } |
6857 * @param {Object} [settings.icon] The icon to display in the block inserter. |
9386 |
6858 */ |
9387 /** |
6859 |
9388 * Returns an action object used to remove a registered block type. |
6860 |
9389 * Ignored from documentation as the recommended usage for this action through unregisterBlockType from @wordpress/blocks. |
6861 function registerBlockCollection(namespace, _ref2) { |
9390 * |
6862 let { |
9391 * @ignore |
9392 * |
|
9393 * @param {string|string[]} names Block name or array of block names to be removed. |
|
9394 * |
|
9395 * |
|
9396 * @return {Object} Action object. |
|
9397 */ |
|
9398 function removeBlockTypes(names) { |
|
9399 return { |
|
9400 type: 'REMOVE_BLOCK_TYPES', |
|
9401 names: Array.isArray(names) ? names : [names] |
|
9402 }; |
|
9403 } |
|
9404 |
|
9405 /** |
|
9406 * Returns an action object used in signalling that new block styles have been added. |
|
9407 * Ignored from documentation as the recommended usage for this action through registerBlockStyle from @wordpress/blocks. |
|
9408 * |
|
9409 * @param {string|Array} blockNames Block names to register new styles for. |
|
9410 * @param {Array|Object} styles Block style object or array of block style objects. |
|
9411 * |
|
9412 * @ignore |
|
9413 * |
|
9414 * @return {Object} Action object. |
|
9415 */ |
|
9416 function addBlockStyles(blockNames, styles) { |
|
9417 return { |
|
9418 type: 'ADD_BLOCK_STYLES', |
|
9419 styles: Array.isArray(styles) ? styles : [styles], |
|
9420 blockNames: Array.isArray(blockNames) ? blockNames : [blockNames] |
|
9421 }; |
|
9422 } |
|
9423 |
|
9424 /** |
|
9425 * Returns an action object used in signalling that block styles have been removed. |
|
9426 * Ignored from documentation as the recommended usage for this action through unregisterBlockStyle from @wordpress/blocks. |
|
9427 * |
|
9428 * @ignore |
|
9429 * |
|
9430 * @param {string} blockName Block name. |
|
9431 * @param {Array|string} styleNames Block style names or array of block style names. |
|
9432 * |
|
9433 * @return {Object} Action object. |
|
9434 */ |
|
9435 function removeBlockStyles(blockName, styleNames) { |
|
9436 return { |
|
9437 type: 'REMOVE_BLOCK_STYLES', |
|
9438 styleNames: Array.isArray(styleNames) ? styleNames : [styleNames], |
|
9439 blockName |
|
9440 }; |
|
9441 } |
|
9442 |
|
9443 /** |
|
9444 * Returns an action object used in signalling that new block variations have been added. |
|
9445 * Ignored from documentation as the recommended usage for this action through registerBlockVariation from @wordpress/blocks. |
|
9446 * |
|
9447 * @ignore |
|
9448 * |
|
9449 * @param {string} blockName Block name. |
|
9450 * @param {WPBlockVariation|WPBlockVariation[]} variations Block variations. |
|
9451 * |
|
9452 * @return {Object} Action object. |
|
9453 */ |
|
9454 function addBlockVariations(blockName, variations) { |
|
9455 return { |
|
9456 type: 'ADD_BLOCK_VARIATIONS', |
|
9457 variations: Array.isArray(variations) ? variations : [variations], |
|
9458 blockName |
|
9459 }; |
|
9460 } |
|
9461 |
|
9462 /** |
|
9463 * Returns an action object used in signalling that block variations have been removed. |
|
9464 * Ignored from documentation as the recommended usage for this action through unregisterBlockVariation from @wordpress/blocks. |
|
9465 * |
|
9466 * @ignore |
|
9467 * |
|
9468 * @param {string} blockName Block name. |
|
9469 * @param {string|string[]} variationNames Block variation names. |
|
9470 * |
|
9471 * @return {Object} Action object. |
|
9472 */ |
|
9473 function removeBlockVariations(blockName, variationNames) { |
|
9474 return { |
|
9475 type: 'REMOVE_BLOCK_VARIATIONS', |
|
9476 variationNames: Array.isArray(variationNames) ? variationNames : [variationNames], |
|
9477 blockName |
|
9478 }; |
|
9479 } |
|
9480 |
|
9481 /** |
|
9482 * Returns an action object used to set the default block name. |
|
9483 * Ignored from documentation as the recommended usage for this action through setDefaultBlockName from @wordpress/blocks. |
|
9484 * |
|
9485 * @ignore |
|
9486 * |
|
9487 * @param {string} name Block name. |
|
9488 * |
|
9489 * @return {Object} Action object. |
|
9490 */ |
|
9491 function actions_setDefaultBlockName(name) { |
|
9492 return { |
|
9493 type: 'SET_DEFAULT_BLOCK_NAME', |
|
9494 name |
|
9495 }; |
|
9496 } |
|
9497 |
|
9498 /** |
|
9499 * Returns an action object used to set the name of the block used as a fallback |
|
9500 * for non-block content. |
|
9501 * Ignored from documentation as the recommended usage for this action through setFreeformContentHandlerName from @wordpress/blocks. |
|
9502 * |
|
9503 * @ignore |
|
9504 * |
|
9505 * @param {string} name Block name. |
|
9506 * |
|
9507 * @return {Object} Action object. |
|
9508 */ |
|
9509 function setFreeformFallbackBlockName(name) { |
|
9510 return { |
|
9511 type: 'SET_FREEFORM_FALLBACK_BLOCK_NAME', |
|
9512 name |
|
9513 }; |
|
9514 } |
|
9515 |
|
9516 /** |
|
9517 * Returns an action object used to set the name of the block used as a fallback |
|
9518 * for unregistered blocks. |
|
9519 * Ignored from documentation as the recommended usage for this action through setUnregisteredTypeHandlerName from @wordpress/blocks. |
|
9520 * |
|
9521 * @ignore |
|
9522 * |
|
9523 * @param {string} name Block name. |
|
9524 * |
|
9525 * @return {Object} Action object. |
|
9526 */ |
|
9527 function setUnregisteredFallbackBlockName(name) { |
|
9528 return { |
|
9529 type: 'SET_UNREGISTERED_FALLBACK_BLOCK_NAME', |
|
9530 name |
|
9531 }; |
|
9532 } |
|
9533 |
|
9534 /** |
|
9535 * Returns an action object used to set the name of the block used |
|
9536 * when grouping other blocks |
|
9537 * eg: in "Group/Ungroup" interactions |
|
9538 * Ignored from documentation as the recommended usage for this action through setGroupingBlockName from @wordpress/blocks. |
|
9539 * |
|
9540 * @ignore |
|
9541 * |
|
9542 * @param {string} name Block name. |
|
9543 * |
|
9544 * @return {Object} Action object. |
|
9545 */ |
|
9546 function actions_setGroupingBlockName(name) { |
|
9547 return { |
|
9548 type: 'SET_GROUPING_BLOCK_NAME', |
|
9549 name |
|
9550 }; |
|
9551 } |
|
9552 |
|
9553 /** |
|
9554 * Returns an action object used to set block categories. |
|
9555 * Ignored from documentation as the recommended usage for this action through setCategories from @wordpress/blocks. |
|
9556 * |
|
9557 * @ignore |
|
9558 * |
|
9559 * @param {WPBlockCategory[]} categories Block categories. |
|
9560 * |
|
9561 * @return {Object} Action object. |
|
9562 */ |
|
9563 function setCategories(categories) { |
|
9564 return { |
|
9565 type: 'SET_CATEGORIES', |
|
9566 categories |
|
9567 }; |
|
9568 } |
|
9569 |
|
9570 /** |
|
9571 * Returns an action object used to update a category. |
|
9572 * Ignored from documentation as the recommended usage for this action through updateCategory from @wordpress/blocks. |
|
9573 * |
|
9574 * @ignore |
|
9575 * |
|
9576 * @param {string} slug Block category slug. |
|
9577 * @param {Object} category Object containing the category properties that should be updated. |
|
9578 * |
|
9579 * @return {Object} Action object. |
|
9580 */ |
|
9581 function updateCategory(slug, category) { |
|
9582 return { |
|
9583 type: 'UPDATE_CATEGORY', |
|
9584 slug, |
|
9585 category |
|
9586 }; |
|
9587 } |
|
9588 |
|
9589 /** |
|
9590 * Returns an action object used to add block collections |
|
9591 * Ignored from documentation as the recommended usage for this action through registerBlockCollection from @wordpress/blocks. |
|
9592 * |
|
9593 * @ignore |
|
9594 * |
|
9595 * @param {string} namespace The namespace of the blocks to put in the collection |
|
9596 * @param {string} title The title to display in the block inserter |
|
9597 * @param {Object} icon (optional) The icon to display in the block inserter |
|
9598 * |
|
9599 * @return {Object} Action object. |
|
9600 */ |
|
9601 function addBlockCollection(namespace, title, icon) { |
|
9602 return { |
|
9603 type: 'ADD_BLOCK_COLLECTION', |
|
9604 namespace, |
|
6863 title, |
9605 title, |
6864 icon |
9606 icon |
6865 } = _ref2; |
9607 }; |
6866 (0,external_wp_data_namespaceObject.dispatch)(store).addBlockCollection(namespace, title, icon); |
9608 } |
6867 } |
9609 |
6868 /** |
9610 /** |
6869 * Unregisters a block collection |
9611 * Returns an action object used to remove block collections |
6870 * |
9612 * Ignored from documentation as the recommended usage for this action through unregisterBlockCollection from @wordpress/blocks. |
6871 * @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace |
9613 * |
6872 * |
9614 * @ignore |
6873 */ |
9615 * |
6874 |
9616 * @param {string} namespace The namespace of the blocks to put in the collection |
6875 function unregisterBlockCollection(namespace) { |
9617 * |
6876 dispatch(blocksStore).removeBlockCollection(namespace); |
9618 * @return {Object} Action object. |
6877 } |
9619 */ |
6878 /** |
9620 function removeBlockCollection(namespace) { |
6879 * Unregisters a block. |
9621 return { |
6880 * |
9622 type: 'REMOVE_BLOCK_COLLECTION', |
6881 * @param {string} name Block name. |
9623 namespace |
6882 * |
9624 }; |
6883 * @return {?WPBlockType} The previous block value, if it has been successfully |
9625 } |
6884 * unregistered; otherwise `undefined`. |
9626 |
6885 */ |
9627 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/private-actions.js |
6886 |
9628 /** |
6887 function unregisterBlockType(name) { |
9629 * Internal dependencies |
6888 const oldBlock = (0,external_wp_data_namespaceObject.select)(store).getBlockType(name); |
9630 */ |
6889 |
9631 |
6890 if (!oldBlock) { |
9632 |
6891 console.error('Block "' + name + '" is not registered.'); |
9633 /** @typedef {import('../api/registration').WPBlockType} WPBlockType */ |
6892 return; |
9634 |
6893 } |
9635 /** |
6894 |
9636 * Add bootstrapped block type metadata to the store. These metadata usually come from |
6895 (0,external_wp_data_namespaceObject.dispatch)(store).removeBlockTypes(name); |
9637 * the `block.json` file and are either statically boostrapped from the server, or |
6896 return oldBlock; |
9638 * passed as the `metadata` parameter to the `registerBlockType` function. |
6897 } |
9639 * |
6898 /** |
9640 * @param {string} name Block name. |
6899 * Assigns name of block for handling non-block content. |
9641 * @param {WPBlockType} blockType Block type metadata. |
6900 * |
9642 */ |
6901 * @param {string} blockName Block name. |
9643 function addBootstrappedBlockType(name, blockType) { |
6902 */ |
9644 return { |
6903 |
9645 type: 'ADD_BOOTSTRAPPED_BLOCK_TYPE', |
6904 function setFreeformContentHandlerName(blockName) { |
9646 name, |
6905 (0,external_wp_data_namespaceObject.dispatch)(store).setFreeformFallbackBlockName(blockName); |
9647 blockType |
6906 } |
9648 }; |
6907 /** |
9649 } |
6908 * Retrieves name of block handling non-block content, or undefined if no |
9650 |
6909 * handler has been defined. |
9651 /** |
6910 * |
9652 * Add unprocessed block type settings to the store. These data are passed as the |
6911 * @return {?string} Block name. |
9653 * `settings` parameter to the client-side `registerBlockType` function. |
6912 */ |
9654 * |
6913 |
9655 * @param {string} name Block name. |
6914 function getFreeformContentHandlerName() { |
9656 * @param {WPBlockType} blockType Unprocessed block type settings. |
6915 return (0,external_wp_data_namespaceObject.select)(store).getFreeformFallbackBlockName(); |
9657 */ |
6916 } |
9658 function addUnprocessedBlockType(name, blockType) { |
6917 /** |
9659 return ({ |
6918 * Retrieves name of block used for handling grouping interactions. |
9660 dispatch |
6919 * |
9661 }) => { |
6920 * @return {?string} Block name. |
9662 dispatch({ |
6921 */ |
9663 type: 'ADD_UNPROCESSED_BLOCK_TYPE', |
6922 |
9664 name, |
6923 function registration_getGroupingBlockName() { |
9665 blockType |
6924 return (0,external_wp_data_namespaceObject.select)(store).getGroupingBlockName(); |
9666 }); |
6925 } |
9667 const processedBlockType = dispatch(processBlockType(name, blockType)); |
6926 /** |
9668 if (!processedBlockType) { |
6927 * Assigns name of block handling unregistered block types. |
9669 return; |
6928 * |
9670 } |
6929 * @param {string} blockName Block name. |
9671 dispatch.addBlockTypes(processedBlockType); |
6930 */ |
9672 }; |
6931 |
9673 } |
6932 function setUnregisteredTypeHandlerName(blockName) { |
9674 |
6933 (0,external_wp_data_namespaceObject.dispatch)(store).setUnregisteredFallbackBlockName(blockName); |
9675 /** |
6934 } |
9676 * Register new block bindings source. |
6935 /** |
9677 * |
6936 * Retrieves name of block handling unregistered block types, or undefined if no |
9678 * @param {string} source Name of the source to register. |
6937 * handler has been defined. |
9679 */ |
6938 * |
9680 function registerBlockBindingsSource(source) { |
6939 * @return {?string} Block name. |
9681 return { |
6940 */ |
9682 type: 'REGISTER_BLOCK_BINDINGS_SOURCE', |
6941 |
9683 sourceName: source.name, |
6942 function getUnregisteredTypeHandlerName() { |
9684 sourceLabel: source.label, |
6943 return (0,external_wp_data_namespaceObject.select)(store).getUnregisteredFallbackBlockName(); |
9685 getValue: source.getValue, |
6944 } |
9686 setValue: source.setValue, |
6945 /** |
9687 setValues: source.setValues, |
6946 * Assigns the default block name. |
9688 getPlaceholder: source.getPlaceholder, |
6947 * |
9689 canUserEditValue: source.canUserEditValue |
6948 * @param {string} name Block name. |
9690 }; |
6949 */ |
9691 } |
6950 |
9692 |
6951 function setDefaultBlockName(name) { |
9693 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/constants.js |
6952 (0,external_wp_data_namespaceObject.dispatch)(store).setDefaultBlockName(name); |
9694 const STORE_NAME = 'core/blocks'; |
6953 } |
9695 |
6954 /** |
9696 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/index.js |
6955 * Assigns name of block for handling block grouping interactions. |
9697 /** |
6956 * |
9698 * WordPress dependencies |
6957 * @param {string} name Block name. |
9699 */ |
6958 */ |
9700 |
6959 |
9701 |
6960 function setGroupingBlockName(name) { |
9702 /** |
6961 (0,external_wp_data_namespaceObject.dispatch)(store).setGroupingBlockName(name); |
9703 * Internal dependencies |
6962 } |
9704 */ |
6963 /** |
9705 |
6964 * Retrieves the default block name. |
9706 |
6965 * |
9707 |
6966 * @return {?string} Block name. |
9708 |
6967 */ |
9709 |
6968 |
9710 |
6969 function registration_getDefaultBlockName() { |
9711 |
6970 return (0,external_wp_data_namespaceObject.select)(store).getDefaultBlockName(); |
9712 |
6971 } |
9713 /** |
6972 /** |
9714 * Store definition for the blocks namespace. |
6973 * Returns a registered block type. |
9715 * |
6974 * |
9716 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore |
6975 * @param {string} name Block name. |
9717 * |
6976 * |
9718 * @type {Object} |
6977 * @return {?Object} Block type. |
9719 */ |
6978 */ |
9720 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { |
6979 |
9721 reducer: reducer, |
6980 function registration_getBlockType(name) { |
9722 selectors: selectors_namespaceObject, |
6981 var _select; |
9723 actions: actions_namespaceObject |
6982 |
9724 }); |
6983 return (_select = (0,external_wp_data_namespaceObject.select)(store)) === null || _select === void 0 ? void 0 : _select.getBlockType(name); |
9725 (0,external_wp_data_namespaceObject.register)(store); |
6984 } |
9726 unlock(store).registerPrivateSelectors(private_selectors_namespaceObject); |
6985 /** |
9727 unlock(store).registerPrivateActions(private_actions_namespaceObject); |
6986 * Returns all registered blocks. |
9728 |
6987 * |
9729 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/native.js |
6988 * @return {Array} Block settings. |
9730 const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto); |
6989 */ |
9731 /* harmony default export */ const esm_browser_native = ({ |
6990 |
9732 randomUUID |
6991 function registration_getBlockTypes() { |
9733 }); |
6992 return (0,external_wp_data_namespaceObject.select)(store).getBlockTypes(); |
|
6993 } |
|
6994 /** |
|
6995 * Returns the block support value for a feature, if defined. |
|
6996 * |
|
6997 * @param {(string|Object)} nameOrType Block name or type object |
|
6998 * @param {string} feature Feature to retrieve |
|
6999 * @param {*} defaultSupports Default value to return if not |
|
7000 * explicitly defined |
|
7001 * |
|
7002 * @return {?*} Block support value |
|
7003 */ |
|
7004 |
|
7005 function registration_getBlockSupport(nameOrType, feature, defaultSupports) { |
|
7006 return (0,external_wp_data_namespaceObject.select)(store).getBlockSupport(nameOrType, feature, defaultSupports); |
|
7007 } |
|
7008 /** |
|
7009 * Returns true if the block defines support for a feature, or false otherwise. |
|
7010 * |
|
7011 * @param {(string|Object)} nameOrType Block name or type object. |
|
7012 * @param {string} feature Feature to test. |
|
7013 * @param {boolean} defaultSupports Whether feature is supported by |
|
7014 * default if not explicitly defined. |
|
7015 * |
|
7016 * @return {boolean} Whether block supports feature. |
|
7017 */ |
|
7018 |
|
7019 function registration_hasBlockSupport(nameOrType, feature, defaultSupports) { |
|
7020 return (0,external_wp_data_namespaceObject.select)(store).hasBlockSupport(nameOrType, feature, defaultSupports); |
|
7021 } |
|
7022 /** |
|
7023 * Determines whether or not the given block is a reusable block. This is a |
|
7024 * special block type that is used to point to a global block stored via the |
|
7025 * API. |
|
7026 * |
|
7027 * @param {Object} blockOrType Block or Block Type to test. |
|
7028 * |
|
7029 * @return {boolean} Whether the given block is a reusable block. |
|
7030 */ |
|
7031 |
|
7032 function isReusableBlock(blockOrType) { |
|
7033 return (blockOrType === null || blockOrType === void 0 ? void 0 : blockOrType.name) === 'core/block'; |
|
7034 } |
|
7035 /** |
|
7036 * Determines whether or not the given block is a template part. This is a |
|
7037 * special block type that allows composing a page template out of reusable |
|
7038 * design elements. |
|
7039 * |
|
7040 * @param {Object} blockOrType Block or Block Type to test. |
|
7041 * |
|
7042 * @return {boolean} Whether the given block is a template part. |
|
7043 */ |
|
7044 |
|
7045 function isTemplatePart(blockOrType) { |
|
7046 return blockOrType.name === 'core/template-part'; |
|
7047 } |
|
7048 /** |
|
7049 * Returns an array with the child blocks of a given block. |
|
7050 * |
|
7051 * @param {string} blockName Name of block (example: “latest-posts”). |
|
7052 * |
|
7053 * @return {Array} Array of child block names. |
|
7054 */ |
|
7055 |
|
7056 const registration_getChildBlockNames = blockName => { |
|
7057 return (0,external_wp_data_namespaceObject.select)(store).getChildBlockNames(blockName); |
|
7058 }; |
|
7059 /** |
|
7060 * Returns a boolean indicating if a block has child blocks or not. |
|
7061 * |
|
7062 * @param {string} blockName Name of block (example: “latest-posts”). |
|
7063 * |
|
7064 * @return {boolean} True if a block contains child blocks and false otherwise. |
|
7065 */ |
|
7066 |
|
7067 const registration_hasChildBlocks = blockName => { |
|
7068 return (0,external_wp_data_namespaceObject.select)(store).hasChildBlocks(blockName); |
|
7069 }; |
|
7070 /** |
|
7071 * Returns a boolean indicating if a block has at least one child block with inserter support. |
|
7072 * |
|
7073 * @param {string} blockName Block type name. |
|
7074 * |
|
7075 * @return {boolean} True if a block contains at least one child blocks with inserter support |
|
7076 * and false otherwise. |
|
7077 */ |
|
7078 |
|
7079 const registration_hasChildBlocksWithInserterSupport = blockName => { |
|
7080 return (0,external_wp_data_namespaceObject.select)(store).hasChildBlocksWithInserterSupport(blockName); |
|
7081 }; |
|
7082 /** |
|
7083 * Registers a new block style variation for the given block. |
|
7084 * |
|
7085 * @param {string} blockName Name of block (example: “core/latest-posts”). |
|
7086 * @param {Object} styleVariation Object containing `name` which is the class name applied to the block and `label` which identifies the variation to the user. |
|
7087 */ |
|
7088 |
|
7089 const registerBlockStyle = (blockName, styleVariation) => { |
|
7090 (0,external_wp_data_namespaceObject.dispatch)(store).addBlockStyles(blockName, styleVariation); |
|
7091 }; |
|
7092 /** |
|
7093 * Unregisters a block style variation for the given block. |
|
7094 * |
|
7095 * @param {string} blockName Name of block (example: “core/latest-posts”). |
|
7096 * @param {string} styleVariationName Name of class applied to the block. |
|
7097 */ |
|
7098 |
|
7099 const unregisterBlockStyle = (blockName, styleVariationName) => { |
|
7100 (0,external_wp_data_namespaceObject.dispatch)(store).removeBlockStyles(blockName, styleVariationName); |
|
7101 }; |
|
7102 /** |
|
7103 * Returns an array with the variations of a given block type. |
|
7104 * |
|
7105 * @param {string} blockName Name of block (example: “core/columns”). |
|
7106 * @param {WPBlockVariationScope} [scope] Block variation scope name. |
|
7107 * |
|
7108 * @return {(WPBlockVariation[]|void)} Block variations. |
|
7109 */ |
|
7110 |
|
7111 const registration_getBlockVariations = (blockName, scope) => { |
|
7112 return (0,external_wp_data_namespaceObject.select)(store).getBlockVariations(blockName, scope); |
|
7113 }; |
|
7114 /** |
|
7115 * Registers a new block variation for the given block type. |
|
7116 * |
|
7117 * @param {string} blockName Name of the block (example: “core/columns”). |
|
7118 * @param {WPBlockVariation} variation Object describing a block variation. |
|
7119 */ |
|
7120 |
|
7121 const registerBlockVariation = (blockName, variation) => { |
|
7122 (0,external_wp_data_namespaceObject.dispatch)(store).addBlockVariations(blockName, variation); |
|
7123 }; |
|
7124 /** |
|
7125 * Unregisters a block variation defined for the given block type. |
|
7126 * |
|
7127 * @param {string} blockName Name of the block (example: “core/columns”). |
|
7128 * @param {string} variationName Name of the variation defined for the block. |
|
7129 */ |
|
7130 |
|
7131 const unregisterBlockVariation = (blockName, variationName) => { |
|
7132 (0,external_wp_data_namespaceObject.dispatch)(store).removeBlockVariations(blockName, variationName); |
|
7133 }; |
|
7134 |
|
7135 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js |
9734 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js |
7136 // Unique ID creation requires a high quality random # generator. In the browser we therefore |
9735 // Unique ID creation requires a high quality random # generator. In the browser we therefore |
7137 // require the crypto API and do not support built-in fallback to lower quality random number |
9736 // require the crypto API and do not support built-in fallback to lower quality random number |
7138 // generators (like Math.random()). |
9737 // generators (like Math.random()). |
7139 var getRandomValues; |
9738 let getRandomValues; |
7140 var rnds8 = new Uint8Array(16); |
9739 const rnds8 = new Uint8Array(16); |
7141 function rng() { |
9740 function rng() { |
7142 // lazy load so that environments that need to polyfill have a chance to do so |
9741 // lazy load so that environments that need to polyfill have a chance to do so |
7143 if (!getRandomValues) { |
9742 if (!getRandomValues) { |
7144 // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also, |
9743 // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. |
7145 // find the complete implementation of crypto (msCrypto) on IE11. |
9744 getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto); |
7146 getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto); |
|
7147 |
9745 |
7148 if (!getRandomValues) { |
9746 if (!getRandomValues) { |
7149 throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported'); |
9747 throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported'); |
7150 } |
9748 } |
7151 } |
9749 } |
7152 |
9750 |
7153 return getRandomValues(rnds8); |
9751 return getRandomValues(rnds8); |
7154 } |
9752 } |
7155 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/regex.js |
|
7156 /* harmony default export */ var regex = (/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i); |
|
7157 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/validate.js |
|
7158 |
|
7159 |
|
7160 function validate(uuid) { |
|
7161 return typeof uuid === 'string' && regex.test(uuid); |
|
7162 } |
|
7163 |
|
7164 /* harmony default export */ var esm_browser_validate = (validate); |
|
7165 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js |
9753 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js |
7166 |
9754 |
7167 /** |
9755 /** |
7168 * Convert array of 16 byte values to UUID string format of the form: |
9756 * Convert array of 16 byte values to UUID string format of the form: |
7169 * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX |
9757 * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX |
7170 */ |
9758 */ |
7171 |
9759 |
7172 var byteToHex = []; |
9760 const byteToHex = []; |
7173 |
9761 |
7174 for (var stringify_i = 0; stringify_i < 256; ++stringify_i) { |
9762 for (let i = 0; i < 256; ++i) { |
7175 byteToHex.push((stringify_i + 0x100).toString(16).substr(1)); |
9763 byteToHex.push((i + 0x100).toString(16).slice(1)); |
7176 } |
9764 } |
7177 |
9765 |
7178 function stringify(arr) { |
9766 function unsafeStringify(arr, offset = 0) { |
7179 var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; |
|
7180 // Note: Be careful editing this code! It's been tuned for performance |
9767 // Note: Be careful editing this code! It's been tuned for performance |
7181 // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 |
9768 // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 |
7182 var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one |
9769 return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]; |
9770 } |
|
9771 |
|
9772 function stringify(arr, offset = 0) { |
|
9773 const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one |
|
7183 // of the following: |
9774 // of the following: |
7184 // - One or more input array values don't map to a hex octet (leading to |
9775 // - One or more input array values don't map to a hex octet (leading to |
7185 // "undefined" in the uuid) |
9776 // "undefined" in the uuid) |
7186 // - Invalid input values for the RFC `version` or `variant` fields |
9777 // - Invalid input values for the RFC `version` or `variant` fields |
7187 |
9778 |
7188 if (!esm_browser_validate(uuid)) { |
9779 if (!validate(uuid)) { |
7189 throw TypeError('Stringified UUID is invalid'); |
9780 throw TypeError('Stringified UUID is invalid'); |
7190 } |
9781 } |
7191 |
9782 |
7192 return uuid; |
9783 return uuid; |
7193 } |
9784 } |
7194 |
9785 |
7195 /* harmony default export */ var esm_browser_stringify = (stringify); |
9786 /* harmony default export */ const esm_browser_stringify = ((/* unused pure expression or super */ null && (stringify))); |
7196 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js |
9787 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js |
7197 |
9788 |
7198 |
9789 |
7199 |
9790 |
9791 |
|
7200 function v4(options, buf, offset) { |
9792 function v4(options, buf, offset) { |
9793 if (esm_browser_native.randomUUID && !buf && !options) { |
|
9794 return esm_browser_native.randomUUID(); |
|
9795 } |
|
9796 |
|
7201 options = options || {}; |
9797 options = options || {}; |
7202 var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` |
9798 const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` |
7203 |
9799 |
7204 rnds[6] = rnds[6] & 0x0f | 0x40; |
9800 rnds[6] = rnds[6] & 0x0f | 0x40; |
7205 rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided |
9801 rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided |
7206 |
9802 |
7207 if (buf) { |
9803 if (buf) { |
7208 offset = offset || 0; |
9804 offset = offset || 0; |
7209 |
9805 |
7210 for (var i = 0; i < 16; ++i) { |
9806 for (let i = 0; i < 16; ++i) { |
7211 buf[offset + i] = rnds[i]; |
9807 buf[offset + i] = rnds[i]; |
7212 } |
9808 } |
7213 |
9809 |
7214 return buf; |
9810 return buf; |
7215 } |
9811 } |
7216 |
9812 |
7217 return esm_browser_stringify(rnds); |
9813 return unsafeStringify(rnds); |
7218 } |
9814 } |
7219 |
9815 |
7220 /* harmony default export */ var esm_browser_v4 = (v4); |
9816 /* harmony default export */ const esm_browser_v4 = (v4); |
7221 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/factory.js |
9817 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/factory.js |
7222 /** |
9818 /** |
7223 * External dependencies |
9819 * External dependencies |
7224 */ |
9820 */ |
7225 |
9821 |
7242 * @param {Object} attributes Block attributes. |
9838 * @param {Object} attributes Block attributes. |
7243 * @param {?Array} innerBlocks Nested blocks. |
9839 * @param {?Array} innerBlocks Nested blocks. |
7244 * |
9840 * |
7245 * @return {Object} Block object. |
9841 * @return {Object} Block object. |
7246 */ |
9842 */ |
7247 |
9843 function createBlock(name, attributes = {}, innerBlocks = []) { |
7248 function createBlock(name) { |
|
7249 let attributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
7250 let innerBlocks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; |
|
7251 |
|
7252 const sanitizedAttributes = __experimentalSanitizeBlockAttributes(name, attributes); |
9844 const sanitizedAttributes = __experimentalSanitizeBlockAttributes(name, attributes); |
7253 |
9845 const clientId = esm_browser_v4(); |
7254 const clientId = esm_browser_v4(); // Blocks are stored with a unique ID, the assigned type name, the block |
9846 |
9847 // Blocks are stored with a unique ID, the assigned type name, the block |
|
7255 // attributes, and their inner blocks. |
9848 // attributes, and their inner blocks. |
7256 |
|
7257 return { |
9849 return { |
7258 clientId, |
9850 clientId, |
7259 name, |
9851 name, |
7260 isValid: true, |
9852 isValid: true, |
7261 attributes: sanitizedAttributes, |
9853 attributes: sanitizedAttributes, |
7262 innerBlocks |
9854 innerBlocks |
7263 }; |
9855 }; |
7264 } |
9856 } |
9857 |
|
7265 /** |
9858 /** |
7266 * Given an array of InnerBlocks templates or Block Objects, |
9859 * Given an array of InnerBlocks templates or Block Objects, |
7267 * returns an array of created Blocks from them. |
9860 * returns an array of created Blocks from them. |
7268 * It handles the case of having InnerBlocks as Blocks by |
9861 * It handles the case of having InnerBlocks as Blocks by |
7269 * converting them to the proper format to continue recursively. |
9862 * converting them to the proper format to continue recursively. |
7270 * |
9863 * |
7271 * @param {Array} innerBlocksOrTemplate Nested blocks or InnerBlocks templates. |
9864 * @param {Array} innerBlocksOrTemplate Nested blocks or InnerBlocks templates. |
7272 * |
9865 * |
7273 * @return {Object[]} Array of Block objects. |
9866 * @return {Object[]} Array of Block objects. |
7274 */ |
9867 */ |
7275 |
9868 function createBlocksFromInnerBlocksTemplate(innerBlocksOrTemplate = []) { |
7276 function createBlocksFromInnerBlocksTemplate() { |
|
7277 let innerBlocksOrTemplate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
|
7278 return innerBlocksOrTemplate.map(innerBlock => { |
9869 return innerBlocksOrTemplate.map(innerBlock => { |
7279 const innerBlockTemplate = Array.isArray(innerBlock) ? innerBlock : [innerBlock.name, innerBlock.attributes, innerBlock.innerBlocks]; |
9870 const innerBlockTemplate = Array.isArray(innerBlock) ? innerBlock : [innerBlock.name, innerBlock.attributes, innerBlock.innerBlocks]; |
7280 const [name, attributes, innerBlocks = []] = innerBlockTemplate; |
9871 const [name, attributes, innerBlocks = []] = innerBlockTemplate; |
7281 return createBlock(name, attributes, createBlocksFromInnerBlocksTemplate(innerBlocks)); |
9872 return createBlock(name, attributes, createBlocksFromInnerBlocksTemplate(innerBlocks)); |
7282 }); |
9873 }); |
7283 } |
9874 } |
9875 |
|
7284 /** |
9876 /** |
7285 * Given a block object, returns a copy of the block object while sanitizing its attributes, |
9877 * Given a block object, returns a copy of the block object while sanitizing its attributes, |
7286 * optionally merging new attributes and/or replacing its inner blocks. |
9878 * optionally merging new attributes and/or replacing its inner blocks. |
7287 * |
9879 * |
7288 * @param {Object} block Block instance. |
9880 * @param {Object} block Block instance. |
7289 * @param {Object} mergeAttributes Block attributes. |
9881 * @param {Object} mergeAttributes Block attributes. |
7290 * @param {?Array} newInnerBlocks Nested blocks. |
9882 * @param {?Array} newInnerBlocks Nested blocks. |
7291 * |
9883 * |
7292 * @return {Object} A cloned block. |
9884 * @return {Object} A cloned block. |
7293 */ |
9885 */ |
7294 |
9886 function __experimentalCloneSanitizedBlock(block, mergeAttributes = {}, newInnerBlocks) { |
7295 function __experimentalCloneSanitizedBlock(block) { |
|
7296 let mergeAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
7297 let newInnerBlocks = arguments.length > 2 ? arguments[2] : undefined; |
|
7298 const clientId = esm_browser_v4(); |
9887 const clientId = esm_browser_v4(); |
7299 |
9888 const sanitizedAttributes = __experimentalSanitizeBlockAttributes(block.name, { |
7300 const sanitizedAttributes = __experimentalSanitizeBlockAttributes(block.name, { ...block.attributes, |
9889 ...block.attributes, |
7301 ...mergeAttributes |
9890 ...mergeAttributes |
7302 }); |
9891 }); |
7303 |
9892 return { |
7304 return { ...block, |
9893 ...block, |
7305 clientId, |
9894 clientId, |
7306 attributes: sanitizedAttributes, |
9895 attributes: sanitizedAttributes, |
7307 innerBlocks: newInnerBlocks || block.innerBlocks.map(innerBlock => __experimentalCloneSanitizedBlock(innerBlock)) |
9896 innerBlocks: newInnerBlocks || block.innerBlocks.map(innerBlock => __experimentalCloneSanitizedBlock(innerBlock)) |
7308 }; |
9897 }; |
7309 } |
9898 } |
9899 |
|
7310 /** |
9900 /** |
7311 * Given a block object, returns a copy of the block object, |
9901 * Given a block object, returns a copy of the block object, |
7312 * optionally merging new attributes and/or replacing its inner blocks. |
9902 * optionally merging new attributes and/or replacing its inner blocks. |
7313 * |
9903 * |
7314 * @param {Object} block Block instance. |
9904 * @param {Object} block Block instance. |
7315 * @param {Object} mergeAttributes Block attributes. |
9905 * @param {Object} mergeAttributes Block attributes. |
7316 * @param {?Array} newInnerBlocks Nested blocks. |
9906 * @param {?Array} newInnerBlocks Nested blocks. |
7317 * |
9907 * |
7318 * @return {Object} A cloned block. |
9908 * @return {Object} A cloned block. |
7319 */ |
9909 */ |
7320 |
9910 function cloneBlock(block, mergeAttributes = {}, newInnerBlocks) { |
7321 function cloneBlock(block) { |
|
7322 let mergeAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
7323 let newInnerBlocks = arguments.length > 2 ? arguments[2] : undefined; |
|
7324 const clientId = esm_browser_v4(); |
9911 const clientId = esm_browser_v4(); |
7325 return { ...block, |
9912 return { |
9913 ...block, |
|
7326 clientId, |
9914 clientId, |
7327 attributes: { ...block.attributes, |
9915 attributes: { |
9916 ...block.attributes, |
|
7328 ...mergeAttributes |
9917 ...mergeAttributes |
7329 }, |
9918 }, |
7330 innerBlocks: newInnerBlocks || block.innerBlocks.map(innerBlock => cloneBlock(innerBlock)) |
9919 innerBlocks: newInnerBlocks || block.innerBlocks.map(innerBlock => cloneBlock(innerBlock)) |
7331 }; |
9920 }; |
7332 } |
9921 } |
9922 |
|
7333 /** |
9923 /** |
7334 * Returns a boolean indicating whether a transform is possible based on |
9924 * Returns a boolean indicating whether a transform is possible based on |
7335 * various bits of context. |
9925 * various bits of context. |
7336 * |
9926 * |
7337 * @param {Object} transform The transform object to validate. |
9927 * @param {Object} transform The transform object to validate. |
7338 * @param {string} direction Is this a 'from' or 'to' transform. |
9928 * @param {string} direction Is this a 'from' or 'to' transform. |
7339 * @param {Array} blocks The blocks to transform from. |
9929 * @param {Array} blocks The blocks to transform from. |
7340 * |
9930 * |
7341 * @return {boolean} Is the transform possible? |
9931 * @return {boolean} Is the transform possible? |
7342 */ |
9932 */ |
7343 |
|
7344 const isPossibleTransformForSource = (transform, direction, blocks) => { |
9933 const isPossibleTransformForSource = (transform, direction, blocks) => { |
7345 if ((0,external_lodash_namespaceObject.isEmpty)(blocks)) { |
9934 if (!blocks.length) { |
7346 return false; |
9935 return false; |
7347 } // If multiple blocks are selected, only multi block transforms |
9936 } |
9937 |
|
9938 // If multiple blocks are selected, only multi block transforms |
|
7348 // or wildcard transforms are allowed. |
9939 // or wildcard transforms are allowed. |
7349 |
|
7350 |
|
7351 const isMultiBlock = blocks.length > 1; |
9940 const isMultiBlock = blocks.length > 1; |
7352 const firstBlockName = (0,external_lodash_namespaceObject.first)(blocks).name; |
9941 const firstBlockName = blocks[0].name; |
7353 const isValidForMultiBlocks = isWildcardBlockTransform(transform) || !isMultiBlock || transform.isMultiBlock; |
9942 const isValidForMultiBlocks = isWildcardBlockTransform(transform) || !isMultiBlock || transform.isMultiBlock; |
7354 |
|
7355 if (!isValidForMultiBlocks) { |
9943 if (!isValidForMultiBlocks) { |
7356 return false; |
9944 return false; |
7357 } // Check non-wildcard transforms to ensure that transform is valid |
9945 } |
9946 |
|
9947 // Check non-wildcard transforms to ensure that transform is valid |
|
7358 // for a block selection of multiple blocks of different types. |
9948 // for a block selection of multiple blocks of different types. |
7359 |
9949 if (!isWildcardBlockTransform(transform) && !blocks.every(block => block.name === firstBlockName)) { |
7360 |
|
7361 if (!isWildcardBlockTransform(transform) && !(0,external_lodash_namespaceObject.every)(blocks, { |
|
7362 name: firstBlockName |
|
7363 })) { |
|
7364 return false; |
9950 return false; |
7365 } // Only consider 'block' type transforms as valid. |
9951 } |
7366 |
9952 |
7367 |
9953 // Only consider 'block' type transforms as valid. |
7368 const isBlockType = transform.type === 'block'; |
9954 const isBlockType = transform.type === 'block'; |
7369 |
|
7370 if (!isBlockType) { |
9955 if (!isBlockType) { |
7371 return false; |
9956 return false; |
7372 } // Check if the transform's block name matches the source block (or is a wildcard) |
9957 } |
9958 |
|
9959 // Check if the transform's block name matches the source block (or is a wildcard) |
|
7373 // only if this is a transform 'from'. |
9960 // only if this is a transform 'from'. |
7374 |
9961 const sourceBlock = blocks[0]; |
7375 |
|
7376 const sourceBlock = (0,external_lodash_namespaceObject.first)(blocks); |
|
7377 const hasMatchingName = direction !== 'from' || transform.blocks.indexOf(sourceBlock.name) !== -1 || isWildcardBlockTransform(transform); |
9962 const hasMatchingName = direction !== 'from' || transform.blocks.indexOf(sourceBlock.name) !== -1 || isWildcardBlockTransform(transform); |
7378 |
|
7379 if (!hasMatchingName) { |
9963 if (!hasMatchingName) { |
7380 return false; |
9964 return false; |
7381 } // Don't allow single Grouping blocks to be transformed into |
9965 } |
9966 |
|
9967 // Don't allow single Grouping blocks to be transformed into |
|
7382 // a Grouping block. |
9968 // a Grouping block. |
7383 |
9969 if (!isMultiBlock && direction === 'from' && isContainerGroupBlock(sourceBlock.name) && isContainerGroupBlock(transform.blockName)) { |
7384 |
|
7385 if (!isMultiBlock && isContainerGroupBlock(sourceBlock.name) && isContainerGroupBlock(transform.blockName)) { |
|
7386 return false; |
9970 return false; |
7387 } // If the transform has a `isMatch` function specified, check that it returns true. |
9971 } |
7388 |
9972 |
7389 |
9973 // If the transform has a `isMatch` function specified, check that it returns true. |
7390 if ((0,external_lodash_namespaceObject.isFunction)(transform.isMatch)) { |
9974 if (!maybeCheckTransformIsMatch(transform, blocks)) { |
7391 const attributes = transform.isMultiBlock ? blocks.map(block => block.attributes) : sourceBlock.attributes; |
|
7392 const block = transform.isMultiBlock ? blocks : sourceBlock; |
|
7393 |
|
7394 if (!transform.isMatch(attributes, block)) { |
|
7395 return false; |
|
7396 } |
|
7397 } |
|
7398 |
|
7399 if (transform.usingMobileTransformations && isWildcardBlockTransform(transform) && !isContainerGroupBlock(sourceBlock.name)) { |
|
7400 return false; |
9975 return false; |
7401 } |
9976 } |
7402 |
|
7403 return true; |
9977 return true; |
7404 }; |
9978 }; |
9979 |
|
7405 /** |
9980 /** |
7406 * Returns block types that the 'blocks' can be transformed into, based on |
9981 * Returns block types that the 'blocks' can be transformed into, based on |
7407 * 'from' transforms on other blocks. |
9982 * 'from' transforms on other blocks. |
7408 * |
9983 * |
7409 * @param {Array} blocks The blocks to transform from. |
9984 * @param {Array} blocks The blocks to transform from. |
7410 * |
9985 * |
7411 * @return {Array} Block types that the blocks can be transformed into. |
9986 * @return {Array} Block types that the blocks can be transformed into. |
7412 */ |
9987 */ |
7413 |
|
7414 |
|
7415 const getBlockTypesForPossibleFromTransforms = blocks => { |
9988 const getBlockTypesForPossibleFromTransforms = blocks => { |
7416 if ((0,external_lodash_namespaceObject.isEmpty)(blocks)) { |
9989 if (!blocks.length) { |
7417 return []; |
9990 return []; |
7418 } |
9991 } |
7419 |
9992 const allBlockTypes = getBlockTypes(); |
7420 const allBlockTypes = registration_getBlockTypes(); // filter all blocks to find those with a 'from' transform. |
9993 |
7421 |
9994 // filter all blocks to find those with a 'from' transform. |
7422 const blockTypesWithPossibleFromTransforms = (0,external_lodash_namespaceObject.filter)(allBlockTypes, blockType => { |
9995 const blockTypesWithPossibleFromTransforms = allBlockTypes.filter(blockType => { |
7423 const fromTransforms = getBlockTransforms('from', blockType.name); |
9996 const fromTransforms = getBlockTransforms('from', blockType.name); |
7424 return !!findTransform(fromTransforms, transform => { |
9997 return !!findTransform(fromTransforms, transform => { |
7425 return isPossibleTransformForSource(transform, 'from', blocks); |
9998 return isPossibleTransformForSource(transform, 'from', blocks); |
7426 }); |
9999 }); |
7427 }); |
10000 }); |
7428 return blockTypesWithPossibleFromTransforms; |
10001 return blockTypesWithPossibleFromTransforms; |
7429 }; |
10002 }; |
10003 |
|
7430 /** |
10004 /** |
7431 * Returns block types that the 'blocks' can be transformed into, based on |
10005 * Returns block types that the 'blocks' can be transformed into, based on |
7432 * the source block's own 'to' transforms. |
10006 * the source block's own 'to' transforms. |
7433 * |
10007 * |
7434 * @param {Array} blocks The blocks to transform from. |
10008 * @param {Array} blocks The blocks to transform from. |
7435 * |
10009 * |
7436 * @return {Array} Block types that the source can be transformed into. |
10010 * @return {Array} Block types that the source can be transformed into. |
7437 */ |
10011 */ |
7438 |
|
7439 |
|
7440 const getBlockTypesForPossibleToTransforms = blocks => { |
10012 const getBlockTypesForPossibleToTransforms = blocks => { |
7441 if ((0,external_lodash_namespaceObject.isEmpty)(blocks)) { |
10013 if (!blocks.length) { |
7442 return []; |
10014 return []; |
7443 } |
10015 } |
7444 |
10016 const sourceBlock = blocks[0]; |
7445 const sourceBlock = (0,external_lodash_namespaceObject.first)(blocks); |
10017 const blockType = getBlockType(sourceBlock.name); |
7446 const blockType = registration_getBlockType(sourceBlock.name); |
10018 const transformsTo = blockType ? getBlockTransforms('to', blockType.name) : []; |
7447 const transformsTo = blockType ? getBlockTransforms('to', blockType.name) : []; // filter all 'to' transforms to find those that are possible. |
10019 |
7448 |
10020 // filter all 'to' transforms to find those that are possible. |
7449 const possibleTransforms = (0,external_lodash_namespaceObject.filter)(transformsTo, transform => { |
10021 const possibleTransforms = transformsTo.filter(transform => { |
7450 return transform && isPossibleTransformForSource(transform, 'to', blocks); |
10022 return transform && isPossibleTransformForSource(transform, 'to', blocks); |
7451 }); // Build a list of block names using the possible 'to' transforms. |
10023 }); |
7452 |
10024 |
7453 const blockNames = (0,external_lodash_namespaceObject.flatMap)(possibleTransforms, transformation => transformation.blocks); // Map block names to block types. |
10025 // Build a list of block names using the possible 'to' transforms. |
7454 |
10026 const blockNames = possibleTransforms.map(transformation => transformation.blocks).flat(); |
7455 return blockNames.map(name => name === '*' ? name : registration_getBlockType(name)); |
10027 |
10028 // Map block names to block types. |
|
10029 return blockNames.map(getBlockType); |
|
7456 }; |
10030 }; |
10031 |
|
7457 /** |
10032 /** |
7458 * Determines whether transform is a "block" type |
10033 * Determines whether transform is a "block" type |
7459 * and if so whether it is a "wildcard" transform |
10034 * and if so whether it is a "wildcard" transform |
7460 * ie: targets "any" block type |
10035 * ie: targets "any" block type |
7461 * |
10036 * |
7462 * @param {Object} t the Block transform object |
10037 * @param {Object} t the Block transform object |
7463 * |
10038 * |
7464 * @return {boolean} whether transform is a wildcard transform |
10039 * @return {boolean} whether transform is a wildcard transform |
7465 */ |
10040 */ |
7466 |
|
7467 |
|
7468 const isWildcardBlockTransform = t => t && t.type === 'block' && Array.isArray(t.blocks) && t.blocks.includes('*'); |
10041 const isWildcardBlockTransform = t => t && t.type === 'block' && Array.isArray(t.blocks) && t.blocks.includes('*'); |
10042 |
|
7469 /** |
10043 /** |
7470 * Determines whether the given Block is the core Block which |
10044 * Determines whether the given Block is the core Block which |
7471 * acts as a container Block for other Blocks as part of the |
10045 * acts as a container Block for other Blocks as part of the |
7472 * Grouping mechanics |
10046 * Grouping mechanics |
7473 * |
10047 * |
7474 * @param {string} name the name of the Block to test against |
10048 * @param {string} name the name of the Block to test against |
7475 * |
10049 * |
7476 * @return {boolean} whether or not the Block is the container Block type |
10050 * @return {boolean} whether or not the Block is the container Block type |
7477 */ |
10051 */ |
7478 |
10052 const isContainerGroupBlock = name => name === getGroupingBlockName(); |
7479 const isContainerGroupBlock = name => name === registration_getGroupingBlockName(); |
10053 |
7480 /** |
10054 /** |
7481 * Returns an array of block types that the set of blocks received as argument |
10055 * Returns an array of block types that the set of blocks received as argument |
7482 * can be transformed into. |
10056 * can be transformed into. |
7483 * |
10057 * |
7484 * @param {Array} blocks Blocks array. |
10058 * @param {Array} blocks Blocks array. |
7485 * |
10059 * |
7486 * @return {Array} Block types that the blocks argument can be transformed to. |
10060 * @return {Array} Block types that the blocks argument can be transformed to. |
7487 */ |
10061 */ |
7488 |
|
7489 function getPossibleBlockTransformations(blocks) { |
10062 function getPossibleBlockTransformations(blocks) { |
7490 if ((0,external_lodash_namespaceObject.isEmpty)(blocks)) { |
10063 if (!blocks.length) { |
7491 return []; |
10064 return []; |
7492 } |
10065 } |
7493 |
|
7494 const blockTypesForFromTransforms = getBlockTypesForPossibleFromTransforms(blocks); |
10066 const blockTypesForFromTransforms = getBlockTypesForPossibleFromTransforms(blocks); |
7495 const blockTypesForToTransforms = getBlockTypesForPossibleToTransforms(blocks); |
10067 const blockTypesForToTransforms = getBlockTypesForPossibleToTransforms(blocks); |
7496 return (0,external_lodash_namespaceObject.uniq)([...blockTypesForFromTransforms, ...blockTypesForToTransforms]); |
10068 return [...new Set([...blockTypesForFromTransforms, ...blockTypesForToTransforms])]; |
7497 } |
10069 } |
10070 |
|
7498 /** |
10071 /** |
7499 * Given an array of transforms, returns the highest-priority transform where |
10072 * Given an array of transforms, returns the highest-priority transform where |
7500 * the predicate function returns a truthy value. A higher-priority transform |
10073 * the predicate function returns a truthy value. A higher-priority transform |
7501 * is one with a lower priority value (i.e. first in priority order). Returns |
10074 * is one with a lower priority value (i.e. first in priority order). Returns |
7502 * null if the transforms set is empty or the predicate function returns a |
10075 * null if the transforms set is empty or the predicate function returns a |
7505 * @param {Object[]} transforms Transforms to search. |
10078 * @param {Object[]} transforms Transforms to search. |
7506 * @param {Function} predicate Function returning true on matching transform. |
10079 * @param {Function} predicate Function returning true on matching transform. |
7507 * |
10080 * |
7508 * @return {?Object} Highest-priority transform candidate. |
10081 * @return {?Object} Highest-priority transform candidate. |
7509 */ |
10082 */ |
7510 |
|
7511 function findTransform(transforms, predicate) { |
10083 function findTransform(transforms, predicate) { |
7512 // The hooks library already has built-in mechanisms for managing priority |
10084 // The hooks library already has built-in mechanisms for managing priority |
7513 // queue, so leverage via locally-defined instance. |
10085 // queue, so leverage via locally-defined instance. |
7514 const hooks = (0,external_wp_hooks_namespaceObject.createHooks)(); |
10086 const hooks = (0,external_wp_hooks_namespaceObject.createHooks)(); |
7515 |
|
7516 for (let i = 0; i < transforms.length; i++) { |
10087 for (let i = 0; i < transforms.length; i++) { |
7517 const candidate = transforms[i]; |
10088 const candidate = transforms[i]; |
7518 |
|
7519 if (predicate(candidate)) { |
10089 if (predicate(candidate)) { |
7520 hooks.addFilter('transform', 'transform/' + i.toString(), result => result ? result : candidate, candidate.priority); |
10090 hooks.addFilter('transform', 'transform/' + i.toString(), result => result ? result : candidate, candidate.priority); |
7521 } |
10091 } |
7522 } // Filter name is arbitrarily chosen but consistent with above aggregation. |
10092 } |
7523 |
10093 |
7524 |
10094 // Filter name is arbitrarily chosen but consistent with above aggregation. |
7525 return hooks.applyFilters('transform', null); |
10095 return hooks.applyFilters('transform', null); |
7526 } |
10096 } |
10097 |
|
7527 /** |
10098 /** |
7528 * Returns normal block transforms for a given transform direction, optionally |
10099 * Returns normal block transforms for a given transform direction, optionally |
7529 * for a specific block by name, or an empty array if there are no transforms. |
10100 * for a specific block by name, or an empty array if there are no transforms. |
7530 * If no block name is provided, returns transforms for all blocks. A normal |
10101 * If no block name is provided, returns transforms for all blocks. A normal |
7531 * transform object includes `blockName` as a property. |
10102 * transform object includes `blockName` as a property. |
7533 * @param {string} direction Transform direction ("to", "from"). |
10104 * @param {string} direction Transform direction ("to", "from"). |
7534 * @param {string|Object} blockTypeOrName Block type or name. |
10105 * @param {string|Object} blockTypeOrName Block type or name. |
7535 * |
10106 * |
7536 * @return {Array} Block transforms for direction. |
10107 * @return {Array} Block transforms for direction. |
7537 */ |
10108 */ |
7538 |
|
7539 function getBlockTransforms(direction, blockTypeOrName) { |
10109 function getBlockTransforms(direction, blockTypeOrName) { |
7540 // When retrieving transforms for all block types, recurse into self. |
10110 // When retrieving transforms for all block types, recurse into self. |
7541 if (blockTypeOrName === undefined) { |
10111 if (blockTypeOrName === undefined) { |
7542 return (0,external_lodash_namespaceObject.flatMap)(registration_getBlockTypes(), _ref => { |
10112 return getBlockTypes().map(({ |
7543 let { |
10113 name |
7544 name |
10114 }) => getBlockTransforms(direction, name)).flat(); |
7545 } = _ref; |
10115 } |
7546 return getBlockTransforms(direction, name); |
10116 |
7547 }); |
10117 // Validate that block type exists and has array of direction. |
7548 } // Validate that block type exists and has array of direction. |
|
7549 |
|
7550 |
|
7551 const blockType = normalizeBlockType(blockTypeOrName); |
10118 const blockType = normalizeBlockType(blockTypeOrName); |
7552 const { |
10119 const { |
7553 name: blockName, |
10120 name: blockName, |
7554 transforms |
10121 transforms |
7555 } = blockType || {}; |
10122 } = blockType || {}; |
7556 |
|
7557 if (!transforms || !Array.isArray(transforms[direction])) { |
10123 if (!transforms || !Array.isArray(transforms[direction])) { |
7558 return []; |
10124 return []; |
7559 } |
10125 } |
7560 |
|
7561 const usingMobileTransformations = transforms.supportedMobileTransforms && Array.isArray(transforms.supportedMobileTransforms); |
10126 const usingMobileTransformations = transforms.supportedMobileTransforms && Array.isArray(transforms.supportedMobileTransforms); |
7562 const filteredTransforms = usingMobileTransformations ? (0,external_lodash_namespaceObject.filter)(transforms[direction], t => { |
10127 const filteredTransforms = usingMobileTransformations ? transforms[direction].filter(t => { |
7563 if (t.type === 'raw') { |
10128 if (t.type === 'raw') { |
7564 return true; |
10129 return true; |
7565 } |
10130 } |
7566 |
|
7567 if (!t.blocks || !t.blocks.length) { |
10131 if (!t.blocks || !t.blocks.length) { |
7568 return false; |
10132 return false; |
7569 } |
10133 } |
7570 |
|
7571 if (isWildcardBlockTransform(t)) { |
10134 if (isWildcardBlockTransform(t)) { |
7572 return true; |
10135 return true; |
7573 } |
10136 } |
7574 |
10137 return t.blocks.every(transformBlockName => transforms.supportedMobileTransforms.includes(transformBlockName)); |
7575 return (0,external_lodash_namespaceObject.every)(t.blocks, transformBlockName => transforms.supportedMobileTransforms.includes(transformBlockName)); |
10138 }) : transforms[direction]; |
7576 }) : transforms[direction]; // Map transforms to normal form. |
10139 |
7577 |
10140 // Map transforms to normal form. |
7578 return filteredTransforms.map(transform => ({ ...transform, |
10141 return filteredTransforms.map(transform => ({ |
10142 ...transform, |
|
7579 blockName, |
10143 blockName, |
7580 usingMobileTransformations |
10144 usingMobileTransformations |
7581 })); |
10145 })); |
7582 } |
10146 } |
10147 |
|
10148 /** |
|
10149 * Checks that a given transforms isMatch method passes for given source blocks. |
|
10150 * |
|
10151 * @param {Object} transform A transform object. |
|
10152 * @param {Array} blocks Blocks array. |
|
10153 * |
|
10154 * @return {boolean} True if given blocks are a match for the transform. |
|
10155 */ |
|
10156 function maybeCheckTransformIsMatch(transform, blocks) { |
|
10157 if (typeof transform.isMatch !== 'function') { |
|
10158 return true; |
|
10159 } |
|
10160 const sourceBlock = blocks[0]; |
|
10161 const attributes = transform.isMultiBlock ? blocks.map(block => block.attributes) : sourceBlock.attributes; |
|
10162 const block = transform.isMultiBlock ? blocks : sourceBlock; |
|
10163 return transform.isMatch(attributes, block); |
|
10164 } |
|
10165 |
|
7583 /** |
10166 /** |
7584 * Switch one or more blocks into one or more blocks of the new block type. |
10167 * Switch one or more blocks into one or more blocks of the new block type. |
7585 * |
10168 * |
7586 * @param {Array|Object} blocks Blocks array or block object. |
10169 * @param {Array|Object} blocks Blocks array or block object. |
7587 * @param {string} name Block name. |
10170 * @param {string} name Block name. |
7588 * |
10171 * |
7589 * @return {?Array} Array of blocks or null. |
10172 * @return {?Array} Array of blocks or null. |
7590 */ |
10173 */ |
7591 |
|
7592 function switchToBlockType(blocks, name) { |
10174 function switchToBlockType(blocks, name) { |
7593 const blocksArray = (0,external_lodash_namespaceObject.castArray)(blocks); |
10175 const blocksArray = Array.isArray(blocks) ? blocks : [blocks]; |
7594 const isMultiBlock = blocksArray.length > 1; |
10176 const isMultiBlock = blocksArray.length > 1; |
7595 const firstBlock = blocksArray[0]; |
10177 const firstBlock = blocksArray[0]; |
7596 const sourceName = firstBlock.name; // Find the right transformation by giving priority to the "to" |
10178 const sourceName = firstBlock.name; |
10179 |
|
10180 // Find the right transformation by giving priority to the "to" |
|
7597 // transformation. |
10181 // transformation. |
7598 |
|
7599 const transformationsFrom = getBlockTransforms('from', name); |
10182 const transformationsFrom = getBlockTransforms('from', name); |
7600 const transformationsTo = getBlockTransforms('to', sourceName); |
10183 const transformationsTo = getBlockTransforms('to', sourceName); |
7601 const transformation = findTransform(transformationsTo, t => t.type === 'block' && (isWildcardBlockTransform(t) || t.blocks.indexOf(name) !== -1) && (!isMultiBlock || t.isMultiBlock)) || findTransform(transformationsFrom, t => t.type === 'block' && (isWildcardBlockTransform(t) || t.blocks.indexOf(sourceName) !== -1) && (!isMultiBlock || t.isMultiBlock)); // Stop if there is no valid transformation. |
10184 const transformation = findTransform(transformationsTo, t => t.type === 'block' && (isWildcardBlockTransform(t) || t.blocks.indexOf(name) !== -1) && (!isMultiBlock || t.isMultiBlock) && maybeCheckTransformIsMatch(t, blocksArray)) || findTransform(transformationsFrom, t => t.type === 'block' && (isWildcardBlockTransform(t) || t.blocks.indexOf(sourceName) !== -1) && (!isMultiBlock || t.isMultiBlock) && maybeCheckTransformIsMatch(t, blocksArray)); |
7602 |
10185 |
10186 // Stop if there is no valid transformation. |
|
7603 if (!transformation) { |
10187 if (!transformation) { |
7604 return null; |
10188 return null; |
7605 } |
10189 } |
7606 |
|
7607 let transformationResults; |
10190 let transformationResults; |
7608 |
|
7609 if (transformation.isMultiBlock) { |
10191 if (transformation.isMultiBlock) { |
7610 if ((0,external_lodash_namespaceObject.has)(transformation, '__experimentalConvert')) { |
10192 if ('__experimentalConvert' in transformation) { |
7611 transformationResults = transformation.__experimentalConvert(blocksArray); |
10193 transformationResults = transformation.__experimentalConvert(blocksArray); |
7612 } else { |
10194 } else { |
7613 transformationResults = transformation.transform(blocksArray.map(currentBlock => currentBlock.attributes), blocksArray.map(currentBlock => currentBlock.innerBlocks)); |
10195 transformationResults = transformation.transform(blocksArray.map(currentBlock => currentBlock.attributes), blocksArray.map(currentBlock => currentBlock.innerBlocks)); |
7614 } |
10196 } |
7615 } else if ((0,external_lodash_namespaceObject.has)(transformation, '__experimentalConvert')) { |
10197 } else if ('__experimentalConvert' in transformation) { |
7616 transformationResults = transformation.__experimentalConvert(firstBlock); |
10198 transformationResults = transformation.__experimentalConvert(firstBlock); |
7617 } else { |
10199 } else { |
7618 transformationResults = transformation.transform(firstBlock.attributes, firstBlock.innerBlocks); |
10200 transformationResults = transformation.transform(firstBlock.attributes, firstBlock.innerBlocks); |
7619 } // Ensure that the transformation function returned an object or an array |
10201 } |
10202 |
|
10203 // Ensure that the transformation function returned an object or an array |
|
7620 // of objects. |
10204 // of objects. |
7621 |
10205 if (transformationResults === null || typeof transformationResults !== 'object') { |
7622 |
|
7623 if (!(0,external_lodash_namespaceObject.isObjectLike)(transformationResults)) { |
|
7624 return null; |
10206 return null; |
7625 } // If the transformation function returned a single object, we want to work |
10207 } |
10208 |
|
10209 // If the transformation function returned a single object, we want to work |
|
7626 // with an array instead. |
10210 // with an array instead. |
7627 |
10211 transformationResults = Array.isArray(transformationResults) ? transformationResults : [transformationResults]; |
7628 |
10212 |
7629 transformationResults = (0,external_lodash_namespaceObject.castArray)(transformationResults); // Ensure that every block object returned by the transformation has a |
10213 // Ensure that every block object returned by the transformation has a |
7630 // valid block type. |
10214 // valid block type. |
7631 |
10215 if (transformationResults.some(result => !getBlockType(result.name))) { |
7632 if (transformationResults.some(result => !registration_getBlockType(result.name))) { |
|
7633 return null; |
10216 return null; |
7634 } |
10217 } |
7635 |
10218 const hasSwitchedBlock = transformationResults.some(result => result.name === name); |
7636 const hasSwitchedBlock = name === '*' || (0,external_lodash_namespaceObject.some)(transformationResults, result => result.name === name); // Ensure that at least one block object returned by the transformation has |
10219 |
10220 // Ensure that at least one block object returned by the transformation has |
|
7637 // the expected "destination" block type. |
10221 // the expected "destination" block type. |
7638 |
|
7639 if (!hasSwitchedBlock) { |
10222 if (!hasSwitchedBlock) { |
7640 return null; |
10223 return null; |
7641 } |
10224 } |
7642 |
|
7643 const ret = transformationResults.map((result, index, results) => { |
10225 const ret = transformationResults.map((result, index, results) => { |
7644 /** |
10226 /** |
7645 * Filters an individual transform result from block transformation. |
10227 * Filters an individual transform result from block transformation. |
7646 * All of the original blocks are passed, since transformations are |
10228 * All of the original blocks are passed, since transformations are |
7647 * many-to-many, not one-to-one. |
10229 * many-to-many, not one-to-one. |
7653 */ |
10235 */ |
7654 return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.switchToBlockType.transformedBlock', result, blocks, index, results); |
10236 return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.switchToBlockType.transformedBlock', result, blocks, index, results); |
7655 }); |
10237 }); |
7656 return ret; |
10238 return ret; |
7657 } |
10239 } |
10240 |
|
7658 /** |
10241 /** |
7659 * Create a block object from the example API. |
10242 * Create a block object from the example API. |
7660 * |
10243 * |
7661 * @param {string} name |
10244 * @param {string} name |
7662 * @param {Object} example |
10245 * @param {Object} example |
7663 * |
10246 * |
7664 * @return {Object} block. |
10247 * @return {Object} block. |
7665 */ |
10248 */ |
7666 |
|
7667 const getBlockFromExample = (name, example) => { |
10249 const getBlockFromExample = (name, example) => { |
7668 return createBlock(name, example.attributes, (0,external_lodash_namespaceObject.map)(example.innerBlocks, innerBlock => getBlockFromExample(innerBlock.name, innerBlock))); |
10250 try { |
10251 var _example$innerBlocks; |
|
10252 return createBlock(name, example.attributes, ((_example$innerBlocks = example.innerBlocks) !== null && _example$innerBlocks !== void 0 ? _example$innerBlocks : []).map(innerBlock => getBlockFromExample(innerBlock.name, innerBlock))); |
|
10253 } catch { |
|
10254 return createBlock('core/missing', { |
|
10255 originalName: name, |
|
10256 originalContent: '', |
|
10257 originalUndelimitedContent: '' |
|
10258 }); |
|
10259 } |
|
7669 }; |
10260 }; |
7670 |
10261 |
7671 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/utils.js |
|
7672 /** |
|
7673 * External dependencies |
|
7674 */ |
|
7675 |
|
7676 |
|
7677 |
|
7678 |
|
7679 /** |
|
7680 * WordPress dependencies |
|
7681 */ |
|
7682 |
|
7683 |
|
7684 |
|
7685 |
|
7686 /** |
|
7687 * Internal dependencies |
|
7688 */ |
|
7689 |
|
7690 |
|
7691 |
|
7692 |
|
7693 k([names, a11y]); |
|
7694 /** |
|
7695 * Array of icon colors containing a color to be used if the icon color |
|
7696 * was not explicitly set but the icon background color was. |
|
7697 * |
|
7698 * @type {Object} |
|
7699 */ |
|
7700 |
|
7701 const ICON_COLORS = ['#191e23', '#f8f9f9']; |
|
7702 /** |
|
7703 * Determines whether the block is a default block |
|
7704 * and its attributes are equal to the default attributes |
|
7705 * which means the block is unmodified. |
|
7706 * |
|
7707 * @param {WPBlock} block Block Object |
|
7708 * |
|
7709 * @return {boolean} Whether the block is an unmodified default block |
|
7710 */ |
|
7711 |
|
7712 function isUnmodifiedDefaultBlock(block) { |
|
7713 const defaultBlockName = registration_getDefaultBlockName(); |
|
7714 |
|
7715 if (block.name !== defaultBlockName) { |
|
7716 return false; |
|
7717 } // Cache a created default block if no cache exists or the default block |
|
7718 // name changed. |
|
7719 |
|
7720 |
|
7721 if (!isUnmodifiedDefaultBlock.block || isUnmodifiedDefaultBlock.block.name !== defaultBlockName) { |
|
7722 isUnmodifiedDefaultBlock.block = createBlock(defaultBlockName); |
|
7723 } |
|
7724 |
|
7725 const newDefaultBlock = isUnmodifiedDefaultBlock.block; |
|
7726 const blockType = registration_getBlockType(defaultBlockName); |
|
7727 return (0,external_lodash_namespaceObject.every)(blockType === null || blockType === void 0 ? void 0 : blockType.attributes, (value, key) => newDefaultBlock.attributes[key] === block.attributes[key]); |
|
7728 } |
|
7729 /** |
|
7730 * Function that checks if the parameter is a valid icon. |
|
7731 * |
|
7732 * @param {*} icon Parameter to be checked. |
|
7733 * |
|
7734 * @return {boolean} True if the parameter is a valid icon and false otherwise. |
|
7735 */ |
|
7736 |
|
7737 function isValidIcon(icon) { |
|
7738 return !!icon && ((0,external_lodash_namespaceObject.isString)(icon) || (0,external_wp_element_namespaceObject.isValidElement)(icon) || (0,external_lodash_namespaceObject.isFunction)(icon) || icon instanceof external_wp_element_namespaceObject.Component); |
|
7739 } |
|
7740 /** |
|
7741 * Function that receives an icon as set by the blocks during the registration |
|
7742 * and returns a new icon object that is normalized so we can rely on just on possible icon structure |
|
7743 * in the codebase. |
|
7744 * |
|
7745 * @param {WPBlockTypeIconRender} icon Render behavior of a block type icon; |
|
7746 * one of a Dashicon slug, an element, or a |
|
7747 * component. |
|
7748 * |
|
7749 * @return {WPBlockTypeIconDescriptor} Object describing the icon. |
|
7750 */ |
|
7751 |
|
7752 function normalizeIconObject(icon) { |
|
7753 icon = icon || BLOCK_ICON_DEFAULT; |
|
7754 |
|
7755 if (isValidIcon(icon)) { |
|
7756 return { |
|
7757 src: icon |
|
7758 }; |
|
7759 } |
|
7760 |
|
7761 if ((0,external_lodash_namespaceObject.has)(icon, ['background'])) { |
|
7762 const colordBgColor = w(icon.background); |
|
7763 return { ...icon, |
|
7764 foreground: icon.foreground ? icon.foreground : (0,external_lodash_namespaceObject.maxBy)(ICON_COLORS, iconColor => colordBgColor.contrast(iconColor)), |
|
7765 shadowColor: colordBgColor.alpha(0.3).toRgbString() |
|
7766 }; |
|
7767 } |
|
7768 |
|
7769 return icon; |
|
7770 } |
|
7771 /** |
|
7772 * Normalizes block type passed as param. When string is passed then |
|
7773 * it converts it to the matching block type object. |
|
7774 * It passes the original object otherwise. |
|
7775 * |
|
7776 * @param {string|Object} blockTypeOrName Block type or name. |
|
7777 * |
|
7778 * @return {?Object} Block type. |
|
7779 */ |
|
7780 |
|
7781 function normalizeBlockType(blockTypeOrName) { |
|
7782 if ((0,external_lodash_namespaceObject.isString)(blockTypeOrName)) { |
|
7783 return registration_getBlockType(blockTypeOrName); |
|
7784 } |
|
7785 |
|
7786 return blockTypeOrName; |
|
7787 } |
|
7788 /** |
|
7789 * Get the label for the block, usually this is either the block title, |
|
7790 * or the value of the block's `label` function when that's specified. |
|
7791 * |
|
7792 * @param {Object} blockType The block type. |
|
7793 * @param {Object} attributes The values of the block's attributes. |
|
7794 * @param {Object} context The intended use for the label. |
|
7795 * |
|
7796 * @return {string} The block label. |
|
7797 */ |
|
7798 |
|
7799 function getBlockLabel(blockType, attributes) { |
|
7800 let context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'visual'; |
|
7801 const { |
|
7802 __experimentalLabel: getLabel, |
|
7803 title |
|
7804 } = blockType; |
|
7805 const label = getLabel && getLabel(attributes, { |
|
7806 context |
|
7807 }); |
|
7808 |
|
7809 if (!label) { |
|
7810 return title; |
|
7811 } // Strip any HTML (i.e. RichText formatting) before returning. |
|
7812 |
|
7813 |
|
7814 return (0,external_wp_dom_namespaceObject.__unstableStripHTML)(label); |
|
7815 } |
|
7816 /** |
|
7817 * Get a label for the block for use by screenreaders, this is more descriptive |
|
7818 * than the visual label and includes the block title and the value of the |
|
7819 * `getLabel` function if it's specified. |
|
7820 * |
|
7821 * @param {Object} blockType The block type. |
|
7822 * @param {Object} attributes The values of the block's attributes. |
|
7823 * @param {?number} position The position of the block in the block list. |
|
7824 * @param {string} [direction='vertical'] The direction of the block layout. |
|
7825 * |
|
7826 * @return {string} The block label. |
|
7827 */ |
|
7828 |
|
7829 function getAccessibleBlockLabel(blockType, attributes, position) { |
|
7830 let direction = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'vertical'; |
|
7831 // `title` is already localized, `label` is a user-supplied value. |
|
7832 const title = blockType === null || blockType === void 0 ? void 0 : blockType.title; |
|
7833 const label = blockType ? getBlockLabel(blockType, attributes, 'accessibility') : ''; |
|
7834 const hasPosition = position !== undefined; // getBlockLabel returns the block title as a fallback when there's no label, |
|
7835 // if it did return the title, this function needs to avoid adding the |
|
7836 // title twice within the accessible label. Use this `hasLabel` boolean to |
|
7837 // handle that. |
|
7838 |
|
7839 const hasLabel = label && label !== title; |
|
7840 |
|
7841 if (hasPosition && direction === 'vertical') { |
|
7842 if (hasLabel) { |
|
7843 return (0,external_wp_i18n_namespaceObject.sprintf)( |
|
7844 /* translators: accessibility text. 1: The block title. 2: The block row number. 3: The block label.. */ |
|
7845 (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Row %2$d. %3$s'), title, position, label); |
|
7846 } |
|
7847 |
|
7848 return (0,external_wp_i18n_namespaceObject.sprintf)( |
|
7849 /* translators: accessibility text. 1: The block title. 2: The block row number. */ |
|
7850 (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Row %2$d'), title, position); |
|
7851 } else if (hasPosition && direction === 'horizontal') { |
|
7852 if (hasLabel) { |
|
7853 return (0,external_wp_i18n_namespaceObject.sprintf)( |
|
7854 /* translators: accessibility text. 1: The block title. 2: The block column number. 3: The block label.. */ |
|
7855 (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Column %2$d. %3$s'), title, position, label); |
|
7856 } |
|
7857 |
|
7858 return (0,external_wp_i18n_namespaceObject.sprintf)( |
|
7859 /* translators: accessibility text. 1: The block title. 2: The block column number. */ |
|
7860 (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Column %2$d'), title, position); |
|
7861 } |
|
7862 |
|
7863 if (hasLabel) { |
|
7864 return (0,external_wp_i18n_namespaceObject.sprintf)( |
|
7865 /* translators: accessibility text. %1: The block title. %2: The block label. */ |
|
7866 (0,external_wp_i18n_namespaceObject.__)('%1$s Block. %2$s'), title, label); |
|
7867 } |
|
7868 |
|
7869 return (0,external_wp_i18n_namespaceObject.sprintf)( |
|
7870 /* translators: accessibility text. %s: The block title. */ |
|
7871 (0,external_wp_i18n_namespaceObject.__)('%s Block'), title); |
|
7872 } |
|
7873 /** |
|
7874 * Ensure attributes contains only values defined by block type, and merge |
|
7875 * default values for missing attributes. |
|
7876 * |
|
7877 * @param {string} name The block's name. |
|
7878 * @param {Object} attributes The block's attributes. |
|
7879 * @return {Object} The sanitized attributes. |
|
7880 */ |
|
7881 |
|
7882 function __experimentalSanitizeBlockAttributes(name, attributes) { |
|
7883 // Get the type definition associated with a registered block. |
|
7884 const blockType = registration_getBlockType(name); |
|
7885 |
|
7886 if (undefined === blockType) { |
|
7887 throw new Error(`Block type '${name}' is not registered.`); |
|
7888 } |
|
7889 |
|
7890 return (0,external_lodash_namespaceObject.reduce)(blockType.attributes, (accumulator, schema, key) => { |
|
7891 const value = attributes[key]; |
|
7892 |
|
7893 if (undefined !== value) { |
|
7894 accumulator[key] = value; |
|
7895 } else if (schema.hasOwnProperty('default')) { |
|
7896 accumulator[key] = schema.default; |
|
7897 } |
|
7898 |
|
7899 if (['node', 'children'].indexOf(schema.source) !== -1) { |
|
7900 // Ensure value passed is always an array, which we're expecting in |
|
7901 // the RichText component to handle the deprecated value. |
|
7902 if (typeof accumulator[key] === 'string') { |
|
7903 accumulator[key] = [accumulator[key]]; |
|
7904 } else if (!Array.isArray(accumulator[key])) { |
|
7905 accumulator[key] = []; |
|
7906 } |
|
7907 } |
|
7908 |
|
7909 return accumulator; |
|
7910 }, {}); |
|
7911 } |
|
7912 /** |
|
7913 * Filter block attributes by `role` and return their names. |
|
7914 * |
|
7915 * @param {string} name Block attribute's name. |
|
7916 * @param {string} role The role of a block attribute. |
|
7917 * |
|
7918 * @return {string[]} The attribute names that have the provided role. |
|
7919 */ |
|
7920 |
|
7921 function __experimentalGetBlockAttributesNamesByRole(name, role) { |
|
7922 var _getBlockType; |
|
7923 |
|
7924 const attributes = (_getBlockType = registration_getBlockType(name)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.attributes; |
|
7925 if (!attributes) return []; |
|
7926 const attributesNames = Object.keys(attributes); |
|
7927 if (!role) return attributesNames; |
|
7928 return attributesNames.filter(attributeName => { |
|
7929 var _attributes$attribute; |
|
7930 |
|
7931 return ((_attributes$attribute = attributes[attributeName]) === null || _attributes$attribute === void 0 ? void 0 : _attributes$attribute.__experimentalRole) === role; |
|
7932 }); |
|
7933 } |
|
7934 |
|
7935 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/actions.js |
|
7936 /** |
|
7937 * External dependencies |
|
7938 */ |
|
7939 |
|
7940 /** |
|
7941 * WordPress dependencies |
|
7942 */ |
|
7943 |
|
7944 |
|
7945 /** |
|
7946 * Internal dependencies |
|
7947 */ |
|
7948 |
|
7949 |
|
7950 |
|
7951 /** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */ |
|
7952 |
|
7953 const { |
|
7954 error, |
|
7955 warn |
|
7956 } = window.console; |
|
7957 /** |
|
7958 * Mapping of legacy category slugs to their latest normal values, used to |
|
7959 * accommodate updates of the default set of block categories. |
|
7960 * |
|
7961 * @type {Record<string,string>} |
|
7962 */ |
|
7963 |
|
7964 const LEGACY_CATEGORY_MAPPING = { |
|
7965 common: 'text', |
|
7966 formatting: 'text', |
|
7967 layout: 'design' |
|
7968 }; |
|
7969 /** |
|
7970 * Takes the unprocessed block type data and applies all the existing filters for the registered block type. |
|
7971 * Next, it validates all the settings and performs additional processing to the block type definition. |
|
7972 * |
|
7973 * @param {WPBlockType} blockType Unprocessed block type settings. |
|
7974 * @param {Object} thunkArgs Argument object for the thunk middleware. |
|
7975 * @param {Function} thunkArgs.select Function to select from the store. |
|
7976 * |
|
7977 * @return {?WPBlockType} The block, if it has been successfully registered; otherwise `undefined`. |
|
7978 */ |
|
7979 |
|
7980 const processBlockType = (blockType, _ref) => { |
|
7981 let { |
|
7982 select |
|
7983 } = _ref; |
|
7984 const { |
|
7985 name |
|
7986 } = blockType; |
|
7987 const settings = (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.registerBlockType', { ...blockType |
|
7988 }, name); |
|
7989 |
|
7990 if (settings.deprecated) { |
|
7991 settings.deprecated = settings.deprecated.map(deprecation => (0,external_lodash_namespaceObject.pick)( // Only keep valid deprecation keys. |
|
7992 (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.registerBlockType', // Merge deprecation keys with pre-filter settings |
|
7993 // so that filters that depend on specific keys being |
|
7994 // present don't fail. |
|
7995 { // Omit deprecation keys here so that deprecations |
|
7996 // can opt out of specific keys like "supports". |
|
7997 ...(0,external_lodash_namespaceObject.omit)(blockType, DEPRECATED_ENTRY_KEYS), |
|
7998 ...deprecation |
|
7999 }, name), DEPRECATED_ENTRY_KEYS)); |
|
8000 } |
|
8001 |
|
8002 if (!(0,external_lodash_namespaceObject.isPlainObject)(settings)) { |
|
8003 error('Block settings must be a valid object.'); |
|
8004 return; |
|
8005 } |
|
8006 |
|
8007 if (!(0,external_lodash_namespaceObject.isFunction)(settings.save)) { |
|
8008 error('The "save" property must be a valid function.'); |
|
8009 return; |
|
8010 } |
|
8011 |
|
8012 if ('edit' in settings && !(0,external_lodash_namespaceObject.isFunction)(settings.edit)) { |
|
8013 error('The "edit" property must be a valid function.'); |
|
8014 return; |
|
8015 } // Canonicalize legacy categories to equivalent fallback. |
|
8016 |
|
8017 |
|
8018 if (LEGACY_CATEGORY_MAPPING.hasOwnProperty(settings.category)) { |
|
8019 settings.category = LEGACY_CATEGORY_MAPPING[settings.category]; |
|
8020 } |
|
8021 |
|
8022 if ('category' in settings && !(0,external_lodash_namespaceObject.some)(select.getCategories(), { |
|
8023 slug: settings.category |
|
8024 })) { |
|
8025 warn('The block "' + name + '" is registered with an invalid category "' + settings.category + '".'); |
|
8026 delete settings.category; |
|
8027 } |
|
8028 |
|
8029 if (!('title' in settings) || settings.title === '') { |
|
8030 error('The block "' + name + '" must have a title.'); |
|
8031 return; |
|
8032 } |
|
8033 |
|
8034 if (typeof settings.title !== 'string') { |
|
8035 error('Block titles must be strings.'); |
|
8036 return; |
|
8037 } |
|
8038 |
|
8039 settings.icon = normalizeIconObject(settings.icon); |
|
8040 |
|
8041 if (!isValidIcon(settings.icon.src)) { |
|
8042 error('The icon passed is invalid. ' + 'The icon should be a string, an element, a function, or an object following the specifications documented in https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#icon-optional'); |
|
8043 return; |
|
8044 } |
|
8045 |
|
8046 return settings; |
|
8047 }; |
|
8048 /** |
|
8049 * Returns an action object used in signalling that block types have been added. |
|
8050 * |
|
8051 * @param {Array|Object} blockTypes Block types received. |
|
8052 * |
|
8053 * @return {Object} Action object. |
|
8054 */ |
|
8055 |
|
8056 |
|
8057 function addBlockTypes(blockTypes) { |
|
8058 return { |
|
8059 type: 'ADD_BLOCK_TYPES', |
|
8060 blockTypes: (0,external_lodash_namespaceObject.castArray)(blockTypes) |
|
8061 }; |
|
8062 } |
|
8063 /** |
|
8064 * Signals that the passed block type's settings should be stored in the state. |
|
8065 * |
|
8066 * @param {WPBlockType} blockType Unprocessed block type settings. |
|
8067 */ |
|
8068 |
|
8069 const __experimentalRegisterBlockType = blockType => _ref2 => { |
|
8070 let { |
|
8071 dispatch, |
|
8072 select |
|
8073 } = _ref2; |
|
8074 dispatch({ |
|
8075 type: 'ADD_UNPROCESSED_BLOCK_TYPE', |
|
8076 blockType |
|
8077 }); |
|
8078 const processedBlockType = processBlockType(blockType, { |
|
8079 select |
|
8080 }); |
|
8081 |
|
8082 if (!processedBlockType) { |
|
8083 return; |
|
8084 } |
|
8085 |
|
8086 dispatch.addBlockTypes(processedBlockType); |
|
8087 }; |
|
8088 /** |
|
8089 * Signals that all block types should be computed again. |
|
8090 * It uses stored unprocessed block types and all the most recent list of registered filters. |
|
8091 * |
|
8092 * It addresses the issue where third party block filters get registered after third party blocks. A sample sequence: |
|
8093 * 1. Filter A. |
|
8094 * 2. Block B. |
|
8095 * 3. Block C. |
|
8096 * 4. Filter D. |
|
8097 * 5. Filter E. |
|
8098 * 6. Block F. |
|
8099 * 7. Filter G. |
|
8100 * In this scenario some filters would not get applied for all blocks because they are registered too late. |
|
8101 */ |
|
8102 |
|
8103 const __experimentalReapplyBlockTypeFilters = () => _ref3 => { |
|
8104 let { |
|
8105 dispatch, |
|
8106 select |
|
8107 } = _ref3; |
|
8108 |
|
8109 const unprocessedBlockTypes = select.__experimentalGetUnprocessedBlockTypes(); |
|
8110 |
|
8111 const processedBlockTypes = Object.keys(unprocessedBlockTypes).reduce((accumulator, blockName) => { |
|
8112 const result = processBlockType(unprocessedBlockTypes[blockName], { |
|
8113 select |
|
8114 }); |
|
8115 |
|
8116 if (result) { |
|
8117 accumulator.push(result); |
|
8118 } |
|
8119 |
|
8120 return accumulator; |
|
8121 }, []); |
|
8122 |
|
8123 if (!processedBlockTypes.length) { |
|
8124 return; |
|
8125 } |
|
8126 |
|
8127 dispatch.addBlockTypes(processedBlockTypes); |
|
8128 }; |
|
8129 /** |
|
8130 * Returns an action object used to remove a registered block type. |
|
8131 * |
|
8132 * @param {string|Array} names Block name. |
|
8133 * |
|
8134 * @return {Object} Action object. |
|
8135 */ |
|
8136 |
|
8137 function removeBlockTypes(names) { |
|
8138 return { |
|
8139 type: 'REMOVE_BLOCK_TYPES', |
|
8140 names: (0,external_lodash_namespaceObject.castArray)(names) |
|
8141 }; |
|
8142 } |
|
8143 /** |
|
8144 * Returns an action object used in signalling that new block styles have been added. |
|
8145 * |
|
8146 * @param {string} blockName Block name. |
|
8147 * @param {Array|Object} styles Block styles. |
|
8148 * |
|
8149 * @return {Object} Action object. |
|
8150 */ |
|
8151 |
|
8152 function addBlockStyles(blockName, styles) { |
|
8153 return { |
|
8154 type: 'ADD_BLOCK_STYLES', |
|
8155 styles: (0,external_lodash_namespaceObject.castArray)(styles), |
|
8156 blockName |
|
8157 }; |
|
8158 } |
|
8159 /** |
|
8160 * Returns an action object used in signalling that block styles have been removed. |
|
8161 * |
|
8162 * @param {string} blockName Block name. |
|
8163 * @param {Array|string} styleNames Block style names. |
|
8164 * |
|
8165 * @return {Object} Action object. |
|
8166 */ |
|
8167 |
|
8168 function removeBlockStyles(blockName, styleNames) { |
|
8169 return { |
|
8170 type: 'REMOVE_BLOCK_STYLES', |
|
8171 styleNames: (0,external_lodash_namespaceObject.castArray)(styleNames), |
|
8172 blockName |
|
8173 }; |
|
8174 } |
|
8175 /** |
|
8176 * Returns an action object used in signalling that new block variations have been added. |
|
8177 * |
|
8178 * @param {string} blockName Block name. |
|
8179 * @param {WPBlockVariation|WPBlockVariation[]} variations Block variations. |
|
8180 * |
|
8181 * @return {Object} Action object. |
|
8182 */ |
|
8183 |
|
8184 function addBlockVariations(blockName, variations) { |
|
8185 return { |
|
8186 type: 'ADD_BLOCK_VARIATIONS', |
|
8187 variations: (0,external_lodash_namespaceObject.castArray)(variations), |
|
8188 blockName |
|
8189 }; |
|
8190 } |
|
8191 /** |
|
8192 * Returns an action object used in signalling that block variations have been removed. |
|
8193 * |
|
8194 * @param {string} blockName Block name. |
|
8195 * @param {string|string[]} variationNames Block variation names. |
|
8196 * |
|
8197 * @return {Object} Action object. |
|
8198 */ |
|
8199 |
|
8200 function removeBlockVariations(blockName, variationNames) { |
|
8201 return { |
|
8202 type: 'REMOVE_BLOCK_VARIATIONS', |
|
8203 variationNames: (0,external_lodash_namespaceObject.castArray)(variationNames), |
|
8204 blockName |
|
8205 }; |
|
8206 } |
|
8207 /** |
|
8208 * Returns an action object used to set the default block name. |
|
8209 * |
|
8210 * @param {string} name Block name. |
|
8211 * |
|
8212 * @return {Object} Action object. |
|
8213 */ |
|
8214 |
|
8215 function actions_setDefaultBlockName(name) { |
|
8216 return { |
|
8217 type: 'SET_DEFAULT_BLOCK_NAME', |
|
8218 name |
|
8219 }; |
|
8220 } |
|
8221 /** |
|
8222 * Returns an action object used to set the name of the block used as a fallback |
|
8223 * for non-block content. |
|
8224 * |
|
8225 * @param {string} name Block name. |
|
8226 * |
|
8227 * @return {Object} Action object. |
|
8228 */ |
|
8229 |
|
8230 function setFreeformFallbackBlockName(name) { |
|
8231 return { |
|
8232 type: 'SET_FREEFORM_FALLBACK_BLOCK_NAME', |
|
8233 name |
|
8234 }; |
|
8235 } |
|
8236 /** |
|
8237 * Returns an action object used to set the name of the block used as a fallback |
|
8238 * for unregistered blocks. |
|
8239 * |
|
8240 * @param {string} name Block name. |
|
8241 * |
|
8242 * @return {Object} Action object. |
|
8243 */ |
|
8244 |
|
8245 function setUnregisteredFallbackBlockName(name) { |
|
8246 return { |
|
8247 type: 'SET_UNREGISTERED_FALLBACK_BLOCK_NAME', |
|
8248 name |
|
8249 }; |
|
8250 } |
|
8251 /** |
|
8252 * Returns an action object used to set the name of the block used |
|
8253 * when grouping other blocks |
|
8254 * eg: in "Group/Ungroup" interactions |
|
8255 * |
|
8256 * @param {string} name Block name. |
|
8257 * |
|
8258 * @return {Object} Action object. |
|
8259 */ |
|
8260 |
|
8261 function actions_setGroupingBlockName(name) { |
|
8262 return { |
|
8263 type: 'SET_GROUPING_BLOCK_NAME', |
|
8264 name |
|
8265 }; |
|
8266 } |
|
8267 /** |
|
8268 * Returns an action object used to set block categories. |
|
8269 * |
|
8270 * @param {Object[]} categories Block categories. |
|
8271 * |
|
8272 * @return {Object} Action object. |
|
8273 */ |
|
8274 |
|
8275 function setCategories(categories) { |
|
8276 return { |
|
8277 type: 'SET_CATEGORIES', |
|
8278 categories |
|
8279 }; |
|
8280 } |
|
8281 /** |
|
8282 * Returns an action object used to update a category. |
|
8283 * |
|
8284 * @param {string} slug Block category slug. |
|
8285 * @param {Object} category Object containing the category properties that should be updated. |
|
8286 * |
|
8287 * @return {Object} Action object. |
|
8288 */ |
|
8289 |
|
8290 function updateCategory(slug, category) { |
|
8291 return { |
|
8292 type: 'UPDATE_CATEGORY', |
|
8293 slug, |
|
8294 category |
|
8295 }; |
|
8296 } |
|
8297 /** |
|
8298 * Returns an action object used to add block collections |
|
8299 * |
|
8300 * @param {string} namespace The namespace of the blocks to put in the collection |
|
8301 * @param {string} title The title to display in the block inserter |
|
8302 * @param {Object} icon (optional) The icon to display in the block inserter |
|
8303 * |
|
8304 * @return {Object} Action object. |
|
8305 */ |
|
8306 |
|
8307 function addBlockCollection(namespace, title, icon) { |
|
8308 return { |
|
8309 type: 'ADD_BLOCK_COLLECTION', |
|
8310 namespace, |
|
8311 title, |
|
8312 icon |
|
8313 }; |
|
8314 } |
|
8315 /** |
|
8316 * Returns an action object used to remove block collections |
|
8317 * |
|
8318 * @param {string} namespace The namespace of the blocks to put in the collection |
|
8319 * |
|
8320 * @return {Object} Action object. |
|
8321 */ |
|
8322 |
|
8323 function removeBlockCollection(namespace) { |
|
8324 return { |
|
8325 type: 'REMOVE_BLOCK_COLLECTION', |
|
8326 namespace |
|
8327 }; |
|
8328 } |
|
8329 |
|
8330 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/constants.js |
|
8331 const STORE_NAME = 'core/blocks'; |
|
8332 |
|
8333 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/index.js |
|
8334 /** |
|
8335 * WordPress dependencies |
|
8336 */ |
|
8337 |
|
8338 /** |
|
8339 * Internal dependencies |
|
8340 */ |
|
8341 |
|
8342 |
|
8343 |
|
8344 |
|
8345 |
|
8346 /** |
|
8347 * Store definition for the blocks namespace. |
|
8348 * |
|
8349 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore |
|
8350 * |
|
8351 * @type {Object} |
|
8352 */ |
|
8353 |
|
8354 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { |
|
8355 reducer: reducer, |
|
8356 selectors: selectors_namespaceObject, |
|
8357 actions: actions_namespaceObject |
|
8358 }); |
|
8359 (0,external_wp_data_namespaceObject.register)(store); |
|
8360 |
|
8361 ;// CONCATENATED MODULE: external ["wp","blockSerializationDefaultParser"] |
10262 ;// CONCATENATED MODULE: external ["wp","blockSerializationDefaultParser"] |
8362 var external_wp_blockSerializationDefaultParser_namespaceObject = window["wp"]["blockSerializationDefaultParser"]; |
10263 const external_wp_blockSerializationDefaultParser_namespaceObject = window["wp"]["blockSerializationDefaultParser"]; |
8363 ;// CONCATENATED MODULE: external ["wp","autop"] |
10264 ;// CONCATENATED MODULE: external ["wp","autop"] |
8364 var external_wp_autop_namespaceObject = window["wp"]["autop"]; |
10265 const external_wp_autop_namespaceObject = window["wp"]["autop"]; |
8365 ;// CONCATENATED MODULE: external ["wp","isShallowEqual"] |
10266 ;// CONCATENATED MODULE: external ["wp","isShallowEqual"] |
8366 var external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"]; |
10267 const external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"]; |
8367 var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject); |
10268 var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject); |
8368 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/serialize-raw-block.js |
10269 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/serialize-raw-block.js |
8369 /** |
10270 /** |
8370 * Internal dependencies |
10271 * Internal dependencies |
8371 */ |
10272 */ |
10273 |
|
8372 |
10274 |
8373 /** |
10275 /** |
8374 * @typedef {Object} Options Serialization options. |
10276 * @typedef {Object} Options Serialization options. |
8375 * @property {boolean} [isCommentDelimited=true] Whether to output HTML comments around blocks. |
10277 * @property {boolean} [isCommentDelimited=true] Whether to output HTML comments around blocks. |
8376 */ |
10278 */ |
8395 * @param {WPRawBlock} rawBlock A block node as returned by a valid parser. |
10297 * @param {WPRawBlock} rawBlock A block node as returned by a valid parser. |
8396 * @param {Options} [options={}] Serialization options. |
10298 * @param {Options} [options={}] Serialization options. |
8397 * |
10299 * |
8398 * @return {string} An HTML string representing a block. |
10300 * @return {string} An HTML string representing a block. |
8399 */ |
10301 */ |
8400 |
10302 function serializeRawBlock(rawBlock, options = {}) { |
8401 function serializeRawBlock(rawBlock) { |
|
8402 let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
8403 const { |
10303 const { |
8404 isCommentDelimited = true |
10304 isCommentDelimited = true |
8405 } = options; |
10305 } = options; |
8406 const { |
10306 const { |
8407 blockName, |
10307 blockName, |
8408 attrs = {}, |
10308 attrs = {}, |
8409 innerBlocks = [], |
10309 innerBlocks = [], |
8410 innerContent = [] |
10310 innerContent = [] |
8411 } = rawBlock; |
10311 } = rawBlock; |
8412 let childIndex = 0; |
10312 let childIndex = 0; |
8413 const content = innerContent.map(item => // `null` denotes a nested block, otherwise we have an HTML fragment. |
10313 const content = innerContent.map(item => |
10314 // `null` denotes a nested block, otherwise we have an HTML fragment. |
|
8414 item !== null ? item : serializeRawBlock(innerBlocks[childIndex++], options)).join('\n').replace(/\n+/g, '\n').trim(); |
10315 item !== null ? item : serializeRawBlock(innerBlocks[childIndex++], options)).join('\n').replace(/\n+/g, '\n').trim(); |
8415 return isCommentDelimited ? getCommentDelimitedContent(blockName, attrs, content) : content; |
10316 return isCommentDelimited ? getCommentDelimitedContent(blockName, attrs, content) : content; |
8416 } |
10317 } |
8417 |
10318 |
10319 ;// CONCATENATED MODULE: external "ReactJSXRuntime" |
|
10320 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"]; |
|
8418 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/serializer.js |
10321 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/serializer.js |
8419 |
|
8420 |
|
8421 /** |
|
8422 * External dependencies |
|
8423 */ |
|
8424 |
|
8425 /** |
10322 /** |
8426 * WordPress dependencies |
10323 * WordPress dependencies |
8427 */ |
10324 */ |
8428 |
10325 |
8429 |
10326 |
8457 // Generated HTML classes for blocks follow the `wp-block-{name}` nomenclature. |
10354 // Generated HTML classes for blocks follow the `wp-block-{name}` nomenclature. |
8458 // Blocks provided by WordPress drop the prefixes 'core/' or 'core-' (historically used in 'core-embed/'). |
10355 // Blocks provided by WordPress drop the prefixes 'core/' or 'core-' (historically used in 'core-embed/'). |
8459 const className = 'wp-block-' + blockName.replace(/\//, '-').replace(/^core-/, ''); |
10356 const className = 'wp-block-' + blockName.replace(/\//, '-').replace(/^core-/, ''); |
8460 return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getBlockDefaultClassName', className, blockName); |
10357 return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getBlockDefaultClassName', className, blockName); |
8461 } |
10358 } |
10359 |
|
8462 /** |
10360 /** |
8463 * Returns the block's default menu item classname from its name. |
10361 * Returns the block's default menu item classname from its name. |
8464 * |
10362 * |
8465 * @param {string} blockName The block name. |
10363 * @param {string} blockName The block name. |
8466 * |
10364 * |
8467 * @return {string} The block's default menu item class. |
10365 * @return {string} The block's default menu item class. |
8468 */ |
10366 */ |
8469 |
|
8470 function getBlockMenuDefaultClassName(blockName) { |
10367 function getBlockMenuDefaultClassName(blockName) { |
8471 // Generated HTML classes for blocks follow the `editor-block-list-item-{name}` nomenclature. |
10368 // Generated HTML classes for blocks follow the `editor-block-list-item-{name}` nomenclature. |
8472 // Blocks provided by WordPress drop the prefixes 'core/' or 'core-' (historically used in 'core-embed/'). |
10369 // Blocks provided by WordPress drop the prefixes 'core/' or 'core-' (historically used in 'core-embed/'). |
8473 const className = 'editor-block-list-item-' + blockName.replace(/\//, '-').replace(/^core-/, ''); |
10370 const className = 'editor-block-list-item-' + blockName.replace(/\//, '-').replace(/^core-/, ''); |
8474 return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getBlockMenuDefaultClassName', className, blockName); |
10371 return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getBlockMenuDefaultClassName', className, blockName); |
8475 } |
10372 } |
8476 const blockPropsProvider = {}; |
10373 const blockPropsProvider = {}; |
8477 const innerBlocksPropsProvider = {}; |
10374 const innerBlocksPropsProvider = {}; |
10375 |
|
8478 /** |
10376 /** |
8479 * Call within a save function to get the props for the block wrapper. |
10377 * Call within a save function to get the props for the block wrapper. |
8480 * |
10378 * |
8481 * @param {Object} props Optional. Props to pass to the element. |
10379 * @param {Object} props Optional. Props to pass to the element. |
8482 */ |
10380 */ |
8483 |
10381 function getBlockProps(props = {}) { |
8484 function getBlockProps() { |
|
8485 let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
8486 const { |
10382 const { |
8487 blockType, |
10383 blockType, |
8488 attributes |
10384 attributes |
8489 } = blockPropsProvider; |
10385 } = blockPropsProvider; |
8490 return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getSaveContent.extraProps', { ...props |
10386 return getBlockProps.skipFilters ? props : (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getSaveContent.extraProps', { |
10387 ...props |
|
8491 }, blockType, attributes); |
10388 }, blockType, attributes); |
8492 } |
10389 } |
10390 |
|
8493 /** |
10391 /** |
8494 * Call within a save function to get the props for the inner blocks wrapper. |
10392 * Call within a save function to get the props for the inner blocks wrapper. |
8495 * |
10393 * |
8496 * @param {Object} props Optional. Props to pass to the element. |
10394 * @param {Object} props Optional. Props to pass to the element. |
8497 */ |
10395 */ |
8498 |
10396 function getInnerBlocksProps(props = {}) { |
8499 function getInnerBlocksProps() { |
|
8500 let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
8501 const { |
10397 const { |
8502 innerBlocks |
10398 innerBlocks |
8503 } = innerBlocksPropsProvider; // Value is an array of blocks, so defer to block serializer. |
10399 } = innerBlocksPropsProvider; |
8504 |
10400 // Allow a different component to be passed to getSaveElement to handle |
8505 const html = serializer_serialize(innerBlocks, { |
10401 // inner blocks, bypassing the default serialisation. |
10402 if (!Array.isArray(innerBlocks)) { |
|
10403 return { |
|
10404 ...props, |
|
10405 children: innerBlocks |
|
10406 }; |
|
10407 } |
|
10408 // Value is an array of blocks, so defer to block serializer. |
|
10409 const html = serialize(innerBlocks, { |
|
8506 isInnerBlocks: true |
10410 isInnerBlocks: true |
8507 }); // Use special-cased raw HTML tag to avoid default escaping. |
10411 }); |
8508 |
10412 // Use special-cased raw HTML tag to avoid default escaping. |
8509 const children = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, null, html); |
10413 const children = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.RawHTML, { |
8510 return { ...props, |
10414 children: html |
10415 }); |
|
10416 return { |
|
10417 ...props, |
|
8511 children |
10418 children |
8512 }; |
10419 }; |
8513 } |
10420 } |
10421 |
|
8514 /** |
10422 /** |
8515 * Given a block type containing a save render implementation and attributes, returns the |
10423 * Given a block type containing a save render implementation and attributes, returns the |
8516 * enhanced element to be saved or string when raw HTML expected. |
10424 * enhanced element to be saved or string when raw HTML expected. |
8517 * |
10425 * |
8518 * @param {string|Object} blockTypeOrName Block type or name. |
10426 * @param {string|Object} blockTypeOrName Block type or name. |
8519 * @param {Object} attributes Block attributes. |
10427 * @param {Object} attributes Block attributes. |
8520 * @param {?Array} innerBlocks Nested blocks. |
10428 * @param {?Array} innerBlocks Nested blocks. |
8521 * |
10429 * |
8522 * @return {Object|string} Save element or raw HTML string. |
10430 * @return {Object|string} Save element or raw HTML string. |
8523 */ |
10431 */ |
8524 |
10432 function getSaveElement(blockTypeOrName, attributes, innerBlocks = []) { |
8525 function getSaveElement(blockTypeOrName, attributes) { |
|
8526 let innerBlocks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; |
|
8527 const blockType = normalizeBlockType(blockTypeOrName); |
10433 const blockType = normalizeBlockType(blockTypeOrName); |
10434 if (!blockType?.save) { |
|
10435 return null; |
|
10436 } |
|
8528 let { |
10437 let { |
8529 save |
10438 save |
8530 } = blockType; // Component classes are unsupported for save since serialization must |
10439 } = blockType; |
10440 |
|
10441 // Component classes are unsupported for save since serialization must |
|
8531 // occur synchronously. For improved interoperability with higher-order |
10442 // occur synchronously. For improved interoperability with higher-order |
8532 // components which often return component class, emulate basic support. |
10443 // components which often return component class, emulate basic support. |
8533 |
|
8534 if (save.prototype instanceof external_wp_element_namespaceObject.Component) { |
10444 if (save.prototype instanceof external_wp_element_namespaceObject.Component) { |
8535 const instance = new save({ |
10445 const instance = new save({ |
8536 attributes |
10446 attributes |
8537 }); |
10447 }); |
8538 save = instance.render.bind(instance); |
10448 save = instance.render.bind(instance); |
8539 } |
10449 } |
8540 |
|
8541 blockPropsProvider.blockType = blockType; |
10450 blockPropsProvider.blockType = blockType; |
8542 blockPropsProvider.attributes = attributes; |
10451 blockPropsProvider.attributes = attributes; |
8543 innerBlocksPropsProvider.innerBlocks = innerBlocks; |
10452 innerBlocksPropsProvider.innerBlocks = innerBlocks; |
8544 let element = save({ |
10453 let element = save({ |
8545 attributes, |
10454 attributes, |
8546 innerBlocks |
10455 innerBlocks |
8547 }); |
10456 }); |
8548 |
10457 if (element !== null && typeof element === 'object' && (0,external_wp_hooks_namespaceObject.hasFilter)('blocks.getSaveContent.extraProps') && !(blockType.apiVersion > 1)) { |
8549 if ((0,external_lodash_namespaceObject.isObject)(element) && (0,external_wp_hooks_namespaceObject.hasFilter)('blocks.getSaveContent.extraProps') && !(blockType.apiVersion > 1)) { |
|
8550 /** |
10458 /** |
8551 * Filters the props applied to the block save result element. |
10459 * Filters the props applied to the block save result element. |
8552 * |
10460 * |
8553 * @param {Object} props Props applied to save element. |
10461 * @param {Object} props Props applied to save element. |
8554 * @param {WPBlock} blockType Block type definition. |
10462 * @param {WPBlock} blockType Block type definition. |
8555 * @param {Object} attributes Block attributes. |
10463 * @param {Object} attributes Block attributes. |
8556 */ |
10464 */ |
8557 const props = (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getSaveContent.extraProps', { ...element.props |
10465 const props = (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getSaveContent.extraProps', { |
10466 ...element.props |
|
8558 }, blockType, attributes); |
10467 }, blockType, attributes); |
8559 |
|
8560 if (!external_wp_isShallowEqual_default()(props, element.props)) { |
10468 if (!external_wp_isShallowEqual_default()(props, element.props)) { |
8561 element = (0,external_wp_element_namespaceObject.cloneElement)(element, props); |
10469 element = (0,external_wp_element_namespaceObject.cloneElement)(element, props); |
8562 } |
10470 } |
8563 } |
10471 } |
10472 |
|
8564 /** |
10473 /** |
8565 * Filters the save result of a block during serialization. |
10474 * Filters the save result of a block during serialization. |
8566 * |
10475 * |
8567 * @param {WPElement} element Block save result. |
10476 * @param {Element} element Block save result. |
8568 * @param {WPBlock} blockType Block type definition. |
10477 * @param {WPBlock} blockType Block type definition. |
8569 * @param {Object} attributes Block attributes. |
10478 * @param {Object} attributes Block attributes. |
8570 */ |
10479 */ |
8571 |
|
8572 |
|
8573 return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getSaveElement', element, blockType, attributes); |
10480 return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getSaveElement', element, blockType, attributes); |
8574 } |
10481 } |
10482 |
|
8575 /** |
10483 /** |
8576 * Given a block type containing a save render implementation and attributes, returns the |
10484 * Given a block type containing a save render implementation and attributes, returns the |
8577 * static markup to be saved. |
10485 * static markup to be saved. |
8578 * |
10486 * |
8579 * @param {string|Object} blockTypeOrName Block type or name. |
10487 * @param {string|Object} blockTypeOrName Block type or name. |
8580 * @param {Object} attributes Block attributes. |
10488 * @param {Object} attributes Block attributes. |
8581 * @param {?Array} innerBlocks Nested blocks. |
10489 * @param {?Array} innerBlocks Nested blocks. |
8582 * |
10490 * |
8583 * @return {string} Save content. |
10491 * @return {string} Save content. |
8584 */ |
10492 */ |
8585 |
|
8586 function getSaveContent(blockTypeOrName, attributes, innerBlocks) { |
10493 function getSaveContent(blockTypeOrName, attributes, innerBlocks) { |
8587 const blockType = normalizeBlockType(blockTypeOrName); |
10494 const blockType = normalizeBlockType(blockTypeOrName); |
8588 return (0,external_wp_element_namespaceObject.renderToString)(getSaveElement(blockType, attributes, innerBlocks)); |
10495 return (0,external_wp_element_namespaceObject.renderToString)(getSaveElement(blockType, attributes, innerBlocks)); |
8589 } |
10496 } |
10497 |
|
8590 /** |
10498 /** |
8591 * Returns attributes which are to be saved and serialized into the block |
10499 * Returns attributes which are to be saved and serialized into the block |
8592 * comment delimiter. |
10500 * comment delimiter. |
8593 * |
10501 * |
8594 * When a block exists in memory it contains as its attributes both those |
10502 * When a block exists in memory it contains as its attributes both those |
8601 * @param {Object<string,*>} blockType Block type. |
10509 * @param {Object<string,*>} blockType Block type. |
8602 * @param {Object<string,*>} attributes Attributes from in-memory block data. |
10510 * @param {Object<string,*>} attributes Attributes from in-memory block data. |
8603 * |
10511 * |
8604 * @return {Object<string,*>} Subset of attributes for comment serialization. |
10512 * @return {Object<string,*>} Subset of attributes for comment serialization. |
8605 */ |
10513 */ |
8606 |
|
8607 function getCommentAttributes(blockType, attributes) { |
10514 function getCommentAttributes(blockType, attributes) { |
8608 return (0,external_lodash_namespaceObject.reduce)(blockType.attributes, (accumulator, attributeSchema, key) => { |
10515 var _blockType$attributes; |
8609 const value = attributes[key]; // Ignore undefined values. |
10516 return Object.entries((_blockType$attributes = blockType.attributes) !== null && _blockType$attributes !== void 0 ? _blockType$attributes : {}).reduce((accumulator, [key, attributeSchema]) => { |
8610 |
10517 const value = attributes[key]; |
10518 // Ignore undefined values. |
|
8611 if (undefined === value) { |
10519 if (undefined === value) { |
8612 return accumulator; |
10520 return accumulator; |
8613 } // Ignore all attributes but the ones with an "undefined" source |
10521 } |
10522 |
|
10523 // Ignore all attributes but the ones with an "undefined" source |
|
8614 // "undefined" source refers to attributes saved in the block comment. |
10524 // "undefined" source refers to attributes saved in the block comment. |
8615 |
|
8616 |
|
8617 if (attributeSchema.source !== undefined) { |
10525 if (attributeSchema.source !== undefined) { |
8618 return accumulator; |
10526 return accumulator; |
8619 } // Ignore default value. |
10527 } |
8620 |
10528 |
8621 |
10529 // Ignore default value. |
8622 if ('default' in attributeSchema && attributeSchema.default === value) { |
10530 if ('default' in attributeSchema && JSON.stringify(attributeSchema.default) === JSON.stringify(value)) { |
8623 return accumulator; |
10531 return accumulator; |
8624 } // Otherwise, include in comment set. |
10532 } |
8625 |
10533 |
8626 |
10534 // Otherwise, include in comment set. |
8627 accumulator[key] = value; |
10535 accumulator[key] = value; |
8628 return accumulator; |
10536 return accumulator; |
8629 }, {}); |
10537 }, {}); |
8630 } |
10538 } |
10539 |
|
8631 /** |
10540 /** |
8632 * Given an attributes object, returns a string in the serialized attributes |
10541 * Given an attributes object, returns a string in the serialized attributes |
8633 * format prepared for post content. |
10542 * format prepared for post content. |
8634 * |
10543 * |
8635 * @param {Object} attributes Attributes object. |
10544 * @param {Object} attributes Attributes object. |
8636 * |
10545 * |
8637 * @return {string} Serialized attributes. |
10546 * @return {string} Serialized attributes. |
8638 */ |
10547 */ |
8639 |
|
8640 function serializeAttributes(attributes) { |
10548 function serializeAttributes(attributes) { |
8641 return JSON.stringify(attributes) // Don't break HTML comments. |
10549 return JSON.stringify(attributes) |
8642 .replace(/--/g, '\\u002d\\u002d') // Don't break non-standard-compliant tools. |
10550 // Don't break HTML comments. |
8643 .replace(/</g, '\\u003c').replace(/>/g, '\\u003e').replace(/&/g, '\\u0026') // Bypass server stripslashes behavior which would unescape stringify's |
10551 .replace(/--/g, '\\u002d\\u002d') |
10552 |
|
10553 // Don't break non-standard-compliant tools. |
|
10554 .replace(/</g, '\\u003c').replace(/>/g, '\\u003e').replace(/&/g, '\\u0026') |
|
10555 |
|
10556 // Bypass server stripslashes behavior which would unescape stringify's |
|
8644 // escaping of quotation mark. |
10557 // escaping of quotation mark. |
8645 // |
10558 // |
8646 // See: https://developer.wordpress.org/reference/functions/wp_kses_stripslashes/ |
10559 // See: https://developer.wordpress.org/reference/functions/wp_kses_stripslashes/ |
8647 .replace(/\\"/g, '\\u0022'); |
10560 .replace(/\\"/g, '\\u0022'); |
8648 } |
10561 } |
10562 |
|
8649 /** |
10563 /** |
8650 * Given a block object, returns the Block's Inner HTML markup. |
10564 * Given a block object, returns the Block's Inner HTML markup. |
8651 * |
10565 * |
8652 * @param {Object} block Block instance. |
10566 * @param {Object} block Block instance. |
8653 * |
10567 * |
8654 * @return {string} HTML. |
10568 * @return {string} HTML. |
8655 */ |
10569 */ |
8656 |
|
8657 function getBlockInnerHTML(block) { |
10570 function getBlockInnerHTML(block) { |
8658 // If block was parsed as invalid or encounters an error while generating |
10571 // If block was parsed as invalid or encounters an error while generating |
8659 // save content, use original content instead to avoid content loss. If a |
10572 // save content, use original content instead to avoid content loss. If a |
8660 // block contains nested content, exempt it from this condition because we |
10573 // block contains nested content, exempt it from this condition because we |
8661 // otherwise have no access to its original content and content loss would |
10574 // otherwise have no access to its original content and content loss would |
8662 // still occur. |
10575 // still occur. |
8663 let saveContent = block.originalContent; |
10576 let saveContent = block.originalContent; |
8664 |
|
8665 if (block.isValid || block.innerBlocks.length) { |
10577 if (block.isValid || block.innerBlocks.length) { |
8666 try { |
10578 try { |
8667 saveContent = getSaveContent(block.name, block.attributes, block.innerBlocks); |
10579 saveContent = getSaveContent(block.name, block.attributes, block.innerBlocks); |
8668 } catch (error) {} |
10580 } catch (error) {} |
8669 } |
10581 } |
8670 |
|
8671 return saveContent; |
10582 return saveContent; |
8672 } |
10583 } |
10584 |
|
8673 /** |
10585 /** |
8674 * Returns the content of a block, including comment delimiters. |
10586 * Returns the content of a block, including comment delimiters. |
8675 * |
10587 * |
8676 * @param {string} rawBlockName Block name. |
10588 * @param {string} rawBlockName Block name. |
8677 * @param {Object} attributes Block attributes. |
10589 * @param {Object} attributes Block attributes. |
8678 * @param {string} content Block save content. |
10590 * @param {string} content Block save content. |
8679 * |
10591 * |
8680 * @return {string} Comment-delimited block content. |
10592 * @return {string} Comment-delimited block content. |
8681 */ |
10593 */ |
8682 |
|
8683 function getCommentDelimitedContent(rawBlockName, attributes, content) { |
10594 function getCommentDelimitedContent(rawBlockName, attributes, content) { |
8684 const serializedAttributes = !(0,external_lodash_namespaceObject.isEmpty)(attributes) ? serializeAttributes(attributes) + ' ' : ''; // Strip core blocks of their namespace prefix. |
10595 const serializedAttributes = attributes && Object.entries(attributes).length ? serializeAttributes(attributes) + ' ' : ''; |
8685 |
10596 |
8686 const blockName = (0,external_lodash_namespaceObject.startsWith)(rawBlockName, 'core/') ? rawBlockName.slice(5) : rawBlockName; // @todo make the `wp:` prefix potentially configurable. |
10597 // Strip core blocks of their namespace prefix. |
10598 const blockName = rawBlockName?.startsWith('core/') ? rawBlockName.slice(5) : rawBlockName; |
|
10599 |
|
10600 // @todo make the `wp:` prefix potentially configurable. |
|
8687 |
10601 |
8688 if (!content) { |
10602 if (!content) { |
8689 return `<!-- wp:${blockName} ${serializedAttributes}/-->`; |
10603 return `<!-- wp:${blockName} ${serializedAttributes}/-->`; |
8690 } |
10604 } |
8691 |
|
8692 return `<!-- wp:${blockName} ${serializedAttributes}-->\n` + content + `\n<!-- /wp:${blockName} -->`; |
10605 return `<!-- wp:${blockName} ${serializedAttributes}-->\n` + content + `\n<!-- /wp:${blockName} -->`; |
8693 } |
10606 } |
10607 |
|
8694 /** |
10608 /** |
8695 * Returns the content of a block, including comment delimiters, determining |
10609 * Returns the content of a block, including comment delimiters, determining |
8696 * serialized attributes and content form from the current state of the block. |
10610 * serialized attributes and content form from the current state of the block. |
8697 * |
10611 * |
8698 * @param {WPBlock} block Block instance. |
10612 * @param {WPBlock} block Block instance. |
8699 * @param {WPBlockSerializationOptions} options Serialization options. |
10613 * @param {WPBlockSerializationOptions} options Serialization options. |
8700 * |
10614 * |
8701 * @return {string} Serialized block. |
10615 * @return {string} Serialized block. |
8702 */ |
10616 */ |
8703 |
10617 function serializeBlock(block, { |
8704 function serializeBlock(block) { |
10618 isInnerBlocks = false |
8705 let { |
10619 } = {}) { |
8706 isInnerBlocks = false |
|
8707 } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
8708 |
|
8709 if (!block.isValid && block.__unstableBlockSource) { |
10620 if (!block.isValid && block.__unstableBlockSource) { |
8710 return serializeRawBlock(block.__unstableBlockSource); |
10621 return serializeRawBlock(block.__unstableBlockSource); |
8711 } |
10622 } |
8712 |
|
8713 const blockName = block.name; |
10623 const blockName = block.name; |
8714 const saveContent = getBlockInnerHTML(block); |
10624 const saveContent = getBlockInnerHTML(block); |
8715 |
|
8716 if (blockName === getUnregisteredTypeHandlerName() || !isInnerBlocks && blockName === getFreeformContentHandlerName()) { |
10625 if (blockName === getUnregisteredTypeHandlerName() || !isInnerBlocks && blockName === getFreeformContentHandlerName()) { |
8717 return saveContent; |
10626 return saveContent; |
8718 } |
10627 } |
8719 |
10628 const blockType = getBlockType(blockName); |
8720 const blockType = registration_getBlockType(blockName); |
10629 if (!blockType) { |
10630 return saveContent; |
|
10631 } |
|
8721 const saveAttributes = getCommentAttributes(blockType, block.attributes); |
10632 const saveAttributes = getCommentAttributes(blockType, block.attributes); |
8722 return getCommentDelimitedContent(blockName, saveAttributes, saveContent); |
10633 return getCommentDelimitedContent(blockName, saveAttributes, saveContent); |
8723 } |
10634 } |
8724 function __unstableSerializeAndClean(blocks) { |
10635 function __unstableSerializeAndClean(blocks) { |
8725 // A single unmodified default block is assumed to |
10636 // A single unmodified default block is assumed to |
8726 // be equivalent to an empty post. |
10637 // be equivalent to an empty post. |
8727 if (blocks.length === 1 && isUnmodifiedDefaultBlock(blocks[0])) { |
10638 if (blocks.length === 1 && isUnmodifiedDefaultBlock(blocks[0])) { |
8728 blocks = []; |
10639 blocks = []; |
8729 } |
10640 } |
8730 |
10641 let content = serialize(blocks); |
8731 let content = serializer_serialize(blocks); // For compatibility, treat a post consisting of a |
10642 |
10643 // For compatibility, treat a post consisting of a |
|
8732 // single freeform block as legacy content and apply |
10644 // single freeform block as legacy content and apply |
8733 // pre-block-editor removep'd content formatting. |
10645 // pre-block-editor removep'd content formatting. |
8734 |
10646 if (blocks.length === 1 && blocks[0].name === getFreeformContentHandlerName() && blocks[0].name === 'core/freeform') { |
8735 if (blocks.length === 1 && blocks[0].name === getFreeformContentHandlerName()) { |
|
8736 content = (0,external_wp_autop_namespaceObject.removep)(content); |
10647 content = (0,external_wp_autop_namespaceObject.removep)(content); |
8737 } |
10648 } |
8738 |
|
8739 return content; |
10649 return content; |
8740 } |
10650 } |
10651 |
|
8741 /** |
10652 /** |
8742 * Takes a block or set of blocks and returns the serialized post content. |
10653 * Takes a block or set of blocks and returns the serialized post content. |
8743 * |
10654 * |
8744 * @param {Array} blocks Block(s) to serialize. |
10655 * @param {Array} blocks Block(s) to serialize. |
8745 * @param {WPBlockSerializationOptions} options Serialization options. |
10656 * @param {WPBlockSerializationOptions} options Serialization options. |
8746 * |
10657 * |
8747 * @return {string} The post content. |
10658 * @return {string} The post content. |
8748 */ |
10659 */ |
8749 |
10660 function serialize(blocks, options) { |
8750 function serializer_serialize(blocks, options) { |
10661 const blocksArray = Array.isArray(blocks) ? blocks : [blocks]; |
8751 return (0,external_lodash_namespaceObject.castArray)(blocks).map(block => serializeBlock(block, options)).join('\n\n'); |
10662 return blocksArray.map(block => serializeBlock(block, options)).join('\n\n'); |
8752 } |
10663 } |
8753 |
10664 |
8754 ;// CONCATENATED MODULE: ./node_modules/simple-html-tokenizer/dist/es6/index.js |
10665 ;// CONCATENATED MODULE: ./node_modules/simple-html-tokenizer/dist/es6/index.js |
8755 /** |
10666 /** |
8756 * generated from https://raw.githubusercontent.com/w3c/html/26b5126f96f736f796b9e29718138919dd513744/entities.json |
10667 * generated from https://raw.githubusercontent.com/w3c/html/26b5126f96f736f796b9e29718138919dd513744/entities.json |
9650 return tokenizer.tokenize(input); |
11561 return tokenizer.tokenize(input); |
9651 } |
11562 } |
9652 |
11563 |
9653 |
11564 |
9654 |
11565 |
9655 ;// CONCATENATED MODULE: external ["wp","deprecated"] |
11566 // EXTERNAL MODULE: ./node_modules/fast-deep-equal/es6/index.js |
9656 var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"]; |
11567 var es6 = __webpack_require__(7734); |
9657 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject); |
11568 var es6_default = /*#__PURE__*/__webpack_require__.n(es6); |
9658 ;// CONCATENATED MODULE: external ["wp","htmlEntities"] |
11569 ;// CONCATENATED MODULE: external ["wp","htmlEntities"] |
9659 var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"]; |
11570 const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"]; |
9660 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/validation/logger.js |
11571 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/validation/logger.js |
9661 /** |
11572 /** |
9662 * @typedef LoggerItem |
11573 * @typedef LoggerItem |
9663 * @property {Function} log Which logger recorded the message |
11574 * @property {Function} log Which logger recorded the message |
9664 * @property {Array<any>} args White arguments were supplied to the logger |
11575 * @property {Array<any>} args White arguments were supplied to the logger |
9665 */ |
11576 */ |
11577 |
|
9666 function createLogger() { |
11578 function createLogger() { |
9667 /** |
11579 /** |
9668 * Creates a log handler with block validation prefix. |
11580 * Creates a log handler with block validation prefix. |
9669 * |
11581 * |
9670 * @param {Function} logger Original logger function. |
11582 * @param {Function} logger Original logger function. |
9671 * |
11583 * |
9672 * @return {Function} Augmented logger function. |
11584 * @return {Function} Augmented logger function. |
9673 */ |
11585 */ |
9674 function createLogHandler(logger) { |
11586 function createLogHandler(logger) { |
9675 let log = function (message) { |
11587 let log = (message, ...args) => logger('Block validation: ' + message, ...args); |
9676 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
11588 |
9677 args[_key - 1] = arguments[_key]; |
11589 // In test environments, pre-process string substitutions to improve |
9678 } |
|
9679 |
|
9680 return logger('Block validation: ' + message, ...args); |
|
9681 }; // In test environments, pre-process string substitutions to improve |
|
9682 // readability of error messages. We'd prefer to avoid pulling in this |
11590 // readability of error messages. We'd prefer to avoid pulling in this |
9683 // dependency in runtime environments, and it can be dropped by a combo |
11591 // dependency in runtime environments, and it can be dropped by a combo |
9684 // of Webpack env substitution + UglifyJS dead code elimination. |
11592 // of Webpack env substitution + UglifyJS dead code elimination. |
9685 |
|
9686 |
|
9687 if (false) {} |
11593 if (false) {} |
9688 |
|
9689 return log; |
11594 return log; |
9690 } |
11595 } |
9691 |
|
9692 return { |
11596 return { |
9693 // eslint-disable-next-line no-console |
11597 // eslint-disable-next-line no-console |
9694 error: createLogHandler(console.error), |
11598 error: createLogHandler(console.error), |
9695 // eslint-disable-next-line no-console |
11599 // eslint-disable-next-line no-console |
9696 warning: createLogHandler(console.warn), |
11600 warning: createLogHandler(console.warn), |
9697 |
|
9698 getItems() { |
11601 getItems() { |
9699 return []; |
11602 return []; |
9700 } |
11603 } |
9701 |
|
9702 }; |
11604 }; |
9703 } |
11605 } |
9704 function createQueuedLogger() { |
11606 function createQueuedLogger() { |
9705 /** |
11607 /** |
9706 * The list of enqueued log actions to print. |
11608 * The list of enqueued log actions to print. |
9708 * @type {Array<LoggerItem>} |
11610 * @type {Array<LoggerItem>} |
9709 */ |
11611 */ |
9710 const queue = []; |
11612 const queue = []; |
9711 const logger = createLogger(); |
11613 const logger = createLogger(); |
9712 return { |
11614 return { |
9713 error() { |
11615 error(...args) { |
9714 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { |
|
9715 args[_key2] = arguments[_key2]; |
|
9716 } |
|
9717 |
|
9718 queue.push({ |
11616 queue.push({ |
9719 log: logger.error, |
11617 log: logger.error, |
9720 args |
11618 args |
9721 }); |
11619 }); |
9722 }, |
11620 }, |
9723 |
11621 warning(...args) { |
9724 warning() { |
|
9725 for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { |
|
9726 args[_key3] = arguments[_key3]; |
|
9727 } |
|
9728 |
|
9729 queue.push({ |
11622 queue.push({ |
9730 log: logger.warning, |
11623 log: logger.warning, |
9731 args |
11624 args |
9732 }); |
11625 }); |
9733 }, |
11626 }, |
9734 |
|
9735 getItems() { |
11627 getItems() { |
9736 return queue; |
11628 return queue; |
9737 } |
11629 } |
9738 |
|
9739 }; |
11630 }; |
9740 } |
11631 } |
9741 |
11632 |
9742 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/validation/index.js |
11633 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/validation/index.js |
9743 /** |
11634 /** |
9744 * External dependencies |
11635 * External dependencies |
9745 */ |
11636 */ |
9746 |
11637 |
9747 |
11638 |
11639 |
|
9748 /** |
11640 /** |
9749 * WordPress dependencies |
11641 * WordPress dependencies |
9750 */ |
11642 */ |
9751 |
11643 |
9752 |
11644 |
9758 |
11650 |
9759 |
11651 |
9760 |
11652 |
9761 |
11653 |
9762 /** @typedef {import('../parser').WPBlock} WPBlock */ |
11654 /** @typedef {import('../parser').WPBlock} WPBlock */ |
9763 |
|
9764 /** @typedef {import('../registration').WPBlockType} WPBlockType */ |
11655 /** @typedef {import('../registration').WPBlockType} WPBlockType */ |
9765 |
|
9766 /** @typedef {import('./logger').LoggerItem} LoggerItem */ |
11656 /** @typedef {import('./logger').LoggerItem} LoggerItem */ |
9767 |
11657 |
11658 const identity = x => x; |
|
11659 |
|
9768 /** |
11660 /** |
9769 * Globally matches any consecutive whitespace |
11661 * Globally matches any consecutive whitespace |
9770 * |
11662 * |
9771 * @type {RegExp} |
11663 * @type {RegExp} |
9772 */ |
11664 */ |
9773 |
|
9774 const REGEXP_WHITESPACE = /[\t\n\r\v\f ]+/g; |
11665 const REGEXP_WHITESPACE = /[\t\n\r\v\f ]+/g; |
11666 |
|
9775 /** |
11667 /** |
9776 * Matches a string containing only whitespace |
11668 * Matches a string containing only whitespace |
9777 * |
11669 * |
9778 * @type {RegExp} |
11670 * @type {RegExp} |
9779 */ |
11671 */ |
9780 |
|
9781 const REGEXP_ONLY_WHITESPACE = /^[\t\n\r\v\f ]*$/; |
11672 const REGEXP_ONLY_WHITESPACE = /^[\t\n\r\v\f ]*$/; |
11673 |
|
9782 /** |
11674 /** |
9783 * Matches a CSS URL type value |
11675 * Matches a CSS URL type value |
9784 * |
11676 * |
9785 * @type {RegExp} |
11677 * @type {RegExp} |
9786 */ |
11678 */ |
9787 |
|
9788 const REGEXP_STYLE_URL_TYPE = /^url\s*\(['"\s]*(.*?)['"\s]*\)$/; |
11679 const REGEXP_STYLE_URL_TYPE = /^url\s*\(['"\s]*(.*?)['"\s]*\)$/; |
11680 |
|
9789 /** |
11681 /** |
9790 * Boolean attributes are attributes whose presence as being assigned is |
11682 * Boolean attributes are attributes whose presence as being assigned is |
9791 * meaningful, even if only empty. |
11683 * meaningful, even if only empty. |
9792 * |
11684 * |
9793 * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes |
11685 * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes |
9799 * [ tr.firstChild.textContent.trim() ]: true |
11691 * [ tr.firstChild.textContent.trim() ]: true |
9800 * } ), {} ) ).sort(); |
11692 * } ), {} ) ).sort(); |
9801 * |
11693 * |
9802 * @type {Array} |
11694 * @type {Array} |
9803 */ |
11695 */ |
9804 |
|
9805 const BOOLEAN_ATTRIBUTES = ['allowfullscreen', 'allowpaymentrequest', 'allowusermedia', 'async', 'autofocus', 'autoplay', 'checked', 'controls', 'default', 'defer', 'disabled', 'download', 'formnovalidate', 'hidden', 'ismap', 'itemscope', 'loop', 'multiple', 'muted', 'nomodule', 'novalidate', 'open', 'playsinline', 'readonly', 'required', 'reversed', 'selected', 'typemustmatch']; |
11696 const BOOLEAN_ATTRIBUTES = ['allowfullscreen', 'allowpaymentrequest', 'allowusermedia', 'async', 'autofocus', 'autoplay', 'checked', 'controls', 'default', 'defer', 'disabled', 'download', 'formnovalidate', 'hidden', 'ismap', 'itemscope', 'loop', 'multiple', 'muted', 'nomodule', 'novalidate', 'open', 'playsinline', 'readonly', 'required', 'reversed', 'selected', 'typemustmatch']; |
11697 |
|
9806 /** |
11698 /** |
9807 * Enumerated attributes are attributes which must be of a specific value form. |
11699 * Enumerated attributes are attributes which must be of a specific value form. |
9808 * Like boolean attributes, these are meaningful if specified, even if not of a |
11700 * Like boolean attributes, these are meaningful if specified, even if not of a |
9809 * valid enumerated value. |
11701 * valid enumerated value. |
9810 * |
11702 * |
9817 * [ tr.firstChild.textContent.trim() ]: true |
11709 * [ tr.firstChild.textContent.trim() ]: true |
9818 * } ), {} ) ).sort(); |
11710 * } ), {} ) ).sort(); |
9819 * |
11711 * |
9820 * @type {Array} |
11712 * @type {Array} |
9821 */ |
11713 */ |
9822 |
|
9823 const ENUMERATED_ATTRIBUTES = ['autocapitalize', 'autocomplete', 'charset', 'contenteditable', 'crossorigin', 'decoding', 'dir', 'draggable', 'enctype', 'formenctype', 'formmethod', 'http-equiv', 'inputmode', 'kind', 'method', 'preload', 'scope', 'shape', 'spellcheck', 'translate', 'type', 'wrap']; |
11714 const ENUMERATED_ATTRIBUTES = ['autocapitalize', 'autocomplete', 'charset', 'contenteditable', 'crossorigin', 'decoding', 'dir', 'draggable', 'enctype', 'formenctype', 'formmethod', 'http-equiv', 'inputmode', 'kind', 'method', 'preload', 'scope', 'shape', 'spellcheck', 'translate', 'type', 'wrap']; |
11715 |
|
9824 /** |
11716 /** |
9825 * Meaningful attributes are those who cannot be safely ignored when omitted in |
11717 * Meaningful attributes are those who cannot be safely ignored when omitted in |
9826 * one HTML markup string and not another. |
11718 * one HTML markup string and not another. |
9827 * |
11719 * |
9828 * @type {Array} |
11720 * @type {Array} |
9829 */ |
11721 */ |
9830 |
|
9831 const MEANINGFUL_ATTRIBUTES = [...BOOLEAN_ATTRIBUTES, ...ENUMERATED_ATTRIBUTES]; |
11722 const MEANINGFUL_ATTRIBUTES = [...BOOLEAN_ATTRIBUTES, ...ENUMERATED_ATTRIBUTES]; |
11723 |
|
9832 /** |
11724 /** |
9833 * Array of functions which receive a text string on which to apply normalizing |
11725 * Array of functions which receive a text string on which to apply normalizing |
9834 * behavior for consideration in text token equivalence, carefully ordered from |
11726 * behavior for consideration in text token equivalence, carefully ordered from |
9835 * least-to-most expensive operations. |
11727 * least-to-most expensive operations. |
9836 * |
11728 * |
9837 * @type {Array} |
11729 * @type {Array} |
9838 */ |
11730 */ |
9839 |
11731 const TEXT_NORMALIZATIONS = [identity, getTextWithCollapsedWhitespace]; |
9840 const TEXT_NORMALIZATIONS = [external_lodash_namespaceObject.identity, getTextWithCollapsedWhitespace]; |
11732 |
9841 /** |
11733 /** |
9842 * Regular expression matching a named character reference. In lieu of bundling |
11734 * Regular expression matching a named character reference. In lieu of bundling |
9843 * a full set of references, the pattern covers the minimal necessary to test |
11735 * a full set of references, the pattern covers the minimal necessary to test |
9844 * positively against the full set. |
11736 * positively against the full set. |
9845 * |
11737 * |
9858 * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references |
11750 * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references |
9859 * @see https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references |
11751 * @see https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references |
9860 * |
11752 * |
9861 * @type {RegExp} |
11753 * @type {RegExp} |
9862 */ |
11754 */ |
9863 |
|
9864 const REGEXP_NAMED_CHARACTER_REFERENCE = /^[\da-z]+$/i; |
11755 const REGEXP_NAMED_CHARACTER_REFERENCE = /^[\da-z]+$/i; |
11756 |
|
9865 /** |
11757 /** |
9866 * Regular expression matching a decimal character reference. |
11758 * Regular expression matching a decimal character reference. |
9867 * |
11759 * |
9868 * "The ampersand must be followed by a U+0023 NUMBER SIGN character (#), |
11760 * "The ampersand must be followed by a U+0023 NUMBER SIGN character (#), |
9869 * followed by one or more ASCII digits, representing a base-ten integer" |
11761 * followed by one or more ASCII digits, representing a base-ten integer" |
9870 * |
11762 * |
9871 * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references |
11763 * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references |
9872 * |
11764 * |
9873 * @type {RegExp} |
11765 * @type {RegExp} |
9874 */ |
11766 */ |
9875 |
|
9876 const REGEXP_DECIMAL_CHARACTER_REFERENCE = /^#\d+$/; |
11767 const REGEXP_DECIMAL_CHARACTER_REFERENCE = /^#\d+$/; |
11768 |
|
9877 /** |
11769 /** |
9878 * Regular expression matching a hexadecimal character reference. |
11770 * Regular expression matching a hexadecimal character reference. |
9879 * |
11771 * |
9880 * "The ampersand must be followed by a U+0023 NUMBER SIGN character (#), which |
11772 * "The ampersand must be followed by a U+0023 NUMBER SIGN character (#), which |
9881 * must be followed by either a U+0078 LATIN SMALL LETTER X character (x) or a |
11773 * must be followed by either a U+0078 LATIN SMALL LETTER X character (x) or a |
9884 * |
11776 * |
9885 * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references |
11777 * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references |
9886 * |
11778 * |
9887 * @type {RegExp} |
11779 * @type {RegExp} |
9888 */ |
11780 */ |
9889 |
|
9890 const REGEXP_HEXADECIMAL_CHARACTER_REFERENCE = /^#x[\da-f]+$/i; |
11781 const REGEXP_HEXADECIMAL_CHARACTER_REFERENCE = /^#x[\da-f]+$/i; |
11782 |
|
9891 /** |
11783 /** |
9892 * Returns true if the given string is a valid character reference segment, or |
11784 * Returns true if the given string is a valid character reference segment, or |
9893 * false otherwise. The text should be stripped of `&` and `;` demarcations. |
11785 * false otherwise. The text should be stripped of `&` and `;` demarcations. |
9894 * |
11786 * |
9895 * @param {string} text Text to test. |
11787 * @param {string} text Text to test. |
9896 * |
11788 * |
9897 * @return {boolean} Whether text is valid character reference. |
11789 * @return {boolean} Whether text is valid character reference. |
9898 */ |
11790 */ |
9899 |
|
9900 function isValidCharacterReference(text) { |
11791 function isValidCharacterReference(text) { |
9901 return REGEXP_NAMED_CHARACTER_REFERENCE.test(text) || REGEXP_DECIMAL_CHARACTER_REFERENCE.test(text) || REGEXP_HEXADECIMAL_CHARACTER_REFERENCE.test(text); |
11792 return REGEXP_NAMED_CHARACTER_REFERENCE.test(text) || REGEXP_DECIMAL_CHARACTER_REFERENCE.test(text) || REGEXP_HEXADECIMAL_CHARACTER_REFERENCE.test(text); |
9902 } |
11793 } |
11794 |
|
9903 /** |
11795 /** |
9904 * Subsitute EntityParser class for `simple-html-tokenizer` which uses the |
11796 * Subsitute EntityParser class for `simple-html-tokenizer` which uses the |
9905 * implementation of `decodeEntities` from `html-entities`, in order to avoid |
11797 * implementation of `decodeEntities` from `html-entities`, in order to avoid |
9906 * bundling a massive named character reference. |
11798 * bundling a massive named character reference. |
9907 * |
11799 * |
9908 * @see https://github.com/tildeio/simple-html-tokenizer/tree/HEAD/src/entity-parser.ts |
11800 * @see https://github.com/tildeio/simple-html-tokenizer/tree/HEAD/src/entity-parser.ts |
9909 */ |
11801 */ |
9910 |
|
9911 class DecodeEntityParser { |
11802 class DecodeEntityParser { |
9912 /** |
11803 /** |
9913 * Returns a substitute string for an entity string sequence between `&` |
11804 * Returns a substitute string for an entity string sequence between `&` |
9914 * and `;`, or undefined if no substitution should occur. |
11805 * and `;`, or undefined if no substitution should occur. |
9915 * |
11806 * |
9916 * @param {string} entity Entity fragment discovered in HTML. |
11807 * @param {string} entity Entity fragment discovered in HTML. |
9917 * |
11808 * |
9918 * @return {?string} Entity substitute value. |
11809 * @return {string | undefined} Entity substitute value. |
9919 */ |
11810 */ |
9920 parse(entity) { |
11811 parse(entity) { |
9921 if (isValidCharacterReference(entity)) { |
11812 if (isValidCharacterReference(entity)) { |
9922 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)('&' + entity + ';'); |
11813 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)('&' + entity + ';'); |
9923 } |
11814 } |
9924 } |
11815 } |
9925 |
11816 } |
9926 } |
11817 |
9927 /** |
11818 /** |
9928 * Given a specified string, returns an array of strings split by consecutive |
11819 * Given a specified string, returns an array of strings split by consecutive |
9929 * whitespace, ignoring leading or trailing whitespace. |
11820 * whitespace, ignoring leading or trailing whitespace. |
9930 * |
11821 * |
9931 * @param {string} text Original text. |
11822 * @param {string} text Original text. |
9932 * |
11823 * |
9933 * @return {string[]} Text pieces split on whitespace. |
11824 * @return {string[]} Text pieces split on whitespace. |
9934 */ |
11825 */ |
9935 |
|
9936 function getTextPiecesSplitOnWhitespace(text) { |
11826 function getTextPiecesSplitOnWhitespace(text) { |
9937 return text.trim().split(REGEXP_WHITESPACE); |
11827 return text.trim().split(REGEXP_WHITESPACE); |
9938 } |
11828 } |
11829 |
|
9939 /** |
11830 /** |
9940 * Given a specified string, returns a new trimmed string where all consecutive |
11831 * Given a specified string, returns a new trimmed string where all consecutive |
9941 * whitespace is collapsed to a single space. |
11832 * whitespace is collapsed to a single space. |
9942 * |
11833 * |
9943 * @param {string} text Original text. |
11834 * @param {string} text Original text. |
9944 * |
11835 * |
9945 * @return {string} Trimmed text with consecutive whitespace collapsed. |
11836 * @return {string} Trimmed text with consecutive whitespace collapsed. |
9946 */ |
11837 */ |
9947 |
|
9948 function getTextWithCollapsedWhitespace(text) { |
11838 function getTextWithCollapsedWhitespace(text) { |
9949 // This is an overly simplified whitespace comparison. The specification is |
11839 // This is an overly simplified whitespace comparison. The specification is |
9950 // more prescriptive of whitespace behavior in inline and block contexts. |
11840 // more prescriptive of whitespace behavior in inline and block contexts. |
9951 // |
11841 // |
9952 // See: https://medium.com/@patrickbrosset/when-does-white-space-matter-in-html-b90e8a7cdd33 |
11842 // See: https://medium.com/@patrickbrosset/when-does-white-space-matter-in-html-b90e8a7cdd33 |
9953 return getTextPiecesSplitOnWhitespace(text).join(' '); |
11843 return getTextPiecesSplitOnWhitespace(text).join(' '); |
9954 } |
11844 } |
11845 |
|
9955 /** |
11846 /** |
9956 * Returns attribute pairs of the given StartTag token, including only pairs |
11847 * Returns attribute pairs of the given StartTag token, including only pairs |
9957 * where the value is non-empty or the attribute is a boolean attribute, an |
11848 * where the value is non-empty or the attribute is a boolean attribute, an |
9958 * enumerated attribute, or a custom data- attribute. |
11849 * enumerated attribute, or a custom data- attribute. |
9959 * |
11850 * |
9961 * |
11852 * |
9962 * @param {Object} token StartTag token. |
11853 * @param {Object} token StartTag token. |
9963 * |
11854 * |
9964 * @return {Array[]} Attribute pairs. |
11855 * @return {Array[]} Attribute pairs. |
9965 */ |
11856 */ |
9966 |
|
9967 function getMeaningfulAttributePairs(token) { |
11857 function getMeaningfulAttributePairs(token) { |
9968 return token.attributes.filter(pair => { |
11858 return token.attributes.filter(pair => { |
9969 const [key, value] = pair; |
11859 const [key, value] = pair; |
9970 return value || key.indexOf('data-') === 0 || (0,external_lodash_namespaceObject.includes)(MEANINGFUL_ATTRIBUTES, key); |
11860 return value || key.indexOf('data-') === 0 || MEANINGFUL_ATTRIBUTES.includes(key); |
9971 }); |
11861 }); |
9972 } |
11862 } |
11863 |
|
9973 /** |
11864 /** |
9974 * Returns true if two text tokens (with `chars` property) are equivalent, or |
11865 * Returns true if two text tokens (with `chars` property) are equivalent, or |
9975 * false otherwise. |
11866 * false otherwise. |
9976 * |
11867 * |
9977 * @param {Object} actual Actual token. |
11868 * @param {Object} actual Actual token. |
9978 * @param {Object} expected Expected token. |
11869 * @param {Object} expected Expected token. |
9979 * @param {Object} logger Validation logger object. |
11870 * @param {Object} logger Validation logger object. |
9980 * |
11871 * |
9981 * @return {boolean} Whether two text tokens are equivalent. |
11872 * @return {boolean} Whether two text tokens are equivalent. |
9982 */ |
11873 */ |
9983 |
11874 function isEquivalentTextTokens(actual, expected, logger = createLogger()) { |
9984 function isEquivalentTextTokens(actual, expected) { |
|
9985 let logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger(); |
|
9986 // This function is intentionally written as syntactically "ugly" as a hot |
11875 // This function is intentionally written as syntactically "ugly" as a hot |
9987 // path optimization. Text is progressively normalized in order from least- |
11876 // path optimization. Text is progressively normalized in order from least- |
9988 // to-most operationally expensive, until the earliest point at which text |
11877 // to-most operationally expensive, until the earliest point at which text |
9989 // can be confidently inferred as being equal. |
11878 // can be confidently inferred as being equal. |
9990 let actualChars = actual.chars; |
11879 let actualChars = actual.chars; |
9991 let expectedChars = expected.chars; |
11880 let expectedChars = expected.chars; |
9992 |
|
9993 for (let i = 0; i < TEXT_NORMALIZATIONS.length; i++) { |
11881 for (let i = 0; i < TEXT_NORMALIZATIONS.length; i++) { |
9994 const normalize = TEXT_NORMALIZATIONS[i]; |
11882 const normalize = TEXT_NORMALIZATIONS[i]; |
9995 actualChars = normalize(actualChars); |
11883 actualChars = normalize(actualChars); |
9996 expectedChars = normalize(expectedChars); |
11884 expectedChars = normalize(expectedChars); |
9997 |
|
9998 if (actualChars === expectedChars) { |
11885 if (actualChars === expectedChars) { |
9999 return true; |
11886 return true; |
10000 } |
11887 } |
10001 } |
11888 } |
10002 |
|
10003 logger.warning('Expected text `%s`, saw `%s`.', expected.chars, actual.chars); |
11889 logger.warning('Expected text `%s`, saw `%s`.', expected.chars, actual.chars); |
10004 return false; |
11890 return false; |
10005 } |
11891 } |
11892 |
|
10006 /** |
11893 /** |
10007 * Given a CSS length value, returns a normalized CSS length value for strict equality |
11894 * Given a CSS length value, returns a normalized CSS length value for strict equality |
10008 * comparison. |
11895 * comparison. |
10009 * |
11896 * |
10010 * @param {string} value CSS length value. |
11897 * @param {string} value CSS length value. |
10011 * |
11898 * |
10012 * @return {string} Normalized CSS length value. |
11899 * @return {string} Normalized CSS length value. |
10013 */ |
11900 */ |
10014 |
|
10015 function getNormalizedLength(value) { |
11901 function getNormalizedLength(value) { |
10016 if (0 === parseFloat(value)) { |
11902 if (0 === parseFloat(value)) { |
10017 return '0'; |
11903 return '0'; |
10018 } // Normalize strings with floats to always include a leading zero. |
11904 } |
10019 |
11905 // Normalize strings with floats to always include a leading zero. |
10020 |
|
10021 if (value.indexOf('.') === 0) { |
11906 if (value.indexOf('.') === 0) { |
10022 return '0' + value; |
11907 return '0' + value; |
10023 } |
11908 } |
10024 |
|
10025 return value; |
11909 return value; |
10026 } |
11910 } |
11911 |
|
10027 /** |
11912 /** |
10028 * Given a style value, returns a normalized style value for strict equality |
11913 * Given a style value, returns a normalized style value for strict equality |
10029 * comparison. |
11914 * comparison. |
10030 * |
11915 * |
10031 * @param {string} value Style value. |
11916 * @param {string} value Style value. |
10032 * |
11917 * |
10033 * @return {string} Normalized style value. |
11918 * @return {string} Normalized style value. |
10034 */ |
11919 */ |
10035 |
|
10036 function getNormalizedStyleValue(value) { |
11920 function getNormalizedStyleValue(value) { |
10037 const textPieces = getTextPiecesSplitOnWhitespace(value); |
11921 const textPieces = getTextPiecesSplitOnWhitespace(value); |
10038 const normalizedPieces = textPieces.map(getNormalizedLength); |
11922 const normalizedPieces = textPieces.map(getNormalizedLength); |
10039 const result = normalizedPieces.join(' '); |
11923 const result = normalizedPieces.join(' '); |
10040 return result // Normalize URL type to omit whitespace or quotes. |
11924 return result |
11925 // Normalize URL type to omit whitespace or quotes. |
|
10041 .replace(REGEXP_STYLE_URL_TYPE, 'url($1)'); |
11926 .replace(REGEXP_STYLE_URL_TYPE, 'url($1)'); |
10042 } |
11927 } |
11928 |
|
10043 /** |
11929 /** |
10044 * Given a style attribute string, returns an object of style properties. |
11930 * Given a style attribute string, returns an object of style properties. |
10045 * |
11931 * |
10046 * @param {string} text Style attribute. |
11932 * @param {string} text Style attribute. |
10047 * |
11933 * |
10048 * @return {Object} Style properties. |
11934 * @return {Object} Style properties. |
10049 */ |
11935 */ |
10050 |
|
10051 function getStyleProperties(text) { |
11936 function getStyleProperties(text) { |
10052 const pairs = text // Trim ending semicolon (avoid including in split) |
11937 const pairs = text |
10053 .replace(/;?\s*$/, '') // Split on property assignment. |
11938 // Trim ending semicolon (avoid including in split) |
10054 .split(';') // For each property assignment... |
11939 .replace(/;?\s*$/, '') |
11940 // Split on property assignment. |
|
11941 .split(';') |
|
11942 // For each property assignment... |
|
10055 .map(style => { |
11943 .map(style => { |
10056 // ...split further into key-value pairs. |
11944 // ...split further into key-value pairs. |
10057 const [key, ...valueParts] = style.split(':'); |
11945 const [key, ...valueParts] = style.split(':'); |
10058 const value = valueParts.join(':'); |
11946 const value = valueParts.join(':'); |
10059 return [key.trim(), getNormalizedStyleValue(value.trim())]; |
11947 return [key.trim(), getNormalizedStyleValue(value.trim())]; |
10060 }); |
11948 }); |
10061 return (0,external_lodash_namespaceObject.fromPairs)(pairs); |
11949 return Object.fromEntries(pairs); |
10062 } |
11950 } |
11951 |
|
10063 /** |
11952 /** |
10064 * Attribute-specific equality handlers |
11953 * Attribute-specific equality handlers |
10065 * |
11954 * |
10066 * @type {Object} |
11955 * @type {Object} |
10067 */ |
11956 */ |
10068 |
|
10069 const isEqualAttributesOfName = { |
11957 const isEqualAttributesOfName = { |
10070 class: (actual, expected) => { |
11958 class: (actual, expected) => { |
10071 // Class matches if members are the same, even if out of order or |
11959 // Class matches if members are the same, even if out of order or |
10072 // superfluous whitespace between. |
11960 // superfluous whitespace between. |
10073 return !(0,external_lodash_namespaceObject.xor)(...[actual, expected].map(getTextPiecesSplitOnWhitespace)).length; |
11961 const [actualPieces, expectedPieces] = [actual, expected].map(getTextPiecesSplitOnWhitespace); |
11962 const actualDiff = actualPieces.filter(c => !expectedPieces.includes(c)); |
|
11963 const expectedDiff = expectedPieces.filter(c => !actualPieces.includes(c)); |
|
11964 return actualDiff.length === 0 && expectedDiff.length === 0; |
|
10074 }, |
11965 }, |
10075 style: (actual, expected) => { |
11966 style: (actual, expected) => { |
10076 return (0,external_lodash_namespaceObject.isEqual)(...[actual, expected].map(getStyleProperties)); |
11967 return es6_default()(...[actual, expected].map(getStyleProperties)); |
10077 }, |
11968 }, |
10078 // For each boolean attribute, mere presence of attribute in both is enough |
11969 // For each boolean attribute, mere presence of attribute in both is enough |
10079 // to assume equivalence. |
11970 // to assume equivalence. |
10080 ...(0,external_lodash_namespaceObject.fromPairs)(BOOLEAN_ATTRIBUTES.map(attribute => [attribute, external_lodash_namespaceObject.stubTrue])) |
11971 ...Object.fromEntries(BOOLEAN_ATTRIBUTES.map(attribute => [attribute, () => true])) |
10081 }; |
11972 }; |
11973 |
|
10082 /** |
11974 /** |
10083 * Given two sets of attribute tuples, returns true if the attribute sets are |
11975 * Given two sets of attribute tuples, returns true if the attribute sets are |
10084 * equivalent. |
11976 * equivalent. |
10085 * |
11977 * |
10086 * @param {Array[]} actual Actual attributes tuples. |
11978 * @param {Array[]} actual Actual attributes tuples. |
10087 * @param {Array[]} expected Expected attributes tuples. |
11979 * @param {Array[]} expected Expected attributes tuples. |
10088 * @param {Object} logger Validation logger object. |
11980 * @param {Object} logger Validation logger object. |
10089 * |
11981 * |
10090 * @return {boolean} Whether attributes are equivalent. |
11982 * @return {boolean} Whether attributes are equivalent. |
10091 */ |
11983 */ |
10092 |
11984 function isEqualTagAttributePairs(actual, expected, logger = createLogger()) { |
10093 function isEqualTagAttributePairs(actual, expected) { |
|
10094 let logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger(); |
|
10095 |
|
10096 // Attributes is tokenized as tuples. Their lengths should match. This also |
11985 // Attributes is tokenized as tuples. Their lengths should match. This also |
10097 // avoids us needing to check both attributes sets, since if A has any keys |
11986 // avoids us needing to check both attributes sets, since if A has any keys |
10098 // which do not exist in B, we know the sets to be different. |
11987 // which do not exist in B, we know the sets to be different. |
10099 if (actual.length !== expected.length) { |
11988 if (actual.length !== expected.length) { |
10100 logger.warning('Expected attributes %o, instead saw %o.', expected, actual); |
11989 logger.warning('Expected attributes %o, instead saw %o.', expected, actual); |
10101 return false; |
11990 return false; |
10102 } // Attributes are not guaranteed to occur in the same order. For validating |
11991 } |
11992 |
|
11993 // Attributes are not guaranteed to occur in the same order. For validating |
|
10103 // actual attributes, first convert the set of expected attribute values to |
11994 // actual attributes, first convert the set of expected attribute values to |
10104 // an object, for lookup by key. |
11995 // an object, for lookup by key. |
10105 |
|
10106 |
|
10107 const expectedAttributes = {}; |
11996 const expectedAttributes = {}; |
10108 |
|
10109 for (let i = 0; i < expected.length; i++) { |
11997 for (let i = 0; i < expected.length; i++) { |
10110 expectedAttributes[expected[i][0].toLowerCase()] = expected[i][1]; |
11998 expectedAttributes[expected[i][0].toLowerCase()] = expected[i][1]; |
10111 } |
11999 } |
10112 |
|
10113 for (let i = 0; i < actual.length; i++) { |
12000 for (let i = 0; i < actual.length; i++) { |
10114 const [name, actualValue] = actual[i]; |
12001 const [name, actualValue] = actual[i]; |
10115 const nameLower = name.toLowerCase(); // As noted above, if missing member in B, assume different. |
12002 const nameLower = name.toLowerCase(); |
10116 |
12003 |
12004 // As noted above, if missing member in B, assume different. |
|
10117 if (!expectedAttributes.hasOwnProperty(nameLower)) { |
12005 if (!expectedAttributes.hasOwnProperty(nameLower)) { |
10118 logger.warning('Encountered unexpected attribute `%s`.', name); |
12006 logger.warning('Encountered unexpected attribute `%s`.', name); |
10119 return false; |
12007 return false; |
10120 } |
12008 } |
10121 |
|
10122 const expectedValue = expectedAttributes[nameLower]; |
12009 const expectedValue = expectedAttributes[nameLower]; |
10123 const isEqualAttributes = isEqualAttributesOfName[nameLower]; |
12010 const isEqualAttributes = isEqualAttributesOfName[nameLower]; |
10124 |
|
10125 if (isEqualAttributes) { |
12011 if (isEqualAttributes) { |
10126 // Defer custom attribute equality handling. |
12012 // Defer custom attribute equality handling. |
10127 if (!isEqualAttributes(actualValue, expectedValue)) { |
12013 if (!isEqualAttributes(actualValue, expectedValue)) { |
10128 logger.warning('Expected attribute `%s` of value `%s`, saw `%s`.', name, expectedValue, actualValue); |
12014 logger.warning('Expected attribute `%s` of value `%s`, saw `%s`.', name, expectedValue, actualValue); |
10129 return false; |
12015 return false; |
10132 // Otherwise strict inequality should bail. |
12018 // Otherwise strict inequality should bail. |
10133 logger.warning('Expected attribute `%s` of value `%s`, saw `%s`.', name, expectedValue, actualValue); |
12019 logger.warning('Expected attribute `%s` of value `%s`, saw `%s`.', name, expectedValue, actualValue); |
10134 return false; |
12020 return false; |
10135 } |
12021 } |
10136 } |
12022 } |
10137 |
|
10138 return true; |
12023 return true; |
10139 } |
12024 } |
12025 |
|
10140 /** |
12026 /** |
10141 * Token-type-specific equality handlers |
12027 * Token-type-specific equality handlers |
10142 * |
12028 * |
10143 * @type {Object} |
12029 * @type {Object} |
10144 */ |
12030 */ |
10145 |
|
10146 const isEqualTokensOfType = { |
12031 const isEqualTokensOfType = { |
10147 StartTag: function (actual, expected) { |
12032 StartTag: (actual, expected, logger = createLogger()) => { |
10148 let logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger(); |
12033 if (actual.tagName !== expected.tagName && |
10149 |
12034 // Optimization: Use short-circuit evaluation to defer case- |
10150 if (actual.tagName !== expected.tagName && // Optimization: Use short-circuit evaluation to defer case- |
|
10151 // insensitive check on the assumption that the majority case will |
12035 // insensitive check on the assumption that the majority case will |
10152 // have exactly equal tag names. |
12036 // have exactly equal tag names. |
10153 actual.tagName.toLowerCase() !== expected.tagName.toLowerCase()) { |
12037 actual.tagName.toLowerCase() !== expected.tagName.toLowerCase()) { |
10154 logger.warning('Expected tag name `%s`, instead saw `%s`.', expected.tagName, actual.tagName); |
12038 logger.warning('Expected tag name `%s`, instead saw `%s`.', expected.tagName, actual.tagName); |
10155 return false; |
12039 return false; |
10156 } |
12040 } |
10157 |
|
10158 return isEqualTagAttributePairs(...[actual, expected].map(getMeaningfulAttributePairs), logger); |
12041 return isEqualTagAttributePairs(...[actual, expected].map(getMeaningfulAttributePairs), logger); |
10159 }, |
12042 }, |
10160 Chars: isEquivalentTextTokens, |
12043 Chars: isEquivalentTextTokens, |
10161 Comment: isEquivalentTextTokens |
12044 Comment: isEquivalentTextTokens |
10162 }; |
12045 }; |
12046 |
|
10163 /** |
12047 /** |
10164 * Given an array of tokens, returns the first token which is not purely |
12048 * Given an array of tokens, returns the first token which is not purely |
10165 * whitespace. |
12049 * whitespace. |
10166 * |
12050 * |
10167 * Mutates the tokens array. |
12051 * Mutates the tokens array. |
10168 * |
12052 * |
10169 * @param {Object[]} tokens Set of tokens to search. |
12053 * @param {Object[]} tokens Set of tokens to search. |
10170 * |
12054 * |
10171 * @return {Object} Next non-whitespace token. |
12055 * @return {Object | undefined} Next non-whitespace token. |
10172 */ |
12056 */ |
10173 |
|
10174 function getNextNonWhitespaceToken(tokens) { |
12057 function getNextNonWhitespaceToken(tokens) { |
10175 let token; |
12058 let token; |
10176 |
|
10177 while (token = tokens.shift()) { |
12059 while (token = tokens.shift()) { |
10178 if (token.type !== 'Chars') { |
12060 if (token.type !== 'Chars') { |
10179 return token; |
12061 return token; |
10180 } |
12062 } |
10181 |
|
10182 if (!REGEXP_ONLY_WHITESPACE.test(token.chars)) { |
12063 if (!REGEXP_ONLY_WHITESPACE.test(token.chars)) { |
10183 return token; |
12064 return token; |
10184 } |
12065 } |
10185 } |
12066 } |
10186 } |
12067 } |
12068 |
|
10187 /** |
12069 /** |
10188 * Tokenize an HTML string, gracefully handling any errors thrown during |
12070 * Tokenize an HTML string, gracefully handling any errors thrown during |
10189 * underlying tokenization. |
12071 * underlying tokenization. |
10190 * |
12072 * |
10191 * @param {string} html HTML string to tokenize. |
12073 * @param {string} html HTML string to tokenize. |
10192 * @param {Object} logger Validation logger object. |
12074 * @param {Object} logger Validation logger object. |
10193 * |
12075 * |
10194 * @return {Object[]|null} Array of valid tokenized HTML elements, or null on error |
12076 * @return {Object[]|null} Array of valid tokenized HTML elements, or null on error |
10195 */ |
12077 */ |
10196 |
12078 function getHTMLTokens(html, logger = createLogger()) { |
10197 function getHTMLTokens(html) { |
|
10198 let logger = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createLogger(); |
|
10199 |
|
10200 try { |
12079 try { |
10201 return new Tokenizer(new DecodeEntityParser()).tokenize(html); |
12080 return new Tokenizer(new DecodeEntityParser()).tokenize(html); |
10202 } catch (e) { |
12081 } catch (e) { |
10203 logger.warning('Malformed HTML detected: %s', html); |
12082 logger.warning('Malformed HTML detected: %s', html); |
10204 } |
12083 } |
10205 |
|
10206 return null; |
12084 return null; |
10207 } |
12085 } |
12086 |
|
10208 /** |
12087 /** |
10209 * Returns true if the next HTML token closes the current token. |
12088 * Returns true if the next HTML token closes the current token. |
10210 * |
12089 * |
10211 * @param {Object} currentToken Current token to compare with. |
12090 * @param {Object} currentToken Current token to compare with. |
10212 * @param {Object|undefined} nextToken Next token to compare against. |
12091 * @param {Object|undefined} nextToken Next token to compare against. |
10213 * |
12092 * |
10214 * @return {boolean} true if `nextToken` closes `currentToken`, false otherwise |
12093 * @return {boolean} true if `nextToken` closes `currentToken`, false otherwise |
10215 */ |
12094 */ |
10216 |
|
10217 |
|
10218 function isClosedByToken(currentToken, nextToken) { |
12095 function isClosedByToken(currentToken, nextToken) { |
10219 // Ensure this is a self closed token. |
12096 // Ensure this is a self closed token. |
10220 if (!currentToken.selfClosing) { |
12097 if (!currentToken.selfClosing) { |
10221 return false; |
12098 return false; |
10222 } // Check token names and determine if nextToken is the closing tag for currentToken. |
12099 } |
10223 |
12100 |
10224 |
12101 // Check token names and determine if nextToken is the closing tag for currentToken. |
10225 if (nextToken && nextToken.tagName === currentToken.tagName && nextToken.type === 'EndTag') { |
12102 if (nextToken && nextToken.tagName === currentToken.tagName && nextToken.type === 'EndTag') { |
10226 return true; |
12103 return true; |
10227 } |
12104 } |
10228 |
|
10229 return false; |
12105 return false; |
10230 } |
12106 } |
12107 |
|
10231 /** |
12108 /** |
10232 * Returns true if the given HTML strings are effectively equivalent, or |
12109 * Returns true if the given HTML strings are effectively equivalent, or |
10233 * false otherwise. Invalid HTML is not considered equivalent, even if the |
12110 * false otherwise. Invalid HTML is not considered equivalent, even if the |
10234 * strings directly match. |
12111 * strings directly match. |
10235 * |
12112 * |
10237 * @param {string} expected Expected HTML string. |
12114 * @param {string} expected Expected HTML string. |
10238 * @param {Object} logger Validation logger object. |
12115 * @param {Object} logger Validation logger object. |
10239 * |
12116 * |
10240 * @return {boolean} Whether HTML strings are equivalent. |
12117 * @return {boolean} Whether HTML strings are equivalent. |
10241 */ |
12118 */ |
10242 |
12119 function isEquivalentHTML(actual, expected, logger = createLogger()) { |
10243 function isEquivalentHTML(actual, expected) { |
|
10244 let logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger(); |
|
10245 |
|
10246 // Short-circuit if markup is identical. |
12120 // Short-circuit if markup is identical. |
10247 if (actual === expected) { |
12121 if (actual === expected) { |
10248 return true; |
12122 return true; |
10249 } // Tokenize input content and reserialized save content. |
12123 } |
10250 |
12124 |
10251 |
12125 // Tokenize input content and reserialized save content. |
10252 const [actualTokens, expectedTokens] = [actual, expected].map(html => getHTMLTokens(html, logger)); // If either is malformed then stop comparing - the strings are not equivalent. |
12126 const [actualTokens, expectedTokens] = [actual, expected].map(html => getHTMLTokens(html, logger)); |
10253 |
12127 |
12128 // If either is malformed then stop comparing - the strings are not equivalent. |
|
10254 if (!actualTokens || !expectedTokens) { |
12129 if (!actualTokens || !expectedTokens) { |
10255 return false; |
12130 return false; |
10256 } |
12131 } |
10257 |
|
10258 let actualToken, expectedToken; |
12132 let actualToken, expectedToken; |
10259 |
|
10260 while (actualToken = getNextNonWhitespaceToken(actualTokens)) { |
12133 while (actualToken = getNextNonWhitespaceToken(actualTokens)) { |
10261 expectedToken = getNextNonWhitespaceToken(expectedTokens); // Inequal if exhausted all expected tokens. |
12134 expectedToken = getNextNonWhitespaceToken(expectedTokens); |
10262 |
12135 |
12136 // Inequal if exhausted all expected tokens. |
|
10263 if (!expectedToken) { |
12137 if (!expectedToken) { |
10264 logger.warning('Expected end of content, instead saw %o.', actualToken); |
12138 logger.warning('Expected end of content, instead saw %o.', actualToken); |
10265 return false; |
12139 return false; |
10266 } // Inequal if next non-whitespace token of each set are not same type. |
12140 } |
10267 |
12141 |
10268 |
12142 // Inequal if next non-whitespace token of each set are not same type. |
10269 if (actualToken.type !== expectedToken.type) { |
12143 if (actualToken.type !== expectedToken.type) { |
10270 logger.warning('Expected token of type `%s` (%o), instead saw `%s` (%o).', expectedToken.type, expectedToken, actualToken.type, actualToken); |
12144 logger.warning('Expected token of type `%s` (%o), instead saw `%s` (%o).', expectedToken.type, expectedToken, actualToken.type, actualToken); |
10271 return false; |
12145 return false; |
10272 } // Defer custom token type equality handling, otherwise continue and |
12146 } |
12147 |
|
12148 // Defer custom token type equality handling, otherwise continue and |
|
10273 // assume as equal. |
12149 // assume as equal. |
10274 |
|
10275 |
|
10276 const isEqualTokens = isEqualTokensOfType[actualToken.type]; |
12150 const isEqualTokens = isEqualTokensOfType[actualToken.type]; |
10277 |
|
10278 if (isEqualTokens && !isEqualTokens(actualToken, expectedToken, logger)) { |
12151 if (isEqualTokens && !isEqualTokens(actualToken, expectedToken, logger)) { |
10279 return false; |
12152 return false; |
10280 } // Peek at the next tokens (actual and expected) to see if they close |
12153 } |
12154 |
|
12155 // Peek at the next tokens (actual and expected) to see if they close |
|
10281 // a self-closing tag. |
12156 // a self-closing tag. |
10282 |
|
10283 |
|
10284 if (isClosedByToken(actualToken, expectedTokens[0])) { |
12157 if (isClosedByToken(actualToken, expectedTokens[0])) { |
10285 // Consume the next expected token that closes the current actual |
12158 // Consume the next expected token that closes the current actual |
10286 // self-closing token. |
12159 // self-closing token. |
10287 getNextNonWhitespaceToken(expectedTokens); |
12160 getNextNonWhitespaceToken(expectedTokens); |
10288 } else if (isClosedByToken(expectedToken, actualTokens[0])) { |
12161 } else if (isClosedByToken(expectedToken, actualTokens[0])) { |
10289 // Consume the next actual token that closes the current expected |
12162 // Consume the next actual token that closes the current expected |
10290 // self-closing token. |
12163 // self-closing token. |
10291 getNextNonWhitespaceToken(actualTokens); |
12164 getNextNonWhitespaceToken(actualTokens); |
10292 } |
12165 } |
10293 } |
12166 } |
10294 |
|
10295 if (expectedToken = getNextNonWhitespaceToken(expectedTokens)) { |
12167 if (expectedToken = getNextNonWhitespaceToken(expectedTokens)) { |
10296 // If any non-whitespace tokens remain in expected token set, this |
12168 // If any non-whitespace tokens remain in expected token set, this |
10297 // indicates inequality. |
12169 // indicates inequality. |
10298 logger.warning('Expected %o, instead saw end of content.', expectedToken); |
12170 logger.warning('Expected %o, instead saw end of content.', expectedToken); |
10299 return false; |
12171 return false; |
10300 } |
12172 } |
10301 |
|
10302 return true; |
12173 return true; |
10303 } |
12174 } |
12175 |
|
10304 /** |
12176 /** |
10305 * Returns an object with `isValid` property set to `true` if the parsed block |
12177 * Returns an object with `isValid` property set to `true` if the parsed block |
10306 * is valid given the input content. A block is considered valid if, when serialized |
12178 * is valid given the input content. A block is considered valid if, when serialized |
10307 * with assumed attributes, the content matches the original value. If block is |
12179 * with assumed attributes, the content matches the original value. If block is |
10308 * invalid, this function returns all validations issues as well. |
12180 * invalid, this function returns all validations issues as well. |
10324 * @param {WPBlock} block block object. |
12196 * @param {WPBlock} block block object. |
10325 * @param {WPBlockType|string} [blockTypeOrName = block.name] Block type or name, inferred from block if not given. |
12197 * @param {WPBlockType|string} [blockTypeOrName = block.name] Block type or name, inferred from block if not given. |
10326 * |
12198 * |
10327 * @return {[boolean,Array<LoggerItem>]} validation results. |
12199 * @return {[boolean,Array<LoggerItem>]} validation results. |
10328 */ |
12200 */ |
10329 |
12201 function validateBlock(block, blockTypeOrName = block.name) { |
10330 function validateBlock(block) { |
12202 const isFallbackBlock = block.name === getFreeformContentHandlerName() || block.name === getUnregisteredTypeHandlerName(); |
10331 let blockTypeOrName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : block.name; |
12203 |
10332 const isFallbackBlock = block.name === getFreeformContentHandlerName() || block.name === getUnregisteredTypeHandlerName(); // Shortcut to avoid costly validation. |
12204 // Shortcut to avoid costly validation. |
10333 |
|
10334 if (isFallbackBlock) { |
12205 if (isFallbackBlock) { |
10335 return [true, []]; |
12206 return [true, []]; |
10336 } |
12207 } |
10337 |
|
10338 const logger = createQueuedLogger(); |
12208 const logger = createQueuedLogger(); |
10339 const blockType = normalizeBlockType(blockTypeOrName); |
12209 const blockType = normalizeBlockType(blockTypeOrName); |
10340 let generatedBlockContent; |
12210 let generatedBlockContent; |
10341 |
|
10342 try { |
12211 try { |
10343 generatedBlockContent = getSaveContent(blockType, block.attributes); |
12212 generatedBlockContent = getSaveContent(blockType, block.attributes); |
10344 } catch (error) { |
12213 } catch (error) { |
10345 logger.error('Block validation failed because an error occurred while generating block content:\n\n%s', error.toString()); |
12214 logger.error('Block validation failed because an error occurred while generating block content:\n\n%s', error.toString()); |
10346 return [false, logger.getItems()]; |
12215 return [false, logger.getItems()]; |
10347 } |
12216 } |
10348 |
|
10349 const isValid = isEquivalentHTML(block.originalContent, generatedBlockContent, logger); |
12217 const isValid = isEquivalentHTML(block.originalContent, generatedBlockContent, logger); |
10350 |
|
10351 if (!isValid) { |
12218 if (!isValid) { |
10352 logger.error('Block validation failed for `%s` (%o).\n\nContent generated by `save` function:\n\n%s\n\nContent retrieved from post body:\n\n%s', blockType.name, blockType, generatedBlockContent, block.originalContent); |
12219 logger.error('Block validation failed for `%s` (%o).\n\nContent generated by `save` function:\n\n%s\n\nContent retrieved from post body:\n\n%s', blockType.name, blockType, generatedBlockContent, block.originalContent); |
10353 } |
12220 } |
10354 |
|
10355 return [isValid, logger.getItems()]; |
12221 return [isValid, logger.getItems()]; |
10356 } |
12222 } |
12223 |
|
10357 /** |
12224 /** |
10358 * Returns true if the parsed block is valid given the input content. A block |
12225 * Returns true if the parsed block is valid given the input content. A block |
10359 * is considered valid if, when serialized with assumed attributes, the content |
12226 * is considered valid if, when serialized with assumed attributes, the content |
10360 * matches the original value. |
12227 * matches the original value. |
10361 * |
12228 * |
10367 * @param {Object} attributes Parsed block attributes. |
12234 * @param {Object} attributes Parsed block attributes. |
10368 * @param {string} originalBlockContent Original block content. |
12235 * @param {string} originalBlockContent Original block content. |
10369 * |
12236 * |
10370 * @return {boolean} Whether block is valid. |
12237 * @return {boolean} Whether block is valid. |
10371 */ |
12238 */ |
10372 |
|
10373 function isValidBlockContent(blockTypeOrName, attributes, originalBlockContent) { |
12239 function isValidBlockContent(blockTypeOrName, attributes, originalBlockContent) { |
10374 external_wp_deprecated_default()('isValidBlockContent introduces opportunity for data loss', { |
12240 external_wp_deprecated_default()('isValidBlockContent introduces opportunity for data loss', { |
10375 since: '12.6', |
12241 since: '12.6', |
10376 plugin: 'Gutenberg', |
12242 plugin: 'Gutenberg', |
10377 alternative: 'validateBlock' |
12243 alternative: 'validateBlock' |
10397 * @param {Object} attributes The block's attributes |
12263 * @param {Object} attributes The block's attributes |
10398 * |
12264 * |
10399 * @return {[string, Object]} The block's name and attributes, changed accordingly if a match was found |
12265 * @return {[string, Object]} The block's name and attributes, changed accordingly if a match was found |
10400 */ |
12266 */ |
10401 function convertLegacyBlockNameAndAttributes(name, attributes) { |
12267 function convertLegacyBlockNameAndAttributes(name, attributes) { |
10402 const newAttributes = { ...attributes |
12268 const newAttributes = { |
10403 }; // Convert 'core/cover-image' block in existing content to 'core/cover'. |
12269 ...attributes |
10404 |
12270 }; |
12271 // Convert 'core/cover-image' block in existing content to 'core/cover'. |
|
10405 if ('core/cover-image' === name) { |
12272 if ('core/cover-image' === name) { |
10406 name = 'core/cover'; |
12273 name = 'core/cover'; |
10407 } // Convert 'core/text' blocks in existing content to 'core/paragraph'. |
12274 } |
10408 |
12275 |
10409 |
12276 // Convert 'core/text' blocks in existing content to 'core/paragraph'. |
10410 if ('core/text' === name || 'core/cover-text' === name) { |
12277 if ('core/text' === name || 'core/cover-text' === name) { |
10411 name = 'core/paragraph'; |
12278 name = 'core/paragraph'; |
10412 } // Convert derivative blocks such as 'core/social-link-wordpress' to the |
12279 } |
12280 |
|
12281 // Convert derivative blocks such as 'core/social-link-wordpress' to the |
|
10413 // canonical form 'core/social-link'. |
12282 // canonical form 'core/social-link'. |
10414 |
|
10415 |
|
10416 if (name && name.indexOf('core/social-link-') === 0) { |
12283 if (name && name.indexOf('core/social-link-') === 0) { |
10417 // Capture `social-link-wordpress` into `{"service":"wordpress"}` |
12284 // Capture `social-link-wordpress` into `{"service":"wordpress"}` |
10418 newAttributes.service = name.substring(17); |
12285 newAttributes.service = name.substring(17); |
10419 name = 'core/social-link'; |
12286 name = 'core/social-link'; |
10420 } // Convert derivative blocks such as 'core-embed/instagram' to the |
12287 } |
12288 |
|
12289 // Convert derivative blocks such as 'core-embed/instagram' to the |
|
10421 // canonical form 'core/embed'. |
12290 // canonical form 'core/embed'. |
10422 |
|
10423 |
|
10424 if (name && name.indexOf('core-embed/') === 0) { |
12291 if (name && name.indexOf('core-embed/') === 0) { |
10425 // Capture `core-embed/instagram` into `{"providerNameSlug":"instagram"}` |
12292 // Capture `core-embed/instagram` into `{"providerNameSlug":"instagram"}` |
10426 const providerSlug = name.substring(11); |
12293 const providerSlug = name.substring(11); |
10427 const deprecated = { |
12294 const deprecated = { |
10428 speaker: 'speaker-deck', |
12295 speaker: 'speaker-deck', |
10429 polldaddy: 'crowdsignal' |
12296 polldaddy: 'crowdsignal' |
10430 }; |
12297 }; |
10431 newAttributes.providerNameSlug = providerSlug in deprecated ? deprecated[providerSlug] : providerSlug; // This is needed as the `responsive` attribute was passed |
12298 newAttributes.providerNameSlug = providerSlug in deprecated ? deprecated[providerSlug] : providerSlug; |
12299 // This is needed as the `responsive` attribute was passed |
|
10432 // in a different way before the refactoring to block variations. |
12300 // in a different way before the refactoring to block variations. |
10433 |
|
10434 if (!['amazon-kindle', 'wordpress'].includes(providerSlug)) { |
12301 if (!['amazon-kindle', 'wordpress'].includes(providerSlug)) { |
10435 newAttributes.responsive = true; |
12302 newAttributes.responsive = true; |
10436 } |
12303 } |
10437 |
|
10438 name = 'core/embed'; |
12304 name = 'core/embed'; |
10439 } // Convert 'core/query-loop' blocks in existing content to 'core/post-template'. |
12305 } |
10440 // TODO: Remove this check when WordPress 5.9 is released. |
12306 |
10441 |
12307 // Convert Post Comment blocks in existing content to Comment blocks. |
10442 |
|
10443 if (name === 'core/query-loop') { |
|
10444 name = 'core/post-template'; |
|
10445 } // Convert Post Comment blocks in existing content to Comment blocks. |
|
10446 // TODO: Remove these checks when WordPress 6.0 is released. |
12308 // TODO: Remove these checks when WordPress 6.0 is released. |
10447 |
|
10448 |
|
10449 if (name === 'core/post-comment-author') { |
12309 if (name === 'core/post-comment-author') { |
10450 name = 'core/comment-author-name'; |
12310 name = 'core/comment-author-name'; |
10451 } |
12311 } |
10452 |
|
10453 if (name === 'core/post-comment-content') { |
12312 if (name === 'core/post-comment-content') { |
10454 name = 'core/comment-content'; |
12313 name = 'core/comment-content'; |
10455 } |
12314 } |
10456 |
|
10457 if (name === 'core/post-comment-date') { |
12315 if (name === 'core/post-comment-date') { |
10458 name = 'core/comment-date'; |
12316 name = 'core/comment-date'; |
10459 } |
12317 } |
10460 |
12318 if (name === 'core/comments-query-loop') { |
12319 name = 'core/comments'; |
|
12320 const { |
|
12321 className = '' |
|
12322 } = newAttributes; |
|
12323 if (!className.includes('wp-block-comments-query-loop')) { |
|
12324 newAttributes.className = ['wp-block-comments-query-loop', className].join(' '); |
|
12325 } |
|
12326 // Note that we also had to add a deprecation to the block in order |
|
12327 // for the ID change to work. |
|
12328 } |
|
12329 if (name === 'core/post-comments') { |
|
12330 name = 'core/comments'; |
|
12331 newAttributes.legacy = true; |
|
12332 } |
|
12333 |
|
12334 // The following code is only relevant for the Gutenberg plugin. |
|
12335 // It's a stand-alone if statement for dead-code elimination. |
|
12336 if (false) {} |
|
10461 return [name, newAttributes]; |
12337 return [name, newAttributes]; |
10462 } |
12338 } |
10463 |
12339 |
10464 ;// CONCATENATED MODULE: ./node_modules/hpq/es/get-path.js |
12340 ;// CONCATENATED MODULE: ./node_modules/hpq/es/get-path.js |
10465 /** |
12341 /** |
10638 return [].map.call(matches, function (match) { |
12514 return [].map.call(matches, function (match) { |
10639 return parse(match, matchers); |
12515 return parse(match, matchers); |
10640 }); |
12516 }); |
10641 }; |
12517 }; |
10642 } |
12518 } |
10643 // EXTERNAL MODULE: ./node_modules/memize/index.js |
12519 ;// CONCATENATED MODULE: ./node_modules/memize/dist/index.js |
10644 var memize = __webpack_require__(9756); |
12520 /** |
10645 var memize_default = /*#__PURE__*/__webpack_require__.n(memize); |
12521 * Memize options object. |
12522 * |
|
12523 * @typedef MemizeOptions |
|
12524 * |
|
12525 * @property {number} [maxSize] Maximum size of the cache. |
|
12526 */ |
|
12527 |
|
12528 /** |
|
12529 * Internal cache entry. |
|
12530 * |
|
12531 * @typedef MemizeCacheNode |
|
12532 * |
|
12533 * @property {?MemizeCacheNode|undefined} [prev] Previous node. |
|
12534 * @property {?MemizeCacheNode|undefined} [next] Next node. |
|
12535 * @property {Array<*>} args Function arguments for cache |
|
12536 * entry. |
|
12537 * @property {*} val Function result. |
|
12538 */ |
|
12539 |
|
12540 /** |
|
12541 * Properties of the enhanced function for controlling cache. |
|
12542 * |
|
12543 * @typedef MemizeMemoizedFunction |
|
12544 * |
|
12545 * @property {()=>void} clear Clear the cache. |
|
12546 */ |
|
12547 |
|
12548 /** |
|
12549 * Accepts a function to be memoized, and returns a new memoized function, with |
|
12550 * optional options. |
|
12551 * |
|
12552 * @template {(...args: any[]) => any} F |
|
12553 * |
|
12554 * @param {F} fn Function to memoize. |
|
12555 * @param {MemizeOptions} [options] Options object. |
|
12556 * |
|
12557 * @return {((...args: Parameters<F>) => ReturnType<F>) & MemizeMemoizedFunction} Memoized function. |
|
12558 */ |
|
12559 function memize(fn, options) { |
|
12560 var size = 0; |
|
12561 |
|
12562 /** @type {?MemizeCacheNode|undefined} */ |
|
12563 var head; |
|
12564 |
|
12565 /** @type {?MemizeCacheNode|undefined} */ |
|
12566 var tail; |
|
12567 |
|
12568 options = options || {}; |
|
12569 |
|
12570 function memoized(/* ...args */) { |
|
12571 var node = head, |
|
12572 len = arguments.length, |
|
12573 args, |
|
12574 i; |
|
12575 |
|
12576 searchCache: while (node) { |
|
12577 // Perform a shallow equality test to confirm that whether the node |
|
12578 // under test is a candidate for the arguments passed. Two arrays |
|
12579 // are shallowly equal if their length matches and each entry is |
|
12580 // strictly equal between the two sets. Avoid abstracting to a |
|
12581 // function which could incur an arguments leaking deoptimization. |
|
12582 |
|
12583 // Check whether node arguments match arguments length |
|
12584 if (node.args.length !== arguments.length) { |
|
12585 node = node.next; |
|
12586 continue; |
|
12587 } |
|
12588 |
|
12589 // Check whether node arguments match arguments values |
|
12590 for (i = 0; i < len; i++) { |
|
12591 if (node.args[i] !== arguments[i]) { |
|
12592 node = node.next; |
|
12593 continue searchCache; |
|
12594 } |
|
12595 } |
|
12596 |
|
12597 // At this point we can assume we've found a match |
|
12598 |
|
12599 // Surface matched node to head if not already |
|
12600 if (node !== head) { |
|
12601 // As tail, shift to previous. Must only shift if not also |
|
12602 // head, since if both head and tail, there is no previous. |
|
12603 if (node === tail) { |
|
12604 tail = node.prev; |
|
12605 } |
|
12606 |
|
12607 // Adjust siblings to point to each other. If node was tail, |
|
12608 // this also handles new tail's empty `next` assignment. |
|
12609 /** @type {MemizeCacheNode} */ (node.prev).next = node.next; |
|
12610 if (node.next) { |
|
12611 node.next.prev = node.prev; |
|
12612 } |
|
12613 |
|
12614 node.next = head; |
|
12615 node.prev = null; |
|
12616 /** @type {MemizeCacheNode} */ (head).prev = node; |
|
12617 head = node; |
|
12618 } |
|
12619 |
|
12620 // Return immediately |
|
12621 return node.val; |
|
12622 } |
|
12623 |
|
12624 // No cached value found. Continue to insertion phase: |
|
12625 |
|
12626 // Create a copy of arguments (avoid leaking deoptimization) |
|
12627 args = new Array(len); |
|
12628 for (i = 0; i < len; i++) { |
|
12629 args[i] = arguments[i]; |
|
12630 } |
|
12631 |
|
12632 node = { |
|
12633 args: args, |
|
12634 |
|
12635 // Generate the result from original function |
|
12636 val: fn.apply(null, args), |
|
12637 }; |
|
12638 |
|
12639 // Don't need to check whether node is already head, since it would |
|
12640 // have been returned above already if it was |
|
12641 |
|
12642 // Shift existing head down list |
|
12643 if (head) { |
|
12644 head.prev = node; |
|
12645 node.next = head; |
|
12646 } else { |
|
12647 // If no head, follows that there's no tail (at initial or reset) |
|
12648 tail = node; |
|
12649 } |
|
12650 |
|
12651 // Trim tail if we're reached max size and are pending cache insertion |
|
12652 if (size === /** @type {MemizeOptions} */ (options).maxSize) { |
|
12653 tail = /** @type {MemizeCacheNode} */ (tail).prev; |
|
12654 /** @type {MemizeCacheNode} */ (tail).next = null; |
|
12655 } else { |
|
12656 size++; |
|
12657 } |
|
12658 |
|
12659 head = node; |
|
12660 |
|
12661 return node.val; |
|
12662 } |
|
12663 |
|
12664 memoized.clear = function () { |
|
12665 head = null; |
|
12666 tail = null; |
|
12667 size = 0; |
|
12668 }; |
|
12669 |
|
12670 // Ignore reason: There's not a clear solution to create an intersection of |
|
12671 // the function with additional properties, where the goal is to retain the |
|
12672 // function signature of the incoming argument and add control properties |
|
12673 // on the return value. |
|
12674 |
|
12675 // @ts-ignore |
|
12676 return memoized; |
|
12677 } |
|
12678 |
|
12679 |
|
12680 |
|
10646 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/matchers.js |
12681 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/matchers.js |
10647 /** |
12682 /** |
10648 * External dependencies |
12683 * External dependencies |
10649 */ |
12684 */ |
10650 |
12685 |
12686 |
|
12687 /** |
|
12688 * WordPress dependencies |
|
12689 */ |
|
12690 |
|
12691 |
|
10651 /** |
12692 /** |
10652 * Internal dependencies |
12693 * Internal dependencies |
10653 */ |
12694 */ |
10654 |
|
10655 |
12695 |
10656 |
12696 |
10657 function matchers_html(selector, multilineTag) { |
12697 function matchers_html(selector, multilineTag) { |
10658 return domNode => { |
12698 return domNode => { |
10659 let match = domNode; |
12699 let match = domNode; |
10660 |
|
10661 if (selector) { |
12700 if (selector) { |
10662 match = domNode.querySelector(selector); |
12701 match = domNode.querySelector(selector); |
10663 } |
12702 } |
10664 |
|
10665 if (!match) { |
12703 if (!match) { |
10666 return ''; |
12704 return ''; |
10667 } |
12705 } |
10668 |
|
10669 if (multilineTag) { |
12706 if (multilineTag) { |
10670 let value = ''; |
12707 let value = ''; |
10671 const length = match.children.length; |
12708 const length = match.children.length; |
10672 |
|
10673 for (let index = 0; index < length; index++) { |
12709 for (let index = 0; index < length; index++) { |
10674 const child = match.children[index]; |
12710 const child = match.children[index]; |
10675 |
|
10676 if (child.nodeName.toLowerCase() !== multilineTag) { |
12711 if (child.nodeName.toLowerCase() !== multilineTag) { |
10677 continue; |
12712 continue; |
10678 } |
12713 } |
10679 |
|
10680 value += child.outerHTML; |
12714 value += child.outerHTML; |
10681 } |
12715 } |
10682 |
|
10683 return value; |
12716 return value; |
10684 } |
12717 } |
10685 |
|
10686 return match.innerHTML; |
12718 return match.innerHTML; |
10687 }; |
12719 }; |
10688 } |
12720 } |
12721 const richText = (selector, preserveWhiteSpace) => el => { |
|
12722 const target = selector ? el.querySelector(selector) : el; |
|
12723 return target ? external_wp_richText_namespaceObject.RichTextData.fromHTMLElement(target, { |
|
12724 preserveWhiteSpace |
|
12725 }) : external_wp_richText_namespaceObject.RichTextData.empty(); |
|
12726 }; |
|
10689 |
12727 |
10690 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/node.js |
12728 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/node.js |
10691 /** |
12729 /** |
12730 * WordPress dependencies |
|
12731 */ |
|
12732 |
|
12733 |
|
12734 /** |
|
10692 * Internal dependencies |
12735 * Internal dependencies |
10693 */ |
12736 */ |
12737 |
|
10694 |
12738 |
10695 /** |
12739 /** |
10696 * A representation of a single node within a block's rich text value. If |
12740 * A representation of a single node within a block's rich text value. If |
10697 * representing a text node, the value is simply a string of the node value. |
12741 * representing a text node, the value is simply a string of the node value. |
10698 * As representing an element node, it is an object of: |
12742 * As representing an element node, it is an object of: |
10710 * @param {WPBlockNode} node Block node to test |
12754 * @param {WPBlockNode} node Block node to test |
10711 * @param {string} type Node to type to test against. |
12755 * @param {string} type Node to type to test against. |
10712 * |
12756 * |
10713 * @return {boolean} Whether node is of intended type. |
12757 * @return {boolean} Whether node is of intended type. |
10714 */ |
12758 */ |
10715 |
|
10716 function isNodeOfType(node, type) { |
12759 function isNodeOfType(node, type) { |
12760 external_wp_deprecated_default()('wp.blocks.node.isNodeOfType', { |
|
12761 since: '6.1', |
|
12762 version: '6.3', |
|
12763 link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/' |
|
12764 }); |
|
10717 return node && node.type === type; |
12765 return node && node.type === type; |
10718 } |
12766 } |
12767 |
|
10719 /** |
12768 /** |
10720 * Given an object implementing the NamedNodeMap interface, returns a plain |
12769 * Given an object implementing the NamedNodeMap interface, returns a plain |
10721 * object equivalent value of name, value key-value pairs. |
12770 * object equivalent value of name, value key-value pairs. |
10722 * |
12771 * |
10723 * @see https://dom.spec.whatwg.org/#interface-namednodemap |
12772 * @see https://dom.spec.whatwg.org/#interface-namednodemap |
10724 * |
12773 * |
10725 * @param {NamedNodeMap} nodeMap NamedNodeMap to convert to object. |
12774 * @param {NamedNodeMap} nodeMap NamedNodeMap to convert to object. |
10726 * |
12775 * |
10727 * @return {Object} Object equivalent value of NamedNodeMap. |
12776 * @return {Object} Object equivalent value of NamedNodeMap. |
10728 */ |
12777 */ |
10729 |
|
10730 |
|
10731 function getNamedNodeMapAsObject(nodeMap) { |
12778 function getNamedNodeMapAsObject(nodeMap) { |
10732 const result = {}; |
12779 const result = {}; |
10733 |
|
10734 for (let i = 0; i < nodeMap.length; i++) { |
12780 for (let i = 0; i < nodeMap.length; i++) { |
10735 const { |
12781 const { |
10736 name, |
12782 name, |
10737 value |
12783 value |
10738 } = nodeMap[i]; |
12784 } = nodeMap[i]; |
10739 result[name] = value; |
12785 result[name] = value; |
10740 } |
12786 } |
10741 |
|
10742 return result; |
12787 return result; |
10743 } |
12788 } |
12789 |
|
10744 /** |
12790 /** |
10745 * Given a DOM Element or Text node, returns an equivalent block node. Throws |
12791 * Given a DOM Element or Text node, returns an equivalent block node. Throws |
10746 * if passed any node type other than element or text. |
12792 * if passed any node type other than element or text. |
10747 * |
12793 * |
10748 * @throws {TypeError} If non-element/text node is passed. |
12794 * @throws {TypeError} If non-element/text node is passed. |
10749 * |
12795 * |
10750 * @param {Node} domNode DOM node to convert. |
12796 * @param {Node} domNode DOM node to convert. |
10751 * |
12797 * |
10752 * @return {WPBlockNode} Block node equivalent to DOM node. |
12798 * @return {WPBlockNode} Block node equivalent to DOM node. |
10753 */ |
12799 */ |
10754 |
|
10755 function fromDOM(domNode) { |
12800 function fromDOM(domNode) { |
12801 external_wp_deprecated_default()('wp.blocks.node.fromDOM', { |
|
12802 since: '6.1', |
|
12803 version: '6.3', |
|
12804 alternative: 'wp.richText.create', |
|
12805 link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/' |
|
12806 }); |
|
10756 if (domNode.nodeType === domNode.TEXT_NODE) { |
12807 if (domNode.nodeType === domNode.TEXT_NODE) { |
10757 return domNode.nodeValue; |
12808 return domNode.nodeValue; |
10758 } |
12809 } |
10759 |
|
10760 if (domNode.nodeType !== domNode.ELEMENT_NODE) { |
12810 if (domNode.nodeType !== domNode.ELEMENT_NODE) { |
10761 throw new TypeError('A block node can only be created from a node of type text or ' + 'element.'); |
12811 throw new TypeError('A block node can only be created from a node of type text or ' + 'element.'); |
10762 } |
12812 } |
10763 |
|
10764 return { |
12813 return { |
10765 type: domNode.nodeName.toLowerCase(), |
12814 type: domNode.nodeName.toLowerCase(), |
10766 props: { ...getNamedNodeMapAsObject(domNode.attributes), |
12815 props: { |
12816 ...getNamedNodeMapAsObject(domNode.attributes), |
|
10767 children: children_fromDOM(domNode.childNodes) |
12817 children: children_fromDOM(domNode.childNodes) |
10768 } |
12818 } |
10769 }; |
12819 }; |
10770 } |
12820 } |
12821 |
|
10771 /** |
12822 /** |
10772 * Given a block node, returns its HTML string representation. |
12823 * Given a block node, returns its HTML string representation. |
10773 * |
12824 * |
10774 * @param {WPBlockNode} node Block node to convert to string. |
12825 * @param {WPBlockNode} node Block node to convert to string. |
10775 * |
12826 * |
10776 * @return {string} String HTML representation of block node. |
12827 * @return {string} String HTML representation of block node. |
10777 */ |
12828 */ |
10778 |
|
10779 function toHTML(node) { |
12829 function toHTML(node) { |
12830 external_wp_deprecated_default()('wp.blocks.node.toHTML', { |
|
12831 since: '6.1', |
|
12832 version: '6.3', |
|
12833 alternative: 'wp.richText.toHTMLString', |
|
12834 link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/' |
|
12835 }); |
|
10780 return children_toHTML([node]); |
12836 return children_toHTML([node]); |
10781 } |
12837 } |
12838 |
|
10782 /** |
12839 /** |
10783 * Given a selector, returns an hpq matcher generating a WPBlockNode value |
12840 * Given a selector, returns an hpq matcher generating a WPBlockNode value |
10784 * matching the selector result. |
12841 * matching the selector result. |
10785 * |
12842 * |
10786 * @param {string} selector DOM selector. |
12843 * @param {string} selector DOM selector. |
10787 * |
12844 * |
10788 * @return {Function} hpq matcher. |
12845 * @return {Function} hpq matcher. |
10789 */ |
12846 */ |
10790 |
12847 function matcher(selector) { |
10791 function node_matcher(selector) { |
12848 external_wp_deprecated_default()('wp.blocks.node.matcher', { |
12849 since: '6.1', |
|
12850 version: '6.3', |
|
12851 alternative: 'html source', |
|
12852 link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/' |
|
12853 }); |
|
10792 return domNode => { |
12854 return domNode => { |
10793 let match = domNode; |
12855 let match = domNode; |
10794 |
|
10795 if (selector) { |
12856 if (selector) { |
10796 match = domNode.querySelector(selector); |
12857 match = domNode.querySelector(selector); |
10797 } |
12858 } |
10798 |
|
10799 try { |
12859 try { |
10800 return fromDOM(match); |
12860 return fromDOM(match); |
10801 } catch (error) { |
12861 } catch (error) { |
10802 return null; |
12862 return null; |
10803 } |
12863 } |
10804 }; |
12864 }; |
10805 } |
12865 } |
12866 |
|
10806 /** |
12867 /** |
10807 * Object of utility functions used in managing block attribute values of |
12868 * Object of utility functions used in managing block attribute values of |
10808 * source `node`. |
12869 * source `node`. |
10809 * |
12870 * |
10810 * @see https://github.com/WordPress/gutenberg/pull/10439 |
12871 * @see https://github.com/WordPress/gutenberg/pull/10439 |
10812 * @deprecated since 4.0. The `node` source should not be used, and can be |
12873 * @deprecated since 4.0. The `node` source should not be used, and can be |
10813 * replaced by the `html` source. |
12874 * replaced by the `html` source. |
10814 * |
12875 * |
10815 * @private |
12876 * @private |
10816 */ |
12877 */ |
10817 |
12878 /* harmony default export */ const node = ({ |
10818 /* harmony default export */ var node = ({ |
|
10819 isNodeOfType, |
12879 isNodeOfType, |
10820 fromDOM, |
12880 fromDOM, |
10821 toHTML, |
12881 toHTML, |
10822 matcher: node_matcher |
12882 matcher |
10823 }); |
12883 }); |
10824 |
12884 |
10825 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/children.js |
12885 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/children.js |
10826 /** |
12886 /** |
10827 * External dependencies |
|
10828 */ |
|
10829 |
|
10830 /** |
|
10831 * WordPress dependencies |
12887 * WordPress dependencies |
10832 */ |
12888 */ |
10833 |
12889 |
10834 |
12890 |
12891 |
|
10835 /** |
12892 /** |
10836 * Internal dependencies |
12893 * Internal dependencies |
10837 */ |
12894 */ |
10838 |
12895 |
10839 |
12896 |
10846 /** |
12903 /** |
10847 * Given block children, returns a serialize-capable WordPress element. |
12904 * Given block children, returns a serialize-capable WordPress element. |
10848 * |
12905 * |
10849 * @param {WPBlockChildren} children Block children object to convert. |
12906 * @param {WPBlockChildren} children Block children object to convert. |
10850 * |
12907 * |
10851 * @return {WPElement} A serialize-capable element. |
12908 * @return {Element} A serialize-capable element. |
10852 */ |
12909 */ |
10853 |
|
10854 function getSerializeCapableElement(children) { |
12910 function getSerializeCapableElement(children) { |
10855 // The fact that block children are compatible with the element serializer is |
12911 // The fact that block children are compatible with the element serializer is |
10856 // merely an implementation detail that currently serves to be true, but |
12912 // merely an implementation detail that currently serves to be true, but |
10857 // should not be mistaken as being a guarantee on the external API. The |
12913 // should not be mistaken as being a guarantee on the external API. The |
10858 // public API only offers guarantees to work with strings (toHTML) and DOM |
12914 // public API only offers guarantees to work with strings (toHTML) and DOM |
10859 // elements (fromDOM), and should provide utilities to manipulate the value |
12915 // elements (fromDOM), and should provide utilities to manipulate the value |
10860 // rather than expect consumers to inspect or construct its shape (concat). |
12916 // rather than expect consumers to inspect or construct its shape (concat). |
10861 return children; |
12917 return children; |
10862 } |
12918 } |
12919 |
|
10863 /** |
12920 /** |
10864 * Given block children, returns an array of block nodes. |
12921 * Given block children, returns an array of block nodes. |
10865 * |
12922 * |
10866 * @param {WPBlockChildren} children Block children object to convert. |
12923 * @param {WPBlockChildren} children Block children object to convert. |
10867 * |
12924 * |
10868 * @return {Array<WPBlockNode>} An array of individual block nodes. |
12925 * @return {Array<WPBlockNode>} An array of individual block nodes. |
10869 */ |
12926 */ |
10870 |
|
10871 function getChildrenArray(children) { |
12927 function getChildrenArray(children) { |
12928 external_wp_deprecated_default()('wp.blocks.children.getChildrenArray', { |
|
12929 since: '6.1', |
|
12930 version: '6.3', |
|
12931 link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/' |
|
12932 }); |
|
12933 |
|
10872 // The fact that block children are compatible with the element serializer |
12934 // The fact that block children are compatible with the element serializer |
10873 // is merely an implementation detail that currently serves to be true, but |
12935 // is merely an implementation detail that currently serves to be true, but |
10874 // should not be mistaken as being a guarantee on the external API. |
12936 // should not be mistaken as being a guarantee on the external API. |
10875 return children; |
12937 return children; |
10876 } |
12938 } |
12939 |
|
10877 /** |
12940 /** |
10878 * Given two or more block nodes, returns a new block node representing a |
12941 * Given two or more block nodes, returns a new block node representing a |
10879 * concatenation of its values. |
12942 * concatenation of its values. |
10880 * |
12943 * |
10881 * @param {...WPBlockChildren} blockNodes Block nodes to concatenate. |
12944 * @param {...WPBlockChildren} blockNodes Block nodes to concatenate. |
10882 * |
12945 * |
10883 * @return {WPBlockChildren} Concatenated block node. |
12946 * @return {WPBlockChildren} Concatenated block node. |
10884 */ |
12947 */ |
10885 |
12948 function concat(...blockNodes) { |
10886 |
12949 external_wp_deprecated_default()('wp.blocks.children.concat', { |
10887 function concat() { |
12950 since: '6.1', |
12951 version: '6.3', |
|
12952 alternative: 'wp.richText.concat', |
|
12953 link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/' |
|
12954 }); |
|
10888 const result = []; |
12955 const result = []; |
10889 |
12956 for (let i = 0; i < blockNodes.length; i++) { |
10890 for (let i = 0; i < arguments.length; i++) { |
12957 const blockNode = Array.isArray(blockNodes[i]) ? blockNodes[i] : [blockNodes[i]]; |
10891 const blockNode = (0,external_lodash_namespaceObject.castArray)(i < 0 || arguments.length <= i ? undefined : arguments[i]); |
|
10892 |
|
10893 for (let j = 0; j < blockNode.length; j++) { |
12958 for (let j = 0; j < blockNode.length; j++) { |
10894 const child = blockNode[j]; |
12959 const child = blockNode[j]; |
10895 const canConcatToPreviousString = typeof child === 'string' && typeof result[result.length - 1] === 'string'; |
12960 const canConcatToPreviousString = typeof child === 'string' && typeof result[result.length - 1] === 'string'; |
10896 |
|
10897 if (canConcatToPreviousString) { |
12961 if (canConcatToPreviousString) { |
10898 result[result.length - 1] += child; |
12962 result[result.length - 1] += child; |
10899 } else { |
12963 } else { |
10900 result.push(child); |
12964 result.push(child); |
10901 } |
12965 } |
10902 } |
12966 } |
10903 } |
12967 } |
10904 |
|
10905 return result; |
12968 return result; |
10906 } |
12969 } |
12970 |
|
10907 /** |
12971 /** |
10908 * Given an iterable set of DOM nodes, returns equivalent block children. |
12972 * Given an iterable set of DOM nodes, returns equivalent block children. |
10909 * Ignores any non-element/text nodes included in set. |
12973 * Ignores any non-element/text nodes included in set. |
10910 * |
12974 * |
10911 * @param {Iterable.<Node>} domNodes Iterable set of DOM nodes to convert. |
12975 * @param {Iterable.<Node>} domNodes Iterable set of DOM nodes to convert. |
10912 * |
12976 * |
10913 * @return {WPBlockChildren} Block children equivalent to DOM nodes. |
12977 * @return {WPBlockChildren} Block children equivalent to DOM nodes. |
10914 */ |
12978 */ |
10915 |
|
10916 function children_fromDOM(domNodes) { |
12979 function children_fromDOM(domNodes) { |
12980 external_wp_deprecated_default()('wp.blocks.children.fromDOM', { |
|
12981 since: '6.1', |
|
12982 version: '6.3', |
|
12983 alternative: 'wp.richText.create', |
|
12984 link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/' |
|
12985 }); |
|
10917 const result = []; |
12986 const result = []; |
10918 |
|
10919 for (let i = 0; i < domNodes.length; i++) { |
12987 for (let i = 0; i < domNodes.length; i++) { |
10920 try { |
12988 try { |
10921 result.push(fromDOM(domNodes[i])); |
12989 result.push(fromDOM(domNodes[i])); |
10922 } catch (error) {// Simply ignore if DOM node could not be converted. |
12990 } catch (error) { |
10923 } |
12991 // Simply ignore if DOM node could not be converted. |
10924 } |
12992 } |
10925 |
12993 } |
10926 return result; |
12994 return result; |
10927 } |
12995 } |
12996 |
|
10928 /** |
12997 /** |
10929 * Given a block node, returns its HTML string representation. |
12998 * Given a block node, returns its HTML string representation. |
10930 * |
12999 * |
10931 * @param {WPBlockChildren} children Block node(s) to convert to string. |
13000 * @param {WPBlockChildren} children Block node(s) to convert to string. |
10932 * |
13001 * |
10933 * @return {string} String HTML representation of block node. |
13002 * @return {string} String HTML representation of block node. |
10934 */ |
13003 */ |
10935 |
|
10936 function children_toHTML(children) { |
13004 function children_toHTML(children) { |
13005 external_wp_deprecated_default()('wp.blocks.children.toHTML', { |
|
13006 since: '6.1', |
|
13007 version: '6.3', |
|
13008 alternative: 'wp.richText.toHTMLString', |
|
13009 link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/' |
|
13010 }); |
|
10937 const element = getSerializeCapableElement(children); |
13011 const element = getSerializeCapableElement(children); |
10938 return (0,external_wp_element_namespaceObject.renderToString)(element); |
13012 return (0,external_wp_element_namespaceObject.renderToString)(element); |
10939 } |
13013 } |
13014 |
|
10940 /** |
13015 /** |
10941 * Given a selector, returns an hpq matcher generating a WPBlockChildren value |
13016 * Given a selector, returns an hpq matcher generating a WPBlockChildren value |
10942 * matching the selector result. |
13017 * matching the selector result. |
10943 * |
13018 * |
10944 * @param {string} selector DOM selector. |
13019 * @param {string} selector DOM selector. |
10945 * |
13020 * |
10946 * @return {Function} hpq matcher. |
13021 * @return {Function} hpq matcher. |
10947 */ |
13022 */ |
10948 |
|
10949 function children_matcher(selector) { |
13023 function children_matcher(selector) { |
13024 external_wp_deprecated_default()('wp.blocks.children.matcher', { |
|
13025 since: '6.1', |
|
13026 version: '6.3', |
|
13027 alternative: 'html source', |
|
13028 link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/' |
|
13029 }); |
|
10950 return domNode => { |
13030 return domNode => { |
10951 let match = domNode; |
13031 let match = domNode; |
10952 |
|
10953 if (selector) { |
13032 if (selector) { |
10954 match = domNode.querySelector(selector); |
13033 match = domNode.querySelector(selector); |
10955 } |
13034 } |
10956 |
|
10957 if (match) { |
13035 if (match) { |
10958 return children_fromDOM(match.childNodes); |
13036 return children_fromDOM(match.childNodes); |
10959 } |
13037 } |
10960 |
|
10961 return []; |
13038 return []; |
10962 }; |
13039 }; |
10963 } |
13040 } |
13041 |
|
10964 /** |
13042 /** |
10965 * Object of utility functions used in managing block attribute values of |
13043 * Object of utility functions used in managing block attribute values of |
10966 * source `children`. |
13044 * source `children`. |
10967 * |
13045 * |
10968 * @see https://github.com/WordPress/gutenberg/pull/10439 |
13046 * @see https://github.com/WordPress/gutenberg/pull/10439 |
10970 * @deprecated since 4.0. The `children` source should not be used, and can be |
13048 * @deprecated since 4.0. The `children` source should not be used, and can be |
10971 * replaced by the `html` source. |
13049 * replaced by the `html` source. |
10972 * |
13050 * |
10973 * @private |
13051 * @private |
10974 */ |
13052 */ |
10975 |
13053 /* harmony default export */ const children = ({ |
10976 /* harmony default export */ var children = ({ |
|
10977 concat, |
13054 concat, |
10978 getChildrenArray, |
13055 getChildrenArray, |
10979 fromDOM: children_fromDOM, |
13056 fromDOM: children_fromDOM, |
10980 toHTML: children_toHTML, |
13057 toHTML: children_toHTML, |
10981 matcher: children_matcher |
13058 matcher: children_matcher |
10991 /** |
13068 /** |
10992 * WordPress dependencies |
13069 * WordPress dependencies |
10993 */ |
13070 */ |
10994 |
13071 |
10995 |
13072 |
13073 |
|
10996 /** |
13074 /** |
10997 * Internal dependencies |
13075 * Internal dependencies |
10998 */ |
13076 */ |
10999 |
13077 |
11000 |
13078 |
11008 * |
13086 * |
11009 * @param {Function} matcher Original hpq matcher. |
13087 * @param {Function} matcher Original hpq matcher. |
11010 * |
13088 * |
11011 * @return {Function} Enhanced hpq matcher. |
13089 * @return {Function} Enhanced hpq matcher. |
11012 */ |
13090 */ |
11013 |
13091 const toBooleanAttributeMatcher = matcher => value => matcher(value) !== undefined; |
11014 const toBooleanAttributeMatcher = matcher => (0,external_lodash_namespaceObject.flow)([matcher, // Expected values from `attr( 'disabled' )`: |
13092 |
11015 // |
|
11016 // <input> |
|
11017 // - Value: `undefined` |
|
11018 // - Transformed: `false` |
|
11019 // |
|
11020 // <input disabled> |
|
11021 // - Value: `''` |
|
11022 // - Transformed: `true` |
|
11023 // |
|
11024 // <input disabled="disabled"> |
|
11025 // - Value: `'disabled'` |
|
11026 // - Transformed: `true` |
|
11027 value => value !== undefined]); |
|
11028 /** |
13093 /** |
11029 * Returns true if value is of the given JSON schema type, or false otherwise. |
13094 * Returns true if value is of the given JSON schema type, or false otherwise. |
11030 * |
13095 * |
11031 * @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25 |
13096 * @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25 |
11032 * |
13097 * |
11033 * @param {*} value Value to test. |
13098 * @param {*} value Value to test. |
11034 * @param {string} type Type to test. |
13099 * @param {string} type Type to test. |
11035 * |
13100 * |
11036 * @return {boolean} Whether value is of type. |
13101 * @return {boolean} Whether value is of type. |
11037 */ |
13102 */ |
11038 |
|
11039 function isOfType(value, type) { |
13103 function isOfType(value, type) { |
11040 switch (type) { |
13104 switch (type) { |
13105 case 'rich-text': |
|
13106 return value instanceof external_wp_richText_namespaceObject.RichTextData; |
|
11041 case 'string': |
13107 case 'string': |
11042 return typeof value === 'string'; |
13108 return typeof value === 'string'; |
11043 |
|
11044 case 'boolean': |
13109 case 'boolean': |
11045 return typeof value === 'boolean'; |
13110 return typeof value === 'boolean'; |
11046 |
|
11047 case 'object': |
13111 case 'object': |
11048 return !!value && value.constructor === Object; |
13112 return !!value && value.constructor === Object; |
11049 |
|
11050 case 'null': |
13113 case 'null': |
11051 return value === null; |
13114 return value === null; |
11052 |
|
11053 case 'array': |
13115 case 'array': |
11054 return Array.isArray(value); |
13116 return Array.isArray(value); |
11055 |
|
11056 case 'integer': |
13117 case 'integer': |
11057 case 'number': |
13118 case 'number': |
11058 return typeof value === 'number'; |
13119 return typeof value === 'number'; |
11059 } |
13120 } |
11060 |
|
11061 return true; |
13121 return true; |
11062 } |
13122 } |
13123 |
|
11063 /** |
13124 /** |
11064 * Returns true if value is of an array of given JSON schema types, or false |
13125 * Returns true if value is of an array of given JSON schema types, or false |
11065 * otherwise. |
13126 * otherwise. |
11066 * |
13127 * |
11067 * @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25 |
13128 * @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25 |
11069 * @param {*} value Value to test. |
13130 * @param {*} value Value to test. |
11070 * @param {string[]} types Types to test. |
13131 * @param {string[]} types Types to test. |
11071 * |
13132 * |
11072 * @return {boolean} Whether value is of types. |
13133 * @return {boolean} Whether value is of types. |
11073 */ |
13134 */ |
11074 |
|
11075 function isOfTypes(value, types) { |
13135 function isOfTypes(value, types) { |
11076 return types.some(type => isOfType(value, type)); |
13136 return types.some(type => isOfType(value, type)); |
11077 } |
13137 } |
13138 |
|
11078 /** |
13139 /** |
11079 * Given an attribute key, an attribute's schema, a block's raw content and the |
13140 * Given an attribute key, an attribute's schema, a block's raw content and the |
11080 * commentAttributes returns the attribute value depending on its source |
13141 * commentAttributes returns the attribute value depending on its source |
11081 * definition of the given attribute key. |
13142 * definition of the given attribute key. |
11082 * |
13143 * |
11083 * @param {string} attributeKey Attribute key. |
13144 * @param {string} attributeKey Attribute key. |
11084 * @param {Object} attributeSchema Attribute's schema. |
13145 * @param {Object} attributeSchema Attribute's schema. |
11085 * @param {string|Node} innerHTML Block's raw content. |
13146 * @param {Node} innerDOM Parsed DOM of block's inner HTML. |
11086 * @param {Object} commentAttributes Block's comment attributes. |
13147 * @param {Object} commentAttributes Block's comment attributes. |
13148 * @param {string} innerHTML Raw HTML from block node's innerHTML property. |
|
11087 * |
13149 * |
11088 * @return {*} Attribute value. |
13150 * @return {*} Attribute value. |
11089 */ |
13151 */ |
11090 |
13152 function getBlockAttribute(attributeKey, attributeSchema, innerDOM, commentAttributes, innerHTML) { |
11091 function getBlockAttribute(attributeKey, attributeSchema, innerHTML, commentAttributes) { |
|
11092 let value; |
13153 let value; |
11093 |
|
11094 switch (attributeSchema.source) { |
13154 switch (attributeSchema.source) { |
11095 // An undefined source means that it's an attribute serialized to the |
13155 // An undefined source means that it's an attribute serialized to the |
11096 // block's "comment". |
13156 // block's "comment". |
11097 case undefined: |
13157 case undefined: |
11098 value = commentAttributes ? commentAttributes[attributeKey] : undefined; |
13158 value = commentAttributes ? commentAttributes[attributeKey] : undefined; |
11099 break; |
13159 break; |
11100 |
13160 // raw source means that it's the original raw block content. |
13161 case 'raw': |
|
13162 value = innerHTML; |
|
13163 break; |
|
11101 case 'attribute': |
13164 case 'attribute': |
11102 case 'property': |
13165 case 'property': |
11103 case 'html': |
13166 case 'html': |
11104 case 'text': |
13167 case 'text': |
13168 case 'rich-text': |
|
11105 case 'children': |
13169 case 'children': |
11106 case 'node': |
13170 case 'node': |
11107 case 'query': |
13171 case 'query': |
11108 case 'tag': |
13172 case 'tag': |
11109 value = parseWithAttributeSchema(innerHTML, attributeSchema); |
13173 value = parseWithAttributeSchema(innerDOM, attributeSchema); |
11110 break; |
13174 break; |
11111 } |
13175 } |
11112 |
|
11113 if (!isValidByType(value, attributeSchema.type) || !isValidByEnum(value, attributeSchema.enum)) { |
13176 if (!isValidByType(value, attributeSchema.type) || !isValidByEnum(value, attributeSchema.enum)) { |
11114 // Reject the value if it is not valid. Reverting to the undefined |
13177 // Reject the value if it is not valid. Reverting to the undefined |
11115 // value ensures the default is respected, if applicable. |
13178 // value ensures the default is respected, if applicable. |
11116 value = undefined; |
13179 value = undefined; |
11117 } |
13180 } |
11118 |
|
11119 if (value === undefined) { |
13181 if (value === undefined) { |
11120 value = attributeSchema.default; |
13182 value = getDefault(attributeSchema); |
11121 } |
13183 } |
11122 |
|
11123 return value; |
13184 return value; |
11124 } |
13185 } |
13186 |
|
11125 /** |
13187 /** |
11126 * Returns true if value is valid per the given block attribute schema type |
13188 * Returns true if value is valid per the given block attribute schema type |
11127 * definition, or false otherwise. |
13189 * definition, or false otherwise. |
11128 * |
13190 * |
11129 * @see https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.1 |
13191 * @see https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.1 |
11131 * @param {*} value Value to test. |
13193 * @param {*} value Value to test. |
11132 * @param {?(Array<string>|string)} type Block attribute schema type. |
13194 * @param {?(Array<string>|string)} type Block attribute schema type. |
11133 * |
13195 * |
11134 * @return {boolean} Whether value is valid. |
13196 * @return {boolean} Whether value is valid. |
11135 */ |
13197 */ |
11136 |
|
11137 function isValidByType(value, type) { |
13198 function isValidByType(value, type) { |
11138 return type === undefined || isOfTypes(value, (0,external_lodash_namespaceObject.castArray)(type)); |
13199 return type === undefined || isOfTypes(value, Array.isArray(type) ? type : [type]); |
11139 } |
13200 } |
13201 |
|
11140 /** |
13202 /** |
11141 * Returns true if value is valid per the given block attribute schema enum |
13203 * Returns true if value is valid per the given block attribute schema enum |
11142 * definition, or false otherwise. |
13204 * definition, or false otherwise. |
11143 * |
13205 * |
11144 * @see https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.2 |
13206 * @see https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.2 |
11146 * @param {*} value Value to test. |
13208 * @param {*} value Value to test. |
11147 * @param {?Array} enumSet Block attribute schema enum. |
13209 * @param {?Array} enumSet Block attribute schema enum. |
11148 * |
13210 * |
11149 * @return {boolean} Whether value is valid. |
13211 * @return {boolean} Whether value is valid. |
11150 */ |
13212 */ |
11151 |
|
11152 function isValidByEnum(value, enumSet) { |
13213 function isValidByEnum(value, enumSet) { |
11153 return !Array.isArray(enumSet) || enumSet.includes(value); |
13214 return !Array.isArray(enumSet) || enumSet.includes(value); |
11154 } |
13215 } |
13216 |
|
11155 /** |
13217 /** |
11156 * Returns an hpq matcher given a source object. |
13218 * Returns an hpq matcher given a source object. |
11157 * |
13219 * |
11158 * @param {Object} sourceConfig Attribute Source object. |
13220 * @param {Object} sourceConfig Attribute Source object. |
11159 * |
13221 * |
11160 * @return {Function} A hpq Matcher. |
13222 * @return {Function} A hpq Matcher. |
11161 */ |
13223 */ |
11162 |
13224 const matcherFromSource = memize(sourceConfig => { |
11163 const matcherFromSource = memize_default()(sourceConfig => { |
|
11164 switch (sourceConfig.source) { |
13225 switch (sourceConfig.source) { |
11165 case 'attribute': |
13226 case 'attribute': |
11166 let matcher = attr(sourceConfig.selector, sourceConfig.attribute); |
13227 { |
11167 |
13228 let matcher = attr(sourceConfig.selector, sourceConfig.attribute); |
11168 if (sourceConfig.type === 'boolean') { |
13229 if (sourceConfig.type === 'boolean') { |
11169 matcher = toBooleanAttributeMatcher(matcher); |
13230 matcher = toBooleanAttributeMatcher(matcher); |
13231 } |
|
13232 return matcher; |
|
11170 } |
13233 } |
11171 |
|
11172 return matcher; |
|
11173 |
|
11174 case 'html': |
13234 case 'html': |
11175 return matchers_html(sourceConfig.selector, sourceConfig.multiline); |
13235 return matchers_html(sourceConfig.selector, sourceConfig.multiline); |
11176 |
|
11177 case 'text': |
13236 case 'text': |
11178 return es_text(sourceConfig.selector); |
13237 return es_text(sourceConfig.selector); |
11179 |
13238 case 'rich-text': |
13239 return richText(sourceConfig.selector, sourceConfig.__unstablePreserveWhiteSpace); |
|
11180 case 'children': |
13240 case 'children': |
11181 return children_matcher(sourceConfig.selector); |
13241 return children_matcher(sourceConfig.selector); |
11182 |
|
11183 case 'node': |
13242 case 'node': |
11184 return node_matcher(sourceConfig.selector); |
13243 return matcher(sourceConfig.selector); |
11185 |
|
11186 case 'query': |
13244 case 'query': |
11187 const subMatchers = (0,external_lodash_namespaceObject.mapValues)(sourceConfig.query, matcherFromSource); |
13245 const subMatchers = Object.fromEntries(Object.entries(sourceConfig.query).map(([key, subSourceConfig]) => [key, matcherFromSource(subSourceConfig)])); |
11188 return query(sourceConfig.selector, subMatchers); |
13246 return query(sourceConfig.selector, subMatchers); |
11189 |
|
11190 case 'tag': |
13247 case 'tag': |
11191 return (0,external_lodash_namespaceObject.flow)([prop(sourceConfig.selector, 'nodeName'), nodeName => nodeName ? nodeName.toLowerCase() : undefined]); |
13248 { |
11192 |
13249 const matcher = prop(sourceConfig.selector, 'nodeName'); |
13250 return domNode => matcher(domNode)?.toLowerCase(); |
|
13251 } |
|
11193 default: |
13252 default: |
11194 // eslint-disable-next-line no-console |
13253 // eslint-disable-next-line no-console |
11195 console.error(`Unknown source type "${sourceConfig.source}"`); |
13254 console.error(`Unknown source type "${sourceConfig.source}"`); |
11196 } |
13255 } |
11197 }); |
13256 }); |
13257 |
|
11198 /** |
13258 /** |
11199 * Parse a HTML string into DOM tree. |
13259 * Parse a HTML string into DOM tree. |
11200 * |
13260 * |
11201 * @param {string|Node} innerHTML HTML string or already parsed DOM node. |
13261 * @param {string|Node} innerHTML HTML string or already parsed DOM node. |
11202 * |
13262 * |
11203 * @return {Node} Parsed DOM node. |
13263 * @return {Node} Parsed DOM node. |
11204 */ |
13264 */ |
11205 |
|
11206 function parseHtml(innerHTML) { |
13265 function parseHtml(innerHTML) { |
11207 return parse(innerHTML, h => h); |
13266 return parse(innerHTML, h => h); |
11208 } |
13267 } |
13268 |
|
11209 /** |
13269 /** |
11210 * Given a block's raw content and an attribute's schema returns the attribute's |
13270 * Given a block's raw content and an attribute's schema returns the attribute's |
11211 * value depending on its source. |
13271 * value depending on its source. |
11212 * |
13272 * |
11213 * @param {string|Node} innerHTML Block's raw content. |
13273 * @param {string|Node} innerHTML Block's raw content. |
11214 * @param {Object} attributeSchema Attribute's schema. |
13274 * @param {Object} attributeSchema Attribute's schema. |
11215 * |
13275 * |
11216 * @return {*} Attribute value. |
13276 * @return {*} Attribute value. |
11217 */ |
13277 */ |
11218 |
|
11219 |
|
11220 function parseWithAttributeSchema(innerHTML, attributeSchema) { |
13278 function parseWithAttributeSchema(innerHTML, attributeSchema) { |
11221 return matcherFromSource(attributeSchema)(parseHtml(innerHTML)); |
13279 return matcherFromSource(attributeSchema)(parseHtml(innerHTML)); |
11222 } |
13280 } |
13281 |
|
11223 /** |
13282 /** |
11224 * Returns the block attributes of a registered block node given its type. |
13283 * Returns the block attributes of a registered block node given its type. |
11225 * |
13284 * |
11226 * @param {string|Object} blockTypeOrName Block type or name. |
13285 * @param {string|Object} blockTypeOrName Block type or name. |
11227 * @param {string|Node} innerHTML Raw block content. |
13286 * @param {string|Node} innerHTML Raw block content. |
11228 * @param {?Object} attributes Known block attributes (from delimiters). |
13287 * @param {?Object} attributes Known block attributes (from delimiters). |
11229 * |
13288 * |
11230 * @return {Object} All block attributes. |
13289 * @return {Object} All block attributes. |
11231 */ |
13290 */ |
11232 |
13291 function getBlockAttributes(blockTypeOrName, innerHTML, attributes = {}) { |
11233 function getBlockAttributes(blockTypeOrName, innerHTML) { |
13292 var _blockType$attributes; |
11234 let attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; |
|
11235 const doc = parseHtml(innerHTML); |
13293 const doc = parseHtml(innerHTML); |
11236 const blockType = normalizeBlockType(blockTypeOrName); |
13294 const blockType = normalizeBlockType(blockTypeOrName); |
11237 const blockAttributes = (0,external_lodash_namespaceObject.mapValues)(blockType.attributes, (schema, key) => getBlockAttribute(key, schema, doc, attributes)); |
13295 const blockAttributes = Object.fromEntries(Object.entries((_blockType$attributes = blockType.attributes) !== null && _blockType$attributes !== void 0 ? _blockType$attributes : {}).map(([key, schema]) => [key, getBlockAttribute(key, schema, doc, attributes, innerHTML)])); |
11238 return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getBlockAttributes', blockAttributes, blockType, innerHTML, attributes); |
13296 return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getBlockAttributes', blockAttributes, blockType, innerHTML, attributes); |
11239 } |
13297 } |
11240 |
13298 |
11241 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/fix-custom-classname.js |
13299 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/fix-custom-classname.js |
11242 /** |
13300 /** |
11243 * External dependencies |
|
11244 */ |
|
11245 |
|
11246 /** |
|
11247 * Internal dependencies |
13301 * Internal dependencies |
11248 */ |
13302 */ |
11249 |
|
11250 |
13303 |
11251 |
13304 |
11252 |
13305 |
11253 const CLASS_ATTR_SCHEMA = { |
13306 const CLASS_ATTR_SCHEMA = { |
11254 type: 'string', |
13307 type: 'string', |
11255 source: 'attribute', |
13308 source: 'attribute', |
11256 selector: '[data-custom-class-name] > *', |
13309 selector: '[data-custom-class-name] > *', |
11257 attribute: 'class' |
13310 attribute: 'class' |
11258 }; |
13311 }; |
13312 |
|
11259 /** |
13313 /** |
11260 * Given an HTML string, returns an array of class names assigned to the root |
13314 * Given an HTML string, returns an array of class names assigned to the root |
11261 * element in the markup. |
13315 * element in the markup. |
11262 * |
13316 * |
11263 * @param {string} innerHTML Markup string from which to extract classes. |
13317 * @param {string} innerHTML Markup string from which to extract classes. |
11264 * |
13318 * |
11265 * @return {string[]} Array of class names assigned to the root element. |
13319 * @return {string[]} Array of class names assigned to the root element. |
11266 */ |
13320 */ |
11267 |
|
11268 function getHTMLRootElementClasses(innerHTML) { |
13321 function getHTMLRootElementClasses(innerHTML) { |
11269 const parsed = parseWithAttributeSchema(`<div data-custom-class-name>${innerHTML}</div>`, CLASS_ATTR_SCHEMA); |
13322 const parsed = parseWithAttributeSchema(`<div data-custom-class-name>${innerHTML}</div>`, CLASS_ATTR_SCHEMA); |
11270 return parsed ? parsed.trim().split(/\s+/) : []; |
13323 return parsed ? parsed.trim().split(/\s+/) : []; |
11271 } |
13324 } |
13325 |
|
11272 /** |
13326 /** |
11273 * Given a parsed set of block attributes, if the block supports custom class |
13327 * Given a parsed set of block attributes, if the block supports custom class |
11274 * names and an unknown class (per the block's serialization behavior) is |
13328 * names and an unknown class (per the block's serialization behavior) is |
11275 * found, the unknown classes are treated as custom classes. This prevents the |
13329 * found, the unknown classes are treated as custom classes. This prevents the |
11276 * block from being considered as invalid. |
13330 * block from being considered as invalid. |
11279 * @param {Object} blockType Block type settings. |
13333 * @param {Object} blockType Block type settings. |
11280 * @param {string} innerHTML Original block markup. |
13334 * @param {string} innerHTML Original block markup. |
11281 * |
13335 * |
11282 * @return {Object} Filtered block attributes. |
13336 * @return {Object} Filtered block attributes. |
11283 */ |
13337 */ |
11284 |
|
11285 function fixCustomClassname(blockAttributes, blockType, innerHTML) { |
13338 function fixCustomClassname(blockAttributes, blockType, innerHTML) { |
11286 if (registration_hasBlockSupport(blockType, 'customClassName', true)) { |
13339 if (hasBlockSupport(blockType, 'customClassName', true)) { |
11287 // To determine difference, serialize block given the known set of |
13340 // To determine difference, serialize block given the known set of |
11288 // attributes, with the exception of `className`. This will determine |
13341 // attributes, with the exception of `className`. This will determine |
11289 // the default set of classes. From there, any difference in innerHTML |
13342 // the default set of classes. From there, any difference in innerHTML |
11290 // can be considered as custom classes. |
13343 // can be considered as custom classes. |
11291 const attributesSansClassName = (0,external_lodash_namespaceObject.omit)(blockAttributes, ['className']); |
13344 const { |
13345 className: omittedClassName, |
|
13346 ...attributesSansClassName |
|
13347 } = blockAttributes; |
|
11292 const serialized = getSaveContent(blockType, attributesSansClassName); |
13348 const serialized = getSaveContent(blockType, attributesSansClassName); |
11293 const defaultClasses = getHTMLRootElementClasses(serialized); |
13349 const defaultClasses = getHTMLRootElementClasses(serialized); |
11294 const actualClasses = getHTMLRootElementClasses(innerHTML); |
13350 const actualClasses = getHTMLRootElementClasses(innerHTML); |
11295 const customClasses = (0,external_lodash_namespaceObject.difference)(actualClasses, defaultClasses); |
13351 const customClasses = actualClasses.filter(className => !defaultClasses.includes(className)); |
11296 |
|
11297 if (customClasses.length) { |
13352 if (customClasses.length) { |
11298 blockAttributes.className = customClasses.join(' '); |
13353 blockAttributes.className = customClasses.join(' '); |
11299 } else if (serialized) { |
13354 } else if (serialized) { |
11300 delete blockAttributes.className; |
13355 delete blockAttributes.className; |
11301 } |
13356 } |
11302 } |
13357 } |
11303 |
|
11304 return blockAttributes; |
13358 return blockAttributes; |
11305 } |
13359 } |
11306 |
13360 |
11307 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/apply-built-in-validation-fixes.js |
13361 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/apply-built-in-validation-fixes.js |
11308 /** |
13362 /** |
11309 * Internal dependencies |
13363 * Internal dependencies |
11310 */ |
13364 */ |
13365 |
|
11311 |
13366 |
11312 /** |
13367 /** |
11313 * Attempts to fix block invalidation by applying build-in validation fixes |
13368 * Attempts to fix block invalidation by applying build-in validation fixes |
11314 * like moving all extra classNames to the className attribute. |
13369 * like moving all extra classNames to the className attribute. |
11315 * |
13370 * |
11318 * can be inferred from the block name, |
13373 * can be inferred from the block name, |
11319 * but it's here for performance reasons. |
13374 * but it's here for performance reasons. |
11320 * |
13375 * |
11321 * @return {WPBlock} Fixed block object |
13376 * @return {WPBlock} Fixed block object |
11322 */ |
13377 */ |
11323 |
|
11324 function applyBuiltInValidationFixes(block, blockType) { |
13378 function applyBuiltInValidationFixes(block, blockType) { |
11325 const updatedBlockAttributes = fixCustomClassname(block.attributes, blockType, block.originalContent); |
13379 const updatedBlockAttributes = fixCustomClassname(block.attributes, blockType, block.originalContent); |
11326 return { ...block, |
13380 return { |
13381 ...block, |
|
11327 attributes: updatedBlockAttributes |
13382 attributes: updatedBlockAttributes |
11328 }; |
13383 }; |
11329 } |
13384 } |
11330 |
13385 |
11331 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/apply-block-deprecated-versions.js |
13386 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/apply-block-deprecated-versions.js |
11332 /** |
13387 /** |
11333 * External dependencies |
|
11334 */ |
|
11335 |
|
11336 /** |
|
11337 * Internal dependencies |
13388 * Internal dependencies |
11338 */ |
13389 */ |
11339 |
13390 |
11340 |
13391 |
11341 |
13392 |
11342 |
13393 |
13394 |
|
13395 |
|
13396 /** |
|
13397 * Function that takes no arguments and always returns false. |
|
13398 * |
|
13399 * @return {boolean} Always returns false. |
|
13400 */ |
|
13401 function stubFalse() { |
|
13402 return false; |
|
13403 } |
|
11343 |
13404 |
11344 /** |
13405 /** |
11345 * Given a block object, returns a new copy of the block with any applicable |
13406 * Given a block object, returns a new copy of the block with any applicable |
11346 * deprecated migrations applied, or the original block if it was both valid |
13407 * deprecated migrations applied, or the original block if it was both valid |
11347 * and no eligible migrations exist. |
13408 * and no eligible migrations exist. |
11352 * can be inferred from the block name, |
13413 * can be inferred from the block name, |
11353 * but it's here for performance reasons. |
13414 * but it's here for performance reasons. |
11354 * |
13415 * |
11355 * @return {import(".").WPBlock} Migrated block object. |
13416 * @return {import(".").WPBlock} Migrated block object. |
11356 */ |
13417 */ |
11357 |
|
11358 function applyBlockDeprecatedVersions(block, rawBlock, blockType) { |
13418 function applyBlockDeprecatedVersions(block, rawBlock, blockType) { |
11359 const parsedAttributes = rawBlock.attrs; |
13419 const parsedAttributes = rawBlock.attrs; |
11360 const { |
13420 const { |
11361 deprecated: deprecatedDefinitions |
13421 deprecated: deprecatedDefinitions |
11362 } = blockType; // Bail early if there are no registered deprecations to be handled. |
13422 } = blockType; |
11363 |
13423 // Bail early if there are no registered deprecations to be handled. |
11364 if (!deprecatedDefinitions || !deprecatedDefinitions.length) { |
13424 if (!deprecatedDefinitions || !deprecatedDefinitions.length) { |
11365 return block; |
13425 return block; |
11366 } // By design, blocks lack any sort of version tracking. Instead, to process |
13426 } |
13427 |
|
13428 // By design, blocks lack any sort of version tracking. Instead, to process |
|
11367 // outdated content the system operates a queue out of all the defined |
13429 // outdated content the system operates a queue out of all the defined |
11368 // attribute shapes and tries each definition until the input produces a |
13430 // attribute shapes and tries each definition until the input produces a |
11369 // valid result. This mechanism seeks to avoid polluting the user-space with |
13431 // valid result. This mechanism seeks to avoid polluting the user-space with |
11370 // machine-specific code. An invalid block is thus a block that could not be |
13432 // machine-specific code. An invalid block is thus a block that could not be |
11371 // matched successfully with any of the registered deprecation definitions. |
13433 // matched successfully with any of the registered deprecation definitions. |
11372 |
|
11373 |
|
11374 for (let i = 0; i < deprecatedDefinitions.length; i++) { |
13434 for (let i = 0; i < deprecatedDefinitions.length; i++) { |
11375 // A block can opt into a migration even if the block is valid by |
13435 // A block can opt into a migration even if the block is valid by |
11376 // defining `isEligible` on its deprecation. If the block is both valid |
13436 // defining `isEligible` on its deprecation. If the block is both valid |
11377 // and does not opt to migrate, skip. |
13437 // and does not opt to migrate, skip. |
11378 const { |
13438 const { |
11379 isEligible = external_lodash_namespaceObject.stubFalse |
13439 isEligible = stubFalse |
11380 } = deprecatedDefinitions[i]; |
13440 } = deprecatedDefinitions[i]; |
11381 |
13441 if (block.isValid && !isEligible(parsedAttributes, block.innerBlocks, { |
11382 if (block.isValid && !isEligible(parsedAttributes, block.innerBlocks)) { |
13442 blockNode: rawBlock, |
13443 block |
|
13444 })) { |
|
11383 continue; |
13445 continue; |
11384 } // Block type properties which could impact either serialization or |
13446 } |
13447 |
|
13448 // Block type properties which could impact either serialization or |
|
11385 // parsing are not considered in the deprecated block type by default, |
13449 // parsing are not considered in the deprecated block type by default, |
11386 // and must be explicitly provided. |
13450 // and must be explicitly provided. |
11387 |
13451 const deprecatedBlockType = Object.assign(omit(blockType, DEPRECATED_ENTRY_KEYS), deprecatedDefinitions[i]); |
11388 |
13452 let migratedBlock = { |
11389 const deprecatedBlockType = Object.assign((0,external_lodash_namespaceObject.omit)(blockType, DEPRECATED_ENTRY_KEYS), deprecatedDefinitions[i]); |
13453 ...block, |
11390 let migratedBlock = { ...block, |
|
11391 attributes: getBlockAttributes(deprecatedBlockType, block.originalContent, parsedAttributes) |
13454 attributes: getBlockAttributes(deprecatedBlockType, block.originalContent, parsedAttributes) |
11392 }; // Ignore the deprecation if it produces a block which is not valid. |
13455 }; |
11393 |
13456 |
11394 let [isValid] = validateBlock(migratedBlock, deprecatedBlockType); // If the migrated block is not valid initially, try the built-in fixes. |
13457 // Ignore the deprecation if it produces a block which is not valid. |
11395 |
13458 let [isValid] = validateBlock(migratedBlock, deprecatedBlockType); |
13459 |
|
13460 // If the migrated block is not valid initially, try the built-in fixes. |
|
11396 if (!isValid) { |
13461 if (!isValid) { |
11397 migratedBlock = applyBuiltInValidationFixes(migratedBlock, deprecatedBlockType); |
13462 migratedBlock = applyBuiltInValidationFixes(migratedBlock, deprecatedBlockType); |
11398 [isValid] = validateBlock(migratedBlock, deprecatedBlockType); |
13463 [isValid] = validateBlock(migratedBlock, deprecatedBlockType); |
11399 } // An invalid block does not imply incorrect HTML but the fact block |
13464 } |
13465 |
|
13466 // An invalid block does not imply incorrect HTML but the fact block |
|
11400 // source information could be lost on re-serialization. |
13467 // source information could be lost on re-serialization. |
11401 |
|
11402 |
|
11403 if (!isValid) { |
13468 if (!isValid) { |
11404 continue; |
13469 continue; |
11405 } |
13470 } |
11406 |
|
11407 let migratedInnerBlocks = migratedBlock.innerBlocks; |
13471 let migratedInnerBlocks = migratedBlock.innerBlocks; |
11408 let migratedAttributes = migratedBlock.attributes; // A block may provide custom behavior to assign new attributes and/or |
13472 let migratedAttributes = migratedBlock.attributes; |
13473 |
|
13474 // A block may provide custom behavior to assign new attributes and/or |
|
11409 // inner blocks. |
13475 // inner blocks. |
11410 |
|
11411 const { |
13476 const { |
11412 migrate |
13477 migrate |
11413 } = deprecatedBlockType; |
13478 } = deprecatedBlockType; |
11414 |
|
11415 if (migrate) { |
13479 if (migrate) { |
11416 [migratedAttributes = parsedAttributes, migratedInnerBlocks = block.innerBlocks] = (0,external_lodash_namespaceObject.castArray)(migrate(migratedAttributes, block.innerBlocks)); |
13480 let migrated = migrate(migratedAttributes, block.innerBlocks); |
11417 } |
13481 if (!Array.isArray(migrated)) { |
11418 |
13482 migrated = [migrated]; |
11419 block = { ...block, |
13483 } |
13484 [migratedAttributes = parsedAttributes, migratedInnerBlocks = block.innerBlocks] = migrated; |
|
13485 } |
|
13486 block = { |
|
13487 ...block, |
|
11420 attributes: migratedAttributes, |
13488 attributes: migratedAttributes, |
11421 innerBlocks: migratedInnerBlocks, |
13489 innerBlocks: migratedInnerBlocks, |
11422 isValid: true, |
13490 isValid: true, |
11423 validationIssues: [] |
13491 validationIssues: [] |
11424 }; |
13492 }; |
11425 } |
13493 } |
11426 |
|
11427 return block; |
13494 return block; |
11428 } |
13495 } |
11429 |
13496 |
11430 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/index.js |
13497 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/index.js |
11431 /** |
13498 /** |
11432 * WordPress dependencies |
13499 * WordPress dependencies |
11433 */ |
13500 */ |
13501 |
|
11434 |
13502 |
11435 |
13503 |
11436 /** |
13504 /** |
11437 * Internal dependencies |
13505 * Internal dependencies |
11438 */ |
13506 */ |
11475 * @property {WPRawBlock} [__unstableBlockSource] Un-processed original copy of block if created through parser. |
13543 * @property {WPRawBlock} [__unstableBlockSource] Un-processed original copy of block if created through parser. |
11476 */ |
13544 */ |
11477 |
13545 |
11478 /** |
13546 /** |
11479 * @typedef {Object} ParseOptions |
13547 * @typedef {Object} ParseOptions |
11480 * @property {boolean} __unstableSkipMigrationLogs If a block is migrated from a deprecated version, skip logging the migration details. |
13548 * @property {boolean?} __unstableSkipMigrationLogs If a block is migrated from a deprecated version, skip logging the migration details. |
13549 * @property {boolean?} __unstableSkipAutop Whether to skip autop when processing freeform content. |
|
11481 */ |
13550 */ |
11482 |
13551 |
11483 /** |
13552 /** |
11484 * Convert legacy blocks to their canonical form. This function is used |
13553 * Convert legacy blocks to their canonical form. This function is used |
11485 * both in the parser level for previous content and to convert such blocks |
13554 * both in the parser level for previous content and to convert such blocks |
11487 * |
13556 * |
11488 * @param {WPRawBlock} rawBlock |
13557 * @param {WPRawBlock} rawBlock |
11489 * |
13558 * |
11490 * @return {WPRawBlock} The block's name and attributes, changed accordingly if a match was found |
13559 * @return {WPRawBlock} The block's name and attributes, changed accordingly if a match was found |
11491 */ |
13560 */ |
11492 |
|
11493 function convertLegacyBlocks(rawBlock) { |
13561 function convertLegacyBlocks(rawBlock) { |
11494 const [correctName, correctedAttributes] = convertLegacyBlockNameAndAttributes(rawBlock.blockName, rawBlock.attrs); |
13562 const [correctName, correctedAttributes] = convertLegacyBlockNameAndAttributes(rawBlock.blockName, rawBlock.attrs); |
11495 return { ...rawBlock, |
13563 return { |
13564 ...rawBlock, |
|
11496 blockName: correctName, |
13565 blockName: correctName, |
11497 attrs: correctedAttributes |
13566 attrs: correctedAttributes |
11498 }; |
13567 }; |
11499 } |
13568 } |
13569 |
|
11500 /** |
13570 /** |
11501 * Normalize the raw block by applying the fallback block name if none given, |
13571 * Normalize the raw block by applying the fallback block name if none given, |
11502 * sanitize the parsed HTML... |
13572 * sanitize the parsed HTML... |
11503 * |
13573 * |
11504 * @param {WPRawBlock} rawBlock The raw block object. |
13574 * @param {WPRawBlock} rawBlock The raw block object. |
13575 * @param {ParseOptions?} options Extra options for handling block parsing. |
|
11505 * |
13576 * |
11506 * @return {WPRawBlock} The normalized block object. |
13577 * @return {WPRawBlock} The normalized block object. |
11507 */ |
13578 */ |
11508 |
13579 function normalizeRawBlock(rawBlock, options) { |
11509 |
13580 const fallbackBlockName = getFreeformContentHandlerName(); |
11510 function normalizeRawBlock(rawBlock) { |
13581 |
11511 const fallbackBlockName = getFreeformContentHandlerName(); // If the grammar parsing don't produce any block name, use the freeform block. |
13582 // If the grammar parsing don't produce any block name, use the freeform block. |
11512 |
|
11513 const rawBlockName = rawBlock.blockName || getFreeformContentHandlerName(); |
13583 const rawBlockName = rawBlock.blockName || getFreeformContentHandlerName(); |
11514 const rawAttributes = rawBlock.attrs || {}; |
13584 const rawAttributes = rawBlock.attrs || {}; |
11515 const rawInnerBlocks = rawBlock.innerBlocks || []; |
13585 const rawInnerBlocks = rawBlock.innerBlocks || []; |
11516 let rawInnerHTML = rawBlock.innerHTML.trim(); // Fallback content may be upgraded from classic content expecting implicit |
13586 let rawInnerHTML = rawBlock.innerHTML.trim(); |
13587 |
|
13588 // Fallback content may be upgraded from classic content expecting implicit |
|
11517 // automatic paragraphs, so preserve them. Assumes wpautop is idempotent, |
13589 // automatic paragraphs, so preserve them. Assumes wpautop is idempotent, |
11518 // meaning there are no negative consequences to repeated autop calls. |
13590 // meaning there are no negative consequences to repeated autop calls. |
11519 |
13591 if (rawBlockName === fallbackBlockName && rawBlockName === 'core/freeform' && !options?.__unstableSkipAutop) { |
11520 if (rawBlockName === fallbackBlockName) { |
|
11521 rawInnerHTML = (0,external_wp_autop_namespaceObject.autop)(rawInnerHTML).trim(); |
13592 rawInnerHTML = (0,external_wp_autop_namespaceObject.autop)(rawInnerHTML).trim(); |
11522 } |
13593 } |
11523 |
13594 return { |
11524 return { ...rawBlock, |
13595 ...rawBlock, |
11525 blockName: rawBlockName, |
13596 blockName: rawBlockName, |
11526 attrs: rawAttributes, |
13597 attrs: rawAttributes, |
11527 innerHTML: rawInnerHTML, |
13598 innerHTML: rawInnerHTML, |
11528 innerBlocks: rawInnerBlocks |
13599 innerBlocks: rawInnerBlocks |
11529 }; |
13600 }; |
11530 } |
13601 } |
13602 |
|
11531 /** |
13603 /** |
11532 * Uses the "unregistered blockType" to create a block object. |
13604 * Uses the "unregistered blockType" to create a block object. |
11533 * |
13605 * |
11534 * @param {WPRawBlock} rawBlock block. |
13606 * @param {WPRawBlock} rawBlock block. |
11535 * |
13607 * |
11536 * @return {WPRawBlock} The unregistered block object. |
13608 * @return {WPRawBlock} The unregistered block object. |
11537 */ |
13609 */ |
11538 |
|
11539 function createMissingBlockType(rawBlock) { |
13610 function createMissingBlockType(rawBlock) { |
11540 const unregisteredFallbackBlock = getUnregisteredTypeHandlerName() || getFreeformContentHandlerName(); // Preserve undelimited content for use by the unregistered type |
13611 const unregisteredFallbackBlock = getUnregisteredTypeHandlerName() || getFreeformContentHandlerName(); |
13612 |
|
13613 // Preserve undelimited content for use by the unregistered type |
|
11541 // handler. A block node's `innerHTML` isn't enough, as that field only |
13614 // handler. A block node's `innerHTML` isn't enough, as that field only |
11542 // carries the block's own HTML and not its nested blocks. |
13615 // carries the block's own HTML and not its nested blocks. |
11543 |
|
11544 const originalUndelimitedContent = serializeRawBlock(rawBlock, { |
13616 const originalUndelimitedContent = serializeRawBlock(rawBlock, { |
11545 isCommentDelimited: false |
13617 isCommentDelimited: false |
11546 }); // Preserve full block content for use by the unregistered type |
13618 }); |
13619 |
|
13620 // Preserve full block content for use by the unregistered type |
|
11547 // handler, block boundaries included. |
13621 // handler, block boundaries included. |
11548 |
|
11549 const originalContent = serializeRawBlock(rawBlock, { |
13622 const originalContent = serializeRawBlock(rawBlock, { |
11550 isCommentDelimited: true |
13623 isCommentDelimited: true |
11551 }); |
13624 }); |
11552 return { |
13625 return { |
11553 blockName: unregisteredFallbackBlock, |
13626 blockName: unregisteredFallbackBlock, |
11559 innerHTML: rawBlock.blockName ? originalContent : rawBlock.innerHTML, |
13632 innerHTML: rawBlock.blockName ? originalContent : rawBlock.innerHTML, |
11560 innerBlocks: rawBlock.innerBlocks, |
13633 innerBlocks: rawBlock.innerBlocks, |
11561 innerContent: rawBlock.innerContent |
13634 innerContent: rawBlock.innerContent |
11562 }; |
13635 }; |
11563 } |
13636 } |
13637 |
|
11564 /** |
13638 /** |
11565 * Validates a block and wraps with validation meta. |
13639 * Validates a block and wraps with validation meta. |
11566 * |
13640 * |
11567 * The name here is regrettable but `validateBlock` is already taken. |
13641 * The name here is regrettable but `validateBlock` is already taken. |
11568 * |
13642 * |
11569 * @param {WPBlock} unvalidatedBlock |
13643 * @param {WPBlock} unvalidatedBlock |
11570 * @param {import('../registration').WPBlockType} blockType |
13644 * @param {import('../registration').WPBlockType} blockType |
11571 * @return {WPBlock} validated block, with auto-fixes if initially invalid |
13645 * @return {WPBlock} validated block, with auto-fixes if initially invalid |
11572 */ |
13646 */ |
11573 |
|
11574 |
|
11575 function applyBlockValidation(unvalidatedBlock, blockType) { |
13647 function applyBlockValidation(unvalidatedBlock, blockType) { |
11576 // Attempt to validate the block. |
13648 // Attempt to validate the block. |
11577 const [isValid] = validateBlock(unvalidatedBlock, blockType); |
13649 const [isValid] = validateBlock(unvalidatedBlock, blockType); |
11578 |
|
11579 if (isValid) { |
13650 if (isValid) { |
11580 return { ...unvalidatedBlock, |
13651 return { |
13652 ...unvalidatedBlock, |
|
11581 isValid, |
13653 isValid, |
11582 validationIssues: [] |
13654 validationIssues: [] |
11583 }; |
13655 }; |
11584 } // If the block is invalid, attempt some built-in fixes |
13656 } |
13657 |
|
13658 // If the block is invalid, attempt some built-in fixes |
|
11585 // like custom classNames handling. |
13659 // like custom classNames handling. |
11586 |
13660 const fixedBlock = applyBuiltInValidationFixes(unvalidatedBlock, blockType); |
11587 |
13661 // Attempt to validate the block once again after the built-in fixes. |
11588 const fixedBlock = applyBuiltInValidationFixes(unvalidatedBlock, blockType); // Attempt to validate the block once again after the built-in fixes. |
|
11589 |
|
11590 const [isFixedValid, validationIssues] = validateBlock(unvalidatedBlock, blockType); |
13662 const [isFixedValid, validationIssues] = validateBlock(unvalidatedBlock, blockType); |
11591 return { ...fixedBlock, |
13663 return { |
13664 ...fixedBlock, |
|
11592 isValid: isFixedValid, |
13665 isValid: isFixedValid, |
11593 validationIssues |
13666 validationIssues |
11594 }; |
13667 }; |
11595 } |
13668 } |
13669 |
|
11596 /** |
13670 /** |
11597 * Given a raw block returned by grammar parsing, returns a fully parsed block. |
13671 * Given a raw block returned by grammar parsing, returns a fully parsed block. |
11598 * |
13672 * |
11599 * @param {WPRawBlock} rawBlock The raw block object. |
13673 * @param {WPRawBlock} rawBlock The raw block object. |
11600 * @param {ParseOptions} options Extra options for handling block parsing. |
13674 * @param {ParseOptions} options Extra options for handling block parsing. |
11601 * |
13675 * |
11602 * @return {WPBlock} Fully parsed block. |
13676 * @return {WPBlock | undefined} Fully parsed block. |
11603 */ |
13677 */ |
11604 |
|
11605 |
|
11606 function parseRawBlock(rawBlock, options) { |
13678 function parseRawBlock(rawBlock, options) { |
11607 let normalizedBlock = normalizeRawBlock(rawBlock); // During the lifecycle of the project, we renamed some old blocks |
13679 let normalizedBlock = normalizeRawBlock(rawBlock, options); |
13680 |
|
13681 // During the lifecycle of the project, we renamed some old blocks |
|
11608 // and transformed others to new blocks. To avoid breaking existing content, |
13682 // and transformed others to new blocks. To avoid breaking existing content, |
11609 // we added this function to properly parse the old content. |
13683 // we added this function to properly parse the old content. |
11610 |
13684 normalizedBlock = convertLegacyBlocks(normalizedBlock); |
11611 normalizedBlock = convertLegacyBlocks(normalizedBlock); // Try finding the type for known block name. |
13685 |
11612 |
13686 // Try finding the type for known block name. |
11613 let blockType = registration_getBlockType(normalizedBlock.blockName); // If not blockType is found for the specified name, fallback to the "unregistedBlockType". |
13687 let blockType = getBlockType(normalizedBlock.blockName); |
11614 |
13688 |
13689 // If not blockType is found for the specified name, fallback to the "unregistedBlockType". |
|
11615 if (!blockType) { |
13690 if (!blockType) { |
11616 normalizedBlock = createMissingBlockType(normalizedBlock); |
13691 normalizedBlock = createMissingBlockType(normalizedBlock); |
11617 blockType = registration_getBlockType(normalizedBlock.blockName); |
13692 blockType = getBlockType(normalizedBlock.blockName); |
11618 } // If it's an empty freeform block or there's no blockType (no missing block handler) |
13693 } |
13694 |
|
13695 // If it's an empty freeform block or there's no blockType (no missing block handler) |
|
11619 // Then, just ignore the block. |
13696 // Then, just ignore the block. |
11620 // It might be a good idea to throw a warning here. |
13697 // It might be a good idea to throw a warning here. |
11621 // TODO: I'm unsure about the unregisteredFallbackBlock check, |
13698 // TODO: I'm unsure about the unregisteredFallbackBlock check, |
11622 // it might ignore some dynamic unregistered third party blocks wrongly. |
13699 // it might ignore some dynamic unregistered third party blocks wrongly. |
11623 |
|
11624 |
|
11625 const isFallbackBlock = normalizedBlock.blockName === getFreeformContentHandlerName() || normalizedBlock.blockName === getUnregisteredTypeHandlerName(); |
13700 const isFallbackBlock = normalizedBlock.blockName === getFreeformContentHandlerName() || normalizedBlock.blockName === getUnregisteredTypeHandlerName(); |
11626 |
|
11627 if (!blockType || !normalizedBlock.innerHTML && isFallbackBlock) { |
13701 if (!blockType || !normalizedBlock.innerHTML && isFallbackBlock) { |
11628 return; |
13702 return; |
11629 } // Parse inner blocks recursively. |
13703 } |
11630 |
13704 |
11631 |
13705 // Parse inner blocks recursively. |
11632 const parsedInnerBlocks = normalizedBlock.innerBlocks.map(innerBlock => parseRawBlock(innerBlock, options)) // See https://github.com/WordPress/gutenberg/pull/17164. |
13706 const parsedInnerBlocks = normalizedBlock.innerBlocks.map(innerBlock => parseRawBlock(innerBlock, options)) |
11633 .filter(innerBlock => !!innerBlock); // Get the fully parsed block. |
13707 // See https://github.com/WordPress/gutenberg/pull/17164. |
11634 |
13708 .filter(innerBlock => !!innerBlock); |
13709 |
|
13710 // Get the fully parsed block. |
|
11635 const parsedBlock = createBlock(normalizedBlock.blockName, getBlockAttributes(blockType, normalizedBlock.innerHTML, normalizedBlock.attrs), parsedInnerBlocks); |
13711 const parsedBlock = createBlock(normalizedBlock.blockName, getBlockAttributes(blockType, normalizedBlock.innerHTML, normalizedBlock.attrs), parsedInnerBlocks); |
11636 parsedBlock.originalContent = normalizedBlock.innerHTML; |
13712 parsedBlock.originalContent = normalizedBlock.innerHTML; |
11637 const validatedBlock = applyBlockValidation(parsedBlock, blockType); |
13713 const validatedBlock = applyBlockValidation(parsedBlock, blockType); |
11638 const { |
13714 const { |
11639 validationIssues |
13715 validationIssues |
11640 } = validatedBlock; // Run the block deprecation and migrations. |
13716 } = validatedBlock; |
13717 |
|
13718 // Run the block deprecation and migrations. |
|
11641 // This is performed on both invalid and valid blocks because |
13719 // This is performed on both invalid and valid blocks because |
11642 // migration using the `migrate` functions should run even |
13720 // migration using the `migrate` functions should run even |
11643 // if the output is deemed valid. |
13721 // if the output is deemed valid. |
11644 |
|
11645 const updatedBlock = applyBlockDeprecatedVersions(validatedBlock, normalizedBlock, blockType); |
13722 const updatedBlock = applyBlockDeprecatedVersions(validatedBlock, normalizedBlock, blockType); |
11646 |
|
11647 if (!updatedBlock.isValid) { |
13723 if (!updatedBlock.isValid) { |
11648 // Preserve the original unprocessed version of the block |
13724 // Preserve the original unprocessed version of the block |
11649 // that we received (no fixes, no deprecations) so that |
13725 // that we received (no fixes, no deprecations) so that |
11650 // we can save it as close to exactly the same way as |
13726 // we can save it as close to exactly the same way as |
11651 // we loaded it. This is important to avoid corruption |
13727 // we loaded it. This is important to avoid corruption |
11652 // and data loss caused by block implementations trying |
13728 // and data loss caused by block implementations trying |
11653 // to process data that isn't fully recognized. |
13729 // to process data that isn't fully recognized. |
11654 updatedBlock.__unstableBlockSource = rawBlock; |
13730 updatedBlock.__unstableBlockSource = rawBlock; |
11655 } |
13731 } |
11656 |
13732 if (!validatedBlock.isValid && updatedBlock.isValid && !options?.__unstableSkipMigrationLogs) { |
11657 if (!validatedBlock.isValid && updatedBlock.isValid && !(options !== null && options !== void 0 && options.__unstableSkipMigrationLogs)) { |
|
11658 /* eslint-disable no-console */ |
13733 /* eslint-disable no-console */ |
11659 console.groupCollapsed('Updated Block: %s', blockType.name); |
13734 console.groupCollapsed('Updated Block: %s', blockType.name); |
11660 console.info('Block successfully updated for `%s` (%o).\n\nNew content generated by `save` function:\n\n%s\n\nContent retrieved from post body:\n\n%s', blockType.name, blockType, getSaveContent(blockType, updatedBlock.attributes), updatedBlock.originalContent); |
13735 console.info('Block successfully updated for `%s` (%o).\n\nNew content generated by `save` function:\n\n%s\n\nContent retrieved from post body:\n\n%s', blockType.name, blockType, getSaveContent(blockType, updatedBlock.attributes), updatedBlock.originalContent); |
11661 console.groupEnd(); |
13736 console.groupEnd(); |
11662 /* eslint-enable no-console */ |
13737 /* eslint-enable no-console */ |
11663 } else if (!validatedBlock.isValid && !updatedBlock.isValid) { |
13738 } else if (!validatedBlock.isValid && !updatedBlock.isValid) { |
11664 validationIssues.forEach(_ref => { |
13739 validationIssues.forEach(({ |
11665 let { |
13740 log, |
11666 log, |
13741 args |
11667 args |
13742 }) => log(...args)); |
11668 } = _ref; |
13743 } |
11669 return log(...args); |
|
11670 }); |
|
11671 } |
|
11672 |
|
11673 return updatedBlock; |
13744 return updatedBlock; |
11674 } |
13745 } |
13746 |
|
11675 /** |
13747 /** |
11676 * Utilizes an optimized token-driven parser based on the Gutenberg grammar spec |
13748 * Utilizes an optimized token-driven parser based on the Gutenberg grammar spec |
11677 * defined through a parsing expression grammar to take advantage of the regular |
13749 * defined through a parsing expression grammar to take advantage of the regular |
11678 * cadence provided by block delimiters -- composed syntactically through HTML |
13750 * cadence provided by block delimiters -- composed syntactically through HTML |
11679 * comments -- which, given a general HTML document as an input, returns a block |
13751 * comments -- which, given a general HTML document as an input, returns a block |
11691 * @param {string} content The post content. |
13763 * @param {string} content The post content. |
11692 * @param {ParseOptions} options Extra options for handling block parsing. |
13764 * @param {ParseOptions} options Extra options for handling block parsing. |
11693 * |
13765 * |
11694 * @return {Array} Block list. |
13766 * @return {Array} Block list. |
11695 */ |
13767 */ |
11696 |
|
11697 function parser_parse(content, options) { |
13768 function parser_parse(content, options) { |
11698 return (0,external_wp_blockSerializationDefaultParser_namespaceObject.parse)(content).reduce((accumulator, rawBlock) => { |
13769 return (0,external_wp_blockSerializationDefaultParser_namespaceObject.parse)(content).reduce((accumulator, rawBlock) => { |
11699 const block = parseRawBlock(rawBlock, options); |
13770 const block = parseRawBlock(rawBlock, options); |
11700 |
|
11701 if (block) { |
13771 if (block) { |
11702 accumulator.push(block); |
13772 accumulator.push(block); |
11703 } |
13773 } |
11704 |
|
11705 return accumulator; |
13774 return accumulator; |
11706 }, []); |
13775 }, []); |
11707 } |
13776 } |
11708 |
13777 |
11709 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/get-raw-transforms.js |
13778 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/get-raw-transforms.js |
11710 /** |
13779 /** |
11711 * External dependencies |
|
11712 */ |
|
11713 |
|
11714 /** |
|
11715 * Internal dependencies |
13780 * Internal dependencies |
11716 */ |
13781 */ |
11717 |
13782 |
11718 |
|
11719 function getRawTransforms() { |
13783 function getRawTransforms() { |
11720 return (0,external_lodash_namespaceObject.filter)(getBlockTransforms('from'), { |
13784 return getBlockTransforms('from').filter(({ |
11721 type: 'raw' |
13785 type |
11722 }).map(transform => { |
13786 }) => type === 'raw').map(transform => { |
11723 return transform.isMatch ? transform : { ...transform, |
13787 return transform.isMatch ? transform : { |
13788 ...transform, |
|
11724 isMatch: node => transform.selector && node.matches(transform.selector) |
13789 isMatch: node => transform.selector && node.matches(transform.selector) |
11725 }; |
13790 }; |
11726 }); |
13791 }); |
11727 } |
13792 } |
11728 |
13793 |
11729 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/html-to-blocks.js |
13794 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/html-to-blocks.js |
11730 /** |
13795 /** |
13796 * WordPress dependencies |
|
13797 */ |
|
13798 |
|
13799 |
|
13800 /** |
|
11731 * Internal dependencies |
13801 * Internal dependencies |
11732 */ |
13802 */ |
13803 |
|
13804 |
|
11733 |
13805 |
11734 |
13806 |
11735 |
13807 |
11736 /** |
13808 /** |
11737 * Converts HTML directly to blocks. Looks for a matching transform for each |
13809 * Converts HTML directly to blocks. Looks for a matching transform for each |
11738 * top-level tag. The HTML should be filtered to not have any text between |
13810 * top-level tag. The HTML should be filtered to not have any text between |
11739 * top-level tags and formatted in a way that blocks can handle the HTML. |
13811 * top-level tags and formatted in a way that blocks can handle the HTML. |
11740 * |
13812 * |
11741 * @param {string} html HTML to convert. |
13813 * @param {string} html HTML to convert. |
13814 * @param {Function} handler The handler calling htmlToBlocks: either rawHandler |
|
13815 * or pasteHandler. |
|
11742 * |
13816 * |
11743 * @return {Array} An array of blocks. |
13817 * @return {Array} An array of blocks. |
11744 */ |
13818 */ |
11745 |
13819 function htmlToBlocks(html, handler) { |
11746 function htmlToBlocks(html) { |
|
11747 const doc = document.implementation.createHTMLDocument(''); |
13820 const doc = document.implementation.createHTMLDocument(''); |
11748 doc.body.innerHTML = html; |
13821 doc.body.innerHTML = html; |
11749 return Array.from(doc.body.children).flatMap(node => { |
13822 return Array.from(doc.body.children).flatMap(node => { |
11750 const rawTransform = findTransform(getRawTransforms(), _ref => { |
13823 const rawTransform = findTransform(getRawTransforms(), ({ |
11751 let { |
13824 isMatch |
11752 isMatch |
13825 }) => isMatch(node)); |
11753 } = _ref; |
|
11754 return isMatch(node); |
|
11755 }); |
|
11756 |
|
11757 if (!rawTransform) { |
13826 if (!rawTransform) { |
11758 return createBlock( // Should not be hardcoded. |
13827 // Until the HTML block is supported in the native version, we'll parse it |
13828 // instead of creating the block to generate it as an unsupported block. |
|
13829 if (external_wp_element_namespaceObject.Platform.isNative) { |
|
13830 return parser_parse(`<!-- wp:html -->${node.outerHTML}<!-- /wp:html -->`); |
|
13831 } |
|
13832 return createBlock( |
|
13833 // Should not be hardcoded. |
|
11759 'core/html', getBlockAttributes('core/html', node.outerHTML)); |
13834 'core/html', getBlockAttributes('core/html', node.outerHTML)); |
11760 } |
13835 } |
11761 |
|
11762 const { |
13836 const { |
11763 transform, |
13837 transform, |
11764 blockName |
13838 blockName |
11765 } = rawTransform; |
13839 } = rawTransform; |
11766 |
|
11767 if (transform) { |
13840 if (transform) { |
11768 return transform(node); |
13841 const block = transform(node, handler); |
11769 } |
13842 if (node.hasAttribute('class')) { |
11770 |
13843 block.attributes.className = node.getAttribute('class'); |
13844 } |
|
13845 return block; |
|
13846 } |
|
11771 return createBlock(blockName, getBlockAttributes(blockName, node.outerHTML)); |
13847 return createBlock(blockName, getBlockAttributes(blockName, node.outerHTML)); |
11772 }); |
13848 }); |
11773 } |
13849 } |
11774 |
13850 |
11775 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/normalise-blocks.js |
13851 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/normalise-blocks.js |
11776 /** |
13852 /** |
11777 * WordPress dependencies |
13853 * WordPress dependencies |
11778 */ |
13854 */ |
11779 |
13855 |
11780 function normaliseBlocks(HTML) { |
13856 function normaliseBlocks(HTML, options = {}) { |
11781 const decuDoc = document.implementation.createHTMLDocument(''); |
13857 const decuDoc = document.implementation.createHTMLDocument(''); |
11782 const accuDoc = document.implementation.createHTMLDocument(''); |
13858 const accuDoc = document.implementation.createHTMLDocument(''); |
11783 const decu = decuDoc.body; |
13859 const decu = decuDoc.body; |
11784 const accu = accuDoc.body; |
13860 const accu = accuDoc.body; |
11785 decu.innerHTML = HTML; |
13861 decu.innerHTML = HTML; |
11786 |
|
11787 while (decu.firstChild) { |
13862 while (decu.firstChild) { |
11788 const node = decu.firstChild; // Text nodes: wrap in a paragraph, or append to previous. |
13863 const node = decu.firstChild; |
11789 |
13864 |
13865 // Text nodes: wrap in a paragraph, or append to previous. |
|
11790 if (node.nodeType === node.TEXT_NODE) { |
13866 if (node.nodeType === node.TEXT_NODE) { |
11791 if ((0,external_wp_dom_namespaceObject.isEmpty)(node)) { |
13867 if ((0,external_wp_dom_namespaceObject.isEmpty)(node)) { |
11792 decu.removeChild(node); |
13868 decu.removeChild(node); |
11793 } else { |
13869 } else { |
11794 if (!accu.lastChild || accu.lastChild.nodeName !== 'P') { |
13870 if (!accu.lastChild || accu.lastChild.nodeName !== 'P') { |
11795 accu.appendChild(accuDoc.createElement('P')); |
13871 accu.appendChild(accuDoc.createElement('P')); |
11796 } |
13872 } |
11797 |
|
11798 accu.lastChild.appendChild(node); |
13873 accu.lastChild.appendChild(node); |
11799 } // Element nodes. |
13874 } |
11800 |
13875 // Element nodes. |
11801 } else if (node.nodeType === node.ELEMENT_NODE) { |
13876 } else if (node.nodeType === node.ELEMENT_NODE) { |
11802 // BR nodes: create a new paragraph on double, or append to previous. |
13877 // BR nodes: create a new paragraph on double, or append to previous. |
11803 if (node.nodeName === 'BR') { |
13878 if (node.nodeName === 'BR') { |
11804 if (node.nextSibling && node.nextSibling.nodeName === 'BR') { |
13879 if (node.nextSibling && node.nextSibling.nodeName === 'BR') { |
11805 accu.appendChild(accuDoc.createElement('P')); |
13880 accu.appendChild(accuDoc.createElement('P')); |
11806 decu.removeChild(node.nextSibling); |
13881 decu.removeChild(node.nextSibling); |
11807 } // Don't append to an empty paragraph. |
13882 } |
11808 |
13883 |
11809 |
13884 // Don't append to an empty paragraph. |
11810 if (accu.lastChild && accu.lastChild.nodeName === 'P' && accu.lastChild.hasChildNodes()) { |
13885 if (accu.lastChild && accu.lastChild.nodeName === 'P' && accu.lastChild.hasChildNodes()) { |
11811 accu.lastChild.appendChild(node); |
13886 accu.lastChild.appendChild(node); |
11812 } else { |
13887 } else { |
11813 decu.removeChild(node); |
13888 decu.removeChild(node); |
11814 } |
13889 } |
11815 } else if (node.nodeName === 'P') { |
13890 } else if (node.nodeName === 'P') { |
11816 // Only append non-empty paragraph nodes. |
13891 // Only append non-empty paragraph nodes. |
11817 if ((0,external_wp_dom_namespaceObject.isEmpty)(node)) { |
13892 if ((0,external_wp_dom_namespaceObject.isEmpty)(node) && !options.raw) { |
11818 decu.removeChild(node); |
13893 decu.removeChild(node); |
11819 } else { |
13894 } else { |
11820 accu.appendChild(node); |
13895 accu.appendChild(node); |
11821 } |
13896 } |
11822 } else if ((0,external_wp_dom_namespaceObject.isPhrasingContent)(node)) { |
13897 } else if ((0,external_wp_dom_namespaceObject.isPhrasingContent)(node)) { |
11823 if (!accu.lastChild || accu.lastChild.nodeName !== 'P') { |
13898 if (!accu.lastChild || accu.lastChild.nodeName !== 'P') { |
11824 accu.appendChild(accuDoc.createElement('P')); |
13899 accu.appendChild(accuDoc.createElement('P')); |
11825 } |
13900 } |
11826 |
|
11827 accu.lastChild.appendChild(node); |
13901 accu.lastChild.appendChild(node); |
11828 } else { |
13902 } else { |
11829 accu.appendChild(node); |
13903 accu.appendChild(node); |
11830 } |
13904 } |
11831 } else { |
13905 } else { |
11832 decu.removeChild(node); |
13906 decu.removeChild(node); |
11833 } |
13907 } |
11834 } |
13908 } |
11835 |
|
11836 return accu.innerHTML; |
13909 return accu.innerHTML; |
11837 } |
13910 } |
11838 |
13911 |
11839 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/special-comment-converter.js |
13912 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/special-comment-converter.js |
11840 /** |
13913 /** |
11841 * WordPress dependencies |
13914 * WordPress dependencies |
11842 */ |
13915 */ |
11843 |
13916 |
11844 /** |
13917 |
11845 * Looks for `<!--nextpage-->` and `<!--more-->` comments, as well as the |
13918 /** |
11846 * `<!--more Some text-->` variant and its `<!--noteaser-->` companion, |
13919 * Looks for `<!--nextpage-->` and `<!--more-->` comments and |
11847 * and replaces them with a custom element representing a future block. |
13920 * replaces them with a custom element representing a future block. |
11848 * |
13921 * |
11849 * The custom element is a way to bypass the rest of the `raw-handling` |
13922 * The custom element is a way to bypass the rest of the `raw-handling` |
11850 * transforms, which would eliminate other kinds of node with which to carry |
13923 * transforms, which would eliminate other kinds of node with which to carry |
11851 * `<!--more-->`'s data: nodes with `data` attributes, empty paragraphs, etc. |
13924 * `<!--more-->`'s data: nodes with `data` attributes, empty paragraphs, etc. |
11852 * |
13925 * |
11855 * |
13928 * |
11856 * @param {Node} node The node to be processed. |
13929 * @param {Node} node The node to be processed. |
11857 * @param {Document} doc The document of the node. |
13930 * @param {Document} doc The document of the node. |
11858 * @return {void} |
13931 * @return {void} |
11859 */ |
13932 */ |
11860 |
|
11861 function specialCommentConverter(node, doc) { |
13933 function specialCommentConverter(node, doc) { |
11862 if (node.nodeType !== node.COMMENT_NODE) { |
13934 if (node.nodeType !== node.COMMENT_NODE) { |
11863 return; |
13935 return; |
11864 } |
13936 } |
11865 |
13937 if (node.nodeValue !== 'nextpage' && node.nodeValue.indexOf('more') !== 0) { |
11866 if (node.nodeValue === 'nextpage') { |
|
11867 (0,external_wp_dom_namespaceObject.replace)(node, createNextpage(doc)); |
|
11868 return; |
13938 return; |
11869 } |
13939 } |
11870 |
13940 const block = special_comment_converter_createBlock(node, doc); |
11871 if (node.nodeValue.indexOf('more') === 0) { |
13941 |
11872 // Grab any custom text in the comment. |
13942 // If our `<!--more-->` comment is in the middle of a paragraph, we should |
11873 const customText = node.nodeValue.slice(4).trim(); |
13943 // split the paragraph in two and insert the more block in between. If it's |
11874 /* |
13944 // inside an empty paragraph, we should still move it out of the paragraph |
11875 * When a `<!--more-->` comment is found, we need to look for any |
13945 // and remove the paragraph. If there's no paragraph, fall back to simply |
11876 * `<!--noteaser-->` sibling, but it may not be a direct sibling |
13946 // replacing the comment. |
11877 * (whitespace typically lies in between) |
13947 if (!node.parentNode || node.parentNode.nodeName !== 'P') { |
11878 */ |
13948 (0,external_wp_dom_namespaceObject.replace)(node, block); |
11879 |
13949 } else { |
11880 let sibling = node; |
13950 const childNodes = Array.from(node.parentNode.childNodes); |
11881 let noTeaser = false; |
13951 const nodeIndex = childNodes.indexOf(node); |
11882 |
13952 const wrapperNode = node.parentNode.parentNode || doc.body; |
11883 while (sibling = sibling.nextSibling) { |
13953 const paragraphBuilder = (acc, child) => { |
11884 if (sibling.nodeType === sibling.COMMENT_NODE && sibling.nodeValue === 'noteaser') { |
13954 if (!acc) { |
11885 noTeaser = true; |
13955 acc = doc.createElement('p'); |
11886 (0,external_wp_dom_namespaceObject.remove)(sibling); |
|
11887 break; |
|
11888 } |
13956 } |
11889 } |
13957 acc.appendChild(child); |
11890 |
13958 return acc; |
11891 (0,external_wp_dom_namespaceObject.replace)(node, createMore(customText, noTeaser, doc)); |
13959 }; |
11892 } |
13960 |
11893 } |
13961 // Split the original parent node and insert our more block |
11894 |
13962 [childNodes.slice(0, nodeIndex).reduce(paragraphBuilder, null), block, childNodes.slice(nodeIndex + 1).reduce(paragraphBuilder, null)].forEach(element => element && wrapperNode.insertBefore(element, node.parentNode)); |
13963 |
|
13964 // Remove the old parent paragraph |
|
13965 (0,external_wp_dom_namespaceObject.remove)(node.parentNode); |
|
13966 } |
|
13967 } |
|
13968 function special_comment_converter_createBlock(commentNode, doc) { |
|
13969 if (commentNode.nodeValue === 'nextpage') { |
|
13970 return createNextpage(doc); |
|
13971 } |
|
13972 |
|
13973 // Grab any custom text in the comment. |
|
13974 const customText = commentNode.nodeValue.slice(4).trim(); |
|
13975 |
|
13976 /* |
|
13977 * When a `<!--more-->` comment is found, we need to look for any |
|
13978 * `<!--noteaser-->` sibling, but it may not be a direct sibling |
|
13979 * (whitespace typically lies in between) |
|
13980 */ |
|
13981 let sibling = commentNode; |
|
13982 let noTeaser = false; |
|
13983 while (sibling = sibling.nextSibling) { |
|
13984 if (sibling.nodeType === sibling.COMMENT_NODE && sibling.nodeValue === 'noteaser') { |
|
13985 noTeaser = true; |
|
13986 (0,external_wp_dom_namespaceObject.remove)(sibling); |
|
13987 break; |
|
13988 } |
|
13989 } |
|
13990 return createMore(customText, noTeaser, doc); |
|
13991 } |
|
11895 function createMore(customText, noTeaser, doc) { |
13992 function createMore(customText, noTeaser, doc) { |
11896 const node = doc.createElement('wp-block'); |
13993 const node = doc.createElement('wp-block'); |
11897 node.dataset.block = 'core/more'; |
13994 node.dataset.block = 'core/more'; |
11898 |
|
11899 if (customText) { |
13995 if (customText) { |
11900 node.dataset.customText = customText; |
13996 node.dataset.customText = customText; |
11901 } |
13997 } |
11902 |
|
11903 if (noTeaser) { |
13998 if (noTeaser) { |
11904 // "Boolean" data attribute. |
13999 // "Boolean" data attribute. |
11905 node.dataset.noTeaser = ''; |
14000 node.dataset.noTeaser = ''; |
11906 } |
14001 } |
11907 |
|
11908 return node; |
14002 return node; |
11909 } |
14003 } |
11910 |
|
11911 function createNextpage(doc) { |
14004 function createNextpage(doc) { |
11912 const node = doc.createElement('wp-block'); |
14005 const node = doc.createElement('wp-block'); |
11913 node.dataset.block = 'core/nextpage'; |
14006 node.dataset.block = 'core/nextpage'; |
11914 return node; |
14007 return node; |
11915 } |
14008 } |
11917 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/list-reducer.js |
14010 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/list-reducer.js |
11918 /** |
14011 /** |
11919 * WordPress dependencies |
14012 * WordPress dependencies |
11920 */ |
14013 */ |
11921 |
14014 |
11922 |
|
11923 function isList(node) { |
14015 function isList(node) { |
11924 return node.nodeName === 'OL' || node.nodeName === 'UL'; |
14016 return node.nodeName === 'OL' || node.nodeName === 'UL'; |
11925 } |
14017 } |
11926 |
|
11927 function shallowTextContent(element) { |
14018 function shallowTextContent(element) { |
11928 return Array.from(element.childNodes).map(_ref => { |
14019 return Array.from(element.childNodes).map(({ |
11929 let { |
14020 nodeValue = '' |
11930 nodeValue = '' |
14021 }) => nodeValue).join(''); |
11931 } = _ref; |
14022 } |
11932 return nodeValue; |
|
11933 }).join(''); |
|
11934 } |
|
11935 |
|
11936 function listReducer(node) { |
14023 function listReducer(node) { |
11937 if (!isList(node)) { |
14024 if (!isList(node)) { |
11938 return; |
14025 return; |
11939 } |
14026 } |
11940 |
|
11941 const list = node; |
14027 const list = node; |
11942 const prevElement = node.previousElementSibling; // Merge with previous list if: |
14028 const prevElement = node.previousElementSibling; |
14029 |
|
14030 // Merge with previous list if: |
|
11943 // * There is a previous list of the same type. |
14031 // * There is a previous list of the same type. |
11944 // * There is only one list item. |
14032 // * There is only one list item. |
11945 |
|
11946 if (prevElement && prevElement.nodeName === node.nodeName && list.children.length === 1) { |
14033 if (prevElement && prevElement.nodeName === node.nodeName && list.children.length === 1) { |
11947 // Move all child nodes, including any text nodes, if any. |
14034 // Move all child nodes, including any text nodes, if any. |
11948 while (list.firstChild) { |
14035 while (list.firstChild) { |
11949 prevElement.appendChild(list.firstChild); |
14036 prevElement.appendChild(list.firstChild); |
11950 } |
14037 } |
11951 |
|
11952 list.parentNode.removeChild(list); |
14038 list.parentNode.removeChild(list); |
11953 } |
14039 } |
11954 |
14040 const parentElement = node.parentNode; |
11955 const parentElement = node.parentNode; // Nested list with empty parent item. |
14041 |
11956 |
14042 // Nested list with empty parent item. |
11957 if (parentElement && parentElement.nodeName === 'LI' && parentElement.children.length === 1 && !/\S/.test(shallowTextContent(parentElement))) { |
14043 if (parentElement && parentElement.nodeName === 'LI' && parentElement.children.length === 1 && !/\S/.test(shallowTextContent(parentElement))) { |
11958 const parentListItem = parentElement; |
14044 const parentListItem = parentElement; |
11959 const prevListItem = parentListItem.previousElementSibling; |
14045 const prevListItem = parentListItem.previousElementSibling; |
11960 const parentList = parentListItem.parentNode; |
14046 const parentList = parentListItem.parentNode; |
11961 |
|
11962 if (prevListItem) { |
14047 if (prevListItem) { |
11963 prevListItem.appendChild(list); |
14048 prevListItem.appendChild(list); |
11964 parentList.removeChild(parentListItem); |
14049 parentList.removeChild(parentListItem); |
11965 } else { |
14050 } |
11966 parentList.parentNode.insertBefore(list, parentList); |
14051 } |
11967 parentList.parentNode.removeChild(parentList); |
14052 |
11968 } |
14053 // Invalid: OL/UL > OL/UL. |
11969 } // Invalid: OL/UL > OL/UL. |
|
11970 |
|
11971 |
|
11972 if (parentElement && isList(parentElement)) { |
14054 if (parentElement && isList(parentElement)) { |
11973 const prevListItem = node.previousElementSibling; |
14055 const prevListItem = node.previousElementSibling; |
11974 |
|
11975 if (prevListItem) { |
14056 if (prevListItem) { |
11976 prevListItem.appendChild(node); |
14057 prevListItem.appendChild(node); |
11977 } else { |
14058 } else { |
11978 (0,external_wp_dom_namespaceObject.unwrap)(node); |
14059 (0,external_wp_dom_namespaceObject.unwrap)(node); |
11979 } |
14060 } |
11983 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/blockquote-normaliser.js |
14064 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/blockquote-normaliser.js |
11984 /** |
14065 /** |
11985 * Internal dependencies |
14066 * Internal dependencies |
11986 */ |
14067 */ |
11987 |
14068 |
11988 function blockquoteNormaliser(node) { |
14069 function blockquoteNormaliser(options) { |
11989 if (node.nodeName !== 'BLOCKQUOTE') { |
14070 return node => { |
11990 return; |
14071 if (node.nodeName !== 'BLOCKQUOTE') { |
11991 } |
14072 return; |
11992 |
14073 } |
11993 node.innerHTML = normaliseBlocks(node.innerHTML); |
14074 node.innerHTML = normaliseBlocks(node.innerHTML, options); |
14075 }; |
|
11994 } |
14076 } |
11995 |
14077 |
11996 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/figure-content-reducer.js |
14078 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/figure-content-reducer.js |
11997 /** |
|
11998 * External dependencies |
|
11999 */ |
|
12000 |
|
12001 /** |
14079 /** |
12002 * WordPress dependencies |
14080 * WordPress dependencies |
12003 */ |
14081 */ |
12004 |
14082 |
12005 |
14083 |
12009 * @param {Node} node The node to check. |
14087 * @param {Node} node The node to check. |
12010 * @param {Object} schema The schema to use. |
14088 * @param {Object} schema The schema to use. |
12011 * |
14089 * |
12012 * @return {boolean} True if figure content, false if not. |
14090 * @return {boolean} True if figure content, false if not. |
12013 */ |
14091 */ |
12014 |
|
12015 function isFigureContent(node, schema) { |
14092 function isFigureContent(node, schema) { |
12016 const tag = node.nodeName.toLowerCase(); // We are looking for tags that can be a child of the figure tag, excluding |
14093 var _schema$figure$childr; |
14094 const tag = node.nodeName.toLowerCase(); |
|
14095 |
|
14096 // We are looking for tags that can be a child of the figure tag, excluding |
|
12017 // `figcaption` and any phrasing content. |
14097 // `figcaption` and any phrasing content. |
12018 |
|
12019 if (tag === 'figcaption' || (0,external_wp_dom_namespaceObject.isTextContent)(node)) { |
14098 if (tag === 'figcaption' || (0,external_wp_dom_namespaceObject.isTextContent)(node)) { |
12020 return false; |
14099 return false; |
12021 } |
14100 } |
12022 |
14101 return tag in ((_schema$figure$childr = schema?.figure?.children) !== null && _schema$figure$childr !== void 0 ? _schema$figure$childr : {}); |
12023 return (0,external_lodash_namespaceObject.has)(schema, ['figure', 'children', tag]); |
14102 } |
12024 } |
14103 |
12025 /** |
14104 /** |
12026 * Whether or not the given node can have an anchor. |
14105 * Whether or not the given node can have an anchor. |
12027 * |
14106 * |
12028 * @param {Node} node The node to check. |
14107 * @param {Node} node The node to check. |
12029 * @param {Object} schema The schema to use. |
14108 * @param {Object} schema The schema to use. |
12030 * |
14109 * |
12031 * @return {boolean} True if it can, false if not. |
14110 * @return {boolean} True if it can, false if not. |
12032 */ |
14111 */ |
12033 |
|
12034 |
|
12035 function canHaveAnchor(node, schema) { |
14112 function canHaveAnchor(node, schema) { |
14113 var _schema$figure$childr2; |
|
12036 const tag = node.nodeName.toLowerCase(); |
14114 const tag = node.nodeName.toLowerCase(); |
12037 return (0,external_lodash_namespaceObject.has)(schema, ['figure', 'children', 'a', 'children', tag]); |
14115 return tag in ((_schema$figure$childr2 = schema?.figure?.children?.a?.children) !== null && _schema$figure$childr2 !== void 0 ? _schema$figure$childr2 : {}); |
12038 } |
14116 } |
14117 |
|
12039 /** |
14118 /** |
12040 * Wraps the given element in a figure element. |
14119 * Wraps the given element in a figure element. |
12041 * |
14120 * |
12042 * @param {Element} element The element to wrap. |
14121 * @param {Element} element The element to wrap. |
12043 * @param {Element} beforeElement The element before which to place the figure. |
14122 * @param {Element} beforeElement The element before which to place the figure. |
12044 */ |
14123 */ |
12045 |
14124 function wrapFigureContent(element, beforeElement = element) { |
12046 |
|
12047 function wrapFigureContent(element) { |
|
12048 let beforeElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : element; |
|
12049 const figure = element.ownerDocument.createElement('figure'); |
14125 const figure = element.ownerDocument.createElement('figure'); |
12050 beforeElement.parentNode.insertBefore(figure, beforeElement); |
14126 beforeElement.parentNode.insertBefore(figure, beforeElement); |
12051 figure.appendChild(element); |
14127 figure.appendChild(element); |
12052 } |
14128 } |
14129 |
|
12053 /** |
14130 /** |
12054 * This filter takes figure content out of paragraphs, wraps it in a figure |
14131 * This filter takes figure content out of paragraphs, wraps it in a figure |
12055 * element, and moves any anchors with it if needed. |
14132 * element, and moves any anchors with it if needed. |
12056 * |
14133 * |
12057 * @param {Node} node The node to filter. |
14134 * @param {Node} node The node to filter. |
12058 * @param {Document} doc The document of the node. |
14135 * @param {Document} doc The document of the node. |
12059 * @param {Object} schema The schema to use. |
14136 * @param {Object} schema The schema to use. |
12060 * |
14137 * |
12061 * @return {void} |
14138 * @return {void} |
12062 */ |
14139 */ |
12063 |
|
12064 |
|
12065 function figureContentReducer(node, doc, schema) { |
14140 function figureContentReducer(node, doc, schema) { |
12066 if (!isFigureContent(node, schema)) { |
14141 if (!isFigureContent(node, schema)) { |
12067 return; |
14142 return; |
12068 } |
14143 } |
12069 |
|
12070 let nodeToInsert = node; |
14144 let nodeToInsert = node; |
12071 const parentNode = node.parentNode; // If the figure content can have an anchor and its parent is an anchor with |
14145 const parentNode = node.parentNode; |
14146 |
|
14147 // If the figure content can have an anchor and its parent is an anchor with |
|
12072 // only the figure content, take the anchor out instead of just the content. |
14148 // only the figure content, take the anchor out instead of just the content. |
12073 |
|
12074 if (canHaveAnchor(node, schema) && parentNode.nodeName === 'A' && parentNode.childNodes.length === 1) { |
14149 if (canHaveAnchor(node, schema) && parentNode.nodeName === 'A' && parentNode.childNodes.length === 1) { |
12075 nodeToInsert = node.parentNode; |
14150 nodeToInsert = node.parentNode; |
12076 } |
14151 } |
12077 |
14152 const wrapper = nodeToInsert.closest('p,div'); |
12078 const wrapper = nodeToInsert.closest('p,div'); // If wrapped in a paragraph or div, only extract if it's aligned or if |
14153 |
14154 // If wrapped in a paragraph or div, only extract if it's aligned or if |
|
12079 // there is no text content. |
14155 // there is no text content. |
12080 // Otherwise, if directly at the root, wrap in a figure element. |
14156 // Otherwise, if directly at the root, wrap in a figure element. |
12081 |
|
12082 if (wrapper) { |
14157 if (wrapper) { |
12083 // In jsdom-jscore, 'node.classList' can be undefined. |
14158 // In jsdom-jscore, 'node.classList' can be undefined. |
12084 // In this case, default to extract as it offers a better UI experience on mobile. |
14159 // In this case, default to extract as it offers a better UI experience on mobile. |
12085 if (!node.classList) { |
14160 if (!node.classList) { |
12086 wrapFigureContent(nodeToInsert, wrapper); |
14161 wrapFigureContent(nodeToInsert, wrapper); |
12091 wrapFigureContent(nodeToInsert); |
14166 wrapFigureContent(nodeToInsert); |
12092 } |
14167 } |
12093 } |
14168 } |
12094 |
14169 |
12095 ;// CONCATENATED MODULE: external ["wp","shortcode"] |
14170 ;// CONCATENATED MODULE: external ["wp","shortcode"] |
12096 var external_wp_shortcode_namespaceObject = window["wp"]["shortcode"]; |
14171 const external_wp_shortcode_namespaceObject = window["wp"]["shortcode"]; |
12097 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/shortcode-converter.js |
14172 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/shortcode-converter.js |
12098 /** |
14173 /** |
12099 * External dependencies |
|
12100 */ |
|
12101 |
|
12102 /** |
|
12103 * WordPress dependencies |
14174 * WordPress dependencies |
12104 */ |
14175 */ |
12105 |
14176 |
12106 |
14177 |
12107 /** |
14178 /** |
12109 */ |
14180 */ |
12110 |
14181 |
12111 |
14182 |
12112 |
14183 |
12113 |
14184 |
12114 |
14185 const castArray = maybeArray => Array.isArray(maybeArray) ? maybeArray : [maybeArray]; |
12115 |
14186 const beforeLineRegexp = /(\n|<p>)\s*$/; |
12116 function segmentHTMLToShortcodeBlock(HTML) { |
14187 const afterLineRegexp = /^\s*(\n|<\/p>)/; |
12117 let lastIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; |
14188 function segmentHTMLToShortcodeBlock(HTML, lastIndex = 0, excludedBlockNames = []) { |
12118 let excludedBlockNames = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; |
|
12119 // Get all matches. |
14189 // Get all matches. |
12120 const transformsFrom = getBlockTransforms('from'); |
14190 const transformsFrom = getBlockTransforms('from'); |
12121 const transformation = findTransform(transformsFrom, transform => excludedBlockNames.indexOf(transform.blockName) === -1 && transform.type === 'shortcode' && (0,external_lodash_namespaceObject.some)((0,external_lodash_namespaceObject.castArray)(transform.tag), tag => (0,external_wp_shortcode_namespaceObject.regexp)(tag).test(HTML))); |
14191 const transformation = findTransform(transformsFrom, transform => excludedBlockNames.indexOf(transform.blockName) === -1 && transform.type === 'shortcode' && castArray(transform.tag).some(tag => (0,external_wp_shortcode_namespaceObject.regexp)(tag).test(HTML))); |
12122 |
|
12123 if (!transformation) { |
14192 if (!transformation) { |
12124 return [HTML]; |
14193 return [HTML]; |
12125 } |
14194 } |
12126 |
14195 const transformTags = castArray(transformation.tag); |
12127 const transformTags = (0,external_lodash_namespaceObject.castArray)(transformation.tag); |
14196 const transformTag = transformTags.find(tag => (0,external_wp_shortcode_namespaceObject.regexp)(tag).test(HTML)); |
12128 const transformTag = (0,external_lodash_namespaceObject.find)(transformTags, tag => (0,external_wp_shortcode_namespaceObject.regexp)(tag).test(HTML)); |
|
12129 let match; |
14197 let match; |
12130 const previousIndex = lastIndex; |
14198 const previousIndex = lastIndex; |
12131 |
|
12132 if (match = (0,external_wp_shortcode_namespaceObject.next)(transformTag, HTML, lastIndex)) { |
14199 if (match = (0,external_wp_shortcode_namespaceObject.next)(transformTag, HTML, lastIndex)) { |
12133 lastIndex = match.index + match.content.length; |
14200 lastIndex = match.index + match.content.length; |
12134 const beforeHTML = HTML.substr(0, match.index); |
14201 const beforeHTML = HTML.substr(0, match.index); |
12135 const afterHTML = HTML.substr(lastIndex); // If the shortcode content does not contain HTML and the shortcode is |
14202 const afterHTML = HTML.substr(lastIndex); |
14203 |
|
14204 // If the shortcode content does not contain HTML and the shortcode is |
|
12136 // not on a new line (or in paragraph from Markdown converter), |
14205 // not on a new line (or in paragraph from Markdown converter), |
12137 // consider the shortcode as inline text, and thus skip conversion for |
14206 // consider the shortcode as inline text, and thus skip conversion for |
12138 // this segment. |
14207 // this segment. |
12139 |
14208 if (!match.shortcode.content?.includes('<') && !(beforeLineRegexp.test(beforeHTML) && afterLineRegexp.test(afterHTML))) { |
12140 if (!(0,external_lodash_namespaceObject.includes)(match.shortcode.content || '', '<') && !(/(\n|<p>)\s*$/.test(beforeHTML) && /^\s*(\n|<\/p>)/.test(afterHTML))) { |
|
12141 return segmentHTMLToShortcodeBlock(HTML, lastIndex); |
14209 return segmentHTMLToShortcodeBlock(HTML, lastIndex); |
12142 } // If a transformation's `isMatch` predicate fails for the inbound |
14210 } |
14211 |
|
14212 // If a transformation's `isMatch` predicate fails for the inbound |
|
12143 // shortcode, try again by excluding the current block type. |
14213 // shortcode, try again by excluding the current block type. |
12144 // |
14214 // |
12145 // This is the only call to `segmentHTMLToShortcodeBlock` that should |
14215 // This is the only call to `segmentHTMLToShortcodeBlock` that should |
12146 // ever carry over `excludedBlockNames`. Other calls in the module |
14216 // ever carry over `excludedBlockNames`. Other calls in the module |
12147 // should skip that argument as a way to reset the exclusion state, so |
14217 // should skip that argument as a way to reset the exclusion state, so |
12148 // that one `isMatch` fail in an HTML fragment doesn't prevent any |
14218 // that one `isMatch` fail in an HTML fragment doesn't prevent any |
12149 // valid matches in subsequent fragments. |
14219 // valid matches in subsequent fragments. |
12150 |
|
12151 |
|
12152 if (transformation.isMatch && !transformation.isMatch(match.shortcode.attrs)) { |
14220 if (transformation.isMatch && !transformation.isMatch(match.shortcode.attrs)) { |
12153 return segmentHTMLToShortcodeBlock(HTML, previousIndex, [...excludedBlockNames, transformation.blockName]); |
14221 return segmentHTMLToShortcodeBlock(HTML, previousIndex, [...excludedBlockNames, transformation.blockName]); |
12154 } |
14222 } |
12155 |
14223 let blocks = []; |
12156 const attributes = (0,external_lodash_namespaceObject.mapValues)((0,external_lodash_namespaceObject.pickBy)(transformation.attributes, schema => schema.shortcode), // Passing all of `match` as second argument is intentionally broad |
14224 if (typeof transformation.transform === 'function') { |
12157 // but shouldn't be too relied upon. |
14225 // Passing all of `match` as second argument is intentionally broad |
12158 // |
14226 // but shouldn't be too relied upon. |
12159 // See: https://github.com/WordPress/gutenberg/pull/3610#discussion_r152546926 |
14227 // |
12160 schema => schema.shortcode(match.shortcode.attrs, match)); |
14228 // See: https://github.com/WordPress/gutenberg/pull/3610#discussion_r152546926 |
12161 const transformationBlockType = { ...registration_getBlockType(transformation.blockName), |
14229 blocks = [].concat(transformation.transform(match.shortcode.attrs, match)); |
12162 attributes: transformation.attributes |
14230 |
12163 }; |
14231 // Applying the built-in fixes can enhance the attributes with missing content like "className". |
12164 let block = createBlock(transformation.blockName, getBlockAttributes(transformationBlockType, match.shortcode.content, attributes)); |
14232 blocks = blocks.map(block => { |
12165 block.originalContent = match.shortcode.content; // Applying the built-in fixes can enhance the attributes with missing content like "className". |
14233 block.originalContent = match.shortcode.content; |
12166 |
14234 return applyBuiltInValidationFixes(block, getBlockType(block.name)); |
12167 block = applyBuiltInValidationFixes(block, transformationBlockType); |
14235 }); |
12168 return [...segmentHTMLToShortcodeBlock(beforeHTML), block, ...segmentHTMLToShortcodeBlock(afterHTML)]; |
14236 } else { |
12169 } |
14237 const attributes = Object.fromEntries(Object.entries(transformation.attributes).filter(([, schema]) => schema.shortcode) |
12170 |
14238 // Passing all of `match` as second argument is intentionally broad |
14239 // but shouldn't be too relied upon. |
|
14240 // |
|
14241 // See: https://github.com/WordPress/gutenberg/pull/3610#discussion_r152546926 |
|
14242 .map(([key, schema]) => [key, schema.shortcode(match.shortcode.attrs, match)])); |
|
14243 const blockType = getBlockType(transformation.blockName); |
|
14244 if (!blockType) { |
|
14245 return [HTML]; |
|
14246 } |
|
14247 const transformationBlockType = { |
|
14248 ...blockType, |
|
14249 attributes: transformation.attributes |
|
14250 }; |
|
14251 let block = createBlock(transformation.blockName, getBlockAttributes(transformationBlockType, match.shortcode.content, attributes)); |
|
14252 |
|
14253 // Applying the built-in fixes can enhance the attributes with missing content like "className". |
|
14254 block.originalContent = match.shortcode.content; |
|
14255 block = applyBuiltInValidationFixes(block, transformationBlockType); |
|
14256 blocks = [block]; |
|
14257 } |
|
14258 return [...segmentHTMLToShortcodeBlock(beforeHTML.replace(beforeLineRegexp, '')), ...blocks, ...segmentHTMLToShortcodeBlock(afterHTML.replace(afterLineRegexp, ''))]; |
|
14259 } |
|
12171 return [HTML]; |
14260 return [HTML]; |
12172 } |
14261 } |
12173 |
14262 /* harmony default export */ const shortcode_converter = (segmentHTMLToShortcodeBlock); |
12174 /* harmony default export */ var shortcode_converter = (segmentHTMLToShortcodeBlock); |
|
12175 |
14263 |
12176 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/utils.js |
14264 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/utils.js |
12177 /** |
14265 /** |
12178 * External dependencies |
|
12179 */ |
|
12180 |
|
12181 /** |
|
12182 * WordPress dependencies |
14266 * WordPress dependencies |
12183 */ |
14267 */ |
12184 |
14268 |
12185 |
14269 |
12186 /** |
14270 /** |
12187 * Internal dependencies |
14271 * Internal dependencies |
12188 */ |
14272 */ |
12189 |
|
12190 |
14273 |
12191 |
14274 |
12192 function getBlockContentSchemaFromTransforms(transforms, context) { |
14275 function getBlockContentSchemaFromTransforms(transforms, context) { |
12193 const phrasingContentSchema = (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)(context); |
14276 const phrasingContentSchema = (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)(context); |
12194 const schemaArgs = { |
14277 const schemaArgs = { |
12195 phrasingContentSchema, |
14278 phrasingContentSchema, |
12196 isPaste: context === 'paste' |
14279 isPaste: context === 'paste' |
12197 }; |
14280 }; |
12198 const schemas = transforms.map(_ref => { |
14281 const schemas = transforms.map(({ |
12199 let { |
14282 isMatch, |
12200 isMatch, |
14283 blockName, |
12201 blockName, |
14284 schema |
12202 schema |
14285 }) => { |
12203 } = _ref; |
14286 const hasAnchorSupport = hasBlockSupport(blockName, 'anchor'); |
12204 const hasAnchorSupport = registration_hasBlockSupport(blockName, 'anchor'); |
14287 schema = typeof schema === 'function' ? schema(schemaArgs) : schema; |
12205 schema = (0,external_lodash_namespaceObject.isFunction)(schema) ? schema(schemaArgs) : schema; // If the block does not has anchor support and the transform does not |
14288 |
14289 // If the block does not has anchor support and the transform does not |
|
12206 // provides an isMatch we can return the schema right away. |
14290 // provides an isMatch we can return the schema right away. |
12207 |
|
12208 if (!hasAnchorSupport && !isMatch) { |
14291 if (!hasAnchorSupport && !isMatch) { |
12209 return schema; |
14292 return schema; |
12210 } |
14293 } |
12211 |
14294 if (!schema) { |
12212 return (0,external_lodash_namespaceObject.mapValues)(schema, value => { |
14295 return {}; |
12213 let attributes = value.attributes || []; // If the block supports the "anchor" functionality, it needs to keep its ID attribute. |
14296 } |
12214 |
14297 return Object.fromEntries(Object.entries(schema).map(([key, value]) => { |
14298 let attributes = value.attributes || []; |
|
14299 // If the block supports the "anchor" functionality, it needs to keep its ID attribute. |
|
12215 if (hasAnchorSupport) { |
14300 if (hasAnchorSupport) { |
12216 attributes = [...attributes, 'id']; |
14301 attributes = [...attributes, 'id']; |
12217 } |
14302 } |
12218 |
14303 return [key, { |
12219 return { ...value, |
14304 ...value, |
12220 attributes, |
14305 attributes, |
12221 isMatch: isMatch ? isMatch : undefined |
14306 isMatch: isMatch ? isMatch : undefined |
12222 }; |
14307 }]; |
12223 }); |
14308 })); |
12224 }); |
14309 }); |
12225 return (0,external_lodash_namespaceObject.mergeWith)({}, ...schemas, (objValue, srcValue, key) => { |
14310 function mergeTagNameSchemaProperties(objValue, srcValue, key) { |
12226 switch (key) { |
14311 switch (key) { |
12227 case 'children': |
14312 case 'children': |
12228 { |
14313 { |
12229 if (objValue === '*' || srcValue === '*') { |
14314 if (objValue === '*' || srcValue === '*') { |
12230 return '*'; |
14315 return '*'; |
12231 } |
14316 } |
12232 |
14317 return { |
12233 return { ...objValue, |
14318 ...objValue, |
12234 ...srcValue |
14319 ...srcValue |
12235 }; |
14320 }; |
12236 } |
14321 } |
12237 |
|
12238 case 'attributes': |
14322 case 'attributes': |
12239 case 'require': |
14323 case 'require': |
12240 { |
14324 { |
12241 return [...(objValue || []), ...(srcValue || [])]; |
14325 return [...(objValue || []), ...(srcValue || [])]; |
12242 } |
14326 } |
12243 |
|
12244 case 'isMatch': |
14327 case 'isMatch': |
12245 { |
14328 { |
12246 // If one of the values being merge is undefined (matches everything), |
14329 // If one of the values being merge is undefined (matches everything), |
12247 // the result of the merge will be undefined. |
14330 // the result of the merge will be undefined. |
12248 if (!objValue || !srcValue) { |
14331 if (!objValue || !srcValue) { |
12249 return undefined; |
14332 return undefined; |
12250 } // When merging two isMatch functions, the result is a new function |
14333 } |
14334 // When merging two isMatch functions, the result is a new function |
|
12251 // that returns if one of the source functions returns true. |
14335 // that returns if one of the source functions returns true. |
12252 |
14336 return (...args) => { |
12253 |
14337 return objValue(...args) || srcValue(...args); |
12254 return function () { |
|
12255 return objValue(...arguments) || srcValue(...arguments); |
|
12256 }; |
14338 }; |
12257 } |
14339 } |
12258 } |
14340 } |
12259 }); |
14341 } |
12260 } |
14342 |
14343 // A tagName schema is an object with children, attributes, require, and |
|
14344 // isMatch properties. |
|
14345 function mergeTagNameSchemas(a, b) { |
|
14346 for (const key in b) { |
|
14347 a[key] = a[key] ? mergeTagNameSchemaProperties(a[key], b[key], key) : { |
|
14348 ...b[key] |
|
14349 }; |
|
14350 } |
|
14351 return a; |
|
14352 } |
|
14353 |
|
14354 // A schema is an object with tagName schemas by tag name. |
|
14355 function mergeSchemas(a, b) { |
|
14356 for (const key in b) { |
|
14357 a[key] = a[key] ? mergeTagNameSchemas(a[key], b[key]) : { |
|
14358 ...b[key] |
|
14359 }; |
|
14360 } |
|
14361 return a; |
|
14362 } |
|
14363 return schemas.reduce(mergeSchemas, {}); |
|
14364 } |
|
14365 |
|
12261 /** |
14366 /** |
12262 * Gets the block content schema, which is extracted and merged from all |
14367 * Gets the block content schema, which is extracted and merged from all |
12263 * registered blocks with raw transfroms. |
14368 * registered blocks with raw transfroms. |
12264 * |
14369 * |
12265 * @param {string} context Set to "paste" when in paste context, where the |
14370 * @param {string} context Set to "paste" when in paste context, where the |
12266 * schema is more strict. |
14371 * schema is more strict. |
12267 * |
14372 * |
12268 * @return {Object} A complete block content schema. |
14373 * @return {Object} A complete block content schema. |
12269 */ |
14374 */ |
12270 |
|
12271 function getBlockContentSchema(context) { |
14375 function getBlockContentSchema(context) { |
12272 return getBlockContentSchemaFromTransforms(getRawTransforms(), context); |
14376 return getBlockContentSchemaFromTransforms(getRawTransforms(), context); |
12273 } |
14377 } |
14378 |
|
12274 /** |
14379 /** |
12275 * Checks whether HTML can be considered plain text. That is, it does not contain |
14380 * Checks whether HTML can be considered plain text. That is, it does not contain |
12276 * any elements that are not line breaks. |
14381 * any elements that are not line breaks. |
12277 * |
14382 * |
12278 * @param {string} HTML The HTML to check. |
14383 * @param {string} HTML The HTML to check. |
12279 * |
14384 * |
12280 * @return {boolean} Whether the HTML can be considered plain text. |
14385 * @return {boolean} Whether the HTML can be considered plain text. |
12281 */ |
14386 */ |
12282 |
|
12283 function isPlain(HTML) { |
14387 function isPlain(HTML) { |
12284 return !/<(?!br[ />])/i.test(HTML); |
14388 return !/<(?!br[ />])/i.test(HTML); |
12285 } |
14389 } |
14390 |
|
12286 /** |
14391 /** |
12287 * Given node filters, deeply filters and mutates a NodeList. |
14392 * Given node filters, deeply filters and mutates a NodeList. |
12288 * |
14393 * |
12289 * @param {NodeList} nodeList The nodeList to filter. |
14394 * @param {NodeList} nodeList The nodeList to filter. |
12290 * @param {Array} filters An array of functions that can mutate with the provided node. |
14395 * @param {Array} filters An array of functions that can mutate with the provided node. |
12291 * @param {Document} doc The document of the nodeList. |
14396 * @param {Document} doc The document of the nodeList. |
12292 * @param {Object} schema The schema to use. |
14397 * @param {Object} schema The schema to use. |
12293 */ |
14398 */ |
12294 |
|
12295 function deepFilterNodeList(nodeList, filters, doc, schema) { |
14399 function deepFilterNodeList(nodeList, filters, doc, schema) { |
12296 Array.from(nodeList).forEach(node => { |
14400 Array.from(nodeList).forEach(node => { |
12297 deepFilterNodeList(node.childNodes, filters, doc, schema); |
14401 deepFilterNodeList(node.childNodes, filters, doc, schema); |
12298 filters.forEach(item => { |
14402 filters.forEach(item => { |
12299 // Make sure the node is still attached to the document. |
14403 // Make sure the node is still attached to the document. |
12300 if (!doc.contains(node)) { |
14404 if (!doc.contains(node)) { |
12301 return; |
14405 return; |
12302 } |
14406 } |
12303 |
|
12304 item(node, doc, schema); |
14407 item(node, doc, schema); |
12305 }); |
14408 }); |
12306 }); |
14409 }); |
12307 } |
14410 } |
14411 |
|
12308 /** |
14412 /** |
12309 * Given node filters, deeply filters HTML tags. |
14413 * Given node filters, deeply filters HTML tags. |
12310 * Filters from the deepest nodes to the top. |
14414 * Filters from the deepest nodes to the top. |
12311 * |
14415 * |
12312 * @param {string} HTML The HTML to filter. |
14416 * @param {string} HTML The HTML to filter. |
12313 * @param {Array} filters An array of functions that can mutate with the provided node. |
14417 * @param {Array} filters An array of functions that can mutate with the provided node. |
12314 * @param {Object} schema The schema to use. |
14418 * @param {Object} schema The schema to use. |
12315 * |
14419 * |
12316 * @return {string} The filtered HTML. |
14420 * @return {string} The filtered HTML. |
12317 */ |
14421 */ |
12318 |
14422 function deepFilterHTML(HTML, filters = [], schema) { |
12319 function deepFilterHTML(HTML) { |
|
12320 let filters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; |
|
12321 let schema = arguments.length > 2 ? arguments[2] : undefined; |
|
12322 const doc = document.implementation.createHTMLDocument(''); |
14423 const doc = document.implementation.createHTMLDocument(''); |
12323 doc.body.innerHTML = HTML; |
14424 doc.body.innerHTML = HTML; |
12324 deepFilterNodeList(doc.body.childNodes, filters, doc, schema); |
14425 deepFilterNodeList(doc.body.childNodes, filters, doc, schema); |
12325 return doc.body.innerHTML; |
14426 return doc.body.innerHTML; |
12326 } |
14427 } |
14428 |
|
12327 /** |
14429 /** |
12328 * Gets a sibling within text-level context. |
14430 * Gets a sibling within text-level context. |
12329 * |
14431 * |
12330 * @param {Element} node The subject node. |
14432 * @param {Element} node The subject node. |
12331 * @param {string} which "next" or "previous". |
14433 * @param {string} which "next" or "previous". |
12332 */ |
14434 */ |
12333 |
|
12334 function getSibling(node, which) { |
14435 function getSibling(node, which) { |
12335 const sibling = node[`${which}Sibling`]; |
14436 const sibling = node[`${which}Sibling`]; |
12336 |
|
12337 if (sibling && (0,external_wp_dom_namespaceObject.isPhrasingContent)(sibling)) { |
14437 if (sibling && (0,external_wp_dom_namespaceObject.isPhrasingContent)(sibling)) { |
12338 return sibling; |
14438 return sibling; |
12339 } |
14439 } |
12340 |
|
12341 const { |
14440 const { |
12342 parentNode |
14441 parentNode |
12343 } = node; |
14442 } = node; |
12344 |
|
12345 if (!parentNode || !(0,external_wp_dom_namespaceObject.isPhrasingContent)(parentNode)) { |
14443 if (!parentNode || !(0,external_wp_dom_namespaceObject.isPhrasingContent)(parentNode)) { |
12346 return; |
14444 return; |
12347 } |
14445 } |
12348 |
|
12349 return getSibling(parentNode, which); |
14446 return getSibling(parentNode, which); |
12350 } |
14447 } |
12351 |
14448 |
12352 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/index.js |
14449 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/index.js |
12353 /** |
14450 /** |
12354 * External dependencies |
|
12355 */ |
|
12356 |
|
12357 /** |
|
12358 * WordPress dependencies |
14451 * WordPress dependencies |
12359 */ |
14452 */ |
12360 |
14453 |
12361 |
14454 |
12362 |
14455 |
12363 /** |
14456 /** |
12364 * Internal dependencies |
14457 * Internal dependencies |
12365 */ |
14458 */ |
12366 |
|
12367 |
14459 |
12368 |
14460 |
12369 |
14461 |
12370 |
14462 |
12371 |
14463 |
12379 since: '5.6', |
14471 since: '5.6', |
12380 alternative: 'wp.dom.getPhrasingContentSchema' |
14472 alternative: 'wp.dom.getPhrasingContentSchema' |
12381 }); |
14473 }); |
12382 return (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)(context); |
14474 return (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)(context); |
12383 } |
14475 } |
14476 |
|
12384 /** |
14477 /** |
12385 * Converts an HTML string to known blocks. |
14478 * Converts an HTML string to known blocks. |
12386 * |
14479 * |
12387 * @param {Object} $1 |
14480 * @param {Object} $1 |
12388 * @param {string} $1.HTML The HTML to convert. |
14481 * @param {string} $1.HTML The HTML to convert. |
12389 * |
14482 * |
12390 * @return {Array} A list of blocks. |
14483 * @return {Array} A list of blocks. |
12391 */ |
14484 */ |
12392 |
14485 function rawHandler({ |
12393 function rawHandler(_ref) { |
14486 HTML = '' |
12394 let { |
14487 }) { |
12395 HTML = '' |
|
12396 } = _ref; |
|
12397 |
|
12398 // If we detect block delimiters, parse entirely as blocks. |
14488 // If we detect block delimiters, parse entirely as blocks. |
12399 if (HTML.indexOf('<!-- wp:') !== -1) { |
14489 if (HTML.indexOf('<!-- wp:') !== -1) { |
12400 return parser_parse(HTML); |
14490 const parseResult = parser_parse(HTML); |
12401 } // An array of HTML strings and block objects. The blocks replace matched |
14491 const isSingleFreeFormBlock = parseResult.length === 1 && parseResult[0].name === 'core/freeform'; |
14492 if (!isSingleFreeFormBlock) { |
|
14493 return parseResult; |
|
14494 } |
|
14495 } |
|
14496 |
|
14497 // An array of HTML strings and block objects. The blocks replace matched |
|
12402 // shortcodes. |
14498 // shortcodes. |
12403 |
|
12404 |
|
12405 const pieces = shortcode_converter(HTML); |
14499 const pieces = shortcode_converter(HTML); |
12406 const blockContentSchema = getBlockContentSchema(); |
14500 const blockContentSchema = getBlockContentSchema(); |
12407 return (0,external_lodash_namespaceObject.compact)((0,external_lodash_namespaceObject.flatMap)(pieces, piece => { |
14501 return pieces.map(piece => { |
12408 // Already a block from shortcode. |
14502 // Already a block from shortcode. |
12409 if (typeof piece !== 'string') { |
14503 if (typeof piece !== 'string') { |
12410 return piece; |
14504 return piece; |
12411 } // These filters are essential for some blocks to be able to transform |
14505 } |
14506 |
|
14507 // These filters are essential for some blocks to be able to transform |
|
12412 // from raw HTML. These filters move around some content or add |
14508 // from raw HTML. These filters move around some content or add |
12413 // additional tags, they do not remove any content. |
14509 // additional tags, they do not remove any content. |
12414 |
14510 const filters = [ |
12415 |
14511 // Needed to adjust invalid lists. |
12416 const filters = [// Needed to adjust invalid lists. |
14512 listReducer, |
12417 listReducer, // Needed to create more and nextpage blocks. |
14513 // Needed to create more and nextpage blocks. |
12418 specialCommentConverter, // Needed to create media blocks. |
14514 specialCommentConverter, |
12419 figureContentReducer, // Needed to create the quote block, which cannot handle text |
14515 // Needed to create media blocks. |
14516 figureContentReducer, |
|
14517 // Needed to create the quote block, which cannot handle text |
|
12420 // without wrapper paragraphs. |
14518 // without wrapper paragraphs. |
12421 blockquoteNormaliser]; |
14519 blockquoteNormaliser({ |
14520 raw: true |
|
14521 })]; |
|
12422 piece = deepFilterHTML(piece, filters, blockContentSchema); |
14522 piece = deepFilterHTML(piece, filters, blockContentSchema); |
12423 piece = normaliseBlocks(piece); |
14523 piece = normaliseBlocks(piece, { |
12424 return htmlToBlocks(piece); |
14524 raw: true |
12425 })); |
14525 }); |
14526 return htmlToBlocks(piece, rawHandler); |
|
14527 }).flat().filter(Boolean); |
|
12426 } |
14528 } |
12427 |
14529 |
12428 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/comment-remover.js |
14530 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/comment-remover.js |
12429 /** |
14531 /** |
12430 * WordPress dependencies |
14532 * WordPress dependencies |
12431 */ |
14533 */ |
14534 |
|
12432 |
14535 |
12433 /** |
14536 /** |
12434 * Looks for comments, and removes them. |
14537 * Looks for comments, and removes them. |
12435 * |
14538 * |
12436 * @param {Node} node The node to be processed. |
14539 * @param {Node} node The node to be processed. |
12437 * @return {void} |
14540 * @return {void} |
12438 */ |
14541 */ |
12439 |
|
12440 function commentRemover(node) { |
14542 function commentRemover(node) { |
12441 if (node.nodeType === node.COMMENT_NODE) { |
14543 if (node.nodeType === node.COMMENT_NODE) { |
12442 (0,external_wp_dom_namespaceObject.remove)(node); |
14544 (0,external_wp_dom_namespaceObject.remove)(node); |
12443 } |
14545 } |
12444 } |
14546 } |
12445 |
14547 |
12446 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/is-inline-content.js |
14548 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/is-inline-content.js |
12447 /** |
14549 /** |
12448 * External dependencies |
|
12449 */ |
|
12450 |
|
12451 /** |
|
12452 * WordPress dependencies |
14550 * WordPress dependencies |
12453 */ |
14551 */ |
12454 |
14552 |
12455 |
14553 |
12456 /** |
14554 /** |
12460 * @param {Node} node Node name. |
14558 * @param {Node} node Node name. |
12461 * @param {string} contextTag Tag name. |
14559 * @param {string} contextTag Tag name. |
12462 * |
14560 * |
12463 * @return {boolean} True if the node is inline content, false if nohe. |
14561 * @return {boolean} True if the node is inline content, false if nohe. |
12464 */ |
14562 */ |
12465 |
|
12466 function isInline(node, contextTag) { |
14563 function isInline(node, contextTag) { |
12467 if ((0,external_wp_dom_namespaceObject.isTextContent)(node)) { |
14564 if ((0,external_wp_dom_namespaceObject.isTextContent)(node)) { |
12468 return true; |
14565 return true; |
12469 } |
14566 } |
12470 |
|
12471 if (!contextTag) { |
14567 if (!contextTag) { |
12472 return false; |
14568 return false; |
12473 } |
14569 } |
12474 |
|
12475 const tag = node.nodeName.toLowerCase(); |
14570 const tag = node.nodeName.toLowerCase(); |
12476 const inlineAllowedTagGroups = [['ul', 'li', 'ol'], ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']]; |
14571 const inlineAllowedTagGroups = [['ul', 'li', 'ol'], ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']]; |
12477 return inlineAllowedTagGroups.some(tagGroup => (0,external_lodash_namespaceObject.difference)([tag, contextTag], tagGroup).length === 0); |
14572 return inlineAllowedTagGroups.some(tagGroup => [tag, contextTag].filter(t => !tagGroup.includes(t)).length === 0); |
12478 } |
14573 } |
12479 |
|
12480 function deepCheck(nodes, contextTag) { |
14574 function deepCheck(nodes, contextTag) { |
12481 return nodes.every(node => isInline(node, contextTag) && deepCheck(Array.from(node.children), contextTag)); |
14575 return nodes.every(node => isInline(node, contextTag) && deepCheck(Array.from(node.children), contextTag)); |
12482 } |
14576 } |
12483 |
|
12484 function isDoubleBR(node) { |
14577 function isDoubleBR(node) { |
12485 return node.nodeName === 'BR' && node.previousSibling && node.previousSibling.nodeName === 'BR'; |
14578 return node.nodeName === 'BR' && node.previousSibling && node.previousSibling.nodeName === 'BR'; |
12486 } |
14579 } |
12487 |
|
12488 function isInlineContent(HTML, contextTag) { |
14580 function isInlineContent(HTML, contextTag) { |
12489 const doc = document.implementation.createHTMLDocument(''); |
14581 const doc = document.implementation.createHTMLDocument(''); |
12490 doc.body.innerHTML = HTML; |
14582 doc.body.innerHTML = HTML; |
12491 const nodes = Array.from(doc.body.children); |
14583 const nodes = Array.from(doc.body.children); |
12492 return !nodes.some(isDoubleBR) && deepCheck(nodes, contextTag); |
14584 return !nodes.some(isDoubleBR) && deepCheck(nodes, contextTag); |
12493 } |
14585 } |
12494 |
14586 |
12495 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/phrasing-content-reducer.js |
14587 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/phrasing-content-reducer.js |
12496 /** |
14588 /** |
12497 * External dependencies |
|
12498 */ |
|
12499 |
|
12500 /** |
|
12501 * WordPress dependencies |
14589 * WordPress dependencies |
12502 */ |
14590 */ |
12503 |
|
12504 |
14591 |
12505 function phrasingContentReducer(node, doc) { |
14592 function phrasingContentReducer(node, doc) { |
12506 // In jsdom-jscore, 'node.style' can be null. |
14593 // In jsdom-jscore, 'node.style' can be null. |
12507 // TODO: Explore fixing this by patching jsdom-jscore. |
14594 // TODO: Explore fixing this by patching jsdom-jscore. |
12508 if (node.nodeName === 'SPAN' && node.style) { |
14595 if (node.nodeName === 'SPAN' && node.style) { |
12511 fontStyle, |
14598 fontStyle, |
12512 textDecorationLine, |
14599 textDecorationLine, |
12513 textDecoration, |
14600 textDecoration, |
12514 verticalAlign |
14601 verticalAlign |
12515 } = node.style; |
14602 } = node.style; |
12516 |
|
12517 if (fontWeight === 'bold' || fontWeight === '700') { |
14603 if (fontWeight === 'bold' || fontWeight === '700') { |
12518 (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('strong'), node); |
14604 (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('strong'), node); |
12519 } |
14605 } |
12520 |
|
12521 if (fontStyle === 'italic') { |
14606 if (fontStyle === 'italic') { |
12522 (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('em'), node); |
14607 (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('em'), node); |
12523 } // Some DOM implementations (Safari, JSDom) don't support |
14608 } |
14609 |
|
14610 // Some DOM implementations (Safari, JSDom) don't support |
|
12524 // style.textDecorationLine, so we check style.textDecoration as a |
14611 // style.textDecorationLine, so we check style.textDecoration as a |
12525 // fallback. |
14612 // fallback. |
12526 |
14613 if (textDecorationLine === 'line-through' || textDecoration.includes('line-through')) { |
12527 |
|
12528 if (textDecorationLine === 'line-through' || (0,external_lodash_namespaceObject.includes)(textDecoration, 'line-through')) { |
|
12529 (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('s'), node); |
14614 (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('s'), node); |
12530 } |
14615 } |
12531 |
|
12532 if (verticalAlign === 'super') { |
14616 if (verticalAlign === 'super') { |
12533 (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('sup'), node); |
14617 (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('sup'), node); |
12534 } else if (verticalAlign === 'sub') { |
14618 } else if (verticalAlign === 'sub') { |
12535 (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('sub'), node); |
14619 (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('sub'), node); |
12536 } |
14620 } |
12544 if (node.target && node.target.toLowerCase() === '_blank') { |
14628 if (node.target && node.target.toLowerCase() === '_blank') { |
12545 node.rel = 'noreferrer noopener'; |
14629 node.rel = 'noreferrer noopener'; |
12546 } else { |
14630 } else { |
12547 node.removeAttribute('target'); |
14631 node.removeAttribute('target'); |
12548 node.removeAttribute('rel'); |
14632 node.removeAttribute('rel'); |
12549 } // Saves anchor elements name attribute as id |
14633 } |
12550 |
14634 |
12551 |
14635 // Saves anchor elements name attribute as id |
12552 if (node.name && !node.id) { |
14636 if (node.name && !node.id) { |
12553 node.id = node.name; |
14637 node.id = node.name; |
12554 } // Keeps id only if there is an internal link pointing to it |
14638 } |
12555 |
14639 |
12556 |
14640 // Keeps id only if there is an internal link pointing to it |
12557 if (node.id && !node.ownerDocument.querySelector(`[href="#${node.id}"]`)) { |
14641 if (node.id && !node.ownerDocument.querySelector(`[href="#${node.id}"]`)) { |
12558 node.removeAttribute('id'); |
14642 node.removeAttribute('id'); |
12559 } |
14643 } |
12560 } |
14644 } |
12561 } |
14645 } |
12563 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/head-remover.js |
14647 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/head-remover.js |
12564 function headRemover(node) { |
14648 function headRemover(node) { |
12565 if (node.nodeName !== 'SCRIPT' && node.nodeName !== 'NOSCRIPT' && node.nodeName !== 'TEMPLATE' && node.nodeName !== 'STYLE') { |
14649 if (node.nodeName !== 'SCRIPT' && node.nodeName !== 'NOSCRIPT' && node.nodeName !== 'TEMPLATE' && node.nodeName !== 'STYLE') { |
12566 return; |
14650 return; |
12567 } |
14651 } |
12568 |
|
12569 node.parentNode.removeChild(node); |
14652 node.parentNode.removeChild(node); |
12570 } |
14653 } |
12571 |
14654 |
14655 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/ms-list-ignore.js |
|
14656 /** |
|
14657 * Looks for comments, and removes them. |
|
14658 * |
|
14659 * @param {Node} node The node to be processed. |
|
14660 * @return {void} |
|
14661 */ |
|
14662 function msListIgnore(node) { |
|
14663 if (node.nodeType !== node.ELEMENT_NODE) { |
|
14664 return; |
|
14665 } |
|
14666 const style = node.getAttribute('style'); |
|
14667 if (!style || !style.includes('mso-list')) { |
|
14668 return; |
|
14669 } |
|
14670 const rules = style.split(';').reduce((acc, rule) => { |
|
14671 const [key, value] = rule.split(':'); |
|
14672 if (key && value) { |
|
14673 acc[key.trim().toLowerCase()] = value.trim().toLowerCase(); |
|
14674 } |
|
14675 return acc; |
|
14676 }, {}); |
|
14677 if (rules['mso-list'] === 'ignore') { |
|
14678 node.remove(); |
|
14679 } |
|
14680 } |
|
14681 |
|
12572 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/ms-list-converter.js |
14682 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/ms-list-converter.js |
12573 /** |
14683 /** |
12574 * Browser dependencies |
14684 * Internal dependencies |
12575 */ |
14685 */ |
12576 const { |
14686 |
12577 parseInt: ms_list_converter_parseInt |
|
12578 } = window; |
|
12579 |
14687 |
12580 function ms_list_converter_isList(node) { |
14688 function ms_list_converter_isList(node) { |
12581 return node.nodeName === 'OL' || node.nodeName === 'UL'; |
14689 return node.nodeName === 'OL' || node.nodeName === 'UL'; |
12582 } |
14690 } |
12583 |
|
12584 function msListConverter(node, doc) { |
14691 function msListConverter(node, doc) { |
12585 if (node.nodeName !== 'P') { |
14692 if (node.nodeName !== 'P') { |
12586 return; |
14693 return; |
12587 } |
14694 } |
12588 |
|
12589 const style = node.getAttribute('style'); |
14695 const style = node.getAttribute('style'); |
12590 |
14696 if (!style || !style.includes('mso-list')) { |
12591 if (!style) { |
|
12592 return; |
14697 return; |
12593 } // Quick check. |
14698 } |
12594 |
14699 const prevNode = node.previousElementSibling; |
12595 |
14700 |
12596 if (style.indexOf('mso-list') === -1) { |
14701 // Add new list if no previous. |
12597 return; |
|
12598 } |
|
12599 |
|
12600 const matches = /mso-list\s*:[^;]+level([0-9]+)/i.exec(style); |
|
12601 |
|
12602 if (!matches) { |
|
12603 return; |
|
12604 } |
|
12605 |
|
12606 let level = ms_list_converter_parseInt(matches[1], 10) - 1 || 0; |
|
12607 const prevNode = node.previousElementSibling; // Add new list if no previous. |
|
12608 |
|
12609 if (!prevNode || !ms_list_converter_isList(prevNode)) { |
14702 if (!prevNode || !ms_list_converter_isList(prevNode)) { |
12610 // See https://html.spec.whatwg.org/multipage/grouping-content.html#attr-ol-type. |
14703 // See https://html.spec.whatwg.org/multipage/grouping-content.html#attr-ol-type. |
12611 const type = node.textContent.trim().slice(0, 1); |
14704 const type = node.textContent.trim().slice(0, 1); |
12612 const isNumeric = /[1iIaA]/.test(type); |
14705 const isNumeric = /[1iIaA]/.test(type); |
12613 const newListNode = doc.createElement(isNumeric ? 'ol' : 'ul'); |
14706 const newListNode = doc.createElement(isNumeric ? 'ol' : 'ul'); |
12614 |
|
12615 if (isNumeric) { |
14707 if (isNumeric) { |
12616 newListNode.setAttribute('type', type); |
14708 newListNode.setAttribute('type', type); |
12617 } |
14709 } |
12618 |
|
12619 node.parentNode.insertBefore(newListNode, node); |
14710 node.parentNode.insertBefore(newListNode, node); |
12620 } |
14711 } |
12621 |
|
12622 const listNode = node.previousElementSibling; |
14712 const listNode = node.previousElementSibling; |
12623 const listType = listNode.nodeName; |
14713 const listType = listNode.nodeName; |
12624 const listItem = doc.createElement('li'); |
14714 const listItem = doc.createElement('li'); |
12625 let receivingNode = listNode; // Remove the first span with list info. |
14715 let receivingNode = listNode; |
12626 |
14716 |
12627 node.removeChild(node.firstChild); // Add content. |
14717 // Add content. |
12628 |
14718 listItem.innerHTML = deepFilterHTML(node.innerHTML, [msListIgnore]); |
12629 while (node.firstChild) { |
14719 const matches = /mso-list\s*:[^;]+level([0-9]+)/i.exec(style); |
12630 listItem.appendChild(node.firstChild); |
14720 let level = matches ? parseInt(matches[1], 10) - 1 || 0 : 0; |
12631 } // Change pointer depending on indentation level. |
14721 |
12632 |
14722 // Change pointer depending on indentation level. |
12633 |
|
12634 while (level--) { |
14723 while (level--) { |
12635 receivingNode = receivingNode.lastChild || receivingNode; // If it's a list, move pointer to the last item. |
14724 receivingNode = receivingNode.lastChild || receivingNode; |
12636 |
14725 |
14726 // If it's a list, move pointer to the last item. |
|
12637 if (ms_list_converter_isList(receivingNode)) { |
14727 if (ms_list_converter_isList(receivingNode)) { |
12638 receivingNode = receivingNode.lastChild || receivingNode; |
14728 receivingNode = receivingNode.lastChild || receivingNode; |
12639 } |
14729 } |
12640 } // Make sure we append to a list. |
14730 } |
12641 |
14731 |
12642 |
14732 // Make sure we append to a list. |
12643 if (!ms_list_converter_isList(receivingNode)) { |
14733 if (!ms_list_converter_isList(receivingNode)) { |
12644 receivingNode = receivingNode.appendChild(doc.createElement(listType)); |
14734 receivingNode = receivingNode.appendChild(doc.createElement(listType)); |
12645 } // Append the list item to the list. |
14735 } |
12646 |
14736 |
12647 |
14737 // Append the list item to the list. |
12648 receivingNode.appendChild(listItem); // Remove the wrapper paragraph. |
14738 receivingNode.appendChild(listItem); |
12649 |
14739 |
14740 // Remove the wrapper paragraph. |
|
12650 node.parentNode.removeChild(node); |
14741 node.parentNode.removeChild(node); |
12651 } |
14742 } |
12652 |
14743 |
12653 ;// CONCATENATED MODULE: external ["wp","blob"] |
14744 ;// CONCATENATED MODULE: external ["wp","blob"] |
12654 var external_wp_blob_namespaceObject = window["wp"]["blob"]; |
14745 const external_wp_blob_namespaceObject = window["wp"]["blob"]; |
12655 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/image-corrector.js |
14746 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/image-corrector.js |
12656 /** |
14747 /** |
12657 * WordPress dependencies |
14748 * WordPress dependencies |
12658 */ |
14749 */ |
12659 |
14750 |
12660 /** |
|
12661 * Browser dependencies |
|
12662 */ |
|
12663 |
|
12664 const { |
|
12665 atob, |
|
12666 File |
|
12667 } = window; |
|
12668 function imageCorrector(node) { |
14751 function imageCorrector(node) { |
12669 if (node.nodeName !== 'IMG') { |
14752 if (node.nodeName !== 'IMG') { |
12670 return; |
14753 return; |
12671 } |
14754 } |
12672 |
|
12673 if (node.src.indexOf('file:') === 0) { |
14755 if (node.src.indexOf('file:') === 0) { |
12674 node.src = ''; |
14756 node.src = ''; |
12675 } // This piece cannot be tested outside a browser env. |
14757 } |
12676 |
14758 |
12677 |
14759 // This piece cannot be tested outside a browser env. |
12678 if (node.src.indexOf('data:') === 0) { |
14760 if (node.src.indexOf('data:') === 0) { |
12679 const [properties, data] = node.src.split(','); |
14761 const [properties, data] = node.src.split(','); |
12680 const [type] = properties.slice(5).split(';'); |
14762 const [type] = properties.slice(5).split(';'); |
12681 |
|
12682 if (!data || !type) { |
14763 if (!data || !type) { |
12683 node.src = ''; |
14764 node.src = ''; |
12684 return; |
14765 return; |
12685 } |
14766 } |
12686 |
14767 let decoded; |
12687 let decoded; // Can throw DOMException! |
14768 |
12688 |
14769 // Can throw DOMException! |
12689 try { |
14770 try { |
12690 decoded = atob(data); |
14771 decoded = atob(data); |
12691 } catch (e) { |
14772 } catch (e) { |
12692 node.src = ''; |
14773 node.src = ''; |
12693 return; |
14774 return; |
12694 } |
14775 } |
12695 |
|
12696 const uint8Array = new Uint8Array(decoded.length); |
14776 const uint8Array = new Uint8Array(decoded.length); |
12697 |
|
12698 for (let i = 0; i < uint8Array.length; i++) { |
14777 for (let i = 0; i < uint8Array.length; i++) { |
12699 uint8Array[i] = decoded.charCodeAt(i); |
14778 uint8Array[i] = decoded.charCodeAt(i); |
12700 } |
14779 } |
12701 |
|
12702 const name = type.replace('/', '.'); |
14780 const name = type.replace('/', '.'); |
12703 const file = new File([uint8Array], name, { |
14781 const file = new window.File([uint8Array], name, { |
12704 type |
14782 type |
12705 }); |
14783 }); |
12706 node.src = (0,external_wp_blob_namespaceObject.createBlobURL)(file); |
14784 node.src = (0,external_wp_blob_namespaceObject.createBlobURL)(file); |
12707 } // Remove trackers and hardly visible images. |
14785 } |
12708 |
14786 |
12709 |
14787 // Remove trackers and hardly visible images. |
12710 if (node.height === 1 || node.width === 1) { |
14788 if (node.height === 1 || node.width === 1) { |
12711 node.parentNode.removeChild(node); |
14789 node.parentNode.removeChild(node); |
12712 } |
14790 } |
12713 } |
14791 } |
12714 |
14792 |
12719 |
14797 |
12720 function divNormaliser(node) { |
14798 function divNormaliser(node) { |
12721 if (node.nodeName !== 'DIV') { |
14799 if (node.nodeName !== 'DIV') { |
12722 return; |
14800 return; |
12723 } |
14801 } |
12724 |
|
12725 node.innerHTML = normaliseBlocks(node.innerHTML); |
14802 node.innerHTML = normaliseBlocks(node.innerHTML); |
12726 } |
14803 } |
12727 |
14804 |
12728 // EXTERNAL MODULE: ./node_modules/showdown/dist/showdown.js |
14805 // EXTERNAL MODULE: ./node_modules/showdown/dist/showdown.js |
12729 var showdown = __webpack_require__(7308); |
14806 var showdown = __webpack_require__(1030); |
12730 var showdown_default = /*#__PURE__*/__webpack_require__.n(showdown); |
14807 var showdown_default = /*#__PURE__*/__webpack_require__.n(showdown); |
12731 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/markdown-converter.js |
14808 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/markdown-converter.js |
12732 /** |
14809 /** |
12733 * External dependencies |
14810 * External dependencies |
12734 */ |
14811 */ |
12735 // Reuse the same showdown converter. |
14812 |
12736 |
14813 |
14814 // Reuse the same showdown converter. |
|
12737 const converter = new (showdown_default()).Converter({ |
14815 const converter = new (showdown_default()).Converter({ |
12738 noHeaderId: true, |
14816 noHeaderId: true, |
12739 tables: true, |
14817 tables: true, |
12740 literalMidWordUnderscores: true, |
14818 literalMidWordUnderscores: true, |
12741 omitExtraWLInCodeBlocks: true, |
14819 omitExtraWLInCodeBlocks: true, |
12742 simpleLineBreaks: true, |
14820 simpleLineBreaks: true, |
12743 strikethrough: true |
14821 strikethrough: true |
12744 }); |
14822 }); |
14823 |
|
12745 /** |
14824 /** |
12746 * Corrects the Slack Markdown variant of the code block. |
14825 * Corrects the Slack Markdown variant of the code block. |
12747 * If uncorrected, it will be converted to inline code. |
14826 * If uncorrected, it will be converted to inline code. |
12748 * |
14827 * |
12749 * @see https://get.slack.help/hc/en-us/articles/202288908-how-can-i-add-formatting-to-my-messages-#code-blocks |
14828 * @see https://get.slack.help/hc/en-us/articles/202288908-how-can-i-add-formatting-to-my-messages-#code-blocks |
12750 * |
14829 * |
12751 * @param {string} text The potential Markdown text to correct. |
14830 * @param {string} text The potential Markdown text to correct. |
12752 * |
14831 * |
12753 * @return {string} The corrected Markdown. |
14832 * @return {string} The corrected Markdown. |
12754 */ |
14833 */ |
12755 |
|
12756 function slackMarkdownVariantCorrector(text) { |
14834 function slackMarkdownVariantCorrector(text) { |
12757 return text.replace(/((?:^|\n)```)([^\n`]+)(```(?:$|\n))/, (match, p1, p2, p3) => `${p1}\n${p2}\n${p3}`); |
14835 return text.replace(/((?:^|\n)```)([^\n`]+)(```(?:$|\n))/, (match, p1, p2, p3) => `${p1}\n${p2}\n${p3}`); |
12758 } |
14836 } |
14837 function bulletsToAsterisks(text) { |
|
14838 return text.replace(/(^|\n)•( +)/g, '$1*$2'); |
|
14839 } |
|
14840 |
|
12759 /** |
14841 /** |
12760 * Converts a piece of text into HTML based on any Markdown present. |
14842 * Converts a piece of text into HTML based on any Markdown present. |
12761 * Also decodes any encoded HTML. |
14843 * Also decodes any encoded HTML. |
12762 * |
14844 * |
12763 * @param {string} text The plain text to convert. |
14845 * @param {string} text The plain text to convert. |
12764 * |
14846 * |
12765 * @return {string} HTML. |
14847 * @return {string} HTML. |
12766 */ |
14848 */ |
12767 |
|
12768 |
|
12769 function markdownConverter(text) { |
14849 function markdownConverter(text) { |
12770 return converter.makeHtml(slackMarkdownVariantCorrector(text)); |
14850 return converter.makeHtml(slackMarkdownVariantCorrector(bulletsToAsterisks(text))); |
12771 } |
14851 } |
12772 |
14852 |
12773 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/iframe-remover.js |
14853 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/iframe-remover.js |
12774 /** |
14854 /** |
12775 * Removes iframes. |
14855 * Removes iframes. |
12793 function googleDocsUIdRemover(node) { |
14873 function googleDocsUIdRemover(node) { |
12794 if (!node.id || node.id.indexOf('docs-internal-guid-') !== 0) { |
14874 if (!node.id || node.id.indexOf('docs-internal-guid-') !== 0) { |
12795 return; |
14875 return; |
12796 } |
14876 } |
12797 |
14877 |
12798 (0,external_wp_dom_namespaceObject.unwrap)(node); |
14878 // Google Docs sometimes wraps the content in a B tag. We don't want to keep |
14879 // this. |
|
14880 if (node.tagName === 'B') { |
|
14881 (0,external_wp_dom_namespaceObject.unwrap)(node); |
|
14882 } else { |
|
14883 node.removeAttribute('id'); |
|
14884 } |
|
12799 } |
14885 } |
12800 |
14886 |
12801 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/html-formatting-remover.js |
14887 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/html-formatting-remover.js |
12802 /** |
14888 /** |
12803 * Internal dependencies |
14889 * Internal dependencies |
12804 */ |
14890 */ |
12805 |
|
12806 |
14891 |
12807 function isFormattingSpace(character) { |
14892 function isFormattingSpace(character) { |
12808 return character === ' ' || character === '\r' || character === '\n' || character === '\t'; |
14893 return character === ' ' || character === '\r' || character === '\n' || character === '\t'; |
12809 } |
14894 } |
14895 |
|
12810 /** |
14896 /** |
12811 * Removes spacing that formats HTML. |
14897 * Removes spacing that formats HTML. |
12812 * |
14898 * |
12813 * @see https://www.w3.org/TR/css-text-3/#white-space-processing |
14899 * @see https://www.w3.org/TR/css-text-3/#white-space-processing |
12814 * |
14900 * |
12815 * @param {Node} node The node to be processed. |
14901 * @param {Node} node The node to be processed. |
12816 * @return {void} |
14902 * @return {void} |
12817 */ |
14903 */ |
12818 |
|
12819 |
|
12820 function htmlFormattingRemover(node) { |
14904 function htmlFormattingRemover(node) { |
12821 if (node.nodeType !== node.TEXT_NODE) { |
14905 if (node.nodeType !== node.TEXT_NODE) { |
12822 return; |
14906 return; |
12823 } // Ignore pre content. Note that this does not use Element#closest due to |
14907 } |
14908 |
|
14909 // Ignore pre content. Note that this does not use Element#closest due to |
|
12824 // a combination of (a) node may not be Element and (b) node.parentElement |
14910 // a combination of (a) node may not be Element and (b) node.parentElement |
12825 // does not have full support in all browsers (Internet Exporer). |
14911 // does not have full support in all browsers (Internet Exporer). |
12826 // |
14912 // |
12827 // See: https://developer.mozilla.org/en-US/docs/Web/API/Node/parentElement#Browser_compatibility |
14913 // See: https://developer.mozilla.org/en-US/docs/Web/API/Node/parentElement#Browser_compatibility |
12828 |
14914 |
12829 /** @type {Node?} */ |
14915 /** @type {Node?} */ |
12830 |
|
12831 |
|
12832 let parent = node; |
14916 let parent = node; |
12833 |
|
12834 while (parent = parent.parentNode) { |
14917 while (parent = parent.parentNode) { |
12835 if (parent.nodeType === parent.ELEMENT_NODE && parent.nodeName === 'PRE') { |
14918 if (parent.nodeType === parent.ELEMENT_NODE && parent.nodeName === 'PRE') { |
12836 return; |
14919 return; |
12837 } |
14920 } |
12838 } // First, replace any sequence of HTML formatting space with a single space. |
14921 } |
12839 |
14922 |
12840 |
14923 // First, replace any sequence of HTML formatting space with a single space. |
12841 let newData = node.data.replace(/[ \r\n\t]+/g, ' '); // Remove the leading space if the text element is at the start of a block, |
14924 let newData = node.data.replace(/[ \r\n\t]+/g, ' '); |
14925 |
|
14926 // Remove the leading space if the text element is at the start of a block, |
|
12842 // is preceded by a line break element, or has a space in the previous |
14927 // is preceded by a line break element, or has a space in the previous |
12843 // node. |
14928 // node. |
12844 |
|
12845 if (newData[0] === ' ') { |
14929 if (newData[0] === ' ') { |
12846 const previousSibling = getSibling(node, 'previous'); |
14930 const previousSibling = getSibling(node, 'previous'); |
12847 |
|
12848 if (!previousSibling || previousSibling.nodeName === 'BR' || previousSibling.textContent.slice(-1) === ' ') { |
14931 if (!previousSibling || previousSibling.nodeName === 'BR' || previousSibling.textContent.slice(-1) === ' ') { |
12849 newData = newData.slice(1); |
14932 newData = newData.slice(1); |
12850 } |
14933 } |
12851 } // Remove the trailing space if the text element is at the end of a block, |
14934 } |
14935 |
|
14936 // Remove the trailing space if the text element is at the end of a block, |
|
12852 // is succeded by a line break element, or has a space in the next text |
14937 // is succeded by a line break element, or has a space in the next text |
12853 // node. |
14938 // node. |
12854 |
|
12855 |
|
12856 if (newData[newData.length - 1] === ' ') { |
14939 if (newData[newData.length - 1] === ' ') { |
12857 const nextSibling = getSibling(node, 'next'); |
14940 const nextSibling = getSibling(node, 'next'); |
12858 |
|
12859 if (!nextSibling || nextSibling.nodeName === 'BR' || nextSibling.nodeType === nextSibling.TEXT_NODE && isFormattingSpace(nextSibling.textContent[0])) { |
14941 if (!nextSibling || nextSibling.nodeName === 'BR' || nextSibling.nodeType === nextSibling.TEXT_NODE && isFormattingSpace(nextSibling.textContent[0])) { |
12860 newData = newData.slice(0, -1); |
14942 newData = newData.slice(0, -1); |
12861 } |
14943 } |
12862 } // If there's no data left, remove the node, so `previousSibling` stays |
14944 } |
14945 |
|
14946 // If there's no data left, remove the node, so `previousSibling` stays |
|
12863 // accurate. Otherwise, update the node data. |
14947 // accurate. Otherwise, update the node data. |
12864 |
|
12865 |
|
12866 if (!newData) { |
14948 if (!newData) { |
12867 node.parentNode.removeChild(node); |
14949 node.parentNode.removeChild(node); |
12868 } else { |
14950 } else { |
12869 node.data = newData; |
14951 node.data = newData; |
12870 } |
14952 } |
12873 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/br-remover.js |
14955 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/br-remover.js |
12874 /** |
14956 /** |
12875 * Internal dependencies |
14957 * Internal dependencies |
12876 */ |
14958 */ |
12877 |
14959 |
14960 |
|
12878 /** |
14961 /** |
12879 * Removes trailing br elements from text-level content. |
14962 * Removes trailing br elements from text-level content. |
12880 * |
14963 * |
12881 * @param {Element} node Node to check. |
14964 * @param {Element} node Node to check. |
12882 */ |
14965 */ |
12883 |
|
12884 function brRemover(node) { |
14966 function brRemover(node) { |
12885 if (node.nodeName !== 'BR') { |
14967 if (node.nodeName !== 'BR') { |
12886 return; |
14968 return; |
12887 } |
14969 } |
12888 |
|
12889 if (getSibling(node, 'next')) { |
14970 if (getSibling(node, 'next')) { |
12890 return; |
14971 return; |
12891 } |
14972 } |
12892 |
|
12893 node.parentNode.removeChild(node); |
14973 node.parentNode.removeChild(node); |
12894 } |
14974 } |
12895 |
14975 |
12896 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/empty-paragraph-remover.js |
14976 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/empty-paragraph-remover.js |
12897 /** |
14977 /** |
12901 */ |
14981 */ |
12902 function emptyParagraphRemover(node) { |
14982 function emptyParagraphRemover(node) { |
12903 if (node.nodeName !== 'P') { |
14983 if (node.nodeName !== 'P') { |
12904 return; |
14984 return; |
12905 } |
14985 } |
12906 |
|
12907 if (node.hasChildNodes()) { |
14986 if (node.hasChildNodes()) { |
12908 return; |
14987 return; |
12909 } |
14988 } |
12910 |
|
12911 node.parentNode.removeChild(node); |
14989 node.parentNode.removeChild(node); |
12912 } |
14990 } |
12913 |
14991 |
14992 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/slack-paragraph-corrector.js |
|
14993 /** |
|
14994 * Replaces Slack paragraph markup with a double line break (later converted to |
|
14995 * a proper paragraph). |
|
14996 * |
|
14997 * @param {Element} node Node to check. |
|
14998 */ |
|
14999 function slackParagraphCorrector(node) { |
|
15000 if (node.nodeName !== 'SPAN') { |
|
15001 return; |
|
15002 } |
|
15003 if (node.getAttribute('data-stringify-type') !== 'paragraph-break') { |
|
15004 return; |
|
15005 } |
|
15006 const { |
|
15007 parentNode |
|
15008 } = node; |
|
15009 parentNode.insertBefore(node.ownerDocument.createElement('br'), node); |
|
15010 parentNode.insertBefore(node.ownerDocument.createElement('br'), node); |
|
15011 parentNode.removeChild(node); |
|
15012 } |
|
15013 |
|
12914 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/paste-handler.js |
15014 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/paste-handler.js |
12915 /** |
15015 /** |
12916 * External dependencies |
|
12917 */ |
|
12918 |
|
12919 /** |
|
12920 * WordPress dependencies |
15016 * WordPress dependencies |
12921 */ |
15017 */ |
12922 |
15018 |
12923 |
15019 |
12924 /** |
15020 /** |
12947 |
15043 |
12948 |
15044 |
12949 |
15045 |
12950 |
15046 |
12951 |
15047 |
12952 /** |
15048 |
12953 * Browser dependencies |
15049 const log = (...args) => window?.console?.log?.(...args); |
12954 */ |
15050 |
12955 |
|
12956 const { |
|
12957 console: paste_handler_console |
|
12958 } = window; |
|
12959 /** |
15051 /** |
12960 * Filters HTML to only contain phrasing content. |
15052 * Filters HTML to only contain phrasing content. |
12961 * |
15053 * |
12962 * @param {string} HTML The HTML to filter. |
15054 * @param {string} HTML The HTML to filter. |
12963 * @param {boolean} preserveWhiteSpace Whether or not to preserve consequent white space. |
|
12964 * |
15055 * |
12965 * @return {string} HTML only containing phrasing content. |
15056 * @return {string} HTML only containing phrasing content. |
12966 */ |
15057 */ |
12967 |
15058 function filterInlineHTML(HTML) { |
12968 function filterInlineHTML(HTML, preserveWhiteSpace) { |
15059 HTML = deepFilterHTML(HTML, [headRemover, googleDocsUIdRemover, msListIgnore, phrasingContentReducer, commentRemover]); |
12969 HTML = deepFilterHTML(HTML, [googleDocsUIdRemover, phrasingContentReducer, commentRemover]); |
|
12970 HTML = (0,external_wp_dom_namespaceObject.removeInvalidHTML)(HTML, (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)('paste'), { |
15060 HTML = (0,external_wp_dom_namespaceObject.removeInvalidHTML)(HTML, (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)('paste'), { |
12971 inline: true |
15061 inline: true |
12972 }); |
15062 }); |
12973 |
15063 HTML = deepFilterHTML(HTML, [htmlFormattingRemover, brRemover]); |
12974 if (!preserveWhiteSpace) { |
15064 |
12975 HTML = deepFilterHTML(HTML, [htmlFormattingRemover, brRemover]); |
15065 // Allows us to ask for this information when we get a report. |
12976 } // Allows us to ask for this information when we get a report. |
15066 log('Processed inline HTML:\n\n', HTML); |
12977 |
|
12978 |
|
12979 paste_handler_console.log('Processed inline HTML:\n\n', HTML); |
|
12980 return HTML; |
15067 return HTML; |
12981 } |
15068 } |
15069 |
|
12982 /** |
15070 /** |
12983 * Converts an HTML string to known blocks. Strips everything else. |
15071 * Converts an HTML string to known blocks. Strips everything else. |
12984 * |
15072 * |
12985 * @param {Object} options |
15073 * @param {Object} options |
12986 * @param {string} [options.HTML] The HTML to convert. |
15074 * @param {string} [options.HTML] The HTML to convert. |
12987 * @param {string} [options.plainText] Plain text version. |
15075 * @param {string} [options.plainText] Plain text version. |
12988 * @param {string} [options.mode] Handle content as blocks or inline content. |
15076 * @param {string} [options.mode] Handle content as blocks or inline content. |
12989 * * 'AUTO': Decide based on the content passed. |
15077 * * 'AUTO': Decide based on the content passed. |
12990 * * 'INLINE': Always handle as inline content, and return string. |
15078 * * 'INLINE': Always handle as inline content, and return string. |
12991 * * 'BLOCKS': Always handle as blocks, and return array of blocks. |
15079 * * 'BLOCKS': Always handle as blocks, and return array of blocks. |
12992 * @param {Array} [options.tagName] The tag into which content will be inserted. |
15080 * @param {Array} [options.tagName] The tag into which content will be inserted. |
12993 * @param {boolean} [options.preserveWhiteSpace] Whether or not to preserve consequent white space. |
|
12994 * |
15081 * |
12995 * @return {Array|string} A list of blocks or a string, depending on `handlerMode`. |
15082 * @return {Array|string} A list of blocks or a string, depending on `handlerMode`. |
12996 */ |
15083 */ |
12997 |
15084 function pasteHandler({ |
12998 |
15085 HTML = '', |
12999 function pasteHandler(_ref) { |
15086 plainText = '', |
13000 let { |
15087 mode = 'AUTO', |
13001 HTML = '', |
15088 tagName |
13002 plainText = '', |
15089 }) { |
13003 mode = 'AUTO', |
|
13004 tagName, |
|
13005 preserveWhiteSpace |
|
13006 } = _ref; |
|
13007 // First of all, strip any meta tags. |
15090 // First of all, strip any meta tags. |
13008 HTML = HTML.replace(/<meta[^>]+>/g, ''); // Strip Windows markers. |
15091 HTML = HTML.replace(/<meta[^>]+>/g, ''); |
13009 |
15092 // Strip Windows markers. |
13010 HTML = HTML.replace(/^\s*<html[^>]*>\s*<body[^>]*>(?:\s*<!--\s*StartFragment\s*-->)?/i, ''); |
15093 HTML = HTML.replace(/^\s*<html[^>]*>\s*<body[^>]*>(?:\s*<!--\s*StartFragment\s*-->)?/i, ''); |
13011 HTML = HTML.replace(/(?:<!--\s*EndFragment\s*-->\s*)?<\/body>\s*<\/html>\s*$/i, ''); // If we detect block delimiters in HTML, parse entirely as blocks. |
15094 HTML = HTML.replace(/(?:<!--\s*EndFragment\s*-->\s*)?<\/body>\s*<\/html>\s*$/i, ''); |
13012 |
15095 |
15096 // If we detect block delimiters in HTML, parse entirely as blocks. |
|
13013 if (mode !== 'INLINE') { |
15097 if (mode !== 'INLINE') { |
13014 // Check plain text if there is no HTML. |
15098 // Check plain text if there is no HTML. |
13015 const content = HTML ? HTML : plainText; |
15099 const content = HTML ? HTML : plainText; |
13016 |
|
13017 if (content.indexOf('<!-- wp:') !== -1) { |
15100 if (content.indexOf('<!-- wp:') !== -1) { |
13018 return parser_parse(content); |
15101 const parseResult = parser_parse(content); |
13019 } |
15102 const isSingleFreeFormBlock = parseResult.length === 1 && parseResult[0].name === 'core/freeform'; |
13020 } // Normalize unicode to use composed characters. |
15103 if (!isSingleFreeFormBlock) { |
15104 return parseResult; |
|
15105 } |
|
15106 } |
|
15107 } |
|
15108 |
|
15109 // Normalize unicode to use composed characters. |
|
13021 // This is unsupported in IE 11 but it's a nice-to-have feature, not mandatory. |
15110 // This is unsupported in IE 11 but it's a nice-to-have feature, not mandatory. |
13022 // Not normalizing the content will only affect older browsers and won't |
15111 // Not normalizing the content will only affect older browsers and won't |
13023 // entirely break the app. |
15112 // entirely break the app. |
13024 // See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize |
15113 // See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize |
13025 // See: https://core.trac.wordpress.org/ticket/30130 |
15114 // See: https://core.trac.wordpress.org/ticket/30130 |
13026 // See: https://github.com/WordPress/gutenberg/pull/6983#pullrequestreview-125151075 |
15115 // See: https://github.com/WordPress/gutenberg/pull/6983#pullrequestreview-125151075 |
13027 |
|
13028 |
|
13029 if (String.prototype.normalize) { |
15116 if (String.prototype.normalize) { |
13030 HTML = HTML.normalize(); |
15117 HTML = HTML.normalize(); |
13031 } // Parse Markdown (and encoded HTML) if: |
15118 } |
15119 |
|
15120 // Must be run before checking if it's inline content. |
|
15121 HTML = deepFilterHTML(HTML, [slackParagraphCorrector]); |
|
15122 |
|
15123 // Consider plain text if: |
|
13032 // * There is a plain text version. |
15124 // * There is a plain text version. |
13033 // * There is no HTML version, or it has no formatting. |
15125 // * There is no HTML version, or it has no formatting. |
13034 |
15126 const isPlainText = plainText && (!HTML || isPlain(HTML)); |
13035 |
15127 |
13036 if (plainText && (!HTML || isPlain(HTML))) { |
15128 // Parse Markdown (and encoded HTML) if it's considered plain text. |
13037 HTML = plainText; // The markdown converter (Showdown) trims whitespace. |
15129 if (isPlainText) { |
13038 |
15130 HTML = plainText; |
15131 |
|
15132 // The markdown converter (Showdown) trims whitespace. |
|
13039 if (!/^\s+$/.test(plainText)) { |
15133 if (!/^\s+$/.test(plainText)) { |
13040 HTML = markdownConverter(HTML); |
15134 HTML = markdownConverter(HTML); |
13041 } // Switch to inline mode if: |
15135 } |
15136 } |
|
15137 |
|
15138 // An array of HTML strings and block objects. The blocks replace matched |
|
15139 // shortcodes. |
|
15140 const pieces = shortcode_converter(HTML); |
|
15141 |
|
15142 // The call to shortcodeConverter will always return more than one element |
|
15143 // if shortcodes are matched. The reason is when shortcodes are matched |
|
15144 // empty HTML strings are included. |
|
15145 const hasShortcodes = pieces.length > 1; |
|
15146 if (isPlainText && !hasShortcodes) { |
|
15147 // Switch to inline mode if: |
|
13042 // * The current mode is AUTO. |
15148 // * The current mode is AUTO. |
13043 // * The original plain text had no line breaks. |
15149 // * The original plain text had no line breaks. |
13044 // * The original plain text was not an HTML paragraph. |
15150 // * The original plain text was not an HTML paragraph. |
13045 // * The converted text is just a paragraph. |
15151 // * The converted text is just a paragraph. |
13046 |
|
13047 |
|
13048 if (mode === 'AUTO' && plainText.indexOf('\n') === -1 && plainText.indexOf('<p>') !== 0 && HTML.indexOf('<p>') === 0) { |
15152 if (mode === 'AUTO' && plainText.indexOf('\n') === -1 && plainText.indexOf('<p>') !== 0 && HTML.indexOf('<p>') === 0) { |
13049 mode = 'INLINE'; |
15153 mode = 'INLINE'; |
13050 } |
15154 } |
13051 } |
15155 } |
13052 |
|
13053 if (mode === 'INLINE') { |
15156 if (mode === 'INLINE') { |
13054 return filterInlineHTML(HTML, preserveWhiteSpace); |
15157 return filterInlineHTML(HTML); |
13055 } // An array of HTML strings and block objects. The blocks replace matched |
15158 } |
13056 // shortcodes. |
|
13057 |
|
13058 |
|
13059 const pieces = shortcode_converter(HTML); // The call to shortcodeConverter will always return more than one element |
|
13060 // if shortcodes are matched. The reason is when shortcodes are matched |
|
13061 // empty HTML strings are included. |
|
13062 |
|
13063 const hasShortcodes = pieces.length > 1; |
|
13064 |
|
13065 if (mode === 'AUTO' && !hasShortcodes && isInlineContent(HTML, tagName)) { |
15159 if (mode === 'AUTO' && !hasShortcodes && isInlineContent(HTML, tagName)) { |
13066 return filterInlineHTML(HTML, preserveWhiteSpace); |
15160 return filterInlineHTML(HTML); |
13067 } |
15161 } |
13068 |
|
13069 const phrasingContentSchema = (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)('paste'); |
15162 const phrasingContentSchema = (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)('paste'); |
13070 const blockContentSchema = getBlockContentSchema('paste'); |
15163 const blockContentSchema = getBlockContentSchema('paste'); |
13071 const blocks = (0,external_lodash_namespaceObject.compact)((0,external_lodash_namespaceObject.flatMap)(pieces, piece => { |
15164 const blocks = pieces.map(piece => { |
13072 // Already a block from shortcode. |
15165 // Already a block from shortcode. |
13073 if (typeof piece !== 'string') { |
15166 if (typeof piece !== 'string') { |
13074 return piece; |
15167 return piece; |
13075 } |
15168 } |
13076 |
15169 const filters = [googleDocsUIdRemover, msListConverter, headRemover, listReducer, imageCorrector, phrasingContentReducer, specialCommentConverter, commentRemover, iframeRemover, figureContentReducer, blockquoteNormaliser(), divNormaliser]; |
13077 const filters = [googleDocsUIdRemover, msListConverter, headRemover, listReducer, imageCorrector, phrasingContentReducer, specialCommentConverter, commentRemover, iframeRemover, figureContentReducer, blockquoteNormaliser, divNormaliser]; |
15170 const schema = { |
13078 const schema = { ...blockContentSchema, |
15171 ...blockContentSchema, |
13079 // Keep top-level phrasing content, normalised by `normaliseBlocks`. |
15172 // Keep top-level phrasing content, normalised by `normaliseBlocks`. |
13080 ...phrasingContentSchema |
15173 ...phrasingContentSchema |
13081 }; |
15174 }; |
13082 piece = deepFilterHTML(piece, filters, blockContentSchema); |
15175 piece = deepFilterHTML(piece, filters, blockContentSchema); |
13083 piece = (0,external_wp_dom_namespaceObject.removeInvalidHTML)(piece, schema); |
15176 piece = (0,external_wp_dom_namespaceObject.removeInvalidHTML)(piece, schema); |
13084 piece = normaliseBlocks(piece); |
15177 piece = normaliseBlocks(piece); |
13085 piece = deepFilterHTML(piece, [htmlFormattingRemover, brRemover, emptyParagraphRemover], blockContentSchema); // Allows us to ask for this information when we get a report. |
15178 piece = deepFilterHTML(piece, [htmlFormattingRemover, brRemover, emptyParagraphRemover], blockContentSchema); |
13086 |
15179 |
13087 paste_handler_console.log('Processed HTML piece:\n\n', piece); |
15180 // Allows us to ask for this information when we get a report. |
13088 return htmlToBlocks(piece); |
15181 log('Processed HTML piece:\n\n', piece); |
13089 })); // If we're allowed to return inline content, and there is only one |
15182 return htmlToBlocks(piece, pasteHandler); |
15183 }).flat().filter(Boolean); |
|
15184 |
|
15185 // If we're allowed to return inline content, and there is only one |
|
13090 // inlineable block, and the original plain text content does not have any |
15186 // inlineable block, and the original plain text content does not have any |
13091 // line breaks, then treat it as inline paste. |
15187 // line breaks, then treat it as inline paste. |
13092 |
15188 if (mode === 'AUTO' && blocks.length === 1 && hasBlockSupport(blocks[0].name, '__unstablePasteTextInline', false)) { |
13093 if (mode === 'AUTO' && blocks.length === 1 && registration_hasBlockSupport(blocks[0].name, '__unstablePasteTextInline', false)) { |
15189 const trimRegex = /^[\n]+|[\n]+$/g; |
13094 // Don't catch line breaks at the start or end. |
15190 // Don't catch line breaks at the start or end. |
13095 const trimmedPlainText = plainText.replace(/^[\n]+|[\n]+$/g, ''); |
15191 const trimmedPlainText = plainText.replace(trimRegex, ''); |
13096 |
|
13097 if (trimmedPlainText !== '' && trimmedPlainText.indexOf('\n') === -1) { |
15192 if (trimmedPlainText !== '' && trimmedPlainText.indexOf('\n') === -1) { |
13098 return (0,external_wp_dom_namespaceObject.removeInvalidHTML)(getBlockInnerHTML(blocks[0]), phrasingContentSchema); |
15193 return (0,external_wp_dom_namespaceObject.removeInvalidHTML)(getBlockInnerHTML(blocks[0]), phrasingContentSchema).replace(trimRegex, ''); |
13099 } |
15194 } |
13100 } |
15195 } |
13101 |
|
13102 return blocks; |
15196 return blocks; |
13103 } |
15197 } |
13104 |
15198 |
13105 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/categories.js |
15199 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/categories.js |
13106 /** |
15200 /** |
13107 * WordPress dependencies |
15201 * WordPress dependencies |
13108 */ |
15202 */ |
13109 |
15203 |
15204 |
|
13110 /** |
15205 /** |
13111 * Internal dependencies |
15206 * Internal dependencies |
13112 */ |
15207 */ |
13113 |
15208 |
13114 |
15209 |
13115 /** @typedef {import('../store/reducer').WPBlockCategory} WPBlockCategory */ |
15210 /** @typedef {import('../store/reducer').WPBlockCategory} WPBlockCategory */ |
13116 |
15211 |
13117 /** |
15212 /** |
13118 * Returns all the block categories. |
15213 * Returns all the block categories. |
15214 * Ignored from documentation as the recommended usage is via useSelect from @wordpress/data. |
|
15215 * |
|
15216 * @ignore |
|
13119 * |
15217 * |
13120 * @return {WPBlockCategory[]} Block categories. |
15218 * @return {WPBlockCategory[]} Block categories. |
13121 */ |
15219 */ |
13122 |
|
13123 function categories_getCategories() { |
15220 function categories_getCategories() { |
13124 return (0,external_wp_data_namespaceObject.select)(store).getCategories(); |
15221 return (0,external_wp_data_namespaceObject.select)(store).getCategories(); |
13125 } |
15222 } |
15223 |
|
13126 /** |
15224 /** |
13127 * Sets the block categories. |
15225 * Sets the block categories. |
13128 * |
15226 * |
13129 * @param {WPBlockCategory[]} categories Block categories. |
15227 * @param {WPBlockCategory[]} categories Block categories. |
13130 */ |
15228 * |
13131 |
15229 * @example |
15230 * ```js |
|
15231 * import { __ } from '@wordpress/i18n'; |
|
15232 * import { store as blocksStore, setCategories } from '@wordpress/blocks'; |
|
15233 * import { useSelect } from '@wordpress/data'; |
|
15234 * import { Button } from '@wordpress/components'; |
|
15235 * |
|
15236 * const ExampleComponent = () => { |
|
15237 * // Retrieve the list of current categories. |
|
15238 * const blockCategories = useSelect( |
|
15239 * ( select ) => select( blocksStore ).getCategories(), |
|
15240 * [] |
|
15241 * ); |
|
15242 * |
|
15243 * return ( |
|
15244 * <Button |
|
15245 * onClick={ () => { |
|
15246 * // Add a custom category to the existing list. |
|
15247 * setCategories( [ |
|
15248 * ...blockCategories, |
|
15249 * { title: 'Custom Category', slug: 'custom-category' }, |
|
15250 * ] ); |
|
15251 * } } |
|
15252 * > |
|
15253 * { __( 'Add a new custom block category' ) } |
|
15254 * </Button> |
|
15255 * ); |
|
15256 * }; |
|
15257 * ``` |
|
15258 */ |
|
13132 function categories_setCategories(categories) { |
15259 function categories_setCategories(categories) { |
13133 (0,external_wp_data_namespaceObject.dispatch)(store).setCategories(categories); |
15260 (0,external_wp_data_namespaceObject.dispatch)(store).setCategories(categories); |
13134 } |
15261 } |
15262 |
|
13135 /** |
15263 /** |
13136 * Updates a category. |
15264 * Updates a category. |
13137 * |
15265 * |
13138 * @param {string} slug Block category slug. |
15266 * @param {string} slug Block category slug. |
13139 * @param {WPBlockCategory} category Object containing the category properties |
15267 * @param {WPBlockCategory} category Object containing the category properties |
13140 * that should be updated. |
15268 * that should be updated. |
13141 */ |
15269 * |
13142 |
15270 * @example |
15271 * ```js |
|
15272 * import { __ } from '@wordpress/i18n'; |
|
15273 * import { updateCategory } from '@wordpress/blocks'; |
|
15274 * import { Button } from '@wordpress/components'; |
|
15275 * |
|
15276 * const ExampleComponent = () => { |
|
15277 * return ( |
|
15278 * <Button |
|
15279 * onClick={ () => { |
|
15280 * updateCategory( 'text', { title: __( 'Written Word' ) } ); |
|
15281 * } } |
|
15282 * > |
|
15283 * { __( 'Update Text category title' ) } |
|
15284 * </Button> |
|
15285 * ) ; |
|
15286 * }; |
|
15287 * ``` |
|
15288 */ |
|
13143 function categories_updateCategory(slug, category) { |
15289 function categories_updateCategory(slug, category) { |
13144 (0,external_wp_data_namespaceObject.dispatch)(store).updateCategory(slug, category); |
15290 (0,external_wp_data_namespaceObject.dispatch)(store).updateCategory(slug, category); |
13145 } |
15291 } |
13146 |
15292 |
13147 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/templates.js |
15293 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/templates.js |
13148 /** |
15294 /** |
13149 * External dependencies |
|
13150 */ |
|
13151 |
|
13152 /** |
|
13153 * WordPress dependencies |
15295 * WordPress dependencies |
13154 */ |
15296 */ |
13155 |
15297 |
13156 |
15298 |
13157 /** |
15299 /** |
13167 * @param {Array} blocks Block list. |
15309 * @param {Array} blocks Block list. |
13168 * @param {Array} template Block template. |
15310 * @param {Array} template Block template. |
13169 * |
15311 * |
13170 * @return {boolean} Whether the list of blocks matches a templates. |
15312 * @return {boolean} Whether the list of blocks matches a templates. |
13171 */ |
15313 */ |
13172 |
15314 function doBlocksMatchTemplate(blocks = [], template = []) { |
13173 function doBlocksMatchTemplate() { |
15315 return blocks.length === template.length && template.every(([name,, innerBlocksTemplate], index) => { |
13174 let blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
|
13175 let template = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; |
|
13176 return blocks.length === template.length && (0,external_lodash_namespaceObject.every)(template, (_ref, index) => { |
|
13177 let [name,, innerBlocksTemplate] = _ref; |
|
13178 const block = blocks[index]; |
15316 const block = blocks[index]; |
13179 return name === block.name && doBlocksMatchTemplate(block.innerBlocks, innerBlocksTemplate); |
15317 return name === block.name && doBlocksMatchTemplate(block.innerBlocks, innerBlocksTemplate); |
13180 }); |
15318 }); |
13181 } |
15319 } |
15320 const isHTMLAttribute = attributeDefinition => attributeDefinition?.source === 'html'; |
|
15321 const isQueryAttribute = attributeDefinition => attributeDefinition?.source === 'query'; |
|
15322 function normalizeAttributes(schema, values) { |
|
15323 if (!values) { |
|
15324 return {}; |
|
15325 } |
|
15326 return Object.fromEntries(Object.entries(values).map(([key, value]) => [key, normalizeAttribute(schema[key], value)])); |
|
15327 } |
|
15328 function normalizeAttribute(definition, value) { |
|
15329 if (isHTMLAttribute(definition) && Array.isArray(value)) { |
|
15330 // Introduce a deprecated call at this point |
|
15331 // When we're confident that "children" format should be removed from the templates. |
|
15332 |
|
15333 return (0,external_wp_element_namespaceObject.renderToString)(value); |
|
15334 } |
|
15335 if (isQueryAttribute(definition) && value) { |
|
15336 return value.map(subValues => { |
|
15337 return normalizeAttributes(definition.query, subValues); |
|
15338 }); |
|
15339 } |
|
15340 return value; |
|
15341 } |
|
15342 |
|
13182 /** |
15343 /** |
13183 * Synchronize a block list with a block template. |
15344 * Synchronize a block list with a block template. |
13184 * |
15345 * |
13185 * Synchronizing a block list with a block template means that we loop over the blocks |
15346 * Synchronizing a block list with a block template means that we loop over the blocks |
13186 * keep the block as is if it matches the block at the same position in the template |
15347 * keep the block as is if it matches the block at the same position in the template |
13190 * @param {Array} blocks Block list. |
15351 * @param {Array} blocks Block list. |
13191 * @param {Array} template Block template. |
15352 * @param {Array} template Block template. |
13192 * |
15353 * |
13193 * @return {Array} Updated Block list. |
15354 * @return {Array} Updated Block list. |
13194 */ |
15355 */ |
13195 |
15356 function synchronizeBlocksWithTemplate(blocks = [], template) { |
13196 function synchronizeBlocksWithTemplate() { |
|
13197 let blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
|
13198 let template = arguments.length > 1 ? arguments[1] : undefined; |
|
13199 |
|
13200 // If no template is provided, return blocks unmodified. |
15357 // If no template is provided, return blocks unmodified. |
13201 if (!template) { |
15358 if (!template) { |
13202 return blocks; |
15359 return blocks; |
13203 } |
15360 } |
13204 |
15361 return template.map(([name, attributes, innerBlocksTemplate], index) => { |
13205 return (0,external_lodash_namespaceObject.map)(template, (_ref2, index) => { |
15362 var _blockType$attributes; |
13206 let [name, attributes, innerBlocksTemplate] = _ref2; |
|
13207 const block = blocks[index]; |
15363 const block = blocks[index]; |
13208 |
|
13209 if (block && block.name === name) { |
15364 if (block && block.name === name) { |
13210 const innerBlocks = synchronizeBlocksWithTemplate(block.innerBlocks, innerBlocksTemplate); |
15365 const innerBlocks = synchronizeBlocksWithTemplate(block.innerBlocks, innerBlocksTemplate); |
13211 return { ...block, |
15366 return { |
15367 ...block, |
|
13212 innerBlocks |
15368 innerBlocks |
13213 }; |
15369 }; |
13214 } // To support old templates that were using the "children" format |
15370 } |
15371 |
|
15372 // To support old templates that were using the "children" format |
|
13215 // for the attributes using "html" strings now, we normalize the template attributes |
15373 // for the attributes using "html" strings now, we normalize the template attributes |
13216 // before creating the blocks. |
15374 // before creating the blocks. |
13217 |
15375 |
13218 |
15376 const blockType = getBlockType(name); |
13219 const blockType = registration_getBlockType(name); |
15377 const normalizedAttributes = normalizeAttributes((_blockType$attributes = blockType?.attributes) !== null && _blockType$attributes !== void 0 ? _blockType$attributes : {}, attributes); |
13220 |
15378 let [blockName, blockAttributes] = convertLegacyBlockNameAndAttributes(name, normalizedAttributes); |
13221 const isHTMLAttribute = attributeDefinition => (0,external_lodash_namespaceObject.get)(attributeDefinition, ['source']) === 'html'; |
15379 |
13222 |
15380 // If a Block is undefined at this point, use the core/missing block as |
13223 const isQueryAttribute = attributeDefinition => (0,external_lodash_namespaceObject.get)(attributeDefinition, ['source']) === 'query'; |
|
13224 |
|
13225 const normalizeAttributes = (schema, values) => { |
|
13226 return (0,external_lodash_namespaceObject.mapValues)(values, (value, key) => { |
|
13227 return normalizeAttribute(schema[key], value); |
|
13228 }); |
|
13229 }; |
|
13230 |
|
13231 const normalizeAttribute = (definition, value) => { |
|
13232 if (isHTMLAttribute(definition) && (0,external_lodash_namespaceObject.isArray)(value)) { |
|
13233 // Introduce a deprecated call at this point |
|
13234 // When we're confident that "children" format should be removed from the templates. |
|
13235 return (0,external_wp_element_namespaceObject.renderToString)(value); |
|
13236 } |
|
13237 |
|
13238 if (isQueryAttribute(definition) && value) { |
|
13239 return value.map(subValues => { |
|
13240 return normalizeAttributes(definition.query, subValues); |
|
13241 }); |
|
13242 } |
|
13243 |
|
13244 return value; |
|
13245 }; |
|
13246 |
|
13247 const normalizedAttributes = normalizeAttributes((0,external_lodash_namespaceObject.get)(blockType, ['attributes'], {}), attributes); |
|
13248 let [blockName, blockAttributes] = convertLegacyBlockNameAndAttributes(name, normalizedAttributes); // If a Block is undefined at this point, use the core/missing block as |
|
13249 // a placeholder for a better user experience. |
15381 // a placeholder for a better user experience. |
13250 |
15382 if (undefined === getBlockType(blockName)) { |
13251 if (undefined === registration_getBlockType(blockName)) { |
|
13252 blockAttributes = { |
15383 blockAttributes = { |
13253 originalName: name, |
15384 originalName: name, |
13254 originalContent: '', |
15385 originalContent: '', |
13255 originalUndelimitedContent: '' |
15386 originalUndelimitedContent: '' |
13256 }; |
15387 }; |
13257 blockName = 'core/missing'; |
15388 blockName = 'core/missing'; |
13258 } |
15389 } |
13259 |
|
13260 return createBlock(blockName, blockAttributes, synchronizeBlocksWithTemplate([], innerBlocksTemplate)); |
15390 return createBlock(blockName, blockAttributes, synchronizeBlocksWithTemplate([], innerBlocksTemplate)); |
13261 }); |
15391 }); |
13262 } |
15392 } |
13263 |
15393 |
13264 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/index.js |
15394 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/index.js |
13266 // all aspects of the block configuration and its interfaces, including `edit` |
15396 // all aspects of the block configuration and its interfaces, including `edit` |
13267 // and `save`. The transforms specification allows converting one blocktype to |
15397 // and `save`. The transforms specification allows converting one blocktype to |
13268 // another through formulas defined by either the source or the destination. |
15398 // another through formulas defined by either the source or the destination. |
13269 // Switching a blocktype is to be considered a one-way operation implying a |
15399 // Switching a blocktype is to be considered a one-way operation implying a |
13270 // transformation in the opposite way has to be handled explicitly. |
15400 // transformation in the opposite way has to be handled explicitly. |
13271 // The block tree is composed of a collection of block nodes. Blocks contained |
15401 |
15402 |
|
15403 // The block tree is composed of a collection of block nodes. Blocks contained |
|
13272 // within other blocks are called inner blocks. An important design |
15404 // within other blocks are called inner blocks. An important design |
13273 // consideration is that inner blocks are -- conceptually -- not part of the |
15405 // consideration is that inner blocks are -- conceptually -- not part of the |
13274 // territory established by the parent block that contains them. |
15406 // territory established by the parent block that contains them. |
13275 // |
15407 // |
13276 // This has multiple practical implications: when parsing, we can safely dispose |
15408 // This has multiple practical implications: when parsing, we can safely dispose |
13286 // components whose mechanisms can be shielded from the `edit` implementation |
15418 // components whose mechanisms can be shielded from the `edit` implementation |
13287 // and just passed along. |
15419 // and just passed along. |
13288 |
15420 |
13289 |
15421 |
13290 |
15422 |
13291 // While block transformations account for a specific surface of the API, there |
15423 |
15424 // While block transformations account for a specific surface of the API, there |
|
13292 // are also raw transformations which handle arbitrary sources not made out of |
15425 // are also raw transformations which handle arbitrary sources not made out of |
13293 // blocks but producing block basaed on various heursitics. This includes |
15426 // blocks but producing block basaed on various heursitics. This includes |
13294 // pasting rich text or HTML data. |
15427 // pasting rich text or HTML data. |
13295 |
15428 |
13296 // The process of serialization aims to deflate the internal memory of the block |
15429 |
15430 // The process of serialization aims to deflate the internal memory of the block |
|
13297 // editor and its state representation back into an HTML valid string. This |
15431 // editor and its state representation back into an HTML valid string. This |
13298 // process restores the document integrity and inserts invisible delimiters |
15432 // process restores the document integrity and inserts invisible delimiters |
13299 // around each block with HTML comment boundaries which can contain any extra |
15433 // around each block with HTML comment boundaries which can contain any extra |
13300 // attributes needed to operate with the block later on. |
15434 // attributes needed to operate with the block later on. |
13301 |
15435 |
13302 // Validation is the process of comparing a block source with its output before |
15436 |
15437 // Validation is the process of comparing a block source with its output before |
|
13303 // there is any user input or interaction with a block. When this operation |
15438 // there is any user input or interaction with a block. When this operation |
13304 // fails -- for whatever reason -- the block is to be considered invalid. As |
15439 // fails -- for whatever reason -- the block is to be considered invalid. As |
13305 // part of validating a block the system will attempt to run the source against |
15440 // part of validating a block the system will attempt to run the source against |
13306 // any provided deprecation definitions. |
15441 // any provided deprecation definitions. |
13307 // |
15442 // |
13321 // they will be run for all valid and invalid blocks alike. However, once a |
15456 // they will be run for all valid and invalid blocks alike. However, once a |
13322 // block is detected as invalid -- failing the three first steps -- it is |
15457 // block is detected as invalid -- failing the three first steps -- it is |
13323 // adequate to spend more time determining validity before throwing a conflict. |
15458 // adequate to spend more time determining validity before throwing a conflict. |
13324 |
15459 |
13325 |
15460 |
13326 // Blocks are inherently indifferent about where the data they operate with ends |
15461 |
15462 // Blocks are inherently indifferent about where the data they operate with ends |
|
13327 // up being saved. For example, all blocks can have a static and dynamic aspect |
15463 // up being saved. For example, all blocks can have a static and dynamic aspect |
13328 // to them depending on the needs. The static nature of a block is the `save()` |
15464 // to them depending on the needs. The static nature of a block is the `save()` |
13329 // definition that is meant to be serialized into HTML and which can be left |
15465 // definition that is meant to be serialized into HTML and which can be left |
13330 // void. Any block can also register a `render_callback` on the server, which |
15466 // void. Any block can also register a `render_callback` on the server, which |
13331 // makes its output dynamic either in part or in its totality. |
15467 // makes its output dynamic either in part or in its totality. |
13339 // blocks. The addition of parent–child would be a subset of the inner block |
15475 // blocks. The addition of parent–child would be a subset of the inner block |
13340 // functionality under the premise that certain blocks only make sense as |
15476 // functionality under the premise that certain blocks only make sense as |
13341 // children of another block. |
15477 // children of another block. |
13342 |
15478 |
13343 |
15479 |
13344 // Templates are, in a general sense, a basic collection of block nodes with any |
15480 |
15481 // Templates are, in a general sense, a basic collection of block nodes with any |
|
13345 // given set of predefined attributes that are supplied as the initial state of |
15482 // given set of predefined attributes that are supplied as the initial state of |
13346 // an inner blocks group. These nodes can, in turn, contain any number of nested |
15483 // an inner blocks group. These nodes can, in turn, contain any number of nested |
13347 // blocks within their definition. Templates allow both to specify a default |
15484 // blocks within their definition. Templates allow both to specify a default |
13348 // state for an editor session or a default set of blocks for any inner block |
15485 // state for an editor session or a default set of blocks for any inner block |
13349 // implementation within a specific block. |
15486 // implementation within a specific block. |
13350 |
15487 |
13351 |
15488 |
13352 |
15489 |
13353 |
15490 |
13354 |
15491 |
13355 |
15492 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/deprecated.js |
13356 ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js |
|
13357 function _extends() { |
|
13358 _extends = Object.assign ? Object.assign.bind() : function (target) { |
|
13359 for (var i = 1; i < arguments.length; i++) { |
|
13360 var source = arguments[i]; |
|
13361 |
|
13362 for (var key in source) { |
|
13363 if (Object.prototype.hasOwnProperty.call(source, key)) { |
|
13364 target[key] = source[key]; |
|
13365 } |
|
13366 } |
|
13367 } |
|
13368 |
|
13369 return target; |
|
13370 }; |
|
13371 return _extends.apply(this, arguments); |
|
13372 } |
|
13373 ;// CONCATENATED MODULE: external ["wp","compose"] |
|
13374 var external_wp_compose_namespaceObject = window["wp"]["compose"]; |
|
13375 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/block-content-provider/index.js |
|
13376 |
|
13377 |
|
13378 |
|
13379 /** |
15493 /** |
13380 * WordPress dependencies |
15494 * WordPress dependencies |
13381 */ |
15495 */ |
13382 |
15496 |
13383 |
15497 |
13384 /** |
|
13385 * Internal dependencies |
|
13386 */ |
|
13387 |
|
13388 |
|
13389 const { |
|
13390 Consumer, |
|
13391 Provider |
|
13392 } = (0,external_wp_element_namespaceObject.createContext)(() => {}); |
|
13393 /** |
|
13394 * An internal block component used in block content serialization to inject |
|
13395 * nested block content within the `save` implementation of the ancestor |
|
13396 * component in which it is nested. The component provides a pre-bound |
|
13397 * `BlockContent` component via context, which is used by the developer-facing |
|
13398 * `InnerBlocks.Content` component to render block content. |
|
13399 * |
|
13400 * @example |
|
13401 * |
|
13402 * ```jsx |
|
13403 * <BlockContentProvider innerBlocks={ innerBlocks }> |
|
13404 * { blockSaveElement } |
|
13405 * </BlockContentProvider> |
|
13406 * ``` |
|
13407 * |
|
13408 * @param {Object} props Component props. |
|
13409 * @param {WPElement} props.children Block save result. |
|
13410 * @param {Array} props.innerBlocks Block(s) to serialize. |
|
13411 * |
|
13412 * @return {WPComponent} Element with BlockContent injected via context. |
|
13413 */ |
|
13414 |
|
13415 const BlockContentProvider = _ref => { |
|
13416 let { |
|
13417 children, |
|
13418 innerBlocks |
|
13419 } = _ref; |
|
13420 |
|
13421 const BlockContent = () => { |
|
13422 // Value is an array of blocks, so defer to block serializer. |
|
13423 const html = serialize(innerBlocks, { |
|
13424 isInnerBlocks: true |
|
13425 }); // Use special-cased raw HTML tag to avoid default escaping |
|
13426 |
|
13427 return createElement(RawHTML, null, html); |
|
13428 }; |
|
13429 |
|
13430 return createElement(Provider, { |
|
13431 value: BlockContent |
|
13432 }, children); |
|
13433 }; |
|
13434 /** |
15498 /** |
13435 * A Higher Order Component used to inject BlockContent using context to the |
15499 * A Higher Order Component used to inject BlockContent using context to the |
13436 * wrapped component. |
15500 * wrapped component. |
13437 * |
15501 * |
13438 * @return {WPComponent} Enhanced component with injected BlockContent as prop. |
15502 * @deprecated |
13439 */ |
15503 * |
13440 |
15504 * @param {Component} OriginalComponent The component to enhance. |
13441 |
15505 * @return {Component} The same component. |
13442 const withBlockContentContext = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(OriginalComponent => { |
15506 */ |
13443 return props => (0,external_wp_element_namespaceObject.createElement)(Consumer, null, context => (0,external_wp_element_namespaceObject.createElement)(OriginalComponent, _extends({}, props, { |
15507 function withBlockContentContext(OriginalComponent) { |
13444 BlockContent: context |
15508 external_wp_deprecated_default()('wp.blocks.withBlockContentContext', { |
13445 }))); |
15509 since: '6.1' |
13446 }, 'withBlockContentContext'); |
15510 }); |
13447 /* harmony default export */ var block_content_provider = ((/* unused pure expression or super */ null && (BlockContentProvider))); |
15511 return OriginalComponent; |
15512 } |
|
13448 |
15513 |
13449 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/index.js |
15514 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/index.js |
13450 // A "block" is the abstract term used to describe units of markup that, |
15515 // A "block" is the abstract term used to describe units of markup that, |
13451 // when composed together, form the content or layout of a page. |
15516 // when composed together, form the content or layout of a page. |
13452 // The API for blocks is exposed via `wp.blocks`. |
15517 // The API for blocks is exposed via `wp.blocks`. |
13458 // and then stored as objects in state, from which it is then rendered for editing. |
15523 // and then stored as objects in state, from which it is then rendered for editing. |
13459 |
15524 |
13460 |
15525 |
13461 |
15526 |
13462 |
15527 |
13463 }(); |
15528 |
15529 })(); |
|
15530 |
|
13464 (window.wp = window.wp || {}).blocks = __webpack_exports__; |
15531 (window.wp = window.wp || {}).blocks = __webpack_exports__; |
13465 /******/ })() |
15532 /******/ })() |
13466 ; |
15533 ; |