1 this["wp"] = this["wp"] || {}; this["wp"]["blocks"] = |
1 /******/ (function() { // webpackBootstrap |
2 /******/ (function(modules) { // webpackBootstrap |
2 /******/ var __webpack_modules__ = ({ |
3 /******/ // The module cache |
3 |
4 /******/ var installedModules = {}; |
4 /***/ 9756: |
5 /******/ |
5 /***/ (function(module) { |
6 /******/ // The require function |
6 |
7 /******/ function __webpack_require__(moduleId) { |
7 /** |
8 /******/ |
8 * Memize options object. |
9 /******/ // Check if module is in cache |
9 * |
10 /******/ if(installedModules[moduleId]) { |
10 * @typedef MemizeOptions |
11 /******/ return installedModules[moduleId].exports; |
11 * |
12 /******/ } |
12 * @property {number} [maxSize] Maximum size of the cache. |
13 /******/ // Create a new module (and put it into the cache) |
13 */ |
14 /******/ var module = installedModules[moduleId] = { |
14 |
15 /******/ i: moduleId, |
15 /** |
16 /******/ l: false, |
16 * Internal cache entry. |
17 /******/ exports: {} |
17 * |
18 /******/ }; |
18 * @typedef MemizeCacheNode |
19 /******/ |
19 * |
20 /******/ // Execute the module function |
20 * @property {?MemizeCacheNode|undefined} [prev] Previous node. |
21 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
21 * @property {?MemizeCacheNode|undefined} [next] Next node. |
22 /******/ |
22 * @property {Array<*>} args Function arguments for cache |
23 /******/ // Flag the module as loaded |
23 * entry. |
24 /******/ module.l = true; |
24 * @property {*} val Function result. |
25 /******/ |
25 */ |
26 /******/ // Return the exports of the module |
26 |
27 /******/ return module.exports; |
27 /** |
28 /******/ } |
28 * Properties of the enhanced function for controlling cache. |
29 /******/ |
29 * |
30 /******/ |
30 * @typedef MemizeMemoizedFunction |
31 /******/ // expose the modules object (__webpack_modules__) |
31 * |
32 /******/ __webpack_require__.m = modules; |
32 * @property {()=>void} clear Clear the cache. |
33 /******/ |
33 */ |
34 /******/ // expose the module cache |
34 |
35 /******/ __webpack_require__.c = installedModules; |
35 /** |
36 /******/ |
36 * Accepts a function to be memoized, and returns a new memoized function, with |
37 /******/ // define getter function for harmony exports |
37 * optional options. |
38 /******/ __webpack_require__.d = function(exports, name, getter) { |
38 * |
39 /******/ if(!__webpack_require__.o(exports, name)) { |
39 * @template {Function} F |
40 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); |
40 * |
41 /******/ } |
41 * @param {F} fn Function to memoize. |
42 /******/ }; |
42 * @param {MemizeOptions} [options] Options object. |
43 /******/ |
43 * |
44 /******/ // define __esModule on exports |
44 * @return {F & MemizeMemoizedFunction} Memoized function. |
45 /******/ __webpack_require__.r = function(exports) { |
45 */ |
46 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
46 function memize( fn, options ) { |
47 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
47 var size = 0; |
48 /******/ } |
48 |
49 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
49 /** @type {?MemizeCacheNode|undefined} */ |
50 /******/ }; |
50 var head; |
51 /******/ |
51 |
52 /******/ // create a fake namespace object |
52 /** @type {?MemizeCacheNode|undefined} */ |
53 /******/ // mode & 1: value is a module id, require it |
53 var tail; |
54 /******/ // mode & 2: merge all properties of value into the ns |
54 |
55 /******/ // mode & 4: return value when already ns object |
55 options = options || {}; |
56 /******/ // mode & 8|1: behave like require |
56 |
57 /******/ __webpack_require__.t = function(value, mode) { |
57 function memoized( /* ...args */ ) { |
58 /******/ if(mode & 1) value = __webpack_require__(value); |
58 var node = head, |
59 /******/ if(mode & 8) return value; |
59 len = arguments.length, |
60 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; |
60 args, i; |
61 /******/ var ns = Object.create(null); |
61 |
62 /******/ __webpack_require__.r(ns); |
62 searchCache: while ( node ) { |
63 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); |
63 // Perform a shallow equality test to confirm that whether the node |
64 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); |
64 // under test is a candidate for the arguments passed. Two arrays |
65 /******/ return ns; |
65 // are shallowly equal if their length matches and each entry is |
66 /******/ }; |
66 // strictly equal between the two sets. Avoid abstracting to a |
67 /******/ |
67 // function which could incur an arguments leaking deoptimization. |
68 /******/ // getDefaultExport function for compatibility with non-harmony modules |
68 |
69 /******/ __webpack_require__.n = function(module) { |
69 // Check whether node arguments match arguments length |
70 /******/ var getter = module && module.__esModule ? |
70 if ( node.args.length !== arguments.length ) { |
71 /******/ function getDefault() { return module['default']; } : |
71 node = node.next; |
72 /******/ function getModuleExports() { return module; }; |
72 continue; |
73 /******/ __webpack_require__.d(getter, 'a', getter); |
73 } |
74 /******/ return getter; |
74 |
75 /******/ }; |
75 // Check whether node arguments match arguments values |
76 /******/ |
76 for ( i = 0; i < len; i++ ) { |
77 /******/ // Object.prototype.hasOwnProperty.call |
77 if ( node.args[ i ] !== arguments[ i ] ) { |
78 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; |
78 node = node.next; |
79 /******/ |
79 continue searchCache; |
80 /******/ // __webpack_public_path__ |
80 } |
81 /******/ __webpack_require__.p = ""; |
81 } |
82 /******/ |
82 |
83 /******/ |
83 // At this point we can assume we've found a match |
84 /******/ // Load entry module and return exports |
84 |
85 /******/ return __webpack_require__(__webpack_require__.s = "0ATp"); |
85 // Surface matched node to head if not already |
86 /******/ }) |
86 if ( node !== head ) { |
87 /************************************************************************/ |
87 // As tail, shift to previous. Must only shift if not also |
88 /******/ ({ |
88 // head, since if both head and tail, there is no previous. |
89 |
89 if ( node === tail ) { |
90 /***/ "//Lo": |
90 tail = node.prev; |
91 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
91 } |
92 |
92 |
93 "use strict"; |
93 // Adjust siblings to point to each other. If node was tail, |
94 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId"); |
94 // this also handles new tail's empty `next` assignment. |
95 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); |
95 /** @type {MemizeCacheNode} */ ( node.prev ).next = node.next; |
96 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9"); |
96 if ( node.next ) { |
97 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__); |
97 node.next.prev = node.prev; |
98 |
98 } |
99 |
99 |
100 /** |
100 node.next = head; |
101 * WordPress dependencies |
101 node.prev = null; |
102 */ |
102 /** @type {MemizeCacheNode} */ ( head ).prev = node; |
103 |
103 head = node; |
104 const blockDefault = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], { |
104 } |
105 xmlns: "http://www.w3.org/2000/svg", |
105 |
106 viewBox: "0 0 24 24" |
106 // Return immediately |
107 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], { |
107 return node.val; |
108 d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z" |
108 } |
109 })); |
109 |
110 /* harmony default export */ __webpack_exports__["a"] = (blockDefault); |
110 // No cached value found. Continue to insertion phase: |
|
111 |
|
112 // Create a copy of arguments (avoid leaking deoptimization) |
|
113 args = new Array( len ); |
|
114 for ( i = 0; i < len; i++ ) { |
|
115 args[ i ] = arguments[ i ]; |
|
116 } |
|
117 |
|
118 node = { |
|
119 args: args, |
|
120 |
|
121 // Generate the result from original function |
|
122 val: fn.apply( null, args ), |
|
123 }; |
|
124 |
|
125 // Don't need to check whether node is already head, since it would |
|
126 // have been returned above already if it was |
|
127 |
|
128 // Shift existing head down list |
|
129 if ( head ) { |
|
130 head.prev = node; |
|
131 node.next = head; |
|
132 } else { |
|
133 // If no head, follows that there's no tail (at initial or reset) |
|
134 tail = node; |
|
135 } |
|
136 |
|
137 // Trim tail if we're reached max size and are pending cache insertion |
|
138 if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) { |
|
139 tail = /** @type {MemizeCacheNode} */ ( tail ).prev; |
|
140 /** @type {MemizeCacheNode} */ ( tail ).next = null; |
|
141 } else { |
|
142 size++; |
|
143 } |
|
144 |
|
145 head = node; |
|
146 |
|
147 return node.val; |
|
148 } |
|
149 |
|
150 memoized.clear = function() { |
|
151 head = null; |
|
152 tail = null; |
|
153 size = 0; |
|
154 }; |
|
155 |
|
156 if ( false ) {} |
|
157 |
|
158 // Ignore reason: There's not a clear solution to create an intersection of |
|
159 // the function with additional properties, where the goal is to retain the |
|
160 // function signature of the incoming argument and add control properties |
|
161 // on the return value. |
|
162 |
|
163 // @ts-ignore |
|
164 return memoized; |
|
165 } |
|
166 |
|
167 module.exports = memize; |
111 |
168 |
112 |
169 |
113 /***/ }), |
170 /***/ }), |
114 |
171 |
115 /***/ "0ATp": |
172 /***/ 7308: |
116 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
117 |
|
118 "use strict"; |
|
119 // ESM COMPAT FLAG |
|
120 __webpack_require__.r(__webpack_exports__); |
|
121 |
|
122 // EXPORTS |
|
123 __webpack_require__.d(__webpack_exports__, "store", function() { return /* reexport */ store; }); |
|
124 __webpack_require__.d(__webpack_exports__, "createBlock", function() { return /* reexport */ createBlock; }); |
|
125 __webpack_require__.d(__webpack_exports__, "createBlocksFromInnerBlocksTemplate", function() { return /* reexport */ createBlocksFromInnerBlocksTemplate; }); |
|
126 __webpack_require__.d(__webpack_exports__, "cloneBlock", function() { return /* reexport */ cloneBlock; }); |
|
127 __webpack_require__.d(__webpack_exports__, "__experimentalCloneSanitizedBlock", function() { return /* reexport */ __experimentalCloneSanitizedBlock; }); |
|
128 __webpack_require__.d(__webpack_exports__, "getPossibleBlockTransformations", function() { return /* reexport */ getPossibleBlockTransformations; }); |
|
129 __webpack_require__.d(__webpack_exports__, "switchToBlockType", function() { return /* reexport */ switchToBlockType; }); |
|
130 __webpack_require__.d(__webpack_exports__, "getBlockTransforms", function() { return /* reexport */ getBlockTransforms; }); |
|
131 __webpack_require__.d(__webpack_exports__, "findTransform", function() { return /* reexport */ findTransform; }); |
|
132 __webpack_require__.d(__webpack_exports__, "getBlockFromExample", function() { return /* reexport */ getBlockFromExample; }); |
|
133 __webpack_require__.d(__webpack_exports__, "parse", function() { return /* reexport */ parser; }); |
|
134 __webpack_require__.d(__webpack_exports__, "getBlockAttributes", function() { return /* reexport */ getBlockAttributes; }); |
|
135 __webpack_require__.d(__webpack_exports__, "parseWithAttributeSchema", function() { return /* reexport */ parseWithAttributeSchema; }); |
|
136 __webpack_require__.d(__webpack_exports__, "pasteHandler", function() { return /* reexport */ pasteHandler; }); |
|
137 __webpack_require__.d(__webpack_exports__, "rawHandler", function() { return /* reexport */ rawHandler; }); |
|
138 __webpack_require__.d(__webpack_exports__, "getPhrasingContentSchema", function() { return /* reexport */ deprecatedGetPhrasingContentSchema; }); |
|
139 __webpack_require__.d(__webpack_exports__, "serialize", function() { return /* reexport */ serialize; }); |
|
140 __webpack_require__.d(__webpack_exports__, "getBlockContent", function() { return /* reexport */ getBlockInnerHTML; }); |
|
141 __webpack_require__.d(__webpack_exports__, "getBlockDefaultClassName", function() { return /* reexport */ getBlockDefaultClassName; }); |
|
142 __webpack_require__.d(__webpack_exports__, "getBlockMenuDefaultClassName", function() { return /* reexport */ getBlockMenuDefaultClassName; }); |
|
143 __webpack_require__.d(__webpack_exports__, "getSaveElement", function() { return /* reexport */ getSaveElement; }); |
|
144 __webpack_require__.d(__webpack_exports__, "getSaveContent", function() { return /* reexport */ getSaveContent; }); |
|
145 __webpack_require__.d(__webpack_exports__, "__unstableGetBlockProps", function() { return /* reexport */ getBlockProps; }); |
|
146 __webpack_require__.d(__webpack_exports__, "__unstableSerializeAndClean", function() { return /* reexport */ __unstableSerializeAndClean; }); |
|
147 __webpack_require__.d(__webpack_exports__, "isValidBlockContent", function() { return /* reexport */ isValidBlockContent; }); |
|
148 __webpack_require__.d(__webpack_exports__, "getCategories", function() { return /* reexport */ categories_getCategories; }); |
|
149 __webpack_require__.d(__webpack_exports__, "setCategories", function() { return /* reexport */ categories_setCategories; }); |
|
150 __webpack_require__.d(__webpack_exports__, "updateCategory", function() { return /* reexport */ categories_updateCategory; }); |
|
151 __webpack_require__.d(__webpack_exports__, "registerBlockType", function() { return /* reexport */ registerBlockType; }); |
|
152 __webpack_require__.d(__webpack_exports__, "registerBlockTypeFromMetadata", function() { return /* reexport */ registerBlockTypeFromMetadata; }); |
|
153 __webpack_require__.d(__webpack_exports__, "registerBlockCollection", function() { return /* reexport */ registerBlockCollection; }); |
|
154 __webpack_require__.d(__webpack_exports__, "unregisterBlockType", function() { return /* reexport */ unregisterBlockType; }); |
|
155 __webpack_require__.d(__webpack_exports__, "setFreeformContentHandlerName", function() { return /* reexport */ setFreeformContentHandlerName; }); |
|
156 __webpack_require__.d(__webpack_exports__, "getFreeformContentHandlerName", function() { return /* reexport */ getFreeformContentHandlerName; }); |
|
157 __webpack_require__.d(__webpack_exports__, "setUnregisteredTypeHandlerName", function() { return /* reexport */ setUnregisteredTypeHandlerName; }); |
|
158 __webpack_require__.d(__webpack_exports__, "getUnregisteredTypeHandlerName", function() { return /* reexport */ getUnregisteredTypeHandlerName; }); |
|
159 __webpack_require__.d(__webpack_exports__, "setDefaultBlockName", function() { return /* reexport */ registration_setDefaultBlockName; }); |
|
160 __webpack_require__.d(__webpack_exports__, "getDefaultBlockName", function() { return /* reexport */ registration_getDefaultBlockName; }); |
|
161 __webpack_require__.d(__webpack_exports__, "setGroupingBlockName", function() { return /* reexport */ registration_setGroupingBlockName; }); |
|
162 __webpack_require__.d(__webpack_exports__, "getGroupingBlockName", function() { return /* reexport */ registration_getGroupingBlockName; }); |
|
163 __webpack_require__.d(__webpack_exports__, "getBlockType", function() { return /* reexport */ registration_getBlockType; }); |
|
164 __webpack_require__.d(__webpack_exports__, "getBlockTypes", function() { return /* reexport */ registration_getBlockTypes; }); |
|
165 __webpack_require__.d(__webpack_exports__, "getBlockSupport", function() { return /* reexport */ registration_getBlockSupport; }); |
|
166 __webpack_require__.d(__webpack_exports__, "hasBlockSupport", function() { return /* reexport */ registration_hasBlockSupport; }); |
|
167 __webpack_require__.d(__webpack_exports__, "getBlockVariations", function() { return /* reexport */ registration_getBlockVariations; }); |
|
168 __webpack_require__.d(__webpack_exports__, "isReusableBlock", function() { return /* reexport */ isReusableBlock; }); |
|
169 __webpack_require__.d(__webpack_exports__, "isTemplatePart", function() { return /* reexport */ isTemplatePart; }); |
|
170 __webpack_require__.d(__webpack_exports__, "getChildBlockNames", function() { return /* reexport */ registration_getChildBlockNames; }); |
|
171 __webpack_require__.d(__webpack_exports__, "hasChildBlocks", function() { return /* reexport */ registration_hasChildBlocks; }); |
|
172 __webpack_require__.d(__webpack_exports__, "hasChildBlocksWithInserterSupport", function() { return /* reexport */ registration_hasChildBlocksWithInserterSupport; }); |
|
173 __webpack_require__.d(__webpack_exports__, "unstable__bootstrapServerSideBlockDefinitions", function() { return /* reexport */ unstable__bootstrapServerSideBlockDefinitions; }); |
|
174 __webpack_require__.d(__webpack_exports__, "registerBlockStyle", function() { return /* reexport */ registerBlockStyle; }); |
|
175 __webpack_require__.d(__webpack_exports__, "unregisterBlockStyle", function() { return /* reexport */ unregisterBlockStyle; }); |
|
176 __webpack_require__.d(__webpack_exports__, "registerBlockVariation", function() { return /* reexport */ registerBlockVariation; }); |
|
177 __webpack_require__.d(__webpack_exports__, "unregisterBlockVariation", function() { return /* reexport */ unregisterBlockVariation; }); |
|
178 __webpack_require__.d(__webpack_exports__, "isUnmodifiedDefaultBlock", function() { return /* reexport */ isUnmodifiedDefaultBlock; }); |
|
179 __webpack_require__.d(__webpack_exports__, "normalizeIconObject", function() { return /* reexport */ normalizeIconObject; }); |
|
180 __webpack_require__.d(__webpack_exports__, "isValidIcon", function() { return /* reexport */ isValidIcon; }); |
|
181 __webpack_require__.d(__webpack_exports__, "__experimentalGetBlockLabel", function() { return /* reexport */ getBlockLabel; }); |
|
182 __webpack_require__.d(__webpack_exports__, "__experimentalGetAccessibleBlockLabel", function() { return /* reexport */ getAccessibleBlockLabel; }); |
|
183 __webpack_require__.d(__webpack_exports__, "__experimentalSanitizeBlockAttributes", function() { return /* reexport */ __experimentalSanitizeBlockAttributes; }); |
|
184 __webpack_require__.d(__webpack_exports__, "__experimentalGetBlockAttributesNamesByRole", function() { return /* reexport */ __experimentalGetBlockAttributesNamesByRole; }); |
|
185 __webpack_require__.d(__webpack_exports__, "doBlocksMatchTemplate", function() { return /* reexport */ doBlocksMatchTemplate; }); |
|
186 __webpack_require__.d(__webpack_exports__, "synchronizeBlocksWithTemplate", function() { return /* reexport */ synchronizeBlocksWithTemplate; }); |
|
187 __webpack_require__.d(__webpack_exports__, "children", function() { return /* reexport */ api_children; }); |
|
188 __webpack_require__.d(__webpack_exports__, "node", function() { return /* reexport */ api_node; }); |
|
189 __webpack_require__.d(__webpack_exports__, "__EXPERIMENTAL_STYLE_PROPERTY", function() { return /* reexport */ __EXPERIMENTAL_STYLE_PROPERTY; }); |
|
190 __webpack_require__.d(__webpack_exports__, "__EXPERIMENTAL_ELEMENTS", function() { return /* reexport */ __EXPERIMENTAL_ELEMENTS; }); |
|
191 __webpack_require__.d(__webpack_exports__, "withBlockContentContext", function() { return /* reexport */ withBlockContentContext; }); |
|
192 |
|
193 // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/selectors.js |
|
194 var selectors_namespaceObject = {}; |
|
195 __webpack_require__.r(selectors_namespaceObject); |
|
196 __webpack_require__.d(selectors_namespaceObject, "getBlockTypes", function() { return getBlockTypes; }); |
|
197 __webpack_require__.d(selectors_namespaceObject, "getBlockType", function() { return getBlockType; }); |
|
198 __webpack_require__.d(selectors_namespaceObject, "getBlockStyles", function() { return getBlockStyles; }); |
|
199 __webpack_require__.d(selectors_namespaceObject, "getBlockVariations", function() { return getBlockVariations; }); |
|
200 __webpack_require__.d(selectors_namespaceObject, "getActiveBlockVariation", function() { return getActiveBlockVariation; }); |
|
201 __webpack_require__.d(selectors_namespaceObject, "getDefaultBlockVariation", function() { return getDefaultBlockVariation; }); |
|
202 __webpack_require__.d(selectors_namespaceObject, "getCategories", function() { return getCategories; }); |
|
203 __webpack_require__.d(selectors_namespaceObject, "getCollections", function() { return getCollections; }); |
|
204 __webpack_require__.d(selectors_namespaceObject, "getDefaultBlockName", function() { return getDefaultBlockName; }); |
|
205 __webpack_require__.d(selectors_namespaceObject, "getFreeformFallbackBlockName", function() { return getFreeformFallbackBlockName; }); |
|
206 __webpack_require__.d(selectors_namespaceObject, "getUnregisteredFallbackBlockName", function() { return getUnregisteredFallbackBlockName; }); |
|
207 __webpack_require__.d(selectors_namespaceObject, "getGroupingBlockName", function() { return getGroupingBlockName; }); |
|
208 __webpack_require__.d(selectors_namespaceObject, "getChildBlockNames", function() { return getChildBlockNames; }); |
|
209 __webpack_require__.d(selectors_namespaceObject, "getBlockSupport", function() { return getBlockSupport; }); |
|
210 __webpack_require__.d(selectors_namespaceObject, "hasBlockSupport", function() { return hasBlockSupport; }); |
|
211 __webpack_require__.d(selectors_namespaceObject, "isMatchingSearchTerm", function() { return isMatchingSearchTerm; }); |
|
212 __webpack_require__.d(selectors_namespaceObject, "hasChildBlocks", function() { return hasChildBlocks; }); |
|
213 __webpack_require__.d(selectors_namespaceObject, "hasChildBlocksWithInserterSupport", function() { return hasChildBlocksWithInserterSupport; }); |
|
214 |
|
215 // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/actions.js |
|
216 var actions_namespaceObject = {}; |
|
217 __webpack_require__.r(actions_namespaceObject); |
|
218 __webpack_require__.d(actions_namespaceObject, "addBlockTypes", function() { return addBlockTypes; }); |
|
219 __webpack_require__.d(actions_namespaceObject, "removeBlockTypes", function() { return removeBlockTypes; }); |
|
220 __webpack_require__.d(actions_namespaceObject, "addBlockStyles", function() { return addBlockStyles; }); |
|
221 __webpack_require__.d(actions_namespaceObject, "removeBlockStyles", function() { return removeBlockStyles; }); |
|
222 __webpack_require__.d(actions_namespaceObject, "addBlockVariations", function() { return addBlockVariations; }); |
|
223 __webpack_require__.d(actions_namespaceObject, "removeBlockVariations", function() { return removeBlockVariations; }); |
|
224 __webpack_require__.d(actions_namespaceObject, "setDefaultBlockName", function() { return setDefaultBlockName; }); |
|
225 __webpack_require__.d(actions_namespaceObject, "setFreeformFallbackBlockName", function() { return setFreeformFallbackBlockName; }); |
|
226 __webpack_require__.d(actions_namespaceObject, "setUnregisteredFallbackBlockName", function() { return setUnregisteredFallbackBlockName; }); |
|
227 __webpack_require__.d(actions_namespaceObject, "setGroupingBlockName", function() { return setGroupingBlockName; }); |
|
228 __webpack_require__.d(actions_namespaceObject, "setCategories", function() { return setCategories; }); |
|
229 __webpack_require__.d(actions_namespaceObject, "updateCategory", function() { return updateCategory; }); |
|
230 __webpack_require__.d(actions_namespaceObject, "addBlockCollection", function() { return addBlockCollection; }); |
|
231 __webpack_require__.d(actions_namespaceObject, "removeBlockCollection", function() { return removeBlockCollection; }); |
|
232 |
|
233 // EXTERNAL MODULE: external ["wp","data"] |
|
234 var external_wp_data_ = __webpack_require__("1ZqX"); |
|
235 |
|
236 // EXTERNAL MODULE: external "lodash" |
|
237 var external_lodash_ = __webpack_require__("YLtl"); |
|
238 |
|
239 // EXTERNAL MODULE: external ["wp","i18n"] |
|
240 var external_wp_i18n_ = __webpack_require__("l3Sj"); |
|
241 |
|
242 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/reducer.js |
|
243 /** |
|
244 * External dependencies |
|
245 */ |
|
246 |
|
247 /** |
|
248 * WordPress dependencies |
|
249 */ |
|
250 |
|
251 |
|
252 |
|
253 /** |
|
254 * @typedef {Object} WPBlockCategory |
|
255 * |
|
256 * @property {string} slug Unique category slug. |
|
257 * @property {string} title Category label, for display in user interface. |
|
258 */ |
|
259 |
|
260 /** |
|
261 * Default set of categories. |
|
262 * |
|
263 * @type {WPBlockCategory[]} |
|
264 */ |
|
265 |
|
266 const DEFAULT_CATEGORIES = [{ |
|
267 slug: 'text', |
|
268 title: Object(external_wp_i18n_["__"])('Text') |
|
269 }, { |
|
270 slug: 'media', |
|
271 title: Object(external_wp_i18n_["__"])('Media') |
|
272 }, { |
|
273 slug: 'design', |
|
274 title: Object(external_wp_i18n_["__"])('Design') |
|
275 }, { |
|
276 slug: 'widgets', |
|
277 title: Object(external_wp_i18n_["__"])('Widgets') |
|
278 }, { |
|
279 slug: 'theme', |
|
280 title: Object(external_wp_i18n_["__"])('Theme') |
|
281 }, { |
|
282 slug: 'embed', |
|
283 title: Object(external_wp_i18n_["__"])('Embeds') |
|
284 }, { |
|
285 slug: 'reusable', |
|
286 title: Object(external_wp_i18n_["__"])('Reusable blocks') |
|
287 }]; |
|
288 /** |
|
289 * Reducer managing the block types |
|
290 * |
|
291 * @param {Object} state Current state. |
|
292 * @param {Object} action Dispatched action. |
|
293 * |
|
294 * @return {Object} Updated state. |
|
295 */ |
|
296 |
|
297 function reducer_blockTypes(state = {}, action) { |
|
298 switch (action.type) { |
|
299 case 'ADD_BLOCK_TYPES': |
|
300 return { ...state, |
|
301 ...Object(external_lodash_["keyBy"])(Object(external_lodash_["map"])(action.blockTypes, blockType => Object(external_lodash_["omit"])(blockType, 'styles ')), 'name') |
|
302 }; |
|
303 |
|
304 case 'REMOVE_BLOCK_TYPES': |
|
305 return Object(external_lodash_["omit"])(state, action.names); |
|
306 } |
|
307 |
|
308 return state; |
|
309 } |
|
310 /** |
|
311 * Reducer managing the block style variations. |
|
312 * |
|
313 * @param {Object} state Current state. |
|
314 * @param {Object} action Dispatched action. |
|
315 * |
|
316 * @return {Object} Updated state. |
|
317 */ |
|
318 |
|
319 function blockStyles(state = {}, action) { |
|
320 switch (action.type) { |
|
321 case 'ADD_BLOCK_TYPES': |
|
322 return { ...state, |
|
323 ...Object(external_lodash_["mapValues"])(Object(external_lodash_["keyBy"])(action.blockTypes, 'name'), blockType => { |
|
324 return Object(external_lodash_["uniqBy"])([...Object(external_lodash_["get"])(blockType, ['styles'], []), ...Object(external_lodash_["get"])(state, [blockType.name], [])], style => style.name); |
|
325 }) |
|
326 }; |
|
327 |
|
328 case 'ADD_BLOCK_STYLES': |
|
329 return { ...state, |
|
330 [action.blockName]: Object(external_lodash_["uniqBy"])([...Object(external_lodash_["get"])(state, [action.blockName], []), ...action.styles], style => style.name) |
|
331 }; |
|
332 |
|
333 case 'REMOVE_BLOCK_STYLES': |
|
334 return { ...state, |
|
335 [action.blockName]: Object(external_lodash_["filter"])(Object(external_lodash_["get"])(state, [action.blockName], []), style => action.styleNames.indexOf(style.name) === -1) |
|
336 }; |
|
337 } |
|
338 |
|
339 return state; |
|
340 } |
|
341 /** |
|
342 * Reducer managing the block variations. |
|
343 * |
|
344 * @param {Object} state Current state. |
|
345 * @param {Object} action Dispatched action. |
|
346 * |
|
347 * @return {Object} Updated state. |
|
348 */ |
|
349 |
|
350 function blockVariations(state = {}, action) { |
|
351 switch (action.type) { |
|
352 case 'ADD_BLOCK_TYPES': |
|
353 return { ...state, |
|
354 ...Object(external_lodash_["mapValues"])(Object(external_lodash_["keyBy"])(action.blockTypes, 'name'), blockType => { |
|
355 return Object(external_lodash_["uniqBy"])([...Object(external_lodash_["get"])(blockType, ['variations'], []), ...Object(external_lodash_["get"])(state, [blockType.name], [])], variation => variation.name); |
|
356 }) |
|
357 }; |
|
358 |
|
359 case 'ADD_BLOCK_VARIATIONS': |
|
360 return { ...state, |
|
361 [action.blockName]: Object(external_lodash_["uniqBy"])([...Object(external_lodash_["get"])(state, [action.blockName], []), ...action.variations], variation => variation.name) |
|
362 }; |
|
363 |
|
364 case 'REMOVE_BLOCK_VARIATIONS': |
|
365 return { ...state, |
|
366 [action.blockName]: Object(external_lodash_["filter"])(Object(external_lodash_["get"])(state, [action.blockName], []), variation => action.variationNames.indexOf(variation.name) === -1) |
|
367 }; |
|
368 } |
|
369 |
|
370 return state; |
|
371 } |
|
372 /** |
|
373 * Higher-order Reducer creating a reducer keeping track of given block name. |
|
374 * |
|
375 * @param {string} setActionType Action type. |
|
376 * |
|
377 * @return {Function} Reducer. |
|
378 */ |
|
379 |
|
380 function createBlockNameSetterReducer(setActionType) { |
|
381 return (state = null, action) => { |
|
382 switch (action.type) { |
|
383 case 'REMOVE_BLOCK_TYPES': |
|
384 if (action.names.indexOf(state) !== -1) { |
|
385 return null; |
|
386 } |
|
387 |
|
388 return state; |
|
389 |
|
390 case setActionType: |
|
391 return action.name || null; |
|
392 } |
|
393 |
|
394 return state; |
|
395 }; |
|
396 } |
|
397 const reducer_defaultBlockName = createBlockNameSetterReducer('SET_DEFAULT_BLOCK_NAME'); |
|
398 const freeformFallbackBlockName = createBlockNameSetterReducer('SET_FREEFORM_FALLBACK_BLOCK_NAME'); |
|
399 const unregisteredFallbackBlockName = createBlockNameSetterReducer('SET_UNREGISTERED_FALLBACK_BLOCK_NAME'); |
|
400 const groupingBlockName = createBlockNameSetterReducer('SET_GROUPING_BLOCK_NAME'); |
|
401 /** |
|
402 * Reducer managing the categories |
|
403 * |
|
404 * @param {WPBlockCategory[]} state Current state. |
|
405 * @param {Object} action Dispatched action. |
|
406 * |
|
407 * @return {WPBlockCategory[]} Updated state. |
|
408 */ |
|
409 |
|
410 function reducer_categories(state = DEFAULT_CATEGORIES, action) { |
|
411 switch (action.type) { |
|
412 case 'SET_CATEGORIES': |
|
413 return action.categories || []; |
|
414 |
|
415 case 'UPDATE_CATEGORY': |
|
416 { |
|
417 if (!action.category || Object(external_lodash_["isEmpty"])(action.category)) { |
|
418 return state; |
|
419 } |
|
420 |
|
421 const categoryToChange = Object(external_lodash_["find"])(state, ['slug', action.slug]); |
|
422 |
|
423 if (categoryToChange) { |
|
424 return Object(external_lodash_["map"])(state, category => { |
|
425 if (category.slug === action.slug) { |
|
426 return { ...category, |
|
427 ...action.category |
|
428 }; |
|
429 } |
|
430 |
|
431 return category; |
|
432 }); |
|
433 } |
|
434 } |
|
435 } |
|
436 |
|
437 return state; |
|
438 } |
|
439 function collections(state = {}, action) { |
|
440 switch (action.type) { |
|
441 case 'ADD_BLOCK_COLLECTION': |
|
442 return { ...state, |
|
443 [action.namespace]: { |
|
444 title: action.title, |
|
445 icon: action.icon |
|
446 } |
|
447 }; |
|
448 |
|
449 case 'REMOVE_BLOCK_COLLECTION': |
|
450 return Object(external_lodash_["omit"])(state, action.namespace); |
|
451 } |
|
452 |
|
453 return state; |
|
454 } |
|
455 /* harmony default export */ var reducer = (Object(external_wp_data_["combineReducers"])({ |
|
456 blockTypes: reducer_blockTypes, |
|
457 blockStyles, |
|
458 blockVariations, |
|
459 defaultBlockName: reducer_defaultBlockName, |
|
460 freeformFallbackBlockName, |
|
461 unregisteredFallbackBlockName, |
|
462 groupingBlockName, |
|
463 categories: reducer_categories, |
|
464 collections |
|
465 })); |
|
466 |
|
467 // EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js |
|
468 var rememo = __webpack_require__("pPDe"); |
|
469 |
|
470 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/selectors.js |
|
471 /** |
|
472 * External dependencies |
|
473 */ |
|
474 |
|
475 |
|
476 /** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */ |
|
477 |
|
478 /** @typedef {import('../api/registration').WPBlockVariationScope} WPBlockVariationScope */ |
|
479 |
|
480 /** @typedef {import('./reducer').WPBlockCategory} WPBlockCategory */ |
|
481 |
|
482 /** |
|
483 * Given a block name or block type object, returns the corresponding |
|
484 * normalized block type object. |
|
485 * |
|
486 * @param {Object} state Blocks state. |
|
487 * @param {(string|Object)} nameOrType Block name or type object |
|
488 * |
|
489 * @return {Object} Block type object. |
|
490 */ |
|
491 |
|
492 const getNormalizedBlockType = (state, nameOrType) => 'string' === typeof nameOrType ? getBlockType(state, nameOrType) : nameOrType; |
|
493 /** |
|
494 * Returns all the available block types. |
|
495 * |
|
496 * @param {Object} state Data state. |
|
497 * |
|
498 * @return {Array} Block Types. |
|
499 */ |
|
500 |
|
501 |
|
502 const getBlockTypes = Object(rememo["a" /* default */])(state => { |
|
503 return Object.values(state.blockTypes).map(blockType => { |
|
504 return { ...blockType, |
|
505 variations: getBlockVariations(state, blockType.name) |
|
506 }; |
|
507 }); |
|
508 }, state => [state.blockTypes, state.blockVariations]); |
|
509 /** |
|
510 * Returns a block type by name. |
|
511 * |
|
512 * @param {Object} state Data state. |
|
513 * @param {string} name Block type name. |
|
514 * |
|
515 * @return {Object?} Block Type. |
|
516 */ |
|
517 |
|
518 function getBlockType(state, name) { |
|
519 return state.blockTypes[name]; |
|
520 } |
|
521 /** |
|
522 * Returns block styles by block name. |
|
523 * |
|
524 * @param {Object} state Data state. |
|
525 * @param {string} name Block type name. |
|
526 * |
|
527 * @return {Array?} Block Styles. |
|
528 */ |
|
529 |
|
530 function getBlockStyles(state, name) { |
|
531 return state.blockStyles[name]; |
|
532 } |
|
533 /** |
|
534 * Returns block variations by block name. |
|
535 * |
|
536 * @param {Object} state Data state. |
|
537 * @param {string} blockName Block type name. |
|
538 * @param {WPBlockVariationScope} [scope] Block variation scope name. |
|
539 * |
|
540 * @return {(WPBlockVariation[]|void)} Block variations. |
|
541 */ |
|
542 |
|
543 const getBlockVariations = Object(rememo["a" /* default */])((state, blockName, scope) => { |
|
544 const variations = state.blockVariations[blockName]; |
|
545 |
|
546 if (!variations || !scope) { |
|
547 return variations; |
|
548 } |
|
549 |
|
550 return variations.filter(variation => { |
|
551 // For backward compatibility reasons, variation's scope defaults to |
|
552 // `block` and `inserter` when not set. |
|
553 return (variation.scope || ['block', 'inserter']).includes(scope); |
|
554 }); |
|
555 }, (state, blockName) => [state.blockVariations[blockName]]); |
|
556 /** |
|
557 * Returns the active block variation for a given block based on its attributes. |
|
558 * Variations are determined by their `isActive` property. |
|
559 * Which is either an array of block attribute keys or a function. |
|
560 * |
|
561 * In case of an array of block attribute keys, the `attributes` are compared |
|
562 * to the variation's attributes using strict equality check. |
|
563 * |
|
564 * In case of function type, the function should accept a block's attributes |
|
565 * and the variation's attributes and determines if a variation is active. |
|
566 * A function that accepts a block's attributes and the variation's attributes and determines if a variation is active. |
|
567 * |
|
568 * @param {Object} state Data state. |
|
569 * @param {string} blockName Name of block (example: “core/columns”). |
|
570 * @param {Object} attributes Block attributes used to determine active variation. |
|
571 * @param {WPBlockVariationScope} [scope] Block variation scope name. |
|
572 * |
|
573 * @return {(WPBlockVariation|undefined)} Active block variation. |
|
574 */ |
|
575 |
|
576 function getActiveBlockVariation(state, blockName, attributes, scope) { |
|
577 const variations = getBlockVariations(state, blockName, scope); |
|
578 const match = variations === null || variations === void 0 ? void 0 : variations.find(variation => { |
|
579 var _variation$isActive; |
|
580 |
|
581 if (Array.isArray(variation.isActive)) { |
|
582 const blockType = getBlockType(state, blockName); |
|
583 const attributeKeys = Object.keys(blockType.attributes || {}); |
|
584 const definedAttributes = variation.isActive.filter(attribute => attributeKeys.includes(attribute)); |
|
585 |
|
586 if (definedAttributes.length === 0) { |
|
587 return false; |
|
588 } |
|
589 |
|
590 return definedAttributes.every(attribute => attributes[attribute] === variation.attributes[attribute]); |
|
591 } |
|
592 |
|
593 return (_variation$isActive = variation.isActive) === null || _variation$isActive === void 0 ? void 0 : _variation$isActive.call(variation, attributes, variation.attributes); |
|
594 }); |
|
595 return match; |
|
596 } |
|
597 /** |
|
598 * Returns the default block variation for the given block type. |
|
599 * When there are multiple variations annotated as the default one, |
|
600 * the last added item is picked. This simplifies registering overrides. |
|
601 * When there is no default variation set, it returns the first item. |
|
602 * |
|
603 * @param {Object} state Data state. |
|
604 * @param {string} blockName Block type name. |
|
605 * @param {WPBlockVariationScope} [scope] Block variation scope name. |
|
606 * |
|
607 * @return {?WPBlockVariation} The default block variation. |
|
608 */ |
|
609 |
|
610 function getDefaultBlockVariation(state, blockName, scope) { |
|
611 const variations = getBlockVariations(state, blockName, scope); |
|
612 return Object(external_lodash_["findLast"])(variations, 'isDefault') || Object(external_lodash_["first"])(variations); |
|
613 } |
|
614 /** |
|
615 * Returns all the available categories. |
|
616 * |
|
617 * @param {Object} state Data state. |
|
618 * |
|
619 * @return {WPBlockCategory[]} Categories list. |
|
620 */ |
|
621 |
|
622 function getCategories(state) { |
|
623 return state.categories; |
|
624 } |
|
625 /** |
|
626 * Returns all the available collections. |
|
627 * |
|
628 * @param {Object} state Data state. |
|
629 * |
|
630 * @return {Object} Collections list. |
|
631 */ |
|
632 |
|
633 function getCollections(state) { |
|
634 return state.collections; |
|
635 } |
|
636 /** |
|
637 * Returns the name of the default block name. |
|
638 * |
|
639 * @param {Object} state Data state. |
|
640 * |
|
641 * @return {string?} Default block name. |
|
642 */ |
|
643 |
|
644 function getDefaultBlockName(state) { |
|
645 return state.defaultBlockName; |
|
646 } |
|
647 /** |
|
648 * Returns the name of the block for handling non-block content. |
|
649 * |
|
650 * @param {Object} state Data state. |
|
651 * |
|
652 * @return {string?} Name of the block for handling non-block content. |
|
653 */ |
|
654 |
|
655 function getFreeformFallbackBlockName(state) { |
|
656 return state.freeformFallbackBlockName; |
|
657 } |
|
658 /** |
|
659 * Returns the name of the block for handling unregistered blocks. |
|
660 * |
|
661 * @param {Object} state Data state. |
|
662 * |
|
663 * @return {string?} Name of the block for handling unregistered blocks. |
|
664 */ |
|
665 |
|
666 function getUnregisteredFallbackBlockName(state) { |
|
667 return state.unregisteredFallbackBlockName; |
|
668 } |
|
669 /** |
|
670 * Returns the name of the block for handling unregistered blocks. |
|
671 * |
|
672 * @param {Object} state Data state. |
|
673 * |
|
674 * @return {string?} Name of the block for handling unregistered blocks. |
|
675 */ |
|
676 |
|
677 function getGroupingBlockName(state) { |
|
678 return state.groupingBlockName; |
|
679 } |
|
680 /** |
|
681 * Returns an array with the child blocks of a given block. |
|
682 * |
|
683 * @param {Object} state Data state. |
|
684 * @param {string} blockName Block type name. |
|
685 * |
|
686 * @return {Array} Array of child block names. |
|
687 */ |
|
688 |
|
689 const getChildBlockNames = Object(rememo["a" /* default */])((state, blockName) => { |
|
690 return Object(external_lodash_["map"])(Object(external_lodash_["filter"])(state.blockTypes, blockType => { |
|
691 return Object(external_lodash_["includes"])(blockType.parent, blockName); |
|
692 }), ({ |
|
693 name |
|
694 }) => name); |
|
695 }, state => [state.blockTypes]); |
|
696 /** |
|
697 * Returns the block support value for a feature, if defined. |
|
698 * |
|
699 * @param {Object} state Data state. |
|
700 * @param {(string|Object)} nameOrType Block name or type object |
|
701 * @param {string} feature Feature to retrieve |
|
702 * @param {*} defaultSupports Default value to return if not |
|
703 * explicitly defined |
|
704 * |
|
705 * @return {?*} Block support value |
|
706 */ |
|
707 |
|
708 const getBlockSupport = (state, nameOrType, feature, defaultSupports) => { |
|
709 const blockType = getNormalizedBlockType(state, nameOrType); |
|
710 return Object(external_lodash_["get"])(blockType, ['supports', ...feature.split('.')], defaultSupports); |
|
711 }; |
|
712 /** |
|
713 * Returns true if the block defines support for a feature, or false otherwise. |
|
714 * |
|
715 * @param {Object} state Data state. |
|
716 * @param {(string|Object)} nameOrType Block name or type object. |
|
717 * @param {string} feature Feature to test. |
|
718 * @param {boolean} defaultSupports Whether feature is supported by |
|
719 * default if not explicitly defined. |
|
720 * |
|
721 * @return {boolean} Whether block supports feature. |
|
722 */ |
|
723 |
|
724 function hasBlockSupport(state, nameOrType, feature, defaultSupports) { |
|
725 return !!getBlockSupport(state, nameOrType, feature, defaultSupports); |
|
726 } |
|
727 /** |
|
728 * Returns true if the block type by the given name or object value matches a |
|
729 * search term, or false otherwise. |
|
730 * |
|
731 * @param {Object} state Blocks state. |
|
732 * @param {(string|Object)} nameOrType Block name or type object. |
|
733 * @param {string} searchTerm Search term by which to filter. |
|
734 * |
|
735 * @return {Object[]} Whether block type matches search term. |
|
736 */ |
|
737 |
|
738 function isMatchingSearchTerm(state, nameOrType, searchTerm) { |
|
739 const blockType = getNormalizedBlockType(state, nameOrType); |
|
740 const getNormalizedSearchTerm = Object(external_lodash_["flow"])([// Disregard diacritics. |
|
741 // Input: "média" |
|
742 external_lodash_["deburr"], // Lowercase. |
|
743 // Input: "MEDIA" |
|
744 term => term.toLowerCase(), // Strip leading and trailing whitespace. |
|
745 // Input: " media " |
|
746 term => term.trim()]); |
|
747 const normalizedSearchTerm = getNormalizedSearchTerm(searchTerm); |
|
748 const isSearchMatch = Object(external_lodash_["flow"])([getNormalizedSearchTerm, normalizedCandidate => Object(external_lodash_["includes"])(normalizedCandidate, normalizedSearchTerm)]); |
|
749 return isSearchMatch(blockType.title) || Object(external_lodash_["some"])(blockType.keywords, isSearchMatch) || isSearchMatch(blockType.category); |
|
750 } |
|
751 /** |
|
752 * Returns a boolean indicating if a block has child blocks or not. |
|
753 * |
|
754 * @param {Object} state Data state. |
|
755 * @param {string} blockName Block type name. |
|
756 * |
|
757 * @return {boolean} True if a block contains child blocks and false otherwise. |
|
758 */ |
|
759 |
|
760 const hasChildBlocks = (state, blockName) => { |
|
761 return getChildBlockNames(state, blockName).length > 0; |
|
762 }; |
|
763 /** |
|
764 * Returns a boolean indicating if a block has at least one child block with inserter support. |
|
765 * |
|
766 * @param {Object} state Data state. |
|
767 * @param {string} blockName Block type name. |
|
768 * |
|
769 * @return {boolean} True if a block contains at least one child blocks with inserter support |
|
770 * and false otherwise. |
|
771 */ |
|
772 |
|
773 const hasChildBlocksWithInserterSupport = (state, blockName) => { |
|
774 return Object(external_lodash_["some"])(getChildBlockNames(state, blockName), childBlockName => { |
|
775 return hasBlockSupport(state, childBlockName, 'inserter', true); |
|
776 }); |
|
777 }; |
|
778 |
|
779 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/actions.js |
|
780 /** |
|
781 * External dependencies |
|
782 */ |
|
783 |
|
784 /** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */ |
|
785 |
|
786 /** |
|
787 * Returns an action object used in signalling that block types have been added. |
|
788 * |
|
789 * @param {Array|Object} blockTypes Block types received. |
|
790 * |
|
791 * @return {Object} Action object. |
|
792 */ |
|
793 |
|
794 function addBlockTypes(blockTypes) { |
|
795 return { |
|
796 type: 'ADD_BLOCK_TYPES', |
|
797 blockTypes: Object(external_lodash_["castArray"])(blockTypes) |
|
798 }; |
|
799 } |
|
800 /** |
|
801 * Returns an action object used to remove a registered block type. |
|
802 * |
|
803 * @param {string|Array} names Block name. |
|
804 * |
|
805 * @return {Object} Action object. |
|
806 */ |
|
807 |
|
808 function removeBlockTypes(names) { |
|
809 return { |
|
810 type: 'REMOVE_BLOCK_TYPES', |
|
811 names: Object(external_lodash_["castArray"])(names) |
|
812 }; |
|
813 } |
|
814 /** |
|
815 * Returns an action object used in signalling that new block styles have been added. |
|
816 * |
|
817 * @param {string} blockName Block name. |
|
818 * @param {Array|Object} styles Block styles. |
|
819 * |
|
820 * @return {Object} Action object. |
|
821 */ |
|
822 |
|
823 function addBlockStyles(blockName, styles) { |
|
824 return { |
|
825 type: 'ADD_BLOCK_STYLES', |
|
826 styles: Object(external_lodash_["castArray"])(styles), |
|
827 blockName |
|
828 }; |
|
829 } |
|
830 /** |
|
831 * Returns an action object used in signalling that block styles have been removed. |
|
832 * |
|
833 * @param {string} blockName Block name. |
|
834 * @param {Array|string} styleNames Block style names. |
|
835 * |
|
836 * @return {Object} Action object. |
|
837 */ |
|
838 |
|
839 function removeBlockStyles(blockName, styleNames) { |
|
840 return { |
|
841 type: 'REMOVE_BLOCK_STYLES', |
|
842 styleNames: Object(external_lodash_["castArray"])(styleNames), |
|
843 blockName |
|
844 }; |
|
845 } |
|
846 /** |
|
847 * Returns an action object used in signalling that new block variations have been added. |
|
848 * |
|
849 * @param {string} blockName Block name. |
|
850 * @param {WPBlockVariation|WPBlockVariation[]} variations Block variations. |
|
851 * |
|
852 * @return {Object} Action object. |
|
853 */ |
|
854 |
|
855 function addBlockVariations(blockName, variations) { |
|
856 return { |
|
857 type: 'ADD_BLOCK_VARIATIONS', |
|
858 variations: Object(external_lodash_["castArray"])(variations), |
|
859 blockName |
|
860 }; |
|
861 } |
|
862 /** |
|
863 * Returns an action object used in signalling that block variations have been removed. |
|
864 * |
|
865 * @param {string} blockName Block name. |
|
866 * @param {string|string[]} variationNames Block variation names. |
|
867 * |
|
868 * @return {Object} Action object. |
|
869 */ |
|
870 |
|
871 function removeBlockVariations(blockName, variationNames) { |
|
872 return { |
|
873 type: 'REMOVE_BLOCK_VARIATIONS', |
|
874 variationNames: Object(external_lodash_["castArray"])(variationNames), |
|
875 blockName |
|
876 }; |
|
877 } |
|
878 /** |
|
879 * Returns an action object used to set the default block name. |
|
880 * |
|
881 * @param {string} name Block name. |
|
882 * |
|
883 * @return {Object} Action object. |
|
884 */ |
|
885 |
|
886 function setDefaultBlockName(name) { |
|
887 return { |
|
888 type: 'SET_DEFAULT_BLOCK_NAME', |
|
889 name |
|
890 }; |
|
891 } |
|
892 /** |
|
893 * Returns an action object used to set the name of the block used as a fallback |
|
894 * for non-block content. |
|
895 * |
|
896 * @param {string} name Block name. |
|
897 * |
|
898 * @return {Object} Action object. |
|
899 */ |
|
900 |
|
901 function setFreeformFallbackBlockName(name) { |
|
902 return { |
|
903 type: 'SET_FREEFORM_FALLBACK_BLOCK_NAME', |
|
904 name |
|
905 }; |
|
906 } |
|
907 /** |
|
908 * Returns an action object used to set the name of the block used as a fallback |
|
909 * for unregistered blocks. |
|
910 * |
|
911 * @param {string} name Block name. |
|
912 * |
|
913 * @return {Object} Action object. |
|
914 */ |
|
915 |
|
916 function setUnregisteredFallbackBlockName(name) { |
|
917 return { |
|
918 type: 'SET_UNREGISTERED_FALLBACK_BLOCK_NAME', |
|
919 name |
|
920 }; |
|
921 } |
|
922 /** |
|
923 * Returns an action object used to set the name of the block used |
|
924 * when grouping other blocks |
|
925 * eg: in "Group/Ungroup" interactions |
|
926 * |
|
927 * @param {string} name Block name. |
|
928 * |
|
929 * @return {Object} Action object. |
|
930 */ |
|
931 |
|
932 function setGroupingBlockName(name) { |
|
933 return { |
|
934 type: 'SET_GROUPING_BLOCK_NAME', |
|
935 name |
|
936 }; |
|
937 } |
|
938 /** |
|
939 * Returns an action object used to set block categories. |
|
940 * |
|
941 * @param {Object[]} categories Block categories. |
|
942 * |
|
943 * @return {Object} Action object. |
|
944 */ |
|
945 |
|
946 function setCategories(categories) { |
|
947 return { |
|
948 type: 'SET_CATEGORIES', |
|
949 categories |
|
950 }; |
|
951 } |
|
952 /** |
|
953 * Returns an action object used to update a category. |
|
954 * |
|
955 * @param {string} slug Block category slug. |
|
956 * @param {Object} category Object containing the category properties that should be updated. |
|
957 * |
|
958 * @return {Object} Action object. |
|
959 */ |
|
960 |
|
961 function updateCategory(slug, category) { |
|
962 return { |
|
963 type: 'UPDATE_CATEGORY', |
|
964 slug, |
|
965 category |
|
966 }; |
|
967 } |
|
968 /** |
|
969 * Returns an action object used to add block collections |
|
970 * |
|
971 * @param {string} namespace The namespace of the blocks to put in the collection |
|
972 * @param {string} title The title to display in the block inserter |
|
973 * @param {Object} icon (optional) The icon to display in the block inserter |
|
974 * |
|
975 * @return {Object} Action object. |
|
976 */ |
|
977 |
|
978 function addBlockCollection(namespace, title, icon) { |
|
979 return { |
|
980 type: 'ADD_BLOCK_COLLECTION', |
|
981 namespace, |
|
982 title, |
|
983 icon |
|
984 }; |
|
985 } |
|
986 /** |
|
987 * Returns an action object used to remove block collections |
|
988 * |
|
989 * @param {string} namespace The namespace of the blocks to put in the collection |
|
990 * |
|
991 * @return {Object} Action object. |
|
992 */ |
|
993 |
|
994 function removeBlockCollection(namespace) { |
|
995 return { |
|
996 type: 'REMOVE_BLOCK_COLLECTION', |
|
997 namespace |
|
998 }; |
|
999 } |
|
1000 |
|
1001 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/constants.js |
|
1002 const STORE_NAME = 'core/blocks'; |
|
1003 |
|
1004 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/index.js |
|
1005 /** |
|
1006 * WordPress dependencies |
|
1007 */ |
|
1008 |
|
1009 /** |
|
1010 * Internal dependencies |
|
1011 */ |
|
1012 |
|
1013 |
|
1014 |
|
1015 |
|
1016 |
|
1017 /** |
|
1018 * Store definition for the blocks namespace. |
|
1019 * |
|
1020 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore |
|
1021 * |
|
1022 * @type {Object} |
|
1023 */ |
|
1024 |
|
1025 const store = Object(external_wp_data_["createReduxStore"])(STORE_NAME, { |
|
1026 reducer: reducer, |
|
1027 selectors: selectors_namespaceObject, |
|
1028 actions: actions_namespaceObject |
|
1029 }); |
|
1030 Object(external_wp_data_["register"])(store); |
|
1031 |
|
1032 // EXTERNAL MODULE: ./node_modules/uuid/dist/esm-browser/v4.js + 4 modules |
|
1033 var v4 = __webpack_require__("7Cbv"); |
|
1034 |
|
1035 // EXTERNAL MODULE: external ["wp","hooks"] |
|
1036 var external_wp_hooks_ = __webpack_require__("g56x"); |
|
1037 |
|
1038 // EXTERNAL MODULE: external ["wp","deprecated"] |
|
1039 var external_wp_deprecated_ = __webpack_require__("NMb1"); |
|
1040 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_); |
|
1041 |
|
1042 // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/block-default.js |
|
1043 var block_default = __webpack_require__("//Lo"); |
|
1044 |
|
1045 // EXTERNAL MODULE: ./node_modules/tinycolor2/tinycolor.js |
|
1046 var tinycolor = __webpack_require__("Zss7"); |
|
1047 var tinycolor_default = /*#__PURE__*/__webpack_require__.n(tinycolor); |
|
1048 |
|
1049 // EXTERNAL MODULE: external ["wp","element"] |
|
1050 var external_wp_element_ = __webpack_require__("GRId"); |
|
1051 |
|
1052 // EXTERNAL MODULE: external ["wp","dom"] |
|
1053 var external_wp_dom_ = __webpack_require__("1CF3"); |
|
1054 |
|
1055 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/utils.js |
|
1056 /** |
|
1057 * External dependencies |
|
1058 */ |
|
1059 |
|
1060 |
|
1061 /** |
|
1062 * WordPress dependencies |
|
1063 */ |
|
1064 |
|
1065 |
|
1066 |
|
1067 |
|
1068 /** |
|
1069 * Internal dependencies |
|
1070 */ |
|
1071 |
|
1072 |
|
1073 |
|
1074 /** |
|
1075 * Array of icon colors containing a color to be used if the icon color |
|
1076 * was not explicitly set but the icon background color was. |
|
1077 * |
|
1078 * @type {Object} |
|
1079 */ |
|
1080 |
|
1081 const ICON_COLORS = ['#191e23', '#f8f9f9']; |
|
1082 /** |
|
1083 * Determines whether the block is a default block |
|
1084 * and its attributes are equal to the default attributes |
|
1085 * which means the block is unmodified. |
|
1086 * |
|
1087 * @param {WPBlock} block Block Object |
|
1088 * |
|
1089 * @return {boolean} Whether the block is an unmodified default block |
|
1090 */ |
|
1091 |
|
1092 function isUnmodifiedDefaultBlock(block) { |
|
1093 const defaultBlockName = registration_getDefaultBlockName(); |
|
1094 |
|
1095 if (block.name !== defaultBlockName) { |
|
1096 return false; |
|
1097 } // Cache a created default block if no cache exists or the default block |
|
1098 // name changed. |
|
1099 |
|
1100 |
|
1101 if (!isUnmodifiedDefaultBlock.block || isUnmodifiedDefaultBlock.block.name !== defaultBlockName) { |
|
1102 isUnmodifiedDefaultBlock.block = createBlock(defaultBlockName); |
|
1103 } |
|
1104 |
|
1105 const newDefaultBlock = isUnmodifiedDefaultBlock.block; |
|
1106 const blockType = registration_getBlockType(defaultBlockName); |
|
1107 return Object(external_lodash_["every"])(blockType.attributes, (value, key) => newDefaultBlock.attributes[key] === block.attributes[key]); |
|
1108 } |
|
1109 /** |
|
1110 * Function that checks if the parameter is a valid icon. |
|
1111 * |
|
1112 * @param {*} icon Parameter to be checked. |
|
1113 * |
|
1114 * @return {boolean} True if the parameter is a valid icon and false otherwise. |
|
1115 */ |
|
1116 |
|
1117 function isValidIcon(icon) { |
|
1118 return !!icon && (Object(external_lodash_["isString"])(icon) || Object(external_wp_element_["isValidElement"])(icon) || Object(external_lodash_["isFunction"])(icon) || icon instanceof external_wp_element_["Component"]); |
|
1119 } |
|
1120 /** |
|
1121 * Function that receives an icon as set by the blocks during the registration |
|
1122 * and returns a new icon object that is normalized so we can rely on just on possible icon structure |
|
1123 * in the codebase. |
|
1124 * |
|
1125 * @param {WPBlockTypeIconRender} icon Render behavior of a block type icon; |
|
1126 * one of a Dashicon slug, an element, or a |
|
1127 * component. |
|
1128 * |
|
1129 * @return {WPBlockTypeIconDescriptor} Object describing the icon. |
|
1130 */ |
|
1131 |
|
1132 function normalizeIconObject(icon) { |
|
1133 if (isValidIcon(icon)) { |
|
1134 return { |
|
1135 src: icon |
|
1136 }; |
|
1137 } |
|
1138 |
|
1139 if (Object(external_lodash_["has"])(icon, ['background'])) { |
|
1140 const tinyBgColor = tinycolor_default()(icon.background); |
|
1141 return { ...icon, |
|
1142 foreground: icon.foreground ? icon.foreground : Object(tinycolor["mostReadable"])(tinyBgColor, ICON_COLORS, { |
|
1143 includeFallbackColors: true, |
|
1144 level: 'AA', |
|
1145 size: 'large' |
|
1146 }).toHexString(), |
|
1147 shadowColor: tinyBgColor.setAlpha(0.3).toRgbString() |
|
1148 }; |
|
1149 } |
|
1150 |
|
1151 return icon; |
|
1152 } |
|
1153 /** |
|
1154 * Normalizes block type passed as param. When string is passed then |
|
1155 * it converts it to the matching block type object. |
|
1156 * It passes the original object otherwise. |
|
1157 * |
|
1158 * @param {string|Object} blockTypeOrName Block type or name. |
|
1159 * |
|
1160 * @return {?Object} Block type. |
|
1161 */ |
|
1162 |
|
1163 function normalizeBlockType(blockTypeOrName) { |
|
1164 if (Object(external_lodash_["isString"])(blockTypeOrName)) { |
|
1165 return registration_getBlockType(blockTypeOrName); |
|
1166 } |
|
1167 |
|
1168 return blockTypeOrName; |
|
1169 } |
|
1170 /** |
|
1171 * Get the label for the block, usually this is either the block title, |
|
1172 * or the value of the block's `label` function when that's specified. |
|
1173 * |
|
1174 * @param {Object} blockType The block type. |
|
1175 * @param {Object} attributes The values of the block's attributes. |
|
1176 * @param {Object} context The intended use for the label. |
|
1177 * |
|
1178 * @return {string} The block label. |
|
1179 */ |
|
1180 |
|
1181 function getBlockLabel(blockType, attributes, context = 'visual') { |
|
1182 const { |
|
1183 __experimentalLabel: getLabel, |
|
1184 title |
|
1185 } = blockType; |
|
1186 const label = getLabel && getLabel(attributes, { |
|
1187 context |
|
1188 }); |
|
1189 |
|
1190 if (!label) { |
|
1191 return title; |
|
1192 } // Strip any HTML (i.e. RichText formatting) before returning. |
|
1193 |
|
1194 |
|
1195 return Object(external_wp_dom_["__unstableStripHTML"])(label); |
|
1196 } |
|
1197 /** |
|
1198 * Get a label for the block for use by screenreaders, this is more descriptive |
|
1199 * than the visual label and includes the block title and the value of the |
|
1200 * `getLabel` function if it's specified. |
|
1201 * |
|
1202 * @param {Object} blockType The block type. |
|
1203 * @param {Object} attributes The values of the block's attributes. |
|
1204 * @param {?number} position The position of the block in the block list. |
|
1205 * @param {string} [direction='vertical'] The direction of the block layout. |
|
1206 * |
|
1207 * @return {string} The block label. |
|
1208 */ |
|
1209 |
|
1210 function getAccessibleBlockLabel(blockType, attributes, position, direction = 'vertical') { |
|
1211 // `title` is already localized, `label` is a user-supplied value. |
|
1212 const { |
|
1213 title |
|
1214 } = blockType; |
|
1215 const label = getBlockLabel(blockType, attributes, 'accessibility'); |
|
1216 const hasPosition = position !== undefined; // getBlockLabel returns the block title as a fallback when there's no label, |
|
1217 // if it did return the title, this function needs to avoid adding the |
|
1218 // title twice within the accessible label. Use this `hasLabel` boolean to |
|
1219 // handle that. |
|
1220 |
|
1221 const hasLabel = label && label !== title; |
|
1222 |
|
1223 if (hasPosition && direction === 'vertical') { |
|
1224 if (hasLabel) { |
|
1225 return Object(external_wp_i18n_["sprintf"])( |
|
1226 /* translators: accessibility text. 1: The block title. 2: The block row number. 3: The block label.. */ |
|
1227 Object(external_wp_i18n_["__"])('%1$s Block. Row %2$d. %3$s'), title, position, label); |
|
1228 } |
|
1229 |
|
1230 return Object(external_wp_i18n_["sprintf"])( |
|
1231 /* translators: accessibility text. 1: The block title. 2: The block row number. */ |
|
1232 Object(external_wp_i18n_["__"])('%1$s Block. Row %2$d'), title, position); |
|
1233 } else if (hasPosition && direction === 'horizontal') { |
|
1234 if (hasLabel) { |
|
1235 return Object(external_wp_i18n_["sprintf"])( |
|
1236 /* translators: accessibility text. 1: The block title. 2: The block column number. 3: The block label.. */ |
|
1237 Object(external_wp_i18n_["__"])('%1$s Block. Column %2$d. %3$s'), title, position, label); |
|
1238 } |
|
1239 |
|
1240 return Object(external_wp_i18n_["sprintf"])( |
|
1241 /* translators: accessibility text. 1: The block title. 2: The block column number. */ |
|
1242 Object(external_wp_i18n_["__"])('%1$s Block. Column %2$d'), title, position); |
|
1243 } |
|
1244 |
|
1245 if (hasLabel) { |
|
1246 return Object(external_wp_i18n_["sprintf"])( |
|
1247 /* translators: accessibility text. %1: The block title. %2: The block label. */ |
|
1248 Object(external_wp_i18n_["__"])('%1$s Block. %2$s'), title, label); |
|
1249 } |
|
1250 |
|
1251 return Object(external_wp_i18n_["sprintf"])( |
|
1252 /* translators: accessibility text. %s: The block title. */ |
|
1253 Object(external_wp_i18n_["__"])('%s Block'), title); |
|
1254 } |
|
1255 /** |
|
1256 * Ensure attributes contains only values defined by block type, and merge |
|
1257 * default values for missing attributes. |
|
1258 * |
|
1259 * @param {string} name The block's name. |
|
1260 * @param {Object} attributes The block's attributes. |
|
1261 * @return {Object} The sanitized attributes. |
|
1262 */ |
|
1263 |
|
1264 function __experimentalSanitizeBlockAttributes(name, attributes) { |
|
1265 // Get the type definition associated with a registered block. |
|
1266 const blockType = registration_getBlockType(name); |
|
1267 |
|
1268 if (undefined === blockType) { |
|
1269 throw new Error(`Block type '${name}' is not registered.`); |
|
1270 } |
|
1271 |
|
1272 return Object(external_lodash_["reduce"])(blockType.attributes, (accumulator, schema, key) => { |
|
1273 const value = attributes[key]; |
|
1274 |
|
1275 if (undefined !== value) { |
|
1276 accumulator[key] = value; |
|
1277 } else if (schema.hasOwnProperty('default')) { |
|
1278 accumulator[key] = schema.default; |
|
1279 } |
|
1280 |
|
1281 if (['node', 'children'].indexOf(schema.source) !== -1) { |
|
1282 // Ensure value passed is always an array, which we're expecting in |
|
1283 // the RichText component to handle the deprecated value. |
|
1284 if (typeof accumulator[key] === 'string') { |
|
1285 accumulator[key] = [accumulator[key]]; |
|
1286 } else if (!Array.isArray(accumulator[key])) { |
|
1287 accumulator[key] = []; |
|
1288 } |
|
1289 } |
|
1290 |
|
1291 return accumulator; |
|
1292 }, {}); |
|
1293 } |
|
1294 /** |
|
1295 * Filter block attributes by `role` and return their names. |
|
1296 * |
|
1297 * @param {string} name Block attribute's name. |
|
1298 * @param {string} role The role of a block attribute. |
|
1299 * |
|
1300 * @return {string[]} The attribute names that have the provided role. |
|
1301 */ |
|
1302 |
|
1303 function __experimentalGetBlockAttributesNamesByRole(name, role) { |
|
1304 var _getBlockType; |
|
1305 |
|
1306 const attributes = (_getBlockType = registration_getBlockType(name)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.attributes; |
|
1307 if (!attributes) return []; |
|
1308 const attributesNames = Object.keys(attributes); |
|
1309 if (!role) return attributesNames; |
|
1310 return attributesNames.filter(attributeName => { |
|
1311 var _attributes$attribute; |
|
1312 |
|
1313 return ((_attributes$attribute = attributes[attributeName]) === null || _attributes$attribute === void 0 ? void 0 : _attributes$attribute.__experimentalRole) === role; |
|
1314 }); |
|
1315 } |
|
1316 |
|
1317 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/constants.js |
|
1318 /** |
|
1319 * Array of valid keys in a block type settings deprecation object. |
|
1320 * |
|
1321 * @type {string[]} |
|
1322 */ |
|
1323 const DEPRECATED_ENTRY_KEYS = ['attributes', 'supports', 'save', 'migrate', 'isEligible', 'apiVersion']; |
|
1324 const __EXPERIMENTAL_STYLE_PROPERTY = { |
|
1325 //kept for back-compatibility purposes. |
|
1326 '--wp--style--color--link': { |
|
1327 value: ['color', 'link'], |
|
1328 support: ['color', 'link'] |
|
1329 }, |
|
1330 background: { |
|
1331 value: ['color', 'gradient'], |
|
1332 support: ['color', 'gradients'] |
|
1333 }, |
|
1334 backgroundColor: { |
|
1335 value: ['color', 'background'], |
|
1336 support: ['color'] |
|
1337 }, |
|
1338 borderColor: { |
|
1339 value: ['border', 'color'], |
|
1340 support: ['__experimentalBorder', 'color'] |
|
1341 }, |
|
1342 borderRadius: { |
|
1343 value: ['border', 'radius'], |
|
1344 support: ['__experimentalBorder', 'radius'] |
|
1345 }, |
|
1346 borderStyle: { |
|
1347 value: ['border', 'style'], |
|
1348 support: ['__experimentalBorder', 'style'] |
|
1349 }, |
|
1350 borderWidth: { |
|
1351 value: ['border', 'width'], |
|
1352 support: ['__experimentalBorder', 'width'] |
|
1353 }, |
|
1354 color: { |
|
1355 value: ['color', 'text'], |
|
1356 support: ['color'] |
|
1357 }, |
|
1358 linkColor: { |
|
1359 value: ['elements', 'link', 'color', 'text'], |
|
1360 support: ['color', 'link'] |
|
1361 }, |
|
1362 fontFamily: { |
|
1363 value: ['typography', 'fontFamily'], |
|
1364 support: ['typography', '__experimentalFontFamily'] |
|
1365 }, |
|
1366 fontSize: { |
|
1367 value: ['typography', 'fontSize'], |
|
1368 support: ['typography', 'fontSize'] |
|
1369 }, |
|
1370 fontStyle: { |
|
1371 value: ['typography', 'fontStyle'], |
|
1372 support: ['typography', '__experimentalFontStyle'] |
|
1373 }, |
|
1374 fontWeight: { |
|
1375 value: ['typography', 'fontWeight'], |
|
1376 support: ['typography', '__experimentalFontWeight'] |
|
1377 }, |
|
1378 lineHeight: { |
|
1379 value: ['typography', 'lineHeight'], |
|
1380 support: ['typography', 'lineHeight'] |
|
1381 }, |
|
1382 margin: { |
|
1383 value: ['spacing', 'margin'], |
|
1384 support: ['spacing', 'margin'], |
|
1385 properties: ['top', 'right', 'bottom', 'left'] |
|
1386 }, |
|
1387 padding: { |
|
1388 value: ['spacing', 'padding'], |
|
1389 support: ['spacing', 'padding'], |
|
1390 properties: ['top', 'right', 'bottom', 'left'] |
|
1391 }, |
|
1392 textDecoration: { |
|
1393 value: ['typography', 'textDecoration'], |
|
1394 support: ['typography', '__experimentalTextDecoration'] |
|
1395 }, |
|
1396 textTransform: { |
|
1397 value: ['typography', 'textTransform'], |
|
1398 support: ['typography', '__experimentalTextTransform'] |
|
1399 } |
|
1400 }; |
|
1401 const __EXPERIMENTAL_ELEMENTS = { |
|
1402 link: 'a', |
|
1403 h1: 'h1', |
|
1404 h2: 'h2', |
|
1405 h3: 'h3', |
|
1406 h4: 'h4', |
|
1407 h5: 'h5', |
|
1408 h6: 'h6' |
|
1409 }; |
|
1410 |
|
1411 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/registration.js |
|
1412 /* eslint no-console: [ 'error', { allow: [ 'error', 'warn' ] } ] */ |
|
1413 |
|
1414 /** |
|
1415 * External dependencies |
|
1416 */ |
|
1417 |
|
1418 /** |
|
1419 * WordPress dependencies |
|
1420 */ |
|
1421 |
|
1422 |
|
1423 |
|
1424 |
|
1425 |
|
1426 |
|
1427 /** |
|
1428 * Internal dependencies |
|
1429 */ |
|
1430 |
|
1431 const i18nBlockSchema = { |
|
1432 title: "block title", |
|
1433 description: "block description", |
|
1434 keywords: ["block keyword"], |
|
1435 styles: [{ |
|
1436 label: "block style label" |
|
1437 }], |
|
1438 variations: [{ |
|
1439 title: "block variation title", |
|
1440 description: "block variation description", |
|
1441 keywords: ["block variation keyword"] |
|
1442 }] |
|
1443 }; |
|
1444 |
|
1445 |
|
1446 |
|
1447 /** |
|
1448 * An icon type definition. One of a Dashicon slug, an element, |
|
1449 * or a component. |
|
1450 * |
|
1451 * @typedef {(string|WPElement|WPComponent)} WPIcon |
|
1452 * |
|
1453 * @see https://developer.wordpress.org/resource/dashicons/ |
|
1454 */ |
|
1455 |
|
1456 /** |
|
1457 * Render behavior of a block type icon; one of a Dashicon slug, an element, |
|
1458 * or a component. |
|
1459 * |
|
1460 * @typedef {WPIcon} WPBlockTypeIconRender |
|
1461 */ |
|
1462 |
|
1463 /** |
|
1464 * An object describing a normalized block type icon. |
|
1465 * |
|
1466 * @typedef {Object} WPBlockTypeIconDescriptor |
|
1467 * |
|
1468 * @property {WPBlockTypeIconRender} src Render behavior of the icon, |
|
1469 * one of a Dashicon slug, an |
|
1470 * element, or a component. |
|
1471 * @property {string} background Optimal background hex string |
|
1472 * color when displaying icon. |
|
1473 * @property {string} foreground Optimal foreground hex string |
|
1474 * color when displaying icon. |
|
1475 * @property {string} shadowColor Optimal shadow hex string |
|
1476 * color when displaying icon. |
|
1477 */ |
|
1478 |
|
1479 /** |
|
1480 * Value to use to render the icon for a block type in an editor interface, |
|
1481 * either a Dashicon slug, an element, a component, or an object describing |
|
1482 * the icon. |
|
1483 * |
|
1484 * @typedef {(WPBlockTypeIconDescriptor|WPBlockTypeIconRender)} WPBlockTypeIcon |
|
1485 */ |
|
1486 |
|
1487 /** |
|
1488 * Named block variation scopes. |
|
1489 * |
|
1490 * @typedef {'block'|'inserter'|'transform'} WPBlockVariationScope |
|
1491 */ |
|
1492 |
|
1493 /** |
|
1494 * An object describing a variation defined for the block type. |
|
1495 * |
|
1496 * @typedef {Object} WPBlockVariation |
|
1497 * |
|
1498 * @property {string} name The unique and machine-readable name. |
|
1499 * @property {string} title A human-readable variation title. |
|
1500 * @property {string} [description] A detailed variation description. |
|
1501 * @property {string} [category] Block type category classification, |
|
1502 * used in search interfaces to arrange |
|
1503 * block types by category. |
|
1504 * @property {WPIcon} [icon] An icon helping to visualize the variation. |
|
1505 * @property {boolean} [isDefault] Indicates whether the current variation is |
|
1506 * the default one. Defaults to `false`. |
|
1507 * @property {Object} [attributes] Values which override block attributes. |
|
1508 * @property {Array[]} [innerBlocks] Initial configuration of nested blocks. |
|
1509 * @property {Object} [example] Example provides structured data for |
|
1510 * the block preview. You can set to |
|
1511 * `undefined` to disable the preview shown |
|
1512 * for the block type. |
|
1513 * @property {WPBlockVariationScope[]} [scope] The list of scopes where the variation |
|
1514 * is applicable. When not provided, it |
|
1515 * assumes all available scopes. |
|
1516 * @property {string[]} [keywords] An array of terms (which can be translated) |
|
1517 * that help users discover the variation |
|
1518 * while searching. |
|
1519 * @property {Function|string[]} [isActive] This can be a function or an array of block attributes. |
|
1520 * Function that accepts a block's attributes and the |
|
1521 * variation's attributes and determines if a variation is active. |
|
1522 * This function doesn't try to find a match dynamically based |
|
1523 * on all block's attributes, as in many cases some attributes are irrelevant. |
|
1524 * An example would be for `embed` block where we only care |
|
1525 * about `providerNameSlug` attribute's value. |
|
1526 * We can also use a `string[]` to tell which attributes |
|
1527 * should be compared as a shorthand. Each attributes will |
|
1528 * be matched and the variation will be active if all of them are matching. |
|
1529 */ |
|
1530 |
|
1531 /** |
|
1532 * Defined behavior of a block type. |
|
1533 * |
|
1534 * @typedef {Object} WPBlock |
|
1535 * |
|
1536 * @property {string} name Block type's namespaced name. |
|
1537 * @property {string} title Human-readable block type label. |
|
1538 * @property {string} [description] A detailed block type description. |
|
1539 * @property {string} [category] Block type category classification, |
|
1540 * used in search interfaces to arrange |
|
1541 * block types by category. |
|
1542 * @property {WPBlockTypeIcon} [icon] Block type icon. |
|
1543 * @property {string[]} [keywords] Additional keywords to produce block |
|
1544 * type as result in search interfaces. |
|
1545 * @property {Object} [attributes] Block type attributes. |
|
1546 * @property {WPComponent} [save] Optional component describing |
|
1547 * serialized markup structure of a |
|
1548 * block type. |
|
1549 * @property {WPComponent} edit Component rendering an element to |
|
1550 * manipulate the attributes of a block |
|
1551 * in the context of an editor. |
|
1552 * @property {WPBlockVariation[]} [variations] The list of block variations. |
|
1553 * @property {Object} [example] Example provides structured data for |
|
1554 * the block preview. When not defined |
|
1555 * then no preview is shown. |
|
1556 */ |
|
1557 |
|
1558 /** |
|
1559 * Mapping of legacy category slugs to their latest normal values, used to |
|
1560 * accommodate updates of the default set of block categories. |
|
1561 * |
|
1562 * @type {Record<string,string>} |
|
1563 */ |
|
1564 |
|
1565 const LEGACY_CATEGORY_MAPPING = { |
|
1566 common: 'text', |
|
1567 formatting: 'text', |
|
1568 layout: 'design' |
|
1569 }; |
|
1570 const serverSideBlockDefinitions = {}; |
|
1571 /** |
|
1572 * Sets the server side block definition of blocks. |
|
1573 * |
|
1574 * @param {Object} definitions Server-side block definitions |
|
1575 */ |
|
1576 // eslint-disable-next-line camelcase |
|
1577 |
|
1578 function unstable__bootstrapServerSideBlockDefinitions(definitions) { |
|
1579 for (const blockName of Object.keys(definitions)) { |
|
1580 // Don't overwrite if already set. It covers the case when metadata |
|
1581 // was initialized from the server. |
|
1582 if (serverSideBlockDefinitions[blockName]) { |
|
1583 // We still need to polyfill `apiVersion` for WordPress version |
|
1584 // lower than 5.7. If it isn't present in the definition shared |
|
1585 // from the server, we try to fallback to the definition passed. |
|
1586 // @see https://github.com/WordPress/gutenberg/pull/29279 |
|
1587 if (serverSideBlockDefinitions[blockName].apiVersion === undefined && definitions[blockName].apiVersion) { |
|
1588 serverSideBlockDefinitions[blockName].apiVersion = definitions[blockName].apiVersion; |
|
1589 } |
|
1590 |
|
1591 continue; |
|
1592 } |
|
1593 |
|
1594 serverSideBlockDefinitions[blockName] = Object(external_lodash_["mapKeys"])(Object(external_lodash_["pickBy"])(definitions[blockName], value => !Object(external_lodash_["isNil"])(value)), (value, key) => Object(external_lodash_["camelCase"])(key)); |
|
1595 } |
|
1596 } |
|
1597 /** |
|
1598 * Gets block settings from metadata loaded from `block.json` file. |
|
1599 * |
|
1600 * @param {Object} metadata Block metadata loaded from `block.json`. |
|
1601 * @param {string} metadata.textdomain Textdomain to use with translations. |
|
1602 * |
|
1603 * @return {Object} Block settings. |
|
1604 */ |
|
1605 |
|
1606 function getBlockSettingsFromMetadata({ |
|
1607 textdomain, |
|
1608 ...metadata |
|
1609 }) { |
|
1610 const allowedFields = ['apiVersion', 'title', 'category', 'parent', 'icon', 'description', 'keywords', 'attributes', 'providesContext', 'usesContext', 'supports', 'styles', 'example', 'variations']; |
|
1611 const settings = Object(external_lodash_["pick"])(metadata, allowedFields); |
|
1612 |
|
1613 if (textdomain) { |
|
1614 Object.keys(i18nBlockSchema).forEach(key => { |
|
1615 if (!settings[key]) { |
|
1616 return; |
|
1617 } |
|
1618 |
|
1619 settings[key] = translateBlockSettingUsingI18nSchema(i18nBlockSchema[key], settings[key], textdomain); |
|
1620 }); |
|
1621 } |
|
1622 |
|
1623 return settings; |
|
1624 } |
|
1625 /** |
|
1626 * Registers a new block provided a unique name and an object defining its |
|
1627 * behavior. Once registered, the block is made available as an option to any |
|
1628 * editor interface where blocks are implemented. |
|
1629 * |
|
1630 * @param {string|Object} blockNameOrMetadata Block type name or its metadata. |
|
1631 * @param {Object} settings Block settings. |
|
1632 * |
|
1633 * @return {?WPBlock} The block, if it has been successfully registered; |
|
1634 * otherwise `undefined`. |
|
1635 */ |
|
1636 |
|
1637 |
|
1638 function registerBlockType(blockNameOrMetadata, settings) { |
|
1639 const name = Object(external_lodash_["isObject"])(blockNameOrMetadata) ? blockNameOrMetadata.name : blockNameOrMetadata; |
|
1640 |
|
1641 if (typeof name !== 'string') { |
|
1642 console.error('Block names must be strings.'); |
|
1643 return; |
|
1644 } |
|
1645 |
|
1646 if (Object(external_lodash_["isObject"])(blockNameOrMetadata)) { |
|
1647 unstable__bootstrapServerSideBlockDefinitions({ |
|
1648 [name]: getBlockSettingsFromMetadata(blockNameOrMetadata) |
|
1649 }); |
|
1650 } |
|
1651 |
|
1652 settings = { |
|
1653 name, |
|
1654 icon: block_default["a" /* default */], |
|
1655 keywords: [], |
|
1656 attributes: {}, |
|
1657 providesContext: {}, |
|
1658 usesContext: [], |
|
1659 supports: {}, |
|
1660 styles: [], |
|
1661 save: () => null, |
|
1662 ...(serverSideBlockDefinitions === null || serverSideBlockDefinitions === void 0 ? void 0 : serverSideBlockDefinitions[name]), |
|
1663 ...settings |
|
1664 }; |
|
1665 |
|
1666 if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(name)) { |
|
1667 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'); |
|
1668 return; |
|
1669 } |
|
1670 |
|
1671 if (Object(external_wp_data_["select"])(store).getBlockType(name)) { |
|
1672 console.error('Block "' + name + '" is already registered.'); |
|
1673 return; |
|
1674 } |
|
1675 |
|
1676 const preFilterSettings = { ...settings |
|
1677 }; |
|
1678 settings = Object(external_wp_hooks_["applyFilters"])('blocks.registerBlockType', settings, name); |
|
1679 |
|
1680 if (settings.deprecated) { |
|
1681 settings.deprecated = settings.deprecated.map(deprecation => Object(external_lodash_["pick"])( // Only keep valid deprecation keys. |
|
1682 Object(external_wp_hooks_["applyFilters"])('blocks.registerBlockType', // Merge deprecation keys with pre-filter settings |
|
1683 // so that filters that depend on specific keys being |
|
1684 // present don't fail. |
|
1685 { // Omit deprecation keys here so that deprecations |
|
1686 // can opt out of specific keys like "supports". |
|
1687 ...Object(external_lodash_["omit"])(preFilterSettings, DEPRECATED_ENTRY_KEYS), |
|
1688 ...deprecation |
|
1689 }, name), DEPRECATED_ENTRY_KEYS)); |
|
1690 } |
|
1691 |
|
1692 if (!Object(external_lodash_["isPlainObject"])(settings)) { |
|
1693 console.error('Block settings must be a valid object.'); |
|
1694 return; |
|
1695 } |
|
1696 |
|
1697 if (!Object(external_lodash_["isFunction"])(settings.save)) { |
|
1698 console.error('The "save" property must be a valid function.'); |
|
1699 return; |
|
1700 } |
|
1701 |
|
1702 if ('edit' in settings && !Object(external_lodash_["isFunction"])(settings.edit)) { |
|
1703 console.error('The "edit" property must be a valid function.'); |
|
1704 return; |
|
1705 } // Canonicalize legacy categories to equivalent fallback. |
|
1706 |
|
1707 |
|
1708 if (LEGACY_CATEGORY_MAPPING.hasOwnProperty(settings.category)) { |
|
1709 settings.category = LEGACY_CATEGORY_MAPPING[settings.category]; |
|
1710 } |
|
1711 |
|
1712 if ('category' in settings && !Object(external_lodash_["some"])(Object(external_wp_data_["select"])(store).getCategories(), { |
|
1713 slug: settings.category |
|
1714 })) { |
|
1715 console.warn('The block "' + name + '" is registered with an invalid category "' + settings.category + '".'); |
|
1716 delete settings.category; |
|
1717 } |
|
1718 |
|
1719 if (!('title' in settings) || settings.title === '') { |
|
1720 console.error('The block "' + name + '" must have a title.'); |
|
1721 return; |
|
1722 } |
|
1723 |
|
1724 if (typeof settings.title !== 'string') { |
|
1725 console.error('Block titles must be strings.'); |
|
1726 return; |
|
1727 } |
|
1728 |
|
1729 settings.icon = normalizeIconObject(settings.icon); |
|
1730 |
|
1731 if (!isValidIcon(settings.icon.src)) { |
|
1732 console.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'); |
|
1733 return; |
|
1734 } |
|
1735 |
|
1736 Object(external_wp_data_["dispatch"])(store).addBlockTypes(settings); |
|
1737 return settings; |
|
1738 } |
|
1739 /** |
|
1740 * Translates block settings provided with metadata using the i18n schema. |
|
1741 * |
|
1742 * @param {string|string[]|Object[]} i18nSchema I18n schema for the block setting. |
|
1743 * @param {string|string[]|Object[]} settingValue Value for the block setting. |
|
1744 * @param {string} textdomain Textdomain to use with translations. |
|
1745 * |
|
1746 * @return {string|string[]|Object[]} Translated setting. |
|
1747 */ |
|
1748 |
|
1749 function translateBlockSettingUsingI18nSchema(i18nSchema, settingValue, textdomain) { |
|
1750 if (Object(external_lodash_["isString"])(i18nSchema) && Object(external_lodash_["isString"])(settingValue)) { |
|
1751 // eslint-disable-next-line @wordpress/i18n-no-variables, @wordpress/i18n-text-domain |
|
1752 return Object(external_wp_i18n_["_x"])(settingValue, i18nSchema, textdomain); |
|
1753 } |
|
1754 |
|
1755 if (Object(external_lodash_["isArray"])(i18nSchema) && !Object(external_lodash_["isEmpty"])(i18nSchema) && Object(external_lodash_["isArray"])(settingValue)) { |
|
1756 return settingValue.map(value => translateBlockSettingUsingI18nSchema(i18nSchema[0], value, textdomain)); |
|
1757 } |
|
1758 |
|
1759 if (Object(external_lodash_["isObject"])(i18nSchema) && !Object(external_lodash_["isEmpty"])(i18nSchema) && Object(external_lodash_["isObject"])(settingValue)) { |
|
1760 return Object.keys(settingValue).reduce((accumulator, key) => { |
|
1761 if (!i18nSchema[key]) { |
|
1762 accumulator[key] = settingValue[key]; |
|
1763 return accumulator; |
|
1764 } |
|
1765 |
|
1766 accumulator[key] = translateBlockSettingUsingI18nSchema(i18nSchema[key], settingValue[key], textdomain); |
|
1767 return accumulator; |
|
1768 }, {}); |
|
1769 } |
|
1770 |
|
1771 return settingValue; |
|
1772 } |
|
1773 /** |
|
1774 * Registers a new block provided from metadata stored in `block.json` file. |
|
1775 * |
|
1776 * @deprecated Use `registerBlockType` instead. |
|
1777 * |
|
1778 * @param {Object} metadata Block metadata loaded from `block.json`. |
|
1779 * @param {Object} additionalSettings Additional block settings. |
|
1780 * |
|
1781 * @return {?WPBlock} The block, if it has been successfully registered; |
|
1782 * otherwise `undefined`. |
|
1783 */ |
|
1784 |
|
1785 |
|
1786 function registerBlockTypeFromMetadata(metadata, additionalSettings) { |
|
1787 external_wp_deprecated_default()('wp.blocks.registerBlockTypeFromMetadata', { |
|
1788 since: '10.7', |
|
1789 plugin: 'Gutenberg', |
|
1790 alternative: 'wp.blocks.registerBlockType', |
|
1791 version: '11.0' |
|
1792 }); |
|
1793 return registerBlockType(metadata, additionalSettings); |
|
1794 } |
|
1795 /** |
|
1796 * Registers a new block collection to group blocks in the same namespace in the inserter. |
|
1797 * |
|
1798 * @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace. |
|
1799 * @param {Object} settings The block collection settings. |
|
1800 * @param {string} settings.title The title to display in the block inserter. |
|
1801 * @param {Object} [settings.icon] The icon to display in the block inserter. |
|
1802 */ |
|
1803 |
|
1804 function registerBlockCollection(namespace, { |
|
1805 title, |
|
1806 icon |
|
1807 }) { |
|
1808 Object(external_wp_data_["dispatch"])(store).addBlockCollection(namespace, title, icon); |
|
1809 } |
|
1810 /** |
|
1811 * Unregisters a block collection |
|
1812 * |
|
1813 * @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace |
|
1814 * |
|
1815 */ |
|
1816 |
|
1817 function unregisterBlockCollection(namespace) { |
|
1818 Object(external_wp_data_["dispatch"])(store).removeBlockCollection(namespace); |
|
1819 } |
|
1820 /** |
|
1821 * Unregisters a block. |
|
1822 * |
|
1823 * @param {string} name Block name. |
|
1824 * |
|
1825 * @return {?WPBlock} The previous block value, if it has been successfully |
|
1826 * unregistered; otherwise `undefined`. |
|
1827 */ |
|
1828 |
|
1829 function unregisterBlockType(name) { |
|
1830 const oldBlock = Object(external_wp_data_["select"])(store).getBlockType(name); |
|
1831 |
|
1832 if (!oldBlock) { |
|
1833 console.error('Block "' + name + '" is not registered.'); |
|
1834 return; |
|
1835 } |
|
1836 |
|
1837 Object(external_wp_data_["dispatch"])(store).removeBlockTypes(name); |
|
1838 return oldBlock; |
|
1839 } |
|
1840 /** |
|
1841 * Assigns name of block for handling non-block content. |
|
1842 * |
|
1843 * @param {string} blockName Block name. |
|
1844 */ |
|
1845 |
|
1846 function setFreeformContentHandlerName(blockName) { |
|
1847 Object(external_wp_data_["dispatch"])(store).setFreeformFallbackBlockName(blockName); |
|
1848 } |
|
1849 /** |
|
1850 * Retrieves name of block handling non-block content, or undefined if no |
|
1851 * handler has been defined. |
|
1852 * |
|
1853 * @return {?string} Block name. |
|
1854 */ |
|
1855 |
|
1856 function getFreeformContentHandlerName() { |
|
1857 return Object(external_wp_data_["select"])(store).getFreeformFallbackBlockName(); |
|
1858 } |
|
1859 /** |
|
1860 * Retrieves name of block used for handling grouping interactions. |
|
1861 * |
|
1862 * @return {?string} Block name. |
|
1863 */ |
|
1864 |
|
1865 function registration_getGroupingBlockName() { |
|
1866 return Object(external_wp_data_["select"])(store).getGroupingBlockName(); |
|
1867 } |
|
1868 /** |
|
1869 * Assigns name of block handling unregistered block types. |
|
1870 * |
|
1871 * @param {string} blockName Block name. |
|
1872 */ |
|
1873 |
|
1874 function setUnregisteredTypeHandlerName(blockName) { |
|
1875 Object(external_wp_data_["dispatch"])(store).setUnregisteredFallbackBlockName(blockName); |
|
1876 } |
|
1877 /** |
|
1878 * Retrieves name of block handling unregistered block types, or undefined if no |
|
1879 * handler has been defined. |
|
1880 * |
|
1881 * @return {?string} Block name. |
|
1882 */ |
|
1883 |
|
1884 function getUnregisteredTypeHandlerName() { |
|
1885 return Object(external_wp_data_["select"])(store).getUnregisteredFallbackBlockName(); |
|
1886 } |
|
1887 /** |
|
1888 * Assigns the default block name. |
|
1889 * |
|
1890 * @param {string} name Block name. |
|
1891 */ |
|
1892 |
|
1893 function registration_setDefaultBlockName(name) { |
|
1894 Object(external_wp_data_["dispatch"])(store).setDefaultBlockName(name); |
|
1895 } |
|
1896 /** |
|
1897 * Assigns name of block for handling block grouping interactions. |
|
1898 * |
|
1899 * @param {string} name Block name. |
|
1900 */ |
|
1901 |
|
1902 function registration_setGroupingBlockName(name) { |
|
1903 Object(external_wp_data_["dispatch"])(store).setGroupingBlockName(name); |
|
1904 } |
|
1905 /** |
|
1906 * Retrieves the default block name. |
|
1907 * |
|
1908 * @return {?string} Block name. |
|
1909 */ |
|
1910 |
|
1911 function registration_getDefaultBlockName() { |
|
1912 return Object(external_wp_data_["select"])(store).getDefaultBlockName(); |
|
1913 } |
|
1914 /** |
|
1915 * Returns a registered block type. |
|
1916 * |
|
1917 * @param {string} name Block name. |
|
1918 * |
|
1919 * @return {?Object} Block type. |
|
1920 */ |
|
1921 |
|
1922 function registration_getBlockType(name) { |
|
1923 return Object(external_wp_data_["select"])(store).getBlockType(name); |
|
1924 } |
|
1925 /** |
|
1926 * Returns all registered blocks. |
|
1927 * |
|
1928 * @return {Array} Block settings. |
|
1929 */ |
|
1930 |
|
1931 function registration_getBlockTypes() { |
|
1932 return Object(external_wp_data_["select"])(store).getBlockTypes(); |
|
1933 } |
|
1934 /** |
|
1935 * Returns the block support value for a feature, if defined. |
|
1936 * |
|
1937 * @param {(string|Object)} nameOrType Block name or type object |
|
1938 * @param {string} feature Feature to retrieve |
|
1939 * @param {*} defaultSupports Default value to return if not |
|
1940 * explicitly defined |
|
1941 * |
|
1942 * @return {?*} Block support value |
|
1943 */ |
|
1944 |
|
1945 function registration_getBlockSupport(nameOrType, feature, defaultSupports) { |
|
1946 return Object(external_wp_data_["select"])(store).getBlockSupport(nameOrType, feature, defaultSupports); |
|
1947 } |
|
1948 /** |
|
1949 * Returns true if the block defines support for a feature, or false otherwise. |
|
1950 * |
|
1951 * @param {(string|Object)} nameOrType Block name or type object. |
|
1952 * @param {string} feature Feature to test. |
|
1953 * @param {boolean} defaultSupports Whether feature is supported by |
|
1954 * default if not explicitly defined. |
|
1955 * |
|
1956 * @return {boolean} Whether block supports feature. |
|
1957 */ |
|
1958 |
|
1959 function registration_hasBlockSupport(nameOrType, feature, defaultSupports) { |
|
1960 return Object(external_wp_data_["select"])(store).hasBlockSupport(nameOrType, feature, defaultSupports); |
|
1961 } |
|
1962 /** |
|
1963 * Determines whether or not the given block is a reusable block. This is a |
|
1964 * special block type that is used to point to a global block stored via the |
|
1965 * API. |
|
1966 * |
|
1967 * @param {Object} blockOrType Block or Block Type to test. |
|
1968 * |
|
1969 * @return {boolean} Whether the given block is a reusable block. |
|
1970 */ |
|
1971 |
|
1972 function isReusableBlock(blockOrType) { |
|
1973 return blockOrType.name === 'core/block'; |
|
1974 } |
|
1975 /** |
|
1976 * Determines whether or not the given block is a template part. This is a |
|
1977 * special block type that allows composing a page template out of reusable |
|
1978 * design elements. |
|
1979 * |
|
1980 * @param {Object} blockOrType Block or Block Type to test. |
|
1981 * |
|
1982 * @return {boolean} Whether the given block is a template part. |
|
1983 */ |
|
1984 |
|
1985 function isTemplatePart(blockOrType) { |
|
1986 return blockOrType.name === 'core/template-part'; |
|
1987 } |
|
1988 /** |
|
1989 * Returns an array with the child blocks of a given block. |
|
1990 * |
|
1991 * @param {string} blockName Name of block (example: “latest-posts”). |
|
1992 * |
|
1993 * @return {Array} Array of child block names. |
|
1994 */ |
|
1995 |
|
1996 const registration_getChildBlockNames = blockName => { |
|
1997 return Object(external_wp_data_["select"])(store).getChildBlockNames(blockName); |
|
1998 }; |
|
1999 /** |
|
2000 * Returns a boolean indicating if a block has child blocks or not. |
|
2001 * |
|
2002 * @param {string} blockName Name of block (example: “latest-posts”). |
|
2003 * |
|
2004 * @return {boolean} True if a block contains child blocks and false otherwise. |
|
2005 */ |
|
2006 |
|
2007 const registration_hasChildBlocks = blockName => { |
|
2008 return Object(external_wp_data_["select"])(store).hasChildBlocks(blockName); |
|
2009 }; |
|
2010 /** |
|
2011 * Returns a boolean indicating if a block has at least one child block with inserter support. |
|
2012 * |
|
2013 * @param {string} blockName Block type name. |
|
2014 * |
|
2015 * @return {boolean} True if a block contains at least one child blocks with inserter support |
|
2016 * and false otherwise. |
|
2017 */ |
|
2018 |
|
2019 const registration_hasChildBlocksWithInserterSupport = blockName => { |
|
2020 return Object(external_wp_data_["select"])(store).hasChildBlocksWithInserterSupport(blockName); |
|
2021 }; |
|
2022 /** |
|
2023 * Registers a new block style variation for the given block. |
|
2024 * |
|
2025 * @param {string} blockName Name of block (example: “core/latest-posts”). |
|
2026 * @param {Object} styleVariation Object containing `name` which is the class name applied to the block and `label` which identifies the variation to the user. |
|
2027 */ |
|
2028 |
|
2029 const registerBlockStyle = (blockName, styleVariation) => { |
|
2030 Object(external_wp_data_["dispatch"])(store).addBlockStyles(blockName, styleVariation); |
|
2031 }; |
|
2032 /** |
|
2033 * Unregisters a block style variation for the given block. |
|
2034 * |
|
2035 * @param {string} blockName Name of block (example: “core/latest-posts”). |
|
2036 * @param {string} styleVariationName Name of class applied to the block. |
|
2037 */ |
|
2038 |
|
2039 const unregisterBlockStyle = (blockName, styleVariationName) => { |
|
2040 Object(external_wp_data_["dispatch"])(store).removeBlockStyles(blockName, styleVariationName); |
|
2041 }; |
|
2042 /** |
|
2043 * Returns an array with the variations of a given block type. |
|
2044 * |
|
2045 * @param {string} blockName Name of block (example: “core/columns”). |
|
2046 * @param {WPBlockVariationScope} [scope] Block variation scope name. |
|
2047 * |
|
2048 * @return {(WPBlockVariation[]|void)} Block variations. |
|
2049 */ |
|
2050 |
|
2051 const registration_getBlockVariations = (blockName, scope) => { |
|
2052 return Object(external_wp_data_["select"])(store).getBlockVariations(blockName, scope); |
|
2053 }; |
|
2054 /** |
|
2055 * Registers a new block variation for the given block type. |
|
2056 * |
|
2057 * @param {string} blockName Name of the block (example: “core/columns”). |
|
2058 * @param {WPBlockVariation} variation Object describing a block variation. |
|
2059 */ |
|
2060 |
|
2061 const registerBlockVariation = (blockName, variation) => { |
|
2062 Object(external_wp_data_["dispatch"])(store).addBlockVariations(blockName, variation); |
|
2063 }; |
|
2064 /** |
|
2065 * Unregisters a block variation defined for the given block type. |
|
2066 * |
|
2067 * @param {string} blockName Name of the block (example: “core/columns”). |
|
2068 * @param {string} variationName Name of the variation defined for the block. |
|
2069 */ |
|
2070 |
|
2071 const unregisterBlockVariation = (blockName, variationName) => { |
|
2072 Object(external_wp_data_["dispatch"])(store).removeBlockVariations(blockName, variationName); |
|
2073 }; |
|
2074 |
|
2075 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/factory.js |
|
2076 /** |
|
2077 * External dependencies |
|
2078 */ |
|
2079 |
|
2080 |
|
2081 /** |
|
2082 * WordPress dependencies |
|
2083 */ |
|
2084 |
|
2085 |
|
2086 /** |
|
2087 * Internal dependencies |
|
2088 */ |
|
2089 |
|
2090 |
|
2091 |
|
2092 /** |
|
2093 * Returns a block object given its type and attributes. |
|
2094 * |
|
2095 * @param {string} name Block name. |
|
2096 * @param {Object} attributes Block attributes. |
|
2097 * @param {?Array} innerBlocks Nested blocks. |
|
2098 * |
|
2099 * @return {Object} Block object. |
|
2100 */ |
|
2101 |
|
2102 function createBlock(name, attributes = {}, innerBlocks = []) { |
|
2103 const sanitizedAttributes = __experimentalSanitizeBlockAttributes(name, attributes); |
|
2104 |
|
2105 const clientId = Object(v4["a" /* default */])(); // Blocks are stored with a unique ID, the assigned type name, the block |
|
2106 // attributes, and their inner blocks. |
|
2107 |
|
2108 return { |
|
2109 clientId, |
|
2110 name, |
|
2111 isValid: true, |
|
2112 attributes: sanitizedAttributes, |
|
2113 innerBlocks |
|
2114 }; |
|
2115 } |
|
2116 /** |
|
2117 * Given an array of InnerBlocks templates or Block Objects, |
|
2118 * returns an array of created Blocks from them. |
|
2119 * It handles the case of having InnerBlocks as Blocks by |
|
2120 * converting them to the proper format to continue recursively. |
|
2121 * |
|
2122 * @param {Array} innerBlocksOrTemplate Nested blocks or InnerBlocks templates. |
|
2123 * |
|
2124 * @return {Object[]} Array of Block objects. |
|
2125 */ |
|
2126 |
|
2127 function createBlocksFromInnerBlocksTemplate(innerBlocksOrTemplate = []) { |
|
2128 return innerBlocksOrTemplate.map(innerBlock => { |
|
2129 const innerBlockTemplate = Array.isArray(innerBlock) ? innerBlock : [innerBlock.name, innerBlock.attributes, innerBlock.innerBlocks]; |
|
2130 const [name, attributes, innerBlocks = []] = innerBlockTemplate; |
|
2131 return createBlock(name, attributes, createBlocksFromInnerBlocksTemplate(innerBlocks)); |
|
2132 }); |
|
2133 } |
|
2134 /** |
|
2135 * Given a block object, returns a copy of the block object while sanitizing its attributes, |
|
2136 * optionally merging new attributes and/or replacing its inner blocks. |
|
2137 * |
|
2138 * @param {Object} block Block instance. |
|
2139 * @param {Object} mergeAttributes Block attributes. |
|
2140 * @param {?Array} newInnerBlocks Nested blocks. |
|
2141 * |
|
2142 * @return {Object} A cloned block. |
|
2143 */ |
|
2144 |
|
2145 function __experimentalCloneSanitizedBlock(block, mergeAttributes = {}, newInnerBlocks) { |
|
2146 const clientId = Object(v4["a" /* default */])(); |
|
2147 |
|
2148 const sanitizedAttributes = __experimentalSanitizeBlockAttributes(block.name, { ...block.attributes, |
|
2149 ...mergeAttributes |
|
2150 }); |
|
2151 |
|
2152 return { ...block, |
|
2153 clientId, |
|
2154 attributes: sanitizedAttributes, |
|
2155 innerBlocks: newInnerBlocks || block.innerBlocks.map(innerBlock => __experimentalCloneSanitizedBlock(innerBlock)) |
|
2156 }; |
|
2157 } |
|
2158 /** |
|
2159 * Given a block object, returns a copy of the block object, |
|
2160 * optionally merging new attributes and/or replacing its inner blocks. |
|
2161 * |
|
2162 * @param {Object} block Block instance. |
|
2163 * @param {Object} mergeAttributes Block attributes. |
|
2164 * @param {?Array} newInnerBlocks Nested blocks. |
|
2165 * |
|
2166 * @return {Object} A cloned block. |
|
2167 */ |
|
2168 |
|
2169 function cloneBlock(block, mergeAttributes = {}, newInnerBlocks) { |
|
2170 const clientId = Object(v4["a" /* default */])(); |
|
2171 return { ...block, |
|
2172 clientId, |
|
2173 attributes: { ...block.attributes, |
|
2174 ...mergeAttributes |
|
2175 }, |
|
2176 innerBlocks: newInnerBlocks || block.innerBlocks.map(innerBlock => cloneBlock(innerBlock)) |
|
2177 }; |
|
2178 } |
|
2179 /** |
|
2180 * Returns a boolean indicating whether a transform is possible based on |
|
2181 * various bits of context. |
|
2182 * |
|
2183 * @param {Object} transform The transform object to validate. |
|
2184 * @param {string} direction Is this a 'from' or 'to' transform. |
|
2185 * @param {Array} blocks The blocks to transform from. |
|
2186 * |
|
2187 * @return {boolean} Is the transform possible? |
|
2188 */ |
|
2189 |
|
2190 const isPossibleTransformForSource = (transform, direction, blocks) => { |
|
2191 if (Object(external_lodash_["isEmpty"])(blocks)) { |
|
2192 return false; |
|
2193 } // If multiple blocks are selected, only multi block transforms |
|
2194 // or wildcard transforms are allowed. |
|
2195 |
|
2196 |
|
2197 const isMultiBlock = blocks.length > 1; |
|
2198 const firstBlockName = Object(external_lodash_["first"])(blocks).name; |
|
2199 const isValidForMultiBlocks = isWildcardBlockTransform(transform) || !isMultiBlock || transform.isMultiBlock; |
|
2200 |
|
2201 if (!isValidForMultiBlocks) { |
|
2202 return false; |
|
2203 } // Check non-wildcard transforms to ensure that transform is valid |
|
2204 // for a block selection of multiple blocks of different types |
|
2205 |
|
2206 |
|
2207 if (!isWildcardBlockTransform(transform) && !Object(external_lodash_["every"])(blocks, { |
|
2208 name: firstBlockName |
|
2209 })) { |
|
2210 return false; |
|
2211 } // Only consider 'block' type transforms as valid. |
|
2212 |
|
2213 |
|
2214 const isBlockType = transform.type === 'block'; |
|
2215 |
|
2216 if (!isBlockType) { |
|
2217 return false; |
|
2218 } // Check if the transform's block name matches the source block (or is a wildcard) |
|
2219 // only if this is a transform 'from'. |
|
2220 |
|
2221 |
|
2222 const sourceBlock = Object(external_lodash_["first"])(blocks); |
|
2223 const hasMatchingName = direction !== 'from' || transform.blocks.indexOf(sourceBlock.name) !== -1 || isWildcardBlockTransform(transform); |
|
2224 |
|
2225 if (!hasMatchingName) { |
|
2226 return false; |
|
2227 } // Don't allow single Grouping blocks to be transformed into |
|
2228 // a Grouping block. |
|
2229 |
|
2230 |
|
2231 if (!isMultiBlock && isContainerGroupBlock(sourceBlock.name) && isContainerGroupBlock(transform.blockName)) { |
|
2232 return false; |
|
2233 } // If the transform has a `isMatch` function specified, check that it returns true. |
|
2234 |
|
2235 |
|
2236 if (Object(external_lodash_["isFunction"])(transform.isMatch)) { |
|
2237 const attributes = transform.isMultiBlock ? blocks.map(block => block.attributes) : sourceBlock.attributes; |
|
2238 |
|
2239 if (!transform.isMatch(attributes)) { |
|
2240 return false; |
|
2241 } |
|
2242 } |
|
2243 |
|
2244 if (transform.usingMobileTransformations && isWildcardBlockTransform(transform) && !isContainerGroupBlock(sourceBlock.name)) { |
|
2245 return false; |
|
2246 } |
|
2247 |
|
2248 return true; |
|
2249 }; |
|
2250 /** |
|
2251 * Returns block types that the 'blocks' can be transformed into, based on |
|
2252 * 'from' transforms on other blocks. |
|
2253 * |
|
2254 * @param {Array} blocks The blocks to transform from. |
|
2255 * |
|
2256 * @return {Array} Block types that the blocks can be transformed into. |
|
2257 */ |
|
2258 |
|
2259 |
|
2260 const getBlockTypesForPossibleFromTransforms = blocks => { |
|
2261 if (Object(external_lodash_["isEmpty"])(blocks)) { |
|
2262 return []; |
|
2263 } |
|
2264 |
|
2265 const allBlockTypes = registration_getBlockTypes(); // filter all blocks to find those with a 'from' transform. |
|
2266 |
|
2267 const blockTypesWithPossibleFromTransforms = Object(external_lodash_["filter"])(allBlockTypes, blockType => { |
|
2268 const fromTransforms = getBlockTransforms('from', blockType.name); |
|
2269 return !!findTransform(fromTransforms, transform => { |
|
2270 return isPossibleTransformForSource(transform, 'from', blocks); |
|
2271 }); |
|
2272 }); |
|
2273 return blockTypesWithPossibleFromTransforms; |
|
2274 }; |
|
2275 /** |
|
2276 * Returns block types that the 'blocks' can be transformed into, based on |
|
2277 * the source block's own 'to' transforms. |
|
2278 * |
|
2279 * @param {Array} blocks The blocks to transform from. |
|
2280 * |
|
2281 * @return {Array} Block types that the source can be transformed into. |
|
2282 */ |
|
2283 |
|
2284 |
|
2285 const getBlockTypesForPossibleToTransforms = blocks => { |
|
2286 if (Object(external_lodash_["isEmpty"])(blocks)) { |
|
2287 return []; |
|
2288 } |
|
2289 |
|
2290 const sourceBlock = Object(external_lodash_["first"])(blocks); |
|
2291 const blockType = registration_getBlockType(sourceBlock.name); |
|
2292 const transformsTo = getBlockTransforms('to', blockType.name); // filter all 'to' transforms to find those that are possible. |
|
2293 |
|
2294 const possibleTransforms = Object(external_lodash_["filter"])(transformsTo, transform => { |
|
2295 return transform && isPossibleTransformForSource(transform, 'to', blocks); |
|
2296 }); // Build a list of block names using the possible 'to' transforms. |
|
2297 |
|
2298 const blockNames = Object(external_lodash_["flatMap"])(possibleTransforms, transformation => transformation.blocks); // Map block names to block types. |
|
2299 |
|
2300 return blockNames.map(name => registration_getBlockType(name)); |
|
2301 }; |
|
2302 /** |
|
2303 * Determines whether transform is a "block" type |
|
2304 * and if so whether it is a "wildcard" transform |
|
2305 * ie: targets "any" block type |
|
2306 * |
|
2307 * @param {Object} t the Block transform object |
|
2308 * |
|
2309 * @return {boolean} whether transform is a wildcard transform |
|
2310 */ |
|
2311 |
|
2312 |
|
2313 const isWildcardBlockTransform = t => t && t.type === 'block' && Array.isArray(t.blocks) && t.blocks.includes('*'); |
|
2314 /** |
|
2315 * Determines whether the given Block is the core Block which |
|
2316 * acts as a container Block for other Blocks as part of the |
|
2317 * Grouping mechanics |
|
2318 * |
|
2319 * @param {string} name the name of the Block to test against |
|
2320 * |
|
2321 * @return {boolean} whether or not the Block is the container Block type |
|
2322 */ |
|
2323 |
|
2324 const isContainerGroupBlock = name => name === registration_getGroupingBlockName(); |
|
2325 /** |
|
2326 * Returns an array of block types that the set of blocks received as argument |
|
2327 * can be transformed into. |
|
2328 * |
|
2329 * @param {Array} blocks Blocks array. |
|
2330 * |
|
2331 * @return {Array} Block types that the blocks argument can be transformed to. |
|
2332 */ |
|
2333 |
|
2334 function getPossibleBlockTransformations(blocks) { |
|
2335 if (Object(external_lodash_["isEmpty"])(blocks)) { |
|
2336 return []; |
|
2337 } |
|
2338 |
|
2339 const blockTypesForFromTransforms = getBlockTypesForPossibleFromTransforms(blocks); |
|
2340 const blockTypesForToTransforms = getBlockTypesForPossibleToTransforms(blocks); |
|
2341 return Object(external_lodash_["uniq"])([...blockTypesForFromTransforms, ...blockTypesForToTransforms]); |
|
2342 } |
|
2343 /** |
|
2344 * Given an array of transforms, returns the highest-priority transform where |
|
2345 * the predicate function returns a truthy value. A higher-priority transform |
|
2346 * is one with a lower priority value (i.e. first in priority order). Returns |
|
2347 * null if the transforms set is empty or the predicate function returns a |
|
2348 * falsey value for all entries. |
|
2349 * |
|
2350 * @param {Object[]} transforms Transforms to search. |
|
2351 * @param {Function} predicate Function returning true on matching transform. |
|
2352 * |
|
2353 * @return {?Object} Highest-priority transform candidate. |
|
2354 */ |
|
2355 |
|
2356 function findTransform(transforms, predicate) { |
|
2357 // The hooks library already has built-in mechanisms for managing priority |
|
2358 // queue, so leverage via locally-defined instance. |
|
2359 const hooks = Object(external_wp_hooks_["createHooks"])(); |
|
2360 |
|
2361 for (let i = 0; i < transforms.length; i++) { |
|
2362 const candidate = transforms[i]; |
|
2363 |
|
2364 if (predicate(candidate)) { |
|
2365 hooks.addFilter('transform', 'transform/' + i.toString(), result => result ? result : candidate, candidate.priority); |
|
2366 } |
|
2367 } // Filter name is arbitrarily chosen but consistent with above aggregation. |
|
2368 |
|
2369 |
|
2370 return hooks.applyFilters('transform', null); |
|
2371 } |
|
2372 /** |
|
2373 * Returns normal block transforms for a given transform direction, optionally |
|
2374 * for a specific block by name, or an empty array if there are no transforms. |
|
2375 * If no block name is provided, returns transforms for all blocks. A normal |
|
2376 * transform object includes `blockName` as a property. |
|
2377 * |
|
2378 * @param {string} direction Transform direction ("to", "from"). |
|
2379 * @param {string|Object} blockTypeOrName Block type or name. |
|
2380 * |
|
2381 * @return {Array} Block transforms for direction. |
|
2382 */ |
|
2383 |
|
2384 function getBlockTransforms(direction, blockTypeOrName) { |
|
2385 // When retrieving transforms for all block types, recurse into self. |
|
2386 if (blockTypeOrName === undefined) { |
|
2387 return Object(external_lodash_["flatMap"])(registration_getBlockTypes(), ({ |
|
2388 name |
|
2389 }) => getBlockTransforms(direction, name)); |
|
2390 } // Validate that block type exists and has array of direction. |
|
2391 |
|
2392 |
|
2393 const blockType = normalizeBlockType(blockTypeOrName); |
|
2394 const { |
|
2395 name: blockName, |
|
2396 transforms |
|
2397 } = blockType || {}; |
|
2398 |
|
2399 if (!transforms || !Array.isArray(transforms[direction])) { |
|
2400 return []; |
|
2401 } |
|
2402 |
|
2403 const usingMobileTransformations = transforms.supportedMobileTransforms && Array.isArray(transforms.supportedMobileTransforms); |
|
2404 const filteredTransforms = usingMobileTransformations ? Object(external_lodash_["filter"])(transforms[direction], t => { |
|
2405 if (t.type === 'raw') { |
|
2406 return true; |
|
2407 } |
|
2408 |
|
2409 if (!t.blocks || !t.blocks.length) { |
|
2410 return false; |
|
2411 } |
|
2412 |
|
2413 if (isWildcardBlockTransform(t)) { |
|
2414 return true; |
|
2415 } |
|
2416 |
|
2417 return Object(external_lodash_["every"])(t.blocks, transformBlockName => transforms.supportedMobileTransforms.includes(transformBlockName)); |
|
2418 }) : transforms[direction]; // Map transforms to normal form. |
|
2419 |
|
2420 return filteredTransforms.map(transform => ({ ...transform, |
|
2421 blockName, |
|
2422 usingMobileTransformations |
|
2423 })); |
|
2424 } |
|
2425 /** |
|
2426 * Switch one or more blocks into one or more blocks of the new block type. |
|
2427 * |
|
2428 * @param {Array|Object} blocks Blocks array or block object. |
|
2429 * @param {string} name Block name. |
|
2430 * |
|
2431 * @return {?Array} Array of blocks or null. |
|
2432 */ |
|
2433 |
|
2434 function switchToBlockType(blocks, name) { |
|
2435 const blocksArray = Object(external_lodash_["castArray"])(blocks); |
|
2436 const isMultiBlock = blocksArray.length > 1; |
|
2437 const firstBlock = blocksArray[0]; |
|
2438 const sourceName = firstBlock.name; // Find the right transformation by giving priority to the "to" |
|
2439 // transformation. |
|
2440 |
|
2441 const transformationsFrom = getBlockTransforms('from', name); |
|
2442 const transformationsTo = getBlockTransforms('to', sourceName); |
|
2443 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. |
|
2444 |
|
2445 if (!transformation) { |
|
2446 return null; |
|
2447 } |
|
2448 |
|
2449 let transformationResults; |
|
2450 |
|
2451 if (transformation.isMultiBlock) { |
|
2452 if (Object(external_lodash_["has"])(transformation, '__experimentalConvert')) { |
|
2453 transformationResults = transformation.__experimentalConvert(blocksArray); |
|
2454 } else { |
|
2455 transformationResults = transformation.transform(blocksArray.map(currentBlock => currentBlock.attributes), blocksArray.map(currentBlock => currentBlock.innerBlocks)); |
|
2456 } |
|
2457 } else if (Object(external_lodash_["has"])(transformation, '__experimentalConvert')) { |
|
2458 transformationResults = transformation.__experimentalConvert(firstBlock); |
|
2459 } else { |
|
2460 transformationResults = transformation.transform(firstBlock.attributes, firstBlock.innerBlocks); |
|
2461 } // Ensure that the transformation function returned an object or an array |
|
2462 // of objects. |
|
2463 |
|
2464 |
|
2465 if (!Object(external_lodash_["isObjectLike"])(transformationResults)) { |
|
2466 return null; |
|
2467 } // If the transformation function returned a single object, we want to work |
|
2468 // with an array instead. |
|
2469 |
|
2470 |
|
2471 transformationResults = Object(external_lodash_["castArray"])(transformationResults); // Ensure that every block object returned by the transformation has a |
|
2472 // valid block type. |
|
2473 |
|
2474 if (transformationResults.some(result => !registration_getBlockType(result.name))) { |
|
2475 return null; |
|
2476 } |
|
2477 |
|
2478 const hasSwitchedBlock = Object(external_lodash_["some"])(transformationResults, result => result.name === name); // Ensure that at least one block object returned by the transformation has |
|
2479 // the expected "destination" block type. |
|
2480 |
|
2481 if (!hasSwitchedBlock) { |
|
2482 return null; |
|
2483 } |
|
2484 |
|
2485 const ret = transformationResults.map(result => { |
|
2486 /** |
|
2487 * Filters an individual transform result from block transformation. |
|
2488 * All of the original blocks are passed, since transformations are |
|
2489 * many-to-many, not one-to-one. |
|
2490 * |
|
2491 * @param {Object} transformedBlock The transformed block. |
|
2492 * @param {Object[]} blocks Original blocks transformed. |
|
2493 */ |
|
2494 return Object(external_wp_hooks_["applyFilters"])('blocks.switchToBlockType.transformedBlock', result, blocks); |
|
2495 }); |
|
2496 return ret; |
|
2497 } |
|
2498 /** |
|
2499 * Create a block object from the example API. |
|
2500 * |
|
2501 * @param {string} name |
|
2502 * @param {Object} example |
|
2503 * |
|
2504 * @return {Object} block. |
|
2505 */ |
|
2506 |
|
2507 const getBlockFromExample = (name, example) => { |
|
2508 return createBlock(name, example.attributes, Object(external_lodash_["map"])(example.innerBlocks, innerBlock => getBlockFromExample(innerBlock.name, innerBlock))); |
|
2509 }; |
|
2510 |
|
2511 // CONCATENATED MODULE: ./node_modules/hpq/es/get-path.js |
|
2512 /** |
|
2513 * Given object and string of dot-delimited path segments, returns value at |
|
2514 * path or undefined if path cannot be resolved. |
|
2515 * |
|
2516 * @param {Object} object Lookup object |
|
2517 * @param {string} path Path to resolve |
|
2518 * @return {?*} Resolved value |
|
2519 */ |
|
2520 function getPath(object, path) { |
|
2521 var segments = path.split('.'); |
|
2522 var segment; |
|
2523 |
|
2524 while (segment = segments.shift()) { |
|
2525 if (!(segment in object)) { |
|
2526 return; |
|
2527 } |
|
2528 |
|
2529 object = object[segment]; |
|
2530 } |
|
2531 |
|
2532 return object; |
|
2533 } |
|
2534 // CONCATENATED MODULE: ./node_modules/hpq/es/index.js |
|
2535 /** |
|
2536 * Internal dependencies |
|
2537 */ |
|
2538 |
|
2539 /** |
|
2540 * Function returning a DOM document created by `createHTMLDocument`. The same |
|
2541 * document is returned between invocations. |
|
2542 * |
|
2543 * @return {Document} DOM document. |
|
2544 */ |
|
2545 |
|
2546 var getDocument = function () { |
|
2547 var doc; |
|
2548 return function () { |
|
2549 if (!doc) { |
|
2550 doc = document.implementation.createHTMLDocument(''); |
|
2551 } |
|
2552 |
|
2553 return doc; |
|
2554 }; |
|
2555 }(); |
|
2556 /** |
|
2557 * Given a markup string or DOM element, creates an object aligning with the |
|
2558 * shape of the matchers object, or the value returned by the matcher. |
|
2559 * |
|
2560 * @param {(string|Element)} source Source content |
|
2561 * @param {(Object|Function)} matchers Matcher function or object of matchers |
|
2562 * @return {(Object|*)} Matched value(s), shaped by object |
|
2563 */ |
|
2564 |
|
2565 |
|
2566 function parse(source, matchers) { |
|
2567 if (!matchers) { |
|
2568 return; |
|
2569 } // Coerce to element |
|
2570 |
|
2571 |
|
2572 if ('string' === typeof source) { |
|
2573 var doc = getDocument(); |
|
2574 doc.body.innerHTML = source; |
|
2575 source = doc.body; |
|
2576 } // Return singular value |
|
2577 |
|
2578 |
|
2579 if ('function' === typeof matchers) { |
|
2580 return matchers(source); |
|
2581 } // Bail if we can't handle matchers |
|
2582 |
|
2583 |
|
2584 if (Object !== matchers.constructor) { |
|
2585 return; |
|
2586 } // Shape result by matcher object |
|
2587 |
|
2588 |
|
2589 return Object.keys(matchers).reduce(function (memo, key) { |
|
2590 memo[key] = parse(source, matchers[key]); |
|
2591 return memo; |
|
2592 }, {}); |
|
2593 } |
|
2594 /** |
|
2595 * Generates a function which matches node of type selector, returning an |
|
2596 * attribute by property if the attribute exists. If no selector is passed, |
|
2597 * returns property of the query element. |
|
2598 * |
|
2599 * @param {?string} selector Optional selector |
|
2600 * @param {string} name Property name |
|
2601 * @return {*} Property value |
|
2602 */ |
|
2603 |
|
2604 function prop(selector, name) { |
|
2605 if (1 === arguments.length) { |
|
2606 name = selector; |
|
2607 selector = undefined; |
|
2608 } |
|
2609 |
|
2610 return function (node) { |
|
2611 var match = node; |
|
2612 |
|
2613 if (selector) { |
|
2614 match = node.querySelector(selector); |
|
2615 } |
|
2616 |
|
2617 if (match) { |
|
2618 return getPath(match, name); |
|
2619 } |
|
2620 }; |
|
2621 } |
|
2622 /** |
|
2623 * Generates a function which matches node of type selector, returning an |
|
2624 * attribute by name if the attribute exists. If no selector is passed, |
|
2625 * returns attribute of the query element. |
|
2626 * |
|
2627 * @param {?string} selector Optional selector |
|
2628 * @param {string} name Attribute name |
|
2629 * @return {?string} Attribute value |
|
2630 */ |
|
2631 |
|
2632 function attr(selector, name) { |
|
2633 if (1 === arguments.length) { |
|
2634 name = selector; |
|
2635 selector = undefined; |
|
2636 } |
|
2637 |
|
2638 return function (node) { |
|
2639 var attributes = prop(selector, 'attributes')(node); |
|
2640 |
|
2641 if (attributes && attributes.hasOwnProperty(name)) { |
|
2642 return attributes[name].value; |
|
2643 } |
|
2644 }; |
|
2645 } |
|
2646 /** |
|
2647 * Convenience for `prop( selector, 'innerHTML' )`. |
|
2648 * |
|
2649 * @see prop() |
|
2650 * |
|
2651 * @param {?string} selector Optional selector |
|
2652 * @return {string} Inner HTML |
|
2653 */ |
|
2654 |
|
2655 function es_html(selector) { |
|
2656 return prop(selector, 'innerHTML'); |
|
2657 } |
|
2658 /** |
|
2659 * Convenience for `prop( selector, 'textContent' )`. |
|
2660 * |
|
2661 * @see prop() |
|
2662 * |
|
2663 * @param {?string} selector Optional selector |
|
2664 * @return {string} Text content |
|
2665 */ |
|
2666 |
|
2667 function es_text(selector) { |
|
2668 return prop(selector, 'textContent'); |
|
2669 } |
|
2670 /** |
|
2671 * Creates a new matching context by first finding elements matching selector |
|
2672 * using querySelectorAll before then running another `parse` on `matchers` |
|
2673 * scoped to the matched elements. |
|
2674 * |
|
2675 * @see parse() |
|
2676 * |
|
2677 * @param {string} selector Selector to match |
|
2678 * @param {(Object|Function)} matchers Matcher function or object of matchers |
|
2679 * @return {Array.<*,Object>} Array of matched value(s) |
|
2680 */ |
|
2681 |
|
2682 function query(selector, matchers) { |
|
2683 return function (node) { |
|
2684 var matches = node.querySelectorAll(selector); |
|
2685 return [].map.call(matches, function (match) { |
|
2686 return parse(match, matchers); |
|
2687 }); |
|
2688 }; |
|
2689 } |
|
2690 // EXTERNAL MODULE: external ["wp","autop"] |
|
2691 var external_wp_autop_ = __webpack_require__("UuzZ"); |
|
2692 |
|
2693 // EXTERNAL MODULE: external ["wp","blockSerializationDefaultParser"] |
|
2694 var external_wp_blockSerializationDefaultParser_ = __webpack_require__("ouCq"); |
|
2695 |
|
2696 // CONCATENATED MODULE: ./node_modules/simple-html-tokenizer/dist/es6/index.js |
|
2697 /** |
|
2698 * generated from https://raw.githubusercontent.com/w3c/html/26b5126f96f736f796b9e29718138919dd513744/entities.json |
|
2699 * do not edit |
|
2700 */ |
|
2701 var namedCharRefs = { |
|
2702 Aacute: "Á", aacute: "á", Abreve: "Ă", abreve: "ă", ac: "∾", acd: "∿", acE: "∾̳", Acirc: "Â", acirc: "â", acute: "´", Acy: "А", acy: "а", AElig: "Æ", aelig: "æ", af: "\u2061", Afr: "𝔄", afr: "𝔞", Agrave: "À", agrave: "à", alefsym: "ℵ", aleph: "ℵ", Alpha: "Α", alpha: "α", Amacr: "Ā", amacr: "ā", amalg: "⨿", amp: "&", AMP: "&", andand: "⩕", And: "⩓", and: "∧", andd: "⩜", andslope: "⩘", andv: "⩚", ang: "∠", ange: "⦤", angle: "∠", angmsdaa: "⦨", angmsdab: "⦩", angmsdac: "⦪", angmsdad: "⦫", angmsdae: "⦬", angmsdaf: "⦭", angmsdag: "⦮", angmsdah: "⦯", angmsd: "∡", angrt: "∟", angrtvb: "⊾", angrtvbd: "⦝", angsph: "∢", angst: "Å", angzarr: "⍼", Aogon: "Ą", aogon: "ą", Aopf: "𝔸", aopf: "𝕒", apacir: "⩯", ap: "≈", apE: "⩰", ape: "≊", apid: "≋", apos: "'", ApplyFunction: "\u2061", approx: "≈", approxeq: "≊", Aring: "Å", aring: "å", Ascr: "𝒜", ascr: "𝒶", Assign: "≔", ast: "*", asymp: "≈", asympeq: "≍", Atilde: "Ã", atilde: "ã", Auml: "Ä", auml: "ä", awconint: "∳", awint: "⨑", backcong: "≌", backepsilon: "϶", backprime: "‵", backsim: "∽", backsimeq: "⋍", Backslash: "∖", Barv: "⫧", barvee: "⊽", barwed: "⌅", Barwed: "⌆", barwedge: "⌅", bbrk: "⎵", bbrktbrk: "⎶", bcong: "≌", Bcy: "Б", bcy: "б", bdquo: "„", becaus: "∵", because: "∵", Because: "∵", bemptyv: "⦰", bepsi: "϶", bernou: "ℬ", Bernoullis: "ℬ", Beta: "Β", beta: "β", beth: "ℶ", between: "≬", Bfr: "𝔅", bfr: "𝔟", bigcap: "⋂", bigcirc: "◯", bigcup: "⋃", bigodot: "⨀", bigoplus: "⨁", bigotimes: "⨂", bigsqcup: "⨆", bigstar: "★", bigtriangledown: "▽", bigtriangleup: "△", biguplus: "⨄", bigvee: "⋁", bigwedge: "⋀", bkarow: "⤍", blacklozenge: "⧫", blacksquare: "▪", blacktriangle: "▴", blacktriangledown: "▾", blacktriangleleft: "◂", blacktriangleright: "▸", blank: "␣", blk12: "▒", blk14: "░", blk34: "▓", block: "█", bne: "=⃥", bnequiv: "≡⃥", bNot: "⫭", bnot: "⌐", Bopf: "𝔹", bopf: "𝕓", bot: "⊥", bottom: "⊥", bowtie: "⋈", boxbox: "⧉", boxdl: "┐", boxdL: "╕", boxDl: "╖", boxDL: "╗", boxdr: "┌", boxdR: "╒", boxDr: "╓", boxDR: "╔", boxh: "─", boxH: "═", boxhd: "┬", boxHd: "╤", boxhD: "╥", boxHD: "╦", boxhu: "┴", boxHu: "╧", boxhU: "╨", boxHU: "╩", boxminus: "⊟", boxplus: "⊞", boxtimes: "⊠", boxul: "┘", boxuL: "╛", boxUl: "╜", boxUL: "╝", boxur: "└", boxuR: "╘", boxUr: "╙", boxUR: "╚", boxv: "│", boxV: "║", boxvh: "┼", boxvH: "╪", boxVh: "╫", boxVH: "╬", boxvl: "┤", boxvL: "╡", boxVl: "╢", boxVL: "╣", boxvr: "├", boxvR: "╞", boxVr: "╟", boxVR: "╠", bprime: "‵", breve: "˘", Breve: "˘", brvbar: "¦", bscr: "𝒷", Bscr: "ℬ", bsemi: "⁏", bsim: "∽", bsime: "⋍", bsolb: "⧅", bsol: "\\", bsolhsub: "⟈", bull: "•", bullet: "•", bump: "≎", bumpE: "⪮", bumpe: "≏", Bumpeq: "≎", bumpeq: "≏", Cacute: "Ć", cacute: "ć", capand: "⩄", capbrcup: "⩉", capcap: "⩋", cap: "∩", Cap: "⋒", capcup: "⩇", capdot: "⩀", CapitalDifferentialD: "ⅅ", caps: "∩︀", caret: "⁁", caron: "ˇ", Cayleys: "ℭ", ccaps: "⩍", Ccaron: "Č", ccaron: "č", Ccedil: "Ç", ccedil: "ç", Ccirc: "Ĉ", ccirc: "ĉ", Cconint: "∰", ccups: "⩌", ccupssm: "⩐", Cdot: "Ċ", cdot: "ċ", cedil: "¸", Cedilla: "¸", cemptyv: "⦲", cent: "¢", centerdot: "·", CenterDot: "·", cfr: "𝔠", Cfr: "ℭ", CHcy: "Ч", chcy: "ч", check: "✓", checkmark: "✓", Chi: "Χ", chi: "χ", circ: "ˆ", circeq: "≗", circlearrowleft: "↺", circlearrowright: "↻", circledast: "⊛", circledcirc: "⊚", circleddash: "⊝", CircleDot: "⊙", circledR: "®", circledS: "Ⓢ", CircleMinus: "⊖", CirclePlus: "⊕", CircleTimes: "⊗", cir: "○", cirE: "⧃", cire: "≗", cirfnint: "⨐", cirmid: "⫯", cirscir: "⧂", ClockwiseContourIntegral: "∲", CloseCurlyDoubleQuote: "”", CloseCurlyQuote: "’", clubs: "♣", clubsuit: "♣", colon: ":", Colon: "∷", Colone: "⩴", colone: "≔", coloneq: "≔", comma: ",", commat: "@", comp: "∁", compfn: "∘", complement: "∁", complexes: "ℂ", cong: "≅", congdot: "⩭", Congruent: "≡", conint: "∮", Conint: "∯", ContourIntegral: "∮", copf: "𝕔", Copf: "ℂ", coprod: "∐", Coproduct: "∐", copy: "©", COPY: "©", copysr: "℗", CounterClockwiseContourIntegral: "∳", crarr: "↵", cross: "✗", Cross: "⨯", Cscr: "𝒞", cscr: "𝒸", csub: "⫏", csube: "⫑", csup: "⫐", csupe: "⫒", ctdot: "⋯", cudarrl: "⤸", cudarrr: "⤵", cuepr: "⋞", cuesc: "⋟", cularr: "↶", cularrp: "⤽", cupbrcap: "⩈", cupcap: "⩆", CupCap: "≍", cup: "∪", Cup: "⋓", cupcup: "⩊", cupdot: "⊍", cupor: "⩅", cups: "∪︀", curarr: "↷", curarrm: "⤼", curlyeqprec: "⋞", curlyeqsucc: "⋟", curlyvee: "⋎", curlywedge: "⋏", curren: "¤", curvearrowleft: "↶", curvearrowright: "↷", cuvee: "⋎", cuwed: "⋏", cwconint: "∲", cwint: "∱", cylcty: "⌭", dagger: "†", Dagger: "‡", daleth: "ℸ", darr: "↓", Darr: "↡", dArr: "⇓", dash: "‐", Dashv: "⫤", dashv: "⊣", dbkarow: "⤏", dblac: "˝", Dcaron: "Ď", dcaron: "ď", Dcy: "Д", dcy: "д", ddagger: "‡", ddarr: "⇊", DD: "ⅅ", dd: "ⅆ", DDotrahd: "⤑", ddotseq: "⩷", deg: "°", Del: "∇", Delta: "Δ", delta: "δ", demptyv: "⦱", dfisht: "⥿", Dfr: "𝔇", dfr: "𝔡", dHar: "⥥", dharl: "⇃", dharr: "⇂", DiacriticalAcute: "´", DiacriticalDot: "˙", DiacriticalDoubleAcute: "˝", DiacriticalGrave: "`", DiacriticalTilde: "˜", diam: "⋄", diamond: "⋄", Diamond: "⋄", diamondsuit: "♦", diams: "♦", die: "¨", DifferentialD: "ⅆ", digamma: "ϝ", disin: "⋲", div: "÷", divide: "÷", divideontimes: "⋇", divonx: "⋇", DJcy: "Ђ", djcy: "ђ", dlcorn: "⌞", dlcrop: "⌍", dollar: "$", Dopf: "𝔻", dopf: "𝕕", Dot: "¨", dot: "˙", DotDot: "⃜", doteq: "≐", doteqdot: "≑", DotEqual: "≐", dotminus: "∸", dotplus: "∔", dotsquare: "⊡", doublebarwedge: "⌆", DoubleContourIntegral: "∯", DoubleDot: "¨", DoubleDownArrow: "⇓", DoubleLeftArrow: "⇐", DoubleLeftRightArrow: "⇔", DoubleLeftTee: "⫤", DoubleLongLeftArrow: "⟸", DoubleLongLeftRightArrow: "⟺", DoubleLongRightArrow: "⟹", DoubleRightArrow: "⇒", DoubleRightTee: "⊨", DoubleUpArrow: "⇑", DoubleUpDownArrow: "⇕", DoubleVerticalBar: "∥", DownArrowBar: "⤓", downarrow: "↓", DownArrow: "↓", Downarrow: "⇓", DownArrowUpArrow: "⇵", DownBreve: "̑", downdownarrows: "⇊", downharpoonleft: "⇃", downharpoonright: "⇂", DownLeftRightVector: "⥐", DownLeftTeeVector: "⥞", DownLeftVectorBar: "⥖", DownLeftVector: "↽", DownRightTeeVector: "⥟", DownRightVectorBar: "⥗", DownRightVector: "⇁", DownTeeArrow: "↧", DownTee: "⊤", drbkarow: "⤐", drcorn: "⌟", drcrop: "⌌", Dscr: "𝒟", dscr: "𝒹", DScy: "Ѕ", dscy: "ѕ", dsol: "⧶", Dstrok: "Đ", dstrok: "đ", dtdot: "⋱", dtri: "▿", dtrif: "▾", duarr: "⇵", duhar: "⥯", dwangle: "⦦", DZcy: "Џ", dzcy: "џ", dzigrarr: "⟿", Eacute: "É", eacute: "é", easter: "⩮", Ecaron: "Ě", ecaron: "ě", Ecirc: "Ê", ecirc: "ê", ecir: "≖", ecolon: "≕", Ecy: "Э", ecy: "э", eDDot: "⩷", Edot: "Ė", edot: "ė", eDot: "≑", ee: "ⅇ", efDot: "≒", Efr: "𝔈", efr: "𝔢", eg: "⪚", Egrave: "È", egrave: "è", egs: "⪖", egsdot: "⪘", el: "⪙", Element: "∈", elinters: "⏧", ell: "ℓ", els: "⪕", elsdot: "⪗", Emacr: "Ē", emacr: "ē", empty: "∅", emptyset: "∅", EmptySmallSquare: "◻", emptyv: "∅", EmptyVerySmallSquare: "▫", emsp13: " ", emsp14: " ", emsp: " ", ENG: "Ŋ", eng: "ŋ", ensp: " ", Eogon: "Ę", eogon: "ę", Eopf: "𝔼", eopf: "𝕖", epar: "⋕", eparsl: "⧣", eplus: "⩱", epsi: "ε", Epsilon: "Ε", epsilon: "ε", epsiv: "ϵ", eqcirc: "≖", eqcolon: "≕", eqsim: "≂", eqslantgtr: "⪖", eqslantless: "⪕", Equal: "⩵", equals: "=", EqualTilde: "≂", equest: "≟", Equilibrium: "⇌", equiv: "≡", equivDD: "⩸", eqvparsl: "⧥", erarr: "⥱", erDot: "≓", escr: "ℯ", Escr: "ℰ", esdot: "≐", Esim: "⩳", esim: "≂", Eta: "Η", eta: "η", ETH: "Ð", eth: "ð", Euml: "Ë", euml: "ë", euro: "€", excl: "!", exist: "∃", Exists: "∃", expectation: "ℰ", exponentiale: "ⅇ", ExponentialE: "ⅇ", fallingdotseq: "≒", Fcy: "Ф", fcy: "ф", female: "♀", ffilig: "ffi", fflig: "ff", ffllig: "ffl", Ffr: "𝔉", ffr: "𝔣", filig: "fi", FilledSmallSquare: "◼", FilledVerySmallSquare: "▪", fjlig: "fj", flat: "♭", fllig: "fl", fltns: "▱", fnof: "ƒ", Fopf: "𝔽", fopf: "𝕗", forall: "∀", ForAll: "∀", fork: "⋔", forkv: "⫙", Fouriertrf: "ℱ", fpartint: "⨍", frac12: "½", frac13: "⅓", frac14: "¼", frac15: "⅕", frac16: "⅙", frac18: "⅛", frac23: "⅔", frac25: "⅖", frac34: "¾", frac35: "⅗", frac38: "⅜", frac45: "⅘", frac56: "⅚", frac58: "⅝", frac78: "⅞", frasl: "⁄", frown: "⌢", fscr: "𝒻", Fscr: "ℱ", gacute: "ǵ", Gamma: "Γ", gamma: "γ", Gammad: "Ϝ", gammad: "ϝ", gap: "⪆", Gbreve: "Ğ", gbreve: "ğ", Gcedil: "Ģ", Gcirc: "Ĝ", gcirc: "ĝ", Gcy: "Г", gcy: "г", Gdot: "Ġ", gdot: "ġ", ge: "≥", gE: "≧", gEl: "⪌", gel: "⋛", geq: "≥", geqq: "≧", geqslant: "⩾", gescc: "⪩", ges: "⩾", gesdot: "⪀", gesdoto: "⪂", gesdotol: "⪄", gesl: "⋛︀", gesles: "⪔", Gfr: "𝔊", gfr: "𝔤", gg: "≫", Gg: "⋙", ggg: "⋙", gimel: "ℷ", GJcy: "Ѓ", gjcy: "ѓ", gla: "⪥", gl: "≷", glE: "⪒", glj: "⪤", gnap: "⪊", gnapprox: "⪊", gne: "⪈", gnE: "≩", gneq: "⪈", gneqq: "≩", gnsim: "⋧", Gopf: "𝔾", gopf: "𝕘", grave: "`", GreaterEqual: "≥", GreaterEqualLess: "⋛", GreaterFullEqual: "≧", GreaterGreater: "⪢", GreaterLess: "≷", GreaterSlantEqual: "⩾", GreaterTilde: "≳", Gscr: "𝒢", gscr: "ℊ", gsim: "≳", gsime: "⪎", gsiml: "⪐", gtcc: "⪧", gtcir: "⩺", gt: ">", GT: ">", Gt: "≫", gtdot: "⋗", gtlPar: "⦕", gtquest: "⩼", gtrapprox: "⪆", gtrarr: "⥸", gtrdot: "⋗", gtreqless: "⋛", gtreqqless: "⪌", gtrless: "≷", gtrsim: "≳", gvertneqq: "≩︀", gvnE: "≩︀", Hacek: "ˇ", hairsp: " ", half: "½", hamilt: "ℋ", HARDcy: "Ъ", hardcy: "ъ", harrcir: "⥈", harr: "↔", hArr: "⇔", harrw: "↭", Hat: "^", hbar: "ℏ", Hcirc: "Ĥ", hcirc: "ĥ", hearts: "♥", heartsuit: "♥", hellip: "…", hercon: "⊹", hfr: "𝔥", Hfr: "ℌ", HilbertSpace: "ℋ", hksearow: "⤥", hkswarow: "⤦", hoarr: "⇿", homtht: "∻", hookleftarrow: "↩", hookrightarrow: "↪", hopf: "𝕙", Hopf: "ℍ", horbar: "―", HorizontalLine: "─", hscr: "𝒽", Hscr: "ℋ", hslash: "ℏ", Hstrok: "Ħ", hstrok: "ħ", HumpDownHump: "≎", HumpEqual: "≏", hybull: "⁃", hyphen: "‐", Iacute: "Í", iacute: "í", ic: "\u2063", Icirc: "Î", icirc: "î", Icy: "И", icy: "и", Idot: "İ", IEcy: "Е", iecy: "е", iexcl: "¡", iff: "⇔", ifr: "𝔦", Ifr: "ℑ", Igrave: "Ì", igrave: "ì", ii: "ⅈ", iiiint: "⨌", iiint: "∭", iinfin: "⧜", iiota: "℩", IJlig: "IJ", ijlig: "ij", Imacr: "Ī", imacr: "ī", image: "ℑ", ImaginaryI: "ⅈ", imagline: "ℐ", imagpart: "ℑ", imath: "ı", Im: "ℑ", imof: "⊷", imped: "Ƶ", Implies: "⇒", incare: "℅", in: "∈", infin: "∞", infintie: "⧝", inodot: "ı", intcal: "⊺", int: "∫", Int: "∬", integers: "ℤ", Integral: "∫", intercal: "⊺", Intersection: "⋂", intlarhk: "⨗", intprod: "⨼", InvisibleComma: "\u2063", InvisibleTimes: "\u2062", IOcy: "Ё", iocy: "ё", Iogon: "Į", iogon: "į", Iopf: "𝕀", iopf: "𝕚", Iota: "Ι", iota: "ι", iprod: "⨼", iquest: "¿", iscr: "𝒾", Iscr: "ℐ", isin: "∈", isindot: "⋵", isinE: "⋹", isins: "⋴", isinsv: "⋳", isinv: "∈", it: "\u2062", Itilde: "Ĩ", itilde: "ĩ", Iukcy: "І", iukcy: "і", Iuml: "Ï", iuml: "ï", Jcirc: "Ĵ", jcirc: "ĵ", Jcy: "Й", jcy: "й", Jfr: "𝔍", jfr: "𝔧", jmath: "ȷ", Jopf: "𝕁", jopf: "𝕛", Jscr: "𝒥", jscr: "𝒿", Jsercy: "Ј", jsercy: "ј", Jukcy: "Є", jukcy: "є", Kappa: "Κ", kappa: "κ", kappav: "ϰ", Kcedil: "Ķ", kcedil: "ķ", Kcy: "К", kcy: "к", Kfr: "𝔎", kfr: "𝔨", kgreen: "ĸ", KHcy: "Х", khcy: "х", KJcy: "Ќ", kjcy: "ќ", Kopf: "𝕂", kopf: "𝕜", Kscr: "𝒦", kscr: "𝓀", lAarr: "⇚", Lacute: "Ĺ", lacute: "ĺ", laemptyv: "⦴", lagran: "ℒ", Lambda: "Λ", lambda: "λ", lang: "⟨", Lang: "⟪", langd: "⦑", langle: "⟨", lap: "⪅", Laplacetrf: "ℒ", laquo: "«", larrb: "⇤", larrbfs: "⤟", larr: "←", Larr: "↞", lArr: "⇐", larrfs: "⤝", larrhk: "↩", larrlp: "↫", larrpl: "⤹", larrsim: "⥳", larrtl: "↢", latail: "⤙", lAtail: "⤛", lat: "⪫", late: "⪭", lates: "⪭︀", lbarr: "⤌", lBarr: "⤎", lbbrk: "❲", lbrace: "{", lbrack: "[", lbrke: "⦋", lbrksld: "⦏", lbrkslu: "⦍", Lcaron: "Ľ", lcaron: "ľ", Lcedil: "Ļ", lcedil: "ļ", lceil: "⌈", lcub: "{", Lcy: "Л", lcy: "л", ldca: "⤶", ldquo: "“", ldquor: "„", ldrdhar: "⥧", ldrushar: "⥋", ldsh: "↲", le: "≤", lE: "≦", LeftAngleBracket: "⟨", LeftArrowBar: "⇤", leftarrow: "←", LeftArrow: "←", Leftarrow: "⇐", LeftArrowRightArrow: "⇆", leftarrowtail: "↢", LeftCeiling: "⌈", LeftDoubleBracket: "⟦", LeftDownTeeVector: "⥡", LeftDownVectorBar: "⥙", LeftDownVector: "⇃", LeftFloor: "⌊", leftharpoondown: "↽", leftharpoonup: "↼", leftleftarrows: "⇇", leftrightarrow: "↔", LeftRightArrow: "↔", Leftrightarrow: "⇔", leftrightarrows: "⇆", leftrightharpoons: "⇋", leftrightsquigarrow: "↭", LeftRightVector: "⥎", LeftTeeArrow: "↤", LeftTee: "⊣", LeftTeeVector: "⥚", leftthreetimes: "⋋", LeftTriangleBar: "⧏", LeftTriangle: "⊲", LeftTriangleEqual: "⊴", LeftUpDownVector: "⥑", LeftUpTeeVector: "⥠", LeftUpVectorBar: "⥘", LeftUpVector: "↿", LeftVectorBar: "⥒", LeftVector: "↼", lEg: "⪋", leg: "⋚", leq: "≤", leqq: "≦", leqslant: "⩽", lescc: "⪨", les: "⩽", lesdot: "⩿", lesdoto: "⪁", lesdotor: "⪃", lesg: "⋚︀", lesges: "⪓", lessapprox: "⪅", lessdot: "⋖", lesseqgtr: "⋚", lesseqqgtr: "⪋", LessEqualGreater: "⋚", LessFullEqual: "≦", LessGreater: "≶", lessgtr: "≶", LessLess: "⪡", lesssim: "≲", LessSlantEqual: "⩽", LessTilde: "≲", lfisht: "⥼", lfloor: "⌊", Lfr: "𝔏", lfr: "𝔩", lg: "≶", lgE: "⪑", lHar: "⥢", lhard: "↽", lharu: "↼", lharul: "⥪", lhblk: "▄", LJcy: "Љ", ljcy: "љ", llarr: "⇇", ll: "≪", Ll: "⋘", llcorner: "⌞", Lleftarrow: "⇚", llhard: "⥫", lltri: "◺", Lmidot: "Ŀ", lmidot: "ŀ", lmoustache: "⎰", lmoust: "⎰", lnap: "⪉", lnapprox: "⪉", lne: "⪇", lnE: "≨", lneq: "⪇", lneqq: "≨", lnsim: "⋦", loang: "⟬", loarr: "⇽", lobrk: "⟦", longleftarrow: "⟵", LongLeftArrow: "⟵", Longleftarrow: "⟸", longleftrightarrow: "⟷", LongLeftRightArrow: "⟷", Longleftrightarrow: "⟺", longmapsto: "⟼", longrightarrow: "⟶", LongRightArrow: "⟶", Longrightarrow: "⟹", looparrowleft: "↫", looparrowright: "↬", lopar: "⦅", Lopf: "𝕃", lopf: "𝕝", loplus: "⨭", lotimes: "⨴", lowast: "∗", lowbar: "_", LowerLeftArrow: "↙", LowerRightArrow: "↘", loz: "◊", lozenge: "◊", lozf: "⧫", lpar: "(", lparlt: "⦓", lrarr: "⇆", lrcorner: "⌟", lrhar: "⇋", lrhard: "⥭", lrm: "\u200e", lrtri: "⊿", lsaquo: "‹", lscr: "𝓁", Lscr: "ℒ", lsh: "↰", Lsh: "↰", lsim: "≲", lsime: "⪍", lsimg: "⪏", lsqb: "[", lsquo: "‘", lsquor: "‚", Lstrok: "Ł", lstrok: "ł", ltcc: "⪦", ltcir: "⩹", lt: "<", LT: "<", Lt: "≪", ltdot: "⋖", lthree: "⋋", ltimes: "⋉", ltlarr: "⥶", ltquest: "⩻", ltri: "◃", ltrie: "⊴", ltrif: "◂", ltrPar: "⦖", lurdshar: "⥊", luruhar: "⥦", lvertneqq: "≨︀", lvnE: "≨︀", macr: "¯", male: "♂", malt: "✠", maltese: "✠", Map: "⤅", map: "↦", mapsto: "↦", mapstodown: "↧", mapstoleft: "↤", mapstoup: "↥", marker: "▮", mcomma: "⨩", Mcy: "М", mcy: "м", mdash: "—", mDDot: "∺", measuredangle: "∡", MediumSpace: " ", Mellintrf: "ℳ", Mfr: "𝔐", mfr: "𝔪", mho: "℧", micro: "µ", midast: "*", midcir: "⫰", mid: "∣", middot: "·", minusb: "⊟", minus: "−", minusd: "∸", minusdu: "⨪", MinusPlus: "∓", mlcp: "⫛", mldr: "…", mnplus: "∓", models: "⊧", Mopf: "𝕄", mopf: "𝕞", mp: "∓", mscr: "𝓂", Mscr: "ℳ", mstpos: "∾", Mu: "Μ", mu: "μ", multimap: "⊸", mumap: "⊸", nabla: "∇", Nacute: "Ń", nacute: "ń", nang: "∠⃒", nap: "≉", napE: "⩰̸", napid: "≋̸", napos: "ʼn", napprox: "≉", natural: "♮", naturals: "ℕ", natur: "♮", nbsp: " ", nbump: "≎̸", nbumpe: "≏̸", ncap: "⩃", Ncaron: "Ň", ncaron: "ň", Ncedil: "Ņ", ncedil: "ņ", ncong: "≇", ncongdot: "⩭̸", ncup: "⩂", Ncy: "Н", ncy: "н", ndash: "–", nearhk: "⤤", nearr: "↗", neArr: "⇗", nearrow: "↗", ne: "≠", nedot: "≐̸", NegativeMediumSpace: "", NegativeThickSpace: "", NegativeThinSpace: "", NegativeVeryThinSpace: "", nequiv: "≢", nesear: "⤨", nesim: "≂̸", NestedGreaterGreater: "≫", NestedLessLess: "≪", NewLine: "\u000a", nexist: "∄", nexists: "∄", Nfr: "𝔑", nfr: "𝔫", ngE: "≧̸", nge: "≱", ngeq: "≱", ngeqq: "≧̸", ngeqslant: "⩾̸", nges: "⩾̸", nGg: "⋙̸", ngsim: "≵", nGt: "≫⃒", ngt: "≯", ngtr: "≯", nGtv: "≫̸", nharr: "↮", nhArr: "⇎", nhpar: "⫲", ni: "∋", nis: "⋼", nisd: "⋺", niv: "∋", NJcy: "Њ", njcy: "њ", nlarr: "↚", nlArr: "⇍", nldr: "‥", nlE: "≦̸", nle: "≰", nleftarrow: "↚", nLeftarrow: "⇍", nleftrightarrow: "↮", nLeftrightarrow: "⇎", nleq: "≰", nleqq: "≦̸", nleqslant: "⩽̸", nles: "⩽̸", nless: "≮", nLl: "⋘̸", nlsim: "≴", nLt: "≪⃒", nlt: "≮", nltri: "⋪", nltrie: "⋬", nLtv: "≪̸", nmid: "∤", NoBreak: "\u2060", NonBreakingSpace: " ", nopf: "𝕟", Nopf: "ℕ", Not: "⫬", not: "¬", NotCongruent: "≢", NotCupCap: "≭", NotDoubleVerticalBar: "∦", NotElement: "∉", NotEqual: "≠", NotEqualTilde: "≂̸", NotExists: "∄", NotGreater: "≯", NotGreaterEqual: "≱", NotGreaterFullEqual: "≧̸", NotGreaterGreater: "≫̸", NotGreaterLess: "≹", NotGreaterSlantEqual: "⩾̸", NotGreaterTilde: "≵", NotHumpDownHump: "≎̸", NotHumpEqual: "≏̸", notin: "∉", notindot: "⋵̸", notinE: "⋹̸", notinva: "∉", notinvb: "⋷", notinvc: "⋶", NotLeftTriangleBar: "⧏̸", NotLeftTriangle: "⋪", NotLeftTriangleEqual: "⋬", NotLess: "≮", NotLessEqual: "≰", NotLessGreater: "≸", NotLessLess: "≪̸", NotLessSlantEqual: "⩽̸", NotLessTilde: "≴", NotNestedGreaterGreater: "⪢̸", NotNestedLessLess: "⪡̸", notni: "∌", notniva: "∌", notnivb: "⋾", notnivc: "⋽", NotPrecedes: "⊀", NotPrecedesEqual: "⪯̸", NotPrecedesSlantEqual: "⋠", NotReverseElement: "∌", NotRightTriangleBar: "⧐̸", NotRightTriangle: "⋫", NotRightTriangleEqual: "⋭", NotSquareSubset: "⊏̸", NotSquareSubsetEqual: "⋢", NotSquareSuperset: "⊐̸", NotSquareSupersetEqual: "⋣", NotSubset: "⊂⃒", NotSubsetEqual: "⊈", NotSucceeds: "⊁", NotSucceedsEqual: "⪰̸", NotSucceedsSlantEqual: "⋡", NotSucceedsTilde: "≿̸", NotSuperset: "⊃⃒", NotSupersetEqual: "⊉", NotTilde: "≁", NotTildeEqual: "≄", NotTildeFullEqual: "≇", NotTildeTilde: "≉", NotVerticalBar: "∤", nparallel: "∦", npar: "∦", nparsl: "⫽⃥", npart: "∂̸", npolint: "⨔", npr: "⊀", nprcue: "⋠", nprec: "⊀", npreceq: "⪯̸", npre: "⪯̸", nrarrc: "⤳̸", nrarr: "↛", nrArr: "⇏", nrarrw: "↝̸", nrightarrow: "↛", nRightarrow: "⇏", nrtri: "⋫", nrtrie: "⋭", nsc: "⊁", nsccue: "⋡", nsce: "⪰̸", Nscr: "𝒩", nscr: "𝓃", nshortmid: "∤", nshortparallel: "∦", nsim: "≁", nsime: "≄", nsimeq: "≄", nsmid: "∤", nspar: "∦", nsqsube: "⋢", nsqsupe: "⋣", nsub: "⊄", nsubE: "⫅̸", nsube: "⊈", nsubset: "⊂⃒", nsubseteq: "⊈", nsubseteqq: "⫅̸", nsucc: "⊁", nsucceq: "⪰̸", nsup: "⊅", nsupE: "⫆̸", nsupe: "⊉", nsupset: "⊃⃒", nsupseteq: "⊉", nsupseteqq: "⫆̸", ntgl: "≹", Ntilde: "Ñ", ntilde: "ñ", ntlg: "≸", ntriangleleft: "⋪", ntrianglelefteq: "⋬", ntriangleright: "⋫", ntrianglerighteq: "⋭", Nu: "Ν", nu: "ν", num: "#", numero: "№", numsp: " ", nvap: "≍⃒", nvdash: "⊬", nvDash: "⊭", nVdash: "⊮", nVDash: "⊯", nvge: "≥⃒", nvgt: ">⃒", nvHarr: "⤄", nvinfin: "⧞", nvlArr: "⤂", nvle: "≤⃒", nvlt: "<⃒", nvltrie: "⊴⃒", nvrArr: "⤃", nvrtrie: "⊵⃒", nvsim: "∼⃒", nwarhk: "⤣", nwarr: "↖", nwArr: "⇖", nwarrow: "↖", nwnear: "⤧", Oacute: "Ó", oacute: "ó", oast: "⊛", Ocirc: "Ô", ocirc: "ô", ocir: "⊚", Ocy: "О", ocy: "о", odash: "⊝", Odblac: "Ő", odblac: "ő", odiv: "⨸", odot: "⊙", odsold: "⦼", OElig: "Œ", oelig: "œ", ofcir: "⦿", Ofr: "𝔒", ofr: "𝔬", ogon: "˛", Ograve: "Ò", ograve: "ò", ogt: "⧁", ohbar: "⦵", ohm: "Ω", oint: "∮", olarr: "↺", olcir: "⦾", olcross: "⦻", oline: "‾", olt: "⧀", Omacr: "Ō", omacr: "ō", Omega: "Ω", omega: "ω", Omicron: "Ο", omicron: "ο", omid: "⦶", ominus: "⊖", Oopf: "𝕆", oopf: "𝕠", opar: "⦷", OpenCurlyDoubleQuote: "“", OpenCurlyQuote: "‘", operp: "⦹", oplus: "⊕", orarr: "↻", Or: "⩔", or: "∨", ord: "⩝", order: "ℴ", orderof: "ℴ", ordf: "ª", ordm: "º", origof: "⊶", oror: "⩖", orslope: "⩗", orv: "⩛", oS: "Ⓢ", Oscr: "𝒪", oscr: "ℴ", Oslash: "Ø", oslash: "ø", osol: "⊘", Otilde: "Õ", otilde: "õ", otimesas: "⨶", Otimes: "⨷", otimes: "⊗", Ouml: "Ö", ouml: "ö", ovbar: "⌽", OverBar: "‾", OverBrace: "⏞", OverBracket: "⎴", OverParenthesis: "⏜", para: "¶", parallel: "∥", par: "∥", parsim: "⫳", parsl: "⫽", part: "∂", PartialD: "∂", Pcy: "П", pcy: "п", percnt: "%", period: ".", permil: "‰", perp: "⊥", pertenk: "‱", Pfr: "𝔓", pfr: "𝔭", Phi: "Φ", phi: "φ", phiv: "ϕ", phmmat: "ℳ", phone: "☎", Pi: "Π", pi: "π", pitchfork: "⋔", piv: "ϖ", planck: "ℏ", planckh: "ℎ", plankv: "ℏ", plusacir: "⨣", plusb: "⊞", pluscir: "⨢", plus: "+", plusdo: "∔", plusdu: "⨥", pluse: "⩲", PlusMinus: "±", plusmn: "±", plussim: "⨦", plustwo: "⨧", pm: "±", Poincareplane: "ℌ", pointint: "⨕", popf: "𝕡", Popf: "ℙ", pound: "£", prap: "⪷", Pr: "⪻", pr: "≺", prcue: "≼", precapprox: "⪷", prec: "≺", preccurlyeq: "≼", Precedes: "≺", PrecedesEqual: "⪯", PrecedesSlantEqual: "≼", PrecedesTilde: "≾", preceq: "⪯", precnapprox: "⪹", precneqq: "⪵", precnsim: "⋨", pre: "⪯", prE: "⪳", precsim: "≾", prime: "′", Prime: "″", primes: "ℙ", prnap: "⪹", prnE: "⪵", prnsim: "⋨", prod: "∏", Product: "∏", profalar: "⌮", profline: "⌒", profsurf: "⌓", prop: "∝", Proportional: "∝", Proportion: "∷", propto: "∝", prsim: "≾", prurel: "⊰", Pscr: "𝒫", pscr: "𝓅", Psi: "Ψ", psi: "ψ", puncsp: " ", Qfr: "𝔔", qfr: "𝔮", qint: "⨌", qopf: "𝕢", Qopf: "ℚ", qprime: "⁗", Qscr: "𝒬", qscr: "𝓆", quaternions: "ℍ", quatint: "⨖", quest: "?", questeq: "≟", quot: "\"", QUOT: "\"", rAarr: "⇛", race: "∽̱", Racute: "Ŕ", racute: "ŕ", radic: "√", raemptyv: "⦳", rang: "⟩", Rang: "⟫", rangd: "⦒", range: "⦥", rangle: "⟩", raquo: "»", rarrap: "⥵", rarrb: "⇥", rarrbfs: "⤠", rarrc: "⤳", rarr: "→", Rarr: "↠", rArr: "⇒", rarrfs: "⤞", rarrhk: "↪", rarrlp: "↬", rarrpl: "⥅", rarrsim: "⥴", Rarrtl: "⤖", rarrtl: "↣", rarrw: "↝", ratail: "⤚", rAtail: "⤜", ratio: "∶", rationals: "ℚ", rbarr: "⤍", rBarr: "⤏", RBarr: "⤐", rbbrk: "❳", rbrace: "}", rbrack: "]", rbrke: "⦌", rbrksld: "⦎", rbrkslu: "⦐", Rcaron: "Ř", rcaron: "ř", Rcedil: "Ŗ", rcedil: "ŗ", rceil: "⌉", rcub: "}", Rcy: "Р", rcy: "р", rdca: "⤷", rdldhar: "⥩", rdquo: "”", rdquor: "”", rdsh: "↳", real: "ℜ", realine: "ℛ", realpart: "ℜ", reals: "ℝ", Re: "ℜ", rect: "▭", reg: "®", REG: "®", ReverseElement: "∋", ReverseEquilibrium: "⇋", ReverseUpEquilibrium: "⥯", rfisht: "⥽", rfloor: "⌋", rfr: "𝔯", Rfr: "ℜ", rHar: "⥤", rhard: "⇁", rharu: "⇀", rharul: "⥬", Rho: "Ρ", rho: "ρ", rhov: "ϱ", RightAngleBracket: "⟩", RightArrowBar: "⇥", rightarrow: "→", RightArrow: "→", Rightarrow: "⇒", RightArrowLeftArrow: "⇄", rightarrowtail: "↣", RightCeiling: "⌉", RightDoubleBracket: "⟧", RightDownTeeVector: "⥝", RightDownVectorBar: "⥕", RightDownVector: "⇂", RightFloor: "⌋", rightharpoondown: "⇁", rightharpoonup: "⇀", rightleftarrows: "⇄", rightleftharpoons: "⇌", rightrightarrows: "⇉", rightsquigarrow: "↝", RightTeeArrow: "↦", RightTee: "⊢", RightTeeVector: "⥛", rightthreetimes: "⋌", RightTriangleBar: "⧐", RightTriangle: "⊳", RightTriangleEqual: "⊵", RightUpDownVector: "⥏", RightUpTeeVector: "⥜", RightUpVectorBar: "⥔", RightUpVector: "↾", RightVectorBar: "⥓", RightVector: "⇀", ring: "˚", risingdotseq: "≓", rlarr: "⇄", rlhar: "⇌", rlm: "\u200f", rmoustache: "⎱", rmoust: "⎱", rnmid: "⫮", roang: "⟭", roarr: "⇾", robrk: "⟧", ropar: "⦆", ropf: "𝕣", Ropf: "ℝ", roplus: "⨮", rotimes: "⨵", RoundImplies: "⥰", rpar: ")", rpargt: "⦔", rppolint: "⨒", rrarr: "⇉", Rrightarrow: "⇛", rsaquo: "›", rscr: "𝓇", Rscr: "ℛ", rsh: "↱", Rsh: "↱", rsqb: "]", rsquo: "’", rsquor: "’", rthree: "⋌", rtimes: "⋊", rtri: "▹", rtrie: "⊵", rtrif: "▸", rtriltri: "⧎", RuleDelayed: "⧴", ruluhar: "⥨", rx: "℞", Sacute: "Ś", sacute: "ś", sbquo: "‚", scap: "⪸", Scaron: "Š", scaron: "š", Sc: "⪼", sc: "≻", sccue: "≽", sce: "⪰", scE: "⪴", Scedil: "Ş", scedil: "ş", Scirc: "Ŝ", scirc: "ŝ", scnap: "⪺", scnE: "⪶", scnsim: "⋩", scpolint: "⨓", scsim: "≿", Scy: "С", scy: "с", sdotb: "⊡", sdot: "⋅", sdote: "⩦", searhk: "⤥", searr: "↘", seArr: "⇘", searrow: "↘", sect: "§", semi: ";", seswar: "⤩", setminus: "∖", setmn: "∖", sext: "✶", Sfr: "𝔖", sfr: "𝔰", sfrown: "⌢", sharp: "♯", SHCHcy: "Щ", shchcy: "щ", SHcy: "Ш", shcy: "ш", ShortDownArrow: "↓", ShortLeftArrow: "←", shortmid: "∣", shortparallel: "∥", ShortRightArrow: "→", ShortUpArrow: "↑", shy: "\u00ad", Sigma: "Σ", sigma: "σ", sigmaf: "ς", sigmav: "ς", sim: "∼", simdot: "⩪", sime: "≃", simeq: "≃", simg: "⪞", simgE: "⪠", siml: "⪝", simlE: "⪟", simne: "≆", simplus: "⨤", simrarr: "⥲", slarr: "←", SmallCircle: "∘", smallsetminus: "∖", smashp: "⨳", smeparsl: "⧤", smid: "∣", smile: "⌣", smt: "⪪", smte: "⪬", smtes: "⪬︀", SOFTcy: "Ь", softcy: "ь", solbar: "⌿", solb: "⧄", sol: "/", Sopf: "𝕊", sopf: "𝕤", spades: "♠", spadesuit: "♠", spar: "∥", sqcap: "⊓", sqcaps: "⊓︀", sqcup: "⊔", sqcups: "⊔︀", Sqrt: "√", sqsub: "⊏", sqsube: "⊑", sqsubset: "⊏", sqsubseteq: "⊑", sqsup: "⊐", sqsupe: "⊒", sqsupset: "⊐", sqsupseteq: "⊒", square: "□", Square: "□", SquareIntersection: "⊓", SquareSubset: "⊏", SquareSubsetEqual: "⊑", SquareSuperset: "⊐", SquareSupersetEqual: "⊒", SquareUnion: "⊔", squarf: "▪", squ: "□", squf: "▪", srarr: "→", Sscr: "𝒮", sscr: "𝓈", ssetmn: "∖", ssmile: "⌣", sstarf: "⋆", Star: "⋆", star: "☆", starf: "★", straightepsilon: "ϵ", straightphi: "ϕ", strns: "¯", sub: "⊂", Sub: "⋐", subdot: "⪽", subE: "⫅", sube: "⊆", subedot: "⫃", submult: "⫁", subnE: "⫋", subne: "⊊", subplus: "⪿", subrarr: "⥹", subset: "⊂", Subset: "⋐", subseteq: "⊆", subseteqq: "⫅", SubsetEqual: "⊆", subsetneq: "⊊", subsetneqq: "⫋", subsim: "⫇", subsub: "⫕", subsup: "⫓", succapprox: "⪸", succ: "≻", succcurlyeq: "≽", Succeeds: "≻", SucceedsEqual: "⪰", SucceedsSlantEqual: "≽", SucceedsTilde: "≿", succeq: "⪰", succnapprox: "⪺", succneqq: "⪶", succnsim: "⋩", succsim: "≿", SuchThat: "∋", sum: "∑", Sum: "∑", sung: "♪", sup1: "¹", sup2: "²", sup3: "³", sup: "⊃", Sup: "⋑", supdot: "⪾", supdsub: "⫘", supE: "⫆", supe: "⊇", supedot: "⫄", Superset: "⊃", SupersetEqual: "⊇", suphsol: "⟉", suphsub: "⫗", suplarr: "⥻", supmult: "⫂", supnE: "⫌", supne: "⊋", supplus: "⫀", supset: "⊃", Supset: "⋑", supseteq: "⊇", supseteqq: "⫆", supsetneq: "⊋", supsetneqq: "⫌", supsim: "⫈", supsub: "⫔", supsup: "⫖", swarhk: "⤦", swarr: "↙", swArr: "⇙", swarrow: "↙", swnwar: "⤪", szlig: "ß", Tab: "\u0009", target: "⌖", Tau: "Τ", tau: "τ", tbrk: "⎴", Tcaron: "Ť", tcaron: "ť", Tcedil: "Ţ", tcedil: "ţ", Tcy: "Т", tcy: "т", tdot: "⃛", telrec: "⌕", Tfr: "𝔗", tfr: "𝔱", there4: "∴", therefore: "∴", Therefore: "∴", Theta: "Θ", theta: "θ", thetasym: "ϑ", thetav: "ϑ", thickapprox: "≈", thicksim: "∼", ThickSpace: " ", ThinSpace: " ", thinsp: " ", thkap: "≈", thksim: "∼", THORN: "Þ", thorn: "þ", tilde: "˜", Tilde: "∼", TildeEqual: "≃", TildeFullEqual: "≅", TildeTilde: "≈", timesbar: "⨱", timesb: "⊠", times: "×", timesd: "⨰", tint: "∭", toea: "⤨", topbot: "⌶", topcir: "⫱", top: "⊤", Topf: "𝕋", topf: "𝕥", topfork: "⫚", tosa: "⤩", tprime: "‴", trade: "™", TRADE: "™", triangle: "▵", triangledown: "▿", triangleleft: "◃", trianglelefteq: "⊴", triangleq: "≜", triangleright: "▹", trianglerighteq: "⊵", tridot: "◬", trie: "≜", triminus: "⨺", TripleDot: "⃛", triplus: "⨹", trisb: "⧍", tritime: "⨻", trpezium: "⏢", Tscr: "𝒯", tscr: "𝓉", TScy: "Ц", tscy: "ц", TSHcy: "Ћ", tshcy: "ћ", Tstrok: "Ŧ", tstrok: "ŧ", twixt: "≬", twoheadleftarrow: "↞", twoheadrightarrow: "↠", Uacute: "Ú", uacute: "ú", uarr: "↑", Uarr: "↟", uArr: "⇑", Uarrocir: "⥉", Ubrcy: "Ў", ubrcy: "ў", Ubreve: "Ŭ", ubreve: "ŭ", Ucirc: "Û", ucirc: "û", Ucy: "У", ucy: "у", udarr: "⇅", Udblac: "Ű", udblac: "ű", udhar: "⥮", ufisht: "⥾", Ufr: "𝔘", ufr: "𝔲", Ugrave: "Ù", ugrave: "ù", uHar: "⥣", uharl: "↿", uharr: "↾", uhblk: "▀", ulcorn: "⌜", ulcorner: "⌜", ulcrop: "⌏", ultri: "◸", Umacr: "Ū", umacr: "ū", uml: "¨", UnderBar: "_", UnderBrace: "⏟", UnderBracket: "⎵", UnderParenthesis: "⏝", Union: "⋃", UnionPlus: "⊎", Uogon: "Ų", uogon: "ų", Uopf: "𝕌", uopf: "𝕦", UpArrowBar: "⤒", uparrow: "↑", UpArrow: "↑", Uparrow: "⇑", UpArrowDownArrow: "⇅", updownarrow: "↕", UpDownArrow: "↕", Updownarrow: "⇕", UpEquilibrium: "⥮", upharpoonleft: "↿", upharpoonright: "↾", uplus: "⊎", UpperLeftArrow: "↖", UpperRightArrow: "↗", upsi: "υ", Upsi: "ϒ", upsih: "ϒ", Upsilon: "Υ", upsilon: "υ", UpTeeArrow: "↥", UpTee: "⊥", upuparrows: "⇈", urcorn: "⌝", urcorner: "⌝", urcrop: "⌎", Uring: "Ů", uring: "ů", urtri: "◹", Uscr: "𝒰", uscr: "𝓊", utdot: "⋰", Utilde: "Ũ", utilde: "ũ", utri: "▵", utrif: "▴", uuarr: "⇈", Uuml: "Ü", uuml: "ü", uwangle: "⦧", vangrt: "⦜", varepsilon: "ϵ", varkappa: "ϰ", varnothing: "∅", varphi: "ϕ", varpi: "ϖ", varpropto: "∝", varr: "↕", vArr: "⇕", varrho: "ϱ", varsigma: "ς", varsubsetneq: "⊊︀", varsubsetneqq: "⫋︀", varsupsetneq: "⊋︀", varsupsetneqq: "⫌︀", vartheta: "ϑ", vartriangleleft: "⊲", vartriangleright: "⊳", vBar: "⫨", Vbar: "⫫", vBarv: "⫩", Vcy: "В", vcy: "в", vdash: "⊢", vDash: "⊨", Vdash: "⊩", VDash: "⊫", Vdashl: "⫦", veebar: "⊻", vee: "∨", Vee: "⋁", veeeq: "≚", vellip: "⋮", verbar: "|", Verbar: "‖", vert: "|", Vert: "‖", VerticalBar: "∣", VerticalLine: "|", VerticalSeparator: "❘", VerticalTilde: "≀", VeryThinSpace: " ", Vfr: "𝔙", vfr: "𝔳", vltri: "⊲", vnsub: "⊂⃒", vnsup: "⊃⃒", Vopf: "𝕍", vopf: "𝕧", vprop: "∝", vrtri: "⊳", Vscr: "𝒱", vscr: "𝓋", vsubnE: "⫋︀", vsubne: "⊊︀", vsupnE: "⫌︀", vsupne: "⊋︀", Vvdash: "⊪", vzigzag: "⦚", Wcirc: "Ŵ", wcirc: "ŵ", wedbar: "⩟", wedge: "∧", Wedge: "⋀", wedgeq: "≙", weierp: "℘", Wfr: "𝔚", wfr: "𝔴", Wopf: "𝕎", wopf: "𝕨", wp: "℘", wr: "≀", wreath: "≀", Wscr: "𝒲", wscr: "𝓌", xcap: "⋂", xcirc: "◯", xcup: "⋃", xdtri: "▽", Xfr: "𝔛", xfr: "𝔵", xharr: "⟷", xhArr: "⟺", Xi: "Ξ", xi: "ξ", xlarr: "⟵", xlArr: "⟸", xmap: "⟼", xnis: "⋻", xodot: "⨀", Xopf: "𝕏", xopf: "𝕩", xoplus: "⨁", xotime: "⨂", xrarr: "⟶", xrArr: "⟹", Xscr: "𝒳", xscr: "𝓍", xsqcup: "⨆", xuplus: "⨄", xutri: "△", xvee: "⋁", xwedge: "⋀", Yacute: "Ý", yacute: "ý", YAcy: "Я", yacy: "я", Ycirc: "Ŷ", ycirc: "ŷ", Ycy: "Ы", ycy: "ы", yen: "¥", Yfr: "𝔜", yfr: "𝔶", YIcy: "Ї", yicy: "ї", Yopf: "𝕐", yopf: "𝕪", Yscr: "𝒴", yscr: "𝓎", YUcy: "Ю", yucy: "ю", yuml: "ÿ", Yuml: "Ÿ", Zacute: "Ź", zacute: "ź", Zcaron: "Ž", zcaron: "ž", Zcy: "З", zcy: "з", Zdot: "Ż", zdot: "ż", zeetrf: "ℨ", ZeroWidthSpace: "", Zeta: "Ζ", zeta: "ζ", zfr: "𝔷", Zfr: "ℨ", ZHcy: "Ж", zhcy: "ж", zigrarr: "⇝", zopf: "𝕫", Zopf: "ℤ", Zscr: "𝒵", zscr: "𝓏", zwj: "\u200d", zwnj: "\u200c" |
|
2703 }; |
|
2704 |
|
2705 var HEXCHARCODE = /^#[xX]([A-Fa-f0-9]+)$/; |
|
2706 var CHARCODE = /^#([0-9]+)$/; |
|
2707 var NAMED = /^([A-Za-z0-9]+)$/; |
|
2708 var EntityParser = /** @class */ (function () { |
|
2709 function EntityParser(named) { |
|
2710 this.named = named; |
|
2711 } |
|
2712 EntityParser.prototype.parse = function (entity) { |
|
2713 if (!entity) { |
|
2714 return; |
|
2715 } |
|
2716 var matches = entity.match(HEXCHARCODE); |
|
2717 if (matches) { |
|
2718 return String.fromCharCode(parseInt(matches[1], 16)); |
|
2719 } |
|
2720 matches = entity.match(CHARCODE); |
|
2721 if (matches) { |
|
2722 return String.fromCharCode(parseInt(matches[1], 10)); |
|
2723 } |
|
2724 matches = entity.match(NAMED); |
|
2725 if (matches) { |
|
2726 return this.named[matches[1]]; |
|
2727 } |
|
2728 }; |
|
2729 return EntityParser; |
|
2730 }()); |
|
2731 |
|
2732 var WSP = /[\t\n\f ]/; |
|
2733 var ALPHA = /[A-Za-z]/; |
|
2734 var CRLF = /\r\n?/g; |
|
2735 function isSpace(char) { |
|
2736 return WSP.test(char); |
|
2737 } |
|
2738 function isAlpha(char) { |
|
2739 return ALPHA.test(char); |
|
2740 } |
|
2741 function preprocessInput(input) { |
|
2742 return input.replace(CRLF, '\n'); |
|
2743 } |
|
2744 |
|
2745 var EventedTokenizer = /** @class */ (function () { |
|
2746 function EventedTokenizer(delegate, entityParser, mode) { |
|
2747 if (mode === void 0) { mode = 'precompile'; } |
|
2748 this.delegate = delegate; |
|
2749 this.entityParser = entityParser; |
|
2750 this.mode = mode; |
|
2751 this.state = "beforeData" /* beforeData */; |
|
2752 this.line = -1; |
|
2753 this.column = -1; |
|
2754 this.input = ''; |
|
2755 this.index = -1; |
|
2756 this.tagNameBuffer = ''; |
|
2757 this.states = { |
|
2758 beforeData: function () { |
|
2759 var char = this.peek(); |
|
2760 if (char === '<' && !this.isIgnoredEndTag()) { |
|
2761 this.transitionTo("tagOpen" /* tagOpen */); |
|
2762 this.markTagStart(); |
|
2763 this.consume(); |
|
2764 } |
|
2765 else { |
|
2766 if (this.mode === 'precompile' && char === '\n') { |
|
2767 var tag = this.tagNameBuffer.toLowerCase(); |
|
2768 if (tag === 'pre' || tag === 'textarea') { |
|
2769 this.consume(); |
|
2770 } |
|
2771 } |
|
2772 this.transitionTo("data" /* data */); |
|
2773 this.delegate.beginData(); |
|
2774 } |
|
2775 }, |
|
2776 data: function () { |
|
2777 var char = this.peek(); |
|
2778 var tag = this.tagNameBuffer; |
|
2779 if (char === '<' && !this.isIgnoredEndTag()) { |
|
2780 this.delegate.finishData(); |
|
2781 this.transitionTo("tagOpen" /* tagOpen */); |
|
2782 this.markTagStart(); |
|
2783 this.consume(); |
|
2784 } |
|
2785 else if (char === '&' && tag !== 'script' && tag !== 'style') { |
|
2786 this.consume(); |
|
2787 this.delegate.appendToData(this.consumeCharRef() || '&'); |
|
2788 } |
|
2789 else { |
|
2790 this.consume(); |
|
2791 this.delegate.appendToData(char); |
|
2792 } |
|
2793 }, |
|
2794 tagOpen: function () { |
|
2795 var char = this.consume(); |
|
2796 if (char === '!') { |
|
2797 this.transitionTo("markupDeclarationOpen" /* markupDeclarationOpen */); |
|
2798 } |
|
2799 else if (char === '/') { |
|
2800 this.transitionTo("endTagOpen" /* endTagOpen */); |
|
2801 } |
|
2802 else if (char === '@' || char === ':' || isAlpha(char)) { |
|
2803 this.transitionTo("tagName" /* tagName */); |
|
2804 this.tagNameBuffer = ''; |
|
2805 this.delegate.beginStartTag(); |
|
2806 this.appendToTagName(char); |
|
2807 } |
|
2808 }, |
|
2809 markupDeclarationOpen: function () { |
|
2810 var char = this.consume(); |
|
2811 if (char === '-' && this.peek() === '-') { |
|
2812 this.consume(); |
|
2813 this.transitionTo("commentStart" /* commentStart */); |
|
2814 this.delegate.beginComment(); |
|
2815 } |
|
2816 else { |
|
2817 var maybeDoctype = char.toUpperCase() + this.input.substring(this.index, this.index + 6).toUpperCase(); |
|
2818 if (maybeDoctype === 'DOCTYPE') { |
|
2819 this.consume(); |
|
2820 this.consume(); |
|
2821 this.consume(); |
|
2822 this.consume(); |
|
2823 this.consume(); |
|
2824 this.consume(); |
|
2825 this.transitionTo("doctype" /* doctype */); |
|
2826 if (this.delegate.beginDoctype) |
|
2827 this.delegate.beginDoctype(); |
|
2828 } |
|
2829 } |
|
2830 }, |
|
2831 doctype: function () { |
|
2832 var char = this.consume(); |
|
2833 if (isSpace(char)) { |
|
2834 this.transitionTo("beforeDoctypeName" /* beforeDoctypeName */); |
|
2835 } |
|
2836 }, |
|
2837 beforeDoctypeName: function () { |
|
2838 var char = this.consume(); |
|
2839 if (isSpace(char)) { |
|
2840 return; |
|
2841 } |
|
2842 else { |
|
2843 this.transitionTo("doctypeName" /* doctypeName */); |
|
2844 if (this.delegate.appendToDoctypeName) |
|
2845 this.delegate.appendToDoctypeName(char.toLowerCase()); |
|
2846 } |
|
2847 }, |
|
2848 doctypeName: function () { |
|
2849 var char = this.consume(); |
|
2850 if (isSpace(char)) { |
|
2851 this.transitionTo("afterDoctypeName" /* afterDoctypeName */); |
|
2852 } |
|
2853 else if (char === '>') { |
|
2854 if (this.delegate.endDoctype) |
|
2855 this.delegate.endDoctype(); |
|
2856 this.transitionTo("beforeData" /* beforeData */); |
|
2857 } |
|
2858 else { |
|
2859 if (this.delegate.appendToDoctypeName) |
|
2860 this.delegate.appendToDoctypeName(char.toLowerCase()); |
|
2861 } |
|
2862 }, |
|
2863 afterDoctypeName: function () { |
|
2864 var char = this.consume(); |
|
2865 if (isSpace(char)) { |
|
2866 return; |
|
2867 } |
|
2868 else if (char === '>') { |
|
2869 if (this.delegate.endDoctype) |
|
2870 this.delegate.endDoctype(); |
|
2871 this.transitionTo("beforeData" /* beforeData */); |
|
2872 } |
|
2873 else { |
|
2874 var nextSixChars = char.toUpperCase() + this.input.substring(this.index, this.index + 5).toUpperCase(); |
|
2875 var isPublic = nextSixChars.toUpperCase() === 'PUBLIC'; |
|
2876 var isSystem = nextSixChars.toUpperCase() === 'SYSTEM'; |
|
2877 if (isPublic || isSystem) { |
|
2878 this.consume(); |
|
2879 this.consume(); |
|
2880 this.consume(); |
|
2881 this.consume(); |
|
2882 this.consume(); |
|
2883 this.consume(); |
|
2884 } |
|
2885 if (isPublic) { |
|
2886 this.transitionTo("afterDoctypePublicKeyword" /* afterDoctypePublicKeyword */); |
|
2887 } |
|
2888 else if (isSystem) { |
|
2889 this.transitionTo("afterDoctypeSystemKeyword" /* afterDoctypeSystemKeyword */); |
|
2890 } |
|
2891 } |
|
2892 }, |
|
2893 afterDoctypePublicKeyword: function () { |
|
2894 var char = this.peek(); |
|
2895 if (isSpace(char)) { |
|
2896 this.transitionTo("beforeDoctypePublicIdentifier" /* beforeDoctypePublicIdentifier */); |
|
2897 this.consume(); |
|
2898 } |
|
2899 else if (char === '"') { |
|
2900 this.transitionTo("doctypePublicIdentifierDoubleQuoted" /* doctypePublicIdentifierDoubleQuoted */); |
|
2901 this.consume(); |
|
2902 } |
|
2903 else if (char === "'") { |
|
2904 this.transitionTo("doctypePublicIdentifierSingleQuoted" /* doctypePublicIdentifierSingleQuoted */); |
|
2905 this.consume(); |
|
2906 } |
|
2907 else if (char === '>') { |
|
2908 this.consume(); |
|
2909 if (this.delegate.endDoctype) |
|
2910 this.delegate.endDoctype(); |
|
2911 this.transitionTo("beforeData" /* beforeData */); |
|
2912 } |
|
2913 }, |
|
2914 doctypePublicIdentifierDoubleQuoted: function () { |
|
2915 var char = this.consume(); |
|
2916 if (char === '"') { |
|
2917 this.transitionTo("afterDoctypePublicIdentifier" /* afterDoctypePublicIdentifier */); |
|
2918 } |
|
2919 else if (char === '>') { |
|
2920 if (this.delegate.endDoctype) |
|
2921 this.delegate.endDoctype(); |
|
2922 this.transitionTo("beforeData" /* beforeData */); |
|
2923 } |
|
2924 else { |
|
2925 if (this.delegate.appendToDoctypePublicIdentifier) |
|
2926 this.delegate.appendToDoctypePublicIdentifier(char); |
|
2927 } |
|
2928 }, |
|
2929 doctypePublicIdentifierSingleQuoted: function () { |
|
2930 var char = this.consume(); |
|
2931 if (char === "'") { |
|
2932 this.transitionTo("afterDoctypePublicIdentifier" /* afterDoctypePublicIdentifier */); |
|
2933 } |
|
2934 else if (char === '>') { |
|
2935 if (this.delegate.endDoctype) |
|
2936 this.delegate.endDoctype(); |
|
2937 this.transitionTo("beforeData" /* beforeData */); |
|
2938 } |
|
2939 else { |
|
2940 if (this.delegate.appendToDoctypePublicIdentifier) |
|
2941 this.delegate.appendToDoctypePublicIdentifier(char); |
|
2942 } |
|
2943 }, |
|
2944 afterDoctypePublicIdentifier: function () { |
|
2945 var char = this.consume(); |
|
2946 if (isSpace(char)) { |
|
2947 this.transitionTo("betweenDoctypePublicAndSystemIdentifiers" /* betweenDoctypePublicAndSystemIdentifiers */); |
|
2948 } |
|
2949 else if (char === '>') { |
|
2950 if (this.delegate.endDoctype) |
|
2951 this.delegate.endDoctype(); |
|
2952 this.transitionTo("beforeData" /* beforeData */); |
|
2953 } |
|
2954 else if (char === '"') { |
|
2955 this.transitionTo("doctypeSystemIdentifierDoubleQuoted" /* doctypeSystemIdentifierDoubleQuoted */); |
|
2956 } |
|
2957 else if (char === "'") { |
|
2958 this.transitionTo("doctypeSystemIdentifierSingleQuoted" /* doctypeSystemIdentifierSingleQuoted */); |
|
2959 } |
|
2960 }, |
|
2961 betweenDoctypePublicAndSystemIdentifiers: function () { |
|
2962 var char = this.consume(); |
|
2963 if (isSpace(char)) { |
|
2964 return; |
|
2965 } |
|
2966 else if (char === '>') { |
|
2967 if (this.delegate.endDoctype) |
|
2968 this.delegate.endDoctype(); |
|
2969 this.transitionTo("beforeData" /* beforeData */); |
|
2970 } |
|
2971 else if (char === '"') { |
|
2972 this.transitionTo("doctypeSystemIdentifierDoubleQuoted" /* doctypeSystemIdentifierDoubleQuoted */); |
|
2973 } |
|
2974 else if (char === "'") { |
|
2975 this.transitionTo("doctypeSystemIdentifierSingleQuoted" /* doctypeSystemIdentifierSingleQuoted */); |
|
2976 } |
|
2977 }, |
|
2978 doctypeSystemIdentifierDoubleQuoted: function () { |
|
2979 var char = this.consume(); |
|
2980 if (char === '"') { |
|
2981 this.transitionTo("afterDoctypeSystemIdentifier" /* afterDoctypeSystemIdentifier */); |
|
2982 } |
|
2983 else if (char === '>') { |
|
2984 if (this.delegate.endDoctype) |
|
2985 this.delegate.endDoctype(); |
|
2986 this.transitionTo("beforeData" /* beforeData */); |
|
2987 } |
|
2988 else { |
|
2989 if (this.delegate.appendToDoctypeSystemIdentifier) |
|
2990 this.delegate.appendToDoctypeSystemIdentifier(char); |
|
2991 } |
|
2992 }, |
|
2993 doctypeSystemIdentifierSingleQuoted: function () { |
|
2994 var char = this.consume(); |
|
2995 if (char === "'") { |
|
2996 this.transitionTo("afterDoctypeSystemIdentifier" /* afterDoctypeSystemIdentifier */); |
|
2997 } |
|
2998 else if (char === '>') { |
|
2999 if (this.delegate.endDoctype) |
|
3000 this.delegate.endDoctype(); |
|
3001 this.transitionTo("beforeData" /* beforeData */); |
|
3002 } |
|
3003 else { |
|
3004 if (this.delegate.appendToDoctypeSystemIdentifier) |
|
3005 this.delegate.appendToDoctypeSystemIdentifier(char); |
|
3006 } |
|
3007 }, |
|
3008 afterDoctypeSystemIdentifier: function () { |
|
3009 var char = this.consume(); |
|
3010 if (isSpace(char)) { |
|
3011 return; |
|
3012 } |
|
3013 else if (char === '>') { |
|
3014 if (this.delegate.endDoctype) |
|
3015 this.delegate.endDoctype(); |
|
3016 this.transitionTo("beforeData" /* beforeData */); |
|
3017 } |
|
3018 }, |
|
3019 commentStart: function () { |
|
3020 var char = this.consume(); |
|
3021 if (char === '-') { |
|
3022 this.transitionTo("commentStartDash" /* commentStartDash */); |
|
3023 } |
|
3024 else if (char === '>') { |
|
3025 this.delegate.finishComment(); |
|
3026 this.transitionTo("beforeData" /* beforeData */); |
|
3027 } |
|
3028 else { |
|
3029 this.delegate.appendToCommentData(char); |
|
3030 this.transitionTo("comment" /* comment */); |
|
3031 } |
|
3032 }, |
|
3033 commentStartDash: function () { |
|
3034 var char = this.consume(); |
|
3035 if (char === '-') { |
|
3036 this.transitionTo("commentEnd" /* commentEnd */); |
|
3037 } |
|
3038 else if (char === '>') { |
|
3039 this.delegate.finishComment(); |
|
3040 this.transitionTo("beforeData" /* beforeData */); |
|
3041 } |
|
3042 else { |
|
3043 this.delegate.appendToCommentData('-'); |
|
3044 this.transitionTo("comment" /* comment */); |
|
3045 } |
|
3046 }, |
|
3047 comment: function () { |
|
3048 var char = this.consume(); |
|
3049 if (char === '-') { |
|
3050 this.transitionTo("commentEndDash" /* commentEndDash */); |
|
3051 } |
|
3052 else { |
|
3053 this.delegate.appendToCommentData(char); |
|
3054 } |
|
3055 }, |
|
3056 commentEndDash: function () { |
|
3057 var char = this.consume(); |
|
3058 if (char === '-') { |
|
3059 this.transitionTo("commentEnd" /* commentEnd */); |
|
3060 } |
|
3061 else { |
|
3062 this.delegate.appendToCommentData('-' + char); |
|
3063 this.transitionTo("comment" /* comment */); |
|
3064 } |
|
3065 }, |
|
3066 commentEnd: function () { |
|
3067 var char = this.consume(); |
|
3068 if (char === '>') { |
|
3069 this.delegate.finishComment(); |
|
3070 this.transitionTo("beforeData" /* beforeData */); |
|
3071 } |
|
3072 else { |
|
3073 this.delegate.appendToCommentData('--' + char); |
|
3074 this.transitionTo("comment" /* comment */); |
|
3075 } |
|
3076 }, |
|
3077 tagName: function () { |
|
3078 var char = this.consume(); |
|
3079 if (isSpace(char)) { |
|
3080 this.transitionTo("beforeAttributeName" /* beforeAttributeName */); |
|
3081 } |
|
3082 else if (char === '/') { |
|
3083 this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */); |
|
3084 } |
|
3085 else if (char === '>') { |
|
3086 this.delegate.finishTag(); |
|
3087 this.transitionTo("beforeData" /* beforeData */); |
|
3088 } |
|
3089 else { |
|
3090 this.appendToTagName(char); |
|
3091 } |
|
3092 }, |
|
3093 endTagName: function () { |
|
3094 var char = this.consume(); |
|
3095 if (isSpace(char)) { |
|
3096 this.transitionTo("beforeAttributeName" /* beforeAttributeName */); |
|
3097 this.tagNameBuffer = ''; |
|
3098 } |
|
3099 else if (char === '/') { |
|
3100 this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */); |
|
3101 this.tagNameBuffer = ''; |
|
3102 } |
|
3103 else if (char === '>') { |
|
3104 this.delegate.finishTag(); |
|
3105 this.transitionTo("beforeData" /* beforeData */); |
|
3106 this.tagNameBuffer = ''; |
|
3107 } |
|
3108 else { |
|
3109 this.appendToTagName(char); |
|
3110 } |
|
3111 }, |
|
3112 beforeAttributeName: function () { |
|
3113 var char = this.peek(); |
|
3114 if (isSpace(char)) { |
|
3115 this.consume(); |
|
3116 return; |
|
3117 } |
|
3118 else if (char === '/') { |
|
3119 this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */); |
|
3120 this.consume(); |
|
3121 } |
|
3122 else if (char === '>') { |
|
3123 this.consume(); |
|
3124 this.delegate.finishTag(); |
|
3125 this.transitionTo("beforeData" /* beforeData */); |
|
3126 } |
|
3127 else if (char === '=') { |
|
3128 this.delegate.reportSyntaxError('attribute name cannot start with equals sign'); |
|
3129 this.transitionTo("attributeName" /* attributeName */); |
|
3130 this.delegate.beginAttribute(); |
|
3131 this.consume(); |
|
3132 this.delegate.appendToAttributeName(char); |
|
3133 } |
|
3134 else { |
|
3135 this.transitionTo("attributeName" /* attributeName */); |
|
3136 this.delegate.beginAttribute(); |
|
3137 } |
|
3138 }, |
|
3139 attributeName: function () { |
|
3140 var char = this.peek(); |
|
3141 if (isSpace(char)) { |
|
3142 this.transitionTo("afterAttributeName" /* afterAttributeName */); |
|
3143 this.consume(); |
|
3144 } |
|
3145 else if (char === '/') { |
|
3146 this.delegate.beginAttributeValue(false); |
|
3147 this.delegate.finishAttributeValue(); |
|
3148 this.consume(); |
|
3149 this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */); |
|
3150 } |
|
3151 else if (char === '=') { |
|
3152 this.transitionTo("beforeAttributeValue" /* beforeAttributeValue */); |
|
3153 this.consume(); |
|
3154 } |
|
3155 else if (char === '>') { |
|
3156 this.delegate.beginAttributeValue(false); |
|
3157 this.delegate.finishAttributeValue(); |
|
3158 this.consume(); |
|
3159 this.delegate.finishTag(); |
|
3160 this.transitionTo("beforeData" /* beforeData */); |
|
3161 } |
|
3162 else if (char === '"' || char === "'" || char === '<') { |
|
3163 this.delegate.reportSyntaxError(char + ' is not a valid character within attribute names'); |
|
3164 this.consume(); |
|
3165 this.delegate.appendToAttributeName(char); |
|
3166 } |
|
3167 else { |
|
3168 this.consume(); |
|
3169 this.delegate.appendToAttributeName(char); |
|
3170 } |
|
3171 }, |
|
3172 afterAttributeName: function () { |
|
3173 var char = this.peek(); |
|
3174 if (isSpace(char)) { |
|
3175 this.consume(); |
|
3176 return; |
|
3177 } |
|
3178 else if (char === '/') { |
|
3179 this.delegate.beginAttributeValue(false); |
|
3180 this.delegate.finishAttributeValue(); |
|
3181 this.consume(); |
|
3182 this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */); |
|
3183 } |
|
3184 else if (char === '=') { |
|
3185 this.consume(); |
|
3186 this.transitionTo("beforeAttributeValue" /* beforeAttributeValue */); |
|
3187 } |
|
3188 else if (char === '>') { |
|
3189 this.delegate.beginAttributeValue(false); |
|
3190 this.delegate.finishAttributeValue(); |
|
3191 this.consume(); |
|
3192 this.delegate.finishTag(); |
|
3193 this.transitionTo("beforeData" /* beforeData */); |
|
3194 } |
|
3195 else { |
|
3196 this.delegate.beginAttributeValue(false); |
|
3197 this.delegate.finishAttributeValue(); |
|
3198 this.transitionTo("attributeName" /* attributeName */); |
|
3199 this.delegate.beginAttribute(); |
|
3200 this.consume(); |
|
3201 this.delegate.appendToAttributeName(char); |
|
3202 } |
|
3203 }, |
|
3204 beforeAttributeValue: function () { |
|
3205 var char = this.peek(); |
|
3206 if (isSpace(char)) { |
|
3207 this.consume(); |
|
3208 } |
|
3209 else if (char === '"') { |
|
3210 this.transitionTo("attributeValueDoubleQuoted" /* attributeValueDoubleQuoted */); |
|
3211 this.delegate.beginAttributeValue(true); |
|
3212 this.consume(); |
|
3213 } |
|
3214 else if (char === "'") { |
|
3215 this.transitionTo("attributeValueSingleQuoted" /* attributeValueSingleQuoted */); |
|
3216 this.delegate.beginAttributeValue(true); |
|
3217 this.consume(); |
|
3218 } |
|
3219 else if (char === '>') { |
|
3220 this.delegate.beginAttributeValue(false); |
|
3221 this.delegate.finishAttributeValue(); |
|
3222 this.consume(); |
|
3223 this.delegate.finishTag(); |
|
3224 this.transitionTo("beforeData" /* beforeData */); |
|
3225 } |
|
3226 else { |
|
3227 this.transitionTo("attributeValueUnquoted" /* attributeValueUnquoted */); |
|
3228 this.delegate.beginAttributeValue(false); |
|
3229 this.consume(); |
|
3230 this.delegate.appendToAttributeValue(char); |
|
3231 } |
|
3232 }, |
|
3233 attributeValueDoubleQuoted: function () { |
|
3234 var char = this.consume(); |
|
3235 if (char === '"') { |
|
3236 this.delegate.finishAttributeValue(); |
|
3237 this.transitionTo("afterAttributeValueQuoted" /* afterAttributeValueQuoted */); |
|
3238 } |
|
3239 else if (char === '&') { |
|
3240 this.delegate.appendToAttributeValue(this.consumeCharRef() || '&'); |
|
3241 } |
|
3242 else { |
|
3243 this.delegate.appendToAttributeValue(char); |
|
3244 } |
|
3245 }, |
|
3246 attributeValueSingleQuoted: function () { |
|
3247 var char = this.consume(); |
|
3248 if (char === "'") { |
|
3249 this.delegate.finishAttributeValue(); |
|
3250 this.transitionTo("afterAttributeValueQuoted" /* afterAttributeValueQuoted */); |
|
3251 } |
|
3252 else if (char === '&') { |
|
3253 this.delegate.appendToAttributeValue(this.consumeCharRef() || '&'); |
|
3254 } |
|
3255 else { |
|
3256 this.delegate.appendToAttributeValue(char); |
|
3257 } |
|
3258 }, |
|
3259 attributeValueUnquoted: function () { |
|
3260 var char = this.peek(); |
|
3261 if (isSpace(char)) { |
|
3262 this.delegate.finishAttributeValue(); |
|
3263 this.consume(); |
|
3264 this.transitionTo("beforeAttributeName" /* beforeAttributeName */); |
|
3265 } |
|
3266 else if (char === '/') { |
|
3267 this.delegate.finishAttributeValue(); |
|
3268 this.consume(); |
|
3269 this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */); |
|
3270 } |
|
3271 else if (char === '&') { |
|
3272 this.consume(); |
|
3273 this.delegate.appendToAttributeValue(this.consumeCharRef() || '&'); |
|
3274 } |
|
3275 else if (char === '>') { |
|
3276 this.delegate.finishAttributeValue(); |
|
3277 this.consume(); |
|
3278 this.delegate.finishTag(); |
|
3279 this.transitionTo("beforeData" /* beforeData */); |
|
3280 } |
|
3281 else { |
|
3282 this.consume(); |
|
3283 this.delegate.appendToAttributeValue(char); |
|
3284 } |
|
3285 }, |
|
3286 afterAttributeValueQuoted: function () { |
|
3287 var char = this.peek(); |
|
3288 if (isSpace(char)) { |
|
3289 this.consume(); |
|
3290 this.transitionTo("beforeAttributeName" /* beforeAttributeName */); |
|
3291 } |
|
3292 else if (char === '/') { |
|
3293 this.consume(); |
|
3294 this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */); |
|
3295 } |
|
3296 else if (char === '>') { |
|
3297 this.consume(); |
|
3298 this.delegate.finishTag(); |
|
3299 this.transitionTo("beforeData" /* beforeData */); |
|
3300 } |
|
3301 else { |
|
3302 this.transitionTo("beforeAttributeName" /* beforeAttributeName */); |
|
3303 } |
|
3304 }, |
|
3305 selfClosingStartTag: function () { |
|
3306 var char = this.peek(); |
|
3307 if (char === '>') { |
|
3308 this.consume(); |
|
3309 this.delegate.markTagAsSelfClosing(); |
|
3310 this.delegate.finishTag(); |
|
3311 this.transitionTo("beforeData" /* beforeData */); |
|
3312 } |
|
3313 else { |
|
3314 this.transitionTo("beforeAttributeName" /* beforeAttributeName */); |
|
3315 } |
|
3316 }, |
|
3317 endTagOpen: function () { |
|
3318 var char = this.consume(); |
|
3319 if (char === '@' || char === ':' || isAlpha(char)) { |
|
3320 this.transitionTo("endTagName" /* endTagName */); |
|
3321 this.tagNameBuffer = ''; |
|
3322 this.delegate.beginEndTag(); |
|
3323 this.appendToTagName(char); |
|
3324 } |
|
3325 } |
|
3326 }; |
|
3327 this.reset(); |
|
3328 } |
|
3329 EventedTokenizer.prototype.reset = function () { |
|
3330 this.transitionTo("beforeData" /* beforeData */); |
|
3331 this.input = ''; |
|
3332 this.tagNameBuffer = ''; |
|
3333 this.index = 0; |
|
3334 this.line = 1; |
|
3335 this.column = 0; |
|
3336 this.delegate.reset(); |
|
3337 }; |
|
3338 EventedTokenizer.prototype.transitionTo = function (state) { |
|
3339 this.state = state; |
|
3340 }; |
|
3341 EventedTokenizer.prototype.tokenize = function (input) { |
|
3342 this.reset(); |
|
3343 this.tokenizePart(input); |
|
3344 this.tokenizeEOF(); |
|
3345 }; |
|
3346 EventedTokenizer.prototype.tokenizePart = function (input) { |
|
3347 this.input += preprocessInput(input); |
|
3348 while (this.index < this.input.length) { |
|
3349 var handler = this.states[this.state]; |
|
3350 if (handler !== undefined) { |
|
3351 handler.call(this); |
|
3352 } |
|
3353 else { |
|
3354 throw new Error("unhandled state " + this.state); |
|
3355 } |
|
3356 } |
|
3357 }; |
|
3358 EventedTokenizer.prototype.tokenizeEOF = function () { |
|
3359 this.flushData(); |
|
3360 }; |
|
3361 EventedTokenizer.prototype.flushData = function () { |
|
3362 if (this.state === 'data') { |
|
3363 this.delegate.finishData(); |
|
3364 this.transitionTo("beforeData" /* beforeData */); |
|
3365 } |
|
3366 }; |
|
3367 EventedTokenizer.prototype.peek = function () { |
|
3368 return this.input.charAt(this.index); |
|
3369 }; |
|
3370 EventedTokenizer.prototype.consume = function () { |
|
3371 var char = this.peek(); |
|
3372 this.index++; |
|
3373 if (char === '\n') { |
|
3374 this.line++; |
|
3375 this.column = 0; |
|
3376 } |
|
3377 else { |
|
3378 this.column++; |
|
3379 } |
|
3380 return char; |
|
3381 }; |
|
3382 EventedTokenizer.prototype.consumeCharRef = function () { |
|
3383 var endIndex = this.input.indexOf(';', this.index); |
|
3384 if (endIndex === -1) { |
|
3385 return; |
|
3386 } |
|
3387 var entity = this.input.slice(this.index, endIndex); |
|
3388 var chars = this.entityParser.parse(entity); |
|
3389 if (chars) { |
|
3390 var count = entity.length; |
|
3391 // consume the entity chars |
|
3392 while (count) { |
|
3393 this.consume(); |
|
3394 count--; |
|
3395 } |
|
3396 // consume the `;` |
|
3397 this.consume(); |
|
3398 return chars; |
|
3399 } |
|
3400 }; |
|
3401 EventedTokenizer.prototype.markTagStart = function () { |
|
3402 this.delegate.tagOpen(); |
|
3403 }; |
|
3404 EventedTokenizer.prototype.appendToTagName = function (char) { |
|
3405 this.tagNameBuffer += char; |
|
3406 this.delegate.appendToTagName(char); |
|
3407 }; |
|
3408 EventedTokenizer.prototype.isIgnoredEndTag = function () { |
|
3409 var tag = this.tagNameBuffer; |
|
3410 return (tag === 'title' && this.input.substring(this.index, this.index + 8) !== '</title>') || |
|
3411 (tag === 'style' && this.input.substring(this.index, this.index + 8) !== '</style>') || |
|
3412 (tag === 'script' && this.input.substring(this.index, this.index + 9) !== '</script>'); |
|
3413 }; |
|
3414 return EventedTokenizer; |
|
3415 }()); |
|
3416 |
|
3417 var Tokenizer = /** @class */ (function () { |
|
3418 function Tokenizer(entityParser, options) { |
|
3419 if (options === void 0) { options = {}; } |
|
3420 this.options = options; |
|
3421 this.token = null; |
|
3422 this.startLine = 1; |
|
3423 this.startColumn = 0; |
|
3424 this.tokens = []; |
|
3425 this.tokenizer = new EventedTokenizer(this, entityParser, options.mode); |
|
3426 this._currentAttribute = undefined; |
|
3427 } |
|
3428 Tokenizer.prototype.tokenize = function (input) { |
|
3429 this.tokens = []; |
|
3430 this.tokenizer.tokenize(input); |
|
3431 return this.tokens; |
|
3432 }; |
|
3433 Tokenizer.prototype.tokenizePart = function (input) { |
|
3434 this.tokens = []; |
|
3435 this.tokenizer.tokenizePart(input); |
|
3436 return this.tokens; |
|
3437 }; |
|
3438 Tokenizer.prototype.tokenizeEOF = function () { |
|
3439 this.tokens = []; |
|
3440 this.tokenizer.tokenizeEOF(); |
|
3441 return this.tokens[0]; |
|
3442 }; |
|
3443 Tokenizer.prototype.reset = function () { |
|
3444 this.token = null; |
|
3445 this.startLine = 1; |
|
3446 this.startColumn = 0; |
|
3447 }; |
|
3448 Tokenizer.prototype.current = function () { |
|
3449 var token = this.token; |
|
3450 if (token === null) { |
|
3451 throw new Error('token was unexpectedly null'); |
|
3452 } |
|
3453 if (arguments.length === 0) { |
|
3454 return token; |
|
3455 } |
|
3456 for (var i = 0; i < arguments.length; i++) { |
|
3457 if (token.type === arguments[i]) { |
|
3458 return token; |
|
3459 } |
|
3460 } |
|
3461 throw new Error("token type was unexpectedly " + token.type); |
|
3462 }; |
|
3463 Tokenizer.prototype.push = function (token) { |
|
3464 this.token = token; |
|
3465 this.tokens.push(token); |
|
3466 }; |
|
3467 Tokenizer.prototype.currentAttribute = function () { |
|
3468 return this._currentAttribute; |
|
3469 }; |
|
3470 Tokenizer.prototype.addLocInfo = function () { |
|
3471 if (this.options.loc) { |
|
3472 this.current().loc = { |
|
3473 start: { |
|
3474 line: this.startLine, |
|
3475 column: this.startColumn |
|
3476 }, |
|
3477 end: { |
|
3478 line: this.tokenizer.line, |
|
3479 column: this.tokenizer.column |
|
3480 } |
|
3481 }; |
|
3482 } |
|
3483 this.startLine = this.tokenizer.line; |
|
3484 this.startColumn = this.tokenizer.column; |
|
3485 }; |
|
3486 // Data |
|
3487 Tokenizer.prototype.beginDoctype = function () { |
|
3488 this.push({ |
|
3489 type: "Doctype" /* Doctype */, |
|
3490 name: '', |
|
3491 }); |
|
3492 }; |
|
3493 Tokenizer.prototype.appendToDoctypeName = function (char) { |
|
3494 this.current("Doctype" /* Doctype */).name += char; |
|
3495 }; |
|
3496 Tokenizer.prototype.appendToDoctypePublicIdentifier = function (char) { |
|
3497 var doctype = this.current("Doctype" /* Doctype */); |
|
3498 if (doctype.publicIdentifier === undefined) { |
|
3499 doctype.publicIdentifier = char; |
|
3500 } |
|
3501 else { |
|
3502 doctype.publicIdentifier += char; |
|
3503 } |
|
3504 }; |
|
3505 Tokenizer.prototype.appendToDoctypeSystemIdentifier = function (char) { |
|
3506 var doctype = this.current("Doctype" /* Doctype */); |
|
3507 if (doctype.systemIdentifier === undefined) { |
|
3508 doctype.systemIdentifier = char; |
|
3509 } |
|
3510 else { |
|
3511 doctype.systemIdentifier += char; |
|
3512 } |
|
3513 }; |
|
3514 Tokenizer.prototype.endDoctype = function () { |
|
3515 this.addLocInfo(); |
|
3516 }; |
|
3517 Tokenizer.prototype.beginData = function () { |
|
3518 this.push({ |
|
3519 type: "Chars" /* Chars */, |
|
3520 chars: '' |
|
3521 }); |
|
3522 }; |
|
3523 Tokenizer.prototype.appendToData = function (char) { |
|
3524 this.current("Chars" /* Chars */).chars += char; |
|
3525 }; |
|
3526 Tokenizer.prototype.finishData = function () { |
|
3527 this.addLocInfo(); |
|
3528 }; |
|
3529 // Comment |
|
3530 Tokenizer.prototype.beginComment = function () { |
|
3531 this.push({ |
|
3532 type: "Comment" /* Comment */, |
|
3533 chars: '' |
|
3534 }); |
|
3535 }; |
|
3536 Tokenizer.prototype.appendToCommentData = function (char) { |
|
3537 this.current("Comment" /* Comment */).chars += char; |
|
3538 }; |
|
3539 Tokenizer.prototype.finishComment = function () { |
|
3540 this.addLocInfo(); |
|
3541 }; |
|
3542 // Tags - basic |
|
3543 Tokenizer.prototype.tagOpen = function () { }; |
|
3544 Tokenizer.prototype.beginStartTag = function () { |
|
3545 this.push({ |
|
3546 type: "StartTag" /* StartTag */, |
|
3547 tagName: '', |
|
3548 attributes: [], |
|
3549 selfClosing: false |
|
3550 }); |
|
3551 }; |
|
3552 Tokenizer.prototype.beginEndTag = function () { |
|
3553 this.push({ |
|
3554 type: "EndTag" /* EndTag */, |
|
3555 tagName: '' |
|
3556 }); |
|
3557 }; |
|
3558 Tokenizer.prototype.finishTag = function () { |
|
3559 this.addLocInfo(); |
|
3560 }; |
|
3561 Tokenizer.prototype.markTagAsSelfClosing = function () { |
|
3562 this.current("StartTag" /* StartTag */).selfClosing = true; |
|
3563 }; |
|
3564 // Tags - name |
|
3565 Tokenizer.prototype.appendToTagName = function (char) { |
|
3566 this.current("StartTag" /* StartTag */, "EndTag" /* EndTag */).tagName += char; |
|
3567 }; |
|
3568 // Tags - attributes |
|
3569 Tokenizer.prototype.beginAttribute = function () { |
|
3570 this._currentAttribute = ['', '', false]; |
|
3571 }; |
|
3572 Tokenizer.prototype.appendToAttributeName = function (char) { |
|
3573 this.currentAttribute()[0] += char; |
|
3574 }; |
|
3575 Tokenizer.prototype.beginAttributeValue = function (isQuoted) { |
|
3576 this.currentAttribute()[2] = isQuoted; |
|
3577 }; |
|
3578 Tokenizer.prototype.appendToAttributeValue = function (char) { |
|
3579 this.currentAttribute()[1] += char; |
|
3580 }; |
|
3581 Tokenizer.prototype.finishAttributeValue = function () { |
|
3582 this.current("StartTag" /* StartTag */).attributes.push(this._currentAttribute); |
|
3583 }; |
|
3584 Tokenizer.prototype.reportSyntaxError = function (message) { |
|
3585 this.current().syntaxError = message; |
|
3586 }; |
|
3587 return Tokenizer; |
|
3588 }()); |
|
3589 |
|
3590 function tokenize(input, options) { |
|
3591 var tokenizer = new Tokenizer(new EntityParser(namedCharRefs), options); |
|
3592 return tokenizer.tokenize(input); |
|
3593 } |
|
3594 |
|
3595 |
|
3596 |
|
3597 // EXTERNAL MODULE: external ["wp","htmlEntities"] |
|
3598 var external_wp_htmlEntities_ = __webpack_require__("rmEH"); |
|
3599 |
|
3600 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/validation/logger.js |
|
3601 function createLogger() { |
|
3602 /** |
|
3603 * Creates a log handler with block validation prefix. |
|
3604 * |
|
3605 * @param {Function} logger Original logger function. |
|
3606 * |
|
3607 * @return {Function} Augmented logger function. |
|
3608 */ |
|
3609 function createLogHandler(logger) { |
|
3610 let log = (message, ...args) => logger('Block validation: ' + message, ...args); // In test environments, pre-process string substitutions to improve |
|
3611 // readability of error messages. We'd prefer to avoid pulling in this |
|
3612 // dependency in runtime environments, and it can be dropped by a combo |
|
3613 // of Webpack env substitution + UglifyJS dead code elimination. |
|
3614 |
|
3615 |
|
3616 if (false) {} |
|
3617 |
|
3618 return log; |
|
3619 } |
|
3620 |
|
3621 return { |
|
3622 // eslint-disable-next-line no-console |
|
3623 error: createLogHandler(console.error), |
|
3624 // eslint-disable-next-line no-console |
|
3625 warning: createLogHandler(console.warn), |
|
3626 |
|
3627 getItems() { |
|
3628 return []; |
|
3629 } |
|
3630 |
|
3631 }; |
|
3632 } |
|
3633 function createQueuedLogger() { |
|
3634 /** |
|
3635 * The list of enqueued log actions to print. |
|
3636 * |
|
3637 * @type {Array} |
|
3638 */ |
|
3639 const queue = []; |
|
3640 const logger = createLogger(); |
|
3641 return { |
|
3642 error(...args) { |
|
3643 queue.push({ |
|
3644 log: logger.error, |
|
3645 args |
|
3646 }); |
|
3647 }, |
|
3648 |
|
3649 warning(...args) { |
|
3650 queue.push({ |
|
3651 log: logger.warning, |
|
3652 args |
|
3653 }); |
|
3654 }, |
|
3655 |
|
3656 getItems() { |
|
3657 return queue; |
|
3658 } |
|
3659 |
|
3660 }; |
|
3661 } |
|
3662 |
|
3663 // EXTERNAL MODULE: external ["wp","isShallowEqual"] |
|
3664 var external_wp_isShallowEqual_ = __webpack_require__("rl8x"); |
|
3665 var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_); |
|
3666 |
|
3667 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js |
|
3668 var esm_extends = __webpack_require__("wx14"); |
|
3669 |
|
3670 // EXTERNAL MODULE: external ["wp","compose"] |
|
3671 var external_wp_compose_ = __webpack_require__("K9lf"); |
|
3672 |
|
3673 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/block-content-provider/index.js |
|
3674 |
|
3675 |
|
3676 |
|
3677 /** |
|
3678 * WordPress dependencies |
|
3679 */ |
|
3680 |
|
3681 |
|
3682 /** |
|
3683 * Internal dependencies |
|
3684 */ |
|
3685 |
|
3686 |
|
3687 const { |
|
3688 Consumer, |
|
3689 Provider |
|
3690 } = Object(external_wp_element_["createContext"])(() => {}); |
|
3691 /** |
|
3692 * An internal block component used in block content serialization to inject |
|
3693 * nested block content within the `save` implementation of the ancestor |
|
3694 * component in which it is nested. The component provides a pre-bound |
|
3695 * `BlockContent` component via context, which is used by the developer-facing |
|
3696 * `InnerBlocks.Content` component to render block content. |
|
3697 * |
|
3698 * @example |
|
3699 * |
|
3700 * ```jsx |
|
3701 * <BlockContentProvider innerBlocks={ innerBlocks }> |
|
3702 * { blockSaveElement } |
|
3703 * </BlockContentProvider> |
|
3704 * ``` |
|
3705 * |
|
3706 * @param {Object} props Component props. |
|
3707 * @param {WPElement} props.children Block save result. |
|
3708 * @param {Array} props.innerBlocks Block(s) to serialize. |
|
3709 * |
|
3710 * @return {WPComponent} Element with BlockContent injected via context. |
|
3711 */ |
|
3712 |
|
3713 const BlockContentProvider = ({ |
|
3714 children, |
|
3715 innerBlocks |
|
3716 }) => { |
|
3717 const BlockContent = () => { |
|
3718 // Value is an array of blocks, so defer to block serializer |
|
3719 const html = serialize(innerBlocks, { |
|
3720 isInnerBlocks: true |
|
3721 }); // Use special-cased raw HTML tag to avoid default escaping |
|
3722 |
|
3723 return Object(external_wp_element_["createElement"])(external_wp_element_["RawHTML"], null, html); |
|
3724 }; |
|
3725 |
|
3726 return Object(external_wp_element_["createElement"])(Provider, { |
|
3727 value: BlockContent |
|
3728 }, children); |
|
3729 }; |
|
3730 /** |
|
3731 * A Higher Order Component used to inject BlockContent using context to the |
|
3732 * wrapped component. |
|
3733 * |
|
3734 * @return {WPComponent} Enhanced component with injected BlockContent as prop. |
|
3735 */ |
|
3736 |
|
3737 |
|
3738 const withBlockContentContext = Object(external_wp_compose_["createHigherOrderComponent"])(OriginalComponent => { |
|
3739 return props => Object(external_wp_element_["createElement"])(Consumer, null, context => Object(external_wp_element_["createElement"])(OriginalComponent, Object(esm_extends["a" /* default */])({}, props, { |
|
3740 BlockContent: context |
|
3741 }))); |
|
3742 }, 'withBlockContentContext'); |
|
3743 /* harmony default export */ var block_content_provider = (BlockContentProvider); |
|
3744 |
|
3745 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/serializer.js |
|
3746 |
|
3747 |
|
3748 /** |
|
3749 * External dependencies |
|
3750 */ |
|
3751 |
|
3752 /** |
|
3753 * WordPress dependencies |
|
3754 */ |
|
3755 |
|
3756 |
|
3757 |
|
3758 |
|
3759 |
|
3760 /** |
|
3761 * Internal dependencies |
|
3762 */ |
|
3763 |
|
3764 |
|
3765 |
|
3766 |
|
3767 /** |
|
3768 * @typedef {Object} WPBlockSerializationOptions Serialization Options. |
|
3769 * |
|
3770 * @property {boolean} isInnerBlocks Whether we are serializing inner blocks. |
|
3771 */ |
|
3772 |
|
3773 /** |
|
3774 * Returns the block's default classname from its name. |
|
3775 * |
|
3776 * @param {string} blockName The block name. |
|
3777 * |
|
3778 * @return {string} The block's default class. |
|
3779 */ |
|
3780 |
|
3781 function getBlockDefaultClassName(blockName) { |
|
3782 // Generated HTML classes for blocks follow the `wp-block-{name}` nomenclature. |
|
3783 // Blocks provided by WordPress drop the prefixes 'core/' or 'core-' (historically used in 'core-embed/'). |
|
3784 const className = 'wp-block-' + blockName.replace(/\//, '-').replace(/^core-/, ''); |
|
3785 return Object(external_wp_hooks_["applyFilters"])('blocks.getBlockDefaultClassName', className, blockName); |
|
3786 } |
|
3787 /** |
|
3788 * Returns the block's default menu item classname from its name. |
|
3789 * |
|
3790 * @param {string} blockName The block name. |
|
3791 * |
|
3792 * @return {string} The block's default menu item class. |
|
3793 */ |
|
3794 |
|
3795 function getBlockMenuDefaultClassName(blockName) { |
|
3796 // Generated HTML classes for blocks follow the `editor-block-list-item-{name}` nomenclature. |
|
3797 // Blocks provided by WordPress drop the prefixes 'core/' or 'core-' (historically used in 'core-embed/'). |
|
3798 const className = 'editor-block-list-item-' + blockName.replace(/\//, '-').replace(/^core-/, ''); |
|
3799 return Object(external_wp_hooks_["applyFilters"])('blocks.getBlockMenuDefaultClassName', className, blockName); |
|
3800 } |
|
3801 const blockPropsProvider = {}; |
|
3802 /** |
|
3803 * Call within a save function to get the props for the block wrapper. |
|
3804 * |
|
3805 * @param {Object} props Optional. Props to pass to the element. |
|
3806 */ |
|
3807 |
|
3808 function getBlockProps(props = {}) { |
|
3809 const { |
|
3810 blockType, |
|
3811 attributes |
|
3812 } = blockPropsProvider; |
|
3813 return Object(external_wp_hooks_["applyFilters"])('blocks.getSaveContent.extraProps', { ...props |
|
3814 }, blockType, attributes); |
|
3815 } |
|
3816 /** |
|
3817 * Given a block type containing a save render implementation and attributes, returns the |
|
3818 * enhanced element to be saved or string when raw HTML expected. |
|
3819 * |
|
3820 * @param {string|Object} blockTypeOrName Block type or name. |
|
3821 * @param {Object} attributes Block attributes. |
|
3822 * @param {?Array} innerBlocks Nested blocks. |
|
3823 * |
|
3824 * @return {Object|string} Save element or raw HTML string. |
|
3825 */ |
|
3826 |
|
3827 function getSaveElement(blockTypeOrName, attributes, innerBlocks = []) { |
|
3828 const blockType = normalizeBlockType(blockTypeOrName); |
|
3829 let { |
|
3830 save |
|
3831 } = blockType; // Component classes are unsupported for save since serialization must |
|
3832 // occur synchronously. For improved interoperability with higher-order |
|
3833 // components which often return component class, emulate basic support. |
|
3834 |
|
3835 if (save.prototype instanceof external_wp_element_["Component"]) { |
|
3836 const instance = new save({ |
|
3837 attributes |
|
3838 }); |
|
3839 save = instance.render.bind(instance); |
|
3840 } |
|
3841 |
|
3842 blockPropsProvider.blockType = blockType; |
|
3843 blockPropsProvider.attributes = attributes; |
|
3844 let element = save({ |
|
3845 attributes, |
|
3846 innerBlocks |
|
3847 }); |
|
3848 const hasLightBlockWrapper = blockType.apiVersion > 1 || registration_hasBlockSupport(blockType, 'lightBlockWrapper', false); |
|
3849 |
|
3850 if (Object(external_lodash_["isObject"])(element) && Object(external_wp_hooks_["hasFilter"])('blocks.getSaveContent.extraProps') && !hasLightBlockWrapper) { |
|
3851 /** |
|
3852 * Filters the props applied to the block save result element. |
|
3853 * |
|
3854 * @param {Object} props Props applied to save element. |
|
3855 * @param {WPBlock} blockType Block type definition. |
|
3856 * @param {Object} attributes Block attributes. |
|
3857 */ |
|
3858 const props = Object(external_wp_hooks_["applyFilters"])('blocks.getSaveContent.extraProps', { ...element.props |
|
3859 }, blockType, attributes); |
|
3860 |
|
3861 if (!external_wp_isShallowEqual_default()(props, element.props)) { |
|
3862 element = Object(external_wp_element_["cloneElement"])(element, props); |
|
3863 } |
|
3864 } |
|
3865 /** |
|
3866 * Filters the save result of a block during serialization. |
|
3867 * |
|
3868 * @param {WPElement} element Block save result. |
|
3869 * @param {WPBlock} blockType Block type definition. |
|
3870 * @param {Object} attributes Block attributes. |
|
3871 */ |
|
3872 |
|
3873 |
|
3874 element = Object(external_wp_hooks_["applyFilters"])('blocks.getSaveElement', element, blockType, attributes); |
|
3875 return Object(external_wp_element_["createElement"])(block_content_provider, { |
|
3876 innerBlocks: innerBlocks |
|
3877 }, element); |
|
3878 } |
|
3879 /** |
|
3880 * Given a block type containing a save render implementation and attributes, returns the |
|
3881 * static markup to be saved. |
|
3882 * |
|
3883 * @param {string|Object} blockTypeOrName Block type or name. |
|
3884 * @param {Object} attributes Block attributes. |
|
3885 * @param {?Array} innerBlocks Nested blocks. |
|
3886 * |
|
3887 * @return {string} Save content. |
|
3888 */ |
|
3889 |
|
3890 function getSaveContent(blockTypeOrName, attributes, innerBlocks) { |
|
3891 const blockType = normalizeBlockType(blockTypeOrName); |
|
3892 return Object(external_wp_element_["renderToString"])(getSaveElement(blockType, attributes, innerBlocks)); |
|
3893 } |
|
3894 /** |
|
3895 * Returns attributes which are to be saved and serialized into the block |
|
3896 * comment delimiter. |
|
3897 * |
|
3898 * When a block exists in memory it contains as its attributes both those |
|
3899 * parsed the block comment delimiter _and_ those which matched from the |
|
3900 * contents of the block. |
|
3901 * |
|
3902 * This function returns only those attributes which are needed to persist and |
|
3903 * which cannot be matched from the block content. |
|
3904 * |
|
3905 * @param {Object<string,*>} blockType Block type. |
|
3906 * @param {Object<string,*>} attributes Attributes from in-memory block data. |
|
3907 * |
|
3908 * @return {Object<string,*>} Subset of attributes for comment serialization. |
|
3909 */ |
|
3910 |
|
3911 function getCommentAttributes(blockType, attributes) { |
|
3912 return Object(external_lodash_["reduce"])(blockType.attributes, (accumulator, attributeSchema, key) => { |
|
3913 const value = attributes[key]; // Ignore undefined values. |
|
3914 |
|
3915 if (undefined === value) { |
|
3916 return accumulator; |
|
3917 } // Ignore all attributes but the ones with an "undefined" source |
|
3918 // "undefined" source refers to attributes saved in the block comment. |
|
3919 |
|
3920 |
|
3921 if (attributeSchema.source !== undefined) { |
|
3922 return accumulator; |
|
3923 } // Ignore default value. |
|
3924 |
|
3925 |
|
3926 if ('default' in attributeSchema && attributeSchema.default === value) { |
|
3927 return accumulator; |
|
3928 } // Otherwise, include in comment set. |
|
3929 |
|
3930 |
|
3931 accumulator[key] = value; |
|
3932 return accumulator; |
|
3933 }, {}); |
|
3934 } |
|
3935 /** |
|
3936 * Given an attributes object, returns a string in the serialized attributes |
|
3937 * format prepared for post content. |
|
3938 * |
|
3939 * @param {Object} attributes Attributes object. |
|
3940 * |
|
3941 * @return {string} Serialized attributes. |
|
3942 */ |
|
3943 |
|
3944 function serializeAttributes(attributes) { |
|
3945 return JSON.stringify(attributes) // Don't break HTML comments. |
|
3946 .replace(/--/g, '\\u002d\\u002d') // Don't break non-standard-compliant tools. |
|
3947 .replace(/</g, '\\u003c').replace(/>/g, '\\u003e').replace(/&/g, '\\u0026') // Bypass server stripslashes behavior which would unescape stringify's |
|
3948 // escaping of quotation mark. |
|
3949 // |
|
3950 // See: https://developer.wordpress.org/reference/functions/wp_kses_stripslashes/ |
|
3951 .replace(/\\"/g, '\\u0022'); |
|
3952 } |
|
3953 /** |
|
3954 * Given a block object, returns the Block's Inner HTML markup. |
|
3955 * |
|
3956 * @param {Object} block Block instance. |
|
3957 * |
|
3958 * @return {string} HTML. |
|
3959 */ |
|
3960 |
|
3961 function getBlockInnerHTML(block) { |
|
3962 // If block was parsed as invalid or encounters an error while generating |
|
3963 // save content, use original content instead to avoid content loss. If a |
|
3964 // block contains nested content, exempt it from this condition because we |
|
3965 // otherwise have no access to its original content and content loss would |
|
3966 // still occur. |
|
3967 let saveContent = block.originalContent; |
|
3968 |
|
3969 if (block.isValid || block.innerBlocks.length) { |
|
3970 try { |
|
3971 saveContent = getSaveContent(block.name, block.attributes, block.innerBlocks); |
|
3972 } catch (error) {} |
|
3973 } |
|
3974 |
|
3975 return saveContent; |
|
3976 } |
|
3977 /** |
|
3978 * Returns the content of a block, including comment delimiters. |
|
3979 * |
|
3980 * @param {string} rawBlockName Block name. |
|
3981 * @param {Object} attributes Block attributes. |
|
3982 * @param {string} content Block save content. |
|
3983 * |
|
3984 * @return {string} Comment-delimited block content. |
|
3985 */ |
|
3986 |
|
3987 function getCommentDelimitedContent(rawBlockName, attributes, content) { |
|
3988 const serializedAttributes = !Object(external_lodash_["isEmpty"])(attributes) ? serializeAttributes(attributes) + ' ' : ''; // Strip core blocks of their namespace prefix. |
|
3989 |
|
3990 const blockName = Object(external_lodash_["startsWith"])(rawBlockName, 'core/') ? rawBlockName.slice(5) : rawBlockName; // @todo make the `wp:` prefix potentially configurable. |
|
3991 |
|
3992 if (!content) { |
|
3993 return `<!-- wp:${blockName} ${serializedAttributes}/-->`; |
|
3994 } |
|
3995 |
|
3996 return `<!-- wp:${blockName} ${serializedAttributes}-->\n` + content + `\n<!-- /wp:${blockName} -->`; |
|
3997 } |
|
3998 /** |
|
3999 * Returns the content of a block, including comment delimiters, determining |
|
4000 * serialized attributes and content form from the current state of the block. |
|
4001 * |
|
4002 * @param {Object} block Block instance. |
|
4003 * @param {WPBlockSerializationOptions} options Serialization options. |
|
4004 * |
|
4005 * @return {string} Serialized block. |
|
4006 */ |
|
4007 |
|
4008 function serializeBlock(block, { |
|
4009 isInnerBlocks = false |
|
4010 } = {}) { |
|
4011 const blockName = block.name; |
|
4012 const saveContent = getBlockInnerHTML(block); |
|
4013 |
|
4014 if (blockName === getUnregisteredTypeHandlerName() || !isInnerBlocks && blockName === getFreeformContentHandlerName()) { |
|
4015 return saveContent; |
|
4016 } |
|
4017 |
|
4018 const blockType = registration_getBlockType(blockName); |
|
4019 const saveAttributes = getCommentAttributes(blockType, block.attributes); |
|
4020 return getCommentDelimitedContent(blockName, saveAttributes, saveContent); |
|
4021 } |
|
4022 function __unstableSerializeAndClean(blocks) { |
|
4023 // A single unmodified default block is assumed to |
|
4024 // be equivalent to an empty post. |
|
4025 if (blocks.length === 1 && isUnmodifiedDefaultBlock(blocks[0])) { |
|
4026 blocks = []; |
|
4027 } |
|
4028 |
|
4029 let content = serialize(blocks); // For compatibility, treat a post consisting of a |
|
4030 // single freeform block as legacy content and apply |
|
4031 // pre-block-editor removep'd content formatting. |
|
4032 |
|
4033 if (blocks.length === 1 && blocks[0].name === getFreeformContentHandlerName()) { |
|
4034 content = Object(external_wp_autop_["removep"])(content); |
|
4035 } |
|
4036 |
|
4037 return content; |
|
4038 } |
|
4039 /** |
|
4040 * Takes a block or set of blocks and returns the serialized post content. |
|
4041 * |
|
4042 * @param {Array} blocks Block(s) to serialize. |
|
4043 * @param {WPBlockSerializationOptions} options Serialization options. |
|
4044 * |
|
4045 * @return {string} The post content. |
|
4046 */ |
|
4047 |
|
4048 function serialize(blocks, options) { |
|
4049 return Object(external_lodash_["castArray"])(blocks).map(block => serializeBlock(block, options)).join('\n\n'); |
|
4050 } |
|
4051 |
|
4052 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/validation/index.js |
|
4053 /** |
|
4054 * External dependencies |
|
4055 */ |
|
4056 |
|
4057 |
|
4058 /** |
|
4059 * WordPress dependencies |
|
4060 */ |
|
4061 |
|
4062 |
|
4063 /** |
|
4064 * Internal dependencies |
|
4065 */ |
|
4066 |
|
4067 |
|
4068 |
|
4069 |
|
4070 /** |
|
4071 * Globally matches any consecutive whitespace |
|
4072 * |
|
4073 * @type {RegExp} |
|
4074 */ |
|
4075 |
|
4076 const REGEXP_WHITESPACE = /[\t\n\r\v\f ]+/g; |
|
4077 /** |
|
4078 * Matches a string containing only whitespace |
|
4079 * |
|
4080 * @type {RegExp} |
|
4081 */ |
|
4082 |
|
4083 const REGEXP_ONLY_WHITESPACE = /^[\t\n\r\v\f ]*$/; |
|
4084 /** |
|
4085 * Matches a CSS URL type value |
|
4086 * |
|
4087 * @type {RegExp} |
|
4088 */ |
|
4089 |
|
4090 const REGEXP_STYLE_URL_TYPE = /^url\s*\(['"\s]*(.*?)['"\s]*\)$/; |
|
4091 /** |
|
4092 * Boolean attributes are attributes whose presence as being assigned is |
|
4093 * meaningful, even if only empty. |
|
4094 * |
|
4095 * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes |
|
4096 * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3 |
|
4097 * |
|
4098 * Object.keys( Array.from( document.querySelectorAll( '#attributes-1 > tbody > tr' ) ) |
|
4099 * .filter( ( tr ) => tr.lastChild.textContent.indexOf( 'Boolean attribute' ) !== -1 ) |
|
4100 * .reduce( ( result, tr ) => Object.assign( result, { |
|
4101 * [ tr.firstChild.textContent.trim() ]: true |
|
4102 * } ), {} ) ).sort(); |
|
4103 * |
|
4104 * @type {Array} |
|
4105 */ |
|
4106 |
|
4107 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']; |
|
4108 /** |
|
4109 * Enumerated attributes are attributes which must be of a specific value form. |
|
4110 * Like boolean attributes, these are meaningful if specified, even if not of a |
|
4111 * valid enumerated value. |
|
4112 * |
|
4113 * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute |
|
4114 * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3 |
|
4115 * |
|
4116 * Object.keys( Array.from( document.querySelectorAll( '#attributes-1 > tbody > tr' ) ) |
|
4117 * .filter( ( tr ) => /^("(.+?)";?\s*)+/.test( tr.lastChild.textContent.trim() ) ) |
|
4118 * .reduce( ( result, tr ) => Object.assign( result, { |
|
4119 * [ tr.firstChild.textContent.trim() ]: true |
|
4120 * } ), {} ) ).sort(); |
|
4121 * |
|
4122 * @type {Array} |
|
4123 */ |
|
4124 |
|
4125 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']; |
|
4126 /** |
|
4127 * Meaningful attributes are those who cannot be safely ignored when omitted in |
|
4128 * one HTML markup string and not another. |
|
4129 * |
|
4130 * @type {Array} |
|
4131 */ |
|
4132 |
|
4133 const MEANINGFUL_ATTRIBUTES = [...BOOLEAN_ATTRIBUTES, ...ENUMERATED_ATTRIBUTES]; |
|
4134 /** |
|
4135 * Array of functions which receive a text string on which to apply normalizing |
|
4136 * behavior for consideration in text token equivalence, carefully ordered from |
|
4137 * least-to-most expensive operations. |
|
4138 * |
|
4139 * @type {Array} |
|
4140 */ |
|
4141 |
|
4142 const TEXT_NORMALIZATIONS = [external_lodash_["identity"], getTextWithCollapsedWhitespace]; |
|
4143 /** |
|
4144 * Regular expression matching a named character reference. In lieu of bundling |
|
4145 * a full set of references, the pattern covers the minimal necessary to test |
|
4146 * positively against the full set. |
|
4147 * |
|
4148 * "The ampersand must be followed by one of the names given in the named |
|
4149 * character references section, using the same case." |
|
4150 * |
|
4151 * Tested aginst "12.5 Named character references": |
|
4152 * |
|
4153 * ``` |
|
4154 * const references = Array.from( document.querySelectorAll( |
|
4155 * '#named-character-references-table tr[id^=entity-] td:first-child' |
|
4156 * ) ).map( ( code ) => code.textContent ) |
|
4157 * references.every( ( reference ) => /^[\da-z]+$/i.test( reference ) ) |
|
4158 * ``` |
|
4159 * |
|
4160 * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references |
|
4161 * @see https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references |
|
4162 * |
|
4163 * @type {RegExp} |
|
4164 */ |
|
4165 |
|
4166 const REGEXP_NAMED_CHARACTER_REFERENCE = /^[\da-z]+$/i; |
|
4167 /** |
|
4168 * Regular expression matching a decimal character reference. |
|
4169 * |
|
4170 * "The ampersand must be followed by a U+0023 NUMBER SIGN character (#), |
|
4171 * followed by one or more ASCII digits, representing a base-ten integer" |
|
4172 * |
|
4173 * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references |
|
4174 * |
|
4175 * @type {RegExp} |
|
4176 */ |
|
4177 |
|
4178 const REGEXP_DECIMAL_CHARACTER_REFERENCE = /^#\d+$/; |
|
4179 /** |
|
4180 * Regular expression matching a hexadecimal character reference. |
|
4181 * |
|
4182 * "The ampersand must be followed by a U+0023 NUMBER SIGN character (#), which |
|
4183 * must be followed by either a U+0078 LATIN SMALL LETTER X character (x) or a |
|
4184 * U+0058 LATIN CAPITAL LETTER X character (X), which must then be followed by |
|
4185 * one or more ASCII hex digits, representing a hexadecimal integer" |
|
4186 * |
|
4187 * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references |
|
4188 * |
|
4189 * @type {RegExp} |
|
4190 */ |
|
4191 |
|
4192 const REGEXP_HEXADECIMAL_CHARACTER_REFERENCE = /^#x[\da-f]+$/i; |
|
4193 /** |
|
4194 * Returns true if the given string is a valid character reference segment, or |
|
4195 * false otherwise. The text should be stripped of `&` and `;` demarcations. |
|
4196 * |
|
4197 * @param {string} text Text to test. |
|
4198 * |
|
4199 * @return {boolean} Whether text is valid character reference. |
|
4200 */ |
|
4201 |
|
4202 function isValidCharacterReference(text) { |
|
4203 return REGEXP_NAMED_CHARACTER_REFERENCE.test(text) || REGEXP_DECIMAL_CHARACTER_REFERENCE.test(text) || REGEXP_HEXADECIMAL_CHARACTER_REFERENCE.test(text); |
|
4204 } |
|
4205 /** |
|
4206 * Subsitute EntityParser class for `simple-html-tokenizer` which uses the |
|
4207 * implementation of `decodeEntities` from `html-entities`, in order to avoid |
|
4208 * bundling a massive named character reference. |
|
4209 * |
|
4210 * @see https://github.com/tildeio/simple-html-tokenizer/tree/HEAD/src/entity-parser.ts |
|
4211 */ |
|
4212 |
|
4213 class validation_DecodeEntityParser { |
|
4214 /** |
|
4215 * Returns a substitute string for an entity string sequence between `&` |
|
4216 * and `;`, or undefined if no substitution should occur. |
|
4217 * |
|
4218 * @param {string} entity Entity fragment discovered in HTML. |
|
4219 * |
|
4220 * @return {?string} Entity substitute value. |
|
4221 */ |
|
4222 parse(entity) { |
|
4223 if (isValidCharacterReference(entity)) { |
|
4224 return Object(external_wp_htmlEntities_["decodeEntities"])('&' + entity + ';'); |
|
4225 } |
|
4226 } |
|
4227 |
|
4228 } |
|
4229 /** |
|
4230 * Given a specified string, returns an array of strings split by consecutive |
|
4231 * whitespace, ignoring leading or trailing whitespace. |
|
4232 * |
|
4233 * @param {string} text Original text. |
|
4234 * |
|
4235 * @return {string[]} Text pieces split on whitespace. |
|
4236 */ |
|
4237 |
|
4238 function getTextPiecesSplitOnWhitespace(text) { |
|
4239 return text.trim().split(REGEXP_WHITESPACE); |
|
4240 } |
|
4241 /** |
|
4242 * Given a specified string, returns a new trimmed string where all consecutive |
|
4243 * whitespace is collapsed to a single space. |
|
4244 * |
|
4245 * @param {string} text Original text. |
|
4246 * |
|
4247 * @return {string} Trimmed text with consecutive whitespace collapsed. |
|
4248 */ |
|
4249 |
|
4250 function getTextWithCollapsedWhitespace(text) { |
|
4251 // This is an overly simplified whitespace comparison. The specification is |
|
4252 // more prescriptive of whitespace behavior in inline and block contexts. |
|
4253 // |
|
4254 // See: https://medium.com/@patrickbrosset/when-does-white-space-matter-in-html-b90e8a7cdd33 |
|
4255 return getTextPiecesSplitOnWhitespace(text).join(' '); |
|
4256 } |
|
4257 /** |
|
4258 * Returns attribute pairs of the given StartTag token, including only pairs |
|
4259 * where the value is non-empty or the attribute is a boolean attribute, an |
|
4260 * enumerated attribute, or a custom data- attribute. |
|
4261 * |
|
4262 * @see MEANINGFUL_ATTRIBUTES |
|
4263 * |
|
4264 * @param {Object} token StartTag token. |
|
4265 * |
|
4266 * @return {Array[]} Attribute pairs. |
|
4267 */ |
|
4268 |
|
4269 function getMeaningfulAttributePairs(token) { |
|
4270 return token.attributes.filter(pair => { |
|
4271 const [key, value] = pair; |
|
4272 return value || key.indexOf('data-') === 0 || Object(external_lodash_["includes"])(MEANINGFUL_ATTRIBUTES, key); |
|
4273 }); |
|
4274 } |
|
4275 /** |
|
4276 * Returns true if two text tokens (with `chars` property) are equivalent, or |
|
4277 * false otherwise. |
|
4278 * |
|
4279 * @param {Object} actual Actual token. |
|
4280 * @param {Object} expected Expected token. |
|
4281 * @param {Object} logger Validation logger object. |
|
4282 * |
|
4283 * @return {boolean} Whether two text tokens are equivalent. |
|
4284 */ |
|
4285 |
|
4286 function isEquivalentTextTokens(actual, expected, logger = createLogger()) { |
|
4287 // This function is intentionally written as syntactically "ugly" as a hot |
|
4288 // path optimization. Text is progressively normalized in order from least- |
|
4289 // to-most operationally expensive, until the earliest point at which text |
|
4290 // can be confidently inferred as being equal. |
|
4291 let actualChars = actual.chars; |
|
4292 let expectedChars = expected.chars; |
|
4293 |
|
4294 for (let i = 0; i < TEXT_NORMALIZATIONS.length; i++) { |
|
4295 const normalize = TEXT_NORMALIZATIONS[i]; |
|
4296 actualChars = normalize(actualChars); |
|
4297 expectedChars = normalize(expectedChars); |
|
4298 |
|
4299 if (actualChars === expectedChars) { |
|
4300 return true; |
|
4301 } |
|
4302 } |
|
4303 |
|
4304 logger.warning('Expected text `%s`, saw `%s`.', expected.chars, actual.chars); |
|
4305 return false; |
|
4306 } |
|
4307 /** |
|
4308 * Given a CSS length value, returns a normalized CSS length value for strict equality |
|
4309 * comparison. |
|
4310 * |
|
4311 * @param {string} value CSS length value. |
|
4312 * |
|
4313 * @return {string} Normalized CSS length value. |
|
4314 */ |
|
4315 |
|
4316 function getNormalizedLength(value) { |
|
4317 return 0 === parseFloat(value) ? '0' : value; |
|
4318 } |
|
4319 /** |
|
4320 * Given a style value, returns a normalized style value for strict equality |
|
4321 * comparison. |
|
4322 * |
|
4323 * @param {string} value Style value. |
|
4324 * |
|
4325 * @return {string} Normalized style value. |
|
4326 */ |
|
4327 |
|
4328 function getNormalizedStyleValue(value) { |
|
4329 const textPieces = getTextPiecesSplitOnWhitespace(value); |
|
4330 const normalizedPieces = textPieces.map(getNormalizedLength); |
|
4331 const result = normalizedPieces.join(' '); |
|
4332 return result // Normalize URL type to omit whitespace or quotes |
|
4333 .replace(REGEXP_STYLE_URL_TYPE, 'url($1)'); |
|
4334 } |
|
4335 /** |
|
4336 * Given a style attribute string, returns an object of style properties. |
|
4337 * |
|
4338 * @param {string} text Style attribute. |
|
4339 * |
|
4340 * @return {Object} Style properties. |
|
4341 */ |
|
4342 |
|
4343 function getStyleProperties(text) { |
|
4344 const pairs = text // Trim ending semicolon (avoid including in split) |
|
4345 .replace(/;?\s*$/, '') // Split on property assignment |
|
4346 .split(';') // For each property assignment... |
|
4347 .map(style => { |
|
4348 // ...split further into key-value pairs |
|
4349 const [key, ...valueParts] = style.split(':'); |
|
4350 const value = valueParts.join(':'); |
|
4351 return [key.trim(), getNormalizedStyleValue(value.trim())]; |
|
4352 }); |
|
4353 return Object(external_lodash_["fromPairs"])(pairs); |
|
4354 } |
|
4355 /** |
|
4356 * Attribute-specific equality handlers |
|
4357 * |
|
4358 * @type {Object} |
|
4359 */ |
|
4360 |
|
4361 const isEqualAttributesOfName = { |
|
4362 class: (actual, expected) => { |
|
4363 // Class matches if members are the same, even if out of order or |
|
4364 // superfluous whitespace between. |
|
4365 return !Object(external_lodash_["xor"])(...[actual, expected].map(getTextPiecesSplitOnWhitespace)).length; |
|
4366 }, |
|
4367 style: (actual, expected) => { |
|
4368 return Object(external_lodash_["isEqual"])(...[actual, expected].map(getStyleProperties)); |
|
4369 }, |
|
4370 // For each boolean attribute, mere presence of attribute in both is enough |
|
4371 // to assume equivalence. |
|
4372 ...Object(external_lodash_["fromPairs"])(BOOLEAN_ATTRIBUTES.map(attribute => [attribute, external_lodash_["stubTrue"]])) |
|
4373 }; |
|
4374 /** |
|
4375 * Given two sets of attribute tuples, returns true if the attribute sets are |
|
4376 * equivalent. |
|
4377 * |
|
4378 * @param {Array[]} actual Actual attributes tuples. |
|
4379 * @param {Array[]} expected Expected attributes tuples. |
|
4380 * @param {Object} logger Validation logger object. |
|
4381 * |
|
4382 * @return {boolean} Whether attributes are equivalent. |
|
4383 */ |
|
4384 |
|
4385 function isEqualTagAttributePairs(actual, expected, logger = createLogger()) { |
|
4386 // Attributes is tokenized as tuples. Their lengths should match. This also |
|
4387 // avoids us needing to check both attributes sets, since if A has any keys |
|
4388 // which do not exist in B, we know the sets to be different. |
|
4389 if (actual.length !== expected.length) { |
|
4390 logger.warning('Expected attributes %o, instead saw %o.', expected, actual); |
|
4391 return false; |
|
4392 } // Attributes are not guaranteed to occur in the same order. For validating |
|
4393 // actual attributes, first convert the set of expected attribute values to |
|
4394 // an object, for lookup by key. |
|
4395 |
|
4396 |
|
4397 const expectedAttributes = {}; |
|
4398 |
|
4399 for (let i = 0; i < expected.length; i++) { |
|
4400 expectedAttributes[expected[i][0].toLowerCase()] = expected[i][1]; |
|
4401 } |
|
4402 |
|
4403 for (let i = 0; i < actual.length; i++) { |
|
4404 const [name, actualValue] = actual[i]; |
|
4405 const nameLower = name.toLowerCase(); // As noted above, if missing member in B, assume different |
|
4406 |
|
4407 if (!expectedAttributes.hasOwnProperty(nameLower)) { |
|
4408 logger.warning('Encountered unexpected attribute `%s`.', name); |
|
4409 return false; |
|
4410 } |
|
4411 |
|
4412 const expectedValue = expectedAttributes[nameLower]; |
|
4413 const isEqualAttributes = isEqualAttributesOfName[nameLower]; |
|
4414 |
|
4415 if (isEqualAttributes) { |
|
4416 // Defer custom attribute equality handling |
|
4417 if (!isEqualAttributes(actualValue, expectedValue)) { |
|
4418 logger.warning('Expected attribute `%s` of value `%s`, saw `%s`.', name, expectedValue, actualValue); |
|
4419 return false; |
|
4420 } |
|
4421 } else if (actualValue !== expectedValue) { |
|
4422 // Otherwise strict inequality should bail |
|
4423 logger.warning('Expected attribute `%s` of value `%s`, saw `%s`.', name, expectedValue, actualValue); |
|
4424 return false; |
|
4425 } |
|
4426 } |
|
4427 |
|
4428 return true; |
|
4429 } |
|
4430 /** |
|
4431 * Token-type-specific equality handlers |
|
4432 * |
|
4433 * @type {Object} |
|
4434 */ |
|
4435 |
|
4436 const isEqualTokensOfType = { |
|
4437 StartTag: (actual, expected, logger = createLogger()) => { |
|
4438 if (actual.tagName !== expected.tagName && // Optimization: Use short-circuit evaluation to defer case- |
|
4439 // insensitive check on the assumption that the majority case will |
|
4440 // have exactly equal tag names. |
|
4441 actual.tagName.toLowerCase() !== expected.tagName.toLowerCase()) { |
|
4442 logger.warning('Expected tag name `%s`, instead saw `%s`.', expected.tagName, actual.tagName); |
|
4443 return false; |
|
4444 } |
|
4445 |
|
4446 return isEqualTagAttributePairs(...[actual, expected].map(getMeaningfulAttributePairs), logger); |
|
4447 }, |
|
4448 Chars: isEquivalentTextTokens, |
|
4449 Comment: isEquivalentTextTokens |
|
4450 }; |
|
4451 /** |
|
4452 * Given an array of tokens, returns the first token which is not purely |
|
4453 * whitespace. |
|
4454 * |
|
4455 * Mutates the tokens array. |
|
4456 * |
|
4457 * @param {Object[]} tokens Set of tokens to search. |
|
4458 * |
|
4459 * @return {Object} Next non-whitespace token. |
|
4460 */ |
|
4461 |
|
4462 function getNextNonWhitespaceToken(tokens) { |
|
4463 let token; |
|
4464 |
|
4465 while (token = tokens.shift()) { |
|
4466 if (token.type !== 'Chars') { |
|
4467 return token; |
|
4468 } |
|
4469 |
|
4470 if (!REGEXP_ONLY_WHITESPACE.test(token.chars)) { |
|
4471 return token; |
|
4472 } |
|
4473 } |
|
4474 } |
|
4475 /** |
|
4476 * Tokenize an HTML string, gracefully handling any errors thrown during |
|
4477 * underlying tokenization. |
|
4478 * |
|
4479 * @param {string} html HTML string to tokenize. |
|
4480 * @param {Object} logger Validation logger object. |
|
4481 * |
|
4482 * @return {Object[]|null} Array of valid tokenized HTML elements, or null on error |
|
4483 */ |
|
4484 |
|
4485 function getHTMLTokens(html, logger = createLogger()) { |
|
4486 try { |
|
4487 return new Tokenizer(new validation_DecodeEntityParser()).tokenize(html); |
|
4488 } catch (e) { |
|
4489 logger.warning('Malformed HTML detected: %s', html); |
|
4490 } |
|
4491 |
|
4492 return null; |
|
4493 } |
|
4494 /** |
|
4495 * Returns true if the next HTML token closes the current token. |
|
4496 * |
|
4497 * @param {Object} currentToken Current token to compare with. |
|
4498 * @param {Object|undefined} nextToken Next token to compare against. |
|
4499 * |
|
4500 * @return {boolean} true if `nextToken` closes `currentToken`, false otherwise |
|
4501 */ |
|
4502 |
|
4503 |
|
4504 function isClosedByToken(currentToken, nextToken) { |
|
4505 // Ensure this is a self closed token |
|
4506 if (!currentToken.selfClosing) { |
|
4507 return false; |
|
4508 } // Check token names and determine if nextToken is the closing tag for currentToken |
|
4509 |
|
4510 |
|
4511 if (nextToken && nextToken.tagName === currentToken.tagName && nextToken.type === 'EndTag') { |
|
4512 return true; |
|
4513 } |
|
4514 |
|
4515 return false; |
|
4516 } |
|
4517 /** |
|
4518 * Returns true if the given HTML strings are effectively equivalent, or |
|
4519 * false otherwise. Invalid HTML is not considered equivalent, even if the |
|
4520 * strings directly match. |
|
4521 * |
|
4522 * @param {string} actual Actual HTML string. |
|
4523 * @param {string} expected Expected HTML string. |
|
4524 * @param {Object} logger Validation logger object. |
|
4525 * |
|
4526 * @return {boolean} Whether HTML strings are equivalent. |
|
4527 */ |
|
4528 |
|
4529 function isEquivalentHTML(actual, expected, logger = createLogger()) { |
|
4530 // Short-circuit if markup is identical. |
|
4531 if (actual === expected) { |
|
4532 return true; |
|
4533 } // Tokenize input content and reserialized save content |
|
4534 |
|
4535 |
|
4536 const [actualTokens, expectedTokens] = [actual, expected].map(html => getHTMLTokens(html, logger)); // If either is malformed then stop comparing - the strings are not equivalent |
|
4537 |
|
4538 if (!actualTokens || !expectedTokens) { |
|
4539 return false; |
|
4540 } |
|
4541 |
|
4542 let actualToken, expectedToken; |
|
4543 |
|
4544 while (actualToken = getNextNonWhitespaceToken(actualTokens)) { |
|
4545 expectedToken = getNextNonWhitespaceToken(expectedTokens); // Inequal if exhausted all expected tokens |
|
4546 |
|
4547 if (!expectedToken) { |
|
4548 logger.warning('Expected end of content, instead saw %o.', actualToken); |
|
4549 return false; |
|
4550 } // Inequal if next non-whitespace token of each set are not same type |
|
4551 |
|
4552 |
|
4553 if (actualToken.type !== expectedToken.type) { |
|
4554 logger.warning('Expected token of type `%s` (%o), instead saw `%s` (%o).', expectedToken.type, expectedToken, actualToken.type, actualToken); |
|
4555 return false; |
|
4556 } // Defer custom token type equality handling, otherwise continue and |
|
4557 // assume as equal |
|
4558 |
|
4559 |
|
4560 const isEqualTokens = isEqualTokensOfType[actualToken.type]; |
|
4561 |
|
4562 if (isEqualTokens && !isEqualTokens(actualToken, expectedToken, logger)) { |
|
4563 return false; |
|
4564 } // Peek at the next tokens (actual and expected) to see if they close |
|
4565 // a self-closing tag |
|
4566 |
|
4567 |
|
4568 if (isClosedByToken(actualToken, expectedTokens[0])) { |
|
4569 // Consume the next expected token that closes the current actual |
|
4570 // self-closing token |
|
4571 getNextNonWhitespaceToken(expectedTokens); |
|
4572 } else if (isClosedByToken(expectedToken, actualTokens[0])) { |
|
4573 // Consume the next actual token that closes the current expected |
|
4574 // self-closing token |
|
4575 getNextNonWhitespaceToken(actualTokens); |
|
4576 } |
|
4577 } |
|
4578 |
|
4579 if (expectedToken = getNextNonWhitespaceToken(expectedTokens)) { |
|
4580 // If any non-whitespace tokens remain in expected token set, this |
|
4581 // indicates inequality |
|
4582 logger.warning('Expected %o, instead saw end of content.', expectedToken); |
|
4583 return false; |
|
4584 } |
|
4585 |
|
4586 return true; |
|
4587 } |
|
4588 /** |
|
4589 * Returns an object with `isValid` property set to `true` if the parsed block |
|
4590 * is valid given the input content. A block is considered valid if, when serialized |
|
4591 * with assumed attributes, the content matches the original value. If block is |
|
4592 * invalid, this function returns all validations issues as well. |
|
4593 * |
|
4594 * @param {string|Object} blockTypeOrName Block type. |
|
4595 * @param {Object} attributes Parsed block attributes. |
|
4596 * @param {string} originalBlockContent Original block content. |
|
4597 * @param {Object} logger Validation logger object. |
|
4598 * |
|
4599 * @return {Object} Whether block is valid and contains validation messages. |
|
4600 */ |
|
4601 |
|
4602 function getBlockContentValidationResult(blockTypeOrName, attributes, originalBlockContent, logger = createQueuedLogger()) { |
|
4603 const blockType = normalizeBlockType(blockTypeOrName); |
|
4604 let generatedBlockContent; |
|
4605 |
|
4606 try { |
|
4607 generatedBlockContent = getSaveContent(blockType, attributes); |
|
4608 } catch (error) { |
|
4609 logger.error('Block validation failed because an error occurred while generating block content:\n\n%s', error.toString()); |
|
4610 return { |
|
4611 isValid: false, |
|
4612 validationIssues: logger.getItems() |
|
4613 }; |
|
4614 } |
|
4615 |
|
4616 const isValid = isEquivalentHTML(originalBlockContent, generatedBlockContent, logger); |
|
4617 |
|
4618 if (!isValid) { |
|
4619 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, originalBlockContent); |
|
4620 } |
|
4621 |
|
4622 return { |
|
4623 isValid, |
|
4624 validationIssues: logger.getItems() |
|
4625 }; |
|
4626 } |
|
4627 /** |
|
4628 * Returns true if the parsed block is valid given the input content. A block |
|
4629 * is considered valid if, when serialized with assumed attributes, the content |
|
4630 * matches the original value. |
|
4631 * |
|
4632 * Logs to console in development environments when invalid. |
|
4633 * |
|
4634 * @param {string|Object} blockTypeOrName Block type. |
|
4635 * @param {Object} attributes Parsed block attributes. |
|
4636 * @param {string} originalBlockContent Original block content. |
|
4637 * |
|
4638 * @return {boolean} Whether block is valid. |
|
4639 */ |
|
4640 |
|
4641 function isValidBlockContent(blockTypeOrName, attributes, originalBlockContent) { |
|
4642 const { |
|
4643 isValid |
|
4644 } = getBlockContentValidationResult(blockTypeOrName, attributes, originalBlockContent, createLogger()); |
|
4645 return isValid; |
|
4646 } |
|
4647 |
|
4648 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/matchers.js |
|
4649 /** |
|
4650 * External dependencies |
|
4651 */ |
|
4652 |
|
4653 /** |
|
4654 * Internal dependencies |
|
4655 */ |
|
4656 |
|
4657 |
|
4658 |
|
4659 function matchers_html(selector, multilineTag) { |
|
4660 return domNode => { |
|
4661 let match = domNode; |
|
4662 |
|
4663 if (selector) { |
|
4664 match = domNode.querySelector(selector); |
|
4665 } |
|
4666 |
|
4667 if (!match) { |
|
4668 return ''; |
|
4669 } |
|
4670 |
|
4671 if (multilineTag) { |
|
4672 let value = ''; |
|
4673 const length = match.children.length; |
|
4674 |
|
4675 for (let index = 0; index < length; index++) { |
|
4676 const child = match.children[index]; |
|
4677 |
|
4678 if (child.nodeName.toLowerCase() !== multilineTag) { |
|
4679 continue; |
|
4680 } |
|
4681 |
|
4682 value += child.outerHTML; |
|
4683 } |
|
4684 |
|
4685 return value; |
|
4686 } |
|
4687 |
|
4688 return match.innerHTML; |
|
4689 }; |
|
4690 } |
|
4691 |
|
4692 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/node.js |
|
4693 /** |
|
4694 * Internal dependencies |
|
4695 */ |
|
4696 |
|
4697 /** |
|
4698 * A representation of a single node within a block's rich text value. If |
|
4699 * representing a text node, the value is simply a string of the node value. |
|
4700 * As representing an element node, it is an object of: |
|
4701 * |
|
4702 * 1. `type` (string): Tag name. |
|
4703 * 2. `props` (object): Attributes and children array of WPBlockNode. |
|
4704 * |
|
4705 * @typedef {string|Object} WPBlockNode |
|
4706 */ |
|
4707 |
|
4708 /** |
|
4709 * Given a single node and a node type (e.g. `'br'`), returns true if the node |
|
4710 * corresponds to that type, false otherwise. |
|
4711 * |
|
4712 * @param {WPBlockNode} node Block node to test |
|
4713 * @param {string} type Node to type to test against. |
|
4714 * |
|
4715 * @return {boolean} Whether node is of intended type. |
|
4716 */ |
|
4717 |
|
4718 function isNodeOfType(node, type) { |
|
4719 return node && node.type === type; |
|
4720 } |
|
4721 /** |
|
4722 * Given an object implementing the NamedNodeMap interface, returns a plain |
|
4723 * object equivalent value of name, value key-value pairs. |
|
4724 * |
|
4725 * @see https://dom.spec.whatwg.org/#interface-namednodemap |
|
4726 * |
|
4727 * @param {NamedNodeMap} nodeMap NamedNodeMap to convert to object. |
|
4728 * |
|
4729 * @return {Object} Object equivalent value of NamedNodeMap. |
|
4730 */ |
|
4731 |
|
4732 |
|
4733 function getNamedNodeMapAsObject(nodeMap) { |
|
4734 const result = {}; |
|
4735 |
|
4736 for (let i = 0; i < nodeMap.length; i++) { |
|
4737 const { |
|
4738 name, |
|
4739 value |
|
4740 } = nodeMap[i]; |
|
4741 result[name] = value; |
|
4742 } |
|
4743 |
|
4744 return result; |
|
4745 } |
|
4746 /** |
|
4747 * Given a DOM Element or Text node, returns an equivalent block node. Throws |
|
4748 * if passed any node type other than element or text. |
|
4749 * |
|
4750 * @throws {TypeError} If non-element/text node is passed. |
|
4751 * |
|
4752 * @param {Node} domNode DOM node to convert. |
|
4753 * |
|
4754 * @return {WPBlockNode} Block node equivalent to DOM node. |
|
4755 */ |
|
4756 |
|
4757 function fromDOM(domNode) { |
|
4758 if (domNode.nodeType === domNode.TEXT_NODE) { |
|
4759 return domNode.nodeValue; |
|
4760 } |
|
4761 |
|
4762 if (domNode.nodeType !== domNode.ELEMENT_NODE) { |
|
4763 throw new TypeError('A block node can only be created from a node of type text or ' + 'element.'); |
|
4764 } |
|
4765 |
|
4766 return { |
|
4767 type: domNode.nodeName.toLowerCase(), |
|
4768 props: { ...getNamedNodeMapAsObject(domNode.attributes), |
|
4769 children: children_fromDOM(domNode.childNodes) |
|
4770 } |
|
4771 }; |
|
4772 } |
|
4773 /** |
|
4774 * Given a block node, returns its HTML string representation. |
|
4775 * |
|
4776 * @param {WPBlockNode} node Block node to convert to string. |
|
4777 * |
|
4778 * @return {string} String HTML representation of block node. |
|
4779 */ |
|
4780 |
|
4781 function toHTML(node) { |
|
4782 return children_toHTML([node]); |
|
4783 } |
|
4784 /** |
|
4785 * Given a selector, returns an hpq matcher generating a WPBlockNode value |
|
4786 * matching the selector result. |
|
4787 * |
|
4788 * @param {string} selector DOM selector. |
|
4789 * |
|
4790 * @return {Function} hpq matcher. |
|
4791 */ |
|
4792 |
|
4793 function node_matcher(selector) { |
|
4794 return domNode => { |
|
4795 let match = domNode; |
|
4796 |
|
4797 if (selector) { |
|
4798 match = domNode.querySelector(selector); |
|
4799 } |
|
4800 |
|
4801 try { |
|
4802 return fromDOM(match); |
|
4803 } catch (error) { |
|
4804 return null; |
|
4805 } |
|
4806 }; |
|
4807 } |
|
4808 /** |
|
4809 * Object of utility functions used in managing block attribute values of |
|
4810 * source `node`. |
|
4811 * |
|
4812 * @see https://github.com/WordPress/gutenberg/pull/10439 |
|
4813 * |
|
4814 * @deprecated since 4.0. The `node` source should not be used, and can be |
|
4815 * replaced by the `html` source. |
|
4816 * |
|
4817 * @private |
|
4818 */ |
|
4819 |
|
4820 /* harmony default export */ var api_node = ({ |
|
4821 isNodeOfType, |
|
4822 fromDOM, |
|
4823 toHTML, |
|
4824 matcher: node_matcher |
|
4825 }); |
|
4826 |
|
4827 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/children.js |
|
4828 /** |
|
4829 * External dependencies |
|
4830 */ |
|
4831 |
|
4832 /** |
|
4833 * WordPress dependencies |
|
4834 */ |
|
4835 |
|
4836 |
|
4837 /** |
|
4838 * Internal dependencies |
|
4839 */ |
|
4840 |
|
4841 |
|
4842 /** |
|
4843 * A representation of a block's rich text value. |
|
4844 * |
|
4845 * @typedef {WPBlockNode[]} WPBlockChildren |
|
4846 */ |
|
4847 |
|
4848 /** |
|
4849 * Given block children, returns a serialize-capable WordPress element. |
|
4850 * |
|
4851 * @param {WPBlockChildren} children Block children object to convert. |
|
4852 * |
|
4853 * @return {WPElement} A serialize-capable element. |
|
4854 */ |
|
4855 |
|
4856 function getSerializeCapableElement(children) { |
|
4857 // The fact that block children are compatible with the element serializer is |
|
4858 // merely an implementation detail that currently serves to be true, but |
|
4859 // should not be mistaken as being a guarantee on the external API. The |
|
4860 // public API only offers guarantees to work with strings (toHTML) and DOM |
|
4861 // elements (fromDOM), and should provide utilities to manipulate the value |
|
4862 // rather than expect consumers to inspect or construct its shape (concat). |
|
4863 return children; |
|
4864 } |
|
4865 /** |
|
4866 * Given block children, returns an array of block nodes. |
|
4867 * |
|
4868 * @param {WPBlockChildren} children Block children object to convert. |
|
4869 * |
|
4870 * @return {Array<WPBlockNode>} An array of individual block nodes. |
|
4871 */ |
|
4872 |
|
4873 function getChildrenArray(children) { |
|
4874 // The fact that block children are compatible with the element serializer |
|
4875 // is merely an implementation detail that currently serves to be true, but |
|
4876 // should not be mistaken as being a guarantee on the external API. |
|
4877 return children; |
|
4878 } |
|
4879 /** |
|
4880 * Given two or more block nodes, returns a new block node representing a |
|
4881 * concatenation of its values. |
|
4882 * |
|
4883 * @param {...WPBlockChildren} blockNodes Block nodes to concatenate. |
|
4884 * |
|
4885 * @return {WPBlockChildren} Concatenated block node. |
|
4886 */ |
|
4887 |
|
4888 |
|
4889 function concat(...blockNodes) { |
|
4890 const result = []; |
|
4891 |
|
4892 for (let i = 0; i < blockNodes.length; i++) { |
|
4893 const blockNode = Object(external_lodash_["castArray"])(blockNodes[i]); |
|
4894 |
|
4895 for (let j = 0; j < blockNode.length; j++) { |
|
4896 const child = blockNode[j]; |
|
4897 const canConcatToPreviousString = typeof child === 'string' && typeof result[result.length - 1] === 'string'; |
|
4898 |
|
4899 if (canConcatToPreviousString) { |
|
4900 result[result.length - 1] += child; |
|
4901 } else { |
|
4902 result.push(child); |
|
4903 } |
|
4904 } |
|
4905 } |
|
4906 |
|
4907 return result; |
|
4908 } |
|
4909 /** |
|
4910 * Given an iterable set of DOM nodes, returns equivalent block children. |
|
4911 * Ignores any non-element/text nodes included in set. |
|
4912 * |
|
4913 * @param {Iterable.<Node>} domNodes Iterable set of DOM nodes to convert. |
|
4914 * |
|
4915 * @return {WPBlockChildren} Block children equivalent to DOM nodes. |
|
4916 */ |
|
4917 |
|
4918 function children_fromDOM(domNodes) { |
|
4919 const result = []; |
|
4920 |
|
4921 for (let i = 0; i < domNodes.length; i++) { |
|
4922 try { |
|
4923 result.push(fromDOM(domNodes[i])); |
|
4924 } catch (error) {// Simply ignore if DOM node could not be converted. |
|
4925 } |
|
4926 } |
|
4927 |
|
4928 return result; |
|
4929 } |
|
4930 /** |
|
4931 * Given a block node, returns its HTML string representation. |
|
4932 * |
|
4933 * @param {WPBlockChildren} children Block node(s) to convert to string. |
|
4934 * |
|
4935 * @return {string} String HTML representation of block node. |
|
4936 */ |
|
4937 |
|
4938 function children_toHTML(children) { |
|
4939 const element = getSerializeCapableElement(children); |
|
4940 return Object(external_wp_element_["renderToString"])(element); |
|
4941 } |
|
4942 /** |
|
4943 * Given a selector, returns an hpq matcher generating a WPBlockChildren value |
|
4944 * matching the selector result. |
|
4945 * |
|
4946 * @param {string} selector DOM selector. |
|
4947 * |
|
4948 * @return {Function} hpq matcher. |
|
4949 */ |
|
4950 |
|
4951 function children_matcher(selector) { |
|
4952 return domNode => { |
|
4953 let match = domNode; |
|
4954 |
|
4955 if (selector) { |
|
4956 match = domNode.querySelector(selector); |
|
4957 } |
|
4958 |
|
4959 if (match) { |
|
4960 return children_fromDOM(match.childNodes); |
|
4961 } |
|
4962 |
|
4963 return []; |
|
4964 }; |
|
4965 } |
|
4966 /** |
|
4967 * Object of utility functions used in managing block attribute values of |
|
4968 * source `children`. |
|
4969 * |
|
4970 * @see https://github.com/WordPress/gutenberg/pull/10439 |
|
4971 * |
|
4972 * @deprecated since 4.0. The `children` source should not be used, and can be |
|
4973 * replaced by the `html` source. |
|
4974 * |
|
4975 * @private |
|
4976 */ |
|
4977 |
|
4978 /* harmony default export */ var api_children = ({ |
|
4979 concat, |
|
4980 getChildrenArray, |
|
4981 fromDOM: children_fromDOM, |
|
4982 toHTML: children_toHTML, |
|
4983 matcher: children_matcher |
|
4984 }); |
|
4985 |
|
4986 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser.js |
|
4987 /** |
|
4988 * External dependencies |
|
4989 */ |
|
4990 |
|
4991 |
|
4992 /** |
|
4993 * WordPress dependencies |
|
4994 */ |
|
4995 |
|
4996 |
|
4997 |
|
4998 |
|
4999 /** |
|
5000 * Internal dependencies |
|
5001 */ |
|
5002 |
|
5003 |
|
5004 |
|
5005 |
|
5006 |
|
5007 |
|
5008 |
|
5009 |
|
5010 /** |
|
5011 * Sources which are guaranteed to return a string value. |
|
5012 * |
|
5013 * @type {Set} |
|
5014 */ |
|
5015 |
|
5016 const STRING_SOURCES = new Set(['attribute', 'html', 'text', 'tag']); |
|
5017 /** |
|
5018 * Higher-order hpq matcher which enhances an attribute matcher to return true |
|
5019 * or false depending on whether the original matcher returns undefined. This |
|
5020 * is useful for boolean attributes (e.g. disabled) whose attribute values may |
|
5021 * be technically falsey (empty string), though their mere presence should be |
|
5022 * enough to infer as true. |
|
5023 * |
|
5024 * @param {Function} matcher Original hpq matcher. |
|
5025 * |
|
5026 * @return {Function} Enhanced hpq matcher. |
|
5027 */ |
|
5028 |
|
5029 const toBooleanAttributeMatcher = matcher => Object(external_lodash_["flow"])([matcher, // Expected values from `attr( 'disabled' )`: |
|
5030 // |
|
5031 // <input> |
|
5032 // - Value: `undefined` |
|
5033 // - Transformed: `false` |
|
5034 // |
|
5035 // <input disabled> |
|
5036 // - Value: `''` |
|
5037 // - Transformed: `true` |
|
5038 // |
|
5039 // <input disabled="disabled"> |
|
5040 // - Value: `'disabled'` |
|
5041 // - Transformed: `true` |
|
5042 value => value !== undefined]); |
|
5043 /** |
|
5044 * Returns true if value is of the given JSON schema type, or false otherwise. |
|
5045 * |
|
5046 * @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25 |
|
5047 * |
|
5048 * @param {*} value Value to test. |
|
5049 * @param {string} type Type to test. |
|
5050 * |
|
5051 * @return {boolean} Whether value is of type. |
|
5052 */ |
|
5053 |
|
5054 function isOfType(value, type) { |
|
5055 switch (type) { |
|
5056 case 'string': |
|
5057 return typeof value === 'string'; |
|
5058 |
|
5059 case 'boolean': |
|
5060 return typeof value === 'boolean'; |
|
5061 |
|
5062 case 'object': |
|
5063 return !!value && value.constructor === Object; |
|
5064 |
|
5065 case 'null': |
|
5066 return value === null; |
|
5067 |
|
5068 case 'array': |
|
5069 return Array.isArray(value); |
|
5070 |
|
5071 case 'integer': |
|
5072 case 'number': |
|
5073 return typeof value === 'number'; |
|
5074 } |
|
5075 |
|
5076 return true; |
|
5077 } |
|
5078 /** |
|
5079 * Returns true if value is of an array of given JSON schema types, or false |
|
5080 * otherwise. |
|
5081 * |
|
5082 * @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25 |
|
5083 * |
|
5084 * @param {*} value Value to test. |
|
5085 * @param {string[]} types Types to test. |
|
5086 * |
|
5087 * @return {boolean} Whether value is of types. |
|
5088 */ |
|
5089 |
|
5090 function isOfTypes(value, types) { |
|
5091 return types.some(type => isOfType(value, type)); |
|
5092 } |
|
5093 /** |
|
5094 * Returns true if value is valid per the given block attribute schema type |
|
5095 * definition, or false otherwise. |
|
5096 * |
|
5097 * @see https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.1 |
|
5098 * |
|
5099 * @param {*} value Value to test. |
|
5100 * @param {?(Array<string>|string)} type Block attribute schema type. |
|
5101 * |
|
5102 * @return {boolean} Whether value is valid. |
|
5103 */ |
|
5104 |
|
5105 function isValidByType(value, type) { |
|
5106 return type === undefined || isOfTypes(value, Object(external_lodash_["castArray"])(type)); |
|
5107 } |
|
5108 /** |
|
5109 * Returns true if value is valid per the given block attribute schema enum |
|
5110 * definition, or false otherwise. |
|
5111 * |
|
5112 * @see https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.2 |
|
5113 * |
|
5114 * @param {*} value Value to test. |
|
5115 * @param {?Array} enumSet Block attribute schema enum. |
|
5116 * |
|
5117 * @return {boolean} Whether value is valid. |
|
5118 */ |
|
5119 |
|
5120 function isValidByEnum(value, enumSet) { |
|
5121 return !Array.isArray(enumSet) || enumSet.includes(value); |
|
5122 } |
|
5123 /** |
|
5124 * Returns true if the given attribute schema describes a value which may be |
|
5125 * an ambiguous string. |
|
5126 * |
|
5127 * Some sources are ambiguously serialized as strings, for which value casting |
|
5128 * is enabled. This is only possible when a singular type is assigned to the |
|
5129 * attribute schema, since the string ambiguity makes it impossible to know the |
|
5130 * correct type of multiple to which to cast. |
|
5131 * |
|
5132 * @param {Object} attributeSchema Attribute's schema. |
|
5133 * |
|
5134 * @return {boolean} Whether attribute schema defines an ambiguous string |
|
5135 * source. |
|
5136 */ |
|
5137 |
|
5138 function isAmbiguousStringSource(attributeSchema) { |
|
5139 const { |
|
5140 source, |
|
5141 type |
|
5142 } = attributeSchema; |
|
5143 const isStringSource = STRING_SOURCES.has(source); |
|
5144 const isSingleType = typeof type === 'string'; |
|
5145 return isStringSource && isSingleType; |
|
5146 } |
|
5147 /** |
|
5148 * Returns an hpq matcher given a source object. |
|
5149 * |
|
5150 * @param {Object} sourceConfig Attribute Source object. |
|
5151 * |
|
5152 * @return {Function} A hpq Matcher. |
|
5153 */ |
|
5154 |
|
5155 function matcherFromSource(sourceConfig) { |
|
5156 switch (sourceConfig.source) { |
|
5157 case 'attribute': |
|
5158 let matcher = attr(sourceConfig.selector, sourceConfig.attribute); |
|
5159 |
|
5160 if (sourceConfig.type === 'boolean') { |
|
5161 matcher = toBooleanAttributeMatcher(matcher); |
|
5162 } |
|
5163 |
|
5164 return matcher; |
|
5165 |
|
5166 case 'html': |
|
5167 return matchers_html(sourceConfig.selector, sourceConfig.multiline); |
|
5168 |
|
5169 case 'text': |
|
5170 return es_text(sourceConfig.selector); |
|
5171 |
|
5172 case 'children': |
|
5173 return children_matcher(sourceConfig.selector); |
|
5174 |
|
5175 case 'node': |
|
5176 return node_matcher(sourceConfig.selector); |
|
5177 |
|
5178 case 'query': |
|
5179 const subMatchers = Object(external_lodash_["mapValues"])(sourceConfig.query, matcherFromSource); |
|
5180 return query(sourceConfig.selector, subMatchers); |
|
5181 |
|
5182 case 'tag': |
|
5183 return Object(external_lodash_["flow"])([prop(sourceConfig.selector, 'nodeName'), nodeName => nodeName ? nodeName.toLowerCase() : undefined]); |
|
5184 |
|
5185 default: |
|
5186 // eslint-disable-next-line no-console |
|
5187 console.error(`Unknown source type "${sourceConfig.source}"`); |
|
5188 } |
|
5189 } |
|
5190 /** |
|
5191 * Given a block's raw content and an attribute's schema returns the attribute's |
|
5192 * value depending on its source. |
|
5193 * |
|
5194 * @param {string} innerHTML Block's raw content. |
|
5195 * @param {Object} attributeSchema Attribute's schema. |
|
5196 * |
|
5197 * @return {*} Attribute value. |
|
5198 */ |
|
5199 |
|
5200 function parseWithAttributeSchema(innerHTML, attributeSchema) { |
|
5201 return parse(innerHTML, matcherFromSource(attributeSchema)); |
|
5202 } |
|
5203 /** |
|
5204 * Given an attribute key, an attribute's schema, a block's raw content and the |
|
5205 * commentAttributes returns the attribute value depending on its source |
|
5206 * definition of the given attribute key. |
|
5207 * |
|
5208 * @param {string} attributeKey Attribute key. |
|
5209 * @param {Object} attributeSchema Attribute's schema. |
|
5210 * @param {string} innerHTML Block's raw content. |
|
5211 * @param {Object} commentAttributes Block's comment attributes. |
|
5212 * |
|
5213 * @return {*} Attribute value. |
|
5214 */ |
|
5215 |
|
5216 function getBlockAttribute(attributeKey, attributeSchema, innerHTML, commentAttributes) { |
|
5217 const { |
|
5218 type, |
|
5219 enum: enumSet |
|
5220 } = attributeSchema; |
|
5221 let value; |
|
5222 |
|
5223 switch (attributeSchema.source) { |
|
5224 // An undefined source means that it's an attribute serialized to the |
|
5225 // block's "comment". |
|
5226 case undefined: |
|
5227 value = commentAttributes ? commentAttributes[attributeKey] : undefined; |
|
5228 break; |
|
5229 |
|
5230 case 'attribute': |
|
5231 case 'property': |
|
5232 case 'html': |
|
5233 case 'text': |
|
5234 case 'children': |
|
5235 case 'node': |
|
5236 case 'query': |
|
5237 case 'tag': |
|
5238 value = parseWithAttributeSchema(innerHTML, attributeSchema); |
|
5239 break; |
|
5240 } |
|
5241 |
|
5242 if (!isValidByType(value, type) || !isValidByEnum(value, enumSet)) { |
|
5243 // Reject the value if it is not valid. Reverting to the undefined |
|
5244 // value ensures the default is respected, if applicable. |
|
5245 value = undefined; |
|
5246 } |
|
5247 |
|
5248 if (value === undefined) { |
|
5249 return attributeSchema.default; |
|
5250 } |
|
5251 |
|
5252 return value; |
|
5253 } |
|
5254 /** |
|
5255 * Returns the block attributes of a registered block node given its type. |
|
5256 * |
|
5257 * @param {string|Object} blockTypeOrName Block type or name. |
|
5258 * @param {string} innerHTML Raw block content. |
|
5259 * @param {?Object} attributes Known block attributes (from delimiters). |
|
5260 * |
|
5261 * @return {Object} All block attributes. |
|
5262 */ |
|
5263 |
|
5264 function getBlockAttributes(blockTypeOrName, innerHTML, attributes = {}) { |
|
5265 const blockType = normalizeBlockType(blockTypeOrName); |
|
5266 const blockAttributes = Object(external_lodash_["mapValues"])(blockType.attributes, (attributeSchema, attributeKey) => { |
|
5267 return getBlockAttribute(attributeKey, attributeSchema, innerHTML, attributes); |
|
5268 }); |
|
5269 return Object(external_wp_hooks_["applyFilters"])('blocks.getBlockAttributes', blockAttributes, blockType, innerHTML, attributes); |
|
5270 } |
|
5271 /** |
|
5272 * Given a block object, returns a new copy of the block with any applicable |
|
5273 * deprecated migrations applied, or the original block if it was both valid |
|
5274 * and no eligible migrations exist. |
|
5275 * |
|
5276 * @param {WPBlock} block Original block object. |
|
5277 * @param {Object} parsedAttributes Attributes as parsed from the initial |
|
5278 * block markup. |
|
5279 * |
|
5280 * @return {WPBlock} Migrated block object. |
|
5281 */ |
|
5282 |
|
5283 function getMigratedBlock(block, parsedAttributes) { |
|
5284 const blockType = registration_getBlockType(block.name); |
|
5285 const { |
|
5286 deprecated: deprecatedDefinitions |
|
5287 } = blockType; // Bail early if there are no registered deprecations to be handled. |
|
5288 |
|
5289 if (!deprecatedDefinitions || !deprecatedDefinitions.length) { |
|
5290 return block; |
|
5291 } |
|
5292 |
|
5293 const { |
|
5294 originalContent, |
|
5295 innerBlocks |
|
5296 } = block; // By design, blocks lack any sort of version tracking. Instead, to process |
|
5297 // outdated content the system operates a queue out of all the defined |
|
5298 // attribute shapes and tries each definition until the input produces a |
|
5299 // valid result. This mechanism seeks to avoid polluting the user-space with |
|
5300 // machine-specific code. An invalid block is thus a block that could not be |
|
5301 // matched successfully with any of the registered deprecation definitions. |
|
5302 |
|
5303 for (let i = 0; i < deprecatedDefinitions.length; i++) { |
|
5304 // A block can opt into a migration even if the block is valid by |
|
5305 // defining `isEligible` on its deprecation. If the block is both valid |
|
5306 // and does not opt to migrate, skip. |
|
5307 const { |
|
5308 isEligible = external_lodash_["stubFalse"] |
|
5309 } = deprecatedDefinitions[i]; |
|
5310 |
|
5311 if (block.isValid && !isEligible(parsedAttributes, innerBlocks)) { |
|
5312 continue; |
|
5313 } // Block type properties which could impact either serialization or |
|
5314 // parsing are not considered in the deprecated block type by default, |
|
5315 // and must be explicitly provided. |
|
5316 |
|
5317 |
|
5318 const deprecatedBlockType = Object.assign(Object(external_lodash_["omit"])(blockType, DEPRECATED_ENTRY_KEYS), deprecatedDefinitions[i]); |
|
5319 let migratedAttributes = getBlockAttributes(deprecatedBlockType, originalContent, parsedAttributes); // Ignore the deprecation if it produces a block which is not valid. |
|
5320 |
|
5321 const { |
|
5322 isValid, |
|
5323 validationIssues |
|
5324 } = getBlockContentValidationResult(deprecatedBlockType, migratedAttributes, originalContent); // An invalid block does not imply incorrect HTML but the fact block |
|
5325 // source information could be lost on reserialization. |
|
5326 |
|
5327 if (!isValid) { |
|
5328 block = { ...block, |
|
5329 validationIssues: [...Object(external_lodash_["get"])(block, 'validationIssues', []), ...validationIssues] |
|
5330 }; |
|
5331 continue; |
|
5332 } |
|
5333 |
|
5334 let migratedInnerBlocks = innerBlocks; // A block may provide custom behavior to assign new attributes and/or |
|
5335 // inner blocks. |
|
5336 |
|
5337 const { |
|
5338 migrate |
|
5339 } = deprecatedBlockType; |
|
5340 |
|
5341 if (migrate) { |
|
5342 [migratedAttributes = parsedAttributes, migratedInnerBlocks = innerBlocks] = Object(external_lodash_["castArray"])(migrate(migratedAttributes, innerBlocks)); |
|
5343 } |
|
5344 |
|
5345 block = { ...block, |
|
5346 attributes: migratedAttributes, |
|
5347 innerBlocks: migratedInnerBlocks, |
|
5348 isValid: true |
|
5349 }; |
|
5350 } |
|
5351 |
|
5352 return block; |
|
5353 } |
|
5354 /** |
|
5355 * Convert legacy blocks to their canonical form. This function is used |
|
5356 * both in the parser level for previous content and to convert such blocks |
|
5357 * used in Custom Post Types templates. |
|
5358 * |
|
5359 * @param {string} name The block's name |
|
5360 * @param {Object} attributes The block's attributes |
|
5361 * |
|
5362 * @return {Object} The block's name and attributes, changed accordingly if a match was found |
|
5363 */ |
|
5364 |
|
5365 function convertLegacyBlocks(name, attributes) { |
|
5366 const newAttributes = { ...attributes |
|
5367 }; // Convert 'core/cover-image' block in existing content to 'core/cover'. |
|
5368 |
|
5369 if ('core/cover-image' === name) { |
|
5370 name = 'core/cover'; |
|
5371 } // Convert 'core/text' blocks in existing content to 'core/paragraph'. |
|
5372 |
|
5373 |
|
5374 if ('core/text' === name || 'core/cover-text' === name) { |
|
5375 name = 'core/paragraph'; |
|
5376 } // Convert derivative blocks such as 'core/social-link-wordpress' to the |
|
5377 // canonical form 'core/social-link'. |
|
5378 |
|
5379 |
|
5380 if (name && name.indexOf('core/social-link-') === 0) { |
|
5381 // Capture `social-link-wordpress` into `{"service":"wordpress"}` |
|
5382 newAttributes.service = name.substring(17); |
|
5383 name = 'core/social-link'; |
|
5384 } // Convert derivative blocks such as 'core-embed/instagram' to the |
|
5385 // canonical form 'core/embed'. |
|
5386 |
|
5387 |
|
5388 if (name && name.indexOf('core-embed/') === 0) { |
|
5389 // Capture `core-embed/instagram` into `{"providerNameSlug":"instagram"}` |
|
5390 const providerSlug = name.substring(11); |
|
5391 const deprecated = { |
|
5392 speaker: 'speaker-deck', |
|
5393 polldaddy: 'crowdsignal' |
|
5394 }; |
|
5395 newAttributes.providerNameSlug = providerSlug in deprecated ? deprecated[providerSlug] : providerSlug; // this is needed as the `responsive` attribute was passed |
|
5396 // in a different way before the refactoring to block variations |
|
5397 |
|
5398 if (!['amazon-kindle', 'wordpress'].includes(providerSlug)) { |
|
5399 newAttributes.responsive = true; |
|
5400 } |
|
5401 |
|
5402 name = 'core/embed'; |
|
5403 } // Convert 'core/query-loop' blocks in existing content to 'core/post-template'. |
|
5404 // TODO: Remove this check when WordPress 5.9 is released. |
|
5405 |
|
5406 |
|
5407 if (name === 'core/query-loop') { |
|
5408 name = 'core/post-template'; |
|
5409 } |
|
5410 |
|
5411 return { |
|
5412 name, |
|
5413 attributes: newAttributes |
|
5414 }; |
|
5415 } |
|
5416 /** |
|
5417 * Creates a block with fallback to the unknown type handler. |
|
5418 * |
|
5419 * @param {Object} blockNode Parsed block node. |
|
5420 * |
|
5421 * @return {?Object} An initialized block object (if possible). |
|
5422 */ |
|
5423 |
|
5424 function createBlockWithFallback(blockNode) { |
|
5425 const { |
|
5426 blockName: originalName |
|
5427 } = blockNode; // The fundamental structure of a blocktype includes its attributes, inner |
|
5428 // blocks, and inner HTML. It is important to distinguish inner blocks from |
|
5429 // the HTML content of the block as only the latter is relevant for block |
|
5430 // validation and edit operations. |
|
5431 |
|
5432 let { |
|
5433 attrs: attributes, |
|
5434 innerBlocks = [], |
|
5435 innerHTML |
|
5436 } = blockNode; |
|
5437 const { |
|
5438 innerContent |
|
5439 } = blockNode; // Blocks that don't have a registered handler are considered freeform. |
|
5440 |
|
5441 const freeformContentFallbackBlock = getFreeformContentHandlerName(); |
|
5442 const unregisteredFallbackBlock = getUnregisteredTypeHandlerName() || freeformContentFallbackBlock; |
|
5443 attributes = attributes || {}; // Trim content to avoid creation of intermediary freeform segments. |
|
5444 |
|
5445 innerHTML = innerHTML.trim(); // Use type from block content if available. Otherwise, default to the |
|
5446 // freeform content fallback. |
|
5447 |
|
5448 let name = originalName || freeformContentFallbackBlock; |
|
5449 ({ |
|
5450 name, |
|
5451 attributes |
|
5452 } = convertLegacyBlocks(name, attributes)); // Fallback content may be upgraded from classic content expecting implicit |
|
5453 // automatic paragraphs, so preserve them. Assumes wpautop is idempotent, |
|
5454 // meaning there are no negative consequences to repeated autop calls. |
|
5455 |
|
5456 if (name === freeformContentFallbackBlock) { |
|
5457 innerHTML = Object(external_wp_autop_["autop"])(innerHTML).trim(); |
|
5458 } // Try finding the type for known block name, else fall back again. |
|
5459 |
|
5460 |
|
5461 let blockType = registration_getBlockType(name); |
|
5462 |
|
5463 if (!blockType) { |
|
5464 // Since the constituents of the block node are extracted at the start |
|
5465 // of the present function, construct a new object rather than reuse |
|
5466 // `blockNode`. |
|
5467 const reconstitutedBlockNode = { |
|
5468 attrs: attributes, |
|
5469 blockName: originalName, |
|
5470 innerBlocks, |
|
5471 innerContent |
|
5472 }; // Preserve undelimited content for use by the unregistered type |
|
5473 // handler. A block node's `innerHTML` isn't enough, as that field only |
|
5474 // carries the block's own HTML and not its nested blocks. |
|
5475 |
|
5476 const originalUndelimitedContent = serializeBlockNode(reconstitutedBlockNode, { |
|
5477 isCommentDelimited: false |
|
5478 }); // Preserve full block content for use by the unregistered type |
|
5479 // handler, block boundaries included. |
|
5480 |
|
5481 const originalContent = serializeBlockNode(reconstitutedBlockNode, { |
|
5482 isCommentDelimited: true |
|
5483 }); // If detected as a block which is not registered, preserve comment |
|
5484 // delimiters in content of unregistered type handler. |
|
5485 |
|
5486 if (name) { |
|
5487 innerHTML = originalContent; |
|
5488 } |
|
5489 |
|
5490 name = unregisteredFallbackBlock; |
|
5491 attributes = { |
|
5492 originalName, |
|
5493 originalContent, |
|
5494 originalUndelimitedContent |
|
5495 }; |
|
5496 blockType = registration_getBlockType(name); |
|
5497 } // Coerce inner blocks from parsed form to canonical form. |
|
5498 |
|
5499 |
|
5500 innerBlocks = innerBlocks.map(createBlockWithFallback); // Remove `undefined` innerBlocks. |
|
5501 // |
|
5502 // This is a temporary fix to prevent unrecoverable TypeErrors when handling unexpectedly |
|
5503 // empty freeform block nodes. See https://github.com/WordPress/gutenberg/pull/17164. |
|
5504 |
|
5505 innerBlocks = innerBlocks.filter(innerBlock => innerBlock); |
|
5506 const isFallbackBlock = name === freeformContentFallbackBlock || name === unregisteredFallbackBlock; // Include in set only if type was determined. |
|
5507 |
|
5508 if (!blockType || !innerHTML && isFallbackBlock) { |
|
5509 return; |
|
5510 } |
|
5511 |
|
5512 let block = createBlock(name, getBlockAttributes(blockType, innerHTML, attributes), innerBlocks); // Block validation assumes an idempotent operation from source block to serialized block |
|
5513 // provided there are no changes in attributes. The validation procedure thus compares the |
|
5514 // provided source value with the serialized output before there are any modifications to |
|
5515 // the block. When both match, the block is marked as valid. |
|
5516 |
|
5517 if (!isFallbackBlock) { |
|
5518 const { |
|
5519 isValid, |
|
5520 validationIssues |
|
5521 } = getBlockContentValidationResult(blockType, block.attributes, innerHTML); |
|
5522 block.isValid = isValid; |
|
5523 block.validationIssues = validationIssues; |
|
5524 } // Preserve original content for future use in case the block is parsed |
|
5525 // as invalid, or future serialization attempt results in an error. |
|
5526 |
|
5527 |
|
5528 block.originalContent = block.originalContent || innerHTML; // Ensure all necessary migrations are applied to the block. |
|
5529 |
|
5530 block = getMigratedBlock(block, attributes); |
|
5531 |
|
5532 if (block.validationIssues && block.validationIssues.length > 0) { |
|
5533 if (block.isValid) { |
|
5534 // eslint-disable-next-line no-console |
|
5535 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, block.attributes), block.originalContent); |
|
5536 } else { |
|
5537 block.validationIssues.forEach(({ |
|
5538 log, |
|
5539 args |
|
5540 }) => log(...args)); |
|
5541 } |
|
5542 } |
|
5543 |
|
5544 return block; |
|
5545 } |
|
5546 /** |
|
5547 * Serializes a block node into the native HTML-comment-powered block format. |
|
5548 * CAVEAT: This function is intended for reserializing blocks as parsed by |
|
5549 * valid parsers and skips any validation steps. This is NOT a generic |
|
5550 * serialization function for in-memory blocks. For most purposes, see the |
|
5551 * following functions available in the `@wordpress/blocks` package: |
|
5552 * |
|
5553 * @see serializeBlock |
|
5554 * @see serialize |
|
5555 * |
|
5556 * For more on the format of block nodes as returned by valid parsers: |
|
5557 * |
|
5558 * @see `@wordpress/block-serialization-default-parser` package |
|
5559 * @see `@wordpress/block-serialization-spec-parser` package |
|
5560 * |
|
5561 * @param {Object} blockNode A block node as returned by a valid parser. |
|
5562 * @param {?Object} options Serialization options. |
|
5563 * @param {?boolean} options.isCommentDelimited Whether to output HTML comments around blocks. |
|
5564 * |
|
5565 * @return {string} An HTML string representing a block. |
|
5566 */ |
|
5567 |
|
5568 function serializeBlockNode(blockNode, options = {}) { |
|
5569 const { |
|
5570 isCommentDelimited = true |
|
5571 } = options; |
|
5572 const { |
|
5573 blockName, |
|
5574 attrs = {}, |
|
5575 innerBlocks = [], |
|
5576 innerContent = [] |
|
5577 } = blockNode; |
|
5578 let childIndex = 0; |
|
5579 const content = innerContent.map(item => // `null` denotes a nested block, otherwise we have an HTML fragment. |
|
5580 item !== null ? item : serializeBlockNode(innerBlocks[childIndex++], options)).join('\n').replace(/\n+/g, '\n').trim(); |
|
5581 return isCommentDelimited ? getCommentDelimitedContent(blockName, attrs, content) : content; |
|
5582 } |
|
5583 /** |
|
5584 * Creates a parse implementation for the post content which returns a list of blocks. |
|
5585 * |
|
5586 * @param {Function} parseImplementation Parse implementation. |
|
5587 * |
|
5588 * @return {Function} An implementation which parses the post content. |
|
5589 */ |
|
5590 |
|
5591 const createParse = parseImplementation => content => parseImplementation(content).reduce((accumulator, blockNode) => { |
|
5592 const block = createBlockWithFallback(blockNode); |
|
5593 |
|
5594 if (block) { |
|
5595 accumulator.push(block); |
|
5596 } |
|
5597 |
|
5598 return accumulator; |
|
5599 }, []); |
|
5600 /** |
|
5601 * Utilizes an optimized token-driven parser based on the Gutenberg grammar spec |
|
5602 * defined through a parsing expression grammar to take advantage of the regular |
|
5603 * cadence provided by block delimiters -- composed syntactically through HTML |
|
5604 * comments -- which, given a general HTML document as an input, returns a block |
|
5605 * list array representation. |
|
5606 * |
|
5607 * This is a recursive-descent parser that scans linearly once through the input |
|
5608 * document. Instead of directly recursing it utilizes a trampoline mechanism to |
|
5609 * prevent stack overflow. This initial pass is mainly interested in separating |
|
5610 * and isolating the blocks serialized in the document and manifestly not in the |
|
5611 * content within the blocks. |
|
5612 * |
|
5613 * @see |
|
5614 * https://developer.wordpress.org/block-editor/packages/packages-block-serialization-default-parser/ |
|
5615 * |
|
5616 * @param {string} content The post content. |
|
5617 * |
|
5618 * @return {Array} Block list. |
|
5619 */ |
|
5620 |
|
5621 |
|
5622 const parseWithGrammar = createParse(external_wp_blockSerializationDefaultParser_["parse"]); |
|
5623 /* harmony default export */ var parser = (parseWithGrammar); |
|
5624 |
|
5625 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/get-raw-transforms.js |
|
5626 /** |
|
5627 * External dependencies |
|
5628 */ |
|
5629 |
|
5630 /** |
|
5631 * Internal dependencies |
|
5632 */ |
|
5633 |
|
5634 |
|
5635 function getRawTransforms() { |
|
5636 return Object(external_lodash_["filter"])(getBlockTransforms('from'), { |
|
5637 type: 'raw' |
|
5638 }).map(transform => { |
|
5639 return transform.isMatch ? transform : { ...transform, |
|
5640 isMatch: node => transform.selector && node.matches(transform.selector) |
|
5641 }; |
|
5642 }); |
|
5643 } |
|
5644 |
|
5645 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/html-to-blocks.js |
|
5646 /** |
|
5647 * Internal dependencies |
|
5648 */ |
|
5649 |
|
5650 |
|
5651 |
|
5652 /** |
|
5653 * Converts HTML directly to blocks. Looks for a matching transform for each |
|
5654 * top-level tag. The HTML should be filtered to not have any text between |
|
5655 * top-level tags and formatted in a way that blocks can handle the HTML. |
|
5656 * |
|
5657 * @param {string} html HTML to convert. |
|
5658 * |
|
5659 * @return {Array} An array of blocks. |
|
5660 */ |
|
5661 |
|
5662 function htmlToBlocks(html) { |
|
5663 const doc = document.implementation.createHTMLDocument(''); |
|
5664 doc.body.innerHTML = html; |
|
5665 return Array.from(doc.body.children).flatMap(node => { |
|
5666 const rawTransform = findTransform(getRawTransforms(), ({ |
|
5667 isMatch |
|
5668 }) => isMatch(node)); |
|
5669 |
|
5670 if (!rawTransform) { |
|
5671 return createBlock( // Should not be hardcoded. |
|
5672 'core/html', getBlockAttributes('core/html', node.outerHTML)); |
|
5673 } |
|
5674 |
|
5675 const { |
|
5676 transform, |
|
5677 blockName |
|
5678 } = rawTransform; |
|
5679 |
|
5680 if (transform) { |
|
5681 return transform(node); |
|
5682 } |
|
5683 |
|
5684 return createBlock(blockName, getBlockAttributes(blockName, node.outerHTML)); |
|
5685 }); |
|
5686 } |
|
5687 |
|
5688 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/normalise-blocks.js |
|
5689 /** |
|
5690 * WordPress dependencies |
|
5691 */ |
|
5692 |
|
5693 function normaliseBlocks(HTML) { |
|
5694 const decuDoc = document.implementation.createHTMLDocument(''); |
|
5695 const accuDoc = document.implementation.createHTMLDocument(''); |
|
5696 const decu = decuDoc.body; |
|
5697 const accu = accuDoc.body; |
|
5698 decu.innerHTML = HTML; |
|
5699 |
|
5700 while (decu.firstChild) { |
|
5701 const node = decu.firstChild; // Text nodes: wrap in a paragraph, or append to previous. |
|
5702 |
|
5703 if (node.nodeType === node.TEXT_NODE) { |
|
5704 if (Object(external_wp_dom_["isEmpty"])(node)) { |
|
5705 decu.removeChild(node); |
|
5706 } else { |
|
5707 if (!accu.lastChild || accu.lastChild.nodeName !== 'P') { |
|
5708 accu.appendChild(accuDoc.createElement('P')); |
|
5709 } |
|
5710 |
|
5711 accu.lastChild.appendChild(node); |
|
5712 } // Element nodes. |
|
5713 |
|
5714 } else if (node.nodeType === node.ELEMENT_NODE) { |
|
5715 // BR nodes: create a new paragraph on double, or append to previous. |
|
5716 if (node.nodeName === 'BR') { |
|
5717 if (node.nextSibling && node.nextSibling.nodeName === 'BR') { |
|
5718 accu.appendChild(accuDoc.createElement('P')); |
|
5719 decu.removeChild(node.nextSibling); |
|
5720 } // Don't append to an empty paragraph. |
|
5721 |
|
5722 |
|
5723 if (accu.lastChild && accu.lastChild.nodeName === 'P' && accu.lastChild.hasChildNodes()) { |
|
5724 accu.lastChild.appendChild(node); |
|
5725 } else { |
|
5726 decu.removeChild(node); |
|
5727 } |
|
5728 } else if (node.nodeName === 'P') { |
|
5729 // Only append non-empty paragraph nodes. |
|
5730 if (Object(external_wp_dom_["isEmpty"])(node)) { |
|
5731 decu.removeChild(node); |
|
5732 } else { |
|
5733 accu.appendChild(node); |
|
5734 } |
|
5735 } else if (Object(external_wp_dom_["isPhrasingContent"])(node)) { |
|
5736 if (!accu.lastChild || accu.lastChild.nodeName !== 'P') { |
|
5737 accu.appendChild(accuDoc.createElement('P')); |
|
5738 } |
|
5739 |
|
5740 accu.lastChild.appendChild(node); |
|
5741 } else { |
|
5742 accu.appendChild(node); |
|
5743 } |
|
5744 } else { |
|
5745 decu.removeChild(node); |
|
5746 } |
|
5747 } |
|
5748 |
|
5749 return accu.innerHTML; |
|
5750 } |
|
5751 |
|
5752 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/special-comment-converter.js |
|
5753 /** |
|
5754 * WordPress dependencies |
|
5755 */ |
|
5756 |
|
5757 /** |
|
5758 * Looks for `<!--nextpage-->` and `<!--more-->` comments, as well as the |
|
5759 * `<!--more Some text-->` variant and its `<!--noteaser-->` companion, |
|
5760 * and replaces them with a custom element representing a future block. |
|
5761 * |
|
5762 * The custom element is a way to bypass the rest of the `raw-handling` |
|
5763 * transforms, which would eliminate other kinds of node with which to carry |
|
5764 * `<!--more-->`'s data: nodes with `data` attributes, empty paragraphs, etc. |
|
5765 * |
|
5766 * The custom element is then expected to be recognized by any registered |
|
5767 * block's `raw` transform. |
|
5768 * |
|
5769 * @param {Node} node The node to be processed. |
|
5770 * @param {Document} doc The document of the node. |
|
5771 * @return {void} |
|
5772 */ |
|
5773 |
|
5774 function specialCommentConverter(node, doc) { |
|
5775 if (node.nodeType !== node.COMMENT_NODE) { |
|
5776 return; |
|
5777 } |
|
5778 |
|
5779 if (node.nodeValue === 'nextpage') { |
|
5780 Object(external_wp_dom_["replace"])(node, createNextpage(doc)); |
|
5781 return; |
|
5782 } |
|
5783 |
|
5784 if (node.nodeValue.indexOf('more') === 0) { |
|
5785 // Grab any custom text in the comment. |
|
5786 const customText = node.nodeValue.slice(4).trim(); |
|
5787 /* |
|
5788 * When a `<!--more-->` comment is found, we need to look for any |
|
5789 * `<!--noteaser-->` sibling, but it may not be a direct sibling |
|
5790 * (whitespace typically lies in between) |
|
5791 */ |
|
5792 |
|
5793 let sibling = node; |
|
5794 let noTeaser = false; |
|
5795 |
|
5796 while (sibling = sibling.nextSibling) { |
|
5797 if (sibling.nodeType === sibling.COMMENT_NODE && sibling.nodeValue === 'noteaser') { |
|
5798 noTeaser = true; |
|
5799 Object(external_wp_dom_["remove"])(sibling); |
|
5800 break; |
|
5801 } |
|
5802 } |
|
5803 |
|
5804 Object(external_wp_dom_["replace"])(node, createMore(customText, noTeaser, doc)); |
|
5805 } |
|
5806 } |
|
5807 |
|
5808 function createMore(customText, noTeaser, doc) { |
|
5809 const node = doc.createElement('wp-block'); |
|
5810 node.dataset.block = 'core/more'; |
|
5811 |
|
5812 if (customText) { |
|
5813 node.dataset.customText = customText; |
|
5814 } |
|
5815 |
|
5816 if (noTeaser) { |
|
5817 // "Boolean" data attribute |
|
5818 node.dataset.noTeaser = ''; |
|
5819 } |
|
5820 |
|
5821 return node; |
|
5822 } |
|
5823 |
|
5824 function createNextpage(doc) { |
|
5825 const node = doc.createElement('wp-block'); |
|
5826 node.dataset.block = 'core/nextpage'; |
|
5827 return node; |
|
5828 } |
|
5829 |
|
5830 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/comment-remover.js |
|
5831 /** |
|
5832 * WordPress dependencies |
|
5833 */ |
|
5834 |
|
5835 /** |
|
5836 * Looks for comments, and removes them. |
|
5837 * |
|
5838 * @param {Node} node The node to be processed. |
|
5839 * @return {void} |
|
5840 */ |
|
5841 |
|
5842 function commentRemover(node) { |
|
5843 if (node.nodeType === node.COMMENT_NODE) { |
|
5844 Object(external_wp_dom_["remove"])(node); |
|
5845 } |
|
5846 } |
|
5847 |
|
5848 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/is-inline-content.js |
|
5849 /** |
|
5850 * External dependencies |
|
5851 */ |
|
5852 |
|
5853 /** |
|
5854 * WordPress dependencies |
|
5855 */ |
|
5856 |
|
5857 |
|
5858 /** |
|
5859 * Checks if the given node should be considered inline content, optionally |
|
5860 * depending on a context tag. |
|
5861 * |
|
5862 * @param {Node} node Node name. |
|
5863 * @param {string} contextTag Tag name. |
|
5864 * |
|
5865 * @return {boolean} True if the node is inline content, false if nohe. |
|
5866 */ |
|
5867 |
|
5868 function isInline(node, contextTag) { |
|
5869 if (Object(external_wp_dom_["isTextContent"])(node)) { |
|
5870 return true; |
|
5871 } |
|
5872 |
|
5873 if (!contextTag) { |
|
5874 return false; |
|
5875 } |
|
5876 |
|
5877 const tag = node.nodeName.toLowerCase(); |
|
5878 const inlineAllowedTagGroups = [['ul', 'li', 'ol'], ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']]; |
|
5879 return inlineAllowedTagGroups.some(tagGroup => Object(external_lodash_["difference"])([tag, contextTag], tagGroup).length === 0); |
|
5880 } |
|
5881 |
|
5882 function deepCheck(nodes, contextTag) { |
|
5883 return nodes.every(node => isInline(node, contextTag) && deepCheck(Array.from(node.children), contextTag)); |
|
5884 } |
|
5885 |
|
5886 function isDoubleBR(node) { |
|
5887 return node.nodeName === 'BR' && node.previousSibling && node.previousSibling.nodeName === 'BR'; |
|
5888 } |
|
5889 |
|
5890 function isInlineContent(HTML, contextTag) { |
|
5891 const doc = document.implementation.createHTMLDocument(''); |
|
5892 doc.body.innerHTML = HTML; |
|
5893 const nodes = Array.from(doc.body.children); |
|
5894 return !nodes.some(isDoubleBR) && deepCheck(nodes, contextTag); |
|
5895 } |
|
5896 |
|
5897 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/phrasing-content-reducer.js |
|
5898 /** |
|
5899 * External dependencies |
|
5900 */ |
|
5901 |
|
5902 /** |
|
5903 * WordPress dependencies |
|
5904 */ |
|
5905 |
|
5906 |
|
5907 function phrasingContentReducer(node, doc) { |
|
5908 // In jsdom-jscore, 'node.style' can be null. |
|
5909 // TODO: Explore fixing this by patching jsdom-jscore. |
|
5910 if (node.nodeName === 'SPAN' && node.style) { |
|
5911 const { |
|
5912 fontWeight, |
|
5913 fontStyle, |
|
5914 textDecorationLine, |
|
5915 textDecoration, |
|
5916 verticalAlign |
|
5917 } = node.style; |
|
5918 |
|
5919 if (fontWeight === 'bold' || fontWeight === '700') { |
|
5920 Object(external_wp_dom_["wrap"])(doc.createElement('strong'), node); |
|
5921 } |
|
5922 |
|
5923 if (fontStyle === 'italic') { |
|
5924 Object(external_wp_dom_["wrap"])(doc.createElement('em'), node); |
|
5925 } // Some DOM implementations (Safari, JSDom) don't support |
|
5926 // style.textDecorationLine, so we check style.textDecoration as a |
|
5927 // fallback. |
|
5928 |
|
5929 |
|
5930 if (textDecorationLine === 'line-through' || Object(external_lodash_["includes"])(textDecoration, 'line-through')) { |
|
5931 Object(external_wp_dom_["wrap"])(doc.createElement('s'), node); |
|
5932 } |
|
5933 |
|
5934 if (verticalAlign === 'super') { |
|
5935 Object(external_wp_dom_["wrap"])(doc.createElement('sup'), node); |
|
5936 } else if (verticalAlign === 'sub') { |
|
5937 Object(external_wp_dom_["wrap"])(doc.createElement('sub'), node); |
|
5938 } |
|
5939 } else if (node.nodeName === 'B') { |
|
5940 node = Object(external_wp_dom_["replaceTag"])(node, 'strong'); |
|
5941 } else if (node.nodeName === 'I') { |
|
5942 node = Object(external_wp_dom_["replaceTag"])(node, 'em'); |
|
5943 } else if (node.nodeName === 'A') { |
|
5944 // In jsdom-jscore, 'node.target' can be null. |
|
5945 // TODO: Explore fixing this by patching jsdom-jscore. |
|
5946 if (node.target && node.target.toLowerCase() === '_blank') { |
|
5947 node.rel = 'noreferrer noopener'; |
|
5948 } else { |
|
5949 node.removeAttribute('target'); |
|
5950 node.removeAttribute('rel'); |
|
5951 } |
|
5952 } |
|
5953 } |
|
5954 |
|
5955 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/head-remover.js |
|
5956 function headRemover(node) { |
|
5957 if (node.nodeName !== 'SCRIPT' && node.nodeName !== 'NOSCRIPT' && node.nodeName !== 'TEMPLATE' && node.nodeName !== 'STYLE') { |
|
5958 return; |
|
5959 } |
|
5960 |
|
5961 node.parentNode.removeChild(node); |
|
5962 } |
|
5963 |
|
5964 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/ms-list-converter.js |
|
5965 /** |
|
5966 * Browser dependencies |
|
5967 */ |
|
5968 const { |
|
5969 parseInt: ms_list_converter_parseInt |
|
5970 } = window; |
|
5971 |
|
5972 function isList(node) { |
|
5973 return node.nodeName === 'OL' || node.nodeName === 'UL'; |
|
5974 } |
|
5975 |
|
5976 function msListConverter(node, doc) { |
|
5977 if (node.nodeName !== 'P') { |
|
5978 return; |
|
5979 } |
|
5980 |
|
5981 const style = node.getAttribute('style'); |
|
5982 |
|
5983 if (!style) { |
|
5984 return; |
|
5985 } // Quick check. |
|
5986 |
|
5987 |
|
5988 if (style.indexOf('mso-list') === -1) { |
|
5989 return; |
|
5990 } |
|
5991 |
|
5992 const matches = /mso-list\s*:[^;]+level([0-9]+)/i.exec(style); |
|
5993 |
|
5994 if (!matches) { |
|
5995 return; |
|
5996 } |
|
5997 |
|
5998 let level = ms_list_converter_parseInt(matches[1], 10) - 1 || 0; |
|
5999 const prevNode = node.previousElementSibling; // Add new list if no previous. |
|
6000 |
|
6001 if (!prevNode || !isList(prevNode)) { |
|
6002 // See https://html.spec.whatwg.org/multipage/grouping-content.html#attr-ol-type. |
|
6003 const type = node.textContent.trim().slice(0, 1); |
|
6004 const isNumeric = /[1iIaA]/.test(type); |
|
6005 const newListNode = doc.createElement(isNumeric ? 'ol' : 'ul'); |
|
6006 |
|
6007 if (isNumeric) { |
|
6008 newListNode.setAttribute('type', type); |
|
6009 } |
|
6010 |
|
6011 node.parentNode.insertBefore(newListNode, node); |
|
6012 } |
|
6013 |
|
6014 const listNode = node.previousElementSibling; |
|
6015 const listType = listNode.nodeName; |
|
6016 const listItem = doc.createElement('li'); |
|
6017 let receivingNode = listNode; // Remove the first span with list info. |
|
6018 |
|
6019 node.removeChild(node.firstElementChild); // Add content. |
|
6020 |
|
6021 while (node.firstChild) { |
|
6022 listItem.appendChild(node.firstChild); |
|
6023 } // Change pointer depending on indentation level. |
|
6024 |
|
6025 |
|
6026 while (level--) { |
|
6027 receivingNode = receivingNode.lastElementChild || receivingNode; // If it's a list, move pointer to the last item. |
|
6028 |
|
6029 if (isList(receivingNode)) { |
|
6030 receivingNode = receivingNode.lastElementChild || receivingNode; |
|
6031 } |
|
6032 } // Make sure we append to a list. |
|
6033 |
|
6034 |
|
6035 if (!isList(receivingNode)) { |
|
6036 receivingNode = receivingNode.appendChild(doc.createElement(listType)); |
|
6037 } // Append the list item to the list. |
|
6038 |
|
6039 |
|
6040 receivingNode.appendChild(listItem); // Remove the wrapper paragraph. |
|
6041 |
|
6042 node.parentNode.removeChild(node); |
|
6043 } |
|
6044 |
|
6045 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/list-reducer.js |
|
6046 /** |
|
6047 * WordPress dependencies |
|
6048 */ |
|
6049 |
|
6050 |
|
6051 function list_reducer_isList(node) { |
|
6052 return node.nodeName === 'OL' || node.nodeName === 'UL'; |
|
6053 } |
|
6054 |
|
6055 function shallowTextContent(element) { |
|
6056 return Array.from(element.childNodes).map(({ |
|
6057 nodeValue = '' |
|
6058 }) => nodeValue).join(''); |
|
6059 } |
|
6060 |
|
6061 function listReducer(node) { |
|
6062 if (!list_reducer_isList(node)) { |
|
6063 return; |
|
6064 } |
|
6065 |
|
6066 const list = node; |
|
6067 const prevElement = node.previousElementSibling; // Merge with previous list if: |
|
6068 // * There is a previous list of the same type. |
|
6069 // * There is only one list item. |
|
6070 |
|
6071 if (prevElement && prevElement.nodeName === node.nodeName && list.children.length === 1) { |
|
6072 // Move all child nodes, including any text nodes, if any. |
|
6073 while (list.firstChild) { |
|
6074 prevElement.appendChild(list.firstChild); |
|
6075 } |
|
6076 |
|
6077 list.parentNode.removeChild(list); |
|
6078 } |
|
6079 |
|
6080 const parentElement = node.parentNode; // Nested list with empty parent item. |
|
6081 |
|
6082 if (parentElement && parentElement.nodeName === 'LI' && parentElement.children.length === 1 && !/\S/.test(shallowTextContent(parentElement))) { |
|
6083 const parentListItem = parentElement; |
|
6084 const prevListItem = parentListItem.previousElementSibling; |
|
6085 const parentList = parentListItem.parentNode; |
|
6086 |
|
6087 if (prevListItem) { |
|
6088 prevListItem.appendChild(list); |
|
6089 parentList.removeChild(parentListItem); |
|
6090 } else { |
|
6091 parentList.parentNode.insertBefore(list, parentList); |
|
6092 parentList.parentNode.removeChild(parentList); |
|
6093 } |
|
6094 } // Invalid: OL/UL > OL/UL. |
|
6095 |
|
6096 |
|
6097 if (parentElement && list_reducer_isList(parentElement)) { |
|
6098 const prevListItem = node.previousElementSibling; |
|
6099 |
|
6100 if (prevListItem) { |
|
6101 prevListItem.appendChild(node); |
|
6102 } else { |
|
6103 Object(external_wp_dom_["unwrap"])(node); |
|
6104 } |
|
6105 } |
|
6106 } |
|
6107 |
|
6108 // EXTERNAL MODULE: external ["wp","blob"] |
|
6109 var external_wp_blob_ = __webpack_require__("xTGt"); |
|
6110 |
|
6111 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/image-corrector.js |
|
6112 /** |
|
6113 * WordPress dependencies |
|
6114 */ |
|
6115 |
|
6116 /** |
|
6117 * Browser dependencies |
|
6118 */ |
|
6119 |
|
6120 const { |
|
6121 atob, |
|
6122 File |
|
6123 } = window; |
|
6124 function imageCorrector(node) { |
|
6125 if (node.nodeName !== 'IMG') { |
|
6126 return; |
|
6127 } |
|
6128 |
|
6129 if (node.src.indexOf('file:') === 0) { |
|
6130 node.src = ''; |
|
6131 } // This piece cannot be tested outside a browser env. |
|
6132 |
|
6133 |
|
6134 if (node.src.indexOf('data:') === 0) { |
|
6135 const [properties, data] = node.src.split(','); |
|
6136 const [type] = properties.slice(5).split(';'); |
|
6137 |
|
6138 if (!data || !type) { |
|
6139 node.src = ''; |
|
6140 return; |
|
6141 } |
|
6142 |
|
6143 let decoded; // Can throw DOMException! |
|
6144 |
|
6145 try { |
|
6146 decoded = atob(data); |
|
6147 } catch (e) { |
|
6148 node.src = ''; |
|
6149 return; |
|
6150 } |
|
6151 |
|
6152 const uint8Array = new Uint8Array(decoded.length); |
|
6153 |
|
6154 for (let i = 0; i < uint8Array.length; i++) { |
|
6155 uint8Array[i] = decoded.charCodeAt(i); |
|
6156 } |
|
6157 |
|
6158 const name = type.replace('/', '.'); |
|
6159 const file = new File([uint8Array], name, { |
|
6160 type |
|
6161 }); |
|
6162 node.src = Object(external_wp_blob_["createBlobURL"])(file); |
|
6163 } // Remove trackers and hardly visible images. |
|
6164 |
|
6165 |
|
6166 if (node.height === 1 || node.width === 1) { |
|
6167 node.parentNode.removeChild(node); |
|
6168 } |
|
6169 } |
|
6170 |
|
6171 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/blockquote-normaliser.js |
|
6172 /** |
|
6173 * Internal dependencies |
|
6174 */ |
|
6175 |
|
6176 function blockquoteNormaliser(node) { |
|
6177 if (node.nodeName !== 'BLOCKQUOTE') { |
|
6178 return; |
|
6179 } |
|
6180 |
|
6181 node.innerHTML = normaliseBlocks(node.innerHTML); |
|
6182 } |
|
6183 |
|
6184 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/figure-content-reducer.js |
|
6185 /** |
|
6186 * External dependencies |
|
6187 */ |
|
6188 |
|
6189 /** |
|
6190 * WordPress dependencies |
|
6191 */ |
|
6192 |
|
6193 |
|
6194 /** |
|
6195 * Whether or not the given node is figure content. |
|
6196 * |
|
6197 * @param {Node} node The node to check. |
|
6198 * @param {Object} schema The schema to use. |
|
6199 * |
|
6200 * @return {boolean} True if figure content, false if not. |
|
6201 */ |
|
6202 |
|
6203 function isFigureContent(node, schema) { |
|
6204 const tag = node.nodeName.toLowerCase(); // We are looking for tags that can be a child of the figure tag, excluding |
|
6205 // `figcaption` and any phrasing content. |
|
6206 |
|
6207 if (tag === 'figcaption' || Object(external_wp_dom_["isTextContent"])(node)) { |
|
6208 return false; |
|
6209 } |
|
6210 |
|
6211 return Object(external_lodash_["has"])(schema, ['figure', 'children', tag]); |
|
6212 } |
|
6213 /** |
|
6214 * Whether or not the given node can have an anchor. |
|
6215 * |
|
6216 * @param {Node} node The node to check. |
|
6217 * @param {Object} schema The schema to use. |
|
6218 * |
|
6219 * @return {boolean} True if it can, false if not. |
|
6220 */ |
|
6221 |
|
6222 |
|
6223 function canHaveAnchor(node, schema) { |
|
6224 const tag = node.nodeName.toLowerCase(); |
|
6225 return Object(external_lodash_["has"])(schema, ['figure', 'children', 'a', 'children', tag]); |
|
6226 } |
|
6227 /** |
|
6228 * Wraps the given element in a figure element. |
|
6229 * |
|
6230 * @param {Element} element The element to wrap. |
|
6231 * @param {Element} beforeElement The element before which to place the figure. |
|
6232 */ |
|
6233 |
|
6234 |
|
6235 function wrapFigureContent(element, beforeElement = element) { |
|
6236 const figure = element.ownerDocument.createElement('figure'); |
|
6237 beforeElement.parentNode.insertBefore(figure, beforeElement); |
|
6238 figure.appendChild(element); |
|
6239 } |
|
6240 /** |
|
6241 * This filter takes figure content out of paragraphs, wraps it in a figure |
|
6242 * element, and moves any anchors with it if needed. |
|
6243 * |
|
6244 * @param {Node} node The node to filter. |
|
6245 * @param {Document} doc The document of the node. |
|
6246 * @param {Object} schema The schema to use. |
|
6247 * |
|
6248 * @return {void} |
|
6249 */ |
|
6250 |
|
6251 |
|
6252 function figureContentReducer(node, doc, schema) { |
|
6253 if (!isFigureContent(node, schema)) { |
|
6254 return; |
|
6255 } |
|
6256 |
|
6257 let nodeToInsert = node; |
|
6258 const parentNode = node.parentNode; // If the figure content can have an anchor and its parent is an anchor with |
|
6259 // only the figure content, take the anchor out instead of just the content. |
|
6260 |
|
6261 if (canHaveAnchor(node, schema) && parentNode.nodeName === 'A' && parentNode.childNodes.length === 1) { |
|
6262 nodeToInsert = node.parentNode; |
|
6263 } |
|
6264 |
|
6265 const wrapper = nodeToInsert.closest('p,div'); // If wrapped in a paragraph or div, only extract if it's aligned or if |
|
6266 // there is no text content. |
|
6267 // Otherwise, if directly at the root, wrap in a figure element. |
|
6268 |
|
6269 if (wrapper) { |
|
6270 // In jsdom-jscore, 'node.classList' can be undefined. |
|
6271 // In this case, default to extract as it offers a better UI experience on mobile. |
|
6272 if (!node.classList) { |
|
6273 wrapFigureContent(nodeToInsert, wrapper); |
|
6274 } else if (node.classList.contains('alignright') || node.classList.contains('alignleft') || node.classList.contains('aligncenter') || !wrapper.textContent.trim()) { |
|
6275 wrapFigureContent(nodeToInsert, wrapper); |
|
6276 } |
|
6277 } else if (nodeToInsert.parentNode.nodeName === 'BODY') { |
|
6278 wrapFigureContent(nodeToInsert); |
|
6279 } |
|
6280 } |
|
6281 |
|
6282 // EXTERNAL MODULE: external ["wp","shortcode"] |
|
6283 var external_wp_shortcode_ = __webpack_require__("SVSp"); |
|
6284 |
|
6285 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/shortcode-converter.js |
|
6286 /** |
|
6287 * External dependencies |
|
6288 */ |
|
6289 |
|
6290 /** |
|
6291 * WordPress dependencies |
|
6292 */ |
|
6293 |
|
6294 |
|
6295 /** |
|
6296 * Internal dependencies |
|
6297 */ |
|
6298 |
|
6299 |
|
6300 |
|
6301 |
|
6302 |
|
6303 function segmentHTMLToShortcodeBlock(HTML, lastIndex = 0, excludedBlockNames = []) { |
|
6304 // Get all matches. |
|
6305 const transformsFrom = getBlockTransforms('from'); |
|
6306 const transformation = findTransform(transformsFrom, transform => excludedBlockNames.indexOf(transform.blockName) === -1 && transform.type === 'shortcode' && Object(external_lodash_["some"])(Object(external_lodash_["castArray"])(transform.tag), tag => Object(external_wp_shortcode_["regexp"])(tag).test(HTML))); |
|
6307 |
|
6308 if (!transformation) { |
|
6309 return [HTML]; |
|
6310 } |
|
6311 |
|
6312 const transformTags = Object(external_lodash_["castArray"])(transformation.tag); |
|
6313 const transformTag = Object(external_lodash_["find"])(transformTags, tag => Object(external_wp_shortcode_["regexp"])(tag).test(HTML)); |
|
6314 let match; |
|
6315 const previousIndex = lastIndex; |
|
6316 |
|
6317 if (match = Object(external_wp_shortcode_["next"])(transformTag, HTML, lastIndex)) { |
|
6318 lastIndex = match.index + match.content.length; |
|
6319 const beforeHTML = HTML.substr(0, match.index); |
|
6320 const afterHTML = HTML.substr(lastIndex); // If the shortcode content does not contain HTML and the shortcode is |
|
6321 // not on a new line (or in paragraph from Markdown converter), |
|
6322 // consider the shortcode as inline text, and thus skip conversion for |
|
6323 // this segment. |
|
6324 |
|
6325 if (!Object(external_lodash_["includes"])(match.shortcode.content || '', '<') && !(/(\n|<p>)\s*$/.test(beforeHTML) && /^\s*(\n|<\/p>)/.test(afterHTML))) { |
|
6326 return segmentHTMLToShortcodeBlock(HTML, lastIndex); |
|
6327 } // If a transformation's `isMatch` predicate fails for the inbound |
|
6328 // shortcode, try again by excluding the current block type. |
|
6329 // |
|
6330 // This is the only call to `segmentHTMLToShortcodeBlock` that should |
|
6331 // ever carry over `excludedBlockNames`. Other calls in the module |
|
6332 // should skip that argument as a way to reset the exclusion state, so |
|
6333 // that one `isMatch` fail in an HTML fragment doesn't prevent any |
|
6334 // valid matches in subsequent fragments. |
|
6335 |
|
6336 |
|
6337 if (transformation.isMatch && !transformation.isMatch(match.shortcode.attrs)) { |
|
6338 return segmentHTMLToShortcodeBlock(HTML, previousIndex, [...excludedBlockNames, transformation.blockName]); |
|
6339 } |
|
6340 |
|
6341 const attributes = Object(external_lodash_["mapValues"])(Object(external_lodash_["pickBy"])(transformation.attributes, schema => schema.shortcode), // Passing all of `match` as second argument is intentionally broad |
|
6342 // but shouldn't be too relied upon. |
|
6343 // |
|
6344 // See: https://github.com/WordPress/gutenberg/pull/3610#discussion_r152546926 |
|
6345 schema => schema.shortcode(match.shortcode.attrs, match)); |
|
6346 const block = createBlock(transformation.blockName, getBlockAttributes({ ...registration_getBlockType(transformation.blockName), |
|
6347 attributes: transformation.attributes |
|
6348 }, match.shortcode.content, attributes)); |
|
6349 return [...segmentHTMLToShortcodeBlock(beforeHTML), block, ...segmentHTMLToShortcodeBlock(afterHTML)]; |
|
6350 } |
|
6351 |
|
6352 return [HTML]; |
|
6353 } |
|
6354 |
|
6355 /* harmony default export */ var shortcode_converter = (segmentHTMLToShortcodeBlock); |
|
6356 |
|
6357 // EXTERNAL MODULE: ./node_modules/showdown/dist/showdown.js |
|
6358 var showdown = __webpack_require__("M55E"); |
|
6359 var showdown_default = /*#__PURE__*/__webpack_require__.n(showdown); |
|
6360 |
|
6361 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/markdown-converter.js |
|
6362 /** |
|
6363 * External dependencies |
|
6364 */ |
|
6365 // Reuse the same showdown converter. |
|
6366 |
|
6367 const converter = new showdown_default.a.Converter({ |
|
6368 noHeaderId: true, |
|
6369 tables: true, |
|
6370 literalMidWordUnderscores: true, |
|
6371 omitExtraWLInCodeBlocks: true, |
|
6372 simpleLineBreaks: true, |
|
6373 strikethrough: true |
|
6374 }); |
|
6375 /** |
|
6376 * Corrects the Slack Markdown variant of the code block. |
|
6377 * If uncorrected, it will be converted to inline code. |
|
6378 * |
|
6379 * @see https://get.slack.help/hc/en-us/articles/202288908-how-can-i-add-formatting-to-my-messages-#code-blocks |
|
6380 * |
|
6381 * @param {string} text The potential Markdown text to correct. |
|
6382 * |
|
6383 * @return {string} The corrected Markdown. |
|
6384 */ |
|
6385 |
|
6386 function slackMarkdownVariantCorrector(text) { |
|
6387 return text.replace(/((?:^|\n)```)([^\n`]+)(```(?:$|\n))/, (match, p1, p2, p3) => `${p1}\n${p2}\n${p3}`); |
|
6388 } |
|
6389 /** |
|
6390 * Converts a piece of text into HTML based on any Markdown present. |
|
6391 * Also decodes any encoded HTML. |
|
6392 * |
|
6393 * @param {string} text The plain text to convert. |
|
6394 * |
|
6395 * @return {string} HTML. |
|
6396 */ |
|
6397 |
|
6398 |
|
6399 function markdownConverter(text) { |
|
6400 return converter.makeHtml(slackMarkdownVariantCorrector(text)); |
|
6401 } |
|
6402 |
|
6403 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/iframe-remover.js |
|
6404 /** |
|
6405 * Removes iframes. |
|
6406 * |
|
6407 * @param {Node} node The node to check. |
|
6408 * |
|
6409 * @return {void} |
|
6410 */ |
|
6411 function iframeRemover(node) { |
|
6412 if (node.nodeName === 'IFRAME') { |
|
6413 const text = node.ownerDocument.createTextNode(node.src); |
|
6414 node.parentNode.replaceChild(text, node); |
|
6415 } |
|
6416 } |
|
6417 |
|
6418 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/google-docs-uid-remover.js |
|
6419 /** |
|
6420 * WordPress dependencies |
|
6421 */ |
|
6422 |
|
6423 function googleDocsUIdRemover(node) { |
|
6424 if (!node.id || node.id.indexOf('docs-internal-guid-') !== 0) { |
|
6425 return; |
|
6426 } |
|
6427 |
|
6428 Object(external_wp_dom_["unwrap"])(node); |
|
6429 } |
|
6430 |
|
6431 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/utils.js |
|
6432 /** |
|
6433 * External dependencies |
|
6434 */ |
|
6435 |
|
6436 /** |
|
6437 * WordPress dependencies |
|
6438 */ |
|
6439 |
|
6440 |
|
6441 /** |
|
6442 * Internal dependencies |
|
6443 */ |
|
6444 |
|
6445 |
|
6446 |
|
6447 function getBlockContentSchemaFromTransforms(transforms, context) { |
|
6448 const phrasingContentSchema = Object(external_wp_dom_["getPhrasingContentSchema"])(context); |
|
6449 const schemaArgs = { |
|
6450 phrasingContentSchema, |
|
6451 isPaste: context === 'paste' |
|
6452 }; |
|
6453 const schemas = transforms.map(({ |
|
6454 isMatch, |
|
6455 blockName, |
|
6456 schema |
|
6457 }) => { |
|
6458 const hasAnchorSupport = registration_hasBlockSupport(blockName, 'anchor'); |
|
6459 schema = Object(external_lodash_["isFunction"])(schema) ? schema(schemaArgs) : schema; // If the block does not has anchor support and the transform does not |
|
6460 // provides an isMatch we can return the schema right away. |
|
6461 |
|
6462 if (!hasAnchorSupport && !isMatch) { |
|
6463 return schema; |
|
6464 } |
|
6465 |
|
6466 return Object(external_lodash_["mapValues"])(schema, value => { |
|
6467 let attributes = value.attributes || []; // If the block supports the "anchor" functionality, it needs to keep its ID attribute. |
|
6468 |
|
6469 if (hasAnchorSupport) { |
|
6470 attributes = [...attributes, 'id']; |
|
6471 } |
|
6472 |
|
6473 return { ...value, |
|
6474 attributes, |
|
6475 isMatch: isMatch ? isMatch : undefined |
|
6476 }; |
|
6477 }); |
|
6478 }); |
|
6479 return Object(external_lodash_["mergeWith"])({}, ...schemas, (objValue, srcValue, key) => { |
|
6480 switch (key) { |
|
6481 case 'children': |
|
6482 { |
|
6483 if (objValue === '*' || srcValue === '*') { |
|
6484 return '*'; |
|
6485 } |
|
6486 |
|
6487 return { ...objValue, |
|
6488 ...srcValue |
|
6489 }; |
|
6490 } |
|
6491 |
|
6492 case 'attributes': |
|
6493 case 'require': |
|
6494 { |
|
6495 return [...(objValue || []), ...(srcValue || [])]; |
|
6496 } |
|
6497 |
|
6498 case 'isMatch': |
|
6499 { |
|
6500 // If one of the values being merge is undefined (matches everything), |
|
6501 // the result of the merge will be undefined. |
|
6502 if (!objValue || !srcValue) { |
|
6503 return undefined; |
|
6504 } // When merging two isMatch functions, the result is a new function |
|
6505 // that returns if one of the source functions returns true. |
|
6506 |
|
6507 |
|
6508 return (...args) => { |
|
6509 return objValue(...args) || srcValue(...args); |
|
6510 }; |
|
6511 } |
|
6512 } |
|
6513 }); |
|
6514 } |
|
6515 /** |
|
6516 * Gets the block content schema, which is extracted and merged from all |
|
6517 * registered blocks with raw transfroms. |
|
6518 * |
|
6519 * @param {string} context Set to "paste" when in paste context, where the |
|
6520 * schema is more strict. |
|
6521 * |
|
6522 * @return {Object} A complete block content schema. |
|
6523 */ |
|
6524 |
|
6525 function getBlockContentSchema(context) { |
|
6526 return getBlockContentSchemaFromTransforms(getRawTransforms(), context); |
|
6527 } |
|
6528 /** |
|
6529 * Checks whether HTML can be considered plain text. That is, it does not contain |
|
6530 * any elements that are not line breaks. |
|
6531 * |
|
6532 * @param {string} HTML The HTML to check. |
|
6533 * |
|
6534 * @return {boolean} Whether the HTML can be considered plain text. |
|
6535 */ |
|
6536 |
|
6537 function isPlain(HTML) { |
|
6538 return !/<(?!br[ />])/i.test(HTML); |
|
6539 } |
|
6540 /** |
|
6541 * Given node filters, deeply filters and mutates a NodeList. |
|
6542 * |
|
6543 * @param {NodeList} nodeList The nodeList to filter. |
|
6544 * @param {Array} filters An array of functions that can mutate with the provided node. |
|
6545 * @param {Document} doc The document of the nodeList. |
|
6546 * @param {Object} schema The schema to use. |
|
6547 */ |
|
6548 |
|
6549 function deepFilterNodeList(nodeList, filters, doc, schema) { |
|
6550 Array.from(nodeList).forEach(node => { |
|
6551 deepFilterNodeList(node.childNodes, filters, doc, schema); |
|
6552 filters.forEach(item => { |
|
6553 // Make sure the node is still attached to the document. |
|
6554 if (!doc.contains(node)) { |
|
6555 return; |
|
6556 } |
|
6557 |
|
6558 item(node, doc, schema); |
|
6559 }); |
|
6560 }); |
|
6561 } |
|
6562 /** |
|
6563 * Given node filters, deeply filters HTML tags. |
|
6564 * Filters from the deepest nodes to the top. |
|
6565 * |
|
6566 * @param {string} HTML The HTML to filter. |
|
6567 * @param {Array} filters An array of functions that can mutate with the provided node. |
|
6568 * @param {Object} schema The schema to use. |
|
6569 * |
|
6570 * @return {string} The filtered HTML. |
|
6571 */ |
|
6572 |
|
6573 function deepFilterHTML(HTML, filters = [], schema) { |
|
6574 const doc = document.implementation.createHTMLDocument(''); |
|
6575 doc.body.innerHTML = HTML; |
|
6576 deepFilterNodeList(doc.body.childNodes, filters, doc, schema); |
|
6577 return doc.body.innerHTML; |
|
6578 } |
|
6579 /** |
|
6580 * Gets a sibling within text-level context. |
|
6581 * |
|
6582 * @param {Element} node The subject node. |
|
6583 * @param {string} which "next" or "previous". |
|
6584 */ |
|
6585 |
|
6586 function getSibling(node, which) { |
|
6587 const sibling = node[`${which}Sibling`]; |
|
6588 |
|
6589 if (sibling && Object(external_wp_dom_["isPhrasingContent"])(sibling)) { |
|
6590 return sibling; |
|
6591 } |
|
6592 |
|
6593 const { |
|
6594 parentNode |
|
6595 } = node; |
|
6596 |
|
6597 if (!parentNode || !Object(external_wp_dom_["isPhrasingContent"])(parentNode)) { |
|
6598 return; |
|
6599 } |
|
6600 |
|
6601 return getSibling(parentNode, which); |
|
6602 } |
|
6603 |
|
6604 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/html-formatting-remover.js |
|
6605 /** |
|
6606 * Internal dependencies |
|
6607 */ |
|
6608 |
|
6609 |
|
6610 function isFormattingSpace(character) { |
|
6611 return character === ' ' || character === '\r' || character === '\n' || character === '\t'; |
|
6612 } |
|
6613 /** |
|
6614 * Removes spacing that formats HTML. |
|
6615 * |
|
6616 * @see https://www.w3.org/TR/css-text-3/#white-space-processing |
|
6617 * |
|
6618 * @param {Node} node The node to be processed. |
|
6619 * @return {void} |
|
6620 */ |
|
6621 |
|
6622 |
|
6623 function htmlFormattingRemover(node) { |
|
6624 if (node.nodeType !== node.TEXT_NODE) { |
|
6625 return; |
|
6626 } // Ignore pre content. Note that this does not use Element#closest due to |
|
6627 // a combination of (a) node may not be Element and (b) node.parentElement |
|
6628 // does not have full support in all browsers (Internet Exporer). |
|
6629 // |
|
6630 // See: https://developer.mozilla.org/en-US/docs/Web/API/Node/parentElement#Browser_compatibility |
|
6631 |
|
6632 /** @type {Node?} */ |
|
6633 |
|
6634 |
|
6635 let parent = node; |
|
6636 |
|
6637 while (parent = parent.parentNode) { |
|
6638 if (parent.nodeType === parent.ELEMENT_NODE && parent.nodeName === 'PRE') { |
|
6639 return; |
|
6640 } |
|
6641 } // First, replace any sequence of HTML formatting space with a single space. |
|
6642 |
|
6643 |
|
6644 let newData = node.data.replace(/[ \r\n\t]+/g, ' '); // Remove the leading space if the text element is at the start of a block, |
|
6645 // is preceded by a line break element, or has a space in the previous |
|
6646 // node. |
|
6647 |
|
6648 if (newData[0] === ' ') { |
|
6649 const previousSibling = getSibling(node, 'previous'); |
|
6650 |
|
6651 if (!previousSibling || previousSibling.nodeName === 'BR' || previousSibling.textContent.slice(-1) === ' ') { |
|
6652 newData = newData.slice(1); |
|
6653 } |
|
6654 } // Remove the trailing space if the text element is at the end of a block, |
|
6655 // is succeded by a line break element, or has a space in the next text |
|
6656 // node. |
|
6657 |
|
6658 |
|
6659 if (newData[newData.length - 1] === ' ') { |
|
6660 const nextSibling = getSibling(node, 'next'); |
|
6661 |
|
6662 if (!nextSibling || nextSibling.nodeName === 'BR' || nextSibling.nodeType === nextSibling.TEXT_NODE && isFormattingSpace(nextSibling.textContent[0])) { |
|
6663 newData = newData.slice(0, -1); |
|
6664 } |
|
6665 } // If there's no data left, remove the node, so `previousSibling` stays |
|
6666 // accurate. Otherwise, update the node data. |
|
6667 |
|
6668 |
|
6669 if (!newData) { |
|
6670 node.parentNode.removeChild(node); |
|
6671 } else { |
|
6672 node.data = newData; |
|
6673 } |
|
6674 } |
|
6675 |
|
6676 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/br-remover.js |
|
6677 /** |
|
6678 * Internal dependencies |
|
6679 */ |
|
6680 |
|
6681 /** |
|
6682 * Removes trailing br elements from text-level content. |
|
6683 * |
|
6684 * @param {Element} node Node to check. |
|
6685 */ |
|
6686 |
|
6687 function brRemover(node) { |
|
6688 if (node.nodeName !== 'BR') { |
|
6689 return; |
|
6690 } |
|
6691 |
|
6692 if (getSibling(node, 'next')) { |
|
6693 return; |
|
6694 } |
|
6695 |
|
6696 node.parentNode.removeChild(node); |
|
6697 } |
|
6698 |
|
6699 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/empty-paragraph-remover.js |
|
6700 /** |
|
6701 * Removes empty paragraph elements. |
|
6702 * |
|
6703 * @param {Element} node Node to check. |
|
6704 */ |
|
6705 function emptyParagraphRemover(node) { |
|
6706 if (node.nodeName !== 'P') { |
|
6707 return; |
|
6708 } |
|
6709 |
|
6710 if (node.hasChildNodes()) { |
|
6711 return; |
|
6712 } |
|
6713 |
|
6714 node.parentNode.removeChild(node); |
|
6715 } |
|
6716 |
|
6717 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/paste-handler.js |
|
6718 /** |
|
6719 * External dependencies |
|
6720 */ |
|
6721 |
|
6722 /** |
|
6723 * WordPress dependencies |
|
6724 */ |
|
6725 |
|
6726 |
|
6727 /** |
|
6728 * Internal dependencies |
|
6729 */ |
|
6730 |
|
6731 |
|
6732 |
|
6733 |
|
6734 |
|
6735 |
|
6736 |
|
6737 |
|
6738 |
|
6739 |
|
6740 |
|
6741 |
|
6742 |
|
6743 |
|
6744 |
|
6745 |
|
6746 |
|
6747 |
|
6748 |
|
6749 |
|
6750 |
|
6751 |
|
6752 |
|
6753 |
|
6754 /** |
|
6755 * Browser dependencies |
|
6756 */ |
|
6757 |
|
6758 const { |
|
6759 console: paste_handler_console |
|
6760 } = window; |
|
6761 /** |
|
6762 * Filters HTML to only contain phrasing content. |
|
6763 * |
|
6764 * @param {string} HTML The HTML to filter. |
|
6765 * @param {boolean} preserveWhiteSpace Whether or not to preserve consequent white space. |
|
6766 * |
|
6767 * @return {string} HTML only containing phrasing content. |
|
6768 */ |
|
6769 |
|
6770 function filterInlineHTML(HTML, preserveWhiteSpace) { |
|
6771 HTML = deepFilterHTML(HTML, [googleDocsUIdRemover, phrasingContentReducer, commentRemover]); |
|
6772 HTML = Object(external_wp_dom_["removeInvalidHTML"])(HTML, Object(external_wp_dom_["getPhrasingContentSchema"])('paste'), { |
|
6773 inline: true |
|
6774 }); |
|
6775 |
|
6776 if (!preserveWhiteSpace) { |
|
6777 HTML = deepFilterHTML(HTML, [htmlFormattingRemover, brRemover]); |
|
6778 } // Allows us to ask for this information when we get a report. |
|
6779 |
|
6780 |
|
6781 paste_handler_console.log('Processed inline HTML:\n\n', HTML); |
|
6782 return HTML; |
|
6783 } |
|
6784 /** |
|
6785 * Converts an HTML string to known blocks. Strips everything else. |
|
6786 * |
|
6787 * @param {Object} options |
|
6788 * @param {string} [options.HTML] The HTML to convert. |
|
6789 * @param {string} [options.plainText] Plain text version. |
|
6790 * @param {string} [options.mode] Handle content as blocks or inline content. |
|
6791 * * 'AUTO': Decide based on the content passed. |
|
6792 * * 'INLINE': Always handle as inline content, and return string. |
|
6793 * * 'BLOCKS': Always handle as blocks, and return array of blocks. |
|
6794 * @param {Array} [options.tagName] The tag into which content will be inserted. |
|
6795 * @param {boolean} [options.preserveWhiteSpace] Whether or not to preserve consequent white space. |
|
6796 * |
|
6797 * @return {Array|string} A list of blocks or a string, depending on `handlerMode`. |
|
6798 */ |
|
6799 |
|
6800 |
|
6801 function pasteHandler({ |
|
6802 HTML = '', |
|
6803 plainText = '', |
|
6804 mode = 'AUTO', |
|
6805 tagName, |
|
6806 preserveWhiteSpace |
|
6807 }) { |
|
6808 // First of all, strip any meta tags. |
|
6809 HTML = HTML.replace(/<meta[^>]+>/g, ''); // Strip Windows markers. |
|
6810 |
|
6811 HTML = HTML.replace(/^\s*<html[^>]*>\s*<body[^>]*>(?:\s*<!--\s*StartFragment\s*-->)?/i, ''); |
|
6812 HTML = HTML.replace(/(?:<!--\s*EndFragment\s*-->\s*)?<\/body>\s*<\/html>\s*$/i, ''); // If we detect block delimiters in HTML, parse entirely as blocks. |
|
6813 |
|
6814 if (mode !== 'INLINE') { |
|
6815 // Check plain text if there is no HTML. |
|
6816 const content = HTML ? HTML : plainText; |
|
6817 |
|
6818 if (content.indexOf('<!-- wp:') !== -1) { |
|
6819 return parseWithGrammar(content); |
|
6820 } |
|
6821 } // Normalize unicode to use composed characters. |
|
6822 // This is unsupported in IE 11 but it's a nice-to-have feature, not mandatory. |
|
6823 // Not normalizing the content will only affect older browsers and won't |
|
6824 // entirely break the app. |
|
6825 // See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize |
|
6826 // See: https://core.trac.wordpress.org/ticket/30130 |
|
6827 // See: https://github.com/WordPress/gutenberg/pull/6983#pullrequestreview-125151075 |
|
6828 |
|
6829 |
|
6830 if (String.prototype.normalize) { |
|
6831 HTML = HTML.normalize(); |
|
6832 } // Parse Markdown (and encoded HTML) if: |
|
6833 // * There is a plain text version. |
|
6834 // * There is no HTML version, or it has no formatting. |
|
6835 |
|
6836 |
|
6837 if (plainText && (!HTML || isPlain(HTML))) { |
|
6838 HTML = plainText; // The markdown converter (Showdown) trims whitespace. |
|
6839 |
|
6840 if (!/^\s+$/.test(plainText)) { |
|
6841 HTML = markdownConverter(HTML); |
|
6842 } // Switch to inline mode if: |
|
6843 // * The current mode is AUTO. |
|
6844 // * The original plain text had no line breaks. |
|
6845 // * The original plain text was not an HTML paragraph. |
|
6846 // * The converted text is just a paragraph. |
|
6847 |
|
6848 |
|
6849 if (mode === 'AUTO' && plainText.indexOf('\n') === -1 && plainText.indexOf('<p>') !== 0 && HTML.indexOf('<p>') === 0) { |
|
6850 mode = 'INLINE'; |
|
6851 } |
|
6852 } |
|
6853 |
|
6854 if (mode === 'INLINE') { |
|
6855 return filterInlineHTML(HTML, preserveWhiteSpace); |
|
6856 } // An array of HTML strings and block objects. The blocks replace matched |
|
6857 // shortcodes. |
|
6858 |
|
6859 |
|
6860 const pieces = shortcode_converter(HTML); // The call to shortcodeConverter will always return more than one element |
|
6861 // if shortcodes are matched. The reason is when shortcodes are matched |
|
6862 // empty HTML strings are included. |
|
6863 |
|
6864 const hasShortcodes = pieces.length > 1; |
|
6865 |
|
6866 if (mode === 'AUTO' && !hasShortcodes && isInlineContent(HTML, tagName)) { |
|
6867 return filterInlineHTML(HTML, preserveWhiteSpace); |
|
6868 } |
|
6869 |
|
6870 const phrasingContentSchema = Object(external_wp_dom_["getPhrasingContentSchema"])('paste'); |
|
6871 const blockContentSchema = getBlockContentSchema('paste'); |
|
6872 const blocks = Object(external_lodash_["compact"])(Object(external_lodash_["flatMap"])(pieces, piece => { |
|
6873 // Already a block from shortcode. |
|
6874 if (typeof piece !== 'string') { |
|
6875 return piece; |
|
6876 } |
|
6877 |
|
6878 const filters = [googleDocsUIdRemover, msListConverter, headRemover, listReducer, imageCorrector, phrasingContentReducer, specialCommentConverter, commentRemover, iframeRemover, figureContentReducer, blockquoteNormaliser]; |
|
6879 const schema = { ...blockContentSchema, |
|
6880 // Keep top-level phrasing content, normalised by `normaliseBlocks`. |
|
6881 ...phrasingContentSchema |
|
6882 }; |
|
6883 piece = deepFilterHTML(piece, filters, blockContentSchema); |
|
6884 piece = Object(external_wp_dom_["removeInvalidHTML"])(piece, schema); |
|
6885 piece = normaliseBlocks(piece); |
|
6886 piece = deepFilterHTML(piece, [htmlFormattingRemover, brRemover, emptyParagraphRemover], blockContentSchema); // Allows us to ask for this information when we get a report. |
|
6887 |
|
6888 paste_handler_console.log('Processed HTML piece:\n\n', piece); |
|
6889 return htmlToBlocks(piece); |
|
6890 })); // If we're allowed to return inline content, and there is only one |
|
6891 // inlineable block, and the original plain text content does not have any |
|
6892 // line breaks, then treat it as inline paste. |
|
6893 |
|
6894 if (mode === 'AUTO' && blocks.length === 1 && registration_hasBlockSupport(blocks[0].name, '__unstablePasteTextInline', false)) { |
|
6895 // Don't catch line breaks at the start or end. |
|
6896 const trimmedPlainText = plainText.replace(/^[\n]+|[\n]+$/g, ''); |
|
6897 |
|
6898 if (trimmedPlainText !== '' && trimmedPlainText.indexOf('\n') === -1) { |
|
6899 return Object(external_wp_dom_["removeInvalidHTML"])(getBlockInnerHTML(blocks[0]), phrasingContentSchema); |
|
6900 } |
|
6901 } |
|
6902 |
|
6903 return blocks; |
|
6904 } |
|
6905 |
|
6906 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/index.js |
|
6907 /** |
|
6908 * External dependencies |
|
6909 */ |
|
6910 |
|
6911 /** |
|
6912 * WordPress dependencies |
|
6913 */ |
|
6914 |
|
6915 |
|
6916 |
|
6917 /** |
|
6918 * Internal dependencies |
|
6919 */ |
|
6920 |
|
6921 |
|
6922 |
|
6923 |
|
6924 |
|
6925 |
|
6926 |
|
6927 |
|
6928 |
|
6929 |
|
6930 |
|
6931 function deprecatedGetPhrasingContentSchema(context) { |
|
6932 external_wp_deprecated_default()('wp.blocks.getPhrasingContentSchema', { |
|
6933 since: '5.6', |
|
6934 alternative: 'wp.dom.getPhrasingContentSchema' |
|
6935 }); |
|
6936 return Object(external_wp_dom_["getPhrasingContentSchema"])(context); |
|
6937 } |
|
6938 /** |
|
6939 * Converts an HTML string to known blocks. |
|
6940 * |
|
6941 * @param {Object} $1 |
|
6942 * @param {string} $1.HTML The HTML to convert. |
|
6943 * |
|
6944 * @return {Array} A list of blocks. |
|
6945 */ |
|
6946 |
|
6947 function rawHandler({ |
|
6948 HTML = '' |
|
6949 }) { |
|
6950 // If we detect block delimiters, parse entirely as blocks. |
|
6951 if (HTML.indexOf('<!-- wp:') !== -1) { |
|
6952 return parseWithGrammar(HTML); |
|
6953 } // An array of HTML strings and block objects. The blocks replace matched |
|
6954 // shortcodes. |
|
6955 |
|
6956 |
|
6957 const pieces = shortcode_converter(HTML); |
|
6958 const blockContentSchema = getBlockContentSchema(); |
|
6959 return Object(external_lodash_["compact"])(Object(external_lodash_["flatMap"])(pieces, piece => { |
|
6960 // Already a block from shortcode. |
|
6961 if (typeof piece !== 'string') { |
|
6962 return piece; |
|
6963 } // These filters are essential for some blocks to be able to transform |
|
6964 // from raw HTML. These filters move around some content or add |
|
6965 // additional tags, they do not remove any content. |
|
6966 |
|
6967 |
|
6968 const filters = [// Needed to adjust invalid lists. |
|
6969 listReducer, // Needed to create more and nextpage blocks. |
|
6970 specialCommentConverter, // Needed to create media blocks. |
|
6971 figureContentReducer, // Needed to create the quote block, which cannot handle text |
|
6972 // without wrapper paragraphs. |
|
6973 blockquoteNormaliser]; |
|
6974 piece = deepFilterHTML(piece, filters, blockContentSchema); |
|
6975 piece = normaliseBlocks(piece); |
|
6976 return htmlToBlocks(piece); |
|
6977 })); |
|
6978 } |
|
6979 |
|
6980 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/categories.js |
|
6981 /** |
|
6982 * WordPress dependencies |
|
6983 */ |
|
6984 |
|
6985 /** |
|
6986 * Internal dependencies |
|
6987 */ |
|
6988 |
|
6989 |
|
6990 /** @typedef {import('../store/reducer').WPBlockCategory} WPBlockCategory */ |
|
6991 |
|
6992 /** |
|
6993 * Returns all the block categories. |
|
6994 * |
|
6995 * @return {WPBlockCategory[]} Block categories. |
|
6996 */ |
|
6997 |
|
6998 function categories_getCategories() { |
|
6999 return Object(external_wp_data_["select"])(store).getCategories(); |
|
7000 } |
|
7001 /** |
|
7002 * Sets the block categories. |
|
7003 * |
|
7004 * @param {WPBlockCategory[]} categories Block categories. |
|
7005 */ |
|
7006 |
|
7007 function categories_setCategories(categories) { |
|
7008 Object(external_wp_data_["dispatch"])(store).setCategories(categories); |
|
7009 } |
|
7010 /** |
|
7011 * Updates a category. |
|
7012 * |
|
7013 * @param {string} slug Block category slug. |
|
7014 * @param {WPBlockCategory} category Object containing the category properties |
|
7015 * that should be updated. |
|
7016 */ |
|
7017 |
|
7018 function categories_updateCategory(slug, category) { |
|
7019 Object(external_wp_data_["dispatch"])(store).updateCategory(slug, category); |
|
7020 } |
|
7021 |
|
7022 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/templates.js |
|
7023 /** |
|
7024 * External dependencies |
|
7025 */ |
|
7026 |
|
7027 /** |
|
7028 * WordPress dependencies |
|
7029 */ |
|
7030 |
|
7031 |
|
7032 /** |
|
7033 * Internal dependencies |
|
7034 */ |
|
7035 |
|
7036 |
|
7037 |
|
7038 |
|
7039 /** |
|
7040 * Checks whether a list of blocks matches a template by comparing the block names. |
|
7041 * |
|
7042 * @param {Array} blocks Block list. |
|
7043 * @param {Array} template Block template. |
|
7044 * |
|
7045 * @return {boolean} Whether the list of blocks matches a templates |
|
7046 */ |
|
7047 |
|
7048 function doBlocksMatchTemplate(blocks = [], template = []) { |
|
7049 return blocks.length === template.length && Object(external_lodash_["every"])(template, ([name,, innerBlocksTemplate], index) => { |
|
7050 const block = blocks[index]; |
|
7051 return name === block.name && doBlocksMatchTemplate(block.innerBlocks, innerBlocksTemplate); |
|
7052 }); |
|
7053 } |
|
7054 /** |
|
7055 * Synchronize a block list with a block template. |
|
7056 * |
|
7057 * Synchronizing a block list with a block template means that we loop over the blocks |
|
7058 * keep the block as is if it matches the block at the same position in the template |
|
7059 * (If it has the same name) and if doesn't match, we create a new block based on the template. |
|
7060 * Extra blocks not present in the template are removed. |
|
7061 * |
|
7062 * @param {Array} blocks Block list. |
|
7063 * @param {Array} template Block template. |
|
7064 * |
|
7065 * @return {Array} Updated Block list. |
|
7066 */ |
|
7067 |
|
7068 function synchronizeBlocksWithTemplate(blocks = [], template) { |
|
7069 // If no template is provided, return blocks unmodified. |
|
7070 if (!template) { |
|
7071 return blocks; |
|
7072 } |
|
7073 |
|
7074 return Object(external_lodash_["map"])(template, ([name, attributes, innerBlocksTemplate], index) => { |
|
7075 const block = blocks[index]; |
|
7076 |
|
7077 if (block && block.name === name) { |
|
7078 const innerBlocks = synchronizeBlocksWithTemplate(block.innerBlocks, innerBlocksTemplate); |
|
7079 return { ...block, |
|
7080 innerBlocks |
|
7081 }; |
|
7082 } // To support old templates that were using the "children" format |
|
7083 // for the attributes using "html" strings now, we normalize the template attributes |
|
7084 // before creating the blocks. |
|
7085 |
|
7086 |
|
7087 const blockType = registration_getBlockType(name); |
|
7088 |
|
7089 const isHTMLAttribute = attributeDefinition => Object(external_lodash_["get"])(attributeDefinition, ['source']) === 'html'; |
|
7090 |
|
7091 const isQueryAttribute = attributeDefinition => Object(external_lodash_["get"])(attributeDefinition, ['source']) === 'query'; |
|
7092 |
|
7093 const normalizeAttributes = (schema, values) => { |
|
7094 return Object(external_lodash_["mapValues"])(values, (value, key) => { |
|
7095 return normalizeAttribute(schema[key], value); |
|
7096 }); |
|
7097 }; |
|
7098 |
|
7099 const normalizeAttribute = (definition, value) => { |
|
7100 if (isHTMLAttribute(definition) && Object(external_lodash_["isArray"])(value)) { |
|
7101 // Introduce a deprecated call at this point |
|
7102 // When we're confident that "children" format should be removed from the templates. |
|
7103 return Object(external_wp_element_["renderToString"])(value); |
|
7104 } |
|
7105 |
|
7106 if (isQueryAttribute(definition) && value) { |
|
7107 return value.map(subValues => { |
|
7108 return normalizeAttributes(definition.query, subValues); |
|
7109 }); |
|
7110 } |
|
7111 |
|
7112 return value; |
|
7113 }; |
|
7114 |
|
7115 const normalizedAttributes = normalizeAttributes(Object(external_lodash_["get"])(blockType, ['attributes'], {}), attributes); |
|
7116 const { |
|
7117 name: blockName, |
|
7118 attributes: blockAttributes |
|
7119 } = convertLegacyBlocks(name, normalizedAttributes); |
|
7120 return createBlock(blockName, blockAttributes, synchronizeBlocksWithTemplate([], innerBlocksTemplate)); |
|
7121 }); |
|
7122 } |
|
7123 |
|
7124 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/index.js |
|
7125 // The blocktype is the most important concept within the block API. It defines |
|
7126 // all aspects of the block configuration and its interfaces, including `edit` |
|
7127 // and `save`. The transforms specification allows converting one blocktype to |
|
7128 // another through formulas defined by either the source or the destination. |
|
7129 // Switching a blocktype is to be considered a one-way operation implying a |
|
7130 // transformation in the opposite way has to be handled explicitly. |
|
7131 // The block tree is composed of a collection of block nodes. Blocks contained |
|
7132 // within other blocks are called inner blocks. An important design |
|
7133 // consideration is that inner blocks are -- conceptually -- not part of the |
|
7134 // territory established by the parent block that contains them. |
|
7135 // |
|
7136 // This has multiple practical implications: when parsing, we can safely dispose |
|
7137 // of any block boundary found within a block from the innerHTML property when |
|
7138 // transfering to state. Not doing so would have a compounding effect on memory |
|
7139 // and uncertainty over the source of truth. This can be illustrated in how, |
|
7140 // given a tree of `n` nested blocks, the entry node would have to contain the |
|
7141 // actual content of each block while each subsequent block node in the state |
|
7142 // tree would replicate the entire chain `n-1`, meaning the extreme end node |
|
7143 // would have been replicated `n` times as the tree is traversed and would |
|
7144 // generate uncertainty as to which one is to hold the current value of the |
|
7145 // block. For composition, it also means inner blocks can effectively be child |
|
7146 // components whose mechanisms can be shielded from the `edit` implementation |
|
7147 // and just passed along. |
|
7148 |
|
7149 // While block transformations account for a specific surface of the API, there |
|
7150 // are also raw transformations which handle arbitrary sources not made out of |
|
7151 // blocks but producing block basaed on various heursitics. This includes |
|
7152 // pasting rich text or HTML data. |
|
7153 |
|
7154 // The process of serialization aims to deflate the internal memory of the block |
|
7155 // editor and its state representation back into an HTML valid string. This |
|
7156 // process restores the document integrity and inserts invisible delimiters |
|
7157 // around each block with HTML comment boundaries which can contain any extra |
|
7158 // attributes needed to operate with the block later on. |
|
7159 |
|
7160 // Validation is the process of comparing a block source with its output before |
|
7161 // there is any user input or interaction with a block. When this operation |
|
7162 // fails -- for whatever reason -- the block is to be considered invalid. As |
|
7163 // part of validating a block the system will attempt to run the source against |
|
7164 // any provided deprecation definitions. |
|
7165 // |
|
7166 // Worth emphasizing that validation is not a case of whether the markup is |
|
7167 // merely HTML spec-compliant but about how the editor knows to create such |
|
7168 // markup and that its inability to create an identical result can be a strong |
|
7169 // indicator of potential data loss (the invalidation is then a protective |
|
7170 // measure). |
|
7171 // |
|
7172 // The invalidation process can also be deconstructed in phases: 1) validate the |
|
7173 // block exists; 2) validate the source matches the output; 3) validate the |
|
7174 // source matches deprecated outputs; 4) work through the significance of |
|
7175 // differences. These are stacked in a way that favors performance and optimizes |
|
7176 // for the majority of cases. That is to say, the evaluation logic can become |
|
7177 // more sophisticated the further down it goes in the process as the cost is |
|
7178 // accounted for. The first logic checks have to be extremely efficient since |
|
7179 // they will be run for all valid and invalid blocks alike. However, once a |
|
7180 // block is detected as invalid -- failing the three first steps -- it is |
|
7181 // adequate to spend more time determining validity before throwing a conflict. |
|
7182 |
|
7183 |
|
7184 // Blocks are inherently indifferent about where the data they operate with ends |
|
7185 // up being saved. For example, all blocks can have a static and dynamic aspect |
|
7186 // to them depending on the needs. The static nature of a block is the `save()` |
|
7187 // definition that is meant to be serialized into HTML and which can be left |
|
7188 // void. Any block can also register a `render_callback` on the server, which |
|
7189 // makes its output dynamic either in part or in its totality. |
|
7190 // |
|
7191 // Child blocks are defined as a relationship that builds on top of the inner |
|
7192 // blocks mechanism. A child block is a block node of a particular type that can |
|
7193 // only exist within the inner block boundaries of a specific parent type. This |
|
7194 // allows block authors to compose specific blocks that are not meant to be used |
|
7195 // outside of a specified parent block context. Thus, child blocks extend the |
|
7196 // concept of inner blocks to support a more direct relationship between sets of |
|
7197 // blocks. The addition of parent–child would be a subset of the inner block |
|
7198 // functionality under the premise that certain blocks only make sense as |
|
7199 // children of another block. |
|
7200 |
|
7201 |
|
7202 // Templates are, in a general sense, a basic collection of block nodes with any |
|
7203 // given set of predefined attributes that are supplied as the initial state of |
|
7204 // an inner blocks group. These nodes can, in turn, contain any number of nested |
|
7205 // blocks within their definition. Templates allow both to specify a default |
|
7206 // state for an editor session or a default set of blocks for any inner block |
|
7207 // implementation within a specific block. |
|
7208 |
|
7209 |
|
7210 |
|
7211 |
|
7212 |
|
7213 |
|
7214 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/index.js |
|
7215 // A "block" is the abstract term used to describe units of markup that, |
|
7216 // when composed together, form the content or layout of a page. |
|
7217 // The API for blocks is exposed via `wp.blocks`. |
|
7218 // |
|
7219 // Supported blocks are registered by calling `registerBlockType`. Once registered, |
|
7220 // the block is made available as an option to the editor interface. |
|
7221 // |
|
7222 // Blocks are inferred from the HTML source of a post through a parsing mechanism |
|
7223 // and then stored as objects in state, from which it is then rendered for editing. |
|
7224 |
|
7225 |
|
7226 |
|
7227 |
|
7228 |
|
7229 /***/ }), |
|
7230 |
|
7231 /***/ "1CF3": |
|
7232 /***/ (function(module, exports) { |
|
7233 |
|
7234 (function() { module.exports = window["wp"]["dom"]; }()); |
|
7235 |
|
7236 /***/ }), |
|
7237 |
|
7238 /***/ "1ZqX": |
|
7239 /***/ (function(module, exports) { |
|
7240 |
|
7241 (function() { module.exports = window["wp"]["data"]; }()); |
|
7242 |
|
7243 /***/ }), |
|
7244 |
|
7245 /***/ "7Cbv": |
|
7246 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
7247 |
|
7248 "use strict"; |
|
7249 |
|
7250 // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js |
|
7251 // Unique ID creation requires a high quality random # generator. In the browser we therefore |
|
7252 // require the crypto API and do not support built-in fallback to lower quality random number |
|
7253 // generators (like Math.random()). |
|
7254 var getRandomValues; |
|
7255 var rnds8 = new Uint8Array(16); |
|
7256 function rng() { |
|
7257 // lazy load so that environments that need to polyfill have a chance to do so |
|
7258 if (!getRandomValues) { |
|
7259 // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also, |
|
7260 // find the complete implementation of crypto (msCrypto) on IE11. |
|
7261 getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto); |
|
7262 |
|
7263 if (!getRandomValues) { |
|
7264 throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported'); |
|
7265 } |
|
7266 } |
|
7267 |
|
7268 return getRandomValues(rnds8); |
|
7269 } |
|
7270 // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/regex.js |
|
7271 /* 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); |
|
7272 // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/validate.js |
|
7273 |
|
7274 |
|
7275 function validate(uuid) { |
|
7276 return typeof uuid === 'string' && regex.test(uuid); |
|
7277 } |
|
7278 |
|
7279 /* harmony default export */ var esm_browser_validate = (validate); |
|
7280 // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js |
|
7281 |
|
7282 /** |
|
7283 * Convert array of 16 byte values to UUID string format of the form: |
|
7284 * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX |
|
7285 */ |
|
7286 |
|
7287 var byteToHex = []; |
|
7288 |
|
7289 for (var stringify_i = 0; stringify_i < 256; ++stringify_i) { |
|
7290 byteToHex.push((stringify_i + 0x100).toString(16).substr(1)); |
|
7291 } |
|
7292 |
|
7293 function stringify(arr) { |
|
7294 var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; |
|
7295 // Note: Be careful editing this code! It's been tuned for performance |
|
7296 // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 |
|
7297 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 |
|
7298 // of the following: |
|
7299 // - One or more input array values don't map to a hex octet (leading to |
|
7300 // "undefined" in the uuid) |
|
7301 // - Invalid input values for the RFC `version` or `variant` fields |
|
7302 |
|
7303 if (!esm_browser_validate(uuid)) { |
|
7304 throw TypeError('Stringified UUID is invalid'); |
|
7305 } |
|
7306 |
|
7307 return uuid; |
|
7308 } |
|
7309 |
|
7310 /* harmony default export */ var esm_browser_stringify = (stringify); |
|
7311 // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js |
|
7312 |
|
7313 |
|
7314 |
|
7315 function v4(options, buf, offset) { |
|
7316 options = options || {}; |
|
7317 var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` |
|
7318 |
|
7319 rnds[6] = rnds[6] & 0x0f | 0x40; |
|
7320 rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided |
|
7321 |
|
7322 if (buf) { |
|
7323 offset = offset || 0; |
|
7324 |
|
7325 for (var i = 0; i < 16; ++i) { |
|
7326 buf[offset + i] = rnds[i]; |
|
7327 } |
|
7328 |
|
7329 return buf; |
|
7330 } |
|
7331 |
|
7332 return esm_browser_stringify(rnds); |
|
7333 } |
|
7334 |
|
7335 /* harmony default export */ var esm_browser_v4 = __webpack_exports__["a"] = (v4); |
|
7336 |
|
7337 /***/ }), |
|
7338 |
|
7339 /***/ "GRId": |
|
7340 /***/ (function(module, exports) { |
|
7341 |
|
7342 (function() { module.exports = window["wp"]["element"]; }()); |
|
7343 |
|
7344 /***/ }), |
|
7345 |
|
7346 /***/ "K9lf": |
|
7347 /***/ (function(module, exports) { |
|
7348 |
|
7349 (function() { module.exports = window["wp"]["compose"]; }()); |
|
7350 |
|
7351 /***/ }), |
|
7352 |
|
7353 /***/ "M55E": |
|
7354 /***/ (function(module, exports, __webpack_require__) { |
173 /***/ (function(module, exports, __webpack_require__) { |
7355 |
174 |
7356 var __WEBPACK_AMD_DEFINE_RESULT__;;/*! showdown v 1.9.1 - 02-11-2019 */ |
175 var __WEBPACK_AMD_DEFINE_RESULT__;;/*! showdown v 1.9.1 - 02-11-2019 */ |
7357 (function(){ |
176 (function(){ |
7358 /** |
177 /** |
12482 if (true) { |
5301 if (true) { |
12483 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () { |
5302 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () { |
12484 'use strict'; |
5303 'use strict'; |
12485 return showdown; |
5304 return showdown; |
12486 }).call(exports, __webpack_require__, exports, module), |
5305 }).call(exports, __webpack_require__, exports, module), |
12487 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); |
5306 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); |
12488 |
5307 |
12489 // CommonJS/nodeJS Loader |
5308 // CommonJS/nodeJS Loader |
12490 } else {} |
5309 } else {} |
12491 }).call(this); |
5310 }).call(this); |
12492 |
5311 |
12493 |
5312 |
12494 |
5313 |
12495 |
5314 |
12496 /***/ }), |
5315 /***/ }) |
12497 |
5316 |
12498 /***/ "NMb1": |
5317 /******/ }); |
12499 /***/ (function(module, exports) { |
5318 /************************************************************************/ |
12500 |
5319 /******/ // The module cache |
12501 (function() { module.exports = window["wp"]["deprecated"]; }()); |
5320 /******/ var __webpack_module_cache__ = {}; |
12502 |
5321 /******/ |
12503 /***/ }), |
5322 /******/ // The require function |
12504 |
5323 /******/ function __webpack_require__(moduleId) { |
12505 /***/ "SVSp": |
5324 /******/ // Check if module is in cache |
12506 /***/ (function(module, exports) { |
5325 /******/ var cachedModule = __webpack_module_cache__[moduleId]; |
12507 |
5326 /******/ if (cachedModule !== undefined) { |
12508 (function() { module.exports = window["wp"]["shortcode"]; }()); |
5327 /******/ return cachedModule.exports; |
12509 |
5328 /******/ } |
12510 /***/ }), |
5329 /******/ // Create a new module (and put it into the cache) |
12511 |
5330 /******/ var module = __webpack_module_cache__[moduleId] = { |
12512 /***/ "Tqx9": |
5331 /******/ // no module.id needed |
12513 /***/ (function(module, exports) { |
5332 /******/ // no module.loaded needed |
12514 |
5333 /******/ exports: {} |
12515 (function() { module.exports = window["wp"]["primitives"]; }()); |
5334 /******/ }; |
12516 |
5335 /******/ |
12517 /***/ }), |
5336 /******/ // Execute the module function |
12518 |
5337 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
12519 /***/ "UuzZ": |
5338 /******/ |
12520 /***/ (function(module, exports) { |
5339 /******/ // Return the exports of the module |
12521 |
5340 /******/ return module.exports; |
12522 (function() { module.exports = window["wp"]["autop"]; }()); |
5341 /******/ } |
12523 |
5342 /******/ |
12524 /***/ }), |
5343 /************************************************************************/ |
12525 |
5344 /******/ /* webpack/runtime/compat get default export */ |
12526 /***/ "YLtl": |
5345 /******/ !function() { |
12527 /***/ (function(module, exports) { |
5346 /******/ // getDefaultExport function for compatibility with non-harmony modules |
12528 |
5347 /******/ __webpack_require__.n = function(module) { |
12529 (function() { module.exports = window["lodash"]; }()); |
5348 /******/ var getter = module && module.__esModule ? |
12530 |
5349 /******/ function() { return module['default']; } : |
12531 /***/ }), |
5350 /******/ function() { return module; }; |
12532 |
5351 /******/ __webpack_require__.d(getter, { a: getter }); |
12533 /***/ "Zss7": |
5352 /******/ return getter; |
12534 /***/ (function(module, exports, __webpack_require__) { |
5353 /******/ }; |
12535 |
5354 /******/ }(); |
12536 var __WEBPACK_AMD_DEFINE_RESULT__;// TinyColor v1.4.2 |
5355 /******/ |
12537 // https://github.com/bgrins/TinyColor |
5356 /******/ /* webpack/runtime/define property getters */ |
12538 // Brian Grinstead, MIT License |
5357 /******/ !function() { |
12539 |
5358 /******/ // define getter functions for harmony exports |
12540 (function(Math) { |
5359 /******/ __webpack_require__.d = function(exports, definition) { |
12541 |
5360 /******/ for(var key in definition) { |
12542 var trimLeft = /^\s+/, |
5361 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
12543 trimRight = /\s+$/, |
5362 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
12544 tinyCounter = 0, |
5363 /******/ } |
12545 mathRound = Math.round, |
5364 /******/ } |
12546 mathMin = Math.min, |
5365 /******/ }; |
12547 mathMax = Math.max, |
5366 /******/ }(); |
12548 mathRandom = Math.random; |
5367 /******/ |
12549 |
5368 /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
12550 function tinycolor (color, opts) { |
5369 /******/ !function() { |
12551 |
5370 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
12552 color = (color) ? color : ''; |
5371 /******/ }(); |
12553 opts = opts || { }; |
5372 /******/ |
12554 |
5373 /******/ /* webpack/runtime/make namespace object */ |
12555 // If input is already a tinycolor, return itself |
5374 /******/ !function() { |
12556 if (color instanceof tinycolor) { |
5375 /******/ // define __esModule on exports |
12557 return color; |
5376 /******/ __webpack_require__.r = function(exports) { |
12558 } |
5377 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
12559 // If we are called as a function, call using new instead |
5378 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
12560 if (!(this instanceof tinycolor)) { |
5379 /******/ } |
12561 return new tinycolor(color, opts); |
5380 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
12562 } |
5381 /******/ }; |
12563 |
5382 /******/ }(); |
12564 var rgb = inputToRGB(color); |
5383 /******/ |
12565 this._originalInput = color, |
5384 /************************************************************************/ |
12566 this._r = rgb.r, |
5385 var __webpack_exports__ = {}; |
12567 this._g = rgb.g, |
5386 // This entry need to be wrapped in an IIFE because it need to be in strict mode. |
12568 this._b = rgb.b, |
5387 !function() { |
12569 this._a = rgb.a, |
5388 "use strict"; |
12570 this._roundA = mathRound(100*this._a) / 100, |
5389 // ESM COMPAT FLAG |
12571 this._format = opts.format || rgb.format; |
5390 __webpack_require__.r(__webpack_exports__); |
12572 this._gradientType = opts.gradientType; |
5391 |
12573 |
5392 // EXPORTS |
12574 // Don't let the range of [0,255] come back in [0,1]. |
5393 __webpack_require__.d(__webpack_exports__, { |
12575 // Potentially lose a little bit of precision here, but will fix issues where |
5394 "__EXPERIMENTAL_ELEMENTS": function() { return /* reexport */ __EXPERIMENTAL_ELEMENTS; }, |
12576 // .5 gets interpreted as half of the total, instead of half of 1 |
5395 "__EXPERIMENTAL_PATHS_WITH_MERGE": function() { return /* reexport */ __EXPERIMENTAL_PATHS_WITH_MERGE; }, |
12577 // If it was supposed to be 128, this was already taken care of by `inputToRgb` |
5396 "__EXPERIMENTAL_STYLE_PROPERTY": function() { return /* reexport */ __EXPERIMENTAL_STYLE_PROPERTY; }, |
12578 if (this._r < 1) { this._r = mathRound(this._r); } |
5397 "__experimentalCloneSanitizedBlock": function() { return /* reexport */ __experimentalCloneSanitizedBlock; }, |
12579 if (this._g < 1) { this._g = mathRound(this._g); } |
5398 "__experimentalGetAccessibleBlockLabel": function() { return /* reexport */ getAccessibleBlockLabel; }, |
12580 if (this._b < 1) { this._b = mathRound(this._b); } |
5399 "__experimentalGetBlockAttributesNamesByRole": function() { return /* reexport */ __experimentalGetBlockAttributesNamesByRole; }, |
12581 |
5400 "__experimentalGetBlockLabel": function() { return /* reexport */ getBlockLabel; }, |
12582 this._ok = rgb.ok; |
5401 "__experimentalSanitizeBlockAttributes": function() { return /* reexport */ __experimentalSanitizeBlockAttributes; }, |
12583 this._tc_id = tinyCounter++; |
5402 "__unstableGetBlockProps": function() { return /* reexport */ getBlockProps; }, |
12584 } |
5403 "__unstableGetInnerBlocksProps": function() { return /* reexport */ getInnerBlocksProps; }, |
12585 |
5404 "__unstableSerializeAndClean": function() { return /* reexport */ __unstableSerializeAndClean; }, |
12586 tinycolor.prototype = { |
5405 "children": function() { return /* reexport */ children; }, |
12587 isDark: function() { |
5406 "cloneBlock": function() { return /* reexport */ cloneBlock; }, |
12588 return this.getBrightness() < 128; |
5407 "createBlock": function() { return /* reexport */ createBlock; }, |
12589 }, |
5408 "createBlocksFromInnerBlocksTemplate": function() { return /* reexport */ createBlocksFromInnerBlocksTemplate; }, |
12590 isLight: function() { |
5409 "doBlocksMatchTemplate": function() { return /* reexport */ doBlocksMatchTemplate; }, |
12591 return !this.isDark(); |
5410 "findTransform": function() { return /* reexport */ findTransform; }, |
12592 }, |
5411 "getBlockAttributes": function() { return /* reexport */ getBlockAttributes; }, |
12593 isValid: function() { |
5412 "getBlockContent": function() { return /* reexport */ getBlockInnerHTML; }, |
12594 return this._ok; |
5413 "getBlockDefaultClassName": function() { return /* reexport */ getBlockDefaultClassName; }, |
12595 }, |
5414 "getBlockFromExample": function() { return /* reexport */ getBlockFromExample; }, |
12596 getOriginalInput: function() { |
5415 "getBlockMenuDefaultClassName": function() { return /* reexport */ getBlockMenuDefaultClassName; }, |
12597 return this._originalInput; |
5416 "getBlockSupport": function() { return /* reexport */ registration_getBlockSupport; }, |
12598 }, |
5417 "getBlockTransforms": function() { return /* reexport */ getBlockTransforms; }, |
12599 getFormat: function() { |
5418 "getBlockType": function() { return /* reexport */ registration_getBlockType; }, |
12600 return this._format; |
5419 "getBlockTypes": function() { return /* reexport */ registration_getBlockTypes; }, |
12601 }, |
5420 "getBlockVariations": function() { return /* reexport */ registration_getBlockVariations; }, |
12602 getAlpha: function() { |
5421 "getCategories": function() { return /* reexport */ categories_getCategories; }, |
12603 return this._a; |
5422 "getChildBlockNames": function() { return /* reexport */ registration_getChildBlockNames; }, |
12604 }, |
5423 "getDefaultBlockName": function() { return /* reexport */ registration_getDefaultBlockName; }, |
12605 getBrightness: function() { |
5424 "getFreeformContentHandlerName": function() { return /* reexport */ getFreeformContentHandlerName; }, |
12606 //http://www.w3.org/TR/AERT#color-contrast |
5425 "getGroupingBlockName": function() { return /* reexport */ registration_getGroupingBlockName; }, |
12607 var rgb = this.toRgb(); |
5426 "getPhrasingContentSchema": function() { return /* reexport */ deprecatedGetPhrasingContentSchema; }, |
12608 return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000; |
5427 "getPossibleBlockTransformations": function() { return /* reexport */ getPossibleBlockTransformations; }, |
12609 }, |
5428 "getSaveContent": function() { return /* reexport */ getSaveContent; }, |
12610 getLuminance: function() { |
5429 "getSaveElement": function() { return /* reexport */ getSaveElement; }, |
12611 //http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef |
5430 "getUnregisteredTypeHandlerName": function() { return /* reexport */ getUnregisteredTypeHandlerName; }, |
12612 var rgb = this.toRgb(); |
5431 "hasBlockSupport": function() { return /* reexport */ registration_hasBlockSupport; }, |
12613 var RsRGB, GsRGB, BsRGB, R, G, B; |
5432 "hasChildBlocks": function() { return /* reexport */ registration_hasChildBlocks; }, |
12614 RsRGB = rgb.r/255; |
5433 "hasChildBlocksWithInserterSupport": function() { return /* reexport */ registration_hasChildBlocksWithInserterSupport; }, |
12615 GsRGB = rgb.g/255; |
5434 "isReusableBlock": function() { return /* reexport */ isReusableBlock; }, |
12616 BsRGB = rgb.b/255; |
5435 "isTemplatePart": function() { return /* reexport */ isTemplatePart; }, |
12617 |
5436 "isUnmodifiedDefaultBlock": function() { return /* reexport */ isUnmodifiedDefaultBlock; }, |
12618 if (RsRGB <= 0.03928) {R = RsRGB / 12.92;} else {R = Math.pow(((RsRGB + 0.055) / 1.055), 2.4);} |
5437 "isValidBlockContent": function() { return /* reexport */ isValidBlockContent; }, |
12619 if (GsRGB <= 0.03928) {G = GsRGB / 12.92;} else {G = Math.pow(((GsRGB + 0.055) / 1.055), 2.4);} |
5438 "isValidIcon": function() { return /* reexport */ isValidIcon; }, |
12620 if (BsRGB <= 0.03928) {B = BsRGB / 12.92;} else {B = Math.pow(((BsRGB + 0.055) / 1.055), 2.4);} |
5439 "node": function() { return /* reexport */ node; }, |
12621 return (0.2126 * R) + (0.7152 * G) + (0.0722 * B); |
5440 "normalizeIconObject": function() { return /* reexport */ normalizeIconObject; }, |
12622 }, |
5441 "parse": function() { return /* reexport */ parser_parse; }, |
12623 setAlpha: function(value) { |
5442 "parseWithAttributeSchema": function() { return /* reexport */ parseWithAttributeSchema; }, |
12624 this._a = boundAlpha(value); |
5443 "pasteHandler": function() { return /* reexport */ pasteHandler; }, |
12625 this._roundA = mathRound(100*this._a) / 100; |
5444 "rawHandler": function() { return /* reexport */ rawHandler; }, |
12626 return this; |
5445 "registerBlockCollection": function() { return /* reexport */ registerBlockCollection; }, |
12627 }, |
5446 "registerBlockStyle": function() { return /* reexport */ registerBlockStyle; }, |
12628 toHsv: function() { |
5447 "registerBlockType": function() { return /* reexport */ registerBlockType; }, |
12629 var hsv = rgbToHsv(this._r, this._g, this._b); |
5448 "registerBlockVariation": function() { return /* reexport */ registerBlockVariation; }, |
12630 return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a }; |
5449 "serialize": function() { return /* reexport */ serializer_serialize; }, |
12631 }, |
5450 "serializeRawBlock": function() { return /* reexport */ serializeRawBlock; }, |
12632 toHsvString: function() { |
5451 "setCategories": function() { return /* reexport */ categories_setCategories; }, |
12633 var hsv = rgbToHsv(this._r, this._g, this._b); |
5452 "setDefaultBlockName": function() { return /* reexport */ setDefaultBlockName; }, |
12634 var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100); |
5453 "setFreeformContentHandlerName": function() { return /* reexport */ setFreeformContentHandlerName; }, |
12635 return (this._a == 1) ? |
5454 "setGroupingBlockName": function() { return /* reexport */ setGroupingBlockName; }, |
12636 "hsv(" + h + ", " + s + "%, " + v + "%)" : |
5455 "setUnregisteredTypeHandlerName": function() { return /* reexport */ setUnregisteredTypeHandlerName; }, |
12637 "hsva(" + h + ", " + s + "%, " + v + "%, "+ this._roundA + ")"; |
5456 "store": function() { return /* reexport */ store; }, |
12638 }, |
5457 "switchToBlockType": function() { return /* reexport */ switchToBlockType; }, |
12639 toHsl: function() { |
5458 "synchronizeBlocksWithTemplate": function() { return /* reexport */ synchronizeBlocksWithTemplate; }, |
12640 var hsl = rgbToHsl(this._r, this._g, this._b); |
5459 "unregisterBlockStyle": function() { return /* reexport */ unregisterBlockStyle; }, |
12641 return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a }; |
5460 "unregisterBlockType": function() { return /* reexport */ unregisterBlockType; }, |
12642 }, |
5461 "unregisterBlockVariation": function() { return /* reexport */ unregisterBlockVariation; }, |
12643 toHslString: function() { |
5462 "unstable__bootstrapServerSideBlockDefinitions": function() { return /* reexport */ unstable__bootstrapServerSideBlockDefinitions; }, |
12644 var hsl = rgbToHsl(this._r, this._g, this._b); |
5463 "updateCategory": function() { return /* reexport */ categories_updateCategory; }, |
12645 var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100); |
5464 "validateBlock": function() { return /* reexport */ validateBlock; }, |
12646 return (this._a == 1) ? |
5465 "withBlockContentContext": function() { return /* reexport */ withBlockContentContext; } |
12647 "hsl(" + h + ", " + s + "%, " + l + "%)" : |
5466 }); |
12648 "hsla(" + h + ", " + s + "%, " + l + "%, "+ this._roundA + ")"; |
5467 |
12649 }, |
5468 // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/selectors.js |
12650 toHex: function(allow3Char) { |
5469 var selectors_namespaceObject = {}; |
12651 return rgbToHex(this._r, this._g, this._b, allow3Char); |
5470 __webpack_require__.r(selectors_namespaceObject); |
12652 }, |
5471 __webpack_require__.d(selectors_namespaceObject, { |
12653 toHexString: function(allow3Char) { |
5472 "__experimentalGetUnprocessedBlockTypes": function() { return __experimentalGetUnprocessedBlockTypes; }, |
12654 return '#' + this.toHex(allow3Char); |
5473 "getActiveBlockVariation": function() { return getActiveBlockVariation; }, |
12655 }, |
5474 "getBlockStyles": function() { return getBlockStyles; }, |
12656 toHex8: function(allow4Char) { |
5475 "getBlockSupport": function() { return getBlockSupport; }, |
12657 return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char); |
5476 "getBlockType": function() { return getBlockType; }, |
12658 }, |
5477 "getBlockTypes": function() { return getBlockTypes; }, |
12659 toHex8String: function(allow4Char) { |
5478 "getBlockVariations": function() { return getBlockVariations; }, |
12660 return '#' + this.toHex8(allow4Char); |
5479 "getCategories": function() { return getCategories; }, |
12661 }, |
5480 "getChildBlockNames": function() { return getChildBlockNames; }, |
12662 toRgb: function() { |
5481 "getCollections": function() { return getCollections; }, |
12663 return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a }; |
5482 "getDefaultBlockName": function() { return getDefaultBlockName; }, |
12664 }, |
5483 "getDefaultBlockVariation": function() { return getDefaultBlockVariation; }, |
12665 toRgbString: function() { |
5484 "getFreeformFallbackBlockName": function() { return getFreeformFallbackBlockName; }, |
12666 return (this._a == 1) ? |
5485 "getGroupingBlockName": function() { return getGroupingBlockName; }, |
12667 "rgb(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ")" : |
5486 "getUnregisteredFallbackBlockName": function() { return getUnregisteredFallbackBlockName; }, |
12668 "rgba(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ", " + this._roundA + ")"; |
5487 "hasBlockSupport": function() { return hasBlockSupport; }, |
12669 }, |
5488 "hasChildBlocks": function() { return hasChildBlocks; }, |
12670 toPercentageRgb: function() { |
5489 "hasChildBlocksWithInserterSupport": function() { return hasChildBlocksWithInserterSupport; }, |
12671 return { r: mathRound(bound01(this._r, 255) * 100) + "%", g: mathRound(bound01(this._g, 255) * 100) + "%", b: mathRound(bound01(this._b, 255) * 100) + "%", a: this._a }; |
5490 "isMatchingSearchTerm": function() { return isMatchingSearchTerm; } |
12672 }, |
5491 }); |
12673 toPercentageRgbString: function() { |
5492 |
12674 return (this._a == 1) ? |
5493 // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/actions.js |
12675 "rgb(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%)" : |
5494 var actions_namespaceObject = {}; |
12676 "rgba(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")"; |
5495 __webpack_require__.r(actions_namespaceObject); |
12677 }, |
5496 __webpack_require__.d(actions_namespaceObject, { |
12678 toName: function() { |
5497 "__experimentalReapplyBlockTypeFilters": function() { return __experimentalReapplyBlockTypeFilters; }, |
12679 if (this._a === 0) { |
5498 "__experimentalRegisterBlockType": function() { return __experimentalRegisterBlockType; }, |
12680 return "transparent"; |
5499 "addBlockCollection": function() { return addBlockCollection; }, |
|
5500 "addBlockStyles": function() { return addBlockStyles; }, |
|
5501 "addBlockTypes": function() { return addBlockTypes; }, |
|
5502 "addBlockVariations": function() { return addBlockVariations; }, |
|
5503 "removeBlockCollection": function() { return removeBlockCollection; }, |
|
5504 "removeBlockStyles": function() { return removeBlockStyles; }, |
|
5505 "removeBlockTypes": function() { return removeBlockTypes; }, |
|
5506 "removeBlockVariations": function() { return removeBlockVariations; }, |
|
5507 "setCategories": function() { return setCategories; }, |
|
5508 "setDefaultBlockName": function() { return actions_setDefaultBlockName; }, |
|
5509 "setFreeformFallbackBlockName": function() { return setFreeformFallbackBlockName; }, |
|
5510 "setGroupingBlockName": function() { return actions_setGroupingBlockName; }, |
|
5511 "setUnregisteredFallbackBlockName": function() { return setUnregisteredFallbackBlockName; }, |
|
5512 "updateCategory": function() { return updateCategory; } |
|
5513 }); |
|
5514 |
|
5515 ;// CONCATENATED MODULE: external ["wp","data"] |
|
5516 var external_wp_data_namespaceObject = window["wp"]["data"]; |
|
5517 ;// CONCATENATED MODULE: external "lodash" |
|
5518 var external_lodash_namespaceObject = window["lodash"]; |
|
5519 ;// CONCATENATED MODULE: external ["wp","i18n"] |
|
5520 var external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
|
5521 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/reducer.js |
|
5522 /** |
|
5523 * External dependencies |
|
5524 */ |
|
5525 |
|
5526 /** |
|
5527 * WordPress dependencies |
|
5528 */ |
|
5529 |
|
5530 |
|
5531 |
|
5532 /** |
|
5533 * @typedef {Object} WPBlockCategory |
|
5534 * |
|
5535 * @property {string} slug Unique category slug. |
|
5536 * @property {string} title Category label, for display in user interface. |
|
5537 */ |
|
5538 |
|
5539 /** |
|
5540 * Default set of categories. |
|
5541 * |
|
5542 * @type {WPBlockCategory[]} |
|
5543 */ |
|
5544 |
|
5545 const DEFAULT_CATEGORIES = [{ |
|
5546 slug: 'text', |
|
5547 title: (0,external_wp_i18n_namespaceObject.__)('Text') |
|
5548 }, { |
|
5549 slug: 'media', |
|
5550 title: (0,external_wp_i18n_namespaceObject.__)('Media') |
|
5551 }, { |
|
5552 slug: 'design', |
|
5553 title: (0,external_wp_i18n_namespaceObject.__)('Design') |
|
5554 }, { |
|
5555 slug: 'widgets', |
|
5556 title: (0,external_wp_i18n_namespaceObject.__)('Widgets') |
|
5557 }, { |
|
5558 slug: 'theme', |
|
5559 title: (0,external_wp_i18n_namespaceObject.__)('Theme') |
|
5560 }, { |
|
5561 slug: 'embed', |
|
5562 title: (0,external_wp_i18n_namespaceObject.__)('Embeds') |
|
5563 }, { |
|
5564 slug: 'reusable', |
|
5565 title: (0,external_wp_i18n_namespaceObject.__)('Reusable blocks') |
|
5566 }]; |
|
5567 /** |
|
5568 * Reducer managing the unprocessed block types in a form passed when registering the by block. |
|
5569 * It's for internal use only. It allows recomputing the processed block types on-demand after block type filters |
|
5570 * get added or removed. |
|
5571 * |
|
5572 * @param {Object} state Current state. |
|
5573 * @param {Object} action Dispatched action. |
|
5574 * |
|
5575 * @return {Object} Updated state. |
|
5576 */ |
|
5577 |
|
5578 function unprocessedBlockTypes() { |
|
5579 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
5580 let action = arguments.length > 1 ? arguments[1] : undefined; |
|
5581 |
|
5582 switch (action.type) { |
|
5583 case 'ADD_UNPROCESSED_BLOCK_TYPE': |
|
5584 return { ...state, |
|
5585 [action.blockType.name]: action.blockType |
|
5586 }; |
|
5587 |
|
5588 case 'REMOVE_BLOCK_TYPES': |
|
5589 return (0,external_lodash_namespaceObject.omit)(state, action.names); |
|
5590 } |
|
5591 |
|
5592 return state; |
|
5593 } |
|
5594 /** |
|
5595 * Reducer managing the processed block types with all filters applied. |
|
5596 * The state is derived from the `unprocessedBlockTypes` reducer. |
|
5597 * |
|
5598 * @param {Object} state Current state. |
|
5599 * @param {Object} action Dispatched action. |
|
5600 * |
|
5601 * @return {Object} Updated state. |
|
5602 */ |
|
5603 |
|
5604 function blockTypes() { |
|
5605 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
5606 let action = arguments.length > 1 ? arguments[1] : undefined; |
|
5607 |
|
5608 switch (action.type) { |
|
5609 case 'ADD_BLOCK_TYPES': |
|
5610 return { ...state, |
|
5611 ...(0,external_lodash_namespaceObject.keyBy)(action.blockTypes, 'name') |
|
5612 }; |
|
5613 |
|
5614 case 'REMOVE_BLOCK_TYPES': |
|
5615 return (0,external_lodash_namespaceObject.omit)(state, action.names); |
|
5616 } |
|
5617 |
|
5618 return state; |
|
5619 } |
|
5620 /** |
|
5621 * Reducer managing the block style variations. |
|
5622 * |
|
5623 * @param {Object} state Current state. |
|
5624 * @param {Object} action Dispatched action. |
|
5625 * |
|
5626 * @return {Object} Updated state. |
|
5627 */ |
|
5628 |
|
5629 function blockStyles() { |
|
5630 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
5631 let action = arguments.length > 1 ? arguments[1] : undefined; |
|
5632 |
|
5633 switch (action.type) { |
|
5634 case 'ADD_BLOCK_TYPES': |
|
5635 return { ...state, |
|
5636 ...(0,external_lodash_namespaceObject.mapValues)((0,external_lodash_namespaceObject.keyBy)(action.blockTypes, 'name'), blockType => { |
|
5637 return (0,external_lodash_namespaceObject.uniqBy)([...(0,external_lodash_namespaceObject.get)(blockType, ['styles'], []).map(style => ({ ...style, |
|
5638 source: 'block' |
|
5639 })), ...(0,external_lodash_namespaceObject.get)(state, [blockType.name], []).filter(_ref => { |
|
5640 let { |
|
5641 source |
|
5642 } = _ref; |
|
5643 return 'block' !== source; |
|
5644 })], style => style.name); |
|
5645 }) |
|
5646 }; |
|
5647 |
|
5648 case 'ADD_BLOCK_STYLES': |
|
5649 return { ...state, |
|
5650 [action.blockName]: (0,external_lodash_namespaceObject.uniqBy)([...(0,external_lodash_namespaceObject.get)(state, [action.blockName], []), ...action.styles], style => style.name) |
|
5651 }; |
|
5652 |
|
5653 case 'REMOVE_BLOCK_STYLES': |
|
5654 return { ...state, |
|
5655 [action.blockName]: (0,external_lodash_namespaceObject.filter)((0,external_lodash_namespaceObject.get)(state, [action.blockName], []), style => action.styleNames.indexOf(style.name) === -1) |
|
5656 }; |
|
5657 } |
|
5658 |
|
5659 return state; |
|
5660 } |
|
5661 /** |
|
5662 * Reducer managing the block variations. |
|
5663 * |
|
5664 * @param {Object} state Current state. |
|
5665 * @param {Object} action Dispatched action. |
|
5666 * |
|
5667 * @return {Object} Updated state. |
|
5668 */ |
|
5669 |
|
5670 function blockVariations() { |
|
5671 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
5672 let action = arguments.length > 1 ? arguments[1] : undefined; |
|
5673 |
|
5674 switch (action.type) { |
|
5675 case 'ADD_BLOCK_TYPES': |
|
5676 return { ...state, |
|
5677 ...(0,external_lodash_namespaceObject.mapValues)((0,external_lodash_namespaceObject.keyBy)(action.blockTypes, 'name'), blockType => { |
|
5678 return (0,external_lodash_namespaceObject.uniqBy)([...(0,external_lodash_namespaceObject.get)(blockType, ['variations'], []).map(variation => ({ ...variation, |
|
5679 source: 'block' |
|
5680 })), ...(0,external_lodash_namespaceObject.get)(state, [blockType.name], []).filter(_ref2 => { |
|
5681 let { |
|
5682 source |
|
5683 } = _ref2; |
|
5684 return 'block' !== source; |
|
5685 })], variation => variation.name); |
|
5686 }) |
|
5687 }; |
|
5688 |
|
5689 case 'ADD_BLOCK_VARIATIONS': |
|
5690 return { ...state, |
|
5691 [action.blockName]: (0,external_lodash_namespaceObject.uniqBy)([...(0,external_lodash_namespaceObject.get)(state, [action.blockName], []), ...action.variations], variation => variation.name) |
|
5692 }; |
|
5693 |
|
5694 case 'REMOVE_BLOCK_VARIATIONS': |
|
5695 return { ...state, |
|
5696 [action.blockName]: (0,external_lodash_namespaceObject.filter)((0,external_lodash_namespaceObject.get)(state, [action.blockName], []), variation => action.variationNames.indexOf(variation.name) === -1) |
|
5697 }; |
|
5698 } |
|
5699 |
|
5700 return state; |
|
5701 } |
|
5702 /** |
|
5703 * Higher-order Reducer creating a reducer keeping track of given block name. |
|
5704 * |
|
5705 * @param {string} setActionType Action type. |
|
5706 * |
|
5707 * @return {Function} Reducer. |
|
5708 */ |
|
5709 |
|
5710 function createBlockNameSetterReducer(setActionType) { |
|
5711 return function () { |
|
5712 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; |
|
5713 let action = arguments.length > 1 ? arguments[1] : undefined; |
|
5714 |
|
5715 switch (action.type) { |
|
5716 case 'REMOVE_BLOCK_TYPES': |
|
5717 if (action.names.indexOf(state) !== -1) { |
|
5718 return null; |
12681 } |
5719 } |
12682 |
5720 |
12683 if (this._a < 1) { |
5721 return state; |
12684 return false; |
5722 |
|
5723 case setActionType: |
|
5724 return action.name || null; |
|
5725 } |
|
5726 |
|
5727 return state; |
|
5728 }; |
|
5729 } |
|
5730 const defaultBlockName = createBlockNameSetterReducer('SET_DEFAULT_BLOCK_NAME'); |
|
5731 const freeformFallbackBlockName = createBlockNameSetterReducer('SET_FREEFORM_FALLBACK_BLOCK_NAME'); |
|
5732 const unregisteredFallbackBlockName = createBlockNameSetterReducer('SET_UNREGISTERED_FALLBACK_BLOCK_NAME'); |
|
5733 const groupingBlockName = createBlockNameSetterReducer('SET_GROUPING_BLOCK_NAME'); |
|
5734 /** |
|
5735 * Reducer managing the categories |
|
5736 * |
|
5737 * @param {WPBlockCategory[]} state Current state. |
|
5738 * @param {Object} action Dispatched action. |
|
5739 * |
|
5740 * @return {WPBlockCategory[]} Updated state. |
|
5741 */ |
|
5742 |
|
5743 function categories() { |
|
5744 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_CATEGORIES; |
|
5745 let action = arguments.length > 1 ? arguments[1] : undefined; |
|
5746 |
|
5747 switch (action.type) { |
|
5748 case 'SET_CATEGORIES': |
|
5749 return action.categories || []; |
|
5750 |
|
5751 case 'UPDATE_CATEGORY': |
|
5752 { |
|
5753 if (!action.category || (0,external_lodash_namespaceObject.isEmpty)(action.category)) { |
|
5754 return state; |
12685 } |
5755 } |
12686 |
5756 |
12687 return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false; |
5757 const categoryToChange = (0,external_lodash_namespaceObject.find)(state, ['slug', action.slug]); |
12688 }, |
5758 |
12689 toFilter: function(secondColor) { |
5759 if (categoryToChange) { |
12690 var hex8String = '#' + rgbaToArgbHex(this._r, this._g, this._b, this._a); |
5760 return (0,external_lodash_namespaceObject.map)(state, category => { |
12691 var secondHex8String = hex8String; |
5761 if (category.slug === action.slug) { |
12692 var gradientType = this._gradientType ? "GradientType = 1, " : ""; |
5762 return { ...category, |
12693 |
5763 ...action.category |
12694 if (secondColor) { |
5764 }; |
12695 var s = tinycolor(secondColor); |
5765 } |
12696 secondHex8String = '#' + rgbaToArgbHex(s._r, s._g, s._b, s._a); |
5766 |
|
5767 return category; |
|
5768 }); |
12697 } |
5769 } |
12698 |
5770 } |
12699 return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")"; |
5771 } |
12700 }, |
5772 |
12701 toString: function(format) { |
5773 return state; |
12702 var formatSet = !!format; |
5774 } |
12703 format = format || this._format; |
5775 function collections() { |
12704 |
5776 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
12705 var formattedString = false; |
5777 let action = arguments.length > 1 ? arguments[1] : undefined; |
12706 var hasAlpha = this._a < 1 && this._a >= 0; |
5778 |
12707 var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name"); |
5779 switch (action.type) { |
12708 |
5780 case 'ADD_BLOCK_COLLECTION': |
12709 if (needsAlphaFormat) { |
5781 return { ...state, |
12710 // Special case for "transparent", all other non-alpha formats |
5782 [action.namespace]: { |
12711 // will return rgba when there is transparency. |
5783 title: action.title, |
12712 if (format === "name" && this._a === 0) { |
5784 icon: action.icon |
12713 return this.toName(); |
|
12714 } |
|
12715 return this.toRgbString(); |
|
12716 } |
5785 } |
12717 if (format === "rgb") { |
5786 }; |
12718 formattedString = this.toRgbString(); |
5787 |
12719 } |
5788 case 'REMOVE_BLOCK_COLLECTION': |
12720 if (format === "prgb") { |
5789 return (0,external_lodash_namespaceObject.omit)(state, action.namespace); |
12721 formattedString = this.toPercentageRgbString(); |
5790 } |
12722 } |
5791 |
12723 if (format === "hex" || format === "hex6") { |
5792 return state; |
12724 formattedString = this.toHexString(); |
5793 } |
12725 } |
5794 /* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ |
12726 if (format === "hex3") { |
5795 unprocessedBlockTypes, |
12727 formattedString = this.toHexString(true); |
5796 blockTypes, |
12728 } |
5797 blockStyles, |
12729 if (format === "hex4") { |
5798 blockVariations, |
12730 formattedString = this.toHex8String(true); |
5799 defaultBlockName, |
12731 } |
5800 freeformFallbackBlockName, |
12732 if (format === "hex8") { |
5801 unregisteredFallbackBlockName, |
12733 formattedString = this.toHex8String(); |
5802 groupingBlockName, |
12734 } |
5803 categories, |
12735 if (format === "name") { |
5804 collections |
12736 formattedString = this.toName(); |
5805 })); |
12737 } |
5806 |
12738 if (format === "hsl") { |
5807 ;// CONCATENATED MODULE: ./node_modules/rememo/es/rememo.js |
12739 formattedString = this.toHslString(); |
|
12740 } |
|
12741 if (format === "hsv") { |
|
12742 formattedString = this.toHsvString(); |
|
12743 } |
|
12744 |
|
12745 return formattedString || this.toHexString(); |
|
12746 }, |
|
12747 clone: function() { |
|
12748 return tinycolor(this.toString()); |
|
12749 }, |
|
12750 |
|
12751 _applyModification: function(fn, args) { |
|
12752 var color = fn.apply(null, [this].concat([].slice.call(args))); |
|
12753 this._r = color._r; |
|
12754 this._g = color._g; |
|
12755 this._b = color._b; |
|
12756 this.setAlpha(color._a); |
|
12757 return this; |
|
12758 }, |
|
12759 lighten: function() { |
|
12760 return this._applyModification(lighten, arguments); |
|
12761 }, |
|
12762 brighten: function() { |
|
12763 return this._applyModification(brighten, arguments); |
|
12764 }, |
|
12765 darken: function() { |
|
12766 return this._applyModification(darken, arguments); |
|
12767 }, |
|
12768 desaturate: function() { |
|
12769 return this._applyModification(desaturate, arguments); |
|
12770 }, |
|
12771 saturate: function() { |
|
12772 return this._applyModification(saturate, arguments); |
|
12773 }, |
|
12774 greyscale: function() { |
|
12775 return this._applyModification(greyscale, arguments); |
|
12776 }, |
|
12777 spin: function() { |
|
12778 return this._applyModification(spin, arguments); |
|
12779 }, |
|
12780 |
|
12781 _applyCombination: function(fn, args) { |
|
12782 return fn.apply(null, [this].concat([].slice.call(args))); |
|
12783 }, |
|
12784 analogous: function() { |
|
12785 return this._applyCombination(analogous, arguments); |
|
12786 }, |
|
12787 complement: function() { |
|
12788 return this._applyCombination(complement, arguments); |
|
12789 }, |
|
12790 monochromatic: function() { |
|
12791 return this._applyCombination(monochromatic, arguments); |
|
12792 }, |
|
12793 splitcomplement: function() { |
|
12794 return this._applyCombination(splitcomplement, arguments); |
|
12795 }, |
|
12796 triad: function() { |
|
12797 return this._applyCombination(triad, arguments); |
|
12798 }, |
|
12799 tetrad: function() { |
|
12800 return this._applyCombination(tetrad, arguments); |
|
12801 } |
|
12802 }; |
|
12803 |
|
12804 // If input is an object, force 1 into "1.0" to handle ratios properly |
|
12805 // String input requires "1.0" as input, so 1 will be treated as 1 |
|
12806 tinycolor.fromRatio = function(color, opts) { |
|
12807 if (typeof color == "object") { |
|
12808 var newColor = {}; |
|
12809 for (var i in color) { |
|
12810 if (color.hasOwnProperty(i)) { |
|
12811 if (i === "a") { |
|
12812 newColor[i] = color[i]; |
|
12813 } |
|
12814 else { |
|
12815 newColor[i] = convertToPercentage(color[i]); |
|
12816 } |
|
12817 } |
|
12818 } |
|
12819 color = newColor; |
|
12820 } |
|
12821 |
|
12822 return tinycolor(color, opts); |
|
12823 }; |
|
12824 |
|
12825 // Given a string or object, convert that input to RGB |
|
12826 // Possible string inputs: |
|
12827 // |
|
12828 // "red" |
|
12829 // "#f00" or "f00" |
|
12830 // "#ff0000" or "ff0000" |
|
12831 // "#ff000000" or "ff000000" |
|
12832 // "rgb 255 0 0" or "rgb (255, 0, 0)" |
|
12833 // "rgb 1.0 0 0" or "rgb (1, 0, 0)" |
|
12834 // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1" |
|
12835 // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1" |
|
12836 // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%" |
|
12837 // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1" |
|
12838 // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%" |
|
12839 // |
|
12840 function inputToRGB(color) { |
|
12841 |
|
12842 var rgb = { r: 0, g: 0, b: 0 }; |
|
12843 var a = 1; |
|
12844 var s = null; |
|
12845 var v = null; |
|
12846 var l = null; |
|
12847 var ok = false; |
|
12848 var format = false; |
|
12849 |
|
12850 if (typeof color == "string") { |
|
12851 color = stringInputToObject(color); |
|
12852 } |
|
12853 |
|
12854 if (typeof color == "object") { |
|
12855 if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) { |
|
12856 rgb = rgbToRgb(color.r, color.g, color.b); |
|
12857 ok = true; |
|
12858 format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb"; |
|
12859 } |
|
12860 else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) { |
|
12861 s = convertToPercentage(color.s); |
|
12862 v = convertToPercentage(color.v); |
|
12863 rgb = hsvToRgb(color.h, s, v); |
|
12864 ok = true; |
|
12865 format = "hsv"; |
|
12866 } |
|
12867 else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) { |
|
12868 s = convertToPercentage(color.s); |
|
12869 l = convertToPercentage(color.l); |
|
12870 rgb = hslToRgb(color.h, s, l); |
|
12871 ok = true; |
|
12872 format = "hsl"; |
|
12873 } |
|
12874 |
|
12875 if (color.hasOwnProperty("a")) { |
|
12876 a = color.a; |
|
12877 } |
|
12878 } |
|
12879 |
|
12880 a = boundAlpha(a); |
|
12881 |
|
12882 return { |
|
12883 ok: ok, |
|
12884 format: color.format || format, |
|
12885 r: mathMin(255, mathMax(rgb.r, 0)), |
|
12886 g: mathMin(255, mathMax(rgb.g, 0)), |
|
12887 b: mathMin(255, mathMax(rgb.b, 0)), |
|
12888 a: a |
|
12889 }; |
|
12890 } |
|
12891 |
|
12892 |
|
12893 // Conversion Functions |
|
12894 // -------------------- |
|
12895 |
|
12896 // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from: |
|
12897 // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript> |
|
12898 |
|
12899 // `rgbToRgb` |
|
12900 // Handle bounds / percentage checking to conform to CSS color spec |
|
12901 // <http://www.w3.org/TR/css3-color/> |
|
12902 // *Assumes:* r, g, b in [0, 255] or [0, 1] |
|
12903 // *Returns:* { r, g, b } in [0, 255] |
|
12904 function rgbToRgb(r, g, b){ |
|
12905 return { |
|
12906 r: bound01(r, 255) * 255, |
|
12907 g: bound01(g, 255) * 255, |
|
12908 b: bound01(b, 255) * 255 |
|
12909 }; |
|
12910 } |
|
12911 |
|
12912 // `rgbToHsl` |
|
12913 // Converts an RGB color value to HSL. |
|
12914 // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1] |
|
12915 // *Returns:* { h, s, l } in [0,1] |
|
12916 function rgbToHsl(r, g, b) { |
|
12917 |
|
12918 r = bound01(r, 255); |
|
12919 g = bound01(g, 255); |
|
12920 b = bound01(b, 255); |
|
12921 |
|
12922 var max = mathMax(r, g, b), min = mathMin(r, g, b); |
|
12923 var h, s, l = (max + min) / 2; |
|
12924 |
|
12925 if(max == min) { |
|
12926 h = s = 0; // achromatic |
|
12927 } |
|
12928 else { |
|
12929 var d = max - min; |
|
12930 s = l > 0.5 ? d / (2 - max - min) : d / (max + min); |
|
12931 switch(max) { |
|
12932 case r: h = (g - b) / d + (g < b ? 6 : 0); break; |
|
12933 case g: h = (b - r) / d + 2; break; |
|
12934 case b: h = (r - g) / d + 4; break; |
|
12935 } |
|
12936 |
|
12937 h /= 6; |
|
12938 } |
|
12939 |
|
12940 return { h: h, s: s, l: l }; |
|
12941 } |
|
12942 |
|
12943 // `hslToRgb` |
|
12944 // Converts an HSL color value to RGB. |
|
12945 // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100] |
|
12946 // *Returns:* { r, g, b } in the set [0, 255] |
|
12947 function hslToRgb(h, s, l) { |
|
12948 var r, g, b; |
|
12949 |
|
12950 h = bound01(h, 360); |
|
12951 s = bound01(s, 100); |
|
12952 l = bound01(l, 100); |
|
12953 |
|
12954 function hue2rgb(p, q, t) { |
|
12955 if(t < 0) t += 1; |
|
12956 if(t > 1) t -= 1; |
|
12957 if(t < 1/6) return p + (q - p) * 6 * t; |
|
12958 if(t < 1/2) return q; |
|
12959 if(t < 2/3) return p + (q - p) * (2/3 - t) * 6; |
|
12960 return p; |
|
12961 } |
|
12962 |
|
12963 if(s === 0) { |
|
12964 r = g = b = l; // achromatic |
|
12965 } |
|
12966 else { |
|
12967 var q = l < 0.5 ? l * (1 + s) : l + s - l * s; |
|
12968 var p = 2 * l - q; |
|
12969 r = hue2rgb(p, q, h + 1/3); |
|
12970 g = hue2rgb(p, q, h); |
|
12971 b = hue2rgb(p, q, h - 1/3); |
|
12972 } |
|
12973 |
|
12974 return { r: r * 255, g: g * 255, b: b * 255 }; |
|
12975 } |
|
12976 |
|
12977 // `rgbToHsv` |
|
12978 // Converts an RGB color value to HSV |
|
12979 // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1] |
|
12980 // *Returns:* { h, s, v } in [0,1] |
|
12981 function rgbToHsv(r, g, b) { |
|
12982 |
|
12983 r = bound01(r, 255); |
|
12984 g = bound01(g, 255); |
|
12985 b = bound01(b, 255); |
|
12986 |
|
12987 var max = mathMax(r, g, b), min = mathMin(r, g, b); |
|
12988 var h, s, v = max; |
|
12989 |
|
12990 var d = max - min; |
|
12991 s = max === 0 ? 0 : d / max; |
|
12992 |
|
12993 if(max == min) { |
|
12994 h = 0; // achromatic |
|
12995 } |
|
12996 else { |
|
12997 switch(max) { |
|
12998 case r: h = (g - b) / d + (g < b ? 6 : 0); break; |
|
12999 case g: h = (b - r) / d + 2; break; |
|
13000 case b: h = (r - g) / d + 4; break; |
|
13001 } |
|
13002 h /= 6; |
|
13003 } |
|
13004 return { h: h, s: s, v: v }; |
|
13005 } |
|
13006 |
|
13007 // `hsvToRgb` |
|
13008 // Converts an HSV color value to RGB. |
|
13009 // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100] |
|
13010 // *Returns:* { r, g, b } in the set [0, 255] |
|
13011 function hsvToRgb(h, s, v) { |
|
13012 |
|
13013 h = bound01(h, 360) * 6; |
|
13014 s = bound01(s, 100); |
|
13015 v = bound01(v, 100); |
|
13016 |
|
13017 var i = Math.floor(h), |
|
13018 f = h - i, |
|
13019 p = v * (1 - s), |
|
13020 q = v * (1 - f * s), |
|
13021 t = v * (1 - (1 - f) * s), |
|
13022 mod = i % 6, |
|
13023 r = [v, q, p, p, t, v][mod], |
|
13024 g = [t, v, v, q, p, p][mod], |
|
13025 b = [p, p, t, v, v, q][mod]; |
|
13026 |
|
13027 return { r: r * 255, g: g * 255, b: b * 255 }; |
|
13028 } |
|
13029 |
|
13030 // `rgbToHex` |
|
13031 // Converts an RGB color to hex |
|
13032 // Assumes r, g, and b are contained in the set [0, 255] |
|
13033 // Returns a 3 or 6 character hex |
|
13034 function rgbToHex(r, g, b, allow3Char) { |
|
13035 |
|
13036 var hex = [ |
|
13037 pad2(mathRound(r).toString(16)), |
|
13038 pad2(mathRound(g).toString(16)), |
|
13039 pad2(mathRound(b).toString(16)) |
|
13040 ]; |
|
13041 |
|
13042 // Return a 3 character hex if possible |
|
13043 if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) { |
|
13044 return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0); |
|
13045 } |
|
13046 |
|
13047 return hex.join(""); |
|
13048 } |
|
13049 |
|
13050 // `rgbaToHex` |
|
13051 // Converts an RGBA color plus alpha transparency to hex |
|
13052 // Assumes r, g, b are contained in the set [0, 255] and |
|
13053 // a in [0, 1]. Returns a 4 or 8 character rgba hex |
|
13054 function rgbaToHex(r, g, b, a, allow4Char) { |
|
13055 |
|
13056 var hex = [ |
|
13057 pad2(mathRound(r).toString(16)), |
|
13058 pad2(mathRound(g).toString(16)), |
|
13059 pad2(mathRound(b).toString(16)), |
|
13060 pad2(convertDecimalToHex(a)) |
|
13061 ]; |
|
13062 |
|
13063 // Return a 4 character hex if possible |
|
13064 if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) { |
|
13065 return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0); |
|
13066 } |
|
13067 |
|
13068 return hex.join(""); |
|
13069 } |
|
13070 |
|
13071 // `rgbaToArgbHex` |
|
13072 // Converts an RGBA color to an ARGB Hex8 string |
|
13073 // Rarely used, but required for "toFilter()" |
|
13074 function rgbaToArgbHex(r, g, b, a) { |
|
13075 |
|
13076 var hex = [ |
|
13077 pad2(convertDecimalToHex(a)), |
|
13078 pad2(mathRound(r).toString(16)), |
|
13079 pad2(mathRound(g).toString(16)), |
|
13080 pad2(mathRound(b).toString(16)) |
|
13081 ]; |
|
13082 |
|
13083 return hex.join(""); |
|
13084 } |
|
13085 |
|
13086 // `equals` |
|
13087 // Can be called with any tinycolor input |
|
13088 tinycolor.equals = function (color1, color2) { |
|
13089 if (!color1 || !color2) { return false; } |
|
13090 return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString(); |
|
13091 }; |
|
13092 |
|
13093 tinycolor.random = function() { |
|
13094 return tinycolor.fromRatio({ |
|
13095 r: mathRandom(), |
|
13096 g: mathRandom(), |
|
13097 b: mathRandom() |
|
13098 }); |
|
13099 }; |
|
13100 |
|
13101 |
|
13102 // Modification Functions |
|
13103 // ---------------------- |
|
13104 // Thanks to less.js for some of the basics here |
|
13105 // <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js> |
|
13106 |
|
13107 function desaturate(color, amount) { |
|
13108 amount = (amount === 0) ? 0 : (amount || 10); |
|
13109 var hsl = tinycolor(color).toHsl(); |
|
13110 hsl.s -= amount / 100; |
|
13111 hsl.s = clamp01(hsl.s); |
|
13112 return tinycolor(hsl); |
|
13113 } |
|
13114 |
|
13115 function saturate(color, amount) { |
|
13116 amount = (amount === 0) ? 0 : (amount || 10); |
|
13117 var hsl = tinycolor(color).toHsl(); |
|
13118 hsl.s += amount / 100; |
|
13119 hsl.s = clamp01(hsl.s); |
|
13120 return tinycolor(hsl); |
|
13121 } |
|
13122 |
|
13123 function greyscale(color) { |
|
13124 return tinycolor(color).desaturate(100); |
|
13125 } |
|
13126 |
|
13127 function lighten (color, amount) { |
|
13128 amount = (amount === 0) ? 0 : (amount || 10); |
|
13129 var hsl = tinycolor(color).toHsl(); |
|
13130 hsl.l += amount / 100; |
|
13131 hsl.l = clamp01(hsl.l); |
|
13132 return tinycolor(hsl); |
|
13133 } |
|
13134 |
|
13135 function brighten(color, amount) { |
|
13136 amount = (amount === 0) ? 0 : (amount || 10); |
|
13137 var rgb = tinycolor(color).toRgb(); |
|
13138 rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100)))); |
|
13139 rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100)))); |
|
13140 rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100)))); |
|
13141 return tinycolor(rgb); |
|
13142 } |
|
13143 |
|
13144 function darken (color, amount) { |
|
13145 amount = (amount === 0) ? 0 : (amount || 10); |
|
13146 var hsl = tinycolor(color).toHsl(); |
|
13147 hsl.l -= amount / 100; |
|
13148 hsl.l = clamp01(hsl.l); |
|
13149 return tinycolor(hsl); |
|
13150 } |
|
13151 |
|
13152 // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue. |
|
13153 // Values outside of this range will be wrapped into this range. |
|
13154 function spin(color, amount) { |
|
13155 var hsl = tinycolor(color).toHsl(); |
|
13156 var hue = (hsl.h + amount) % 360; |
|
13157 hsl.h = hue < 0 ? 360 + hue : hue; |
|
13158 return tinycolor(hsl); |
|
13159 } |
|
13160 |
|
13161 // Combination Functions |
|
13162 // --------------------- |
|
13163 // Thanks to jQuery xColor for some of the ideas behind these |
|
13164 // <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js> |
|
13165 |
|
13166 function complement(color) { |
|
13167 var hsl = tinycolor(color).toHsl(); |
|
13168 hsl.h = (hsl.h + 180) % 360; |
|
13169 return tinycolor(hsl); |
|
13170 } |
|
13171 |
|
13172 function triad(color) { |
|
13173 var hsl = tinycolor(color).toHsl(); |
|
13174 var h = hsl.h; |
|
13175 return [ |
|
13176 tinycolor(color), |
|
13177 tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }), |
|
13178 tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l }) |
|
13179 ]; |
|
13180 } |
|
13181 |
|
13182 function tetrad(color) { |
|
13183 var hsl = tinycolor(color).toHsl(); |
|
13184 var h = hsl.h; |
|
13185 return [ |
|
13186 tinycolor(color), |
|
13187 tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }), |
|
13188 tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }), |
|
13189 tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l }) |
|
13190 ]; |
|
13191 } |
|
13192 |
|
13193 function splitcomplement(color) { |
|
13194 var hsl = tinycolor(color).toHsl(); |
|
13195 var h = hsl.h; |
|
13196 return [ |
|
13197 tinycolor(color), |
|
13198 tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}), |
|
13199 tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l}) |
|
13200 ]; |
|
13201 } |
|
13202 |
|
13203 function analogous(color, results, slices) { |
|
13204 results = results || 6; |
|
13205 slices = slices || 30; |
|
13206 |
|
13207 var hsl = tinycolor(color).toHsl(); |
|
13208 var part = 360 / slices; |
|
13209 var ret = [tinycolor(color)]; |
|
13210 |
|
13211 for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) { |
|
13212 hsl.h = (hsl.h + part) % 360; |
|
13213 ret.push(tinycolor(hsl)); |
|
13214 } |
|
13215 return ret; |
|
13216 } |
|
13217 |
|
13218 function monochromatic(color, results) { |
|
13219 results = results || 6; |
|
13220 var hsv = tinycolor(color).toHsv(); |
|
13221 var h = hsv.h, s = hsv.s, v = hsv.v; |
|
13222 var ret = []; |
|
13223 var modification = 1 / results; |
|
13224 |
|
13225 while (results--) { |
|
13226 ret.push(tinycolor({ h: h, s: s, v: v})); |
|
13227 v = (v + modification) % 1; |
|
13228 } |
|
13229 |
|
13230 return ret; |
|
13231 } |
|
13232 |
|
13233 // Utility Functions |
|
13234 // --------------------- |
|
13235 |
|
13236 tinycolor.mix = function(color1, color2, amount) { |
|
13237 amount = (amount === 0) ? 0 : (amount || 50); |
|
13238 |
|
13239 var rgb1 = tinycolor(color1).toRgb(); |
|
13240 var rgb2 = tinycolor(color2).toRgb(); |
|
13241 |
|
13242 var p = amount / 100; |
|
13243 |
|
13244 var rgba = { |
|
13245 r: ((rgb2.r - rgb1.r) * p) + rgb1.r, |
|
13246 g: ((rgb2.g - rgb1.g) * p) + rgb1.g, |
|
13247 b: ((rgb2.b - rgb1.b) * p) + rgb1.b, |
|
13248 a: ((rgb2.a - rgb1.a) * p) + rgb1.a |
|
13249 }; |
|
13250 |
|
13251 return tinycolor(rgba); |
|
13252 }; |
|
13253 |
|
13254 |
|
13255 // Readability Functions |
|
13256 // --------------------- |
|
13257 // <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2) |
|
13258 |
|
13259 // `contrast` |
|
13260 // Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2) |
|
13261 tinycolor.readability = function(color1, color2) { |
|
13262 var c1 = tinycolor(color1); |
|
13263 var c2 = tinycolor(color2); |
|
13264 return (Math.max(c1.getLuminance(),c2.getLuminance())+0.05) / (Math.min(c1.getLuminance(),c2.getLuminance())+0.05); |
|
13265 }; |
|
13266 |
|
13267 // `isReadable` |
|
13268 // Ensure that foreground and background color combinations meet WCAG2 guidelines. |
|
13269 // The third argument is an optional Object. |
|
13270 // the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA'; |
|
13271 // the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'. |
|
13272 // If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}. |
|
13273 |
|
13274 // *Example* |
|
13275 // tinycolor.isReadable("#000", "#111") => false |
|
13276 // tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false |
|
13277 tinycolor.isReadable = function(color1, color2, wcag2) { |
|
13278 var readability = tinycolor.readability(color1, color2); |
|
13279 var wcag2Parms, out; |
|
13280 |
|
13281 out = false; |
|
13282 |
|
13283 wcag2Parms = validateWCAG2Parms(wcag2); |
|
13284 switch (wcag2Parms.level + wcag2Parms.size) { |
|
13285 case "AAsmall": |
|
13286 case "AAAlarge": |
|
13287 out = readability >= 4.5; |
|
13288 break; |
|
13289 case "AAlarge": |
|
13290 out = readability >= 3; |
|
13291 break; |
|
13292 case "AAAsmall": |
|
13293 out = readability >= 7; |
|
13294 break; |
|
13295 } |
|
13296 return out; |
|
13297 |
|
13298 }; |
|
13299 |
|
13300 // `mostReadable` |
|
13301 // Given a base color and a list of possible foreground or background |
|
13302 // colors for that base, returns the most readable color. |
|
13303 // Optionally returns Black or White if the most readable color is unreadable. |
|
13304 // *Example* |
|
13305 // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255" |
|
13306 // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff" |
|
13307 // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3" |
|
13308 // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff" |
|
13309 tinycolor.mostReadable = function(baseColor, colorList, args) { |
|
13310 var bestColor = null; |
|
13311 var bestScore = 0; |
|
13312 var readability; |
|
13313 var includeFallbackColors, level, size ; |
|
13314 args = args || {}; |
|
13315 includeFallbackColors = args.includeFallbackColors ; |
|
13316 level = args.level; |
|
13317 size = args.size; |
|
13318 |
|
13319 for (var i= 0; i < colorList.length ; i++) { |
|
13320 readability = tinycolor.readability(baseColor, colorList[i]); |
|
13321 if (readability > bestScore) { |
|
13322 bestScore = readability; |
|
13323 bestColor = tinycolor(colorList[i]); |
|
13324 } |
|
13325 } |
|
13326 |
|
13327 if (tinycolor.isReadable(baseColor, bestColor, {"level":level,"size":size}) || !includeFallbackColors) { |
|
13328 return bestColor; |
|
13329 } |
|
13330 else { |
|
13331 args.includeFallbackColors=false; |
|
13332 return tinycolor.mostReadable(baseColor,["#fff", "#000"],args); |
|
13333 } |
|
13334 }; |
|
13335 |
|
13336 |
|
13337 // Big List of Colors |
|
13338 // ------------------ |
|
13339 // <http://www.w3.org/TR/css3-color/#svg-color> |
|
13340 var names = tinycolor.names = { |
|
13341 aliceblue: "f0f8ff", |
|
13342 antiquewhite: "faebd7", |
|
13343 aqua: "0ff", |
|
13344 aquamarine: "7fffd4", |
|
13345 azure: "f0ffff", |
|
13346 beige: "f5f5dc", |
|
13347 bisque: "ffe4c4", |
|
13348 black: "000", |
|
13349 blanchedalmond: "ffebcd", |
|
13350 blue: "00f", |
|
13351 blueviolet: "8a2be2", |
|
13352 brown: "a52a2a", |
|
13353 burlywood: "deb887", |
|
13354 burntsienna: "ea7e5d", |
|
13355 cadetblue: "5f9ea0", |
|
13356 chartreuse: "7fff00", |
|
13357 chocolate: "d2691e", |
|
13358 coral: "ff7f50", |
|
13359 cornflowerblue: "6495ed", |
|
13360 cornsilk: "fff8dc", |
|
13361 crimson: "dc143c", |
|
13362 cyan: "0ff", |
|
13363 darkblue: "00008b", |
|
13364 darkcyan: "008b8b", |
|
13365 darkgoldenrod: "b8860b", |
|
13366 darkgray: "a9a9a9", |
|
13367 darkgreen: "006400", |
|
13368 darkgrey: "a9a9a9", |
|
13369 darkkhaki: "bdb76b", |
|
13370 darkmagenta: "8b008b", |
|
13371 darkolivegreen: "556b2f", |
|
13372 darkorange: "ff8c00", |
|
13373 darkorchid: "9932cc", |
|
13374 darkred: "8b0000", |
|
13375 darksalmon: "e9967a", |
|
13376 darkseagreen: "8fbc8f", |
|
13377 darkslateblue: "483d8b", |
|
13378 darkslategray: "2f4f4f", |
|
13379 darkslategrey: "2f4f4f", |
|
13380 darkturquoise: "00ced1", |
|
13381 darkviolet: "9400d3", |
|
13382 deeppink: "ff1493", |
|
13383 deepskyblue: "00bfff", |
|
13384 dimgray: "696969", |
|
13385 dimgrey: "696969", |
|
13386 dodgerblue: "1e90ff", |
|
13387 firebrick: "b22222", |
|
13388 floralwhite: "fffaf0", |
|
13389 forestgreen: "228b22", |
|
13390 fuchsia: "f0f", |
|
13391 gainsboro: "dcdcdc", |
|
13392 ghostwhite: "f8f8ff", |
|
13393 gold: "ffd700", |
|
13394 goldenrod: "daa520", |
|
13395 gray: "808080", |
|
13396 green: "008000", |
|
13397 greenyellow: "adff2f", |
|
13398 grey: "808080", |
|
13399 honeydew: "f0fff0", |
|
13400 hotpink: "ff69b4", |
|
13401 indianred: "cd5c5c", |
|
13402 indigo: "4b0082", |
|
13403 ivory: "fffff0", |
|
13404 khaki: "f0e68c", |
|
13405 lavender: "e6e6fa", |
|
13406 lavenderblush: "fff0f5", |
|
13407 lawngreen: "7cfc00", |
|
13408 lemonchiffon: "fffacd", |
|
13409 lightblue: "add8e6", |
|
13410 lightcoral: "f08080", |
|
13411 lightcyan: "e0ffff", |
|
13412 lightgoldenrodyellow: "fafad2", |
|
13413 lightgray: "d3d3d3", |
|
13414 lightgreen: "90ee90", |
|
13415 lightgrey: "d3d3d3", |
|
13416 lightpink: "ffb6c1", |
|
13417 lightsalmon: "ffa07a", |
|
13418 lightseagreen: "20b2aa", |
|
13419 lightskyblue: "87cefa", |
|
13420 lightslategray: "789", |
|
13421 lightslategrey: "789", |
|
13422 lightsteelblue: "b0c4de", |
|
13423 lightyellow: "ffffe0", |
|
13424 lime: "0f0", |
|
13425 limegreen: "32cd32", |
|
13426 linen: "faf0e6", |
|
13427 magenta: "f0f", |
|
13428 maroon: "800000", |
|
13429 mediumaquamarine: "66cdaa", |
|
13430 mediumblue: "0000cd", |
|
13431 mediumorchid: "ba55d3", |
|
13432 mediumpurple: "9370db", |
|
13433 mediumseagreen: "3cb371", |
|
13434 mediumslateblue: "7b68ee", |
|
13435 mediumspringgreen: "00fa9a", |
|
13436 mediumturquoise: "48d1cc", |
|
13437 mediumvioletred: "c71585", |
|
13438 midnightblue: "191970", |
|
13439 mintcream: "f5fffa", |
|
13440 mistyrose: "ffe4e1", |
|
13441 moccasin: "ffe4b5", |
|
13442 navajowhite: "ffdead", |
|
13443 navy: "000080", |
|
13444 oldlace: "fdf5e6", |
|
13445 olive: "808000", |
|
13446 olivedrab: "6b8e23", |
|
13447 orange: "ffa500", |
|
13448 orangered: "ff4500", |
|
13449 orchid: "da70d6", |
|
13450 palegoldenrod: "eee8aa", |
|
13451 palegreen: "98fb98", |
|
13452 paleturquoise: "afeeee", |
|
13453 palevioletred: "db7093", |
|
13454 papayawhip: "ffefd5", |
|
13455 peachpuff: "ffdab9", |
|
13456 peru: "cd853f", |
|
13457 pink: "ffc0cb", |
|
13458 plum: "dda0dd", |
|
13459 powderblue: "b0e0e6", |
|
13460 purple: "800080", |
|
13461 rebeccapurple: "663399", |
|
13462 red: "f00", |
|
13463 rosybrown: "bc8f8f", |
|
13464 royalblue: "4169e1", |
|
13465 saddlebrown: "8b4513", |
|
13466 salmon: "fa8072", |
|
13467 sandybrown: "f4a460", |
|
13468 seagreen: "2e8b57", |
|
13469 seashell: "fff5ee", |
|
13470 sienna: "a0522d", |
|
13471 silver: "c0c0c0", |
|
13472 skyblue: "87ceeb", |
|
13473 slateblue: "6a5acd", |
|
13474 slategray: "708090", |
|
13475 slategrey: "708090", |
|
13476 snow: "fffafa", |
|
13477 springgreen: "00ff7f", |
|
13478 steelblue: "4682b4", |
|
13479 tan: "d2b48c", |
|
13480 teal: "008080", |
|
13481 thistle: "d8bfd8", |
|
13482 tomato: "ff6347", |
|
13483 turquoise: "40e0d0", |
|
13484 violet: "ee82ee", |
|
13485 wheat: "f5deb3", |
|
13486 white: "fff", |
|
13487 whitesmoke: "f5f5f5", |
|
13488 yellow: "ff0", |
|
13489 yellowgreen: "9acd32" |
|
13490 }; |
|
13491 |
|
13492 // Make it easy to access colors via `hexNames[hex]` |
|
13493 var hexNames = tinycolor.hexNames = flip(names); |
|
13494 |
|
13495 |
|
13496 // Utilities |
|
13497 // --------- |
|
13498 |
|
13499 // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }` |
|
13500 function flip(o) { |
|
13501 var flipped = { }; |
|
13502 for (var i in o) { |
|
13503 if (o.hasOwnProperty(i)) { |
|
13504 flipped[o[i]] = i; |
|
13505 } |
|
13506 } |
|
13507 return flipped; |
|
13508 } |
|
13509 |
|
13510 // Return a valid alpha value [0,1] with all invalid values being set to 1 |
|
13511 function boundAlpha(a) { |
|
13512 a = parseFloat(a); |
|
13513 |
|
13514 if (isNaN(a) || a < 0 || a > 1) { |
|
13515 a = 1; |
|
13516 } |
|
13517 |
|
13518 return a; |
|
13519 } |
|
13520 |
|
13521 // Take input from [0, n] and return it as [0, 1] |
|
13522 function bound01(n, max) { |
|
13523 if (isOnePointZero(n)) { n = "100%"; } |
|
13524 |
|
13525 var processPercent = isPercentage(n); |
|
13526 n = mathMin(max, mathMax(0, parseFloat(n))); |
|
13527 |
|
13528 // Automatically convert percentage into number |
|
13529 if (processPercent) { |
|
13530 n = parseInt(n * max, 10) / 100; |
|
13531 } |
|
13532 |
|
13533 // Handle floating point rounding errors |
|
13534 if ((Math.abs(n - max) < 0.000001)) { |
|
13535 return 1; |
|
13536 } |
|
13537 |
|
13538 // Convert into [0, 1] range if it isn't already |
|
13539 return (n % max) / parseFloat(max); |
|
13540 } |
|
13541 |
|
13542 // Force a number between 0 and 1 |
|
13543 function clamp01(val) { |
|
13544 return mathMin(1, mathMax(0, val)); |
|
13545 } |
|
13546 |
|
13547 // Parse a base-16 hex value into a base-10 integer |
|
13548 function parseIntFromHex(val) { |
|
13549 return parseInt(val, 16); |
|
13550 } |
|
13551 |
|
13552 // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1 |
|
13553 // <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0> |
|
13554 function isOnePointZero(n) { |
|
13555 return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1; |
|
13556 } |
|
13557 |
|
13558 // Check to see if string passed in is a percentage |
|
13559 function isPercentage(n) { |
|
13560 return typeof n === "string" && n.indexOf('%') != -1; |
|
13561 } |
|
13562 |
|
13563 // Force a hex value to have 2 characters |
|
13564 function pad2(c) { |
|
13565 return c.length == 1 ? '0' + c : '' + c; |
|
13566 } |
|
13567 |
|
13568 // Replace a decimal with it's percentage value |
|
13569 function convertToPercentage(n) { |
|
13570 if (n <= 1) { |
|
13571 n = (n * 100) + "%"; |
|
13572 } |
|
13573 |
|
13574 return n; |
|
13575 } |
|
13576 |
|
13577 // Converts a decimal to a hex value |
|
13578 function convertDecimalToHex(d) { |
|
13579 return Math.round(parseFloat(d) * 255).toString(16); |
|
13580 } |
|
13581 // Converts a hex value to a decimal |
|
13582 function convertHexToDecimal(h) { |
|
13583 return (parseIntFromHex(h) / 255); |
|
13584 } |
|
13585 |
|
13586 var matchers = (function() { |
|
13587 |
|
13588 // <http://www.w3.org/TR/css3-values/#integers> |
|
13589 var CSS_INTEGER = "[-\\+]?\\d+%?"; |
|
13590 |
|
13591 // <http://www.w3.org/TR/css3-values/#number-value> |
|
13592 var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?"; |
|
13593 |
|
13594 // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome. |
|
13595 var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")"; |
|
13596 |
|
13597 // Actual matching. |
|
13598 // Parentheses and commas are optional, but not required. |
|
13599 // Whitespace can take the place of commas or opening paren |
|
13600 var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; |
|
13601 var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; |
|
13602 |
|
13603 return { |
|
13604 CSS_UNIT: new RegExp(CSS_UNIT), |
|
13605 rgb: new RegExp("rgb" + PERMISSIVE_MATCH3), |
|
13606 rgba: new RegExp("rgba" + PERMISSIVE_MATCH4), |
|
13607 hsl: new RegExp("hsl" + PERMISSIVE_MATCH3), |
|
13608 hsla: new RegExp("hsla" + PERMISSIVE_MATCH4), |
|
13609 hsv: new RegExp("hsv" + PERMISSIVE_MATCH3), |
|
13610 hsva: new RegExp("hsva" + PERMISSIVE_MATCH4), |
|
13611 hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, |
|
13612 hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/, |
|
13613 hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, |
|
13614 hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/ |
|
13615 }; |
|
13616 })(); |
|
13617 |
|
13618 // `isValidCSSUnit` |
|
13619 // Take in a single string / number and check to see if it looks like a CSS unit |
|
13620 // (see `matchers` above for definition). |
|
13621 function isValidCSSUnit(color) { |
|
13622 return !!matchers.CSS_UNIT.exec(color); |
|
13623 } |
|
13624 |
|
13625 // `stringInputToObject` |
|
13626 // Permissive string parsing. Take in a number of formats, and output an object |
|
13627 // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` |
|
13628 function stringInputToObject(color) { |
|
13629 |
|
13630 color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase(); |
|
13631 var named = false; |
|
13632 if (names[color]) { |
|
13633 color = names[color]; |
|
13634 named = true; |
|
13635 } |
|
13636 else if (color == 'transparent') { |
|
13637 return { r: 0, g: 0, b: 0, a: 0, format: "name" }; |
|
13638 } |
|
13639 |
|
13640 // Try to match string input using regular expressions. |
|
13641 // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360] |
|
13642 // Just return an object and let the conversion functions handle that. |
|
13643 // This way the result will be the same whether the tinycolor is initialized with string or object. |
|
13644 var match; |
|
13645 if ((match = matchers.rgb.exec(color))) { |
|
13646 return { r: match[1], g: match[2], b: match[3] }; |
|
13647 } |
|
13648 if ((match = matchers.rgba.exec(color))) { |
|
13649 return { r: match[1], g: match[2], b: match[3], a: match[4] }; |
|
13650 } |
|
13651 if ((match = matchers.hsl.exec(color))) { |
|
13652 return { h: match[1], s: match[2], l: match[3] }; |
|
13653 } |
|
13654 if ((match = matchers.hsla.exec(color))) { |
|
13655 return { h: match[1], s: match[2], l: match[3], a: match[4] }; |
|
13656 } |
|
13657 if ((match = matchers.hsv.exec(color))) { |
|
13658 return { h: match[1], s: match[2], v: match[3] }; |
|
13659 } |
|
13660 if ((match = matchers.hsva.exec(color))) { |
|
13661 return { h: match[1], s: match[2], v: match[3], a: match[4] }; |
|
13662 } |
|
13663 if ((match = matchers.hex8.exec(color))) { |
|
13664 return { |
|
13665 r: parseIntFromHex(match[1]), |
|
13666 g: parseIntFromHex(match[2]), |
|
13667 b: parseIntFromHex(match[3]), |
|
13668 a: convertHexToDecimal(match[4]), |
|
13669 format: named ? "name" : "hex8" |
|
13670 }; |
|
13671 } |
|
13672 if ((match = matchers.hex6.exec(color))) { |
|
13673 return { |
|
13674 r: parseIntFromHex(match[1]), |
|
13675 g: parseIntFromHex(match[2]), |
|
13676 b: parseIntFromHex(match[3]), |
|
13677 format: named ? "name" : "hex" |
|
13678 }; |
|
13679 } |
|
13680 if ((match = matchers.hex4.exec(color))) { |
|
13681 return { |
|
13682 r: parseIntFromHex(match[1] + '' + match[1]), |
|
13683 g: parseIntFromHex(match[2] + '' + match[2]), |
|
13684 b: parseIntFromHex(match[3] + '' + match[3]), |
|
13685 a: convertHexToDecimal(match[4] + '' + match[4]), |
|
13686 format: named ? "name" : "hex8" |
|
13687 }; |
|
13688 } |
|
13689 if ((match = matchers.hex3.exec(color))) { |
|
13690 return { |
|
13691 r: parseIntFromHex(match[1] + '' + match[1]), |
|
13692 g: parseIntFromHex(match[2] + '' + match[2]), |
|
13693 b: parseIntFromHex(match[3] + '' + match[3]), |
|
13694 format: named ? "name" : "hex" |
|
13695 }; |
|
13696 } |
|
13697 |
|
13698 return false; |
|
13699 } |
|
13700 |
|
13701 function validateWCAG2Parms(parms) { |
|
13702 // return valid WCAG2 parms for isReadable. |
|
13703 // If input parms are invalid, return {"level":"AA", "size":"small"} |
|
13704 var level, size; |
|
13705 parms = parms || {"level":"AA", "size":"small"}; |
|
13706 level = (parms.level || "AA").toUpperCase(); |
|
13707 size = (parms.size || "small").toLowerCase(); |
|
13708 if (level !== "AA" && level !== "AAA") { |
|
13709 level = "AA"; |
|
13710 } |
|
13711 if (size !== "small" && size !== "large") { |
|
13712 size = "small"; |
|
13713 } |
|
13714 return {"level":level, "size":size}; |
|
13715 } |
|
13716 |
|
13717 // Node: Export function |
|
13718 if ( true && module.exports) { |
|
13719 module.exports = tinycolor; |
|
13720 } |
|
13721 // AMD/requirejs: Define the module |
|
13722 else if (true) { |
|
13723 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {return tinycolor;}).call(exports, __webpack_require__, exports, module), |
|
13724 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); |
|
13725 } |
|
13726 // Browser: Expose to window |
|
13727 else {} |
|
13728 |
|
13729 })(Math); |
|
13730 |
|
13731 |
|
13732 /***/ }), |
|
13733 |
|
13734 /***/ "g56x": |
|
13735 /***/ (function(module, exports) { |
|
13736 |
|
13737 (function() { module.exports = window["wp"]["hooks"]; }()); |
|
13738 |
|
13739 /***/ }), |
|
13740 |
|
13741 /***/ "l3Sj": |
|
13742 /***/ (function(module, exports) { |
|
13743 |
|
13744 (function() { module.exports = window["wp"]["i18n"]; }()); |
|
13745 |
|
13746 /***/ }), |
|
13747 |
|
13748 /***/ "ouCq": |
|
13749 /***/ (function(module, exports) { |
|
13750 |
|
13751 (function() { module.exports = window["wp"]["blockSerializationDefaultParser"]; }()); |
|
13752 |
|
13753 /***/ }), |
|
13754 |
|
13755 /***/ "pPDe": |
|
13756 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
13757 |
|
13758 "use strict"; |
|
13759 |
5808 |
13760 |
5809 |
13761 var LEAF_KEY, hasWeakMap; |
5810 var LEAF_KEY, hasWeakMap; |
13762 |
5811 |
13763 /** |
5812 /** |
14027 callSelector.getDependants = getDependants; |
6076 callSelector.getDependants = getDependants; |
14028 callSelector.clear = clear; |
6077 callSelector.clear = clear; |
14029 clear(); |
6078 clear(); |
14030 |
6079 |
14031 return callSelector; |
6080 return callSelector; |
|
6081 } |
|
6082 |
|
6083 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/selectors.js |
|
6084 /** |
|
6085 * External dependencies |
|
6086 */ |
|
6087 |
|
6088 |
|
6089 /** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */ |
|
6090 |
|
6091 /** @typedef {import('../api/registration').WPBlockVariationScope} WPBlockVariationScope */ |
|
6092 |
|
6093 /** @typedef {import('./reducer').WPBlockCategory} WPBlockCategory */ |
|
6094 |
|
6095 /** |
|
6096 * Given a block name or block type object, returns the corresponding |
|
6097 * normalized block type object. |
|
6098 * |
|
6099 * @param {Object} state Blocks state. |
|
6100 * @param {(string|Object)} nameOrType Block name or type object |
|
6101 * |
|
6102 * @return {Object} Block type object. |
|
6103 */ |
|
6104 |
|
6105 const getNormalizedBlockType = (state, nameOrType) => 'string' === typeof nameOrType ? getBlockType(state, nameOrType) : nameOrType; |
|
6106 /** |
|
6107 * Returns all the unprocessed block types as passed during the registration. |
|
6108 * |
|
6109 * @param {Object} state Data state. |
|
6110 * |
|
6111 * @return {Array} Unprocessed block types. |
|
6112 */ |
|
6113 |
|
6114 |
|
6115 function __experimentalGetUnprocessedBlockTypes(state) { |
|
6116 return state.unprocessedBlockTypes; |
|
6117 } |
|
6118 /** |
|
6119 * Returns all the available block types. |
|
6120 * |
|
6121 * @param {Object} state Data state. |
|
6122 * |
|
6123 * @return {Array} Block Types. |
|
6124 */ |
|
6125 |
|
6126 const getBlockTypes = rememo(state => Object.values(state.blockTypes), state => [state.blockTypes]); |
|
6127 /** |
|
6128 * Returns a block type by name. |
|
6129 * |
|
6130 * @param {Object} state Data state. |
|
6131 * @param {string} name Block type name. |
|
6132 * |
|
6133 * @return {Object?} Block Type. |
|
6134 */ |
|
6135 |
|
6136 function getBlockType(state, name) { |
|
6137 return state.blockTypes[name]; |
|
6138 } |
|
6139 /** |
|
6140 * Returns block styles by block name. |
|
6141 * |
|
6142 * @param {Object} state Data state. |
|
6143 * @param {string} name Block type name. |
|
6144 * |
|
6145 * @return {Array?} Block Styles. |
|
6146 */ |
|
6147 |
|
6148 function getBlockStyles(state, name) { |
|
6149 return state.blockStyles[name]; |
|
6150 } |
|
6151 /** |
|
6152 * Returns block variations by block name. |
|
6153 * |
|
6154 * @param {Object} state Data state. |
|
6155 * @param {string} blockName Block type name. |
|
6156 * @param {WPBlockVariationScope} [scope] Block variation scope name. |
|
6157 * |
|
6158 * @return {(WPBlockVariation[]|void)} Block variations. |
|
6159 */ |
|
6160 |
|
6161 const getBlockVariations = rememo((state, blockName, scope) => { |
|
6162 const variations = state.blockVariations[blockName]; |
|
6163 |
|
6164 if (!variations || !scope) { |
|
6165 return variations; |
|
6166 } |
|
6167 |
|
6168 return variations.filter(variation => { |
|
6169 // For backward compatibility reasons, variation's scope defaults to |
|
6170 // `block` and `inserter` when not set. |
|
6171 return (variation.scope || ['block', 'inserter']).includes(scope); |
|
6172 }); |
|
6173 }, (state, blockName) => [state.blockVariations[blockName]]); |
|
6174 /** |
|
6175 * Returns the active block variation for a given block based on its attributes. |
|
6176 * Variations are determined by their `isActive` property. |
|
6177 * Which is either an array of block attribute keys or a function. |
|
6178 * |
|
6179 * In case of an array of block attribute keys, the `attributes` are compared |
|
6180 * to the variation's attributes using strict equality check. |
|
6181 * |
|
6182 * In case of function type, the function should accept a block's attributes |
|
6183 * and the variation's attributes and determines if a variation is active. |
|
6184 * A function that accepts a block's attributes and the variation's attributes and determines if a variation is active. |
|
6185 * |
|
6186 * @param {Object} state Data state. |
|
6187 * @param {string} blockName Name of block (example: “core/columns”). |
|
6188 * @param {Object} attributes Block attributes used to determine active variation. |
|
6189 * @param {WPBlockVariationScope} [scope] Block variation scope name. |
|
6190 * |
|
6191 * @return {(WPBlockVariation|undefined)} Active block variation. |
|
6192 */ |
|
6193 |
|
6194 function getActiveBlockVariation(state, blockName, attributes, scope) { |
|
6195 const variations = getBlockVariations(state, blockName, scope); |
|
6196 const match = variations === null || variations === void 0 ? void 0 : variations.find(variation => { |
|
6197 var _variation$isActive; |
|
6198 |
|
6199 if (Array.isArray(variation.isActive)) { |
|
6200 const blockType = getBlockType(state, blockName); |
|
6201 const attributeKeys = Object.keys((blockType === null || blockType === void 0 ? void 0 : blockType.attributes) || {}); |
|
6202 const definedAttributes = variation.isActive.filter(attribute => attributeKeys.includes(attribute)); |
|
6203 |
|
6204 if (definedAttributes.length === 0) { |
|
6205 return false; |
|
6206 } |
|
6207 |
|
6208 return definedAttributes.every(attribute => attributes[attribute] === variation.attributes[attribute]); |
|
6209 } |
|
6210 |
|
6211 return (_variation$isActive = variation.isActive) === null || _variation$isActive === void 0 ? void 0 : _variation$isActive.call(variation, attributes, variation.attributes); |
|
6212 }); |
|
6213 return match; |
|
6214 } |
|
6215 /** |
|
6216 * Returns the default block variation for the given block type. |
|
6217 * When there are multiple variations annotated as the default one, |
|
6218 * the last added item is picked. This simplifies registering overrides. |
|
6219 * When there is no default variation set, it returns the first item. |
|
6220 * |
|
6221 * @param {Object} state Data state. |
|
6222 * @param {string} blockName Block type name. |
|
6223 * @param {WPBlockVariationScope} [scope] Block variation scope name. |
|
6224 * |
|
6225 * @return {?WPBlockVariation} The default block variation. |
|
6226 */ |
|
6227 |
|
6228 function getDefaultBlockVariation(state, blockName, scope) { |
|
6229 const variations = getBlockVariations(state, blockName, scope); |
|
6230 return (0,external_lodash_namespaceObject.findLast)(variations, 'isDefault') || (0,external_lodash_namespaceObject.first)(variations); |
|
6231 } |
|
6232 /** |
|
6233 * Returns all the available categories. |
|
6234 * |
|
6235 * @param {Object} state Data state. |
|
6236 * |
|
6237 * @return {WPBlockCategory[]} Categories list. |
|
6238 */ |
|
6239 |
|
6240 function getCategories(state) { |
|
6241 return state.categories; |
|
6242 } |
|
6243 /** |
|
6244 * Returns all the available collections. |
|
6245 * |
|
6246 * @param {Object} state Data state. |
|
6247 * |
|
6248 * @return {Object} Collections list. |
|
6249 */ |
|
6250 |
|
6251 function getCollections(state) { |
|
6252 return state.collections; |
|
6253 } |
|
6254 /** |
|
6255 * Returns the name of the default block name. |
|
6256 * |
|
6257 * @param {Object} state Data state. |
|
6258 * |
|
6259 * @return {string?} Default block name. |
|
6260 */ |
|
6261 |
|
6262 function getDefaultBlockName(state) { |
|
6263 return state.defaultBlockName; |
|
6264 } |
|
6265 /** |
|
6266 * Returns the name of the block for handling non-block content. |
|
6267 * |
|
6268 * @param {Object} state Data state. |
|
6269 * |
|
6270 * @return {string?} Name of the block for handling non-block content. |
|
6271 */ |
|
6272 |
|
6273 function getFreeformFallbackBlockName(state) { |
|
6274 return state.freeformFallbackBlockName; |
|
6275 } |
|
6276 /** |
|
6277 * Returns the name of the block for handling unregistered blocks. |
|
6278 * |
|
6279 * @param {Object} state Data state. |
|
6280 * |
|
6281 * @return {string?} Name of the block for handling unregistered blocks. |
|
6282 */ |
|
6283 |
|
6284 function getUnregisteredFallbackBlockName(state) { |
|
6285 return state.unregisteredFallbackBlockName; |
|
6286 } |
|
6287 /** |
|
6288 * Returns the name of the block for handling unregistered blocks. |
|
6289 * |
|
6290 * @param {Object} state Data state. |
|
6291 * |
|
6292 * @return {string?} Name of the block for handling unregistered blocks. |
|
6293 */ |
|
6294 |
|
6295 function getGroupingBlockName(state) { |
|
6296 return state.groupingBlockName; |
|
6297 } |
|
6298 /** |
|
6299 * Returns an array with the child blocks of a given block. |
|
6300 * |
|
6301 * @param {Object} state Data state. |
|
6302 * @param {string} blockName Block type name. |
|
6303 * |
|
6304 * @return {Array} Array of child block names. |
|
6305 */ |
|
6306 |
|
6307 const getChildBlockNames = rememo((state, blockName) => { |
|
6308 return (0,external_lodash_namespaceObject.map)((0,external_lodash_namespaceObject.filter)(state.blockTypes, blockType => { |
|
6309 return (0,external_lodash_namespaceObject.includes)(blockType.parent, blockName); |
|
6310 }), _ref => { |
|
6311 let { |
|
6312 name |
|
6313 } = _ref; |
|
6314 return name; |
|
6315 }); |
|
6316 }, state => [state.blockTypes]); |
|
6317 /** |
|
6318 * Returns the block support value for a feature, if defined. |
|
6319 * |
|
6320 * @param {Object} state Data state. |
|
6321 * @param {(string|Object)} nameOrType Block name or type object |
|
6322 * @param {Array|string} feature Feature to retrieve |
|
6323 * @param {*} defaultSupports Default value to return if not |
|
6324 * explicitly defined |
|
6325 * |
|
6326 * @return {?*} Block support value |
|
6327 */ |
|
6328 |
|
6329 const getBlockSupport = (state, nameOrType, feature, defaultSupports) => { |
|
6330 const blockType = getNormalizedBlockType(state, nameOrType); |
|
6331 |
|
6332 if (!(blockType !== null && blockType !== void 0 && blockType.supports)) { |
|
6333 return defaultSupports; |
|
6334 } |
|
6335 |
|
6336 return (0,external_lodash_namespaceObject.get)(blockType.supports, feature, defaultSupports); |
|
6337 }; |
|
6338 /** |
|
6339 * Returns true if the block defines support for a feature, or false otherwise. |
|
6340 * |
|
6341 * @param {Object} state Data state. |
|
6342 * @param {(string|Object)} nameOrType Block name or type object. |
|
6343 * @param {string} feature Feature to test. |
|
6344 * @param {boolean} defaultSupports Whether feature is supported by |
|
6345 * default if not explicitly defined. |
|
6346 * |
|
6347 * @return {boolean} Whether block supports feature. |
|
6348 */ |
|
6349 |
|
6350 function hasBlockSupport(state, nameOrType, feature, defaultSupports) { |
|
6351 return !!getBlockSupport(state, nameOrType, feature, defaultSupports); |
|
6352 } |
|
6353 /** |
|
6354 * Returns true if the block type by the given name or object value matches a |
|
6355 * search term, or false otherwise. |
|
6356 * |
|
6357 * @param {Object} state Blocks state. |
|
6358 * @param {(string|Object)} nameOrType Block name or type object. |
|
6359 * @param {string} searchTerm Search term by which to filter. |
|
6360 * |
|
6361 * @return {Object[]} Whether block type matches search term. |
|
6362 */ |
|
6363 |
|
6364 function isMatchingSearchTerm(state, nameOrType, searchTerm) { |
|
6365 const blockType = getNormalizedBlockType(state, nameOrType); |
|
6366 const getNormalizedSearchTerm = (0,external_lodash_namespaceObject.flow)([// Disregard diacritics. |
|
6367 // Input: "média" |
|
6368 external_lodash_namespaceObject.deburr, // Lowercase. |
|
6369 // Input: "MEDIA" |
|
6370 term => term.toLowerCase(), // Strip leading and trailing whitespace. |
|
6371 // Input: " media " |
|
6372 term => term.trim()]); |
|
6373 const normalizedSearchTerm = getNormalizedSearchTerm(searchTerm); |
|
6374 const isSearchMatch = (0,external_lodash_namespaceObject.flow)([getNormalizedSearchTerm, normalizedCandidate => (0,external_lodash_namespaceObject.includes)(normalizedCandidate, normalizedSearchTerm)]); |
|
6375 return isSearchMatch(blockType.title) || (0,external_lodash_namespaceObject.some)(blockType.keywords, isSearchMatch) || isSearchMatch(blockType.category) || isSearchMatch(blockType.description); |
|
6376 } |
|
6377 /** |
|
6378 * Returns a boolean indicating if a block has child blocks or not. |
|
6379 * |
|
6380 * @param {Object} state Data state. |
|
6381 * @param {string} blockName Block type name. |
|
6382 * |
|
6383 * @return {boolean} True if a block contains child blocks and false otherwise. |
|
6384 */ |
|
6385 |
|
6386 const hasChildBlocks = (state, blockName) => { |
|
6387 return getChildBlockNames(state, blockName).length > 0; |
|
6388 }; |
|
6389 /** |
|
6390 * Returns a boolean indicating if a block has at least one child block with inserter support. |
|
6391 * |
|
6392 * @param {Object} state Data state. |
|
6393 * @param {string} blockName Block type name. |
|
6394 * |
|
6395 * @return {boolean} True if a block contains at least one child blocks with inserter support |
|
6396 * and false otherwise. |
|
6397 */ |
|
6398 |
|
6399 const hasChildBlocksWithInserterSupport = (state, blockName) => { |
|
6400 return (0,external_lodash_namespaceObject.some)(getChildBlockNames(state, blockName), childBlockName => { |
|
6401 return hasBlockSupport(state, childBlockName, 'inserter', true); |
|
6402 }); |
|
6403 }; |
|
6404 |
|
6405 ;// CONCATENATED MODULE: external ["wp","hooks"] |
|
6406 var external_wp_hooks_namespaceObject = window["wp"]["hooks"]; |
|
6407 ;// CONCATENATED MODULE: ./node_modules/colord/index.mjs |
|
6408 var r={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n+0},e=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},u=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},a=function(r){return{r:e(r.r,0,255),g:e(r.g,0,255),b:e(r.b,0,255),a:e(r.a)}},o=function(r){return{r:n(r.r),g:n(r.g),b:n(r.b),a:n(r.a,3)}},i=/^#([0-9a-f]{3,8})$/i,s=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},h=function(r){var t=r.r,n=r.g,e=r.b,u=r.a,a=Math.max(t,n,e),o=a-Math.min(t,n,e),i=o?a===t?(n-e)/o:a===n?2+(e-t)/o:4+(t-n)/o:0;return{h:60*(i<0?i+6:i),s:a?o/a*100:0,v:a/255*100,a:u}},b=function(r){var t=r.h,n=r.s,e=r.v,u=r.a;t=t/360*6,n/=100,e/=100;var a=Math.floor(t),o=e*(1-n),i=e*(1-(t-a)*n),s=e*(1-(1-t+a)*n),h=a%6;return{r:255*[e,i,o,o,s,e][h],g:255*[s,e,e,i,o,o][h],b:255*[o,o,s,e,e,i][h],a:u}},g=function(r){return{h:u(r.h),s:e(r.s,0,100),l:e(r.l,0,100),a:e(r.a)}},d=function(r){return{h:n(r.h),s:n(r.s),l:n(r.l),a:n(r.a,3)}},f=function(r){return b((n=(t=r).s,{h:t.h,s:(n*=((e=t.l)<50?e:100-e)/100)>0?2*n/(e+n)*100:0,v:e+n,a:t.a}));var t,n,e},c=function(r){return{h:(t=h(r)).h,s:(u=(200-(n=t.s))*(e=t.v)/100)>0&&u<200?n*e/100/(u<=100?u:200-u)*100:0,l:u/2,a:t.a};var t,n,e,u},l=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,p=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,v=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,m=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y={string:[[function(r){var t=i.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:4===r.length?n(parseInt(r[3]+r[3],16)/255,2):1}:6===r.length||8===r.length?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:8===r.length?n(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=v.exec(r)||m.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:a({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:void 0===t[7]?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(t){var n=l.exec(t)||p.exec(t);if(!n)return null;var e,u,a=g({h:(e=n[1],u=n[2],void 0===u&&(u="deg"),Number(e)*(r[u]||1)),s:Number(n[3]),l:Number(n[4]),a:void 0===n[5]?1:Number(n[5])/(n[6]?100:1)});return f(a)},"hsl"]],object:[[function(r){var n=r.r,e=r.g,u=r.b,o=r.a,i=void 0===o?1:o;return t(n)&&t(e)&&t(u)?a({r:Number(n),g:Number(e),b:Number(u),a:Number(i)}):null},"rgb"],[function(r){var n=r.h,e=r.s,u=r.l,a=r.a,o=void 0===a?1:a;if(!t(n)||!t(e)||!t(u))return null;var i=g({h:Number(n),s:Number(e),l:Number(u),a:Number(o)});return f(i)},"hsl"],[function(r){var n=r.h,a=r.s,o=r.v,i=r.a,s=void 0===i?1:i;if(!t(n)||!t(a)||!t(o))return null;var h=function(r){return{h:u(r.h),s:e(r.s,0,100),v:e(r.v,0,100),a:e(r.a)}}({h:Number(n),s:Number(a),v:Number(o),a:Number(s)});return b(h)},"hsv"]]},N=function(r,t){for(var n=0;n<t.length;n++){var e=t[n][0](r);if(e)return[e,t[n][1]]}return[null,void 0]},x=function(r){return"string"==typeof r?N(r.trim(),y.string):"object"==typeof r&&null!==r?N(r,y.object):[null,void 0]},I=function(r){return x(r)[1]},M=function(r,t){var n=c(r);return{h:n.h,s:e(n.s+100*t,0,100),l:n.l,a:n.a}},H=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},$=function(r,t){var n=c(r);return{h:n.h,s:n.s,l:e(n.l+100*t,0,100),a:n.a}},j=function(){function r(r){this.parsed=x(r)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return null!==this.parsed},r.prototype.brightness=function(){return n(H(this.rgba),2)},r.prototype.isDark=function(){return H(this.rgba)<.5},r.prototype.isLight=function(){return H(this.rgba)>=.5},r.prototype.toHex=function(){return r=o(this.rgba),t=r.r,e=r.g,u=r.b,i=(a=r.a)<1?s(n(255*a)):"","#"+s(t)+s(e)+s(u)+i;var r,t,e,u,a,i},r.prototype.toRgb=function(){return o(this.rgba)},r.prototype.toRgbString=function(){return r=o(this.rgba),t=r.r,n=r.g,e=r.b,(u=r.a)<1?"rgba("+t+", "+n+", "+e+", "+u+")":"rgb("+t+", "+n+", "+e+")";var r,t,n,e,u},r.prototype.toHsl=function(){return d(c(this.rgba))},r.prototype.toHslString=function(){return r=d(c(this.rgba)),t=r.h,n=r.s,e=r.l,(u=r.a)<1?"hsla("+t+", "+n+"%, "+e+"%, "+u+")":"hsl("+t+", "+n+"%, "+e+"%)";var r,t,n,e,u},r.prototype.toHsv=function(){return r=h(this.rgba),{h:n(r.h),s:n(r.s),v:n(r.v),a:n(r.a,3)};var r},r.prototype.invert=function(){return w({r:255-(r=this.rgba).r,g:255-r.g,b:255-r.b,a:r.a});var r},r.prototype.saturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,r))},r.prototype.desaturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,-r))},r.prototype.grayscale=function(){return w(M(this.rgba,-1))},r.prototype.lighten=function(r){return void 0===r&&(r=.1),w($(this.rgba,r))},r.prototype.darken=function(r){return void 0===r&&(r=.1),w($(this.rgba,-r))},r.prototype.rotate=function(r){return void 0===r&&(r=15),this.hue(this.hue()+r)},r.prototype.alpha=function(r){return"number"==typeof r?w({r:(t=this.rgba).r,g:t.g,b:t.b,a:r}):n(this.rgba.a,3);var t},r.prototype.hue=function(r){var t=c(this.rgba);return"number"==typeof r?w({h:r,s:t.s,l:t.l,a:t.a}):n(t.h)},r.prototype.isEqual=function(r){return this.toHex()===w(r).toHex()},r}(),w=function(r){return r instanceof j?r:new j(r)},S=[],k=function(r){r.forEach(function(r){S.indexOf(r)<0&&(r(j,y),S.push(r))})},E=function(){return new j({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})}; |
|
6409 |
|
6410 ;// CONCATENATED MODULE: ./node_modules/colord/plugins/names.mjs |
|
6411 /* harmony default export */ function names(e,f){var a={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},r={};for(var d in a)r[a[d]]=d;var l={};e.prototype.toName=function(f){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var d,i,n=r[this.toHex()];if(n)return n;if(null==f?void 0:f.closest){var o=this.toRgb(),t=1/0,b="black";if(!l.length)for(var c in a)l[c]=new e(a[c]).toRgb();for(var g in a){var u=(d=o,i=l[g],Math.pow(d.r-i.r,2)+Math.pow(d.g-i.g,2)+Math.pow(d.b-i.b,2));u<t&&(t=u,b=g)}return b}};f.string.push([function(f){var r=f.toLowerCase(),d="transparent"===r?"#0000":a[r];return d?new e(d).toRgb():null},"name"])} |
|
6412 |
|
6413 ;// CONCATENATED MODULE: ./node_modules/colord/plugins/a11y.mjs |
|
6414 var a11y_o=function(o){var t=o/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},a11y_t=function(t){return.2126*a11y_o(t.r)+.7152*a11y_o(t.g)+.0722*a11y_o(t.b)};/* harmony default export */ function a11y(o){o.prototype.luminance=function(){return o=a11y_t(this.rgba),void 0===(r=2)&&(r=0),void 0===n&&(n=Math.pow(10,r)),Math.round(n*o)/n+0;var o,r,n},o.prototype.contrast=function(r){void 0===r&&(r="#FFF");var n,a,i,e,v,u,d,c=r instanceof o?r:new o(r);return e=this.rgba,v=c.toRgb(),u=a11y_t(e),d=a11y_t(v),n=u>d?(u+.05)/(d+.05):(d+.05)/(u+.05),void 0===(a=2)&&(a=0),void 0===i&&(i=Math.pow(10,a)),Math.floor(i*n)/i+0},o.prototype.isReadable=function(o,t){return void 0===o&&(o="#FFF"),void 0===t&&(t={}),this.contrast(o)>=(e=void 0===(i=(r=t).size)?"normal":i,"AAA"===(a=void 0===(n=r.level)?"AA":n)&&"normal"===e?7:"AA"===a&&"large"===e?3:4.5);var r,n,a,i,e}} |
|
6415 |
|
6416 ;// CONCATENATED MODULE: external ["wp","element"] |
|
6417 var external_wp_element_namespaceObject = window["wp"]["element"]; |
|
6418 ;// CONCATENATED MODULE: external ["wp","dom"] |
|
6419 var external_wp_dom_namespaceObject = window["wp"]["dom"]; |
|
6420 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/constants.js |
|
6421 const BLOCK_ICON_DEFAULT = 'block-default'; |
|
6422 /** |
|
6423 * Array of valid keys in a block type settings deprecation object. |
|
6424 * |
|
6425 * @type {string[]} |
|
6426 */ |
|
6427 |
|
6428 const DEPRECATED_ENTRY_KEYS = ['attributes', 'supports', 'save', 'migrate', 'isEligible', 'apiVersion']; |
|
6429 const __EXPERIMENTAL_STYLE_PROPERTY = { |
|
6430 // Kept for back-compatibility purposes. |
|
6431 '--wp--style--color--link': { |
|
6432 value: ['color', 'link'], |
|
6433 support: ['color', 'link'] |
|
6434 }, |
|
6435 background: { |
|
6436 value: ['color', 'gradient'], |
|
6437 support: ['color', 'gradients'] |
|
6438 }, |
|
6439 backgroundColor: { |
|
6440 value: ['color', 'background'], |
|
6441 support: ['color', 'background'], |
|
6442 requiresOptOut: true |
|
6443 }, |
|
6444 borderColor: { |
|
6445 value: ['border', 'color'], |
|
6446 support: ['__experimentalBorder', 'color'] |
|
6447 }, |
|
6448 borderRadius: { |
|
6449 value: ['border', 'radius'], |
|
6450 support: ['__experimentalBorder', 'radius'], |
|
6451 properties: { |
|
6452 borderTopLeftRadius: 'topLeft', |
|
6453 borderTopRightRadius: 'topRight', |
|
6454 borderBottomLeftRadius: 'bottomLeft', |
|
6455 borderBottomRightRadius: 'bottomRight' |
|
6456 } |
|
6457 }, |
|
6458 borderStyle: { |
|
6459 value: ['border', 'style'], |
|
6460 support: ['__experimentalBorder', 'style'] |
|
6461 }, |
|
6462 borderWidth: { |
|
6463 value: ['border', 'width'], |
|
6464 support: ['__experimentalBorder', 'width'] |
|
6465 }, |
|
6466 color: { |
|
6467 value: ['color', 'text'], |
|
6468 support: ['color', 'text'], |
|
6469 requiresOptOut: true |
|
6470 }, |
|
6471 filter: { |
|
6472 value: ['filter', 'duotone'], |
|
6473 support: ['color', '__experimentalDuotone'] |
|
6474 }, |
|
6475 linkColor: { |
|
6476 value: ['elements', 'link', 'color', 'text'], |
|
6477 support: ['color', 'link'] |
|
6478 }, |
|
6479 fontFamily: { |
|
6480 value: ['typography', 'fontFamily'], |
|
6481 support: ['typography', '__experimentalFontFamily'] |
|
6482 }, |
|
6483 fontSize: { |
|
6484 value: ['typography', 'fontSize'], |
|
6485 support: ['typography', 'fontSize'] |
|
6486 }, |
|
6487 fontStyle: { |
|
6488 value: ['typography', 'fontStyle'], |
|
6489 support: ['typography', '__experimentalFontStyle'] |
|
6490 }, |
|
6491 fontWeight: { |
|
6492 value: ['typography', 'fontWeight'], |
|
6493 support: ['typography', '__experimentalFontWeight'] |
|
6494 }, |
|
6495 lineHeight: { |
|
6496 value: ['typography', 'lineHeight'], |
|
6497 support: ['typography', 'lineHeight'] |
|
6498 }, |
|
6499 margin: { |
|
6500 value: ['spacing', 'margin'], |
|
6501 support: ['spacing', 'margin'], |
|
6502 properties: { |
|
6503 marginTop: 'top', |
|
6504 marginRight: 'right', |
|
6505 marginBottom: 'bottom', |
|
6506 marginLeft: 'left' |
|
6507 }, |
|
6508 useEngine: true |
|
6509 }, |
|
6510 padding: { |
|
6511 value: ['spacing', 'padding'], |
|
6512 support: ['spacing', 'padding'], |
|
6513 properties: { |
|
6514 paddingTop: 'top', |
|
6515 paddingRight: 'right', |
|
6516 paddingBottom: 'bottom', |
|
6517 paddingLeft: 'left' |
|
6518 }, |
|
6519 useEngine: true |
|
6520 }, |
|
6521 textDecoration: { |
|
6522 value: ['typography', 'textDecoration'], |
|
6523 support: ['typography', '__experimentalTextDecoration'] |
|
6524 }, |
|
6525 textTransform: { |
|
6526 value: ['typography', 'textTransform'], |
|
6527 support: ['typography', '__experimentalTextTransform'] |
|
6528 }, |
|
6529 letterSpacing: { |
|
6530 value: ['typography', 'letterSpacing'], |
|
6531 support: ['typography', '__experimentalLetterSpacing'] |
|
6532 }, |
|
6533 '--wp--style--block-gap': { |
|
6534 value: ['spacing', 'blockGap'], |
|
6535 support: ['spacing', 'blockGap'] |
|
6536 } |
|
6537 }; |
|
6538 const __EXPERIMENTAL_ELEMENTS = { |
|
6539 link: 'a', |
|
6540 h1: 'h1', |
|
6541 h2: 'h2', |
|
6542 h3: 'h3', |
|
6543 h4: 'h4', |
|
6544 h5: 'h5', |
|
6545 h6: 'h6' |
|
6546 }; |
|
6547 const __EXPERIMENTAL_PATHS_WITH_MERGE = { |
|
6548 'color.duotone': true, |
|
6549 'color.gradients': true, |
|
6550 'color.palette': true, |
|
6551 'typography.fontFamilies': true, |
|
6552 'typography.fontSizes': true |
|
6553 }; |
|
6554 |
|
6555 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/registration.js |
|
6556 /* eslint no-console: [ 'error', { allow: [ 'error', 'warn' ] } ] */ |
|
6557 |
|
6558 /** |
|
6559 * External dependencies |
|
6560 */ |
|
6561 |
|
6562 /** |
|
6563 * WordPress dependencies |
|
6564 */ |
|
6565 |
|
6566 |
|
6567 |
|
6568 /** |
|
6569 * Internal dependencies |
|
6570 */ |
|
6571 |
|
6572 const i18nBlockSchema = { |
|
6573 title: "block title", |
|
6574 description: "block description", |
|
6575 keywords: ["block keyword"], |
|
6576 styles: [{ |
|
6577 label: "block style label" |
|
6578 }], |
|
6579 variations: [{ |
|
6580 title: "block variation title", |
|
6581 description: "block variation description", |
|
6582 keywords: ["block variation keyword"] |
|
6583 }] |
|
6584 }; |
|
6585 |
|
6586 |
|
6587 /** |
|
6588 * An icon type definition. One of a Dashicon slug, an element, |
|
6589 * or a component. |
|
6590 * |
|
6591 * @typedef {(string|WPElement|WPComponent)} WPIcon |
|
6592 * |
|
6593 * @see https://developer.wordpress.org/resource/dashicons/ |
|
6594 */ |
|
6595 |
|
6596 /** |
|
6597 * Render behavior of a block type icon; one of a Dashicon slug, an element, |
|
6598 * or a component. |
|
6599 * |
|
6600 * @typedef {WPIcon} WPBlockTypeIconRender |
|
6601 */ |
|
6602 |
|
6603 /** |
|
6604 * An object describing a normalized block type icon. |
|
6605 * |
|
6606 * @typedef {Object} WPBlockTypeIconDescriptor |
|
6607 * |
|
6608 * @property {WPBlockTypeIconRender} src Render behavior of the icon, |
|
6609 * one of a Dashicon slug, an |
|
6610 * element, or a component. |
|
6611 * @property {string} background Optimal background hex string |
|
6612 * color when displaying icon. |
|
6613 * @property {string} foreground Optimal foreground hex string |
|
6614 * color when displaying icon. |
|
6615 * @property {string} shadowColor Optimal shadow hex string |
|
6616 * color when displaying icon. |
|
6617 */ |
|
6618 |
|
6619 /** |
|
6620 * Value to use to render the icon for a block type in an editor interface, |
|
6621 * either a Dashicon slug, an element, a component, or an object describing |
|
6622 * the icon. |
|
6623 * |
|
6624 * @typedef {(WPBlockTypeIconDescriptor|WPBlockTypeIconRender)} WPBlockTypeIcon |
|
6625 */ |
|
6626 |
|
6627 /** |
|
6628 * Named block variation scopes. |
|
6629 * |
|
6630 * @typedef {'block'|'inserter'|'transform'} WPBlockVariationScope |
|
6631 */ |
|
6632 |
|
6633 /** |
|
6634 * An object describing a variation defined for the block type. |
|
6635 * |
|
6636 * @typedef {Object} WPBlockVariation |
|
6637 * |
|
6638 * @property {string} name The unique and machine-readable name. |
|
6639 * @property {string} title A human-readable variation title. |
|
6640 * @property {string} [description] A detailed variation description. |
|
6641 * @property {string} [category] Block type category classification, |
|
6642 * used in search interfaces to arrange |
|
6643 * block types by category. |
|
6644 * @property {WPIcon} [icon] An icon helping to visualize the variation. |
|
6645 * @property {boolean} [isDefault] Indicates whether the current variation is |
|
6646 * the default one. Defaults to `false`. |
|
6647 * @property {Object} [attributes] Values which override block attributes. |
|
6648 * @property {Array[]} [innerBlocks] Initial configuration of nested blocks. |
|
6649 * @property {Object} [example] Example provides structured data for |
|
6650 * the block preview. You can set to |
|
6651 * `undefined` to disable the preview shown |
|
6652 * for the block type. |
|
6653 * @property {WPBlockVariationScope[]} [scope] The list of scopes where the variation |
|
6654 * is applicable. When not provided, it |
|
6655 * assumes all available scopes. |
|
6656 * @property {string[]} [keywords] An array of terms (which can be translated) |
|
6657 * that help users discover the variation |
|
6658 * while searching. |
|
6659 * @property {Function|string[]} [isActive] This can be a function or an array of block attributes. |
|
6660 * Function that accepts a block's attributes and the |
|
6661 * variation's attributes and determines if a variation is active. |
|
6662 * This function doesn't try to find a match dynamically based |
|
6663 * on all block's attributes, as in many cases some attributes are irrelevant. |
|
6664 * An example would be for `embed` block where we only care |
|
6665 * about `providerNameSlug` attribute's value. |
|
6666 * We can also use a `string[]` to tell which attributes |
|
6667 * should be compared as a shorthand. Each attributes will |
|
6668 * be matched and the variation will be active if all of them are matching. |
|
6669 */ |
|
6670 |
|
6671 /** |
|
6672 * Defined behavior of a block type. |
|
6673 * |
|
6674 * @typedef {Object} WPBlockType |
|
6675 * |
|
6676 * @property {string} name Block type's namespaced name. |
|
6677 * @property {string} title Human-readable block type label. |
|
6678 * @property {string} [description] A detailed block type description. |
|
6679 * @property {string} [category] Block type category classification, |
|
6680 * used in search interfaces to arrange |
|
6681 * block types by category. |
|
6682 * @property {WPBlockTypeIcon} [icon] Block type icon. |
|
6683 * @property {string[]} [keywords] Additional keywords to produce block |
|
6684 * type as result in search interfaces. |
|
6685 * @property {Object} [attributes] Block type attributes. |
|
6686 * @property {WPComponent} [save] Optional component describing |
|
6687 * serialized markup structure of a |
|
6688 * block type. |
|
6689 * @property {WPComponent} edit Component rendering an element to |
|
6690 * manipulate the attributes of a block |
|
6691 * in the context of an editor. |
|
6692 * @property {WPBlockVariation[]} [variations] The list of block variations. |
|
6693 * @property {Object} [example] Example provides structured data for |
|
6694 * the block preview. When not defined |
|
6695 * then no preview is shown. |
|
6696 */ |
|
6697 |
|
6698 const serverSideBlockDefinitions = {}; |
|
6699 /** |
|
6700 * Sets the server side block definition of blocks. |
|
6701 * |
|
6702 * @param {Object} definitions Server-side block definitions |
|
6703 */ |
|
6704 // eslint-disable-next-line camelcase |
|
6705 |
|
6706 function unstable__bootstrapServerSideBlockDefinitions(definitions) { |
|
6707 for (const blockName of Object.keys(definitions)) { |
|
6708 // Don't overwrite if already set. It covers the case when metadata |
|
6709 // was initialized from the server. |
|
6710 if (serverSideBlockDefinitions[blockName]) { |
|
6711 // We still need to polyfill `apiVersion` for WordPress version |
|
6712 // lower than 5.7. If it isn't present in the definition shared |
|
6713 // from the server, we try to fallback to the definition passed. |
|
6714 // @see https://github.com/WordPress/gutenberg/pull/29279 |
|
6715 if (serverSideBlockDefinitions[blockName].apiVersion === undefined && definitions[blockName].apiVersion) { |
|
6716 serverSideBlockDefinitions[blockName].apiVersion = definitions[blockName].apiVersion; |
|
6717 } // The `ancestor` prop is not included in the definitions shared |
|
6718 // from the server yet, so it needs to be polyfilled as well. |
|
6719 // @see https://github.com/WordPress/gutenberg/pull/39894 |
|
6720 |
|
6721 |
|
6722 if (serverSideBlockDefinitions[blockName].ancestor === undefined && definitions[blockName].ancestor) { |
|
6723 serverSideBlockDefinitions[blockName].ancestor = definitions[blockName].ancestor; |
|
6724 } |
|
6725 |
|
6726 continue; |
|
6727 } |
|
6728 |
|
6729 serverSideBlockDefinitions[blockName] = (0,external_lodash_namespaceObject.mapKeys)((0,external_lodash_namespaceObject.pickBy)(definitions[blockName], value => !(0,external_lodash_namespaceObject.isNil)(value)), (value, key) => (0,external_lodash_namespaceObject.camelCase)(key)); |
|
6730 } |
|
6731 } |
|
6732 /** |
|
6733 * Gets block settings from metadata loaded from `block.json` file. |
|
6734 * |
|
6735 * @param {Object} metadata Block metadata loaded from `block.json`. |
|
6736 * @param {string} metadata.textdomain Textdomain to use with translations. |
|
6737 * |
|
6738 * @return {Object} Block settings. |
|
6739 */ |
|
6740 |
|
6741 function getBlockSettingsFromMetadata(_ref) { |
|
6742 let { |
|
6743 textdomain, |
|
6744 ...metadata |
|
6745 } = _ref; |
|
6746 const allowedFields = ['apiVersion', 'title', 'category', 'parent', 'ancestor', 'icon', 'description', 'keywords', 'attributes', 'providesContext', 'usesContext', 'supports', 'styles', 'example', 'variations']; |
|
6747 const settings = (0,external_lodash_namespaceObject.pick)(metadata, allowedFields); |
|
6748 |
|
6749 if (textdomain) { |
|
6750 Object.keys(i18nBlockSchema).forEach(key => { |
|
6751 if (!settings[key]) { |
|
6752 return; |
|
6753 } |
|
6754 |
|
6755 settings[key] = translateBlockSettingUsingI18nSchema(i18nBlockSchema[key], settings[key], textdomain); |
|
6756 }); |
|
6757 } |
|
6758 |
|
6759 return settings; |
|
6760 } |
|
6761 /** |
|
6762 * Registers a new block provided a unique name and an object defining its |
|
6763 * behavior. Once registered, the block is made available as an option to any |
|
6764 * editor interface where blocks are implemented. |
|
6765 * |
|
6766 * @param {string|Object} blockNameOrMetadata Block type name or its metadata. |
|
6767 * @param {Object} settings Block settings. |
|
6768 * |
|
6769 * @return {?WPBlockType} The block, if it has been successfully registered; |
|
6770 * otherwise `undefined`. |
|
6771 */ |
|
6772 |
|
6773 |
|
6774 function registerBlockType(blockNameOrMetadata, settings) { |
|
6775 const name = (0,external_lodash_namespaceObject.isObject)(blockNameOrMetadata) ? blockNameOrMetadata.name : blockNameOrMetadata; |
|
6776 |
|
6777 if (typeof name !== 'string') { |
|
6778 console.error('Block names must be strings.'); |
|
6779 return; |
|
6780 } |
|
6781 |
|
6782 if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(name)) { |
|
6783 console.error('Block names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-block'); |
|
6784 return; |
|
6785 } |
|
6786 |
|
6787 if ((0,external_wp_data_namespaceObject.select)(store).getBlockType(name)) { |
|
6788 console.error('Block "' + name + '" is already registered.'); |
|
6789 return; |
|
6790 } |
|
6791 |
|
6792 if ((0,external_lodash_namespaceObject.isObject)(blockNameOrMetadata)) { |
|
6793 unstable__bootstrapServerSideBlockDefinitions({ |
|
6794 [name]: getBlockSettingsFromMetadata(blockNameOrMetadata) |
|
6795 }); |
|
6796 } |
|
6797 |
|
6798 const blockType = { |
|
6799 name, |
|
6800 icon: BLOCK_ICON_DEFAULT, |
|
6801 keywords: [], |
|
6802 attributes: {}, |
|
6803 providesContext: {}, |
|
6804 usesContext: [], |
|
6805 supports: {}, |
|
6806 styles: [], |
|
6807 variations: [], |
|
6808 save: () => null, |
|
6809 ...(serverSideBlockDefinitions === null || serverSideBlockDefinitions === void 0 ? void 0 : serverSideBlockDefinitions[name]), |
|
6810 ...settings |
|
6811 }; |
|
6812 |
|
6813 (0,external_wp_data_namespaceObject.dispatch)(store).__experimentalRegisterBlockType(blockType); |
|
6814 |
|
6815 return (0,external_wp_data_namespaceObject.select)(store).getBlockType(name); |
|
6816 } |
|
6817 /** |
|
6818 * Translates block settings provided with metadata using the i18n schema. |
|
6819 * |
|
6820 * @param {string|string[]|Object[]} i18nSchema I18n schema for the block setting. |
|
6821 * @param {string|string[]|Object[]} settingValue Value for the block setting. |
|
6822 * @param {string} textdomain Textdomain to use with translations. |
|
6823 * |
|
6824 * @return {string|string[]|Object[]} Translated setting. |
|
6825 */ |
|
6826 |
|
6827 function translateBlockSettingUsingI18nSchema(i18nSchema, settingValue, textdomain) { |
|
6828 if ((0,external_lodash_namespaceObject.isString)(i18nSchema) && (0,external_lodash_namespaceObject.isString)(settingValue)) { |
|
6829 // eslint-disable-next-line @wordpress/i18n-no-variables, @wordpress/i18n-text-domain |
|
6830 return (0,external_wp_i18n_namespaceObject._x)(settingValue, i18nSchema, textdomain); |
|
6831 } |
|
6832 |
|
6833 if ((0,external_lodash_namespaceObject.isArray)(i18nSchema) && !(0,external_lodash_namespaceObject.isEmpty)(i18nSchema) && (0,external_lodash_namespaceObject.isArray)(settingValue)) { |
|
6834 return settingValue.map(value => translateBlockSettingUsingI18nSchema(i18nSchema[0], value, textdomain)); |
|
6835 } |
|
6836 |
|
6837 if ((0,external_lodash_namespaceObject.isObject)(i18nSchema) && !(0,external_lodash_namespaceObject.isEmpty)(i18nSchema) && (0,external_lodash_namespaceObject.isObject)(settingValue)) { |
|
6838 return Object.keys(settingValue).reduce((accumulator, key) => { |
|
6839 if (!i18nSchema[key]) { |
|
6840 accumulator[key] = settingValue[key]; |
|
6841 return accumulator; |
|
6842 } |
|
6843 |
|
6844 accumulator[key] = translateBlockSettingUsingI18nSchema(i18nSchema[key], settingValue[key], textdomain); |
|
6845 return accumulator; |
|
6846 }, {}); |
|
6847 } |
|
6848 |
|
6849 return settingValue; |
|
6850 } |
|
6851 /** |
|
6852 * Registers a new block collection to group blocks in the same namespace in the inserter. |
|
6853 * |
|
6854 * @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace. |
|
6855 * @param {Object} settings The block collection settings. |
|
6856 * @param {string} settings.title The title to display in the block inserter. |
|
6857 * @param {Object} [settings.icon] The icon to display in the block inserter. |
|
6858 */ |
|
6859 |
|
6860 |
|
6861 function registerBlockCollection(namespace, _ref2) { |
|
6862 let { |
|
6863 title, |
|
6864 icon |
|
6865 } = _ref2; |
|
6866 (0,external_wp_data_namespaceObject.dispatch)(store).addBlockCollection(namespace, title, icon); |
|
6867 } |
|
6868 /** |
|
6869 * Unregisters a block collection |
|
6870 * |
|
6871 * @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace |
|
6872 * |
|
6873 */ |
|
6874 |
|
6875 function unregisterBlockCollection(namespace) { |
|
6876 dispatch(blocksStore).removeBlockCollection(namespace); |
|
6877 } |
|
6878 /** |
|
6879 * Unregisters a block. |
|
6880 * |
|
6881 * @param {string} name Block name. |
|
6882 * |
|
6883 * @return {?WPBlockType} The previous block value, if it has been successfully |
|
6884 * unregistered; otherwise `undefined`. |
|
6885 */ |
|
6886 |
|
6887 function unregisterBlockType(name) { |
|
6888 const oldBlock = (0,external_wp_data_namespaceObject.select)(store).getBlockType(name); |
|
6889 |
|
6890 if (!oldBlock) { |
|
6891 console.error('Block "' + name + '" is not registered.'); |
|
6892 return; |
|
6893 } |
|
6894 |
|
6895 (0,external_wp_data_namespaceObject.dispatch)(store).removeBlockTypes(name); |
|
6896 return oldBlock; |
|
6897 } |
|
6898 /** |
|
6899 * Assigns name of block for handling non-block content. |
|
6900 * |
|
6901 * @param {string} blockName Block name. |
|
6902 */ |
|
6903 |
|
6904 function setFreeformContentHandlerName(blockName) { |
|
6905 (0,external_wp_data_namespaceObject.dispatch)(store).setFreeformFallbackBlockName(blockName); |
|
6906 } |
|
6907 /** |
|
6908 * Retrieves name of block handling non-block content, or undefined if no |
|
6909 * handler has been defined. |
|
6910 * |
|
6911 * @return {?string} Block name. |
|
6912 */ |
|
6913 |
|
6914 function getFreeformContentHandlerName() { |
|
6915 return (0,external_wp_data_namespaceObject.select)(store).getFreeformFallbackBlockName(); |
|
6916 } |
|
6917 /** |
|
6918 * Retrieves name of block used for handling grouping interactions. |
|
6919 * |
|
6920 * @return {?string} Block name. |
|
6921 */ |
|
6922 |
|
6923 function registration_getGroupingBlockName() { |
|
6924 return (0,external_wp_data_namespaceObject.select)(store).getGroupingBlockName(); |
|
6925 } |
|
6926 /** |
|
6927 * Assigns name of block handling unregistered block types. |
|
6928 * |
|
6929 * @param {string} blockName Block name. |
|
6930 */ |
|
6931 |
|
6932 function setUnregisteredTypeHandlerName(blockName) { |
|
6933 (0,external_wp_data_namespaceObject.dispatch)(store).setUnregisteredFallbackBlockName(blockName); |
|
6934 } |
|
6935 /** |
|
6936 * Retrieves name of block handling unregistered block types, or undefined if no |
|
6937 * handler has been defined. |
|
6938 * |
|
6939 * @return {?string} Block name. |
|
6940 */ |
|
6941 |
|
6942 function getUnregisteredTypeHandlerName() { |
|
6943 return (0,external_wp_data_namespaceObject.select)(store).getUnregisteredFallbackBlockName(); |
|
6944 } |
|
6945 /** |
|
6946 * Assigns the default block name. |
|
6947 * |
|
6948 * @param {string} name Block name. |
|
6949 */ |
|
6950 |
|
6951 function setDefaultBlockName(name) { |
|
6952 (0,external_wp_data_namespaceObject.dispatch)(store).setDefaultBlockName(name); |
|
6953 } |
|
6954 /** |
|
6955 * Assigns name of block for handling block grouping interactions. |
|
6956 * |
|
6957 * @param {string} name Block name. |
|
6958 */ |
|
6959 |
|
6960 function setGroupingBlockName(name) { |
|
6961 (0,external_wp_data_namespaceObject.dispatch)(store).setGroupingBlockName(name); |
|
6962 } |
|
6963 /** |
|
6964 * Retrieves the default block name. |
|
6965 * |
|
6966 * @return {?string} Block name. |
|
6967 */ |
|
6968 |
|
6969 function registration_getDefaultBlockName() { |
|
6970 return (0,external_wp_data_namespaceObject.select)(store).getDefaultBlockName(); |
|
6971 } |
|
6972 /** |
|
6973 * Returns a registered block type. |
|
6974 * |
|
6975 * @param {string} name Block name. |
|
6976 * |
|
6977 * @return {?Object} Block type. |
|
6978 */ |
|
6979 |
|
6980 function registration_getBlockType(name) { |
|
6981 var _select; |
|
6982 |
|
6983 return (_select = (0,external_wp_data_namespaceObject.select)(store)) === null || _select === void 0 ? void 0 : _select.getBlockType(name); |
|
6984 } |
|
6985 /** |
|
6986 * Returns all registered blocks. |
|
6987 * |
|
6988 * @return {Array} Block settings. |
|
6989 */ |
|
6990 |
|
6991 function registration_getBlockTypes() { |
|
6992 return (0,external_wp_data_namespaceObject.select)(store).getBlockTypes(); |
|
6993 } |
|
6994 /** |
|
6995 * Returns the block support value for a feature, if defined. |
|
6996 * |
|
6997 * @param {(string|Object)} nameOrType Block name or type object |
|
6998 * @param {string} feature Feature to retrieve |
|
6999 * @param {*} defaultSupports Default value to return if not |
|
7000 * explicitly defined |
|
7001 * |
|
7002 * @return {?*} Block support value |
|
7003 */ |
|
7004 |
|
7005 function registration_getBlockSupport(nameOrType, feature, defaultSupports) { |
|
7006 return (0,external_wp_data_namespaceObject.select)(store).getBlockSupport(nameOrType, feature, defaultSupports); |
|
7007 } |
|
7008 /** |
|
7009 * Returns true if the block defines support for a feature, or false otherwise. |
|
7010 * |
|
7011 * @param {(string|Object)} nameOrType Block name or type object. |
|
7012 * @param {string} feature Feature to test. |
|
7013 * @param {boolean} defaultSupports Whether feature is supported by |
|
7014 * default if not explicitly defined. |
|
7015 * |
|
7016 * @return {boolean} Whether block supports feature. |
|
7017 */ |
|
7018 |
|
7019 function registration_hasBlockSupport(nameOrType, feature, defaultSupports) { |
|
7020 return (0,external_wp_data_namespaceObject.select)(store).hasBlockSupport(nameOrType, feature, defaultSupports); |
|
7021 } |
|
7022 /** |
|
7023 * Determines whether or not the given block is a reusable block. This is a |
|
7024 * special block type that is used to point to a global block stored via the |
|
7025 * API. |
|
7026 * |
|
7027 * @param {Object} blockOrType Block or Block Type to test. |
|
7028 * |
|
7029 * @return {boolean} Whether the given block is a reusable block. |
|
7030 */ |
|
7031 |
|
7032 function isReusableBlock(blockOrType) { |
|
7033 return (blockOrType === null || blockOrType === void 0 ? void 0 : blockOrType.name) === 'core/block'; |
|
7034 } |
|
7035 /** |
|
7036 * Determines whether or not the given block is a template part. This is a |
|
7037 * special block type that allows composing a page template out of reusable |
|
7038 * design elements. |
|
7039 * |
|
7040 * @param {Object} blockOrType Block or Block Type to test. |
|
7041 * |
|
7042 * @return {boolean} Whether the given block is a template part. |
|
7043 */ |
|
7044 |
|
7045 function isTemplatePart(blockOrType) { |
|
7046 return blockOrType.name === 'core/template-part'; |
|
7047 } |
|
7048 /** |
|
7049 * Returns an array with the child blocks of a given block. |
|
7050 * |
|
7051 * @param {string} blockName Name of block (example: “latest-posts”). |
|
7052 * |
|
7053 * @return {Array} Array of child block names. |
|
7054 */ |
|
7055 |
|
7056 const registration_getChildBlockNames = blockName => { |
|
7057 return (0,external_wp_data_namespaceObject.select)(store).getChildBlockNames(blockName); |
|
7058 }; |
|
7059 /** |
|
7060 * Returns a boolean indicating if a block has child blocks or not. |
|
7061 * |
|
7062 * @param {string} blockName Name of block (example: “latest-posts”). |
|
7063 * |
|
7064 * @return {boolean} True if a block contains child blocks and false otherwise. |
|
7065 */ |
|
7066 |
|
7067 const registration_hasChildBlocks = blockName => { |
|
7068 return (0,external_wp_data_namespaceObject.select)(store).hasChildBlocks(blockName); |
|
7069 }; |
|
7070 /** |
|
7071 * Returns a boolean indicating if a block has at least one child block with inserter support. |
|
7072 * |
|
7073 * @param {string} blockName Block type name. |
|
7074 * |
|
7075 * @return {boolean} True if a block contains at least one child blocks with inserter support |
|
7076 * and false otherwise. |
|
7077 */ |
|
7078 |
|
7079 const registration_hasChildBlocksWithInserterSupport = blockName => { |
|
7080 return (0,external_wp_data_namespaceObject.select)(store).hasChildBlocksWithInserterSupport(blockName); |
|
7081 }; |
|
7082 /** |
|
7083 * Registers a new block style variation for the given block. |
|
7084 * |
|
7085 * @param {string} blockName Name of block (example: “core/latest-posts”). |
|
7086 * @param {Object} styleVariation Object containing `name` which is the class name applied to the block and `label` which identifies the variation to the user. |
|
7087 */ |
|
7088 |
|
7089 const registerBlockStyle = (blockName, styleVariation) => { |
|
7090 (0,external_wp_data_namespaceObject.dispatch)(store).addBlockStyles(blockName, styleVariation); |
|
7091 }; |
|
7092 /** |
|
7093 * Unregisters a block style variation for the given block. |
|
7094 * |
|
7095 * @param {string} blockName Name of block (example: “core/latest-posts”). |
|
7096 * @param {string} styleVariationName Name of class applied to the block. |
|
7097 */ |
|
7098 |
|
7099 const unregisterBlockStyle = (blockName, styleVariationName) => { |
|
7100 (0,external_wp_data_namespaceObject.dispatch)(store).removeBlockStyles(blockName, styleVariationName); |
|
7101 }; |
|
7102 /** |
|
7103 * Returns an array with the variations of a given block type. |
|
7104 * |
|
7105 * @param {string} blockName Name of block (example: “core/columns”). |
|
7106 * @param {WPBlockVariationScope} [scope] Block variation scope name. |
|
7107 * |
|
7108 * @return {(WPBlockVariation[]|void)} Block variations. |
|
7109 */ |
|
7110 |
|
7111 const registration_getBlockVariations = (blockName, scope) => { |
|
7112 return (0,external_wp_data_namespaceObject.select)(store).getBlockVariations(blockName, scope); |
|
7113 }; |
|
7114 /** |
|
7115 * Registers a new block variation for the given block type. |
|
7116 * |
|
7117 * @param {string} blockName Name of the block (example: “core/columns”). |
|
7118 * @param {WPBlockVariation} variation Object describing a block variation. |
|
7119 */ |
|
7120 |
|
7121 const registerBlockVariation = (blockName, variation) => { |
|
7122 (0,external_wp_data_namespaceObject.dispatch)(store).addBlockVariations(blockName, variation); |
|
7123 }; |
|
7124 /** |
|
7125 * Unregisters a block variation defined for the given block type. |
|
7126 * |
|
7127 * @param {string} blockName Name of the block (example: “core/columns”). |
|
7128 * @param {string} variationName Name of the variation defined for the block. |
|
7129 */ |
|
7130 |
|
7131 const unregisterBlockVariation = (blockName, variationName) => { |
|
7132 (0,external_wp_data_namespaceObject.dispatch)(store).removeBlockVariations(blockName, variationName); |
|
7133 }; |
|
7134 |
|
7135 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js |
|
7136 // Unique ID creation requires a high quality random # generator. In the browser we therefore |
|
7137 // require the crypto API and do not support built-in fallback to lower quality random number |
|
7138 // generators (like Math.random()). |
|
7139 var getRandomValues; |
|
7140 var rnds8 = new Uint8Array(16); |
|
7141 function rng() { |
|
7142 // lazy load so that environments that need to polyfill have a chance to do so |
|
7143 if (!getRandomValues) { |
|
7144 // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also, |
|
7145 // find the complete implementation of crypto (msCrypto) on IE11. |
|
7146 getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto); |
|
7147 |
|
7148 if (!getRandomValues) { |
|
7149 throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported'); |
|
7150 } |
|
7151 } |
|
7152 |
|
7153 return getRandomValues(rnds8); |
|
7154 } |
|
7155 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/regex.js |
|
7156 /* harmony default export */ var regex = (/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i); |
|
7157 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/validate.js |
|
7158 |
|
7159 |
|
7160 function validate(uuid) { |
|
7161 return typeof uuid === 'string' && regex.test(uuid); |
|
7162 } |
|
7163 |
|
7164 /* harmony default export */ var esm_browser_validate = (validate); |
|
7165 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js |
|
7166 |
|
7167 /** |
|
7168 * Convert array of 16 byte values to UUID string format of the form: |
|
7169 * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX |
|
7170 */ |
|
7171 |
|
7172 var byteToHex = []; |
|
7173 |
|
7174 for (var stringify_i = 0; stringify_i < 256; ++stringify_i) { |
|
7175 byteToHex.push((stringify_i + 0x100).toString(16).substr(1)); |
|
7176 } |
|
7177 |
|
7178 function stringify(arr) { |
|
7179 var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; |
|
7180 // Note: Be careful editing this code! It's been tuned for performance |
|
7181 // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 |
|
7182 var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one |
|
7183 // of the following: |
|
7184 // - One or more input array values don't map to a hex octet (leading to |
|
7185 // "undefined" in the uuid) |
|
7186 // - Invalid input values for the RFC `version` or `variant` fields |
|
7187 |
|
7188 if (!esm_browser_validate(uuid)) { |
|
7189 throw TypeError('Stringified UUID is invalid'); |
|
7190 } |
|
7191 |
|
7192 return uuid; |
|
7193 } |
|
7194 |
|
7195 /* harmony default export */ var esm_browser_stringify = (stringify); |
|
7196 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js |
|
7197 |
|
7198 |
|
7199 |
|
7200 function v4(options, buf, offset) { |
|
7201 options = options || {}; |
|
7202 var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` |
|
7203 |
|
7204 rnds[6] = rnds[6] & 0x0f | 0x40; |
|
7205 rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided |
|
7206 |
|
7207 if (buf) { |
|
7208 offset = offset || 0; |
|
7209 |
|
7210 for (var i = 0; i < 16; ++i) { |
|
7211 buf[offset + i] = rnds[i]; |
|
7212 } |
|
7213 |
|
7214 return buf; |
|
7215 } |
|
7216 |
|
7217 return esm_browser_stringify(rnds); |
|
7218 } |
|
7219 |
|
7220 /* harmony default export */ var esm_browser_v4 = (v4); |
|
7221 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/factory.js |
|
7222 /** |
|
7223 * External dependencies |
|
7224 */ |
|
7225 |
|
7226 |
|
7227 /** |
|
7228 * WordPress dependencies |
|
7229 */ |
|
7230 |
|
7231 |
|
7232 /** |
|
7233 * Internal dependencies |
|
7234 */ |
|
7235 |
|
7236 |
|
7237 |
|
7238 /** |
|
7239 * Returns a block object given its type and attributes. |
|
7240 * |
|
7241 * @param {string} name Block name. |
|
7242 * @param {Object} attributes Block attributes. |
|
7243 * @param {?Array} innerBlocks Nested blocks. |
|
7244 * |
|
7245 * @return {Object} Block object. |
|
7246 */ |
|
7247 |
|
7248 function createBlock(name) { |
|
7249 let attributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
7250 let innerBlocks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; |
|
7251 |
|
7252 const sanitizedAttributes = __experimentalSanitizeBlockAttributes(name, attributes); |
|
7253 |
|
7254 const clientId = esm_browser_v4(); // Blocks are stored with a unique ID, the assigned type name, the block |
|
7255 // attributes, and their inner blocks. |
|
7256 |
|
7257 return { |
|
7258 clientId, |
|
7259 name, |
|
7260 isValid: true, |
|
7261 attributes: sanitizedAttributes, |
|
7262 innerBlocks |
|
7263 }; |
|
7264 } |
|
7265 /** |
|
7266 * Given an array of InnerBlocks templates or Block Objects, |
|
7267 * returns an array of created Blocks from them. |
|
7268 * It handles the case of having InnerBlocks as Blocks by |
|
7269 * converting them to the proper format to continue recursively. |
|
7270 * |
|
7271 * @param {Array} innerBlocksOrTemplate Nested blocks or InnerBlocks templates. |
|
7272 * |
|
7273 * @return {Object[]} Array of Block objects. |
|
7274 */ |
|
7275 |
|
7276 function createBlocksFromInnerBlocksTemplate() { |
|
7277 let innerBlocksOrTemplate = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
|
7278 return innerBlocksOrTemplate.map(innerBlock => { |
|
7279 const innerBlockTemplate = Array.isArray(innerBlock) ? innerBlock : [innerBlock.name, innerBlock.attributes, innerBlock.innerBlocks]; |
|
7280 const [name, attributes, innerBlocks = []] = innerBlockTemplate; |
|
7281 return createBlock(name, attributes, createBlocksFromInnerBlocksTemplate(innerBlocks)); |
|
7282 }); |
|
7283 } |
|
7284 /** |
|
7285 * Given a block object, returns a copy of the block object while sanitizing its attributes, |
|
7286 * optionally merging new attributes and/or replacing its inner blocks. |
|
7287 * |
|
7288 * @param {Object} block Block instance. |
|
7289 * @param {Object} mergeAttributes Block attributes. |
|
7290 * @param {?Array} newInnerBlocks Nested blocks. |
|
7291 * |
|
7292 * @return {Object} A cloned block. |
|
7293 */ |
|
7294 |
|
7295 function __experimentalCloneSanitizedBlock(block) { |
|
7296 let mergeAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
7297 let newInnerBlocks = arguments.length > 2 ? arguments[2] : undefined; |
|
7298 const clientId = esm_browser_v4(); |
|
7299 |
|
7300 const sanitizedAttributes = __experimentalSanitizeBlockAttributes(block.name, { ...block.attributes, |
|
7301 ...mergeAttributes |
|
7302 }); |
|
7303 |
|
7304 return { ...block, |
|
7305 clientId, |
|
7306 attributes: sanitizedAttributes, |
|
7307 innerBlocks: newInnerBlocks || block.innerBlocks.map(innerBlock => __experimentalCloneSanitizedBlock(innerBlock)) |
|
7308 }; |
|
7309 } |
|
7310 /** |
|
7311 * Given a block object, returns a copy of the block object, |
|
7312 * optionally merging new attributes and/or replacing its inner blocks. |
|
7313 * |
|
7314 * @param {Object} block Block instance. |
|
7315 * @param {Object} mergeAttributes Block attributes. |
|
7316 * @param {?Array} newInnerBlocks Nested blocks. |
|
7317 * |
|
7318 * @return {Object} A cloned block. |
|
7319 */ |
|
7320 |
|
7321 function cloneBlock(block) { |
|
7322 let mergeAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
7323 let newInnerBlocks = arguments.length > 2 ? arguments[2] : undefined; |
|
7324 const clientId = esm_browser_v4(); |
|
7325 return { ...block, |
|
7326 clientId, |
|
7327 attributes: { ...block.attributes, |
|
7328 ...mergeAttributes |
|
7329 }, |
|
7330 innerBlocks: newInnerBlocks || block.innerBlocks.map(innerBlock => cloneBlock(innerBlock)) |
|
7331 }; |
|
7332 } |
|
7333 /** |
|
7334 * Returns a boolean indicating whether a transform is possible based on |
|
7335 * various bits of context. |
|
7336 * |
|
7337 * @param {Object} transform The transform object to validate. |
|
7338 * @param {string} direction Is this a 'from' or 'to' transform. |
|
7339 * @param {Array} blocks The blocks to transform from. |
|
7340 * |
|
7341 * @return {boolean} Is the transform possible? |
|
7342 */ |
|
7343 |
|
7344 const isPossibleTransformForSource = (transform, direction, blocks) => { |
|
7345 if ((0,external_lodash_namespaceObject.isEmpty)(blocks)) { |
|
7346 return false; |
|
7347 } // If multiple blocks are selected, only multi block transforms |
|
7348 // or wildcard transforms are allowed. |
|
7349 |
|
7350 |
|
7351 const isMultiBlock = blocks.length > 1; |
|
7352 const firstBlockName = (0,external_lodash_namespaceObject.first)(blocks).name; |
|
7353 const isValidForMultiBlocks = isWildcardBlockTransform(transform) || !isMultiBlock || transform.isMultiBlock; |
|
7354 |
|
7355 if (!isValidForMultiBlocks) { |
|
7356 return false; |
|
7357 } // Check non-wildcard transforms to ensure that transform is valid |
|
7358 // for a block selection of multiple blocks of different types. |
|
7359 |
|
7360 |
|
7361 if (!isWildcardBlockTransform(transform) && !(0,external_lodash_namespaceObject.every)(blocks, { |
|
7362 name: firstBlockName |
|
7363 })) { |
|
7364 return false; |
|
7365 } // Only consider 'block' type transforms as valid. |
|
7366 |
|
7367 |
|
7368 const isBlockType = transform.type === 'block'; |
|
7369 |
|
7370 if (!isBlockType) { |
|
7371 return false; |
|
7372 } // Check if the transform's block name matches the source block (or is a wildcard) |
|
7373 // only if this is a transform 'from'. |
|
7374 |
|
7375 |
|
7376 const sourceBlock = (0,external_lodash_namespaceObject.first)(blocks); |
|
7377 const hasMatchingName = direction !== 'from' || transform.blocks.indexOf(sourceBlock.name) !== -1 || isWildcardBlockTransform(transform); |
|
7378 |
|
7379 if (!hasMatchingName) { |
|
7380 return false; |
|
7381 } // Don't allow single Grouping blocks to be transformed into |
|
7382 // a Grouping block. |
|
7383 |
|
7384 |
|
7385 if (!isMultiBlock && isContainerGroupBlock(sourceBlock.name) && isContainerGroupBlock(transform.blockName)) { |
|
7386 return false; |
|
7387 } // If the transform has a `isMatch` function specified, check that it returns true. |
|
7388 |
|
7389 |
|
7390 if ((0,external_lodash_namespaceObject.isFunction)(transform.isMatch)) { |
|
7391 const attributes = transform.isMultiBlock ? blocks.map(block => block.attributes) : sourceBlock.attributes; |
|
7392 const block = transform.isMultiBlock ? blocks : sourceBlock; |
|
7393 |
|
7394 if (!transform.isMatch(attributes, block)) { |
|
7395 return false; |
|
7396 } |
|
7397 } |
|
7398 |
|
7399 if (transform.usingMobileTransformations && isWildcardBlockTransform(transform) && !isContainerGroupBlock(sourceBlock.name)) { |
|
7400 return false; |
|
7401 } |
|
7402 |
|
7403 return true; |
|
7404 }; |
|
7405 /** |
|
7406 * Returns block types that the 'blocks' can be transformed into, based on |
|
7407 * 'from' transforms on other blocks. |
|
7408 * |
|
7409 * @param {Array} blocks The blocks to transform from. |
|
7410 * |
|
7411 * @return {Array} Block types that the blocks can be transformed into. |
|
7412 */ |
|
7413 |
|
7414 |
|
7415 const getBlockTypesForPossibleFromTransforms = blocks => { |
|
7416 if ((0,external_lodash_namespaceObject.isEmpty)(blocks)) { |
|
7417 return []; |
|
7418 } |
|
7419 |
|
7420 const allBlockTypes = registration_getBlockTypes(); // filter all blocks to find those with a 'from' transform. |
|
7421 |
|
7422 const blockTypesWithPossibleFromTransforms = (0,external_lodash_namespaceObject.filter)(allBlockTypes, blockType => { |
|
7423 const fromTransforms = getBlockTransforms('from', blockType.name); |
|
7424 return !!findTransform(fromTransforms, transform => { |
|
7425 return isPossibleTransformForSource(transform, 'from', blocks); |
|
7426 }); |
|
7427 }); |
|
7428 return blockTypesWithPossibleFromTransforms; |
|
7429 }; |
|
7430 /** |
|
7431 * Returns block types that the 'blocks' can be transformed into, based on |
|
7432 * the source block's own 'to' transforms. |
|
7433 * |
|
7434 * @param {Array} blocks The blocks to transform from. |
|
7435 * |
|
7436 * @return {Array} Block types that the source can be transformed into. |
|
7437 */ |
|
7438 |
|
7439 |
|
7440 const getBlockTypesForPossibleToTransforms = blocks => { |
|
7441 if ((0,external_lodash_namespaceObject.isEmpty)(blocks)) { |
|
7442 return []; |
|
7443 } |
|
7444 |
|
7445 const sourceBlock = (0,external_lodash_namespaceObject.first)(blocks); |
|
7446 const blockType = registration_getBlockType(sourceBlock.name); |
|
7447 const transformsTo = blockType ? getBlockTransforms('to', blockType.name) : []; // filter all 'to' transforms to find those that are possible. |
|
7448 |
|
7449 const possibleTransforms = (0,external_lodash_namespaceObject.filter)(transformsTo, transform => { |
|
7450 return transform && isPossibleTransformForSource(transform, 'to', blocks); |
|
7451 }); // Build a list of block names using the possible 'to' transforms. |
|
7452 |
|
7453 const blockNames = (0,external_lodash_namespaceObject.flatMap)(possibleTransforms, transformation => transformation.blocks); // Map block names to block types. |
|
7454 |
|
7455 return blockNames.map(name => name === '*' ? name : registration_getBlockType(name)); |
|
7456 }; |
|
7457 /** |
|
7458 * Determines whether transform is a "block" type |
|
7459 * and if so whether it is a "wildcard" transform |
|
7460 * ie: targets "any" block type |
|
7461 * |
|
7462 * @param {Object} t the Block transform object |
|
7463 * |
|
7464 * @return {boolean} whether transform is a wildcard transform |
|
7465 */ |
|
7466 |
|
7467 |
|
7468 const isWildcardBlockTransform = t => t && t.type === 'block' && Array.isArray(t.blocks) && t.blocks.includes('*'); |
|
7469 /** |
|
7470 * Determines whether the given Block is the core Block which |
|
7471 * acts as a container Block for other Blocks as part of the |
|
7472 * Grouping mechanics |
|
7473 * |
|
7474 * @param {string} name the name of the Block to test against |
|
7475 * |
|
7476 * @return {boolean} whether or not the Block is the container Block type |
|
7477 */ |
|
7478 |
|
7479 const isContainerGroupBlock = name => name === registration_getGroupingBlockName(); |
|
7480 /** |
|
7481 * Returns an array of block types that the set of blocks received as argument |
|
7482 * can be transformed into. |
|
7483 * |
|
7484 * @param {Array} blocks Blocks array. |
|
7485 * |
|
7486 * @return {Array} Block types that the blocks argument can be transformed to. |
|
7487 */ |
|
7488 |
|
7489 function getPossibleBlockTransformations(blocks) { |
|
7490 if ((0,external_lodash_namespaceObject.isEmpty)(blocks)) { |
|
7491 return []; |
|
7492 } |
|
7493 |
|
7494 const blockTypesForFromTransforms = getBlockTypesForPossibleFromTransforms(blocks); |
|
7495 const blockTypesForToTransforms = getBlockTypesForPossibleToTransforms(blocks); |
|
7496 return (0,external_lodash_namespaceObject.uniq)([...blockTypesForFromTransforms, ...blockTypesForToTransforms]); |
|
7497 } |
|
7498 /** |
|
7499 * Given an array of transforms, returns the highest-priority transform where |
|
7500 * the predicate function returns a truthy value. A higher-priority transform |
|
7501 * is one with a lower priority value (i.e. first in priority order). Returns |
|
7502 * null if the transforms set is empty or the predicate function returns a |
|
7503 * falsey value for all entries. |
|
7504 * |
|
7505 * @param {Object[]} transforms Transforms to search. |
|
7506 * @param {Function} predicate Function returning true on matching transform. |
|
7507 * |
|
7508 * @return {?Object} Highest-priority transform candidate. |
|
7509 */ |
|
7510 |
|
7511 function findTransform(transforms, predicate) { |
|
7512 // The hooks library already has built-in mechanisms for managing priority |
|
7513 // queue, so leverage via locally-defined instance. |
|
7514 const hooks = (0,external_wp_hooks_namespaceObject.createHooks)(); |
|
7515 |
|
7516 for (let i = 0; i < transforms.length; i++) { |
|
7517 const candidate = transforms[i]; |
|
7518 |
|
7519 if (predicate(candidate)) { |
|
7520 hooks.addFilter('transform', 'transform/' + i.toString(), result => result ? result : candidate, candidate.priority); |
|
7521 } |
|
7522 } // Filter name is arbitrarily chosen but consistent with above aggregation. |
|
7523 |
|
7524 |
|
7525 return hooks.applyFilters('transform', null); |
|
7526 } |
|
7527 /** |
|
7528 * Returns normal block transforms for a given transform direction, optionally |
|
7529 * for a specific block by name, or an empty array if there are no transforms. |
|
7530 * If no block name is provided, returns transforms for all blocks. A normal |
|
7531 * transform object includes `blockName` as a property. |
|
7532 * |
|
7533 * @param {string} direction Transform direction ("to", "from"). |
|
7534 * @param {string|Object} blockTypeOrName Block type or name. |
|
7535 * |
|
7536 * @return {Array} Block transforms for direction. |
|
7537 */ |
|
7538 |
|
7539 function getBlockTransforms(direction, blockTypeOrName) { |
|
7540 // When retrieving transforms for all block types, recurse into self. |
|
7541 if (blockTypeOrName === undefined) { |
|
7542 return (0,external_lodash_namespaceObject.flatMap)(registration_getBlockTypes(), _ref => { |
|
7543 let { |
|
7544 name |
|
7545 } = _ref; |
|
7546 return getBlockTransforms(direction, name); |
|
7547 }); |
|
7548 } // Validate that block type exists and has array of direction. |
|
7549 |
|
7550 |
|
7551 const blockType = normalizeBlockType(blockTypeOrName); |
|
7552 const { |
|
7553 name: blockName, |
|
7554 transforms |
|
7555 } = blockType || {}; |
|
7556 |
|
7557 if (!transforms || !Array.isArray(transforms[direction])) { |
|
7558 return []; |
|
7559 } |
|
7560 |
|
7561 const usingMobileTransformations = transforms.supportedMobileTransforms && Array.isArray(transforms.supportedMobileTransforms); |
|
7562 const filteredTransforms = usingMobileTransformations ? (0,external_lodash_namespaceObject.filter)(transforms[direction], t => { |
|
7563 if (t.type === 'raw') { |
|
7564 return true; |
|
7565 } |
|
7566 |
|
7567 if (!t.blocks || !t.blocks.length) { |
|
7568 return false; |
|
7569 } |
|
7570 |
|
7571 if (isWildcardBlockTransform(t)) { |
|
7572 return true; |
|
7573 } |
|
7574 |
|
7575 return (0,external_lodash_namespaceObject.every)(t.blocks, transformBlockName => transforms.supportedMobileTransforms.includes(transformBlockName)); |
|
7576 }) : transforms[direction]; // Map transforms to normal form. |
|
7577 |
|
7578 return filteredTransforms.map(transform => ({ ...transform, |
|
7579 blockName, |
|
7580 usingMobileTransformations |
|
7581 })); |
|
7582 } |
|
7583 /** |
|
7584 * Switch one or more blocks into one or more blocks of the new block type. |
|
7585 * |
|
7586 * @param {Array|Object} blocks Blocks array or block object. |
|
7587 * @param {string} name Block name. |
|
7588 * |
|
7589 * @return {?Array} Array of blocks or null. |
|
7590 */ |
|
7591 |
|
7592 function switchToBlockType(blocks, name) { |
|
7593 const blocksArray = (0,external_lodash_namespaceObject.castArray)(blocks); |
|
7594 const isMultiBlock = blocksArray.length > 1; |
|
7595 const firstBlock = blocksArray[0]; |
|
7596 const sourceName = firstBlock.name; // Find the right transformation by giving priority to the "to" |
|
7597 // transformation. |
|
7598 |
|
7599 const transformationsFrom = getBlockTransforms('from', name); |
|
7600 const transformationsTo = getBlockTransforms('to', sourceName); |
|
7601 const transformation = findTransform(transformationsTo, t => t.type === 'block' && (isWildcardBlockTransform(t) || t.blocks.indexOf(name) !== -1) && (!isMultiBlock || t.isMultiBlock)) || findTransform(transformationsFrom, t => t.type === 'block' && (isWildcardBlockTransform(t) || t.blocks.indexOf(sourceName) !== -1) && (!isMultiBlock || t.isMultiBlock)); // Stop if there is no valid transformation. |
|
7602 |
|
7603 if (!transformation) { |
|
7604 return null; |
|
7605 } |
|
7606 |
|
7607 let transformationResults; |
|
7608 |
|
7609 if (transformation.isMultiBlock) { |
|
7610 if ((0,external_lodash_namespaceObject.has)(transformation, '__experimentalConvert')) { |
|
7611 transformationResults = transformation.__experimentalConvert(blocksArray); |
|
7612 } else { |
|
7613 transformationResults = transformation.transform(blocksArray.map(currentBlock => currentBlock.attributes), blocksArray.map(currentBlock => currentBlock.innerBlocks)); |
|
7614 } |
|
7615 } else if ((0,external_lodash_namespaceObject.has)(transformation, '__experimentalConvert')) { |
|
7616 transformationResults = transformation.__experimentalConvert(firstBlock); |
|
7617 } else { |
|
7618 transformationResults = transformation.transform(firstBlock.attributes, firstBlock.innerBlocks); |
|
7619 } // Ensure that the transformation function returned an object or an array |
|
7620 // of objects. |
|
7621 |
|
7622 |
|
7623 if (!(0,external_lodash_namespaceObject.isObjectLike)(transformationResults)) { |
|
7624 return null; |
|
7625 } // If the transformation function returned a single object, we want to work |
|
7626 // with an array instead. |
|
7627 |
|
7628 |
|
7629 transformationResults = (0,external_lodash_namespaceObject.castArray)(transformationResults); // Ensure that every block object returned by the transformation has a |
|
7630 // valid block type. |
|
7631 |
|
7632 if (transformationResults.some(result => !registration_getBlockType(result.name))) { |
|
7633 return null; |
|
7634 } |
|
7635 |
|
7636 const hasSwitchedBlock = name === '*' || (0,external_lodash_namespaceObject.some)(transformationResults, result => result.name === name); // Ensure that at least one block object returned by the transformation has |
|
7637 // the expected "destination" block type. |
|
7638 |
|
7639 if (!hasSwitchedBlock) { |
|
7640 return null; |
|
7641 } |
|
7642 |
|
7643 const ret = transformationResults.map((result, index, results) => { |
|
7644 /** |
|
7645 * Filters an individual transform result from block transformation. |
|
7646 * All of the original blocks are passed, since transformations are |
|
7647 * many-to-many, not one-to-one. |
|
7648 * |
|
7649 * @param {Object} transformedBlock The transformed block. |
|
7650 * @param {Object[]} blocks Original blocks transformed. |
|
7651 * @param {Object[]} index Index of the transformed block on the array of results. |
|
7652 * @param {Object[]} results An array all the blocks that resulted from the transformation. |
|
7653 */ |
|
7654 return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.switchToBlockType.transformedBlock', result, blocks, index, results); |
|
7655 }); |
|
7656 return ret; |
|
7657 } |
|
7658 /** |
|
7659 * Create a block object from the example API. |
|
7660 * |
|
7661 * @param {string} name |
|
7662 * @param {Object} example |
|
7663 * |
|
7664 * @return {Object} block. |
|
7665 */ |
|
7666 |
|
7667 const getBlockFromExample = (name, example) => { |
|
7668 return createBlock(name, example.attributes, (0,external_lodash_namespaceObject.map)(example.innerBlocks, innerBlock => getBlockFromExample(innerBlock.name, innerBlock))); |
|
7669 }; |
|
7670 |
|
7671 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/utils.js |
|
7672 /** |
|
7673 * External dependencies |
|
7674 */ |
|
7675 |
|
7676 |
|
7677 |
|
7678 |
|
7679 /** |
|
7680 * WordPress dependencies |
|
7681 */ |
|
7682 |
|
7683 |
|
7684 |
|
7685 |
|
7686 /** |
|
7687 * Internal dependencies |
|
7688 */ |
|
7689 |
|
7690 |
|
7691 |
|
7692 |
|
7693 k([names, a11y]); |
|
7694 /** |
|
7695 * Array of icon colors containing a color to be used if the icon color |
|
7696 * was not explicitly set but the icon background color was. |
|
7697 * |
|
7698 * @type {Object} |
|
7699 */ |
|
7700 |
|
7701 const ICON_COLORS = ['#191e23', '#f8f9f9']; |
|
7702 /** |
|
7703 * Determines whether the block is a default block |
|
7704 * and its attributes are equal to the default attributes |
|
7705 * which means the block is unmodified. |
|
7706 * |
|
7707 * @param {WPBlock} block Block Object |
|
7708 * |
|
7709 * @return {boolean} Whether the block is an unmodified default block |
|
7710 */ |
|
7711 |
|
7712 function isUnmodifiedDefaultBlock(block) { |
|
7713 const defaultBlockName = registration_getDefaultBlockName(); |
|
7714 |
|
7715 if (block.name !== defaultBlockName) { |
|
7716 return false; |
|
7717 } // Cache a created default block if no cache exists or the default block |
|
7718 // name changed. |
|
7719 |
|
7720 |
|
7721 if (!isUnmodifiedDefaultBlock.block || isUnmodifiedDefaultBlock.block.name !== defaultBlockName) { |
|
7722 isUnmodifiedDefaultBlock.block = createBlock(defaultBlockName); |
|
7723 } |
|
7724 |
|
7725 const newDefaultBlock = isUnmodifiedDefaultBlock.block; |
|
7726 const blockType = registration_getBlockType(defaultBlockName); |
|
7727 return (0,external_lodash_namespaceObject.every)(blockType === null || blockType === void 0 ? void 0 : blockType.attributes, (value, key) => newDefaultBlock.attributes[key] === block.attributes[key]); |
|
7728 } |
|
7729 /** |
|
7730 * Function that checks if the parameter is a valid icon. |
|
7731 * |
|
7732 * @param {*} icon Parameter to be checked. |
|
7733 * |
|
7734 * @return {boolean} True if the parameter is a valid icon and false otherwise. |
|
7735 */ |
|
7736 |
|
7737 function isValidIcon(icon) { |
|
7738 return !!icon && ((0,external_lodash_namespaceObject.isString)(icon) || (0,external_wp_element_namespaceObject.isValidElement)(icon) || (0,external_lodash_namespaceObject.isFunction)(icon) || icon instanceof external_wp_element_namespaceObject.Component); |
|
7739 } |
|
7740 /** |
|
7741 * Function that receives an icon as set by the blocks during the registration |
|
7742 * and returns a new icon object that is normalized so we can rely on just on possible icon structure |
|
7743 * in the codebase. |
|
7744 * |
|
7745 * @param {WPBlockTypeIconRender} icon Render behavior of a block type icon; |
|
7746 * one of a Dashicon slug, an element, or a |
|
7747 * component. |
|
7748 * |
|
7749 * @return {WPBlockTypeIconDescriptor} Object describing the icon. |
|
7750 */ |
|
7751 |
|
7752 function normalizeIconObject(icon) { |
|
7753 icon = icon || BLOCK_ICON_DEFAULT; |
|
7754 |
|
7755 if (isValidIcon(icon)) { |
|
7756 return { |
|
7757 src: icon |
|
7758 }; |
|
7759 } |
|
7760 |
|
7761 if ((0,external_lodash_namespaceObject.has)(icon, ['background'])) { |
|
7762 const colordBgColor = w(icon.background); |
|
7763 return { ...icon, |
|
7764 foreground: icon.foreground ? icon.foreground : (0,external_lodash_namespaceObject.maxBy)(ICON_COLORS, iconColor => colordBgColor.contrast(iconColor)), |
|
7765 shadowColor: colordBgColor.alpha(0.3).toRgbString() |
|
7766 }; |
|
7767 } |
|
7768 |
|
7769 return icon; |
|
7770 } |
|
7771 /** |
|
7772 * Normalizes block type passed as param. When string is passed then |
|
7773 * it converts it to the matching block type object. |
|
7774 * It passes the original object otherwise. |
|
7775 * |
|
7776 * @param {string|Object} blockTypeOrName Block type or name. |
|
7777 * |
|
7778 * @return {?Object} Block type. |
|
7779 */ |
|
7780 |
|
7781 function normalizeBlockType(blockTypeOrName) { |
|
7782 if ((0,external_lodash_namespaceObject.isString)(blockTypeOrName)) { |
|
7783 return registration_getBlockType(blockTypeOrName); |
|
7784 } |
|
7785 |
|
7786 return blockTypeOrName; |
|
7787 } |
|
7788 /** |
|
7789 * Get the label for the block, usually this is either the block title, |
|
7790 * or the value of the block's `label` function when that's specified. |
|
7791 * |
|
7792 * @param {Object} blockType The block type. |
|
7793 * @param {Object} attributes The values of the block's attributes. |
|
7794 * @param {Object} context The intended use for the label. |
|
7795 * |
|
7796 * @return {string} The block label. |
|
7797 */ |
|
7798 |
|
7799 function getBlockLabel(blockType, attributes) { |
|
7800 let context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'visual'; |
|
7801 const { |
|
7802 __experimentalLabel: getLabel, |
|
7803 title |
|
7804 } = blockType; |
|
7805 const label = getLabel && getLabel(attributes, { |
|
7806 context |
|
7807 }); |
|
7808 |
|
7809 if (!label) { |
|
7810 return title; |
|
7811 } // Strip any HTML (i.e. RichText formatting) before returning. |
|
7812 |
|
7813 |
|
7814 return (0,external_wp_dom_namespaceObject.__unstableStripHTML)(label); |
|
7815 } |
|
7816 /** |
|
7817 * Get a label for the block for use by screenreaders, this is more descriptive |
|
7818 * than the visual label and includes the block title and the value of the |
|
7819 * `getLabel` function if it's specified. |
|
7820 * |
|
7821 * @param {Object} blockType The block type. |
|
7822 * @param {Object} attributes The values of the block's attributes. |
|
7823 * @param {?number} position The position of the block in the block list. |
|
7824 * @param {string} [direction='vertical'] The direction of the block layout. |
|
7825 * |
|
7826 * @return {string} The block label. |
|
7827 */ |
|
7828 |
|
7829 function getAccessibleBlockLabel(blockType, attributes, position) { |
|
7830 let direction = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'vertical'; |
|
7831 // `title` is already localized, `label` is a user-supplied value. |
|
7832 const title = blockType === null || blockType === void 0 ? void 0 : blockType.title; |
|
7833 const label = blockType ? getBlockLabel(blockType, attributes, 'accessibility') : ''; |
|
7834 const hasPosition = position !== undefined; // getBlockLabel returns the block title as a fallback when there's no label, |
|
7835 // if it did return the title, this function needs to avoid adding the |
|
7836 // title twice within the accessible label. Use this `hasLabel` boolean to |
|
7837 // handle that. |
|
7838 |
|
7839 const hasLabel = label && label !== title; |
|
7840 |
|
7841 if (hasPosition && direction === 'vertical') { |
|
7842 if (hasLabel) { |
|
7843 return (0,external_wp_i18n_namespaceObject.sprintf)( |
|
7844 /* translators: accessibility text. 1: The block title. 2: The block row number. 3: The block label.. */ |
|
7845 (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Row %2$d. %3$s'), title, position, label); |
|
7846 } |
|
7847 |
|
7848 return (0,external_wp_i18n_namespaceObject.sprintf)( |
|
7849 /* translators: accessibility text. 1: The block title. 2: The block row number. */ |
|
7850 (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Row %2$d'), title, position); |
|
7851 } else if (hasPosition && direction === 'horizontal') { |
|
7852 if (hasLabel) { |
|
7853 return (0,external_wp_i18n_namespaceObject.sprintf)( |
|
7854 /* translators: accessibility text. 1: The block title. 2: The block column number. 3: The block label.. */ |
|
7855 (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Column %2$d. %3$s'), title, position, label); |
|
7856 } |
|
7857 |
|
7858 return (0,external_wp_i18n_namespaceObject.sprintf)( |
|
7859 /* translators: accessibility text. 1: The block title. 2: The block column number. */ |
|
7860 (0,external_wp_i18n_namespaceObject.__)('%1$s Block. Column %2$d'), title, position); |
|
7861 } |
|
7862 |
|
7863 if (hasLabel) { |
|
7864 return (0,external_wp_i18n_namespaceObject.sprintf)( |
|
7865 /* translators: accessibility text. %1: The block title. %2: The block label. */ |
|
7866 (0,external_wp_i18n_namespaceObject.__)('%1$s Block. %2$s'), title, label); |
|
7867 } |
|
7868 |
|
7869 return (0,external_wp_i18n_namespaceObject.sprintf)( |
|
7870 /* translators: accessibility text. %s: The block title. */ |
|
7871 (0,external_wp_i18n_namespaceObject.__)('%s Block'), title); |
|
7872 } |
|
7873 /** |
|
7874 * Ensure attributes contains only values defined by block type, and merge |
|
7875 * default values for missing attributes. |
|
7876 * |
|
7877 * @param {string} name The block's name. |
|
7878 * @param {Object} attributes The block's attributes. |
|
7879 * @return {Object} The sanitized attributes. |
|
7880 */ |
|
7881 |
|
7882 function __experimentalSanitizeBlockAttributes(name, attributes) { |
|
7883 // Get the type definition associated with a registered block. |
|
7884 const blockType = registration_getBlockType(name); |
|
7885 |
|
7886 if (undefined === blockType) { |
|
7887 throw new Error(`Block type '${name}' is not registered.`); |
|
7888 } |
|
7889 |
|
7890 return (0,external_lodash_namespaceObject.reduce)(blockType.attributes, (accumulator, schema, key) => { |
|
7891 const value = attributes[key]; |
|
7892 |
|
7893 if (undefined !== value) { |
|
7894 accumulator[key] = value; |
|
7895 } else if (schema.hasOwnProperty('default')) { |
|
7896 accumulator[key] = schema.default; |
|
7897 } |
|
7898 |
|
7899 if (['node', 'children'].indexOf(schema.source) !== -1) { |
|
7900 // Ensure value passed is always an array, which we're expecting in |
|
7901 // the RichText component to handle the deprecated value. |
|
7902 if (typeof accumulator[key] === 'string') { |
|
7903 accumulator[key] = [accumulator[key]]; |
|
7904 } else if (!Array.isArray(accumulator[key])) { |
|
7905 accumulator[key] = []; |
|
7906 } |
|
7907 } |
|
7908 |
|
7909 return accumulator; |
|
7910 }, {}); |
|
7911 } |
|
7912 /** |
|
7913 * Filter block attributes by `role` and return their names. |
|
7914 * |
|
7915 * @param {string} name Block attribute's name. |
|
7916 * @param {string} role The role of a block attribute. |
|
7917 * |
|
7918 * @return {string[]} The attribute names that have the provided role. |
|
7919 */ |
|
7920 |
|
7921 function __experimentalGetBlockAttributesNamesByRole(name, role) { |
|
7922 var _getBlockType; |
|
7923 |
|
7924 const attributes = (_getBlockType = registration_getBlockType(name)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.attributes; |
|
7925 if (!attributes) return []; |
|
7926 const attributesNames = Object.keys(attributes); |
|
7927 if (!role) return attributesNames; |
|
7928 return attributesNames.filter(attributeName => { |
|
7929 var _attributes$attribute; |
|
7930 |
|
7931 return ((_attributes$attribute = attributes[attributeName]) === null || _attributes$attribute === void 0 ? void 0 : _attributes$attribute.__experimentalRole) === role; |
|
7932 }); |
|
7933 } |
|
7934 |
|
7935 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/actions.js |
|
7936 /** |
|
7937 * External dependencies |
|
7938 */ |
|
7939 |
|
7940 /** |
|
7941 * WordPress dependencies |
|
7942 */ |
|
7943 |
|
7944 |
|
7945 /** |
|
7946 * Internal dependencies |
|
7947 */ |
|
7948 |
|
7949 |
|
7950 |
|
7951 /** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */ |
|
7952 |
|
7953 const { |
|
7954 error, |
|
7955 warn |
|
7956 } = window.console; |
|
7957 /** |
|
7958 * Mapping of legacy category slugs to their latest normal values, used to |
|
7959 * accommodate updates of the default set of block categories. |
|
7960 * |
|
7961 * @type {Record<string,string>} |
|
7962 */ |
|
7963 |
|
7964 const LEGACY_CATEGORY_MAPPING = { |
|
7965 common: 'text', |
|
7966 formatting: 'text', |
|
7967 layout: 'design' |
|
7968 }; |
|
7969 /** |
|
7970 * Takes the unprocessed block type data and applies all the existing filters for the registered block type. |
|
7971 * Next, it validates all the settings and performs additional processing to the block type definition. |
|
7972 * |
|
7973 * @param {WPBlockType} blockType Unprocessed block type settings. |
|
7974 * @param {Object} thunkArgs Argument object for the thunk middleware. |
|
7975 * @param {Function} thunkArgs.select Function to select from the store. |
|
7976 * |
|
7977 * @return {?WPBlockType} The block, if it has been successfully registered; otherwise `undefined`. |
|
7978 */ |
|
7979 |
|
7980 const processBlockType = (blockType, _ref) => { |
|
7981 let { |
|
7982 select |
|
7983 } = _ref; |
|
7984 const { |
|
7985 name |
|
7986 } = blockType; |
|
7987 const settings = (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.registerBlockType', { ...blockType |
|
7988 }, name); |
|
7989 |
|
7990 if (settings.deprecated) { |
|
7991 settings.deprecated = settings.deprecated.map(deprecation => (0,external_lodash_namespaceObject.pick)( // Only keep valid deprecation keys. |
|
7992 (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.registerBlockType', // Merge deprecation keys with pre-filter settings |
|
7993 // so that filters that depend on specific keys being |
|
7994 // present don't fail. |
|
7995 { // Omit deprecation keys here so that deprecations |
|
7996 // can opt out of specific keys like "supports". |
|
7997 ...(0,external_lodash_namespaceObject.omit)(blockType, DEPRECATED_ENTRY_KEYS), |
|
7998 ...deprecation |
|
7999 }, name), DEPRECATED_ENTRY_KEYS)); |
|
8000 } |
|
8001 |
|
8002 if (!(0,external_lodash_namespaceObject.isPlainObject)(settings)) { |
|
8003 error('Block settings must be a valid object.'); |
|
8004 return; |
|
8005 } |
|
8006 |
|
8007 if (!(0,external_lodash_namespaceObject.isFunction)(settings.save)) { |
|
8008 error('The "save" property must be a valid function.'); |
|
8009 return; |
|
8010 } |
|
8011 |
|
8012 if ('edit' in settings && !(0,external_lodash_namespaceObject.isFunction)(settings.edit)) { |
|
8013 error('The "edit" property must be a valid function.'); |
|
8014 return; |
|
8015 } // Canonicalize legacy categories to equivalent fallback. |
|
8016 |
|
8017 |
|
8018 if (LEGACY_CATEGORY_MAPPING.hasOwnProperty(settings.category)) { |
|
8019 settings.category = LEGACY_CATEGORY_MAPPING[settings.category]; |
|
8020 } |
|
8021 |
|
8022 if ('category' in settings && !(0,external_lodash_namespaceObject.some)(select.getCategories(), { |
|
8023 slug: settings.category |
|
8024 })) { |
|
8025 warn('The block "' + name + '" is registered with an invalid category "' + settings.category + '".'); |
|
8026 delete settings.category; |
|
8027 } |
|
8028 |
|
8029 if (!('title' in settings) || settings.title === '') { |
|
8030 error('The block "' + name + '" must have a title.'); |
|
8031 return; |
|
8032 } |
|
8033 |
|
8034 if (typeof settings.title !== 'string') { |
|
8035 error('Block titles must be strings.'); |
|
8036 return; |
|
8037 } |
|
8038 |
|
8039 settings.icon = normalizeIconObject(settings.icon); |
|
8040 |
|
8041 if (!isValidIcon(settings.icon.src)) { |
|
8042 error('The icon passed is invalid. ' + 'The icon should be a string, an element, a function, or an object following the specifications documented in https://developer.wordpress.org/block-editor/developers/block-api/block-registration/#icon-optional'); |
|
8043 return; |
|
8044 } |
|
8045 |
|
8046 return settings; |
|
8047 }; |
|
8048 /** |
|
8049 * Returns an action object used in signalling that block types have been added. |
|
8050 * |
|
8051 * @param {Array|Object} blockTypes Block types received. |
|
8052 * |
|
8053 * @return {Object} Action object. |
|
8054 */ |
|
8055 |
|
8056 |
|
8057 function addBlockTypes(blockTypes) { |
|
8058 return { |
|
8059 type: 'ADD_BLOCK_TYPES', |
|
8060 blockTypes: (0,external_lodash_namespaceObject.castArray)(blockTypes) |
|
8061 }; |
|
8062 } |
|
8063 /** |
|
8064 * Signals that the passed block type's settings should be stored in the state. |
|
8065 * |
|
8066 * @param {WPBlockType} blockType Unprocessed block type settings. |
|
8067 */ |
|
8068 |
|
8069 const __experimentalRegisterBlockType = blockType => _ref2 => { |
|
8070 let { |
|
8071 dispatch, |
|
8072 select |
|
8073 } = _ref2; |
|
8074 dispatch({ |
|
8075 type: 'ADD_UNPROCESSED_BLOCK_TYPE', |
|
8076 blockType |
|
8077 }); |
|
8078 const processedBlockType = processBlockType(blockType, { |
|
8079 select |
|
8080 }); |
|
8081 |
|
8082 if (!processedBlockType) { |
|
8083 return; |
|
8084 } |
|
8085 |
|
8086 dispatch.addBlockTypes(processedBlockType); |
|
8087 }; |
|
8088 /** |
|
8089 * Signals that all block types should be computed again. |
|
8090 * It uses stored unprocessed block types and all the most recent list of registered filters. |
|
8091 * |
|
8092 * It addresses the issue where third party block filters get registered after third party blocks. A sample sequence: |
|
8093 * 1. Filter A. |
|
8094 * 2. Block B. |
|
8095 * 3. Block C. |
|
8096 * 4. Filter D. |
|
8097 * 5. Filter E. |
|
8098 * 6. Block F. |
|
8099 * 7. Filter G. |
|
8100 * In this scenario some filters would not get applied for all blocks because they are registered too late. |
|
8101 */ |
|
8102 |
|
8103 const __experimentalReapplyBlockTypeFilters = () => _ref3 => { |
|
8104 let { |
|
8105 dispatch, |
|
8106 select |
|
8107 } = _ref3; |
|
8108 |
|
8109 const unprocessedBlockTypes = select.__experimentalGetUnprocessedBlockTypes(); |
|
8110 |
|
8111 const processedBlockTypes = Object.keys(unprocessedBlockTypes).reduce((accumulator, blockName) => { |
|
8112 const result = processBlockType(unprocessedBlockTypes[blockName], { |
|
8113 select |
|
8114 }); |
|
8115 |
|
8116 if (result) { |
|
8117 accumulator.push(result); |
|
8118 } |
|
8119 |
|
8120 return accumulator; |
|
8121 }, []); |
|
8122 |
|
8123 if (!processedBlockTypes.length) { |
|
8124 return; |
|
8125 } |
|
8126 |
|
8127 dispatch.addBlockTypes(processedBlockTypes); |
|
8128 }; |
|
8129 /** |
|
8130 * Returns an action object used to remove a registered block type. |
|
8131 * |
|
8132 * @param {string|Array} names Block name. |
|
8133 * |
|
8134 * @return {Object} Action object. |
|
8135 */ |
|
8136 |
|
8137 function removeBlockTypes(names) { |
|
8138 return { |
|
8139 type: 'REMOVE_BLOCK_TYPES', |
|
8140 names: (0,external_lodash_namespaceObject.castArray)(names) |
|
8141 }; |
|
8142 } |
|
8143 /** |
|
8144 * Returns an action object used in signalling that new block styles have been added. |
|
8145 * |
|
8146 * @param {string} blockName Block name. |
|
8147 * @param {Array|Object} styles Block styles. |
|
8148 * |
|
8149 * @return {Object} Action object. |
|
8150 */ |
|
8151 |
|
8152 function addBlockStyles(blockName, styles) { |
|
8153 return { |
|
8154 type: 'ADD_BLOCK_STYLES', |
|
8155 styles: (0,external_lodash_namespaceObject.castArray)(styles), |
|
8156 blockName |
|
8157 }; |
|
8158 } |
|
8159 /** |
|
8160 * Returns an action object used in signalling that block styles have been removed. |
|
8161 * |
|
8162 * @param {string} blockName Block name. |
|
8163 * @param {Array|string} styleNames Block style names. |
|
8164 * |
|
8165 * @return {Object} Action object. |
|
8166 */ |
|
8167 |
|
8168 function removeBlockStyles(blockName, styleNames) { |
|
8169 return { |
|
8170 type: 'REMOVE_BLOCK_STYLES', |
|
8171 styleNames: (0,external_lodash_namespaceObject.castArray)(styleNames), |
|
8172 blockName |
|
8173 }; |
|
8174 } |
|
8175 /** |
|
8176 * Returns an action object used in signalling that new block variations have been added. |
|
8177 * |
|
8178 * @param {string} blockName Block name. |
|
8179 * @param {WPBlockVariation|WPBlockVariation[]} variations Block variations. |
|
8180 * |
|
8181 * @return {Object} Action object. |
|
8182 */ |
|
8183 |
|
8184 function addBlockVariations(blockName, variations) { |
|
8185 return { |
|
8186 type: 'ADD_BLOCK_VARIATIONS', |
|
8187 variations: (0,external_lodash_namespaceObject.castArray)(variations), |
|
8188 blockName |
|
8189 }; |
|
8190 } |
|
8191 /** |
|
8192 * Returns an action object used in signalling that block variations have been removed. |
|
8193 * |
|
8194 * @param {string} blockName Block name. |
|
8195 * @param {string|string[]} variationNames Block variation names. |
|
8196 * |
|
8197 * @return {Object} Action object. |
|
8198 */ |
|
8199 |
|
8200 function removeBlockVariations(blockName, variationNames) { |
|
8201 return { |
|
8202 type: 'REMOVE_BLOCK_VARIATIONS', |
|
8203 variationNames: (0,external_lodash_namespaceObject.castArray)(variationNames), |
|
8204 blockName |
|
8205 }; |
|
8206 } |
|
8207 /** |
|
8208 * Returns an action object used to set the default block name. |
|
8209 * |
|
8210 * @param {string} name Block name. |
|
8211 * |
|
8212 * @return {Object} Action object. |
|
8213 */ |
|
8214 |
|
8215 function actions_setDefaultBlockName(name) { |
|
8216 return { |
|
8217 type: 'SET_DEFAULT_BLOCK_NAME', |
|
8218 name |
|
8219 }; |
|
8220 } |
|
8221 /** |
|
8222 * Returns an action object used to set the name of the block used as a fallback |
|
8223 * for non-block content. |
|
8224 * |
|
8225 * @param {string} name Block name. |
|
8226 * |
|
8227 * @return {Object} Action object. |
|
8228 */ |
|
8229 |
|
8230 function setFreeformFallbackBlockName(name) { |
|
8231 return { |
|
8232 type: 'SET_FREEFORM_FALLBACK_BLOCK_NAME', |
|
8233 name |
|
8234 }; |
|
8235 } |
|
8236 /** |
|
8237 * Returns an action object used to set the name of the block used as a fallback |
|
8238 * for unregistered blocks. |
|
8239 * |
|
8240 * @param {string} name Block name. |
|
8241 * |
|
8242 * @return {Object} Action object. |
|
8243 */ |
|
8244 |
|
8245 function setUnregisteredFallbackBlockName(name) { |
|
8246 return { |
|
8247 type: 'SET_UNREGISTERED_FALLBACK_BLOCK_NAME', |
|
8248 name |
|
8249 }; |
|
8250 } |
|
8251 /** |
|
8252 * Returns an action object used to set the name of the block used |
|
8253 * when grouping other blocks |
|
8254 * eg: in "Group/Ungroup" interactions |
|
8255 * |
|
8256 * @param {string} name Block name. |
|
8257 * |
|
8258 * @return {Object} Action object. |
|
8259 */ |
|
8260 |
|
8261 function actions_setGroupingBlockName(name) { |
|
8262 return { |
|
8263 type: 'SET_GROUPING_BLOCK_NAME', |
|
8264 name |
|
8265 }; |
|
8266 } |
|
8267 /** |
|
8268 * Returns an action object used to set block categories. |
|
8269 * |
|
8270 * @param {Object[]} categories Block categories. |
|
8271 * |
|
8272 * @return {Object} Action object. |
|
8273 */ |
|
8274 |
|
8275 function setCategories(categories) { |
|
8276 return { |
|
8277 type: 'SET_CATEGORIES', |
|
8278 categories |
|
8279 }; |
|
8280 } |
|
8281 /** |
|
8282 * Returns an action object used to update a category. |
|
8283 * |
|
8284 * @param {string} slug Block category slug. |
|
8285 * @param {Object} category Object containing the category properties that should be updated. |
|
8286 * |
|
8287 * @return {Object} Action object. |
|
8288 */ |
|
8289 |
|
8290 function updateCategory(slug, category) { |
|
8291 return { |
|
8292 type: 'UPDATE_CATEGORY', |
|
8293 slug, |
|
8294 category |
|
8295 }; |
|
8296 } |
|
8297 /** |
|
8298 * Returns an action object used to add block collections |
|
8299 * |
|
8300 * @param {string} namespace The namespace of the blocks to put in the collection |
|
8301 * @param {string} title The title to display in the block inserter |
|
8302 * @param {Object} icon (optional) The icon to display in the block inserter |
|
8303 * |
|
8304 * @return {Object} Action object. |
|
8305 */ |
|
8306 |
|
8307 function addBlockCollection(namespace, title, icon) { |
|
8308 return { |
|
8309 type: 'ADD_BLOCK_COLLECTION', |
|
8310 namespace, |
|
8311 title, |
|
8312 icon |
|
8313 }; |
|
8314 } |
|
8315 /** |
|
8316 * Returns an action object used to remove block collections |
|
8317 * |
|
8318 * @param {string} namespace The namespace of the blocks to put in the collection |
|
8319 * |
|
8320 * @return {Object} Action object. |
|
8321 */ |
|
8322 |
|
8323 function removeBlockCollection(namespace) { |
|
8324 return { |
|
8325 type: 'REMOVE_BLOCK_COLLECTION', |
|
8326 namespace |
|
8327 }; |
|
8328 } |
|
8329 |
|
8330 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/constants.js |
|
8331 const STORE_NAME = 'core/blocks'; |
|
8332 |
|
8333 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/index.js |
|
8334 /** |
|
8335 * WordPress dependencies |
|
8336 */ |
|
8337 |
|
8338 /** |
|
8339 * Internal dependencies |
|
8340 */ |
|
8341 |
|
8342 |
|
8343 |
|
8344 |
|
8345 |
|
8346 /** |
|
8347 * Store definition for the blocks namespace. |
|
8348 * |
|
8349 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore |
|
8350 * |
|
8351 * @type {Object} |
|
8352 */ |
|
8353 |
|
8354 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { |
|
8355 reducer: reducer, |
|
8356 selectors: selectors_namespaceObject, |
|
8357 actions: actions_namespaceObject |
14032 }); |
8358 }); |
14033 |
8359 (0,external_wp_data_namespaceObject.register)(store); |
14034 |
8360 |
14035 /***/ }), |
8361 ;// CONCATENATED MODULE: external ["wp","blockSerializationDefaultParser"] |
14036 |
8362 var external_wp_blockSerializationDefaultParser_namespaceObject = window["wp"]["blockSerializationDefaultParser"]; |
14037 /***/ "rl8x": |
8363 ;// CONCATENATED MODULE: external ["wp","autop"] |
14038 /***/ (function(module, exports) { |
8364 var external_wp_autop_namespaceObject = window["wp"]["autop"]; |
14039 |
8365 ;// CONCATENATED MODULE: external ["wp","isShallowEqual"] |
14040 (function() { module.exports = window["wp"]["isShallowEqual"]; }()); |
8366 var external_wp_isShallowEqual_namespaceObject = window["wp"]["isShallowEqual"]; |
14041 |
8367 var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_namespaceObject); |
14042 /***/ }), |
8368 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/serialize-raw-block.js |
14043 |
8369 /** |
14044 /***/ "rmEH": |
8370 * Internal dependencies |
14045 /***/ (function(module, exports) { |
8371 */ |
14046 |
8372 |
14047 (function() { module.exports = window["wp"]["htmlEntities"]; }()); |
8373 /** |
14048 |
8374 * @typedef {Object} Options Serialization options. |
14049 /***/ }), |
8375 * @property {boolean} [isCommentDelimited=true] Whether to output HTML comments around blocks. |
14050 |
8376 */ |
14051 /***/ "wx14": |
8377 |
14052 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
8378 /** @typedef {import("./").WPRawBlock} WPRawBlock */ |
14053 |
8379 |
14054 "use strict"; |
8380 /** |
14055 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; }); |
8381 * Serializes a block node into the native HTML-comment-powered block format. |
|
8382 * CAVEAT: This function is intended for re-serializing blocks as parsed by |
|
8383 * valid parsers and skips any validation steps. This is NOT a generic |
|
8384 * serialization function for in-memory blocks. For most purposes, see the |
|
8385 * following functions available in the `@wordpress/blocks` package: |
|
8386 * |
|
8387 * @see serializeBlock |
|
8388 * @see serialize |
|
8389 * |
|
8390 * For more on the format of block nodes as returned by valid parsers: |
|
8391 * |
|
8392 * @see `@wordpress/block-serialization-default-parser` package |
|
8393 * @see `@wordpress/block-serialization-spec-parser` package |
|
8394 * |
|
8395 * @param {WPRawBlock} rawBlock A block node as returned by a valid parser. |
|
8396 * @param {Options} [options={}] Serialization options. |
|
8397 * |
|
8398 * @return {string} An HTML string representing a block. |
|
8399 */ |
|
8400 |
|
8401 function serializeRawBlock(rawBlock) { |
|
8402 let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
8403 const { |
|
8404 isCommentDelimited = true |
|
8405 } = options; |
|
8406 const { |
|
8407 blockName, |
|
8408 attrs = {}, |
|
8409 innerBlocks = [], |
|
8410 innerContent = [] |
|
8411 } = rawBlock; |
|
8412 let childIndex = 0; |
|
8413 const content = innerContent.map(item => // `null` denotes a nested block, otherwise we have an HTML fragment. |
|
8414 item !== null ? item : serializeRawBlock(innerBlocks[childIndex++], options)).join('\n').replace(/\n+/g, '\n').trim(); |
|
8415 return isCommentDelimited ? getCommentDelimitedContent(blockName, attrs, content) : content; |
|
8416 } |
|
8417 |
|
8418 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/serializer.js |
|
8419 |
|
8420 |
|
8421 /** |
|
8422 * External dependencies |
|
8423 */ |
|
8424 |
|
8425 /** |
|
8426 * WordPress dependencies |
|
8427 */ |
|
8428 |
|
8429 |
|
8430 |
|
8431 |
|
8432 |
|
8433 /** |
|
8434 * Internal dependencies |
|
8435 */ |
|
8436 |
|
8437 |
|
8438 |
|
8439 |
|
8440 /** @typedef {import('./parser').WPBlock} WPBlock */ |
|
8441 |
|
8442 /** |
|
8443 * @typedef {Object} WPBlockSerializationOptions Serialization Options. |
|
8444 * |
|
8445 * @property {boolean} isInnerBlocks Whether we are serializing inner blocks. |
|
8446 */ |
|
8447 |
|
8448 /** |
|
8449 * Returns the block's default classname from its name. |
|
8450 * |
|
8451 * @param {string} blockName The block name. |
|
8452 * |
|
8453 * @return {string} The block's default class. |
|
8454 */ |
|
8455 |
|
8456 function getBlockDefaultClassName(blockName) { |
|
8457 // Generated HTML classes for blocks follow the `wp-block-{name}` nomenclature. |
|
8458 // Blocks provided by WordPress drop the prefixes 'core/' or 'core-' (historically used in 'core-embed/'). |
|
8459 const className = 'wp-block-' + blockName.replace(/\//, '-').replace(/^core-/, ''); |
|
8460 return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getBlockDefaultClassName', className, blockName); |
|
8461 } |
|
8462 /** |
|
8463 * Returns the block's default menu item classname from its name. |
|
8464 * |
|
8465 * @param {string} blockName The block name. |
|
8466 * |
|
8467 * @return {string} The block's default menu item class. |
|
8468 */ |
|
8469 |
|
8470 function getBlockMenuDefaultClassName(blockName) { |
|
8471 // Generated HTML classes for blocks follow the `editor-block-list-item-{name}` nomenclature. |
|
8472 // Blocks provided by WordPress drop the prefixes 'core/' or 'core-' (historically used in 'core-embed/'). |
|
8473 const className = 'editor-block-list-item-' + blockName.replace(/\//, '-').replace(/^core-/, ''); |
|
8474 return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getBlockMenuDefaultClassName', className, blockName); |
|
8475 } |
|
8476 const blockPropsProvider = {}; |
|
8477 const innerBlocksPropsProvider = {}; |
|
8478 /** |
|
8479 * Call within a save function to get the props for the block wrapper. |
|
8480 * |
|
8481 * @param {Object} props Optional. Props to pass to the element. |
|
8482 */ |
|
8483 |
|
8484 function getBlockProps() { |
|
8485 let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
8486 const { |
|
8487 blockType, |
|
8488 attributes |
|
8489 } = blockPropsProvider; |
|
8490 return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getSaveContent.extraProps', { ...props |
|
8491 }, blockType, attributes); |
|
8492 } |
|
8493 /** |
|
8494 * Call within a save function to get the props for the inner blocks wrapper. |
|
8495 * |
|
8496 * @param {Object} props Optional. Props to pass to the element. |
|
8497 */ |
|
8498 |
|
8499 function getInnerBlocksProps() { |
|
8500 let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
8501 const { |
|
8502 innerBlocks |
|
8503 } = innerBlocksPropsProvider; // Value is an array of blocks, so defer to block serializer. |
|
8504 |
|
8505 const html = serializer_serialize(innerBlocks, { |
|
8506 isInnerBlocks: true |
|
8507 }); // Use special-cased raw HTML tag to avoid default escaping. |
|
8508 |
|
8509 const children = (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, null, html); |
|
8510 return { ...props, |
|
8511 children |
|
8512 }; |
|
8513 } |
|
8514 /** |
|
8515 * Given a block type containing a save render implementation and attributes, returns the |
|
8516 * enhanced element to be saved or string when raw HTML expected. |
|
8517 * |
|
8518 * @param {string|Object} blockTypeOrName Block type or name. |
|
8519 * @param {Object} attributes Block attributes. |
|
8520 * @param {?Array} innerBlocks Nested blocks. |
|
8521 * |
|
8522 * @return {Object|string} Save element or raw HTML string. |
|
8523 */ |
|
8524 |
|
8525 function getSaveElement(blockTypeOrName, attributes) { |
|
8526 let innerBlocks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; |
|
8527 const blockType = normalizeBlockType(blockTypeOrName); |
|
8528 let { |
|
8529 save |
|
8530 } = blockType; // Component classes are unsupported for save since serialization must |
|
8531 // occur synchronously. For improved interoperability with higher-order |
|
8532 // components which often return component class, emulate basic support. |
|
8533 |
|
8534 if (save.prototype instanceof external_wp_element_namespaceObject.Component) { |
|
8535 const instance = new save({ |
|
8536 attributes |
|
8537 }); |
|
8538 save = instance.render.bind(instance); |
|
8539 } |
|
8540 |
|
8541 blockPropsProvider.blockType = blockType; |
|
8542 blockPropsProvider.attributes = attributes; |
|
8543 innerBlocksPropsProvider.innerBlocks = innerBlocks; |
|
8544 let element = save({ |
|
8545 attributes, |
|
8546 innerBlocks |
|
8547 }); |
|
8548 |
|
8549 if ((0,external_lodash_namespaceObject.isObject)(element) && (0,external_wp_hooks_namespaceObject.hasFilter)('blocks.getSaveContent.extraProps') && !(blockType.apiVersion > 1)) { |
|
8550 /** |
|
8551 * Filters the props applied to the block save result element. |
|
8552 * |
|
8553 * @param {Object} props Props applied to save element. |
|
8554 * @param {WPBlock} blockType Block type definition. |
|
8555 * @param {Object} attributes Block attributes. |
|
8556 */ |
|
8557 const props = (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getSaveContent.extraProps', { ...element.props |
|
8558 }, blockType, attributes); |
|
8559 |
|
8560 if (!external_wp_isShallowEqual_default()(props, element.props)) { |
|
8561 element = (0,external_wp_element_namespaceObject.cloneElement)(element, props); |
|
8562 } |
|
8563 } |
|
8564 /** |
|
8565 * Filters the save result of a block during serialization. |
|
8566 * |
|
8567 * @param {WPElement} element Block save result. |
|
8568 * @param {WPBlock} blockType Block type definition. |
|
8569 * @param {Object} attributes Block attributes. |
|
8570 */ |
|
8571 |
|
8572 |
|
8573 return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getSaveElement', element, blockType, attributes); |
|
8574 } |
|
8575 /** |
|
8576 * Given a block type containing a save render implementation and attributes, returns the |
|
8577 * static markup to be saved. |
|
8578 * |
|
8579 * @param {string|Object} blockTypeOrName Block type or name. |
|
8580 * @param {Object} attributes Block attributes. |
|
8581 * @param {?Array} innerBlocks Nested blocks. |
|
8582 * |
|
8583 * @return {string} Save content. |
|
8584 */ |
|
8585 |
|
8586 function getSaveContent(blockTypeOrName, attributes, innerBlocks) { |
|
8587 const blockType = normalizeBlockType(blockTypeOrName); |
|
8588 return (0,external_wp_element_namespaceObject.renderToString)(getSaveElement(blockType, attributes, innerBlocks)); |
|
8589 } |
|
8590 /** |
|
8591 * Returns attributes which are to be saved and serialized into the block |
|
8592 * comment delimiter. |
|
8593 * |
|
8594 * When a block exists in memory it contains as its attributes both those |
|
8595 * parsed the block comment delimiter _and_ those which matched from the |
|
8596 * contents of the block. |
|
8597 * |
|
8598 * This function returns only those attributes which are needed to persist and |
|
8599 * which cannot be matched from the block content. |
|
8600 * |
|
8601 * @param {Object<string,*>} blockType Block type. |
|
8602 * @param {Object<string,*>} attributes Attributes from in-memory block data. |
|
8603 * |
|
8604 * @return {Object<string,*>} Subset of attributes for comment serialization. |
|
8605 */ |
|
8606 |
|
8607 function getCommentAttributes(blockType, attributes) { |
|
8608 return (0,external_lodash_namespaceObject.reduce)(blockType.attributes, (accumulator, attributeSchema, key) => { |
|
8609 const value = attributes[key]; // Ignore undefined values. |
|
8610 |
|
8611 if (undefined === value) { |
|
8612 return accumulator; |
|
8613 } // Ignore all attributes but the ones with an "undefined" source |
|
8614 // "undefined" source refers to attributes saved in the block comment. |
|
8615 |
|
8616 |
|
8617 if (attributeSchema.source !== undefined) { |
|
8618 return accumulator; |
|
8619 } // Ignore default value. |
|
8620 |
|
8621 |
|
8622 if ('default' in attributeSchema && attributeSchema.default === value) { |
|
8623 return accumulator; |
|
8624 } // Otherwise, include in comment set. |
|
8625 |
|
8626 |
|
8627 accumulator[key] = value; |
|
8628 return accumulator; |
|
8629 }, {}); |
|
8630 } |
|
8631 /** |
|
8632 * Given an attributes object, returns a string in the serialized attributes |
|
8633 * format prepared for post content. |
|
8634 * |
|
8635 * @param {Object} attributes Attributes object. |
|
8636 * |
|
8637 * @return {string} Serialized attributes. |
|
8638 */ |
|
8639 |
|
8640 function serializeAttributes(attributes) { |
|
8641 return JSON.stringify(attributes) // Don't break HTML comments. |
|
8642 .replace(/--/g, '\\u002d\\u002d') // Don't break non-standard-compliant tools. |
|
8643 .replace(/</g, '\\u003c').replace(/>/g, '\\u003e').replace(/&/g, '\\u0026') // Bypass server stripslashes behavior which would unescape stringify's |
|
8644 // escaping of quotation mark. |
|
8645 // |
|
8646 // See: https://developer.wordpress.org/reference/functions/wp_kses_stripslashes/ |
|
8647 .replace(/\\"/g, '\\u0022'); |
|
8648 } |
|
8649 /** |
|
8650 * Given a block object, returns the Block's Inner HTML markup. |
|
8651 * |
|
8652 * @param {Object} block Block instance. |
|
8653 * |
|
8654 * @return {string} HTML. |
|
8655 */ |
|
8656 |
|
8657 function getBlockInnerHTML(block) { |
|
8658 // If block was parsed as invalid or encounters an error while generating |
|
8659 // save content, use original content instead to avoid content loss. If a |
|
8660 // block contains nested content, exempt it from this condition because we |
|
8661 // otherwise have no access to its original content and content loss would |
|
8662 // still occur. |
|
8663 let saveContent = block.originalContent; |
|
8664 |
|
8665 if (block.isValid || block.innerBlocks.length) { |
|
8666 try { |
|
8667 saveContent = getSaveContent(block.name, block.attributes, block.innerBlocks); |
|
8668 } catch (error) {} |
|
8669 } |
|
8670 |
|
8671 return saveContent; |
|
8672 } |
|
8673 /** |
|
8674 * Returns the content of a block, including comment delimiters. |
|
8675 * |
|
8676 * @param {string} rawBlockName Block name. |
|
8677 * @param {Object} attributes Block attributes. |
|
8678 * @param {string} content Block save content. |
|
8679 * |
|
8680 * @return {string} Comment-delimited block content. |
|
8681 */ |
|
8682 |
|
8683 function getCommentDelimitedContent(rawBlockName, attributes, content) { |
|
8684 const serializedAttributes = !(0,external_lodash_namespaceObject.isEmpty)(attributes) ? serializeAttributes(attributes) + ' ' : ''; // Strip core blocks of their namespace prefix. |
|
8685 |
|
8686 const blockName = (0,external_lodash_namespaceObject.startsWith)(rawBlockName, 'core/') ? rawBlockName.slice(5) : rawBlockName; // @todo make the `wp:` prefix potentially configurable. |
|
8687 |
|
8688 if (!content) { |
|
8689 return `<!-- wp:${blockName} ${serializedAttributes}/-->`; |
|
8690 } |
|
8691 |
|
8692 return `<!-- wp:${blockName} ${serializedAttributes}-->\n` + content + `\n<!-- /wp:${blockName} -->`; |
|
8693 } |
|
8694 /** |
|
8695 * Returns the content of a block, including comment delimiters, determining |
|
8696 * serialized attributes and content form from the current state of the block. |
|
8697 * |
|
8698 * @param {WPBlock} block Block instance. |
|
8699 * @param {WPBlockSerializationOptions} options Serialization options. |
|
8700 * |
|
8701 * @return {string} Serialized block. |
|
8702 */ |
|
8703 |
|
8704 function serializeBlock(block) { |
|
8705 let { |
|
8706 isInnerBlocks = false |
|
8707 } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
8708 |
|
8709 if (!block.isValid && block.__unstableBlockSource) { |
|
8710 return serializeRawBlock(block.__unstableBlockSource); |
|
8711 } |
|
8712 |
|
8713 const blockName = block.name; |
|
8714 const saveContent = getBlockInnerHTML(block); |
|
8715 |
|
8716 if (blockName === getUnregisteredTypeHandlerName() || !isInnerBlocks && blockName === getFreeformContentHandlerName()) { |
|
8717 return saveContent; |
|
8718 } |
|
8719 |
|
8720 const blockType = registration_getBlockType(blockName); |
|
8721 const saveAttributes = getCommentAttributes(blockType, block.attributes); |
|
8722 return getCommentDelimitedContent(blockName, saveAttributes, saveContent); |
|
8723 } |
|
8724 function __unstableSerializeAndClean(blocks) { |
|
8725 // A single unmodified default block is assumed to |
|
8726 // be equivalent to an empty post. |
|
8727 if (blocks.length === 1 && isUnmodifiedDefaultBlock(blocks[0])) { |
|
8728 blocks = []; |
|
8729 } |
|
8730 |
|
8731 let content = serializer_serialize(blocks); // For compatibility, treat a post consisting of a |
|
8732 // single freeform block as legacy content and apply |
|
8733 // pre-block-editor removep'd content formatting. |
|
8734 |
|
8735 if (blocks.length === 1 && blocks[0].name === getFreeformContentHandlerName()) { |
|
8736 content = (0,external_wp_autop_namespaceObject.removep)(content); |
|
8737 } |
|
8738 |
|
8739 return content; |
|
8740 } |
|
8741 /** |
|
8742 * Takes a block or set of blocks and returns the serialized post content. |
|
8743 * |
|
8744 * @param {Array} blocks Block(s) to serialize. |
|
8745 * @param {WPBlockSerializationOptions} options Serialization options. |
|
8746 * |
|
8747 * @return {string} The post content. |
|
8748 */ |
|
8749 |
|
8750 function serializer_serialize(blocks, options) { |
|
8751 return (0,external_lodash_namespaceObject.castArray)(blocks).map(block => serializeBlock(block, options)).join('\n\n'); |
|
8752 } |
|
8753 |
|
8754 ;// CONCATENATED MODULE: ./node_modules/simple-html-tokenizer/dist/es6/index.js |
|
8755 /** |
|
8756 * generated from https://raw.githubusercontent.com/w3c/html/26b5126f96f736f796b9e29718138919dd513744/entities.json |
|
8757 * do not edit |
|
8758 */ |
|
8759 var namedCharRefs = { |
|
8760 Aacute: "Á", aacute: "á", Abreve: "Ă", abreve: "ă", ac: "∾", acd: "∿", acE: "∾̳", Acirc: "Â", acirc: "â", acute: "´", Acy: "А", acy: "а", AElig: "Æ", aelig: "æ", af: "\u2061", Afr: "𝔄", afr: "𝔞", Agrave: "À", agrave: "à", alefsym: "ℵ", aleph: "ℵ", Alpha: "Α", alpha: "α", Amacr: "Ā", amacr: "ā", amalg: "⨿", amp: "&", AMP: "&", andand: "⩕", And: "⩓", and: "∧", andd: "⩜", andslope: "⩘", andv: "⩚", ang: "∠", ange: "⦤", angle: "∠", angmsdaa: "⦨", angmsdab: "⦩", angmsdac: "⦪", angmsdad: "⦫", angmsdae: "⦬", angmsdaf: "⦭", angmsdag: "⦮", angmsdah: "⦯", angmsd: "∡", angrt: "∟", angrtvb: "⊾", angrtvbd: "⦝", angsph: "∢", angst: "Å", angzarr: "⍼", Aogon: "Ą", aogon: "ą", Aopf: "𝔸", aopf: "𝕒", apacir: "⩯", ap: "≈", apE: "⩰", ape: "≊", apid: "≋", apos: "'", ApplyFunction: "\u2061", approx: "≈", approxeq: "≊", Aring: "Å", aring: "å", Ascr: "𝒜", ascr: "𝒶", Assign: "≔", ast: "*", asymp: "≈", asympeq: "≍", Atilde: "Ã", atilde: "ã", Auml: "Ä", auml: "ä", awconint: "∳", awint: "⨑", backcong: "≌", backepsilon: "϶", backprime: "‵", backsim: "∽", backsimeq: "⋍", Backslash: "∖", Barv: "⫧", barvee: "⊽", barwed: "⌅", Barwed: "⌆", barwedge: "⌅", bbrk: "⎵", bbrktbrk: "⎶", bcong: "≌", Bcy: "Б", bcy: "б", bdquo: "„", becaus: "∵", because: "∵", Because: "∵", bemptyv: "⦰", bepsi: "϶", bernou: "ℬ", Bernoullis: "ℬ", Beta: "Β", beta: "β", beth: "ℶ", between: "≬", Bfr: "𝔅", bfr: "𝔟", bigcap: "⋂", bigcirc: "◯", bigcup: "⋃", bigodot: "⨀", bigoplus: "⨁", bigotimes: "⨂", bigsqcup: "⨆", bigstar: "★", bigtriangledown: "▽", bigtriangleup: "△", biguplus: "⨄", bigvee: "⋁", bigwedge: "⋀", bkarow: "⤍", blacklozenge: "⧫", blacksquare: "▪", blacktriangle: "▴", blacktriangledown: "▾", blacktriangleleft: "◂", blacktriangleright: "▸", blank: "␣", blk12: "▒", blk14: "░", blk34: "▓", block: "█", bne: "=⃥", bnequiv: "≡⃥", bNot: "⫭", bnot: "⌐", Bopf: "𝔹", bopf: "𝕓", bot: "⊥", bottom: "⊥", bowtie: "⋈", boxbox: "⧉", boxdl: "┐", boxdL: "╕", boxDl: "╖", boxDL: "╗", boxdr: "┌", boxdR: "╒", boxDr: "╓", boxDR: "╔", boxh: "─", boxH: "═", boxhd: "┬", boxHd: "╤", boxhD: "╥", boxHD: "╦", boxhu: "┴", boxHu: "╧", boxhU: "╨", boxHU: "╩", boxminus: "⊟", boxplus: "⊞", boxtimes: "⊠", boxul: "┘", boxuL: "╛", boxUl: "╜", boxUL: "╝", boxur: "└", boxuR: "╘", boxUr: "╙", boxUR: "╚", boxv: "│", boxV: "║", boxvh: "┼", boxvH: "╪", boxVh: "╫", boxVH: "╬", boxvl: "┤", boxvL: "╡", boxVl: "╢", boxVL: "╣", boxvr: "├", boxvR: "╞", boxVr: "╟", boxVR: "╠", bprime: "‵", breve: "˘", Breve: "˘", brvbar: "¦", bscr: "𝒷", Bscr: "ℬ", bsemi: "⁏", bsim: "∽", bsime: "⋍", bsolb: "⧅", bsol: "\\", bsolhsub: "⟈", bull: "•", bullet: "•", bump: "≎", bumpE: "⪮", bumpe: "≏", Bumpeq: "≎", bumpeq: "≏", Cacute: "Ć", cacute: "ć", capand: "⩄", capbrcup: "⩉", capcap: "⩋", cap: "∩", Cap: "⋒", capcup: "⩇", capdot: "⩀", CapitalDifferentialD: "ⅅ", caps: "∩︀", caret: "⁁", caron: "ˇ", Cayleys: "ℭ", ccaps: "⩍", Ccaron: "Č", ccaron: "č", Ccedil: "Ç", ccedil: "ç", Ccirc: "Ĉ", ccirc: "ĉ", Cconint: "∰", ccups: "⩌", ccupssm: "⩐", Cdot: "Ċ", cdot: "ċ", cedil: "¸", Cedilla: "¸", cemptyv: "⦲", cent: "¢", centerdot: "·", CenterDot: "·", cfr: "𝔠", Cfr: "ℭ", CHcy: "Ч", chcy: "ч", check: "✓", checkmark: "✓", Chi: "Χ", chi: "χ", circ: "ˆ", circeq: "≗", circlearrowleft: "↺", circlearrowright: "↻", circledast: "⊛", circledcirc: "⊚", circleddash: "⊝", CircleDot: "⊙", circledR: "®", circledS: "Ⓢ", CircleMinus: "⊖", CirclePlus: "⊕", CircleTimes: "⊗", cir: "○", cirE: "⧃", cire: "≗", cirfnint: "⨐", cirmid: "⫯", cirscir: "⧂", ClockwiseContourIntegral: "∲", CloseCurlyDoubleQuote: "”", CloseCurlyQuote: "’", clubs: "♣", clubsuit: "♣", colon: ":", Colon: "∷", Colone: "⩴", colone: "≔", coloneq: "≔", comma: ",", commat: "@", comp: "∁", compfn: "∘", complement: "∁", complexes: "ℂ", cong: "≅", congdot: "⩭", Congruent: "≡", conint: "∮", Conint: "∯", ContourIntegral: "∮", copf: "𝕔", Copf: "ℂ", coprod: "∐", Coproduct: "∐", copy: "©", COPY: "©", copysr: "℗", CounterClockwiseContourIntegral: "∳", crarr: "↵", cross: "✗", Cross: "⨯", Cscr: "𝒞", cscr: "𝒸", csub: "⫏", csube: "⫑", csup: "⫐", csupe: "⫒", ctdot: "⋯", cudarrl: "⤸", cudarrr: "⤵", cuepr: "⋞", cuesc: "⋟", cularr: "↶", cularrp: "⤽", cupbrcap: "⩈", cupcap: "⩆", CupCap: "≍", cup: "∪", Cup: "⋓", cupcup: "⩊", cupdot: "⊍", cupor: "⩅", cups: "∪︀", curarr: "↷", curarrm: "⤼", curlyeqprec: "⋞", curlyeqsucc: "⋟", curlyvee: "⋎", curlywedge: "⋏", curren: "¤", curvearrowleft: "↶", curvearrowright: "↷", cuvee: "⋎", cuwed: "⋏", cwconint: "∲", cwint: "∱", cylcty: "⌭", dagger: "†", Dagger: "‡", daleth: "ℸ", darr: "↓", Darr: "↡", dArr: "⇓", dash: "‐", Dashv: "⫤", dashv: "⊣", dbkarow: "⤏", dblac: "˝", Dcaron: "Ď", dcaron: "ď", Dcy: "Д", dcy: "д", ddagger: "‡", ddarr: "⇊", DD: "ⅅ", dd: "ⅆ", DDotrahd: "⤑", ddotseq: "⩷", deg: "°", Del: "∇", Delta: "Δ", delta: "δ", demptyv: "⦱", dfisht: "⥿", Dfr: "𝔇", dfr: "𝔡", dHar: "⥥", dharl: "⇃", dharr: "⇂", DiacriticalAcute: "´", DiacriticalDot: "˙", DiacriticalDoubleAcute: "˝", DiacriticalGrave: "`", DiacriticalTilde: "˜", diam: "⋄", diamond: "⋄", Diamond: "⋄", diamondsuit: "♦", diams: "♦", die: "¨", DifferentialD: "ⅆ", digamma: "ϝ", disin: "⋲", div: "÷", divide: "÷", divideontimes: "⋇", divonx: "⋇", DJcy: "Ђ", djcy: "ђ", dlcorn: "⌞", dlcrop: "⌍", dollar: "$", Dopf: "𝔻", dopf: "𝕕", Dot: "¨", dot: "˙", DotDot: "⃜", doteq: "≐", doteqdot: "≑", DotEqual: "≐", dotminus: "∸", dotplus: "∔", dotsquare: "⊡", doublebarwedge: "⌆", DoubleContourIntegral: "∯", DoubleDot: "¨", DoubleDownArrow: "⇓", DoubleLeftArrow: "⇐", DoubleLeftRightArrow: "⇔", DoubleLeftTee: "⫤", DoubleLongLeftArrow: "⟸", DoubleLongLeftRightArrow: "⟺", DoubleLongRightArrow: "⟹", DoubleRightArrow: "⇒", DoubleRightTee: "⊨", DoubleUpArrow: "⇑", DoubleUpDownArrow: "⇕", DoubleVerticalBar: "∥", DownArrowBar: "⤓", downarrow: "↓", DownArrow: "↓", Downarrow: "⇓", DownArrowUpArrow: "⇵", DownBreve: "̑", downdownarrows: "⇊", downharpoonleft: "⇃", downharpoonright: "⇂", DownLeftRightVector: "⥐", DownLeftTeeVector: "⥞", DownLeftVectorBar: "⥖", DownLeftVector: "↽", DownRightTeeVector: "⥟", DownRightVectorBar: "⥗", DownRightVector: "⇁", DownTeeArrow: "↧", DownTee: "⊤", drbkarow: "⤐", drcorn: "⌟", drcrop: "⌌", Dscr: "𝒟", dscr: "𝒹", DScy: "Ѕ", dscy: "ѕ", dsol: "⧶", Dstrok: "Đ", dstrok: "đ", dtdot: "⋱", dtri: "▿", dtrif: "▾", duarr: "⇵", duhar: "⥯", dwangle: "⦦", DZcy: "Џ", dzcy: "џ", dzigrarr: "⟿", Eacute: "É", eacute: "é", easter: "⩮", Ecaron: "Ě", ecaron: "ě", Ecirc: "Ê", ecirc: "ê", ecir: "≖", ecolon: "≕", Ecy: "Э", ecy: "э", eDDot: "⩷", Edot: "Ė", edot: "ė", eDot: "≑", ee: "ⅇ", efDot: "≒", Efr: "𝔈", efr: "𝔢", eg: "⪚", Egrave: "È", egrave: "è", egs: "⪖", egsdot: "⪘", el: "⪙", Element: "∈", elinters: "⏧", ell: "ℓ", els: "⪕", elsdot: "⪗", Emacr: "Ē", emacr: "ē", empty: "∅", emptyset: "∅", EmptySmallSquare: "◻", emptyv: "∅", EmptyVerySmallSquare: "▫", emsp13: " ", emsp14: " ", emsp: " ", ENG: "Ŋ", eng: "ŋ", ensp: " ", Eogon: "Ę", eogon: "ę", Eopf: "𝔼", eopf: "𝕖", epar: "⋕", eparsl: "⧣", eplus: "⩱", epsi: "ε", Epsilon: "Ε", epsilon: "ε", epsiv: "ϵ", eqcirc: "≖", eqcolon: "≕", eqsim: "≂", eqslantgtr: "⪖", eqslantless: "⪕", Equal: "⩵", equals: "=", EqualTilde: "≂", equest: "≟", Equilibrium: "⇌", equiv: "≡", equivDD: "⩸", eqvparsl: "⧥", erarr: "⥱", erDot: "≓", escr: "ℯ", Escr: "ℰ", esdot: "≐", Esim: "⩳", esim: "≂", Eta: "Η", eta: "η", ETH: "Ð", eth: "ð", Euml: "Ë", euml: "ë", euro: "€", excl: "!", exist: "∃", Exists: "∃", expectation: "ℰ", exponentiale: "ⅇ", ExponentialE: "ⅇ", fallingdotseq: "≒", Fcy: "Ф", fcy: "ф", female: "♀", ffilig: "ffi", fflig: "ff", ffllig: "ffl", Ffr: "𝔉", ffr: "𝔣", filig: "fi", FilledSmallSquare: "◼", FilledVerySmallSquare: "▪", fjlig: "fj", flat: "♭", fllig: "fl", fltns: "▱", fnof: "ƒ", Fopf: "𝔽", fopf: "𝕗", forall: "∀", ForAll: "∀", fork: "⋔", forkv: "⫙", Fouriertrf: "ℱ", fpartint: "⨍", frac12: "½", frac13: "⅓", frac14: "¼", frac15: "⅕", frac16: "⅙", frac18: "⅛", frac23: "⅔", frac25: "⅖", frac34: "¾", frac35: "⅗", frac38: "⅜", frac45: "⅘", frac56: "⅚", frac58: "⅝", frac78: "⅞", frasl: "⁄", frown: "⌢", fscr: "𝒻", Fscr: "ℱ", gacute: "ǵ", Gamma: "Γ", gamma: "γ", Gammad: "Ϝ", gammad: "ϝ", gap: "⪆", Gbreve: "Ğ", gbreve: "ğ", Gcedil: "Ģ", Gcirc: "Ĝ", gcirc: "ĝ", Gcy: "Г", gcy: "г", Gdot: "Ġ", gdot: "ġ", ge: "≥", gE: "≧", gEl: "⪌", gel: "⋛", geq: "≥", geqq: "≧", geqslant: "⩾", gescc: "⪩", ges: "⩾", gesdot: "⪀", gesdoto: "⪂", gesdotol: "⪄", gesl: "⋛︀", gesles: "⪔", Gfr: "𝔊", gfr: "𝔤", gg: "≫", Gg: "⋙", ggg: "⋙", gimel: "ℷ", GJcy: "Ѓ", gjcy: "ѓ", gla: "⪥", gl: "≷", glE: "⪒", glj: "⪤", gnap: "⪊", gnapprox: "⪊", gne: "⪈", gnE: "≩", gneq: "⪈", gneqq: "≩", gnsim: "⋧", Gopf: "𝔾", gopf: "𝕘", grave: "`", GreaterEqual: "≥", GreaterEqualLess: "⋛", GreaterFullEqual: "≧", GreaterGreater: "⪢", GreaterLess: "≷", GreaterSlantEqual: "⩾", GreaterTilde: "≳", Gscr: "𝒢", gscr: "ℊ", gsim: "≳", gsime: "⪎", gsiml: "⪐", gtcc: "⪧", gtcir: "⩺", gt: ">", GT: ">", Gt: "≫", gtdot: "⋗", gtlPar: "⦕", gtquest: "⩼", gtrapprox: "⪆", gtrarr: "⥸", gtrdot: "⋗", gtreqless: "⋛", gtreqqless: "⪌", gtrless: "≷", gtrsim: "≳", gvertneqq: "≩︀", gvnE: "≩︀", Hacek: "ˇ", hairsp: " ", half: "½", hamilt: "ℋ", HARDcy: "Ъ", hardcy: "ъ", harrcir: "⥈", harr: "↔", hArr: "⇔", harrw: "↭", Hat: "^", hbar: "ℏ", Hcirc: "Ĥ", hcirc: "ĥ", hearts: "♥", heartsuit: "♥", hellip: "…", hercon: "⊹", hfr: "𝔥", Hfr: "ℌ", HilbertSpace: "ℋ", hksearow: "⤥", hkswarow: "⤦", hoarr: "⇿", homtht: "∻", hookleftarrow: "↩", hookrightarrow: "↪", hopf: "𝕙", Hopf: "ℍ", horbar: "―", HorizontalLine: "─", hscr: "𝒽", Hscr: "ℋ", hslash: "ℏ", Hstrok: "Ħ", hstrok: "ħ", HumpDownHump: "≎", HumpEqual: "≏", hybull: "⁃", hyphen: "‐", Iacute: "Í", iacute: "í", ic: "\u2063", Icirc: "Î", icirc: "î", Icy: "И", icy: "и", Idot: "İ", IEcy: "Е", iecy: "е", iexcl: "¡", iff: "⇔", ifr: "𝔦", Ifr: "ℑ", Igrave: "Ì", igrave: "ì", ii: "ⅈ", iiiint: "⨌", iiint: "∭", iinfin: "⧜", iiota: "℩", IJlig: "IJ", ijlig: "ij", Imacr: "Ī", imacr: "ī", image: "ℑ", ImaginaryI: "ⅈ", imagline: "ℐ", imagpart: "ℑ", imath: "ı", Im: "ℑ", imof: "⊷", imped: "Ƶ", Implies: "⇒", incare: "℅", in: "∈", infin: "∞", infintie: "⧝", inodot: "ı", intcal: "⊺", int: "∫", Int: "∬", integers: "ℤ", Integral: "∫", intercal: "⊺", Intersection: "⋂", intlarhk: "⨗", intprod: "⨼", InvisibleComma: "\u2063", InvisibleTimes: "\u2062", IOcy: "Ё", iocy: "ё", Iogon: "Į", iogon: "į", Iopf: "𝕀", iopf: "𝕚", Iota: "Ι", iota: "ι", iprod: "⨼", iquest: "¿", iscr: "𝒾", Iscr: "ℐ", isin: "∈", isindot: "⋵", isinE: "⋹", isins: "⋴", isinsv: "⋳", isinv: "∈", it: "\u2062", Itilde: "Ĩ", itilde: "ĩ", Iukcy: "І", iukcy: "і", Iuml: "Ï", iuml: "ï", Jcirc: "Ĵ", jcirc: "ĵ", Jcy: "Й", jcy: "й", Jfr: "𝔍", jfr: "𝔧", jmath: "ȷ", Jopf: "𝕁", jopf: "𝕛", Jscr: "𝒥", jscr: "𝒿", Jsercy: "Ј", jsercy: "ј", Jukcy: "Є", jukcy: "є", Kappa: "Κ", kappa: "κ", kappav: "ϰ", Kcedil: "Ķ", kcedil: "ķ", Kcy: "К", kcy: "к", Kfr: "𝔎", kfr: "𝔨", kgreen: "ĸ", KHcy: "Х", khcy: "х", KJcy: "Ќ", kjcy: "ќ", Kopf: "𝕂", kopf: "𝕜", Kscr: "𝒦", kscr: "𝓀", lAarr: "⇚", Lacute: "Ĺ", lacute: "ĺ", laemptyv: "⦴", lagran: "ℒ", Lambda: "Λ", lambda: "λ", lang: "⟨", Lang: "⟪", langd: "⦑", langle: "⟨", lap: "⪅", Laplacetrf: "ℒ", laquo: "«", larrb: "⇤", larrbfs: "⤟", larr: "←", Larr: "↞", lArr: "⇐", larrfs: "⤝", larrhk: "↩", larrlp: "↫", larrpl: "⤹", larrsim: "⥳", larrtl: "↢", latail: "⤙", lAtail: "⤛", lat: "⪫", late: "⪭", lates: "⪭︀", lbarr: "⤌", lBarr: "⤎", lbbrk: "❲", lbrace: "{", lbrack: "[", lbrke: "⦋", lbrksld: "⦏", lbrkslu: "⦍", Lcaron: "Ľ", lcaron: "ľ", Lcedil: "Ļ", lcedil: "ļ", lceil: "⌈", lcub: "{", Lcy: "Л", lcy: "л", ldca: "⤶", ldquo: "“", ldquor: "„", ldrdhar: "⥧", ldrushar: "⥋", ldsh: "↲", le: "≤", lE: "≦", LeftAngleBracket: "⟨", LeftArrowBar: "⇤", leftarrow: "←", LeftArrow: "←", Leftarrow: "⇐", LeftArrowRightArrow: "⇆", leftarrowtail: "↢", LeftCeiling: "⌈", LeftDoubleBracket: "⟦", LeftDownTeeVector: "⥡", LeftDownVectorBar: "⥙", LeftDownVector: "⇃", LeftFloor: "⌊", leftharpoondown: "↽", leftharpoonup: "↼", leftleftarrows: "⇇", leftrightarrow: "↔", LeftRightArrow: "↔", Leftrightarrow: "⇔", leftrightarrows: "⇆", leftrightharpoons: "⇋", leftrightsquigarrow: "↭", LeftRightVector: "⥎", LeftTeeArrow: "↤", LeftTee: "⊣", LeftTeeVector: "⥚", leftthreetimes: "⋋", LeftTriangleBar: "⧏", LeftTriangle: "⊲", LeftTriangleEqual: "⊴", LeftUpDownVector: "⥑", LeftUpTeeVector: "⥠", LeftUpVectorBar: "⥘", LeftUpVector: "↿", LeftVectorBar: "⥒", LeftVector: "↼", lEg: "⪋", leg: "⋚", leq: "≤", leqq: "≦", leqslant: "⩽", lescc: "⪨", les: "⩽", lesdot: "⩿", lesdoto: "⪁", lesdotor: "⪃", lesg: "⋚︀", lesges: "⪓", lessapprox: "⪅", lessdot: "⋖", lesseqgtr: "⋚", lesseqqgtr: "⪋", LessEqualGreater: "⋚", LessFullEqual: "≦", LessGreater: "≶", lessgtr: "≶", LessLess: "⪡", lesssim: "≲", LessSlantEqual: "⩽", LessTilde: "≲", lfisht: "⥼", lfloor: "⌊", Lfr: "𝔏", lfr: "𝔩", lg: "≶", lgE: "⪑", lHar: "⥢", lhard: "↽", lharu: "↼", lharul: "⥪", lhblk: "▄", LJcy: "Љ", ljcy: "љ", llarr: "⇇", ll: "≪", Ll: "⋘", llcorner: "⌞", Lleftarrow: "⇚", llhard: "⥫", lltri: "◺", Lmidot: "Ŀ", lmidot: "ŀ", lmoustache: "⎰", lmoust: "⎰", lnap: "⪉", lnapprox: "⪉", lne: "⪇", lnE: "≨", lneq: "⪇", lneqq: "≨", lnsim: "⋦", loang: "⟬", loarr: "⇽", lobrk: "⟦", longleftarrow: "⟵", LongLeftArrow: "⟵", Longleftarrow: "⟸", longleftrightarrow: "⟷", LongLeftRightArrow: "⟷", Longleftrightarrow: "⟺", longmapsto: "⟼", longrightarrow: "⟶", LongRightArrow: "⟶", Longrightarrow: "⟹", looparrowleft: "↫", looparrowright: "↬", lopar: "⦅", Lopf: "𝕃", lopf: "𝕝", loplus: "⨭", lotimes: "⨴", lowast: "∗", lowbar: "_", LowerLeftArrow: "↙", LowerRightArrow: "↘", loz: "◊", lozenge: "◊", lozf: "⧫", lpar: "(", lparlt: "⦓", lrarr: "⇆", lrcorner: "⌟", lrhar: "⇋", lrhard: "⥭", lrm: "\u200e", lrtri: "⊿", lsaquo: "‹", lscr: "𝓁", Lscr: "ℒ", lsh: "↰", Lsh: "↰", lsim: "≲", lsime: "⪍", lsimg: "⪏", lsqb: "[", lsquo: "‘", lsquor: "‚", Lstrok: "Ł", lstrok: "ł", ltcc: "⪦", ltcir: "⩹", lt: "<", LT: "<", Lt: "≪", ltdot: "⋖", lthree: "⋋", ltimes: "⋉", ltlarr: "⥶", ltquest: "⩻", ltri: "◃", ltrie: "⊴", ltrif: "◂", ltrPar: "⦖", lurdshar: "⥊", luruhar: "⥦", lvertneqq: "≨︀", lvnE: "≨︀", macr: "¯", male: "♂", malt: "✠", maltese: "✠", Map: "⤅", map: "↦", mapsto: "↦", mapstodown: "↧", mapstoleft: "↤", mapstoup: "↥", marker: "▮", mcomma: "⨩", Mcy: "М", mcy: "м", mdash: "—", mDDot: "∺", measuredangle: "∡", MediumSpace: " ", Mellintrf: "ℳ", Mfr: "𝔐", mfr: "𝔪", mho: "℧", micro: "µ", midast: "*", midcir: "⫰", mid: "∣", middot: "·", minusb: "⊟", minus: "−", minusd: "∸", minusdu: "⨪", MinusPlus: "∓", mlcp: "⫛", mldr: "…", mnplus: "∓", models: "⊧", Mopf: "𝕄", mopf: "𝕞", mp: "∓", mscr: "𝓂", Mscr: "ℳ", mstpos: "∾", Mu: "Μ", mu: "μ", multimap: "⊸", mumap: "⊸", nabla: "∇", Nacute: "Ń", nacute: "ń", nang: "∠⃒", nap: "≉", napE: "⩰̸", napid: "≋̸", napos: "ʼn", napprox: "≉", natural: "♮", naturals: "ℕ", natur: "♮", nbsp: " ", nbump: "≎̸", nbumpe: "≏̸", ncap: "⩃", Ncaron: "Ň", ncaron: "ň", Ncedil: "Ņ", ncedil: "ņ", ncong: "≇", ncongdot: "⩭̸", ncup: "⩂", Ncy: "Н", ncy: "н", ndash: "–", nearhk: "⤤", nearr: "↗", neArr: "⇗", nearrow: "↗", ne: "≠", nedot: "≐̸", NegativeMediumSpace: "", NegativeThickSpace: "", NegativeThinSpace: "", NegativeVeryThinSpace: "", nequiv: "≢", nesear: "⤨", nesim: "≂̸", NestedGreaterGreater: "≫", NestedLessLess: "≪", NewLine: "\u000a", nexist: "∄", nexists: "∄", Nfr: "𝔑", nfr: "𝔫", ngE: "≧̸", nge: "≱", ngeq: "≱", ngeqq: "≧̸", ngeqslant: "⩾̸", nges: "⩾̸", nGg: "⋙̸", ngsim: "≵", nGt: "≫⃒", ngt: "≯", ngtr: "≯", nGtv: "≫̸", nharr: "↮", nhArr: "⇎", nhpar: "⫲", ni: "∋", nis: "⋼", nisd: "⋺", niv: "∋", NJcy: "Њ", njcy: "њ", nlarr: "↚", nlArr: "⇍", nldr: "‥", nlE: "≦̸", nle: "≰", nleftarrow: "↚", nLeftarrow: "⇍", nleftrightarrow: "↮", nLeftrightarrow: "⇎", nleq: "≰", nleqq: "≦̸", nleqslant: "⩽̸", nles: "⩽̸", nless: "≮", nLl: "⋘̸", nlsim: "≴", nLt: "≪⃒", nlt: "≮", nltri: "⋪", nltrie: "⋬", nLtv: "≪̸", nmid: "∤", NoBreak: "\u2060", NonBreakingSpace: " ", nopf: "𝕟", Nopf: "ℕ", Not: "⫬", not: "¬", NotCongruent: "≢", NotCupCap: "≭", NotDoubleVerticalBar: "∦", NotElement: "∉", NotEqual: "≠", NotEqualTilde: "≂̸", NotExists: "∄", NotGreater: "≯", NotGreaterEqual: "≱", NotGreaterFullEqual: "≧̸", NotGreaterGreater: "≫̸", NotGreaterLess: "≹", NotGreaterSlantEqual: "⩾̸", NotGreaterTilde: "≵", NotHumpDownHump: "≎̸", NotHumpEqual: "≏̸", notin: "∉", notindot: "⋵̸", notinE: "⋹̸", notinva: "∉", notinvb: "⋷", notinvc: "⋶", NotLeftTriangleBar: "⧏̸", NotLeftTriangle: "⋪", NotLeftTriangleEqual: "⋬", NotLess: "≮", NotLessEqual: "≰", NotLessGreater: "≸", NotLessLess: "≪̸", NotLessSlantEqual: "⩽̸", NotLessTilde: "≴", NotNestedGreaterGreater: "⪢̸", NotNestedLessLess: "⪡̸", notni: "∌", notniva: "∌", notnivb: "⋾", notnivc: "⋽", NotPrecedes: "⊀", NotPrecedesEqual: "⪯̸", NotPrecedesSlantEqual: "⋠", NotReverseElement: "∌", NotRightTriangleBar: "⧐̸", NotRightTriangle: "⋫", NotRightTriangleEqual: "⋭", NotSquareSubset: "⊏̸", NotSquareSubsetEqual: "⋢", NotSquareSuperset: "⊐̸", NotSquareSupersetEqual: "⋣", NotSubset: "⊂⃒", NotSubsetEqual: "⊈", NotSucceeds: "⊁", NotSucceedsEqual: "⪰̸", NotSucceedsSlantEqual: "⋡", NotSucceedsTilde: "≿̸", NotSuperset: "⊃⃒", NotSupersetEqual: "⊉", NotTilde: "≁", NotTildeEqual: "≄", NotTildeFullEqual: "≇", NotTildeTilde: "≉", NotVerticalBar: "∤", nparallel: "∦", npar: "∦", nparsl: "⫽⃥", npart: "∂̸", npolint: "⨔", npr: "⊀", nprcue: "⋠", nprec: "⊀", npreceq: "⪯̸", npre: "⪯̸", nrarrc: "⤳̸", nrarr: "↛", nrArr: "⇏", nrarrw: "↝̸", nrightarrow: "↛", nRightarrow: "⇏", nrtri: "⋫", nrtrie: "⋭", nsc: "⊁", nsccue: "⋡", nsce: "⪰̸", Nscr: "𝒩", nscr: "𝓃", nshortmid: "∤", nshortparallel: "∦", nsim: "≁", nsime: "≄", nsimeq: "≄", nsmid: "∤", nspar: "∦", nsqsube: "⋢", nsqsupe: "⋣", nsub: "⊄", nsubE: "⫅̸", nsube: "⊈", nsubset: "⊂⃒", nsubseteq: "⊈", nsubseteqq: "⫅̸", nsucc: "⊁", nsucceq: "⪰̸", nsup: "⊅", nsupE: "⫆̸", nsupe: "⊉", nsupset: "⊃⃒", nsupseteq: "⊉", nsupseteqq: "⫆̸", ntgl: "≹", Ntilde: "Ñ", ntilde: "ñ", ntlg: "≸", ntriangleleft: "⋪", ntrianglelefteq: "⋬", ntriangleright: "⋫", ntrianglerighteq: "⋭", Nu: "Ν", nu: "ν", num: "#", numero: "№", numsp: " ", nvap: "≍⃒", nvdash: "⊬", nvDash: "⊭", nVdash: "⊮", nVDash: "⊯", nvge: "≥⃒", nvgt: ">⃒", nvHarr: "⤄", nvinfin: "⧞", nvlArr: "⤂", nvle: "≤⃒", nvlt: "<⃒", nvltrie: "⊴⃒", nvrArr: "⤃", nvrtrie: "⊵⃒", nvsim: "∼⃒", nwarhk: "⤣", nwarr: "↖", nwArr: "⇖", nwarrow: "↖", nwnear: "⤧", Oacute: "Ó", oacute: "ó", oast: "⊛", Ocirc: "Ô", ocirc: "ô", ocir: "⊚", Ocy: "О", ocy: "о", odash: "⊝", Odblac: "Ő", odblac: "ő", odiv: "⨸", odot: "⊙", odsold: "⦼", OElig: "Œ", oelig: "œ", ofcir: "⦿", Ofr: "𝔒", ofr: "𝔬", ogon: "˛", Ograve: "Ò", ograve: "ò", ogt: "⧁", ohbar: "⦵", ohm: "Ω", oint: "∮", olarr: "↺", olcir: "⦾", olcross: "⦻", oline: "‾", olt: "⧀", Omacr: "Ō", omacr: "ō", Omega: "Ω", omega: "ω", Omicron: "Ο", omicron: "ο", omid: "⦶", ominus: "⊖", Oopf: "𝕆", oopf: "𝕠", opar: "⦷", OpenCurlyDoubleQuote: "“", OpenCurlyQuote: "‘", operp: "⦹", oplus: "⊕", orarr: "↻", Or: "⩔", or: "∨", ord: "⩝", order: "ℴ", orderof: "ℴ", ordf: "ª", ordm: "º", origof: "⊶", oror: "⩖", orslope: "⩗", orv: "⩛", oS: "Ⓢ", Oscr: "𝒪", oscr: "ℴ", Oslash: "Ø", oslash: "ø", osol: "⊘", Otilde: "Õ", otilde: "õ", otimesas: "⨶", Otimes: "⨷", otimes: "⊗", Ouml: "Ö", ouml: "ö", ovbar: "⌽", OverBar: "‾", OverBrace: "⏞", OverBracket: "⎴", OverParenthesis: "⏜", para: "¶", parallel: "∥", par: "∥", parsim: "⫳", parsl: "⫽", part: "∂", PartialD: "∂", Pcy: "П", pcy: "п", percnt: "%", period: ".", permil: "‰", perp: "⊥", pertenk: "‱", Pfr: "𝔓", pfr: "𝔭", Phi: "Φ", phi: "φ", phiv: "ϕ", phmmat: "ℳ", phone: "☎", Pi: "Π", pi: "π", pitchfork: "⋔", piv: "ϖ", planck: "ℏ", planckh: "ℎ", plankv: "ℏ", plusacir: "⨣", plusb: "⊞", pluscir: "⨢", plus: "+", plusdo: "∔", plusdu: "⨥", pluse: "⩲", PlusMinus: "±", plusmn: "±", plussim: "⨦", plustwo: "⨧", pm: "±", Poincareplane: "ℌ", pointint: "⨕", popf: "𝕡", Popf: "ℙ", pound: "£", prap: "⪷", Pr: "⪻", pr: "≺", prcue: "≼", precapprox: "⪷", prec: "≺", preccurlyeq: "≼", Precedes: "≺", PrecedesEqual: "⪯", PrecedesSlantEqual: "≼", PrecedesTilde: "≾", preceq: "⪯", precnapprox: "⪹", precneqq: "⪵", precnsim: "⋨", pre: "⪯", prE: "⪳", precsim: "≾", prime: "′", Prime: "″", primes: "ℙ", prnap: "⪹", prnE: "⪵", prnsim: "⋨", prod: "∏", Product: "∏", profalar: "⌮", profline: "⌒", profsurf: "⌓", prop: "∝", Proportional: "∝", Proportion: "∷", propto: "∝", prsim: "≾", prurel: "⊰", Pscr: "𝒫", pscr: "𝓅", Psi: "Ψ", psi: "ψ", puncsp: " ", Qfr: "𝔔", qfr: "𝔮", qint: "⨌", qopf: "𝕢", Qopf: "ℚ", qprime: "⁗", Qscr: "𝒬", qscr: "𝓆", quaternions: "ℍ", quatint: "⨖", quest: "?", questeq: "≟", quot: "\"", QUOT: "\"", rAarr: "⇛", race: "∽̱", Racute: "Ŕ", racute: "ŕ", radic: "√", raemptyv: "⦳", rang: "⟩", Rang: "⟫", rangd: "⦒", range: "⦥", rangle: "⟩", raquo: "»", rarrap: "⥵", rarrb: "⇥", rarrbfs: "⤠", rarrc: "⤳", rarr: "→", Rarr: "↠", rArr: "⇒", rarrfs: "⤞", rarrhk: "↪", rarrlp: "↬", rarrpl: "⥅", rarrsim: "⥴", Rarrtl: "⤖", rarrtl: "↣", rarrw: "↝", ratail: "⤚", rAtail: "⤜", ratio: "∶", rationals: "ℚ", rbarr: "⤍", rBarr: "⤏", RBarr: "⤐", rbbrk: "❳", rbrace: "}", rbrack: "]", rbrke: "⦌", rbrksld: "⦎", rbrkslu: "⦐", Rcaron: "Ř", rcaron: "ř", Rcedil: "Ŗ", rcedil: "ŗ", rceil: "⌉", rcub: "}", Rcy: "Р", rcy: "р", rdca: "⤷", rdldhar: "⥩", rdquo: "”", rdquor: "”", rdsh: "↳", real: "ℜ", realine: "ℛ", realpart: "ℜ", reals: "ℝ", Re: "ℜ", rect: "▭", reg: "®", REG: "®", ReverseElement: "∋", ReverseEquilibrium: "⇋", ReverseUpEquilibrium: "⥯", rfisht: "⥽", rfloor: "⌋", rfr: "𝔯", Rfr: "ℜ", rHar: "⥤", rhard: "⇁", rharu: "⇀", rharul: "⥬", Rho: "Ρ", rho: "ρ", rhov: "ϱ", RightAngleBracket: "⟩", RightArrowBar: "⇥", rightarrow: "→", RightArrow: "→", Rightarrow: "⇒", RightArrowLeftArrow: "⇄", rightarrowtail: "↣", RightCeiling: "⌉", RightDoubleBracket: "⟧", RightDownTeeVector: "⥝", RightDownVectorBar: "⥕", RightDownVector: "⇂", RightFloor: "⌋", rightharpoondown: "⇁", rightharpoonup: "⇀", rightleftarrows: "⇄", rightleftharpoons: "⇌", rightrightarrows: "⇉", rightsquigarrow: "↝", RightTeeArrow: "↦", RightTee: "⊢", RightTeeVector: "⥛", rightthreetimes: "⋌", RightTriangleBar: "⧐", RightTriangle: "⊳", RightTriangleEqual: "⊵", RightUpDownVector: "⥏", RightUpTeeVector: "⥜", RightUpVectorBar: "⥔", RightUpVector: "↾", RightVectorBar: "⥓", RightVector: "⇀", ring: "˚", risingdotseq: "≓", rlarr: "⇄", rlhar: "⇌", rlm: "\u200f", rmoustache: "⎱", rmoust: "⎱", rnmid: "⫮", roang: "⟭", roarr: "⇾", robrk: "⟧", ropar: "⦆", ropf: "𝕣", Ropf: "ℝ", roplus: "⨮", rotimes: "⨵", RoundImplies: "⥰", rpar: ")", rpargt: "⦔", rppolint: "⨒", rrarr: "⇉", Rrightarrow: "⇛", rsaquo: "›", rscr: "𝓇", Rscr: "ℛ", rsh: "↱", Rsh: "↱", rsqb: "]", rsquo: "’", rsquor: "’", rthree: "⋌", rtimes: "⋊", rtri: "▹", rtrie: "⊵", rtrif: "▸", rtriltri: "⧎", RuleDelayed: "⧴", ruluhar: "⥨", rx: "℞", Sacute: "Ś", sacute: "ś", sbquo: "‚", scap: "⪸", Scaron: "Š", scaron: "š", Sc: "⪼", sc: "≻", sccue: "≽", sce: "⪰", scE: "⪴", Scedil: "Ş", scedil: "ş", Scirc: "Ŝ", scirc: "ŝ", scnap: "⪺", scnE: "⪶", scnsim: "⋩", scpolint: "⨓", scsim: "≿", Scy: "С", scy: "с", sdotb: "⊡", sdot: "⋅", sdote: "⩦", searhk: "⤥", searr: "↘", seArr: "⇘", searrow: "↘", sect: "§", semi: ";", seswar: "⤩", setminus: "∖", setmn: "∖", sext: "✶", Sfr: "𝔖", sfr: "𝔰", sfrown: "⌢", sharp: "♯", SHCHcy: "Щ", shchcy: "щ", SHcy: "Ш", shcy: "ш", ShortDownArrow: "↓", ShortLeftArrow: "←", shortmid: "∣", shortparallel: "∥", ShortRightArrow: "→", ShortUpArrow: "↑", shy: "\u00ad", Sigma: "Σ", sigma: "σ", sigmaf: "ς", sigmav: "ς", sim: "∼", simdot: "⩪", sime: "≃", simeq: "≃", simg: "⪞", simgE: "⪠", siml: "⪝", simlE: "⪟", simne: "≆", simplus: "⨤", simrarr: "⥲", slarr: "←", SmallCircle: "∘", smallsetminus: "∖", smashp: "⨳", smeparsl: "⧤", smid: "∣", smile: "⌣", smt: "⪪", smte: "⪬", smtes: "⪬︀", SOFTcy: "Ь", softcy: "ь", solbar: "⌿", solb: "⧄", sol: "/", Sopf: "𝕊", sopf: "𝕤", spades: "♠", spadesuit: "♠", spar: "∥", sqcap: "⊓", sqcaps: "⊓︀", sqcup: "⊔", sqcups: "⊔︀", Sqrt: "√", sqsub: "⊏", sqsube: "⊑", sqsubset: "⊏", sqsubseteq: "⊑", sqsup: "⊐", sqsupe: "⊒", sqsupset: "⊐", sqsupseteq: "⊒", square: "□", Square: "□", SquareIntersection: "⊓", SquareSubset: "⊏", SquareSubsetEqual: "⊑", SquareSuperset: "⊐", SquareSupersetEqual: "⊒", SquareUnion: "⊔", squarf: "▪", squ: "□", squf: "▪", srarr: "→", Sscr: "𝒮", sscr: "𝓈", ssetmn: "∖", ssmile: "⌣", sstarf: "⋆", Star: "⋆", star: "☆", starf: "★", straightepsilon: "ϵ", straightphi: "ϕ", strns: "¯", sub: "⊂", Sub: "⋐", subdot: "⪽", subE: "⫅", sube: "⊆", subedot: "⫃", submult: "⫁", subnE: "⫋", subne: "⊊", subplus: "⪿", subrarr: "⥹", subset: "⊂", Subset: "⋐", subseteq: "⊆", subseteqq: "⫅", SubsetEqual: "⊆", subsetneq: "⊊", subsetneqq: "⫋", subsim: "⫇", subsub: "⫕", subsup: "⫓", succapprox: "⪸", succ: "≻", succcurlyeq: "≽", Succeeds: "≻", SucceedsEqual: "⪰", SucceedsSlantEqual: "≽", SucceedsTilde: "≿", succeq: "⪰", succnapprox: "⪺", succneqq: "⪶", succnsim: "⋩", succsim: "≿", SuchThat: "∋", sum: "∑", Sum: "∑", sung: "♪", sup1: "¹", sup2: "²", sup3: "³", sup: "⊃", Sup: "⋑", supdot: "⪾", supdsub: "⫘", supE: "⫆", supe: "⊇", supedot: "⫄", Superset: "⊃", SupersetEqual: "⊇", suphsol: "⟉", suphsub: "⫗", suplarr: "⥻", supmult: "⫂", supnE: "⫌", supne: "⊋", supplus: "⫀", supset: "⊃", Supset: "⋑", supseteq: "⊇", supseteqq: "⫆", supsetneq: "⊋", supsetneqq: "⫌", supsim: "⫈", supsub: "⫔", supsup: "⫖", swarhk: "⤦", swarr: "↙", swArr: "⇙", swarrow: "↙", swnwar: "⤪", szlig: "ß", Tab: "\u0009", target: "⌖", Tau: "Τ", tau: "τ", tbrk: "⎴", Tcaron: "Ť", tcaron: "ť", Tcedil: "Ţ", tcedil: "ţ", Tcy: "Т", tcy: "т", tdot: "⃛", telrec: "⌕", Tfr: "𝔗", tfr: "𝔱", there4: "∴", therefore: "∴", Therefore: "∴", Theta: "Θ", theta: "θ", thetasym: "ϑ", thetav: "ϑ", thickapprox: "≈", thicksim: "∼", ThickSpace: " ", ThinSpace: " ", thinsp: " ", thkap: "≈", thksim: "∼", THORN: "Þ", thorn: "þ", tilde: "˜", Tilde: "∼", TildeEqual: "≃", TildeFullEqual: "≅", TildeTilde: "≈", timesbar: "⨱", timesb: "⊠", times: "×", timesd: "⨰", tint: "∭", toea: "⤨", topbot: "⌶", topcir: "⫱", top: "⊤", Topf: "𝕋", topf: "𝕥", topfork: "⫚", tosa: "⤩", tprime: "‴", trade: "™", TRADE: "™", triangle: "▵", triangledown: "▿", triangleleft: "◃", trianglelefteq: "⊴", triangleq: "≜", triangleright: "▹", trianglerighteq: "⊵", tridot: "◬", trie: "≜", triminus: "⨺", TripleDot: "⃛", triplus: "⨹", trisb: "⧍", tritime: "⨻", trpezium: "⏢", Tscr: "𝒯", tscr: "𝓉", TScy: "Ц", tscy: "ц", TSHcy: "Ћ", tshcy: "ћ", Tstrok: "Ŧ", tstrok: "ŧ", twixt: "≬", twoheadleftarrow: "↞", twoheadrightarrow: "↠", Uacute: "Ú", uacute: "ú", uarr: "↑", Uarr: "↟", uArr: "⇑", Uarrocir: "⥉", Ubrcy: "Ў", ubrcy: "ў", Ubreve: "Ŭ", ubreve: "ŭ", Ucirc: "Û", ucirc: "û", Ucy: "У", ucy: "у", udarr: "⇅", Udblac: "Ű", udblac: "ű", udhar: "⥮", ufisht: "⥾", Ufr: "𝔘", ufr: "𝔲", Ugrave: "Ù", ugrave: "ù", uHar: "⥣", uharl: "↿", uharr: "↾", uhblk: "▀", ulcorn: "⌜", ulcorner: "⌜", ulcrop: "⌏", ultri: "◸", Umacr: "Ū", umacr: "ū", uml: "¨", UnderBar: "_", UnderBrace: "⏟", UnderBracket: "⎵", UnderParenthesis: "⏝", Union: "⋃", UnionPlus: "⊎", Uogon: "Ų", uogon: "ų", Uopf: "𝕌", uopf: "𝕦", UpArrowBar: "⤒", uparrow: "↑", UpArrow: "↑", Uparrow: "⇑", UpArrowDownArrow: "⇅", updownarrow: "↕", UpDownArrow: "↕", Updownarrow: "⇕", UpEquilibrium: "⥮", upharpoonleft: "↿", upharpoonright: "↾", uplus: "⊎", UpperLeftArrow: "↖", UpperRightArrow: "↗", upsi: "υ", Upsi: "ϒ", upsih: "ϒ", Upsilon: "Υ", upsilon: "υ", UpTeeArrow: "↥", UpTee: "⊥", upuparrows: "⇈", urcorn: "⌝", urcorner: "⌝", urcrop: "⌎", Uring: "Ů", uring: "ů", urtri: "◹", Uscr: "𝒰", uscr: "𝓊", utdot: "⋰", Utilde: "Ũ", utilde: "ũ", utri: "▵", utrif: "▴", uuarr: "⇈", Uuml: "Ü", uuml: "ü", uwangle: "⦧", vangrt: "⦜", varepsilon: "ϵ", varkappa: "ϰ", varnothing: "∅", varphi: "ϕ", varpi: "ϖ", varpropto: "∝", varr: "↕", vArr: "⇕", varrho: "ϱ", varsigma: "ς", varsubsetneq: "⊊︀", varsubsetneqq: "⫋︀", varsupsetneq: "⊋︀", varsupsetneqq: "⫌︀", vartheta: "ϑ", vartriangleleft: "⊲", vartriangleright: "⊳", vBar: "⫨", Vbar: "⫫", vBarv: "⫩", Vcy: "В", vcy: "в", vdash: "⊢", vDash: "⊨", Vdash: "⊩", VDash: "⊫", Vdashl: "⫦", veebar: "⊻", vee: "∨", Vee: "⋁", veeeq: "≚", vellip: "⋮", verbar: "|", Verbar: "‖", vert: "|", Vert: "‖", VerticalBar: "∣", VerticalLine: "|", VerticalSeparator: "❘", VerticalTilde: "≀", VeryThinSpace: " ", Vfr: "𝔙", vfr: "𝔳", vltri: "⊲", vnsub: "⊂⃒", vnsup: "⊃⃒", Vopf: "𝕍", vopf: "𝕧", vprop: "∝", vrtri: "⊳", Vscr: "𝒱", vscr: "𝓋", vsubnE: "⫋︀", vsubne: "⊊︀", vsupnE: "⫌︀", vsupne: "⊋︀", Vvdash: "⊪", vzigzag: "⦚", Wcirc: "Ŵ", wcirc: "ŵ", wedbar: "⩟", wedge: "∧", Wedge: "⋀", wedgeq: "≙", weierp: "℘", Wfr: "𝔚", wfr: "𝔴", Wopf: "𝕎", wopf: "𝕨", wp: "℘", wr: "≀", wreath: "≀", Wscr: "𝒲", wscr: "𝓌", xcap: "⋂", xcirc: "◯", xcup: "⋃", xdtri: "▽", Xfr: "𝔛", xfr: "𝔵", xharr: "⟷", xhArr: "⟺", Xi: "Ξ", xi: "ξ", xlarr: "⟵", xlArr: "⟸", xmap: "⟼", xnis: "⋻", xodot: "⨀", Xopf: "𝕏", xopf: "𝕩", xoplus: "⨁", xotime: "⨂", xrarr: "⟶", xrArr: "⟹", Xscr: "𝒳", xscr: "𝓍", xsqcup: "⨆", xuplus: "⨄", xutri: "△", xvee: "⋁", xwedge: "⋀", Yacute: "Ý", yacute: "ý", YAcy: "Я", yacy: "я", Ycirc: "Ŷ", ycirc: "ŷ", Ycy: "Ы", ycy: "ы", yen: "¥", Yfr: "𝔜", yfr: "𝔶", YIcy: "Ї", yicy: "ї", Yopf: "𝕐", yopf: "𝕪", Yscr: "𝒴", yscr: "𝓎", YUcy: "Ю", yucy: "ю", yuml: "ÿ", Yuml: "Ÿ", Zacute: "Ź", zacute: "ź", Zcaron: "Ž", zcaron: "ž", Zcy: "З", zcy: "з", Zdot: "Ż", zdot: "ż", zeetrf: "ℨ", ZeroWidthSpace: "", Zeta: "Ζ", zeta: "ζ", zfr: "𝔷", Zfr: "ℨ", ZHcy: "Ж", zhcy: "ж", zigrarr: "⇝", zopf: "𝕫", Zopf: "ℤ", Zscr: "𝒵", zscr: "𝓏", zwj: "\u200d", zwnj: "\u200c" |
|
8761 }; |
|
8762 |
|
8763 var HEXCHARCODE = /^#[xX]([A-Fa-f0-9]+)$/; |
|
8764 var CHARCODE = /^#([0-9]+)$/; |
|
8765 var NAMED = /^([A-Za-z0-9]+)$/; |
|
8766 var EntityParser = /** @class */ (function () { |
|
8767 function EntityParser(named) { |
|
8768 this.named = named; |
|
8769 } |
|
8770 EntityParser.prototype.parse = function (entity) { |
|
8771 if (!entity) { |
|
8772 return; |
|
8773 } |
|
8774 var matches = entity.match(HEXCHARCODE); |
|
8775 if (matches) { |
|
8776 return String.fromCharCode(parseInt(matches[1], 16)); |
|
8777 } |
|
8778 matches = entity.match(CHARCODE); |
|
8779 if (matches) { |
|
8780 return String.fromCharCode(parseInt(matches[1], 10)); |
|
8781 } |
|
8782 matches = entity.match(NAMED); |
|
8783 if (matches) { |
|
8784 return this.named[matches[1]]; |
|
8785 } |
|
8786 }; |
|
8787 return EntityParser; |
|
8788 }()); |
|
8789 |
|
8790 var WSP = /[\t\n\f ]/; |
|
8791 var ALPHA = /[A-Za-z]/; |
|
8792 var CRLF = /\r\n?/g; |
|
8793 function isSpace(char) { |
|
8794 return WSP.test(char); |
|
8795 } |
|
8796 function isAlpha(char) { |
|
8797 return ALPHA.test(char); |
|
8798 } |
|
8799 function preprocessInput(input) { |
|
8800 return input.replace(CRLF, '\n'); |
|
8801 } |
|
8802 |
|
8803 var EventedTokenizer = /** @class */ (function () { |
|
8804 function EventedTokenizer(delegate, entityParser, mode) { |
|
8805 if (mode === void 0) { mode = 'precompile'; } |
|
8806 this.delegate = delegate; |
|
8807 this.entityParser = entityParser; |
|
8808 this.mode = mode; |
|
8809 this.state = "beforeData" /* beforeData */; |
|
8810 this.line = -1; |
|
8811 this.column = -1; |
|
8812 this.input = ''; |
|
8813 this.index = -1; |
|
8814 this.tagNameBuffer = ''; |
|
8815 this.states = { |
|
8816 beforeData: function () { |
|
8817 var char = this.peek(); |
|
8818 if (char === '<' && !this.isIgnoredEndTag()) { |
|
8819 this.transitionTo("tagOpen" /* tagOpen */); |
|
8820 this.markTagStart(); |
|
8821 this.consume(); |
|
8822 } |
|
8823 else { |
|
8824 if (this.mode === 'precompile' && char === '\n') { |
|
8825 var tag = this.tagNameBuffer.toLowerCase(); |
|
8826 if (tag === 'pre' || tag === 'textarea') { |
|
8827 this.consume(); |
|
8828 } |
|
8829 } |
|
8830 this.transitionTo("data" /* data */); |
|
8831 this.delegate.beginData(); |
|
8832 } |
|
8833 }, |
|
8834 data: function () { |
|
8835 var char = this.peek(); |
|
8836 var tag = this.tagNameBuffer; |
|
8837 if (char === '<' && !this.isIgnoredEndTag()) { |
|
8838 this.delegate.finishData(); |
|
8839 this.transitionTo("tagOpen" /* tagOpen */); |
|
8840 this.markTagStart(); |
|
8841 this.consume(); |
|
8842 } |
|
8843 else if (char === '&' && tag !== 'script' && tag !== 'style') { |
|
8844 this.consume(); |
|
8845 this.delegate.appendToData(this.consumeCharRef() || '&'); |
|
8846 } |
|
8847 else { |
|
8848 this.consume(); |
|
8849 this.delegate.appendToData(char); |
|
8850 } |
|
8851 }, |
|
8852 tagOpen: function () { |
|
8853 var char = this.consume(); |
|
8854 if (char === '!') { |
|
8855 this.transitionTo("markupDeclarationOpen" /* markupDeclarationOpen */); |
|
8856 } |
|
8857 else if (char === '/') { |
|
8858 this.transitionTo("endTagOpen" /* endTagOpen */); |
|
8859 } |
|
8860 else if (char === '@' || char === ':' || isAlpha(char)) { |
|
8861 this.transitionTo("tagName" /* tagName */); |
|
8862 this.tagNameBuffer = ''; |
|
8863 this.delegate.beginStartTag(); |
|
8864 this.appendToTagName(char); |
|
8865 } |
|
8866 }, |
|
8867 markupDeclarationOpen: function () { |
|
8868 var char = this.consume(); |
|
8869 if (char === '-' && this.peek() === '-') { |
|
8870 this.consume(); |
|
8871 this.transitionTo("commentStart" /* commentStart */); |
|
8872 this.delegate.beginComment(); |
|
8873 } |
|
8874 else { |
|
8875 var maybeDoctype = char.toUpperCase() + this.input.substring(this.index, this.index + 6).toUpperCase(); |
|
8876 if (maybeDoctype === 'DOCTYPE') { |
|
8877 this.consume(); |
|
8878 this.consume(); |
|
8879 this.consume(); |
|
8880 this.consume(); |
|
8881 this.consume(); |
|
8882 this.consume(); |
|
8883 this.transitionTo("doctype" /* doctype */); |
|
8884 if (this.delegate.beginDoctype) |
|
8885 this.delegate.beginDoctype(); |
|
8886 } |
|
8887 } |
|
8888 }, |
|
8889 doctype: function () { |
|
8890 var char = this.consume(); |
|
8891 if (isSpace(char)) { |
|
8892 this.transitionTo("beforeDoctypeName" /* beforeDoctypeName */); |
|
8893 } |
|
8894 }, |
|
8895 beforeDoctypeName: function () { |
|
8896 var char = this.consume(); |
|
8897 if (isSpace(char)) { |
|
8898 return; |
|
8899 } |
|
8900 else { |
|
8901 this.transitionTo("doctypeName" /* doctypeName */); |
|
8902 if (this.delegate.appendToDoctypeName) |
|
8903 this.delegate.appendToDoctypeName(char.toLowerCase()); |
|
8904 } |
|
8905 }, |
|
8906 doctypeName: function () { |
|
8907 var char = this.consume(); |
|
8908 if (isSpace(char)) { |
|
8909 this.transitionTo("afterDoctypeName" /* afterDoctypeName */); |
|
8910 } |
|
8911 else if (char === '>') { |
|
8912 if (this.delegate.endDoctype) |
|
8913 this.delegate.endDoctype(); |
|
8914 this.transitionTo("beforeData" /* beforeData */); |
|
8915 } |
|
8916 else { |
|
8917 if (this.delegate.appendToDoctypeName) |
|
8918 this.delegate.appendToDoctypeName(char.toLowerCase()); |
|
8919 } |
|
8920 }, |
|
8921 afterDoctypeName: function () { |
|
8922 var char = this.consume(); |
|
8923 if (isSpace(char)) { |
|
8924 return; |
|
8925 } |
|
8926 else if (char === '>') { |
|
8927 if (this.delegate.endDoctype) |
|
8928 this.delegate.endDoctype(); |
|
8929 this.transitionTo("beforeData" /* beforeData */); |
|
8930 } |
|
8931 else { |
|
8932 var nextSixChars = char.toUpperCase() + this.input.substring(this.index, this.index + 5).toUpperCase(); |
|
8933 var isPublic = nextSixChars.toUpperCase() === 'PUBLIC'; |
|
8934 var isSystem = nextSixChars.toUpperCase() === 'SYSTEM'; |
|
8935 if (isPublic || isSystem) { |
|
8936 this.consume(); |
|
8937 this.consume(); |
|
8938 this.consume(); |
|
8939 this.consume(); |
|
8940 this.consume(); |
|
8941 this.consume(); |
|
8942 } |
|
8943 if (isPublic) { |
|
8944 this.transitionTo("afterDoctypePublicKeyword" /* afterDoctypePublicKeyword */); |
|
8945 } |
|
8946 else if (isSystem) { |
|
8947 this.transitionTo("afterDoctypeSystemKeyword" /* afterDoctypeSystemKeyword */); |
|
8948 } |
|
8949 } |
|
8950 }, |
|
8951 afterDoctypePublicKeyword: function () { |
|
8952 var char = this.peek(); |
|
8953 if (isSpace(char)) { |
|
8954 this.transitionTo("beforeDoctypePublicIdentifier" /* beforeDoctypePublicIdentifier */); |
|
8955 this.consume(); |
|
8956 } |
|
8957 else if (char === '"') { |
|
8958 this.transitionTo("doctypePublicIdentifierDoubleQuoted" /* doctypePublicIdentifierDoubleQuoted */); |
|
8959 this.consume(); |
|
8960 } |
|
8961 else if (char === "'") { |
|
8962 this.transitionTo("doctypePublicIdentifierSingleQuoted" /* doctypePublicIdentifierSingleQuoted */); |
|
8963 this.consume(); |
|
8964 } |
|
8965 else if (char === '>') { |
|
8966 this.consume(); |
|
8967 if (this.delegate.endDoctype) |
|
8968 this.delegate.endDoctype(); |
|
8969 this.transitionTo("beforeData" /* beforeData */); |
|
8970 } |
|
8971 }, |
|
8972 doctypePublicIdentifierDoubleQuoted: function () { |
|
8973 var char = this.consume(); |
|
8974 if (char === '"') { |
|
8975 this.transitionTo("afterDoctypePublicIdentifier" /* afterDoctypePublicIdentifier */); |
|
8976 } |
|
8977 else if (char === '>') { |
|
8978 if (this.delegate.endDoctype) |
|
8979 this.delegate.endDoctype(); |
|
8980 this.transitionTo("beforeData" /* beforeData */); |
|
8981 } |
|
8982 else { |
|
8983 if (this.delegate.appendToDoctypePublicIdentifier) |
|
8984 this.delegate.appendToDoctypePublicIdentifier(char); |
|
8985 } |
|
8986 }, |
|
8987 doctypePublicIdentifierSingleQuoted: function () { |
|
8988 var char = this.consume(); |
|
8989 if (char === "'") { |
|
8990 this.transitionTo("afterDoctypePublicIdentifier" /* afterDoctypePublicIdentifier */); |
|
8991 } |
|
8992 else if (char === '>') { |
|
8993 if (this.delegate.endDoctype) |
|
8994 this.delegate.endDoctype(); |
|
8995 this.transitionTo("beforeData" /* beforeData */); |
|
8996 } |
|
8997 else { |
|
8998 if (this.delegate.appendToDoctypePublicIdentifier) |
|
8999 this.delegate.appendToDoctypePublicIdentifier(char); |
|
9000 } |
|
9001 }, |
|
9002 afterDoctypePublicIdentifier: function () { |
|
9003 var char = this.consume(); |
|
9004 if (isSpace(char)) { |
|
9005 this.transitionTo("betweenDoctypePublicAndSystemIdentifiers" /* betweenDoctypePublicAndSystemIdentifiers */); |
|
9006 } |
|
9007 else if (char === '>') { |
|
9008 if (this.delegate.endDoctype) |
|
9009 this.delegate.endDoctype(); |
|
9010 this.transitionTo("beforeData" /* beforeData */); |
|
9011 } |
|
9012 else if (char === '"') { |
|
9013 this.transitionTo("doctypeSystemIdentifierDoubleQuoted" /* doctypeSystemIdentifierDoubleQuoted */); |
|
9014 } |
|
9015 else if (char === "'") { |
|
9016 this.transitionTo("doctypeSystemIdentifierSingleQuoted" /* doctypeSystemIdentifierSingleQuoted */); |
|
9017 } |
|
9018 }, |
|
9019 betweenDoctypePublicAndSystemIdentifiers: function () { |
|
9020 var char = this.consume(); |
|
9021 if (isSpace(char)) { |
|
9022 return; |
|
9023 } |
|
9024 else if (char === '>') { |
|
9025 if (this.delegate.endDoctype) |
|
9026 this.delegate.endDoctype(); |
|
9027 this.transitionTo("beforeData" /* beforeData */); |
|
9028 } |
|
9029 else if (char === '"') { |
|
9030 this.transitionTo("doctypeSystemIdentifierDoubleQuoted" /* doctypeSystemIdentifierDoubleQuoted */); |
|
9031 } |
|
9032 else if (char === "'") { |
|
9033 this.transitionTo("doctypeSystemIdentifierSingleQuoted" /* doctypeSystemIdentifierSingleQuoted */); |
|
9034 } |
|
9035 }, |
|
9036 doctypeSystemIdentifierDoubleQuoted: function () { |
|
9037 var char = this.consume(); |
|
9038 if (char === '"') { |
|
9039 this.transitionTo("afterDoctypeSystemIdentifier" /* afterDoctypeSystemIdentifier */); |
|
9040 } |
|
9041 else if (char === '>') { |
|
9042 if (this.delegate.endDoctype) |
|
9043 this.delegate.endDoctype(); |
|
9044 this.transitionTo("beforeData" /* beforeData */); |
|
9045 } |
|
9046 else { |
|
9047 if (this.delegate.appendToDoctypeSystemIdentifier) |
|
9048 this.delegate.appendToDoctypeSystemIdentifier(char); |
|
9049 } |
|
9050 }, |
|
9051 doctypeSystemIdentifierSingleQuoted: function () { |
|
9052 var char = this.consume(); |
|
9053 if (char === "'") { |
|
9054 this.transitionTo("afterDoctypeSystemIdentifier" /* afterDoctypeSystemIdentifier */); |
|
9055 } |
|
9056 else if (char === '>') { |
|
9057 if (this.delegate.endDoctype) |
|
9058 this.delegate.endDoctype(); |
|
9059 this.transitionTo("beforeData" /* beforeData */); |
|
9060 } |
|
9061 else { |
|
9062 if (this.delegate.appendToDoctypeSystemIdentifier) |
|
9063 this.delegate.appendToDoctypeSystemIdentifier(char); |
|
9064 } |
|
9065 }, |
|
9066 afterDoctypeSystemIdentifier: function () { |
|
9067 var char = this.consume(); |
|
9068 if (isSpace(char)) { |
|
9069 return; |
|
9070 } |
|
9071 else if (char === '>') { |
|
9072 if (this.delegate.endDoctype) |
|
9073 this.delegate.endDoctype(); |
|
9074 this.transitionTo("beforeData" /* beforeData */); |
|
9075 } |
|
9076 }, |
|
9077 commentStart: function () { |
|
9078 var char = this.consume(); |
|
9079 if (char === '-') { |
|
9080 this.transitionTo("commentStartDash" /* commentStartDash */); |
|
9081 } |
|
9082 else if (char === '>') { |
|
9083 this.delegate.finishComment(); |
|
9084 this.transitionTo("beforeData" /* beforeData */); |
|
9085 } |
|
9086 else { |
|
9087 this.delegate.appendToCommentData(char); |
|
9088 this.transitionTo("comment" /* comment */); |
|
9089 } |
|
9090 }, |
|
9091 commentStartDash: function () { |
|
9092 var char = this.consume(); |
|
9093 if (char === '-') { |
|
9094 this.transitionTo("commentEnd" /* commentEnd */); |
|
9095 } |
|
9096 else if (char === '>') { |
|
9097 this.delegate.finishComment(); |
|
9098 this.transitionTo("beforeData" /* beforeData */); |
|
9099 } |
|
9100 else { |
|
9101 this.delegate.appendToCommentData('-'); |
|
9102 this.transitionTo("comment" /* comment */); |
|
9103 } |
|
9104 }, |
|
9105 comment: function () { |
|
9106 var char = this.consume(); |
|
9107 if (char === '-') { |
|
9108 this.transitionTo("commentEndDash" /* commentEndDash */); |
|
9109 } |
|
9110 else { |
|
9111 this.delegate.appendToCommentData(char); |
|
9112 } |
|
9113 }, |
|
9114 commentEndDash: function () { |
|
9115 var char = this.consume(); |
|
9116 if (char === '-') { |
|
9117 this.transitionTo("commentEnd" /* commentEnd */); |
|
9118 } |
|
9119 else { |
|
9120 this.delegate.appendToCommentData('-' + char); |
|
9121 this.transitionTo("comment" /* comment */); |
|
9122 } |
|
9123 }, |
|
9124 commentEnd: function () { |
|
9125 var char = this.consume(); |
|
9126 if (char === '>') { |
|
9127 this.delegate.finishComment(); |
|
9128 this.transitionTo("beforeData" /* beforeData */); |
|
9129 } |
|
9130 else { |
|
9131 this.delegate.appendToCommentData('--' + char); |
|
9132 this.transitionTo("comment" /* comment */); |
|
9133 } |
|
9134 }, |
|
9135 tagName: function () { |
|
9136 var char = this.consume(); |
|
9137 if (isSpace(char)) { |
|
9138 this.transitionTo("beforeAttributeName" /* beforeAttributeName */); |
|
9139 } |
|
9140 else if (char === '/') { |
|
9141 this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */); |
|
9142 } |
|
9143 else if (char === '>') { |
|
9144 this.delegate.finishTag(); |
|
9145 this.transitionTo("beforeData" /* beforeData */); |
|
9146 } |
|
9147 else { |
|
9148 this.appendToTagName(char); |
|
9149 } |
|
9150 }, |
|
9151 endTagName: function () { |
|
9152 var char = this.consume(); |
|
9153 if (isSpace(char)) { |
|
9154 this.transitionTo("beforeAttributeName" /* beforeAttributeName */); |
|
9155 this.tagNameBuffer = ''; |
|
9156 } |
|
9157 else if (char === '/') { |
|
9158 this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */); |
|
9159 this.tagNameBuffer = ''; |
|
9160 } |
|
9161 else if (char === '>') { |
|
9162 this.delegate.finishTag(); |
|
9163 this.transitionTo("beforeData" /* beforeData */); |
|
9164 this.tagNameBuffer = ''; |
|
9165 } |
|
9166 else { |
|
9167 this.appendToTagName(char); |
|
9168 } |
|
9169 }, |
|
9170 beforeAttributeName: function () { |
|
9171 var char = this.peek(); |
|
9172 if (isSpace(char)) { |
|
9173 this.consume(); |
|
9174 return; |
|
9175 } |
|
9176 else if (char === '/') { |
|
9177 this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */); |
|
9178 this.consume(); |
|
9179 } |
|
9180 else if (char === '>') { |
|
9181 this.consume(); |
|
9182 this.delegate.finishTag(); |
|
9183 this.transitionTo("beforeData" /* beforeData */); |
|
9184 } |
|
9185 else if (char === '=') { |
|
9186 this.delegate.reportSyntaxError('attribute name cannot start with equals sign'); |
|
9187 this.transitionTo("attributeName" /* attributeName */); |
|
9188 this.delegate.beginAttribute(); |
|
9189 this.consume(); |
|
9190 this.delegate.appendToAttributeName(char); |
|
9191 } |
|
9192 else { |
|
9193 this.transitionTo("attributeName" /* attributeName */); |
|
9194 this.delegate.beginAttribute(); |
|
9195 } |
|
9196 }, |
|
9197 attributeName: function () { |
|
9198 var char = this.peek(); |
|
9199 if (isSpace(char)) { |
|
9200 this.transitionTo("afterAttributeName" /* afterAttributeName */); |
|
9201 this.consume(); |
|
9202 } |
|
9203 else if (char === '/') { |
|
9204 this.delegate.beginAttributeValue(false); |
|
9205 this.delegate.finishAttributeValue(); |
|
9206 this.consume(); |
|
9207 this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */); |
|
9208 } |
|
9209 else if (char === '=') { |
|
9210 this.transitionTo("beforeAttributeValue" /* beforeAttributeValue */); |
|
9211 this.consume(); |
|
9212 } |
|
9213 else if (char === '>') { |
|
9214 this.delegate.beginAttributeValue(false); |
|
9215 this.delegate.finishAttributeValue(); |
|
9216 this.consume(); |
|
9217 this.delegate.finishTag(); |
|
9218 this.transitionTo("beforeData" /* beforeData */); |
|
9219 } |
|
9220 else if (char === '"' || char === "'" || char === '<') { |
|
9221 this.delegate.reportSyntaxError(char + ' is not a valid character within attribute names'); |
|
9222 this.consume(); |
|
9223 this.delegate.appendToAttributeName(char); |
|
9224 } |
|
9225 else { |
|
9226 this.consume(); |
|
9227 this.delegate.appendToAttributeName(char); |
|
9228 } |
|
9229 }, |
|
9230 afterAttributeName: function () { |
|
9231 var char = this.peek(); |
|
9232 if (isSpace(char)) { |
|
9233 this.consume(); |
|
9234 return; |
|
9235 } |
|
9236 else if (char === '/') { |
|
9237 this.delegate.beginAttributeValue(false); |
|
9238 this.delegate.finishAttributeValue(); |
|
9239 this.consume(); |
|
9240 this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */); |
|
9241 } |
|
9242 else if (char === '=') { |
|
9243 this.consume(); |
|
9244 this.transitionTo("beforeAttributeValue" /* beforeAttributeValue */); |
|
9245 } |
|
9246 else if (char === '>') { |
|
9247 this.delegate.beginAttributeValue(false); |
|
9248 this.delegate.finishAttributeValue(); |
|
9249 this.consume(); |
|
9250 this.delegate.finishTag(); |
|
9251 this.transitionTo("beforeData" /* beforeData */); |
|
9252 } |
|
9253 else { |
|
9254 this.delegate.beginAttributeValue(false); |
|
9255 this.delegate.finishAttributeValue(); |
|
9256 this.transitionTo("attributeName" /* attributeName */); |
|
9257 this.delegate.beginAttribute(); |
|
9258 this.consume(); |
|
9259 this.delegate.appendToAttributeName(char); |
|
9260 } |
|
9261 }, |
|
9262 beforeAttributeValue: function () { |
|
9263 var char = this.peek(); |
|
9264 if (isSpace(char)) { |
|
9265 this.consume(); |
|
9266 } |
|
9267 else if (char === '"') { |
|
9268 this.transitionTo("attributeValueDoubleQuoted" /* attributeValueDoubleQuoted */); |
|
9269 this.delegate.beginAttributeValue(true); |
|
9270 this.consume(); |
|
9271 } |
|
9272 else if (char === "'") { |
|
9273 this.transitionTo("attributeValueSingleQuoted" /* attributeValueSingleQuoted */); |
|
9274 this.delegate.beginAttributeValue(true); |
|
9275 this.consume(); |
|
9276 } |
|
9277 else if (char === '>') { |
|
9278 this.delegate.beginAttributeValue(false); |
|
9279 this.delegate.finishAttributeValue(); |
|
9280 this.consume(); |
|
9281 this.delegate.finishTag(); |
|
9282 this.transitionTo("beforeData" /* beforeData */); |
|
9283 } |
|
9284 else { |
|
9285 this.transitionTo("attributeValueUnquoted" /* attributeValueUnquoted */); |
|
9286 this.delegate.beginAttributeValue(false); |
|
9287 this.consume(); |
|
9288 this.delegate.appendToAttributeValue(char); |
|
9289 } |
|
9290 }, |
|
9291 attributeValueDoubleQuoted: function () { |
|
9292 var char = this.consume(); |
|
9293 if (char === '"') { |
|
9294 this.delegate.finishAttributeValue(); |
|
9295 this.transitionTo("afterAttributeValueQuoted" /* afterAttributeValueQuoted */); |
|
9296 } |
|
9297 else if (char === '&') { |
|
9298 this.delegate.appendToAttributeValue(this.consumeCharRef() || '&'); |
|
9299 } |
|
9300 else { |
|
9301 this.delegate.appendToAttributeValue(char); |
|
9302 } |
|
9303 }, |
|
9304 attributeValueSingleQuoted: function () { |
|
9305 var char = this.consume(); |
|
9306 if (char === "'") { |
|
9307 this.delegate.finishAttributeValue(); |
|
9308 this.transitionTo("afterAttributeValueQuoted" /* afterAttributeValueQuoted */); |
|
9309 } |
|
9310 else if (char === '&') { |
|
9311 this.delegate.appendToAttributeValue(this.consumeCharRef() || '&'); |
|
9312 } |
|
9313 else { |
|
9314 this.delegate.appendToAttributeValue(char); |
|
9315 } |
|
9316 }, |
|
9317 attributeValueUnquoted: function () { |
|
9318 var char = this.peek(); |
|
9319 if (isSpace(char)) { |
|
9320 this.delegate.finishAttributeValue(); |
|
9321 this.consume(); |
|
9322 this.transitionTo("beforeAttributeName" /* beforeAttributeName */); |
|
9323 } |
|
9324 else if (char === '/') { |
|
9325 this.delegate.finishAttributeValue(); |
|
9326 this.consume(); |
|
9327 this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */); |
|
9328 } |
|
9329 else if (char === '&') { |
|
9330 this.consume(); |
|
9331 this.delegate.appendToAttributeValue(this.consumeCharRef() || '&'); |
|
9332 } |
|
9333 else if (char === '>') { |
|
9334 this.delegate.finishAttributeValue(); |
|
9335 this.consume(); |
|
9336 this.delegate.finishTag(); |
|
9337 this.transitionTo("beforeData" /* beforeData */); |
|
9338 } |
|
9339 else { |
|
9340 this.consume(); |
|
9341 this.delegate.appendToAttributeValue(char); |
|
9342 } |
|
9343 }, |
|
9344 afterAttributeValueQuoted: function () { |
|
9345 var char = this.peek(); |
|
9346 if (isSpace(char)) { |
|
9347 this.consume(); |
|
9348 this.transitionTo("beforeAttributeName" /* beforeAttributeName */); |
|
9349 } |
|
9350 else if (char === '/') { |
|
9351 this.consume(); |
|
9352 this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */); |
|
9353 } |
|
9354 else if (char === '>') { |
|
9355 this.consume(); |
|
9356 this.delegate.finishTag(); |
|
9357 this.transitionTo("beforeData" /* beforeData */); |
|
9358 } |
|
9359 else { |
|
9360 this.transitionTo("beforeAttributeName" /* beforeAttributeName */); |
|
9361 } |
|
9362 }, |
|
9363 selfClosingStartTag: function () { |
|
9364 var char = this.peek(); |
|
9365 if (char === '>') { |
|
9366 this.consume(); |
|
9367 this.delegate.markTagAsSelfClosing(); |
|
9368 this.delegate.finishTag(); |
|
9369 this.transitionTo("beforeData" /* beforeData */); |
|
9370 } |
|
9371 else { |
|
9372 this.transitionTo("beforeAttributeName" /* beforeAttributeName */); |
|
9373 } |
|
9374 }, |
|
9375 endTagOpen: function () { |
|
9376 var char = this.consume(); |
|
9377 if (char === '@' || char === ':' || isAlpha(char)) { |
|
9378 this.transitionTo("endTagName" /* endTagName */); |
|
9379 this.tagNameBuffer = ''; |
|
9380 this.delegate.beginEndTag(); |
|
9381 this.appendToTagName(char); |
|
9382 } |
|
9383 } |
|
9384 }; |
|
9385 this.reset(); |
|
9386 } |
|
9387 EventedTokenizer.prototype.reset = function () { |
|
9388 this.transitionTo("beforeData" /* beforeData */); |
|
9389 this.input = ''; |
|
9390 this.tagNameBuffer = ''; |
|
9391 this.index = 0; |
|
9392 this.line = 1; |
|
9393 this.column = 0; |
|
9394 this.delegate.reset(); |
|
9395 }; |
|
9396 EventedTokenizer.prototype.transitionTo = function (state) { |
|
9397 this.state = state; |
|
9398 }; |
|
9399 EventedTokenizer.prototype.tokenize = function (input) { |
|
9400 this.reset(); |
|
9401 this.tokenizePart(input); |
|
9402 this.tokenizeEOF(); |
|
9403 }; |
|
9404 EventedTokenizer.prototype.tokenizePart = function (input) { |
|
9405 this.input += preprocessInput(input); |
|
9406 while (this.index < this.input.length) { |
|
9407 var handler = this.states[this.state]; |
|
9408 if (handler !== undefined) { |
|
9409 handler.call(this); |
|
9410 } |
|
9411 else { |
|
9412 throw new Error("unhandled state " + this.state); |
|
9413 } |
|
9414 } |
|
9415 }; |
|
9416 EventedTokenizer.prototype.tokenizeEOF = function () { |
|
9417 this.flushData(); |
|
9418 }; |
|
9419 EventedTokenizer.prototype.flushData = function () { |
|
9420 if (this.state === 'data') { |
|
9421 this.delegate.finishData(); |
|
9422 this.transitionTo("beforeData" /* beforeData */); |
|
9423 } |
|
9424 }; |
|
9425 EventedTokenizer.prototype.peek = function () { |
|
9426 return this.input.charAt(this.index); |
|
9427 }; |
|
9428 EventedTokenizer.prototype.consume = function () { |
|
9429 var char = this.peek(); |
|
9430 this.index++; |
|
9431 if (char === '\n') { |
|
9432 this.line++; |
|
9433 this.column = 0; |
|
9434 } |
|
9435 else { |
|
9436 this.column++; |
|
9437 } |
|
9438 return char; |
|
9439 }; |
|
9440 EventedTokenizer.prototype.consumeCharRef = function () { |
|
9441 var endIndex = this.input.indexOf(';', this.index); |
|
9442 if (endIndex === -1) { |
|
9443 return; |
|
9444 } |
|
9445 var entity = this.input.slice(this.index, endIndex); |
|
9446 var chars = this.entityParser.parse(entity); |
|
9447 if (chars) { |
|
9448 var count = entity.length; |
|
9449 // consume the entity chars |
|
9450 while (count) { |
|
9451 this.consume(); |
|
9452 count--; |
|
9453 } |
|
9454 // consume the `;` |
|
9455 this.consume(); |
|
9456 return chars; |
|
9457 } |
|
9458 }; |
|
9459 EventedTokenizer.prototype.markTagStart = function () { |
|
9460 this.delegate.tagOpen(); |
|
9461 }; |
|
9462 EventedTokenizer.prototype.appendToTagName = function (char) { |
|
9463 this.tagNameBuffer += char; |
|
9464 this.delegate.appendToTagName(char); |
|
9465 }; |
|
9466 EventedTokenizer.prototype.isIgnoredEndTag = function () { |
|
9467 var tag = this.tagNameBuffer; |
|
9468 return (tag === 'title' && this.input.substring(this.index, this.index + 8) !== '</title>') || |
|
9469 (tag === 'style' && this.input.substring(this.index, this.index + 8) !== '</style>') || |
|
9470 (tag === 'script' && this.input.substring(this.index, this.index + 9) !== '</script>'); |
|
9471 }; |
|
9472 return EventedTokenizer; |
|
9473 }()); |
|
9474 |
|
9475 var Tokenizer = /** @class */ (function () { |
|
9476 function Tokenizer(entityParser, options) { |
|
9477 if (options === void 0) { options = {}; } |
|
9478 this.options = options; |
|
9479 this.token = null; |
|
9480 this.startLine = 1; |
|
9481 this.startColumn = 0; |
|
9482 this.tokens = []; |
|
9483 this.tokenizer = new EventedTokenizer(this, entityParser, options.mode); |
|
9484 this._currentAttribute = undefined; |
|
9485 } |
|
9486 Tokenizer.prototype.tokenize = function (input) { |
|
9487 this.tokens = []; |
|
9488 this.tokenizer.tokenize(input); |
|
9489 return this.tokens; |
|
9490 }; |
|
9491 Tokenizer.prototype.tokenizePart = function (input) { |
|
9492 this.tokens = []; |
|
9493 this.tokenizer.tokenizePart(input); |
|
9494 return this.tokens; |
|
9495 }; |
|
9496 Tokenizer.prototype.tokenizeEOF = function () { |
|
9497 this.tokens = []; |
|
9498 this.tokenizer.tokenizeEOF(); |
|
9499 return this.tokens[0]; |
|
9500 }; |
|
9501 Tokenizer.prototype.reset = function () { |
|
9502 this.token = null; |
|
9503 this.startLine = 1; |
|
9504 this.startColumn = 0; |
|
9505 }; |
|
9506 Tokenizer.prototype.current = function () { |
|
9507 var token = this.token; |
|
9508 if (token === null) { |
|
9509 throw new Error('token was unexpectedly null'); |
|
9510 } |
|
9511 if (arguments.length === 0) { |
|
9512 return token; |
|
9513 } |
|
9514 for (var i = 0; i < arguments.length; i++) { |
|
9515 if (token.type === arguments[i]) { |
|
9516 return token; |
|
9517 } |
|
9518 } |
|
9519 throw new Error("token type was unexpectedly " + token.type); |
|
9520 }; |
|
9521 Tokenizer.prototype.push = function (token) { |
|
9522 this.token = token; |
|
9523 this.tokens.push(token); |
|
9524 }; |
|
9525 Tokenizer.prototype.currentAttribute = function () { |
|
9526 return this._currentAttribute; |
|
9527 }; |
|
9528 Tokenizer.prototype.addLocInfo = function () { |
|
9529 if (this.options.loc) { |
|
9530 this.current().loc = { |
|
9531 start: { |
|
9532 line: this.startLine, |
|
9533 column: this.startColumn |
|
9534 }, |
|
9535 end: { |
|
9536 line: this.tokenizer.line, |
|
9537 column: this.tokenizer.column |
|
9538 } |
|
9539 }; |
|
9540 } |
|
9541 this.startLine = this.tokenizer.line; |
|
9542 this.startColumn = this.tokenizer.column; |
|
9543 }; |
|
9544 // Data |
|
9545 Tokenizer.prototype.beginDoctype = function () { |
|
9546 this.push({ |
|
9547 type: "Doctype" /* Doctype */, |
|
9548 name: '', |
|
9549 }); |
|
9550 }; |
|
9551 Tokenizer.prototype.appendToDoctypeName = function (char) { |
|
9552 this.current("Doctype" /* Doctype */).name += char; |
|
9553 }; |
|
9554 Tokenizer.prototype.appendToDoctypePublicIdentifier = function (char) { |
|
9555 var doctype = this.current("Doctype" /* Doctype */); |
|
9556 if (doctype.publicIdentifier === undefined) { |
|
9557 doctype.publicIdentifier = char; |
|
9558 } |
|
9559 else { |
|
9560 doctype.publicIdentifier += char; |
|
9561 } |
|
9562 }; |
|
9563 Tokenizer.prototype.appendToDoctypeSystemIdentifier = function (char) { |
|
9564 var doctype = this.current("Doctype" /* Doctype */); |
|
9565 if (doctype.systemIdentifier === undefined) { |
|
9566 doctype.systemIdentifier = char; |
|
9567 } |
|
9568 else { |
|
9569 doctype.systemIdentifier += char; |
|
9570 } |
|
9571 }; |
|
9572 Tokenizer.prototype.endDoctype = function () { |
|
9573 this.addLocInfo(); |
|
9574 }; |
|
9575 Tokenizer.prototype.beginData = function () { |
|
9576 this.push({ |
|
9577 type: "Chars" /* Chars */, |
|
9578 chars: '' |
|
9579 }); |
|
9580 }; |
|
9581 Tokenizer.prototype.appendToData = function (char) { |
|
9582 this.current("Chars" /* Chars */).chars += char; |
|
9583 }; |
|
9584 Tokenizer.prototype.finishData = function () { |
|
9585 this.addLocInfo(); |
|
9586 }; |
|
9587 // Comment |
|
9588 Tokenizer.prototype.beginComment = function () { |
|
9589 this.push({ |
|
9590 type: "Comment" /* Comment */, |
|
9591 chars: '' |
|
9592 }); |
|
9593 }; |
|
9594 Tokenizer.prototype.appendToCommentData = function (char) { |
|
9595 this.current("Comment" /* Comment */).chars += char; |
|
9596 }; |
|
9597 Tokenizer.prototype.finishComment = function () { |
|
9598 this.addLocInfo(); |
|
9599 }; |
|
9600 // Tags - basic |
|
9601 Tokenizer.prototype.tagOpen = function () { }; |
|
9602 Tokenizer.prototype.beginStartTag = function () { |
|
9603 this.push({ |
|
9604 type: "StartTag" /* StartTag */, |
|
9605 tagName: '', |
|
9606 attributes: [], |
|
9607 selfClosing: false |
|
9608 }); |
|
9609 }; |
|
9610 Tokenizer.prototype.beginEndTag = function () { |
|
9611 this.push({ |
|
9612 type: "EndTag" /* EndTag */, |
|
9613 tagName: '' |
|
9614 }); |
|
9615 }; |
|
9616 Tokenizer.prototype.finishTag = function () { |
|
9617 this.addLocInfo(); |
|
9618 }; |
|
9619 Tokenizer.prototype.markTagAsSelfClosing = function () { |
|
9620 this.current("StartTag" /* StartTag */).selfClosing = true; |
|
9621 }; |
|
9622 // Tags - name |
|
9623 Tokenizer.prototype.appendToTagName = function (char) { |
|
9624 this.current("StartTag" /* StartTag */, "EndTag" /* EndTag */).tagName += char; |
|
9625 }; |
|
9626 // Tags - attributes |
|
9627 Tokenizer.prototype.beginAttribute = function () { |
|
9628 this._currentAttribute = ['', '', false]; |
|
9629 }; |
|
9630 Tokenizer.prototype.appendToAttributeName = function (char) { |
|
9631 this.currentAttribute()[0] += char; |
|
9632 }; |
|
9633 Tokenizer.prototype.beginAttributeValue = function (isQuoted) { |
|
9634 this.currentAttribute()[2] = isQuoted; |
|
9635 }; |
|
9636 Tokenizer.prototype.appendToAttributeValue = function (char) { |
|
9637 this.currentAttribute()[1] += char; |
|
9638 }; |
|
9639 Tokenizer.prototype.finishAttributeValue = function () { |
|
9640 this.current("StartTag" /* StartTag */).attributes.push(this._currentAttribute); |
|
9641 }; |
|
9642 Tokenizer.prototype.reportSyntaxError = function (message) { |
|
9643 this.current().syntaxError = message; |
|
9644 }; |
|
9645 return Tokenizer; |
|
9646 }()); |
|
9647 |
|
9648 function tokenize(input, options) { |
|
9649 var tokenizer = new Tokenizer(new EntityParser(namedCharRefs), options); |
|
9650 return tokenizer.tokenize(input); |
|
9651 } |
|
9652 |
|
9653 |
|
9654 |
|
9655 ;// CONCATENATED MODULE: external ["wp","deprecated"] |
|
9656 var external_wp_deprecated_namespaceObject = window["wp"]["deprecated"]; |
|
9657 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject); |
|
9658 ;// CONCATENATED MODULE: external ["wp","htmlEntities"] |
|
9659 var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"]; |
|
9660 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/validation/logger.js |
|
9661 /** |
|
9662 * @typedef LoggerItem |
|
9663 * @property {Function} log Which logger recorded the message |
|
9664 * @property {Array<any>} args White arguments were supplied to the logger |
|
9665 */ |
|
9666 function createLogger() { |
|
9667 /** |
|
9668 * Creates a log handler with block validation prefix. |
|
9669 * |
|
9670 * @param {Function} logger Original logger function. |
|
9671 * |
|
9672 * @return {Function} Augmented logger function. |
|
9673 */ |
|
9674 function createLogHandler(logger) { |
|
9675 let log = function (message) { |
|
9676 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
|
9677 args[_key - 1] = arguments[_key]; |
|
9678 } |
|
9679 |
|
9680 return logger('Block validation: ' + message, ...args); |
|
9681 }; // In test environments, pre-process string substitutions to improve |
|
9682 // readability of error messages. We'd prefer to avoid pulling in this |
|
9683 // dependency in runtime environments, and it can be dropped by a combo |
|
9684 // of Webpack env substitution + UglifyJS dead code elimination. |
|
9685 |
|
9686 |
|
9687 if (false) {} |
|
9688 |
|
9689 return log; |
|
9690 } |
|
9691 |
|
9692 return { |
|
9693 // eslint-disable-next-line no-console |
|
9694 error: createLogHandler(console.error), |
|
9695 // eslint-disable-next-line no-console |
|
9696 warning: createLogHandler(console.warn), |
|
9697 |
|
9698 getItems() { |
|
9699 return []; |
|
9700 } |
|
9701 |
|
9702 }; |
|
9703 } |
|
9704 function createQueuedLogger() { |
|
9705 /** |
|
9706 * The list of enqueued log actions to print. |
|
9707 * |
|
9708 * @type {Array<LoggerItem>} |
|
9709 */ |
|
9710 const queue = []; |
|
9711 const logger = createLogger(); |
|
9712 return { |
|
9713 error() { |
|
9714 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { |
|
9715 args[_key2] = arguments[_key2]; |
|
9716 } |
|
9717 |
|
9718 queue.push({ |
|
9719 log: logger.error, |
|
9720 args |
|
9721 }); |
|
9722 }, |
|
9723 |
|
9724 warning() { |
|
9725 for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { |
|
9726 args[_key3] = arguments[_key3]; |
|
9727 } |
|
9728 |
|
9729 queue.push({ |
|
9730 log: logger.warning, |
|
9731 args |
|
9732 }); |
|
9733 }, |
|
9734 |
|
9735 getItems() { |
|
9736 return queue; |
|
9737 } |
|
9738 |
|
9739 }; |
|
9740 } |
|
9741 |
|
9742 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/validation/index.js |
|
9743 /** |
|
9744 * External dependencies |
|
9745 */ |
|
9746 |
|
9747 |
|
9748 /** |
|
9749 * WordPress dependencies |
|
9750 */ |
|
9751 |
|
9752 |
|
9753 |
|
9754 /** |
|
9755 * Internal dependencies |
|
9756 */ |
|
9757 |
|
9758 |
|
9759 |
|
9760 |
|
9761 |
|
9762 /** @typedef {import('../parser').WPBlock} WPBlock */ |
|
9763 |
|
9764 /** @typedef {import('../registration').WPBlockType} WPBlockType */ |
|
9765 |
|
9766 /** @typedef {import('./logger').LoggerItem} LoggerItem */ |
|
9767 |
|
9768 /** |
|
9769 * Globally matches any consecutive whitespace |
|
9770 * |
|
9771 * @type {RegExp} |
|
9772 */ |
|
9773 |
|
9774 const REGEXP_WHITESPACE = /[\t\n\r\v\f ]+/g; |
|
9775 /** |
|
9776 * Matches a string containing only whitespace |
|
9777 * |
|
9778 * @type {RegExp} |
|
9779 */ |
|
9780 |
|
9781 const REGEXP_ONLY_WHITESPACE = /^[\t\n\r\v\f ]*$/; |
|
9782 /** |
|
9783 * Matches a CSS URL type value |
|
9784 * |
|
9785 * @type {RegExp} |
|
9786 */ |
|
9787 |
|
9788 const REGEXP_STYLE_URL_TYPE = /^url\s*\(['"\s]*(.*?)['"\s]*\)$/; |
|
9789 /** |
|
9790 * Boolean attributes are attributes whose presence as being assigned is |
|
9791 * meaningful, even if only empty. |
|
9792 * |
|
9793 * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes |
|
9794 * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3 |
|
9795 * |
|
9796 * Object.keys( Array.from( document.querySelectorAll( '#attributes-1 > tbody > tr' ) ) |
|
9797 * .filter( ( tr ) => tr.lastChild.textContent.indexOf( 'Boolean attribute' ) !== -1 ) |
|
9798 * .reduce( ( result, tr ) => Object.assign( result, { |
|
9799 * [ tr.firstChild.textContent.trim() ]: true |
|
9800 * } ), {} ) ).sort(); |
|
9801 * |
|
9802 * @type {Array} |
|
9803 */ |
|
9804 |
|
9805 const BOOLEAN_ATTRIBUTES = ['allowfullscreen', 'allowpaymentrequest', 'allowusermedia', 'async', 'autofocus', 'autoplay', 'checked', 'controls', 'default', 'defer', 'disabled', 'download', 'formnovalidate', 'hidden', 'ismap', 'itemscope', 'loop', 'multiple', 'muted', 'nomodule', 'novalidate', 'open', 'playsinline', 'readonly', 'required', 'reversed', 'selected', 'typemustmatch']; |
|
9806 /** |
|
9807 * Enumerated attributes are attributes which must be of a specific value form. |
|
9808 * Like boolean attributes, these are meaningful if specified, even if not of a |
|
9809 * valid enumerated value. |
|
9810 * |
|
9811 * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute |
|
9812 * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3 |
|
9813 * |
|
9814 * Object.keys( Array.from( document.querySelectorAll( '#attributes-1 > tbody > tr' ) ) |
|
9815 * .filter( ( tr ) => /^("(.+?)";?\s*)+/.test( tr.lastChild.textContent.trim() ) ) |
|
9816 * .reduce( ( result, tr ) => Object.assign( result, { |
|
9817 * [ tr.firstChild.textContent.trim() ]: true |
|
9818 * } ), {} ) ).sort(); |
|
9819 * |
|
9820 * @type {Array} |
|
9821 */ |
|
9822 |
|
9823 const ENUMERATED_ATTRIBUTES = ['autocapitalize', 'autocomplete', 'charset', 'contenteditable', 'crossorigin', 'decoding', 'dir', 'draggable', 'enctype', 'formenctype', 'formmethod', 'http-equiv', 'inputmode', 'kind', 'method', 'preload', 'scope', 'shape', 'spellcheck', 'translate', 'type', 'wrap']; |
|
9824 /** |
|
9825 * Meaningful attributes are those who cannot be safely ignored when omitted in |
|
9826 * one HTML markup string and not another. |
|
9827 * |
|
9828 * @type {Array} |
|
9829 */ |
|
9830 |
|
9831 const MEANINGFUL_ATTRIBUTES = [...BOOLEAN_ATTRIBUTES, ...ENUMERATED_ATTRIBUTES]; |
|
9832 /** |
|
9833 * Array of functions which receive a text string on which to apply normalizing |
|
9834 * behavior for consideration in text token equivalence, carefully ordered from |
|
9835 * least-to-most expensive operations. |
|
9836 * |
|
9837 * @type {Array} |
|
9838 */ |
|
9839 |
|
9840 const TEXT_NORMALIZATIONS = [external_lodash_namespaceObject.identity, getTextWithCollapsedWhitespace]; |
|
9841 /** |
|
9842 * Regular expression matching a named character reference. In lieu of bundling |
|
9843 * a full set of references, the pattern covers the minimal necessary to test |
|
9844 * positively against the full set. |
|
9845 * |
|
9846 * "The ampersand must be followed by one of the names given in the named |
|
9847 * character references section, using the same case." |
|
9848 * |
|
9849 * Tested aginst "12.5 Named character references": |
|
9850 * |
|
9851 * ``` |
|
9852 * const references = Array.from( document.querySelectorAll( |
|
9853 * '#named-character-references-table tr[id^=entity-] td:first-child' |
|
9854 * ) ).map( ( code ) => code.textContent ) |
|
9855 * references.every( ( reference ) => /^[\da-z]+$/i.test( reference ) ) |
|
9856 * ``` |
|
9857 * |
|
9858 * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references |
|
9859 * @see https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references |
|
9860 * |
|
9861 * @type {RegExp} |
|
9862 */ |
|
9863 |
|
9864 const REGEXP_NAMED_CHARACTER_REFERENCE = /^[\da-z]+$/i; |
|
9865 /** |
|
9866 * Regular expression matching a decimal character reference. |
|
9867 * |
|
9868 * "The ampersand must be followed by a U+0023 NUMBER SIGN character (#), |
|
9869 * followed by one or more ASCII digits, representing a base-ten integer" |
|
9870 * |
|
9871 * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references |
|
9872 * |
|
9873 * @type {RegExp} |
|
9874 */ |
|
9875 |
|
9876 const REGEXP_DECIMAL_CHARACTER_REFERENCE = /^#\d+$/; |
|
9877 /** |
|
9878 * Regular expression matching a hexadecimal character reference. |
|
9879 * |
|
9880 * "The ampersand must be followed by a U+0023 NUMBER SIGN character (#), which |
|
9881 * must be followed by either a U+0078 LATIN SMALL LETTER X character (x) or a |
|
9882 * U+0058 LATIN CAPITAL LETTER X character (X), which must then be followed by |
|
9883 * one or more ASCII hex digits, representing a hexadecimal integer" |
|
9884 * |
|
9885 * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references |
|
9886 * |
|
9887 * @type {RegExp} |
|
9888 */ |
|
9889 |
|
9890 const REGEXP_HEXADECIMAL_CHARACTER_REFERENCE = /^#x[\da-f]+$/i; |
|
9891 /** |
|
9892 * Returns true if the given string is a valid character reference segment, or |
|
9893 * false otherwise. The text should be stripped of `&` and `;` demarcations. |
|
9894 * |
|
9895 * @param {string} text Text to test. |
|
9896 * |
|
9897 * @return {boolean} Whether text is valid character reference. |
|
9898 */ |
|
9899 |
|
9900 function isValidCharacterReference(text) { |
|
9901 return REGEXP_NAMED_CHARACTER_REFERENCE.test(text) || REGEXP_DECIMAL_CHARACTER_REFERENCE.test(text) || REGEXP_HEXADECIMAL_CHARACTER_REFERENCE.test(text); |
|
9902 } |
|
9903 /** |
|
9904 * Subsitute EntityParser class for `simple-html-tokenizer` which uses the |
|
9905 * implementation of `decodeEntities` from `html-entities`, in order to avoid |
|
9906 * bundling a massive named character reference. |
|
9907 * |
|
9908 * @see https://github.com/tildeio/simple-html-tokenizer/tree/HEAD/src/entity-parser.ts |
|
9909 */ |
|
9910 |
|
9911 class DecodeEntityParser { |
|
9912 /** |
|
9913 * Returns a substitute string for an entity string sequence between `&` |
|
9914 * and `;`, or undefined if no substitution should occur. |
|
9915 * |
|
9916 * @param {string} entity Entity fragment discovered in HTML. |
|
9917 * |
|
9918 * @return {?string} Entity substitute value. |
|
9919 */ |
|
9920 parse(entity) { |
|
9921 if (isValidCharacterReference(entity)) { |
|
9922 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)('&' + entity + ';'); |
|
9923 } |
|
9924 } |
|
9925 |
|
9926 } |
|
9927 /** |
|
9928 * Given a specified string, returns an array of strings split by consecutive |
|
9929 * whitespace, ignoring leading or trailing whitespace. |
|
9930 * |
|
9931 * @param {string} text Original text. |
|
9932 * |
|
9933 * @return {string[]} Text pieces split on whitespace. |
|
9934 */ |
|
9935 |
|
9936 function getTextPiecesSplitOnWhitespace(text) { |
|
9937 return text.trim().split(REGEXP_WHITESPACE); |
|
9938 } |
|
9939 /** |
|
9940 * Given a specified string, returns a new trimmed string where all consecutive |
|
9941 * whitespace is collapsed to a single space. |
|
9942 * |
|
9943 * @param {string} text Original text. |
|
9944 * |
|
9945 * @return {string} Trimmed text with consecutive whitespace collapsed. |
|
9946 */ |
|
9947 |
|
9948 function getTextWithCollapsedWhitespace(text) { |
|
9949 // This is an overly simplified whitespace comparison. The specification is |
|
9950 // more prescriptive of whitespace behavior in inline and block contexts. |
|
9951 // |
|
9952 // See: https://medium.com/@patrickbrosset/when-does-white-space-matter-in-html-b90e8a7cdd33 |
|
9953 return getTextPiecesSplitOnWhitespace(text).join(' '); |
|
9954 } |
|
9955 /** |
|
9956 * Returns attribute pairs of the given StartTag token, including only pairs |
|
9957 * where the value is non-empty or the attribute is a boolean attribute, an |
|
9958 * enumerated attribute, or a custom data- attribute. |
|
9959 * |
|
9960 * @see MEANINGFUL_ATTRIBUTES |
|
9961 * |
|
9962 * @param {Object} token StartTag token. |
|
9963 * |
|
9964 * @return {Array[]} Attribute pairs. |
|
9965 */ |
|
9966 |
|
9967 function getMeaningfulAttributePairs(token) { |
|
9968 return token.attributes.filter(pair => { |
|
9969 const [key, value] = pair; |
|
9970 return value || key.indexOf('data-') === 0 || (0,external_lodash_namespaceObject.includes)(MEANINGFUL_ATTRIBUTES, key); |
|
9971 }); |
|
9972 } |
|
9973 /** |
|
9974 * Returns true if two text tokens (with `chars` property) are equivalent, or |
|
9975 * false otherwise. |
|
9976 * |
|
9977 * @param {Object} actual Actual token. |
|
9978 * @param {Object} expected Expected token. |
|
9979 * @param {Object} logger Validation logger object. |
|
9980 * |
|
9981 * @return {boolean} Whether two text tokens are equivalent. |
|
9982 */ |
|
9983 |
|
9984 function isEquivalentTextTokens(actual, expected) { |
|
9985 let logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger(); |
|
9986 // This function is intentionally written as syntactically "ugly" as a hot |
|
9987 // path optimization. Text is progressively normalized in order from least- |
|
9988 // to-most operationally expensive, until the earliest point at which text |
|
9989 // can be confidently inferred as being equal. |
|
9990 let actualChars = actual.chars; |
|
9991 let expectedChars = expected.chars; |
|
9992 |
|
9993 for (let i = 0; i < TEXT_NORMALIZATIONS.length; i++) { |
|
9994 const normalize = TEXT_NORMALIZATIONS[i]; |
|
9995 actualChars = normalize(actualChars); |
|
9996 expectedChars = normalize(expectedChars); |
|
9997 |
|
9998 if (actualChars === expectedChars) { |
|
9999 return true; |
|
10000 } |
|
10001 } |
|
10002 |
|
10003 logger.warning('Expected text `%s`, saw `%s`.', expected.chars, actual.chars); |
|
10004 return false; |
|
10005 } |
|
10006 /** |
|
10007 * Given a CSS length value, returns a normalized CSS length value for strict equality |
|
10008 * comparison. |
|
10009 * |
|
10010 * @param {string} value CSS length value. |
|
10011 * |
|
10012 * @return {string} Normalized CSS length value. |
|
10013 */ |
|
10014 |
|
10015 function getNormalizedLength(value) { |
|
10016 if (0 === parseFloat(value)) { |
|
10017 return '0'; |
|
10018 } // Normalize strings with floats to always include a leading zero. |
|
10019 |
|
10020 |
|
10021 if (value.indexOf('.') === 0) { |
|
10022 return '0' + value; |
|
10023 } |
|
10024 |
|
10025 return value; |
|
10026 } |
|
10027 /** |
|
10028 * Given a style value, returns a normalized style value for strict equality |
|
10029 * comparison. |
|
10030 * |
|
10031 * @param {string} value Style value. |
|
10032 * |
|
10033 * @return {string} Normalized style value. |
|
10034 */ |
|
10035 |
|
10036 function getNormalizedStyleValue(value) { |
|
10037 const textPieces = getTextPiecesSplitOnWhitespace(value); |
|
10038 const normalizedPieces = textPieces.map(getNormalizedLength); |
|
10039 const result = normalizedPieces.join(' '); |
|
10040 return result // Normalize URL type to omit whitespace or quotes. |
|
10041 .replace(REGEXP_STYLE_URL_TYPE, 'url($1)'); |
|
10042 } |
|
10043 /** |
|
10044 * Given a style attribute string, returns an object of style properties. |
|
10045 * |
|
10046 * @param {string} text Style attribute. |
|
10047 * |
|
10048 * @return {Object} Style properties. |
|
10049 */ |
|
10050 |
|
10051 function getStyleProperties(text) { |
|
10052 const pairs = text // Trim ending semicolon (avoid including in split) |
|
10053 .replace(/;?\s*$/, '') // Split on property assignment. |
|
10054 .split(';') // For each property assignment... |
|
10055 .map(style => { |
|
10056 // ...split further into key-value pairs. |
|
10057 const [key, ...valueParts] = style.split(':'); |
|
10058 const value = valueParts.join(':'); |
|
10059 return [key.trim(), getNormalizedStyleValue(value.trim())]; |
|
10060 }); |
|
10061 return (0,external_lodash_namespaceObject.fromPairs)(pairs); |
|
10062 } |
|
10063 /** |
|
10064 * Attribute-specific equality handlers |
|
10065 * |
|
10066 * @type {Object} |
|
10067 */ |
|
10068 |
|
10069 const isEqualAttributesOfName = { |
|
10070 class: (actual, expected) => { |
|
10071 // Class matches if members are the same, even if out of order or |
|
10072 // superfluous whitespace between. |
|
10073 return !(0,external_lodash_namespaceObject.xor)(...[actual, expected].map(getTextPiecesSplitOnWhitespace)).length; |
|
10074 }, |
|
10075 style: (actual, expected) => { |
|
10076 return (0,external_lodash_namespaceObject.isEqual)(...[actual, expected].map(getStyleProperties)); |
|
10077 }, |
|
10078 // For each boolean attribute, mere presence of attribute in both is enough |
|
10079 // to assume equivalence. |
|
10080 ...(0,external_lodash_namespaceObject.fromPairs)(BOOLEAN_ATTRIBUTES.map(attribute => [attribute, external_lodash_namespaceObject.stubTrue])) |
|
10081 }; |
|
10082 /** |
|
10083 * Given two sets of attribute tuples, returns true if the attribute sets are |
|
10084 * equivalent. |
|
10085 * |
|
10086 * @param {Array[]} actual Actual attributes tuples. |
|
10087 * @param {Array[]} expected Expected attributes tuples. |
|
10088 * @param {Object} logger Validation logger object. |
|
10089 * |
|
10090 * @return {boolean} Whether attributes are equivalent. |
|
10091 */ |
|
10092 |
|
10093 function isEqualTagAttributePairs(actual, expected) { |
|
10094 let logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger(); |
|
10095 |
|
10096 // Attributes is tokenized as tuples. Their lengths should match. This also |
|
10097 // avoids us needing to check both attributes sets, since if A has any keys |
|
10098 // which do not exist in B, we know the sets to be different. |
|
10099 if (actual.length !== expected.length) { |
|
10100 logger.warning('Expected attributes %o, instead saw %o.', expected, actual); |
|
10101 return false; |
|
10102 } // Attributes are not guaranteed to occur in the same order. For validating |
|
10103 // actual attributes, first convert the set of expected attribute values to |
|
10104 // an object, for lookup by key. |
|
10105 |
|
10106 |
|
10107 const expectedAttributes = {}; |
|
10108 |
|
10109 for (let i = 0; i < expected.length; i++) { |
|
10110 expectedAttributes[expected[i][0].toLowerCase()] = expected[i][1]; |
|
10111 } |
|
10112 |
|
10113 for (let i = 0; i < actual.length; i++) { |
|
10114 const [name, actualValue] = actual[i]; |
|
10115 const nameLower = name.toLowerCase(); // As noted above, if missing member in B, assume different. |
|
10116 |
|
10117 if (!expectedAttributes.hasOwnProperty(nameLower)) { |
|
10118 logger.warning('Encountered unexpected attribute `%s`.', name); |
|
10119 return false; |
|
10120 } |
|
10121 |
|
10122 const expectedValue = expectedAttributes[nameLower]; |
|
10123 const isEqualAttributes = isEqualAttributesOfName[nameLower]; |
|
10124 |
|
10125 if (isEqualAttributes) { |
|
10126 // Defer custom attribute equality handling. |
|
10127 if (!isEqualAttributes(actualValue, expectedValue)) { |
|
10128 logger.warning('Expected attribute `%s` of value `%s`, saw `%s`.', name, expectedValue, actualValue); |
|
10129 return false; |
|
10130 } |
|
10131 } else if (actualValue !== expectedValue) { |
|
10132 // Otherwise strict inequality should bail. |
|
10133 logger.warning('Expected attribute `%s` of value `%s`, saw `%s`.', name, expectedValue, actualValue); |
|
10134 return false; |
|
10135 } |
|
10136 } |
|
10137 |
|
10138 return true; |
|
10139 } |
|
10140 /** |
|
10141 * Token-type-specific equality handlers |
|
10142 * |
|
10143 * @type {Object} |
|
10144 */ |
|
10145 |
|
10146 const isEqualTokensOfType = { |
|
10147 StartTag: function (actual, expected) { |
|
10148 let logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger(); |
|
10149 |
|
10150 if (actual.tagName !== expected.tagName && // Optimization: Use short-circuit evaluation to defer case- |
|
10151 // insensitive check on the assumption that the majority case will |
|
10152 // have exactly equal tag names. |
|
10153 actual.tagName.toLowerCase() !== expected.tagName.toLowerCase()) { |
|
10154 logger.warning('Expected tag name `%s`, instead saw `%s`.', expected.tagName, actual.tagName); |
|
10155 return false; |
|
10156 } |
|
10157 |
|
10158 return isEqualTagAttributePairs(...[actual, expected].map(getMeaningfulAttributePairs), logger); |
|
10159 }, |
|
10160 Chars: isEquivalentTextTokens, |
|
10161 Comment: isEquivalentTextTokens |
|
10162 }; |
|
10163 /** |
|
10164 * Given an array of tokens, returns the first token which is not purely |
|
10165 * whitespace. |
|
10166 * |
|
10167 * Mutates the tokens array. |
|
10168 * |
|
10169 * @param {Object[]} tokens Set of tokens to search. |
|
10170 * |
|
10171 * @return {Object} Next non-whitespace token. |
|
10172 */ |
|
10173 |
|
10174 function getNextNonWhitespaceToken(tokens) { |
|
10175 let token; |
|
10176 |
|
10177 while (token = tokens.shift()) { |
|
10178 if (token.type !== 'Chars') { |
|
10179 return token; |
|
10180 } |
|
10181 |
|
10182 if (!REGEXP_ONLY_WHITESPACE.test(token.chars)) { |
|
10183 return token; |
|
10184 } |
|
10185 } |
|
10186 } |
|
10187 /** |
|
10188 * Tokenize an HTML string, gracefully handling any errors thrown during |
|
10189 * underlying tokenization. |
|
10190 * |
|
10191 * @param {string} html HTML string to tokenize. |
|
10192 * @param {Object} logger Validation logger object. |
|
10193 * |
|
10194 * @return {Object[]|null} Array of valid tokenized HTML elements, or null on error |
|
10195 */ |
|
10196 |
|
10197 function getHTMLTokens(html) { |
|
10198 let logger = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createLogger(); |
|
10199 |
|
10200 try { |
|
10201 return new Tokenizer(new DecodeEntityParser()).tokenize(html); |
|
10202 } catch (e) { |
|
10203 logger.warning('Malformed HTML detected: %s', html); |
|
10204 } |
|
10205 |
|
10206 return null; |
|
10207 } |
|
10208 /** |
|
10209 * Returns true if the next HTML token closes the current token. |
|
10210 * |
|
10211 * @param {Object} currentToken Current token to compare with. |
|
10212 * @param {Object|undefined} nextToken Next token to compare against. |
|
10213 * |
|
10214 * @return {boolean} true if `nextToken` closes `currentToken`, false otherwise |
|
10215 */ |
|
10216 |
|
10217 |
|
10218 function isClosedByToken(currentToken, nextToken) { |
|
10219 // Ensure this is a self closed token. |
|
10220 if (!currentToken.selfClosing) { |
|
10221 return false; |
|
10222 } // Check token names and determine if nextToken is the closing tag for currentToken. |
|
10223 |
|
10224 |
|
10225 if (nextToken && nextToken.tagName === currentToken.tagName && nextToken.type === 'EndTag') { |
|
10226 return true; |
|
10227 } |
|
10228 |
|
10229 return false; |
|
10230 } |
|
10231 /** |
|
10232 * Returns true if the given HTML strings are effectively equivalent, or |
|
10233 * false otherwise. Invalid HTML is not considered equivalent, even if the |
|
10234 * strings directly match. |
|
10235 * |
|
10236 * @param {string} actual Actual HTML string. |
|
10237 * @param {string} expected Expected HTML string. |
|
10238 * @param {Object} logger Validation logger object. |
|
10239 * |
|
10240 * @return {boolean} Whether HTML strings are equivalent. |
|
10241 */ |
|
10242 |
|
10243 function isEquivalentHTML(actual, expected) { |
|
10244 let logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger(); |
|
10245 |
|
10246 // Short-circuit if markup is identical. |
|
10247 if (actual === expected) { |
|
10248 return true; |
|
10249 } // Tokenize input content and reserialized save content. |
|
10250 |
|
10251 |
|
10252 const [actualTokens, expectedTokens] = [actual, expected].map(html => getHTMLTokens(html, logger)); // If either is malformed then stop comparing - the strings are not equivalent. |
|
10253 |
|
10254 if (!actualTokens || !expectedTokens) { |
|
10255 return false; |
|
10256 } |
|
10257 |
|
10258 let actualToken, expectedToken; |
|
10259 |
|
10260 while (actualToken = getNextNonWhitespaceToken(actualTokens)) { |
|
10261 expectedToken = getNextNonWhitespaceToken(expectedTokens); // Inequal if exhausted all expected tokens. |
|
10262 |
|
10263 if (!expectedToken) { |
|
10264 logger.warning('Expected end of content, instead saw %o.', actualToken); |
|
10265 return false; |
|
10266 } // Inequal if next non-whitespace token of each set are not same type. |
|
10267 |
|
10268 |
|
10269 if (actualToken.type !== expectedToken.type) { |
|
10270 logger.warning('Expected token of type `%s` (%o), instead saw `%s` (%o).', expectedToken.type, expectedToken, actualToken.type, actualToken); |
|
10271 return false; |
|
10272 } // Defer custom token type equality handling, otherwise continue and |
|
10273 // assume as equal. |
|
10274 |
|
10275 |
|
10276 const isEqualTokens = isEqualTokensOfType[actualToken.type]; |
|
10277 |
|
10278 if (isEqualTokens && !isEqualTokens(actualToken, expectedToken, logger)) { |
|
10279 return false; |
|
10280 } // Peek at the next tokens (actual and expected) to see if they close |
|
10281 // a self-closing tag. |
|
10282 |
|
10283 |
|
10284 if (isClosedByToken(actualToken, expectedTokens[0])) { |
|
10285 // Consume the next expected token that closes the current actual |
|
10286 // self-closing token. |
|
10287 getNextNonWhitespaceToken(expectedTokens); |
|
10288 } else if (isClosedByToken(expectedToken, actualTokens[0])) { |
|
10289 // Consume the next actual token that closes the current expected |
|
10290 // self-closing token. |
|
10291 getNextNonWhitespaceToken(actualTokens); |
|
10292 } |
|
10293 } |
|
10294 |
|
10295 if (expectedToken = getNextNonWhitespaceToken(expectedTokens)) { |
|
10296 // If any non-whitespace tokens remain in expected token set, this |
|
10297 // indicates inequality. |
|
10298 logger.warning('Expected %o, instead saw end of content.', expectedToken); |
|
10299 return false; |
|
10300 } |
|
10301 |
|
10302 return true; |
|
10303 } |
|
10304 /** |
|
10305 * Returns an object with `isValid` property set to `true` if the parsed block |
|
10306 * is valid given the input content. A block is considered valid if, when serialized |
|
10307 * with assumed attributes, the content matches the original value. If block is |
|
10308 * invalid, this function returns all validations issues as well. |
|
10309 * |
|
10310 * @param {string|Object} blockTypeOrName Block type. |
|
10311 * @param {Object} attributes Parsed block attributes. |
|
10312 * @param {string} originalBlockContent Original block content. |
|
10313 * @param {Object} logger Validation logger object. |
|
10314 * |
|
10315 * @return {Object} Whether block is valid and contains validation messages. |
|
10316 */ |
|
10317 |
|
10318 /** |
|
10319 * Returns an object with `isValid` property set to `true` if the parsed block |
|
10320 * is valid given the input content. A block is considered valid if, when serialized |
|
10321 * with assumed attributes, the content matches the original value. If block is |
|
10322 * invalid, this function returns all validations issues as well. |
|
10323 * |
|
10324 * @param {WPBlock} block block object. |
|
10325 * @param {WPBlockType|string} [blockTypeOrName = block.name] Block type or name, inferred from block if not given. |
|
10326 * |
|
10327 * @return {[boolean,Array<LoggerItem>]} validation results. |
|
10328 */ |
|
10329 |
|
10330 function validateBlock(block) { |
|
10331 let blockTypeOrName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : block.name; |
|
10332 const isFallbackBlock = block.name === getFreeformContentHandlerName() || block.name === getUnregisteredTypeHandlerName(); // Shortcut to avoid costly validation. |
|
10333 |
|
10334 if (isFallbackBlock) { |
|
10335 return [true, []]; |
|
10336 } |
|
10337 |
|
10338 const logger = createQueuedLogger(); |
|
10339 const blockType = normalizeBlockType(blockTypeOrName); |
|
10340 let generatedBlockContent; |
|
10341 |
|
10342 try { |
|
10343 generatedBlockContent = getSaveContent(blockType, block.attributes); |
|
10344 } catch (error) { |
|
10345 logger.error('Block validation failed because an error occurred while generating block content:\n\n%s', error.toString()); |
|
10346 return [false, logger.getItems()]; |
|
10347 } |
|
10348 |
|
10349 const isValid = isEquivalentHTML(block.originalContent, generatedBlockContent, logger); |
|
10350 |
|
10351 if (!isValid) { |
|
10352 logger.error('Block validation failed for `%s` (%o).\n\nContent generated by `save` function:\n\n%s\n\nContent retrieved from post body:\n\n%s', blockType.name, blockType, generatedBlockContent, block.originalContent); |
|
10353 } |
|
10354 |
|
10355 return [isValid, logger.getItems()]; |
|
10356 } |
|
10357 /** |
|
10358 * Returns true if the parsed block is valid given the input content. A block |
|
10359 * is considered valid if, when serialized with assumed attributes, the content |
|
10360 * matches the original value. |
|
10361 * |
|
10362 * Logs to console in development environments when invalid. |
|
10363 * |
|
10364 * @deprecated Use validateBlock instead to avoid data loss. |
|
10365 * |
|
10366 * @param {string|Object} blockTypeOrName Block type. |
|
10367 * @param {Object} attributes Parsed block attributes. |
|
10368 * @param {string} originalBlockContent Original block content. |
|
10369 * |
|
10370 * @return {boolean} Whether block is valid. |
|
10371 */ |
|
10372 |
|
10373 function isValidBlockContent(blockTypeOrName, attributes, originalBlockContent) { |
|
10374 external_wp_deprecated_default()('isValidBlockContent introduces opportunity for data loss', { |
|
10375 since: '12.6', |
|
10376 plugin: 'Gutenberg', |
|
10377 alternative: 'validateBlock' |
|
10378 }); |
|
10379 const blockType = normalizeBlockType(blockTypeOrName); |
|
10380 const block = { |
|
10381 name: blockType.name, |
|
10382 attributes, |
|
10383 innerBlocks: [], |
|
10384 originalContent: originalBlockContent |
|
10385 }; |
|
10386 const [isValid] = validateBlock(block, blockType); |
|
10387 return isValid; |
|
10388 } |
|
10389 |
|
10390 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/convert-legacy-block.js |
|
10391 /** |
|
10392 * Convert legacy blocks to their canonical form. This function is used |
|
10393 * both in the parser level for previous content and to convert such blocks |
|
10394 * used in Custom Post Types templates. |
|
10395 * |
|
10396 * @param {string} name The block's name |
|
10397 * @param {Object} attributes The block's attributes |
|
10398 * |
|
10399 * @return {[string, Object]} The block's name and attributes, changed accordingly if a match was found |
|
10400 */ |
|
10401 function convertLegacyBlockNameAndAttributes(name, attributes) { |
|
10402 const newAttributes = { ...attributes |
|
10403 }; // Convert 'core/cover-image' block in existing content to 'core/cover'. |
|
10404 |
|
10405 if ('core/cover-image' === name) { |
|
10406 name = 'core/cover'; |
|
10407 } // Convert 'core/text' blocks in existing content to 'core/paragraph'. |
|
10408 |
|
10409 |
|
10410 if ('core/text' === name || 'core/cover-text' === name) { |
|
10411 name = 'core/paragraph'; |
|
10412 } // Convert derivative blocks such as 'core/social-link-wordpress' to the |
|
10413 // canonical form 'core/social-link'. |
|
10414 |
|
10415 |
|
10416 if (name && name.indexOf('core/social-link-') === 0) { |
|
10417 // Capture `social-link-wordpress` into `{"service":"wordpress"}` |
|
10418 newAttributes.service = name.substring(17); |
|
10419 name = 'core/social-link'; |
|
10420 } // Convert derivative blocks such as 'core-embed/instagram' to the |
|
10421 // canonical form 'core/embed'. |
|
10422 |
|
10423 |
|
10424 if (name && name.indexOf('core-embed/') === 0) { |
|
10425 // Capture `core-embed/instagram` into `{"providerNameSlug":"instagram"}` |
|
10426 const providerSlug = name.substring(11); |
|
10427 const deprecated = { |
|
10428 speaker: 'speaker-deck', |
|
10429 polldaddy: 'crowdsignal' |
|
10430 }; |
|
10431 newAttributes.providerNameSlug = providerSlug in deprecated ? deprecated[providerSlug] : providerSlug; // This is needed as the `responsive` attribute was passed |
|
10432 // in a different way before the refactoring to block variations. |
|
10433 |
|
10434 if (!['amazon-kindle', 'wordpress'].includes(providerSlug)) { |
|
10435 newAttributes.responsive = true; |
|
10436 } |
|
10437 |
|
10438 name = 'core/embed'; |
|
10439 } // Convert 'core/query-loop' blocks in existing content to 'core/post-template'. |
|
10440 // TODO: Remove this check when WordPress 5.9 is released. |
|
10441 |
|
10442 |
|
10443 if (name === 'core/query-loop') { |
|
10444 name = 'core/post-template'; |
|
10445 } // Convert Post Comment blocks in existing content to Comment blocks. |
|
10446 // TODO: Remove these checks when WordPress 6.0 is released. |
|
10447 |
|
10448 |
|
10449 if (name === 'core/post-comment-author') { |
|
10450 name = 'core/comment-author-name'; |
|
10451 } |
|
10452 |
|
10453 if (name === 'core/post-comment-content') { |
|
10454 name = 'core/comment-content'; |
|
10455 } |
|
10456 |
|
10457 if (name === 'core/post-comment-date') { |
|
10458 name = 'core/comment-date'; |
|
10459 } |
|
10460 |
|
10461 return [name, newAttributes]; |
|
10462 } |
|
10463 |
|
10464 ;// CONCATENATED MODULE: ./node_modules/hpq/es/get-path.js |
|
10465 /** |
|
10466 * Given object and string of dot-delimited path segments, returns value at |
|
10467 * path or undefined if path cannot be resolved. |
|
10468 * |
|
10469 * @param {Object} object Lookup object |
|
10470 * @param {string} path Path to resolve |
|
10471 * @return {?*} Resolved value |
|
10472 */ |
|
10473 function getPath(object, path) { |
|
10474 var segments = path.split('.'); |
|
10475 var segment; |
|
10476 |
|
10477 while (segment = segments.shift()) { |
|
10478 if (!(segment in object)) { |
|
10479 return; |
|
10480 } |
|
10481 |
|
10482 object = object[segment]; |
|
10483 } |
|
10484 |
|
10485 return object; |
|
10486 } |
|
10487 ;// CONCATENATED MODULE: ./node_modules/hpq/es/index.js |
|
10488 /** |
|
10489 * Internal dependencies |
|
10490 */ |
|
10491 |
|
10492 /** |
|
10493 * Function returning a DOM document created by `createHTMLDocument`. The same |
|
10494 * document is returned between invocations. |
|
10495 * |
|
10496 * @return {Document} DOM document. |
|
10497 */ |
|
10498 |
|
10499 var getDocument = function () { |
|
10500 var doc; |
|
10501 return function () { |
|
10502 if (!doc) { |
|
10503 doc = document.implementation.createHTMLDocument(''); |
|
10504 } |
|
10505 |
|
10506 return doc; |
|
10507 }; |
|
10508 }(); |
|
10509 /** |
|
10510 * Given a markup string or DOM element, creates an object aligning with the |
|
10511 * shape of the matchers object, or the value returned by the matcher. |
|
10512 * |
|
10513 * @param {(string|Element)} source Source content |
|
10514 * @param {(Object|Function)} matchers Matcher function or object of matchers |
|
10515 * @return {(Object|*)} Matched value(s), shaped by object |
|
10516 */ |
|
10517 |
|
10518 |
|
10519 function parse(source, matchers) { |
|
10520 if (!matchers) { |
|
10521 return; |
|
10522 } // Coerce to element |
|
10523 |
|
10524 |
|
10525 if ('string' === typeof source) { |
|
10526 var doc = getDocument(); |
|
10527 doc.body.innerHTML = source; |
|
10528 source = doc.body; |
|
10529 } // Return singular value |
|
10530 |
|
10531 |
|
10532 if ('function' === typeof matchers) { |
|
10533 return matchers(source); |
|
10534 } // Bail if we can't handle matchers |
|
10535 |
|
10536 |
|
10537 if (Object !== matchers.constructor) { |
|
10538 return; |
|
10539 } // Shape result by matcher object |
|
10540 |
|
10541 |
|
10542 return Object.keys(matchers).reduce(function (memo, key) { |
|
10543 memo[key] = parse(source, matchers[key]); |
|
10544 return memo; |
|
10545 }, {}); |
|
10546 } |
|
10547 /** |
|
10548 * Generates a function which matches node of type selector, returning an |
|
10549 * attribute by property if the attribute exists. If no selector is passed, |
|
10550 * returns property of the query element. |
|
10551 * |
|
10552 * @param {?string} selector Optional selector |
|
10553 * @param {string} name Property name |
|
10554 * @return {*} Property value |
|
10555 */ |
|
10556 |
|
10557 function prop(selector, name) { |
|
10558 if (1 === arguments.length) { |
|
10559 name = selector; |
|
10560 selector = undefined; |
|
10561 } |
|
10562 |
|
10563 return function (node) { |
|
10564 var match = node; |
|
10565 |
|
10566 if (selector) { |
|
10567 match = node.querySelector(selector); |
|
10568 } |
|
10569 |
|
10570 if (match) { |
|
10571 return getPath(match, name); |
|
10572 } |
|
10573 }; |
|
10574 } |
|
10575 /** |
|
10576 * Generates a function which matches node of type selector, returning an |
|
10577 * attribute by name if the attribute exists. If no selector is passed, |
|
10578 * returns attribute of the query element. |
|
10579 * |
|
10580 * @param {?string} selector Optional selector |
|
10581 * @param {string} name Attribute name |
|
10582 * @return {?string} Attribute value |
|
10583 */ |
|
10584 |
|
10585 function attr(selector, name) { |
|
10586 if (1 === arguments.length) { |
|
10587 name = selector; |
|
10588 selector = undefined; |
|
10589 } |
|
10590 |
|
10591 return function (node) { |
|
10592 var attributes = prop(selector, 'attributes')(node); |
|
10593 |
|
10594 if (attributes && attributes.hasOwnProperty(name)) { |
|
10595 return attributes[name].value; |
|
10596 } |
|
10597 }; |
|
10598 } |
|
10599 /** |
|
10600 * Convenience for `prop( selector, 'innerHTML' )`. |
|
10601 * |
|
10602 * @see prop() |
|
10603 * |
|
10604 * @param {?string} selector Optional selector |
|
10605 * @return {string} Inner HTML |
|
10606 */ |
|
10607 |
|
10608 function html(selector) { |
|
10609 return prop(selector, 'innerHTML'); |
|
10610 } |
|
10611 /** |
|
10612 * Convenience for `prop( selector, 'textContent' )`. |
|
10613 * |
|
10614 * @see prop() |
|
10615 * |
|
10616 * @param {?string} selector Optional selector |
|
10617 * @return {string} Text content |
|
10618 */ |
|
10619 |
|
10620 function es_text(selector) { |
|
10621 return prop(selector, 'textContent'); |
|
10622 } |
|
10623 /** |
|
10624 * Creates a new matching context by first finding elements matching selector |
|
10625 * using querySelectorAll before then running another `parse` on `matchers` |
|
10626 * scoped to the matched elements. |
|
10627 * |
|
10628 * @see parse() |
|
10629 * |
|
10630 * @param {string} selector Selector to match |
|
10631 * @param {(Object|Function)} matchers Matcher function or object of matchers |
|
10632 * @return {Array.<*,Object>} Array of matched value(s) |
|
10633 */ |
|
10634 |
|
10635 function query(selector, matchers) { |
|
10636 return function (node) { |
|
10637 var matches = node.querySelectorAll(selector); |
|
10638 return [].map.call(matches, function (match) { |
|
10639 return parse(match, matchers); |
|
10640 }); |
|
10641 }; |
|
10642 } |
|
10643 // EXTERNAL MODULE: ./node_modules/memize/index.js |
|
10644 var memize = __webpack_require__(9756); |
|
10645 var memize_default = /*#__PURE__*/__webpack_require__.n(memize); |
|
10646 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/matchers.js |
|
10647 /** |
|
10648 * External dependencies |
|
10649 */ |
|
10650 |
|
10651 /** |
|
10652 * Internal dependencies |
|
10653 */ |
|
10654 |
|
10655 |
|
10656 |
|
10657 function matchers_html(selector, multilineTag) { |
|
10658 return domNode => { |
|
10659 let match = domNode; |
|
10660 |
|
10661 if (selector) { |
|
10662 match = domNode.querySelector(selector); |
|
10663 } |
|
10664 |
|
10665 if (!match) { |
|
10666 return ''; |
|
10667 } |
|
10668 |
|
10669 if (multilineTag) { |
|
10670 let value = ''; |
|
10671 const length = match.children.length; |
|
10672 |
|
10673 for (let index = 0; index < length; index++) { |
|
10674 const child = match.children[index]; |
|
10675 |
|
10676 if (child.nodeName.toLowerCase() !== multilineTag) { |
|
10677 continue; |
|
10678 } |
|
10679 |
|
10680 value += child.outerHTML; |
|
10681 } |
|
10682 |
|
10683 return value; |
|
10684 } |
|
10685 |
|
10686 return match.innerHTML; |
|
10687 }; |
|
10688 } |
|
10689 |
|
10690 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/node.js |
|
10691 /** |
|
10692 * Internal dependencies |
|
10693 */ |
|
10694 |
|
10695 /** |
|
10696 * A representation of a single node within a block's rich text value. If |
|
10697 * representing a text node, the value is simply a string of the node value. |
|
10698 * As representing an element node, it is an object of: |
|
10699 * |
|
10700 * 1. `type` (string): Tag name. |
|
10701 * 2. `props` (object): Attributes and children array of WPBlockNode. |
|
10702 * |
|
10703 * @typedef {string|Object} WPBlockNode |
|
10704 */ |
|
10705 |
|
10706 /** |
|
10707 * Given a single node and a node type (e.g. `'br'`), returns true if the node |
|
10708 * corresponds to that type, false otherwise. |
|
10709 * |
|
10710 * @param {WPBlockNode} node Block node to test |
|
10711 * @param {string} type Node to type to test against. |
|
10712 * |
|
10713 * @return {boolean} Whether node is of intended type. |
|
10714 */ |
|
10715 |
|
10716 function isNodeOfType(node, type) { |
|
10717 return node && node.type === type; |
|
10718 } |
|
10719 /** |
|
10720 * Given an object implementing the NamedNodeMap interface, returns a plain |
|
10721 * object equivalent value of name, value key-value pairs. |
|
10722 * |
|
10723 * @see https://dom.spec.whatwg.org/#interface-namednodemap |
|
10724 * |
|
10725 * @param {NamedNodeMap} nodeMap NamedNodeMap to convert to object. |
|
10726 * |
|
10727 * @return {Object} Object equivalent value of NamedNodeMap. |
|
10728 */ |
|
10729 |
|
10730 |
|
10731 function getNamedNodeMapAsObject(nodeMap) { |
|
10732 const result = {}; |
|
10733 |
|
10734 for (let i = 0; i < nodeMap.length; i++) { |
|
10735 const { |
|
10736 name, |
|
10737 value |
|
10738 } = nodeMap[i]; |
|
10739 result[name] = value; |
|
10740 } |
|
10741 |
|
10742 return result; |
|
10743 } |
|
10744 /** |
|
10745 * Given a DOM Element or Text node, returns an equivalent block node. Throws |
|
10746 * if passed any node type other than element or text. |
|
10747 * |
|
10748 * @throws {TypeError} If non-element/text node is passed. |
|
10749 * |
|
10750 * @param {Node} domNode DOM node to convert. |
|
10751 * |
|
10752 * @return {WPBlockNode} Block node equivalent to DOM node. |
|
10753 */ |
|
10754 |
|
10755 function fromDOM(domNode) { |
|
10756 if (domNode.nodeType === domNode.TEXT_NODE) { |
|
10757 return domNode.nodeValue; |
|
10758 } |
|
10759 |
|
10760 if (domNode.nodeType !== domNode.ELEMENT_NODE) { |
|
10761 throw new TypeError('A block node can only be created from a node of type text or ' + 'element.'); |
|
10762 } |
|
10763 |
|
10764 return { |
|
10765 type: domNode.nodeName.toLowerCase(), |
|
10766 props: { ...getNamedNodeMapAsObject(domNode.attributes), |
|
10767 children: children_fromDOM(domNode.childNodes) |
|
10768 } |
|
10769 }; |
|
10770 } |
|
10771 /** |
|
10772 * Given a block node, returns its HTML string representation. |
|
10773 * |
|
10774 * @param {WPBlockNode} node Block node to convert to string. |
|
10775 * |
|
10776 * @return {string} String HTML representation of block node. |
|
10777 */ |
|
10778 |
|
10779 function toHTML(node) { |
|
10780 return children_toHTML([node]); |
|
10781 } |
|
10782 /** |
|
10783 * Given a selector, returns an hpq matcher generating a WPBlockNode value |
|
10784 * matching the selector result. |
|
10785 * |
|
10786 * @param {string} selector DOM selector. |
|
10787 * |
|
10788 * @return {Function} hpq matcher. |
|
10789 */ |
|
10790 |
|
10791 function node_matcher(selector) { |
|
10792 return domNode => { |
|
10793 let match = domNode; |
|
10794 |
|
10795 if (selector) { |
|
10796 match = domNode.querySelector(selector); |
|
10797 } |
|
10798 |
|
10799 try { |
|
10800 return fromDOM(match); |
|
10801 } catch (error) { |
|
10802 return null; |
|
10803 } |
|
10804 }; |
|
10805 } |
|
10806 /** |
|
10807 * Object of utility functions used in managing block attribute values of |
|
10808 * source `node`. |
|
10809 * |
|
10810 * @see https://github.com/WordPress/gutenberg/pull/10439 |
|
10811 * |
|
10812 * @deprecated since 4.0. The `node` source should not be used, and can be |
|
10813 * replaced by the `html` source. |
|
10814 * |
|
10815 * @private |
|
10816 */ |
|
10817 |
|
10818 /* harmony default export */ var node = ({ |
|
10819 isNodeOfType, |
|
10820 fromDOM, |
|
10821 toHTML, |
|
10822 matcher: node_matcher |
|
10823 }); |
|
10824 |
|
10825 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/children.js |
|
10826 /** |
|
10827 * External dependencies |
|
10828 */ |
|
10829 |
|
10830 /** |
|
10831 * WordPress dependencies |
|
10832 */ |
|
10833 |
|
10834 |
|
10835 /** |
|
10836 * Internal dependencies |
|
10837 */ |
|
10838 |
|
10839 |
|
10840 /** |
|
10841 * A representation of a block's rich text value. |
|
10842 * |
|
10843 * @typedef {WPBlockNode[]} WPBlockChildren |
|
10844 */ |
|
10845 |
|
10846 /** |
|
10847 * Given block children, returns a serialize-capable WordPress element. |
|
10848 * |
|
10849 * @param {WPBlockChildren} children Block children object to convert. |
|
10850 * |
|
10851 * @return {WPElement} A serialize-capable element. |
|
10852 */ |
|
10853 |
|
10854 function getSerializeCapableElement(children) { |
|
10855 // The fact that block children are compatible with the element serializer is |
|
10856 // merely an implementation detail that currently serves to be true, but |
|
10857 // should not be mistaken as being a guarantee on the external API. The |
|
10858 // public API only offers guarantees to work with strings (toHTML) and DOM |
|
10859 // elements (fromDOM), and should provide utilities to manipulate the value |
|
10860 // rather than expect consumers to inspect or construct its shape (concat). |
|
10861 return children; |
|
10862 } |
|
10863 /** |
|
10864 * Given block children, returns an array of block nodes. |
|
10865 * |
|
10866 * @param {WPBlockChildren} children Block children object to convert. |
|
10867 * |
|
10868 * @return {Array<WPBlockNode>} An array of individual block nodes. |
|
10869 */ |
|
10870 |
|
10871 function getChildrenArray(children) { |
|
10872 // The fact that block children are compatible with the element serializer |
|
10873 // is merely an implementation detail that currently serves to be true, but |
|
10874 // should not be mistaken as being a guarantee on the external API. |
|
10875 return children; |
|
10876 } |
|
10877 /** |
|
10878 * Given two or more block nodes, returns a new block node representing a |
|
10879 * concatenation of its values. |
|
10880 * |
|
10881 * @param {...WPBlockChildren} blockNodes Block nodes to concatenate. |
|
10882 * |
|
10883 * @return {WPBlockChildren} Concatenated block node. |
|
10884 */ |
|
10885 |
|
10886 |
|
10887 function concat() { |
|
10888 const result = []; |
|
10889 |
|
10890 for (let i = 0; i < arguments.length; i++) { |
|
10891 const blockNode = (0,external_lodash_namespaceObject.castArray)(i < 0 || arguments.length <= i ? undefined : arguments[i]); |
|
10892 |
|
10893 for (let j = 0; j < blockNode.length; j++) { |
|
10894 const child = blockNode[j]; |
|
10895 const canConcatToPreviousString = typeof child === 'string' && typeof result[result.length - 1] === 'string'; |
|
10896 |
|
10897 if (canConcatToPreviousString) { |
|
10898 result[result.length - 1] += child; |
|
10899 } else { |
|
10900 result.push(child); |
|
10901 } |
|
10902 } |
|
10903 } |
|
10904 |
|
10905 return result; |
|
10906 } |
|
10907 /** |
|
10908 * Given an iterable set of DOM nodes, returns equivalent block children. |
|
10909 * Ignores any non-element/text nodes included in set. |
|
10910 * |
|
10911 * @param {Iterable.<Node>} domNodes Iterable set of DOM nodes to convert. |
|
10912 * |
|
10913 * @return {WPBlockChildren} Block children equivalent to DOM nodes. |
|
10914 */ |
|
10915 |
|
10916 function children_fromDOM(domNodes) { |
|
10917 const result = []; |
|
10918 |
|
10919 for (let i = 0; i < domNodes.length; i++) { |
|
10920 try { |
|
10921 result.push(fromDOM(domNodes[i])); |
|
10922 } catch (error) {// Simply ignore if DOM node could not be converted. |
|
10923 } |
|
10924 } |
|
10925 |
|
10926 return result; |
|
10927 } |
|
10928 /** |
|
10929 * Given a block node, returns its HTML string representation. |
|
10930 * |
|
10931 * @param {WPBlockChildren} children Block node(s) to convert to string. |
|
10932 * |
|
10933 * @return {string} String HTML representation of block node. |
|
10934 */ |
|
10935 |
|
10936 function children_toHTML(children) { |
|
10937 const element = getSerializeCapableElement(children); |
|
10938 return (0,external_wp_element_namespaceObject.renderToString)(element); |
|
10939 } |
|
10940 /** |
|
10941 * Given a selector, returns an hpq matcher generating a WPBlockChildren value |
|
10942 * matching the selector result. |
|
10943 * |
|
10944 * @param {string} selector DOM selector. |
|
10945 * |
|
10946 * @return {Function} hpq matcher. |
|
10947 */ |
|
10948 |
|
10949 function children_matcher(selector) { |
|
10950 return domNode => { |
|
10951 let match = domNode; |
|
10952 |
|
10953 if (selector) { |
|
10954 match = domNode.querySelector(selector); |
|
10955 } |
|
10956 |
|
10957 if (match) { |
|
10958 return children_fromDOM(match.childNodes); |
|
10959 } |
|
10960 |
|
10961 return []; |
|
10962 }; |
|
10963 } |
|
10964 /** |
|
10965 * Object of utility functions used in managing block attribute values of |
|
10966 * source `children`. |
|
10967 * |
|
10968 * @see https://github.com/WordPress/gutenberg/pull/10439 |
|
10969 * |
|
10970 * @deprecated since 4.0. The `children` source should not be used, and can be |
|
10971 * replaced by the `html` source. |
|
10972 * |
|
10973 * @private |
|
10974 */ |
|
10975 |
|
10976 /* harmony default export */ var children = ({ |
|
10977 concat, |
|
10978 getChildrenArray, |
|
10979 fromDOM: children_fromDOM, |
|
10980 toHTML: children_toHTML, |
|
10981 matcher: children_matcher |
|
10982 }); |
|
10983 |
|
10984 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/get-block-attributes.js |
|
10985 /** |
|
10986 * External dependencies |
|
10987 */ |
|
10988 |
|
10989 |
|
10990 |
|
10991 /** |
|
10992 * WordPress dependencies |
|
10993 */ |
|
10994 |
|
10995 |
|
10996 /** |
|
10997 * Internal dependencies |
|
10998 */ |
|
10999 |
|
11000 |
|
11001 |
|
11002 /** |
|
11003 * Higher-order hpq matcher which enhances an attribute matcher to return true |
|
11004 * or false depending on whether the original matcher returns undefined. This |
|
11005 * is useful for boolean attributes (e.g. disabled) whose attribute values may |
|
11006 * be technically falsey (empty string), though their mere presence should be |
|
11007 * enough to infer as true. |
|
11008 * |
|
11009 * @param {Function} matcher Original hpq matcher. |
|
11010 * |
|
11011 * @return {Function} Enhanced hpq matcher. |
|
11012 */ |
|
11013 |
|
11014 const toBooleanAttributeMatcher = matcher => (0,external_lodash_namespaceObject.flow)([matcher, // Expected values from `attr( 'disabled' )`: |
|
11015 // |
|
11016 // <input> |
|
11017 // - Value: `undefined` |
|
11018 // - Transformed: `false` |
|
11019 // |
|
11020 // <input disabled> |
|
11021 // - Value: `''` |
|
11022 // - Transformed: `true` |
|
11023 // |
|
11024 // <input disabled="disabled"> |
|
11025 // - Value: `'disabled'` |
|
11026 // - Transformed: `true` |
|
11027 value => value !== undefined]); |
|
11028 /** |
|
11029 * Returns true if value is of the given JSON schema type, or false otherwise. |
|
11030 * |
|
11031 * @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25 |
|
11032 * |
|
11033 * @param {*} value Value to test. |
|
11034 * @param {string} type Type to test. |
|
11035 * |
|
11036 * @return {boolean} Whether value is of type. |
|
11037 */ |
|
11038 |
|
11039 function isOfType(value, type) { |
|
11040 switch (type) { |
|
11041 case 'string': |
|
11042 return typeof value === 'string'; |
|
11043 |
|
11044 case 'boolean': |
|
11045 return typeof value === 'boolean'; |
|
11046 |
|
11047 case 'object': |
|
11048 return !!value && value.constructor === Object; |
|
11049 |
|
11050 case 'null': |
|
11051 return value === null; |
|
11052 |
|
11053 case 'array': |
|
11054 return Array.isArray(value); |
|
11055 |
|
11056 case 'integer': |
|
11057 case 'number': |
|
11058 return typeof value === 'number'; |
|
11059 } |
|
11060 |
|
11061 return true; |
|
11062 } |
|
11063 /** |
|
11064 * Returns true if value is of an array of given JSON schema types, or false |
|
11065 * otherwise. |
|
11066 * |
|
11067 * @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25 |
|
11068 * |
|
11069 * @param {*} value Value to test. |
|
11070 * @param {string[]} types Types to test. |
|
11071 * |
|
11072 * @return {boolean} Whether value is of types. |
|
11073 */ |
|
11074 |
|
11075 function isOfTypes(value, types) { |
|
11076 return types.some(type => isOfType(value, type)); |
|
11077 } |
|
11078 /** |
|
11079 * Given an attribute key, an attribute's schema, a block's raw content and the |
|
11080 * commentAttributes returns the attribute value depending on its source |
|
11081 * definition of the given attribute key. |
|
11082 * |
|
11083 * @param {string} attributeKey Attribute key. |
|
11084 * @param {Object} attributeSchema Attribute's schema. |
|
11085 * @param {string|Node} innerHTML Block's raw content. |
|
11086 * @param {Object} commentAttributes Block's comment attributes. |
|
11087 * |
|
11088 * @return {*} Attribute value. |
|
11089 */ |
|
11090 |
|
11091 function getBlockAttribute(attributeKey, attributeSchema, innerHTML, commentAttributes) { |
|
11092 let value; |
|
11093 |
|
11094 switch (attributeSchema.source) { |
|
11095 // An undefined source means that it's an attribute serialized to the |
|
11096 // block's "comment". |
|
11097 case undefined: |
|
11098 value = commentAttributes ? commentAttributes[attributeKey] : undefined; |
|
11099 break; |
|
11100 |
|
11101 case 'attribute': |
|
11102 case 'property': |
|
11103 case 'html': |
|
11104 case 'text': |
|
11105 case 'children': |
|
11106 case 'node': |
|
11107 case 'query': |
|
11108 case 'tag': |
|
11109 value = parseWithAttributeSchema(innerHTML, attributeSchema); |
|
11110 break; |
|
11111 } |
|
11112 |
|
11113 if (!isValidByType(value, attributeSchema.type) || !isValidByEnum(value, attributeSchema.enum)) { |
|
11114 // Reject the value if it is not valid. Reverting to the undefined |
|
11115 // value ensures the default is respected, if applicable. |
|
11116 value = undefined; |
|
11117 } |
|
11118 |
|
11119 if (value === undefined) { |
|
11120 value = attributeSchema.default; |
|
11121 } |
|
11122 |
|
11123 return value; |
|
11124 } |
|
11125 /** |
|
11126 * Returns true if value is valid per the given block attribute schema type |
|
11127 * definition, or false otherwise. |
|
11128 * |
|
11129 * @see https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.1 |
|
11130 * |
|
11131 * @param {*} value Value to test. |
|
11132 * @param {?(Array<string>|string)} type Block attribute schema type. |
|
11133 * |
|
11134 * @return {boolean} Whether value is valid. |
|
11135 */ |
|
11136 |
|
11137 function isValidByType(value, type) { |
|
11138 return type === undefined || isOfTypes(value, (0,external_lodash_namespaceObject.castArray)(type)); |
|
11139 } |
|
11140 /** |
|
11141 * Returns true if value is valid per the given block attribute schema enum |
|
11142 * definition, or false otherwise. |
|
11143 * |
|
11144 * @see https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.2 |
|
11145 * |
|
11146 * @param {*} value Value to test. |
|
11147 * @param {?Array} enumSet Block attribute schema enum. |
|
11148 * |
|
11149 * @return {boolean} Whether value is valid. |
|
11150 */ |
|
11151 |
|
11152 function isValidByEnum(value, enumSet) { |
|
11153 return !Array.isArray(enumSet) || enumSet.includes(value); |
|
11154 } |
|
11155 /** |
|
11156 * Returns an hpq matcher given a source object. |
|
11157 * |
|
11158 * @param {Object} sourceConfig Attribute Source object. |
|
11159 * |
|
11160 * @return {Function} A hpq Matcher. |
|
11161 */ |
|
11162 |
|
11163 const matcherFromSource = memize_default()(sourceConfig => { |
|
11164 switch (sourceConfig.source) { |
|
11165 case 'attribute': |
|
11166 let matcher = attr(sourceConfig.selector, sourceConfig.attribute); |
|
11167 |
|
11168 if (sourceConfig.type === 'boolean') { |
|
11169 matcher = toBooleanAttributeMatcher(matcher); |
|
11170 } |
|
11171 |
|
11172 return matcher; |
|
11173 |
|
11174 case 'html': |
|
11175 return matchers_html(sourceConfig.selector, sourceConfig.multiline); |
|
11176 |
|
11177 case 'text': |
|
11178 return es_text(sourceConfig.selector); |
|
11179 |
|
11180 case 'children': |
|
11181 return children_matcher(sourceConfig.selector); |
|
11182 |
|
11183 case 'node': |
|
11184 return node_matcher(sourceConfig.selector); |
|
11185 |
|
11186 case 'query': |
|
11187 const subMatchers = (0,external_lodash_namespaceObject.mapValues)(sourceConfig.query, matcherFromSource); |
|
11188 return query(sourceConfig.selector, subMatchers); |
|
11189 |
|
11190 case 'tag': |
|
11191 return (0,external_lodash_namespaceObject.flow)([prop(sourceConfig.selector, 'nodeName'), nodeName => nodeName ? nodeName.toLowerCase() : undefined]); |
|
11192 |
|
11193 default: |
|
11194 // eslint-disable-next-line no-console |
|
11195 console.error(`Unknown source type "${sourceConfig.source}"`); |
|
11196 } |
|
11197 }); |
|
11198 /** |
|
11199 * Parse a HTML string into DOM tree. |
|
11200 * |
|
11201 * @param {string|Node} innerHTML HTML string or already parsed DOM node. |
|
11202 * |
|
11203 * @return {Node} Parsed DOM node. |
|
11204 */ |
|
11205 |
|
11206 function parseHtml(innerHTML) { |
|
11207 return parse(innerHTML, h => h); |
|
11208 } |
|
11209 /** |
|
11210 * Given a block's raw content and an attribute's schema returns the attribute's |
|
11211 * value depending on its source. |
|
11212 * |
|
11213 * @param {string|Node} innerHTML Block's raw content. |
|
11214 * @param {Object} attributeSchema Attribute's schema. |
|
11215 * |
|
11216 * @return {*} Attribute value. |
|
11217 */ |
|
11218 |
|
11219 |
|
11220 function parseWithAttributeSchema(innerHTML, attributeSchema) { |
|
11221 return matcherFromSource(attributeSchema)(parseHtml(innerHTML)); |
|
11222 } |
|
11223 /** |
|
11224 * Returns the block attributes of a registered block node given its type. |
|
11225 * |
|
11226 * @param {string|Object} blockTypeOrName Block type or name. |
|
11227 * @param {string|Node} innerHTML Raw block content. |
|
11228 * @param {?Object} attributes Known block attributes (from delimiters). |
|
11229 * |
|
11230 * @return {Object} All block attributes. |
|
11231 */ |
|
11232 |
|
11233 function getBlockAttributes(blockTypeOrName, innerHTML) { |
|
11234 let attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; |
|
11235 const doc = parseHtml(innerHTML); |
|
11236 const blockType = normalizeBlockType(blockTypeOrName); |
|
11237 const blockAttributes = (0,external_lodash_namespaceObject.mapValues)(blockType.attributes, (schema, key) => getBlockAttribute(key, schema, doc, attributes)); |
|
11238 return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getBlockAttributes', blockAttributes, blockType, innerHTML, attributes); |
|
11239 } |
|
11240 |
|
11241 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/fix-custom-classname.js |
|
11242 /** |
|
11243 * External dependencies |
|
11244 */ |
|
11245 |
|
11246 /** |
|
11247 * Internal dependencies |
|
11248 */ |
|
11249 |
|
11250 |
|
11251 |
|
11252 |
|
11253 const CLASS_ATTR_SCHEMA = { |
|
11254 type: 'string', |
|
11255 source: 'attribute', |
|
11256 selector: '[data-custom-class-name] > *', |
|
11257 attribute: 'class' |
|
11258 }; |
|
11259 /** |
|
11260 * Given an HTML string, returns an array of class names assigned to the root |
|
11261 * element in the markup. |
|
11262 * |
|
11263 * @param {string} innerHTML Markup string from which to extract classes. |
|
11264 * |
|
11265 * @return {string[]} Array of class names assigned to the root element. |
|
11266 */ |
|
11267 |
|
11268 function getHTMLRootElementClasses(innerHTML) { |
|
11269 const parsed = parseWithAttributeSchema(`<div data-custom-class-name>${innerHTML}</div>`, CLASS_ATTR_SCHEMA); |
|
11270 return parsed ? parsed.trim().split(/\s+/) : []; |
|
11271 } |
|
11272 /** |
|
11273 * Given a parsed set of block attributes, if the block supports custom class |
|
11274 * names and an unknown class (per the block's serialization behavior) is |
|
11275 * found, the unknown classes are treated as custom classes. This prevents the |
|
11276 * block from being considered as invalid. |
|
11277 * |
|
11278 * @param {Object} blockAttributes Original block attributes. |
|
11279 * @param {Object} blockType Block type settings. |
|
11280 * @param {string} innerHTML Original block markup. |
|
11281 * |
|
11282 * @return {Object} Filtered block attributes. |
|
11283 */ |
|
11284 |
|
11285 function fixCustomClassname(blockAttributes, blockType, innerHTML) { |
|
11286 if (registration_hasBlockSupport(blockType, 'customClassName', true)) { |
|
11287 // To determine difference, serialize block given the known set of |
|
11288 // attributes, with the exception of `className`. This will determine |
|
11289 // the default set of classes. From there, any difference in innerHTML |
|
11290 // can be considered as custom classes. |
|
11291 const attributesSansClassName = (0,external_lodash_namespaceObject.omit)(blockAttributes, ['className']); |
|
11292 const serialized = getSaveContent(blockType, attributesSansClassName); |
|
11293 const defaultClasses = getHTMLRootElementClasses(serialized); |
|
11294 const actualClasses = getHTMLRootElementClasses(innerHTML); |
|
11295 const customClasses = (0,external_lodash_namespaceObject.difference)(actualClasses, defaultClasses); |
|
11296 |
|
11297 if (customClasses.length) { |
|
11298 blockAttributes.className = customClasses.join(' '); |
|
11299 } else if (serialized) { |
|
11300 delete blockAttributes.className; |
|
11301 } |
|
11302 } |
|
11303 |
|
11304 return blockAttributes; |
|
11305 } |
|
11306 |
|
11307 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/apply-built-in-validation-fixes.js |
|
11308 /** |
|
11309 * Internal dependencies |
|
11310 */ |
|
11311 |
|
11312 /** |
|
11313 * Attempts to fix block invalidation by applying build-in validation fixes |
|
11314 * like moving all extra classNames to the className attribute. |
|
11315 * |
|
11316 * @param {WPBlock} block block object. |
|
11317 * @param {import('../registration').WPBlockType} blockType Block type. This is normalize not necessary and |
|
11318 * can be inferred from the block name, |
|
11319 * but it's here for performance reasons. |
|
11320 * |
|
11321 * @return {WPBlock} Fixed block object |
|
11322 */ |
|
11323 |
|
11324 function applyBuiltInValidationFixes(block, blockType) { |
|
11325 const updatedBlockAttributes = fixCustomClassname(block.attributes, blockType, block.originalContent); |
|
11326 return { ...block, |
|
11327 attributes: updatedBlockAttributes |
|
11328 }; |
|
11329 } |
|
11330 |
|
11331 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/apply-block-deprecated-versions.js |
|
11332 /** |
|
11333 * External dependencies |
|
11334 */ |
|
11335 |
|
11336 /** |
|
11337 * Internal dependencies |
|
11338 */ |
|
11339 |
|
11340 |
|
11341 |
|
11342 |
|
11343 |
|
11344 /** |
|
11345 * Given a block object, returns a new copy of the block with any applicable |
|
11346 * deprecated migrations applied, or the original block if it was both valid |
|
11347 * and no eligible migrations exist. |
|
11348 * |
|
11349 * @param {import(".").WPBlock} block Parsed and invalid block object. |
|
11350 * @param {import(".").WPRawBlock} rawBlock Raw block object. |
|
11351 * @param {import('../registration').WPBlockType} blockType Block type. This is normalize not necessary and |
|
11352 * can be inferred from the block name, |
|
11353 * but it's here for performance reasons. |
|
11354 * |
|
11355 * @return {import(".").WPBlock} Migrated block object. |
|
11356 */ |
|
11357 |
|
11358 function applyBlockDeprecatedVersions(block, rawBlock, blockType) { |
|
11359 const parsedAttributes = rawBlock.attrs; |
|
11360 const { |
|
11361 deprecated: deprecatedDefinitions |
|
11362 } = blockType; // Bail early if there are no registered deprecations to be handled. |
|
11363 |
|
11364 if (!deprecatedDefinitions || !deprecatedDefinitions.length) { |
|
11365 return block; |
|
11366 } // By design, blocks lack any sort of version tracking. Instead, to process |
|
11367 // outdated content the system operates a queue out of all the defined |
|
11368 // attribute shapes and tries each definition until the input produces a |
|
11369 // valid result. This mechanism seeks to avoid polluting the user-space with |
|
11370 // machine-specific code. An invalid block is thus a block that could not be |
|
11371 // matched successfully with any of the registered deprecation definitions. |
|
11372 |
|
11373 |
|
11374 for (let i = 0; i < deprecatedDefinitions.length; i++) { |
|
11375 // A block can opt into a migration even if the block is valid by |
|
11376 // defining `isEligible` on its deprecation. If the block is both valid |
|
11377 // and does not opt to migrate, skip. |
|
11378 const { |
|
11379 isEligible = external_lodash_namespaceObject.stubFalse |
|
11380 } = deprecatedDefinitions[i]; |
|
11381 |
|
11382 if (block.isValid && !isEligible(parsedAttributes, block.innerBlocks)) { |
|
11383 continue; |
|
11384 } // Block type properties which could impact either serialization or |
|
11385 // parsing are not considered in the deprecated block type by default, |
|
11386 // and must be explicitly provided. |
|
11387 |
|
11388 |
|
11389 const deprecatedBlockType = Object.assign((0,external_lodash_namespaceObject.omit)(blockType, DEPRECATED_ENTRY_KEYS), deprecatedDefinitions[i]); |
|
11390 let migratedBlock = { ...block, |
|
11391 attributes: getBlockAttributes(deprecatedBlockType, block.originalContent, parsedAttributes) |
|
11392 }; // Ignore the deprecation if it produces a block which is not valid. |
|
11393 |
|
11394 let [isValid] = validateBlock(migratedBlock, deprecatedBlockType); // If the migrated block is not valid initially, try the built-in fixes. |
|
11395 |
|
11396 if (!isValid) { |
|
11397 migratedBlock = applyBuiltInValidationFixes(migratedBlock, deprecatedBlockType); |
|
11398 [isValid] = validateBlock(migratedBlock, deprecatedBlockType); |
|
11399 } // An invalid block does not imply incorrect HTML but the fact block |
|
11400 // source information could be lost on re-serialization. |
|
11401 |
|
11402 |
|
11403 if (!isValid) { |
|
11404 continue; |
|
11405 } |
|
11406 |
|
11407 let migratedInnerBlocks = migratedBlock.innerBlocks; |
|
11408 let migratedAttributes = migratedBlock.attributes; // A block may provide custom behavior to assign new attributes and/or |
|
11409 // inner blocks. |
|
11410 |
|
11411 const { |
|
11412 migrate |
|
11413 } = deprecatedBlockType; |
|
11414 |
|
11415 if (migrate) { |
|
11416 [migratedAttributes = parsedAttributes, migratedInnerBlocks = block.innerBlocks] = (0,external_lodash_namespaceObject.castArray)(migrate(migratedAttributes, block.innerBlocks)); |
|
11417 } |
|
11418 |
|
11419 block = { ...block, |
|
11420 attributes: migratedAttributes, |
|
11421 innerBlocks: migratedInnerBlocks, |
|
11422 isValid: true, |
|
11423 validationIssues: [] |
|
11424 }; |
|
11425 } |
|
11426 |
|
11427 return block; |
|
11428 } |
|
11429 |
|
11430 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/index.js |
|
11431 /** |
|
11432 * WordPress dependencies |
|
11433 */ |
|
11434 |
|
11435 |
|
11436 /** |
|
11437 * Internal dependencies |
|
11438 */ |
|
11439 |
|
11440 |
|
11441 |
|
11442 |
|
11443 |
|
11444 |
|
11445 |
|
11446 |
|
11447 |
|
11448 |
|
11449 /** |
|
11450 * The raw structure of a block includes its attributes, inner |
|
11451 * blocks, and inner HTML. It is important to distinguish inner blocks from |
|
11452 * the HTML content of the block as only the latter is relevant for block |
|
11453 * validation and edit operations. |
|
11454 * |
|
11455 * @typedef WPRawBlock |
|
11456 * |
|
11457 * @property {string=} blockName Block name |
|
11458 * @property {Object=} attrs Block raw or comment attributes. |
|
11459 * @property {string} innerHTML HTML content of the block. |
|
11460 * @property {(string|null)[]} innerContent Content without inner blocks. |
|
11461 * @property {WPRawBlock[]} innerBlocks Inner Blocks. |
|
11462 */ |
|
11463 |
|
11464 /** |
|
11465 * Fully parsed block object. |
|
11466 * |
|
11467 * @typedef WPBlock |
|
11468 * |
|
11469 * @property {string} name Block name |
|
11470 * @property {Object} attributes Block raw or comment attributes. |
|
11471 * @property {WPBlock[]} innerBlocks Inner Blocks. |
|
11472 * @property {string} originalContent Original content of the block before validation fixes. |
|
11473 * @property {boolean} isValid Whether the block is valid. |
|
11474 * @property {Object[]} validationIssues Validation issues. |
|
11475 * @property {WPRawBlock} [__unstableBlockSource] Un-processed original copy of block if created through parser. |
|
11476 */ |
|
11477 |
|
11478 /** |
|
11479 * @typedef {Object} ParseOptions |
|
11480 * @property {boolean} __unstableSkipMigrationLogs If a block is migrated from a deprecated version, skip logging the migration details. |
|
11481 */ |
|
11482 |
|
11483 /** |
|
11484 * Convert legacy blocks to their canonical form. This function is used |
|
11485 * both in the parser level for previous content and to convert such blocks |
|
11486 * used in Custom Post Types templates. |
|
11487 * |
|
11488 * @param {WPRawBlock} rawBlock |
|
11489 * |
|
11490 * @return {WPRawBlock} The block's name and attributes, changed accordingly if a match was found |
|
11491 */ |
|
11492 |
|
11493 function convertLegacyBlocks(rawBlock) { |
|
11494 const [correctName, correctedAttributes] = convertLegacyBlockNameAndAttributes(rawBlock.blockName, rawBlock.attrs); |
|
11495 return { ...rawBlock, |
|
11496 blockName: correctName, |
|
11497 attrs: correctedAttributes |
|
11498 }; |
|
11499 } |
|
11500 /** |
|
11501 * Normalize the raw block by applying the fallback block name if none given, |
|
11502 * sanitize the parsed HTML... |
|
11503 * |
|
11504 * @param {WPRawBlock} rawBlock The raw block object. |
|
11505 * |
|
11506 * @return {WPRawBlock} The normalized block object. |
|
11507 */ |
|
11508 |
|
11509 |
|
11510 function normalizeRawBlock(rawBlock) { |
|
11511 const fallbackBlockName = getFreeformContentHandlerName(); // If the grammar parsing don't produce any block name, use the freeform block. |
|
11512 |
|
11513 const rawBlockName = rawBlock.blockName || getFreeformContentHandlerName(); |
|
11514 const rawAttributes = rawBlock.attrs || {}; |
|
11515 const rawInnerBlocks = rawBlock.innerBlocks || []; |
|
11516 let rawInnerHTML = rawBlock.innerHTML.trim(); // Fallback content may be upgraded from classic content expecting implicit |
|
11517 // automatic paragraphs, so preserve them. Assumes wpautop is idempotent, |
|
11518 // meaning there are no negative consequences to repeated autop calls. |
|
11519 |
|
11520 if (rawBlockName === fallbackBlockName) { |
|
11521 rawInnerHTML = (0,external_wp_autop_namespaceObject.autop)(rawInnerHTML).trim(); |
|
11522 } |
|
11523 |
|
11524 return { ...rawBlock, |
|
11525 blockName: rawBlockName, |
|
11526 attrs: rawAttributes, |
|
11527 innerHTML: rawInnerHTML, |
|
11528 innerBlocks: rawInnerBlocks |
|
11529 }; |
|
11530 } |
|
11531 /** |
|
11532 * Uses the "unregistered blockType" to create a block object. |
|
11533 * |
|
11534 * @param {WPRawBlock} rawBlock block. |
|
11535 * |
|
11536 * @return {WPRawBlock} The unregistered block object. |
|
11537 */ |
|
11538 |
|
11539 function createMissingBlockType(rawBlock) { |
|
11540 const unregisteredFallbackBlock = getUnregisteredTypeHandlerName() || getFreeformContentHandlerName(); // Preserve undelimited content for use by the unregistered type |
|
11541 // handler. A block node's `innerHTML` isn't enough, as that field only |
|
11542 // carries the block's own HTML and not its nested blocks. |
|
11543 |
|
11544 const originalUndelimitedContent = serializeRawBlock(rawBlock, { |
|
11545 isCommentDelimited: false |
|
11546 }); // Preserve full block content for use by the unregistered type |
|
11547 // handler, block boundaries included. |
|
11548 |
|
11549 const originalContent = serializeRawBlock(rawBlock, { |
|
11550 isCommentDelimited: true |
|
11551 }); |
|
11552 return { |
|
11553 blockName: unregisteredFallbackBlock, |
|
11554 attrs: { |
|
11555 originalName: rawBlock.blockName, |
|
11556 originalContent, |
|
11557 originalUndelimitedContent |
|
11558 }, |
|
11559 innerHTML: rawBlock.blockName ? originalContent : rawBlock.innerHTML, |
|
11560 innerBlocks: rawBlock.innerBlocks, |
|
11561 innerContent: rawBlock.innerContent |
|
11562 }; |
|
11563 } |
|
11564 /** |
|
11565 * Validates a block and wraps with validation meta. |
|
11566 * |
|
11567 * The name here is regrettable but `validateBlock` is already taken. |
|
11568 * |
|
11569 * @param {WPBlock} unvalidatedBlock |
|
11570 * @param {import('../registration').WPBlockType} blockType |
|
11571 * @return {WPBlock} validated block, with auto-fixes if initially invalid |
|
11572 */ |
|
11573 |
|
11574 |
|
11575 function applyBlockValidation(unvalidatedBlock, blockType) { |
|
11576 // Attempt to validate the block. |
|
11577 const [isValid] = validateBlock(unvalidatedBlock, blockType); |
|
11578 |
|
11579 if (isValid) { |
|
11580 return { ...unvalidatedBlock, |
|
11581 isValid, |
|
11582 validationIssues: [] |
|
11583 }; |
|
11584 } // If the block is invalid, attempt some built-in fixes |
|
11585 // like custom classNames handling. |
|
11586 |
|
11587 |
|
11588 const fixedBlock = applyBuiltInValidationFixes(unvalidatedBlock, blockType); // Attempt to validate the block once again after the built-in fixes. |
|
11589 |
|
11590 const [isFixedValid, validationIssues] = validateBlock(unvalidatedBlock, blockType); |
|
11591 return { ...fixedBlock, |
|
11592 isValid: isFixedValid, |
|
11593 validationIssues |
|
11594 }; |
|
11595 } |
|
11596 /** |
|
11597 * Given a raw block returned by grammar parsing, returns a fully parsed block. |
|
11598 * |
|
11599 * @param {WPRawBlock} rawBlock The raw block object. |
|
11600 * @param {ParseOptions} options Extra options for handling block parsing. |
|
11601 * |
|
11602 * @return {WPBlock} Fully parsed block. |
|
11603 */ |
|
11604 |
|
11605 |
|
11606 function parseRawBlock(rawBlock, options) { |
|
11607 let normalizedBlock = normalizeRawBlock(rawBlock); // During the lifecycle of the project, we renamed some old blocks |
|
11608 // and transformed others to new blocks. To avoid breaking existing content, |
|
11609 // we added this function to properly parse the old content. |
|
11610 |
|
11611 normalizedBlock = convertLegacyBlocks(normalizedBlock); // Try finding the type for known block name. |
|
11612 |
|
11613 let blockType = registration_getBlockType(normalizedBlock.blockName); // If not blockType is found for the specified name, fallback to the "unregistedBlockType". |
|
11614 |
|
11615 if (!blockType) { |
|
11616 normalizedBlock = createMissingBlockType(normalizedBlock); |
|
11617 blockType = registration_getBlockType(normalizedBlock.blockName); |
|
11618 } // If it's an empty freeform block or there's no blockType (no missing block handler) |
|
11619 // Then, just ignore the block. |
|
11620 // It might be a good idea to throw a warning here. |
|
11621 // TODO: I'm unsure about the unregisteredFallbackBlock check, |
|
11622 // it might ignore some dynamic unregistered third party blocks wrongly. |
|
11623 |
|
11624 |
|
11625 const isFallbackBlock = normalizedBlock.blockName === getFreeformContentHandlerName() || normalizedBlock.blockName === getUnregisteredTypeHandlerName(); |
|
11626 |
|
11627 if (!blockType || !normalizedBlock.innerHTML && isFallbackBlock) { |
|
11628 return; |
|
11629 } // Parse inner blocks recursively. |
|
11630 |
|
11631 |
|
11632 const parsedInnerBlocks = normalizedBlock.innerBlocks.map(innerBlock => parseRawBlock(innerBlock, options)) // See https://github.com/WordPress/gutenberg/pull/17164. |
|
11633 .filter(innerBlock => !!innerBlock); // Get the fully parsed block. |
|
11634 |
|
11635 const parsedBlock = createBlock(normalizedBlock.blockName, getBlockAttributes(blockType, normalizedBlock.innerHTML, normalizedBlock.attrs), parsedInnerBlocks); |
|
11636 parsedBlock.originalContent = normalizedBlock.innerHTML; |
|
11637 const validatedBlock = applyBlockValidation(parsedBlock, blockType); |
|
11638 const { |
|
11639 validationIssues |
|
11640 } = validatedBlock; // Run the block deprecation and migrations. |
|
11641 // This is performed on both invalid and valid blocks because |
|
11642 // migration using the `migrate` functions should run even |
|
11643 // if the output is deemed valid. |
|
11644 |
|
11645 const updatedBlock = applyBlockDeprecatedVersions(validatedBlock, normalizedBlock, blockType); |
|
11646 |
|
11647 if (!updatedBlock.isValid) { |
|
11648 // Preserve the original unprocessed version of the block |
|
11649 // that we received (no fixes, no deprecations) so that |
|
11650 // we can save it as close to exactly the same way as |
|
11651 // we loaded it. This is important to avoid corruption |
|
11652 // and data loss caused by block implementations trying |
|
11653 // to process data that isn't fully recognized. |
|
11654 updatedBlock.__unstableBlockSource = rawBlock; |
|
11655 } |
|
11656 |
|
11657 if (!validatedBlock.isValid && updatedBlock.isValid && !(options !== null && options !== void 0 && options.__unstableSkipMigrationLogs)) { |
|
11658 /* eslint-disable no-console */ |
|
11659 console.groupCollapsed('Updated Block: %s', blockType.name); |
|
11660 console.info('Block successfully updated for `%s` (%o).\n\nNew content generated by `save` function:\n\n%s\n\nContent retrieved from post body:\n\n%s', blockType.name, blockType, getSaveContent(blockType, updatedBlock.attributes), updatedBlock.originalContent); |
|
11661 console.groupEnd(); |
|
11662 /* eslint-enable no-console */ |
|
11663 } else if (!validatedBlock.isValid && !updatedBlock.isValid) { |
|
11664 validationIssues.forEach(_ref => { |
|
11665 let { |
|
11666 log, |
|
11667 args |
|
11668 } = _ref; |
|
11669 return log(...args); |
|
11670 }); |
|
11671 } |
|
11672 |
|
11673 return updatedBlock; |
|
11674 } |
|
11675 /** |
|
11676 * Utilizes an optimized token-driven parser based on the Gutenberg grammar spec |
|
11677 * defined through a parsing expression grammar to take advantage of the regular |
|
11678 * cadence provided by block delimiters -- composed syntactically through HTML |
|
11679 * comments -- which, given a general HTML document as an input, returns a block |
|
11680 * list array representation. |
|
11681 * |
|
11682 * This is a recursive-descent parser that scans linearly once through the input |
|
11683 * document. Instead of directly recursing it utilizes a trampoline mechanism to |
|
11684 * prevent stack overflow. This initial pass is mainly interested in separating |
|
11685 * and isolating the blocks serialized in the document and manifestly not in the |
|
11686 * content within the blocks. |
|
11687 * |
|
11688 * @see |
|
11689 * https://developer.wordpress.org/block-editor/packages/packages-block-serialization-default-parser/ |
|
11690 * |
|
11691 * @param {string} content The post content. |
|
11692 * @param {ParseOptions} options Extra options for handling block parsing. |
|
11693 * |
|
11694 * @return {Array} Block list. |
|
11695 */ |
|
11696 |
|
11697 function parser_parse(content, options) { |
|
11698 return (0,external_wp_blockSerializationDefaultParser_namespaceObject.parse)(content).reduce((accumulator, rawBlock) => { |
|
11699 const block = parseRawBlock(rawBlock, options); |
|
11700 |
|
11701 if (block) { |
|
11702 accumulator.push(block); |
|
11703 } |
|
11704 |
|
11705 return accumulator; |
|
11706 }, []); |
|
11707 } |
|
11708 |
|
11709 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/get-raw-transforms.js |
|
11710 /** |
|
11711 * External dependencies |
|
11712 */ |
|
11713 |
|
11714 /** |
|
11715 * Internal dependencies |
|
11716 */ |
|
11717 |
|
11718 |
|
11719 function getRawTransforms() { |
|
11720 return (0,external_lodash_namespaceObject.filter)(getBlockTransforms('from'), { |
|
11721 type: 'raw' |
|
11722 }).map(transform => { |
|
11723 return transform.isMatch ? transform : { ...transform, |
|
11724 isMatch: node => transform.selector && node.matches(transform.selector) |
|
11725 }; |
|
11726 }); |
|
11727 } |
|
11728 |
|
11729 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/html-to-blocks.js |
|
11730 /** |
|
11731 * Internal dependencies |
|
11732 */ |
|
11733 |
|
11734 |
|
11735 |
|
11736 /** |
|
11737 * Converts HTML directly to blocks. Looks for a matching transform for each |
|
11738 * top-level tag. The HTML should be filtered to not have any text between |
|
11739 * top-level tags and formatted in a way that blocks can handle the HTML. |
|
11740 * |
|
11741 * @param {string} html HTML to convert. |
|
11742 * |
|
11743 * @return {Array} An array of blocks. |
|
11744 */ |
|
11745 |
|
11746 function htmlToBlocks(html) { |
|
11747 const doc = document.implementation.createHTMLDocument(''); |
|
11748 doc.body.innerHTML = html; |
|
11749 return Array.from(doc.body.children).flatMap(node => { |
|
11750 const rawTransform = findTransform(getRawTransforms(), _ref => { |
|
11751 let { |
|
11752 isMatch |
|
11753 } = _ref; |
|
11754 return isMatch(node); |
|
11755 }); |
|
11756 |
|
11757 if (!rawTransform) { |
|
11758 return createBlock( // Should not be hardcoded. |
|
11759 'core/html', getBlockAttributes('core/html', node.outerHTML)); |
|
11760 } |
|
11761 |
|
11762 const { |
|
11763 transform, |
|
11764 blockName |
|
11765 } = rawTransform; |
|
11766 |
|
11767 if (transform) { |
|
11768 return transform(node); |
|
11769 } |
|
11770 |
|
11771 return createBlock(blockName, getBlockAttributes(blockName, node.outerHTML)); |
|
11772 }); |
|
11773 } |
|
11774 |
|
11775 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/normalise-blocks.js |
|
11776 /** |
|
11777 * WordPress dependencies |
|
11778 */ |
|
11779 |
|
11780 function normaliseBlocks(HTML) { |
|
11781 const decuDoc = document.implementation.createHTMLDocument(''); |
|
11782 const accuDoc = document.implementation.createHTMLDocument(''); |
|
11783 const decu = decuDoc.body; |
|
11784 const accu = accuDoc.body; |
|
11785 decu.innerHTML = HTML; |
|
11786 |
|
11787 while (decu.firstChild) { |
|
11788 const node = decu.firstChild; // Text nodes: wrap in a paragraph, or append to previous. |
|
11789 |
|
11790 if (node.nodeType === node.TEXT_NODE) { |
|
11791 if ((0,external_wp_dom_namespaceObject.isEmpty)(node)) { |
|
11792 decu.removeChild(node); |
|
11793 } else { |
|
11794 if (!accu.lastChild || accu.lastChild.nodeName !== 'P') { |
|
11795 accu.appendChild(accuDoc.createElement('P')); |
|
11796 } |
|
11797 |
|
11798 accu.lastChild.appendChild(node); |
|
11799 } // Element nodes. |
|
11800 |
|
11801 } else if (node.nodeType === node.ELEMENT_NODE) { |
|
11802 // BR nodes: create a new paragraph on double, or append to previous. |
|
11803 if (node.nodeName === 'BR') { |
|
11804 if (node.nextSibling && node.nextSibling.nodeName === 'BR') { |
|
11805 accu.appendChild(accuDoc.createElement('P')); |
|
11806 decu.removeChild(node.nextSibling); |
|
11807 } // Don't append to an empty paragraph. |
|
11808 |
|
11809 |
|
11810 if (accu.lastChild && accu.lastChild.nodeName === 'P' && accu.lastChild.hasChildNodes()) { |
|
11811 accu.lastChild.appendChild(node); |
|
11812 } else { |
|
11813 decu.removeChild(node); |
|
11814 } |
|
11815 } else if (node.nodeName === 'P') { |
|
11816 // Only append non-empty paragraph nodes. |
|
11817 if ((0,external_wp_dom_namespaceObject.isEmpty)(node)) { |
|
11818 decu.removeChild(node); |
|
11819 } else { |
|
11820 accu.appendChild(node); |
|
11821 } |
|
11822 } else if ((0,external_wp_dom_namespaceObject.isPhrasingContent)(node)) { |
|
11823 if (!accu.lastChild || accu.lastChild.nodeName !== 'P') { |
|
11824 accu.appendChild(accuDoc.createElement('P')); |
|
11825 } |
|
11826 |
|
11827 accu.lastChild.appendChild(node); |
|
11828 } else { |
|
11829 accu.appendChild(node); |
|
11830 } |
|
11831 } else { |
|
11832 decu.removeChild(node); |
|
11833 } |
|
11834 } |
|
11835 |
|
11836 return accu.innerHTML; |
|
11837 } |
|
11838 |
|
11839 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/special-comment-converter.js |
|
11840 /** |
|
11841 * WordPress dependencies |
|
11842 */ |
|
11843 |
|
11844 /** |
|
11845 * Looks for `<!--nextpage-->` and `<!--more-->` comments, as well as the |
|
11846 * `<!--more Some text-->` variant and its `<!--noteaser-->` companion, |
|
11847 * and replaces them with a custom element representing a future block. |
|
11848 * |
|
11849 * The custom element is a way to bypass the rest of the `raw-handling` |
|
11850 * transforms, which would eliminate other kinds of node with which to carry |
|
11851 * `<!--more-->`'s data: nodes with `data` attributes, empty paragraphs, etc. |
|
11852 * |
|
11853 * The custom element is then expected to be recognized by any registered |
|
11854 * block's `raw` transform. |
|
11855 * |
|
11856 * @param {Node} node The node to be processed. |
|
11857 * @param {Document} doc The document of the node. |
|
11858 * @return {void} |
|
11859 */ |
|
11860 |
|
11861 function specialCommentConverter(node, doc) { |
|
11862 if (node.nodeType !== node.COMMENT_NODE) { |
|
11863 return; |
|
11864 } |
|
11865 |
|
11866 if (node.nodeValue === 'nextpage') { |
|
11867 (0,external_wp_dom_namespaceObject.replace)(node, createNextpage(doc)); |
|
11868 return; |
|
11869 } |
|
11870 |
|
11871 if (node.nodeValue.indexOf('more') === 0) { |
|
11872 // Grab any custom text in the comment. |
|
11873 const customText = node.nodeValue.slice(4).trim(); |
|
11874 /* |
|
11875 * When a `<!--more-->` comment is found, we need to look for any |
|
11876 * `<!--noteaser-->` sibling, but it may not be a direct sibling |
|
11877 * (whitespace typically lies in between) |
|
11878 */ |
|
11879 |
|
11880 let sibling = node; |
|
11881 let noTeaser = false; |
|
11882 |
|
11883 while (sibling = sibling.nextSibling) { |
|
11884 if (sibling.nodeType === sibling.COMMENT_NODE && sibling.nodeValue === 'noteaser') { |
|
11885 noTeaser = true; |
|
11886 (0,external_wp_dom_namespaceObject.remove)(sibling); |
|
11887 break; |
|
11888 } |
|
11889 } |
|
11890 |
|
11891 (0,external_wp_dom_namespaceObject.replace)(node, createMore(customText, noTeaser, doc)); |
|
11892 } |
|
11893 } |
|
11894 |
|
11895 function createMore(customText, noTeaser, doc) { |
|
11896 const node = doc.createElement('wp-block'); |
|
11897 node.dataset.block = 'core/more'; |
|
11898 |
|
11899 if (customText) { |
|
11900 node.dataset.customText = customText; |
|
11901 } |
|
11902 |
|
11903 if (noTeaser) { |
|
11904 // "Boolean" data attribute. |
|
11905 node.dataset.noTeaser = ''; |
|
11906 } |
|
11907 |
|
11908 return node; |
|
11909 } |
|
11910 |
|
11911 function createNextpage(doc) { |
|
11912 const node = doc.createElement('wp-block'); |
|
11913 node.dataset.block = 'core/nextpage'; |
|
11914 return node; |
|
11915 } |
|
11916 |
|
11917 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/list-reducer.js |
|
11918 /** |
|
11919 * WordPress dependencies |
|
11920 */ |
|
11921 |
|
11922 |
|
11923 function isList(node) { |
|
11924 return node.nodeName === 'OL' || node.nodeName === 'UL'; |
|
11925 } |
|
11926 |
|
11927 function shallowTextContent(element) { |
|
11928 return Array.from(element.childNodes).map(_ref => { |
|
11929 let { |
|
11930 nodeValue = '' |
|
11931 } = _ref; |
|
11932 return nodeValue; |
|
11933 }).join(''); |
|
11934 } |
|
11935 |
|
11936 function listReducer(node) { |
|
11937 if (!isList(node)) { |
|
11938 return; |
|
11939 } |
|
11940 |
|
11941 const list = node; |
|
11942 const prevElement = node.previousElementSibling; // Merge with previous list if: |
|
11943 // * There is a previous list of the same type. |
|
11944 // * There is only one list item. |
|
11945 |
|
11946 if (prevElement && prevElement.nodeName === node.nodeName && list.children.length === 1) { |
|
11947 // Move all child nodes, including any text nodes, if any. |
|
11948 while (list.firstChild) { |
|
11949 prevElement.appendChild(list.firstChild); |
|
11950 } |
|
11951 |
|
11952 list.parentNode.removeChild(list); |
|
11953 } |
|
11954 |
|
11955 const parentElement = node.parentNode; // Nested list with empty parent item. |
|
11956 |
|
11957 if (parentElement && parentElement.nodeName === 'LI' && parentElement.children.length === 1 && !/\S/.test(shallowTextContent(parentElement))) { |
|
11958 const parentListItem = parentElement; |
|
11959 const prevListItem = parentListItem.previousElementSibling; |
|
11960 const parentList = parentListItem.parentNode; |
|
11961 |
|
11962 if (prevListItem) { |
|
11963 prevListItem.appendChild(list); |
|
11964 parentList.removeChild(parentListItem); |
|
11965 } else { |
|
11966 parentList.parentNode.insertBefore(list, parentList); |
|
11967 parentList.parentNode.removeChild(parentList); |
|
11968 } |
|
11969 } // Invalid: OL/UL > OL/UL. |
|
11970 |
|
11971 |
|
11972 if (parentElement && isList(parentElement)) { |
|
11973 const prevListItem = node.previousElementSibling; |
|
11974 |
|
11975 if (prevListItem) { |
|
11976 prevListItem.appendChild(node); |
|
11977 } else { |
|
11978 (0,external_wp_dom_namespaceObject.unwrap)(node); |
|
11979 } |
|
11980 } |
|
11981 } |
|
11982 |
|
11983 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/blockquote-normaliser.js |
|
11984 /** |
|
11985 * Internal dependencies |
|
11986 */ |
|
11987 |
|
11988 function blockquoteNormaliser(node) { |
|
11989 if (node.nodeName !== 'BLOCKQUOTE') { |
|
11990 return; |
|
11991 } |
|
11992 |
|
11993 node.innerHTML = normaliseBlocks(node.innerHTML); |
|
11994 } |
|
11995 |
|
11996 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/figure-content-reducer.js |
|
11997 /** |
|
11998 * External dependencies |
|
11999 */ |
|
12000 |
|
12001 /** |
|
12002 * WordPress dependencies |
|
12003 */ |
|
12004 |
|
12005 |
|
12006 /** |
|
12007 * Whether or not the given node is figure content. |
|
12008 * |
|
12009 * @param {Node} node The node to check. |
|
12010 * @param {Object} schema The schema to use. |
|
12011 * |
|
12012 * @return {boolean} True if figure content, false if not. |
|
12013 */ |
|
12014 |
|
12015 function isFigureContent(node, schema) { |
|
12016 const tag = node.nodeName.toLowerCase(); // We are looking for tags that can be a child of the figure tag, excluding |
|
12017 // `figcaption` and any phrasing content. |
|
12018 |
|
12019 if (tag === 'figcaption' || (0,external_wp_dom_namespaceObject.isTextContent)(node)) { |
|
12020 return false; |
|
12021 } |
|
12022 |
|
12023 return (0,external_lodash_namespaceObject.has)(schema, ['figure', 'children', tag]); |
|
12024 } |
|
12025 /** |
|
12026 * Whether or not the given node can have an anchor. |
|
12027 * |
|
12028 * @param {Node} node The node to check. |
|
12029 * @param {Object} schema The schema to use. |
|
12030 * |
|
12031 * @return {boolean} True if it can, false if not. |
|
12032 */ |
|
12033 |
|
12034 |
|
12035 function canHaveAnchor(node, schema) { |
|
12036 const tag = node.nodeName.toLowerCase(); |
|
12037 return (0,external_lodash_namespaceObject.has)(schema, ['figure', 'children', 'a', 'children', tag]); |
|
12038 } |
|
12039 /** |
|
12040 * Wraps the given element in a figure element. |
|
12041 * |
|
12042 * @param {Element} element The element to wrap. |
|
12043 * @param {Element} beforeElement The element before which to place the figure. |
|
12044 */ |
|
12045 |
|
12046 |
|
12047 function wrapFigureContent(element) { |
|
12048 let beforeElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : element; |
|
12049 const figure = element.ownerDocument.createElement('figure'); |
|
12050 beforeElement.parentNode.insertBefore(figure, beforeElement); |
|
12051 figure.appendChild(element); |
|
12052 } |
|
12053 /** |
|
12054 * This filter takes figure content out of paragraphs, wraps it in a figure |
|
12055 * element, and moves any anchors with it if needed. |
|
12056 * |
|
12057 * @param {Node} node The node to filter. |
|
12058 * @param {Document} doc The document of the node. |
|
12059 * @param {Object} schema The schema to use. |
|
12060 * |
|
12061 * @return {void} |
|
12062 */ |
|
12063 |
|
12064 |
|
12065 function figureContentReducer(node, doc, schema) { |
|
12066 if (!isFigureContent(node, schema)) { |
|
12067 return; |
|
12068 } |
|
12069 |
|
12070 let nodeToInsert = node; |
|
12071 const parentNode = node.parentNode; // If the figure content can have an anchor and its parent is an anchor with |
|
12072 // only the figure content, take the anchor out instead of just the content. |
|
12073 |
|
12074 if (canHaveAnchor(node, schema) && parentNode.nodeName === 'A' && parentNode.childNodes.length === 1) { |
|
12075 nodeToInsert = node.parentNode; |
|
12076 } |
|
12077 |
|
12078 const wrapper = nodeToInsert.closest('p,div'); // If wrapped in a paragraph or div, only extract if it's aligned or if |
|
12079 // there is no text content. |
|
12080 // Otherwise, if directly at the root, wrap in a figure element. |
|
12081 |
|
12082 if (wrapper) { |
|
12083 // In jsdom-jscore, 'node.classList' can be undefined. |
|
12084 // In this case, default to extract as it offers a better UI experience on mobile. |
|
12085 if (!node.classList) { |
|
12086 wrapFigureContent(nodeToInsert, wrapper); |
|
12087 } else if (node.classList.contains('alignright') || node.classList.contains('alignleft') || node.classList.contains('aligncenter') || !wrapper.textContent.trim()) { |
|
12088 wrapFigureContent(nodeToInsert, wrapper); |
|
12089 } |
|
12090 } else if (nodeToInsert.parentNode.nodeName === 'BODY') { |
|
12091 wrapFigureContent(nodeToInsert); |
|
12092 } |
|
12093 } |
|
12094 |
|
12095 ;// CONCATENATED MODULE: external ["wp","shortcode"] |
|
12096 var external_wp_shortcode_namespaceObject = window["wp"]["shortcode"]; |
|
12097 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/shortcode-converter.js |
|
12098 /** |
|
12099 * External dependencies |
|
12100 */ |
|
12101 |
|
12102 /** |
|
12103 * WordPress dependencies |
|
12104 */ |
|
12105 |
|
12106 |
|
12107 /** |
|
12108 * Internal dependencies |
|
12109 */ |
|
12110 |
|
12111 |
|
12112 |
|
12113 |
|
12114 |
|
12115 |
|
12116 function segmentHTMLToShortcodeBlock(HTML) { |
|
12117 let lastIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; |
|
12118 let excludedBlockNames = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; |
|
12119 // Get all matches. |
|
12120 const transformsFrom = getBlockTransforms('from'); |
|
12121 const transformation = findTransform(transformsFrom, transform => excludedBlockNames.indexOf(transform.blockName) === -1 && transform.type === 'shortcode' && (0,external_lodash_namespaceObject.some)((0,external_lodash_namespaceObject.castArray)(transform.tag), tag => (0,external_wp_shortcode_namespaceObject.regexp)(tag).test(HTML))); |
|
12122 |
|
12123 if (!transformation) { |
|
12124 return [HTML]; |
|
12125 } |
|
12126 |
|
12127 const transformTags = (0,external_lodash_namespaceObject.castArray)(transformation.tag); |
|
12128 const transformTag = (0,external_lodash_namespaceObject.find)(transformTags, tag => (0,external_wp_shortcode_namespaceObject.regexp)(tag).test(HTML)); |
|
12129 let match; |
|
12130 const previousIndex = lastIndex; |
|
12131 |
|
12132 if (match = (0,external_wp_shortcode_namespaceObject.next)(transformTag, HTML, lastIndex)) { |
|
12133 lastIndex = match.index + match.content.length; |
|
12134 const beforeHTML = HTML.substr(0, match.index); |
|
12135 const afterHTML = HTML.substr(lastIndex); // If the shortcode content does not contain HTML and the shortcode is |
|
12136 // not on a new line (or in paragraph from Markdown converter), |
|
12137 // consider the shortcode as inline text, and thus skip conversion for |
|
12138 // this segment. |
|
12139 |
|
12140 if (!(0,external_lodash_namespaceObject.includes)(match.shortcode.content || '', '<') && !(/(\n|<p>)\s*$/.test(beforeHTML) && /^\s*(\n|<\/p>)/.test(afterHTML))) { |
|
12141 return segmentHTMLToShortcodeBlock(HTML, lastIndex); |
|
12142 } // If a transformation's `isMatch` predicate fails for the inbound |
|
12143 // shortcode, try again by excluding the current block type. |
|
12144 // |
|
12145 // This is the only call to `segmentHTMLToShortcodeBlock` that should |
|
12146 // ever carry over `excludedBlockNames`. Other calls in the module |
|
12147 // should skip that argument as a way to reset the exclusion state, so |
|
12148 // that one `isMatch` fail in an HTML fragment doesn't prevent any |
|
12149 // valid matches in subsequent fragments. |
|
12150 |
|
12151 |
|
12152 if (transformation.isMatch && !transformation.isMatch(match.shortcode.attrs)) { |
|
12153 return segmentHTMLToShortcodeBlock(HTML, previousIndex, [...excludedBlockNames, transformation.blockName]); |
|
12154 } |
|
12155 |
|
12156 const attributes = (0,external_lodash_namespaceObject.mapValues)((0,external_lodash_namespaceObject.pickBy)(transformation.attributes, schema => schema.shortcode), // Passing all of `match` as second argument is intentionally broad |
|
12157 // but shouldn't be too relied upon. |
|
12158 // |
|
12159 // See: https://github.com/WordPress/gutenberg/pull/3610#discussion_r152546926 |
|
12160 schema => schema.shortcode(match.shortcode.attrs, match)); |
|
12161 const transformationBlockType = { ...registration_getBlockType(transformation.blockName), |
|
12162 attributes: transformation.attributes |
|
12163 }; |
|
12164 let block = createBlock(transformation.blockName, getBlockAttributes(transformationBlockType, match.shortcode.content, attributes)); |
|
12165 block.originalContent = match.shortcode.content; // Applying the built-in fixes can enhance the attributes with missing content like "className". |
|
12166 |
|
12167 block = applyBuiltInValidationFixes(block, transformationBlockType); |
|
12168 return [...segmentHTMLToShortcodeBlock(beforeHTML), block, ...segmentHTMLToShortcodeBlock(afterHTML)]; |
|
12169 } |
|
12170 |
|
12171 return [HTML]; |
|
12172 } |
|
12173 |
|
12174 /* harmony default export */ var shortcode_converter = (segmentHTMLToShortcodeBlock); |
|
12175 |
|
12176 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/utils.js |
|
12177 /** |
|
12178 * External dependencies |
|
12179 */ |
|
12180 |
|
12181 /** |
|
12182 * WordPress dependencies |
|
12183 */ |
|
12184 |
|
12185 |
|
12186 /** |
|
12187 * Internal dependencies |
|
12188 */ |
|
12189 |
|
12190 |
|
12191 |
|
12192 function getBlockContentSchemaFromTransforms(transforms, context) { |
|
12193 const phrasingContentSchema = (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)(context); |
|
12194 const schemaArgs = { |
|
12195 phrasingContentSchema, |
|
12196 isPaste: context === 'paste' |
|
12197 }; |
|
12198 const schemas = transforms.map(_ref => { |
|
12199 let { |
|
12200 isMatch, |
|
12201 blockName, |
|
12202 schema |
|
12203 } = _ref; |
|
12204 const hasAnchorSupport = registration_hasBlockSupport(blockName, 'anchor'); |
|
12205 schema = (0,external_lodash_namespaceObject.isFunction)(schema) ? schema(schemaArgs) : schema; // If the block does not has anchor support and the transform does not |
|
12206 // provides an isMatch we can return the schema right away. |
|
12207 |
|
12208 if (!hasAnchorSupport && !isMatch) { |
|
12209 return schema; |
|
12210 } |
|
12211 |
|
12212 return (0,external_lodash_namespaceObject.mapValues)(schema, value => { |
|
12213 let attributes = value.attributes || []; // If the block supports the "anchor" functionality, it needs to keep its ID attribute. |
|
12214 |
|
12215 if (hasAnchorSupport) { |
|
12216 attributes = [...attributes, 'id']; |
|
12217 } |
|
12218 |
|
12219 return { ...value, |
|
12220 attributes, |
|
12221 isMatch: isMatch ? isMatch : undefined |
|
12222 }; |
|
12223 }); |
|
12224 }); |
|
12225 return (0,external_lodash_namespaceObject.mergeWith)({}, ...schemas, (objValue, srcValue, key) => { |
|
12226 switch (key) { |
|
12227 case 'children': |
|
12228 { |
|
12229 if (objValue === '*' || srcValue === '*') { |
|
12230 return '*'; |
|
12231 } |
|
12232 |
|
12233 return { ...objValue, |
|
12234 ...srcValue |
|
12235 }; |
|
12236 } |
|
12237 |
|
12238 case 'attributes': |
|
12239 case 'require': |
|
12240 { |
|
12241 return [...(objValue || []), ...(srcValue || [])]; |
|
12242 } |
|
12243 |
|
12244 case 'isMatch': |
|
12245 { |
|
12246 // If one of the values being merge is undefined (matches everything), |
|
12247 // the result of the merge will be undefined. |
|
12248 if (!objValue || !srcValue) { |
|
12249 return undefined; |
|
12250 } // When merging two isMatch functions, the result is a new function |
|
12251 // that returns if one of the source functions returns true. |
|
12252 |
|
12253 |
|
12254 return function () { |
|
12255 return objValue(...arguments) || srcValue(...arguments); |
|
12256 }; |
|
12257 } |
|
12258 } |
|
12259 }); |
|
12260 } |
|
12261 /** |
|
12262 * Gets the block content schema, which is extracted and merged from all |
|
12263 * registered blocks with raw transfroms. |
|
12264 * |
|
12265 * @param {string} context Set to "paste" when in paste context, where the |
|
12266 * schema is more strict. |
|
12267 * |
|
12268 * @return {Object} A complete block content schema. |
|
12269 */ |
|
12270 |
|
12271 function getBlockContentSchema(context) { |
|
12272 return getBlockContentSchemaFromTransforms(getRawTransforms(), context); |
|
12273 } |
|
12274 /** |
|
12275 * Checks whether HTML can be considered plain text. That is, it does not contain |
|
12276 * any elements that are not line breaks. |
|
12277 * |
|
12278 * @param {string} HTML The HTML to check. |
|
12279 * |
|
12280 * @return {boolean} Whether the HTML can be considered plain text. |
|
12281 */ |
|
12282 |
|
12283 function isPlain(HTML) { |
|
12284 return !/<(?!br[ />])/i.test(HTML); |
|
12285 } |
|
12286 /** |
|
12287 * Given node filters, deeply filters and mutates a NodeList. |
|
12288 * |
|
12289 * @param {NodeList} nodeList The nodeList to filter. |
|
12290 * @param {Array} filters An array of functions that can mutate with the provided node. |
|
12291 * @param {Document} doc The document of the nodeList. |
|
12292 * @param {Object} schema The schema to use. |
|
12293 */ |
|
12294 |
|
12295 function deepFilterNodeList(nodeList, filters, doc, schema) { |
|
12296 Array.from(nodeList).forEach(node => { |
|
12297 deepFilterNodeList(node.childNodes, filters, doc, schema); |
|
12298 filters.forEach(item => { |
|
12299 // Make sure the node is still attached to the document. |
|
12300 if (!doc.contains(node)) { |
|
12301 return; |
|
12302 } |
|
12303 |
|
12304 item(node, doc, schema); |
|
12305 }); |
|
12306 }); |
|
12307 } |
|
12308 /** |
|
12309 * Given node filters, deeply filters HTML tags. |
|
12310 * Filters from the deepest nodes to the top. |
|
12311 * |
|
12312 * @param {string} HTML The HTML to filter. |
|
12313 * @param {Array} filters An array of functions that can mutate with the provided node. |
|
12314 * @param {Object} schema The schema to use. |
|
12315 * |
|
12316 * @return {string} The filtered HTML. |
|
12317 */ |
|
12318 |
|
12319 function deepFilterHTML(HTML) { |
|
12320 let filters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; |
|
12321 let schema = arguments.length > 2 ? arguments[2] : undefined; |
|
12322 const doc = document.implementation.createHTMLDocument(''); |
|
12323 doc.body.innerHTML = HTML; |
|
12324 deepFilterNodeList(doc.body.childNodes, filters, doc, schema); |
|
12325 return doc.body.innerHTML; |
|
12326 } |
|
12327 /** |
|
12328 * Gets a sibling within text-level context. |
|
12329 * |
|
12330 * @param {Element} node The subject node. |
|
12331 * @param {string} which "next" or "previous". |
|
12332 */ |
|
12333 |
|
12334 function getSibling(node, which) { |
|
12335 const sibling = node[`${which}Sibling`]; |
|
12336 |
|
12337 if (sibling && (0,external_wp_dom_namespaceObject.isPhrasingContent)(sibling)) { |
|
12338 return sibling; |
|
12339 } |
|
12340 |
|
12341 const { |
|
12342 parentNode |
|
12343 } = node; |
|
12344 |
|
12345 if (!parentNode || !(0,external_wp_dom_namespaceObject.isPhrasingContent)(parentNode)) { |
|
12346 return; |
|
12347 } |
|
12348 |
|
12349 return getSibling(parentNode, which); |
|
12350 } |
|
12351 |
|
12352 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/index.js |
|
12353 /** |
|
12354 * External dependencies |
|
12355 */ |
|
12356 |
|
12357 /** |
|
12358 * WordPress dependencies |
|
12359 */ |
|
12360 |
|
12361 |
|
12362 |
|
12363 /** |
|
12364 * Internal dependencies |
|
12365 */ |
|
12366 |
|
12367 |
|
12368 |
|
12369 |
|
12370 |
|
12371 |
|
12372 |
|
12373 |
|
12374 |
|
12375 |
|
12376 |
|
12377 function deprecatedGetPhrasingContentSchema(context) { |
|
12378 external_wp_deprecated_default()('wp.blocks.getPhrasingContentSchema', { |
|
12379 since: '5.6', |
|
12380 alternative: 'wp.dom.getPhrasingContentSchema' |
|
12381 }); |
|
12382 return (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)(context); |
|
12383 } |
|
12384 /** |
|
12385 * Converts an HTML string to known blocks. |
|
12386 * |
|
12387 * @param {Object} $1 |
|
12388 * @param {string} $1.HTML The HTML to convert. |
|
12389 * |
|
12390 * @return {Array} A list of blocks. |
|
12391 */ |
|
12392 |
|
12393 function rawHandler(_ref) { |
|
12394 let { |
|
12395 HTML = '' |
|
12396 } = _ref; |
|
12397 |
|
12398 // If we detect block delimiters, parse entirely as blocks. |
|
12399 if (HTML.indexOf('<!-- wp:') !== -1) { |
|
12400 return parser_parse(HTML); |
|
12401 } // An array of HTML strings and block objects. The blocks replace matched |
|
12402 // shortcodes. |
|
12403 |
|
12404 |
|
12405 const pieces = shortcode_converter(HTML); |
|
12406 const blockContentSchema = getBlockContentSchema(); |
|
12407 return (0,external_lodash_namespaceObject.compact)((0,external_lodash_namespaceObject.flatMap)(pieces, piece => { |
|
12408 // Already a block from shortcode. |
|
12409 if (typeof piece !== 'string') { |
|
12410 return piece; |
|
12411 } // These filters are essential for some blocks to be able to transform |
|
12412 // from raw HTML. These filters move around some content or add |
|
12413 // additional tags, they do not remove any content. |
|
12414 |
|
12415 |
|
12416 const filters = [// Needed to adjust invalid lists. |
|
12417 listReducer, // Needed to create more and nextpage blocks. |
|
12418 specialCommentConverter, // Needed to create media blocks. |
|
12419 figureContentReducer, // Needed to create the quote block, which cannot handle text |
|
12420 // without wrapper paragraphs. |
|
12421 blockquoteNormaliser]; |
|
12422 piece = deepFilterHTML(piece, filters, blockContentSchema); |
|
12423 piece = normaliseBlocks(piece); |
|
12424 return htmlToBlocks(piece); |
|
12425 })); |
|
12426 } |
|
12427 |
|
12428 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/comment-remover.js |
|
12429 /** |
|
12430 * WordPress dependencies |
|
12431 */ |
|
12432 |
|
12433 /** |
|
12434 * Looks for comments, and removes them. |
|
12435 * |
|
12436 * @param {Node} node The node to be processed. |
|
12437 * @return {void} |
|
12438 */ |
|
12439 |
|
12440 function commentRemover(node) { |
|
12441 if (node.nodeType === node.COMMENT_NODE) { |
|
12442 (0,external_wp_dom_namespaceObject.remove)(node); |
|
12443 } |
|
12444 } |
|
12445 |
|
12446 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/is-inline-content.js |
|
12447 /** |
|
12448 * External dependencies |
|
12449 */ |
|
12450 |
|
12451 /** |
|
12452 * WordPress dependencies |
|
12453 */ |
|
12454 |
|
12455 |
|
12456 /** |
|
12457 * Checks if the given node should be considered inline content, optionally |
|
12458 * depending on a context tag. |
|
12459 * |
|
12460 * @param {Node} node Node name. |
|
12461 * @param {string} contextTag Tag name. |
|
12462 * |
|
12463 * @return {boolean} True if the node is inline content, false if nohe. |
|
12464 */ |
|
12465 |
|
12466 function isInline(node, contextTag) { |
|
12467 if ((0,external_wp_dom_namespaceObject.isTextContent)(node)) { |
|
12468 return true; |
|
12469 } |
|
12470 |
|
12471 if (!contextTag) { |
|
12472 return false; |
|
12473 } |
|
12474 |
|
12475 const tag = node.nodeName.toLowerCase(); |
|
12476 const inlineAllowedTagGroups = [['ul', 'li', 'ol'], ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']]; |
|
12477 return inlineAllowedTagGroups.some(tagGroup => (0,external_lodash_namespaceObject.difference)([tag, contextTag], tagGroup).length === 0); |
|
12478 } |
|
12479 |
|
12480 function deepCheck(nodes, contextTag) { |
|
12481 return nodes.every(node => isInline(node, contextTag) && deepCheck(Array.from(node.children), contextTag)); |
|
12482 } |
|
12483 |
|
12484 function isDoubleBR(node) { |
|
12485 return node.nodeName === 'BR' && node.previousSibling && node.previousSibling.nodeName === 'BR'; |
|
12486 } |
|
12487 |
|
12488 function isInlineContent(HTML, contextTag) { |
|
12489 const doc = document.implementation.createHTMLDocument(''); |
|
12490 doc.body.innerHTML = HTML; |
|
12491 const nodes = Array.from(doc.body.children); |
|
12492 return !nodes.some(isDoubleBR) && deepCheck(nodes, contextTag); |
|
12493 } |
|
12494 |
|
12495 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/phrasing-content-reducer.js |
|
12496 /** |
|
12497 * External dependencies |
|
12498 */ |
|
12499 |
|
12500 /** |
|
12501 * WordPress dependencies |
|
12502 */ |
|
12503 |
|
12504 |
|
12505 function phrasingContentReducer(node, doc) { |
|
12506 // In jsdom-jscore, 'node.style' can be null. |
|
12507 // TODO: Explore fixing this by patching jsdom-jscore. |
|
12508 if (node.nodeName === 'SPAN' && node.style) { |
|
12509 const { |
|
12510 fontWeight, |
|
12511 fontStyle, |
|
12512 textDecorationLine, |
|
12513 textDecoration, |
|
12514 verticalAlign |
|
12515 } = node.style; |
|
12516 |
|
12517 if (fontWeight === 'bold' || fontWeight === '700') { |
|
12518 (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('strong'), node); |
|
12519 } |
|
12520 |
|
12521 if (fontStyle === 'italic') { |
|
12522 (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('em'), node); |
|
12523 } // Some DOM implementations (Safari, JSDom) don't support |
|
12524 // style.textDecorationLine, so we check style.textDecoration as a |
|
12525 // fallback. |
|
12526 |
|
12527 |
|
12528 if (textDecorationLine === 'line-through' || (0,external_lodash_namespaceObject.includes)(textDecoration, 'line-through')) { |
|
12529 (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('s'), node); |
|
12530 } |
|
12531 |
|
12532 if (verticalAlign === 'super') { |
|
12533 (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('sup'), node); |
|
12534 } else if (verticalAlign === 'sub') { |
|
12535 (0,external_wp_dom_namespaceObject.wrap)(doc.createElement('sub'), node); |
|
12536 } |
|
12537 } else if (node.nodeName === 'B') { |
|
12538 node = (0,external_wp_dom_namespaceObject.replaceTag)(node, 'strong'); |
|
12539 } else if (node.nodeName === 'I') { |
|
12540 node = (0,external_wp_dom_namespaceObject.replaceTag)(node, 'em'); |
|
12541 } else if (node.nodeName === 'A') { |
|
12542 // In jsdom-jscore, 'node.target' can be null. |
|
12543 // TODO: Explore fixing this by patching jsdom-jscore. |
|
12544 if (node.target && node.target.toLowerCase() === '_blank') { |
|
12545 node.rel = 'noreferrer noopener'; |
|
12546 } else { |
|
12547 node.removeAttribute('target'); |
|
12548 node.removeAttribute('rel'); |
|
12549 } // Saves anchor elements name attribute as id |
|
12550 |
|
12551 |
|
12552 if (node.name && !node.id) { |
|
12553 node.id = node.name; |
|
12554 } // Keeps id only if there is an internal link pointing to it |
|
12555 |
|
12556 |
|
12557 if (node.id && !node.ownerDocument.querySelector(`[href="#${node.id}"]`)) { |
|
12558 node.removeAttribute('id'); |
|
12559 } |
|
12560 } |
|
12561 } |
|
12562 |
|
12563 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/head-remover.js |
|
12564 function headRemover(node) { |
|
12565 if (node.nodeName !== 'SCRIPT' && node.nodeName !== 'NOSCRIPT' && node.nodeName !== 'TEMPLATE' && node.nodeName !== 'STYLE') { |
|
12566 return; |
|
12567 } |
|
12568 |
|
12569 node.parentNode.removeChild(node); |
|
12570 } |
|
12571 |
|
12572 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/ms-list-converter.js |
|
12573 /** |
|
12574 * Browser dependencies |
|
12575 */ |
|
12576 const { |
|
12577 parseInt: ms_list_converter_parseInt |
|
12578 } = window; |
|
12579 |
|
12580 function ms_list_converter_isList(node) { |
|
12581 return node.nodeName === 'OL' || node.nodeName === 'UL'; |
|
12582 } |
|
12583 |
|
12584 function msListConverter(node, doc) { |
|
12585 if (node.nodeName !== 'P') { |
|
12586 return; |
|
12587 } |
|
12588 |
|
12589 const style = node.getAttribute('style'); |
|
12590 |
|
12591 if (!style) { |
|
12592 return; |
|
12593 } // Quick check. |
|
12594 |
|
12595 |
|
12596 if (style.indexOf('mso-list') === -1) { |
|
12597 return; |
|
12598 } |
|
12599 |
|
12600 const matches = /mso-list\s*:[^;]+level([0-9]+)/i.exec(style); |
|
12601 |
|
12602 if (!matches) { |
|
12603 return; |
|
12604 } |
|
12605 |
|
12606 let level = ms_list_converter_parseInt(matches[1], 10) - 1 || 0; |
|
12607 const prevNode = node.previousElementSibling; // Add new list if no previous. |
|
12608 |
|
12609 if (!prevNode || !ms_list_converter_isList(prevNode)) { |
|
12610 // See https://html.spec.whatwg.org/multipage/grouping-content.html#attr-ol-type. |
|
12611 const type = node.textContent.trim().slice(0, 1); |
|
12612 const isNumeric = /[1iIaA]/.test(type); |
|
12613 const newListNode = doc.createElement(isNumeric ? 'ol' : 'ul'); |
|
12614 |
|
12615 if (isNumeric) { |
|
12616 newListNode.setAttribute('type', type); |
|
12617 } |
|
12618 |
|
12619 node.parentNode.insertBefore(newListNode, node); |
|
12620 } |
|
12621 |
|
12622 const listNode = node.previousElementSibling; |
|
12623 const listType = listNode.nodeName; |
|
12624 const listItem = doc.createElement('li'); |
|
12625 let receivingNode = listNode; // Remove the first span with list info. |
|
12626 |
|
12627 node.removeChild(node.firstChild); // Add content. |
|
12628 |
|
12629 while (node.firstChild) { |
|
12630 listItem.appendChild(node.firstChild); |
|
12631 } // Change pointer depending on indentation level. |
|
12632 |
|
12633 |
|
12634 while (level--) { |
|
12635 receivingNode = receivingNode.lastChild || receivingNode; // If it's a list, move pointer to the last item. |
|
12636 |
|
12637 if (ms_list_converter_isList(receivingNode)) { |
|
12638 receivingNode = receivingNode.lastChild || receivingNode; |
|
12639 } |
|
12640 } // Make sure we append to a list. |
|
12641 |
|
12642 |
|
12643 if (!ms_list_converter_isList(receivingNode)) { |
|
12644 receivingNode = receivingNode.appendChild(doc.createElement(listType)); |
|
12645 } // Append the list item to the list. |
|
12646 |
|
12647 |
|
12648 receivingNode.appendChild(listItem); // Remove the wrapper paragraph. |
|
12649 |
|
12650 node.parentNode.removeChild(node); |
|
12651 } |
|
12652 |
|
12653 ;// CONCATENATED MODULE: external ["wp","blob"] |
|
12654 var external_wp_blob_namespaceObject = window["wp"]["blob"]; |
|
12655 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/image-corrector.js |
|
12656 /** |
|
12657 * WordPress dependencies |
|
12658 */ |
|
12659 |
|
12660 /** |
|
12661 * Browser dependencies |
|
12662 */ |
|
12663 |
|
12664 const { |
|
12665 atob, |
|
12666 File |
|
12667 } = window; |
|
12668 function imageCorrector(node) { |
|
12669 if (node.nodeName !== 'IMG') { |
|
12670 return; |
|
12671 } |
|
12672 |
|
12673 if (node.src.indexOf('file:') === 0) { |
|
12674 node.src = ''; |
|
12675 } // This piece cannot be tested outside a browser env. |
|
12676 |
|
12677 |
|
12678 if (node.src.indexOf('data:') === 0) { |
|
12679 const [properties, data] = node.src.split(','); |
|
12680 const [type] = properties.slice(5).split(';'); |
|
12681 |
|
12682 if (!data || !type) { |
|
12683 node.src = ''; |
|
12684 return; |
|
12685 } |
|
12686 |
|
12687 let decoded; // Can throw DOMException! |
|
12688 |
|
12689 try { |
|
12690 decoded = atob(data); |
|
12691 } catch (e) { |
|
12692 node.src = ''; |
|
12693 return; |
|
12694 } |
|
12695 |
|
12696 const uint8Array = new Uint8Array(decoded.length); |
|
12697 |
|
12698 for (let i = 0; i < uint8Array.length; i++) { |
|
12699 uint8Array[i] = decoded.charCodeAt(i); |
|
12700 } |
|
12701 |
|
12702 const name = type.replace('/', '.'); |
|
12703 const file = new File([uint8Array], name, { |
|
12704 type |
|
12705 }); |
|
12706 node.src = (0,external_wp_blob_namespaceObject.createBlobURL)(file); |
|
12707 } // Remove trackers and hardly visible images. |
|
12708 |
|
12709 |
|
12710 if (node.height === 1 || node.width === 1) { |
|
12711 node.parentNode.removeChild(node); |
|
12712 } |
|
12713 } |
|
12714 |
|
12715 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/div-normaliser.js |
|
12716 /** |
|
12717 * Internal dependencies |
|
12718 */ |
|
12719 |
|
12720 function divNormaliser(node) { |
|
12721 if (node.nodeName !== 'DIV') { |
|
12722 return; |
|
12723 } |
|
12724 |
|
12725 node.innerHTML = normaliseBlocks(node.innerHTML); |
|
12726 } |
|
12727 |
|
12728 // EXTERNAL MODULE: ./node_modules/showdown/dist/showdown.js |
|
12729 var showdown = __webpack_require__(7308); |
|
12730 var showdown_default = /*#__PURE__*/__webpack_require__.n(showdown); |
|
12731 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/markdown-converter.js |
|
12732 /** |
|
12733 * External dependencies |
|
12734 */ |
|
12735 // Reuse the same showdown converter. |
|
12736 |
|
12737 const converter = new (showdown_default()).Converter({ |
|
12738 noHeaderId: true, |
|
12739 tables: true, |
|
12740 literalMidWordUnderscores: true, |
|
12741 omitExtraWLInCodeBlocks: true, |
|
12742 simpleLineBreaks: true, |
|
12743 strikethrough: true |
|
12744 }); |
|
12745 /** |
|
12746 * Corrects the Slack Markdown variant of the code block. |
|
12747 * If uncorrected, it will be converted to inline code. |
|
12748 * |
|
12749 * @see https://get.slack.help/hc/en-us/articles/202288908-how-can-i-add-formatting-to-my-messages-#code-blocks |
|
12750 * |
|
12751 * @param {string} text The potential Markdown text to correct. |
|
12752 * |
|
12753 * @return {string} The corrected Markdown. |
|
12754 */ |
|
12755 |
|
12756 function slackMarkdownVariantCorrector(text) { |
|
12757 return text.replace(/((?:^|\n)```)([^\n`]+)(```(?:$|\n))/, (match, p1, p2, p3) => `${p1}\n${p2}\n${p3}`); |
|
12758 } |
|
12759 /** |
|
12760 * Converts a piece of text into HTML based on any Markdown present. |
|
12761 * Also decodes any encoded HTML. |
|
12762 * |
|
12763 * @param {string} text The plain text to convert. |
|
12764 * |
|
12765 * @return {string} HTML. |
|
12766 */ |
|
12767 |
|
12768 |
|
12769 function markdownConverter(text) { |
|
12770 return converter.makeHtml(slackMarkdownVariantCorrector(text)); |
|
12771 } |
|
12772 |
|
12773 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/iframe-remover.js |
|
12774 /** |
|
12775 * Removes iframes. |
|
12776 * |
|
12777 * @param {Node} node The node to check. |
|
12778 * |
|
12779 * @return {void} |
|
12780 */ |
|
12781 function iframeRemover(node) { |
|
12782 if (node.nodeName === 'IFRAME') { |
|
12783 const text = node.ownerDocument.createTextNode(node.src); |
|
12784 node.parentNode.replaceChild(text, node); |
|
12785 } |
|
12786 } |
|
12787 |
|
12788 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/google-docs-uid-remover.js |
|
12789 /** |
|
12790 * WordPress dependencies |
|
12791 */ |
|
12792 |
|
12793 function googleDocsUIdRemover(node) { |
|
12794 if (!node.id || node.id.indexOf('docs-internal-guid-') !== 0) { |
|
12795 return; |
|
12796 } |
|
12797 |
|
12798 (0,external_wp_dom_namespaceObject.unwrap)(node); |
|
12799 } |
|
12800 |
|
12801 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/html-formatting-remover.js |
|
12802 /** |
|
12803 * Internal dependencies |
|
12804 */ |
|
12805 |
|
12806 |
|
12807 function isFormattingSpace(character) { |
|
12808 return character === ' ' || character === '\r' || character === '\n' || character === '\t'; |
|
12809 } |
|
12810 /** |
|
12811 * Removes spacing that formats HTML. |
|
12812 * |
|
12813 * @see https://www.w3.org/TR/css-text-3/#white-space-processing |
|
12814 * |
|
12815 * @param {Node} node The node to be processed. |
|
12816 * @return {void} |
|
12817 */ |
|
12818 |
|
12819 |
|
12820 function htmlFormattingRemover(node) { |
|
12821 if (node.nodeType !== node.TEXT_NODE) { |
|
12822 return; |
|
12823 } // Ignore pre content. Note that this does not use Element#closest due to |
|
12824 // a combination of (a) node may not be Element and (b) node.parentElement |
|
12825 // does not have full support in all browsers (Internet Exporer). |
|
12826 // |
|
12827 // See: https://developer.mozilla.org/en-US/docs/Web/API/Node/parentElement#Browser_compatibility |
|
12828 |
|
12829 /** @type {Node?} */ |
|
12830 |
|
12831 |
|
12832 let parent = node; |
|
12833 |
|
12834 while (parent = parent.parentNode) { |
|
12835 if (parent.nodeType === parent.ELEMENT_NODE && parent.nodeName === 'PRE') { |
|
12836 return; |
|
12837 } |
|
12838 } // First, replace any sequence of HTML formatting space with a single space. |
|
12839 |
|
12840 |
|
12841 let newData = node.data.replace(/[ \r\n\t]+/g, ' '); // Remove the leading space if the text element is at the start of a block, |
|
12842 // is preceded by a line break element, or has a space in the previous |
|
12843 // node. |
|
12844 |
|
12845 if (newData[0] === ' ') { |
|
12846 const previousSibling = getSibling(node, 'previous'); |
|
12847 |
|
12848 if (!previousSibling || previousSibling.nodeName === 'BR' || previousSibling.textContent.slice(-1) === ' ') { |
|
12849 newData = newData.slice(1); |
|
12850 } |
|
12851 } // Remove the trailing space if the text element is at the end of a block, |
|
12852 // is succeded by a line break element, or has a space in the next text |
|
12853 // node. |
|
12854 |
|
12855 |
|
12856 if (newData[newData.length - 1] === ' ') { |
|
12857 const nextSibling = getSibling(node, 'next'); |
|
12858 |
|
12859 if (!nextSibling || nextSibling.nodeName === 'BR' || nextSibling.nodeType === nextSibling.TEXT_NODE && isFormattingSpace(nextSibling.textContent[0])) { |
|
12860 newData = newData.slice(0, -1); |
|
12861 } |
|
12862 } // If there's no data left, remove the node, so `previousSibling` stays |
|
12863 // accurate. Otherwise, update the node data. |
|
12864 |
|
12865 |
|
12866 if (!newData) { |
|
12867 node.parentNode.removeChild(node); |
|
12868 } else { |
|
12869 node.data = newData; |
|
12870 } |
|
12871 } |
|
12872 |
|
12873 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/br-remover.js |
|
12874 /** |
|
12875 * Internal dependencies |
|
12876 */ |
|
12877 |
|
12878 /** |
|
12879 * Removes trailing br elements from text-level content. |
|
12880 * |
|
12881 * @param {Element} node Node to check. |
|
12882 */ |
|
12883 |
|
12884 function brRemover(node) { |
|
12885 if (node.nodeName !== 'BR') { |
|
12886 return; |
|
12887 } |
|
12888 |
|
12889 if (getSibling(node, 'next')) { |
|
12890 return; |
|
12891 } |
|
12892 |
|
12893 node.parentNode.removeChild(node); |
|
12894 } |
|
12895 |
|
12896 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/empty-paragraph-remover.js |
|
12897 /** |
|
12898 * Removes empty paragraph elements. |
|
12899 * |
|
12900 * @param {Element} node Node to check. |
|
12901 */ |
|
12902 function emptyParagraphRemover(node) { |
|
12903 if (node.nodeName !== 'P') { |
|
12904 return; |
|
12905 } |
|
12906 |
|
12907 if (node.hasChildNodes()) { |
|
12908 return; |
|
12909 } |
|
12910 |
|
12911 node.parentNode.removeChild(node); |
|
12912 } |
|
12913 |
|
12914 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/paste-handler.js |
|
12915 /** |
|
12916 * External dependencies |
|
12917 */ |
|
12918 |
|
12919 /** |
|
12920 * WordPress dependencies |
|
12921 */ |
|
12922 |
|
12923 |
|
12924 /** |
|
12925 * Internal dependencies |
|
12926 */ |
|
12927 |
|
12928 |
|
12929 |
|
12930 |
|
12931 |
|
12932 |
|
12933 |
|
12934 |
|
12935 |
|
12936 |
|
12937 |
|
12938 |
|
12939 |
|
12940 |
|
12941 |
|
12942 |
|
12943 |
|
12944 |
|
12945 |
|
12946 |
|
12947 |
|
12948 |
|
12949 |
|
12950 |
|
12951 |
|
12952 /** |
|
12953 * Browser dependencies |
|
12954 */ |
|
12955 |
|
12956 const { |
|
12957 console: paste_handler_console |
|
12958 } = window; |
|
12959 /** |
|
12960 * Filters HTML to only contain phrasing content. |
|
12961 * |
|
12962 * @param {string} HTML The HTML to filter. |
|
12963 * @param {boolean} preserveWhiteSpace Whether or not to preserve consequent white space. |
|
12964 * |
|
12965 * @return {string} HTML only containing phrasing content. |
|
12966 */ |
|
12967 |
|
12968 function filterInlineHTML(HTML, preserveWhiteSpace) { |
|
12969 HTML = deepFilterHTML(HTML, [googleDocsUIdRemover, phrasingContentReducer, commentRemover]); |
|
12970 HTML = (0,external_wp_dom_namespaceObject.removeInvalidHTML)(HTML, (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)('paste'), { |
|
12971 inline: true |
|
12972 }); |
|
12973 |
|
12974 if (!preserveWhiteSpace) { |
|
12975 HTML = deepFilterHTML(HTML, [htmlFormattingRemover, brRemover]); |
|
12976 } // Allows us to ask for this information when we get a report. |
|
12977 |
|
12978 |
|
12979 paste_handler_console.log('Processed inline HTML:\n\n', HTML); |
|
12980 return HTML; |
|
12981 } |
|
12982 /** |
|
12983 * Converts an HTML string to known blocks. Strips everything else. |
|
12984 * |
|
12985 * @param {Object} options |
|
12986 * @param {string} [options.HTML] The HTML to convert. |
|
12987 * @param {string} [options.plainText] Plain text version. |
|
12988 * @param {string} [options.mode] Handle content as blocks or inline content. |
|
12989 * * 'AUTO': Decide based on the content passed. |
|
12990 * * 'INLINE': Always handle as inline content, and return string. |
|
12991 * * 'BLOCKS': Always handle as blocks, and return array of blocks. |
|
12992 * @param {Array} [options.tagName] The tag into which content will be inserted. |
|
12993 * @param {boolean} [options.preserveWhiteSpace] Whether or not to preserve consequent white space. |
|
12994 * |
|
12995 * @return {Array|string} A list of blocks or a string, depending on `handlerMode`. |
|
12996 */ |
|
12997 |
|
12998 |
|
12999 function pasteHandler(_ref) { |
|
13000 let { |
|
13001 HTML = '', |
|
13002 plainText = '', |
|
13003 mode = 'AUTO', |
|
13004 tagName, |
|
13005 preserveWhiteSpace |
|
13006 } = _ref; |
|
13007 // First of all, strip any meta tags. |
|
13008 HTML = HTML.replace(/<meta[^>]+>/g, ''); // Strip Windows markers. |
|
13009 |
|
13010 HTML = HTML.replace(/^\s*<html[^>]*>\s*<body[^>]*>(?:\s*<!--\s*StartFragment\s*-->)?/i, ''); |
|
13011 HTML = HTML.replace(/(?:<!--\s*EndFragment\s*-->\s*)?<\/body>\s*<\/html>\s*$/i, ''); // If we detect block delimiters in HTML, parse entirely as blocks. |
|
13012 |
|
13013 if (mode !== 'INLINE') { |
|
13014 // Check plain text if there is no HTML. |
|
13015 const content = HTML ? HTML : plainText; |
|
13016 |
|
13017 if (content.indexOf('<!-- wp:') !== -1) { |
|
13018 return parser_parse(content); |
|
13019 } |
|
13020 } // Normalize unicode to use composed characters. |
|
13021 // This is unsupported in IE 11 but it's a nice-to-have feature, not mandatory. |
|
13022 // Not normalizing the content will only affect older browsers and won't |
|
13023 // entirely break the app. |
|
13024 // See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize |
|
13025 // See: https://core.trac.wordpress.org/ticket/30130 |
|
13026 // See: https://github.com/WordPress/gutenberg/pull/6983#pullrequestreview-125151075 |
|
13027 |
|
13028 |
|
13029 if (String.prototype.normalize) { |
|
13030 HTML = HTML.normalize(); |
|
13031 } // Parse Markdown (and encoded HTML) if: |
|
13032 // * There is a plain text version. |
|
13033 // * There is no HTML version, or it has no formatting. |
|
13034 |
|
13035 |
|
13036 if (plainText && (!HTML || isPlain(HTML))) { |
|
13037 HTML = plainText; // The markdown converter (Showdown) trims whitespace. |
|
13038 |
|
13039 if (!/^\s+$/.test(plainText)) { |
|
13040 HTML = markdownConverter(HTML); |
|
13041 } // Switch to inline mode if: |
|
13042 // * The current mode is AUTO. |
|
13043 // * The original plain text had no line breaks. |
|
13044 // * The original plain text was not an HTML paragraph. |
|
13045 // * The converted text is just a paragraph. |
|
13046 |
|
13047 |
|
13048 if (mode === 'AUTO' && plainText.indexOf('\n') === -1 && plainText.indexOf('<p>') !== 0 && HTML.indexOf('<p>') === 0) { |
|
13049 mode = 'INLINE'; |
|
13050 } |
|
13051 } |
|
13052 |
|
13053 if (mode === 'INLINE') { |
|
13054 return filterInlineHTML(HTML, preserveWhiteSpace); |
|
13055 } // An array of HTML strings and block objects. The blocks replace matched |
|
13056 // shortcodes. |
|
13057 |
|
13058 |
|
13059 const pieces = shortcode_converter(HTML); // The call to shortcodeConverter will always return more than one element |
|
13060 // if shortcodes are matched. The reason is when shortcodes are matched |
|
13061 // empty HTML strings are included. |
|
13062 |
|
13063 const hasShortcodes = pieces.length > 1; |
|
13064 |
|
13065 if (mode === 'AUTO' && !hasShortcodes && isInlineContent(HTML, tagName)) { |
|
13066 return filterInlineHTML(HTML, preserveWhiteSpace); |
|
13067 } |
|
13068 |
|
13069 const phrasingContentSchema = (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)('paste'); |
|
13070 const blockContentSchema = getBlockContentSchema('paste'); |
|
13071 const blocks = (0,external_lodash_namespaceObject.compact)((0,external_lodash_namespaceObject.flatMap)(pieces, piece => { |
|
13072 // Already a block from shortcode. |
|
13073 if (typeof piece !== 'string') { |
|
13074 return piece; |
|
13075 } |
|
13076 |
|
13077 const filters = [googleDocsUIdRemover, msListConverter, headRemover, listReducer, imageCorrector, phrasingContentReducer, specialCommentConverter, commentRemover, iframeRemover, figureContentReducer, blockquoteNormaliser, divNormaliser]; |
|
13078 const schema = { ...blockContentSchema, |
|
13079 // Keep top-level phrasing content, normalised by `normaliseBlocks`. |
|
13080 ...phrasingContentSchema |
|
13081 }; |
|
13082 piece = deepFilterHTML(piece, filters, blockContentSchema); |
|
13083 piece = (0,external_wp_dom_namespaceObject.removeInvalidHTML)(piece, schema); |
|
13084 piece = normaliseBlocks(piece); |
|
13085 piece = deepFilterHTML(piece, [htmlFormattingRemover, brRemover, emptyParagraphRemover], blockContentSchema); // Allows us to ask for this information when we get a report. |
|
13086 |
|
13087 paste_handler_console.log('Processed HTML piece:\n\n', piece); |
|
13088 return htmlToBlocks(piece); |
|
13089 })); // If we're allowed to return inline content, and there is only one |
|
13090 // inlineable block, and the original plain text content does not have any |
|
13091 // line breaks, then treat it as inline paste. |
|
13092 |
|
13093 if (mode === 'AUTO' && blocks.length === 1 && registration_hasBlockSupport(blocks[0].name, '__unstablePasteTextInline', false)) { |
|
13094 // Don't catch line breaks at the start or end. |
|
13095 const trimmedPlainText = plainText.replace(/^[\n]+|[\n]+$/g, ''); |
|
13096 |
|
13097 if (trimmedPlainText !== '' && trimmedPlainText.indexOf('\n') === -1) { |
|
13098 return (0,external_wp_dom_namespaceObject.removeInvalidHTML)(getBlockInnerHTML(blocks[0]), phrasingContentSchema); |
|
13099 } |
|
13100 } |
|
13101 |
|
13102 return blocks; |
|
13103 } |
|
13104 |
|
13105 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/categories.js |
|
13106 /** |
|
13107 * WordPress dependencies |
|
13108 */ |
|
13109 |
|
13110 /** |
|
13111 * Internal dependencies |
|
13112 */ |
|
13113 |
|
13114 |
|
13115 /** @typedef {import('../store/reducer').WPBlockCategory} WPBlockCategory */ |
|
13116 |
|
13117 /** |
|
13118 * Returns all the block categories. |
|
13119 * |
|
13120 * @return {WPBlockCategory[]} Block categories. |
|
13121 */ |
|
13122 |
|
13123 function categories_getCategories() { |
|
13124 return (0,external_wp_data_namespaceObject.select)(store).getCategories(); |
|
13125 } |
|
13126 /** |
|
13127 * Sets the block categories. |
|
13128 * |
|
13129 * @param {WPBlockCategory[]} categories Block categories. |
|
13130 */ |
|
13131 |
|
13132 function categories_setCategories(categories) { |
|
13133 (0,external_wp_data_namespaceObject.dispatch)(store).setCategories(categories); |
|
13134 } |
|
13135 /** |
|
13136 * Updates a category. |
|
13137 * |
|
13138 * @param {string} slug Block category slug. |
|
13139 * @param {WPBlockCategory} category Object containing the category properties |
|
13140 * that should be updated. |
|
13141 */ |
|
13142 |
|
13143 function categories_updateCategory(slug, category) { |
|
13144 (0,external_wp_data_namespaceObject.dispatch)(store).updateCategory(slug, category); |
|
13145 } |
|
13146 |
|
13147 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/templates.js |
|
13148 /** |
|
13149 * External dependencies |
|
13150 */ |
|
13151 |
|
13152 /** |
|
13153 * WordPress dependencies |
|
13154 */ |
|
13155 |
|
13156 |
|
13157 /** |
|
13158 * Internal dependencies |
|
13159 */ |
|
13160 |
|
13161 |
|
13162 |
|
13163 |
|
13164 /** |
|
13165 * Checks whether a list of blocks matches a template by comparing the block names. |
|
13166 * |
|
13167 * @param {Array} blocks Block list. |
|
13168 * @param {Array} template Block template. |
|
13169 * |
|
13170 * @return {boolean} Whether the list of blocks matches a templates. |
|
13171 */ |
|
13172 |
|
13173 function doBlocksMatchTemplate() { |
|
13174 let blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
|
13175 let template = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; |
|
13176 return blocks.length === template.length && (0,external_lodash_namespaceObject.every)(template, (_ref, index) => { |
|
13177 let [name,, innerBlocksTemplate] = _ref; |
|
13178 const block = blocks[index]; |
|
13179 return name === block.name && doBlocksMatchTemplate(block.innerBlocks, innerBlocksTemplate); |
|
13180 }); |
|
13181 } |
|
13182 /** |
|
13183 * Synchronize a block list with a block template. |
|
13184 * |
|
13185 * Synchronizing a block list with a block template means that we loop over the blocks |
|
13186 * keep the block as is if it matches the block at the same position in the template |
|
13187 * (If it has the same name) and if doesn't match, we create a new block based on the template. |
|
13188 * Extra blocks not present in the template are removed. |
|
13189 * |
|
13190 * @param {Array} blocks Block list. |
|
13191 * @param {Array} template Block template. |
|
13192 * |
|
13193 * @return {Array} Updated Block list. |
|
13194 */ |
|
13195 |
|
13196 function synchronizeBlocksWithTemplate() { |
|
13197 let blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
|
13198 let template = arguments.length > 1 ? arguments[1] : undefined; |
|
13199 |
|
13200 // If no template is provided, return blocks unmodified. |
|
13201 if (!template) { |
|
13202 return blocks; |
|
13203 } |
|
13204 |
|
13205 return (0,external_lodash_namespaceObject.map)(template, (_ref2, index) => { |
|
13206 let [name, attributes, innerBlocksTemplate] = _ref2; |
|
13207 const block = blocks[index]; |
|
13208 |
|
13209 if (block && block.name === name) { |
|
13210 const innerBlocks = synchronizeBlocksWithTemplate(block.innerBlocks, innerBlocksTemplate); |
|
13211 return { ...block, |
|
13212 innerBlocks |
|
13213 }; |
|
13214 } // To support old templates that were using the "children" format |
|
13215 // for the attributes using "html" strings now, we normalize the template attributes |
|
13216 // before creating the blocks. |
|
13217 |
|
13218 |
|
13219 const blockType = registration_getBlockType(name); |
|
13220 |
|
13221 const isHTMLAttribute = attributeDefinition => (0,external_lodash_namespaceObject.get)(attributeDefinition, ['source']) === 'html'; |
|
13222 |
|
13223 const isQueryAttribute = attributeDefinition => (0,external_lodash_namespaceObject.get)(attributeDefinition, ['source']) === 'query'; |
|
13224 |
|
13225 const normalizeAttributes = (schema, values) => { |
|
13226 return (0,external_lodash_namespaceObject.mapValues)(values, (value, key) => { |
|
13227 return normalizeAttribute(schema[key], value); |
|
13228 }); |
|
13229 }; |
|
13230 |
|
13231 const normalizeAttribute = (definition, value) => { |
|
13232 if (isHTMLAttribute(definition) && (0,external_lodash_namespaceObject.isArray)(value)) { |
|
13233 // Introduce a deprecated call at this point |
|
13234 // When we're confident that "children" format should be removed from the templates. |
|
13235 return (0,external_wp_element_namespaceObject.renderToString)(value); |
|
13236 } |
|
13237 |
|
13238 if (isQueryAttribute(definition) && value) { |
|
13239 return value.map(subValues => { |
|
13240 return normalizeAttributes(definition.query, subValues); |
|
13241 }); |
|
13242 } |
|
13243 |
|
13244 return value; |
|
13245 }; |
|
13246 |
|
13247 const normalizedAttributes = normalizeAttributes((0,external_lodash_namespaceObject.get)(blockType, ['attributes'], {}), attributes); |
|
13248 let [blockName, blockAttributes] = convertLegacyBlockNameAndAttributes(name, normalizedAttributes); // If a Block is undefined at this point, use the core/missing block as |
|
13249 // a placeholder for a better user experience. |
|
13250 |
|
13251 if (undefined === registration_getBlockType(blockName)) { |
|
13252 blockAttributes = { |
|
13253 originalName: name, |
|
13254 originalContent: '', |
|
13255 originalUndelimitedContent: '' |
|
13256 }; |
|
13257 blockName = 'core/missing'; |
|
13258 } |
|
13259 |
|
13260 return createBlock(blockName, blockAttributes, synchronizeBlocksWithTemplate([], innerBlocksTemplate)); |
|
13261 }); |
|
13262 } |
|
13263 |
|
13264 ;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/index.js |
|
13265 // The blocktype is the most important concept within the block API. It defines |
|
13266 // all aspects of the block configuration and its interfaces, including `edit` |
|
13267 // and `save`. The transforms specification allows converting one blocktype to |
|
13268 // another through formulas defined by either the source or the destination. |
|
13269 // Switching a blocktype is to be considered a one-way operation implying a |
|
13270 // transformation in the opposite way has to be handled explicitly. |
|
13271 // The block tree is composed of a collection of block nodes. Blocks contained |
|
13272 // within other blocks are called inner blocks. An important design |
|
13273 // consideration is that inner blocks are -- conceptually -- not part of the |
|
13274 // territory established by the parent block that contains them. |
|
13275 // |
|
13276 // This has multiple practical implications: when parsing, we can safely dispose |
|
13277 // of any block boundary found within a block from the innerHTML property when |
|
13278 // transfering to state. Not doing so would have a compounding effect on memory |
|
13279 // and uncertainty over the source of truth. This can be illustrated in how, |
|
13280 // given a tree of `n` nested blocks, the entry node would have to contain the |
|
13281 // actual content of each block while each subsequent block node in the state |
|
13282 // tree would replicate the entire chain `n-1`, meaning the extreme end node |
|
13283 // would have been replicated `n` times as the tree is traversed and would |
|
13284 // generate uncertainty as to which one is to hold the current value of the |
|
13285 // block. For composition, it also means inner blocks can effectively be child |
|
13286 // components whose mechanisms can be shielded from the `edit` implementation |
|
13287 // and just passed along. |
|
13288 |
|
13289 |
|
13290 |
|
13291 // While block transformations account for a specific surface of the API, there |
|
13292 // are also raw transformations which handle arbitrary sources not made out of |
|
13293 // blocks but producing block basaed on various heursitics. This includes |
|
13294 // pasting rich text or HTML data. |
|
13295 |
|
13296 // The process of serialization aims to deflate the internal memory of the block |
|
13297 // editor and its state representation back into an HTML valid string. This |
|
13298 // process restores the document integrity and inserts invisible delimiters |
|
13299 // around each block with HTML comment boundaries which can contain any extra |
|
13300 // attributes needed to operate with the block later on. |
|
13301 |
|
13302 // Validation is the process of comparing a block source with its output before |
|
13303 // there is any user input or interaction with a block. When this operation |
|
13304 // fails -- for whatever reason -- the block is to be considered invalid. As |
|
13305 // part of validating a block the system will attempt to run the source against |
|
13306 // any provided deprecation definitions. |
|
13307 // |
|
13308 // Worth emphasizing that validation is not a case of whether the markup is |
|
13309 // merely HTML spec-compliant but about how the editor knows to create such |
|
13310 // markup and that its inability to create an identical result can be a strong |
|
13311 // indicator of potential data loss (the invalidation is then a protective |
|
13312 // measure). |
|
13313 // |
|
13314 // The invalidation process can also be deconstructed in phases: 1) validate the |
|
13315 // block exists; 2) validate the source matches the output; 3) validate the |
|
13316 // source matches deprecated outputs; 4) work through the significance of |
|
13317 // differences. These are stacked in a way that favors performance and optimizes |
|
13318 // for the majority of cases. That is to say, the evaluation logic can become |
|
13319 // more sophisticated the further down it goes in the process as the cost is |
|
13320 // accounted for. The first logic checks have to be extremely efficient since |
|
13321 // they will be run for all valid and invalid blocks alike. However, once a |
|
13322 // block is detected as invalid -- failing the three first steps -- it is |
|
13323 // adequate to spend more time determining validity before throwing a conflict. |
|
13324 |
|
13325 |
|
13326 // Blocks are inherently indifferent about where the data they operate with ends |
|
13327 // up being saved. For example, all blocks can have a static and dynamic aspect |
|
13328 // to them depending on the needs. The static nature of a block is the `save()` |
|
13329 // definition that is meant to be serialized into HTML and which can be left |
|
13330 // void. Any block can also register a `render_callback` on the server, which |
|
13331 // makes its output dynamic either in part or in its totality. |
|
13332 // |
|
13333 // Child blocks are defined as a relationship that builds on top of the inner |
|
13334 // blocks mechanism. A child block is a block node of a particular type that can |
|
13335 // only exist within the inner block boundaries of a specific parent type. This |
|
13336 // allows block authors to compose specific blocks that are not meant to be used |
|
13337 // outside of a specified parent block context. Thus, child blocks extend the |
|
13338 // concept of inner blocks to support a more direct relationship between sets of |
|
13339 // blocks. The addition of parent–child would be a subset of the inner block |
|
13340 // functionality under the premise that certain blocks only make sense as |
|
13341 // children of another block. |
|
13342 |
|
13343 |
|
13344 // Templates are, in a general sense, a basic collection of block nodes with any |
|
13345 // given set of predefined attributes that are supplied as the initial state of |
|
13346 // an inner blocks group. These nodes can, in turn, contain any number of nested |
|
13347 // blocks within their definition. Templates allow both to specify a default |
|
13348 // state for an editor session or a default set of blocks for any inner block |
|
13349 // implementation within a specific block. |
|
13350 |
|
13351 |
|
13352 |
|
13353 |
|
13354 |
|
13355 |
|
13356 ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js |
14056 function _extends() { |
13357 function _extends() { |
14057 _extends = Object.assign || function (target) { |
13358 _extends = Object.assign ? Object.assign.bind() : function (target) { |
14058 for (var i = 1; i < arguments.length; i++) { |
13359 for (var i = 1; i < arguments.length; i++) { |
14059 var source = arguments[i]; |
13360 var source = arguments[i]; |
14060 |
13361 |
14061 for (var key in source) { |
13362 for (var key in source) { |
14062 if (Object.prototype.hasOwnProperty.call(source, key)) { |
13363 if (Object.prototype.hasOwnProperty.call(source, key)) { |