--- a/wp/wp-includes/js/dist/blocks.js Thu Sep 29 08:06:27 2022 +0200
+++ b/wp/wp-includes/js/dist/blocks.js Fri Sep 05 18:40:08 2025 +0200
@@ -1,175 +1,611 @@
-/******/ (function() { // webpackBootstrap
+/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
-/***/ 9756:
-/***/ (function(module) {
-
-/**
- * Memize options object.
- *
- * @typedef MemizeOptions
- *
- * @property {number} [maxSize] Maximum size of the cache.
- */
-
-/**
- * Internal cache entry.
- *
- * @typedef MemizeCacheNode
- *
- * @property {?MemizeCacheNode|undefined} [prev] Previous node.
- * @property {?MemizeCacheNode|undefined} [next] Next node.
- * @property {Array<*>} args Function arguments for cache
- * entry.
- * @property {*} val Function result.
- */
-
-/**
- * Properties of the enhanced function for controlling cache.
- *
- * @typedef MemizeMemoizedFunction
- *
- * @property {()=>void} clear Clear the cache.
- */
-
-/**
- * Accepts a function to be memoized, and returns a new memoized function, with
- * optional options.
- *
- * @template {Function} F
- *
- * @param {F} fn Function to memoize.
- * @param {MemizeOptions} [options] Options object.
- *
- * @return {F & MemizeMemoizedFunction} Memoized function.
- */
-function memize( fn, options ) {
- var size = 0;
-
- /** @type {?MemizeCacheNode|undefined} */
- var head;
-
- /** @type {?MemizeCacheNode|undefined} */
- var tail;
-
- options = options || {};
-
- function memoized( /* ...args */ ) {
- var node = head,
- len = arguments.length,
- args, i;
-
- searchCache: while ( node ) {
- // Perform a shallow equality test to confirm that whether the node
- // under test is a candidate for the arguments passed. Two arrays
- // are shallowly equal if their length matches and each entry is
- // strictly equal between the two sets. Avoid abstracting to a
- // function which could incur an arguments leaking deoptimization.
-
- // Check whether node arguments match arguments length
- if ( node.args.length !== arguments.length ) {
- node = node.next;
- continue;
- }
-
- // Check whether node arguments match arguments values
- for ( i = 0; i < len; i++ ) {
- if ( node.args[ i ] !== arguments[ i ] ) {
- node = node.next;
- continue searchCache;
- }
- }
-
- // At this point we can assume we've found a match
-
- // Surface matched node to head if not already
- if ( node !== head ) {
- // As tail, shift to previous. Must only shift if not also
- // head, since if both head and tail, there is no previous.
- if ( node === tail ) {
- tail = node.prev;
- }
-
- // Adjust siblings to point to each other. If node was tail,
- // this also handles new tail's empty `next` assignment.
- /** @type {MemizeCacheNode} */ ( node.prev ).next = node.next;
- if ( node.next ) {
- node.next.prev = node.prev;
- }
-
- node.next = head;
- node.prev = null;
- /** @type {MemizeCacheNode} */ ( head ).prev = node;
- head = node;
- }
-
- // Return immediately
- return node.val;
- }
-
- // No cached value found. Continue to insertion phase:
-
- // Create a copy of arguments (avoid leaking deoptimization)
- args = new Array( len );
- for ( i = 0; i < len; i++ ) {
- args[ i ] = arguments[ i ];
- }
-
- node = {
- args: args,
-
- // Generate the result from original function
- val: fn.apply( null, args ),
- };
-
- // Don't need to check whether node is already head, since it would
- // have been returned above already if it was
-
- // Shift existing head down list
- if ( head ) {
- head.prev = node;
- node.next = head;
- } else {
- // If no head, follows that there's no tail (at initial or reset)
- tail = node;
- }
-
- // Trim tail if we're reached max size and are pending cache insertion
- if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) {
- tail = /** @type {MemizeCacheNode} */ ( tail ).prev;
- /** @type {MemizeCacheNode} */ ( tail ).next = null;
- } else {
- size++;
- }
-
- head = node;
-
- return node.val;
- }
-
- memoized.clear = function() {
- head = null;
- tail = null;
- size = 0;
- };
-
- if ( false ) {}
-
- // Ignore reason: There's not a clear solution to create an intersection of
- // the function with additional properties, where the goal is to retain the
- // function signature of the incoming argument and add control properties
- // on the return value.
-
- // @ts-ignore
- return memoized;
-}
-
-module.exports = memize;
+/***/ 7734:
+/***/ ((module) => {
+
+"use strict";
+
+
+// do not edit .js files directly - edit src/index.jst
+
+
+ var envHasBigInt64Array = typeof BigInt64Array !== 'undefined';
+
+
+module.exports = function equal(a, b) {
+ if (a === b) return true;
+
+ if (a && b && typeof a == 'object' && typeof b == 'object') {
+ if (a.constructor !== b.constructor) return false;
+
+ var length, i, keys;
+ if (Array.isArray(a)) {
+ length = a.length;
+ if (length != b.length) return false;
+ for (i = length; i-- !== 0;)
+ if (!equal(a[i], b[i])) return false;
+ return true;
+ }
+
+
+ if ((a instanceof Map) && (b instanceof Map)) {
+ if (a.size !== b.size) return false;
+ for (i of a.entries())
+ if (!b.has(i[0])) return false;
+ for (i of a.entries())
+ if (!equal(i[1], b.get(i[0]))) return false;
+ return true;
+ }
+
+ if ((a instanceof Set) && (b instanceof Set)) {
+ if (a.size !== b.size) return false;
+ for (i of a.entries())
+ if (!b.has(i[0])) return false;
+ return true;
+ }
+
+ if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
+ length = a.length;
+ if (length != b.length) return false;
+ for (i = length; i-- !== 0;)
+ if (a[i] !== b[i]) return false;
+ return true;
+ }
+
+
+ if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
+ if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
+ if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
+
+ keys = Object.keys(a);
+ length = keys.length;
+ if (length !== Object.keys(b).length) return false;
+
+ for (i = length; i-- !== 0;)
+ if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
+
+ for (i = length; i-- !== 0;) {
+ var key = keys[i];
+
+ if (!equal(a[key], b[key])) return false;
+ }
+
+ return true;
+ }
+
+ // true if both NaN, false otherwise
+ return a!==a && b!==b;
+};
+
+
+/***/ }),
+
+/***/ 5373:
+/***/ ((__unused_webpack_module, exports) => {
+
+"use strict";
+var __webpack_unused_export__;
+/**
+ * @license React
+ * react-is.production.min.js
+ *
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+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");
+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;
+__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};
+__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};
+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;
+
+
+/***/ }),
+
+/***/ 8529:
+/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
+
+"use strict";
+
+
+if (true) {
+ module.exports = __webpack_require__(5373);
+} else {}
/***/ }),
-/***/ 7308:
+/***/ 9681:
+/***/ ((module) => {
+
+var characterMap = {
+ "À": "A",
+ "Á": "A",
+ "Â": "A",
+ "Ã": "A",
+ "Ä": "A",
+ "Å": "A",
+ "Ấ": "A",
+ "Ắ": "A",
+ "Ẳ": "A",
+ "Ẵ": "A",
+ "Ặ": "A",
+ "Æ": "AE",
+ "Ầ": "A",
+ "Ằ": "A",
+ "Ȃ": "A",
+ "Ả": "A",
+ "Ạ": "A",
+ "Ẩ": "A",
+ "Ẫ": "A",
+ "Ậ": "A",
+ "Ç": "C",
+ "Ḉ": "C",
+ "È": "E",
+ "É": "E",
+ "Ê": "E",
+ "Ë": "E",
+ "Ế": "E",
+ "Ḗ": "E",
+ "Ề": "E",
+ "Ḕ": "E",
+ "Ḝ": "E",
+ "Ȇ": "E",
+ "Ẻ": "E",
+ "Ẽ": "E",
+ "Ẹ": "E",
+ "Ể": "E",
+ "Ễ": "E",
+ "Ệ": "E",
+ "Ì": "I",
+ "Í": "I",
+ "Î": "I",
+ "Ï": "I",
+ "Ḯ": "I",
+ "Ȋ": "I",
+ "Ỉ": "I",
+ "Ị": "I",
+ "Ð": "D",
+ "Ñ": "N",
+ "Ò": "O",
+ "Ó": "O",
+ "Ô": "O",
+ "Õ": "O",
+ "Ö": "O",
+ "Ø": "O",
+ "Ố": "O",
+ "Ṍ": "O",
+ "Ṓ": "O",
+ "Ȏ": "O",
+ "Ỏ": "O",
+ "Ọ": "O",
+ "Ổ": "O",
+ "Ỗ": "O",
+ "Ộ": "O",
+ "Ờ": "O",
+ "Ở": "O",
+ "Ỡ": "O",
+ "Ớ": "O",
+ "Ợ": "O",
+ "Ù": "U",
+ "Ú": "U",
+ "Û": "U",
+ "Ü": "U",
+ "Ủ": "U",
+ "Ụ": "U",
+ "Ử": "U",
+ "Ữ": "U",
+ "Ự": "U",
+ "Ý": "Y",
+ "à": "a",
+ "á": "a",
+ "â": "a",
+ "ã": "a",
+ "ä": "a",
+ "å": "a",
+ "ấ": "a",
+ "ắ": "a",
+ "ẳ": "a",
+ "ẵ": "a",
+ "ặ": "a",
+ "æ": "ae",
+ "ầ": "a",
+ "ằ": "a",
+ "ȃ": "a",
+ "ả": "a",
+ "ạ": "a",
+ "ẩ": "a",
+ "ẫ": "a",
+ "ậ": "a",
+ "ç": "c",
+ "ḉ": "c",
+ "è": "e",
+ "é": "e",
+ "ê": "e",
+ "ë": "e",
+ "ế": "e",
+ "ḗ": "e",
+ "ề": "e",
+ "ḕ": "e",
+ "ḝ": "e",
+ "ȇ": "e",
+ "ẻ": "e",
+ "ẽ": "e",
+ "ẹ": "e",
+ "ể": "e",
+ "ễ": "e",
+ "ệ": "e",
+ "ì": "i",
+ "í": "i",
+ "î": "i",
+ "ï": "i",
+ "ḯ": "i",
+ "ȋ": "i",
+ "ỉ": "i",
+ "ị": "i",
+ "ð": "d",
+ "ñ": "n",
+ "ò": "o",
+ "ó": "o",
+ "ô": "o",
+ "õ": "o",
+ "ö": "o",
+ "ø": "o",
+ "ố": "o",
+ "ṍ": "o",
+ "ṓ": "o",
+ "ȏ": "o",
+ "ỏ": "o",
+ "ọ": "o",
+ "ổ": "o",
+ "ỗ": "o",
+ "ộ": "o",
+ "ờ": "o",
+ "ở": "o",
+ "ỡ": "o",
+ "ớ": "o",
+ "ợ": "o",
+ "ù": "u",
+ "ú": "u",
+ "û": "u",
+ "ü": "u",
+ "ủ": "u",
+ "ụ": "u",
+ "ử": "u",
+ "ữ": "u",
+ "ự": "u",
+ "ý": "y",
+ "ÿ": "y",
+ "Ā": "A",
+ "ā": "a",
+ "Ă": "A",
+ "ă": "a",
+ "Ą": "A",
+ "ą": "a",
+ "Ć": "C",
+ "ć": "c",
+ "Ĉ": "C",
+ "ĉ": "c",
+ "Ċ": "C",
+ "ċ": "c",
+ "Č": "C",
+ "č": "c",
+ "C̆": "C",
+ "c̆": "c",
+ "Ď": "D",
+ "ď": "d",
+ "Đ": "D",
+ "đ": "d",
+ "Ē": "E",
+ "ē": "e",
+ "Ĕ": "E",
+ "ĕ": "e",
+ "Ė": "E",
+ "ė": "e",
+ "Ę": "E",
+ "ę": "e",
+ "Ě": "E",
+ "ě": "e",
+ "Ĝ": "G",
+ "Ǵ": "G",
+ "ĝ": "g",
+ "ǵ": "g",
+ "Ğ": "G",
+ "ğ": "g",
+ "Ġ": "G",
+ "ġ": "g",
+ "Ģ": "G",
+ "ģ": "g",
+ "Ĥ": "H",
+ "ĥ": "h",
+ "Ħ": "H",
+ "ħ": "h",
+ "Ḫ": "H",
+ "ḫ": "h",
+ "Ĩ": "I",
+ "ĩ": "i",
+ "Ī": "I",
+ "ī": "i",
+ "Ĭ": "I",
+ "ĭ": "i",
+ "Į": "I",
+ "į": "i",
+ "İ": "I",
+ "ı": "i",
+ "IJ": "IJ",
+ "ij": "ij",
+ "Ĵ": "J",
+ "ĵ": "j",
+ "Ķ": "K",
+ "ķ": "k",
+ "Ḱ": "K",
+ "ḱ": "k",
+ "K̆": "K",
+ "k̆": "k",
+ "Ĺ": "L",
+ "ĺ": "l",
+ "Ļ": "L",
+ "ļ": "l",
+ "Ľ": "L",
+ "ľ": "l",
+ "Ŀ": "L",
+ "ŀ": "l",
+ "Ł": "l",
+ "ł": "l",
+ "Ḿ": "M",
+ "ḿ": "m",
+ "M̆": "M",
+ "m̆": "m",
+ "Ń": "N",
+ "ń": "n",
+ "Ņ": "N",
+ "ņ": "n",
+ "Ň": "N",
+ "ň": "n",
+ "ʼn": "n",
+ "N̆": "N",
+ "n̆": "n",
+ "Ō": "O",
+ "ō": "o",
+ "Ŏ": "O",
+ "ŏ": "o",
+ "Ő": "O",
+ "ő": "o",
+ "Œ": "OE",
+ "œ": "oe",
+ "P̆": "P",
+ "p̆": "p",
+ "Ŕ": "R",
+ "ŕ": "r",
+ "Ŗ": "R",
+ "ŗ": "r",
+ "Ř": "R",
+ "ř": "r",
+ "R̆": "R",
+ "r̆": "r",
+ "Ȓ": "R",
+ "ȓ": "r",
+ "Ś": "S",
+ "ś": "s",
+ "Ŝ": "S",
+ "ŝ": "s",
+ "Ş": "S",
+ "Ș": "S",
+ "ș": "s",
+ "ş": "s",
+ "Š": "S",
+ "š": "s",
+ "Ţ": "T",
+ "ţ": "t",
+ "ț": "t",
+ "Ț": "T",
+ "Ť": "T",
+ "ť": "t",
+ "Ŧ": "T",
+ "ŧ": "t",
+ "T̆": "T",
+ "t̆": "t",
+ "Ũ": "U",
+ "ũ": "u",
+ "Ū": "U",
+ "ū": "u",
+ "Ŭ": "U",
+ "ŭ": "u",
+ "Ů": "U",
+ "ů": "u",
+ "Ű": "U",
+ "ű": "u",
+ "Ų": "U",
+ "ų": "u",
+ "Ȗ": "U",
+ "ȗ": "u",
+ "V̆": "V",
+ "v̆": "v",
+ "Ŵ": "W",
+ "ŵ": "w",
+ "Ẃ": "W",
+ "ẃ": "w",
+ "X̆": "X",
+ "x̆": "x",
+ "Ŷ": "Y",
+ "ŷ": "y",
+ "Ÿ": "Y",
+ "Y̆": "Y",
+ "y̆": "y",
+ "Ź": "Z",
+ "ź": "z",
+ "Ż": "Z",
+ "ż": "z",
+ "Ž": "Z",
+ "ž": "z",
+ "ſ": "s",
+ "ƒ": "f",
+ "Ơ": "O",
+ "ơ": "o",
+ "Ư": "U",
+ "ư": "u",
+ "Ǎ": "A",
+ "ǎ": "a",
+ "Ǐ": "I",
+ "ǐ": "i",
+ "Ǒ": "O",
+ "ǒ": "o",
+ "Ǔ": "U",
+ "ǔ": "u",
+ "Ǖ": "U",
+ "ǖ": "u",
+ "Ǘ": "U",
+ "ǘ": "u",
+ "Ǚ": "U",
+ "ǚ": "u",
+ "Ǜ": "U",
+ "ǜ": "u",
+ "Ứ": "U",
+ "ứ": "u",
+ "Ṹ": "U",
+ "ṹ": "u",
+ "Ǻ": "A",
+ "ǻ": "a",
+ "Ǽ": "AE",
+ "ǽ": "ae",
+ "Ǿ": "O",
+ "ǿ": "o",
+ "Þ": "TH",
+ "þ": "th",
+ "Ṕ": "P",
+ "ṕ": "p",
+ "Ṥ": "S",
+ "ṥ": "s",
+ "X́": "X",
+ "x́": "x",
+ "Ѓ": "Г",
+ "ѓ": "г",
+ "Ќ": "К",
+ "ќ": "к",
+ "A̋": "A",
+ "a̋": "a",
+ "E̋": "E",
+ "e̋": "e",
+ "I̋": "I",
+ "i̋": "i",
+ "Ǹ": "N",
+ "ǹ": "n",
+ "Ồ": "O",
+ "ồ": "o",
+ "Ṑ": "O",
+ "ṑ": "o",
+ "Ừ": "U",
+ "ừ": "u",
+ "Ẁ": "W",
+ "ẁ": "w",
+ "Ỳ": "Y",
+ "ỳ": "y",
+ "Ȁ": "A",
+ "ȁ": "a",
+ "Ȅ": "E",
+ "ȅ": "e",
+ "Ȉ": "I",
+ "ȉ": "i",
+ "Ȍ": "O",
+ "ȍ": "o",
+ "Ȑ": "R",
+ "ȑ": "r",
+ "Ȕ": "U",
+ "ȕ": "u",
+ "B̌": "B",
+ "b̌": "b",
+ "Č̣": "C",
+ "č̣": "c",
+ "Ê̌": "E",
+ "ê̌": "e",
+ "F̌": "F",
+ "f̌": "f",
+ "Ǧ": "G",
+ "ǧ": "g",
+ "Ȟ": "H",
+ "ȟ": "h",
+ "J̌": "J",
+ "ǰ": "j",
+ "Ǩ": "K",
+ "ǩ": "k",
+ "M̌": "M",
+ "m̌": "m",
+ "P̌": "P",
+ "p̌": "p",
+ "Q̌": "Q",
+ "q̌": "q",
+ "Ř̩": "R",
+ "ř̩": "r",
+ "Ṧ": "S",
+ "ṧ": "s",
+ "V̌": "V",
+ "v̌": "v",
+ "W̌": "W",
+ "w̌": "w",
+ "X̌": "X",
+ "x̌": "x",
+ "Y̌": "Y",
+ "y̌": "y",
+ "A̧": "A",
+ "a̧": "a",
+ "B̧": "B",
+ "b̧": "b",
+ "Ḑ": "D",
+ "ḑ": "d",
+ "Ȩ": "E",
+ "ȩ": "e",
+ "Ɛ̧": "E",
+ "ɛ̧": "e",
+ "Ḩ": "H",
+ "ḩ": "h",
+ "I̧": "I",
+ "i̧": "i",
+ "Ɨ̧": "I",
+ "ɨ̧": "i",
+ "M̧": "M",
+ "m̧": "m",
+ "O̧": "O",
+ "o̧": "o",
+ "Q̧": "Q",
+ "q̧": "q",
+ "U̧": "U",
+ "u̧": "u",
+ "X̧": "X",
+ "x̧": "x",
+ "Z̧": "Z",
+ "z̧": "z",
+ "й":"и",
+ "Й":"И",
+ "ё":"е",
+ "Ё":"Е",
+};
+
+var chars = Object.keys(characterMap).join('|');
+var allAccents = new RegExp(chars, 'g');
+var firstAccent = new RegExp(chars, '');
+
+function matcher(match) {
+ return characterMap[match];
+}
+
+var removeAccents = function(string) {
+ return string.replace(allAccents, matcher);
+};
+
+var hasAccents = function(string) {
+ return !!string.match(firstAccent);
+};
+
+module.exports = removeAccents;
+module.exports.has = hasAccents;
+module.exports.remove = removeAccents;
+
+
+/***/ }),
+
+/***/ 1030:
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_RESULT__;;/*! showdown v 1.9.1 - 02-11-2019 */
@@ -5342,1068 +5778,691 @@
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
-/******/ !function() {
+/******/ (() => {
/******/ // getDefaultExport function for compatibility with non-harmony modules
-/******/ __webpack_require__.n = function(module) {
+/******/ __webpack_require__.n = (module) => {
/******/ var getter = module && module.__esModule ?
-/******/ function() { return module['default']; } :
-/******/ function() { return module; };
+/******/ () => (module['default']) :
+/******/ () => (module);
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
-/******/ }();
+/******/ })();
/******/
/******/ /* webpack/runtime/define property getters */
-/******/ !function() {
+/******/ (() => {
/******/ // define getter functions for harmony exports
-/******/ __webpack_require__.d = function(exports, definition) {
+/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
-/******/ }();
+/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
-/******/ !function() {
-/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
-/******/ }();
+/******/ (() => {
+/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
+/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
-/******/ !function() {
+/******/ (() => {
/******/ // define __esModule on exports
-/******/ __webpack_require__.r = function(exports) {
+/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
-/******/ }();
+/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
-!function() {
+(() => {
"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
- "__EXPERIMENTAL_ELEMENTS": function() { return /* reexport */ __EXPERIMENTAL_ELEMENTS; },
- "__EXPERIMENTAL_PATHS_WITH_MERGE": function() { return /* reexport */ __EXPERIMENTAL_PATHS_WITH_MERGE; },
- "__EXPERIMENTAL_STYLE_PROPERTY": function() { return /* reexport */ __EXPERIMENTAL_STYLE_PROPERTY; },
- "__experimentalCloneSanitizedBlock": function() { return /* reexport */ __experimentalCloneSanitizedBlock; },
- "__experimentalGetAccessibleBlockLabel": function() { return /* reexport */ getAccessibleBlockLabel; },
- "__experimentalGetBlockAttributesNamesByRole": function() { return /* reexport */ __experimentalGetBlockAttributesNamesByRole; },
- "__experimentalGetBlockLabel": function() { return /* reexport */ getBlockLabel; },
- "__experimentalSanitizeBlockAttributes": function() { return /* reexport */ __experimentalSanitizeBlockAttributes; },
- "__unstableGetBlockProps": function() { return /* reexport */ getBlockProps; },
- "__unstableGetInnerBlocksProps": function() { return /* reexport */ getInnerBlocksProps; },
- "__unstableSerializeAndClean": function() { return /* reexport */ __unstableSerializeAndClean; },
- "children": function() { return /* reexport */ children; },
- "cloneBlock": function() { return /* reexport */ cloneBlock; },
- "createBlock": function() { return /* reexport */ createBlock; },
- "createBlocksFromInnerBlocksTemplate": function() { return /* reexport */ createBlocksFromInnerBlocksTemplate; },
- "doBlocksMatchTemplate": function() { return /* reexport */ doBlocksMatchTemplate; },
- "findTransform": function() { return /* reexport */ findTransform; },
- "getBlockAttributes": function() { return /* reexport */ getBlockAttributes; },
- "getBlockContent": function() { return /* reexport */ getBlockInnerHTML; },
- "getBlockDefaultClassName": function() { return /* reexport */ getBlockDefaultClassName; },
- "getBlockFromExample": function() { return /* reexport */ getBlockFromExample; },
- "getBlockMenuDefaultClassName": function() { return /* reexport */ getBlockMenuDefaultClassName; },
- "getBlockSupport": function() { return /* reexport */ registration_getBlockSupport; },
- "getBlockTransforms": function() { return /* reexport */ getBlockTransforms; },
- "getBlockType": function() { return /* reexport */ registration_getBlockType; },
- "getBlockTypes": function() { return /* reexport */ registration_getBlockTypes; },
- "getBlockVariations": function() { return /* reexport */ registration_getBlockVariations; },
- "getCategories": function() { return /* reexport */ categories_getCategories; },
- "getChildBlockNames": function() { return /* reexport */ registration_getChildBlockNames; },
- "getDefaultBlockName": function() { return /* reexport */ registration_getDefaultBlockName; },
- "getFreeformContentHandlerName": function() { return /* reexport */ getFreeformContentHandlerName; },
- "getGroupingBlockName": function() { return /* reexport */ registration_getGroupingBlockName; },
- "getPhrasingContentSchema": function() { return /* reexport */ deprecatedGetPhrasingContentSchema; },
- "getPossibleBlockTransformations": function() { return /* reexport */ getPossibleBlockTransformations; },
- "getSaveContent": function() { return /* reexport */ getSaveContent; },
- "getSaveElement": function() { return /* reexport */ getSaveElement; },
- "getUnregisteredTypeHandlerName": function() { return /* reexport */ getUnregisteredTypeHandlerName; },
- "hasBlockSupport": function() { return /* reexport */ registration_hasBlockSupport; },
- "hasChildBlocks": function() { return /* reexport */ registration_hasChildBlocks; },
- "hasChildBlocksWithInserterSupport": function() { return /* reexport */ registration_hasChildBlocksWithInserterSupport; },
- "isReusableBlock": function() { return /* reexport */ isReusableBlock; },
- "isTemplatePart": function() { return /* reexport */ isTemplatePart; },
- "isUnmodifiedDefaultBlock": function() { return /* reexport */ isUnmodifiedDefaultBlock; },
- "isValidBlockContent": function() { return /* reexport */ isValidBlockContent; },
- "isValidIcon": function() { return /* reexport */ isValidIcon; },
- "node": function() { return /* reexport */ node; },
- "normalizeIconObject": function() { return /* reexport */ normalizeIconObject; },
- "parse": function() { return /* reexport */ parser_parse; },
- "parseWithAttributeSchema": function() { return /* reexport */ parseWithAttributeSchema; },
- "pasteHandler": function() { return /* reexport */ pasteHandler; },
- "rawHandler": function() { return /* reexport */ rawHandler; },
- "registerBlockCollection": function() { return /* reexport */ registerBlockCollection; },
- "registerBlockStyle": function() { return /* reexport */ registerBlockStyle; },
- "registerBlockType": function() { return /* reexport */ registerBlockType; },
- "registerBlockVariation": function() { return /* reexport */ registerBlockVariation; },
- "serialize": function() { return /* reexport */ serializer_serialize; },
- "serializeRawBlock": function() { return /* reexport */ serializeRawBlock; },
- "setCategories": function() { return /* reexport */ categories_setCategories; },
- "setDefaultBlockName": function() { return /* reexport */ setDefaultBlockName; },
- "setFreeformContentHandlerName": function() { return /* reexport */ setFreeformContentHandlerName; },
- "setGroupingBlockName": function() { return /* reexport */ setGroupingBlockName; },
- "setUnregisteredTypeHandlerName": function() { return /* reexport */ setUnregisteredTypeHandlerName; },
- "store": function() { return /* reexport */ store; },
- "switchToBlockType": function() { return /* reexport */ switchToBlockType; },
- "synchronizeBlocksWithTemplate": function() { return /* reexport */ synchronizeBlocksWithTemplate; },
- "unregisterBlockStyle": function() { return /* reexport */ unregisterBlockStyle; },
- "unregisterBlockType": function() { return /* reexport */ unregisterBlockType; },
- "unregisterBlockVariation": function() { return /* reexport */ unregisterBlockVariation; },
- "unstable__bootstrapServerSideBlockDefinitions": function() { return /* reexport */ unstable__bootstrapServerSideBlockDefinitions; },
- "updateCategory": function() { return /* reexport */ categories_updateCategory; },
- "validateBlock": function() { return /* reexport */ validateBlock; },
- "withBlockContentContext": function() { return /* reexport */ withBlockContentContext; }
+ __EXPERIMENTAL_ELEMENTS: () => (/* reexport */ __EXPERIMENTAL_ELEMENTS),
+ __EXPERIMENTAL_PATHS_WITH_OVERRIDE: () => (/* reexport */ __EXPERIMENTAL_PATHS_WITH_OVERRIDE),
+ __EXPERIMENTAL_STYLE_PROPERTY: () => (/* reexport */ __EXPERIMENTAL_STYLE_PROPERTY),
+ __experimentalCloneSanitizedBlock: () => (/* reexport */ __experimentalCloneSanitizedBlock),
+ __experimentalGetAccessibleBlockLabel: () => (/* reexport */ getAccessibleBlockLabel),
+ __experimentalGetBlockAttributesNamesByRole: () => (/* reexport */ __experimentalGetBlockAttributesNamesByRole),
+ __experimentalGetBlockLabel: () => (/* reexport */ getBlockLabel),
+ __experimentalSanitizeBlockAttributes: () => (/* reexport */ __experimentalSanitizeBlockAttributes),
+ __unstableGetBlockProps: () => (/* reexport */ getBlockProps),
+ __unstableGetInnerBlocksProps: () => (/* reexport */ getInnerBlocksProps),
+ __unstableSerializeAndClean: () => (/* reexport */ __unstableSerializeAndClean),
+ children: () => (/* reexport */ children),
+ cloneBlock: () => (/* reexport */ cloneBlock),
+ createBlock: () => (/* reexport */ createBlock),
+ createBlocksFromInnerBlocksTemplate: () => (/* reexport */ createBlocksFromInnerBlocksTemplate),
+ doBlocksMatchTemplate: () => (/* reexport */ doBlocksMatchTemplate),
+ findTransform: () => (/* reexport */ findTransform),
+ getBlockAttributes: () => (/* reexport */ getBlockAttributes),
+ getBlockContent: () => (/* reexport */ getBlockInnerHTML),
+ getBlockDefaultClassName: () => (/* reexport */ getBlockDefaultClassName),
+ getBlockFromExample: () => (/* reexport */ getBlockFromExample),
+ getBlockMenuDefaultClassName: () => (/* reexport */ getBlockMenuDefaultClassName),
+ getBlockSupport: () => (/* reexport */ getBlockSupport),
+ getBlockTransforms: () => (/* reexport */ getBlockTransforms),
+ getBlockType: () => (/* reexport */ getBlockType),
+ getBlockTypes: () => (/* reexport */ getBlockTypes),
+ getBlockVariations: () => (/* reexport */ getBlockVariations),
+ getCategories: () => (/* reexport */ categories_getCategories),
+ getChildBlockNames: () => (/* reexport */ getChildBlockNames),
+ getDefaultBlockName: () => (/* reexport */ getDefaultBlockName),
+ getFreeformContentHandlerName: () => (/* reexport */ getFreeformContentHandlerName),
+ getGroupingBlockName: () => (/* reexport */ getGroupingBlockName),
+ getPhrasingContentSchema: () => (/* reexport */ deprecatedGetPhrasingContentSchema),
+ getPossibleBlockTransformations: () => (/* reexport */ getPossibleBlockTransformations),
+ getSaveContent: () => (/* reexport */ getSaveContent),
+ getSaveElement: () => (/* reexport */ getSaveElement),
+ getUnregisteredTypeHandlerName: () => (/* reexport */ getUnregisteredTypeHandlerName),
+ hasBlockSupport: () => (/* reexport */ hasBlockSupport),
+ hasChildBlocks: () => (/* reexport */ hasChildBlocks),
+ hasChildBlocksWithInserterSupport: () => (/* reexport */ hasChildBlocksWithInserterSupport),
+ isReusableBlock: () => (/* reexport */ isReusableBlock),
+ isTemplatePart: () => (/* reexport */ isTemplatePart),
+ isUnmodifiedBlock: () => (/* reexport */ isUnmodifiedBlock),
+ isUnmodifiedDefaultBlock: () => (/* reexport */ isUnmodifiedDefaultBlock),
+ isValidBlockContent: () => (/* reexport */ isValidBlockContent),
+ isValidIcon: () => (/* reexport */ isValidIcon),
+ node: () => (/* reexport */ node),
+ normalizeIconObject: () => (/* reexport */ normalizeIconObject),
+ parse: () => (/* reexport */ parser_parse),
+ parseWithAttributeSchema: () => (/* reexport */ parseWithAttributeSchema),
+ pasteHandler: () => (/* reexport */ pasteHandler),
+ rawHandler: () => (/* reexport */ rawHandler),
+ registerBlockCollection: () => (/* reexport */ registerBlockCollection),
+ registerBlockStyle: () => (/* reexport */ registerBlockStyle),
+ registerBlockType: () => (/* reexport */ registerBlockType),
+ registerBlockVariation: () => (/* reexport */ registerBlockVariation),
+ serialize: () => (/* reexport */ serialize),
+ serializeRawBlock: () => (/* reexport */ serializeRawBlock),
+ setCategories: () => (/* reexport */ categories_setCategories),
+ setDefaultBlockName: () => (/* reexport */ setDefaultBlockName),
+ setFreeformContentHandlerName: () => (/* reexport */ setFreeformContentHandlerName),
+ setGroupingBlockName: () => (/* reexport */ setGroupingBlockName),
+ setUnregisteredTypeHandlerName: () => (/* reexport */ setUnregisteredTypeHandlerName),
+ store: () => (/* reexport */ store),
+ switchToBlockType: () => (/* reexport */ switchToBlockType),
+ synchronizeBlocksWithTemplate: () => (/* reexport */ synchronizeBlocksWithTemplate),
+ unregisterBlockStyle: () => (/* reexport */ unregisterBlockStyle),
+ unregisterBlockType: () => (/* reexport */ unregisterBlockType),
+ unregisterBlockVariation: () => (/* reexport */ unregisterBlockVariation),
+ unstable__bootstrapServerSideBlockDefinitions: () => (/* reexport */ unstable__bootstrapServerSideBlockDefinitions),
+ updateCategory: () => (/* reexport */ categories_updateCategory),
+ validateBlock: () => (/* reexport */ validateBlock),
+ withBlockContentContext: () => (/* reexport */ withBlockContentContext)
});
// NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/selectors.js
var selectors_namespaceObject = {};
__webpack_require__.r(selectors_namespaceObject);
__webpack_require__.d(selectors_namespaceObject, {
- "__experimentalGetUnprocessedBlockTypes": function() { return __experimentalGetUnprocessedBlockTypes; },
- "getActiveBlockVariation": function() { return getActiveBlockVariation; },
- "getBlockStyles": function() { return getBlockStyles; },
- "getBlockSupport": function() { return getBlockSupport; },
- "getBlockType": function() { return getBlockType; },
- "getBlockTypes": function() { return getBlockTypes; },
- "getBlockVariations": function() { return getBlockVariations; },
- "getCategories": function() { return getCategories; },
- "getChildBlockNames": function() { return getChildBlockNames; },
- "getCollections": function() { return getCollections; },
- "getDefaultBlockName": function() { return getDefaultBlockName; },
- "getDefaultBlockVariation": function() { return getDefaultBlockVariation; },
- "getFreeformFallbackBlockName": function() { return getFreeformFallbackBlockName; },
- "getGroupingBlockName": function() { return getGroupingBlockName; },
- "getUnregisteredFallbackBlockName": function() { return getUnregisteredFallbackBlockName; },
- "hasBlockSupport": function() { return hasBlockSupport; },
- "hasChildBlocks": function() { return hasChildBlocks; },
- "hasChildBlocksWithInserterSupport": function() { return hasChildBlocksWithInserterSupport; },
- "isMatchingSearchTerm": function() { return isMatchingSearchTerm; }
+ __experimentalHasContentRoleAttribute: () => (__experimentalHasContentRoleAttribute),
+ getActiveBlockVariation: () => (getActiveBlockVariation),
+ getBlockStyles: () => (getBlockStyles),
+ getBlockSupport: () => (selectors_getBlockSupport),
+ getBlockType: () => (selectors_getBlockType),
+ getBlockTypes: () => (selectors_getBlockTypes),
+ getBlockVariations: () => (selectors_getBlockVariations),
+ getCategories: () => (getCategories),
+ getChildBlockNames: () => (selectors_getChildBlockNames),
+ getCollections: () => (getCollections),
+ getDefaultBlockName: () => (selectors_getDefaultBlockName),
+ getDefaultBlockVariation: () => (getDefaultBlockVariation),
+ getFreeformFallbackBlockName: () => (getFreeformFallbackBlockName),
+ getGroupingBlockName: () => (selectors_getGroupingBlockName),
+ getUnregisteredFallbackBlockName: () => (getUnregisteredFallbackBlockName),
+ hasBlockSupport: () => (selectors_hasBlockSupport),
+ hasChildBlocks: () => (selectors_hasChildBlocks),
+ hasChildBlocksWithInserterSupport: () => (selectors_hasChildBlocksWithInserterSupport),
+ isMatchingSearchTerm: () => (isMatchingSearchTerm)
+});
+
+// NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/private-selectors.js
+var private_selectors_namespaceObject = {};
+__webpack_require__.r(private_selectors_namespaceObject);
+__webpack_require__.d(private_selectors_namespaceObject, {
+ getAllBlockBindingsSources: () => (getAllBlockBindingsSources),
+ getBlockBindingsSource: () => (getBlockBindingsSource),
+ getBootstrappedBlockType: () => (getBootstrappedBlockType),
+ getSupportedStyles: () => (getSupportedStyles),
+ getUnprocessedBlockTypes: () => (getUnprocessedBlockTypes)
});
// NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/actions.js
var actions_namespaceObject = {};
__webpack_require__.r(actions_namespaceObject);
__webpack_require__.d(actions_namespaceObject, {
- "__experimentalReapplyBlockTypeFilters": function() { return __experimentalReapplyBlockTypeFilters; },
- "__experimentalRegisterBlockType": function() { return __experimentalRegisterBlockType; },
- "addBlockCollection": function() { return addBlockCollection; },
- "addBlockStyles": function() { return addBlockStyles; },
- "addBlockTypes": function() { return addBlockTypes; },
- "addBlockVariations": function() { return addBlockVariations; },
- "removeBlockCollection": function() { return removeBlockCollection; },
- "removeBlockStyles": function() { return removeBlockStyles; },
- "removeBlockTypes": function() { return removeBlockTypes; },
- "removeBlockVariations": function() { return removeBlockVariations; },
- "setCategories": function() { return setCategories; },
- "setDefaultBlockName": function() { return actions_setDefaultBlockName; },
- "setFreeformFallbackBlockName": function() { return setFreeformFallbackBlockName; },
- "setGroupingBlockName": function() { return actions_setGroupingBlockName; },
- "setUnregisteredFallbackBlockName": function() { return setUnregisteredFallbackBlockName; },
- "updateCategory": function() { return updateCategory; }
+ __experimentalReapplyBlockFilters: () => (__experimentalReapplyBlockFilters),
+ addBlockCollection: () => (addBlockCollection),
+ addBlockStyles: () => (addBlockStyles),
+ addBlockTypes: () => (addBlockTypes),
+ addBlockVariations: () => (addBlockVariations),
+ reapplyBlockTypeFilters: () => (reapplyBlockTypeFilters),
+ removeBlockCollection: () => (removeBlockCollection),
+ removeBlockStyles: () => (removeBlockStyles),
+ removeBlockTypes: () => (removeBlockTypes),
+ removeBlockVariations: () => (removeBlockVariations),
+ setCategories: () => (setCategories),
+ setDefaultBlockName: () => (actions_setDefaultBlockName),
+ setFreeformFallbackBlockName: () => (setFreeformFallbackBlockName),
+ setGroupingBlockName: () => (actions_setGroupingBlockName),
+ setUnregisteredFallbackBlockName: () => (setUnregisteredFallbackBlockName),
+ updateCategory: () => (updateCategory)
+});
+
+// NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/private-actions.js
+var private_actions_namespaceObject = {};
+__webpack_require__.r(private_actions_namespaceObject);
+__webpack_require__.d(private_actions_namespaceObject, {
+ addBootstrappedBlockType: () => (addBootstrappedBlockType),
+ addUnprocessedBlockType: () => (addUnprocessedBlockType),
+ registerBlockBindingsSource: () => (registerBlockBindingsSource)
});
;// CONCATENATED MODULE: external ["wp","data"]
-var external_wp_data_namespaceObject = window["wp"]["data"];
-;// CONCATENATED MODULE: external "lodash"
-var external_lodash_namespaceObject = window["lodash"];
+const external_wp_data_namespaceObject = window["wp"]["data"];
+;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs
+/******************************************************************************
+Copyright (c) Microsoft Corporation.
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+***************************************************************************** */
+/* global Reflect, Promise, SuppressedError, Symbol */
+
+var extendStatics = function(d, b) {
+ extendStatics = Object.setPrototypeOf ||
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
+ return extendStatics(d, b);
+};
+
+function __extends(d, b) {
+ if (typeof b !== "function" && b !== null)
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
+ extendStatics(d, b);
+ function __() { this.constructor = d; }
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+}
+
+var __assign = function() {
+ __assign = Object.assign || function __assign(t) {
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
+ s = arguments[i];
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
+ }
+ return t;
+ }
+ return __assign.apply(this, arguments);
+}
+
+function __rest(s, e) {
+ var t = {};
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
+ t[p] = s[p];
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
+ t[p[i]] = s[p[i]];
+ }
+ return t;
+}
+
+function __decorate(decorators, target, key, desc) {
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
+ 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;
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
+}
+
+function __param(paramIndex, decorator) {
+ return function (target, key) { decorator(target, key, paramIndex); }
+}
+
+function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
+ var _, done = false;
+ for (var i = decorators.length - 1; i >= 0; i--) {
+ var context = {};
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
+ if (kind === "accessor") {
+ if (result === void 0) continue;
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
+ if (_ = accept(result.get)) descriptor.get = _;
+ if (_ = accept(result.set)) descriptor.set = _;
+ if (_ = accept(result.init)) initializers.unshift(_);
+ }
+ else if (_ = accept(result)) {
+ if (kind === "field") initializers.unshift(_);
+ else descriptor[key] = _;
+ }
+ }
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
+ done = true;
+};
+
+function __runInitializers(thisArg, initializers, value) {
+ var useValue = arguments.length > 2;
+ for (var i = 0; i < initializers.length; i++) {
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
+ }
+ return useValue ? value : void 0;
+};
+
+function __propKey(x) {
+ return typeof x === "symbol" ? x : "".concat(x);
+};
+
+function __setFunctionName(f, name, prefix) {
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
+};
+
+function __metadata(metadataKey, metadataValue) {
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
+}
+
+function __awaiter(thisArg, _arguments, P, generator) {
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+ return new (P || (P = Promise))(function (resolve, reject) {
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
+ });
+}
+
+function __generator(thisArg, body) {
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
+ function verb(n) { return function (v) { return step([n, v]); }; }
+ function step(op) {
+ if (f) throw new TypeError("Generator is already executing.");
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
+ 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;
+ if (y = 0, t) op = [op[0] & 2, t.value];
+ switch (op[0]) {
+ case 0: case 1: t = op; break;
+ case 4: _.label++; return { value: op[1], done: false };
+ case 5: _.label++; y = op[1]; op = [0]; continue;
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
+ default:
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
+ if (t[2]) _.ops.pop();
+ _.trys.pop(); continue;
+ }
+ op = body.call(thisArg, _);
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
+ }
+}
+
+var __createBinding = Object.create ? (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ var desc = Object.getOwnPropertyDescriptor(m, k);
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
+ desc = { enumerable: true, get: function() { return m[k]; } };
+ }
+ Object.defineProperty(o, k2, desc);
+}) : (function(o, m, k, k2) {
+ if (k2 === undefined) k2 = k;
+ o[k2] = m[k];
+});
+
+function __exportStar(m, o) {
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
+}
+
+function __values(o) {
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
+ if (m) return m.call(o);
+ if (o && typeof o.length === "number") return {
+ next: function () {
+ if (o && i >= o.length) o = void 0;
+ return { value: o && o[i++], done: !o };
+ }
+ };
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
+}
+
+function __read(o, n) {
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
+ if (!m) return o;
+ var i = m.call(o), r, ar = [], e;
+ try {
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
+ }
+ catch (error) { e = { error: error }; }
+ finally {
+ try {
+ if (r && !r.done && (m = i["return"])) m.call(i);
+ }
+ finally { if (e) throw e.error; }
+ }
+ return ar;
+}
+
+/** @deprecated */
+function __spread() {
+ for (var ar = [], i = 0; i < arguments.length; i++)
+ ar = ar.concat(__read(arguments[i]));
+ return ar;
+}
+
+/** @deprecated */
+function __spreadArrays() {
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
+ r[k] = a[j];
+ return r;
+}
+
+function __spreadArray(to, from, pack) {
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
+ if (ar || !(i in from)) {
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
+ ar[i] = from[i];
+ }
+ }
+ return to.concat(ar || Array.prototype.slice.call(from));
+}
+
+function __await(v) {
+ return this instanceof __await ? (this.v = v, this) : new __await(v);
+}
+
+function __asyncGenerator(thisArg, _arguments, generator) {
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
+ return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
+ 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); }); }; }
+ function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
+ function fulfill(value) { resume("next", value); }
+ function reject(value) { resume("throw", value); }
+ function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
+}
+
+function __asyncDelegator(o) {
+ var i, p;
+ return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
+ 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; }
+}
+
+function __asyncValues(o) {
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
+ var m = o[Symbol.asyncIterator], i;
+ 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);
+ 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); }); }; }
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
+}
+
+function __makeTemplateObject(cooked, raw) {
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
+ return cooked;
+};
+
+var __setModuleDefault = Object.create ? (function(o, v) {
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
+}) : function(o, v) {
+ o["default"] = v;
+};
+
+function __importStar(mod) {
+ if (mod && mod.__esModule) return mod;
+ var result = {};
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+ __setModuleDefault(result, mod);
+ return result;
+}
+
+function __importDefault(mod) {
+ return (mod && mod.__esModule) ? mod : { default: mod };
+}
+
+function __classPrivateFieldGet(receiver, state, kind, f) {
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
+ 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");
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
+}
+
+function __classPrivateFieldSet(receiver, state, value, kind, f) {
+ if (kind === "m") throw new TypeError("Private method is not writable");
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
+ 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");
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
+}
+
+function __classPrivateFieldIn(state, receiver) {
+ if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
+ return typeof state === "function" ? receiver === state : state.has(receiver);
+}
+
+function __addDisposableResource(env, value, async) {
+ if (value !== null && value !== void 0) {
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
+ var dispose;
+ if (async) {
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
+ dispose = value[Symbol.asyncDispose];
+ }
+ if (dispose === void 0) {
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
+ dispose = value[Symbol.dispose];
+ }
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
+ env.stack.push({ value: value, dispose: dispose, async: async });
+ }
+ else if (async) {
+ env.stack.push({ async: true });
+ }
+ return value;
+}
+
+var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
+ var e = new Error(message);
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
+};
+
+function __disposeResources(env) {
+ function fail(e) {
+ env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
+ env.hasError = true;
+ }
+ function next() {
+ while (env.stack.length) {
+ var rec = env.stack.pop();
+ try {
+ var result = rec.dispose && rec.dispose.call(rec.value);
+ if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
+ }
+ catch (e) {
+ fail(e);
+ }
+ }
+ if (env.hasError) throw env.error;
+ }
+ return next();
+}
+
+/* harmony default export */ const tslib_es6 = ({
+ __extends,
+ __assign,
+ __rest,
+ __decorate,
+ __param,
+ __metadata,
+ __awaiter,
+ __generator,
+ __createBinding,
+ __exportStar,
+ __values,
+ __read,
+ __spread,
+ __spreadArrays,
+ __spreadArray,
+ __await,
+ __asyncGenerator,
+ __asyncDelegator,
+ __asyncValues,
+ __makeTemplateObject,
+ __importStar,
+ __importDefault,
+ __classPrivateFieldGet,
+ __classPrivateFieldSet,
+ __classPrivateFieldIn,
+ __addDisposableResource,
+ __disposeResources,
+});
+
+;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js
+/**
+ * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
+ */
+var SUPPORTED_LOCALE = {
+ tr: {
+ regexp: /\u0130|\u0049|\u0049\u0307/g,
+ map: {
+ İ: "\u0069",
+ I: "\u0131",
+ İ: "\u0069",
+ },
+ },
+ az: {
+ regexp: /\u0130/g,
+ map: {
+ İ: "\u0069",
+ I: "\u0131",
+ İ: "\u0069",
+ },
+ },
+ lt: {
+ regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
+ map: {
+ I: "\u0069\u0307",
+ J: "\u006A\u0307",
+ Į: "\u012F\u0307",
+ Ì: "\u0069\u0307\u0300",
+ Í: "\u0069\u0307\u0301",
+ Ĩ: "\u0069\u0307\u0303",
+ },
+ },
+};
+/**
+ * Localized lower case.
+ */
+function localeLowerCase(str, locale) {
+ var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
+ if (lang)
+ return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));
+ return lowerCase(str);
+}
+/**
+ * Lower case as a function.
+ */
+function lowerCase(str) {
+ return str.toLowerCase();
+}
+
+;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js
+
+// Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
+var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
+// Remove all non-word characters.
+var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
+/**
+ * Normalize the string into something other libraries can manipulate easier.
+ */
+function noCase(input, options) {
+ if (options === void 0) { options = {}; }
+ 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;
+ var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
+ var start = 0;
+ var end = result.length;
+ // Trim the delimiter from around the output string.
+ while (result.charAt(start) === "\0")
+ start++;
+ while (result.charAt(end - 1) === "\0")
+ end--;
+ // Transform each token independently.
+ return result.slice(start, end).split("\0").map(transform).join(delimiter);
+}
+/**
+ * Replace `re` in the input string with the replacement value.
+ */
+function replace(input, re, value) {
+ if (re instanceof RegExp)
+ return input.replace(re, value);
+ return re.reduce(function (input, re) { return input.replace(re, value); }, input);
+}
+
+;// CONCATENATED MODULE: ./node_modules/pascal-case/dist.es2015/index.js
+
+
+function pascalCaseTransform(input, index) {
+ var firstChar = input.charAt(0);
+ var lowerChars = input.substr(1).toLowerCase();
+ if (index > 0 && firstChar >= "0" && firstChar <= "9") {
+ return "_" + firstChar + lowerChars;
+ }
+ return "" + firstChar.toUpperCase() + lowerChars;
+}
+function dist_es2015_pascalCaseTransformMerge(input) {
+ return input.charAt(0).toUpperCase() + input.slice(1).toLowerCase();
+}
+function pascalCase(input, options) {
+ if (options === void 0) { options = {}; }
+ return noCase(input, __assign({ delimiter: "", transform: pascalCaseTransform }, options));
+}
+
+;// CONCATENATED MODULE: ./node_modules/camel-case/dist.es2015/index.js
+
+
+function camelCaseTransform(input, index) {
+ if (index === 0)
+ return input.toLowerCase();
+ return pascalCaseTransform(input, index);
+}
+function camelCaseTransformMerge(input, index) {
+ if (index === 0)
+ return input.toLowerCase();
+ return pascalCaseTransformMerge(input);
+}
+function camelCase(input, options) {
+ if (options === void 0) { options = {}; }
+ return pascalCase(input, __assign({ transform: camelCaseTransform }, options));
+}
+
;// CONCATENATED MODULE: external ["wp","i18n"]
-var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
-;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/reducer.js
-/**
- * External dependencies
- */
-
-/**
- * WordPress dependencies
- */
-
-
-
-/**
- * @typedef {Object} WPBlockCategory
- *
- * @property {string} slug Unique category slug.
- * @property {string} title Category label, for display in user interface.
- */
-
-/**
- * Default set of categories.
- *
- * @type {WPBlockCategory[]}
- */
-
-const DEFAULT_CATEGORIES = [{
- slug: 'text',
- title: (0,external_wp_i18n_namespaceObject.__)('Text')
-}, {
- slug: 'media',
- title: (0,external_wp_i18n_namespaceObject.__)('Media')
-}, {
- slug: 'design',
- title: (0,external_wp_i18n_namespaceObject.__)('Design')
-}, {
- slug: 'widgets',
- title: (0,external_wp_i18n_namespaceObject.__)('Widgets')
-}, {
- slug: 'theme',
- title: (0,external_wp_i18n_namespaceObject.__)('Theme')
-}, {
- slug: 'embed',
- title: (0,external_wp_i18n_namespaceObject.__)('Embeds')
-}, {
- slug: 'reusable',
- title: (0,external_wp_i18n_namespaceObject.__)('Reusable blocks')
-}];
-/**
- * Reducer managing the unprocessed block types in a form passed when registering the by block.
- * It's for internal use only. It allows recomputing the processed block types on-demand after block type filters
- * get added or removed.
- *
- * @param {Object} state Current state.
- * @param {Object} action Dispatched action.
- *
- * @return {Object} Updated state.
- */
-
-function unprocessedBlockTypes() {
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- let action = arguments.length > 1 ? arguments[1] : undefined;
-
- switch (action.type) {
- case 'ADD_UNPROCESSED_BLOCK_TYPE':
- return { ...state,
- [action.blockType.name]: action.blockType
- };
-
- case 'REMOVE_BLOCK_TYPES':
- return (0,external_lodash_namespaceObject.omit)(state, action.names);
- }
-
- return state;
-}
-/**
- * Reducer managing the processed block types with all filters applied.
- * The state is derived from the `unprocessedBlockTypes` reducer.
- *
- * @param {Object} state Current state.
- * @param {Object} action Dispatched action.
- *
- * @return {Object} Updated state.
- */
-
-function blockTypes() {
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- let action = arguments.length > 1 ? arguments[1] : undefined;
-
- switch (action.type) {
- case 'ADD_BLOCK_TYPES':
- return { ...state,
- ...(0,external_lodash_namespaceObject.keyBy)(action.blockTypes, 'name')
- };
-
- case 'REMOVE_BLOCK_TYPES':
- return (0,external_lodash_namespaceObject.omit)(state, action.names);
- }
-
- return state;
-}
-/**
- * Reducer managing the block style variations.
- *
- * @param {Object} state Current state.
- * @param {Object} action Dispatched action.
- *
- * @return {Object} Updated state.
- */
-
-function blockStyles() {
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- let action = arguments.length > 1 ? arguments[1] : undefined;
-
- switch (action.type) {
- case 'ADD_BLOCK_TYPES':
- return { ...state,
- ...(0,external_lodash_namespaceObject.mapValues)((0,external_lodash_namespaceObject.keyBy)(action.blockTypes, 'name'), blockType => {
- return (0,external_lodash_namespaceObject.uniqBy)([...(0,external_lodash_namespaceObject.get)(blockType, ['styles'], []).map(style => ({ ...style,
- source: 'block'
- })), ...(0,external_lodash_namespaceObject.get)(state, [blockType.name], []).filter(_ref => {
- let {
- source
- } = _ref;
- return 'block' !== source;
- })], style => style.name);
- })
- };
-
- case 'ADD_BLOCK_STYLES':
- return { ...state,
- [action.blockName]: (0,external_lodash_namespaceObject.uniqBy)([...(0,external_lodash_namespaceObject.get)(state, [action.blockName], []), ...action.styles], style => style.name)
- };
-
- case 'REMOVE_BLOCK_STYLES':
- return { ...state,
- [action.blockName]: (0,external_lodash_namespaceObject.filter)((0,external_lodash_namespaceObject.get)(state, [action.blockName], []), style => action.styleNames.indexOf(style.name) === -1)
- };
- }
-
- return state;
-}
-/**
- * Reducer managing the block variations.
- *
- * @param {Object} state Current state.
- * @param {Object} action Dispatched action.
- *
- * @return {Object} Updated state.
- */
-
-function blockVariations() {
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- let action = arguments.length > 1 ? arguments[1] : undefined;
-
- switch (action.type) {
- case 'ADD_BLOCK_TYPES':
- return { ...state,
- ...(0,external_lodash_namespaceObject.mapValues)((0,external_lodash_namespaceObject.keyBy)(action.blockTypes, 'name'), blockType => {
- return (0,external_lodash_namespaceObject.uniqBy)([...(0,external_lodash_namespaceObject.get)(blockType, ['variations'], []).map(variation => ({ ...variation,
- source: 'block'
- })), ...(0,external_lodash_namespaceObject.get)(state, [blockType.name], []).filter(_ref2 => {
- let {
- source
- } = _ref2;
- return 'block' !== source;
- })], variation => variation.name);
- })
- };
-
- case 'ADD_BLOCK_VARIATIONS':
- return { ...state,
- [action.blockName]: (0,external_lodash_namespaceObject.uniqBy)([...(0,external_lodash_namespaceObject.get)(state, [action.blockName], []), ...action.variations], variation => variation.name)
- };
-
- case 'REMOVE_BLOCK_VARIATIONS':
- return { ...state,
- [action.blockName]: (0,external_lodash_namespaceObject.filter)((0,external_lodash_namespaceObject.get)(state, [action.blockName], []), variation => action.variationNames.indexOf(variation.name) === -1)
- };
- }
-
- return state;
-}
-/**
- * Higher-order Reducer creating a reducer keeping track of given block name.
- *
- * @param {string} setActionType Action type.
- *
- * @return {Function} Reducer.
- */
-
-function createBlockNameSetterReducer(setActionType) {
- return function () {
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
- let action = arguments.length > 1 ? arguments[1] : undefined;
-
- switch (action.type) {
- case 'REMOVE_BLOCK_TYPES':
- if (action.names.indexOf(state) !== -1) {
- return null;
- }
-
- return state;
-
- case setActionType:
- return action.name || null;
- }
-
- return state;
- };
-}
-const defaultBlockName = createBlockNameSetterReducer('SET_DEFAULT_BLOCK_NAME');
-const freeformFallbackBlockName = createBlockNameSetterReducer('SET_FREEFORM_FALLBACK_BLOCK_NAME');
-const unregisteredFallbackBlockName = createBlockNameSetterReducer('SET_UNREGISTERED_FALLBACK_BLOCK_NAME');
-const groupingBlockName = createBlockNameSetterReducer('SET_GROUPING_BLOCK_NAME');
-/**
- * Reducer managing the categories
- *
- * @param {WPBlockCategory[]} state Current state.
- * @param {Object} action Dispatched action.
- *
- * @return {WPBlockCategory[]} Updated state.
- */
-
-function categories() {
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_CATEGORIES;
- let action = arguments.length > 1 ? arguments[1] : undefined;
-
- switch (action.type) {
- case 'SET_CATEGORIES':
- return action.categories || [];
-
- case 'UPDATE_CATEGORY':
- {
- if (!action.category || (0,external_lodash_namespaceObject.isEmpty)(action.category)) {
- return state;
- }
-
- const categoryToChange = (0,external_lodash_namespaceObject.find)(state, ['slug', action.slug]);
-
- if (categoryToChange) {
- return (0,external_lodash_namespaceObject.map)(state, category => {
- if (category.slug === action.slug) {
- return { ...category,
- ...action.category
- };
- }
-
- return category;
- });
- }
- }
- }
-
- return state;
-}
-function collections() {
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
- let action = arguments.length > 1 ? arguments[1] : undefined;
-
- switch (action.type) {
- case 'ADD_BLOCK_COLLECTION':
- return { ...state,
- [action.namespace]: {
- title: action.title,
- icon: action.icon
- }
- };
-
- case 'REMOVE_BLOCK_COLLECTION':
- return (0,external_lodash_namespaceObject.omit)(state, action.namespace);
- }
-
- return state;
-}
-/* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
- unprocessedBlockTypes,
- blockTypes,
- blockStyles,
- blockVariations,
- defaultBlockName,
- freeformFallbackBlockName,
- unregisteredFallbackBlockName,
- groupingBlockName,
- categories,
- collections
-}));
-
-;// CONCATENATED MODULE: ./node_modules/rememo/es/rememo.js
-
-
-var LEAF_KEY, hasWeakMap;
-
-/**
- * Arbitrary value used as key for referencing cache object in WeakMap tree.
- *
- * @type {Object}
- */
-LEAF_KEY = {};
-
-/**
- * Whether environment supports WeakMap.
- *
- * @type {boolean}
- */
-hasWeakMap = typeof WeakMap !== 'undefined';
-
-/**
- * Returns the first argument as the sole entry in an array.
- *
- * @param {*} value Value to return.
- *
- * @return {Array} Value returned as entry in array.
- */
-function arrayOf( value ) {
- return [ value ];
-}
-
-/**
- * Returns true if the value passed is object-like, or false otherwise. A value
- * is object-like if it can support property assignment, e.g. object or array.
- *
- * @param {*} value Value to test.
- *
- * @return {boolean} Whether value is object-like.
- */
-function isObjectLike( value ) {
- return !! value && 'object' === typeof value;
-}
-
-/**
- * Creates and returns a new cache object.
- *
- * @return {Object} Cache object.
- */
-function createCache() {
- var cache = {
- clear: function() {
- cache.head = null;
- },
- };
-
- return cache;
-}
-
-/**
- * Returns true if entries within the two arrays are strictly equal by
- * reference from a starting index.
- *
- * @param {Array} a First array.
- * @param {Array} b Second array.
- * @param {number} fromIndex Index from which to start comparison.
- *
- * @return {boolean} Whether arrays are shallowly equal.
- */
-function isShallowEqual( a, b, fromIndex ) {
- var i;
-
- if ( a.length !== b.length ) {
- return false;
- }
-
- for ( i = fromIndex; i < a.length; i++ ) {
- if ( a[ i ] !== b[ i ] ) {
- return false;
- }
- }
-
- return true;
-}
-
-/**
- * Returns a memoized selector function. The getDependants function argument is
- * called before the memoized selector and is expected to return an immutable
- * reference or array of references on which the selector depends for computing
- * its own return value. The memoize cache is preserved only as long as those
- * dependant references remain the same. If getDependants returns a different
- * reference(s), the cache is cleared and the selector value regenerated.
- *
- * @param {Function} selector Selector function.
- * @param {Function} getDependants Dependant getter returning an immutable
- * reference or array of reference used in
- * cache bust consideration.
- *
- * @return {Function} Memoized selector.
- */
-/* harmony default export */ function rememo(selector, getDependants ) {
- var rootCache, getCache;
-
- // Use object source as dependant if getter not provided
- if ( ! getDependants ) {
- getDependants = arrayOf;
- }
-
- /**
- * Returns the root cache. If WeakMap is supported, this is assigned to the
- * root WeakMap cache set, otherwise it is a shared instance of the default
- * cache object.
- *
- * @return {(WeakMap|Object)} Root cache object.
- */
- function getRootCache() {
- return rootCache;
- }
-
- /**
- * Returns the cache for a given dependants array. When possible, a WeakMap
- * will be used to create a unique cache for each set of dependants. This
- * is feasible due to the nature of WeakMap in allowing garbage collection
- * to occur on entries where the key object is no longer referenced. Since
- * WeakMap requires the key to be an object, this is only possible when the
- * dependant is object-like. The root cache is created as a hierarchy where
- * each top-level key is the first entry in a dependants set, the value a
- * WeakMap where each key is the next dependant, and so on. This continues
- * so long as the dependants are object-like. If no dependants are object-
- * like, then the cache is shared across all invocations.
- *
- * @see isObjectLike
- *
- * @param {Array} dependants Selector dependants.
- *
- * @return {Object} Cache object.
- */
- function getWeakMapCache( dependants ) {
- var caches = rootCache,
- isUniqueByDependants = true,
- i, dependant, map, cache;
-
- for ( i = 0; i < dependants.length; i++ ) {
- dependant = dependants[ i ];
-
- // Can only compose WeakMap from object-like key.
- if ( ! isObjectLike( dependant ) ) {
- isUniqueByDependants = false;
- break;
- }
-
- // Does current segment of cache already have a WeakMap?
- if ( caches.has( dependant ) ) {
- // Traverse into nested WeakMap.
- caches = caches.get( dependant );
- } else {
- // Create, set, and traverse into a new one.
- map = new WeakMap();
- caches.set( dependant, map );
- caches = map;
- }
- }
-
- // We use an arbitrary (but consistent) object as key for the last item
- // in the WeakMap to serve as our running cache.
- if ( ! caches.has( LEAF_KEY ) ) {
- cache = createCache();
- cache.isUniqueByDependants = isUniqueByDependants;
- caches.set( LEAF_KEY, cache );
- }
-
- return caches.get( LEAF_KEY );
- }
-
- // Assign cache handler by availability of WeakMap
- getCache = hasWeakMap ? getWeakMapCache : getRootCache;
-
- /**
- * Resets root memoization cache.
- */
- function clear() {
- rootCache = hasWeakMap ? new WeakMap() : createCache();
- }
-
- // eslint-disable-next-line jsdoc/check-param-names
- /**
- * The augmented selector call, considering first whether dependants have
- * changed before passing it to underlying memoize function.
- *
- * @param {Object} source Source object for derivation.
- * @param {...*} extraArgs Additional arguments to pass to selector.
- *
- * @return {*} Selector result.
- */
- function callSelector( /* source, ...extraArgs */ ) {
- var len = arguments.length,
- cache, node, i, args, dependants;
-
- // Create copy of arguments (avoid leaking deoptimization).
- args = new Array( len );
- for ( i = 0; i < len; i++ ) {
- args[ i ] = arguments[ i ];
- }
-
- dependants = getDependants.apply( null, args );
- cache = getCache( dependants );
-
- // If not guaranteed uniqueness by dependants (primitive type or lack
- // of WeakMap support), shallow compare against last dependants and, if
- // references have changed, destroy cache to recalculate result.
- if ( ! cache.isUniqueByDependants ) {
- if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) {
- cache.clear();
- }
-
- cache.lastDependants = dependants;
- }
-
- node = cache.head;
- while ( node ) {
- // Check whether node arguments match arguments
- if ( ! isShallowEqual( node.args, args, 1 ) ) {
- node = node.next;
- continue;
- }
-
- // At this point we can assume we've found a match
-
- // Surface matched node to head if not already
- if ( node !== cache.head ) {
- // Adjust siblings to point to each other.
- node.prev.next = node.next;
- if ( node.next ) {
- node.next.prev = node.prev;
- }
-
- node.next = cache.head;
- node.prev = null;
- cache.head.prev = node;
- cache.head = node;
- }
-
- // Return immediately
- return node.val;
- }
-
- // No cached value found. Continue to insertion phase:
-
- node = {
- // Generate the result from original function
- val: selector.apply( null, args ),
- };
-
- // Avoid including the source object in the cache.
- args[ 0 ] = null;
- node.args = args;
-
- // Don't need to check whether node is already head, since it would
- // have been returned above already if it was
-
- // Shift existing head down list
- if ( cache.head ) {
- cache.head.prev = node;
- node.next = cache.head;
- }
-
- cache.head = node;
-
- return node.val;
- }
-
- callSelector.getDependants = getDependants;
- callSelector.clear = clear;
- clear();
-
- return callSelector;
-}
-
-;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/selectors.js
-/**
- * External dependencies
- */
-
-
-/** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */
-
-/** @typedef {import('../api/registration').WPBlockVariationScope} WPBlockVariationScope */
-
-/** @typedef {import('./reducer').WPBlockCategory} WPBlockCategory */
-
-/**
- * Given a block name or block type object, returns the corresponding
- * normalized block type object.
- *
- * @param {Object} state Blocks state.
- * @param {(string|Object)} nameOrType Block name or type object
- *
- * @return {Object} Block type object.
- */
-
-const getNormalizedBlockType = (state, nameOrType) => 'string' === typeof nameOrType ? getBlockType(state, nameOrType) : nameOrType;
-/**
- * Returns all the unprocessed block types as passed during the registration.
- *
- * @param {Object} state Data state.
- *
- * @return {Array} Unprocessed block types.
- */
-
-
-function __experimentalGetUnprocessedBlockTypes(state) {
- return state.unprocessedBlockTypes;
-}
-/**
- * Returns all the available block types.
- *
- * @param {Object} state Data state.
- *
- * @return {Array} Block Types.
- */
-
-const getBlockTypes = rememo(state => Object.values(state.blockTypes), state => [state.blockTypes]);
-/**
- * Returns a block type by name.
- *
- * @param {Object} state Data state.
- * @param {string} name Block type name.
- *
- * @return {Object?} Block Type.
- */
-
-function getBlockType(state, name) {
- return state.blockTypes[name];
-}
-/**
- * Returns block styles by block name.
- *
- * @param {Object} state Data state.
- * @param {string} name Block type name.
- *
- * @return {Array?} Block Styles.
- */
-
-function getBlockStyles(state, name) {
- return state.blockStyles[name];
-}
-/**
- * Returns block variations by block name.
- *
- * @param {Object} state Data state.
- * @param {string} blockName Block type name.
- * @param {WPBlockVariationScope} [scope] Block variation scope name.
- *
- * @return {(WPBlockVariation[]|void)} Block variations.
- */
-
-const getBlockVariations = rememo((state, blockName, scope) => {
- const variations = state.blockVariations[blockName];
-
- if (!variations || !scope) {
- return variations;
- }
-
- return variations.filter(variation => {
- // For backward compatibility reasons, variation's scope defaults to
- // `block` and `inserter` when not set.
- return (variation.scope || ['block', 'inserter']).includes(scope);
- });
-}, (state, blockName) => [state.blockVariations[blockName]]);
-/**
- * Returns the active block variation for a given block based on its attributes.
- * Variations are determined by their `isActive` property.
- * Which is either an array of block attribute keys or a function.
- *
- * In case of an array of block attribute keys, the `attributes` are compared
- * to the variation's attributes using strict equality check.
- *
- * In case of function type, the function should accept a block's attributes
- * and the variation's attributes and determines if a variation is active.
- * A function that accepts a block's attributes and the variation's attributes and determines if a variation is active.
- *
- * @param {Object} state Data state.
- * @param {string} blockName Name of block (example: “core/columns”).
- * @param {Object} attributes Block attributes used to determine active variation.
- * @param {WPBlockVariationScope} [scope] Block variation scope name.
- *
- * @return {(WPBlockVariation|undefined)} Active block variation.
- */
-
-function getActiveBlockVariation(state, blockName, attributes, scope) {
- const variations = getBlockVariations(state, blockName, scope);
- const match = variations === null || variations === void 0 ? void 0 : variations.find(variation => {
- var _variation$isActive;
-
- if (Array.isArray(variation.isActive)) {
- const blockType = getBlockType(state, blockName);
- const attributeKeys = Object.keys((blockType === null || blockType === void 0 ? void 0 : blockType.attributes) || {});
- const definedAttributes = variation.isActive.filter(attribute => attributeKeys.includes(attribute));
-
- if (definedAttributes.length === 0) {
- return false;
- }
-
- return definedAttributes.every(attribute => attributes[attribute] === variation.attributes[attribute]);
- }
-
- return (_variation$isActive = variation.isActive) === null || _variation$isActive === void 0 ? void 0 : _variation$isActive.call(variation, attributes, variation.attributes);
- });
- return match;
-}
-/**
- * Returns the default block variation for the given block type.
- * When there are multiple variations annotated as the default one,
- * the last added item is picked. This simplifies registering overrides.
- * When there is no default variation set, it returns the first item.
- *
- * @param {Object} state Data state.
- * @param {string} blockName Block type name.
- * @param {WPBlockVariationScope} [scope] Block variation scope name.
- *
- * @return {?WPBlockVariation} The default block variation.
- */
-
-function getDefaultBlockVariation(state, blockName, scope) {
- const variations = getBlockVariations(state, blockName, scope);
- return (0,external_lodash_namespaceObject.findLast)(variations, 'isDefault') || (0,external_lodash_namespaceObject.first)(variations);
-}
-/**
- * Returns all the available categories.
- *
- * @param {Object} state Data state.
- *
- * @return {WPBlockCategory[]} Categories list.
- */
-
-function getCategories(state) {
- return state.categories;
-}
-/**
- * Returns all the available collections.
- *
- * @param {Object} state Data state.
- *
- * @return {Object} Collections list.
- */
-
-function getCollections(state) {
- return state.collections;
-}
-/**
- * Returns the name of the default block name.
- *
- * @param {Object} state Data state.
- *
- * @return {string?} Default block name.
- */
-
-function getDefaultBlockName(state) {
- return state.defaultBlockName;
-}
-/**
- * Returns the name of the block for handling non-block content.
- *
- * @param {Object} state Data state.
- *
- * @return {string?} Name of the block for handling non-block content.
- */
-
-function getFreeformFallbackBlockName(state) {
- return state.freeformFallbackBlockName;
-}
-/**
- * Returns the name of the block for handling unregistered blocks.
- *
- * @param {Object} state Data state.
- *
- * @return {string?} Name of the block for handling unregistered blocks.
- */
-
-function getUnregisteredFallbackBlockName(state) {
- return state.unregisteredFallbackBlockName;
-}
-/**
- * Returns the name of the block for handling unregistered blocks.
- *
- * @param {Object} state Data state.
- *
- * @return {string?} Name of the block for handling unregistered blocks.
- */
-
-function getGroupingBlockName(state) {
- return state.groupingBlockName;
-}
-/**
- * Returns an array with the child blocks of a given block.
- *
- * @param {Object} state Data state.
- * @param {string} blockName Block type name.
- *
- * @return {Array} Array of child block names.
- */
-
-const getChildBlockNames = rememo((state, blockName) => {
- return (0,external_lodash_namespaceObject.map)((0,external_lodash_namespaceObject.filter)(state.blockTypes, blockType => {
- return (0,external_lodash_namespaceObject.includes)(blockType.parent, blockName);
- }), _ref => {
- let {
- name
- } = _ref;
- return name;
- });
-}, state => [state.blockTypes]);
-/**
- * Returns the block support value for a feature, if defined.
- *
- * @param {Object} state Data state.
- * @param {(string|Object)} nameOrType Block name or type object
- * @param {Array|string} feature Feature to retrieve
- * @param {*} defaultSupports Default value to return if not
- * explicitly defined
- *
- * @return {?*} Block support value
- */
-
-const getBlockSupport = (state, nameOrType, feature, defaultSupports) => {
- const blockType = getNormalizedBlockType(state, nameOrType);
-
- if (!(blockType !== null && blockType !== void 0 && blockType.supports)) {
- return defaultSupports;
- }
-
- return (0,external_lodash_namespaceObject.get)(blockType.supports, feature, defaultSupports);
-};
-/**
- * Returns true if the block defines support for a feature, or false otherwise.
- *
- * @param {Object} state Data state.
- * @param {(string|Object)} nameOrType Block name or type object.
- * @param {string} feature Feature to test.
- * @param {boolean} defaultSupports Whether feature is supported by
- * default if not explicitly defined.
- *
- * @return {boolean} Whether block supports feature.
- */
-
-function hasBlockSupport(state, nameOrType, feature, defaultSupports) {
- return !!getBlockSupport(state, nameOrType, feature, defaultSupports);
-}
-/**
- * Returns true if the block type by the given name or object value matches a
- * search term, or false otherwise.
- *
- * @param {Object} state Blocks state.
- * @param {(string|Object)} nameOrType Block name or type object.
- * @param {string} searchTerm Search term by which to filter.
- *
- * @return {Object[]} Whether block type matches search term.
- */
-
-function isMatchingSearchTerm(state, nameOrType, searchTerm) {
- const blockType = getNormalizedBlockType(state, nameOrType);
- const getNormalizedSearchTerm = (0,external_lodash_namespaceObject.flow)([// Disregard diacritics.
- // Input: "média"
- external_lodash_namespaceObject.deburr, // Lowercase.
- // Input: "MEDIA"
- term => term.toLowerCase(), // Strip leading and trailing whitespace.
- // Input: " media "
- term => term.trim()]);
- const normalizedSearchTerm = getNormalizedSearchTerm(searchTerm);
- const isSearchMatch = (0,external_lodash_namespaceObject.flow)([getNormalizedSearchTerm, normalizedCandidate => (0,external_lodash_namespaceObject.includes)(normalizedCandidate, normalizedSearchTerm)]);
- return isSearchMatch(blockType.title) || (0,external_lodash_namespaceObject.some)(blockType.keywords, isSearchMatch) || isSearchMatch(blockType.category) || isSearchMatch(blockType.description);
-}
-/**
- * Returns a boolean indicating if a block has child blocks or not.
- *
- * @param {Object} state Data state.
- * @param {string} blockName Block type name.
- *
- * @return {boolean} True if a block contains child blocks and false otherwise.
- */
-
-const hasChildBlocks = (state, blockName) => {
- return getChildBlockNames(state, blockName).length > 0;
-};
-/**
- * Returns a boolean indicating if a block has at least one child block with inserter support.
- *
- * @param {Object} state Data state.
- * @param {string} blockName Block type name.
- *
- * @return {boolean} True if a block contains at least one child blocks with inserter support
- * and false otherwise.
- */
-
-const hasChildBlocksWithInserterSupport = (state, blockName) => {
- return (0,external_lodash_namespaceObject.some)(getChildBlockNames(state, blockName), childBlockName => {
- return hasBlockSupport(state, childBlockName, 'inserter', true);
- });
-};
-
-;// CONCATENATED MODULE: external ["wp","hooks"]
-var external_wp_hooks_namespaceObject = window["wp"]["hooks"];
+const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
;// CONCATENATED MODULE: ./node_modules/colord/index.mjs
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()})};
@@ -6414,17 +6473,19 @@
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}}
;// CONCATENATED MODULE: external ["wp","element"]
-var external_wp_element_namespaceObject = window["wp"]["element"];
+const external_wp_element_namespaceObject = window["wp"]["element"];
;// CONCATENATED MODULE: external ["wp","dom"]
-var external_wp_dom_namespaceObject = window["wp"]["dom"];
+const external_wp_dom_namespaceObject = window["wp"]["dom"];
+;// CONCATENATED MODULE: external ["wp","richText"]
+const external_wp_richText_namespaceObject = window["wp"]["richText"];
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/constants.js
const BLOCK_ICON_DEFAULT = 'block-default';
+
/**
* Array of valid keys in a block type settings deprecation object.
*
* @type {string[]}
*/
-
const DEPRECATED_ENTRY_KEYS = ['attributes', 'supports', 'save', 'migrate', 'isEligible', 'apiVersion'];
const __EXPERIMENTAL_STYLE_PROPERTY = {
// Kept for back-compatibility purposes.
@@ -6432,18 +6493,46 @@
value: ['color', 'link'],
support: ['color', 'link']
},
+ aspectRatio: {
+ value: ['dimensions', 'aspectRatio'],
+ support: ['dimensions', 'aspectRatio'],
+ useEngine: true
+ },
background: {
value: ['color', 'gradient'],
- support: ['color', 'gradients']
+ support: ['color', 'gradients'],
+ useEngine: true
},
backgroundColor: {
value: ['color', 'background'],
support: ['color', 'background'],
- requiresOptOut: true
+ requiresOptOut: true,
+ useEngine: true
+ },
+ backgroundImage: {
+ value: ['background', 'backgroundImage'],
+ support: ['background', 'backgroundImage'],
+ useEngine: true
+ },
+ backgroundRepeat: {
+ value: ['background', 'backgroundRepeat'],
+ support: ['background', 'backgroundRepeat'],
+ useEngine: true
+ },
+ backgroundSize: {
+ value: ['background', 'backgroundSize'],
+ support: ['background', 'backgroundSize'],
+ useEngine: true
+ },
+ backgroundPosition: {
+ value: ['background', 'backgroundPosition'],
+ support: ['background', 'backgroundPosition'],
+ useEngine: true
},
borderColor: {
value: ['border', 'color'],
- support: ['__experimentalBorder', 'color']
+ support: ['__experimentalBorder', 'color'],
+ useEngine: true
},
borderRadius: {
value: ['border', 'radius'],
@@ -6453,48 +6542,142 @@
borderTopRightRadius: 'topRight',
borderBottomLeftRadius: 'bottomLeft',
borderBottomRightRadius: 'bottomRight'
- }
+ },
+ useEngine: true
},
borderStyle: {
value: ['border', 'style'],
- support: ['__experimentalBorder', 'style']
+ support: ['__experimentalBorder', 'style'],
+ useEngine: true
},
borderWidth: {
value: ['border', 'width'],
- support: ['__experimentalBorder', 'width']
+ support: ['__experimentalBorder', 'width'],
+ useEngine: true
+ },
+ borderTopColor: {
+ value: ['border', 'top', 'color'],
+ support: ['__experimentalBorder', 'color'],
+ useEngine: true
+ },
+ borderTopStyle: {
+ value: ['border', 'top', 'style'],
+ support: ['__experimentalBorder', 'style'],
+ useEngine: true
+ },
+ borderTopWidth: {
+ value: ['border', 'top', 'width'],
+ support: ['__experimentalBorder', 'width'],
+ useEngine: true
+ },
+ borderRightColor: {
+ value: ['border', 'right', 'color'],
+ support: ['__experimentalBorder', 'color'],
+ useEngine: true
+ },
+ borderRightStyle: {
+ value: ['border', 'right', 'style'],
+ support: ['__experimentalBorder', 'style'],
+ useEngine: true
+ },
+ borderRightWidth: {
+ value: ['border', 'right', 'width'],
+ support: ['__experimentalBorder', 'width'],
+ useEngine: true
+ },
+ borderBottomColor: {
+ value: ['border', 'bottom', 'color'],
+ support: ['__experimentalBorder', 'color'],
+ useEngine: true
+ },
+ borderBottomStyle: {
+ value: ['border', 'bottom', 'style'],
+ support: ['__experimentalBorder', 'style'],
+ useEngine: true
+ },
+ borderBottomWidth: {
+ value: ['border', 'bottom', 'width'],
+ support: ['__experimentalBorder', 'width'],
+ useEngine: true
+ },
+ borderLeftColor: {
+ value: ['border', 'left', 'color'],
+ support: ['__experimentalBorder', 'color'],
+ useEngine: true
+ },
+ borderLeftStyle: {
+ value: ['border', 'left', 'style'],
+ support: ['__experimentalBorder', 'style'],
+ useEngine: true
+ },
+ borderLeftWidth: {
+ value: ['border', 'left', 'width'],
+ support: ['__experimentalBorder', 'width'],
+ useEngine: true
},
color: {
value: ['color', 'text'],
support: ['color', 'text'],
- requiresOptOut: true
+ requiresOptOut: true,
+ useEngine: true
+ },
+ columnCount: {
+ value: ['typography', 'textColumns'],
+ support: ['typography', 'textColumns'],
+ useEngine: true
},
filter: {
value: ['filter', 'duotone'],
- support: ['color', '__experimentalDuotone']
+ support: ['filter', 'duotone']
},
linkColor: {
value: ['elements', 'link', 'color', 'text'],
support: ['color', 'link']
},
+ captionColor: {
+ value: ['elements', 'caption', 'color', 'text'],
+ support: ['color', 'caption']
+ },
+ buttonColor: {
+ value: ['elements', 'button', 'color', 'text'],
+ support: ['color', 'button']
+ },
+ buttonBackgroundColor: {
+ value: ['elements', 'button', 'color', 'background'],
+ support: ['color', 'button']
+ },
+ headingColor: {
+ value: ['elements', 'heading', 'color', 'text'],
+ support: ['color', 'heading']
+ },
+ headingBackgroundColor: {
+ value: ['elements', 'heading', 'color', 'background'],
+ support: ['color', 'heading']
+ },
fontFamily: {
value: ['typography', 'fontFamily'],
- support: ['typography', '__experimentalFontFamily']
+ support: ['typography', '__experimentalFontFamily'],
+ useEngine: true
},
fontSize: {
value: ['typography', 'fontSize'],
- support: ['typography', 'fontSize']
+ support: ['typography', 'fontSize'],
+ useEngine: true
},
fontStyle: {
value: ['typography', 'fontStyle'],
- support: ['typography', '__experimentalFontStyle']
+ support: ['typography', '__experimentalFontStyle'],
+ useEngine: true
},
fontWeight: {
value: ['typography', 'fontWeight'],
- support: ['typography', '__experimentalFontWeight']
+ support: ['typography', '__experimentalFontWeight'],
+ useEngine: true
},
lineHeight: {
value: ['typography', 'lineHeight'],
- support: ['typography', 'lineHeight']
+ support: ['typography', 'lineHeight'],
+ useEngine: true
},
margin: {
value: ['spacing', 'margin'],
@@ -6507,6 +6690,11 @@
},
useEngine: true
},
+ minHeight: {
+ value: ['dimensions', 'minHeight'],
+ support: ['dimensions', 'minHeight'],
+ useEngine: true
+ },
padding: {
value: ['spacing', 'padding'],
support: ['spacing', 'padding'],
@@ -6518,48 +6706,85 @@
},
useEngine: true
},
+ textAlign: {
+ value: ['typography', 'textAlign'],
+ support: ['typography', 'textAlign'],
+ useEngine: false
+ },
textDecoration: {
value: ['typography', 'textDecoration'],
- support: ['typography', '__experimentalTextDecoration']
+ support: ['typography', '__experimentalTextDecoration'],
+ useEngine: true
},
textTransform: {
value: ['typography', 'textTransform'],
- support: ['typography', '__experimentalTextTransform']
+ support: ['typography', '__experimentalTextTransform'],
+ useEngine: true
},
letterSpacing: {
value: ['typography', 'letterSpacing'],
- support: ['typography', '__experimentalLetterSpacing']
+ support: ['typography', '__experimentalLetterSpacing'],
+ useEngine: true
+ },
+ writingMode: {
+ value: ['typography', 'writingMode'],
+ support: ['typography', '__experimentalWritingMode'],
+ useEngine: true
},
- '--wp--style--block-gap': {
- value: ['spacing', 'blockGap'],
- support: ['spacing', 'blockGap']
+ '--wp--style--root--padding': {
+ value: ['spacing', 'padding'],
+ support: ['spacing', 'padding'],
+ properties: {
+ '--wp--style--root--padding-top': 'top',
+ '--wp--style--root--padding-right': 'right',
+ '--wp--style--root--padding-bottom': 'bottom',
+ '--wp--style--root--padding-left': 'left'
+ },
+ rootOnly: true
}
};
const __EXPERIMENTAL_ELEMENTS = {
- link: 'a',
+ link: 'a:where(:not(.wp-element-button))',
+ heading: 'h1, h2, h3, h4, h5, h6',
h1: 'h1',
h2: 'h2',
h3: 'h3',
h4: 'h4',
h5: 'h5',
- h6: 'h6'
-};
-const __EXPERIMENTAL_PATHS_WITH_MERGE = {
+ h6: 'h6',
+ button: '.wp-element-button, .wp-block-button__link',
+ 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',
+ cite: 'cite'
+};
+
+// These paths may have three origins, custom, theme, and default,
+// and are expected to override other origins with custom, theme,
+// and default priority.
+const __EXPERIMENTAL_PATHS_WITH_OVERRIDE = {
'color.duotone': true,
'color.gradients': true,
'color.palette': true,
- 'typography.fontFamilies': true,
- 'typography.fontSizes': true
-};
+ 'dimensions.aspectRatios': true,
+ 'typography.fontSizes': true,
+ 'spacing.spacingSizes': true
+};
+
+;// CONCATENATED MODULE: external ["wp","privateApis"]
+const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
+;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/lock-unlock.js
+/**
+ * WordPress dependencies
+ */
+
+const {
+ lock,
+ unlock
+} = (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');
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/registration.js
/* eslint no-console: [ 'error', { allow: [ 'error', 'warn' ] } ] */
/**
- * External dependencies
- */
-
-/**
* WordPress dependencies
*/
@@ -6568,7 +6793,6 @@
/**
* Internal dependencies
*/
-
const i18nBlockSchema = {
title: "block title",
description: "block description",
@@ -6584,11 +6808,12 @@
};
+
/**
* An icon type definition. One of a Dashicon slug, an element,
* or a component.
*
- * @typedef {(string|WPElement|WPComponent)} WPIcon
+ * @typedef {(string|Element|Component)} WPIcon
*
* @see https://developer.wordpress.org/resource/dashicons/
*/
@@ -6683,10 +6908,10 @@
* @property {string[]} [keywords] Additional keywords to produce block
* type as result in search interfaces.
* @property {Object} [attributes] Block type attributes.
- * @property {WPComponent} [save] Optional component describing
+ * @property {Component} [save] Optional component describing
* serialized markup structure of a
* block type.
- * @property {WPComponent} edit Component rendering an element to
+ * @property {Component} edit Component rendering an element to
* manipulate the attributes of a block
* in the context of an editor.
* @property {WPBlockVariation[]} [variations] The list of block variations.
@@ -6695,40 +6920,25 @@
* then no preview is shown.
*/
-const serverSideBlockDefinitions = {};
+function isObject(object) {
+ return object !== null && typeof object === 'object';
+}
+
/**
* Sets the server side block definition of blocks.
*
* @param {Object} definitions Server-side block definitions
*/
// eslint-disable-next-line camelcase
-
function unstable__bootstrapServerSideBlockDefinitions(definitions) {
- for (const blockName of Object.keys(definitions)) {
- // Don't overwrite if already set. It covers the case when metadata
- // was initialized from the server.
- if (serverSideBlockDefinitions[blockName]) {
- // We still need to polyfill `apiVersion` for WordPress version
- // lower than 5.7. If it isn't present in the definition shared
- // from the server, we try to fallback to the definition passed.
- // @see https://github.com/WordPress/gutenberg/pull/29279
- if (serverSideBlockDefinitions[blockName].apiVersion === undefined && definitions[blockName].apiVersion) {
- serverSideBlockDefinitions[blockName].apiVersion = definitions[blockName].apiVersion;
- } // The `ancestor` prop is not included in the definitions shared
- // from the server yet, so it needs to be polyfilled as well.
- // @see https://github.com/WordPress/gutenberg/pull/39894
-
-
- if (serverSideBlockDefinitions[blockName].ancestor === undefined && definitions[blockName].ancestor) {
- serverSideBlockDefinitions[blockName].ancestor = definitions[blockName].ancestor;
- }
-
- continue;
- }
-
- 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));
- }
-}
+ const {
+ addBootstrappedBlockType
+ } = unlock((0,external_wp_data_namespaceObject.dispatch)(store));
+ for (const [name, blockType] of Object.entries(definitions)) {
+ addBootstrappedBlockType(name, blockType);
+ }
+}
+
/**
* Gets block settings from metadata loaded from `block.json` file.
*
@@ -6737,83 +6947,75 @@
*
* @return {Object} Block settings.
*/
-
-function getBlockSettingsFromMetadata(_ref) {
- let {
- textdomain,
- ...metadata
- } = _ref;
- const allowedFields = ['apiVersion', 'title', 'category', 'parent', 'ancestor', 'icon', 'description', 'keywords', 'attributes', 'providesContext', 'usesContext', 'supports', 'styles', 'example', 'variations'];
- const settings = (0,external_lodash_namespaceObject.pick)(metadata, allowedFields);
-
+function getBlockSettingsFromMetadata({
+ textdomain,
+ ...metadata
+}) {
+ const allowedFields = ['apiVersion', 'title', 'category', 'parent', 'ancestor', 'icon', 'description', 'keywords', 'attributes', 'providesContext', 'usesContext', 'selectors', 'supports', 'styles', 'example', 'variations', 'blockHooks', 'allowedBlocks'];
+ const settings = Object.fromEntries(Object.entries(metadata).filter(([key]) => allowedFields.includes(key)));
if (textdomain) {
Object.keys(i18nBlockSchema).forEach(key => {
if (!settings[key]) {
return;
}
-
settings[key] = translateBlockSettingUsingI18nSchema(i18nBlockSchema[key], settings[key], textdomain);
});
}
-
return settings;
}
+
/**
* Registers a new block provided a unique name and an object defining its
* behavior. Once registered, the block is made available as an option to any
* editor interface where blocks are implemented.
*
+ * For more in-depth information on registering a custom block see the
+ * [Create a block tutorial](https://developer.wordpress.org/block-editor/getting-started/create-block/).
+ *
* @param {string|Object} blockNameOrMetadata Block type name or its metadata.
* @param {Object} settings Block settings.
*
- * @return {?WPBlockType} The block, if it has been successfully registered;
+ * @example
+ * ```js
+ * import { __ } from '@wordpress/i18n';
+ * import { registerBlockType } from '@wordpress/blocks'
+ *
+ * registerBlockType( 'namespace/block-name', {
+ * title: __( 'My First Block' ),
+ * edit: () => <div>{ __( 'Hello from the editor!' ) }</div>,
+ * save: () => <div>Hello from the saved content!</div>,
+ * } );
+ * ```
+ *
+ * @return {WPBlockType | undefined} The block, if it has been successfully registered;
* otherwise `undefined`.
*/
-
-
function registerBlockType(blockNameOrMetadata, settings) {
- const name = (0,external_lodash_namespaceObject.isObject)(blockNameOrMetadata) ? blockNameOrMetadata.name : blockNameOrMetadata;
-
+ const name = isObject(blockNameOrMetadata) ? blockNameOrMetadata.name : blockNameOrMetadata;
if (typeof name !== 'string') {
console.error('Block names must be strings.');
return;
}
-
if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(name)) {
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');
return;
}
-
if ((0,external_wp_data_namespaceObject.select)(store).getBlockType(name)) {
console.error('Block "' + name + '" is already registered.');
return;
}
-
- if ((0,external_lodash_namespaceObject.isObject)(blockNameOrMetadata)) {
- unstable__bootstrapServerSideBlockDefinitions({
- [name]: getBlockSettingsFromMetadata(blockNameOrMetadata)
- });
- }
-
- const blockType = {
- name,
- icon: BLOCK_ICON_DEFAULT,
- keywords: [],
- attributes: {},
- providesContext: {},
- usesContext: [],
- supports: {},
- styles: [],
- variations: [],
- save: () => null,
- ...(serverSideBlockDefinitions === null || serverSideBlockDefinitions === void 0 ? void 0 : serverSideBlockDefinitions[name]),
- ...settings
- };
-
- (0,external_wp_data_namespaceObject.dispatch)(store).__experimentalRegisterBlockType(blockType);
-
+ const {
+ addBootstrappedBlockType,
+ addUnprocessedBlockType
+ } = unlock((0,external_wp_data_namespaceObject.dispatch)(store));
+ if (isObject(blockNameOrMetadata)) {
+ const metadata = getBlockSettingsFromMetadata(blockNameOrMetadata);
+ addBootstrappedBlockType(name, metadata);
+ }
+ addUnprocessedBlockType(name, settings);
return (0,external_wp_data_namespaceObject.select)(store).getBlockType(name);
}
+
/**
* Translates block settings provided with metadata using the i18n schema.
*
@@ -6823,31 +7025,27 @@
*
* @return {string|string[]|Object[]} Translated setting.
*/
-
function translateBlockSettingUsingI18nSchema(i18nSchema, settingValue, textdomain) {
- if ((0,external_lodash_namespaceObject.isString)(i18nSchema) && (0,external_lodash_namespaceObject.isString)(settingValue)) {
+ if (typeof i18nSchema === 'string' && typeof settingValue === 'string') {
// eslint-disable-next-line @wordpress/i18n-no-variables, @wordpress/i18n-text-domain
return (0,external_wp_i18n_namespaceObject._x)(settingValue, i18nSchema, textdomain);
}
-
- if ((0,external_lodash_namespaceObject.isArray)(i18nSchema) && !(0,external_lodash_namespaceObject.isEmpty)(i18nSchema) && (0,external_lodash_namespaceObject.isArray)(settingValue)) {
+ if (Array.isArray(i18nSchema) && i18nSchema.length && Array.isArray(settingValue)) {
return settingValue.map(value => translateBlockSettingUsingI18nSchema(i18nSchema[0], value, textdomain));
}
-
- if ((0,external_lodash_namespaceObject.isObject)(i18nSchema) && !(0,external_lodash_namespaceObject.isEmpty)(i18nSchema) && (0,external_lodash_namespaceObject.isObject)(settingValue)) {
+ if (isObject(i18nSchema) && Object.entries(i18nSchema).length && isObject(settingValue)) {
return Object.keys(settingValue).reduce((accumulator, key) => {
if (!i18nSchema[key]) {
accumulator[key] = settingValue[key];
return accumulator;
}
-
accumulator[key] = translateBlockSettingUsingI18nSchema(i18nSchema[key], settingValue[key], textdomain);
return accumulator;
}, {});
}
-
return settingValue;
}
+
/**
* Registers a new block collection to group blocks in the same namespace in the inserter.
*
@@ -6855,120 +7053,190 @@
* @param {Object} settings The block collection settings.
* @param {string} settings.title The title to display in the block inserter.
* @param {Object} [settings.icon] The icon to display in the block inserter.
- */
-
-
-function registerBlockCollection(namespace, _ref2) {
- let {
- title,
- icon
- } = _ref2;
+ *
+ * @example
+ * ```js
+ * import { __ } from '@wordpress/i18n';
+ * import { registerBlockCollection, registerBlockType } from '@wordpress/blocks';
+ *
+ * // Register the collection.
+ * registerBlockCollection( 'my-collection', {
+ * title: __( 'Custom Collection' ),
+ * } );
+ *
+ * // Register a block in the same namespace to add it to the collection.
+ * registerBlockType( 'my-collection/block-name', {
+ * title: __( 'My First Block' ),
+ * edit: () => <div>{ __( 'Hello from the editor!' ) }</div>,
+ * save: () => <div>'Hello from the saved content!</div>,
+ * } );
+ * ```
+ */
+function registerBlockCollection(namespace, {
+ title,
+ icon
+}) {
(0,external_wp_data_namespaceObject.dispatch)(store).addBlockCollection(namespace, title, icon);
}
+
/**
* Unregisters a block collection
*
* @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace
*
- */
-
+ * @example
+ * ```js
+ * import { unregisterBlockCollection } from '@wordpress/blocks';
+ *
+ * unregisterBlockCollection( 'my-collection' );
+ * ```
+ */
function unregisterBlockCollection(namespace) {
dispatch(blocksStore).removeBlockCollection(namespace);
}
+
/**
* Unregisters a block.
*
* @param {string} name Block name.
*
- * @return {?WPBlockType} The previous block value, if it has been successfully
+ * @example
+ * ```js
+ * import { __ } from '@wordpress/i18n';
+ * import { unregisterBlockType } from '@wordpress/blocks';
+ *
+ * const ExampleComponent = () => {
+ * return (
+ * <Button
+ * onClick={ () =>
+ * unregisterBlockType( 'my-collection/block-name' )
+ * }
+ * >
+ * { __( 'Unregister my custom block.' ) }
+ * </Button>
+ * );
+ * };
+ * ```
+ *
+ * @return {WPBlockType | undefined} The previous block value, if it has been successfully
* unregistered; otherwise `undefined`.
*/
-
function unregisterBlockType(name) {
const oldBlock = (0,external_wp_data_namespaceObject.select)(store).getBlockType(name);
-
if (!oldBlock) {
console.error('Block "' + name + '" is not registered.');
return;
}
-
(0,external_wp_data_namespaceObject.dispatch)(store).removeBlockTypes(name);
return oldBlock;
}
+
/**
* Assigns name of block for handling non-block content.
*
* @param {string} blockName Block name.
*/
-
function setFreeformContentHandlerName(blockName) {
(0,external_wp_data_namespaceObject.dispatch)(store).setFreeformFallbackBlockName(blockName);
}
+
/**
* Retrieves name of block handling non-block content, or undefined if no
* handler has been defined.
*
* @return {?string} Block name.
*/
-
function getFreeformContentHandlerName() {
return (0,external_wp_data_namespaceObject.select)(store).getFreeformFallbackBlockName();
}
+
/**
* Retrieves name of block used for handling grouping interactions.
*
* @return {?string} Block name.
*/
-
-function registration_getGroupingBlockName() {
+function getGroupingBlockName() {
return (0,external_wp_data_namespaceObject.select)(store).getGroupingBlockName();
}
+
/**
* Assigns name of block handling unregistered block types.
*
* @param {string} blockName Block name.
*/
-
function setUnregisteredTypeHandlerName(blockName) {
(0,external_wp_data_namespaceObject.dispatch)(store).setUnregisteredFallbackBlockName(blockName);
}
+
/**
* Retrieves name of block handling unregistered block types, or undefined if no
* handler has been defined.
*
* @return {?string} Block name.
*/
-
function getUnregisteredTypeHandlerName() {
return (0,external_wp_data_namespaceObject.select)(store).getUnregisteredFallbackBlockName();
}
+
/**
* Assigns the default block name.
*
* @param {string} name Block name.
- */
-
+ *
+ * @example
+ * ```js
+ * import { setDefaultBlockName } from '@wordpress/blocks';
+ *
+ * const ExampleComponent = () => {
+ *
+ * return (
+ * <Button onClick={ () => setDefaultBlockName( 'core/heading' ) }>
+ * { __( 'Set the default block to Heading' ) }
+ * </Button>
+ * );
+ * };
+ * ```
+ */
function setDefaultBlockName(name) {
(0,external_wp_data_namespaceObject.dispatch)(store).setDefaultBlockName(name);
}
+
/**
* Assigns name of block for handling block grouping interactions.
*
+ * This function lets you select a different block to group other blocks in instead of the
+ * default `core/group` block. This function must be used in a component or when the DOM is fully
+ * loaded. See https://developer.wordpress.org/block-editor/reference-guides/packages/packages-dom-ready/
+ *
* @param {string} name Block name.
- */
-
+ *
+ * @example
+ * ```js
+ * import { setGroupingBlockName } from '@wordpress/blocks';
+ *
+ * const ExampleComponent = () => {
+ *
+ * return (
+ * <Button onClick={ () => setGroupingBlockName( 'core/columns' ) }>
+ * { __( 'Wrap in columns' ) }
+ * </Button>
+ * );
+ * };
+ * ```
+ */
function setGroupingBlockName(name) {
(0,external_wp_data_namespaceObject.dispatch)(store).setGroupingBlockName(name);
}
+
/**
* Retrieves the default block name.
*
* @return {?string} Block name.
*/
-
-function registration_getDefaultBlockName() {
+function getDefaultBlockName() {
return (0,external_wp_data_namespaceObject.select)(store).getDefaultBlockName();
}
+
/**
* Returns a registered block type.
*
@@ -6976,21 +7244,19 @@
*
* @return {?Object} Block type.
*/
-
-function registration_getBlockType(name) {
- var _select;
-
- return (_select = (0,external_wp_data_namespaceObject.select)(store)) === null || _select === void 0 ? void 0 : _select.getBlockType(name);
-}
+function getBlockType(name) {
+ return (0,external_wp_data_namespaceObject.select)(store)?.getBlockType(name);
+}
+
/**
* Returns all registered blocks.
*
* @return {Array} Block settings.
*/
-
-function registration_getBlockTypes() {
+function getBlockTypes() {
return (0,external_wp_data_namespaceObject.select)(store).getBlockTypes();
}
+
/**
* Returns the block support value for a feature, if defined.
*
@@ -7001,10 +7267,10 @@
*
* @return {?*} Block support value
*/
-
-function registration_getBlockSupport(nameOrType, feature, defaultSupports) {
+function getBlockSupport(nameOrType, feature, defaultSupports) {
return (0,external_wp_data_namespaceObject.select)(store).getBlockSupport(nameOrType, feature, defaultSupports);
}
+
/**
* Returns true if the block defines support for a feature, or false otherwise.
*
@@ -7015,10 +7281,10 @@
*
* @return {boolean} Whether block supports feature.
*/
-
-function registration_hasBlockSupport(nameOrType, feature, defaultSupports) {
+function hasBlockSupport(nameOrType, feature, defaultSupports) {
return (0,external_wp_data_namespaceObject.select)(store).hasBlockSupport(nameOrType, feature, defaultSupports);
}
+
/**
* Determines whether or not the given block is a reusable block. This is a
* special block type that is used to point to a global block stored via the
@@ -7028,10 +7294,10 @@
*
* @return {boolean} Whether the given block is a reusable block.
*/
-
function isReusableBlock(blockOrType) {
- return (blockOrType === null || blockOrType === void 0 ? void 0 : blockOrType.name) === 'core/block';
-}
+ return blockOrType?.name === 'core/block';
+}
+
/**
* Determines whether or not the given block is a template part. This is a
* special block type that allows composing a page template out of reusable
@@ -7041,10 +7307,10 @@
*
* @return {boolean} Whether the given block is a template part.
*/
-
function isTemplatePart(blockOrType) {
- return blockOrType.name === 'core/template-part';
-}
+ return blockOrType?.name === 'core/template-part';
+}
+
/**
* Returns an array with the child blocks of a given block.
*
@@ -7052,10 +7318,10 @@
*
* @return {Array} Array of child block names.
*/
-
-const registration_getChildBlockNames = blockName => {
+const getChildBlockNames = blockName => {
return (0,external_wp_data_namespaceObject.select)(store).getChildBlockNames(blockName);
};
+
/**
* Returns a boolean indicating if a block has child blocks or not.
*
@@ -7063,10 +7329,10 @@
*
* @return {boolean} True if a block contains child blocks and false otherwise.
*/
-
-const registration_hasChildBlocks = blockName => {
+const hasChildBlocks = blockName => {
return (0,external_wp_data_namespaceObject.select)(store).hasChildBlocks(blockName);
};
+
/**
* Returns a boolean indicating if a block has at least one child block with inserter support.
*
@@ -7075,75 +7341,2407 @@
* @return {boolean} True if a block contains at least one child blocks with inserter support
* and false otherwise.
*/
-
-const registration_hasChildBlocksWithInserterSupport = blockName => {
+const hasChildBlocksWithInserterSupport = blockName => {
return (0,external_wp_data_namespaceObject.select)(store).hasChildBlocksWithInserterSupport(blockName);
};
-/**
- * Registers a new block style variation for the given block.
- *
- * @param {string} blockName Name of block (example: “core/latest-posts”).
- * @param {Object} styleVariation Object containing `name` which is the class name applied to the block and `label` which identifies the variation to the user.
- */
-
-const registerBlockStyle = (blockName, styleVariation) => {
- (0,external_wp_data_namespaceObject.dispatch)(store).addBlockStyles(blockName, styleVariation);
-};
-/**
- * Unregisters a block style variation for the given block.
+
+/**
+ * Registers a new block style for the given block types.
+ *
+ * For more information on connecting the styles with CSS
+ * [the official documentation](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-styles/#styles).
+ *
+ * @param {string|Array} blockNames Name of blocks e.g. “core/latest-posts” or `["core/group", "core/columns"]`.
+ * @param {Object} styleVariation Object containing `name` which is the class name applied to the block and `label` which identifies the variation to the user.
+ *
+ * @example
+ * ```js
+ * import { __ } from '@wordpress/i18n';
+ * import { registerBlockStyle } from '@wordpress/blocks';
+ * import { Button } from '@wordpress/components';
+ *
+ *
+ * const ExampleComponent = () => {
+ * return (
+ * <Button
+ * onClick={ () => {
+ * registerBlockStyle( 'core/quote', {
+ * name: 'fancy-quote',
+ * label: __( 'Fancy Quote' ),
+ * } );
+ * } }
+ * >
+ * { __( 'Add a new block style for core/quote' ) }
+ * </Button>
+ * );
+ * };
+ * ```
+ */
+const registerBlockStyle = (blockNames, styleVariation) => {
+ (0,external_wp_data_namespaceObject.dispatch)(store).addBlockStyles(blockNames, styleVariation);
+};
+
+/**
+ * Unregisters a block style for the given block.
*
* @param {string} blockName Name of block (example: “core/latest-posts”).
* @param {string} styleVariationName Name of class applied to the block.
- */
-
+ *
+ * @example
+ * ```js
+ * import { __ } from '@wordpress/i18n';
+ * import { unregisterBlockStyle } from '@wordpress/blocks';
+ * import { Button } from '@wordpress/components';
+ *
+ * const ExampleComponent = () => {
+ * return (
+ * <Button
+ * onClick={ () => {
+ * unregisterBlockStyle( 'core/quote', 'plain' );
+ * } }
+ * >
+ * { __( 'Remove the "Plain" block style for core/quote' ) }
+ * </Button>
+ * );
+ * };
+ * ```
+ */
const unregisterBlockStyle = (blockName, styleVariationName) => {
(0,external_wp_data_namespaceObject.dispatch)(store).removeBlockStyles(blockName, styleVariationName);
};
+
/**
* Returns an array with the variations of a given block type.
+ * Ignored from documentation as the recommended usage is via useSelect from @wordpress/data.
+ *
+ * @ignore
*
* @param {string} blockName Name of block (example: “core/columns”).
* @param {WPBlockVariationScope} [scope] Block variation scope name.
*
* @return {(WPBlockVariation[]|void)} Block variations.
*/
-
-const registration_getBlockVariations = (blockName, scope) => {
+const getBlockVariations = (blockName, scope) => {
return (0,external_wp_data_namespaceObject.select)(store).getBlockVariations(blockName, scope);
};
+
/**
* Registers a new block variation for the given block type.
*
+ * For more information on block variations see
+ * [the official documentation ](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-variations/).
+ *
* @param {string} blockName Name of the block (example: “core/columns”).
* @param {WPBlockVariation} variation Object describing a block variation.
- */
-
+ *
+ * @example
+ * ```js
+ * import { __ } from '@wordpress/i18n';
+ * import { registerBlockVariation } from '@wordpress/blocks';
+ * import { Button } from '@wordpress/components';
+ *
+ * const ExampleComponent = () => {
+ * return (
+ * <Button
+ * onClick={ () => {
+ * registerBlockVariation( 'core/embed', {
+ * name: 'custom',
+ * title: __( 'My Custom Embed' ),
+ * attributes: { providerNameSlug: 'custom' },
+ * } );
+ * } }
+ * >
+ * __( 'Add a custom variation for core/embed' ) }
+ * </Button>
+ * );
+ * };
+ * ```
+ */
const registerBlockVariation = (blockName, variation) => {
+ if (typeof variation.name !== 'string') {
+ console.warn('Variation names must be unique strings.');
+ }
(0,external_wp_data_namespaceObject.dispatch)(store).addBlockVariations(blockName, variation);
};
+
/**
* Unregisters a block variation defined for the given block type.
*
* @param {string} blockName Name of the block (example: “core/columns”).
* @param {string} variationName Name of the variation defined for the block.
- */
-
+ *
+ * @example
+ * ```js
+ * import { __ } from '@wordpress/i18n';
+ * import { unregisterBlockVariation } from '@wordpress/blocks';
+ * import { Button } from '@wordpress/components';
+ *
+ * const ExampleComponent = () => {
+ * return (
+ * <Button
+ * onClick={ () => {
+ * unregisterBlockVariation( 'core/embed', 'youtube' );
+ * } }
+ * >
+ * { __( 'Remove the YouTube variation from core/embed' ) }
+ * </Button>
+ * );
+ * };
+ * ```
+ */
const unregisterBlockVariation = (blockName, variationName) => {
(0,external_wp_data_namespaceObject.dispatch)(store).removeBlockVariations(blockName, variationName);
};
+;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/utils.js
+/**
+ * External dependencies
+ */
+
+
+
+
+/**
+ * WordPress dependencies
+ */
+
+
+
+
+
+/**
+ * Internal dependencies
+ */
+
+
+k([names, a11y]);
+
+/**
+ * Array of icon colors containing a color to be used if the icon color
+ * was not explicitly set but the icon background color was.
+ *
+ * @type {Object}
+ */
+const ICON_COLORS = ['#191e23', '#f8f9f9'];
+
+/**
+ * Determines whether the block's attributes are equal to the default attributes
+ * which means the block is unmodified.
+ *
+ * @param {WPBlock} block Block Object
+ *
+ * @return {boolean} Whether the block is an unmodified block.
+ */
+function isUnmodifiedBlock(block) {
+ var _getBlockType$attribu;
+ return Object.entries((_getBlockType$attribu = getBlockType(block.name)?.attributes) !== null && _getBlockType$attribu !== void 0 ? _getBlockType$attribu : {}).every(([key, definition]) => {
+ const value = block.attributes[key];
+
+ // Every attribute that has a default must match the default.
+ if (definition.hasOwnProperty('default')) {
+ return value === definition.default;
+ }
+
+ // The rich text type is a bit different from the rest because it
+ // has an implicit default value of an empty RichTextData instance,
+ // so check the length of the value.
+ if (definition.type === 'rich-text') {
+ return !value?.length;
+ }
+
+ // Every attribute that doesn't have a default should be undefined.
+ return value === undefined;
+ });
+}
+
+/**
+ * Determines whether the block is a default block and its attributes are equal
+ * to the default attributes which means the block is unmodified.
+ *
+ * @param {WPBlock} block Block Object
+ *
+ * @return {boolean} Whether the block is an unmodified default block.
+ */
+function isUnmodifiedDefaultBlock(block) {
+ return block.name === getDefaultBlockName() && isUnmodifiedBlock(block);
+}
+
+/**
+ * Function that checks if the parameter is a valid icon.
+ *
+ * @param {*} icon Parameter to be checked.
+ *
+ * @return {boolean} True if the parameter is a valid icon and false otherwise.
+ */
+
+function isValidIcon(icon) {
+ return !!icon && (typeof icon === 'string' || (0,external_wp_element_namespaceObject.isValidElement)(icon) || typeof icon === 'function' || icon instanceof external_wp_element_namespaceObject.Component);
+}
+
+/**
+ * Function that receives an icon as set by the blocks during the registration
+ * and returns a new icon object that is normalized so we can rely on just on possible icon structure
+ * in the codebase.
+ *
+ * @param {WPBlockTypeIconRender} icon Render behavior of a block type icon;
+ * one of a Dashicon slug, an element, or a
+ * component.
+ *
+ * @return {WPBlockTypeIconDescriptor} Object describing the icon.
+ */
+function normalizeIconObject(icon) {
+ icon = icon || BLOCK_ICON_DEFAULT;
+ if (isValidIcon(icon)) {
+ return {
+ src: icon
+ };
+ }
+ if ('background' in icon) {
+ const colordBgColor = w(icon.background);
+ const getColorContrast = iconColor => colordBgColor.contrast(iconColor);
+ const maxContrast = Math.max(...ICON_COLORS.map(getColorContrast));
+ return {
+ ...icon,
+ foreground: icon.foreground ? icon.foreground : ICON_COLORS.find(iconColor => getColorContrast(iconColor) === maxContrast),
+ shadowColor: colordBgColor.alpha(0.3).toRgbString()
+ };
+ }
+ return icon;
+}
+
+/**
+ * Normalizes block type passed as param. When string is passed then
+ * it converts it to the matching block type object.
+ * It passes the original object otherwise.
+ *
+ * @param {string|Object} blockTypeOrName Block type or name.
+ *
+ * @return {?Object} Block type.
+ */
+function normalizeBlockType(blockTypeOrName) {
+ if (typeof blockTypeOrName === 'string') {
+ return getBlockType(blockTypeOrName);
+ }
+ return blockTypeOrName;
+}
+
+/**
+ * Get the label for the block, usually this is either the block title,
+ * or the value of the block's `label` function when that's specified.
+ *
+ * @param {Object} blockType The block type.
+ * @param {Object} attributes The values of the block's attributes.
+ * @param {Object} context The intended use for the label.
+ *
+ * @return {string} The block label.
+ */
+function getBlockLabel(blockType, attributes, context = 'visual') {
+ const {
+ __experimentalLabel: getLabel,
+ title
+ } = blockType;
+ const label = getLabel && getLabel(attributes, {
+ context
+ });
+ if (!label) {
+ return title;
+ }
+ if (label.toPlainText) {
+ return label.toPlainText();
+ }
+
+ // Strip any HTML (i.e. RichText formatting) before returning.
+ return (0,external_wp_dom_namespaceObject.__unstableStripHTML)(label);
+}
+
+/**
+ * Get a label for the block for use by screenreaders, this is more descriptive
+ * than the visual label and includes the block title and the value of the
+ * `getLabel` function if it's specified.
+ *
+ * @param {?Object} blockType The block type.
+ * @param {Object} attributes The values of the block's attributes.
+ * @param {?number} position The position of the block in the block list.
+ * @param {string} [direction='vertical'] The direction of the block layout.
+ *
+ * @return {string} The block label.
+ */
+function getAccessibleBlockLabel(blockType, attributes, position, direction = 'vertical') {
+ // `title` is already localized, `label` is a user-supplied value.
+ const title = blockType?.title;
+ const label = blockType ? getBlockLabel(blockType, attributes, 'accessibility') : '';
+ const hasPosition = position !== undefined;
+
+ // getBlockLabel returns the block title as a fallback when there's no label,
+ // if it did return the title, this function needs to avoid adding the
+ // title twice within the accessible label. Use this `hasLabel` boolean to
+ // handle that.
+ const hasLabel = label && label !== title;
+ if (hasPosition && direction === 'vertical') {
+ if (hasLabel) {
+ return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. 1: The block title. 2: The block row number. 3: The block label.. */
+ (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Row %2$d. %3$s'), title, position, label);
+ }
+ return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. 1: The block title. 2: The block row number. */
+ (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Row %2$d'), title, position);
+ } else if (hasPosition && direction === 'horizontal') {
+ if (hasLabel) {
+ return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. 1: The block title. 2: The block column number. 3: The block label.. */
+ (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Column %2$d. %3$s'), title, position, label);
+ }
+ return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. 1: The block title. 2: The block column number. */
+ (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Column %2$d'), title, position);
+ }
+ if (hasLabel) {
+ return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. %1: The block title. %2: The block label. */
+ (0,external_wp_i18n_namespaceObject.__)('%1$s Block. %2$s'), title, label);
+ }
+ return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: accessibility text. %s: The block title. */
+ (0,external_wp_i18n_namespaceObject.__)('%s Block'), title);
+}
+function getDefault(attributeSchema) {
+ if (attributeSchema.default !== undefined) {
+ return attributeSchema.default;
+ }
+ if (attributeSchema.type === 'rich-text') {
+ return new external_wp_richText_namespaceObject.RichTextData();
+ }
+}
+
+/**
+ * Ensure attributes contains only values defined by block type, and merge
+ * default values for missing attributes.
+ *
+ * @param {string} name The block's name.
+ * @param {Object} attributes The block's attributes.
+ * @return {Object} The sanitized attributes.
+ */
+function __experimentalSanitizeBlockAttributes(name, attributes) {
+ // Get the type definition associated with a registered block.
+ const blockType = getBlockType(name);
+ if (undefined === blockType) {
+ throw new Error(`Block type '${name}' is not registered.`);
+ }
+ return Object.entries(blockType.attributes).reduce((accumulator, [key, schema]) => {
+ const value = attributes[key];
+ if (undefined !== value) {
+ if (schema.type === 'rich-text') {
+ if (value instanceof external_wp_richText_namespaceObject.RichTextData) {
+ accumulator[key] = value;
+ } else if (typeof value === 'string') {
+ accumulator[key] = external_wp_richText_namespaceObject.RichTextData.fromHTMLString(value);
+ }
+ } else if (schema.type === 'string' && value instanceof external_wp_richText_namespaceObject.RichTextData) {
+ accumulator[key] = value.toHTMLString();
+ } else {
+ accumulator[key] = value;
+ }
+ } else {
+ const _default = getDefault(schema);
+ if (undefined !== _default) {
+ accumulator[key] = _default;
+ }
+ }
+ if (['node', 'children'].indexOf(schema.source) !== -1) {
+ // Ensure value passed is always an array, which we're expecting in
+ // the RichText component to handle the deprecated value.
+ if (typeof accumulator[key] === 'string') {
+ accumulator[key] = [accumulator[key]];
+ } else if (!Array.isArray(accumulator[key])) {
+ accumulator[key] = [];
+ }
+ }
+ return accumulator;
+ }, {});
+}
+
+/**
+ * Filter block attributes by `role` and return their names.
+ *
+ * @param {string} name Block attribute's name.
+ * @param {string} role The role of a block attribute.
+ *
+ * @return {string[]} The attribute names that have the provided role.
+ */
+function __experimentalGetBlockAttributesNamesByRole(name, role) {
+ const attributes = getBlockType(name)?.attributes;
+ if (!attributes) {
+ return [];
+ }
+ const attributesNames = Object.keys(attributes);
+ if (!role) {
+ return attributesNames;
+ }
+ return attributesNames.filter(attributeName => attributes[attributeName]?.__experimentalRole === role);
+}
+
+/**
+ * Return a new object with the specified keys omitted.
+ *
+ * @param {Object} object Original object.
+ * @param {Array} keys Keys to be omitted.
+ *
+ * @return {Object} Object with omitted keys.
+ */
+function omit(object, keys) {
+ return Object.fromEntries(Object.entries(object).filter(([key]) => !keys.includes(key)));
+}
+
+;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/reducer.js
+/**
+ * External dependencies
+ */
+
+
+/**
+ * WordPress dependencies
+ */
+
+
+
+/**
+ * Internal dependencies
+ */
+
+
+/**
+ * @typedef {Object} WPBlockCategory
+ *
+ * @property {string} slug Unique category slug.
+ * @property {string} title Category label, for display in user interface.
+ */
+
+/**
+ * Default set of categories.
+ *
+ * @type {WPBlockCategory[]}
+ */
+const DEFAULT_CATEGORIES = [{
+ slug: 'text',
+ title: (0,external_wp_i18n_namespaceObject.__)('Text')
+}, {
+ slug: 'media',
+ title: (0,external_wp_i18n_namespaceObject.__)('Media')
+}, {
+ slug: 'design',
+ title: (0,external_wp_i18n_namespaceObject.__)('Design')
+}, {
+ slug: 'widgets',
+ title: (0,external_wp_i18n_namespaceObject.__)('Widgets')
+}, {
+ slug: 'theme',
+ title: (0,external_wp_i18n_namespaceObject.__)('Theme')
+}, {
+ slug: 'embed',
+ title: (0,external_wp_i18n_namespaceObject.__)('Embeds')
+}, {
+ slug: 'reusable',
+ title: (0,external_wp_i18n_namespaceObject.__)('Reusable blocks')
+}];
+
+// Key block types by their name.
+function keyBlockTypesByName(types) {
+ return types.reduce((newBlockTypes, block) => ({
+ ...newBlockTypes,
+ [block.name]: block
+ }), {});
+}
+
+// Filter items to ensure they're unique by their name.
+function getUniqueItemsByName(items) {
+ return items.reduce((acc, currentItem) => {
+ if (!acc.some(item => item.name === currentItem.name)) {
+ acc.push(currentItem);
+ }
+ return acc;
+ }, []);
+}
+function bootstrappedBlockTypes(state = {}, action) {
+ switch (action.type) {
+ case 'ADD_BOOTSTRAPPED_BLOCK_TYPE':
+ const {
+ name,
+ blockType
+ } = action;
+ const serverDefinition = state[name];
+ let newDefinition;
+ // Don't overwrite if already set. It covers the case when metadata
+ // was initialized from the server.
+ if (serverDefinition) {
+ // The `blockHooks` prop is not yet included in the server provided
+ // definitions and needs to be polyfilled. This can be removed when the
+ // minimum supported WordPress is >= 6.4.
+ if (serverDefinition.blockHooks === undefined && blockType.blockHooks) {
+ newDefinition = {
+ ...serverDefinition,
+ ...newDefinition,
+ blockHooks: blockType.blockHooks
+ };
+ }
+
+ // The `allowedBlocks` prop is not yet included in the server provided
+ // definitions and needs to be polyfilled. This can be removed when the
+ // minimum supported WordPress is >= 6.5.
+ if (serverDefinition.allowedBlocks === undefined && blockType.allowedBlocks) {
+ newDefinition = {
+ ...serverDefinition,
+ ...newDefinition,
+ allowedBlocks: blockType.allowedBlocks
+ };
+ }
+ } else {
+ newDefinition = Object.fromEntries(Object.entries(blockType).filter(([, value]) => value !== null && value !== undefined).map(([key, value]) => [camelCase(key), value]));
+ newDefinition.name = name;
+ }
+ if (newDefinition) {
+ return {
+ ...state,
+ [name]: newDefinition
+ };
+ }
+ return state;
+ case 'REMOVE_BLOCK_TYPES':
+ return omit(state, action.names);
+ }
+ return state;
+}
+
+/**
+ * Reducer managing the unprocessed block types in a form passed when registering the by block.
+ * It's for internal use only. It allows recomputing the processed block types on-demand after block type filters
+ * get added or removed.
+ *
+ * @param {Object} state Current state.
+ * @param {Object} action Dispatched action.
+ *
+ * @return {Object} Updated state.
+ */
+function unprocessedBlockTypes(state = {}, action) {
+ switch (action.type) {
+ case 'ADD_UNPROCESSED_BLOCK_TYPE':
+ return {
+ ...state,
+ [action.name]: action.blockType
+ };
+ case 'REMOVE_BLOCK_TYPES':
+ return omit(state, action.names);
+ }
+ return state;
+}
+
+/**
+ * Reducer managing the processed block types with all filters applied.
+ * The state is derived from the `unprocessedBlockTypes` reducer.
+ *
+ * @param {Object} state Current state.
+ * @param {Object} action Dispatched action.
+ *
+ * @return {Object} Updated state.
+ */
+function blockTypes(state = {}, action) {
+ switch (action.type) {
+ case 'ADD_BLOCK_TYPES':
+ return {
+ ...state,
+ ...keyBlockTypesByName(action.blockTypes)
+ };
+ case 'REMOVE_BLOCK_TYPES':
+ return omit(state, action.names);
+ }
+ return state;
+}
+
+/**
+ * Reducer managing the block styles.
+ *
+ * @param {Object} state Current state.
+ * @param {Object} action Dispatched action.
+ *
+ * @return {Object} Updated state.
+ */
+function blockStyles(state = {}, action) {
+ var _state$action$blockNa;
+ switch (action.type) {
+ case 'ADD_BLOCK_TYPES':
+ return {
+ ...state,
+ ...Object.fromEntries(Object.entries(keyBlockTypesByName(action.blockTypes)).map(([name, blockType]) => {
+ var _blockType$styles, _state$blockType$name;
+ return [name, getUniqueItemsByName([...((_blockType$styles = blockType.styles) !== null && _blockType$styles !== void 0 ? _blockType$styles : []).map(style => ({
+ ...style,
+ source: 'block'
+ })), ...((_state$blockType$name = state[blockType.name]) !== null && _state$blockType$name !== void 0 ? _state$blockType$name : []).filter(({
+ source
+ }) => 'block' !== source)])];
+ }))
+ };
+ case 'ADD_BLOCK_STYLES':
+ const updatedStyles = {};
+ action.blockNames.forEach(blockName => {
+ var _state$blockName;
+ updatedStyles[blockName] = getUniqueItemsByName([...((_state$blockName = state[blockName]) !== null && _state$blockName !== void 0 ? _state$blockName : []), ...action.styles]);
+ });
+ return {
+ ...state,
+ ...updatedStyles
+ };
+ case 'REMOVE_BLOCK_STYLES':
+ return {
+ ...state,
+ [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)
+ };
+ }
+ return state;
+}
+
+/**
+ * Reducer managing the block variations.
+ *
+ * @param {Object} state Current state.
+ * @param {Object} action Dispatched action.
+ *
+ * @return {Object} Updated state.
+ */
+function blockVariations(state = {}, action) {
+ var _state$action$blockNa2, _state$action$blockNa3;
+ switch (action.type) {
+ case 'ADD_BLOCK_TYPES':
+ return {
+ ...state,
+ ...Object.fromEntries(Object.entries(keyBlockTypesByName(action.blockTypes)).map(([name, blockType]) => {
+ var _blockType$variations, _state$blockType$name2;
+ return [name, getUniqueItemsByName([...((_blockType$variations = blockType.variations) !== null && _blockType$variations !== void 0 ? _blockType$variations : []).map(variation => ({
+ ...variation,
+ source: 'block'
+ })), ...((_state$blockType$name2 = state[blockType.name]) !== null && _state$blockType$name2 !== void 0 ? _state$blockType$name2 : []).filter(({
+ source
+ }) => 'block' !== source)])];
+ }))
+ };
+ case 'ADD_BLOCK_VARIATIONS':
+ return {
+ ...state,
+ [action.blockName]: getUniqueItemsByName([...((_state$action$blockNa2 = state[action.blockName]) !== null && _state$action$blockNa2 !== void 0 ? _state$action$blockNa2 : []), ...action.variations])
+ };
+ case 'REMOVE_BLOCK_VARIATIONS':
+ return {
+ ...state,
+ [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)
+ };
+ }
+ return state;
+}
+
+/**
+ * Higher-order Reducer creating a reducer keeping track of given block name.
+ *
+ * @param {string} setActionType Action type.
+ *
+ * @return {Function} Reducer.
+ */
+function createBlockNameSetterReducer(setActionType) {
+ return (state = null, action) => {
+ switch (action.type) {
+ case 'REMOVE_BLOCK_TYPES':
+ if (action.names.indexOf(state) !== -1) {
+ return null;
+ }
+ return state;
+ case setActionType:
+ return action.name || null;
+ }
+ return state;
+ };
+}
+const defaultBlockName = createBlockNameSetterReducer('SET_DEFAULT_BLOCK_NAME');
+const freeformFallbackBlockName = createBlockNameSetterReducer('SET_FREEFORM_FALLBACK_BLOCK_NAME');
+const unregisteredFallbackBlockName = createBlockNameSetterReducer('SET_UNREGISTERED_FALLBACK_BLOCK_NAME');
+const groupingBlockName = createBlockNameSetterReducer('SET_GROUPING_BLOCK_NAME');
+
+/**
+ * Reducer managing the categories
+ *
+ * @param {WPBlockCategory[]} state Current state.
+ * @param {Object} action Dispatched action.
+ *
+ * @return {WPBlockCategory[]} Updated state.
+ */
+function categories(state = DEFAULT_CATEGORIES, action) {
+ switch (action.type) {
+ case 'SET_CATEGORIES':
+ return action.categories || [];
+ case 'UPDATE_CATEGORY':
+ {
+ if (!action.category || !Object.keys(action.category).length) {
+ return state;
+ }
+ const categoryToChange = state.find(({
+ slug
+ }) => slug === action.slug);
+ if (categoryToChange) {
+ return state.map(category => {
+ if (category.slug === action.slug) {
+ return {
+ ...category,
+ ...action.category
+ };
+ }
+ return category;
+ });
+ }
+ }
+ }
+ return state;
+}
+function collections(state = {}, action) {
+ switch (action.type) {
+ case 'ADD_BLOCK_COLLECTION':
+ return {
+ ...state,
+ [action.namespace]: {
+ title: action.title,
+ icon: action.icon
+ }
+ };
+ case 'REMOVE_BLOCK_COLLECTION':
+ return omit(state, action.namespace);
+ }
+ return state;
+}
+function blockBindingsSources(state = {}, action) {
+ if (action.type === 'REGISTER_BLOCK_BINDINGS_SOURCE') {
+ return {
+ ...state,
+ [action.sourceName]: {
+ label: action.sourceLabel,
+ getValue: action.getValue,
+ setValue: action.setValue,
+ setValues: action.setValues,
+ getPlaceholder: action.getPlaceholder,
+ canUserEditValue: action.canUserEditValue || (() => false)
+ }
+ };
+ }
+ return state;
+}
+/* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
+ bootstrappedBlockTypes,
+ unprocessedBlockTypes,
+ blockTypes,
+ blockStyles,
+ blockVariations,
+ defaultBlockName,
+ freeformFallbackBlockName,
+ unregisteredFallbackBlockName,
+ groupingBlockName,
+ categories,
+ collections,
+ blockBindingsSources
+}));
+
+// EXTERNAL MODULE: ./node_modules/remove-accents/index.js
+var remove_accents = __webpack_require__(9681);
+var remove_accents_default = /*#__PURE__*/__webpack_require__.n(remove_accents);
+;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/utils.js
+/**
+ * Helper util to return a value from a certain path of the object.
+ * Path is specified as either:
+ * - a string of properties, separated by dots, for example: "x.y".
+ * - an array of properties, for example `[ 'x', 'y' ]`.
+ * You can also specify a default value in case the result is nullish.
+ *
+ * @param {Object} object Input object.
+ * @param {string|Array} path Path to the object property.
+ * @param {*} defaultValue Default value if the value at the specified path is nullish.
+ * @return {*} Value of the object property at the specified path.
+ */
+const getValueFromObjectPath = (object, path, defaultValue) => {
+ var _value;
+ const normalizedPath = Array.isArray(path) ? path : path.split('.');
+ let value = object;
+ normalizedPath.forEach(fieldName => {
+ value = value?.[fieldName];
+ });
+ return (_value = value) !== null && _value !== void 0 ? _value : defaultValue;
+};
+function utils_isObject(candidate) {
+ return typeof candidate === 'object' && candidate.constructor === Object && candidate !== null;
+}
+
+/**
+ * Determine whether a set of object properties matches a given object.
+ *
+ * Given an object of block attributes and an object of variation attributes,
+ * this function checks recursively whether all the variation attributes are
+ * present in the block attributes object.
+ *
+ * @param {Object} blockAttributes The object to inspect.
+ * @param {Object} variationAttributes The object of property values to match.
+ * @return {boolean} Whether the block attributes match the variation attributes.
+ */
+function matchesAttributes(blockAttributes, variationAttributes) {
+ if (utils_isObject(blockAttributes) && utils_isObject(variationAttributes)) {
+ return Object.entries(variationAttributes).every(([key, value]) => matchesAttributes(blockAttributes?.[key], value));
+ }
+ return blockAttributes === variationAttributes;
+}
+
+;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/selectors.js
+/**
+ * External dependencies
+ */
+
+
+/**
+ * WordPress dependencies
+ */
+
+
+
+/**
+ * Internal dependencies
+ */
+
+
+/** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */
+/** @typedef {import('../api/registration').WPBlockVariationScope} WPBlockVariationScope */
+/** @typedef {import('./reducer').WPBlockCategory} WPBlockCategory */
+
+/**
+ * Given a block name or block type object, returns the corresponding
+ * normalized block type object.
+ *
+ * @param {Object} state Blocks state.
+ * @param {(string|Object)} nameOrType Block name or type object
+ *
+ * @return {Object} Block type object.
+ */
+const getNormalizedBlockType = (state, nameOrType) => 'string' === typeof nameOrType ? selectors_getBlockType(state, nameOrType) : nameOrType;
+
+/**
+ * Returns all the available block types.
+ *
+ * @param {Object} state Data state.
+ *
+ * @example
+ * ```js
+ * import { store as blocksStore } from '@wordpress/blocks';
+ * import { useSelect } from '@wordpress/data';
+ *
+ * const ExampleComponent = () => {
+ * const blockTypes = useSelect(
+ * ( select ) => select( blocksStore ).getBlockTypes(),
+ * []
+ * );
+ *
+ * return (
+ * <ul>
+ * { blockTypes.map( ( block ) => (
+ * <li key={ block.name }>{ block.title }</li>
+ * ) ) }
+ * </ul>
+ * );
+ * };
+ * ```
+ *
+ * @return {Array} Block Types.
+ */
+const selectors_getBlockTypes = (0,external_wp_data_namespaceObject.createSelector)(state => Object.values(state.blockTypes), state => [state.blockTypes]);
+
+/**
+ * Returns a block type by name.
+ *
+ * @param {Object} state Data state.
+ * @param {string} name Block type name.
+ *
+ * @example
+ * ```js
+ * import { store as blocksStore } from '@wordpress/blocks';
+ * import { useSelect } from '@wordpress/data';
+ *
+ * const ExampleComponent = () => {
+ * const paragraphBlock = useSelect( ( select ) =>
+ * ( select ) => select( blocksStore ).getBlockType( 'core/paragraph' ),
+ * []
+ * );
+ *
+ * return (
+ * <ul>
+ * { paragraphBlock &&
+ * Object.entries( paragraphBlock.supports ).map(
+ * ( blockSupportsEntry ) => {
+ * const [ propertyName, value ] = blockSupportsEntry;
+ * return (
+ * <li
+ * key={ propertyName }
+ * >{ `${ propertyName } : ${ value }` }</li>
+ * );
+ * }
+ * ) }
+ * </ul>
+ * );
+ * };
+ * ```
+ *
+ * @return {Object?} Block Type.
+ */
+function selectors_getBlockType(state, name) {
+ return state.blockTypes[name];
+}
+
+/**
+ * Returns block styles by block name.
+ *
+ * @param {Object} state Data state.
+ * @param {string} name Block type name.
+ *
+ * @example
+ * ```js
+ * import { store as blocksStore } from '@wordpress/blocks';
+ * import { useSelect } from '@wordpress/data';
+ *
+ * const ExampleComponent = () => {
+ * const buttonBlockStyles = useSelect( ( select ) =>
+ * select( blocksStore ).getBlockStyles( 'core/button' ),
+ * []
+ * );
+ *
+ * return (
+ * <ul>
+ * { buttonBlockStyles &&
+ * buttonBlockStyles.map( ( style ) => (
+ * <li key={ style.name }>{ style.label }</li>
+ * ) ) }
+ * </ul>
+ * );
+ * };
+ * ```
+ *
+ * @return {Array?} Block Styles.
+ */
+function getBlockStyles(state, name) {
+ return state.blockStyles[name];
+}
+
+/**
+ * Returns block variations by block name.
+ *
+ * @param {Object} state Data state.
+ * @param {string} blockName Block type name.
+ * @param {WPBlockVariationScope} [scope] Block variation scope name.
+ *
+ * @example
+ * ```js
+ * import { store as blocksStore } from '@wordpress/blocks';
+ * import { useSelect } from '@wordpress/data';
+ *
+ * const ExampleComponent = () => {
+ * const socialLinkVariations = useSelect( ( select ) =>
+ * select( blocksStore ).getBlockVariations( 'core/social-link' ),
+ * []
+ * );
+ *
+ * return (
+ * <ul>
+ * { socialLinkVariations &&
+ * socialLinkVariations.map( ( variation ) => (
+ * <li key={ variation.name }>{ variation.title }</li>
+ * ) ) }
+ * </ul>
+ * );
+ * };
+ * ```
+ *
+ * @return {(WPBlockVariation[]|void)} Block variations.
+ */
+const selectors_getBlockVariations = (0,external_wp_data_namespaceObject.createSelector)((state, blockName, scope) => {
+ const variations = state.blockVariations[blockName];
+ if (!variations || !scope) {
+ return variations;
+ }
+ return variations.filter(variation => {
+ // For backward compatibility reasons, variation's scope defaults to
+ // `block` and `inserter` when not set.
+ return (variation.scope || ['block', 'inserter']).includes(scope);
+ });
+}, (state, blockName) => [state.blockVariations[blockName]]);
+
+/**
+ * Returns the active block variation for a given block based on its attributes.
+ * Variations are determined by their `isActive` property.
+ * Which is either an array of block attribute keys or a function.
+ *
+ * In case of an array of block attribute keys, the `attributes` are compared
+ * to the variation's attributes using strict equality check.
+ *
+ * In case of function type, the function should accept a block's attributes
+ * and the variation's attributes and determines if a variation is active.
+ * A function that accepts a block's attributes and the variation's attributes and determines if a variation is active.
+ *
+ * @param {Object} state Data state.
+ * @param {string} blockName Name of block (example: “core/columns”).
+ * @param {Object} attributes Block attributes used to determine active variation.
+ * @param {WPBlockVariationScope} [scope] Block variation scope name.
+ *
+ * @example
+ * ```js
+ * import { __ } from '@wordpress/i18n';
+ * import { store as blocksStore } from '@wordpress/blocks';
+ * import { store as blockEditorStore } from '@wordpress/block-editor';
+ * import { useSelect } from '@wordpress/data';
+ *
+ * const ExampleComponent = () => {
+ * // This example assumes that a core/embed block is the first block in the Block Editor.
+ * const activeBlockVariation = useSelect( ( select ) => {
+ * // Retrieve the list of blocks.
+ * const [ firstBlock ] = select( blockEditorStore ).getBlocks()
+ *
+ * // Return the active block variation for the first block.
+ * return select( blocksStore ).getActiveBlockVariation(
+ * firstBlock.name,
+ * firstBlock.attributes
+ * );
+ * }, [] );
+ *
+ * return activeBlockVariation && activeBlockVariation.name === 'spotify' ? (
+ * <p>{ __( 'Spotify variation' ) }</p>
+ * ) : (
+ * <p>{ __( 'Other variation' ) }</p>
+ * );
+ * };
+ * ```
+ *
+ * @return {(WPBlockVariation|undefined)} Active block variation.
+ */
+function getActiveBlockVariation(state, blockName, attributes, scope) {
+ const variations = selectors_getBlockVariations(state, blockName, scope);
+ if (!variations) {
+ return variations;
+ }
+ const blockType = selectors_getBlockType(state, blockName);
+ const attributeKeys = Object.keys(blockType?.attributes || {});
+ let match;
+ let maxMatchedAttributes = 0;
+ for (const variation of variations) {
+ if (Array.isArray(variation.isActive)) {
+ const definedAttributes = variation.isActive.filter(attribute => {
+ // We support nested attribute paths, e.g. `layout.type`.
+ // In this case, we need to check if the part before the
+ // first dot is a known attribute.
+ const topLevelAttribute = attribute.split('.')[0];
+ return attributeKeys.includes(topLevelAttribute);
+ });
+ const definedAttributesLength = definedAttributes.length;
+ if (definedAttributesLength === 0) {
+ continue;
+ }
+ const isMatch = definedAttributes.every(attribute => {
+ const variationAttributeValue = getValueFromObjectPath(variation.attributes, attribute);
+ if (variationAttributeValue === undefined) {
+ return false;
+ }
+ let blockAttributeValue = getValueFromObjectPath(attributes, attribute);
+ if (blockAttributeValue instanceof external_wp_richText_namespaceObject.RichTextData) {
+ blockAttributeValue = blockAttributeValue.toHTMLString();
+ }
+ return matchesAttributes(blockAttributeValue, variationAttributeValue);
+ });
+ if (isMatch && definedAttributesLength > maxMatchedAttributes) {
+ match = variation;
+ maxMatchedAttributes = definedAttributesLength;
+ }
+ } else if (variation.isActive?.(attributes, variation.attributes)) {
+ // If isActive is a function, we cannot know how many attributes it matches.
+ // This means that we cannot compare the specificity of our matches,
+ // and simply return the best match we have found.
+ return match || variation;
+ }
+ }
+ return match;
+}
+
+/**
+ * Returns the default block variation for the given block type.
+ * When there are multiple variations annotated as the default one,
+ * the last added item is picked. This simplifies registering overrides.
+ * When there is no default variation set, it returns the first item.
+ *
+ * @param {Object} state Data state.
+ * @param {string} blockName Block type name.
+ * @param {WPBlockVariationScope} [scope] Block variation scope name.
+ *
+ * @example
+ * ```js
+ * import { __, sprintf } from '@wordpress/i18n';
+ * import { store as blocksStore } from '@wordpress/blocks';
+ * import { useSelect } from '@wordpress/data';
+ *
+ * const ExampleComponent = () => {
+ * const defaultEmbedBlockVariation = useSelect( ( select ) =>
+ * select( blocksStore ).getDefaultBlockVariation( 'core/embed' ),
+ * []
+ * );
+ *
+ * return (
+ * defaultEmbedBlockVariation && (
+ * <p>
+ * { sprintf(
+ * __( 'core/embed default variation: %s' ),
+ * defaultEmbedBlockVariation.title
+ * ) }
+ * </p>
+ * )
+ * );
+ * };
+ * ```
+ *
+ * @return {?WPBlockVariation} The default block variation.
+ */
+function getDefaultBlockVariation(state, blockName, scope) {
+ const variations = selectors_getBlockVariations(state, blockName, scope);
+ const defaultVariation = [...variations].reverse().find(({
+ isDefault
+ }) => !!isDefault);
+ return defaultVariation || variations[0];
+}
+
+/**
+ * Returns all the available block categories.
+ *
+ * @param {Object} state Data state.
+ *
+ * @example
+ * ```js
+ * import { store as blocksStore } from '@wordpress/blocks';
+ * import { useSelect, } from '@wordpress/data';
+ *
+ * const ExampleComponent = () => {
+ * const blockCategories = useSelect( ( select ) =>
+ * select( blocksStore ).getCategories(),
+ * []
+ * );
+ *
+ * return (
+ * <ul>
+ * { blockCategories.map( ( category ) => (
+ * <li key={ category.slug }>{ category.title }</li>
+ * ) ) }
+ * </ul>
+ * );
+ * };
+ * ```
+ *
+ * @return {WPBlockCategory[]} Categories list.
+ */
+function getCategories(state) {
+ return state.categories;
+}
+
+/**
+ * Returns all the available collections.
+ *
+ * @param {Object} state Data state.
+ *
+ * @example
+ * ```js
+ * import { store as blocksStore } from '@wordpress/blocks';
+ * import { useSelect } from '@wordpress/data';
+ *
+ * const ExampleComponent = () => {
+ * const blockCollections = useSelect( ( select ) =>
+ * select( blocksStore ).getCollections(),
+ * []
+ * );
+ *
+ * return (
+ * <ul>
+ * { Object.values( blockCollections ).length > 0 &&
+ * Object.values( blockCollections ).map( ( collection ) => (
+ * <li key={ collection.title }>{ collection.title }</li>
+ * ) ) }
+ * </ul>
+ * );
+ * };
+ * ```
+ *
+ * @return {Object} Collections list.
+ */
+function getCollections(state) {
+ return state.collections;
+}
+
+/**
+ * Returns the name of the default block name.
+ *
+ * @param {Object} state Data state.
+ *
+ * @example
+ * ```js
+ * import { __, sprintf } from '@wordpress/i18n';
+ * import { store as blocksStore } from '@wordpress/blocks';
+ * import { useSelect } from '@wordpress/data';
+ *
+ * const ExampleComponent = () => {
+ * const defaultBlockName = useSelect( ( select ) =>
+ * select( blocksStore ).getDefaultBlockName(),
+ * []
+ * );
+ *
+ * return (
+ * defaultBlockName && (
+ * <p>
+ * { sprintf( __( 'Default block name: %s' ), defaultBlockName ) }
+ * </p>
+ * )
+ * );
+ * };
+ * ```
+ *
+ * @return {string?} Default block name.
+ */
+function selectors_getDefaultBlockName(state) {
+ return state.defaultBlockName;
+}
+
+/**
+ * Returns the name of the block for handling non-block content.
+ *
+ * @param {Object} state Data state.
+ *
+ * @example
+ * ```js
+ * import { __, sprintf } from '@wordpress/i18n';
+ * import { store as blocksStore } from '@wordpress/blocks';
+ * import { useSelect } from '@wordpress/data';
+ *
+ * const ExampleComponent = () => {
+ * const freeformFallbackBlockName = useSelect( ( select ) =>
+ * select( blocksStore ).getFreeformFallbackBlockName(),
+ * []
+ * );
+ *
+ * return (
+ * freeformFallbackBlockName && (
+ * <p>
+ * { sprintf( __(
+ * 'Freeform fallback block name: %s' ),
+ * freeformFallbackBlockName
+ * ) }
+ * </p>
+ * )
+ * );
+ * };
+ * ```
+ *
+ * @return {string?} Name of the block for handling non-block content.
+ */
+function getFreeformFallbackBlockName(state) {
+ return state.freeformFallbackBlockName;
+}
+
+/**
+ * Returns the name of the block for handling unregistered blocks.
+ *
+ * @param {Object} state Data state.
+ *
+ * @example
+ * ```js
+ * import { __, sprintf } from '@wordpress/i18n';
+ * import { store as blocksStore } from '@wordpress/blocks';
+ * import { useSelect } from '@wordpress/data';
+ *
+ * const ExampleComponent = () => {
+ * const unregisteredFallbackBlockName = useSelect( ( select ) =>
+ * select( blocksStore ).getUnregisteredFallbackBlockName(),
+ * []
+ * );
+ *
+ * return (
+ * unregisteredFallbackBlockName && (
+ * <p>
+ * { sprintf( __(
+ * 'Unregistered fallback block name: %s' ),
+ * unregisteredFallbackBlockName
+ * ) }
+ * </p>
+ * )
+ * );
+ * };
+ * ```
+ *
+ * @return {string?} Name of the block for handling unregistered blocks.
+ */
+function getUnregisteredFallbackBlockName(state) {
+ return state.unregisteredFallbackBlockName;
+}
+
+/**
+ * Returns the name of the block for handling the grouping of blocks.
+ *
+ * @param {Object} state Data state.
+ *
+ * @example
+ * ```js
+ * import { __, sprintf } from '@wordpress/i18n';
+ * import { store as blocksStore } from '@wordpress/blocks';
+ * import { useSelect } from '@wordpress/data';
+ *
+ * const ExampleComponent = () => {
+ * const groupingBlockName = useSelect( ( select ) =>
+ * select( blocksStore ).getGroupingBlockName(),
+ * []
+ * );
+ *
+ * return (
+ * groupingBlockName && (
+ * <p>
+ * { sprintf(
+ * __( 'Default grouping block name: %s' ),
+ * groupingBlockName
+ * ) }
+ * </p>
+ * )
+ * );
+ * };
+ * ```
+ *
+ * @return {string?} Name of the block for handling the grouping of blocks.
+ */
+function selectors_getGroupingBlockName(state) {
+ return state.groupingBlockName;
+}
+
+/**
+ * Returns an array with the child blocks of a given block.
+ *
+ * @param {Object} state Data state.
+ * @param {string} blockName Block type name.
+ *
+ * @example
+ * ```js
+ * import { store as blocksStore } from '@wordpress/blocks';
+ * import { useSelect } from '@wordpress/data';
+ *
+ * const ExampleComponent = () => {
+ * const childBlockNames = useSelect( ( select ) =>
+ * select( blocksStore ).getChildBlockNames( 'core/navigation' ),
+ * []
+ * );
+ *
+ * return (
+ * <ul>
+ * { childBlockNames &&
+ * childBlockNames.map( ( child ) => (
+ * <li key={ child }>{ child }</li>
+ * ) ) }
+ * </ul>
+ * );
+ * };
+ * ```
+ *
+ * @return {Array} Array of child block names.
+ */
+const selectors_getChildBlockNames = (0,external_wp_data_namespaceObject.createSelector)((state, blockName) => {
+ return selectors_getBlockTypes(state).filter(blockType => {
+ return blockType.parent?.includes(blockName);
+ }).map(({
+ name
+ }) => name);
+}, state => [state.blockTypes]);
+
+/**
+ * Returns the block support value for a feature, if defined.
+ *
+ * @param {Object} state Data state.
+ * @param {(string|Object)} nameOrType Block name or type object
+ * @param {Array|string} feature Feature to retrieve
+ * @param {*} defaultSupports Default value to return if not
+ * explicitly defined
+ *
+ * @example
+ * ```js
+ * import { __, sprintf } from '@wordpress/i18n';
+ * import { store as blocksStore } from '@wordpress/blocks';
+ * import { useSelect } from '@wordpress/data';
+ *
+ * const ExampleComponent = () => {
+ * const paragraphBlockSupportValue = useSelect( ( select ) =>
+ * select( blocksStore ).getBlockSupport( 'core/paragraph', 'anchor' ),
+ * []
+ * );
+ *
+ * return (
+ * <p>
+ * { sprintf(
+ * __( 'core/paragraph supports.anchor value: %s' ),
+ * paragraphBlockSupportValue
+ * ) }
+ * </p>
+ * );
+ * };
+ * ```
+ *
+ * @return {?*} Block support value
+ */
+const selectors_getBlockSupport = (state, nameOrType, feature, defaultSupports) => {
+ const blockType = getNormalizedBlockType(state, nameOrType);
+ if (!blockType?.supports) {
+ return defaultSupports;
+ }
+ return getValueFromObjectPath(blockType.supports, feature, defaultSupports);
+};
+
+/**
+ * Returns true if the block defines support for a feature, or false otherwise.
+ *
+ * @param {Object} state Data state.
+ * @param {(string|Object)} nameOrType Block name or type object.
+ * @param {string} feature Feature to test.
+ * @param {boolean} defaultSupports Whether feature is supported by
+ * default if not explicitly defined.
+ *
+ * @example
+ * ```js
+ * import { __, sprintf } from '@wordpress/i18n';
+ * import { store as blocksStore } from '@wordpress/blocks';
+ * import { useSelect } from '@wordpress/data';
+ *
+ * const ExampleComponent = () => {
+ * const paragraphBlockSupportClassName = useSelect( ( select ) =>
+ * select( blocksStore ).hasBlockSupport( 'core/paragraph', 'className' ),
+ * []
+ * );
+ *
+ * return (
+ * <p>
+ * { sprintf(
+ * __( 'core/paragraph supports custom class name?: %s' ),
+ * paragraphBlockSupportClassName
+ * ) }
+ * /p>
+ * );
+ * };
+ * ```
+ *
+ * @return {boolean} Whether block supports feature.
+ */
+function selectors_hasBlockSupport(state, nameOrType, feature, defaultSupports) {
+ return !!selectors_getBlockSupport(state, nameOrType, feature, defaultSupports);
+}
+
+/**
+ * Normalizes a search term string: removes accents, converts to lowercase, removes extra whitespace.
+ *
+ * @param {string|null|undefined} term Search term to normalize.
+ * @return {string} Normalized search term.
+ */
+function getNormalizedSearchTerm(term) {
+ return remove_accents_default()(term !== null && term !== void 0 ? term : '').toLowerCase().trim();
+}
+
+/**
+ * Returns true if the block type by the given name or object value matches a
+ * search term, or false otherwise.
+ *
+ * @param {Object} state Blocks state.
+ * @param {(string|Object)} nameOrType Block name or type object.
+ * @param {string} searchTerm Search term by which to filter.
+ *
+ * @example
+ * ```js
+ * import { __, sprintf } from '@wordpress/i18n';
+ * import { store as blocksStore } from '@wordpress/blocks';
+ * import { useSelect } from '@wordpress/data';
+ *
+ * const ExampleComponent = () => {
+ * const termFound = useSelect(
+ * ( select ) =>
+ * select( blocksStore ).isMatchingSearchTerm(
+ * 'core/navigation',
+ * 'theme'
+ * ),
+ * []
+ * );
+ *
+ * return (
+ * <p>
+ * { sprintf(
+ * __(
+ * 'Search term was found in the title, keywords, category or description in block.json: %s'
+ * ),
+ * termFound
+ * ) }
+ * </p>
+ * );
+ * };
+ * ```
+ *
+ * @return {Object[]} Whether block type matches search term.
+ */
+function isMatchingSearchTerm(state, nameOrType, searchTerm = '') {
+ const blockType = getNormalizedBlockType(state, nameOrType);
+ const normalizedSearchTerm = getNormalizedSearchTerm(searchTerm);
+ const isSearchMatch = candidate => getNormalizedSearchTerm(candidate).includes(normalizedSearchTerm);
+ return isSearchMatch(blockType.title) || blockType.keywords?.some(isSearchMatch) || isSearchMatch(blockType.category) || typeof blockType.description === 'string' && isSearchMatch(blockType.description);
+}
+
+/**
+ * Returns a boolean indicating if a block has child blocks or not.
+ *
+ * @param {Object} state Data state.
+ * @param {string} blockName Block type name.
+ *
+ * @example
+ * ```js
+ * import { __, sprintf } from '@wordpress/i18n';
+ * import { store as blocksStore } from '@wordpress/blocks';
+ * import { useSelect } from '@wordpress/data';
+ *
+ * const ExampleComponent = () => {
+ * const navigationBlockHasChildBlocks = useSelect( ( select ) =>
+ * select( blocksStore ).hasChildBlocks( 'core/navigation' ),
+ * []
+ * );
+ *
+ * return (
+ * <p>
+ * { sprintf(
+ * __( 'core/navigation has child blocks: %s' ),
+ * navigationBlockHasChildBlocks
+ * ) }
+ * </p>
+ * );
+ * };
+ * ```
+ *
+ * @return {boolean} True if a block contains child blocks and false otherwise.
+ */
+const selectors_hasChildBlocks = (state, blockName) => {
+ return selectors_getChildBlockNames(state, blockName).length > 0;
+};
+
+/**
+ * Returns a boolean indicating if a block has at least one child block with inserter support.
+ *
+ * @param {Object} state Data state.
+ * @param {string} blockName Block type name.
+ *
+ * @example
+ * ```js
+ * import { __, sprintf } from '@wordpress/i18n';
+ * import { store as blocksStore } from '@wordpress/blocks';
+ * import { useSelect } from '@wordpress/data';
+ *
+ * const ExampleComponent = () => {
+ * const navigationBlockHasChildBlocksWithInserterSupport = useSelect( ( select ) =>
+ * select( blocksStore ).hasChildBlocksWithInserterSupport(
+ * 'core/navigation'
+ * ),
+ * []
+ * );
+ *
+ * return (
+ * <p>
+ * { sprintf(
+ * __( 'core/navigation has child blocks with inserter support: %s' ),
+ * navigationBlockHasChildBlocksWithInserterSupport
+ * ) }
+ * </p>
+ * );
+ * };
+ * ```
+ *
+ * @return {boolean} True if a block contains at least one child blocks with inserter support
+ * and false otherwise.
+ */
+const selectors_hasChildBlocksWithInserterSupport = (state, blockName) => {
+ return selectors_getChildBlockNames(state, blockName).some(childBlockName => {
+ return selectors_hasBlockSupport(state, childBlockName, 'inserter', true);
+ });
+};
+
+/**
+ * DO-NOT-USE in production.
+ * This selector is created for internal/experimental only usage and may be
+ * removed anytime without any warning, causing breakage on any plugin or theme invoking it.
+ */
+const __experimentalHasContentRoleAttribute = (0,external_wp_data_namespaceObject.createSelector)((state, blockTypeName) => {
+ const blockType = selectors_getBlockType(state, blockTypeName);
+ if (!blockType) {
+ return false;
+ }
+ return Object.entries(blockType.attributes).some(([, {
+ __experimentalRole
+ }]) => __experimentalRole === 'content');
+}, (state, blockTypeName) => [state.blockTypes[blockTypeName]?.attributes]);
+
+;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/private-selectors.js
+/**
+ * WordPress dependencies
+ */
+
+
+/**
+ * Internal dependencies
+ */
+
+
+
+const ROOT_BLOCK_SUPPORTS = ['background', 'backgroundColor', 'color', 'linkColor', 'captionColor', 'buttonColor', 'headingColor', 'fontFamily', 'fontSize', 'fontStyle', 'fontWeight', 'lineHeight', 'padding', 'contentSize', 'wideSize', 'blockGap', 'textDecoration', 'textTransform', 'letterSpacing'];
+
+/**
+ * Filters the list of supported styles for a given element.
+ *
+ * @param {string[]} blockSupports list of supported styles.
+ * @param {string|undefined} name block name.
+ * @param {string|undefined} element element name.
+ *
+ * @return {string[]} filtered list of supported styles.
+ */
+function filterElementBlockSupports(blockSupports, name, element) {
+ return blockSupports.filter(support => {
+ if (support === 'fontSize' && element === 'heading') {
+ return false;
+ }
+
+ // This is only available for links
+ if (support === 'textDecoration' && !name && element !== 'link') {
+ return false;
+ }
+
+ // This is only available for heading, button, caption and text
+ if (support === 'textTransform' && !name && !(['heading', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(element) || element === 'button' || element === 'caption' || element === 'text')) {
+ return false;
+ }
+
+ // This is only available for heading, button, caption and text
+ if (support === 'letterSpacing' && !name && !(['heading', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(element) || element === 'button' || element === 'caption' || element === 'text')) {
+ return false;
+ }
+
+ // Text columns is only available for blocks.
+ if (support === 'textColumns' && !name) {
+ return false;
+ }
+ return true;
+ });
+}
+
+/**
+ * Returns the list of supported styles for a given block name and element.
+ */
+const getSupportedStyles = (0,external_wp_data_namespaceObject.createSelector)((state, name, element) => {
+ if (!name) {
+ return filterElementBlockSupports(ROOT_BLOCK_SUPPORTS, name, element);
+ }
+ const blockType = selectors_getBlockType(state, name);
+ if (!blockType) {
+ return [];
+ }
+ const supportKeys = [];
+
+ // Check for blockGap support.
+ // Block spacing support doesn't map directly to a single style property, so needs to be handled separately.
+ if (blockType?.supports?.spacing?.blockGap) {
+ supportKeys.push('blockGap');
+ }
+
+ // check for shadow support
+ if (blockType?.supports?.shadow) {
+ supportKeys.push('shadow');
+ }
+ Object.keys(__EXPERIMENTAL_STYLE_PROPERTY).forEach(styleName => {
+ if (!__EXPERIMENTAL_STYLE_PROPERTY[styleName].support) {
+ return;
+ }
+
+ // Opting out means that, for certain support keys like background color,
+ // blocks have to explicitly set the support value false. If the key is
+ // unset, we still enable it.
+ if (__EXPERIMENTAL_STYLE_PROPERTY[styleName].requiresOptOut) {
+ if (__EXPERIMENTAL_STYLE_PROPERTY[styleName].support[0] in blockType.supports && getValueFromObjectPath(blockType.supports, __EXPERIMENTAL_STYLE_PROPERTY[styleName].support) !== false) {
+ supportKeys.push(styleName);
+ return;
+ }
+ }
+ if (getValueFromObjectPath(blockType.supports, __EXPERIMENTAL_STYLE_PROPERTY[styleName].support, false)) {
+ supportKeys.push(styleName);
+ }
+ });
+ return filterElementBlockSupports(supportKeys, name, element);
+}, (state, name) => [state.blockTypes[name]]);
+
+/**
+ * Returns the bootstrapped block type metadata for a give block name.
+ *
+ * @param {Object} state Data state.
+ * @param {string} name Block name.
+ *
+ * @return {Object} Bootstrapped block type metadata for a block.
+ */
+function getBootstrappedBlockType(state, name) {
+ return state.bootstrappedBlockTypes[name];
+}
+
+/**
+ * Returns all the unprocessed (before applying the `registerBlockType` filter)
+ * block type settings as passed during block registration.
+ *
+ * @param {Object} state Data state.
+ *
+ * @return {Array} Unprocessed block type settings for all blocks.
+ */
+function getUnprocessedBlockTypes(state) {
+ return state.unprocessedBlockTypes;
+}
+
+/**
+ * Returns all the block bindings sources registered.
+ *
+ * @param {Object} state Data state.
+ *
+ * @return {Object} All the registered sources and their properties.
+ */
+function getAllBlockBindingsSources(state) {
+ return state.blockBindingsSources;
+}
+
+/**
+ * Returns a specific block bindings source.
+ *
+ * @param {Object} state Data state.
+ * @param {string} sourceName Name of the source to get.
+ *
+ * @return {Object} The specific block binding source and its properties.
+ */
+function getBlockBindingsSource(state, sourceName) {
+ return state.blockBindingsSources[sourceName];
+}
+
+;// CONCATENATED MODULE: external ["wp","deprecated"]
+const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
+var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
+;// CONCATENATED MODULE: ./node_modules/is-plain-object/dist/is-plain-object.mjs
+/*!
+ * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
+ *
+ * Copyright (c) 2014-2017, Jon Schlinkert.
+ * Released under the MIT License.
+ */
+
+function is_plain_object_isObject(o) {
+ return Object.prototype.toString.call(o) === '[object Object]';
+}
+
+function isPlainObject(o) {
+ var ctor,prot;
+
+ if (is_plain_object_isObject(o) === false) return false;
+
+ // If has modified constructor
+ ctor = o.constructor;
+ if (ctor === undefined) return true;
+
+ // If has modified prototype
+ prot = ctor.prototype;
+ if (is_plain_object_isObject(prot) === false) return false;
+
+ // If constructor does not have an Object-specific method
+ if (prot.hasOwnProperty('isPrototypeOf') === false) {
+ return false;
+ }
+
+ // Most likely a plain Object
+ return true;
+}
+
+
+
+// EXTERNAL MODULE: ./node_modules/react-is/index.js
+var react_is = __webpack_require__(8529);
+;// CONCATENATED MODULE: external ["wp","hooks"]
+const external_wp_hooks_namespaceObject = window["wp"]["hooks"];
+;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/process-block-type.js
+/**
+ * External dependencies
+ */
+
+
+
+/**
+ * WordPress dependencies
+ */
+
+
+
+/**
+ * Internal dependencies
+ */
+
+
+
+/** @typedef {import('../api/registration').WPBlockType} WPBlockType */
+
+const error = (...args) => window?.console?.error?.(...args);
+const warn = (...args) => window?.console?.warn?.(...args);
+
+/**
+ * Mapping of legacy category slugs to their latest normal values, used to
+ * accommodate updates of the default set of block categories.
+ *
+ * @type {Record<string,string>}
+ */
+const LEGACY_CATEGORY_MAPPING = {
+ common: 'text',
+ formatting: 'text',
+ layout: 'design'
+};
+
+/**
+ * Merge block variations bootstrapped from the server and client.
+ *
+ * When a variation is registered in both places, its properties are merged.
+ *
+ * @param {Array} bootstrappedVariations - A block type variations from the server.
+ * @param {Array} clientVariations - A block type variations from the client.
+ * @return {Array} The merged array of block variations.
+ */
+function mergeBlockVariations(bootstrappedVariations = [], clientVariations = []) {
+ const result = [...bootstrappedVariations];
+ clientVariations.forEach(clientVariation => {
+ const index = result.findIndex(bootstrappedVariation => bootstrappedVariation.name === clientVariation.name);
+ if (index !== -1) {
+ result[index] = {
+ ...result[index],
+ ...clientVariation
+ };
+ } else {
+ result.push(clientVariation);
+ }
+ });
+ return result;
+}
+
+/**
+ * Takes the unprocessed block type settings, merges them with block type metadata
+ * and applies all the existing filters for the registered block type.
+ * Next, it validates all the settings and performs additional processing to the block type definition.
+ *
+ * @param {string} name Block name.
+ * @param {WPBlockType} blockSettings Unprocessed block type settings.
+ *
+ * @return {WPBlockType | undefined} The block, if it has been processed and can be registered; otherwise `undefined`.
+ */
+const processBlockType = (name, blockSettings) => ({
+ select
+}) => {
+ const bootstrappedBlockType = select.getBootstrappedBlockType(name);
+ const blockType = {
+ name,
+ icon: BLOCK_ICON_DEFAULT,
+ keywords: [],
+ attributes: {},
+ providesContext: {},
+ usesContext: [],
+ selectors: {},
+ supports: {},
+ styles: [],
+ blockHooks: {},
+ save: () => null,
+ ...bootstrappedBlockType,
+ ...blockSettings,
+ variations: mergeBlockVariations(bootstrappedBlockType?.variations, blockSettings?.variations)
+ };
+ const settings = (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.registerBlockType', blockType, name, null);
+ if (settings.description && typeof settings.description !== 'string') {
+ external_wp_deprecated_default()('Declaring non-string block descriptions', {
+ since: '6.2'
+ });
+ }
+ if (settings.deprecated) {
+ settings.deprecated = settings.deprecated.map(deprecation => Object.fromEntries(Object.entries(
+ // Only keep valid deprecation keys.
+ (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.registerBlockType',
+ // Merge deprecation keys with pre-filter settings
+ // so that filters that depend on specific keys being
+ // present don't fail.
+ {
+ // Omit deprecation keys here so that deprecations
+ // can opt out of specific keys like "supports".
+ ...omit(blockType, DEPRECATED_ENTRY_KEYS),
+ ...deprecation
+ }, blockType.name, deprecation)).filter(([key]) => DEPRECATED_ENTRY_KEYS.includes(key))));
+ }
+ if (!isPlainObject(settings)) {
+ error('Block settings must be a valid object.');
+ return;
+ }
+ if (typeof settings.save !== 'function') {
+ error('The "save" property must be a valid function.');
+ return;
+ }
+ if ('edit' in settings && !(0,react_is.isValidElementType)(settings.edit)) {
+ error('The "edit" property must be a valid component.');
+ return;
+ }
+
+ // Canonicalize legacy categories to equivalent fallback.
+ if (LEGACY_CATEGORY_MAPPING.hasOwnProperty(settings.category)) {
+ settings.category = LEGACY_CATEGORY_MAPPING[settings.category];
+ }
+ if ('category' in settings && !select.getCategories().some(({
+ slug
+ }) => slug === settings.category)) {
+ warn('The block "' + name + '" is registered with an invalid category "' + settings.category + '".');
+ delete settings.category;
+ }
+ if (!('title' in settings) || settings.title === '') {
+ error('The block "' + name + '" must have a title.');
+ return;
+ }
+ if (typeof settings.title !== 'string') {
+ error('Block titles must be strings.');
+ return;
+ }
+ settings.icon = normalizeIconObject(settings.icon);
+ if (!isValidIcon(settings.icon.src)) {
+ 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');
+ return;
+ }
+ return settings;
+};
+
+;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/actions.js
+/**
+ * WordPress dependencies
+ */
+
+
+/**
+ * Internal dependencies
+ */
+
+
+/** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */
+/** @typedef {import('../api/registration').WPBlockType} WPBlockType */
+/** @typedef {import('./reducer').WPBlockCategory} WPBlockCategory */
+
+/**
+ * Returns an action object used in signalling that block types have been added.
+ * Ignored from documentation as the recommended usage for this action through registerBlockType from @wordpress/blocks.
+ *
+ * @ignore
+ *
+ * @param {WPBlockType|WPBlockType[]} blockTypes Object or array of objects representing blocks to added.
+ *
+ *
+ * @return {Object} Action object.
+ */
+function addBlockTypes(blockTypes) {
+ return {
+ type: 'ADD_BLOCK_TYPES',
+ blockTypes: Array.isArray(blockTypes) ? blockTypes : [blockTypes]
+ };
+}
+
+/**
+ * Signals that all block types should be computed again.
+ * It uses stored unprocessed block types and all the most recent list of registered filters.
+ *
+ * It addresses the issue where third party block filters get registered after third party blocks. A sample sequence:
+ * 1. Filter A.
+ * 2. Block B.
+ * 3. Block C.
+ * 4. Filter D.
+ * 5. Filter E.
+ * 6. Block F.
+ * 7. Filter G.
+ * In this scenario some filters would not get applied for all blocks because they are registered too late.
+ */
+function reapplyBlockTypeFilters() {
+ return ({
+ dispatch,
+ select
+ }) => {
+ const processedBlockTypes = [];
+ for (const [name, settings] of Object.entries(select.getUnprocessedBlockTypes())) {
+ const result = dispatch(processBlockType(name, settings));
+ if (result) {
+ processedBlockTypes.push(result);
+ }
+ }
+ if (!processedBlockTypes.length) {
+ return;
+ }
+ dispatch.addBlockTypes(processedBlockTypes);
+ };
+}
+function __experimentalReapplyBlockFilters() {
+ external_wp_deprecated_default()('wp.data.dispatch( "core/blocks" ).__experimentalReapplyBlockFilters', {
+ since: '6.4',
+ alternative: 'reapplyBlockFilters'
+ });
+ return reapplyBlockTypeFilters();
+}
+
+/**
+ * Returns an action object used to remove a registered block type.
+ * Ignored from documentation as the recommended usage for this action through unregisterBlockType from @wordpress/blocks.
+ *
+ * @ignore
+ *
+ * @param {string|string[]} names Block name or array of block names to be removed.
+ *
+ *
+ * @return {Object} Action object.
+ */
+function removeBlockTypes(names) {
+ return {
+ type: 'REMOVE_BLOCK_TYPES',
+ names: Array.isArray(names) ? names : [names]
+ };
+}
+
+/**
+ * Returns an action object used in signalling that new block styles have been added.
+ * Ignored from documentation as the recommended usage for this action through registerBlockStyle from @wordpress/blocks.
+ *
+ * @param {string|Array} blockNames Block names to register new styles for.
+ * @param {Array|Object} styles Block style object or array of block style objects.
+ *
+ * @ignore
+ *
+ * @return {Object} Action object.
+ */
+function addBlockStyles(blockNames, styles) {
+ return {
+ type: 'ADD_BLOCK_STYLES',
+ styles: Array.isArray(styles) ? styles : [styles],
+ blockNames: Array.isArray(blockNames) ? blockNames : [blockNames]
+ };
+}
+
+/**
+ * Returns an action object used in signalling that block styles have been removed.
+ * Ignored from documentation as the recommended usage for this action through unregisterBlockStyle from @wordpress/blocks.
+ *
+ * @ignore
+ *
+ * @param {string} blockName Block name.
+ * @param {Array|string} styleNames Block style names or array of block style names.
+ *
+ * @return {Object} Action object.
+ */
+function removeBlockStyles(blockName, styleNames) {
+ return {
+ type: 'REMOVE_BLOCK_STYLES',
+ styleNames: Array.isArray(styleNames) ? styleNames : [styleNames],
+ blockName
+ };
+}
+
+/**
+ * Returns an action object used in signalling that new block variations have been added.
+ * Ignored from documentation as the recommended usage for this action through registerBlockVariation from @wordpress/blocks.
+ *
+ * @ignore
+ *
+ * @param {string} blockName Block name.
+ * @param {WPBlockVariation|WPBlockVariation[]} variations Block variations.
+ *
+ * @return {Object} Action object.
+ */
+function addBlockVariations(blockName, variations) {
+ return {
+ type: 'ADD_BLOCK_VARIATIONS',
+ variations: Array.isArray(variations) ? variations : [variations],
+ blockName
+ };
+}
+
+/**
+ * Returns an action object used in signalling that block variations have been removed.
+ * Ignored from documentation as the recommended usage for this action through unregisterBlockVariation from @wordpress/blocks.
+ *
+ * @ignore
+ *
+ * @param {string} blockName Block name.
+ * @param {string|string[]} variationNames Block variation names.
+ *
+ * @return {Object} Action object.
+ */
+function removeBlockVariations(blockName, variationNames) {
+ return {
+ type: 'REMOVE_BLOCK_VARIATIONS',
+ variationNames: Array.isArray(variationNames) ? variationNames : [variationNames],
+ blockName
+ };
+}
+
+/**
+ * Returns an action object used to set the default block name.
+ * Ignored from documentation as the recommended usage for this action through setDefaultBlockName from @wordpress/blocks.
+ *
+ * @ignore
+ *
+ * @param {string} name Block name.
+ *
+ * @return {Object} Action object.
+ */
+function actions_setDefaultBlockName(name) {
+ return {
+ type: 'SET_DEFAULT_BLOCK_NAME',
+ name
+ };
+}
+
+/**
+ * Returns an action object used to set the name of the block used as a fallback
+ * for non-block content.
+ * Ignored from documentation as the recommended usage for this action through setFreeformContentHandlerName from @wordpress/blocks.
+ *
+ * @ignore
+ *
+ * @param {string} name Block name.
+ *
+ * @return {Object} Action object.
+ */
+function setFreeformFallbackBlockName(name) {
+ return {
+ type: 'SET_FREEFORM_FALLBACK_BLOCK_NAME',
+ name
+ };
+}
+
+/**
+ * Returns an action object used to set the name of the block used as a fallback
+ * for unregistered blocks.
+ * Ignored from documentation as the recommended usage for this action through setUnregisteredTypeHandlerName from @wordpress/blocks.
+ *
+ * @ignore
+ *
+ * @param {string} name Block name.
+ *
+ * @return {Object} Action object.
+ */
+function setUnregisteredFallbackBlockName(name) {
+ return {
+ type: 'SET_UNREGISTERED_FALLBACK_BLOCK_NAME',
+ name
+ };
+}
+
+/**
+ * Returns an action object used to set the name of the block used
+ * when grouping other blocks
+ * eg: in "Group/Ungroup" interactions
+ * Ignored from documentation as the recommended usage for this action through setGroupingBlockName from @wordpress/blocks.
+ *
+ * @ignore
+ *
+ * @param {string} name Block name.
+ *
+ * @return {Object} Action object.
+ */
+function actions_setGroupingBlockName(name) {
+ return {
+ type: 'SET_GROUPING_BLOCK_NAME',
+ name
+ };
+}
+
+/**
+ * Returns an action object used to set block categories.
+ * Ignored from documentation as the recommended usage for this action through setCategories from @wordpress/blocks.
+ *
+ * @ignore
+ *
+ * @param {WPBlockCategory[]} categories Block categories.
+ *
+ * @return {Object} Action object.
+ */
+function setCategories(categories) {
+ return {
+ type: 'SET_CATEGORIES',
+ categories
+ };
+}
+
+/**
+ * Returns an action object used to update a category.
+ * Ignored from documentation as the recommended usage for this action through updateCategory from @wordpress/blocks.
+ *
+ * @ignore
+ *
+ * @param {string} slug Block category slug.
+ * @param {Object} category Object containing the category properties that should be updated.
+ *
+ * @return {Object} Action object.
+ */
+function updateCategory(slug, category) {
+ return {
+ type: 'UPDATE_CATEGORY',
+ slug,
+ category
+ };
+}
+
+/**
+ * Returns an action object used to add block collections
+ * Ignored from documentation as the recommended usage for this action through registerBlockCollection from @wordpress/blocks.
+ *
+ * @ignore
+ *
+ * @param {string} namespace The namespace of the blocks to put in the collection
+ * @param {string} title The title to display in the block inserter
+ * @param {Object} icon (optional) The icon to display in the block inserter
+ *
+ * @return {Object} Action object.
+ */
+function addBlockCollection(namespace, title, icon) {
+ return {
+ type: 'ADD_BLOCK_COLLECTION',
+ namespace,
+ title,
+ icon
+ };
+}
+
+/**
+ * Returns an action object used to remove block collections
+ * Ignored from documentation as the recommended usage for this action through unregisterBlockCollection from @wordpress/blocks.
+ *
+ * @ignore
+ *
+ * @param {string} namespace The namespace of the blocks to put in the collection
+ *
+ * @return {Object} Action object.
+ */
+function removeBlockCollection(namespace) {
+ return {
+ type: 'REMOVE_BLOCK_COLLECTION',
+ namespace
+ };
+}
+
+;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/private-actions.js
+/**
+ * Internal dependencies
+ */
+
+
+/** @typedef {import('../api/registration').WPBlockType} WPBlockType */
+
+/**
+ * Add bootstrapped block type metadata to the store. These metadata usually come from
+ * the `block.json` file and are either statically boostrapped from the server, or
+ * passed as the `metadata` parameter to the `registerBlockType` function.
+ *
+ * @param {string} name Block name.
+ * @param {WPBlockType} blockType Block type metadata.
+ */
+function addBootstrappedBlockType(name, blockType) {
+ return {
+ type: 'ADD_BOOTSTRAPPED_BLOCK_TYPE',
+ name,
+ blockType
+ };
+}
+
+/**
+ * Add unprocessed block type settings to the store. These data are passed as the
+ * `settings` parameter to the client-side `registerBlockType` function.
+ *
+ * @param {string} name Block name.
+ * @param {WPBlockType} blockType Unprocessed block type settings.
+ */
+function addUnprocessedBlockType(name, blockType) {
+ return ({
+ dispatch
+ }) => {
+ dispatch({
+ type: 'ADD_UNPROCESSED_BLOCK_TYPE',
+ name,
+ blockType
+ });
+ const processedBlockType = dispatch(processBlockType(name, blockType));
+ if (!processedBlockType) {
+ return;
+ }
+ dispatch.addBlockTypes(processedBlockType);
+ };
+}
+
+/**
+ * Register new block bindings source.
+ *
+ * @param {string} source Name of the source to register.
+ */
+function registerBlockBindingsSource(source) {
+ return {
+ type: 'REGISTER_BLOCK_BINDINGS_SOURCE',
+ sourceName: source.name,
+ sourceLabel: source.label,
+ getValue: source.getValue,
+ setValue: source.setValue,
+ setValues: source.setValues,
+ getPlaceholder: source.getPlaceholder,
+ canUserEditValue: source.canUserEditValue
+ };
+}
+
+;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/constants.js
+const STORE_NAME = 'core/blocks';
+
+;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/index.js
+/**
+ * WordPress dependencies
+ */
+
+
+/**
+ * Internal dependencies
+ */
+
+
+
+
+
+
+
+
+/**
+ * Store definition for the blocks namespace.
+ *
+ * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
+ *
+ * @type {Object}
+ */
+const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
+ reducer: reducer,
+ selectors: selectors_namespaceObject,
+ actions: actions_namespaceObject
+});
+(0,external_wp_data_namespaceObject.register)(store);
+unlock(store).registerPrivateSelectors(private_selectors_namespaceObject);
+unlock(store).registerPrivateActions(private_actions_namespaceObject);
+
+;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/native.js
+const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
+/* harmony default export */ const esm_browser_native = ({
+ randomUUID
+});
;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js
// Unique ID creation requires a high quality random # generator. In the browser we therefore
// require the crypto API and do not support built-in fallback to lower quality random number
// generators (like Math.random()).
-var getRandomValues;
-var rnds8 = new Uint8Array(16);
+let getRandomValues;
+const rnds8 = new Uint8Array(16);
function rng() {
// lazy load so that environments that need to polyfill have a chance to do so
if (!getRandomValues) {
- // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
- // find the complete implementation of crypto (msCrypto) on IE11.
- getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
+ getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
if (!getRandomValues) {
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
@@ -7152,16 +9750,6 @@
return getRandomValues(rnds8);
}
-;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/regex.js
-/* 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);
-;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/validate.js
-
-
-function validate(uuid) {
- return typeof uuid === 'string' && regex.test(uuid);
-}
-
-/* harmony default export */ var esm_browser_validate = (validate);
;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js
/**
@@ -7169,37 +9757,45 @@
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
*/
-var byteToHex = [];
-
-for (var stringify_i = 0; stringify_i < 256; ++stringify_i) {
- byteToHex.push((stringify_i + 0x100).toString(16).substr(1));
-}
-
-function stringify(arr) {
- var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
+const byteToHex = [];
+
+for (let i = 0; i < 256; ++i) {
+ byteToHex.push((i + 0x100).toString(16).slice(1));
+}
+
+function unsafeStringify(arr, offset = 0) {
// Note: Be careful editing this code! It's been tuned for performance
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
- 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
+ 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]];
+}
+
+function stringify(arr, offset = 0) {
+ const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one
// of the following:
// - One or more input array values don't map to a hex octet (leading to
// "undefined" in the uuid)
// - Invalid input values for the RFC `version` or `variant` fields
- if (!esm_browser_validate(uuid)) {
+ if (!validate(uuid)) {
throw TypeError('Stringified UUID is invalid');
}
return uuid;
}
-/* harmony default export */ var esm_browser_stringify = (stringify);
+/* harmony default export */ const esm_browser_stringify = ((/* unused pure expression or super */ null && (stringify)));
;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js
+
function v4(options, buf, offset) {
+ if (esm_browser_native.randomUUID && !buf && !options) {
+ return esm_browser_native.randomUUID();
+ }
+
options = options || {};
- var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
+ const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
rnds[6] = rnds[6] & 0x0f | 0x40;
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
@@ -7207,17 +9803,17 @@
if (buf) {
offset = offset || 0;
- for (var i = 0; i < 16; ++i) {
+ for (let i = 0; i < 16; ++i) {
buf[offset + i] = rnds[i];
}
return buf;
}
- return esm_browser_stringify(rnds);
-}
-
-/* harmony default export */ var esm_browser_v4 = (v4);
+ return unsafeStringify(rnds);
+}
+
+/* harmony default export */ const esm_browser_v4 = (v4);
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/factory.js
/**
* External dependencies
@@ -7244,16 +9840,12 @@
*
* @return {Object} Block object.
*/
-
-function createBlock(name) {
- let attributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- let innerBlocks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
-
+function createBlock(name, attributes = {}, innerBlocks = []) {
const sanitizedAttributes = __experimentalSanitizeBlockAttributes(name, attributes);
-
- const clientId = esm_browser_v4(); // Blocks are stored with a unique ID, the assigned type name, the block
+ const clientId = esm_browser_v4();
+
+ // Blocks are stored with a unique ID, the assigned type name, the block
// attributes, and their inner blocks.
-
return {
clientId,
name,
@@ -7262,6 +9854,7 @@
innerBlocks
};
}
+
/**
* Given an array of InnerBlocks templates or Block Objects,
* returns an array of created Blocks from them.
@@ -7272,15 +9865,14 @@
*
* @return {Object[]} Array of Block objects.
*/
-
-function createBlocksFromInnerBlocksTemplate() {
- let innerBlocksOrTemplate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
+function createBlocksFromInnerBlocksTemplate(innerBlocksOrTemplate = []) {
return innerBlocksOrTemplate.map(innerBlock => {
const innerBlockTemplate = Array.isArray(innerBlock) ? innerBlock : [innerBlock.name, innerBlock.attributes, innerBlock.innerBlocks];
const [name, attributes, innerBlocks = []] = innerBlockTemplate;
return createBlock(name, attributes, createBlocksFromInnerBlocksTemplate(innerBlocks));
});
}
+
/**
* Given a block object, returns a copy of the block object while sanitizing its attributes,
* optionally merging new attributes and/or replacing its inner blocks.
@@ -7291,22 +9883,20 @@
*
* @return {Object} A cloned block.
*/
-
-function __experimentalCloneSanitizedBlock(block) {
- let mergeAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- let newInnerBlocks = arguments.length > 2 ? arguments[2] : undefined;
+function __experimentalCloneSanitizedBlock(block, mergeAttributes = {}, newInnerBlocks) {
const clientId = esm_browser_v4();
-
- const sanitizedAttributes = __experimentalSanitizeBlockAttributes(block.name, { ...block.attributes,
+ const sanitizedAttributes = __experimentalSanitizeBlockAttributes(block.name, {
+ ...block.attributes,
...mergeAttributes
});
-
- return { ...block,
+ return {
+ ...block,
clientId,
attributes: sanitizedAttributes,
innerBlocks: newInnerBlocks || block.innerBlocks.map(innerBlock => __experimentalCloneSanitizedBlock(innerBlock))
};
}
+
/**
* Given a block object, returns a copy of the block object,
* optionally merging new attributes and/or replacing its inner blocks.
@@ -7317,19 +9907,19 @@
*
* @return {Object} A cloned block.
*/
-
-function cloneBlock(block) {
- let mergeAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- let newInnerBlocks = arguments.length > 2 ? arguments[2] : undefined;
+function cloneBlock(block, mergeAttributes = {}, newInnerBlocks) {
const clientId = esm_browser_v4();
- return { ...block,
+ return {
+ ...block,
clientId,
- attributes: { ...block.attributes,
+ attributes: {
+ ...block.attributes,
...mergeAttributes
},
innerBlocks: newInnerBlocks || block.innerBlocks.map(innerBlock => cloneBlock(innerBlock))
};
}
+
/**
* Returns a boolean indicating whether a transform is possible based on
* various bits of context.
@@ -7340,68 +9930,53 @@
*
* @return {boolean} Is the transform possible?
*/
-
const isPossibleTransformForSource = (transform, direction, blocks) => {
- if ((0,external_lodash_namespaceObject.isEmpty)(blocks)) {
+ if (!blocks.length) {
return false;
- } // If multiple blocks are selected, only multi block transforms
+ }
+
+ // If multiple blocks are selected, only multi block transforms
// or wildcard transforms are allowed.
-
-
const isMultiBlock = blocks.length > 1;
- const firstBlockName = (0,external_lodash_namespaceObject.first)(blocks).name;
+ const firstBlockName = blocks[0].name;
const isValidForMultiBlocks = isWildcardBlockTransform(transform) || !isMultiBlock || transform.isMultiBlock;
-
if (!isValidForMultiBlocks) {
return false;
- } // Check non-wildcard transforms to ensure that transform is valid
+ }
+
+ // Check non-wildcard transforms to ensure that transform is valid
// for a block selection of multiple blocks of different types.
-
-
- if (!isWildcardBlockTransform(transform) && !(0,external_lodash_namespaceObject.every)(blocks, {
- name: firstBlockName
- })) {
+ if (!isWildcardBlockTransform(transform) && !blocks.every(block => block.name === firstBlockName)) {
return false;
- } // Only consider 'block' type transforms as valid.
-
-
+ }
+
+ // Only consider 'block' type transforms as valid.
const isBlockType = transform.type === 'block';
-
if (!isBlockType) {
return false;
- } // Check if the transform's block name matches the source block (or is a wildcard)
+ }
+
+ // Check if the transform's block name matches the source block (or is a wildcard)
// only if this is a transform 'from'.
-
-
- const sourceBlock = (0,external_lodash_namespaceObject.first)(blocks);
+ const sourceBlock = blocks[0];
const hasMatchingName = direction !== 'from' || transform.blocks.indexOf(sourceBlock.name) !== -1 || isWildcardBlockTransform(transform);
-
if (!hasMatchingName) {
return false;
- } // Don't allow single Grouping blocks to be transformed into
+ }
+
+ // Don't allow single Grouping blocks to be transformed into
// a Grouping block.
-
-
- if (!isMultiBlock && isContainerGroupBlock(sourceBlock.name) && isContainerGroupBlock(transform.blockName)) {
+ if (!isMultiBlock && direction === 'from' && isContainerGroupBlock(sourceBlock.name) && isContainerGroupBlock(transform.blockName)) {
return false;
- } // If the transform has a `isMatch` function specified, check that it returns true.
-
-
- if ((0,external_lodash_namespaceObject.isFunction)(transform.isMatch)) {
- const attributes = transform.isMultiBlock ? blocks.map(block => block.attributes) : sourceBlock.attributes;
- const block = transform.isMultiBlock ? blocks : sourceBlock;
-
- if (!transform.isMatch(attributes, block)) {
- return false;
- }
- }
-
- if (transform.usingMobileTransformations && isWildcardBlockTransform(transform) && !isContainerGroupBlock(sourceBlock.name)) {
+ }
+
+ // If the transform has a `isMatch` function specified, check that it returns true.
+ if (!maybeCheckTransformIsMatch(transform, blocks)) {
return false;
}
-
return true;
};
+
/**
* Returns block types that the 'blocks' can be transformed into, based on
* 'from' transforms on other blocks.
@@ -7410,16 +9985,14 @@
*
* @return {Array} Block types that the blocks can be transformed into.
*/
-
-
const getBlockTypesForPossibleFromTransforms = blocks => {
- if ((0,external_lodash_namespaceObject.isEmpty)(blocks)) {
+ if (!blocks.length) {
return [];
}
-
- const allBlockTypes = registration_getBlockTypes(); // filter all blocks to find those with a 'from' transform.
-
- const blockTypesWithPossibleFromTransforms = (0,external_lodash_namespaceObject.filter)(allBlockTypes, blockType => {
+ const allBlockTypes = getBlockTypes();
+
+ // filter all blocks to find those with a 'from' transform.
+ const blockTypesWithPossibleFromTransforms = allBlockTypes.filter(blockType => {
const fromTransforms = getBlockTransforms('from', blockType.name);
return !!findTransform(fromTransforms, transform => {
return isPossibleTransformForSource(transform, 'from', blocks);
@@ -7427,6 +10000,7 @@
});
return blockTypesWithPossibleFromTransforms;
};
+
/**
* Returns block types that the 'blocks' can be transformed into, based on
* the source block's own 'to' transforms.
@@ -7435,25 +10009,26 @@
*
* @return {Array} Block types that the source can be transformed into.
*/
-
-
const getBlockTypesForPossibleToTransforms = blocks => {
- if ((0,external_lodash_namespaceObject.isEmpty)(blocks)) {
+ if (!blocks.length) {
return [];
}
-
- const sourceBlock = (0,external_lodash_namespaceObject.first)(blocks);
- const blockType = registration_getBlockType(sourceBlock.name);
- const transformsTo = blockType ? getBlockTransforms('to', blockType.name) : []; // filter all 'to' transforms to find those that are possible.
-
- const possibleTransforms = (0,external_lodash_namespaceObject.filter)(transformsTo, transform => {
+ const sourceBlock = blocks[0];
+ const blockType = getBlockType(sourceBlock.name);
+ const transformsTo = blockType ? getBlockTransforms('to', blockType.name) : [];
+
+ // filter all 'to' transforms to find those that are possible.
+ const possibleTransforms = transformsTo.filter(transform => {
return transform && isPossibleTransformForSource(transform, 'to', blocks);
- }); // Build a list of block names using the possible 'to' transforms.
-
- const blockNames = (0,external_lodash_namespaceObject.flatMap)(possibleTransforms, transformation => transformation.blocks); // Map block names to block types.
-
- return blockNames.map(name => name === '*' ? name : registration_getBlockType(name));
-};
+ });
+
+ // Build a list of block names using the possible 'to' transforms.
+ const blockNames = possibleTransforms.map(transformation => transformation.blocks).flat();
+
+ // Map block names to block types.
+ return blockNames.map(getBlockType);
+};
+
/**
* Determines whether transform is a "block" type
* and if so whether it is a "wildcard" transform
@@ -7463,9 +10038,8 @@
*
* @return {boolean} whether transform is a wildcard transform
*/
-
-
const isWildcardBlockTransform = t => t && t.type === 'block' && Array.isArray(t.blocks) && t.blocks.includes('*');
+
/**
* Determines whether the given Block is the core Block which
* acts as a container Block for other Blocks as part of the
@@ -7475,8 +10049,8 @@
*
* @return {boolean} whether or not the Block is the container Block type
*/
-
-const isContainerGroupBlock = name => name === registration_getGroupingBlockName();
+const isContainerGroupBlock = name => name === getGroupingBlockName();
+
/**
* Returns an array of block types that the set of blocks received as argument
* can be transformed into.
@@ -7485,16 +10059,15 @@
*
* @return {Array} Block types that the blocks argument can be transformed to.
*/
-
function getPossibleBlockTransformations(blocks) {
- if ((0,external_lodash_namespaceObject.isEmpty)(blocks)) {
+ if (!blocks.length) {
return [];
}
-
const blockTypesForFromTransforms = getBlockTypesForPossibleFromTransforms(blocks);
const blockTypesForToTransforms = getBlockTypesForPossibleToTransforms(blocks);
- return (0,external_lodash_namespaceObject.uniq)([...blockTypesForFromTransforms, ...blockTypesForToTransforms]);
-}
+ return [...new Set([...blockTypesForFromTransforms, ...blockTypesForToTransforms])];
+}
+
/**
* Given an array of transforms, returns the highest-priority transform where
* the predicate function returns a truthy value. A higher-priority transform
@@ -7507,23 +10080,21 @@
*
* @return {?Object} Highest-priority transform candidate.
*/
-
function findTransform(transforms, predicate) {
// The hooks library already has built-in mechanisms for managing priority
// queue, so leverage via locally-defined instance.
const hooks = (0,external_wp_hooks_namespaceObject.createHooks)();
-
for (let i = 0; i < transforms.length; i++) {
const candidate = transforms[i];
-
if (predicate(candidate)) {
hooks.addFilter('transform', 'transform/' + i.toString(), result => result ? result : candidate, candidate.priority);
}
- } // Filter name is arbitrarily chosen but consistent with above aggregation.
-
-
+ }
+
+ // Filter name is arbitrarily chosen but consistent with above aggregation.
return hooks.applyFilters('transform', null);
}
+
/**
* Returns normal block transforms for a given transform direction, optionally
* for a specific block by name, or an empty array if there are no transforms.
@@ -7535,51 +10106,63 @@
*
* @return {Array} Block transforms for direction.
*/
-
function getBlockTransforms(direction, blockTypeOrName) {
// When retrieving transforms for all block types, recurse into self.
if (blockTypeOrName === undefined) {
- return (0,external_lodash_namespaceObject.flatMap)(registration_getBlockTypes(), _ref => {
- let {
- name
- } = _ref;
- return getBlockTransforms(direction, name);
- });
- } // Validate that block type exists and has array of direction.
-
-
+ return getBlockTypes().map(({
+ name
+ }) => getBlockTransforms(direction, name)).flat();
+ }
+
+ // Validate that block type exists and has array of direction.
const blockType = normalizeBlockType(blockTypeOrName);
const {
name: blockName,
transforms
} = blockType || {};
-
if (!transforms || !Array.isArray(transforms[direction])) {
return [];
}
-
const usingMobileTransformations = transforms.supportedMobileTransforms && Array.isArray(transforms.supportedMobileTransforms);
- const filteredTransforms = usingMobileTransformations ? (0,external_lodash_namespaceObject.filter)(transforms[direction], t => {
+ const filteredTransforms = usingMobileTransformations ? transforms[direction].filter(t => {
if (t.type === 'raw') {
return true;
}
-
if (!t.blocks || !t.blocks.length) {
return false;
}
-
if (isWildcardBlockTransform(t)) {
return true;
}
-
- return (0,external_lodash_namespaceObject.every)(t.blocks, transformBlockName => transforms.supportedMobileTransforms.includes(transformBlockName));
- }) : transforms[direction]; // Map transforms to normal form.
-
- return filteredTransforms.map(transform => ({ ...transform,
+ return t.blocks.every(transformBlockName => transforms.supportedMobileTransforms.includes(transformBlockName));
+ }) : transforms[direction];
+
+ // Map transforms to normal form.
+ return filteredTransforms.map(transform => ({
+ ...transform,
blockName,
usingMobileTransformations
}));
}
+
+/**
+ * Checks that a given transforms isMatch method passes for given source blocks.
+ *
+ * @param {Object} transform A transform object.
+ * @param {Array} blocks Blocks array.
+ *
+ * @return {boolean} True if given blocks are a match for the transform.
+ */
+function maybeCheckTransformIsMatch(transform, blocks) {
+ if (typeof transform.isMatch !== 'function') {
+ return true;
+ }
+ const sourceBlock = blocks[0];
+ const attributes = transform.isMultiBlock ? blocks.map(block => block.attributes) : sourceBlock.attributes;
+ const block = transform.isMultiBlock ? blocks : sourceBlock;
+ return transform.isMatch(attributes, block);
+}
+
/**
* Switch one or more blocks into one or more blocks of the new block type.
*
@@ -7588,58 +10171,57 @@
*
* @return {?Array} Array of blocks or null.
*/
-
function switchToBlockType(blocks, name) {
- const blocksArray = (0,external_lodash_namespaceObject.castArray)(blocks);
+ const blocksArray = Array.isArray(blocks) ? blocks : [blocks];
const isMultiBlock = blocksArray.length > 1;
const firstBlock = blocksArray[0];
- const sourceName = firstBlock.name; // Find the right transformation by giving priority to the "to"
+ const sourceName = firstBlock.name;
+
+ // Find the right transformation by giving priority to the "to"
// transformation.
-
const transformationsFrom = getBlockTransforms('from', name);
const transformationsTo = getBlockTransforms('to', sourceName);
- 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.
-
+ 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));
+
+ // Stop if there is no valid transformation.
if (!transformation) {
return null;
}
-
let transformationResults;
-
if (transformation.isMultiBlock) {
- if ((0,external_lodash_namespaceObject.has)(transformation, '__experimentalConvert')) {
+ if ('__experimentalConvert' in transformation) {
transformationResults = transformation.__experimentalConvert(blocksArray);
} else {
transformationResults = transformation.transform(blocksArray.map(currentBlock => currentBlock.attributes), blocksArray.map(currentBlock => currentBlock.innerBlocks));
}
- } else if ((0,external_lodash_namespaceObject.has)(transformation, '__experimentalConvert')) {
+ } else if ('__experimentalConvert' in transformation) {
transformationResults = transformation.__experimentalConvert(firstBlock);
} else {
transformationResults = transformation.transform(firstBlock.attributes, firstBlock.innerBlocks);
- } // Ensure that the transformation function returned an object or an array
+ }
+
+ // Ensure that the transformation function returned an object or an array
// of objects.
-
-
- if (!(0,external_lodash_namespaceObject.isObjectLike)(transformationResults)) {
+ if (transformationResults === null || typeof transformationResults !== 'object') {
return null;
- } // If the transformation function returned a single object, we want to work
+ }
+
+ // If the transformation function returned a single object, we want to work
// with an array instead.
-
-
- transformationResults = (0,external_lodash_namespaceObject.castArray)(transformationResults); // Ensure that every block object returned by the transformation has a
+ transformationResults = Array.isArray(transformationResults) ? transformationResults : [transformationResults];
+
+ // Ensure that every block object returned by the transformation has a
// valid block type.
-
- if (transformationResults.some(result => !registration_getBlockType(result.name))) {
+ if (transformationResults.some(result => !getBlockType(result.name))) {
return null;
}
-
- 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
+ const hasSwitchedBlock = transformationResults.some(result => result.name === name);
+
+ // Ensure that at least one block object returned by the transformation has
// the expected "destination" block type.
-
if (!hasSwitchedBlock) {
return null;
}
-
const ret = transformationResults.map((result, index, results) => {
/**
* Filters an individual transform result from block transformation.
@@ -7655,6 +10237,7 @@
});
return ret;
}
+
/**
* Create a block object from the example API.
*
@@ -7663,713 +10246,32 @@
*
* @return {Object} block.
*/
-
const getBlockFromExample = (name, example) => {
- return createBlock(name, example.attributes, (0,external_lodash_namespaceObject.map)(example.innerBlocks, innerBlock => getBlockFromExample(innerBlock.name, innerBlock)));
-};
-
-;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/utils.js
-/**
- * External dependencies
- */
-
-
-
-
-/**
- * WordPress dependencies
- */
-
-
-
-
-/**
- * Internal dependencies
- */
-
-
-
-
-k([names, a11y]);
-/**
- * Array of icon colors containing a color to be used if the icon color
- * was not explicitly set but the icon background color was.
- *
- * @type {Object}
- */
-
-const ICON_COLORS = ['#191e23', '#f8f9f9'];
-/**
- * Determines whether the block is a default block
- * and its attributes are equal to the default attributes
- * which means the block is unmodified.
- *
- * @param {WPBlock} block Block Object
- *
- * @return {boolean} Whether the block is an unmodified default block
- */
-
-function isUnmodifiedDefaultBlock(block) {
- const defaultBlockName = registration_getDefaultBlockName();
-
- if (block.name !== defaultBlockName) {
- return false;
- } // Cache a created default block if no cache exists or the default block
- // name changed.
-
-
- if (!isUnmodifiedDefaultBlock.block || isUnmodifiedDefaultBlock.block.name !== defaultBlockName) {
- isUnmodifiedDefaultBlock.block = createBlock(defaultBlockName);
- }
-
- const newDefaultBlock = isUnmodifiedDefaultBlock.block;
- const blockType = registration_getBlockType(defaultBlockName);
- return (0,external_lodash_namespaceObject.every)(blockType === null || blockType === void 0 ? void 0 : blockType.attributes, (value, key) => newDefaultBlock.attributes[key] === block.attributes[key]);
-}
-/**
- * Function that checks if the parameter is a valid icon.
- *
- * @param {*} icon Parameter to be checked.
- *
- * @return {boolean} True if the parameter is a valid icon and false otherwise.
- */
-
-function isValidIcon(icon) {
- 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);
-}
-/**
- * Function that receives an icon as set by the blocks during the registration
- * and returns a new icon object that is normalized so we can rely on just on possible icon structure
- * in the codebase.
- *
- * @param {WPBlockTypeIconRender} icon Render behavior of a block type icon;
- * one of a Dashicon slug, an element, or a
- * component.
- *
- * @return {WPBlockTypeIconDescriptor} Object describing the icon.
- */
-
-function normalizeIconObject(icon) {
- icon = icon || BLOCK_ICON_DEFAULT;
-
- if (isValidIcon(icon)) {
- return {
- src: icon
- };
- }
-
- if ((0,external_lodash_namespaceObject.has)(icon, ['background'])) {
- const colordBgColor = w(icon.background);
- return { ...icon,
- foreground: icon.foreground ? icon.foreground : (0,external_lodash_namespaceObject.maxBy)(ICON_COLORS, iconColor => colordBgColor.contrast(iconColor)),
- shadowColor: colordBgColor.alpha(0.3).toRgbString()
- };
- }
-
- return icon;
-}
-/**
- * Normalizes block type passed as param. When string is passed then
- * it converts it to the matching block type object.
- * It passes the original object otherwise.
- *
- * @param {string|Object} blockTypeOrName Block type or name.
- *
- * @return {?Object} Block type.
- */
-
-function normalizeBlockType(blockTypeOrName) {
- if ((0,external_lodash_namespaceObject.isString)(blockTypeOrName)) {
- return registration_getBlockType(blockTypeOrName);
- }
-
- return blockTypeOrName;
-}
-/**
- * Get the label for the block, usually this is either the block title,
- * or the value of the block's `label` function when that's specified.
- *
- * @param {Object} blockType The block type.
- * @param {Object} attributes The values of the block's attributes.
- * @param {Object} context The intended use for the label.
- *
- * @return {string} The block label.
- */
-
-function getBlockLabel(blockType, attributes) {
- let context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'visual';
- const {
- __experimentalLabel: getLabel,
- title
- } = blockType;
- const label = getLabel && getLabel(attributes, {
- context
- });
-
- if (!label) {
- return title;
- } // Strip any HTML (i.e. RichText formatting) before returning.
-
-
- return (0,external_wp_dom_namespaceObject.__unstableStripHTML)(label);
-}
-/**
- * Get a label for the block for use by screenreaders, this is more descriptive
- * than the visual label and includes the block title and the value of the
- * `getLabel` function if it's specified.
- *
- * @param {Object} blockType The block type.
- * @param {Object} attributes The values of the block's attributes.
- * @param {?number} position The position of the block in the block list.
- * @param {string} [direction='vertical'] The direction of the block layout.
- *
- * @return {string} The block label.
- */
-
-function getAccessibleBlockLabel(blockType, attributes, position) {
- let direction = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'vertical';
- // `title` is already localized, `label` is a user-supplied value.
- const title = blockType === null || blockType === void 0 ? void 0 : blockType.title;
- const label = blockType ? getBlockLabel(blockType, attributes, 'accessibility') : '';
- const hasPosition = position !== undefined; // getBlockLabel returns the block title as a fallback when there's no label,
- // if it did return the title, this function needs to avoid adding the
- // title twice within the accessible label. Use this `hasLabel` boolean to
- // handle that.
-
- const hasLabel = label && label !== title;
-
- if (hasPosition && direction === 'vertical') {
- if (hasLabel) {
- return (0,external_wp_i18n_namespaceObject.sprintf)(
- /* translators: accessibility text. 1: The block title. 2: The block row number. 3: The block label.. */
- (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Row %2$d. %3$s'), title, position, label);
- }
-
- return (0,external_wp_i18n_namespaceObject.sprintf)(
- /* translators: accessibility text. 1: The block title. 2: The block row number. */
- (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Row %2$d'), title, position);
- } else if (hasPosition && direction === 'horizontal') {
- if (hasLabel) {
- return (0,external_wp_i18n_namespaceObject.sprintf)(
- /* translators: accessibility text. 1: The block title. 2: The block column number. 3: The block label.. */
- (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Column %2$d. %3$s'), title, position, label);
- }
-
- return (0,external_wp_i18n_namespaceObject.sprintf)(
- /* translators: accessibility text. 1: The block title. 2: The block column number. */
- (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Column %2$d'), title, position);
- }
-
- if (hasLabel) {
- return (0,external_wp_i18n_namespaceObject.sprintf)(
- /* translators: accessibility text. %1: The block title. %2: The block label. */
- (0,external_wp_i18n_namespaceObject.__)('%1$s Block. %2$s'), title, label);
- }
-
- return (0,external_wp_i18n_namespaceObject.sprintf)(
- /* translators: accessibility text. %s: The block title. */
- (0,external_wp_i18n_namespaceObject.__)('%s Block'), title);
-}
-/**
- * Ensure attributes contains only values defined by block type, and merge
- * default values for missing attributes.
- *
- * @param {string} name The block's name.
- * @param {Object} attributes The block's attributes.
- * @return {Object} The sanitized attributes.
- */
-
-function __experimentalSanitizeBlockAttributes(name, attributes) {
- // Get the type definition associated with a registered block.
- const blockType = registration_getBlockType(name);
-
- if (undefined === blockType) {
- throw new Error(`Block type '${name}' is not registered.`);
- }
-
- return (0,external_lodash_namespaceObject.reduce)(blockType.attributes, (accumulator, schema, key) => {
- const value = attributes[key];
-
- if (undefined !== value) {
- accumulator[key] = value;
- } else if (schema.hasOwnProperty('default')) {
- accumulator[key] = schema.default;
- }
-
- if (['node', 'children'].indexOf(schema.source) !== -1) {
- // Ensure value passed is always an array, which we're expecting in
- // the RichText component to handle the deprecated value.
- if (typeof accumulator[key] === 'string') {
- accumulator[key] = [accumulator[key]];
- } else if (!Array.isArray(accumulator[key])) {
- accumulator[key] = [];
- }
- }
-
- return accumulator;
- }, {});
-}
-/**
- * Filter block attributes by `role` and return their names.
- *
- * @param {string} name Block attribute's name.
- * @param {string} role The role of a block attribute.
- *
- * @return {string[]} The attribute names that have the provided role.
- */
-
-function __experimentalGetBlockAttributesNamesByRole(name, role) {
- var _getBlockType;
-
- const attributes = (_getBlockType = registration_getBlockType(name)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.attributes;
- if (!attributes) return [];
- const attributesNames = Object.keys(attributes);
- if (!role) return attributesNames;
- return attributesNames.filter(attributeName => {
- var _attributes$attribute;
-
- return ((_attributes$attribute = attributes[attributeName]) === null || _attributes$attribute === void 0 ? void 0 : _attributes$attribute.__experimentalRole) === role;
- });
-}
-
-;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/actions.js
-/**
- * External dependencies
- */
-
-/**
- * WordPress dependencies
- */
-
-
-/**
- * Internal dependencies
- */
-
-
-
-/** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */
-
-const {
- error,
- warn
-} = window.console;
-/**
- * Mapping of legacy category slugs to their latest normal values, used to
- * accommodate updates of the default set of block categories.
- *
- * @type {Record<string,string>}
- */
-
-const LEGACY_CATEGORY_MAPPING = {
- common: 'text',
- formatting: 'text',
- layout: 'design'
-};
-/**
- * Takes the unprocessed block type data and applies all the existing filters for the registered block type.
- * Next, it validates all the settings and performs additional processing to the block type definition.
- *
- * @param {WPBlockType} blockType Unprocessed block type settings.
- * @param {Object} thunkArgs Argument object for the thunk middleware.
- * @param {Function} thunkArgs.select Function to select from the store.
- *
- * @return {?WPBlockType} The block, if it has been successfully registered; otherwise `undefined`.
- */
-
-const processBlockType = (blockType, _ref) => {
- let {
- select
- } = _ref;
- const {
- name
- } = blockType;
- const settings = (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.registerBlockType', { ...blockType
- }, name);
-
- if (settings.deprecated) {
- settings.deprecated = settings.deprecated.map(deprecation => (0,external_lodash_namespaceObject.pick)( // Only keep valid deprecation keys.
- (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.registerBlockType', // Merge deprecation keys with pre-filter settings
- // so that filters that depend on specific keys being
- // present don't fail.
- { // Omit deprecation keys here so that deprecations
- // can opt out of specific keys like "supports".
- ...(0,external_lodash_namespaceObject.omit)(blockType, DEPRECATED_ENTRY_KEYS),
- ...deprecation
- }, name), DEPRECATED_ENTRY_KEYS));
- }
-
- if (!(0,external_lodash_namespaceObject.isPlainObject)(settings)) {
- error('Block settings must be a valid object.');
- return;
- }
-
- if (!(0,external_lodash_namespaceObject.isFunction)(settings.save)) {
- error('The "save" property must be a valid function.');
- return;
- }
-
- if ('edit' in settings && !(0,external_lodash_namespaceObject.isFunction)(settings.edit)) {
- error('The "edit" property must be a valid function.');
- return;
- } // Canonicalize legacy categories to equivalent fallback.
-
-
- if (LEGACY_CATEGORY_MAPPING.hasOwnProperty(settings.category)) {
- settings.category = LEGACY_CATEGORY_MAPPING[settings.category];
- }
-
- if ('category' in settings && !(0,external_lodash_namespaceObject.some)(select.getCategories(), {
- slug: settings.category
- })) {
- warn('The block "' + name + '" is registered with an invalid category "' + settings.category + '".');
- delete settings.category;
- }
-
- if (!('title' in settings) || settings.title === '') {
- error('The block "' + name + '" must have a title.');
- return;
- }
-
- if (typeof settings.title !== 'string') {
- error('Block titles must be strings.');
- return;
- }
-
- settings.icon = normalizeIconObject(settings.icon);
-
- if (!isValidIcon(settings.icon.src)) {
- 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');
- return;
- }
-
- return settings;
-};
-/**
- * Returns an action object used in signalling that block types have been added.
- *
- * @param {Array|Object} blockTypes Block types received.
- *
- * @return {Object} Action object.
- */
-
-
-function addBlockTypes(blockTypes) {
- return {
- type: 'ADD_BLOCK_TYPES',
- blockTypes: (0,external_lodash_namespaceObject.castArray)(blockTypes)
- };
-}
-/**
- * Signals that the passed block type's settings should be stored in the state.
- *
- * @param {WPBlockType} blockType Unprocessed block type settings.
- */
-
-const __experimentalRegisterBlockType = blockType => _ref2 => {
- let {
- dispatch,
- select
- } = _ref2;
- dispatch({
- type: 'ADD_UNPROCESSED_BLOCK_TYPE',
- blockType
- });
- const processedBlockType = processBlockType(blockType, {
- select
- });
-
- if (!processedBlockType) {
- return;
- }
-
- dispatch.addBlockTypes(processedBlockType);
-};
-/**
- * Signals that all block types should be computed again.
- * It uses stored unprocessed block types and all the most recent list of registered filters.
- *
- * It addresses the issue where third party block filters get registered after third party blocks. A sample sequence:
- * 1. Filter A.
- * 2. Block B.
- * 3. Block C.
- * 4. Filter D.
- * 5. Filter E.
- * 6. Block F.
- * 7. Filter G.
- * In this scenario some filters would not get applied for all blocks because they are registered too late.
- */
-
-const __experimentalReapplyBlockTypeFilters = () => _ref3 => {
- let {
- dispatch,
- select
- } = _ref3;
-
- const unprocessedBlockTypes = select.__experimentalGetUnprocessedBlockTypes();
-
- const processedBlockTypes = Object.keys(unprocessedBlockTypes).reduce((accumulator, blockName) => {
- const result = processBlockType(unprocessedBlockTypes[blockName], {
- select
+ try {
+ var _example$innerBlocks;
+ return createBlock(name, example.attributes, ((_example$innerBlocks = example.innerBlocks) !== null && _example$innerBlocks !== void 0 ? _example$innerBlocks : []).map(innerBlock => getBlockFromExample(innerBlock.name, innerBlock)));
+ } catch {
+ return createBlock('core/missing', {
+ originalName: name,
+ originalContent: '',
+ originalUndelimitedContent: ''
});
-
- if (result) {
- accumulator.push(result);
- }
-
- return accumulator;
- }, []);
-
- if (!processedBlockTypes.length) {
- return;
- }
-
- dispatch.addBlockTypes(processedBlockTypes);
-};
-/**
- * Returns an action object used to remove a registered block type.
- *
- * @param {string|Array} names Block name.
- *
- * @return {Object} Action object.
- */
-
-function removeBlockTypes(names) {
- return {
- type: 'REMOVE_BLOCK_TYPES',
- names: (0,external_lodash_namespaceObject.castArray)(names)
- };
-}
-/**
- * Returns an action object used in signalling that new block styles have been added.
- *
- * @param {string} blockName Block name.
- * @param {Array|Object} styles Block styles.
- *
- * @return {Object} Action object.
- */
-
-function addBlockStyles(blockName, styles) {
- return {
- type: 'ADD_BLOCK_STYLES',
- styles: (0,external_lodash_namespaceObject.castArray)(styles),
- blockName
- };
-}
-/**
- * Returns an action object used in signalling that block styles have been removed.
- *
- * @param {string} blockName Block name.
- * @param {Array|string} styleNames Block style names.
- *
- * @return {Object} Action object.
- */
-
-function removeBlockStyles(blockName, styleNames) {
- return {
- type: 'REMOVE_BLOCK_STYLES',
- styleNames: (0,external_lodash_namespaceObject.castArray)(styleNames),
- blockName
- };
-}
-/**
- * Returns an action object used in signalling that new block variations have been added.
- *
- * @param {string} blockName Block name.
- * @param {WPBlockVariation|WPBlockVariation[]} variations Block variations.
- *
- * @return {Object} Action object.
- */
-
-function addBlockVariations(blockName, variations) {
- return {
- type: 'ADD_BLOCK_VARIATIONS',
- variations: (0,external_lodash_namespaceObject.castArray)(variations),
- blockName
- };
-}
-/**
- * Returns an action object used in signalling that block variations have been removed.
- *
- * @param {string} blockName Block name.
- * @param {string|string[]} variationNames Block variation names.
- *
- * @return {Object} Action object.
- */
-
-function removeBlockVariations(blockName, variationNames) {
- return {
- type: 'REMOVE_BLOCK_VARIATIONS',
- variationNames: (0,external_lodash_namespaceObject.castArray)(variationNames),
- blockName
- };
-}
-/**
- * Returns an action object used to set the default block name.
- *
- * @param {string} name Block name.
- *
- * @return {Object} Action object.
- */
-
-function actions_setDefaultBlockName(name) {
- return {
- type: 'SET_DEFAULT_BLOCK_NAME',
- name
- };
-}
-/**
- * Returns an action object used to set the name of the block used as a fallback
- * for non-block content.
- *
- * @param {string} name Block name.
- *
- * @return {Object} Action object.
- */
-
-function setFreeformFallbackBlockName(name) {
- return {
- type: 'SET_FREEFORM_FALLBACK_BLOCK_NAME',
- name
- };
-}
-/**
- * Returns an action object used to set the name of the block used as a fallback
- * for unregistered blocks.
- *
- * @param {string} name Block name.
- *
- * @return {Object} Action object.
- */
-
-function setUnregisteredFallbackBlockName(name) {
- return {
- type: 'SET_UNREGISTERED_FALLBACK_BLOCK_NAME',
- name
- };
-}
-/**
- * Returns an action object used to set the name of the block used
- * when grouping other blocks
- * eg: in "Group/Ungroup" interactions
- *
- * @param {string} name Block name.
- *
- * @return {Object} Action object.
- */
-
-function actions_setGroupingBlockName(name) {
- return {
- type: 'SET_GROUPING_BLOCK_NAME',
- name
- };
-}
-/**
- * Returns an action object used to set block categories.
- *
- * @param {Object[]} categories Block categories.
- *
- * @return {Object} Action object.
- */
-
-function setCategories(categories) {
- return {
- type: 'SET_CATEGORIES',
- categories
- };
-}
-/**
- * Returns an action object used to update a category.
- *
- * @param {string} slug Block category slug.
- * @param {Object} category Object containing the category properties that should be updated.
- *
- * @return {Object} Action object.
- */
-
-function updateCategory(slug, category) {
- return {
- type: 'UPDATE_CATEGORY',
- slug,
- category
- };
-}
-/**
- * Returns an action object used to add block collections
- *
- * @param {string} namespace The namespace of the blocks to put in the collection
- * @param {string} title The title to display in the block inserter
- * @param {Object} icon (optional) The icon to display in the block inserter
- *
- * @return {Object} Action object.
- */
-
-function addBlockCollection(namespace, title, icon) {
- return {
- type: 'ADD_BLOCK_COLLECTION',
- namespace,
- title,
- icon
- };
-}
-/**
- * Returns an action object used to remove block collections
- *
- * @param {string} namespace The namespace of the blocks to put in the collection
- *
- * @return {Object} Action object.
- */
-
-function removeBlockCollection(namespace) {
- return {
- type: 'REMOVE_BLOCK_COLLECTION',
- namespace
- };
-}
-
-;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/constants.js
-const STORE_NAME = 'core/blocks';
-
-;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/index.js
-/**
- * WordPress dependencies
- */
-
-/**
- * Internal dependencies
- */
-
-
-
-
-
-/**
- * Store definition for the blocks namespace.
- *
- * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
- *
- * @type {Object}
- */
-
-const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
- reducer: reducer,
- selectors: selectors_namespaceObject,
- actions: actions_namespaceObject
-});
-(0,external_wp_data_namespaceObject.register)(store);
+ }
+};
;// CONCATENATED MODULE: external ["wp","blockSerializationDefaultParser"]
-var external_wp_blockSerializationDefaultParser_namespaceObject = window["wp"]["blockSerializationDefaultParser"];
+const external_wp_blockSerializationDefaultParser_namespaceObject = window["wp"]["blockSerializationDefaultParser"];
;// CONCATENATED MODULE: external ["wp","autop"]
-var external_wp_autop_namespaceObject = window["wp"]["autop"];
+const external_wp_autop_namespaceObject = window["wp"]["autop"];
;// CONCATENATED MODULE: external ["wp","isShallowEqual"]
-var external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"];
+const external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"];
var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject);
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/serialize-raw-block.js
/**
* Internal dependencies
*/
+
/**
* @typedef {Object} Options Serialization options.
* @property {boolean} [isCommentDelimited=true] Whether to output HTML comments around blocks.
@@ -8397,9 +10299,7 @@
*
* @return {string} An HTML string representing a block.
*/
-
-function serializeRawBlock(rawBlock) {
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
+function serializeRawBlock(rawBlock, options = {}) {
const {
isCommentDelimited = true
} = options;
@@ -8410,18 +10310,15 @@
innerContent = []
} = rawBlock;
let childIndex = 0;
- const content = innerContent.map(item => // `null` denotes a nested block, otherwise we have an HTML fragment.
+ const content = innerContent.map(item =>
+ // `null` denotes a nested block, otherwise we have an HTML fragment.
item !== null ? item : serializeRawBlock(innerBlocks[childIndex++], options)).join('\n').replace(/\n+/g, '\n').trim();
return isCommentDelimited ? getCommentDelimitedContent(blockName, attrs, content) : content;
}
+;// CONCATENATED MODULE: external "ReactJSXRuntime"
+const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/serializer.js
-
-
-/**
- * External dependencies
- */
-
/**
* WordPress dependencies
*/
@@ -8459,6 +10356,7 @@
const className = 'wp-block-' + blockName.replace(/\//, '-').replace(/^core-/, '');
return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getBlockDefaultClassName', className, blockName);
}
+
/**
* Returns the block's default menu item classname from its name.
*
@@ -8466,7 +10364,6 @@
*
* @return {string} The block's default menu item class.
*/
-
function getBlockMenuDefaultClassName(blockName) {
// Generated HTML classes for blocks follow the `editor-block-list-item-{name}` nomenclature.
// Blocks provided by WordPress drop the prefixes 'core/' or 'core-' (historically used in 'core-embed/').
@@ -8475,42 +10372,53 @@
}
const blockPropsProvider = {};
const innerBlocksPropsProvider = {};
+
/**
* Call within a save function to get the props for the block wrapper.
*
* @param {Object} props Optional. Props to pass to the element.
*/
-
-function getBlockProps() {
- let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
+function getBlockProps(props = {}) {
const {
blockType,
attributes
} = blockPropsProvider;
- return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getSaveContent.extraProps', { ...props
+ return getBlockProps.skipFilters ? props : (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getSaveContent.extraProps', {
+ ...props
}, blockType, attributes);
}
+
/**
* Call within a save function to get the props for the inner blocks wrapper.
*
* @param {Object} props Optional. Props to pass to the element.
*/
-
-function getInnerBlocksProps() {
- let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
+function getInnerBlocksProps(props = {}) {
const {
innerBlocks
- } = innerBlocksPropsProvider; // Value is an array of blocks, so defer to block serializer.
-
- const html = serializer_serialize(innerBlocks, {
+ } = innerBlocksPropsProvider;
+ // Allow a different component to be passed to getSaveElement to handle
+ // inner blocks, bypassing the default serialisation.
+ if (!Array.isArray(innerBlocks)) {
+ return {
+ ...props,
+ children: innerBlocks
+ };
+ }
+ // Value is an array of blocks, so defer to block serializer.
+ const html = serialize(innerBlocks, {
isInnerBlocks: true
- }); // Use special-cased raw HTML tag to avoid default escaping.
-
- const children = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, null, html);
- return { ...props,
+ });
+ // Use special-cased raw HTML tag to avoid default escaping.
+ const children = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.RawHTML, {
+ children: html
+ });
+ return {
+ ...props,
children
};
}
+
/**
* Given a block type containing a save render implementation and attributes, returns the
* enhanced element to be saved or string when raw HTML expected.
@@ -8521,23 +10429,24 @@
*
* @return {Object|string} Save element or raw HTML string.
*/
-
-function getSaveElement(blockTypeOrName, attributes) {
- let innerBlocks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
+function getSaveElement(blockTypeOrName, attributes, innerBlocks = []) {
const blockType = normalizeBlockType(blockTypeOrName);
+ if (!blockType?.save) {
+ return null;
+ }
let {
save
- } = blockType; // Component classes are unsupported for save since serialization must
+ } = blockType;
+
+ // Component classes are unsupported for save since serialization must
// occur synchronously. For improved interoperability with higher-order
// components which often return component class, emulate basic support.
-
if (save.prototype instanceof external_wp_element_namespaceObject.Component) {
const instance = new save({
attributes
});
save = instance.render.bind(instance);
}
-
blockPropsProvider.blockType = blockType;
blockPropsProvider.attributes = attributes;
innerBlocksPropsProvider.innerBlocks = innerBlocks;
@@ -8545,8 +10454,7 @@
attributes,
innerBlocks
});
-
- if ((0,external_lodash_namespaceObject.isObject)(element) && (0,external_wp_hooks_namespaceObject.hasFilter)('blocks.getSaveContent.extraProps') && !(blockType.apiVersion > 1)) {
+ if (element !== null && typeof element === 'object' && (0,external_wp_hooks_namespaceObject.hasFilter)('blocks.getSaveContent.extraProps') && !(blockType.apiVersion > 1)) {
/**
* Filters the props applied to the block save result element.
*
@@ -8554,24 +10462,24 @@
* @param {WPBlock} blockType Block type definition.
* @param {Object} attributes Block attributes.
*/
- const props = (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getSaveContent.extraProps', { ...element.props
+ const props = (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getSaveContent.extraProps', {
+ ...element.props
}, blockType, attributes);
-
if (!external_wp_isShallowEqual_default()(props, element.props)) {
element = (0,external_wp_element_namespaceObject.cloneElement)(element, props);
}
}
+
/**
* Filters the save result of a block during serialization.
*
- * @param {WPElement} element Block save result.
- * @param {WPBlock} blockType Block type definition.
- * @param {Object} attributes Block attributes.
+ * @param {Element} element Block save result.
+ * @param {WPBlock} blockType Block type definition.
+ * @param {Object} attributes Block attributes.
*/
-
-
return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getSaveElement', element, blockType, attributes);
}
+
/**
* Given a block type containing a save render implementation and attributes, returns the
* static markup to be saved.
@@ -8582,11 +10490,11 @@
*
* @return {string} Save content.
*/
-
function getSaveContent(blockTypeOrName, attributes, innerBlocks) {
const blockType = normalizeBlockType(blockTypeOrName);
return (0,external_wp_element_namespaceObject.renderToString)(getSaveElement(blockType, attributes, innerBlocks));
}
+
/**
* Returns attributes which are to be saved and serialized into the block
* comment delimiter.
@@ -8603,31 +10511,32 @@
*
* @return {Object<string,*>} Subset of attributes for comment serialization.
*/
-
function getCommentAttributes(blockType, attributes) {
- return (0,external_lodash_namespaceObject.reduce)(blockType.attributes, (accumulator, attributeSchema, key) => {
- const value = attributes[key]; // Ignore undefined values.
-
+ var _blockType$attributes;
+ return Object.entries((_blockType$attributes = blockType.attributes) !== null && _blockType$attributes !== void 0 ? _blockType$attributes : {}).reduce((accumulator, [key, attributeSchema]) => {
+ const value = attributes[key];
+ // Ignore undefined values.
if (undefined === value) {
return accumulator;
- } // Ignore all attributes but the ones with an "undefined" source
+ }
+
+ // Ignore all attributes but the ones with an "undefined" source
// "undefined" source refers to attributes saved in the block comment.
-
-
if (attributeSchema.source !== undefined) {
return accumulator;
- } // Ignore default value.
-
-
- if ('default' in attributeSchema && attributeSchema.default === value) {
+ }
+
+ // Ignore default value.
+ if ('default' in attributeSchema && JSON.stringify(attributeSchema.default) === JSON.stringify(value)) {
return accumulator;
- } // Otherwise, include in comment set.
-
-
+ }
+
+ // Otherwise, include in comment set.
accumulator[key] = value;
return accumulator;
}, {});
}
+
/**
* Given an attributes object, returns a string in the serialized attributes
* format prepared for post content.
@@ -8636,16 +10545,21 @@
*
* @return {string} Serialized attributes.
*/
-
function serializeAttributes(attributes) {
- return JSON.stringify(attributes) // Don't break HTML comments.
- .replace(/--/g, '\\u002d\\u002d') // Don't break non-standard-compliant tools.
- .replace(/</g, '\\u003c').replace(/>/g, '\\u003e').replace(/&/g, '\\u0026') // Bypass server stripslashes behavior which would unescape stringify's
+ return JSON.stringify(attributes)
+ // Don't break HTML comments.
+ .replace(/--/g, '\\u002d\\u002d')
+
+ // Don't break non-standard-compliant tools.
+ .replace(/</g, '\\u003c').replace(/>/g, '\\u003e').replace(/&/g, '\\u0026')
+
+ // Bypass server stripslashes behavior which would unescape stringify's
// escaping of quotation mark.
//
// See: https://developer.wordpress.org/reference/functions/wp_kses_stripslashes/
.replace(/\\"/g, '\\u0022');
}
+
/**
* Given a block object, returns the Block's Inner HTML markup.
*
@@ -8653,7 +10567,6 @@
*
* @return {string} HTML.
*/
-
function getBlockInnerHTML(block) {
// If block was parsed as invalid or encounters an error while generating
// save content, use original content instead to avoid content loss. If a
@@ -8661,15 +10574,14 @@
// otherwise have no access to its original content and content loss would
// still occur.
let saveContent = block.originalContent;
-
if (block.isValid || block.innerBlocks.length) {
try {
saveContent = getSaveContent(block.name, block.attributes, block.innerBlocks);
} catch (error) {}
}
-
return saveContent;
}
+
/**
* Returns the content of a block, including comment delimiters.
*
@@ -8679,45 +10591,44 @@
*
* @return {string} Comment-delimited block content.
*/
-
function getCommentDelimitedContent(rawBlockName, attributes, content) {
- const serializedAttributes = !(0,external_lodash_namespaceObject.isEmpty)(attributes) ? serializeAttributes(attributes) + ' ' : ''; // Strip core blocks of their namespace prefix.
-
- const blockName = (0,external_lodash_namespaceObject.startsWith)(rawBlockName, 'core/') ? rawBlockName.slice(5) : rawBlockName; // @todo make the `wp:` prefix potentially configurable.
+ const serializedAttributes = attributes && Object.entries(attributes).length ? serializeAttributes(attributes) + ' ' : '';
+
+ // Strip core blocks of their namespace prefix.
+ const blockName = rawBlockName?.startsWith('core/') ? rawBlockName.slice(5) : rawBlockName;
+
+ // @todo make the `wp:` prefix potentially configurable.
if (!content) {
return `<!-- wp:${blockName} ${serializedAttributes}/-->`;
}
-
return `<!-- wp:${blockName} ${serializedAttributes}-->\n` + content + `\n<!-- /wp:${blockName} -->`;
}
+
/**
* Returns the content of a block, including comment delimiters, determining
* serialized attributes and content form from the current state of the block.
*
- * @param {WPBlock} block Block instance.
- * @param {WPBlockSerializationOptions} options Serialization options.
+ * @param {WPBlock} block Block instance.
+ * @param {WPBlockSerializationOptions} options Serialization options.
*
* @return {string} Serialized block.
*/
-
-function serializeBlock(block) {
- let {
- isInnerBlocks = false
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
-
+function serializeBlock(block, {
+ isInnerBlocks = false
+} = {}) {
if (!block.isValid && block.__unstableBlockSource) {
return serializeRawBlock(block.__unstableBlockSource);
}
-
const blockName = block.name;
const saveContent = getBlockInnerHTML(block);
-
if (blockName === getUnregisteredTypeHandlerName() || !isInnerBlocks && blockName === getFreeformContentHandlerName()) {
return saveContent;
}
-
- const blockType = registration_getBlockType(blockName);
+ const blockType = getBlockType(blockName);
+ if (!blockType) {
+ return saveContent;
+ }
const saveAttributes = getCommentAttributes(blockType, block.attributes);
return getCommentDelimitedContent(blockName, saveAttributes, saveContent);
}
@@ -8727,17 +10638,17 @@
if (blocks.length === 1 && isUnmodifiedDefaultBlock(blocks[0])) {
blocks = [];
}
-
- let content = serializer_serialize(blocks); // For compatibility, treat a post consisting of a
+ let content = serialize(blocks);
+
+ // For compatibility, treat a post consisting of a
// single freeform block as legacy content and apply
// pre-block-editor removep'd content formatting.
-
- if (blocks.length === 1 && blocks[0].name === getFreeformContentHandlerName()) {
+ if (blocks.length === 1 && blocks[0].name === getFreeformContentHandlerName() && blocks[0].name === 'core/freeform') {
content = (0,external_wp_autop_namespaceObject.removep)(content);
}
-
return content;
}
+
/**
* Takes a block or set of blocks and returns the serialized post content.
*
@@ -8746,9 +10657,9 @@
*
* @return {string} The post content.
*/
-
-function serializer_serialize(blocks, options) {
- return (0,external_lodash_namespaceObject.castArray)(blocks).map(block => serializeBlock(block, options)).join('\n\n');
+function serialize(blocks, options) {
+ const blocksArray = Array.isArray(blocks) ? blocks : [blocks];
+ return blocksArray.map(block => serializeBlock(block, options)).join('\n\n');
}
;// CONCATENATED MODULE: ./node_modules/simple-html-tokenizer/dist/es6/index.js
@@ -9652,17 +11563,18 @@
-;// CONCATENATED MODULE: external ["wp","deprecated"]
-var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
-var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
+// EXTERNAL MODULE: ./node_modules/fast-deep-equal/es6/index.js
+var es6 = __webpack_require__(7734);
+var es6_default = /*#__PURE__*/__webpack_require__.n(es6);
;// CONCATENATED MODULE: external ["wp","htmlEntities"]
-var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
+const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/validation/logger.js
/**
* @typedef LoggerItem
* @property {Function} log Which logger recorded the message
* @property {Array<any>} args White arguments were supplied to the logger
*/
+
function createLogger() {
/**
* Creates a log handler with block validation prefix.
@@ -9672,33 +11584,23 @@
* @return {Function} Augmented logger function.
*/
function createLogHandler(logger) {
- let log = function (message) {
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
- args[_key - 1] = arguments[_key];
- }
-
- return logger('Block validation: ' + message, ...args);
- }; // In test environments, pre-process string substitutions to improve
+ let log = (message, ...args) => logger('Block validation: ' + message, ...args);
+
+ // In test environments, pre-process string substitutions to improve
// readability of error messages. We'd prefer to avoid pulling in this
// dependency in runtime environments, and it can be dropped by a combo
// of Webpack env substitution + UglifyJS dead code elimination.
-
-
if (false) {}
-
return log;
}
-
return {
// eslint-disable-next-line no-console
error: createLogHandler(console.error),
// eslint-disable-next-line no-console
warning: createLogHandler(console.warn),
-
getItems() {
return [];
}
-
};
}
function createQueuedLogger() {
@@ -9710,32 +11612,21 @@
const queue = [];
const logger = createLogger();
return {
- error() {
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
- args[_key2] = arguments[_key2];
- }
-
+ error(...args) {
queue.push({
log: logger.error,
args
});
},
-
- warning() {
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
- args[_key3] = arguments[_key3];
- }
-
+ warning(...args) {
queue.push({
log: logger.warning,
args
});
},
-
getItems() {
return queue;
}
-
};
}
@@ -9745,6 +11636,7 @@
*/
+
/**
* WordPress dependencies
*/
@@ -9760,32 +11652,32 @@
/** @typedef {import('../parser').WPBlock} WPBlock */
-
/** @typedef {import('../registration').WPBlockType} WPBlockType */
-
/** @typedef {import('./logger').LoggerItem} LoggerItem */
+const identity = x => x;
+
/**
* Globally matches any consecutive whitespace
*
* @type {RegExp}
*/
-
const REGEXP_WHITESPACE = /[\t\n\r\v\f ]+/g;
+
/**
* Matches a string containing only whitespace
*
* @type {RegExp}
*/
-
const REGEXP_ONLY_WHITESPACE = /^[\t\n\r\v\f ]*$/;
+
/**
* Matches a CSS URL type value
*
* @type {RegExp}
*/
-
const REGEXP_STYLE_URL_TYPE = /^url\s*\(['"\s]*(.*?)['"\s]*\)$/;
+
/**
* Boolean attributes are attributes whose presence as being assigned is
* meaningful, even if only empty.
@@ -9801,8 +11693,8 @@
*
* @type {Array}
*/
-
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'];
+
/**
* Enumerated attributes are attributes which must be of a specific value form.
* Like boolean attributes, these are meaningful if specified, even if not of a
@@ -9819,16 +11711,16 @@
*
* @type {Array}
*/
-
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'];
+
/**
* Meaningful attributes are those who cannot be safely ignored when omitted in
* one HTML markup string and not another.
*
* @type {Array}
*/
-
const MEANINGFUL_ATTRIBUTES = [...BOOLEAN_ATTRIBUTES, ...ENUMERATED_ATTRIBUTES];
+
/**
* Array of functions which receive a text string on which to apply normalizing
* behavior for consideration in text token equivalence, carefully ordered from
@@ -9836,8 +11728,8 @@
*
* @type {Array}
*/
-
-const TEXT_NORMALIZATIONS = [external_lodash_namespaceObject.identity, getTextWithCollapsedWhitespace];
+const TEXT_NORMALIZATIONS = [identity, getTextWithCollapsedWhitespace];
+
/**
* Regular expression matching a named character reference. In lieu of bundling
* a full set of references, the pattern covers the minimal necessary to test
@@ -9860,8 +11752,8 @@
*
* @type {RegExp}
*/
-
const REGEXP_NAMED_CHARACTER_REFERENCE = /^[\da-z]+$/i;
+
/**
* Regular expression matching a decimal character reference.
*
@@ -9872,8 +11764,8 @@
*
* @type {RegExp}
*/
-
const REGEXP_DECIMAL_CHARACTER_REFERENCE = /^#\d+$/;
+
/**
* Regular expression matching a hexadecimal character reference.
*
@@ -9886,8 +11778,8 @@
*
* @type {RegExp}
*/
-
const REGEXP_HEXADECIMAL_CHARACTER_REFERENCE = /^#x[\da-f]+$/i;
+
/**
* Returns true if the given string is a valid character reference segment, or
* false otherwise. The text should be stripped of `&` and `;` demarcations.
@@ -9896,10 +11788,10 @@
*
* @return {boolean} Whether text is valid character reference.
*/
-
function isValidCharacterReference(text) {
return REGEXP_NAMED_CHARACTER_REFERENCE.test(text) || REGEXP_DECIMAL_CHARACTER_REFERENCE.test(text) || REGEXP_HEXADECIMAL_CHARACTER_REFERENCE.test(text);
}
+
/**
* Subsitute EntityParser class for `simple-html-tokenizer` which uses the
* implementation of `decodeEntities` from `html-entities`, in order to avoid
@@ -9907,7 +11799,6 @@
*
* @see https://github.com/tildeio/simple-html-tokenizer/tree/HEAD/src/entity-parser.ts
*/
-
class DecodeEntityParser {
/**
* Returns a substitute string for an entity string sequence between `&`
@@ -9915,15 +11806,15 @@
*
* @param {string} entity Entity fragment discovered in HTML.
*
- * @return {?string} Entity substitute value.
+ * @return {string | undefined} Entity substitute value.
*/
parse(entity) {
if (isValidCharacterReference(entity)) {
return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)('&' + entity + ';');
}
}
-
-}
+}
+
/**
* Given a specified string, returns an array of strings split by consecutive
* whitespace, ignoring leading or trailing whitespace.
@@ -9932,10 +11823,10 @@
*
* @return {string[]} Text pieces split on whitespace.
*/
-
function getTextPiecesSplitOnWhitespace(text) {
return text.trim().split(REGEXP_WHITESPACE);
}
+
/**
* Given a specified string, returns a new trimmed string where all consecutive
* whitespace is collapsed to a single space.
@@ -9944,7 +11835,6 @@
*
* @return {string} Trimmed text with consecutive whitespace collapsed.
*/
-
function getTextWithCollapsedWhitespace(text) {
// This is an overly simplified whitespace comparison. The specification is
// more prescriptive of whitespace behavior in inline and block contexts.
@@ -9952,6 +11842,7 @@
// See: https://medium.com/@patrickbrosset/when-does-white-space-matter-in-html-b90e8a7cdd33
return getTextPiecesSplitOnWhitespace(text).join(' ');
}
+
/**
* Returns attribute pairs of the given StartTag token, including only pairs
* where the value is non-empty or the attribute is a boolean attribute, an
@@ -9963,13 +11854,13 @@
*
* @return {Array[]} Attribute pairs.
*/
-
function getMeaningfulAttributePairs(token) {
return token.attributes.filter(pair => {
const [key, value] = pair;
- return value || key.indexOf('data-') === 0 || (0,external_lodash_namespaceObject.includes)(MEANINGFUL_ATTRIBUTES, key);
+ return value || key.indexOf('data-') === 0 || MEANINGFUL_ATTRIBUTES.includes(key);
});
}
+
/**
* Returns true if two text tokens (with `chars` property) are equivalent, or
* false otherwise.
@@ -9980,29 +11871,25 @@
*
* @return {boolean} Whether two text tokens are equivalent.
*/
-
-function isEquivalentTextTokens(actual, expected) {
- let logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger();
+function isEquivalentTextTokens(actual, expected, logger = createLogger()) {
// This function is intentionally written as syntactically "ugly" as a hot
// path optimization. Text is progressively normalized in order from least-
// to-most operationally expensive, until the earliest point at which text
// can be confidently inferred as being equal.
let actualChars = actual.chars;
let expectedChars = expected.chars;
-
for (let i = 0; i < TEXT_NORMALIZATIONS.length; i++) {
const normalize = TEXT_NORMALIZATIONS[i];
actualChars = normalize(actualChars);
expectedChars = normalize(expectedChars);
-
if (actualChars === expectedChars) {
return true;
}
}
-
logger.warning('Expected text `%s`, saw `%s`.', expected.chars, actual.chars);
return false;
}
+
/**
* Given a CSS length value, returns a normalized CSS length value for strict equality
* comparison.
@@ -10011,19 +11898,17 @@
*
* @return {string} Normalized CSS length value.
*/
-
function getNormalizedLength(value) {
if (0 === parseFloat(value)) {
return '0';
- } // Normalize strings with floats to always include a leading zero.
-
-
+ }
+ // Normalize strings with floats to always include a leading zero.
if (value.indexOf('.') === 0) {
return '0' + value;
}
-
return value;
}
+
/**
* Given a style value, returns a normalized style value for strict equality
* comparison.
@@ -10032,14 +11917,15 @@
*
* @return {string} Normalized style value.
*/
-
function getNormalizedStyleValue(value) {
const textPieces = getTextPiecesSplitOnWhitespace(value);
const normalizedPieces = textPieces.map(getNormalizedLength);
const result = normalizedPieces.join(' ');
- return result // Normalize URL type to omit whitespace or quotes.
+ return result
+ // Normalize URL type to omit whitespace or quotes.
.replace(REGEXP_STYLE_URL_TYPE, 'url($1)');
}
+
/**
* Given a style attribute string, returns an object of style properties.
*
@@ -10047,38 +11933,44 @@
*
* @return {Object} Style properties.
*/
-
function getStyleProperties(text) {
- const pairs = text // Trim ending semicolon (avoid including in split)
- .replace(/;?\s*$/, '') // Split on property assignment.
- .split(';') // For each property assignment...
+ const pairs = text
+ // Trim ending semicolon (avoid including in split)
+ .replace(/;?\s*$/, '')
+ // Split on property assignment.
+ .split(';')
+ // For each property assignment...
.map(style => {
// ...split further into key-value pairs.
const [key, ...valueParts] = style.split(':');
const value = valueParts.join(':');
return [key.trim(), getNormalizedStyleValue(value.trim())];
});
- return (0,external_lodash_namespaceObject.fromPairs)(pairs);
-}
+ return Object.fromEntries(pairs);
+}
+
/**
* Attribute-specific equality handlers
*
* @type {Object}
*/
-
const isEqualAttributesOfName = {
class: (actual, expected) => {
// Class matches if members are the same, even if out of order or
// superfluous whitespace between.
- return !(0,external_lodash_namespaceObject.xor)(...[actual, expected].map(getTextPiecesSplitOnWhitespace)).length;
+ const [actualPieces, expectedPieces] = [actual, expected].map(getTextPiecesSplitOnWhitespace);
+ const actualDiff = actualPieces.filter(c => !expectedPieces.includes(c));
+ const expectedDiff = expectedPieces.filter(c => !actualPieces.includes(c));
+ return actualDiff.length === 0 && expectedDiff.length === 0;
},
style: (actual, expected) => {
- return (0,external_lodash_namespaceObject.isEqual)(...[actual, expected].map(getStyleProperties));
+ return es6_default()(...[actual, expected].map(getStyleProperties));
},
// For each boolean attribute, mere presence of attribute in both is enough
// to assume equivalence.
- ...(0,external_lodash_namespaceObject.fromPairs)(BOOLEAN_ATTRIBUTES.map(attribute => [attribute, external_lodash_namespaceObject.stubTrue]))
-};
+ ...Object.fromEntries(BOOLEAN_ATTRIBUTES.map(attribute => [attribute, () => true]))
+};
+
/**
* Given two sets of attribute tuples, returns true if the attribute sets are
* equivalent.
@@ -10089,39 +11981,33 @@
*
* @return {boolean} Whether attributes are equivalent.
*/
-
-function isEqualTagAttributePairs(actual, expected) {
- let logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger();
-
+function isEqualTagAttributePairs(actual, expected, logger = createLogger()) {
// Attributes is tokenized as tuples. Their lengths should match. This also
// avoids us needing to check both attributes sets, since if A has any keys
// which do not exist in B, we know the sets to be different.
if (actual.length !== expected.length) {
logger.warning('Expected attributes %o, instead saw %o.', expected, actual);
return false;
- } // Attributes are not guaranteed to occur in the same order. For validating
+ }
+
+ // Attributes are not guaranteed to occur in the same order. For validating
// actual attributes, first convert the set of expected attribute values to
// an object, for lookup by key.
-
-
const expectedAttributes = {};
-
for (let i = 0; i < expected.length; i++) {
expectedAttributes[expected[i][0].toLowerCase()] = expected[i][1];
}
-
for (let i = 0; i < actual.length; i++) {
const [name, actualValue] = actual[i];
- const nameLower = name.toLowerCase(); // As noted above, if missing member in B, assume different.
-
+ const nameLower = name.toLowerCase();
+
+ // As noted above, if missing member in B, assume different.
if (!expectedAttributes.hasOwnProperty(nameLower)) {
logger.warning('Encountered unexpected attribute `%s`.', name);
return false;
}
-
const expectedValue = expectedAttributes[nameLower];
const isEqualAttributes = isEqualAttributesOfName[nameLower];
-
if (isEqualAttributes) {
// Defer custom attribute equality handling.
if (!isEqualAttributes(actualValue, expectedValue)) {
@@ -10134,32 +12020,30 @@
return false;
}
}
-
return true;
}
+
/**
* Token-type-specific equality handlers
*
* @type {Object}
*/
-
const isEqualTokensOfType = {
- StartTag: function (actual, expected) {
- let logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger();
-
- if (actual.tagName !== expected.tagName && // Optimization: Use short-circuit evaluation to defer case-
+ StartTag: (actual, expected, logger = createLogger()) => {
+ if (actual.tagName !== expected.tagName &&
+ // Optimization: Use short-circuit evaluation to defer case-
// insensitive check on the assumption that the majority case will
// have exactly equal tag names.
actual.tagName.toLowerCase() !== expected.tagName.toLowerCase()) {
logger.warning('Expected tag name `%s`, instead saw `%s`.', expected.tagName, actual.tagName);
return false;
}
-
return isEqualTagAttributePairs(...[actual, expected].map(getMeaningfulAttributePairs), logger);
},
Chars: isEquivalentTextTokens,
Comment: isEquivalentTextTokens
};
+
/**
* Given an array of tokens, returns the first token which is not purely
* whitespace.
@@ -10168,22 +12052,20 @@
*
* @param {Object[]} tokens Set of tokens to search.
*
- * @return {Object} Next non-whitespace token.
- */
-
+ * @return {Object | undefined} Next non-whitespace token.
+ */
function getNextNonWhitespaceToken(tokens) {
let token;
-
while (token = tokens.shift()) {
if (token.type !== 'Chars') {
return token;
}
-
if (!REGEXP_ONLY_WHITESPACE.test(token.chars)) {
return token;
}
}
}
+
/**
* Tokenize an HTML string, gracefully handling any errors thrown during
* underlying tokenization.
@@ -10193,18 +12075,15 @@
*
* @return {Object[]|null} Array of valid tokenized HTML elements, or null on error
*/
-
-function getHTMLTokens(html) {
- let logger = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createLogger();
-
+function getHTMLTokens(html, logger = createLogger()) {
try {
return new Tokenizer(new DecodeEntityParser()).tokenize(html);
} catch (e) {
logger.warning('Malformed HTML detected: %s', html);
}
-
return null;
}
+
/**
* Returns true if the next HTML token closes the current token.
*
@@ -10213,21 +12092,19 @@
*
* @return {boolean} true if `nextToken` closes `currentToken`, false otherwise
*/
-
-
function isClosedByToken(currentToken, nextToken) {
// Ensure this is a self closed token.
if (!currentToken.selfClosing) {
return false;
- } // Check token names and determine if nextToken is the closing tag for currentToken.
-
-
+ }
+
+ // Check token names and determine if nextToken is the closing tag for currentToken.
if (nextToken && nextToken.tagName === currentToken.tagName && nextToken.type === 'EndTag') {
return true;
}
-
return false;
}
+
/**
* Returns true if the given HTML strings are effectively equivalent, or
* false otherwise. Invalid HTML is not considered equivalent, even if the
@@ -10239,48 +12116,44 @@
*
* @return {boolean} Whether HTML strings are equivalent.
*/
-
-function isEquivalentHTML(actual, expected) {
- let logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger();
-
+function isEquivalentHTML(actual, expected, logger = createLogger()) {
// Short-circuit if markup is identical.
if (actual === expected) {
return true;
- } // Tokenize input content and reserialized save content.
-
-
- const [actualTokens, expectedTokens] = [actual, expected].map(html => getHTMLTokens(html, logger)); // If either is malformed then stop comparing - the strings are not equivalent.
-
+ }
+
+ // Tokenize input content and reserialized save content.
+ const [actualTokens, expectedTokens] = [actual, expected].map(html => getHTMLTokens(html, logger));
+
+ // If either is malformed then stop comparing - the strings are not equivalent.
if (!actualTokens || !expectedTokens) {
return false;
}
-
let actualToken, expectedToken;
-
while (actualToken = getNextNonWhitespaceToken(actualTokens)) {
- expectedToken = getNextNonWhitespaceToken(expectedTokens); // Inequal if exhausted all expected tokens.
-
+ expectedToken = getNextNonWhitespaceToken(expectedTokens);
+
+ // Inequal if exhausted all expected tokens.
if (!expectedToken) {
logger.warning('Expected end of content, instead saw %o.', actualToken);
return false;
- } // Inequal if next non-whitespace token of each set are not same type.
-
-
+ }
+
+ // Inequal if next non-whitespace token of each set are not same type.
if (actualToken.type !== expectedToken.type) {
logger.warning('Expected token of type `%s` (%o), instead saw `%s` (%o).', expectedToken.type, expectedToken, actualToken.type, actualToken);
return false;
- } // Defer custom token type equality handling, otherwise continue and
+ }
+
+ // Defer custom token type equality handling, otherwise continue and
// assume as equal.
-
-
const isEqualTokens = isEqualTokensOfType[actualToken.type];
-
if (isEqualTokens && !isEqualTokens(actualToken, expectedToken, logger)) {
return false;
- } // Peek at the next tokens (actual and expected) to see if they close
+ }
+
+ // Peek at the next tokens (actual and expected) to see if they close
// a self-closing tag.
-
-
if (isClosedByToken(actualToken, expectedTokens[0])) {
// Consume the next expected token that closes the current actual
// self-closing token.
@@ -10291,16 +12164,15 @@
getNextNonWhitespaceToken(actualTokens);
}
}
-
if (expectedToken = getNextNonWhitespaceToken(expectedTokens)) {
// If any non-whitespace tokens remain in expected token set, this
// indicates inequality.
logger.warning('Expected %o, instead saw end of content.', expectedToken);
return false;
}
-
return true;
}
+
/**
* Returns an object with `isValid` property set to `true` if the parsed block
* is valid given the input content. A block is considered valid if, when serialized
@@ -10326,34 +12198,29 @@
*
* @return {[boolean,Array<LoggerItem>]} validation results.
*/
-
-function validateBlock(block) {
- let blockTypeOrName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : block.name;
- const isFallbackBlock = block.name === getFreeformContentHandlerName() || block.name === getUnregisteredTypeHandlerName(); // Shortcut to avoid costly validation.
-
+function validateBlock(block, blockTypeOrName = block.name) {
+ const isFallbackBlock = block.name === getFreeformContentHandlerName() || block.name === getUnregisteredTypeHandlerName();
+
+ // Shortcut to avoid costly validation.
if (isFallbackBlock) {
return [true, []];
}
-
const logger = createQueuedLogger();
const blockType = normalizeBlockType(blockTypeOrName);
let generatedBlockContent;
-
try {
generatedBlockContent = getSaveContent(blockType, block.attributes);
} catch (error) {
logger.error('Block validation failed because an error occurred while generating block content:\n\n%s', error.toString());
return [false, logger.getItems()];
}
-
const isValid = isEquivalentHTML(block.originalContent, generatedBlockContent, logger);
-
if (!isValid) {
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);
}
-
return [isValid, logger.getItems()];
}
+
/**
* Returns true if the parsed block is valid given the input content. A block
* is considered valid if, when serialized with assumed attributes, the content
@@ -10369,7 +12236,6 @@
*
* @return {boolean} Whether block is valid.
*/
-
function isValidBlockContent(blockTypeOrName, attributes, originalBlockContent) {
external_wp_deprecated_default()('isValidBlockContent introduces opportunity for data loss', {
since: '12.6',
@@ -10399,28 +12265,29 @@
* @return {[string, Object]} The block's name and attributes, changed accordingly if a match was found
*/
function convertLegacyBlockNameAndAttributes(name, attributes) {
- const newAttributes = { ...attributes
- }; // Convert 'core/cover-image' block in existing content to 'core/cover'.
-
+ const newAttributes = {
+ ...attributes
+ };
+ // Convert 'core/cover-image' block in existing content to 'core/cover'.
if ('core/cover-image' === name) {
name = 'core/cover';
- } // Convert 'core/text' blocks in existing content to 'core/paragraph'.
-
-
+ }
+
+ // Convert 'core/text' blocks in existing content to 'core/paragraph'.
if ('core/text' === name || 'core/cover-text' === name) {
name = 'core/paragraph';
- } // Convert derivative blocks such as 'core/social-link-wordpress' to the
+ }
+
+ // Convert derivative blocks such as 'core/social-link-wordpress' to the
// canonical form 'core/social-link'.
-
-
if (name && name.indexOf('core/social-link-') === 0) {
// Capture `social-link-wordpress` into `{"service":"wordpress"}`
newAttributes.service = name.substring(17);
name = 'core/social-link';
- } // Convert derivative blocks such as 'core-embed/instagram' to the
+ }
+
+ // Convert derivative blocks such as 'core-embed/instagram' to the
// canonical form 'core/embed'.
-
-
if (name && name.indexOf('core-embed/') === 0) {
// Capture `core-embed/instagram` into `{"providerNameSlug":"instagram"}`
const providerSlug = name.substring(11);
@@ -10428,36 +12295,45 @@
speaker: 'speaker-deck',
polldaddy: 'crowdsignal'
};
- newAttributes.providerNameSlug = providerSlug in deprecated ? deprecated[providerSlug] : providerSlug; // This is needed as the `responsive` attribute was passed
+ newAttributes.providerNameSlug = providerSlug in deprecated ? deprecated[providerSlug] : providerSlug;
+ // This is needed as the `responsive` attribute was passed
// in a different way before the refactoring to block variations.
-
if (!['amazon-kindle', 'wordpress'].includes(providerSlug)) {
newAttributes.responsive = true;
}
-
name = 'core/embed';
- } // Convert 'core/query-loop' blocks in existing content to 'core/post-template'.
- // TODO: Remove this check when WordPress 5.9 is released.
-
-
- if (name === 'core/query-loop') {
- name = 'core/post-template';
- } // Convert Post Comment blocks in existing content to Comment blocks.
+ }
+
+ // Convert Post Comment blocks in existing content to Comment blocks.
// TODO: Remove these checks when WordPress 6.0 is released.
-
-
if (name === 'core/post-comment-author') {
name = 'core/comment-author-name';
}
-
if (name === 'core/post-comment-content') {
name = 'core/comment-content';
}
-
if (name === 'core/post-comment-date') {
name = 'core/comment-date';
}
-
+ if (name === 'core/comments-query-loop') {
+ name = 'core/comments';
+ const {
+ className = ''
+ } = newAttributes;
+ if (!className.includes('wp-block-comments-query-loop')) {
+ newAttributes.className = ['wp-block-comments-query-loop', className].join(' ');
+ }
+ // Note that we also had to add a deprecation to the block in order
+ // for the ID change to work.
+ }
+ if (name === 'core/post-comments') {
+ name = 'core/comments';
+ newAttributes.legacy = true;
+ }
+
+ // The following code is only relevant for the Gutenberg plugin.
+ // It's a stand-alone if statement for dead-code elimination.
+ if (false) {}
return [name, newAttributes];
}
@@ -10640,58 +12516,226 @@
});
};
}
-// EXTERNAL MODULE: ./node_modules/memize/index.js
-var memize = __webpack_require__(9756);
-var memize_default = /*#__PURE__*/__webpack_require__.n(memize);
+;// CONCATENATED MODULE: ./node_modules/memize/dist/index.js
+/**
+ * Memize options object.
+ *
+ * @typedef MemizeOptions
+ *
+ * @property {number} [maxSize] Maximum size of the cache.
+ */
+
+/**
+ * Internal cache entry.
+ *
+ * @typedef MemizeCacheNode
+ *
+ * @property {?MemizeCacheNode|undefined} [prev] Previous node.
+ * @property {?MemizeCacheNode|undefined} [next] Next node.
+ * @property {Array<*>} args Function arguments for cache
+ * entry.
+ * @property {*} val Function result.
+ */
+
+/**
+ * Properties of the enhanced function for controlling cache.
+ *
+ * @typedef MemizeMemoizedFunction
+ *
+ * @property {()=>void} clear Clear the cache.
+ */
+
+/**
+ * Accepts a function to be memoized, and returns a new memoized function, with
+ * optional options.
+ *
+ * @template {(...args: any[]) => any} F
+ *
+ * @param {F} fn Function to memoize.
+ * @param {MemizeOptions} [options] Options object.
+ *
+ * @return {((...args: Parameters<F>) => ReturnType<F>) & MemizeMemoizedFunction} Memoized function.
+ */
+function memize(fn, options) {
+ var size = 0;
+
+ /** @type {?MemizeCacheNode|undefined} */
+ var head;
+
+ /** @type {?MemizeCacheNode|undefined} */
+ var tail;
+
+ options = options || {};
+
+ function memoized(/* ...args */) {
+ var node = head,
+ len = arguments.length,
+ args,
+ i;
+
+ searchCache: while (node) {
+ // Perform a shallow equality test to confirm that whether the node
+ // under test is a candidate for the arguments passed. Two arrays
+ // are shallowly equal if their length matches and each entry is
+ // strictly equal between the two sets. Avoid abstracting to a
+ // function which could incur an arguments leaking deoptimization.
+
+ // Check whether node arguments match arguments length
+ if (node.args.length !== arguments.length) {
+ node = node.next;
+ continue;
+ }
+
+ // Check whether node arguments match arguments values
+ for (i = 0; i < len; i++) {
+ if (node.args[i] !== arguments[i]) {
+ node = node.next;
+ continue searchCache;
+ }
+ }
+
+ // At this point we can assume we've found a match
+
+ // Surface matched node to head if not already
+ if (node !== head) {
+ // As tail, shift to previous. Must only shift if not also
+ // head, since if both head and tail, there is no previous.
+ if (node === tail) {
+ tail = node.prev;
+ }
+
+ // Adjust siblings to point to each other. If node was tail,
+ // this also handles new tail's empty `next` assignment.
+ /** @type {MemizeCacheNode} */ (node.prev).next = node.next;
+ if (node.next) {
+ node.next.prev = node.prev;
+ }
+
+ node.next = head;
+ node.prev = null;
+ /** @type {MemizeCacheNode} */ (head).prev = node;
+ head = node;
+ }
+
+ // Return immediately
+ return node.val;
+ }
+
+ // No cached value found. Continue to insertion phase:
+
+ // Create a copy of arguments (avoid leaking deoptimization)
+ args = new Array(len);
+ for (i = 0; i < len; i++) {
+ args[i] = arguments[i];
+ }
+
+ node = {
+ args: args,
+
+ // Generate the result from original function
+ val: fn.apply(null, args),
+ };
+
+ // Don't need to check whether node is already head, since it would
+ // have been returned above already if it was
+
+ // Shift existing head down list
+ if (head) {
+ head.prev = node;
+ node.next = head;
+ } else {
+ // If no head, follows that there's no tail (at initial or reset)
+ tail = node;
+ }
+
+ // Trim tail if we're reached max size and are pending cache insertion
+ if (size === /** @type {MemizeOptions} */ (options).maxSize) {
+ tail = /** @type {MemizeCacheNode} */ (tail).prev;
+ /** @type {MemizeCacheNode} */ (tail).next = null;
+ } else {
+ size++;
+ }
+
+ head = node;
+
+ return node.val;
+ }
+
+ memoized.clear = function () {
+ head = null;
+ tail = null;
+ size = 0;
+ };
+
+ // Ignore reason: There's not a clear solution to create an intersection of
+ // the function with additional properties, where the goal is to retain the
+ // function signature of the incoming argument and add control properties
+ // on the return value.
+
+ // @ts-ignore
+ return memoized;
+}
+
+
+
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/matchers.js
/**
* External dependencies
*/
+
+/**
+ * WordPress dependencies
+ */
+
+
/**
* Internal dependencies
*/
-
function matchers_html(selector, multilineTag) {
return domNode => {
let match = domNode;
-
if (selector) {
match = domNode.querySelector(selector);
}
-
if (!match) {
return '';
}
-
if (multilineTag) {
let value = '';
const length = match.children.length;
-
for (let index = 0; index < length; index++) {
const child = match.children[index];
-
if (child.nodeName.toLowerCase() !== multilineTag) {
continue;
}
-
value += child.outerHTML;
}
-
return value;
}
-
return match.innerHTML;
};
}
+const richText = (selector, preserveWhiteSpace) => el => {
+ const target = selector ? el.querySelector(selector) : el;
+ return target ? external_wp_richText_namespaceObject.RichTextData.fromHTMLElement(target, {
+ preserveWhiteSpace
+ }) : external_wp_richText_namespaceObject.RichTextData.empty();
+};
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/node.js
/**
+ * WordPress dependencies
+ */
+
+
+/**
* Internal dependencies
*/
+
/**
* A representation of a single node within a block's rich text value. If
* representing a text node, the value is simply a string of the node value.
@@ -10712,10 +12756,15 @@
*
* @return {boolean} Whether node is of intended type.
*/
-
function isNodeOfType(node, type) {
+ external_wp_deprecated_default()('wp.blocks.node.isNodeOfType', {
+ since: '6.1',
+ version: '6.3',
+ link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
+ });
return node && node.type === type;
}
+
/**
* Given an object implementing the NamedNodeMap interface, returns a plain
* object equivalent value of name, value key-value pairs.
@@ -10726,11 +12775,8 @@
*
* @return {Object} Object equivalent value of NamedNodeMap.
*/
-
-
function getNamedNodeMapAsObject(nodeMap) {
const result = {};
-
for (let i = 0; i < nodeMap.length; i++) {
const {
name,
@@ -10738,9 +12784,9 @@
} = nodeMap[i];
result[name] = value;
}
-
return result;
}
+
/**
* Given a DOM Element or Text node, returns an equivalent block node. Throws
* if passed any node type other than element or text.
@@ -10751,23 +12797,28 @@
*
* @return {WPBlockNode} Block node equivalent to DOM node.
*/
-
function fromDOM(domNode) {
+ external_wp_deprecated_default()('wp.blocks.node.fromDOM', {
+ since: '6.1',
+ version: '6.3',
+ alternative: 'wp.richText.create',
+ link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
+ });
if (domNode.nodeType === domNode.TEXT_NODE) {
return domNode.nodeValue;
}
-
if (domNode.nodeType !== domNode.ELEMENT_NODE) {
throw new TypeError('A block node can only be created from a node of type text or ' + 'element.');
}
-
return {
type: domNode.nodeName.toLowerCase(),
- props: { ...getNamedNodeMapAsObject(domNode.attributes),
+ props: {
+ ...getNamedNodeMapAsObject(domNode.attributes),
children: children_fromDOM(domNode.childNodes)
}
};
}
+
/**
* Given a block node, returns its HTML string representation.
*
@@ -10775,10 +12826,16 @@
*
* @return {string} String HTML representation of block node.
*/
-
function toHTML(node) {
+ external_wp_deprecated_default()('wp.blocks.node.toHTML', {
+ since: '6.1',
+ version: '6.3',
+ alternative: 'wp.richText.toHTMLString',
+ link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
+ });
return children_toHTML([node]);
}
+
/**
* Given a selector, returns an hpq matcher generating a WPBlockNode value
* matching the selector result.
@@ -10787,15 +12844,18 @@
*
* @return {Function} hpq matcher.
*/
-
-function node_matcher(selector) {
+function matcher(selector) {
+ external_wp_deprecated_default()('wp.blocks.node.matcher', {
+ since: '6.1',
+ version: '6.3',
+ alternative: 'html source',
+ link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
+ });
return domNode => {
let match = domNode;
-
if (selector) {
match = domNode.querySelector(selector);
}
-
try {
return fromDOM(match);
} catch (error) {
@@ -10803,6 +12863,7 @@
}
};
}
+
/**
* Object of utility functions used in managing block attribute values of
* source `node`.
@@ -10814,24 +12875,20 @@
*
* @private
*/
-
-/* harmony default export */ var node = ({
+/* harmony default export */ const node = ({
isNodeOfType,
fromDOM,
toHTML,
- matcher: node_matcher
+ matcher
});
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/children.js
/**
- * External dependencies
- */
-
-/**
* WordPress dependencies
*/
+
/**
* Internal dependencies
*/
@@ -10848,9 +12905,8 @@
*
* @param {WPBlockChildren} children Block children object to convert.
*
- * @return {WPElement} A serialize-capable element.
- */
-
+ * @return {Element} A serialize-capable element.
+ */
function getSerializeCapableElement(children) {
// The fact that block children are compatible with the element serializer is
// merely an implementation detail that currently serves to be true, but
@@ -10860,6 +12916,7 @@
// rather than expect consumers to inspect or construct its shape (concat).
return children;
}
+
/**
* Given block children, returns an array of block nodes.
*
@@ -10867,13 +12924,19 @@
*
* @return {Array<WPBlockNode>} An array of individual block nodes.
*/
-
function getChildrenArray(children) {
+ external_wp_deprecated_default()('wp.blocks.children.getChildrenArray', {
+ since: '6.1',
+ version: '6.3',
+ link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
+ });
+
// The fact that block children are compatible with the element serializer
// is merely an implementation detail that currently serves to be true, but
// should not be mistaken as being a guarantee on the external API.
return children;
}
+
/**
* Given two or more block nodes, returns a new block node representing a
* concatenation of its values.
@@ -10882,18 +12945,19 @@
*
* @return {WPBlockChildren} Concatenated block node.
*/
-
-
-function concat() {
+function concat(...blockNodes) {
+ external_wp_deprecated_default()('wp.blocks.children.concat', {
+ since: '6.1',
+ version: '6.3',
+ alternative: 'wp.richText.concat',
+ link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
+ });
const result = [];
-
- for (let i = 0; i < arguments.length; i++) {
- const blockNode = (0,external_lodash_namespaceObject.castArray)(i < 0 || arguments.length <= i ? undefined : arguments[i]);
-
+ for (let i = 0; i < blockNodes.length; i++) {
+ const blockNode = Array.isArray(blockNodes[i]) ? blockNodes[i] : [blockNodes[i]];
for (let j = 0; j < blockNode.length; j++) {
const child = blockNode[j];
const canConcatToPreviousString = typeof child === 'string' && typeof result[result.length - 1] === 'string';
-
if (canConcatToPreviousString) {
result[result.length - 1] += child;
} else {
@@ -10901,9 +12965,9 @@
}
}
}
-
return result;
}
+
/**
* Given an iterable set of DOM nodes, returns equivalent block children.
* Ignores any non-element/text nodes included in set.
@@ -10912,19 +12976,24 @@
*
* @return {WPBlockChildren} Block children equivalent to DOM nodes.
*/
-
function children_fromDOM(domNodes) {
+ external_wp_deprecated_default()('wp.blocks.children.fromDOM', {
+ since: '6.1',
+ version: '6.3',
+ alternative: 'wp.richText.create',
+ link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
+ });
const result = [];
-
for (let i = 0; i < domNodes.length; i++) {
try {
result.push(fromDOM(domNodes[i]));
- } catch (error) {// Simply ignore if DOM node could not be converted.
- }
- }
-
+ } catch (error) {
+ // Simply ignore if DOM node could not be converted.
+ }
+ }
return result;
}
+
/**
* Given a block node, returns its HTML string representation.
*
@@ -10932,11 +13001,17 @@
*
* @return {string} String HTML representation of block node.
*/
-
function children_toHTML(children) {
+ external_wp_deprecated_default()('wp.blocks.children.toHTML', {
+ since: '6.1',
+ version: '6.3',
+ alternative: 'wp.richText.toHTMLString',
+ link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
+ });
const element = getSerializeCapableElement(children);
return (0,external_wp_element_namespaceObject.renderToString)(element);
}
+
/**
* Given a selector, returns an hpq matcher generating a WPBlockChildren value
* matching the selector result.
@@ -10945,22 +13020,25 @@
*
* @return {Function} hpq matcher.
*/
-
function children_matcher(selector) {
+ external_wp_deprecated_default()('wp.blocks.children.matcher', {
+ since: '6.1',
+ version: '6.3',
+ alternative: 'html source',
+ link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
+ });
return domNode => {
let match = domNode;
-
if (selector) {
match = domNode.querySelector(selector);
}
-
if (match) {
return children_fromDOM(match.childNodes);
}
-
return [];
};
}
+
/**
* Object of utility functions used in managing block attribute values of
* source `children`.
@@ -10972,8 +13050,7 @@
*
* @private
*/
-
-/* harmony default export */ var children = ({
+/* harmony default export */ const children = ({
concat,
getChildrenArray,
fromDOM: children_fromDOM,
@@ -10993,6 +13070,7 @@
*/
+
/**
* Internal dependencies
*/
@@ -11010,21 +13088,8 @@
*
* @return {Function} Enhanced hpq matcher.
*/
-
-const toBooleanAttributeMatcher = matcher => (0,external_lodash_namespaceObject.flow)([matcher, // Expected values from `attr( 'disabled' )`:
-//
-// <input>
-// - Value: `undefined`
-// - Transformed: `false`
-//
-// <input disabled>
-// - Value: `''`
-// - Transformed: `true`
-//
-// <input disabled="disabled">
-// - Value: `'disabled'`
-// - Transformed: `true`
-value => value !== undefined]);
+const toBooleanAttributeMatcher = matcher => value => matcher(value) !== undefined;
+
/**
* Returns true if value is of the given JSON schema type, or false otherwise.
*
@@ -11035,31 +13100,27 @@
*
* @return {boolean} Whether value is of type.
*/
-
function isOfType(value, type) {
switch (type) {
+ case 'rich-text':
+ return value instanceof external_wp_richText_namespaceObject.RichTextData;
case 'string':
return typeof value === 'string';
-
case 'boolean':
return typeof value === 'boolean';
-
case 'object':
return !!value && value.constructor === Object;
-
case 'null':
return value === null;
-
case 'array':
return Array.isArray(value);
-
case 'integer':
case 'number':
return typeof value === 'number';
}
-
return true;
}
+
/**
* Returns true if value is of an array of given JSON schema types, or false
* otherwise.
@@ -11071,57 +13132,58 @@
*
* @return {boolean} Whether value is of types.
*/
-
function isOfTypes(value, types) {
return types.some(type => isOfType(value, type));
}
+
/**
* Given an attribute key, an attribute's schema, a block's raw content and the
* commentAttributes returns the attribute value depending on its source
* definition of the given attribute key.
*
- * @param {string} attributeKey Attribute key.
- * @param {Object} attributeSchema Attribute's schema.
- * @param {string|Node} innerHTML Block's raw content.
- * @param {Object} commentAttributes Block's comment attributes.
+ * @param {string} attributeKey Attribute key.
+ * @param {Object} attributeSchema Attribute's schema.
+ * @param {Node} innerDOM Parsed DOM of block's inner HTML.
+ * @param {Object} commentAttributes Block's comment attributes.
+ * @param {string} innerHTML Raw HTML from block node's innerHTML property.
*
* @return {*} Attribute value.
*/
-
-function getBlockAttribute(attributeKey, attributeSchema, innerHTML, commentAttributes) {
+function getBlockAttribute(attributeKey, attributeSchema, innerDOM, commentAttributes, innerHTML) {
let value;
-
switch (attributeSchema.source) {
// An undefined source means that it's an attribute serialized to the
// block's "comment".
case undefined:
value = commentAttributes ? commentAttributes[attributeKey] : undefined;
break;
-
+ // raw source means that it's the original raw block content.
+ case 'raw':
+ value = innerHTML;
+ break;
case 'attribute':
case 'property':
case 'html':
case 'text':
+ case 'rich-text':
case 'children':
case 'node':
case 'query':
case 'tag':
- value = parseWithAttributeSchema(innerHTML, attributeSchema);
+ value = parseWithAttributeSchema(innerDOM, attributeSchema);
break;
}
-
if (!isValidByType(value, attributeSchema.type) || !isValidByEnum(value, attributeSchema.enum)) {
// Reject the value if it is not valid. Reverting to the undefined
// value ensures the default is respected, if applicable.
value = undefined;
}
-
if (value === undefined) {
- value = attributeSchema.default;
- }
-
+ value = getDefault(attributeSchema);
+ }
return value;
}
+
/**
* Returns true if value is valid per the given block attribute schema type
* definition, or false otherwise.
@@ -11133,10 +13195,10 @@
*
* @return {boolean} Whether value is valid.
*/
-
function isValidByType(value, type) {
- return type === undefined || isOfTypes(value, (0,external_lodash_namespaceObject.castArray)(type));
-}
+ return type === undefined || isOfTypes(value, Array.isArray(type) ? type : [type]);
+}
+
/**
* Returns true if value is valid per the given block attribute schema enum
* definition, or false otherwise.
@@ -11148,10 +13210,10 @@
*
* @return {boolean} Whether value is valid.
*/
-
function isValidByEnum(value, enumSet) {
return !Array.isArray(enumSet) || enumSet.includes(value);
}
+
/**
* Returns an hpq matcher given a source object.
*
@@ -11159,42 +13221,40 @@
*
* @return {Function} A hpq Matcher.
*/
-
-const matcherFromSource = memize_default()(sourceConfig => {
+const matcherFromSource = memize(sourceConfig => {
switch (sourceConfig.source) {
case 'attribute':
- let matcher = attr(sourceConfig.selector, sourceConfig.attribute);
-
- if (sourceConfig.type === 'boolean') {
- matcher = toBooleanAttributeMatcher(matcher);
- }
-
- return matcher;
-
+ {
+ let matcher = attr(sourceConfig.selector, sourceConfig.attribute);
+ if (sourceConfig.type === 'boolean') {
+ matcher = toBooleanAttributeMatcher(matcher);
+ }
+ return matcher;
+ }
case 'html':
return matchers_html(sourceConfig.selector, sourceConfig.multiline);
-
case 'text':
return es_text(sourceConfig.selector);
-
+ case 'rich-text':
+ return richText(sourceConfig.selector, sourceConfig.__unstablePreserveWhiteSpace);
case 'children':
return children_matcher(sourceConfig.selector);
-
case 'node':
- return node_matcher(sourceConfig.selector);
-
+ return matcher(sourceConfig.selector);
case 'query':
- const subMatchers = (0,external_lodash_namespaceObject.mapValues)(sourceConfig.query, matcherFromSource);
+ const subMatchers = Object.fromEntries(Object.entries(sourceConfig.query).map(([key, subSourceConfig]) => [key, matcherFromSource(subSourceConfig)]));
return query(sourceConfig.selector, subMatchers);
-
case 'tag':
- return (0,external_lodash_namespaceObject.flow)([prop(sourceConfig.selector, 'nodeName'), nodeName => nodeName ? nodeName.toLowerCase() : undefined]);
-
+ {
+ const matcher = prop(sourceConfig.selector, 'nodeName');
+ return domNode => matcher(domNode)?.toLowerCase();
+ }
default:
// eslint-disable-next-line no-console
console.error(`Unknown source type "${sourceConfig.source}"`);
}
});
+
/**
* Parse a HTML string into DOM tree.
*
@@ -11202,10 +13262,10 @@
*
* @return {Node} Parsed DOM node.
*/
-
function parseHtml(innerHTML) {
return parse(innerHTML, h => h);
}
+
/**
* Given a block's raw content and an attribute's schema returns the attribute's
* value depending on its source.
@@ -11215,11 +13275,10 @@
*
* @return {*} Attribute value.
*/
-
-
function parseWithAttributeSchema(innerHTML, attributeSchema) {
return matcherFromSource(attributeSchema)(parseHtml(innerHTML));
}
+
/**
* Returns the block attributes of a registered block node given its type.
*
@@ -11229,33 +13288,28 @@
*
* @return {Object} All block attributes.
*/
-
-function getBlockAttributes(blockTypeOrName, innerHTML) {
- let attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
+function getBlockAttributes(blockTypeOrName, innerHTML, attributes = {}) {
+ var _blockType$attributes;
const doc = parseHtml(innerHTML);
const blockType = normalizeBlockType(blockTypeOrName);
- const blockAttributes = (0,external_lodash_namespaceObject.mapValues)(blockType.attributes, (schema, key) => getBlockAttribute(key, schema, doc, attributes));
+ 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)]));
return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getBlockAttributes', blockAttributes, blockType, innerHTML, attributes);
}
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/fix-custom-classname.js
/**
- * External dependencies
- */
-
-/**
* Internal dependencies
*/
-
const CLASS_ATTR_SCHEMA = {
type: 'string',
source: 'attribute',
selector: '[data-custom-class-name] > *',
attribute: 'class'
};
+
/**
* Given an HTML string, returns an array of class names assigned to the root
* element in the markup.
@@ -11264,11 +13318,11 @@
*
* @return {string[]} Array of class names assigned to the root element.
*/
-
function getHTMLRootElementClasses(innerHTML) {
const parsed = parseWithAttributeSchema(`<div data-custom-class-name>${innerHTML}</div>`, CLASS_ATTR_SCHEMA);
return parsed ? parsed.trim().split(/\s+/) : [];
}
+
/**
* Given a parsed set of block attributes, if the block supports custom class
* names and an unknown class (per the block's serialization behavior) is
@@ -11281,26 +13335,26 @@
*
* @return {Object} Filtered block attributes.
*/
-
function fixCustomClassname(blockAttributes, blockType, innerHTML) {
- if (registration_hasBlockSupport(blockType, 'customClassName', true)) {
+ if (hasBlockSupport(blockType, 'customClassName', true)) {
// To determine difference, serialize block given the known set of
// attributes, with the exception of `className`. This will determine
// the default set of classes. From there, any difference in innerHTML
// can be considered as custom classes.
- const attributesSansClassName = (0,external_lodash_namespaceObject.omit)(blockAttributes, ['className']);
+ const {
+ className: omittedClassName,
+ ...attributesSansClassName
+ } = blockAttributes;
const serialized = getSaveContent(blockType, attributesSansClassName);
const defaultClasses = getHTMLRootElementClasses(serialized);
const actualClasses = getHTMLRootElementClasses(innerHTML);
- const customClasses = (0,external_lodash_namespaceObject.difference)(actualClasses, defaultClasses);
-
+ const customClasses = actualClasses.filter(className => !defaultClasses.includes(className));
if (customClasses.length) {
blockAttributes.className = customClasses.join(' ');
} else if (serialized) {
delete blockAttributes.className;
}
}
-
return blockAttributes;
}
@@ -11309,6 +13363,7 @@
* Internal dependencies
*/
+
/**
* Attempts to fix block invalidation by applying build-in validation fixes
* like moving all extra classNames to the className attribute.
@@ -11320,20 +13375,16 @@
*
* @return {WPBlock} Fixed block object
*/
-
function applyBuiltInValidationFixes(block, blockType) {
const updatedBlockAttributes = fixCustomClassname(block.attributes, blockType, block.originalContent);
- return { ...block,
+ return {
+ ...block,
attributes: updatedBlockAttributes
};
}
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/apply-block-deprecated-versions.js
/**
- * External dependencies
- */
-
-/**
* Internal dependencies
*/
@@ -11341,6 +13392,16 @@
+
+/**
+ * Function that takes no arguments and always returns false.
+ *
+ * @return {boolean} Always returns false.
+ */
+function stubFalse() {
+ return false;
+}
+
/**
* Given a block object, returns a new copy of the block with any applicable
* deprecated migrations applied, or the original block if it was both valid
@@ -11354,76 +13415,82 @@
*
* @return {import(".").WPBlock} Migrated block object.
*/
-
function applyBlockDeprecatedVersions(block, rawBlock, blockType) {
const parsedAttributes = rawBlock.attrs;
const {
deprecated: deprecatedDefinitions
- } = blockType; // Bail early if there are no registered deprecations to be handled.
-
+ } = blockType;
+ // Bail early if there are no registered deprecations to be handled.
if (!deprecatedDefinitions || !deprecatedDefinitions.length) {
return block;
- } // By design, blocks lack any sort of version tracking. Instead, to process
+ }
+
+ // By design, blocks lack any sort of version tracking. Instead, to process
// outdated content the system operates a queue out of all the defined
// attribute shapes and tries each definition until the input produces a
// valid result. This mechanism seeks to avoid polluting the user-space with
// machine-specific code. An invalid block is thus a block that could not be
// matched successfully with any of the registered deprecation definitions.
-
-
for (let i = 0; i < deprecatedDefinitions.length; i++) {
// A block can opt into a migration even if the block is valid by
// defining `isEligible` on its deprecation. If the block is both valid
// and does not opt to migrate, skip.
const {
- isEligible = external_lodash_namespaceObject.stubFalse
+ isEligible = stubFalse
} = deprecatedDefinitions[i];
-
- if (block.isValid && !isEligible(parsedAttributes, block.innerBlocks)) {
+ if (block.isValid && !isEligible(parsedAttributes, block.innerBlocks, {
+ blockNode: rawBlock,
+ block
+ })) {
continue;
- } // Block type properties which could impact either serialization or
+ }
+
+ // Block type properties which could impact either serialization or
// parsing are not considered in the deprecated block type by default,
// and must be explicitly provided.
-
-
- const deprecatedBlockType = Object.assign((0,external_lodash_namespaceObject.omit)(blockType, DEPRECATED_ENTRY_KEYS), deprecatedDefinitions[i]);
- let migratedBlock = { ...block,
+ const deprecatedBlockType = Object.assign(omit(blockType, DEPRECATED_ENTRY_KEYS), deprecatedDefinitions[i]);
+ let migratedBlock = {
+ ...block,
attributes: getBlockAttributes(deprecatedBlockType, block.originalContent, parsedAttributes)
- }; // Ignore the deprecation if it produces a block which is not valid.
-
- let [isValid] = validateBlock(migratedBlock, deprecatedBlockType); // If the migrated block is not valid initially, try the built-in fixes.
-
+ };
+
+ // Ignore the deprecation if it produces a block which is not valid.
+ let [isValid] = validateBlock(migratedBlock, deprecatedBlockType);
+
+ // If the migrated block is not valid initially, try the built-in fixes.
if (!isValid) {
migratedBlock = applyBuiltInValidationFixes(migratedBlock, deprecatedBlockType);
[isValid] = validateBlock(migratedBlock, deprecatedBlockType);
- } // An invalid block does not imply incorrect HTML but the fact block
+ }
+
+ // An invalid block does not imply incorrect HTML but the fact block
// source information could be lost on re-serialization.
-
-
if (!isValid) {
continue;
}
-
let migratedInnerBlocks = migratedBlock.innerBlocks;
- let migratedAttributes = migratedBlock.attributes; // A block may provide custom behavior to assign new attributes and/or
+ let migratedAttributes = migratedBlock.attributes;
+
+ // A block may provide custom behavior to assign new attributes and/or
// inner blocks.
-
const {
migrate
} = deprecatedBlockType;
-
if (migrate) {
- [migratedAttributes = parsedAttributes, migratedInnerBlocks = block.innerBlocks] = (0,external_lodash_namespaceObject.castArray)(migrate(migratedAttributes, block.innerBlocks));
- }
-
- block = { ...block,
+ let migrated = migrate(migratedAttributes, block.innerBlocks);
+ if (!Array.isArray(migrated)) {
+ migrated = [migrated];
+ }
+ [migratedAttributes = parsedAttributes, migratedInnerBlocks = block.innerBlocks] = migrated;
+ }
+ block = {
+ ...block,
attributes: migratedAttributes,
innerBlocks: migratedInnerBlocks,
isValid: true,
validationIssues: []
};
}
-
return block;
}
@@ -11433,6 +13500,7 @@
*/
+
/**
* Internal dependencies
*/
@@ -11477,7 +13545,8 @@
/**
* @typedef {Object} ParseOptions
- * @property {boolean} __unstableSkipMigrationLogs If a block is migrated from a deprecated version, skip logging the migration details.
+ * @property {boolean?} __unstableSkipMigrationLogs If a block is migrated from a deprecated version, skip logging the migration details.
+ * @property {boolean?} __unstableSkipAutop Whether to skip autop when processing freeform content.
*/
/**
@@ -11489,45 +13558,48 @@
*
* @return {WPRawBlock} The block's name and attributes, changed accordingly if a match was found
*/
-
function convertLegacyBlocks(rawBlock) {
const [correctName, correctedAttributes] = convertLegacyBlockNameAndAttributes(rawBlock.blockName, rawBlock.attrs);
- return { ...rawBlock,
+ return {
+ ...rawBlock,
blockName: correctName,
attrs: correctedAttributes
};
}
+
/**
* Normalize the raw block by applying the fallback block name if none given,
* sanitize the parsed HTML...
*
- * @param {WPRawBlock} rawBlock The raw block object.
+ * @param {WPRawBlock} rawBlock The raw block object.
+ * @param {ParseOptions?} options Extra options for handling block parsing.
*
* @return {WPRawBlock} The normalized block object.
*/
-
-
-function normalizeRawBlock(rawBlock) {
- const fallbackBlockName = getFreeformContentHandlerName(); // If the grammar parsing don't produce any block name, use the freeform block.
-
+function normalizeRawBlock(rawBlock, options) {
+ const fallbackBlockName = getFreeformContentHandlerName();
+
+ // If the grammar parsing don't produce any block name, use the freeform block.
const rawBlockName = rawBlock.blockName || getFreeformContentHandlerName();
const rawAttributes = rawBlock.attrs || {};
const rawInnerBlocks = rawBlock.innerBlocks || [];
- let rawInnerHTML = rawBlock.innerHTML.trim(); // Fallback content may be upgraded from classic content expecting implicit
+ let rawInnerHTML = rawBlock.innerHTML.trim();
+
+ // Fallback content may be upgraded from classic content expecting implicit
// automatic paragraphs, so preserve them. Assumes wpautop is idempotent,
// meaning there are no negative consequences to repeated autop calls.
-
- if (rawBlockName === fallbackBlockName) {
+ if (rawBlockName === fallbackBlockName && rawBlockName === 'core/freeform' && !options?.__unstableSkipAutop) {
rawInnerHTML = (0,external_wp_autop_namespaceObject.autop)(rawInnerHTML).trim();
}
-
- return { ...rawBlock,
+ return {
+ ...rawBlock,
blockName: rawBlockName,
attrs: rawAttributes,
innerHTML: rawInnerHTML,
innerBlocks: rawInnerBlocks
};
}
+
/**
* Uses the "unregistered blockType" to create a block object.
*
@@ -11535,17 +13607,18 @@
*
* @return {WPRawBlock} The unregistered block object.
*/
-
function createMissingBlockType(rawBlock) {
- const unregisteredFallbackBlock = getUnregisteredTypeHandlerName() || getFreeformContentHandlerName(); // Preserve undelimited content for use by the unregistered type
+ const unregisteredFallbackBlock = getUnregisteredTypeHandlerName() || getFreeformContentHandlerName();
+
+ // Preserve undelimited content for use by the unregistered type
// handler. A block node's `innerHTML` isn't enough, as that field only
// carries the block's own HTML and not its nested blocks.
-
const originalUndelimitedContent = serializeRawBlock(rawBlock, {
isCommentDelimited: false
- }); // Preserve full block content for use by the unregistered type
+ });
+
+ // Preserve full block content for use by the unregistered type
// handler, block boundaries included.
-
const originalContent = serializeRawBlock(rawBlock, {
isCommentDelimited: true
});
@@ -11561,6 +13634,7 @@
innerContent: rawBlock.innerContent
};
}
+
/**
* Validates a block and wraps with validation meta.
*
@@ -11570,80 +13644,82 @@
* @param {import('../registration').WPBlockType} blockType
* @return {WPBlock} validated block, with auto-fixes if initially invalid
*/
-
-
function applyBlockValidation(unvalidatedBlock, blockType) {
// Attempt to validate the block.
const [isValid] = validateBlock(unvalidatedBlock, blockType);
-
if (isValid) {
- return { ...unvalidatedBlock,
+ return {
+ ...unvalidatedBlock,
isValid,
validationIssues: []
};
- } // If the block is invalid, attempt some built-in fixes
+ }
+
+ // If the block is invalid, attempt some built-in fixes
// like custom classNames handling.
-
-
- const fixedBlock = applyBuiltInValidationFixes(unvalidatedBlock, blockType); // Attempt to validate the block once again after the built-in fixes.
-
+ const fixedBlock = applyBuiltInValidationFixes(unvalidatedBlock, blockType);
+ // Attempt to validate the block once again after the built-in fixes.
const [isFixedValid, validationIssues] = validateBlock(unvalidatedBlock, blockType);
- return { ...fixedBlock,
+ return {
+ ...fixedBlock,
isValid: isFixedValid,
validationIssues
};
}
+
/**
* Given a raw block returned by grammar parsing, returns a fully parsed block.
*
* @param {WPRawBlock} rawBlock The raw block object.
* @param {ParseOptions} options Extra options for handling block parsing.
*
- * @return {WPBlock} Fully parsed block.
- */
-
-
+ * @return {WPBlock | undefined} Fully parsed block.
+ */
function parseRawBlock(rawBlock, options) {
- let normalizedBlock = normalizeRawBlock(rawBlock); // During the lifecycle of the project, we renamed some old blocks
+ let normalizedBlock = normalizeRawBlock(rawBlock, options);
+
+ // During the lifecycle of the project, we renamed some old blocks
// and transformed others to new blocks. To avoid breaking existing content,
// we added this function to properly parse the old content.
-
- normalizedBlock = convertLegacyBlocks(normalizedBlock); // Try finding the type for known block name.
-
- let blockType = registration_getBlockType(normalizedBlock.blockName); // If not blockType is found for the specified name, fallback to the "unregistedBlockType".
-
+ normalizedBlock = convertLegacyBlocks(normalizedBlock);
+
+ // Try finding the type for known block name.
+ let blockType = getBlockType(normalizedBlock.blockName);
+
+ // If not blockType is found for the specified name, fallback to the "unregistedBlockType".
if (!blockType) {
normalizedBlock = createMissingBlockType(normalizedBlock);
- blockType = registration_getBlockType(normalizedBlock.blockName);
- } // If it's an empty freeform block or there's no blockType (no missing block handler)
+ blockType = getBlockType(normalizedBlock.blockName);
+ }
+
+ // If it's an empty freeform block or there's no blockType (no missing block handler)
// Then, just ignore the block.
// It might be a good idea to throw a warning here.
// TODO: I'm unsure about the unregisteredFallbackBlock check,
// it might ignore some dynamic unregistered third party blocks wrongly.
-
-
const isFallbackBlock = normalizedBlock.blockName === getFreeformContentHandlerName() || normalizedBlock.blockName === getUnregisteredTypeHandlerName();
-
if (!blockType || !normalizedBlock.innerHTML && isFallbackBlock) {
return;
- } // Parse inner blocks recursively.
-
-
- const parsedInnerBlocks = normalizedBlock.innerBlocks.map(innerBlock => parseRawBlock(innerBlock, options)) // See https://github.com/WordPress/gutenberg/pull/17164.
- .filter(innerBlock => !!innerBlock); // Get the fully parsed block.
-
+ }
+
+ // Parse inner blocks recursively.
+ const parsedInnerBlocks = normalizedBlock.innerBlocks.map(innerBlock => parseRawBlock(innerBlock, options))
+ // See https://github.com/WordPress/gutenberg/pull/17164.
+ .filter(innerBlock => !!innerBlock);
+
+ // Get the fully parsed block.
const parsedBlock = createBlock(normalizedBlock.blockName, getBlockAttributes(blockType, normalizedBlock.innerHTML, normalizedBlock.attrs), parsedInnerBlocks);
parsedBlock.originalContent = normalizedBlock.innerHTML;
const validatedBlock = applyBlockValidation(parsedBlock, blockType);
const {
validationIssues
- } = validatedBlock; // Run the block deprecation and migrations.
+ } = validatedBlock;
+
+ // Run the block deprecation and migrations.
// This is performed on both invalid and valid blocks because
// migration using the `migrate` functions should run even
// if the output is deemed valid.
-
const updatedBlock = applyBlockDeprecatedVersions(validatedBlock, normalizedBlock, blockType);
-
if (!updatedBlock.isValid) {
// Preserve the original unprocessed version of the block
// that we received (no fixes, no deprecations) so that
@@ -11653,25 +13729,21 @@
// to process data that isn't fully recognized.
updatedBlock.__unstableBlockSource = rawBlock;
}
-
- if (!validatedBlock.isValid && updatedBlock.isValid && !(options !== null && options !== void 0 && options.__unstableSkipMigrationLogs)) {
+ if (!validatedBlock.isValid && updatedBlock.isValid && !options?.__unstableSkipMigrationLogs) {
/* eslint-disable no-console */
console.groupCollapsed('Updated Block: %s', blockType.name);
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);
console.groupEnd();
/* eslint-enable no-console */
} else if (!validatedBlock.isValid && !updatedBlock.isValid) {
- validationIssues.forEach(_ref => {
- let {
- log,
- args
- } = _ref;
- return log(...args);
- });
- }
-
+ validationIssues.forEach(({
+ log,
+ args
+ }) => log(...args));
+ }
return updatedBlock;
}
+
/**
* Utilizes an optimized token-driven parser based on the Gutenberg grammar spec
* defined through a parsing expression grammar to take advantage of the regular
@@ -11693,34 +13765,27 @@
*
* @return {Array} Block list.
*/
-
function parser_parse(content, options) {
return (0,external_wp_blockSerializationDefaultParser_namespaceObject.parse)(content).reduce((accumulator, rawBlock) => {
const block = parseRawBlock(rawBlock, options);
-
if (block) {
accumulator.push(block);
}
-
return accumulator;
}, []);
}
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/get-raw-transforms.js
/**
- * External dependencies
- */
-
-/**
* Internal dependencies
*/
-
function getRawTransforms() {
- return (0,external_lodash_namespaceObject.filter)(getBlockTransforms('from'), {
- type: 'raw'
- }).map(transform => {
- return transform.isMatch ? transform : { ...transform,
+ return getBlockTransforms('from').filter(({
+ type
+ }) => type === 'raw').map(transform => {
+ return transform.isMatch ? transform : {
+ ...transform,
isMatch: node => transform.selector && node.matches(transform.selector)
};
});
@@ -11728,46 +13793,57 @@
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/html-to-blocks.js
/**
+ * WordPress dependencies
+ */
+
+
+/**
* Internal dependencies
*/
+
+
/**
* Converts HTML directly to blocks. Looks for a matching transform for each
* top-level tag. The HTML should be filtered to not have any text between
* top-level tags and formatted in a way that blocks can handle the HTML.
*
- * @param {string} html HTML to convert.
+ * @param {string} html HTML to convert.
+ * @param {Function} handler The handler calling htmlToBlocks: either rawHandler
+ * or pasteHandler.
*
* @return {Array} An array of blocks.
*/
-
-function htmlToBlocks(html) {
+function htmlToBlocks(html, handler) {
const doc = document.implementation.createHTMLDocument('');
doc.body.innerHTML = html;
return Array.from(doc.body.children).flatMap(node => {
- const rawTransform = findTransform(getRawTransforms(), _ref => {
- let {
- isMatch
- } = _ref;
- return isMatch(node);
- });
-
+ const rawTransform = findTransform(getRawTransforms(), ({
+ isMatch
+ }) => isMatch(node));
if (!rawTransform) {
- return createBlock( // Should not be hardcoded.
+ // Until the HTML block is supported in the native version, we'll parse it
+ // instead of creating the block to generate it as an unsupported block.
+ if (external_wp_element_namespaceObject.Platform.isNative) {
+ return parser_parse(`<!-- wp:html -->${node.outerHTML}<!-- /wp:html -->`);
+ }
+ return createBlock(
+ // Should not be hardcoded.
'core/html', getBlockAttributes('core/html', node.outerHTML));
}
-
const {
transform,
blockName
} = rawTransform;
-
if (transform) {
- return transform(node);
- }
-
+ const block = transform(node, handler);
+ if (node.hasAttribute('class')) {
+ block.attributes.className = node.getAttribute('class');
+ }
+ return block;
+ }
return createBlock(blockName, getBlockAttributes(blockName, node.outerHTML));
});
}
@@ -11777,16 +13853,16 @@
* WordPress dependencies
*/
-function normaliseBlocks(HTML) {
+function normaliseBlocks(HTML, options = {}) {
const decuDoc = document.implementation.createHTMLDocument('');
const accuDoc = document.implementation.createHTMLDocument('');
const decu = decuDoc.body;
const accu = accuDoc.body;
decu.innerHTML = HTML;
-
while (decu.firstChild) {
- const node = decu.firstChild; // Text nodes: wrap in a paragraph, or append to previous.
-
+ const node = decu.firstChild;
+
+ // Text nodes: wrap in a paragraph, or append to previous.
if (node.nodeType === node.TEXT_NODE) {
if ((0,external_wp_dom_namespaceObject.isEmpty)(node)) {
decu.removeChild(node);
@@ -11794,19 +13870,18 @@
if (!accu.lastChild || accu.lastChild.nodeName !== 'P') {
accu.appendChild(accuDoc.createElement('P'));
}
-
accu.lastChild.appendChild(node);
- } // Element nodes.
-
+ }
+ // Element nodes.
} else if (node.nodeType === node.ELEMENT_NODE) {
// BR nodes: create a new paragraph on double, or append to previous.
if (node.nodeName === 'BR') {
if (node.nextSibling && node.nextSibling.nodeName === 'BR') {
accu.appendChild(accuDoc.createElement('P'));
decu.removeChild(node.nextSibling);
- } // Don't append to an empty paragraph.
-
-
+ }
+
+ // Don't append to an empty paragraph.
if (accu.lastChild && accu.lastChild.nodeName === 'P' && accu.lastChild.hasChildNodes()) {
accu.lastChild.appendChild(node);
} else {
@@ -11814,7 +13889,7 @@
}
} else if (node.nodeName === 'P') {
// Only append non-empty paragraph nodes.
- if ((0,external_wp_dom_namespaceObject.isEmpty)(node)) {
+ if ((0,external_wp_dom_namespaceObject.isEmpty)(node) && !options.raw) {
decu.removeChild(node);
} else {
accu.appendChild(node);
@@ -11823,7 +13898,6 @@
if (!accu.lastChild || accu.lastChild.nodeName !== 'P') {
accu.appendChild(accuDoc.createElement('P'));
}
-
accu.lastChild.appendChild(node);
} else {
accu.appendChild(node);
@@ -11832,7 +13906,6 @@
decu.removeChild(node);
}
}
-
return accu.innerHTML;
}
@@ -11841,10 +13914,10 @@
* WordPress dependencies
*/
-/**
- * Looks for `<!--nextpage-->` and `<!--more-->` comments, as well as the
- * `<!--more Some text-->` variant and its `<!--noteaser-->` companion,
- * and replaces them with a custom element representing a future block.
+
+/**
+ * Looks for `<!--nextpage-->` and `<!--more-->` comments and
+ * replaces them with a custom element representing a future block.
*
* The custom element is a way to bypass the rest of the `raw-handling`
* transforms, which would eliminate other kinds of node with which to carry
@@ -11857,57 +13930,77 @@
* @param {Document} doc The document of the node.
* @return {void}
*/
-
function specialCommentConverter(node, doc) {
if (node.nodeType !== node.COMMENT_NODE) {
return;
}
-
- if (node.nodeValue === 'nextpage') {
- (0,external_wp_dom_namespaceObject.replace)(node, createNextpage(doc));
+ if (node.nodeValue !== 'nextpage' && node.nodeValue.indexOf('more') !== 0) {
return;
}
-
- if (node.nodeValue.indexOf('more') === 0) {
- // Grab any custom text in the comment.
- const customText = node.nodeValue.slice(4).trim();
- /*
- * When a `<!--more-->` comment is found, we need to look for any
- * `<!--noteaser-->` sibling, but it may not be a direct sibling
- * (whitespace typically lies in between)
- */
-
- let sibling = node;
- let noTeaser = false;
-
- while (sibling = sibling.nextSibling) {
- if (sibling.nodeType === sibling.COMMENT_NODE && sibling.nodeValue === 'noteaser') {
- noTeaser = true;
- (0,external_wp_dom_namespaceObject.remove)(sibling);
- break;
- }
- }
-
- (0,external_wp_dom_namespaceObject.replace)(node, createMore(customText, noTeaser, doc));
- }
-}
-
+ const block = special_comment_converter_createBlock(node, doc);
+
+ // If our `<!--more-->` comment is in the middle of a paragraph, we should
+ // split the paragraph in two and insert the more block in between. If it's
+ // inside an empty paragraph, we should still move it out of the paragraph
+ // and remove the paragraph. If there's no paragraph, fall back to simply
+ // replacing the comment.
+ if (!node.parentNode || node.parentNode.nodeName !== 'P') {
+ (0,external_wp_dom_namespaceObject.replace)(node, block);
+ } else {
+ const childNodes = Array.from(node.parentNode.childNodes);
+ const nodeIndex = childNodes.indexOf(node);
+ const wrapperNode = node.parentNode.parentNode || doc.body;
+ const paragraphBuilder = (acc, child) => {
+ if (!acc) {
+ acc = doc.createElement('p');
+ }
+ acc.appendChild(child);
+ return acc;
+ };
+
+ // Split the original parent node and insert our more block
+ [childNodes.slice(0, nodeIndex).reduce(paragraphBuilder, null), block, childNodes.slice(nodeIndex + 1).reduce(paragraphBuilder, null)].forEach(element => element && wrapperNode.insertBefore(element, node.parentNode));
+
+ // Remove the old parent paragraph
+ (0,external_wp_dom_namespaceObject.remove)(node.parentNode);
+ }
+}
+function special_comment_converter_createBlock(commentNode, doc) {
+ if (commentNode.nodeValue === 'nextpage') {
+ return createNextpage(doc);
+ }
+
+ // Grab any custom text in the comment.
+ const customText = commentNode.nodeValue.slice(4).trim();
+
+ /*
+ * When a `<!--more-->` comment is found, we need to look for any
+ * `<!--noteaser-->` sibling, but it may not be a direct sibling
+ * (whitespace typically lies in between)
+ */
+ let sibling = commentNode;
+ let noTeaser = false;
+ while (sibling = sibling.nextSibling) {
+ if (sibling.nodeType === sibling.COMMENT_NODE && sibling.nodeValue === 'noteaser') {
+ noTeaser = true;
+ (0,external_wp_dom_namespaceObject.remove)(sibling);
+ break;
+ }
+ }
+ return createMore(customText, noTeaser, doc);
+}
function createMore(customText, noTeaser, doc) {
const node = doc.createElement('wp-block');
node.dataset.block = 'core/more';
-
if (customText) {
node.dataset.customText = customText;
}
-
if (noTeaser) {
// "Boolean" data attribute.
node.dataset.noTeaser = '';
}
-
return node;
}
-
function createNextpage(doc) {
const node = doc.createElement('wp-block');
node.dataset.block = 'core/nextpage';
@@ -11919,59 +14012,47 @@
* WordPress dependencies
*/
-
function isList(node) {
return node.nodeName === 'OL' || node.nodeName === 'UL';
}
-
function shallowTextContent(element) {
- return Array.from(element.childNodes).map(_ref => {
- let {
- nodeValue = ''
- } = _ref;
- return nodeValue;
- }).join('');
-}
-
+ return Array.from(element.childNodes).map(({
+ nodeValue = ''
+ }) => nodeValue).join('');
+}
function listReducer(node) {
if (!isList(node)) {
return;
}
-
const list = node;
- const prevElement = node.previousElementSibling; // Merge with previous list if:
+ const prevElement = node.previousElementSibling;
+
+ // Merge with previous list if:
// * There is a previous list of the same type.
// * There is only one list item.
-
if (prevElement && prevElement.nodeName === node.nodeName && list.children.length === 1) {
// Move all child nodes, including any text nodes, if any.
while (list.firstChild) {
prevElement.appendChild(list.firstChild);
}
-
list.parentNode.removeChild(list);
}
-
- const parentElement = node.parentNode; // Nested list with empty parent item.
-
+ const parentElement = node.parentNode;
+
+ // Nested list with empty parent item.
if (parentElement && parentElement.nodeName === 'LI' && parentElement.children.length === 1 && !/\S/.test(shallowTextContent(parentElement))) {
const parentListItem = parentElement;
const prevListItem = parentListItem.previousElementSibling;
const parentList = parentListItem.parentNode;
-
if (prevListItem) {
prevListItem.appendChild(list);
parentList.removeChild(parentListItem);
- } else {
- parentList.parentNode.insertBefore(list, parentList);
- parentList.parentNode.removeChild(parentList);
- }
- } // Invalid: OL/UL > OL/UL.
-
-
+ }
+ }
+
+ // Invalid: OL/UL > OL/UL.
if (parentElement && isList(parentElement)) {
const prevListItem = node.previousElementSibling;
-
if (prevListItem) {
prevListItem.appendChild(node);
} else {
@@ -11985,20 +14066,17 @@
* Internal dependencies
*/
-function blockquoteNormaliser(node) {
- if (node.nodeName !== 'BLOCKQUOTE') {
- return;
- }
-
- node.innerHTML = normaliseBlocks(node.innerHTML);
+function blockquoteNormaliser(options) {
+ return node => {
+ if (node.nodeName !== 'BLOCKQUOTE') {
+ return;
+ }
+ node.innerHTML = normaliseBlocks(node.innerHTML, options);
+ };
}
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/figure-content-reducer.js
/**
- * External dependencies
- */
-
-/**
* WordPress dependencies
*/
@@ -12011,17 +14089,18 @@
*
* @return {boolean} True if figure content, false if not.
*/
-
function isFigureContent(node, schema) {
- const tag = node.nodeName.toLowerCase(); // We are looking for tags that can be a child of the figure tag, excluding
+ var _schema$figure$childr;
+ const tag = node.nodeName.toLowerCase();
+
+ // We are looking for tags that can be a child of the figure tag, excluding
// `figcaption` and any phrasing content.
-
if (tag === 'figcaption' || (0,external_wp_dom_namespaceObject.isTextContent)(node)) {
return false;
}
-
- return (0,external_lodash_namespaceObject.has)(schema, ['figure', 'children', tag]);
-}
+ return tag in ((_schema$figure$childr = schema?.figure?.children) !== null && _schema$figure$childr !== void 0 ? _schema$figure$childr : {});
+}
+
/**
* Whether or not the given node can have an anchor.
*
@@ -12030,26 +14109,24 @@
*
* @return {boolean} True if it can, false if not.
*/
-
-
function canHaveAnchor(node, schema) {
+ var _schema$figure$childr2;
const tag = node.nodeName.toLowerCase();
- return (0,external_lodash_namespaceObject.has)(schema, ['figure', 'children', 'a', 'children', tag]);
-}
+ return tag in ((_schema$figure$childr2 = schema?.figure?.children?.a?.children) !== null && _schema$figure$childr2 !== void 0 ? _schema$figure$childr2 : {});
+}
+
/**
* Wraps the given element in a figure element.
*
* @param {Element} element The element to wrap.
* @param {Element} beforeElement The element before which to place the figure.
*/
-
-
-function wrapFigureContent(element) {
- let beforeElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : element;
+function wrapFigureContent(element, beforeElement = element) {
const figure = element.ownerDocument.createElement('figure');
beforeElement.parentNode.insertBefore(figure, beforeElement);
figure.appendChild(element);
}
+
/**
* This filter takes figure content out of paragraphs, wraps it in a figure
* element, and moves any anchors with it if needed.
@@ -12060,25 +14137,23 @@
*
* @return {void}
*/
-
-
function figureContentReducer(node, doc, schema) {
if (!isFigureContent(node, schema)) {
return;
}
-
let nodeToInsert = node;
- const parentNode = node.parentNode; // If the figure content can have an anchor and its parent is an anchor with
+ const parentNode = node.parentNode;
+
+ // If the figure content can have an anchor and its parent is an anchor with
// only the figure content, take the anchor out instead of just the content.
-
if (canHaveAnchor(node, schema) && parentNode.nodeName === 'A' && parentNode.childNodes.length === 1) {
nodeToInsert = node.parentNode;
}
-
- const wrapper = nodeToInsert.closest('p,div'); // If wrapped in a paragraph or div, only extract if it's aligned or if
+ const wrapper = nodeToInsert.closest('p,div');
+
+ // If wrapped in a paragraph or div, only extract if it's aligned or if
// there is no text content.
// Otherwise, if directly at the root, wrap in a figure element.
-
if (wrapper) {
// In jsdom-jscore, 'node.classList' can be undefined.
// In this case, default to extract as it offers a better UI experience on mobile.
@@ -12093,13 +14168,9 @@
}
;// CONCATENATED MODULE: external ["wp","shortcode"]
-var external_wp_shortcode_namespaceObject = window["wp"]["shortcode"];
+const external_wp_shortcode_namespaceObject = window["wp"]["shortcode"];
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/shortcode-converter.js
/**
- * External dependencies
- */
-
-/**
* WordPress dependencies
*/
@@ -12111,35 +14182,34 @@
-
-
-function segmentHTMLToShortcodeBlock(HTML) {
- let lastIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
- let excludedBlockNames = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
+const castArray = maybeArray => Array.isArray(maybeArray) ? maybeArray : [maybeArray];
+const beforeLineRegexp = /(\n|<p>)\s*$/;
+const afterLineRegexp = /^\s*(\n|<\/p>)/;
+function segmentHTMLToShortcodeBlock(HTML, lastIndex = 0, excludedBlockNames = []) {
// Get all matches.
const transformsFrom = getBlockTransforms('from');
- 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)));
-
+ 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)));
if (!transformation) {
return [HTML];
}
-
- const transformTags = (0,external_lodash_namespaceObject.castArray)(transformation.tag);
- const transformTag = (0,external_lodash_namespaceObject.find)(transformTags, tag => (0,external_wp_shortcode_namespaceObject.regexp)(tag).test(HTML));
+ const transformTags = castArray(transformation.tag);
+ const transformTag = transformTags.find(tag => (0,external_wp_shortcode_namespaceObject.regexp)(tag).test(HTML));
let match;
const previousIndex = lastIndex;
-
if (match = (0,external_wp_shortcode_namespaceObject.next)(transformTag, HTML, lastIndex)) {
lastIndex = match.index + match.content.length;
const beforeHTML = HTML.substr(0, match.index);
- const afterHTML = HTML.substr(lastIndex); // If the shortcode content does not contain HTML and the shortcode is
+ const afterHTML = HTML.substr(lastIndex);
+
+ // If the shortcode content does not contain HTML and the shortcode is
// not on a new line (or in paragraph from Markdown converter),
// consider the shortcode as inline text, and thus skip conversion for
// this segment.
-
- if (!(0,external_lodash_namespaceObject.includes)(match.shortcode.content || '', '<') && !(/(\n|<p>)\s*$/.test(beforeHTML) && /^\s*(\n|<\/p>)/.test(afterHTML))) {
+ if (!match.shortcode.content?.includes('<') && !(beforeLineRegexp.test(beforeHTML) && afterLineRegexp.test(afterHTML))) {
return segmentHTMLToShortcodeBlock(HTML, lastIndex);
- } // If a transformation's `isMatch` predicate fails for the inbound
+ }
+
+ // If a transformation's `isMatch` predicate fails for the inbound
// shortcode, try again by excluding the current block type.
//
// This is the only call to `segmentHTMLToShortcodeBlock` that should
@@ -12147,38 +14217,52 @@
// should skip that argument as a way to reset the exclusion state, so
// that one `isMatch` fail in an HTML fragment doesn't prevent any
// valid matches in subsequent fragments.
-
-
if (transformation.isMatch && !transformation.isMatch(match.shortcode.attrs)) {
return segmentHTMLToShortcodeBlock(HTML, previousIndex, [...excludedBlockNames, transformation.blockName]);
}
-
- 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
- // but shouldn't be too relied upon.
- //
- // See: https://github.com/WordPress/gutenberg/pull/3610#discussion_r152546926
- schema => schema.shortcode(match.shortcode.attrs, match));
- const transformationBlockType = { ...registration_getBlockType(transformation.blockName),
- attributes: transformation.attributes
- };
- let block = createBlock(transformation.blockName, getBlockAttributes(transformationBlockType, match.shortcode.content, attributes));
- block.originalContent = match.shortcode.content; // Applying the built-in fixes can enhance the attributes with missing content like "className".
-
- block = applyBuiltInValidationFixes(block, transformationBlockType);
- return [...segmentHTMLToShortcodeBlock(beforeHTML), block, ...segmentHTMLToShortcodeBlock(afterHTML)];
- }
-
+ let blocks = [];
+ if (typeof transformation.transform === 'function') {
+ // Passing all of `match` as second argument is intentionally broad
+ // but shouldn't be too relied upon.
+ //
+ // See: https://github.com/WordPress/gutenberg/pull/3610#discussion_r152546926
+ blocks = [].concat(transformation.transform(match.shortcode.attrs, match));
+
+ // Applying the built-in fixes can enhance the attributes with missing content like "className".
+ blocks = blocks.map(block => {
+ block.originalContent = match.shortcode.content;
+ return applyBuiltInValidationFixes(block, getBlockType(block.name));
+ });
+ } else {
+ const attributes = Object.fromEntries(Object.entries(transformation.attributes).filter(([, schema]) => schema.shortcode)
+ // Passing all of `match` as second argument is intentionally broad
+ // but shouldn't be too relied upon.
+ //
+ // See: https://github.com/WordPress/gutenberg/pull/3610#discussion_r152546926
+ .map(([key, schema]) => [key, schema.shortcode(match.shortcode.attrs, match)]));
+ const blockType = getBlockType(transformation.blockName);
+ if (!blockType) {
+ return [HTML];
+ }
+ const transformationBlockType = {
+ ...blockType,
+ attributes: transformation.attributes
+ };
+ let block = createBlock(transformation.blockName, getBlockAttributes(transformationBlockType, match.shortcode.content, attributes));
+
+ // Applying the built-in fixes can enhance the attributes with missing content like "className".
+ block.originalContent = match.shortcode.content;
+ block = applyBuiltInValidationFixes(block, transformationBlockType);
+ blocks = [block];
+ }
+ return [...segmentHTMLToShortcodeBlock(beforeHTML.replace(beforeLineRegexp, '')), ...blocks, ...segmentHTMLToShortcodeBlock(afterHTML.replace(afterLineRegexp, ''))];
+ }
return [HTML];
}
-
-/* harmony default export */ var shortcode_converter = (segmentHTMLToShortcodeBlock);
+/* harmony default export */ const shortcode_converter = (segmentHTMLToShortcodeBlock);
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/utils.js
/**
- * External dependencies
- */
-
-/**
* WordPress dependencies
*/
@@ -12188,76 +14272,97 @@
*/
-
function getBlockContentSchemaFromTransforms(transforms, context) {
const phrasingContentSchema = (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)(context);
const schemaArgs = {
phrasingContentSchema,
isPaste: context === 'paste'
};
- const schemas = transforms.map(_ref => {
- let {
- isMatch,
- blockName,
- schema
- } = _ref;
- const hasAnchorSupport = registration_hasBlockSupport(blockName, 'anchor');
- schema = (0,external_lodash_namespaceObject.isFunction)(schema) ? schema(schemaArgs) : schema; // If the block does not has anchor support and the transform does not
+ const schemas = transforms.map(({
+ isMatch,
+ blockName,
+ schema
+ }) => {
+ const hasAnchorSupport = hasBlockSupport(blockName, 'anchor');
+ schema = typeof schema === 'function' ? schema(schemaArgs) : schema;
+
+ // If the block does not has anchor support and the transform does not
// provides an isMatch we can return the schema right away.
-
if (!hasAnchorSupport && !isMatch) {
return schema;
}
-
- return (0,external_lodash_namespaceObject.mapValues)(schema, value => {
- let attributes = value.attributes || []; // If the block supports the "anchor" functionality, it needs to keep its ID attribute.
-
+ if (!schema) {
+ return {};
+ }
+ return Object.fromEntries(Object.entries(schema).map(([key, value]) => {
+ let attributes = value.attributes || [];
+ // If the block supports the "anchor" functionality, it needs to keep its ID attribute.
if (hasAnchorSupport) {
attributes = [...attributes, 'id'];
}
-
- return { ...value,
+ return [key, {
+ ...value,
attributes,
isMatch: isMatch ? isMatch : undefined
- };
- });
+ }];
+ }));
});
- return (0,external_lodash_namespaceObject.mergeWith)({}, ...schemas, (objValue, srcValue, key) => {
+ function mergeTagNameSchemaProperties(objValue, srcValue, key) {
switch (key) {
case 'children':
{
if (objValue === '*' || srcValue === '*') {
return '*';
}
-
- return { ...objValue,
+ return {
+ ...objValue,
...srcValue
};
}
-
case 'attributes':
case 'require':
{
return [...(objValue || []), ...(srcValue || [])];
}
-
case 'isMatch':
{
// If one of the values being merge is undefined (matches everything),
// the result of the merge will be undefined.
if (!objValue || !srcValue) {
return undefined;
- } // When merging two isMatch functions, the result is a new function
+ }
+ // When merging two isMatch functions, the result is a new function
// that returns if one of the source functions returns true.
-
-
- return function () {
- return objValue(...arguments) || srcValue(...arguments);
+ return (...args) => {
+ return objValue(...args) || srcValue(...args);
};
}
}
- });
-}
+ }
+
+ // A tagName schema is an object with children, attributes, require, and
+ // isMatch properties.
+ function mergeTagNameSchemas(a, b) {
+ for (const key in b) {
+ a[key] = a[key] ? mergeTagNameSchemaProperties(a[key], b[key], key) : {
+ ...b[key]
+ };
+ }
+ return a;
+ }
+
+ // A schema is an object with tagName schemas by tag name.
+ function mergeSchemas(a, b) {
+ for (const key in b) {
+ a[key] = a[key] ? mergeTagNameSchemas(a[key], b[key]) : {
+ ...b[key]
+ };
+ }
+ return a;
+ }
+ return schemas.reduce(mergeSchemas, {});
+}
+
/**
* Gets the block content schema, which is extracted and merged from all
* registered blocks with raw transfroms.
@@ -12267,10 +14372,10 @@
*
* @return {Object} A complete block content schema.
*/
-
function getBlockContentSchema(context) {
return getBlockContentSchemaFromTransforms(getRawTransforms(), context);
}
+
/**
* Checks whether HTML can be considered plain text. That is, it does not contain
* any elements that are not line breaks.
@@ -12279,10 +14384,10 @@
*
* @return {boolean} Whether the HTML can be considered plain text.
*/
-
function isPlain(HTML) {
return !/<(?!br[ />])/i.test(HTML);
}
+
/**
* Given node filters, deeply filters and mutates a NodeList.
*
@@ -12291,7 +14396,6 @@
* @param {Document} doc The document of the nodeList.
* @param {Object} schema The schema to use.
*/
-
function deepFilterNodeList(nodeList, filters, doc, schema) {
Array.from(nodeList).forEach(node => {
deepFilterNodeList(node.childNodes, filters, doc, schema);
@@ -12300,11 +14404,11 @@
if (!doc.contains(node)) {
return;
}
-
item(node, doc, schema);
});
});
}
+
/**
* Given node filters, deeply filters HTML tags.
* Filters from the deepest nodes to the top.
@@ -12315,46 +14419,35 @@
*
* @return {string} The filtered HTML.
*/
-
-function deepFilterHTML(HTML) {
- let filters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
- let schema = arguments.length > 2 ? arguments[2] : undefined;
+function deepFilterHTML(HTML, filters = [], schema) {
const doc = document.implementation.createHTMLDocument('');
doc.body.innerHTML = HTML;
deepFilterNodeList(doc.body.childNodes, filters, doc, schema);
return doc.body.innerHTML;
}
+
/**
* Gets a sibling within text-level context.
*
* @param {Element} node The subject node.
* @param {string} which "next" or "previous".
*/
-
function getSibling(node, which) {
const sibling = node[`${which}Sibling`];
-
if (sibling && (0,external_wp_dom_namespaceObject.isPhrasingContent)(sibling)) {
return sibling;
}
-
const {
parentNode
} = node;
-
if (!parentNode || !(0,external_wp_dom_namespaceObject.isPhrasingContent)(parentNode)) {
return;
}
-
return getSibling(parentNode, which);
}
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/index.js
/**
- * External dependencies
- */
-
-/**
* WordPress dependencies
*/
@@ -12373,7 +14466,6 @@
-
function deprecatedGetPhrasingContentSchema(context) {
external_wp_deprecated_default()('wp.blocks.getPhrasingContentSchema', {
since: '5.6',
@@ -12381,6 +14473,7 @@
});
return (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)(context);
}
+
/**
* Converts an HTML string to known blocks.
*
@@ -12389,40 +14482,49 @@
*
* @return {Array} A list of blocks.
*/
-
-function rawHandler(_ref) {
- let {
- HTML = ''
- } = _ref;
-
+function rawHandler({
+ HTML = ''
+}) {
// If we detect block delimiters, parse entirely as blocks.
if (HTML.indexOf('<!-- wp:') !== -1) {
- return parser_parse(HTML);
- } // An array of HTML strings and block objects. The blocks replace matched
+ const parseResult = parser_parse(HTML);
+ const isSingleFreeFormBlock = parseResult.length === 1 && parseResult[0].name === 'core/freeform';
+ if (!isSingleFreeFormBlock) {
+ return parseResult;
+ }
+ }
+
+ // An array of HTML strings and block objects. The blocks replace matched
// shortcodes.
-
-
const pieces = shortcode_converter(HTML);
const blockContentSchema = getBlockContentSchema();
- return (0,external_lodash_namespaceObject.compact)((0,external_lodash_namespaceObject.flatMap)(pieces, piece => {
+ return pieces.map(piece => {
// Already a block from shortcode.
if (typeof piece !== 'string') {
return piece;
- } // These filters are essential for some blocks to be able to transform
+ }
+
+ // These filters are essential for some blocks to be able to transform
// from raw HTML. These filters move around some content or add
// additional tags, they do not remove any content.
-
-
- const filters = [// Needed to adjust invalid lists.
- listReducer, // Needed to create more and nextpage blocks.
- specialCommentConverter, // Needed to create media blocks.
- figureContentReducer, // Needed to create the quote block, which cannot handle text
+ const filters = [
+ // Needed to adjust invalid lists.
+ listReducer,
+ // Needed to create more and nextpage blocks.
+ specialCommentConverter,
+ // Needed to create media blocks.
+ figureContentReducer,
+ // Needed to create the quote block, which cannot handle text
// without wrapper paragraphs.
- blockquoteNormaliser];
+ blockquoteNormaliser({
+ raw: true
+ })];
piece = deepFilterHTML(piece, filters, blockContentSchema);
- piece = normaliseBlocks(piece);
- return htmlToBlocks(piece);
- }));
+ piece = normaliseBlocks(piece, {
+ raw: true
+ });
+ return htmlToBlocks(piece, rawHandler);
+ }).flat().filter(Boolean);
}
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/comment-remover.js
@@ -12430,13 +14532,13 @@
* WordPress dependencies
*/
+
/**
* Looks for comments, and removes them.
*
* @param {Node} node The node to be processed.
* @return {void}
*/
-
function commentRemover(node) {
if (node.nodeType === node.COMMENT_NODE) {
(0,external_wp_dom_namespaceObject.remove)(node);
@@ -12445,10 +14547,6 @@
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/is-inline-content.js
/**
- * External dependencies
- */
-
-/**
* WordPress dependencies
*/
@@ -12462,29 +14560,23 @@
*
* @return {boolean} True if the node is inline content, false if nohe.
*/
-
function isInline(node, contextTag) {
if ((0,external_wp_dom_namespaceObject.isTextContent)(node)) {
return true;
}
-
if (!contextTag) {
return false;
}
-
const tag = node.nodeName.toLowerCase();
const inlineAllowedTagGroups = [['ul', 'li', 'ol'], ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']];
- return inlineAllowedTagGroups.some(tagGroup => (0,external_lodash_namespaceObject.difference)([tag, contextTag], tagGroup).length === 0);
-}
-
+ return inlineAllowedTagGroups.some(tagGroup => [tag, contextTag].filter(t => !tagGroup.includes(t)).length === 0);
+}
function deepCheck(nodes, contextTag) {
return nodes.every(node => isInline(node, contextTag) && deepCheck(Array.from(node.children), contextTag));
}
-
function isDoubleBR(node) {
return node.nodeName === 'BR' && node.previousSibling && node.previousSibling.nodeName === 'BR';
}
-
function isInlineContent(HTML, contextTag) {
const doc = document.implementation.createHTMLDocument('');
doc.body.innerHTML = HTML;
@@ -12494,14 +14586,9 @@
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/phrasing-content-reducer.js
/**
- * External dependencies
- */
-
-/**
* WordPress dependencies
*/
-
function phrasingContentReducer(node, doc) {
// In jsdom-jscore, 'node.style' can be null.
// TODO: Explore fixing this by patching jsdom-jscore.
@@ -12513,22 +14600,19 @@
textDecoration,
verticalAlign
} = node.style;
-
if (fontWeight === 'bold' || fontWeight === '700') {
(0,external_wp_dom_namespaceObject.wrap)(doc.createElement('strong'), node);
}
-
if (fontStyle === 'italic') {
(0,external_wp_dom_namespaceObject.wrap)(doc.createElement('em'), node);
- } // Some DOM implementations (Safari, JSDom) don't support
+ }
+
+ // Some DOM implementations (Safari, JSDom) don't support
// style.textDecorationLine, so we check style.textDecoration as a
// fallback.
-
-
- if (textDecorationLine === 'line-through' || (0,external_lodash_namespaceObject.includes)(textDecoration, 'line-through')) {
+ if (textDecorationLine === 'line-through' || textDecoration.includes('line-through')) {
(0,external_wp_dom_namespaceObject.wrap)(doc.createElement('s'), node);
}
-
if (verticalAlign === 'super') {
(0,external_wp_dom_namespaceObject.wrap)(doc.createElement('sup'), node);
} else if (verticalAlign === 'sub') {
@@ -12546,14 +14630,14 @@
} else {
node.removeAttribute('target');
node.removeAttribute('rel');
- } // Saves anchor elements name attribute as id
-
-
+ }
+
+ // Saves anchor elements name attribute as id
if (node.name && !node.id) {
node.id = node.name;
- } // Keeps id only if there is an internal link pointing to it
-
-
+ }
+
+ // Keeps id only if there is an internal link pointing to it
if (node.id && !node.ownerDocument.querySelector(`[href="#${node.id}"]`)) {
node.removeAttribute('id');
}
@@ -12565,148 +14649,142 @@
if (node.nodeName !== 'SCRIPT' && node.nodeName !== 'NOSCRIPT' && node.nodeName !== 'TEMPLATE' && node.nodeName !== 'STYLE') {
return;
}
-
node.parentNode.removeChild(node);
}
+;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/ms-list-ignore.js
+/**
+ * Looks for comments, and removes them.
+ *
+ * @param {Node} node The node to be processed.
+ * @return {void}
+ */
+function msListIgnore(node) {
+ if (node.nodeType !== node.ELEMENT_NODE) {
+ return;
+ }
+ const style = node.getAttribute('style');
+ if (!style || !style.includes('mso-list')) {
+ return;
+ }
+ const rules = style.split(';').reduce((acc, rule) => {
+ const [key, value] = rule.split(':');
+ if (key && value) {
+ acc[key.trim().toLowerCase()] = value.trim().toLowerCase();
+ }
+ return acc;
+ }, {});
+ if (rules['mso-list'] === 'ignore') {
+ node.remove();
+ }
+}
+
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/ms-list-converter.js
/**
- * Browser dependencies
- */
-const {
- parseInt: ms_list_converter_parseInt
-} = window;
+ * Internal dependencies
+ */
+
function ms_list_converter_isList(node) {
return node.nodeName === 'OL' || node.nodeName === 'UL';
}
-
function msListConverter(node, doc) {
if (node.nodeName !== 'P') {
return;
}
-
const style = node.getAttribute('style');
-
- if (!style) {
- return;
- } // Quick check.
-
-
- if (style.indexOf('mso-list') === -1) {
+ if (!style || !style.includes('mso-list')) {
return;
}
-
- const matches = /mso-list\s*:[^;]+level([0-9]+)/i.exec(style);
-
- if (!matches) {
- return;
- }
-
- let level = ms_list_converter_parseInt(matches[1], 10) - 1 || 0;
- const prevNode = node.previousElementSibling; // Add new list if no previous.
-
+ const prevNode = node.previousElementSibling;
+
+ // Add new list if no previous.
if (!prevNode || !ms_list_converter_isList(prevNode)) {
// See https://html.spec.whatwg.org/multipage/grouping-content.html#attr-ol-type.
const type = node.textContent.trim().slice(0, 1);
const isNumeric = /[1iIaA]/.test(type);
const newListNode = doc.createElement(isNumeric ? 'ol' : 'ul');
-
if (isNumeric) {
newListNode.setAttribute('type', type);
}
-
node.parentNode.insertBefore(newListNode, node);
}
-
const listNode = node.previousElementSibling;
const listType = listNode.nodeName;
const listItem = doc.createElement('li');
- let receivingNode = listNode; // Remove the first span with list info.
-
- node.removeChild(node.firstChild); // Add content.
-
- while (node.firstChild) {
- listItem.appendChild(node.firstChild);
- } // Change pointer depending on indentation level.
-
-
+ let receivingNode = listNode;
+
+ // Add content.
+ listItem.innerHTML = deepFilterHTML(node.innerHTML, [msListIgnore]);
+ const matches = /mso-list\s*:[^;]+level([0-9]+)/i.exec(style);
+ let level = matches ? parseInt(matches[1], 10) - 1 || 0 : 0;
+
+ // Change pointer depending on indentation level.
while (level--) {
- receivingNode = receivingNode.lastChild || receivingNode; // If it's a list, move pointer to the last item.
-
+ receivingNode = receivingNode.lastChild || receivingNode;
+
+ // If it's a list, move pointer to the last item.
if (ms_list_converter_isList(receivingNode)) {
receivingNode = receivingNode.lastChild || receivingNode;
}
- } // Make sure we append to a list.
-
-
+ }
+
+ // Make sure we append to a list.
if (!ms_list_converter_isList(receivingNode)) {
receivingNode = receivingNode.appendChild(doc.createElement(listType));
- } // Append the list item to the list.
-
-
- receivingNode.appendChild(listItem); // Remove the wrapper paragraph.
-
+ }
+
+ // Append the list item to the list.
+ receivingNode.appendChild(listItem);
+
+ // Remove the wrapper paragraph.
node.parentNode.removeChild(node);
}
;// CONCATENATED MODULE: external ["wp","blob"]
-var external_wp_blob_namespaceObject = window["wp"]["blob"];
+const external_wp_blob_namespaceObject = window["wp"]["blob"];
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/image-corrector.js
/**
* WordPress dependencies
*/
-/**
- * Browser dependencies
- */
-
-const {
- atob,
- File
-} = window;
function imageCorrector(node) {
if (node.nodeName !== 'IMG') {
return;
}
-
if (node.src.indexOf('file:') === 0) {
node.src = '';
- } // This piece cannot be tested outside a browser env.
-
-
+ }
+
+ // This piece cannot be tested outside a browser env.
if (node.src.indexOf('data:') === 0) {
const [properties, data] = node.src.split(',');
const [type] = properties.slice(5).split(';');
-
if (!data || !type) {
node.src = '';
return;
}
-
- let decoded; // Can throw DOMException!
-
+ let decoded;
+
+ // Can throw DOMException!
try {
decoded = atob(data);
} catch (e) {
node.src = '';
return;
}
-
const uint8Array = new Uint8Array(decoded.length);
-
for (let i = 0; i < uint8Array.length; i++) {
uint8Array[i] = decoded.charCodeAt(i);
}
-
const name = type.replace('/', '.');
- const file = new File([uint8Array], name, {
+ const file = new window.File([uint8Array], name, {
type
});
node.src = (0,external_wp_blob_namespaceObject.createBlobURL)(file);
- } // Remove trackers and hardly visible images.
-
-
+ }
+
+ // Remove trackers and hardly visible images.
if (node.height === 1 || node.width === 1) {
node.parentNode.removeChild(node);
}
@@ -12721,19 +14799,19 @@
if (node.nodeName !== 'DIV') {
return;
}
-
node.innerHTML = normaliseBlocks(node.innerHTML);
}
// EXTERNAL MODULE: ./node_modules/showdown/dist/showdown.js
-var showdown = __webpack_require__(7308);
+var showdown = __webpack_require__(1030);
var showdown_default = /*#__PURE__*/__webpack_require__.n(showdown);
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/markdown-converter.js
/**
* External dependencies
*/
- // Reuse the same showdown converter.
-
+
+
+// Reuse the same showdown converter.
const converter = new (showdown_default()).Converter({
noHeaderId: true,
tables: true,
@@ -12742,6 +14820,7 @@
simpleLineBreaks: true,
strikethrough: true
});
+
/**
* Corrects the Slack Markdown variant of the code block.
* If uncorrected, it will be converted to inline code.
@@ -12752,10 +14831,13 @@
*
* @return {string} The corrected Markdown.
*/
-
function slackMarkdownVariantCorrector(text) {
return text.replace(/((?:^|\n)```)([^\n`]+)(```(?:$|\n))/, (match, p1, p2, p3) => `${p1}\n${p2}\n${p3}`);
}
+function bulletsToAsterisks(text) {
+ return text.replace(/(^|\n)•( +)/g, '$1*$2');
+}
+
/**
* Converts a piece of text into HTML based on any Markdown present.
* Also decodes any encoded HTML.
@@ -12764,10 +14846,8 @@
*
* @return {string} HTML.
*/
-
-
function markdownConverter(text) {
- return converter.makeHtml(slackMarkdownVariantCorrector(text));
+ return converter.makeHtml(slackMarkdownVariantCorrector(bulletsToAsterisks(text)));
}
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/iframe-remover.js
@@ -12795,7 +14875,13 @@
return;
}
- (0,external_wp_dom_namespaceObject.unwrap)(node);
+ // Google Docs sometimes wraps the content in a B tag. We don't want to keep
+ // this.
+ if (node.tagName === 'B') {
+ (0,external_wp_dom_namespaceObject.unwrap)(node);
+ } else {
+ node.removeAttribute('id');
+ }
}
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/html-formatting-remover.js
@@ -12803,10 +14889,10 @@
* Internal dependencies
*/
-
function isFormattingSpace(character) {
return character === ' ' || character === '\r' || character === '\n' || character === '\t';
}
+
/**
* Removes spacing that formats HTML.
*
@@ -12815,54 +14901,50 @@
* @param {Node} node The node to be processed.
* @return {void}
*/
-
-
function htmlFormattingRemover(node) {
if (node.nodeType !== node.TEXT_NODE) {
return;
- } // Ignore pre content. Note that this does not use Element#closest due to
+ }
+
+ // Ignore pre content. Note that this does not use Element#closest due to
// a combination of (a) node may not be Element and (b) node.parentElement
// does not have full support in all browsers (Internet Exporer).
//
// See: https://developer.mozilla.org/en-US/docs/Web/API/Node/parentElement#Browser_compatibility
/** @type {Node?} */
-
-
let parent = node;
-
while (parent = parent.parentNode) {
if (parent.nodeType === parent.ELEMENT_NODE && parent.nodeName === 'PRE') {
return;
}
- } // First, replace any sequence of HTML formatting space with a single space.
-
-
- let newData = node.data.replace(/[ \r\n\t]+/g, ' '); // Remove the leading space if the text element is at the start of a block,
+ }
+
+ // First, replace any sequence of HTML formatting space with a single space.
+ let newData = node.data.replace(/[ \r\n\t]+/g, ' ');
+
+ // Remove the leading space if the text element is at the start of a block,
// is preceded by a line break element, or has a space in the previous
// node.
-
if (newData[0] === ' ') {
const previousSibling = getSibling(node, 'previous');
-
if (!previousSibling || previousSibling.nodeName === 'BR' || previousSibling.textContent.slice(-1) === ' ') {
newData = newData.slice(1);
}
- } // Remove the trailing space if the text element is at the end of a block,
+ }
+
+ // Remove the trailing space if the text element is at the end of a block,
// is succeded by a line break element, or has a space in the next text
// node.
-
-
if (newData[newData.length - 1] === ' ') {
const nextSibling = getSibling(node, 'next');
-
if (!nextSibling || nextSibling.nodeName === 'BR' || nextSibling.nodeType === nextSibling.TEXT_NODE && isFormattingSpace(nextSibling.textContent[0])) {
newData = newData.slice(0, -1);
}
- } // If there's no data left, remove the node, so `previousSibling` stays
+ }
+
+ // If there's no data left, remove the node, so `previousSibling` stays
// accurate. Otherwise, update the node data.
-
-
if (!newData) {
node.parentNode.removeChild(node);
} else {
@@ -12875,21 +14957,19 @@
* Internal dependencies
*/
+
/**
* Removes trailing br elements from text-level content.
*
* @param {Element} node Node to check.
*/
-
function brRemover(node) {
if (node.nodeName !== 'BR') {
return;
}
-
if (getSibling(node, 'next')) {
return;
}
-
node.parentNode.removeChild(node);
}
@@ -12903,20 +14983,36 @@
if (node.nodeName !== 'P') {
return;
}
-
if (node.hasChildNodes()) {
return;
}
-
node.parentNode.removeChild(node);
}
+;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/slack-paragraph-corrector.js
+/**
+ * Replaces Slack paragraph markup with a double line break (later converted to
+ * a proper paragraph).
+ *
+ * @param {Element} node Node to check.
+ */
+function slackParagraphCorrector(node) {
+ if (node.nodeName !== 'SPAN') {
+ return;
+ }
+ if (node.getAttribute('data-stringify-type') !== 'paragraph-break') {
+ return;
+ }
+ const {
+ parentNode
+ } = node;
+ parentNode.insertBefore(node.ownerDocument.createElement('br'), node);
+ parentNode.insertBefore(node.ownerDocument.createElement('br'), node);
+ parentNode.removeChild(node);
+}
+
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/paste-handler.js
/**
- * External dependencies
- */
-
-/**
* WordPress dependencies
*/
@@ -12949,156 +15045,154 @@
-/**
- * Browser dependencies
- */
-
-const {
- console: paste_handler_console
-} = window;
+
+const log = (...args) => window?.console?.log?.(...args);
+
/**
* Filters HTML to only contain phrasing content.
*
- * @param {string} HTML The HTML to filter.
- * @param {boolean} preserveWhiteSpace Whether or not to preserve consequent white space.
+ * @param {string} HTML The HTML to filter.
*
* @return {string} HTML only containing phrasing content.
*/
-
-function filterInlineHTML(HTML, preserveWhiteSpace) {
- HTML = deepFilterHTML(HTML, [googleDocsUIdRemover, phrasingContentReducer, commentRemover]);
+function filterInlineHTML(HTML) {
+ HTML = deepFilterHTML(HTML, [headRemover, googleDocsUIdRemover, msListIgnore, phrasingContentReducer, commentRemover]);
HTML = (0,external_wp_dom_namespaceObject.removeInvalidHTML)(HTML, (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)('paste'), {
inline: true
});
-
- if (!preserveWhiteSpace) {
- HTML = deepFilterHTML(HTML, [htmlFormattingRemover, brRemover]);
- } // Allows us to ask for this information when we get a report.
-
-
- paste_handler_console.log('Processed inline HTML:\n\n', HTML);
+ HTML = deepFilterHTML(HTML, [htmlFormattingRemover, brRemover]);
+
+ // Allows us to ask for this information when we get a report.
+ log('Processed inline HTML:\n\n', HTML);
return HTML;
}
+
/**
* Converts an HTML string to known blocks. Strips everything else.
*
- * @param {Object} options
- * @param {string} [options.HTML] The HTML to convert.
- * @param {string} [options.plainText] Plain text version.
- * @param {string} [options.mode] Handle content as blocks or inline content.
- * * 'AUTO': Decide based on the content passed.
- * * 'INLINE': Always handle as inline content, and return string.
- * * 'BLOCKS': Always handle as blocks, and return array of blocks.
- * @param {Array} [options.tagName] The tag into which content will be inserted.
- * @param {boolean} [options.preserveWhiteSpace] Whether or not to preserve consequent white space.
+ * @param {Object} options
+ * @param {string} [options.HTML] The HTML to convert.
+ * @param {string} [options.plainText] Plain text version.
+ * @param {string} [options.mode] Handle content as blocks or inline content.
+ * * 'AUTO': Decide based on the content passed.
+ * * 'INLINE': Always handle as inline content, and return string.
+ * * 'BLOCKS': Always handle as blocks, and return array of blocks.
+ * @param {Array} [options.tagName] The tag into which content will be inserted.
*
* @return {Array|string} A list of blocks or a string, depending on `handlerMode`.
*/
-
-
-function pasteHandler(_ref) {
- let {
- HTML = '',
- plainText = '',
- mode = 'AUTO',
- tagName,
- preserveWhiteSpace
- } = _ref;
+function pasteHandler({
+ HTML = '',
+ plainText = '',
+ mode = 'AUTO',
+ tagName
+}) {
// First of all, strip any meta tags.
- HTML = HTML.replace(/<meta[^>]+>/g, ''); // Strip Windows markers.
-
+ HTML = HTML.replace(/<meta[^>]+>/g, '');
+ // Strip Windows markers.
HTML = HTML.replace(/^\s*<html[^>]*>\s*<body[^>]*>(?:\s*<!--\s*StartFragment\s*-->)?/i, '');
- HTML = HTML.replace(/(?:<!--\s*EndFragment\s*-->\s*)?<\/body>\s*<\/html>\s*$/i, ''); // If we detect block delimiters in HTML, parse entirely as blocks.
-
+ HTML = HTML.replace(/(?:<!--\s*EndFragment\s*-->\s*)?<\/body>\s*<\/html>\s*$/i, '');
+
+ // If we detect block delimiters in HTML, parse entirely as blocks.
if (mode !== 'INLINE') {
// Check plain text if there is no HTML.
const content = HTML ? HTML : plainText;
-
if (content.indexOf('<!-- wp:') !== -1) {
- return parser_parse(content);
- }
- } // Normalize unicode to use composed characters.
+ const parseResult = parser_parse(content);
+ const isSingleFreeFormBlock = parseResult.length === 1 && parseResult[0].name === 'core/freeform';
+ if (!isSingleFreeFormBlock) {
+ return parseResult;
+ }
+ }
+ }
+
+ // Normalize unicode to use composed characters.
// This is unsupported in IE 11 but it's a nice-to-have feature, not mandatory.
// Not normalizing the content will only affect older browsers and won't
// entirely break the app.
// See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
// See: https://core.trac.wordpress.org/ticket/30130
// See: https://github.com/WordPress/gutenberg/pull/6983#pullrequestreview-125151075
-
-
if (String.prototype.normalize) {
HTML = HTML.normalize();
- } // Parse Markdown (and encoded HTML) if:
+ }
+
+ // Must be run before checking if it's inline content.
+ HTML = deepFilterHTML(HTML, [slackParagraphCorrector]);
+
+ // Consider plain text if:
// * There is a plain text version.
// * There is no HTML version, or it has no formatting.
-
-
- if (plainText && (!HTML || isPlain(HTML))) {
- HTML = plainText; // The markdown converter (Showdown) trims whitespace.
-
+ const isPlainText = plainText && (!HTML || isPlain(HTML));
+
+ // Parse Markdown (and encoded HTML) if it's considered plain text.
+ if (isPlainText) {
+ HTML = plainText;
+
+ // The markdown converter (Showdown) trims whitespace.
if (!/^\s+$/.test(plainText)) {
HTML = markdownConverter(HTML);
- } // Switch to inline mode if:
+ }
+ }
+
+ // An array of HTML strings and block objects. The blocks replace matched
+ // shortcodes.
+ const pieces = shortcode_converter(HTML);
+
+ // The call to shortcodeConverter will always return more than one element
+ // if shortcodes are matched. The reason is when shortcodes are matched
+ // empty HTML strings are included.
+ const hasShortcodes = pieces.length > 1;
+ if (isPlainText && !hasShortcodes) {
+ // Switch to inline mode if:
// * The current mode is AUTO.
// * The original plain text had no line breaks.
// * The original plain text was not an HTML paragraph.
// * The converted text is just a paragraph.
-
-
if (mode === 'AUTO' && plainText.indexOf('\n') === -1 && plainText.indexOf('<p>') !== 0 && HTML.indexOf('<p>') === 0) {
mode = 'INLINE';
}
}
-
if (mode === 'INLINE') {
- return filterInlineHTML(HTML, preserveWhiteSpace);
- } // An array of HTML strings and block objects. The blocks replace matched
- // shortcodes.
-
-
- const pieces = shortcode_converter(HTML); // The call to shortcodeConverter will always return more than one element
- // if shortcodes are matched. The reason is when shortcodes are matched
- // empty HTML strings are included.
-
- const hasShortcodes = pieces.length > 1;
-
+ return filterInlineHTML(HTML);
+ }
if (mode === 'AUTO' && !hasShortcodes && isInlineContent(HTML, tagName)) {
- return filterInlineHTML(HTML, preserveWhiteSpace);
- }
-
+ return filterInlineHTML(HTML);
+ }
const phrasingContentSchema = (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)('paste');
const blockContentSchema = getBlockContentSchema('paste');
- const blocks = (0,external_lodash_namespaceObject.compact)((0,external_lodash_namespaceObject.flatMap)(pieces, piece => {
+ const blocks = pieces.map(piece => {
// Already a block from shortcode.
if (typeof piece !== 'string') {
return piece;
}
-
- const filters = [googleDocsUIdRemover, msListConverter, headRemover, listReducer, imageCorrector, phrasingContentReducer, specialCommentConverter, commentRemover, iframeRemover, figureContentReducer, blockquoteNormaliser, divNormaliser];
- const schema = { ...blockContentSchema,
+ const filters = [googleDocsUIdRemover, msListConverter, headRemover, listReducer, imageCorrector, phrasingContentReducer, specialCommentConverter, commentRemover, iframeRemover, figureContentReducer, blockquoteNormaliser(), divNormaliser];
+ const schema = {
+ ...blockContentSchema,
// Keep top-level phrasing content, normalised by `normaliseBlocks`.
...phrasingContentSchema
};
piece = deepFilterHTML(piece, filters, blockContentSchema);
piece = (0,external_wp_dom_namespaceObject.removeInvalidHTML)(piece, schema);
piece = normaliseBlocks(piece);
- piece = deepFilterHTML(piece, [htmlFormattingRemover, brRemover, emptyParagraphRemover], blockContentSchema); // Allows us to ask for this information when we get a report.
-
- paste_handler_console.log('Processed HTML piece:\n\n', piece);
- return htmlToBlocks(piece);
- })); // If we're allowed to return inline content, and there is only one
+ piece = deepFilterHTML(piece, [htmlFormattingRemover, brRemover, emptyParagraphRemover], blockContentSchema);
+
+ // Allows us to ask for this information when we get a report.
+ log('Processed HTML piece:\n\n', piece);
+ return htmlToBlocks(piece, pasteHandler);
+ }).flat().filter(Boolean);
+
+ // If we're allowed to return inline content, and there is only one
// inlineable block, and the original plain text content does not have any
// line breaks, then treat it as inline paste.
-
- if (mode === 'AUTO' && blocks.length === 1 && registration_hasBlockSupport(blocks[0].name, '__unstablePasteTextInline', false)) {
+ if (mode === 'AUTO' && blocks.length === 1 && hasBlockSupport(blocks[0].name, '__unstablePasteTextInline', false)) {
+ const trimRegex = /^[\n]+|[\n]+$/g;
// Don't catch line breaks at the start or end.
- const trimmedPlainText = plainText.replace(/^[\n]+|[\n]+$/g, '');
-
+ const trimmedPlainText = plainText.replace(trimRegex, '');
if (trimmedPlainText !== '' && trimmedPlainText.indexOf('\n') === -1) {
- return (0,external_wp_dom_namespaceObject.removeInvalidHTML)(getBlockInnerHTML(blocks[0]), phrasingContentSchema);
- }
- }
-
+ return (0,external_wp_dom_namespaceObject.removeInvalidHTML)(getBlockInnerHTML(blocks[0]), phrasingContentSchema).replace(trimRegex, '');
+ }
+ }
return blocks;
}
@@ -13107,6 +15201,7 @@
* WordPress dependencies
*/
+
/**
* Internal dependencies
*/
@@ -13116,40 +15211,87 @@
/**
* Returns all the block categories.
+ * Ignored from documentation as the recommended usage is via useSelect from @wordpress/data.
+ *
+ * @ignore
*
* @return {WPBlockCategory[]} Block categories.
*/
-
function categories_getCategories() {
return (0,external_wp_data_namespaceObject.select)(store).getCategories();
}
+
/**
* Sets the block categories.
*
* @param {WPBlockCategory[]} categories Block categories.
- */
-
+ *
+ * @example
+ * ```js
+ * import { __ } from '@wordpress/i18n';
+ * import { store as blocksStore, setCategories } from '@wordpress/blocks';
+ * import { useSelect } from '@wordpress/data';
+ * import { Button } from '@wordpress/components';
+ *
+ * const ExampleComponent = () => {
+ * // Retrieve the list of current categories.
+ * const blockCategories = useSelect(
+ * ( select ) => select( blocksStore ).getCategories(),
+ * []
+ * );
+ *
+ * return (
+ * <Button
+ * onClick={ () => {
+ * // Add a custom category to the existing list.
+ * setCategories( [
+ * ...blockCategories,
+ * { title: 'Custom Category', slug: 'custom-category' },
+ * ] );
+ * } }
+ * >
+ * { __( 'Add a new custom block category' ) }
+ * </Button>
+ * );
+ * };
+ * ```
+ */
function categories_setCategories(categories) {
(0,external_wp_data_namespaceObject.dispatch)(store).setCategories(categories);
}
+
/**
* Updates a category.
*
* @param {string} slug Block category slug.
* @param {WPBlockCategory} category Object containing the category properties
* that should be updated.
- */
-
+ *
+ * @example
+ * ```js
+ * import { __ } from '@wordpress/i18n';
+ * import { updateCategory } from '@wordpress/blocks';
+ * import { Button } from '@wordpress/components';
+ *
+ * const ExampleComponent = () => {
+ * return (
+ * <Button
+ * onClick={ () => {
+ * updateCategory( 'text', { title: __( 'Written Word' ) } );
+ * } }
+ * >
+ * { __( 'Update Text category title' ) }
+ * </Button>
+ * ) ;
+ * };
+ * ```
+ */
function categories_updateCategory(slug, category) {
(0,external_wp_data_namespaceObject.dispatch)(store).updateCategory(slug, category);
}
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/templates.js
/**
- * External dependencies
- */
-
-/**
* WordPress dependencies
*/
@@ -13169,16 +15311,35 @@
*
* @return {boolean} Whether the list of blocks matches a templates.
*/
-
-function doBlocksMatchTemplate() {
- let blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
- let template = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
- return blocks.length === template.length && (0,external_lodash_namespaceObject.every)(template, (_ref, index) => {
- let [name,, innerBlocksTemplate] = _ref;
+function doBlocksMatchTemplate(blocks = [], template = []) {
+ return blocks.length === template.length && template.every(([name,, innerBlocksTemplate], index) => {
const block = blocks[index];
return name === block.name && doBlocksMatchTemplate(block.innerBlocks, innerBlocksTemplate);
});
}
+const isHTMLAttribute = attributeDefinition => attributeDefinition?.source === 'html';
+const isQueryAttribute = attributeDefinition => attributeDefinition?.source === 'query';
+function normalizeAttributes(schema, values) {
+ if (!values) {
+ return {};
+ }
+ return Object.fromEntries(Object.entries(values).map(([key, value]) => [key, normalizeAttribute(schema[key], value)]));
+}
+function normalizeAttribute(definition, value) {
+ if (isHTMLAttribute(definition) && Array.isArray(value)) {
+ // Introduce a deprecated call at this point
+ // When we're confident that "children" format should be removed from the templates.
+
+ return (0,external_wp_element_namespaceObject.renderToString)(value);
+ }
+ if (isQueryAttribute(definition) && value) {
+ return value.map(subValues => {
+ return normalizeAttributes(definition.query, subValues);
+ });
+ }
+ return value;
+}
+
/**
* Synchronize a block list with a block template.
*
@@ -13192,63 +15353,33 @@
*
* @return {Array} Updated Block list.
*/
-
-function synchronizeBlocksWithTemplate() {
- let blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
- let template = arguments.length > 1 ? arguments[1] : undefined;
-
+function synchronizeBlocksWithTemplate(blocks = [], template) {
// If no template is provided, return blocks unmodified.
if (!template) {
return blocks;
}
-
- return (0,external_lodash_namespaceObject.map)(template, (_ref2, index) => {
- let [name, attributes, innerBlocksTemplate] = _ref2;
+ return template.map(([name, attributes, innerBlocksTemplate], index) => {
+ var _blockType$attributes;
const block = blocks[index];
-
if (block && block.name === name) {
const innerBlocks = synchronizeBlocksWithTemplate(block.innerBlocks, innerBlocksTemplate);
- return { ...block,
+ return {
+ ...block,
innerBlocks
};
- } // To support old templates that were using the "children" format
+ }
+
+ // To support old templates that were using the "children" format
// for the attributes using "html" strings now, we normalize the template attributes
// before creating the blocks.
-
- const blockType = registration_getBlockType(name);
-
- const isHTMLAttribute = attributeDefinition => (0,external_lodash_namespaceObject.get)(attributeDefinition, ['source']) === 'html';
-
- const isQueryAttribute = attributeDefinition => (0,external_lodash_namespaceObject.get)(attributeDefinition, ['source']) === 'query';
-
- const normalizeAttributes = (schema, values) => {
- return (0,external_lodash_namespaceObject.mapValues)(values, (value, key) => {
- return normalizeAttribute(schema[key], value);
- });
- };
-
- const normalizeAttribute = (definition, value) => {
- if (isHTMLAttribute(definition) && (0,external_lodash_namespaceObject.isArray)(value)) {
- // Introduce a deprecated call at this point
- // When we're confident that "children" format should be removed from the templates.
- return (0,external_wp_element_namespaceObject.renderToString)(value);
- }
-
- if (isQueryAttribute(definition) && value) {
- return value.map(subValues => {
- return normalizeAttributes(definition.query, subValues);
- });
- }
-
- return value;
- };
-
- const normalizedAttributes = normalizeAttributes((0,external_lodash_namespaceObject.get)(blockType, ['attributes'], {}), attributes);
- let [blockName, blockAttributes] = convertLegacyBlockNameAndAttributes(name, normalizedAttributes); // If a Block is undefined at this point, use the core/missing block as
+ const blockType = getBlockType(name);
+ const normalizedAttributes = normalizeAttributes((_blockType$attributes = blockType?.attributes) !== null && _blockType$attributes !== void 0 ? _blockType$attributes : {}, attributes);
+ let [blockName, blockAttributes] = convertLegacyBlockNameAndAttributes(name, normalizedAttributes);
+
+ // If a Block is undefined at this point, use the core/missing block as
// a placeholder for a better user experience.
-
- if (undefined === registration_getBlockType(blockName)) {
+ if (undefined === getBlockType(blockName)) {
blockAttributes = {
originalName: name,
originalContent: '',
@@ -13256,7 +15387,6 @@
};
blockName = 'core/missing';
}
-
return createBlock(blockName, blockAttributes, synchronizeBlocksWithTemplate([], innerBlocksTemplate));
});
}
@@ -13268,7 +15398,9 @@
// another through formulas defined by either the source or the destination.
// Switching a blocktype is to be considered a one-way operation implying a
// transformation in the opposite way has to be handled explicitly.
- // The block tree is composed of a collection of block nodes. Blocks contained
+
+
+// The block tree is composed of a collection of block nodes. Blocks contained
// within other blocks are called inner blocks. An important design
// consideration is that inner blocks are -- conceptually -- not part of the
// territory established by the parent block that contains them.
@@ -13288,18 +15420,21 @@
- // While block transformations account for a specific surface of the API, there
+
+// While block transformations account for a specific surface of the API, there
// are also raw transformations which handle arbitrary sources not made out of
// blocks but producing block basaed on various heursitics. This includes
// pasting rich text or HTML data.
- // The process of serialization aims to deflate the internal memory of the block
+
+// The process of serialization aims to deflate the internal memory of the block
// editor and its state representation back into an HTML valid string. This
// process restores the document integrity and inserts invisible delimiters
// around each block with HTML comment boundaries which can contain any extra
// attributes needed to operate with the block later on.
- // Validation is the process of comparing a block source with its output before
+
+// Validation is the process of comparing a block source with its output before
// there is any user input or interaction with a block. When this operation
// fails -- for whatever reason -- the block is to be considered invalid. As
// part of validating a block the system will attempt to run the source against
@@ -13323,7 +15458,8 @@
// adequate to spend more time determining validity before throwing a conflict.
- // Blocks are inherently indifferent about where the data they operate with ends
+
+// Blocks are inherently indifferent about where the data they operate with ends
// up being saved. For example, all blocks can have a static and dynamic aspect
// to them depending on the needs. The static nature of a block is the `save()`
// definition that is meant to be serialized into HTML and which can be left
@@ -13341,7 +15477,8 @@
// children of another block.
- // Templates are, in a general sense, a basic collection of block nodes with any
+
+// Templates are, in a general sense, a basic collection of block nodes with any
// given set of predefined attributes that are supplied as the initial state of
// an inner blocks group. These nodes can, in turn, contain any number of nested
// blocks within their definition. Templates allow both to specify a default
@@ -13352,99 +15489,27 @@
-
-;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
-function _extends() {
- _extends = Object.assign ? Object.assign.bind() : function (target) {
- for (var i = 1; i < arguments.length; i++) {
- var source = arguments[i];
-
- for (var key in source) {
- if (Object.prototype.hasOwnProperty.call(source, key)) {
- target[key] = source[key];
- }
- }
- }
-
- return target;
- };
- return _extends.apply(this, arguments);
-}
-;// CONCATENATED MODULE: external ["wp","compose"]
-var external_wp_compose_namespaceObject = window["wp"]["compose"];
-;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/block-content-provider/index.js
-
-
-
+;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/deprecated.js
/**
* WordPress dependencies
*/
/**
- * Internal dependencies
- */
-
-
-const {
- Consumer,
- Provider
-} = (0,external_wp_element_namespaceObject.createContext)(() => {});
-/**
- * An internal block component used in block content serialization to inject
- * nested block content within the `save` implementation of the ancestor
- * component in which it is nested. The component provides a pre-bound
- * `BlockContent` component via context, which is used by the developer-facing
- * `InnerBlocks.Content` component to render block content.
- *
- * @example
- *
- * ```jsx
- * <BlockContentProvider innerBlocks={ innerBlocks }>
- * { blockSaveElement }
- * </BlockContentProvider>
- * ```
- *
- * @param {Object} props Component props.
- * @param {WPElement} props.children Block save result.
- * @param {Array} props.innerBlocks Block(s) to serialize.
- *
- * @return {WPComponent} Element with BlockContent injected via context.
- */
-
-const BlockContentProvider = _ref => {
- let {
- children,
- innerBlocks
- } = _ref;
-
- const BlockContent = () => {
- // Value is an array of blocks, so defer to block serializer.
- const html = serialize(innerBlocks, {
- isInnerBlocks: true
- }); // Use special-cased raw HTML tag to avoid default escaping
-
- return createElement(RawHTML, null, html);
- };
-
- return createElement(Provider, {
- value: BlockContent
- }, children);
-};
-/**
* A Higher Order Component used to inject BlockContent using context to the
* wrapped component.
*
- * @return {WPComponent} Enhanced component with injected BlockContent as prop.
- */
-
-
-const withBlockContentContext = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(OriginalComponent => {
- return props => (0,external_wp_element_namespaceObject.createElement)(Consumer, null, context => (0,external_wp_element_namespaceObject.createElement)(OriginalComponent, _extends({}, props, {
- BlockContent: context
- })));
-}, 'withBlockContentContext');
-/* harmony default export */ var block_content_provider = ((/* unused pure expression or super */ null && (BlockContentProvider)));
+ * @deprecated
+ *
+ * @param {Component} OriginalComponent The component to enhance.
+ * @return {Component} The same component.
+ */
+function withBlockContentContext(OriginalComponent) {
+ external_wp_deprecated_default()('wp.blocks.withBlockContentContext', {
+ since: '6.1'
+ });
+ return OriginalComponent;
+}
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/index.js
// A "block" is the abstract term used to describe units of markup that,
@@ -13460,7 +15525,9 @@
-}();
+
+})();
+
(window.wp = window.wp || {}).blocks = __webpack_exports__;
/******/ })()
;
\ No newline at end of file