80 /******/ // __webpack_public_path__ |
80 /******/ // __webpack_public_path__ |
81 /******/ __webpack_require__.p = ""; |
81 /******/ __webpack_require__.p = ""; |
82 /******/ |
82 /******/ |
83 /******/ |
83 /******/ |
84 /******/ // Load entry module and return exports |
84 /******/ // Load entry module and return exports |
85 /******/ return __webpack_require__(__webpack_require__.s = 441); |
85 /******/ return __webpack_require__(__webpack_require__.s = "0ATp"); |
86 /******/ }) |
86 /******/ }) |
87 /************************************************************************/ |
87 /************************************************************************/ |
88 /******/ ({ |
88 /******/ ({ |
89 |
89 |
90 /***/ 0: |
90 /***/ "//Lo": |
91 /***/ (function(module, exports) { |
|
92 |
|
93 (function() { module.exports = this["wp"]["element"]; }()); |
|
94 |
|
95 /***/ }), |
|
96 |
|
97 /***/ 1: |
|
98 /***/ (function(module, exports) { |
|
99 |
|
100 (function() { module.exports = this["wp"]["i18n"]; }()); |
|
101 |
|
102 /***/ }), |
|
103 |
|
104 /***/ 103: |
|
105 /***/ (function(module, exports) { |
|
106 |
|
107 (function() { module.exports = this["wp"]["autop"]; }()); |
|
108 |
|
109 /***/ }), |
|
110 |
|
111 /***/ 125: |
|
112 /***/ (function(module, exports) { |
|
113 |
|
114 (function() { module.exports = this["wp"]["shortcode"]; }()); |
|
115 |
|
116 /***/ }), |
|
117 |
|
118 /***/ 14: |
|
119 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
91 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
120 |
92 |
121 "use strict"; |
93 "use strict"; |
122 |
94 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("GRId"); |
123 // EXPORTS |
|
124 __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _slicedToArray; }); |
|
125 |
|
126 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js |
|
127 var arrayWithHoles = __webpack_require__(38); |
|
128 |
|
129 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js |
|
130 function _iterableToArrayLimit(arr, i) { |
|
131 if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; |
|
132 var _arr = []; |
|
133 var _n = true; |
|
134 var _d = false; |
|
135 var _e = undefined; |
|
136 |
|
137 try { |
|
138 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { |
|
139 _arr.push(_s.value); |
|
140 |
|
141 if (i && _arr.length === i) break; |
|
142 } |
|
143 } catch (err) { |
|
144 _d = true; |
|
145 _e = err; |
|
146 } finally { |
|
147 try { |
|
148 if (!_n && _i["return"] != null) _i["return"](); |
|
149 } finally { |
|
150 if (_d) throw _e; |
|
151 } |
|
152 } |
|
153 |
|
154 return _arr; |
|
155 } |
|
156 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js |
|
157 var unsupportedIterableToArray = __webpack_require__(29); |
|
158 |
|
159 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js |
|
160 var nonIterableRest = __webpack_require__(39); |
|
161 |
|
162 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 function _slicedToArray(arr, i) { |
|
168 return Object(arrayWithHoles["a" /* default */])(arr) || _iterableToArrayLimit(arr, i) || Object(unsupportedIterableToArray["a" /* default */])(arr, i) || Object(nonIterableRest["a" /* default */])(); |
|
169 } |
|
170 |
|
171 /***/ }), |
|
172 |
|
173 /***/ 146: |
|
174 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
175 |
|
176 "use strict"; |
|
177 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _toArray; }); |
|
178 /* harmony import */ var _arrayWithHoles__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(38); |
|
179 /* harmony import */ var _iterableToArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(35); |
|
180 /* harmony import */ var _unsupportedIterableToArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(29); |
|
181 /* harmony import */ var _nonIterableRest__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(39); |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 function _toArray(arr) { |
|
187 return Object(_arrayWithHoles__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(arr) || Object(_iterableToArray__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(arr) || Object(_unsupportedIterableToArray__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"])(arr) || Object(_nonIterableRest__WEBPACK_IMPORTED_MODULE_3__[/* default */ "a"])(); |
|
188 } |
|
189 |
|
190 /***/ }), |
|
191 |
|
192 /***/ 18: |
|
193 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
194 |
|
195 "use strict"; |
|
196 |
|
197 // EXPORTS |
|
198 __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _toConsumableArray; }); |
|
199 |
|
200 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js |
|
201 var arrayLikeToArray = __webpack_require__(26); |
|
202 |
|
203 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js |
|
204 |
|
205 function _arrayWithoutHoles(arr) { |
|
206 if (Array.isArray(arr)) return Object(arrayLikeToArray["a" /* default */])(arr); |
|
207 } |
|
208 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js |
|
209 var iterableToArray = __webpack_require__(35); |
|
210 |
|
211 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js |
|
212 var unsupportedIterableToArray = __webpack_require__(29); |
|
213 |
|
214 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js |
|
215 function _nonIterableSpread() { |
|
216 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
|
217 } |
|
218 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js |
|
219 |
|
220 |
|
221 |
|
222 |
|
223 function _toConsumableArray(arr) { |
|
224 return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || Object(unsupportedIterableToArray["a" /* default */])(arr) || _nonIterableSpread(); |
|
225 } |
|
226 |
|
227 /***/ }), |
|
228 |
|
229 /***/ 19: |
|
230 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
231 |
|
232 "use strict"; |
|
233 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; }); |
|
234 function _defineProperties(target, props) { |
|
235 for (var i = 0; i < props.length; i++) { |
|
236 var descriptor = props[i]; |
|
237 descriptor.enumerable = descriptor.enumerable || false; |
|
238 descriptor.configurable = true; |
|
239 if ("value" in descriptor) descriptor.writable = true; |
|
240 Object.defineProperty(target, descriptor.key, descriptor); |
|
241 } |
|
242 } |
|
243 |
|
244 function _createClass(Constructor, protoProps, staticProps) { |
|
245 if (protoProps) _defineProperties(Constructor.prototype, protoProps); |
|
246 if (staticProps) _defineProperties(Constructor, staticProps); |
|
247 return Constructor; |
|
248 } |
|
249 |
|
250 /***/ }), |
|
251 |
|
252 /***/ 2: |
|
253 /***/ (function(module, exports) { |
|
254 |
|
255 (function() { module.exports = this["lodash"]; }()); |
|
256 |
|
257 /***/ }), |
|
258 |
|
259 /***/ 20: |
|
260 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
261 |
|
262 "use strict"; |
|
263 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; }); |
|
264 function _classCallCheck(instance, Constructor) { |
|
265 if (!(instance instanceof Constructor)) { |
|
266 throw new TypeError("Cannot call a class as a function"); |
|
267 } |
|
268 } |
|
269 |
|
270 /***/ }), |
|
271 |
|
272 /***/ 202: |
|
273 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
274 |
|
275 "use strict"; |
|
276 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0); |
|
277 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); |
95 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); |
278 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6); |
96 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("Tqx9"); |
279 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__); |
97 /* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__); |
280 |
98 |
281 |
99 |
282 /** |
100 /** |
283 * WordPress dependencies |
101 * WordPress dependencies |
284 */ |
102 */ |
285 |
103 |
286 var blockDefault = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], { |
104 const blockDefault = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], { |
287 xmlns: "http://www.w3.org/2000/svg", |
105 xmlns: "http://www.w3.org/2000/svg", |
288 viewBox: "0 0 24 24" |
106 viewBox: "0 0 24 24" |
289 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], { |
107 }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], { |
290 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 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" |
291 })); |
109 })); |
292 /* harmony default export */ __webpack_exports__["a"] = (blockDefault); |
110 /* harmony default export */ __webpack_exports__["a"] = (blockDefault); |
293 |
111 |
294 |
112 |
295 /***/ }), |
113 /***/ }), |
296 |
114 |
297 /***/ 26: |
115 /***/ "0ATp": |
298 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
116 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
299 |
117 |
300 "use strict"; |
118 "use strict"; |
301 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayLikeToArray; }); |
119 // ESM COMPAT FLAG |
302 function _arrayLikeToArray(arr, len) { |
120 __webpack_require__.r(__webpack_exports__); |
303 if (len == null || len > arr.length) len = arr.length; |
121 |
304 |
122 // EXPORTS |
305 for (var i = 0, arr2 = new Array(len); i < len; i++) { |
123 __webpack_require__.d(__webpack_exports__, "store", function() { return /* reexport */ store; }); |
306 arr2[i] = arr[i]; |
124 __webpack_require__.d(__webpack_exports__, "createBlock", function() { return /* reexport */ createBlock; }); |
307 } |
125 __webpack_require__.d(__webpack_exports__, "createBlocksFromInnerBlocksTemplate", function() { return /* reexport */ createBlocksFromInnerBlocksTemplate; }); |
308 |
126 __webpack_require__.d(__webpack_exports__, "cloneBlock", function() { return /* reexport */ cloneBlock; }); |
309 return arr2; |
127 __webpack_require__.d(__webpack_exports__, "__experimentalCloneSanitizedBlock", function() { return /* reexport */ __experimentalCloneSanitizedBlock; }); |
310 } |
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 |
311 |
7228 |
312 /***/ }), |
7229 /***/ }), |
313 |
7230 |
314 /***/ 268: |
7231 /***/ "1CF3": |
315 /***/ (function(module, exports) { |
7232 /***/ (function(module, exports) { |
316 |
7233 |
317 (function() { module.exports = this["wp"]["blockSerializationDefaultParser"]; }()); |
7234 (function() { module.exports = window["wp"]["dom"]; }()); |
318 |
7235 |
319 /***/ }), |
7236 /***/ }), |
320 |
7237 |
321 /***/ 269: |
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": |
322 /***/ (function(module, exports, __webpack_require__) { |
7354 /***/ (function(module, exports, __webpack_require__) { |
323 |
7355 |
324 var __WEBPACK_AMD_DEFINE_RESULT__;;/*! showdown v 1.9.1 - 02-11-2019 */ |
7356 var __WEBPACK_AMD_DEFINE_RESULT__;;/*! showdown v 1.9.1 - 02-11-2019 */ |
325 (function(){ |
7357 (function(){ |
326 /** |
7358 /** |
5458 } else {} |
12490 } else {} |
5459 }).call(this); |
12491 }).call(this); |
5460 |
12492 |
5461 |
12493 |
5462 |
12494 |
|
12495 |
5463 /***/ }), |
12496 /***/ }), |
5464 |
12497 |
5465 /***/ 29: |
12498 /***/ "NMb1": |
5466 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
12499 /***/ (function(module, exports) { |
5467 |
12500 |
5468 "use strict"; |
12501 (function() { module.exports = window["wp"]["deprecated"]; }()); |
5469 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; }); |
|
5470 /* harmony import */ var _arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(26); |
|
5471 |
|
5472 function _unsupportedIterableToArray(o, minLen) { |
|
5473 if (!o) return; |
|
5474 if (typeof o === "string") return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen); |
|
5475 var n = Object.prototype.toString.call(o).slice(8, -1); |
|
5476 if (n === "Object" && o.constructor) n = o.constructor.name; |
|
5477 if (n === "Map" || n === "Set") return Array.from(o); |
|
5478 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen); |
|
5479 } |
|
5480 |
12502 |
5481 /***/ }), |
12503 /***/ }), |
5482 |
12504 |
5483 /***/ 30: |
12505 /***/ "SVSp": |
5484 /***/ (function(module, exports) { |
12506 /***/ (function(module, exports) { |
5485 |
12507 |
5486 (function() { module.exports = this["wp"]["dom"]; }()); |
12508 (function() { module.exports = window["wp"]["shortcode"]; }()); |
5487 |
12509 |
5488 /***/ }), |
12510 /***/ }), |
5489 |
12511 |
5490 /***/ 32: |
12512 /***/ "Tqx9": |
5491 /***/ (function(module, exports) { |
12513 /***/ (function(module, exports) { |
5492 |
12514 |
5493 (function() { module.exports = this["wp"]["hooks"]; }()); |
12515 (function() { module.exports = window["wp"]["primitives"]; }()); |
5494 |
12516 |
5495 /***/ }), |
12517 /***/ }), |
5496 |
12518 |
5497 /***/ 35: |
12519 /***/ "UuzZ": |
5498 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
12520 /***/ (function(module, exports) { |
5499 |
12521 |
5500 "use strict"; |
12522 (function() { module.exports = window["wp"]["autop"]; }()); |
5501 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; }); |
|
5502 function _iterableToArray(iter) { |
|
5503 if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); |
|
5504 } |
|
5505 |
12523 |
5506 /***/ }), |
12524 /***/ }), |
5507 |
12525 |
5508 /***/ 38: |
12526 /***/ "YLtl": |
5509 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
12527 /***/ (function(module, exports) { |
5510 |
12528 |
5511 "use strict"; |
12529 (function() { module.exports = window["lodash"]; }()); |
5512 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; }); |
|
5513 function _arrayWithHoles(arr) { |
|
5514 if (Array.isArray(arr)) return arr; |
|
5515 } |
|
5516 |
12530 |
5517 /***/ }), |
12531 /***/ }), |
5518 |
12532 |
5519 /***/ 39: |
12533 /***/ "Zss7": |
5520 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
5521 |
|
5522 "use strict"; |
|
5523 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; }); |
|
5524 function _nonIterableRest() { |
|
5525 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
|
5526 } |
|
5527 |
|
5528 /***/ }), |
|
5529 |
|
5530 /***/ 4: |
|
5531 /***/ (function(module, exports) { |
|
5532 |
|
5533 (function() { module.exports = this["wp"]["data"]; }()); |
|
5534 |
|
5535 /***/ }), |
|
5536 |
|
5537 /***/ 42: |
|
5538 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
5539 |
|
5540 "use strict"; |
|
5541 |
|
5542 |
|
5543 var LEAF_KEY, hasWeakMap; |
|
5544 |
|
5545 /** |
|
5546 * Arbitrary value used as key for referencing cache object in WeakMap tree. |
|
5547 * |
|
5548 * @type {Object} |
|
5549 */ |
|
5550 LEAF_KEY = {}; |
|
5551 |
|
5552 /** |
|
5553 * Whether environment supports WeakMap. |
|
5554 * |
|
5555 * @type {boolean} |
|
5556 */ |
|
5557 hasWeakMap = typeof WeakMap !== 'undefined'; |
|
5558 |
|
5559 /** |
|
5560 * Returns the first argument as the sole entry in an array. |
|
5561 * |
|
5562 * @param {*} value Value to return. |
|
5563 * |
|
5564 * @return {Array} Value returned as entry in array. |
|
5565 */ |
|
5566 function arrayOf( value ) { |
|
5567 return [ value ]; |
|
5568 } |
|
5569 |
|
5570 /** |
|
5571 * Returns true if the value passed is object-like, or false otherwise. A value |
|
5572 * is object-like if it can support property assignment, e.g. object or array. |
|
5573 * |
|
5574 * @param {*} value Value to test. |
|
5575 * |
|
5576 * @return {boolean} Whether value is object-like. |
|
5577 */ |
|
5578 function isObjectLike( value ) { |
|
5579 return !! value && 'object' === typeof value; |
|
5580 } |
|
5581 |
|
5582 /** |
|
5583 * Creates and returns a new cache object. |
|
5584 * |
|
5585 * @return {Object} Cache object. |
|
5586 */ |
|
5587 function createCache() { |
|
5588 var cache = { |
|
5589 clear: function() { |
|
5590 cache.head = null; |
|
5591 }, |
|
5592 }; |
|
5593 |
|
5594 return cache; |
|
5595 } |
|
5596 |
|
5597 /** |
|
5598 * Returns true if entries within the two arrays are strictly equal by |
|
5599 * reference from a starting index. |
|
5600 * |
|
5601 * @param {Array} a First array. |
|
5602 * @param {Array} b Second array. |
|
5603 * @param {number} fromIndex Index from which to start comparison. |
|
5604 * |
|
5605 * @return {boolean} Whether arrays are shallowly equal. |
|
5606 */ |
|
5607 function isShallowEqual( a, b, fromIndex ) { |
|
5608 var i; |
|
5609 |
|
5610 if ( a.length !== b.length ) { |
|
5611 return false; |
|
5612 } |
|
5613 |
|
5614 for ( i = fromIndex; i < a.length; i++ ) { |
|
5615 if ( a[ i ] !== b[ i ] ) { |
|
5616 return false; |
|
5617 } |
|
5618 } |
|
5619 |
|
5620 return true; |
|
5621 } |
|
5622 |
|
5623 /** |
|
5624 * Returns a memoized selector function. The getDependants function argument is |
|
5625 * called before the memoized selector and is expected to return an immutable |
|
5626 * reference or array of references on which the selector depends for computing |
|
5627 * its own return value. The memoize cache is preserved only as long as those |
|
5628 * dependant references remain the same. If getDependants returns a different |
|
5629 * reference(s), the cache is cleared and the selector value regenerated. |
|
5630 * |
|
5631 * @param {Function} selector Selector function. |
|
5632 * @param {Function} getDependants Dependant getter returning an immutable |
|
5633 * reference or array of reference used in |
|
5634 * cache bust consideration. |
|
5635 * |
|
5636 * @return {Function} Memoized selector. |
|
5637 */ |
|
5638 /* harmony default export */ __webpack_exports__["a"] = (function( selector, getDependants ) { |
|
5639 var rootCache, getCache; |
|
5640 |
|
5641 // Use object source as dependant if getter not provided |
|
5642 if ( ! getDependants ) { |
|
5643 getDependants = arrayOf; |
|
5644 } |
|
5645 |
|
5646 /** |
|
5647 * Returns the root cache. If WeakMap is supported, this is assigned to the |
|
5648 * root WeakMap cache set, otherwise it is a shared instance of the default |
|
5649 * cache object. |
|
5650 * |
|
5651 * @return {(WeakMap|Object)} Root cache object. |
|
5652 */ |
|
5653 function getRootCache() { |
|
5654 return rootCache; |
|
5655 } |
|
5656 |
|
5657 /** |
|
5658 * Returns the cache for a given dependants array. When possible, a WeakMap |
|
5659 * will be used to create a unique cache for each set of dependants. This |
|
5660 * is feasible due to the nature of WeakMap in allowing garbage collection |
|
5661 * to occur on entries where the key object is no longer referenced. Since |
|
5662 * WeakMap requires the key to be an object, this is only possible when the |
|
5663 * dependant is object-like. The root cache is created as a hierarchy where |
|
5664 * each top-level key is the first entry in a dependants set, the value a |
|
5665 * WeakMap where each key is the next dependant, and so on. This continues |
|
5666 * so long as the dependants are object-like. If no dependants are object- |
|
5667 * like, then the cache is shared across all invocations. |
|
5668 * |
|
5669 * @see isObjectLike |
|
5670 * |
|
5671 * @param {Array} dependants Selector dependants. |
|
5672 * |
|
5673 * @return {Object} Cache object. |
|
5674 */ |
|
5675 function getWeakMapCache( dependants ) { |
|
5676 var caches = rootCache, |
|
5677 isUniqueByDependants = true, |
|
5678 i, dependant, map, cache; |
|
5679 |
|
5680 for ( i = 0; i < dependants.length; i++ ) { |
|
5681 dependant = dependants[ i ]; |
|
5682 |
|
5683 // Can only compose WeakMap from object-like key. |
|
5684 if ( ! isObjectLike( dependant ) ) { |
|
5685 isUniqueByDependants = false; |
|
5686 break; |
|
5687 } |
|
5688 |
|
5689 // Does current segment of cache already have a WeakMap? |
|
5690 if ( caches.has( dependant ) ) { |
|
5691 // Traverse into nested WeakMap. |
|
5692 caches = caches.get( dependant ); |
|
5693 } else { |
|
5694 // Create, set, and traverse into a new one. |
|
5695 map = new WeakMap(); |
|
5696 caches.set( dependant, map ); |
|
5697 caches = map; |
|
5698 } |
|
5699 } |
|
5700 |
|
5701 // We use an arbitrary (but consistent) object as key for the last item |
|
5702 // in the WeakMap to serve as our running cache. |
|
5703 if ( ! caches.has( LEAF_KEY ) ) { |
|
5704 cache = createCache(); |
|
5705 cache.isUniqueByDependants = isUniqueByDependants; |
|
5706 caches.set( LEAF_KEY, cache ); |
|
5707 } |
|
5708 |
|
5709 return caches.get( LEAF_KEY ); |
|
5710 } |
|
5711 |
|
5712 // Assign cache handler by availability of WeakMap |
|
5713 getCache = hasWeakMap ? getWeakMapCache : getRootCache; |
|
5714 |
|
5715 /** |
|
5716 * Resets root memoization cache. |
|
5717 */ |
|
5718 function clear() { |
|
5719 rootCache = hasWeakMap ? new WeakMap() : createCache(); |
|
5720 } |
|
5721 |
|
5722 // eslint-disable-next-line jsdoc/check-param-names |
|
5723 /** |
|
5724 * The augmented selector call, considering first whether dependants have |
|
5725 * changed before passing it to underlying memoize function. |
|
5726 * |
|
5727 * @param {Object} source Source object for derivation. |
|
5728 * @param {...*} extraArgs Additional arguments to pass to selector. |
|
5729 * |
|
5730 * @return {*} Selector result. |
|
5731 */ |
|
5732 function callSelector( /* source, ...extraArgs */ ) { |
|
5733 var len = arguments.length, |
|
5734 cache, node, i, args, dependants; |
|
5735 |
|
5736 // Create copy of arguments (avoid leaking deoptimization). |
|
5737 args = new Array( len ); |
|
5738 for ( i = 0; i < len; i++ ) { |
|
5739 args[ i ] = arguments[ i ]; |
|
5740 } |
|
5741 |
|
5742 dependants = getDependants.apply( null, args ); |
|
5743 cache = getCache( dependants ); |
|
5744 |
|
5745 // If not guaranteed uniqueness by dependants (primitive type or lack |
|
5746 // of WeakMap support), shallow compare against last dependants and, if |
|
5747 // references have changed, destroy cache to recalculate result. |
|
5748 if ( ! cache.isUniqueByDependants ) { |
|
5749 if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) { |
|
5750 cache.clear(); |
|
5751 } |
|
5752 |
|
5753 cache.lastDependants = dependants; |
|
5754 } |
|
5755 |
|
5756 node = cache.head; |
|
5757 while ( node ) { |
|
5758 // Check whether node arguments match arguments |
|
5759 if ( ! isShallowEqual( node.args, args, 1 ) ) { |
|
5760 node = node.next; |
|
5761 continue; |
|
5762 } |
|
5763 |
|
5764 // At this point we can assume we've found a match |
|
5765 |
|
5766 // Surface matched node to head if not already |
|
5767 if ( node !== cache.head ) { |
|
5768 // Adjust siblings to point to each other. |
|
5769 node.prev.next = node.next; |
|
5770 if ( node.next ) { |
|
5771 node.next.prev = node.prev; |
|
5772 } |
|
5773 |
|
5774 node.next = cache.head; |
|
5775 node.prev = null; |
|
5776 cache.head.prev = node; |
|
5777 cache.head = node; |
|
5778 } |
|
5779 |
|
5780 // Return immediately |
|
5781 return node.val; |
|
5782 } |
|
5783 |
|
5784 // No cached value found. Continue to insertion phase: |
|
5785 |
|
5786 node = { |
|
5787 // Generate the result from original function |
|
5788 val: selector.apply( null, args ), |
|
5789 }; |
|
5790 |
|
5791 // Avoid including the source object in the cache. |
|
5792 args[ 0 ] = null; |
|
5793 node.args = args; |
|
5794 |
|
5795 // Don't need to check whether node is already head, since it would |
|
5796 // have been returned above already if it was |
|
5797 |
|
5798 // Shift existing head down list |
|
5799 if ( cache.head ) { |
|
5800 cache.head.prev = node; |
|
5801 node.next = cache.head; |
|
5802 } |
|
5803 |
|
5804 cache.head = node; |
|
5805 |
|
5806 return node.val; |
|
5807 } |
|
5808 |
|
5809 callSelector.getDependants = getDependants; |
|
5810 callSelector.clear = clear; |
|
5811 clear(); |
|
5812 |
|
5813 return callSelector; |
|
5814 }); |
|
5815 |
|
5816 |
|
5817 /***/ }), |
|
5818 |
|
5819 /***/ 44: |
|
5820 /***/ (function(module, exports) { |
|
5821 |
|
5822 (function() { module.exports = this["wp"]["blob"]; }()); |
|
5823 |
|
5824 /***/ }), |
|
5825 |
|
5826 /***/ 441: |
|
5827 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
5828 |
|
5829 "use strict"; |
|
5830 // ESM COMPAT FLAG |
|
5831 __webpack_require__.r(__webpack_exports__); |
|
5832 |
|
5833 // EXPORTS |
|
5834 __webpack_require__.d(__webpack_exports__, "createBlock", function() { return /* reexport */ createBlock; }); |
|
5835 __webpack_require__.d(__webpack_exports__, "cloneBlock", function() { return /* reexport */ cloneBlock; }); |
|
5836 __webpack_require__.d(__webpack_exports__, "getPossibleBlockTransformations", function() { return /* reexport */ getPossibleBlockTransformations; }); |
|
5837 __webpack_require__.d(__webpack_exports__, "switchToBlockType", function() { return /* reexport */ switchToBlockType; }); |
|
5838 __webpack_require__.d(__webpack_exports__, "getBlockTransforms", function() { return /* reexport */ getBlockTransforms; }); |
|
5839 __webpack_require__.d(__webpack_exports__, "findTransform", function() { return /* reexport */ findTransform; }); |
|
5840 __webpack_require__.d(__webpack_exports__, "getBlockFromExample", function() { return /* reexport */ factory_getBlockFromExample; }); |
|
5841 __webpack_require__.d(__webpack_exports__, "parse", function() { return /* reexport */ parser; }); |
|
5842 __webpack_require__.d(__webpack_exports__, "getBlockAttributes", function() { return /* reexport */ getBlockAttributes; }); |
|
5843 __webpack_require__.d(__webpack_exports__, "parseWithAttributeSchema", function() { return /* reexport */ parseWithAttributeSchema; }); |
|
5844 __webpack_require__.d(__webpack_exports__, "pasteHandler", function() { return /* reexport */ pasteHandler; }); |
|
5845 __webpack_require__.d(__webpack_exports__, "rawHandler", function() { return /* reexport */ rawHandler; }); |
|
5846 __webpack_require__.d(__webpack_exports__, "getPhrasingContentSchema", function() { return /* reexport */ getPhrasingContentSchema; }); |
|
5847 __webpack_require__.d(__webpack_exports__, "serialize", function() { return /* reexport */ serialize; }); |
|
5848 __webpack_require__.d(__webpack_exports__, "getBlockContent", function() { return /* reexport */ getBlockContent; }); |
|
5849 __webpack_require__.d(__webpack_exports__, "getBlockDefaultClassName", function() { return /* reexport */ getBlockDefaultClassName; }); |
|
5850 __webpack_require__.d(__webpack_exports__, "getBlockMenuDefaultClassName", function() { return /* reexport */ getBlockMenuDefaultClassName; }); |
|
5851 __webpack_require__.d(__webpack_exports__, "getSaveElement", function() { return /* reexport */ getSaveElement; }); |
|
5852 __webpack_require__.d(__webpack_exports__, "getSaveContent", function() { return /* reexport */ getSaveContent; }); |
|
5853 __webpack_require__.d(__webpack_exports__, "isValidBlockContent", function() { return /* reexport */ isValidBlockContent; }); |
|
5854 __webpack_require__.d(__webpack_exports__, "getCategories", function() { return /* reexport */ categories_getCategories; }); |
|
5855 __webpack_require__.d(__webpack_exports__, "setCategories", function() { return /* reexport */ categories_setCategories; }); |
|
5856 __webpack_require__.d(__webpack_exports__, "updateCategory", function() { return /* reexport */ categories_updateCategory; }); |
|
5857 __webpack_require__.d(__webpack_exports__, "registerBlockType", function() { return /* reexport */ registerBlockType; }); |
|
5858 __webpack_require__.d(__webpack_exports__, "registerBlockCollection", function() { return /* reexport */ registerBlockCollection; }); |
|
5859 __webpack_require__.d(__webpack_exports__, "unregisterBlockType", function() { return /* reexport */ unregisterBlockType; }); |
|
5860 __webpack_require__.d(__webpack_exports__, "setFreeformContentHandlerName", function() { return /* reexport */ setFreeformContentHandlerName; }); |
|
5861 __webpack_require__.d(__webpack_exports__, "getFreeformContentHandlerName", function() { return /* reexport */ getFreeformContentHandlerName; }); |
|
5862 __webpack_require__.d(__webpack_exports__, "setUnregisteredTypeHandlerName", function() { return /* reexport */ setUnregisteredTypeHandlerName; }); |
|
5863 __webpack_require__.d(__webpack_exports__, "getUnregisteredTypeHandlerName", function() { return /* reexport */ getUnregisteredTypeHandlerName; }); |
|
5864 __webpack_require__.d(__webpack_exports__, "setDefaultBlockName", function() { return /* reexport */ registration_setDefaultBlockName; }); |
|
5865 __webpack_require__.d(__webpack_exports__, "getDefaultBlockName", function() { return /* reexport */ registration_getDefaultBlockName; }); |
|
5866 __webpack_require__.d(__webpack_exports__, "setGroupingBlockName", function() { return /* reexport */ registration_setGroupingBlockName; }); |
|
5867 __webpack_require__.d(__webpack_exports__, "getGroupingBlockName", function() { return /* reexport */ registration_getGroupingBlockName; }); |
|
5868 __webpack_require__.d(__webpack_exports__, "getBlockType", function() { return /* reexport */ registration_getBlockType; }); |
|
5869 __webpack_require__.d(__webpack_exports__, "getBlockTypes", function() { return /* reexport */ registration_getBlockTypes; }); |
|
5870 __webpack_require__.d(__webpack_exports__, "getBlockSupport", function() { return /* reexport */ registration_getBlockSupport; }); |
|
5871 __webpack_require__.d(__webpack_exports__, "hasBlockSupport", function() { return /* reexport */ registration_hasBlockSupport; }); |
|
5872 __webpack_require__.d(__webpack_exports__, "isReusableBlock", function() { return /* reexport */ isReusableBlock; }); |
|
5873 __webpack_require__.d(__webpack_exports__, "getChildBlockNames", function() { return /* reexport */ registration_getChildBlockNames; }); |
|
5874 __webpack_require__.d(__webpack_exports__, "hasChildBlocks", function() { return /* reexport */ registration_hasChildBlocks; }); |
|
5875 __webpack_require__.d(__webpack_exports__, "hasChildBlocksWithInserterSupport", function() { return /* reexport */ registration_hasChildBlocksWithInserterSupport; }); |
|
5876 __webpack_require__.d(__webpack_exports__, "unstable__bootstrapServerSideBlockDefinitions", function() { return /* reexport */ unstable__bootstrapServerSideBlockDefinitions; }); |
|
5877 __webpack_require__.d(__webpack_exports__, "registerBlockStyle", function() { return /* reexport */ registration_registerBlockStyle; }); |
|
5878 __webpack_require__.d(__webpack_exports__, "unregisterBlockStyle", function() { return /* reexport */ registration_unregisterBlockStyle; }); |
|
5879 __webpack_require__.d(__webpack_exports__, "registerBlockVariation", function() { return /* reexport */ registration_registerBlockVariation; }); |
|
5880 __webpack_require__.d(__webpack_exports__, "unregisterBlockVariation", function() { return /* reexport */ registration_unregisterBlockVariation; }); |
|
5881 __webpack_require__.d(__webpack_exports__, "isUnmodifiedDefaultBlock", function() { return /* reexport */ isUnmodifiedDefaultBlock; }); |
|
5882 __webpack_require__.d(__webpack_exports__, "normalizeIconObject", function() { return /* reexport */ normalizeIconObject; }); |
|
5883 __webpack_require__.d(__webpack_exports__, "isValidIcon", function() { return /* reexport */ isValidIcon; }); |
|
5884 __webpack_require__.d(__webpack_exports__, "__experimentalGetBlockLabel", function() { return /* reexport */ getBlockLabel; }); |
|
5885 __webpack_require__.d(__webpack_exports__, "__experimentalGetAccessibleBlockLabel", function() { return /* reexport */ getAccessibleBlockLabel; }); |
|
5886 __webpack_require__.d(__webpack_exports__, "doBlocksMatchTemplate", function() { return /* reexport */ doBlocksMatchTemplate; }); |
|
5887 __webpack_require__.d(__webpack_exports__, "synchronizeBlocksWithTemplate", function() { return /* reexport */ synchronizeBlocksWithTemplate; }); |
|
5888 __webpack_require__.d(__webpack_exports__, "children", function() { return /* reexport */ api_children; }); |
|
5889 __webpack_require__.d(__webpack_exports__, "node", function() { return /* reexport */ api_node; }); |
|
5890 __webpack_require__.d(__webpack_exports__, "withBlockContentContext", function() { return /* reexport */ withBlockContentContext; }); |
|
5891 |
|
5892 // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/selectors.js |
|
5893 var selectors_namespaceObject = {}; |
|
5894 __webpack_require__.r(selectors_namespaceObject); |
|
5895 __webpack_require__.d(selectors_namespaceObject, "getBlockTypes", function() { return getBlockTypes; }); |
|
5896 __webpack_require__.d(selectors_namespaceObject, "getBlockType", function() { return getBlockType; }); |
|
5897 __webpack_require__.d(selectors_namespaceObject, "getBlockStyles", function() { return getBlockStyles; }); |
|
5898 __webpack_require__.d(selectors_namespaceObject, "getBlockVariations", function() { return getBlockVariations; }); |
|
5899 __webpack_require__.d(selectors_namespaceObject, "getDefaultBlockVariation", function() { return getDefaultBlockVariation; }); |
|
5900 __webpack_require__.d(selectors_namespaceObject, "getCategories", function() { return getCategories; }); |
|
5901 __webpack_require__.d(selectors_namespaceObject, "getCollections", function() { return getCollections; }); |
|
5902 __webpack_require__.d(selectors_namespaceObject, "getDefaultBlockName", function() { return getDefaultBlockName; }); |
|
5903 __webpack_require__.d(selectors_namespaceObject, "getFreeformFallbackBlockName", function() { return getFreeformFallbackBlockName; }); |
|
5904 __webpack_require__.d(selectors_namespaceObject, "getUnregisteredFallbackBlockName", function() { return getUnregisteredFallbackBlockName; }); |
|
5905 __webpack_require__.d(selectors_namespaceObject, "getGroupingBlockName", function() { return getGroupingBlockName; }); |
|
5906 __webpack_require__.d(selectors_namespaceObject, "getChildBlockNames", function() { return selectors_getChildBlockNames; }); |
|
5907 __webpack_require__.d(selectors_namespaceObject, "getBlockSupport", function() { return selectors_getBlockSupport; }); |
|
5908 __webpack_require__.d(selectors_namespaceObject, "hasBlockSupport", function() { return hasBlockSupport; }); |
|
5909 __webpack_require__.d(selectors_namespaceObject, "isMatchingSearchTerm", function() { return isMatchingSearchTerm; }); |
|
5910 __webpack_require__.d(selectors_namespaceObject, "hasChildBlocks", function() { return selectors_hasChildBlocks; }); |
|
5911 __webpack_require__.d(selectors_namespaceObject, "hasChildBlocksWithInserterSupport", function() { return selectors_hasChildBlocksWithInserterSupport; }); |
|
5912 |
|
5913 // NAMESPACE OBJECT: ./node_modules/@wordpress/blocks/build-module/store/actions.js |
|
5914 var actions_namespaceObject = {}; |
|
5915 __webpack_require__.r(actions_namespaceObject); |
|
5916 __webpack_require__.d(actions_namespaceObject, "addBlockTypes", function() { return addBlockTypes; }); |
|
5917 __webpack_require__.d(actions_namespaceObject, "removeBlockTypes", function() { return removeBlockTypes; }); |
|
5918 __webpack_require__.d(actions_namespaceObject, "addBlockStyles", function() { return addBlockStyles; }); |
|
5919 __webpack_require__.d(actions_namespaceObject, "removeBlockStyles", function() { return removeBlockStyles; }); |
|
5920 __webpack_require__.d(actions_namespaceObject, "addBlockVariations", function() { return addBlockVariations; }); |
|
5921 __webpack_require__.d(actions_namespaceObject, "removeBlockVariations", function() { return removeBlockVariations; }); |
|
5922 __webpack_require__.d(actions_namespaceObject, "setDefaultBlockName", function() { return setDefaultBlockName; }); |
|
5923 __webpack_require__.d(actions_namespaceObject, "setFreeformFallbackBlockName", function() { return setFreeformFallbackBlockName; }); |
|
5924 __webpack_require__.d(actions_namespaceObject, "setUnregisteredFallbackBlockName", function() { return setUnregisteredFallbackBlockName; }); |
|
5925 __webpack_require__.d(actions_namespaceObject, "setGroupingBlockName", function() { return setGroupingBlockName; }); |
|
5926 __webpack_require__.d(actions_namespaceObject, "setCategories", function() { return setCategories; }); |
|
5927 __webpack_require__.d(actions_namespaceObject, "updateCategory", function() { return updateCategory; }); |
|
5928 __webpack_require__.d(actions_namespaceObject, "addBlockCollection", function() { return addBlockCollection; }); |
|
5929 __webpack_require__.d(actions_namespaceObject, "removeBlockCollection", function() { return removeBlockCollection; }); |
|
5930 |
|
5931 // EXTERNAL MODULE: external {"this":["wp","data"]} |
|
5932 var external_this_wp_data_ = __webpack_require__(4); |
|
5933 |
|
5934 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules |
|
5935 var toConsumableArray = __webpack_require__(18); |
|
5936 |
|
5937 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js |
|
5938 var defineProperty = __webpack_require__(5); |
|
5939 |
|
5940 // EXTERNAL MODULE: external {"this":"lodash"} |
|
5941 var external_this_lodash_ = __webpack_require__(2); |
|
5942 |
|
5943 // EXTERNAL MODULE: external {"this":["wp","i18n"]} |
|
5944 var external_this_wp_i18n_ = __webpack_require__(1); |
|
5945 |
|
5946 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/reducer.js |
|
5947 |
|
5948 |
|
5949 |
|
5950 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
5951 |
|
5952 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
5953 |
|
5954 /** |
|
5955 * External dependencies |
|
5956 */ |
|
5957 |
|
5958 /** |
|
5959 * WordPress dependencies |
|
5960 */ |
|
5961 |
|
5962 |
|
5963 |
|
5964 /** |
|
5965 * @typedef {Object} WPBlockCategory |
|
5966 * |
|
5967 * @property {string} slug Unique category slug. |
|
5968 * @property {string} title Category label, for display in user interface. |
|
5969 */ |
|
5970 |
|
5971 /** |
|
5972 * Default set of categories. |
|
5973 * |
|
5974 * @type {WPBlockCategory[]} |
|
5975 */ |
|
5976 |
|
5977 var DEFAULT_CATEGORIES = [{ |
|
5978 slug: 'text', |
|
5979 title: Object(external_this_wp_i18n_["__"])('Text') |
|
5980 }, { |
|
5981 slug: 'media', |
|
5982 title: Object(external_this_wp_i18n_["__"])('Media') |
|
5983 }, { |
|
5984 slug: 'design', |
|
5985 title: Object(external_this_wp_i18n_["__"])('Design') |
|
5986 }, { |
|
5987 slug: 'widgets', |
|
5988 title: Object(external_this_wp_i18n_["__"])('Widgets') |
|
5989 }, { |
|
5990 slug: 'embed', |
|
5991 title: Object(external_this_wp_i18n_["__"])('Embeds') |
|
5992 }, { |
|
5993 slug: 'reusable', |
|
5994 title: Object(external_this_wp_i18n_["__"])('Reusable blocks') |
|
5995 }]; |
|
5996 /** |
|
5997 * Reducer managing the block types |
|
5998 * |
|
5999 * @param {Object} state Current state. |
|
6000 * @param {Object} action Dispatched action. |
|
6001 * |
|
6002 * @return {Object} Updated state. |
|
6003 */ |
|
6004 |
|
6005 function reducer_blockTypes() { |
|
6006 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
6007 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
6008 |
|
6009 switch (action.type) { |
|
6010 case 'ADD_BLOCK_TYPES': |
|
6011 return _objectSpread({}, state, {}, Object(external_this_lodash_["keyBy"])(Object(external_this_lodash_["map"])(action.blockTypes, function (blockType) { |
|
6012 return Object(external_this_lodash_["omit"])(blockType, 'styles '); |
|
6013 }), 'name')); |
|
6014 |
|
6015 case 'REMOVE_BLOCK_TYPES': |
|
6016 return Object(external_this_lodash_["omit"])(state, action.names); |
|
6017 } |
|
6018 |
|
6019 return state; |
|
6020 } |
|
6021 /** |
|
6022 * Reducer managing the block style variations. |
|
6023 * |
|
6024 * @param {Object} state Current state. |
|
6025 * @param {Object} action Dispatched action. |
|
6026 * |
|
6027 * @return {Object} Updated state. |
|
6028 */ |
|
6029 |
|
6030 function blockStyles() { |
|
6031 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
6032 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
6033 |
|
6034 switch (action.type) { |
|
6035 case 'ADD_BLOCK_TYPES': |
|
6036 return _objectSpread({}, state, {}, Object(external_this_lodash_["mapValues"])(Object(external_this_lodash_["keyBy"])(action.blockTypes, 'name'), function (blockType) { |
|
6037 return Object(external_this_lodash_["uniqBy"])([].concat(Object(toConsumableArray["a" /* default */])(Object(external_this_lodash_["get"])(blockType, ['styles'], [])), Object(toConsumableArray["a" /* default */])(Object(external_this_lodash_["get"])(state, [blockType.name], []))), function (style) { |
|
6038 return style.name; |
|
6039 }); |
|
6040 })); |
|
6041 |
|
6042 case 'ADD_BLOCK_STYLES': |
|
6043 return _objectSpread({}, state, Object(defineProperty["a" /* default */])({}, action.blockName, Object(external_this_lodash_["uniqBy"])([].concat(Object(toConsumableArray["a" /* default */])(Object(external_this_lodash_["get"])(state, [action.blockName], [])), Object(toConsumableArray["a" /* default */])(action.styles)), function (style) { |
|
6044 return style.name; |
|
6045 }))); |
|
6046 |
|
6047 case 'REMOVE_BLOCK_STYLES': |
|
6048 return _objectSpread({}, state, Object(defineProperty["a" /* default */])({}, action.blockName, Object(external_this_lodash_["filter"])(Object(external_this_lodash_["get"])(state, [action.blockName], []), function (style) { |
|
6049 return action.styleNames.indexOf(style.name) === -1; |
|
6050 }))); |
|
6051 } |
|
6052 |
|
6053 return state; |
|
6054 } |
|
6055 /** |
|
6056 * Reducer managing the block variations. |
|
6057 * |
|
6058 * @param {Object} state Current state. |
|
6059 * @param {Object} action Dispatched action. |
|
6060 * |
|
6061 * @return {Object} Updated state. |
|
6062 */ |
|
6063 |
|
6064 function blockVariations() { |
|
6065 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
6066 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
6067 |
|
6068 switch (action.type) { |
|
6069 case 'ADD_BLOCK_TYPES': |
|
6070 return _objectSpread({}, state, {}, Object(external_this_lodash_["mapValues"])(Object(external_this_lodash_["keyBy"])(action.blockTypes, 'name'), function (blockType) { |
|
6071 return Object(external_this_lodash_["uniqBy"])([].concat(Object(toConsumableArray["a" /* default */])(Object(external_this_lodash_["get"])(blockType, ['variations'], [])), Object(toConsumableArray["a" /* default */])(Object(external_this_lodash_["get"])(state, [blockType.name], []))), function (variation) { |
|
6072 return variation.name; |
|
6073 }); |
|
6074 })); |
|
6075 |
|
6076 case 'ADD_BLOCK_VARIATIONS': |
|
6077 return _objectSpread({}, state, Object(defineProperty["a" /* default */])({}, action.blockName, Object(external_this_lodash_["uniqBy"])([].concat(Object(toConsumableArray["a" /* default */])(Object(external_this_lodash_["get"])(state, [action.blockName], [])), Object(toConsumableArray["a" /* default */])(action.variations)), function (variation) { |
|
6078 return variation.name; |
|
6079 }))); |
|
6080 |
|
6081 case 'REMOVE_BLOCK_VARIATIONS': |
|
6082 return _objectSpread({}, state, Object(defineProperty["a" /* default */])({}, action.blockName, Object(external_this_lodash_["filter"])(Object(external_this_lodash_["get"])(state, [action.blockName], []), function (variation) { |
|
6083 return action.variationNames.indexOf(variation.name) === -1; |
|
6084 }))); |
|
6085 } |
|
6086 |
|
6087 return state; |
|
6088 } |
|
6089 /** |
|
6090 * Higher-order Reducer creating a reducer keeping track of given block name. |
|
6091 * |
|
6092 * @param {string} setActionType Action type. |
|
6093 * |
|
6094 * @return {Function} Reducer. |
|
6095 */ |
|
6096 |
|
6097 function createBlockNameSetterReducer(setActionType) { |
|
6098 return function () { |
|
6099 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; |
|
6100 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
6101 |
|
6102 switch (action.type) { |
|
6103 case 'REMOVE_BLOCK_TYPES': |
|
6104 if (action.names.indexOf(state) !== -1) { |
|
6105 return null; |
|
6106 } |
|
6107 |
|
6108 return state; |
|
6109 |
|
6110 case setActionType: |
|
6111 return action.name || null; |
|
6112 } |
|
6113 |
|
6114 return state; |
|
6115 }; |
|
6116 } |
|
6117 var reducer_defaultBlockName = createBlockNameSetterReducer('SET_DEFAULT_BLOCK_NAME'); |
|
6118 var freeformFallbackBlockName = createBlockNameSetterReducer('SET_FREEFORM_FALLBACK_BLOCK_NAME'); |
|
6119 var unregisteredFallbackBlockName = createBlockNameSetterReducer('SET_UNREGISTERED_FALLBACK_BLOCK_NAME'); |
|
6120 var groupingBlockName = createBlockNameSetterReducer('SET_GROUPING_BLOCK_NAME'); |
|
6121 /** |
|
6122 * Reducer managing the categories |
|
6123 * |
|
6124 * @param {WPBlockCategory[]} state Current state. |
|
6125 * @param {Object} action Dispatched action. |
|
6126 * |
|
6127 * @return {WPBlockCategory[]} Updated state. |
|
6128 */ |
|
6129 |
|
6130 function reducer_categories() { |
|
6131 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_CATEGORIES; |
|
6132 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
6133 |
|
6134 switch (action.type) { |
|
6135 case 'SET_CATEGORIES': |
|
6136 return action.categories || []; |
|
6137 |
|
6138 case 'UPDATE_CATEGORY': |
|
6139 { |
|
6140 if (!action.category || Object(external_this_lodash_["isEmpty"])(action.category)) { |
|
6141 return state; |
|
6142 } |
|
6143 |
|
6144 var categoryToChange = Object(external_this_lodash_["find"])(state, ['slug', action.slug]); |
|
6145 |
|
6146 if (categoryToChange) { |
|
6147 return Object(external_this_lodash_["map"])(state, function (category) { |
|
6148 if (category.slug === action.slug) { |
|
6149 return _objectSpread({}, category, {}, action.category); |
|
6150 } |
|
6151 |
|
6152 return category; |
|
6153 }); |
|
6154 } |
|
6155 } |
|
6156 } |
|
6157 |
|
6158 return state; |
|
6159 } |
|
6160 function collections() { |
|
6161 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
6162 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
6163 |
|
6164 switch (action.type) { |
|
6165 case 'ADD_BLOCK_COLLECTION': |
|
6166 return _objectSpread({}, state, Object(defineProperty["a" /* default */])({}, action.namespace, { |
|
6167 title: action.title, |
|
6168 icon: action.icon |
|
6169 })); |
|
6170 |
|
6171 case 'REMOVE_BLOCK_COLLECTION': |
|
6172 return Object(external_this_lodash_["omit"])(state, action.namespace); |
|
6173 } |
|
6174 |
|
6175 return state; |
|
6176 } |
|
6177 /* harmony default export */ var reducer = (Object(external_this_wp_data_["combineReducers"])({ |
|
6178 blockTypes: reducer_blockTypes, |
|
6179 blockStyles: blockStyles, |
|
6180 blockVariations: blockVariations, |
|
6181 defaultBlockName: reducer_defaultBlockName, |
|
6182 freeformFallbackBlockName: freeformFallbackBlockName, |
|
6183 unregisteredFallbackBlockName: unregisteredFallbackBlockName, |
|
6184 groupingBlockName: groupingBlockName, |
|
6185 categories: reducer_categories, |
|
6186 collections: collections |
|
6187 })); |
|
6188 |
|
6189 // EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js |
|
6190 var rememo = __webpack_require__(42); |
|
6191 |
|
6192 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/selectors.js |
|
6193 |
|
6194 |
|
6195 |
|
6196 function selectors_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
6197 |
|
6198 function selectors_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { selectors_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { selectors_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
6199 |
|
6200 /** |
|
6201 * External dependencies |
|
6202 */ |
|
6203 |
|
6204 |
|
6205 /** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */ |
|
6206 |
|
6207 /** @typedef {import('../api/registration').WPBlockVariationScope} WPBlockVariationScope */ |
|
6208 |
|
6209 /** @typedef {import('./reducer').WPBlockCategory} WPBlockCategory */ |
|
6210 |
|
6211 /** |
|
6212 * Given a block name or block type object, returns the corresponding |
|
6213 * normalized block type object. |
|
6214 * |
|
6215 * @param {Object} state Blocks state. |
|
6216 * @param {(string|Object)} nameOrType Block name or type object |
|
6217 * |
|
6218 * @return {Object} Block type object. |
|
6219 */ |
|
6220 |
|
6221 var getNormalizedBlockType = function getNormalizedBlockType(state, nameOrType) { |
|
6222 return 'string' === typeof nameOrType ? getBlockType(state, nameOrType) : nameOrType; |
|
6223 }; |
|
6224 /** |
|
6225 * Returns all the available block types. |
|
6226 * |
|
6227 * @param {Object} state Data state. |
|
6228 * |
|
6229 * @return {Array} Block Types. |
|
6230 */ |
|
6231 |
|
6232 |
|
6233 var getBlockTypes = Object(rememo["a" /* default */])(function (state) { |
|
6234 return Object.values(state.blockTypes).map(function (blockType) { |
|
6235 return selectors_objectSpread({}, blockType, { |
|
6236 variations: getBlockVariations(state, blockType.name) |
|
6237 }); |
|
6238 }); |
|
6239 }, function (state) { |
|
6240 return [state.blockTypes, state.blockVariations]; |
|
6241 }); |
|
6242 /** |
|
6243 * Returns a block type by name. |
|
6244 * |
|
6245 * @param {Object} state Data state. |
|
6246 * @param {string} name Block type name. |
|
6247 * |
|
6248 * @return {Object?} Block Type. |
|
6249 */ |
|
6250 |
|
6251 function getBlockType(state, name) { |
|
6252 return state.blockTypes[name]; |
|
6253 } |
|
6254 /** |
|
6255 * Returns block styles by block name. |
|
6256 * |
|
6257 * @param {Object} state Data state. |
|
6258 * @param {string} name Block type name. |
|
6259 * |
|
6260 * @return {Array?} Block Styles. |
|
6261 */ |
|
6262 |
|
6263 function getBlockStyles(state, name) { |
|
6264 return state.blockStyles[name]; |
|
6265 } |
|
6266 /** |
|
6267 * Returns block variations by block name. |
|
6268 * |
|
6269 * @param {Object} state Data state. |
|
6270 * @param {string} blockName Block type name. |
|
6271 * @param {WPBlockVariationScope} [scope] Block variation scope name. |
|
6272 * |
|
6273 * @return {(WPBlockVariation[]|void)} Block variations. |
|
6274 */ |
|
6275 |
|
6276 function getBlockVariations(state, blockName, scope) { |
|
6277 var variations = state.blockVariations[blockName]; |
|
6278 |
|
6279 if (!variations || !scope) { |
|
6280 return variations; |
|
6281 } |
|
6282 |
|
6283 return variations.filter(function (variation) { |
|
6284 return !variation.scope || variation.scope.includes(scope); |
|
6285 }); |
|
6286 } |
|
6287 /** |
|
6288 * Returns the default block variation for the given block type. |
|
6289 * When there are multiple variations annotated as the default one, |
|
6290 * the last added item is picked. This simplifies registering overrides. |
|
6291 * When there is no default variation set, it returns the first item. |
|
6292 * |
|
6293 * @param {Object} state Data state. |
|
6294 * @param {string} blockName Block type name. |
|
6295 * @param {WPBlockVariationScope} [scope] Block variation scope name. |
|
6296 * |
|
6297 * @return {?WPBlockVariation} The default block variation. |
|
6298 */ |
|
6299 |
|
6300 function getDefaultBlockVariation(state, blockName, scope) { |
|
6301 var variations = getBlockVariations(state, blockName, scope); |
|
6302 return Object(external_this_lodash_["findLast"])(variations, 'isDefault') || Object(external_this_lodash_["first"])(variations); |
|
6303 } |
|
6304 /** |
|
6305 * Returns all the available categories. |
|
6306 * |
|
6307 * @param {Object} state Data state. |
|
6308 * |
|
6309 * @return {WPBlockCategory[]} Categories list. |
|
6310 */ |
|
6311 |
|
6312 function getCategories(state) { |
|
6313 return state.categories; |
|
6314 } |
|
6315 /** |
|
6316 * Returns all the available collections. |
|
6317 * |
|
6318 * @param {Object} state Data state. |
|
6319 * |
|
6320 * @return {Object} Collections list. |
|
6321 */ |
|
6322 |
|
6323 function getCollections(state) { |
|
6324 return state.collections; |
|
6325 } |
|
6326 /** |
|
6327 * Returns the name of the default block name. |
|
6328 * |
|
6329 * @param {Object} state Data state. |
|
6330 * |
|
6331 * @return {string?} Default block name. |
|
6332 */ |
|
6333 |
|
6334 function getDefaultBlockName(state) { |
|
6335 return state.defaultBlockName; |
|
6336 } |
|
6337 /** |
|
6338 * Returns the name of the block for handling non-block content. |
|
6339 * |
|
6340 * @param {Object} state Data state. |
|
6341 * |
|
6342 * @return {string?} Name of the block for handling non-block content. |
|
6343 */ |
|
6344 |
|
6345 function getFreeformFallbackBlockName(state) { |
|
6346 return state.freeformFallbackBlockName; |
|
6347 } |
|
6348 /** |
|
6349 * Returns the name of the block for handling unregistered blocks. |
|
6350 * |
|
6351 * @param {Object} state Data state. |
|
6352 * |
|
6353 * @return {string?} Name of the block for handling unregistered blocks. |
|
6354 */ |
|
6355 |
|
6356 function getUnregisteredFallbackBlockName(state) { |
|
6357 return state.unregisteredFallbackBlockName; |
|
6358 } |
|
6359 /** |
|
6360 * Returns the name of the block for handling unregistered blocks. |
|
6361 * |
|
6362 * @param {Object} state Data state. |
|
6363 * |
|
6364 * @return {string?} Name of the block for handling unregistered blocks. |
|
6365 */ |
|
6366 |
|
6367 function getGroupingBlockName(state) { |
|
6368 return state.groupingBlockName; |
|
6369 } |
|
6370 /** |
|
6371 * Returns an array with the child blocks of a given block. |
|
6372 * |
|
6373 * @param {Object} state Data state. |
|
6374 * @param {string} blockName Block type name. |
|
6375 * |
|
6376 * @return {Array} Array of child block names. |
|
6377 */ |
|
6378 |
|
6379 var selectors_getChildBlockNames = Object(rememo["a" /* default */])(function (state, blockName) { |
|
6380 return Object(external_this_lodash_["map"])(Object(external_this_lodash_["filter"])(state.blockTypes, function (blockType) { |
|
6381 return Object(external_this_lodash_["includes"])(blockType.parent, blockName); |
|
6382 }), function (_ref) { |
|
6383 var name = _ref.name; |
|
6384 return name; |
|
6385 }); |
|
6386 }, function (state) { |
|
6387 return [state.blockTypes]; |
|
6388 }); |
|
6389 /** |
|
6390 * Returns the block support value for a feature, if defined. |
|
6391 * |
|
6392 * @param {Object} state Data state. |
|
6393 * @param {(string|Object)} nameOrType Block name or type object |
|
6394 * @param {string} feature Feature to retrieve |
|
6395 * @param {*} defaultSupports Default value to return if not |
|
6396 * explicitly defined |
|
6397 * |
|
6398 * @return {?*} Block support value |
|
6399 */ |
|
6400 |
|
6401 var selectors_getBlockSupport = function getBlockSupport(state, nameOrType, feature, defaultSupports) { |
|
6402 var blockType = getNormalizedBlockType(state, nameOrType); |
|
6403 return Object(external_this_lodash_["get"])(blockType, ['supports'].concat(Object(toConsumableArray["a" /* default */])(feature.split('.'))), defaultSupports); |
|
6404 }; |
|
6405 /** |
|
6406 * Returns true if the block defines support for a feature, or false otherwise. |
|
6407 * |
|
6408 * @param {Object} state Data state. |
|
6409 * @param {(string|Object)} nameOrType Block name or type object. |
|
6410 * @param {string} feature Feature to test. |
|
6411 * @param {boolean} defaultSupports Whether feature is supported by |
|
6412 * default if not explicitly defined. |
|
6413 * |
|
6414 * @return {boolean} Whether block supports feature. |
|
6415 */ |
|
6416 |
|
6417 function hasBlockSupport(state, nameOrType, feature, defaultSupports) { |
|
6418 return !!selectors_getBlockSupport(state, nameOrType, feature, defaultSupports); |
|
6419 } |
|
6420 /** |
|
6421 * Returns true if the block type by the given name or object value matches a |
|
6422 * search term, or false otherwise. |
|
6423 * |
|
6424 * @param {Object} state Blocks state. |
|
6425 * @param {(string|Object)} nameOrType Block name or type object. |
|
6426 * @param {string} searchTerm Search term by which to filter. |
|
6427 * |
|
6428 * @return {Object[]} Whether block type matches search term. |
|
6429 */ |
|
6430 |
|
6431 function isMatchingSearchTerm(state, nameOrType, searchTerm) { |
|
6432 var blockType = getNormalizedBlockType(state, nameOrType); |
|
6433 var getNormalizedSearchTerm = Object(external_this_lodash_["flow"])([// Disregard diacritics. |
|
6434 // Input: "média" |
|
6435 external_this_lodash_["deburr"], // Lowercase. |
|
6436 // Input: "MEDIA" |
|
6437 function (term) { |
|
6438 return term.toLowerCase(); |
|
6439 }, // Strip leading and trailing whitespace. |
|
6440 // Input: " media " |
|
6441 function (term) { |
|
6442 return term.trim(); |
|
6443 }]); |
|
6444 var normalizedSearchTerm = getNormalizedSearchTerm(searchTerm); |
|
6445 var isSearchMatch = Object(external_this_lodash_["flow"])([getNormalizedSearchTerm, function (normalizedCandidate) { |
|
6446 return Object(external_this_lodash_["includes"])(normalizedCandidate, normalizedSearchTerm); |
|
6447 }]); |
|
6448 return isSearchMatch(blockType.title) || Object(external_this_lodash_["some"])(blockType.keywords, isSearchMatch) || isSearchMatch(blockType.category); |
|
6449 } |
|
6450 /** |
|
6451 * Returns a boolean indicating if a block has child blocks or not. |
|
6452 * |
|
6453 * @param {Object} state Data state. |
|
6454 * @param {string} blockName Block type name. |
|
6455 * |
|
6456 * @return {boolean} True if a block contains child blocks and false otherwise. |
|
6457 */ |
|
6458 |
|
6459 var selectors_hasChildBlocks = function hasChildBlocks(state, blockName) { |
|
6460 return selectors_getChildBlockNames(state, blockName).length > 0; |
|
6461 }; |
|
6462 /** |
|
6463 * Returns a boolean indicating if a block has at least one child block with inserter support. |
|
6464 * |
|
6465 * @param {Object} state Data state. |
|
6466 * @param {string} blockName Block type name. |
|
6467 * |
|
6468 * @return {boolean} True if a block contains at least one child blocks with inserter support |
|
6469 * and false otherwise. |
|
6470 */ |
|
6471 |
|
6472 var selectors_hasChildBlocksWithInserterSupport = function hasChildBlocksWithInserterSupport(state, blockName) { |
|
6473 return Object(external_this_lodash_["some"])(selectors_getChildBlockNames(state, blockName), function (childBlockName) { |
|
6474 return hasBlockSupport(state, childBlockName, 'inserter', true); |
|
6475 }); |
|
6476 }; |
|
6477 |
|
6478 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/actions.js |
|
6479 /** |
|
6480 * External dependencies |
|
6481 */ |
|
6482 |
|
6483 /** @typedef {import('../api/registration').WPBlockVariation} WPBlockVariation */ |
|
6484 |
|
6485 /** |
|
6486 * Returns an action object used in signalling that block types have been added. |
|
6487 * |
|
6488 * @param {Array|Object} blockTypes Block types received. |
|
6489 * |
|
6490 * @return {Object} Action object. |
|
6491 */ |
|
6492 |
|
6493 function addBlockTypes(blockTypes) { |
|
6494 return { |
|
6495 type: 'ADD_BLOCK_TYPES', |
|
6496 blockTypes: Object(external_this_lodash_["castArray"])(blockTypes) |
|
6497 }; |
|
6498 } |
|
6499 /** |
|
6500 * Returns an action object used to remove a registered block type. |
|
6501 * |
|
6502 * @param {string|Array} names Block name. |
|
6503 * |
|
6504 * @return {Object} Action object. |
|
6505 */ |
|
6506 |
|
6507 function removeBlockTypes(names) { |
|
6508 return { |
|
6509 type: 'REMOVE_BLOCK_TYPES', |
|
6510 names: Object(external_this_lodash_["castArray"])(names) |
|
6511 }; |
|
6512 } |
|
6513 /** |
|
6514 * Returns an action object used in signalling that new block styles have been added. |
|
6515 * |
|
6516 * @param {string} blockName Block name. |
|
6517 * @param {Array|Object} styles Block styles. |
|
6518 * |
|
6519 * @return {Object} Action object. |
|
6520 */ |
|
6521 |
|
6522 function addBlockStyles(blockName, styles) { |
|
6523 return { |
|
6524 type: 'ADD_BLOCK_STYLES', |
|
6525 styles: Object(external_this_lodash_["castArray"])(styles), |
|
6526 blockName: blockName |
|
6527 }; |
|
6528 } |
|
6529 /** |
|
6530 * Returns an action object used in signalling that block styles have been removed. |
|
6531 * |
|
6532 * @param {string} blockName Block name. |
|
6533 * @param {Array|string} styleNames Block style names. |
|
6534 * |
|
6535 * @return {Object} Action object. |
|
6536 */ |
|
6537 |
|
6538 function removeBlockStyles(blockName, styleNames) { |
|
6539 return { |
|
6540 type: 'REMOVE_BLOCK_STYLES', |
|
6541 styleNames: Object(external_this_lodash_["castArray"])(styleNames), |
|
6542 blockName: blockName |
|
6543 }; |
|
6544 } |
|
6545 /** |
|
6546 * Returns an action object used in signalling that new block variations have been added. |
|
6547 * |
|
6548 * @param {string} blockName Block name. |
|
6549 * @param {WPBlockVariation|WPBlockVariation[]} variations Block variations. |
|
6550 * |
|
6551 * @return {Object} Action object. |
|
6552 */ |
|
6553 |
|
6554 function addBlockVariations(blockName, variations) { |
|
6555 return { |
|
6556 type: 'ADD_BLOCK_VARIATIONS', |
|
6557 variations: Object(external_this_lodash_["castArray"])(variations), |
|
6558 blockName: blockName |
|
6559 }; |
|
6560 } |
|
6561 /** |
|
6562 * Returns an action object used in signalling that block variations have been removed. |
|
6563 * |
|
6564 * @param {string} blockName Block name. |
|
6565 * @param {string|string[]} variationNames Block variation names. |
|
6566 * |
|
6567 * @return {Object} Action object. |
|
6568 */ |
|
6569 |
|
6570 function removeBlockVariations(blockName, variationNames) { |
|
6571 return { |
|
6572 type: 'REMOVE_BLOCK_VARIATIONS', |
|
6573 variationNames: Object(external_this_lodash_["castArray"])(variationNames), |
|
6574 blockName: blockName |
|
6575 }; |
|
6576 } |
|
6577 /** |
|
6578 * Returns an action object used to set the default block name. |
|
6579 * |
|
6580 * @param {string} name Block name. |
|
6581 * |
|
6582 * @return {Object} Action object. |
|
6583 */ |
|
6584 |
|
6585 function setDefaultBlockName(name) { |
|
6586 return { |
|
6587 type: 'SET_DEFAULT_BLOCK_NAME', |
|
6588 name: name |
|
6589 }; |
|
6590 } |
|
6591 /** |
|
6592 * Returns an action object used to set the name of the block used as a fallback |
|
6593 * for non-block content. |
|
6594 * |
|
6595 * @param {string} name Block name. |
|
6596 * |
|
6597 * @return {Object} Action object. |
|
6598 */ |
|
6599 |
|
6600 function setFreeformFallbackBlockName(name) { |
|
6601 return { |
|
6602 type: 'SET_FREEFORM_FALLBACK_BLOCK_NAME', |
|
6603 name: name |
|
6604 }; |
|
6605 } |
|
6606 /** |
|
6607 * Returns an action object used to set the name of the block used as a fallback |
|
6608 * for unregistered blocks. |
|
6609 * |
|
6610 * @param {string} name Block name. |
|
6611 * |
|
6612 * @return {Object} Action object. |
|
6613 */ |
|
6614 |
|
6615 function setUnregisteredFallbackBlockName(name) { |
|
6616 return { |
|
6617 type: 'SET_UNREGISTERED_FALLBACK_BLOCK_NAME', |
|
6618 name: name |
|
6619 }; |
|
6620 } |
|
6621 /** |
|
6622 * Returns an action object used to set the name of the block used |
|
6623 * when grouping other blocks |
|
6624 * eg: in "Group/Ungroup" interactions |
|
6625 * |
|
6626 * @param {string} name Block name. |
|
6627 * |
|
6628 * @return {Object} Action object. |
|
6629 */ |
|
6630 |
|
6631 function setGroupingBlockName(name) { |
|
6632 return { |
|
6633 type: 'SET_GROUPING_BLOCK_NAME', |
|
6634 name: name |
|
6635 }; |
|
6636 } |
|
6637 /** |
|
6638 * Returns an action object used to set block categories. |
|
6639 * |
|
6640 * @param {Object[]} categories Block categories. |
|
6641 * |
|
6642 * @return {Object} Action object. |
|
6643 */ |
|
6644 |
|
6645 function setCategories(categories) { |
|
6646 return { |
|
6647 type: 'SET_CATEGORIES', |
|
6648 categories: categories |
|
6649 }; |
|
6650 } |
|
6651 /** |
|
6652 * Returns an action object used to update a category. |
|
6653 * |
|
6654 * @param {string} slug Block category slug. |
|
6655 * @param {Object} category Object containing the category properties that should be updated. |
|
6656 * |
|
6657 * @return {Object} Action object. |
|
6658 */ |
|
6659 |
|
6660 function updateCategory(slug, category) { |
|
6661 return { |
|
6662 type: 'UPDATE_CATEGORY', |
|
6663 slug: slug, |
|
6664 category: category |
|
6665 }; |
|
6666 } |
|
6667 /** |
|
6668 * Returns an action object used to add block collections |
|
6669 * |
|
6670 * @param {string} namespace The namespace of the blocks to put in the collection |
|
6671 * @param {string} title The title to display in the block inserter |
|
6672 * @param {Object} icon (optional) The icon to display in the block inserter |
|
6673 * |
|
6674 * @return {Object} Action object. |
|
6675 */ |
|
6676 |
|
6677 function addBlockCollection(namespace, title, icon) { |
|
6678 return { |
|
6679 type: 'ADD_BLOCK_COLLECTION', |
|
6680 namespace: namespace, |
|
6681 title: title, |
|
6682 icon: icon |
|
6683 }; |
|
6684 } |
|
6685 /** |
|
6686 * Returns an action object used to remove block collections |
|
6687 * |
|
6688 * @param {string} namespace The namespace of the blocks to put in the collection |
|
6689 * |
|
6690 * @return {Object} Action object. |
|
6691 */ |
|
6692 |
|
6693 function removeBlockCollection(namespace) { |
|
6694 return { |
|
6695 type: 'REMOVE_BLOCK_COLLECTION', |
|
6696 namespace: namespace |
|
6697 }; |
|
6698 } |
|
6699 |
|
6700 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/store/index.js |
|
6701 /** |
|
6702 * WordPress dependencies |
|
6703 */ |
|
6704 |
|
6705 /** |
|
6706 * Internal dependencies |
|
6707 */ |
|
6708 |
|
6709 |
|
6710 |
|
6711 |
|
6712 Object(external_this_wp_data_["registerStore"])('core/blocks', { |
|
6713 reducer: reducer, |
|
6714 selectors: selectors_namespaceObject, |
|
6715 actions: actions_namespaceObject |
|
6716 }); |
|
6717 |
|
6718 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/node_modules/uuid/dist/esm-browser/rng.js |
|
6719 // Unique ID creation requires a high quality random # generator. In the browser we therefore |
|
6720 // require the crypto API and do not support built-in fallback to lower quality random number |
|
6721 // generators (like Math.random()). |
|
6722 // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also, |
|
6723 // find the complete implementation of crypto (msCrypto) on IE11. |
|
6724 var getRandomValues = typeof crypto != 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto != 'undefined' && typeof msCrypto.getRandomValues == 'function' && msCrypto.getRandomValues.bind(msCrypto); |
|
6725 var rnds8 = new Uint8Array(16); // eslint-disable-line no-undef |
|
6726 |
|
6727 function rng() { |
|
6728 if (!getRandomValues) { |
|
6729 throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported'); |
|
6730 } |
|
6731 |
|
6732 return getRandomValues(rnds8); |
|
6733 } |
|
6734 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/node_modules/uuid/dist/esm-browser/bytesToUuid.js |
|
6735 /** |
|
6736 * Convert array of 16 byte values to UUID string format of the form: |
|
6737 * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX |
|
6738 */ |
|
6739 var byteToHex = []; |
|
6740 |
|
6741 for (var bytesToUuid_i = 0; bytesToUuid_i < 256; ++bytesToUuid_i) { |
|
6742 byteToHex[bytesToUuid_i] = (bytesToUuid_i + 0x100).toString(16).substr(1); |
|
6743 } |
|
6744 |
|
6745 function bytesToUuid(buf, offset) { |
|
6746 var i = offset || 0; |
|
6747 var bth = byteToHex; // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4 |
|
6748 |
|
6749 return [bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]]].join(''); |
|
6750 } |
|
6751 |
|
6752 /* harmony default export */ var esm_browser_bytesToUuid = (bytesToUuid); |
|
6753 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/node_modules/uuid/dist/esm-browser/v4.js |
|
6754 |
|
6755 |
|
6756 |
|
6757 function v4(options, buf, offset) { |
|
6758 var i = buf && offset || 0; |
|
6759 |
|
6760 if (typeof options == 'string') { |
|
6761 buf = options === 'binary' ? new Array(16) : null; |
|
6762 options = null; |
|
6763 } |
|
6764 |
|
6765 options = options || {}; |
|
6766 var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` |
|
6767 |
|
6768 rnds[6] = rnds[6] & 0x0f | 0x40; |
|
6769 rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided |
|
6770 |
|
6771 if (buf) { |
|
6772 for (var ii = 0; ii < 16; ++ii) { |
|
6773 buf[i + ii] = rnds[ii]; |
|
6774 } |
|
6775 } |
|
6776 |
|
6777 return buf || esm_browser_bytesToUuid(rnds); |
|
6778 } |
|
6779 |
|
6780 /* harmony default export */ var esm_browser_v4 = (v4); |
|
6781 // EXTERNAL MODULE: external {"this":["wp","hooks"]} |
|
6782 var external_this_wp_hooks_ = __webpack_require__(32); |
|
6783 |
|
6784 // EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/block-default.js |
|
6785 var block_default = __webpack_require__(202); |
|
6786 |
|
6787 // EXTERNAL MODULE: ./node_modules/tinycolor2/tinycolor.js |
|
6788 var tinycolor = __webpack_require__(66); |
|
6789 var tinycolor_default = /*#__PURE__*/__webpack_require__.n(tinycolor); |
|
6790 |
|
6791 // EXTERNAL MODULE: external {"this":["wp","element"]} |
|
6792 var external_this_wp_element_ = __webpack_require__(0); |
|
6793 |
|
6794 // EXTERNAL MODULE: external {"this":["wp","dom"]} |
|
6795 var external_this_wp_dom_ = __webpack_require__(30); |
|
6796 |
|
6797 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/utils.js |
|
6798 |
|
6799 |
|
6800 function utils_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
6801 |
|
6802 function utils_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { utils_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { utils_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
6803 |
|
6804 /** |
|
6805 * External dependencies |
|
6806 */ |
|
6807 |
|
6808 |
|
6809 /** |
|
6810 * WordPress dependencies |
|
6811 */ |
|
6812 |
|
6813 |
|
6814 |
|
6815 |
|
6816 /** |
|
6817 * Internal dependencies |
|
6818 */ |
|
6819 |
|
6820 |
|
6821 |
|
6822 /** |
|
6823 * Array of icon colors containing a color to be used if the icon color |
|
6824 * was not explicitly set but the icon background color was. |
|
6825 * |
|
6826 * @type {Object} |
|
6827 */ |
|
6828 |
|
6829 var ICON_COLORS = ['#191e23', '#f8f9f9']; |
|
6830 /** |
|
6831 * Determines whether the block is a default block |
|
6832 * and its attributes are equal to the default attributes |
|
6833 * which means the block is unmodified. |
|
6834 * |
|
6835 * @param {WPBlock} block Block Object |
|
6836 * |
|
6837 * @return {boolean} Whether the block is an unmodified default block |
|
6838 */ |
|
6839 |
|
6840 function isUnmodifiedDefaultBlock(block) { |
|
6841 var defaultBlockName = registration_getDefaultBlockName(); |
|
6842 |
|
6843 if (block.name !== defaultBlockName) { |
|
6844 return false; |
|
6845 } // Cache a created default block if no cache exists or the default block |
|
6846 // name changed. |
|
6847 |
|
6848 |
|
6849 if (!isUnmodifiedDefaultBlock.block || isUnmodifiedDefaultBlock.block.name !== defaultBlockName) { |
|
6850 isUnmodifiedDefaultBlock.block = createBlock(defaultBlockName); |
|
6851 } |
|
6852 |
|
6853 var newDefaultBlock = isUnmodifiedDefaultBlock.block; |
|
6854 var blockType = registration_getBlockType(defaultBlockName); |
|
6855 return Object(external_this_lodash_["every"])(blockType.attributes, function (value, key) { |
|
6856 return newDefaultBlock.attributes[key] === block.attributes[key]; |
|
6857 }); |
|
6858 } |
|
6859 /** |
|
6860 * Function that checks if the parameter is a valid icon. |
|
6861 * |
|
6862 * @param {*} icon Parameter to be checked. |
|
6863 * |
|
6864 * @return {boolean} True if the parameter is a valid icon and false otherwise. |
|
6865 */ |
|
6866 |
|
6867 function isValidIcon(icon) { |
|
6868 return !!icon && (Object(external_this_lodash_["isString"])(icon) || Object(external_this_wp_element_["isValidElement"])(icon) || Object(external_this_lodash_["isFunction"])(icon) || icon instanceof external_this_wp_element_["Component"]); |
|
6869 } |
|
6870 /** |
|
6871 * Function that receives an icon as set by the blocks during the registration |
|
6872 * and returns a new icon object that is normalized so we can rely on just on possible icon structure |
|
6873 * in the codebase. |
|
6874 * |
|
6875 * @param {WPBlockTypeIconRender} icon Render behavior of a block type icon; |
|
6876 * one of a Dashicon slug, an element, or a |
|
6877 * component. |
|
6878 * |
|
6879 * @return {WPBlockTypeIconDescriptor} Object describing the icon. |
|
6880 */ |
|
6881 |
|
6882 function normalizeIconObject(icon) { |
|
6883 if (isValidIcon(icon)) { |
|
6884 return { |
|
6885 src: icon |
|
6886 }; |
|
6887 } |
|
6888 |
|
6889 if (Object(external_this_lodash_["has"])(icon, ['background'])) { |
|
6890 var tinyBgColor = tinycolor_default()(icon.background); |
|
6891 return utils_objectSpread({}, icon, { |
|
6892 foreground: icon.foreground ? icon.foreground : Object(tinycolor["mostReadable"])(tinyBgColor, ICON_COLORS, { |
|
6893 includeFallbackColors: true, |
|
6894 level: 'AA', |
|
6895 size: 'large' |
|
6896 }).toHexString(), |
|
6897 shadowColor: tinyBgColor.setAlpha(0.3).toRgbString() |
|
6898 }); |
|
6899 } |
|
6900 |
|
6901 return icon; |
|
6902 } |
|
6903 /** |
|
6904 * Normalizes block type passed as param. When string is passed then |
|
6905 * it converts it to the matching block type object. |
|
6906 * It passes the original object otherwise. |
|
6907 * |
|
6908 * @param {string|Object} blockTypeOrName Block type or name. |
|
6909 * |
|
6910 * @return {?Object} Block type. |
|
6911 */ |
|
6912 |
|
6913 function normalizeBlockType(blockTypeOrName) { |
|
6914 if (Object(external_this_lodash_["isString"])(blockTypeOrName)) { |
|
6915 return registration_getBlockType(blockTypeOrName); |
|
6916 } |
|
6917 |
|
6918 return blockTypeOrName; |
|
6919 } |
|
6920 /** |
|
6921 * Get the label for the block, usually this is either the block title, |
|
6922 * or the value of the block's `label` function when that's specified. |
|
6923 * |
|
6924 * @param {Object} blockType The block type. |
|
6925 * @param {Object} attributes The values of the block's attributes. |
|
6926 * @param {Object} context The intended use for the label. |
|
6927 * |
|
6928 * @return {string} The block label. |
|
6929 */ |
|
6930 |
|
6931 function getBlockLabel(blockType, attributes) { |
|
6932 var context = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'visual'; |
|
6933 var getLabel = blockType.__experimentalLabel, |
|
6934 title = blockType.title; |
|
6935 var label = getLabel && getLabel(attributes, { |
|
6936 context: context |
|
6937 }); |
|
6938 |
|
6939 if (!label) { |
|
6940 return title; |
|
6941 } // Strip any HTML (i.e. RichText formatting) before returning. |
|
6942 |
|
6943 |
|
6944 return Object(external_this_wp_dom_["__unstableStripHTML"])(label); |
|
6945 } |
|
6946 /** |
|
6947 * Get a label for the block for use by screenreaders, this is more descriptive |
|
6948 * than the visual label and includes the block title and the value of the |
|
6949 * `getLabel` function if it's specified. |
|
6950 * |
|
6951 * @param {Object} blockType The block type. |
|
6952 * @param {Object} attributes The values of the block's attributes. |
|
6953 * @param {?number} position The position of the block in the block list. |
|
6954 * @param {string} [direction='vertical'] The direction of the block layout. |
|
6955 * |
|
6956 * @return {string} The block label. |
|
6957 */ |
|
6958 |
|
6959 function getAccessibleBlockLabel(blockType, attributes, position) { |
|
6960 var direction = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'vertical'; |
|
6961 // `title` is already localized, `label` is a user-supplied value. |
|
6962 var title = blockType.title; |
|
6963 var label = getBlockLabel(blockType, attributes, 'accessibility'); |
|
6964 var hasPosition = position !== undefined; // getBlockLabel returns the block title as a fallback when there's no label, |
|
6965 // if it did return the title, this function needs to avoid adding the |
|
6966 // title twice within the accessible label. Use this `hasLabel` boolean to |
|
6967 // handle that. |
|
6968 |
|
6969 var hasLabel = label && label !== title; |
|
6970 |
|
6971 if (hasPosition && direction === 'vertical') { |
|
6972 if (hasLabel) { |
|
6973 return Object(external_this_wp_i18n_["sprintf"])( |
|
6974 /* translators: accessibility text. 1: The block title. 2: The block row number. 3: The block label.. */ |
|
6975 Object(external_this_wp_i18n_["__"])('%1$s Block. Row %2$d. %3$s'), title, position, label); |
|
6976 } |
|
6977 |
|
6978 return Object(external_this_wp_i18n_["sprintf"])( |
|
6979 /* translators: accessibility text. 1: The block title. 2: The block row number. */ |
|
6980 Object(external_this_wp_i18n_["__"])('%1$s Block. Row %2$d'), title, position); |
|
6981 } else if (hasPosition && direction === 'horizontal') { |
|
6982 if (hasLabel) { |
|
6983 return Object(external_this_wp_i18n_["sprintf"])( |
|
6984 /* translators: accessibility text. 1: The block title. 2: The block column number. 3: The block label.. */ |
|
6985 Object(external_this_wp_i18n_["__"])('%1$s Block. Column %2$d. %3$s'), title, position, label); |
|
6986 } |
|
6987 |
|
6988 return Object(external_this_wp_i18n_["sprintf"])( |
|
6989 /* translators: accessibility text. 1: The block title. 2: The block column number. */ |
|
6990 Object(external_this_wp_i18n_["__"])('%1$s Block. Column %2$d'), title, position); |
|
6991 } |
|
6992 |
|
6993 if (hasLabel) { |
|
6994 return Object(external_this_wp_i18n_["sprintf"])( |
|
6995 /* translators: accessibility text. %1: The block title. %2: The block label. */ |
|
6996 Object(external_this_wp_i18n_["__"])('%1$s Block. %2$s'), title, label); |
|
6997 } |
|
6998 |
|
6999 return Object(external_this_wp_i18n_["sprintf"])( |
|
7000 /* translators: accessibility text. %s: The block title. */ |
|
7001 Object(external_this_wp_i18n_["__"])('%s Block'), title); |
|
7002 } |
|
7003 |
|
7004 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/constants.js |
|
7005 /** |
|
7006 * Array of valid keys in a block type settings deprecation object. |
|
7007 * |
|
7008 * @type {string[]} |
|
7009 */ |
|
7010 var DEPRECATED_ENTRY_KEYS = ['attributes', 'supports', 'save', 'migrate', 'isEligible']; |
|
7011 |
|
7012 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/registration.js |
|
7013 |
|
7014 |
|
7015 function registration_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
7016 |
|
7017 function registration_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { registration_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { registration_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
7018 |
|
7019 /* eslint no-console: [ 'error', { allow: [ 'error', 'warn' ] } ] */ |
|
7020 |
|
7021 /** |
|
7022 * External dependencies |
|
7023 */ |
|
7024 |
|
7025 /** |
|
7026 * WordPress dependencies |
|
7027 */ |
|
7028 |
|
7029 |
|
7030 |
|
7031 |
|
7032 /** |
|
7033 * Internal dependencies |
|
7034 */ |
|
7035 |
|
7036 |
|
7037 |
|
7038 /** |
|
7039 * An icon type definition. One of a Dashicon slug, an element, |
|
7040 * or a component. |
|
7041 * |
|
7042 * @typedef {(string|WPElement|WPComponent)} WPIcon |
|
7043 * |
|
7044 * @see https://developer.wordpress.org/resource/dashicons/ |
|
7045 */ |
|
7046 |
|
7047 /** |
|
7048 * Render behavior of a block type icon; one of a Dashicon slug, an element, |
|
7049 * or a component. |
|
7050 * |
|
7051 * @typedef {WPIcon} WPBlockTypeIconRender |
|
7052 */ |
|
7053 |
|
7054 /** |
|
7055 * An object describing a normalized block type icon. |
|
7056 * |
|
7057 * @typedef {Object} WPBlockTypeIconDescriptor |
|
7058 * |
|
7059 * @property {WPBlockTypeIconRender} src Render behavior of the icon, |
|
7060 * one of a Dashicon slug, an |
|
7061 * element, or a component. |
|
7062 * @property {string} background Optimal background hex string |
|
7063 * color when displaying icon. |
|
7064 * @property {string} foreground Optimal foreground hex string |
|
7065 * color when displaying icon. |
|
7066 * @property {string} shadowColor Optimal shadow hex string |
|
7067 * color when displaying icon. |
|
7068 */ |
|
7069 |
|
7070 /** |
|
7071 * Value to use to render the icon for a block type in an editor interface, |
|
7072 * either a Dashicon slug, an element, a component, or an object describing |
|
7073 * the icon. |
|
7074 * |
|
7075 * @typedef {(WPBlockTypeIconDescriptor|WPBlockTypeIconRender)} WPBlockTypeIcon |
|
7076 */ |
|
7077 |
|
7078 /** |
|
7079 * Named block variation scopes. |
|
7080 * |
|
7081 * @typedef {'block'|'inserter'} WPBlockVariationScope |
|
7082 */ |
|
7083 |
|
7084 /** |
|
7085 * An object describing a variation defined for the block type. |
|
7086 * |
|
7087 * @typedef {Object} WPBlockVariation |
|
7088 * |
|
7089 * @property {string} name The unique and machine-readable name. |
|
7090 * @property {string} title A human-readable variation title. |
|
7091 * @property {string} [description] A detailed variation description. |
|
7092 * @property {WPIcon} [icon] An icon helping to visualize the variation. |
|
7093 * @property {boolean} [isDefault] Indicates whether the current variation is |
|
7094 * the default one. Defaults to `false`. |
|
7095 * @property {Object} [attributes] Values which override block attributes. |
|
7096 * @property {Array[]} [innerBlocks] Initial configuration of nested blocks. |
|
7097 * @property {Object} [example] Example provides structured data for |
|
7098 * the block preview. You can set to |
|
7099 * `undefined` to disable the preview shown |
|
7100 * for the block type. |
|
7101 * @property {WPBlockVariationScope[]} [scope] The list of scopes where the variation |
|
7102 * is applicable. When not provided, it |
|
7103 * assumes all available scopes. |
|
7104 */ |
|
7105 |
|
7106 /** |
|
7107 * Defined behavior of a block type. |
|
7108 * |
|
7109 * @typedef {Object} WPBlock |
|
7110 * |
|
7111 * @property {string} name Block type's namespaced name. |
|
7112 * @property {string} title Human-readable block type label. |
|
7113 * @property {string} [description] A detailed block type description. |
|
7114 * @property {string} [category] Block type category classification, |
|
7115 * used in search interfaces to arrange |
|
7116 * block types by category. |
|
7117 * @property {WPBlockTypeIcon} [icon] Block type icon. |
|
7118 * @property {string[]} [keywords] Additional keywords to produce block |
|
7119 * type as result in search interfaces. |
|
7120 * @property {Object} [attributes] Block type attributes. |
|
7121 * @property {WPComponent} [save] Optional component describing |
|
7122 * serialized markup structure of a |
|
7123 * block type. |
|
7124 * @property {WPComponent} edit Component rendering an element to |
|
7125 * manipulate the attributes of a block |
|
7126 * in the context of an editor. |
|
7127 * @property {WPBlockVariation[]} [variations] The list of block variations. |
|
7128 * @property {Object} [example] Example provides structured data for |
|
7129 * the block preview. When not defined |
|
7130 * then no preview is shown. |
|
7131 */ |
|
7132 |
|
7133 /** |
|
7134 * Mapping of legacy category slugs to their latest normal values, used to |
|
7135 * accommodate updates of the default set of block categories. |
|
7136 * |
|
7137 * @type {Record<string,string>} |
|
7138 */ |
|
7139 |
|
7140 var LEGACY_CATEGORY_MAPPING = { |
|
7141 common: 'text', |
|
7142 formatting: 'text', |
|
7143 layout: 'design' |
|
7144 }; |
|
7145 var serverSideBlockDefinitions = {}; |
|
7146 /** |
|
7147 * Sets the server side block definition of blocks. |
|
7148 * |
|
7149 * @param {Object} definitions Server-side block definitions |
|
7150 */ |
|
7151 // eslint-disable-next-line camelcase |
|
7152 |
|
7153 function unstable__bootstrapServerSideBlockDefinitions(definitions) { |
|
7154 serverSideBlockDefinitions = registration_objectSpread({}, serverSideBlockDefinitions, {}, definitions); |
|
7155 } |
|
7156 /** |
|
7157 * Registers a new block provided a unique name and an object defining its |
|
7158 * behavior. Once registered, the block is made available as an option to any |
|
7159 * editor interface where blocks are implemented. |
|
7160 * |
|
7161 * @param {string} name Block name. |
|
7162 * @param {Object} settings Block settings. |
|
7163 * |
|
7164 * @return {?WPBlock} The block, if it has been successfully registered; |
|
7165 * otherwise `undefined`. |
|
7166 */ |
|
7167 |
|
7168 function registerBlockType(name, settings) { |
|
7169 settings = registration_objectSpread({ |
|
7170 name: name, |
|
7171 icon: block_default["a" /* default */], |
|
7172 keywords: [], |
|
7173 attributes: {}, |
|
7174 providesContext: {}, |
|
7175 usesContext: [], |
|
7176 supports: {}, |
|
7177 styles: [], |
|
7178 save: function save() { |
|
7179 return null; |
|
7180 } |
|
7181 }, Object(external_this_lodash_["pickBy"])(Object(external_this_lodash_["get"])(serverSideBlockDefinitions, name, {}), function (value) { |
|
7182 return !Object(external_this_lodash_["isNil"])(value); |
|
7183 }), {}, settings); |
|
7184 |
|
7185 if (typeof name !== 'string') { |
|
7186 console.error('Block names must be strings.'); |
|
7187 return; |
|
7188 } |
|
7189 |
|
7190 if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(name)) { |
|
7191 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'); |
|
7192 return; |
|
7193 } |
|
7194 |
|
7195 if (Object(external_this_wp_data_["select"])('core/blocks').getBlockType(name)) { |
|
7196 console.error('Block "' + name + '" is already registered.'); |
|
7197 return; |
|
7198 } |
|
7199 |
|
7200 var preFilterSettings = registration_objectSpread({}, settings); |
|
7201 |
|
7202 settings = Object(external_this_wp_hooks_["applyFilters"])('blocks.registerBlockType', settings, name); |
|
7203 |
|
7204 if (settings.deprecated) { |
|
7205 settings.deprecated = settings.deprecated.map(function (deprecation) { |
|
7206 return Object(external_this_lodash_["pick"])( // Only keep valid deprecation keys. |
|
7207 Object(external_this_wp_hooks_["applyFilters"])('blocks.registerBlockType', // Merge deprecation keys with pre-filter settings |
|
7208 // so that filters that depend on specific keys being |
|
7209 // present don't fail. |
|
7210 registration_objectSpread({}, Object(external_this_lodash_["omit"])(preFilterSettings, DEPRECATED_ENTRY_KEYS), {}, deprecation), name), DEPRECATED_ENTRY_KEYS); |
|
7211 }); |
|
7212 } |
|
7213 |
|
7214 if (!Object(external_this_lodash_["isPlainObject"])(settings)) { |
|
7215 console.error('Block settings must be a valid object.'); |
|
7216 return; |
|
7217 } |
|
7218 |
|
7219 if (!Object(external_this_lodash_["isFunction"])(settings.save)) { |
|
7220 console.error('The "save" property must be a valid function.'); |
|
7221 return; |
|
7222 } |
|
7223 |
|
7224 if ('edit' in settings && !Object(external_this_lodash_["isFunction"])(settings.edit)) { |
|
7225 console.error('The "edit" property must be a valid function.'); |
|
7226 return; |
|
7227 } // Canonicalize legacy categories to equivalent fallback. |
|
7228 |
|
7229 |
|
7230 if (LEGACY_CATEGORY_MAPPING.hasOwnProperty(settings.category)) { |
|
7231 settings.category = LEGACY_CATEGORY_MAPPING[settings.category]; |
|
7232 } |
|
7233 |
|
7234 if ('category' in settings && !Object(external_this_lodash_["some"])(Object(external_this_wp_data_["select"])('core/blocks').getCategories(), { |
|
7235 slug: settings.category |
|
7236 })) { |
|
7237 console.warn('The block "' + name + '" is registered with an invalid category "' + settings.category + '".'); |
|
7238 delete settings.category; |
|
7239 } |
|
7240 |
|
7241 if (!('title' in settings) || settings.title === '') { |
|
7242 console.error('The block "' + name + '" must have a title.'); |
|
7243 return; |
|
7244 } |
|
7245 |
|
7246 if (typeof settings.title !== 'string') { |
|
7247 console.error('Block titles must be strings.'); |
|
7248 return; |
|
7249 } |
|
7250 |
|
7251 settings.icon = normalizeIconObject(settings.icon); |
|
7252 |
|
7253 if (!isValidIcon(settings.icon.src)) { |
|
7254 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'); |
|
7255 return; |
|
7256 } |
|
7257 |
|
7258 Object(external_this_wp_data_["dispatch"])('core/blocks').addBlockTypes(settings); |
|
7259 return settings; |
|
7260 } |
|
7261 /** |
|
7262 * Registers a new block collection to group blocks in the same namespace in the inserter. |
|
7263 * |
|
7264 * @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace. |
|
7265 * @param {Object} settings The block collection settings. |
|
7266 * @param {string} settings.title The title to display in the block inserter. |
|
7267 * @param {Object} [settings.icon] The icon to display in the block inserter. |
|
7268 */ |
|
7269 |
|
7270 function registerBlockCollection(namespace, _ref) { |
|
7271 var title = _ref.title, |
|
7272 icon = _ref.icon; |
|
7273 Object(external_this_wp_data_["dispatch"])('core/blocks').addBlockCollection(namespace, title, icon); |
|
7274 } |
|
7275 /** |
|
7276 * Unregisters a block collection |
|
7277 * |
|
7278 * @param {string} namespace The namespace to group blocks by in the inserter; corresponds to the block namespace |
|
7279 * |
|
7280 */ |
|
7281 |
|
7282 function unregisterBlockCollection(namespace) { |
|
7283 Object(external_this_wp_data_["dispatch"])('core/blocks').removeBlockCollection(namespace); |
|
7284 } |
|
7285 /** |
|
7286 * Unregisters a block. |
|
7287 * |
|
7288 * @param {string} name Block name. |
|
7289 * |
|
7290 * @return {?WPBlock} The previous block value, if it has been successfully |
|
7291 * unregistered; otherwise `undefined`. |
|
7292 */ |
|
7293 |
|
7294 function unregisterBlockType(name) { |
|
7295 var oldBlock = Object(external_this_wp_data_["select"])('core/blocks').getBlockType(name); |
|
7296 |
|
7297 if (!oldBlock) { |
|
7298 console.error('Block "' + name + '" is not registered.'); |
|
7299 return; |
|
7300 } |
|
7301 |
|
7302 Object(external_this_wp_data_["dispatch"])('core/blocks').removeBlockTypes(name); |
|
7303 return oldBlock; |
|
7304 } |
|
7305 /** |
|
7306 * Assigns name of block for handling non-block content. |
|
7307 * |
|
7308 * @param {string} blockName Block name. |
|
7309 */ |
|
7310 |
|
7311 function setFreeformContentHandlerName(blockName) { |
|
7312 Object(external_this_wp_data_["dispatch"])('core/blocks').setFreeformFallbackBlockName(blockName); |
|
7313 } |
|
7314 /** |
|
7315 * Retrieves name of block handling non-block content, or undefined if no |
|
7316 * handler has been defined. |
|
7317 * |
|
7318 * @return {?string} Block name. |
|
7319 */ |
|
7320 |
|
7321 function getFreeformContentHandlerName() { |
|
7322 return Object(external_this_wp_data_["select"])('core/blocks').getFreeformFallbackBlockName(); |
|
7323 } |
|
7324 /** |
|
7325 * Retrieves name of block used for handling grouping interactions. |
|
7326 * |
|
7327 * @return {?string} Block name. |
|
7328 */ |
|
7329 |
|
7330 function registration_getGroupingBlockName() { |
|
7331 return Object(external_this_wp_data_["select"])('core/blocks').getGroupingBlockName(); |
|
7332 } |
|
7333 /** |
|
7334 * Assigns name of block handling unregistered block types. |
|
7335 * |
|
7336 * @param {string} blockName Block name. |
|
7337 */ |
|
7338 |
|
7339 function setUnregisteredTypeHandlerName(blockName) { |
|
7340 Object(external_this_wp_data_["dispatch"])('core/blocks').setUnregisteredFallbackBlockName(blockName); |
|
7341 } |
|
7342 /** |
|
7343 * Retrieves name of block handling unregistered block types, or undefined if no |
|
7344 * handler has been defined. |
|
7345 * |
|
7346 * @return {?string} Block name. |
|
7347 */ |
|
7348 |
|
7349 function getUnregisteredTypeHandlerName() { |
|
7350 return Object(external_this_wp_data_["select"])('core/blocks').getUnregisteredFallbackBlockName(); |
|
7351 } |
|
7352 /** |
|
7353 * Assigns the default block name. |
|
7354 * |
|
7355 * @param {string} name Block name. |
|
7356 */ |
|
7357 |
|
7358 function registration_setDefaultBlockName(name) { |
|
7359 Object(external_this_wp_data_["dispatch"])('core/blocks').setDefaultBlockName(name); |
|
7360 } |
|
7361 /** |
|
7362 * Assigns name of block for handling block grouping interactions. |
|
7363 * |
|
7364 * @param {string} name Block name. |
|
7365 */ |
|
7366 |
|
7367 function registration_setGroupingBlockName(name) { |
|
7368 Object(external_this_wp_data_["dispatch"])('core/blocks').setGroupingBlockName(name); |
|
7369 } |
|
7370 /** |
|
7371 * Retrieves the default block name. |
|
7372 * |
|
7373 * @return {?string} Block name. |
|
7374 */ |
|
7375 |
|
7376 function registration_getDefaultBlockName() { |
|
7377 return Object(external_this_wp_data_["select"])('core/blocks').getDefaultBlockName(); |
|
7378 } |
|
7379 /** |
|
7380 * Returns a registered block type. |
|
7381 * |
|
7382 * @param {string} name Block name. |
|
7383 * |
|
7384 * @return {?Object} Block type. |
|
7385 */ |
|
7386 |
|
7387 function registration_getBlockType(name) { |
|
7388 return Object(external_this_wp_data_["select"])('core/blocks').getBlockType(name); |
|
7389 } |
|
7390 /** |
|
7391 * Returns all registered blocks. |
|
7392 * |
|
7393 * @return {Array} Block settings. |
|
7394 */ |
|
7395 |
|
7396 function registration_getBlockTypes() { |
|
7397 return Object(external_this_wp_data_["select"])('core/blocks').getBlockTypes(); |
|
7398 } |
|
7399 /** |
|
7400 * Returns the block support value for a feature, if defined. |
|
7401 * |
|
7402 * @param {(string|Object)} nameOrType Block name or type object |
|
7403 * @param {string} feature Feature to retrieve |
|
7404 * @param {*} defaultSupports Default value to return if not |
|
7405 * explicitly defined |
|
7406 * |
|
7407 * @return {?*} Block support value |
|
7408 */ |
|
7409 |
|
7410 function registration_getBlockSupport(nameOrType, feature, defaultSupports) { |
|
7411 return Object(external_this_wp_data_["select"])('core/blocks').getBlockSupport(nameOrType, feature, defaultSupports); |
|
7412 } |
|
7413 /** |
|
7414 * Returns true if the block defines support for a feature, or false otherwise. |
|
7415 * |
|
7416 * @param {(string|Object)} nameOrType Block name or type object. |
|
7417 * @param {string} feature Feature to test. |
|
7418 * @param {boolean} defaultSupports Whether feature is supported by |
|
7419 * default if not explicitly defined. |
|
7420 * |
|
7421 * @return {boolean} Whether block supports feature. |
|
7422 */ |
|
7423 |
|
7424 function registration_hasBlockSupport(nameOrType, feature, defaultSupports) { |
|
7425 return Object(external_this_wp_data_["select"])('core/blocks').hasBlockSupport(nameOrType, feature, defaultSupports); |
|
7426 } |
|
7427 /** |
|
7428 * Determines whether or not the given block is a reusable block. This is a |
|
7429 * special block type that is used to point to a global block stored via the |
|
7430 * API. |
|
7431 * |
|
7432 * @param {Object} blockOrType Block or Block Type to test. |
|
7433 * |
|
7434 * @return {boolean} Whether the given block is a reusable block. |
|
7435 */ |
|
7436 |
|
7437 function isReusableBlock(blockOrType) { |
|
7438 return blockOrType.name === 'core/block'; |
|
7439 } |
|
7440 /** |
|
7441 * Returns an array with the child blocks of a given block. |
|
7442 * |
|
7443 * @param {string} blockName Name of block (example: “latest-posts”). |
|
7444 * |
|
7445 * @return {Array} Array of child block names. |
|
7446 */ |
|
7447 |
|
7448 var registration_getChildBlockNames = function getChildBlockNames(blockName) { |
|
7449 return Object(external_this_wp_data_["select"])('core/blocks').getChildBlockNames(blockName); |
|
7450 }; |
|
7451 /** |
|
7452 * Returns a boolean indicating if a block has child blocks or not. |
|
7453 * |
|
7454 * @param {string} blockName Name of block (example: “latest-posts”). |
|
7455 * |
|
7456 * @return {boolean} True if a block contains child blocks and false otherwise. |
|
7457 */ |
|
7458 |
|
7459 var registration_hasChildBlocks = function hasChildBlocks(blockName) { |
|
7460 return Object(external_this_wp_data_["select"])('core/blocks').hasChildBlocks(blockName); |
|
7461 }; |
|
7462 /** |
|
7463 * Returns a boolean indicating if a block has at least one child block with inserter support. |
|
7464 * |
|
7465 * @param {string} blockName Block type name. |
|
7466 * |
|
7467 * @return {boolean} True if a block contains at least one child blocks with inserter support |
|
7468 * and false otherwise. |
|
7469 */ |
|
7470 |
|
7471 var registration_hasChildBlocksWithInserterSupport = function hasChildBlocksWithInserterSupport(blockName) { |
|
7472 return Object(external_this_wp_data_["select"])('core/blocks').hasChildBlocksWithInserterSupport(blockName); |
|
7473 }; |
|
7474 /** |
|
7475 * Registers a new block style variation for the given block. |
|
7476 * |
|
7477 * @param {string} blockName Name of block (example: “core/latest-posts”). |
|
7478 * @param {Object} styleVariation Object containing `name` which is the class name applied to the block and `label` which identifies the variation to the user. |
|
7479 */ |
|
7480 |
|
7481 var registration_registerBlockStyle = function registerBlockStyle(blockName, styleVariation) { |
|
7482 Object(external_this_wp_data_["dispatch"])('core/blocks').addBlockStyles(blockName, styleVariation); |
|
7483 }; |
|
7484 /** |
|
7485 * Unregisters a block style variation for the given block. |
|
7486 * |
|
7487 * @param {string} blockName Name of block (example: “core/latest-posts”). |
|
7488 * @param {string} styleVariationName Name of class applied to the block. |
|
7489 */ |
|
7490 |
|
7491 var registration_unregisterBlockStyle = function unregisterBlockStyle(blockName, styleVariationName) { |
|
7492 Object(external_this_wp_data_["dispatch"])('core/blocks').removeBlockStyles(blockName, styleVariationName); |
|
7493 }; |
|
7494 /** |
|
7495 * Registers a new block variation for the given block type. |
|
7496 * |
|
7497 * @param {string} blockName Name of the block (example: “core/columns”). |
|
7498 * @param {WPBlockVariation} variation Object describing a block variation. |
|
7499 */ |
|
7500 |
|
7501 var registration_registerBlockVariation = function registerBlockVariation(blockName, variation) { |
|
7502 Object(external_this_wp_data_["dispatch"])('core/blocks').addBlockVariations(blockName, variation); |
|
7503 }; |
|
7504 /** |
|
7505 * Unregisters a block variation defined for the given block type. |
|
7506 * |
|
7507 * @param {string} blockName Name of the block (example: “core/columns”). |
|
7508 * @param {string} variationName Name of the variation defined for the block. |
|
7509 */ |
|
7510 |
|
7511 var registration_unregisterBlockVariation = function unregisterBlockVariation(blockName, variationName) { |
|
7512 Object(external_this_wp_data_["dispatch"])('core/blocks').removeBlockVariations(blockName, variationName); |
|
7513 }; |
|
7514 |
|
7515 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/factory.js |
|
7516 |
|
7517 |
|
7518 |
|
7519 function factory_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
7520 |
|
7521 function factory_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { factory_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { factory_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
7522 |
|
7523 /** |
|
7524 * External dependencies |
|
7525 */ |
|
7526 |
|
7527 |
|
7528 /** |
|
7529 * WordPress dependencies |
|
7530 */ |
|
7531 |
|
7532 |
|
7533 /** |
|
7534 * Internal dependencies |
|
7535 */ |
|
7536 |
|
7537 |
|
7538 |
|
7539 /** |
|
7540 * Returns a block object given its type and attributes. |
|
7541 * |
|
7542 * @param {string} name Block name. |
|
7543 * @param {Object} attributes Block attributes. |
|
7544 * @param {?Array} innerBlocks Nested blocks. |
|
7545 * |
|
7546 * @return {Object} Block object. |
|
7547 */ |
|
7548 |
|
7549 function createBlock(name) { |
|
7550 var attributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
7551 var innerBlocks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; |
|
7552 // Get the type definition associated with a registered block. |
|
7553 var blockType = registration_getBlockType(name); // Ensure attributes contains only values defined by block type, and merge |
|
7554 // default values for missing attributes. |
|
7555 |
|
7556 var sanitizedAttributes = Object(external_this_lodash_["reduce"])(blockType.attributes, function (accumulator, schema, key) { |
|
7557 var value = attributes[key]; |
|
7558 |
|
7559 if (undefined !== value) { |
|
7560 accumulator[key] = value; |
|
7561 } else if (schema.hasOwnProperty('default')) { |
|
7562 accumulator[key] = schema.default; |
|
7563 } |
|
7564 |
|
7565 if (['node', 'children'].indexOf(schema.source) !== -1) { |
|
7566 // Ensure value passed is always an array, which we're expecting in |
|
7567 // the RichText component to handle the deprecated value. |
|
7568 if (typeof accumulator[key] === 'string') { |
|
7569 accumulator[key] = [accumulator[key]]; |
|
7570 } else if (!Array.isArray(accumulator[key])) { |
|
7571 accumulator[key] = []; |
|
7572 } |
|
7573 } |
|
7574 |
|
7575 return accumulator; |
|
7576 }, {}); |
|
7577 var clientId = esm_browser_v4(); // Blocks are stored with a unique ID, the assigned type name, the block |
|
7578 // attributes, and their inner blocks. |
|
7579 |
|
7580 return { |
|
7581 clientId: clientId, |
|
7582 name: name, |
|
7583 isValid: true, |
|
7584 attributes: sanitizedAttributes, |
|
7585 innerBlocks: innerBlocks |
|
7586 }; |
|
7587 } |
|
7588 /** |
|
7589 * Given a block object, returns a copy of the block object, optionally merging |
|
7590 * new attributes and/or replacing its inner blocks. |
|
7591 * |
|
7592 * @param {Object} block Block instance. |
|
7593 * @param {Object} mergeAttributes Block attributes. |
|
7594 * @param {?Array} newInnerBlocks Nested blocks. |
|
7595 * |
|
7596 * @return {Object} A cloned block. |
|
7597 */ |
|
7598 |
|
7599 function cloneBlock(block) { |
|
7600 var mergeAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
7601 var newInnerBlocks = arguments.length > 2 ? arguments[2] : undefined; |
|
7602 var clientId = esm_browser_v4(); |
|
7603 return factory_objectSpread({}, block, { |
|
7604 clientId: clientId, |
|
7605 attributes: factory_objectSpread({}, block.attributes, {}, mergeAttributes), |
|
7606 innerBlocks: newInnerBlocks || block.innerBlocks.map(function (innerBlock) { |
|
7607 return cloneBlock(innerBlock); |
|
7608 }) |
|
7609 }); |
|
7610 } |
|
7611 /** |
|
7612 * Returns a boolean indicating whether a transform is possible based on |
|
7613 * various bits of context. |
|
7614 * |
|
7615 * @param {Object} transform The transform object to validate. |
|
7616 * @param {string} direction Is this a 'from' or 'to' transform. |
|
7617 * @param {Array} blocks The blocks to transform from. |
|
7618 * |
|
7619 * @return {boolean} Is the transform possible? |
|
7620 */ |
|
7621 |
|
7622 var factory_isPossibleTransformForSource = function isPossibleTransformForSource(transform, direction, blocks) { |
|
7623 if (Object(external_this_lodash_["isEmpty"])(blocks)) { |
|
7624 return false; |
|
7625 } // If multiple blocks are selected, only multi block transforms |
|
7626 // or wildcard transforms are allowed. |
|
7627 |
|
7628 |
|
7629 var isMultiBlock = blocks.length > 1; |
|
7630 var firstBlockName = Object(external_this_lodash_["first"])(blocks).name; |
|
7631 var isValidForMultiBlocks = isWildcardBlockTransform(transform) || !isMultiBlock || transform.isMultiBlock; |
|
7632 |
|
7633 if (!isValidForMultiBlocks) { |
|
7634 return false; |
|
7635 } // Check non-wildcard transforms to ensure that transform is valid |
|
7636 // for a block selection of multiple blocks of different types |
|
7637 |
|
7638 |
|
7639 if (!isWildcardBlockTransform(transform) && !Object(external_this_lodash_["every"])(blocks, { |
|
7640 name: firstBlockName |
|
7641 })) { |
|
7642 return false; |
|
7643 } // Only consider 'block' type transforms as valid. |
|
7644 |
|
7645 |
|
7646 var isBlockType = transform.type === 'block'; |
|
7647 |
|
7648 if (!isBlockType) { |
|
7649 return false; |
|
7650 } // Check if the transform's block name matches the source block (or is a wildcard) |
|
7651 // only if this is a transform 'from'. |
|
7652 |
|
7653 |
|
7654 var sourceBlock = Object(external_this_lodash_["first"])(blocks); |
|
7655 var hasMatchingName = direction !== 'from' || transform.blocks.indexOf(sourceBlock.name) !== -1 || isWildcardBlockTransform(transform); |
|
7656 |
|
7657 if (!hasMatchingName) { |
|
7658 return false; |
|
7659 } // Don't allow single Grouping blocks to be transformed into |
|
7660 // a Grouping block. |
|
7661 |
|
7662 |
|
7663 if (!isMultiBlock && factory_isContainerGroupBlock(sourceBlock.name) && factory_isContainerGroupBlock(transform.blockName)) { |
|
7664 return false; |
|
7665 } // If the transform has a `isMatch` function specified, check that it returns true. |
|
7666 |
|
7667 |
|
7668 if (Object(external_this_lodash_["isFunction"])(transform.isMatch)) { |
|
7669 var attributes = transform.isMultiBlock ? blocks.map(function (block) { |
|
7670 return block.attributes; |
|
7671 }) : sourceBlock.attributes; |
|
7672 |
|
7673 if (!transform.isMatch(attributes)) { |
|
7674 return false; |
|
7675 } |
|
7676 } |
|
7677 |
|
7678 return true; |
|
7679 }; |
|
7680 /** |
|
7681 * Returns block types that the 'blocks' can be transformed into, based on |
|
7682 * 'from' transforms on other blocks. |
|
7683 * |
|
7684 * @param {Array} blocks The blocks to transform from. |
|
7685 * |
|
7686 * @return {Array} Block types that the blocks can be transformed into. |
|
7687 */ |
|
7688 |
|
7689 |
|
7690 var factory_getBlockTypesForPossibleFromTransforms = function getBlockTypesForPossibleFromTransforms(blocks) { |
|
7691 if (Object(external_this_lodash_["isEmpty"])(blocks)) { |
|
7692 return []; |
|
7693 } |
|
7694 |
|
7695 var allBlockTypes = registration_getBlockTypes(); // filter all blocks to find those with a 'from' transform. |
|
7696 |
|
7697 var blockTypesWithPossibleFromTransforms = Object(external_this_lodash_["filter"])(allBlockTypes, function (blockType) { |
|
7698 var fromTransforms = getBlockTransforms('from', blockType.name); |
|
7699 return !!findTransform(fromTransforms, function (transform) { |
|
7700 return factory_isPossibleTransformForSource(transform, 'from', blocks); |
|
7701 }); |
|
7702 }); |
|
7703 return blockTypesWithPossibleFromTransforms; |
|
7704 }; |
|
7705 /** |
|
7706 * Returns block types that the 'blocks' can be transformed into, based on |
|
7707 * the source block's own 'to' transforms. |
|
7708 * |
|
7709 * @param {Array} blocks The blocks to transform from. |
|
7710 * |
|
7711 * @return {Array} Block types that the source can be transformed into. |
|
7712 */ |
|
7713 |
|
7714 |
|
7715 var factory_getBlockTypesForPossibleToTransforms = function getBlockTypesForPossibleToTransforms(blocks) { |
|
7716 if (Object(external_this_lodash_["isEmpty"])(blocks)) { |
|
7717 return []; |
|
7718 } |
|
7719 |
|
7720 var sourceBlock = Object(external_this_lodash_["first"])(blocks); |
|
7721 var blockType = registration_getBlockType(sourceBlock.name); |
|
7722 var transformsTo = getBlockTransforms('to', blockType.name); // filter all 'to' transforms to find those that are possible. |
|
7723 |
|
7724 var possibleTransforms = Object(external_this_lodash_["filter"])(transformsTo, function (transform) { |
|
7725 return transform && factory_isPossibleTransformForSource(transform, 'to', blocks); |
|
7726 }); // Build a list of block names using the possible 'to' transforms. |
|
7727 |
|
7728 var blockNames = Object(external_this_lodash_["flatMap"])(possibleTransforms, function (transformation) { |
|
7729 return transformation.blocks; |
|
7730 }); // Map block names to block types. |
|
7731 |
|
7732 return blockNames.map(function (name) { |
|
7733 return registration_getBlockType(name); |
|
7734 }); |
|
7735 }; |
|
7736 /** |
|
7737 * Determines whether transform is a "block" type |
|
7738 * and if so whether it is a "wildcard" transform |
|
7739 * ie: targets "any" block type |
|
7740 * |
|
7741 * @param {Object} t the Block transform object |
|
7742 * |
|
7743 * @return {boolean} whether transform is a wildcard transform |
|
7744 */ |
|
7745 |
|
7746 |
|
7747 var isWildcardBlockTransform = function isWildcardBlockTransform(t) { |
|
7748 return t && t.type === 'block' && Array.isArray(t.blocks) && t.blocks.includes('*'); |
|
7749 }; |
|
7750 /** |
|
7751 * Determines whether the given Block is the core Block which |
|
7752 * acts as a container Block for other Blocks as part of the |
|
7753 * Grouping mechanics |
|
7754 * |
|
7755 * @param {string} name the name of the Block to test against |
|
7756 * |
|
7757 * @return {boolean} whether or not the Block is the container Block type |
|
7758 */ |
|
7759 |
|
7760 var factory_isContainerGroupBlock = function isContainerGroupBlock(name) { |
|
7761 return name === registration_getGroupingBlockName(); |
|
7762 }; |
|
7763 /** |
|
7764 * Returns an array of block types that the set of blocks received as argument |
|
7765 * can be transformed into. |
|
7766 * |
|
7767 * @param {Array} blocks Blocks array. |
|
7768 * |
|
7769 * @return {Array} Block types that the blocks argument can be transformed to. |
|
7770 */ |
|
7771 |
|
7772 function getPossibleBlockTransformations(blocks) { |
|
7773 if (Object(external_this_lodash_["isEmpty"])(blocks)) { |
|
7774 return []; |
|
7775 } |
|
7776 |
|
7777 var blockTypesForFromTransforms = factory_getBlockTypesForPossibleFromTransforms(blocks); |
|
7778 var blockTypesForToTransforms = factory_getBlockTypesForPossibleToTransforms(blocks); |
|
7779 return Object(external_this_lodash_["uniq"])([].concat(Object(toConsumableArray["a" /* default */])(blockTypesForFromTransforms), Object(toConsumableArray["a" /* default */])(blockTypesForToTransforms))); |
|
7780 } |
|
7781 /** |
|
7782 * Given an array of transforms, returns the highest-priority transform where |
|
7783 * the predicate function returns a truthy value. A higher-priority transform |
|
7784 * is one with a lower priority value (i.e. first in priority order). Returns |
|
7785 * null if the transforms set is empty or the predicate function returns a |
|
7786 * falsey value for all entries. |
|
7787 * |
|
7788 * @param {Object[]} transforms Transforms to search. |
|
7789 * @param {Function} predicate Function returning true on matching transform. |
|
7790 * |
|
7791 * @return {?Object} Highest-priority transform candidate. |
|
7792 */ |
|
7793 |
|
7794 function findTransform(transforms, predicate) { |
|
7795 // The hooks library already has built-in mechanisms for managing priority |
|
7796 // queue, so leverage via locally-defined instance. |
|
7797 var hooks = Object(external_this_wp_hooks_["createHooks"])(); |
|
7798 |
|
7799 var _loop = function _loop(i) { |
|
7800 var candidate = transforms[i]; |
|
7801 |
|
7802 if (predicate(candidate)) { |
|
7803 hooks.addFilter('transform', 'transform/' + i.toString(), function (result) { |
|
7804 return result ? result : candidate; |
|
7805 }, candidate.priority); |
|
7806 } |
|
7807 }; |
|
7808 |
|
7809 for (var i = 0; i < transforms.length; i++) { |
|
7810 _loop(i); |
|
7811 } // Filter name is arbitrarily chosen but consistent with above aggregation. |
|
7812 |
|
7813 |
|
7814 return hooks.applyFilters('transform', null); |
|
7815 } |
|
7816 /** |
|
7817 * Returns normal block transforms for a given transform direction, optionally |
|
7818 * for a specific block by name, or an empty array if there are no transforms. |
|
7819 * If no block name is provided, returns transforms for all blocks. A normal |
|
7820 * transform object includes `blockName` as a property. |
|
7821 * |
|
7822 * @param {string} direction Transform direction ("to", "from"). |
|
7823 * @param {string|Object} blockTypeOrName Block type or name. |
|
7824 * |
|
7825 * @return {Array} Block transforms for direction. |
|
7826 */ |
|
7827 |
|
7828 function getBlockTransforms(direction, blockTypeOrName) { |
|
7829 // When retrieving transforms for all block types, recurse into self. |
|
7830 if (blockTypeOrName === undefined) { |
|
7831 return Object(external_this_lodash_["flatMap"])(registration_getBlockTypes(), function (_ref) { |
|
7832 var name = _ref.name; |
|
7833 return getBlockTransforms(direction, name); |
|
7834 }); |
|
7835 } // Validate that block type exists and has array of direction. |
|
7836 |
|
7837 |
|
7838 var blockType = normalizeBlockType(blockTypeOrName); |
|
7839 |
|
7840 var _ref2 = blockType || {}, |
|
7841 blockName = _ref2.name, |
|
7842 transforms = _ref2.transforms; |
|
7843 |
|
7844 if (!transforms || !Array.isArray(transforms[direction])) { |
|
7845 return []; |
|
7846 } // Map transforms to normal form. |
|
7847 |
|
7848 |
|
7849 return transforms[direction].map(function (transform) { |
|
7850 return factory_objectSpread({}, transform, { |
|
7851 blockName: blockName |
|
7852 }); |
|
7853 }); |
|
7854 } |
|
7855 /** |
|
7856 * Switch one or more blocks into one or more blocks of the new block type. |
|
7857 * |
|
7858 * @param {Array|Object} blocks Blocks array or block object. |
|
7859 * @param {string} name Block name. |
|
7860 * |
|
7861 * @return {?Array} Array of blocks or null. |
|
7862 */ |
|
7863 |
|
7864 function switchToBlockType(blocks, name) { |
|
7865 var blocksArray = Object(external_this_lodash_["castArray"])(blocks); |
|
7866 var isMultiBlock = blocksArray.length > 1; |
|
7867 var firstBlock = blocksArray[0]; |
|
7868 var sourceName = firstBlock.name; // Find the right transformation by giving priority to the "to" |
|
7869 // transformation. |
|
7870 |
|
7871 var transformationsFrom = getBlockTransforms('from', name); |
|
7872 var transformationsTo = getBlockTransforms('to', sourceName); |
|
7873 var transformation = findTransform(transformationsTo, function (t) { |
|
7874 return t.type === 'block' && (isWildcardBlockTransform(t) || t.blocks.indexOf(name) !== -1) && (!isMultiBlock || t.isMultiBlock); |
|
7875 }) || findTransform(transformationsFrom, function (t) { |
|
7876 return t.type === 'block' && (isWildcardBlockTransform(t) || t.blocks.indexOf(sourceName) !== -1) && (!isMultiBlock || t.isMultiBlock); |
|
7877 }); // Stop if there is no valid transformation. |
|
7878 |
|
7879 if (!transformation) { |
|
7880 return null; |
|
7881 } |
|
7882 |
|
7883 var transformationResults; |
|
7884 |
|
7885 if (transformation.isMultiBlock) { |
|
7886 if (Object(external_this_lodash_["has"])(transformation, '__experimentalConvert')) { |
|
7887 transformationResults = transformation.__experimentalConvert(blocksArray); |
|
7888 } else { |
|
7889 transformationResults = transformation.transform(blocksArray.map(function (currentBlock) { |
|
7890 return currentBlock.attributes; |
|
7891 }), blocksArray.map(function (currentBlock) { |
|
7892 return currentBlock.innerBlocks; |
|
7893 })); |
|
7894 } |
|
7895 } else if (Object(external_this_lodash_["has"])(transformation, '__experimentalConvert')) { |
|
7896 transformationResults = transformation.__experimentalConvert(firstBlock); |
|
7897 } else { |
|
7898 transformationResults = transformation.transform(firstBlock.attributes, firstBlock.innerBlocks); |
|
7899 } // Ensure that the transformation function returned an object or an array |
|
7900 // of objects. |
|
7901 |
|
7902 |
|
7903 if (!Object(external_this_lodash_["isObjectLike"])(transformationResults)) { |
|
7904 return null; |
|
7905 } // If the transformation function returned a single object, we want to work |
|
7906 // with an array instead. |
|
7907 |
|
7908 |
|
7909 transformationResults = Object(external_this_lodash_["castArray"])(transformationResults); // Ensure that every block object returned by the transformation has a |
|
7910 // valid block type. |
|
7911 |
|
7912 if (transformationResults.some(function (result) { |
|
7913 return !registration_getBlockType(result.name); |
|
7914 })) { |
|
7915 return null; |
|
7916 } |
|
7917 |
|
7918 var firstSwitchedBlock = Object(external_this_lodash_["findIndex"])(transformationResults, function (result) { |
|
7919 return result.name === name; |
|
7920 }); // Ensure that at least one block object returned by the transformation has |
|
7921 // the expected "destination" block type. |
|
7922 |
|
7923 if (firstSwitchedBlock < 0) { |
|
7924 return null; |
|
7925 } |
|
7926 |
|
7927 return transformationResults.map(function (result, index) { |
|
7928 var transformedBlock = factory_objectSpread({}, result, { |
|
7929 // The first transformed block whose type matches the "destination" |
|
7930 // type gets to keep the existing client ID of the first block. |
|
7931 clientId: index === firstSwitchedBlock ? firstBlock.clientId : result.clientId |
|
7932 }); |
|
7933 /** |
|
7934 * Filters an individual transform result from block transformation. |
|
7935 * All of the original blocks are passed, since transformations are |
|
7936 * many-to-many, not one-to-one. |
|
7937 * |
|
7938 * @param {Object} transformedBlock The transformed block. |
|
7939 * @param {Object[]} blocks Original blocks transformed. |
|
7940 */ |
|
7941 |
|
7942 |
|
7943 return Object(external_this_wp_hooks_["applyFilters"])('blocks.switchToBlockType.transformedBlock', transformedBlock, blocks); |
|
7944 }); |
|
7945 } |
|
7946 /** |
|
7947 * Create a block object from the example API. |
|
7948 * |
|
7949 * @param {string} name |
|
7950 * @param {Object} example |
|
7951 * |
|
7952 * @return {Object} block. |
|
7953 */ |
|
7954 |
|
7955 var factory_getBlockFromExample = function getBlockFromExample(name, example) { |
|
7956 return createBlock(name, example.attributes, Object(external_this_lodash_["map"])(example.innerBlocks, function (innerBlock) { |
|
7957 return getBlockFromExample(innerBlock.name, innerBlock); |
|
7958 })); |
|
7959 }; |
|
7960 |
|
7961 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules |
|
7962 var slicedToArray = __webpack_require__(14); |
|
7963 |
|
7964 // CONCATENATED MODULE: ./node_modules/hpq/es/get-path.js |
|
7965 /** |
|
7966 * Given object and string of dot-delimited path segments, returns value at |
|
7967 * path or undefined if path cannot be resolved. |
|
7968 * |
|
7969 * @param {Object} object Lookup object |
|
7970 * @param {string} path Path to resolve |
|
7971 * @return {?*} Resolved value |
|
7972 */ |
|
7973 function getPath(object, path) { |
|
7974 var segments = path.split('.'); |
|
7975 var segment; |
|
7976 |
|
7977 while (segment = segments.shift()) { |
|
7978 if (!(segment in object)) { |
|
7979 return; |
|
7980 } |
|
7981 |
|
7982 object = object[segment]; |
|
7983 } |
|
7984 |
|
7985 return object; |
|
7986 } |
|
7987 // CONCATENATED MODULE: ./node_modules/hpq/es/index.js |
|
7988 /** |
|
7989 * Internal dependencies |
|
7990 */ |
|
7991 |
|
7992 /** |
|
7993 * Function returning a DOM document created by `createHTMLDocument`. The same |
|
7994 * document is returned between invocations. |
|
7995 * |
|
7996 * @return {Document} DOM document. |
|
7997 */ |
|
7998 |
|
7999 var getDocument = function () { |
|
8000 var doc; |
|
8001 return function () { |
|
8002 if (!doc) { |
|
8003 doc = document.implementation.createHTMLDocument(''); |
|
8004 } |
|
8005 |
|
8006 return doc; |
|
8007 }; |
|
8008 }(); |
|
8009 /** |
|
8010 * Given a markup string or DOM element, creates an object aligning with the |
|
8011 * shape of the matchers object, or the value returned by the matcher. |
|
8012 * |
|
8013 * @param {(string|Element)} source Source content |
|
8014 * @param {(Object|Function)} matchers Matcher function or object of matchers |
|
8015 * @return {(Object|*)} Matched value(s), shaped by object |
|
8016 */ |
|
8017 |
|
8018 |
|
8019 function es_parse(source, matchers) { |
|
8020 if (!matchers) { |
|
8021 return; |
|
8022 } // Coerce to element |
|
8023 |
|
8024 |
|
8025 if ('string' === typeof source) { |
|
8026 var doc = getDocument(); |
|
8027 doc.body.innerHTML = source; |
|
8028 source = doc.body; |
|
8029 } // Return singular value |
|
8030 |
|
8031 |
|
8032 if ('function' === typeof matchers) { |
|
8033 return matchers(source); |
|
8034 } // Bail if we can't handle matchers |
|
8035 |
|
8036 |
|
8037 if (Object !== matchers.constructor) { |
|
8038 return; |
|
8039 } // Shape result by matcher object |
|
8040 |
|
8041 |
|
8042 return Object.keys(matchers).reduce(function (memo, key) { |
|
8043 memo[key] = es_parse(source, matchers[key]); |
|
8044 return memo; |
|
8045 }, {}); |
|
8046 } |
|
8047 /** |
|
8048 * Generates a function which matches node of type selector, returning an |
|
8049 * attribute by property if the attribute exists. If no selector is passed, |
|
8050 * returns property of the query element. |
|
8051 * |
|
8052 * @param {?string} selector Optional selector |
|
8053 * @param {string} name Property name |
|
8054 * @return {*} Property value |
|
8055 */ |
|
8056 |
|
8057 function prop(selector, name) { |
|
8058 if (1 === arguments.length) { |
|
8059 name = selector; |
|
8060 selector = undefined; |
|
8061 } |
|
8062 |
|
8063 return function (node) { |
|
8064 var match = node; |
|
8065 |
|
8066 if (selector) { |
|
8067 match = node.querySelector(selector); |
|
8068 } |
|
8069 |
|
8070 if (match) { |
|
8071 return getPath(match, name); |
|
8072 } |
|
8073 }; |
|
8074 } |
|
8075 /** |
|
8076 * Generates a function which matches node of type selector, returning an |
|
8077 * attribute by name if the attribute exists. If no selector is passed, |
|
8078 * returns attribute of the query element. |
|
8079 * |
|
8080 * @param {?string} selector Optional selector |
|
8081 * @param {string} name Attribute name |
|
8082 * @return {?string} Attribute value |
|
8083 */ |
|
8084 |
|
8085 function attr(selector, name) { |
|
8086 if (1 === arguments.length) { |
|
8087 name = selector; |
|
8088 selector = undefined; |
|
8089 } |
|
8090 |
|
8091 return function (node) { |
|
8092 var attributes = prop(selector, 'attributes')(node); |
|
8093 |
|
8094 if (attributes && attributes.hasOwnProperty(name)) { |
|
8095 return attributes[name].value; |
|
8096 } |
|
8097 }; |
|
8098 } |
|
8099 /** |
|
8100 * Convenience for `prop( selector, 'innerHTML' )`. |
|
8101 * |
|
8102 * @see prop() |
|
8103 * |
|
8104 * @param {?string} selector Optional selector |
|
8105 * @return {string} Inner HTML |
|
8106 */ |
|
8107 |
|
8108 function es_html(selector) { |
|
8109 return prop(selector, 'innerHTML'); |
|
8110 } |
|
8111 /** |
|
8112 * Convenience for `prop( selector, 'textContent' )`. |
|
8113 * |
|
8114 * @see prop() |
|
8115 * |
|
8116 * @param {?string} selector Optional selector |
|
8117 * @return {string} Text content |
|
8118 */ |
|
8119 |
|
8120 function es_text(selector) { |
|
8121 return prop(selector, 'textContent'); |
|
8122 } |
|
8123 /** |
|
8124 * Creates a new matching context by first finding elements matching selector |
|
8125 * using querySelectorAll before then running another `parse` on `matchers` |
|
8126 * scoped to the matched elements. |
|
8127 * |
|
8128 * @see parse() |
|
8129 * |
|
8130 * @param {string} selector Selector to match |
|
8131 * @param {(Object|Function)} matchers Matcher function or object of matchers |
|
8132 * @return {Array.<*,Object>} Array of matched value(s) |
|
8133 */ |
|
8134 |
|
8135 function query(selector, matchers) { |
|
8136 return function (node) { |
|
8137 var matches = node.querySelectorAll(selector); |
|
8138 return [].map.call(matches, function (match) { |
|
8139 return es_parse(match, matchers); |
|
8140 }); |
|
8141 }; |
|
8142 } |
|
8143 // EXTERNAL MODULE: external {"this":["wp","autop"]} |
|
8144 var external_this_wp_autop_ = __webpack_require__(103); |
|
8145 |
|
8146 // EXTERNAL MODULE: external {"this":["wp","blockSerializationDefaultParser"]} |
|
8147 var external_this_wp_blockSerializationDefaultParser_ = __webpack_require__(268); |
|
8148 |
|
8149 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toArray.js |
|
8150 var toArray = __webpack_require__(146); |
|
8151 |
|
8152 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js |
|
8153 var classCallCheck = __webpack_require__(20); |
|
8154 |
|
8155 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js |
|
8156 var createClass = __webpack_require__(19); |
|
8157 |
|
8158 // CONCATENATED MODULE: ./node_modules/simple-html-tokenizer/dist/es6/index.js |
|
8159 /** |
|
8160 * generated from https://raw.githubusercontent.com/w3c/html/26b5126f96f736f796b9e29718138919dd513744/entities.json |
|
8161 * do not edit |
|
8162 */ |
|
8163 var namedCharRefs = { |
|
8164 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" |
|
8165 }; |
|
8166 |
|
8167 var HEXCHARCODE = /^#[xX]([A-Fa-f0-9]+)$/; |
|
8168 var CHARCODE = /^#([0-9]+)$/; |
|
8169 var NAMED = /^([A-Za-z0-9]+)$/; |
|
8170 var EntityParser = /** @class */ (function () { |
|
8171 function EntityParser(named) { |
|
8172 this.named = named; |
|
8173 } |
|
8174 EntityParser.prototype.parse = function (entity) { |
|
8175 if (!entity) { |
|
8176 return; |
|
8177 } |
|
8178 var matches = entity.match(HEXCHARCODE); |
|
8179 if (matches) { |
|
8180 return String.fromCharCode(parseInt(matches[1], 16)); |
|
8181 } |
|
8182 matches = entity.match(CHARCODE); |
|
8183 if (matches) { |
|
8184 return String.fromCharCode(parseInt(matches[1], 10)); |
|
8185 } |
|
8186 matches = entity.match(NAMED); |
|
8187 if (matches) { |
|
8188 return this.named[matches[1]]; |
|
8189 } |
|
8190 }; |
|
8191 return EntityParser; |
|
8192 }()); |
|
8193 |
|
8194 var WSP = /[\t\n\f ]/; |
|
8195 var ALPHA = /[A-Za-z]/; |
|
8196 var CRLF = /\r\n?/g; |
|
8197 function isSpace(char) { |
|
8198 return WSP.test(char); |
|
8199 } |
|
8200 function isAlpha(char) { |
|
8201 return ALPHA.test(char); |
|
8202 } |
|
8203 function preprocessInput(input) { |
|
8204 return input.replace(CRLF, '\n'); |
|
8205 } |
|
8206 |
|
8207 var EventedTokenizer = /** @class */ (function () { |
|
8208 function EventedTokenizer(delegate, entityParser) { |
|
8209 this.delegate = delegate; |
|
8210 this.entityParser = entityParser; |
|
8211 this.state = "beforeData" /* beforeData */; |
|
8212 this.line = -1; |
|
8213 this.column = -1; |
|
8214 this.input = ''; |
|
8215 this.index = -1; |
|
8216 this.tagNameBuffer = ''; |
|
8217 this.states = { |
|
8218 beforeData: function () { |
|
8219 var char = this.peek(); |
|
8220 if (char === '<' && !this.isIgnoredEndTag()) { |
|
8221 this.transitionTo("tagOpen" /* tagOpen */); |
|
8222 this.markTagStart(); |
|
8223 this.consume(); |
|
8224 } |
|
8225 else { |
|
8226 if (char === '\n') { |
|
8227 var tag = this.tagNameBuffer.toLowerCase(); |
|
8228 if (tag === 'pre' || tag === 'textarea') { |
|
8229 this.consume(); |
|
8230 } |
|
8231 } |
|
8232 this.transitionTo("data" /* data */); |
|
8233 this.delegate.beginData(); |
|
8234 } |
|
8235 }, |
|
8236 data: function () { |
|
8237 var char = this.peek(); |
|
8238 var tag = this.tagNameBuffer; |
|
8239 if (char === '<' && !this.isIgnoredEndTag()) { |
|
8240 this.delegate.finishData(); |
|
8241 this.transitionTo("tagOpen" /* tagOpen */); |
|
8242 this.markTagStart(); |
|
8243 this.consume(); |
|
8244 } |
|
8245 else if (char === '&' && tag !== 'script' && tag !== 'style') { |
|
8246 this.consume(); |
|
8247 this.delegate.appendToData(this.consumeCharRef() || '&'); |
|
8248 } |
|
8249 else { |
|
8250 this.consume(); |
|
8251 this.delegate.appendToData(char); |
|
8252 } |
|
8253 }, |
|
8254 tagOpen: function () { |
|
8255 var char = this.consume(); |
|
8256 if (char === '!') { |
|
8257 this.transitionTo("markupDeclarationOpen" /* markupDeclarationOpen */); |
|
8258 } |
|
8259 else if (char === '/') { |
|
8260 this.transitionTo("endTagOpen" /* endTagOpen */); |
|
8261 } |
|
8262 else if (char === '@' || char === ':' || isAlpha(char)) { |
|
8263 this.transitionTo("tagName" /* tagName */); |
|
8264 this.tagNameBuffer = ''; |
|
8265 this.delegate.beginStartTag(); |
|
8266 this.appendToTagName(char); |
|
8267 } |
|
8268 }, |
|
8269 markupDeclarationOpen: function () { |
|
8270 var char = this.consume(); |
|
8271 if (char === '-' && this.peek() === '-') { |
|
8272 this.consume(); |
|
8273 this.transitionTo("commentStart" /* commentStart */); |
|
8274 this.delegate.beginComment(); |
|
8275 } |
|
8276 }, |
|
8277 commentStart: function () { |
|
8278 var char = this.consume(); |
|
8279 if (char === '-') { |
|
8280 this.transitionTo("commentStartDash" /* commentStartDash */); |
|
8281 } |
|
8282 else if (char === '>') { |
|
8283 this.delegate.finishComment(); |
|
8284 this.transitionTo("beforeData" /* beforeData */); |
|
8285 } |
|
8286 else { |
|
8287 this.delegate.appendToCommentData(char); |
|
8288 this.transitionTo("comment" /* comment */); |
|
8289 } |
|
8290 }, |
|
8291 commentStartDash: function () { |
|
8292 var char = this.consume(); |
|
8293 if (char === '-') { |
|
8294 this.transitionTo("commentEnd" /* commentEnd */); |
|
8295 } |
|
8296 else if (char === '>') { |
|
8297 this.delegate.finishComment(); |
|
8298 this.transitionTo("beforeData" /* beforeData */); |
|
8299 } |
|
8300 else { |
|
8301 this.delegate.appendToCommentData('-'); |
|
8302 this.transitionTo("comment" /* comment */); |
|
8303 } |
|
8304 }, |
|
8305 comment: function () { |
|
8306 var char = this.consume(); |
|
8307 if (char === '-') { |
|
8308 this.transitionTo("commentEndDash" /* commentEndDash */); |
|
8309 } |
|
8310 else { |
|
8311 this.delegate.appendToCommentData(char); |
|
8312 } |
|
8313 }, |
|
8314 commentEndDash: function () { |
|
8315 var char = this.consume(); |
|
8316 if (char === '-') { |
|
8317 this.transitionTo("commentEnd" /* commentEnd */); |
|
8318 } |
|
8319 else { |
|
8320 this.delegate.appendToCommentData('-' + char); |
|
8321 this.transitionTo("comment" /* comment */); |
|
8322 } |
|
8323 }, |
|
8324 commentEnd: function () { |
|
8325 var char = this.consume(); |
|
8326 if (char === '>') { |
|
8327 this.delegate.finishComment(); |
|
8328 this.transitionTo("beforeData" /* beforeData */); |
|
8329 } |
|
8330 else { |
|
8331 this.delegate.appendToCommentData('--' + char); |
|
8332 this.transitionTo("comment" /* comment */); |
|
8333 } |
|
8334 }, |
|
8335 tagName: function () { |
|
8336 var char = this.consume(); |
|
8337 if (isSpace(char)) { |
|
8338 this.transitionTo("beforeAttributeName" /* beforeAttributeName */); |
|
8339 } |
|
8340 else if (char === '/') { |
|
8341 this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */); |
|
8342 } |
|
8343 else if (char === '>') { |
|
8344 this.delegate.finishTag(); |
|
8345 this.transitionTo("beforeData" /* beforeData */); |
|
8346 } |
|
8347 else { |
|
8348 this.appendToTagName(char); |
|
8349 } |
|
8350 }, |
|
8351 endTagName: function () { |
|
8352 var char = this.consume(); |
|
8353 if (isSpace(char)) { |
|
8354 this.transitionTo("beforeAttributeName" /* beforeAttributeName */); |
|
8355 this.tagNameBuffer = ''; |
|
8356 } |
|
8357 else if (char === '/') { |
|
8358 this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */); |
|
8359 this.tagNameBuffer = ''; |
|
8360 } |
|
8361 else if (char === '>') { |
|
8362 this.delegate.finishTag(); |
|
8363 this.transitionTo("beforeData" /* beforeData */); |
|
8364 this.tagNameBuffer = ''; |
|
8365 } |
|
8366 else { |
|
8367 this.appendToTagName(char); |
|
8368 } |
|
8369 }, |
|
8370 beforeAttributeName: function () { |
|
8371 var char = this.peek(); |
|
8372 if (isSpace(char)) { |
|
8373 this.consume(); |
|
8374 return; |
|
8375 } |
|
8376 else if (char === '/') { |
|
8377 this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */); |
|
8378 this.consume(); |
|
8379 } |
|
8380 else if (char === '>') { |
|
8381 this.consume(); |
|
8382 this.delegate.finishTag(); |
|
8383 this.transitionTo("beforeData" /* beforeData */); |
|
8384 } |
|
8385 else if (char === '=') { |
|
8386 this.delegate.reportSyntaxError('attribute name cannot start with equals sign'); |
|
8387 this.transitionTo("attributeName" /* attributeName */); |
|
8388 this.delegate.beginAttribute(); |
|
8389 this.consume(); |
|
8390 this.delegate.appendToAttributeName(char); |
|
8391 } |
|
8392 else { |
|
8393 this.transitionTo("attributeName" /* attributeName */); |
|
8394 this.delegate.beginAttribute(); |
|
8395 } |
|
8396 }, |
|
8397 attributeName: function () { |
|
8398 var char = this.peek(); |
|
8399 if (isSpace(char)) { |
|
8400 this.transitionTo("afterAttributeName" /* afterAttributeName */); |
|
8401 this.consume(); |
|
8402 } |
|
8403 else if (char === '/') { |
|
8404 this.delegate.beginAttributeValue(false); |
|
8405 this.delegate.finishAttributeValue(); |
|
8406 this.consume(); |
|
8407 this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */); |
|
8408 } |
|
8409 else if (char === '=') { |
|
8410 this.transitionTo("beforeAttributeValue" /* beforeAttributeValue */); |
|
8411 this.consume(); |
|
8412 } |
|
8413 else if (char === '>') { |
|
8414 this.delegate.beginAttributeValue(false); |
|
8415 this.delegate.finishAttributeValue(); |
|
8416 this.consume(); |
|
8417 this.delegate.finishTag(); |
|
8418 this.transitionTo("beforeData" /* beforeData */); |
|
8419 } |
|
8420 else if (char === '"' || char === "'" || char === '<') { |
|
8421 this.delegate.reportSyntaxError(char + ' is not a valid character within attribute names'); |
|
8422 this.consume(); |
|
8423 this.delegate.appendToAttributeName(char); |
|
8424 } |
|
8425 else { |
|
8426 this.consume(); |
|
8427 this.delegate.appendToAttributeName(char); |
|
8428 } |
|
8429 }, |
|
8430 afterAttributeName: function () { |
|
8431 var char = this.peek(); |
|
8432 if (isSpace(char)) { |
|
8433 this.consume(); |
|
8434 return; |
|
8435 } |
|
8436 else if (char === '/') { |
|
8437 this.delegate.beginAttributeValue(false); |
|
8438 this.delegate.finishAttributeValue(); |
|
8439 this.consume(); |
|
8440 this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */); |
|
8441 } |
|
8442 else if (char === '=') { |
|
8443 this.consume(); |
|
8444 this.transitionTo("beforeAttributeValue" /* beforeAttributeValue */); |
|
8445 } |
|
8446 else if (char === '>') { |
|
8447 this.delegate.beginAttributeValue(false); |
|
8448 this.delegate.finishAttributeValue(); |
|
8449 this.consume(); |
|
8450 this.delegate.finishTag(); |
|
8451 this.transitionTo("beforeData" /* beforeData */); |
|
8452 } |
|
8453 else { |
|
8454 this.delegate.beginAttributeValue(false); |
|
8455 this.delegate.finishAttributeValue(); |
|
8456 this.transitionTo("attributeName" /* attributeName */); |
|
8457 this.delegate.beginAttribute(); |
|
8458 this.consume(); |
|
8459 this.delegate.appendToAttributeName(char); |
|
8460 } |
|
8461 }, |
|
8462 beforeAttributeValue: function () { |
|
8463 var char = this.peek(); |
|
8464 if (isSpace(char)) { |
|
8465 this.consume(); |
|
8466 } |
|
8467 else if (char === '"') { |
|
8468 this.transitionTo("attributeValueDoubleQuoted" /* attributeValueDoubleQuoted */); |
|
8469 this.delegate.beginAttributeValue(true); |
|
8470 this.consume(); |
|
8471 } |
|
8472 else if (char === "'") { |
|
8473 this.transitionTo("attributeValueSingleQuoted" /* attributeValueSingleQuoted */); |
|
8474 this.delegate.beginAttributeValue(true); |
|
8475 this.consume(); |
|
8476 } |
|
8477 else if (char === '>') { |
|
8478 this.delegate.beginAttributeValue(false); |
|
8479 this.delegate.finishAttributeValue(); |
|
8480 this.consume(); |
|
8481 this.delegate.finishTag(); |
|
8482 this.transitionTo("beforeData" /* beforeData */); |
|
8483 } |
|
8484 else { |
|
8485 this.transitionTo("attributeValueUnquoted" /* attributeValueUnquoted */); |
|
8486 this.delegate.beginAttributeValue(false); |
|
8487 this.consume(); |
|
8488 this.delegate.appendToAttributeValue(char); |
|
8489 } |
|
8490 }, |
|
8491 attributeValueDoubleQuoted: function () { |
|
8492 var char = this.consume(); |
|
8493 if (char === '"') { |
|
8494 this.delegate.finishAttributeValue(); |
|
8495 this.transitionTo("afterAttributeValueQuoted" /* afterAttributeValueQuoted */); |
|
8496 } |
|
8497 else if (char === '&') { |
|
8498 this.delegate.appendToAttributeValue(this.consumeCharRef() || '&'); |
|
8499 } |
|
8500 else { |
|
8501 this.delegate.appendToAttributeValue(char); |
|
8502 } |
|
8503 }, |
|
8504 attributeValueSingleQuoted: function () { |
|
8505 var char = this.consume(); |
|
8506 if (char === "'") { |
|
8507 this.delegate.finishAttributeValue(); |
|
8508 this.transitionTo("afterAttributeValueQuoted" /* afterAttributeValueQuoted */); |
|
8509 } |
|
8510 else if (char === '&') { |
|
8511 this.delegate.appendToAttributeValue(this.consumeCharRef() || '&'); |
|
8512 } |
|
8513 else { |
|
8514 this.delegate.appendToAttributeValue(char); |
|
8515 } |
|
8516 }, |
|
8517 attributeValueUnquoted: function () { |
|
8518 var char = this.peek(); |
|
8519 if (isSpace(char)) { |
|
8520 this.delegate.finishAttributeValue(); |
|
8521 this.consume(); |
|
8522 this.transitionTo("beforeAttributeName" /* beforeAttributeName */); |
|
8523 } |
|
8524 else if (char === '/') { |
|
8525 this.delegate.finishAttributeValue(); |
|
8526 this.consume(); |
|
8527 this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */); |
|
8528 } |
|
8529 else if (char === '&') { |
|
8530 this.consume(); |
|
8531 this.delegate.appendToAttributeValue(this.consumeCharRef() || '&'); |
|
8532 } |
|
8533 else if (char === '>') { |
|
8534 this.delegate.finishAttributeValue(); |
|
8535 this.consume(); |
|
8536 this.delegate.finishTag(); |
|
8537 this.transitionTo("beforeData" /* beforeData */); |
|
8538 } |
|
8539 else { |
|
8540 this.consume(); |
|
8541 this.delegate.appendToAttributeValue(char); |
|
8542 } |
|
8543 }, |
|
8544 afterAttributeValueQuoted: function () { |
|
8545 var char = this.peek(); |
|
8546 if (isSpace(char)) { |
|
8547 this.consume(); |
|
8548 this.transitionTo("beforeAttributeName" /* beforeAttributeName */); |
|
8549 } |
|
8550 else if (char === '/') { |
|
8551 this.consume(); |
|
8552 this.transitionTo("selfClosingStartTag" /* selfClosingStartTag */); |
|
8553 } |
|
8554 else if (char === '>') { |
|
8555 this.consume(); |
|
8556 this.delegate.finishTag(); |
|
8557 this.transitionTo("beforeData" /* beforeData */); |
|
8558 } |
|
8559 else { |
|
8560 this.transitionTo("beforeAttributeName" /* beforeAttributeName */); |
|
8561 } |
|
8562 }, |
|
8563 selfClosingStartTag: function () { |
|
8564 var char = this.peek(); |
|
8565 if (char === '>') { |
|
8566 this.consume(); |
|
8567 this.delegate.markTagAsSelfClosing(); |
|
8568 this.delegate.finishTag(); |
|
8569 this.transitionTo("beforeData" /* beforeData */); |
|
8570 } |
|
8571 else { |
|
8572 this.transitionTo("beforeAttributeName" /* beforeAttributeName */); |
|
8573 } |
|
8574 }, |
|
8575 endTagOpen: function () { |
|
8576 var char = this.consume(); |
|
8577 if (char === '@' || char === ':' || isAlpha(char)) { |
|
8578 this.transitionTo("endTagName" /* endTagName */); |
|
8579 this.tagNameBuffer = ''; |
|
8580 this.delegate.beginEndTag(); |
|
8581 this.appendToTagName(char); |
|
8582 } |
|
8583 } |
|
8584 }; |
|
8585 this.reset(); |
|
8586 } |
|
8587 EventedTokenizer.prototype.reset = function () { |
|
8588 this.transitionTo("beforeData" /* beforeData */); |
|
8589 this.input = ''; |
|
8590 this.tagNameBuffer = ''; |
|
8591 this.index = 0; |
|
8592 this.line = 1; |
|
8593 this.column = 0; |
|
8594 this.delegate.reset(); |
|
8595 }; |
|
8596 EventedTokenizer.prototype.transitionTo = function (state) { |
|
8597 this.state = state; |
|
8598 }; |
|
8599 EventedTokenizer.prototype.tokenize = function (input) { |
|
8600 this.reset(); |
|
8601 this.tokenizePart(input); |
|
8602 this.tokenizeEOF(); |
|
8603 }; |
|
8604 EventedTokenizer.prototype.tokenizePart = function (input) { |
|
8605 this.input += preprocessInput(input); |
|
8606 while (this.index < this.input.length) { |
|
8607 var handler = this.states[this.state]; |
|
8608 if (handler !== undefined) { |
|
8609 handler.call(this); |
|
8610 } |
|
8611 else { |
|
8612 throw new Error("unhandled state " + this.state); |
|
8613 } |
|
8614 } |
|
8615 }; |
|
8616 EventedTokenizer.prototype.tokenizeEOF = function () { |
|
8617 this.flushData(); |
|
8618 }; |
|
8619 EventedTokenizer.prototype.flushData = function () { |
|
8620 if (this.state === 'data') { |
|
8621 this.delegate.finishData(); |
|
8622 this.transitionTo("beforeData" /* beforeData */); |
|
8623 } |
|
8624 }; |
|
8625 EventedTokenizer.prototype.peek = function () { |
|
8626 return this.input.charAt(this.index); |
|
8627 }; |
|
8628 EventedTokenizer.prototype.consume = function () { |
|
8629 var char = this.peek(); |
|
8630 this.index++; |
|
8631 if (char === '\n') { |
|
8632 this.line++; |
|
8633 this.column = 0; |
|
8634 } |
|
8635 else { |
|
8636 this.column++; |
|
8637 } |
|
8638 return char; |
|
8639 }; |
|
8640 EventedTokenizer.prototype.consumeCharRef = function () { |
|
8641 var endIndex = this.input.indexOf(';', this.index); |
|
8642 if (endIndex === -1) { |
|
8643 return; |
|
8644 } |
|
8645 var entity = this.input.slice(this.index, endIndex); |
|
8646 var chars = this.entityParser.parse(entity); |
|
8647 if (chars) { |
|
8648 var count = entity.length; |
|
8649 // consume the entity chars |
|
8650 while (count) { |
|
8651 this.consume(); |
|
8652 count--; |
|
8653 } |
|
8654 // consume the `;` |
|
8655 this.consume(); |
|
8656 return chars; |
|
8657 } |
|
8658 }; |
|
8659 EventedTokenizer.prototype.markTagStart = function () { |
|
8660 this.delegate.tagOpen(); |
|
8661 }; |
|
8662 EventedTokenizer.prototype.appendToTagName = function (char) { |
|
8663 this.tagNameBuffer += char; |
|
8664 this.delegate.appendToTagName(char); |
|
8665 }; |
|
8666 EventedTokenizer.prototype.isIgnoredEndTag = function () { |
|
8667 var tag = this.tagNameBuffer; |
|
8668 return (tag === 'title' && this.input.substring(this.index, this.index + 8) !== '</title>') || |
|
8669 (tag === 'style' && this.input.substring(this.index, this.index + 8) !== '</style>') || |
|
8670 (tag === 'script' && this.input.substring(this.index, this.index + 9) !== '</script>'); |
|
8671 }; |
|
8672 return EventedTokenizer; |
|
8673 }()); |
|
8674 |
|
8675 var Tokenizer = /** @class */ (function () { |
|
8676 function Tokenizer(entityParser, options) { |
|
8677 if (options === void 0) { options = {}; } |
|
8678 this.options = options; |
|
8679 this.token = null; |
|
8680 this.startLine = 1; |
|
8681 this.startColumn = 0; |
|
8682 this.tokens = []; |
|
8683 this.tokenizer = new EventedTokenizer(this, entityParser); |
|
8684 this._currentAttribute = undefined; |
|
8685 } |
|
8686 Tokenizer.prototype.tokenize = function (input) { |
|
8687 this.tokens = []; |
|
8688 this.tokenizer.tokenize(input); |
|
8689 return this.tokens; |
|
8690 }; |
|
8691 Tokenizer.prototype.tokenizePart = function (input) { |
|
8692 this.tokens = []; |
|
8693 this.tokenizer.tokenizePart(input); |
|
8694 return this.tokens; |
|
8695 }; |
|
8696 Tokenizer.prototype.tokenizeEOF = function () { |
|
8697 this.tokens = []; |
|
8698 this.tokenizer.tokenizeEOF(); |
|
8699 return this.tokens[0]; |
|
8700 }; |
|
8701 Tokenizer.prototype.reset = function () { |
|
8702 this.token = null; |
|
8703 this.startLine = 1; |
|
8704 this.startColumn = 0; |
|
8705 }; |
|
8706 Tokenizer.prototype.current = function () { |
|
8707 var token = this.token; |
|
8708 if (token === null) { |
|
8709 throw new Error('token was unexpectedly null'); |
|
8710 } |
|
8711 if (arguments.length === 0) { |
|
8712 return token; |
|
8713 } |
|
8714 for (var i = 0; i < arguments.length; i++) { |
|
8715 if (token.type === arguments[i]) { |
|
8716 return token; |
|
8717 } |
|
8718 } |
|
8719 throw new Error("token type was unexpectedly " + token.type); |
|
8720 }; |
|
8721 Tokenizer.prototype.push = function (token) { |
|
8722 this.token = token; |
|
8723 this.tokens.push(token); |
|
8724 }; |
|
8725 Tokenizer.prototype.currentAttribute = function () { |
|
8726 return this._currentAttribute; |
|
8727 }; |
|
8728 Tokenizer.prototype.addLocInfo = function () { |
|
8729 if (this.options.loc) { |
|
8730 this.current().loc = { |
|
8731 start: { |
|
8732 line: this.startLine, |
|
8733 column: this.startColumn |
|
8734 }, |
|
8735 end: { |
|
8736 line: this.tokenizer.line, |
|
8737 column: this.tokenizer.column |
|
8738 } |
|
8739 }; |
|
8740 } |
|
8741 this.startLine = this.tokenizer.line; |
|
8742 this.startColumn = this.tokenizer.column; |
|
8743 }; |
|
8744 // Data |
|
8745 Tokenizer.prototype.beginData = function () { |
|
8746 this.push({ |
|
8747 type: "Chars" /* Chars */, |
|
8748 chars: '' |
|
8749 }); |
|
8750 }; |
|
8751 Tokenizer.prototype.appendToData = function (char) { |
|
8752 this.current("Chars" /* Chars */).chars += char; |
|
8753 }; |
|
8754 Tokenizer.prototype.finishData = function () { |
|
8755 this.addLocInfo(); |
|
8756 }; |
|
8757 // Comment |
|
8758 Tokenizer.prototype.beginComment = function () { |
|
8759 this.push({ |
|
8760 type: "Comment" /* Comment */, |
|
8761 chars: '' |
|
8762 }); |
|
8763 }; |
|
8764 Tokenizer.prototype.appendToCommentData = function (char) { |
|
8765 this.current("Comment" /* Comment */).chars += char; |
|
8766 }; |
|
8767 Tokenizer.prototype.finishComment = function () { |
|
8768 this.addLocInfo(); |
|
8769 }; |
|
8770 // Tags - basic |
|
8771 Tokenizer.prototype.tagOpen = function () { }; |
|
8772 Tokenizer.prototype.beginStartTag = function () { |
|
8773 this.push({ |
|
8774 type: "StartTag" /* StartTag */, |
|
8775 tagName: '', |
|
8776 attributes: [], |
|
8777 selfClosing: false |
|
8778 }); |
|
8779 }; |
|
8780 Tokenizer.prototype.beginEndTag = function () { |
|
8781 this.push({ |
|
8782 type: "EndTag" /* EndTag */, |
|
8783 tagName: '' |
|
8784 }); |
|
8785 }; |
|
8786 Tokenizer.prototype.finishTag = function () { |
|
8787 this.addLocInfo(); |
|
8788 }; |
|
8789 Tokenizer.prototype.markTagAsSelfClosing = function () { |
|
8790 this.current("StartTag" /* StartTag */).selfClosing = true; |
|
8791 }; |
|
8792 // Tags - name |
|
8793 Tokenizer.prototype.appendToTagName = function (char) { |
|
8794 this.current("StartTag" /* StartTag */, "EndTag" /* EndTag */).tagName += char; |
|
8795 }; |
|
8796 // Tags - attributes |
|
8797 Tokenizer.prototype.beginAttribute = function () { |
|
8798 this._currentAttribute = ['', '', false]; |
|
8799 }; |
|
8800 Tokenizer.prototype.appendToAttributeName = function (char) { |
|
8801 this.currentAttribute()[0] += char; |
|
8802 }; |
|
8803 Tokenizer.prototype.beginAttributeValue = function (isQuoted) { |
|
8804 this.currentAttribute()[2] = isQuoted; |
|
8805 }; |
|
8806 Tokenizer.prototype.appendToAttributeValue = function (char) { |
|
8807 this.currentAttribute()[1] += char; |
|
8808 }; |
|
8809 Tokenizer.prototype.finishAttributeValue = function () { |
|
8810 this.current("StartTag" /* StartTag */).attributes.push(this._currentAttribute); |
|
8811 }; |
|
8812 Tokenizer.prototype.reportSyntaxError = function (message) { |
|
8813 this.current().syntaxError = message; |
|
8814 }; |
|
8815 return Tokenizer; |
|
8816 }()); |
|
8817 |
|
8818 function tokenize(input, options) { |
|
8819 var tokenizer = new Tokenizer(new EntityParser(namedCharRefs), options); |
|
8820 return tokenizer.tokenize(input); |
|
8821 } |
|
8822 |
|
8823 |
|
8824 |
|
8825 // EXTERNAL MODULE: external {"this":["wp","htmlEntities"]} |
|
8826 var external_this_wp_htmlEntities_ = __webpack_require__(75); |
|
8827 |
|
8828 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/validation/logger.js |
|
8829 function createLogger() { |
|
8830 /** |
|
8831 * Creates a log handler with block validation prefix. |
|
8832 * |
|
8833 * @param {Function} logger Original logger function. |
|
8834 * |
|
8835 * @return {Function} Augmented logger function. |
|
8836 */ |
|
8837 function createLogHandler(logger) { |
|
8838 var log = function log(message) { |
|
8839 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
|
8840 args[_key - 1] = arguments[_key]; |
|
8841 } |
|
8842 |
|
8843 return logger.apply(void 0, ['Block validation: ' + message].concat(args)); |
|
8844 }; // In test environments, pre-process the sprintf message to improve |
|
8845 // readability of error messages. We'd prefer to avoid pulling in this |
|
8846 // dependency in runtime environments, and it can be dropped by a combo |
|
8847 // of Webpack env substitution + UglifyJS dead code elimination. |
|
8848 |
|
8849 |
|
8850 if (false) {} |
|
8851 |
|
8852 return log; |
|
8853 } |
|
8854 |
|
8855 return { |
|
8856 // eslint-disable-next-line no-console |
|
8857 error: createLogHandler(console.error), |
|
8858 // eslint-disable-next-line no-console |
|
8859 warning: createLogHandler(console.warn), |
|
8860 getItems: function getItems() { |
|
8861 return []; |
|
8862 } |
|
8863 }; |
|
8864 } |
|
8865 function createQueuedLogger() { |
|
8866 /** |
|
8867 * The list of enqueued log actions to print. |
|
8868 * |
|
8869 * @type {Array} |
|
8870 */ |
|
8871 var queue = []; |
|
8872 var logger = createLogger(); |
|
8873 return { |
|
8874 error: function error() { |
|
8875 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { |
|
8876 args[_key2] = arguments[_key2]; |
|
8877 } |
|
8878 |
|
8879 queue.push({ |
|
8880 log: logger.error, |
|
8881 args: args |
|
8882 }); |
|
8883 }, |
|
8884 warning: function warning() { |
|
8885 for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { |
|
8886 args[_key3] = arguments[_key3]; |
|
8887 } |
|
8888 |
|
8889 queue.push({ |
|
8890 log: logger.warning, |
|
8891 args: args |
|
8892 }); |
|
8893 }, |
|
8894 getItems: function getItems() { |
|
8895 return queue; |
|
8896 } |
|
8897 }; |
|
8898 } |
|
8899 |
|
8900 // EXTERNAL MODULE: external {"this":["wp","isShallowEqual"]} |
|
8901 var external_this_wp_isShallowEqual_ = __webpack_require__(64); |
|
8902 var external_this_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_isShallowEqual_); |
|
8903 |
|
8904 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js |
|
8905 var esm_extends = __webpack_require__(8); |
|
8906 |
|
8907 // EXTERNAL MODULE: external {"this":["wp","compose"]} |
|
8908 var external_this_wp_compose_ = __webpack_require__(9); |
|
8909 |
|
8910 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/block-content-provider/index.js |
|
8911 |
|
8912 |
|
8913 |
|
8914 /** |
|
8915 * WordPress dependencies |
|
8916 */ |
|
8917 |
|
8918 |
|
8919 /** |
|
8920 * Internal dependencies |
|
8921 */ |
|
8922 |
|
8923 |
|
8924 |
|
8925 var _createContext = Object(external_this_wp_element_["createContext"])(function () {}), |
|
8926 Consumer = _createContext.Consumer, |
|
8927 Provider = _createContext.Provider; |
|
8928 /** |
|
8929 * An internal block component used in block content serialization to inject |
|
8930 * nested block content within the `save` implementation of the ancestor |
|
8931 * component in which it is nested. The component provides a pre-bound |
|
8932 * `BlockContent` component via context, which is used by the developer-facing |
|
8933 * `InnerBlocks.Content` component to render block content. |
|
8934 * |
|
8935 * @example |
|
8936 * |
|
8937 * ```jsx |
|
8938 * <BlockContentProvider innerBlocks={ innerBlocks }> |
|
8939 * { blockSaveElement } |
|
8940 * </BlockContentProvider> |
|
8941 * ``` |
|
8942 * |
|
8943 * @param {Object} props Component props. |
|
8944 * @param {WPElement} props.children Block save result. |
|
8945 * @param {Array} props.innerBlocks Block(s) to serialize. |
|
8946 * |
|
8947 * @return {WPComponent} Element with BlockContent injected via context. |
|
8948 */ |
|
8949 |
|
8950 |
|
8951 var block_content_provider_BlockContentProvider = function BlockContentProvider(_ref) { |
|
8952 var children = _ref.children, |
|
8953 innerBlocks = _ref.innerBlocks; |
|
8954 |
|
8955 var BlockContent = function BlockContent() { |
|
8956 // Value is an array of blocks, so defer to block serializer |
|
8957 var html = serialize(innerBlocks, { |
|
8958 isInnerBlocks: true |
|
8959 }); // Use special-cased raw HTML tag to avoid default escaping |
|
8960 |
|
8961 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["RawHTML"], null, html); |
|
8962 }; |
|
8963 |
|
8964 return Object(external_this_wp_element_["createElement"])(Provider, { |
|
8965 value: BlockContent |
|
8966 }, children); |
|
8967 }; |
|
8968 /** |
|
8969 * A Higher Order Component used to inject BlockContent using context to the |
|
8970 * wrapped component. |
|
8971 * |
|
8972 * @return {WPComponent} Enhanced component with injected BlockContent as prop. |
|
8973 */ |
|
8974 |
|
8975 |
|
8976 var withBlockContentContext = Object(external_this_wp_compose_["createHigherOrderComponent"])(function (OriginalComponent) { |
|
8977 return function (props) { |
|
8978 return Object(external_this_wp_element_["createElement"])(Consumer, null, function (context) { |
|
8979 return Object(external_this_wp_element_["createElement"])(OriginalComponent, Object(esm_extends["a" /* default */])({}, props, { |
|
8980 BlockContent: context |
|
8981 })); |
|
8982 }); |
|
8983 }; |
|
8984 }, 'withBlockContentContext'); |
|
8985 /* harmony default export */ var block_content_provider = (block_content_provider_BlockContentProvider); |
|
8986 |
|
8987 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/serializer.js |
|
8988 |
|
8989 |
|
8990 |
|
8991 function serializer_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
8992 |
|
8993 function serializer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { serializer_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { serializer_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
8994 |
|
8995 /** |
|
8996 * External dependencies |
|
8997 */ |
|
8998 |
|
8999 /** |
|
9000 * WordPress dependencies |
|
9001 */ |
|
9002 |
|
9003 |
|
9004 |
|
9005 |
|
9006 /** |
|
9007 * Internal dependencies |
|
9008 */ |
|
9009 |
|
9010 |
|
9011 |
|
9012 |
|
9013 /** |
|
9014 * @typedef {Object} WPBlockSerializationOptions Serialization Options. |
|
9015 * |
|
9016 * @property {boolean} isInnerBlocks Whether we are serializing inner blocks. |
|
9017 */ |
|
9018 |
|
9019 /** |
|
9020 * Returns the block's default classname from its name. |
|
9021 * |
|
9022 * @param {string} blockName The block name. |
|
9023 * |
|
9024 * @return {string} The block's default class. |
|
9025 */ |
|
9026 |
|
9027 function getBlockDefaultClassName(blockName) { |
|
9028 // Generated HTML classes for blocks follow the `wp-block-{name}` nomenclature. |
|
9029 // Blocks provided by WordPress drop the prefixes 'core/' or 'core-' (used in 'core-embed/'). |
|
9030 var className = 'wp-block-' + blockName.replace(/\//, '-').replace(/^core-/, ''); |
|
9031 return Object(external_this_wp_hooks_["applyFilters"])('blocks.getBlockDefaultClassName', className, blockName); |
|
9032 } |
|
9033 /** |
|
9034 * Returns the block's default menu item classname from its name. |
|
9035 * |
|
9036 * @param {string} blockName The block name. |
|
9037 * |
|
9038 * @return {string} The block's default menu item class. |
|
9039 */ |
|
9040 |
|
9041 function getBlockMenuDefaultClassName(blockName) { |
|
9042 // Generated HTML classes for blocks follow the `editor-block-list-item-{name}` nomenclature. |
|
9043 // Blocks provided by WordPress drop the prefixes 'core/' or 'core-' (used in 'core-embed/'). |
|
9044 var className = 'editor-block-list-item-' + blockName.replace(/\//, '-').replace(/^core-/, ''); |
|
9045 return Object(external_this_wp_hooks_["applyFilters"])('blocks.getBlockMenuDefaultClassName', className, blockName); |
|
9046 } |
|
9047 /** |
|
9048 * Given a block type containing a save render implementation and attributes, returns the |
|
9049 * enhanced element to be saved or string when raw HTML expected. |
|
9050 * |
|
9051 * @param {string|Object} blockTypeOrName Block type or name. |
|
9052 * @param {Object} attributes Block attributes. |
|
9053 * @param {?Array} innerBlocks Nested blocks. |
|
9054 * |
|
9055 * @return {Object|string} Save element or raw HTML string. |
|
9056 */ |
|
9057 |
|
9058 function getSaveElement(blockTypeOrName, attributes) { |
|
9059 var innerBlocks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; |
|
9060 var blockType = normalizeBlockType(blockTypeOrName); |
|
9061 var save = blockType.save; // Component classes are unsupported for save since serialization must |
|
9062 // occur synchronously. For improved interoperability with higher-order |
|
9063 // components which often return component class, emulate basic support. |
|
9064 |
|
9065 if (save.prototype instanceof external_this_wp_element_["Component"]) { |
|
9066 var instance = new save({ |
|
9067 attributes: attributes |
|
9068 }); |
|
9069 save = instance.render.bind(instance); |
|
9070 } |
|
9071 |
|
9072 var element = save({ |
|
9073 attributes: attributes, |
|
9074 innerBlocks: innerBlocks |
|
9075 }); |
|
9076 |
|
9077 if (Object(external_this_lodash_["isObject"])(element) && Object(external_this_wp_hooks_["hasFilter"])('blocks.getSaveContent.extraProps')) { |
|
9078 /** |
|
9079 * Filters the props applied to the block save result element. |
|
9080 * |
|
9081 * @param {Object} props Props applied to save element. |
|
9082 * @param {WPBlock} blockType Block type definition. |
|
9083 * @param {Object} attributes Block attributes. |
|
9084 */ |
|
9085 var props = Object(external_this_wp_hooks_["applyFilters"])('blocks.getSaveContent.extraProps', serializer_objectSpread({}, element.props), blockType, attributes); |
|
9086 |
|
9087 if (!external_this_wp_isShallowEqual_default()(props, element.props)) { |
|
9088 element = Object(external_this_wp_element_["cloneElement"])(element, props); |
|
9089 } |
|
9090 } |
|
9091 /** |
|
9092 * Filters the save result of a block during serialization. |
|
9093 * |
|
9094 * @param {WPElement} element Block save result. |
|
9095 * @param {WPBlock} blockType Block type definition. |
|
9096 * @param {Object} attributes Block attributes. |
|
9097 */ |
|
9098 |
|
9099 |
|
9100 element = Object(external_this_wp_hooks_["applyFilters"])('blocks.getSaveElement', element, blockType, attributes); |
|
9101 return Object(external_this_wp_element_["createElement"])(block_content_provider, { |
|
9102 innerBlocks: innerBlocks |
|
9103 }, element); |
|
9104 } |
|
9105 /** |
|
9106 * Given a block type containing a save render implementation and attributes, returns the |
|
9107 * static markup to be saved. |
|
9108 * |
|
9109 * @param {string|Object} blockTypeOrName Block type or name. |
|
9110 * @param {Object} attributes Block attributes. |
|
9111 * @param {?Array} innerBlocks Nested blocks. |
|
9112 * |
|
9113 * @return {string} Save content. |
|
9114 */ |
|
9115 |
|
9116 function getSaveContent(blockTypeOrName, attributes, innerBlocks) { |
|
9117 var blockType = normalizeBlockType(blockTypeOrName); |
|
9118 return Object(external_this_wp_element_["renderToString"])(getSaveElement(blockType, attributes, innerBlocks)); |
|
9119 } |
|
9120 /** |
|
9121 * Returns attributes which are to be saved and serialized into the block |
|
9122 * comment delimiter. |
|
9123 * |
|
9124 * When a block exists in memory it contains as its attributes both those |
|
9125 * parsed the block comment delimiter _and_ those which matched from the |
|
9126 * contents of the block. |
|
9127 * |
|
9128 * This function returns only those attributes which are needed to persist and |
|
9129 * which cannot be matched from the block content. |
|
9130 * |
|
9131 * @param {Object<string,*>} blockType Block type. |
|
9132 * @param {Object<string,*>} attributes Attributes from in-memory block data. |
|
9133 * |
|
9134 * @return {Object<string,*>} Subset of attributes for comment serialization. |
|
9135 */ |
|
9136 |
|
9137 function getCommentAttributes(blockType, attributes) { |
|
9138 return Object(external_this_lodash_["reduce"])(blockType.attributes, function (accumulator, attributeSchema, key) { |
|
9139 var value = attributes[key]; // Ignore undefined values. |
|
9140 |
|
9141 if (undefined === value) { |
|
9142 return accumulator; |
|
9143 } // Ignore all attributes but the ones with an "undefined" source |
|
9144 // "undefined" source refers to attributes saved in the block comment. |
|
9145 |
|
9146 |
|
9147 if (attributeSchema.source !== undefined) { |
|
9148 return accumulator; |
|
9149 } // Ignore default value. |
|
9150 |
|
9151 |
|
9152 if ('default' in attributeSchema && attributeSchema.default === value) { |
|
9153 return accumulator; |
|
9154 } // Otherwise, include in comment set. |
|
9155 |
|
9156 |
|
9157 accumulator[key] = value; |
|
9158 return accumulator; |
|
9159 }, {}); |
|
9160 } |
|
9161 /** |
|
9162 * Given an attributes object, returns a string in the serialized attributes |
|
9163 * format prepared for post content. |
|
9164 * |
|
9165 * @param {Object} attributes Attributes object. |
|
9166 * |
|
9167 * @return {string} Serialized attributes. |
|
9168 */ |
|
9169 |
|
9170 function serializeAttributes(attributes) { |
|
9171 return JSON.stringify(attributes) // Don't break HTML comments. |
|
9172 .replace(/--/g, "\\u002d\\u002d") // Don't break non-standard-compliant tools. |
|
9173 .replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/&/g, "\\u0026") // Bypass server stripslashes behavior which would unescape stringify's |
|
9174 // escaping of quotation mark. |
|
9175 // |
|
9176 // See: https://developer.wordpress.org/reference/functions/wp_kses_stripslashes/ |
|
9177 .replace(/\\"/g, "\\u0022"); |
|
9178 } |
|
9179 /** |
|
9180 * Given a block object, returns the Block's Inner HTML markup. |
|
9181 * |
|
9182 * @param {Object} block Block instance. |
|
9183 * |
|
9184 * @return {string} HTML. |
|
9185 */ |
|
9186 |
|
9187 function getBlockContent(block) { |
|
9188 // @todo why not getBlockInnerHtml? |
|
9189 // If block was parsed as invalid or encounters an error while generating |
|
9190 // save content, use original content instead to avoid content loss. If a |
|
9191 // block contains nested content, exempt it from this condition because we |
|
9192 // otherwise have no access to its original content and content loss would |
|
9193 // still occur. |
|
9194 var saveContent = block.originalContent; |
|
9195 |
|
9196 if (block.isValid || block.innerBlocks.length) { |
|
9197 try { |
|
9198 saveContent = getSaveContent(block.name, block.attributes, block.innerBlocks); |
|
9199 } catch (error) {} |
|
9200 } |
|
9201 |
|
9202 return saveContent; |
|
9203 } |
|
9204 /** |
|
9205 * Returns the content of a block, including comment delimiters. |
|
9206 * |
|
9207 * @param {string} rawBlockName Block name. |
|
9208 * @param {Object} attributes Block attributes. |
|
9209 * @param {string} content Block save content. |
|
9210 * |
|
9211 * @return {string} Comment-delimited block content. |
|
9212 */ |
|
9213 |
|
9214 function getCommentDelimitedContent(rawBlockName, attributes, content) { |
|
9215 var serializedAttributes = !Object(external_this_lodash_["isEmpty"])(attributes) ? serializeAttributes(attributes) + ' ' : ''; // Strip core blocks of their namespace prefix. |
|
9216 |
|
9217 var blockName = Object(external_this_lodash_["startsWith"])(rawBlockName, 'core/') ? rawBlockName.slice(5) : rawBlockName; // @todo make the `wp:` prefix potentially configurable. |
|
9218 |
|
9219 if (!content) { |
|
9220 return "<!-- wp:".concat(blockName, " ").concat(serializedAttributes, "/-->"); |
|
9221 } |
|
9222 |
|
9223 return "<!-- wp:".concat(blockName, " ").concat(serializedAttributes, "-->\n") + content + "\n<!-- /wp:".concat(blockName, " -->"); |
|
9224 } |
|
9225 /** |
|
9226 * Returns the content of a block, including comment delimiters, determining |
|
9227 * serialized attributes and content form from the current state of the block. |
|
9228 * |
|
9229 * @param {Object} block Block instance. |
|
9230 * @param {WPBlockSerializationOptions} options Serialization options. |
|
9231 * |
|
9232 * @return {string} Serialized block. |
|
9233 */ |
|
9234 |
|
9235 function serializeBlock(block) { |
|
9236 var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, |
|
9237 _ref$isInnerBlocks = _ref.isInnerBlocks, |
|
9238 isInnerBlocks = _ref$isInnerBlocks === void 0 ? false : _ref$isInnerBlocks; |
|
9239 |
|
9240 var blockName = block.name; |
|
9241 var saveContent = getBlockContent(block); |
|
9242 |
|
9243 if (blockName === getUnregisteredTypeHandlerName() || !isInnerBlocks && blockName === getFreeformContentHandlerName()) { |
|
9244 return saveContent; |
|
9245 } |
|
9246 |
|
9247 var blockType = registration_getBlockType(blockName); |
|
9248 var saveAttributes = getCommentAttributes(blockType, block.attributes); |
|
9249 return getCommentDelimitedContent(blockName, saveAttributes, saveContent); |
|
9250 } |
|
9251 /** |
|
9252 * Takes a block or set of blocks and returns the serialized post content. |
|
9253 * |
|
9254 * @param {Array} blocks Block(s) to serialize. |
|
9255 * @param {WPBlockSerializationOptions} options Serialization options. |
|
9256 * |
|
9257 * @return {string} The post content. |
|
9258 */ |
|
9259 |
|
9260 function serialize(blocks, options) { |
|
9261 return Object(external_this_lodash_["castArray"])(blocks).map(function (block) { |
|
9262 return serializeBlock(block, options); |
|
9263 }).join('\n\n'); |
|
9264 } |
|
9265 |
|
9266 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/validation/index.js |
|
9267 |
|
9268 |
|
9269 |
|
9270 |
|
9271 |
|
9272 |
|
9273 |
|
9274 function validation_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
9275 |
|
9276 function validation_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { validation_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { validation_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
9277 |
|
9278 /** |
|
9279 * External dependencies |
|
9280 */ |
|
9281 |
|
9282 |
|
9283 /** |
|
9284 * WordPress dependencies |
|
9285 */ |
|
9286 |
|
9287 |
|
9288 /** |
|
9289 * Internal dependencies |
|
9290 */ |
|
9291 |
|
9292 |
|
9293 |
|
9294 |
|
9295 /** |
|
9296 * Globally matches any consecutive whitespace |
|
9297 * |
|
9298 * @type {RegExp} |
|
9299 */ |
|
9300 |
|
9301 var REGEXP_WHITESPACE = /[\t\n\r\v\f ]+/g; |
|
9302 /** |
|
9303 * Matches a string containing only whitespace |
|
9304 * |
|
9305 * @type {RegExp} |
|
9306 */ |
|
9307 |
|
9308 var REGEXP_ONLY_WHITESPACE = /^[\t\n\r\v\f ]*$/; |
|
9309 /** |
|
9310 * Matches a CSS URL type value |
|
9311 * |
|
9312 * @type {RegExp} |
|
9313 */ |
|
9314 |
|
9315 var REGEXP_STYLE_URL_TYPE = /^url\s*\(['"\s]*(.*?)['"\s]*\)$/; |
|
9316 /** |
|
9317 * Boolean attributes are attributes whose presence as being assigned is |
|
9318 * meaningful, even if only empty. |
|
9319 * |
|
9320 * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes |
|
9321 * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3 |
|
9322 * |
|
9323 * Object.keys( Array.from( document.querySelectorAll( '#attributes-1 > tbody > tr' ) ) |
|
9324 * .filter( ( tr ) => tr.lastChild.textContent.indexOf( 'Boolean attribute' ) !== -1 ) |
|
9325 * .reduce( ( result, tr ) => Object.assign( result, { |
|
9326 * [ tr.firstChild.textContent.trim() ]: true |
|
9327 * } ), {} ) ).sort(); |
|
9328 * |
|
9329 * @type {Array} |
|
9330 */ |
|
9331 |
|
9332 var 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']; |
|
9333 /** |
|
9334 * Enumerated attributes are attributes which must be of a specific value form. |
|
9335 * Like boolean attributes, these are meaningful if specified, even if not of a |
|
9336 * valid enumerated value. |
|
9337 * |
|
9338 * See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute |
|
9339 * Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3 |
|
9340 * |
|
9341 * Object.keys( Array.from( document.querySelectorAll( '#attributes-1 > tbody > tr' ) ) |
|
9342 * .filter( ( tr ) => /^("(.+?)";?\s*)+/.test( tr.lastChild.textContent.trim() ) ) |
|
9343 * .reduce( ( result, tr ) => Object.assign( result, { |
|
9344 * [ tr.firstChild.textContent.trim() ]: true |
|
9345 * } ), {} ) ).sort(); |
|
9346 * |
|
9347 * @type {Array} |
|
9348 */ |
|
9349 |
|
9350 var 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']; |
|
9351 /** |
|
9352 * Meaningful attributes are those who cannot be safely ignored when omitted in |
|
9353 * one HTML markup string and not another. |
|
9354 * |
|
9355 * @type {Array} |
|
9356 */ |
|
9357 |
|
9358 var MEANINGFUL_ATTRIBUTES = [].concat(BOOLEAN_ATTRIBUTES, ENUMERATED_ATTRIBUTES); |
|
9359 /** |
|
9360 * Array of functions which receive a text string on which to apply normalizing |
|
9361 * behavior for consideration in text token equivalence, carefully ordered from |
|
9362 * least-to-most expensive operations. |
|
9363 * |
|
9364 * @type {Array} |
|
9365 */ |
|
9366 |
|
9367 var TEXT_NORMALIZATIONS = [external_this_lodash_["identity"], getTextWithCollapsedWhitespace]; |
|
9368 /** |
|
9369 * Regular expression matching a named character reference. In lieu of bundling |
|
9370 * a full set of references, the pattern covers the minimal necessary to test |
|
9371 * positively against the full set. |
|
9372 * |
|
9373 * "The ampersand must be followed by one of the names given in the named |
|
9374 * character references section, using the same case." |
|
9375 * |
|
9376 * Tested aginst "12.5 Named character references": |
|
9377 * |
|
9378 * ``` |
|
9379 * const references = Array.from( document.querySelectorAll( |
|
9380 * '#named-character-references-table tr[id^=entity-] td:first-child' |
|
9381 * ) ).map( ( code ) => code.textContent ) |
|
9382 * references.every( ( reference ) => /^[\da-z]+$/i.test( reference ) ) |
|
9383 * ``` |
|
9384 * |
|
9385 * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references |
|
9386 * @see https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references |
|
9387 * |
|
9388 * @type {RegExp} |
|
9389 */ |
|
9390 |
|
9391 var REGEXP_NAMED_CHARACTER_REFERENCE = /^[\da-z]+$/i; |
|
9392 /** |
|
9393 * Regular expression matching a decimal character reference. |
|
9394 * |
|
9395 * "The ampersand must be followed by a U+0023 NUMBER SIGN character (#), |
|
9396 * followed by one or more ASCII digits, representing a base-ten integer" |
|
9397 * |
|
9398 * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references |
|
9399 * |
|
9400 * @type {RegExp} |
|
9401 */ |
|
9402 |
|
9403 var REGEXP_DECIMAL_CHARACTER_REFERENCE = /^#\d+$/; |
|
9404 /** |
|
9405 * Regular expression matching a hexadecimal character reference. |
|
9406 * |
|
9407 * "The ampersand must be followed by a U+0023 NUMBER SIGN character (#), which |
|
9408 * must be followed by either a U+0078 LATIN SMALL LETTER X character (x) or a |
|
9409 * U+0058 LATIN CAPITAL LETTER X character (X), which must then be followed by |
|
9410 * one or more ASCII hex digits, representing a hexadecimal integer" |
|
9411 * |
|
9412 * @see https://html.spec.whatwg.org/multipage/syntax.html#character-references |
|
9413 * |
|
9414 * @type {RegExp} |
|
9415 */ |
|
9416 |
|
9417 var REGEXP_HEXADECIMAL_CHARACTER_REFERENCE = /^#x[\da-f]+$/i; |
|
9418 /** |
|
9419 * Returns true if the given string is a valid character reference segment, or |
|
9420 * false otherwise. The text should be stripped of `&` and `;` demarcations. |
|
9421 * |
|
9422 * @param {string} text Text to test. |
|
9423 * |
|
9424 * @return {boolean} Whether text is valid character reference. |
|
9425 */ |
|
9426 |
|
9427 function isValidCharacterReference(text) { |
|
9428 return REGEXP_NAMED_CHARACTER_REFERENCE.test(text) || REGEXP_DECIMAL_CHARACTER_REFERENCE.test(text) || REGEXP_HEXADECIMAL_CHARACTER_REFERENCE.test(text); |
|
9429 } |
|
9430 /** |
|
9431 * Subsitute EntityParser class for `simple-html-tokenizer` which uses the |
|
9432 * implementation of `decodeEntities` from `html-entities`, in order to avoid |
|
9433 * bundling a massive named character reference. |
|
9434 * |
|
9435 * @see https://github.com/tildeio/simple-html-tokenizer/tree/master/src/entity-parser.ts |
|
9436 */ |
|
9437 |
|
9438 var validation_DecodeEntityParser = /*#__PURE__*/function () { |
|
9439 function DecodeEntityParser() { |
|
9440 Object(classCallCheck["a" /* default */])(this, DecodeEntityParser); |
|
9441 } |
|
9442 |
|
9443 Object(createClass["a" /* default */])(DecodeEntityParser, [{ |
|
9444 key: "parse", |
|
9445 |
|
9446 /** |
|
9447 * Returns a substitute string for an entity string sequence between `&` |
|
9448 * and `;`, or undefined if no substitution should occur. |
|
9449 * |
|
9450 * @param {string} entity Entity fragment discovered in HTML. |
|
9451 * |
|
9452 * @return {?string} Entity substitute value. |
|
9453 */ |
|
9454 value: function parse(entity) { |
|
9455 if (isValidCharacterReference(entity)) { |
|
9456 return Object(external_this_wp_htmlEntities_["decodeEntities"])('&' + entity + ';'); |
|
9457 } |
|
9458 } |
|
9459 }]); |
|
9460 |
|
9461 return DecodeEntityParser; |
|
9462 }(); |
|
9463 /** |
|
9464 * Given a specified string, returns an array of strings split by consecutive |
|
9465 * whitespace, ignoring leading or trailing whitespace. |
|
9466 * |
|
9467 * @param {string} text Original text. |
|
9468 * |
|
9469 * @return {string[]} Text pieces split on whitespace. |
|
9470 */ |
|
9471 |
|
9472 function getTextPiecesSplitOnWhitespace(text) { |
|
9473 return text.trim().split(REGEXP_WHITESPACE); |
|
9474 } |
|
9475 /** |
|
9476 * Given a specified string, returns a new trimmed string where all consecutive |
|
9477 * whitespace is collapsed to a single space. |
|
9478 * |
|
9479 * @param {string} text Original text. |
|
9480 * |
|
9481 * @return {string} Trimmed text with consecutive whitespace collapsed. |
|
9482 */ |
|
9483 |
|
9484 function getTextWithCollapsedWhitespace(text) { |
|
9485 // This is an overly simplified whitespace comparison. The specification is |
|
9486 // more prescriptive of whitespace behavior in inline and block contexts. |
|
9487 // |
|
9488 // See: https://medium.com/@patrickbrosset/when-does-white-space-matter-in-html-b90e8a7cdd33 |
|
9489 return getTextPiecesSplitOnWhitespace(text).join(' '); |
|
9490 } |
|
9491 /** |
|
9492 * Returns attribute pairs of the given StartTag token, including only pairs |
|
9493 * where the value is non-empty or the attribute is a boolean attribute, an |
|
9494 * enumerated attribute, or a custom data- attribute. |
|
9495 * |
|
9496 * @see MEANINGFUL_ATTRIBUTES |
|
9497 * |
|
9498 * @param {Object} token StartTag token. |
|
9499 * |
|
9500 * @return {Array[]} Attribute pairs. |
|
9501 */ |
|
9502 |
|
9503 function getMeaningfulAttributePairs(token) { |
|
9504 return token.attributes.filter(function (pair) { |
|
9505 var _pair = Object(slicedToArray["a" /* default */])(pair, 2), |
|
9506 key = _pair[0], |
|
9507 value = _pair[1]; |
|
9508 |
|
9509 return value || key.indexOf('data-') === 0 || Object(external_this_lodash_["includes"])(MEANINGFUL_ATTRIBUTES, key); |
|
9510 }); |
|
9511 } |
|
9512 /** |
|
9513 * Returns true if two text tokens (with `chars` property) are equivalent, or |
|
9514 * false otherwise. |
|
9515 * |
|
9516 * @param {Object} actual Actual token. |
|
9517 * @param {Object} expected Expected token. |
|
9518 * @param {Object} logger Validation logger object. |
|
9519 * |
|
9520 * @return {boolean} Whether two text tokens are equivalent. |
|
9521 */ |
|
9522 |
|
9523 function isEquivalentTextTokens(actual, expected) { |
|
9524 var logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger(); |
|
9525 // This function is intentionally written as syntactically "ugly" as a hot |
|
9526 // path optimization. Text is progressively normalized in order from least- |
|
9527 // to-most operationally expensive, until the earliest point at which text |
|
9528 // can be confidently inferred as being equal. |
|
9529 var actualChars = actual.chars; |
|
9530 var expectedChars = expected.chars; |
|
9531 |
|
9532 for (var i = 0; i < TEXT_NORMALIZATIONS.length; i++) { |
|
9533 var normalize = TEXT_NORMALIZATIONS[i]; |
|
9534 actualChars = normalize(actualChars); |
|
9535 expectedChars = normalize(expectedChars); |
|
9536 |
|
9537 if (actualChars === expectedChars) { |
|
9538 return true; |
|
9539 } |
|
9540 } |
|
9541 |
|
9542 logger.warning('Expected text `%s`, saw `%s`.', expected.chars, actual.chars); |
|
9543 return false; |
|
9544 } |
|
9545 /** |
|
9546 * Given a style value, returns a normalized style value for strict equality |
|
9547 * comparison. |
|
9548 * |
|
9549 * @param {string} value Style value. |
|
9550 * |
|
9551 * @return {string} Normalized style value. |
|
9552 */ |
|
9553 |
|
9554 function getNormalizedStyleValue(value) { |
|
9555 return value // Normalize URL type to omit whitespace or quotes |
|
9556 .replace(REGEXP_STYLE_URL_TYPE, 'url($1)'); |
|
9557 } |
|
9558 /** |
|
9559 * Given a style attribute string, returns an object of style properties. |
|
9560 * |
|
9561 * @param {string} text Style attribute. |
|
9562 * |
|
9563 * @return {Object} Style properties. |
|
9564 */ |
|
9565 |
|
9566 function getStyleProperties(text) { |
|
9567 var pairs = text // Trim ending semicolon (avoid including in split) |
|
9568 .replace(/;?\s*$/, '') // Split on property assignment |
|
9569 .split(';') // For each property assignment... |
|
9570 .map(function (style) { |
|
9571 // ...split further into key-value pairs |
|
9572 var _style$split = style.split(':'), |
|
9573 _style$split2 = Object(toArray["a" /* default */])(_style$split), |
|
9574 key = _style$split2[0], |
|
9575 valueParts = _style$split2.slice(1); |
|
9576 |
|
9577 var value = valueParts.join(':'); |
|
9578 return [key.trim(), getNormalizedStyleValue(value.trim())]; |
|
9579 }); |
|
9580 return Object(external_this_lodash_["fromPairs"])(pairs); |
|
9581 } |
|
9582 /** |
|
9583 * Attribute-specific equality handlers |
|
9584 * |
|
9585 * @type {Object} |
|
9586 */ |
|
9587 |
|
9588 var isEqualAttributesOfName = validation_objectSpread({ |
|
9589 class: function _class(actual, expected) { |
|
9590 // Class matches if members are the same, even if out of order or |
|
9591 // superfluous whitespace between. |
|
9592 return !external_this_lodash_["xor"].apply(void 0, Object(toConsumableArray["a" /* default */])([actual, expected].map(getTextPiecesSplitOnWhitespace))).length; |
|
9593 }, |
|
9594 style: function style(actual, expected) { |
|
9595 return external_this_lodash_["isEqual"].apply(void 0, Object(toConsumableArray["a" /* default */])([actual, expected].map(getStyleProperties))); |
|
9596 } |
|
9597 }, Object(external_this_lodash_["fromPairs"])(BOOLEAN_ATTRIBUTES.map(function (attribute) { |
|
9598 return [attribute, external_this_lodash_["stubTrue"]]; |
|
9599 }))); |
|
9600 /** |
|
9601 * Given two sets of attribute tuples, returns true if the attribute sets are |
|
9602 * equivalent. |
|
9603 * |
|
9604 * @param {Array[]} actual Actual attributes tuples. |
|
9605 * @param {Array[]} expected Expected attributes tuples. |
|
9606 * @param {Object} logger Validation logger object. |
|
9607 * |
|
9608 * @return {boolean} Whether attributes are equivalent. |
|
9609 */ |
|
9610 |
|
9611 function isEqualTagAttributePairs(actual, expected) { |
|
9612 var logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger(); |
|
9613 |
|
9614 // Attributes is tokenized as tuples. Their lengths should match. This also |
|
9615 // avoids us needing to check both attributes sets, since if A has any keys |
|
9616 // which do not exist in B, we know the sets to be different. |
|
9617 if (actual.length !== expected.length) { |
|
9618 logger.warning('Expected attributes %o, instead saw %o.', expected, actual); |
|
9619 return false; |
|
9620 } // Attributes are not guaranteed to occur in the same order. For validating |
|
9621 // actual attributes, first convert the set of expected attribute values to |
|
9622 // an object, for lookup by key. |
|
9623 |
|
9624 |
|
9625 var expectedAttributes = {}; |
|
9626 |
|
9627 for (var i = 0; i < expected.length; i++) { |
|
9628 expectedAttributes[expected[i][0].toLowerCase()] = expected[i][1]; |
|
9629 } |
|
9630 |
|
9631 for (var _i = 0; _i < actual.length; _i++) { |
|
9632 var _actual$_i = Object(slicedToArray["a" /* default */])(actual[_i], 2), |
|
9633 name = _actual$_i[0], |
|
9634 actualValue = _actual$_i[1]; |
|
9635 |
|
9636 var nameLower = name.toLowerCase(); // As noted above, if missing member in B, assume different |
|
9637 |
|
9638 if (!expectedAttributes.hasOwnProperty(nameLower)) { |
|
9639 logger.warning('Encountered unexpected attribute `%s`.', name); |
|
9640 return false; |
|
9641 } |
|
9642 |
|
9643 var expectedValue = expectedAttributes[nameLower]; |
|
9644 var isEqualAttributes = isEqualAttributesOfName[nameLower]; |
|
9645 |
|
9646 if (isEqualAttributes) { |
|
9647 // Defer custom attribute equality handling |
|
9648 if (!isEqualAttributes(actualValue, expectedValue)) { |
|
9649 logger.warning('Expected attribute `%s` of value `%s`, saw `%s`.', name, expectedValue, actualValue); |
|
9650 return false; |
|
9651 } |
|
9652 } else if (actualValue !== expectedValue) { |
|
9653 // Otherwise strict inequality should bail |
|
9654 logger.warning('Expected attribute `%s` of value `%s`, saw `%s`.', name, expectedValue, actualValue); |
|
9655 return false; |
|
9656 } |
|
9657 } |
|
9658 |
|
9659 return true; |
|
9660 } |
|
9661 /** |
|
9662 * Token-type-specific equality handlers |
|
9663 * |
|
9664 * @type {Object} |
|
9665 */ |
|
9666 |
|
9667 var isEqualTokensOfType = { |
|
9668 StartTag: function StartTag(actual, expected) { |
|
9669 var logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger(); |
|
9670 |
|
9671 if (actual.tagName !== expected.tagName && // Optimization: Use short-circuit evaluation to defer case- |
|
9672 // insensitive check on the assumption that the majority case will |
|
9673 // have exactly equal tag names. |
|
9674 actual.tagName.toLowerCase() !== expected.tagName.toLowerCase()) { |
|
9675 logger.warning('Expected tag name `%s`, instead saw `%s`.', expected.tagName, actual.tagName); |
|
9676 return false; |
|
9677 } |
|
9678 |
|
9679 return isEqualTagAttributePairs.apply(void 0, Object(toConsumableArray["a" /* default */])([actual, expected].map(getMeaningfulAttributePairs)).concat([logger])); |
|
9680 }, |
|
9681 Chars: isEquivalentTextTokens, |
|
9682 Comment: isEquivalentTextTokens |
|
9683 }; |
|
9684 /** |
|
9685 * Given an array of tokens, returns the first token which is not purely |
|
9686 * whitespace. |
|
9687 * |
|
9688 * Mutates the tokens array. |
|
9689 * |
|
9690 * @param {Object[]} tokens Set of tokens to search. |
|
9691 * |
|
9692 * @return {Object} Next non-whitespace token. |
|
9693 */ |
|
9694 |
|
9695 function getNextNonWhitespaceToken(tokens) { |
|
9696 var token; |
|
9697 |
|
9698 while (token = tokens.shift()) { |
|
9699 if (token.type !== 'Chars') { |
|
9700 return token; |
|
9701 } |
|
9702 |
|
9703 if (!REGEXP_ONLY_WHITESPACE.test(token.chars)) { |
|
9704 return token; |
|
9705 } |
|
9706 } |
|
9707 } |
|
9708 /** |
|
9709 * Tokenize an HTML string, gracefully handling any errors thrown during |
|
9710 * underlying tokenization. |
|
9711 * |
|
9712 * @param {string} html HTML string to tokenize. |
|
9713 * @param {Object} logger Validation logger object. |
|
9714 * |
|
9715 * @return {Object[]|null} Array of valid tokenized HTML elements, or null on error |
|
9716 */ |
|
9717 |
|
9718 function getHTMLTokens(html) { |
|
9719 var logger = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : createLogger(); |
|
9720 |
|
9721 try { |
|
9722 return new Tokenizer(new validation_DecodeEntityParser()).tokenize(html); |
|
9723 } catch (e) { |
|
9724 logger.warning('Malformed HTML detected: %s', html); |
|
9725 } |
|
9726 |
|
9727 return null; |
|
9728 } |
|
9729 /** |
|
9730 * Returns true if the next HTML token closes the current token. |
|
9731 * |
|
9732 * @param {Object} currentToken Current token to compare with. |
|
9733 * @param {Object|undefined} nextToken Next token to compare against. |
|
9734 * |
|
9735 * @return {boolean} true if `nextToken` closes `currentToken`, false otherwise |
|
9736 */ |
|
9737 |
|
9738 |
|
9739 function isClosedByToken(currentToken, nextToken) { |
|
9740 // Ensure this is a self closed token |
|
9741 if (!currentToken.selfClosing) { |
|
9742 return false; |
|
9743 } // Check token names and determine if nextToken is the closing tag for currentToken |
|
9744 |
|
9745 |
|
9746 if (nextToken && nextToken.tagName === currentToken.tagName && nextToken.type === 'EndTag') { |
|
9747 return true; |
|
9748 } |
|
9749 |
|
9750 return false; |
|
9751 } |
|
9752 /** |
|
9753 * Returns true if the given HTML strings are effectively equivalent, or |
|
9754 * false otherwise. Invalid HTML is not considered equivalent, even if the |
|
9755 * strings directly match. |
|
9756 * |
|
9757 * @param {string} actual Actual HTML string. |
|
9758 * @param {string} expected Expected HTML string. |
|
9759 * @param {Object} logger Validation logger object. |
|
9760 * |
|
9761 * @return {boolean} Whether HTML strings are equivalent. |
|
9762 */ |
|
9763 |
|
9764 function isEquivalentHTML(actual, expected) { |
|
9765 var logger = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : createLogger(); |
|
9766 |
|
9767 // Short-circuit if markup is identical. |
|
9768 if (actual === expected) { |
|
9769 return true; |
|
9770 } // Tokenize input content and reserialized save content |
|
9771 |
|
9772 |
|
9773 var _map = [actual, expected].map(function (html) { |
|
9774 return getHTMLTokens(html, logger); |
|
9775 }), |
|
9776 _map2 = Object(slicedToArray["a" /* default */])(_map, 2), |
|
9777 actualTokens = _map2[0], |
|
9778 expectedTokens = _map2[1]; // If either is malformed then stop comparing - the strings are not equivalent |
|
9779 |
|
9780 |
|
9781 if (!actualTokens || !expectedTokens) { |
|
9782 return false; |
|
9783 } |
|
9784 |
|
9785 var actualToken, expectedToken; |
|
9786 |
|
9787 while (actualToken = getNextNonWhitespaceToken(actualTokens)) { |
|
9788 expectedToken = getNextNonWhitespaceToken(expectedTokens); // Inequal if exhausted all expected tokens |
|
9789 |
|
9790 if (!expectedToken) { |
|
9791 logger.warning('Expected end of content, instead saw %o.', actualToken); |
|
9792 return false; |
|
9793 } // Inequal if next non-whitespace token of each set are not same type |
|
9794 |
|
9795 |
|
9796 if (actualToken.type !== expectedToken.type) { |
|
9797 logger.warning('Expected token of type `%s` (%o), instead saw `%s` (%o).', expectedToken.type, expectedToken, actualToken.type, actualToken); |
|
9798 return false; |
|
9799 } // Defer custom token type equality handling, otherwise continue and |
|
9800 // assume as equal |
|
9801 |
|
9802 |
|
9803 var isEqualTokens = isEqualTokensOfType[actualToken.type]; |
|
9804 |
|
9805 if (isEqualTokens && !isEqualTokens(actualToken, expectedToken, logger)) { |
|
9806 return false; |
|
9807 } // Peek at the next tokens (actual and expected) to see if they close |
|
9808 // a self-closing tag |
|
9809 |
|
9810 |
|
9811 if (isClosedByToken(actualToken, expectedTokens[0])) { |
|
9812 // Consume the next expected token that closes the current actual |
|
9813 // self-closing token |
|
9814 getNextNonWhitespaceToken(expectedTokens); |
|
9815 } else if (isClosedByToken(expectedToken, actualTokens[0])) { |
|
9816 // Consume the next actual token that closes the current expected |
|
9817 // self-closing token |
|
9818 getNextNonWhitespaceToken(actualTokens); |
|
9819 } |
|
9820 } |
|
9821 |
|
9822 if (expectedToken = getNextNonWhitespaceToken(expectedTokens)) { |
|
9823 // If any non-whitespace tokens remain in expected token set, this |
|
9824 // indicates inequality |
|
9825 logger.warning('Expected %o, instead saw end of content.', expectedToken); |
|
9826 return false; |
|
9827 } |
|
9828 |
|
9829 return true; |
|
9830 } |
|
9831 /** |
|
9832 * Returns an object with `isValid` property set to `true` if the parsed block |
|
9833 * is valid given the input content. A block is considered valid if, when serialized |
|
9834 * with assumed attributes, the content matches the original value. If block is |
|
9835 * invalid, this function returns all validations issues as well. |
|
9836 * |
|
9837 * @param {string|Object} blockTypeOrName Block type. |
|
9838 * @param {Object} attributes Parsed block attributes. |
|
9839 * @param {string} originalBlockContent Original block content. |
|
9840 * @param {Object} logger Validation logger object. |
|
9841 * |
|
9842 * @return {Object} Whether block is valid and contains validation messages. |
|
9843 */ |
|
9844 |
|
9845 function getBlockContentValidationResult(blockTypeOrName, attributes, originalBlockContent) { |
|
9846 var logger = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : createQueuedLogger(); |
|
9847 var blockType = normalizeBlockType(blockTypeOrName); |
|
9848 var generatedBlockContent; |
|
9849 |
|
9850 try { |
|
9851 generatedBlockContent = getSaveContent(blockType, attributes); |
|
9852 } catch (error) { |
|
9853 logger.error('Block validation failed because an error occurred while generating block content:\n\n%s', error.toString()); |
|
9854 return { |
|
9855 isValid: false, |
|
9856 validationIssues: logger.getItems() |
|
9857 }; |
|
9858 } |
|
9859 |
|
9860 var isValid = isEquivalentHTML(originalBlockContent, generatedBlockContent, logger); |
|
9861 |
|
9862 if (!isValid) { |
|
9863 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); |
|
9864 } |
|
9865 |
|
9866 return { |
|
9867 isValid: isValid, |
|
9868 validationIssues: logger.getItems() |
|
9869 }; |
|
9870 } |
|
9871 /** |
|
9872 * Returns true if the parsed block is valid given the input content. A block |
|
9873 * is considered valid if, when serialized with assumed attributes, the content |
|
9874 * matches the original value. |
|
9875 * |
|
9876 * Logs to console in development environments when invalid. |
|
9877 * |
|
9878 * @param {string|Object} blockTypeOrName Block type. |
|
9879 * @param {Object} attributes Parsed block attributes. |
|
9880 * @param {string} originalBlockContent Original block content. |
|
9881 * |
|
9882 * @return {boolean} Whether block is valid. |
|
9883 */ |
|
9884 |
|
9885 function isValidBlockContent(blockTypeOrName, attributes, originalBlockContent) { |
|
9886 var _getBlockContentValid = getBlockContentValidationResult(blockTypeOrName, attributes, originalBlockContent, createLogger()), |
|
9887 isValid = _getBlockContentValid.isValid; |
|
9888 |
|
9889 return isValid; |
|
9890 } |
|
9891 |
|
9892 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/matchers.js |
|
9893 /** |
|
9894 * External dependencies |
|
9895 */ |
|
9896 |
|
9897 /** |
|
9898 * Internal dependencies |
|
9899 */ |
|
9900 |
|
9901 |
|
9902 |
|
9903 function matchers_html(selector, multilineTag) { |
|
9904 return function (domNode) { |
|
9905 var match = domNode; |
|
9906 |
|
9907 if (selector) { |
|
9908 match = domNode.querySelector(selector); |
|
9909 } |
|
9910 |
|
9911 if (!match) { |
|
9912 return ''; |
|
9913 } |
|
9914 |
|
9915 if (multilineTag) { |
|
9916 var value = ''; |
|
9917 var length = match.children.length; |
|
9918 |
|
9919 for (var index = 0; index < length; index++) { |
|
9920 var child = match.children[index]; |
|
9921 |
|
9922 if (child.nodeName.toLowerCase() !== multilineTag) { |
|
9923 continue; |
|
9924 } |
|
9925 |
|
9926 value += child.outerHTML; |
|
9927 } |
|
9928 |
|
9929 return value; |
|
9930 } |
|
9931 |
|
9932 return match.innerHTML; |
|
9933 }; |
|
9934 } |
|
9935 |
|
9936 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/node.js |
|
9937 |
|
9938 |
|
9939 function node_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
9940 |
|
9941 function node_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { node_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { node_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
9942 |
|
9943 /** |
|
9944 * Internal dependencies |
|
9945 */ |
|
9946 |
|
9947 /** |
|
9948 * Browser dependencies |
|
9949 */ |
|
9950 |
|
9951 var _window$Node = window.Node, |
|
9952 TEXT_NODE = _window$Node.TEXT_NODE, |
|
9953 ELEMENT_NODE = _window$Node.ELEMENT_NODE; |
|
9954 /** |
|
9955 * A representation of a single node within a block's rich text value. If |
|
9956 * representing a text node, the value is simply a string of the node value. |
|
9957 * As representing an element node, it is an object of: |
|
9958 * |
|
9959 * 1. `type` (string): Tag name. |
|
9960 * 2. `props` (object): Attributes and children array of WPBlockNode. |
|
9961 * |
|
9962 * @typedef {string|Object} WPBlockNode |
|
9963 */ |
|
9964 |
|
9965 /** |
|
9966 * Given a single node and a node type (e.g. `'br'`), returns true if the node |
|
9967 * corresponds to that type, false otherwise. |
|
9968 * |
|
9969 * @param {WPBlockNode} node Block node to test |
|
9970 * @param {string} type Node to type to test against. |
|
9971 * |
|
9972 * @return {boolean} Whether node is of intended type. |
|
9973 */ |
|
9974 |
|
9975 function isNodeOfType(node, type) { |
|
9976 return node && node.type === type; |
|
9977 } |
|
9978 /** |
|
9979 * Given an object implementing the NamedNodeMap interface, returns a plain |
|
9980 * object equivalent value of name, value key-value pairs. |
|
9981 * |
|
9982 * @see https://dom.spec.whatwg.org/#interface-namednodemap |
|
9983 * |
|
9984 * @param {NamedNodeMap} nodeMap NamedNodeMap to convert to object. |
|
9985 * |
|
9986 * @return {Object} Object equivalent value of NamedNodeMap. |
|
9987 */ |
|
9988 |
|
9989 |
|
9990 function getNamedNodeMapAsObject(nodeMap) { |
|
9991 var result = {}; |
|
9992 |
|
9993 for (var i = 0; i < nodeMap.length; i++) { |
|
9994 var _nodeMap$i = nodeMap[i], |
|
9995 name = _nodeMap$i.name, |
|
9996 value = _nodeMap$i.value; |
|
9997 result[name] = value; |
|
9998 } |
|
9999 |
|
10000 return result; |
|
10001 } |
|
10002 /** |
|
10003 * Given a DOM Element or Text node, returns an equivalent block node. Throws |
|
10004 * if passed any node type other than element or text. |
|
10005 * |
|
10006 * @throws {TypeError} If non-element/text node is passed. |
|
10007 * |
|
10008 * @param {Node} domNode DOM node to convert. |
|
10009 * |
|
10010 * @return {WPBlockNode} Block node equivalent to DOM node. |
|
10011 */ |
|
10012 |
|
10013 function fromDOM(domNode) { |
|
10014 if (domNode.nodeType === TEXT_NODE) { |
|
10015 return domNode.nodeValue; |
|
10016 } |
|
10017 |
|
10018 if (domNode.nodeType !== ELEMENT_NODE) { |
|
10019 throw new TypeError('A block node can only be created from a node of type text or ' + 'element.'); |
|
10020 } |
|
10021 |
|
10022 return { |
|
10023 type: domNode.nodeName.toLowerCase(), |
|
10024 props: node_objectSpread({}, getNamedNodeMapAsObject(domNode.attributes), { |
|
10025 children: children_fromDOM(domNode.childNodes) |
|
10026 }) |
|
10027 }; |
|
10028 } |
|
10029 /** |
|
10030 * Given a block node, returns its HTML string representation. |
|
10031 * |
|
10032 * @param {WPBlockNode} node Block node to convert to string. |
|
10033 * |
|
10034 * @return {string} String HTML representation of block node. |
|
10035 */ |
|
10036 |
|
10037 function toHTML(node) { |
|
10038 return children_toHTML([node]); |
|
10039 } |
|
10040 /** |
|
10041 * Given a selector, returns an hpq matcher generating a WPBlockNode value |
|
10042 * matching the selector result. |
|
10043 * |
|
10044 * @param {string} selector DOM selector. |
|
10045 * |
|
10046 * @return {Function} hpq matcher. |
|
10047 */ |
|
10048 |
|
10049 function node_matcher(selector) { |
|
10050 return function (domNode) { |
|
10051 var match = domNode; |
|
10052 |
|
10053 if (selector) { |
|
10054 match = domNode.querySelector(selector); |
|
10055 } |
|
10056 |
|
10057 try { |
|
10058 return fromDOM(match); |
|
10059 } catch (error) { |
|
10060 return null; |
|
10061 } |
|
10062 }; |
|
10063 } |
|
10064 /** |
|
10065 * Object of utility functions used in managing block attribute values of |
|
10066 * source `node`. |
|
10067 * |
|
10068 * @see https://github.com/WordPress/gutenberg/pull/10439 |
|
10069 * |
|
10070 * @deprecated since 4.0. The `node` source should not be used, and can be |
|
10071 * replaced by the `html` source. |
|
10072 * |
|
10073 * @private |
|
10074 */ |
|
10075 |
|
10076 /* harmony default export */ var api_node = ({ |
|
10077 isNodeOfType: isNodeOfType, |
|
10078 fromDOM: fromDOM, |
|
10079 toHTML: toHTML, |
|
10080 matcher: node_matcher |
|
10081 }); |
|
10082 |
|
10083 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/children.js |
|
10084 /** |
|
10085 * External dependencies |
|
10086 */ |
|
10087 |
|
10088 /** |
|
10089 * WordPress dependencies |
|
10090 */ |
|
10091 |
|
10092 |
|
10093 /** |
|
10094 * Internal dependencies |
|
10095 */ |
|
10096 |
|
10097 |
|
10098 /** |
|
10099 * A representation of a block's rich text value. |
|
10100 * |
|
10101 * @typedef {WPBlockNode[]} WPBlockChildren |
|
10102 */ |
|
10103 |
|
10104 /** |
|
10105 * Given block children, returns a serialize-capable WordPress element. |
|
10106 * |
|
10107 * @param {WPBlockChildren} children Block children object to convert. |
|
10108 * |
|
10109 * @return {WPElement} A serialize-capable element. |
|
10110 */ |
|
10111 |
|
10112 function getSerializeCapableElement(children) { |
|
10113 // The fact that block children are compatible with the element serializer is |
|
10114 // merely an implementation detail that currently serves to be true, but |
|
10115 // should not be mistaken as being a guarantee on the external API. The |
|
10116 // public API only offers guarantees to work with strings (toHTML) and DOM |
|
10117 // elements (fromDOM), and should provide utilities to manipulate the value |
|
10118 // rather than expect consumers to inspect or construct its shape (concat). |
|
10119 return children; |
|
10120 } |
|
10121 /** |
|
10122 * Given block children, returns an array of block nodes. |
|
10123 * |
|
10124 * @param {WPBlockChildren} children Block children object to convert. |
|
10125 * |
|
10126 * @return {Array<WPBlockNode>} An array of individual block nodes. |
|
10127 */ |
|
10128 |
|
10129 function getChildrenArray(children) { |
|
10130 // The fact that block children are compatible with the element serializer |
|
10131 // is merely an implementation detail that currently serves to be true, but |
|
10132 // should not be mistaken as being a guarantee on the external API. |
|
10133 return children; |
|
10134 } |
|
10135 /** |
|
10136 * Given two or more block nodes, returns a new block node representing a |
|
10137 * concatenation of its values. |
|
10138 * |
|
10139 * @param {...WPBlockChildren} blockNodes Block nodes to concatenate. |
|
10140 * |
|
10141 * @return {WPBlockChildren} Concatenated block node. |
|
10142 */ |
|
10143 |
|
10144 |
|
10145 function concat() { |
|
10146 var result = []; |
|
10147 |
|
10148 for (var i = 0; i < arguments.length; i++) { |
|
10149 var blockNode = Object(external_this_lodash_["castArray"])(i < 0 || arguments.length <= i ? undefined : arguments[i]); |
|
10150 |
|
10151 for (var j = 0; j < blockNode.length; j++) { |
|
10152 var child = blockNode[j]; |
|
10153 var canConcatToPreviousString = typeof child === 'string' && typeof result[result.length - 1] === 'string'; |
|
10154 |
|
10155 if (canConcatToPreviousString) { |
|
10156 result[result.length - 1] += child; |
|
10157 } else { |
|
10158 result.push(child); |
|
10159 } |
|
10160 } |
|
10161 } |
|
10162 |
|
10163 return result; |
|
10164 } |
|
10165 /** |
|
10166 * Given an iterable set of DOM nodes, returns equivalent block children. |
|
10167 * Ignores any non-element/text nodes included in set. |
|
10168 * |
|
10169 * @param {Iterable.<Node>} domNodes Iterable set of DOM nodes to convert. |
|
10170 * |
|
10171 * @return {WPBlockChildren} Block children equivalent to DOM nodes. |
|
10172 */ |
|
10173 |
|
10174 function children_fromDOM(domNodes) { |
|
10175 var result = []; |
|
10176 |
|
10177 for (var i = 0; i < domNodes.length; i++) { |
|
10178 try { |
|
10179 result.push(fromDOM(domNodes[i])); |
|
10180 } catch (error) {// Simply ignore if DOM node could not be converted. |
|
10181 } |
|
10182 } |
|
10183 |
|
10184 return result; |
|
10185 } |
|
10186 /** |
|
10187 * Given a block node, returns its HTML string representation. |
|
10188 * |
|
10189 * @param {WPBlockChildren} children Block node(s) to convert to string. |
|
10190 * |
|
10191 * @return {string} String HTML representation of block node. |
|
10192 */ |
|
10193 |
|
10194 function children_toHTML(children) { |
|
10195 var element = getSerializeCapableElement(children); |
|
10196 return Object(external_this_wp_element_["renderToString"])(element); |
|
10197 } |
|
10198 /** |
|
10199 * Given a selector, returns an hpq matcher generating a WPBlockChildren value |
|
10200 * matching the selector result. |
|
10201 * |
|
10202 * @param {string} selector DOM selector. |
|
10203 * |
|
10204 * @return {Function} hpq matcher. |
|
10205 */ |
|
10206 |
|
10207 function children_matcher(selector) { |
|
10208 return function (domNode) { |
|
10209 var match = domNode; |
|
10210 |
|
10211 if (selector) { |
|
10212 match = domNode.querySelector(selector); |
|
10213 } |
|
10214 |
|
10215 if (match) { |
|
10216 return children_fromDOM(match.childNodes); |
|
10217 } |
|
10218 |
|
10219 return []; |
|
10220 }; |
|
10221 } |
|
10222 /** |
|
10223 * Object of utility functions used in managing block attribute values of |
|
10224 * source `children`. |
|
10225 * |
|
10226 * @see https://github.com/WordPress/gutenberg/pull/10439 |
|
10227 * |
|
10228 * @deprecated since 4.0. The `children` source should not be used, and can be |
|
10229 * replaced by the `html` source. |
|
10230 * |
|
10231 * @private |
|
10232 */ |
|
10233 |
|
10234 /* harmony default export */ var api_children = ({ |
|
10235 concat: concat, |
|
10236 getChildrenArray: getChildrenArray, |
|
10237 fromDOM: children_fromDOM, |
|
10238 toHTML: children_toHTML, |
|
10239 matcher: children_matcher |
|
10240 }); |
|
10241 |
|
10242 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser.js |
|
10243 |
|
10244 |
|
10245 |
|
10246 |
|
10247 function parser_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
10248 |
|
10249 function parser_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { parser_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { parser_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
10250 |
|
10251 /** |
|
10252 * External dependencies |
|
10253 */ |
|
10254 |
|
10255 |
|
10256 /** |
|
10257 * WordPress dependencies |
|
10258 */ |
|
10259 |
|
10260 |
|
10261 |
|
10262 |
|
10263 /** |
|
10264 * Internal dependencies |
|
10265 */ |
|
10266 |
|
10267 |
|
10268 |
|
10269 |
|
10270 |
|
10271 |
|
10272 |
|
10273 |
|
10274 /** |
|
10275 * Sources which are guaranteed to return a string value. |
|
10276 * |
|
10277 * @type {Set} |
|
10278 */ |
|
10279 |
|
10280 var STRING_SOURCES = new Set(['attribute', 'html', 'text', 'tag']); |
|
10281 /** |
|
10282 * Higher-order hpq matcher which enhances an attribute matcher to return true |
|
10283 * or false depending on whether the original matcher returns undefined. This |
|
10284 * is useful for boolean attributes (e.g. disabled) whose attribute values may |
|
10285 * be technically falsey (empty string), though their mere presence should be |
|
10286 * enough to infer as true. |
|
10287 * |
|
10288 * @param {Function} matcher Original hpq matcher. |
|
10289 * |
|
10290 * @return {Function} Enhanced hpq matcher. |
|
10291 */ |
|
10292 |
|
10293 var parser_toBooleanAttributeMatcher = function toBooleanAttributeMatcher(matcher) { |
|
10294 return Object(external_this_lodash_["flow"])([matcher, // Expected values from `attr( 'disabled' )`: |
|
10295 // |
|
10296 // <input> |
|
10297 // - Value: `undefined` |
|
10298 // - Transformed: `false` |
|
10299 // |
|
10300 // <input disabled> |
|
10301 // - Value: `''` |
|
10302 // - Transformed: `true` |
|
10303 // |
|
10304 // <input disabled="disabled"> |
|
10305 // - Value: `'disabled'` |
|
10306 // - Transformed: `true` |
|
10307 function (value) { |
|
10308 return value !== undefined; |
|
10309 }]); |
|
10310 }; |
|
10311 /** |
|
10312 * Returns true if value is of the given JSON schema type, or false otherwise. |
|
10313 * |
|
10314 * @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25 |
|
10315 * |
|
10316 * @param {*} value Value to test. |
|
10317 * @param {string} type Type to test. |
|
10318 * |
|
10319 * @return {boolean} Whether value is of type. |
|
10320 */ |
|
10321 |
|
10322 function isOfType(value, type) { |
|
10323 switch (type) { |
|
10324 case 'string': |
|
10325 return typeof value === 'string'; |
|
10326 |
|
10327 case 'boolean': |
|
10328 return typeof value === 'boolean'; |
|
10329 |
|
10330 case 'object': |
|
10331 return !!value && value.constructor === Object; |
|
10332 |
|
10333 case 'null': |
|
10334 return value === null; |
|
10335 |
|
10336 case 'array': |
|
10337 return Array.isArray(value); |
|
10338 |
|
10339 case 'integer': |
|
10340 case 'number': |
|
10341 return typeof value === 'number'; |
|
10342 } |
|
10343 |
|
10344 return true; |
|
10345 } |
|
10346 /** |
|
10347 * Returns true if value is of an array of given JSON schema types, or false |
|
10348 * otherwise. |
|
10349 * |
|
10350 * @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25 |
|
10351 * |
|
10352 * @param {*} value Value to test. |
|
10353 * @param {string[]} types Types to test. |
|
10354 * |
|
10355 * @return {boolean} Whether value is of types. |
|
10356 */ |
|
10357 |
|
10358 function isOfTypes(value, types) { |
|
10359 return types.some(function (type) { |
|
10360 return isOfType(value, type); |
|
10361 }); |
|
10362 } |
|
10363 /** |
|
10364 * Returns true if value is valid per the given block attribute schema type |
|
10365 * definition, or false otherwise. |
|
10366 * |
|
10367 * @see https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.1 |
|
10368 * |
|
10369 * @param {*} value Value to test. |
|
10370 * @param {?(Array<string>|string)} type Block attribute schema type. |
|
10371 * |
|
10372 * @return {boolean} Whether value is valid. |
|
10373 */ |
|
10374 |
|
10375 function isValidByType(value, type) { |
|
10376 return type === undefined || isOfTypes(value, Object(external_this_lodash_["castArray"])(type)); |
|
10377 } |
|
10378 /** |
|
10379 * Returns true if value is valid per the given block attribute schema enum |
|
10380 * definition, or false otherwise. |
|
10381 * |
|
10382 * @see https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.2 |
|
10383 * |
|
10384 * @param {*} value Value to test. |
|
10385 * @param {?Array} enumSet Block attribute schema enum. |
|
10386 * |
|
10387 * @return {boolean} Whether value is valid. |
|
10388 */ |
|
10389 |
|
10390 function isValidByEnum(value, enumSet) { |
|
10391 return !Array.isArray(enumSet) || enumSet.includes(value); |
|
10392 } |
|
10393 /** |
|
10394 * Returns true if the given attribute schema describes a value which may be |
|
10395 * an ambiguous string. |
|
10396 * |
|
10397 * Some sources are ambiguously serialized as strings, for which value casting |
|
10398 * is enabled. This is only possible when a singular type is assigned to the |
|
10399 * attribute schema, since the string ambiguity makes it impossible to know the |
|
10400 * correct type of multiple to which to cast. |
|
10401 * |
|
10402 * @param {Object} attributeSchema Attribute's schema. |
|
10403 * |
|
10404 * @return {boolean} Whether attribute schema defines an ambiguous string |
|
10405 * source. |
|
10406 */ |
|
10407 |
|
10408 function isAmbiguousStringSource(attributeSchema) { |
|
10409 var source = attributeSchema.source, |
|
10410 type = attributeSchema.type; |
|
10411 var isStringSource = STRING_SOURCES.has(source); |
|
10412 var isSingleType = typeof type === 'string'; |
|
10413 return isStringSource && isSingleType; |
|
10414 } |
|
10415 /** |
|
10416 * Returns an hpq matcher given a source object. |
|
10417 * |
|
10418 * @param {Object} sourceConfig Attribute Source object. |
|
10419 * |
|
10420 * @return {Function} A hpq Matcher. |
|
10421 */ |
|
10422 |
|
10423 function matcherFromSource(sourceConfig) { |
|
10424 switch (sourceConfig.source) { |
|
10425 case 'attribute': |
|
10426 var matcher = attr(sourceConfig.selector, sourceConfig.attribute); |
|
10427 |
|
10428 if (sourceConfig.type === 'boolean') { |
|
10429 matcher = parser_toBooleanAttributeMatcher(matcher); |
|
10430 } |
|
10431 |
|
10432 return matcher; |
|
10433 |
|
10434 case 'html': |
|
10435 return matchers_html(sourceConfig.selector, sourceConfig.multiline); |
|
10436 |
|
10437 case 'text': |
|
10438 return es_text(sourceConfig.selector); |
|
10439 |
|
10440 case 'children': |
|
10441 return children_matcher(sourceConfig.selector); |
|
10442 |
|
10443 case 'node': |
|
10444 return node_matcher(sourceConfig.selector); |
|
10445 |
|
10446 case 'query': |
|
10447 var subMatchers = Object(external_this_lodash_["mapValues"])(sourceConfig.query, matcherFromSource); |
|
10448 return query(sourceConfig.selector, subMatchers); |
|
10449 |
|
10450 case 'tag': |
|
10451 return Object(external_this_lodash_["flow"])([prop(sourceConfig.selector, 'nodeName'), function (nodeName) { |
|
10452 return nodeName ? nodeName.toLowerCase() : undefined; |
|
10453 }]); |
|
10454 |
|
10455 default: |
|
10456 // eslint-disable-next-line no-console |
|
10457 console.error("Unknown source type \"".concat(sourceConfig.source, "\"")); |
|
10458 } |
|
10459 } |
|
10460 /** |
|
10461 * Given a block's raw content and an attribute's schema returns the attribute's |
|
10462 * value depending on its source. |
|
10463 * |
|
10464 * @param {string} innerHTML Block's raw content. |
|
10465 * @param {Object} attributeSchema Attribute's schema. |
|
10466 * |
|
10467 * @return {*} Attribute value. |
|
10468 */ |
|
10469 |
|
10470 function parseWithAttributeSchema(innerHTML, attributeSchema) { |
|
10471 return es_parse(innerHTML, matcherFromSource(attributeSchema)); |
|
10472 } |
|
10473 /** |
|
10474 * Given an attribute key, an attribute's schema, a block's raw content and the |
|
10475 * commentAttributes returns the attribute value depending on its source |
|
10476 * definition of the given attribute key. |
|
10477 * |
|
10478 * @param {string} attributeKey Attribute key. |
|
10479 * @param {Object} attributeSchema Attribute's schema. |
|
10480 * @param {string} innerHTML Block's raw content. |
|
10481 * @param {Object} commentAttributes Block's comment attributes. |
|
10482 * |
|
10483 * @return {*} Attribute value. |
|
10484 */ |
|
10485 |
|
10486 function getBlockAttribute(attributeKey, attributeSchema, innerHTML, commentAttributes) { |
|
10487 var type = attributeSchema.type, |
|
10488 enumSet = attributeSchema.enum; |
|
10489 var value; |
|
10490 |
|
10491 switch (attributeSchema.source) { |
|
10492 // undefined source means that it's an attribute serialized to the block's "comment" |
|
10493 case undefined: |
|
10494 value = commentAttributes ? commentAttributes[attributeKey] : undefined; |
|
10495 break; |
|
10496 |
|
10497 case 'attribute': |
|
10498 case 'property': |
|
10499 case 'html': |
|
10500 case 'text': |
|
10501 case 'children': |
|
10502 case 'node': |
|
10503 case 'query': |
|
10504 case 'tag': |
|
10505 value = parseWithAttributeSchema(innerHTML, attributeSchema); |
|
10506 break; |
|
10507 } |
|
10508 |
|
10509 if (!isValidByType(value, type) || !isValidByEnum(value, enumSet)) { |
|
10510 // Reject the value if it is not valid. Reverting to the undefined |
|
10511 // value ensures the default is respected, if applicable. |
|
10512 value = undefined; |
|
10513 } |
|
10514 |
|
10515 if (value === undefined) { |
|
10516 return attributeSchema.default; |
|
10517 } |
|
10518 |
|
10519 return value; |
|
10520 } |
|
10521 /** |
|
10522 * Returns the block attributes of a registered block node given its type. |
|
10523 * |
|
10524 * @param {string|Object} blockTypeOrName Block type or name. |
|
10525 * @param {string} innerHTML Raw block content. |
|
10526 * @param {?Object} attributes Known block attributes (from delimiters). |
|
10527 * |
|
10528 * @return {Object} All block attributes. |
|
10529 */ |
|
10530 |
|
10531 function getBlockAttributes(blockTypeOrName, innerHTML) { |
|
10532 var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; |
|
10533 var blockType = normalizeBlockType(blockTypeOrName); |
|
10534 var blockAttributes = Object(external_this_lodash_["mapValues"])(blockType.attributes, function (attributeSchema, attributeKey) { |
|
10535 return getBlockAttribute(attributeKey, attributeSchema, innerHTML, attributes); |
|
10536 }); |
|
10537 return Object(external_this_wp_hooks_["applyFilters"])('blocks.getBlockAttributes', blockAttributes, blockType, innerHTML, attributes); |
|
10538 } |
|
10539 /** |
|
10540 * Given a block object, returns a new copy of the block with any applicable |
|
10541 * deprecated migrations applied, or the original block if it was both valid |
|
10542 * and no eligible migrations exist. |
|
10543 * |
|
10544 * @param {WPBlock} block Original block object. |
|
10545 * @param {Object} parsedAttributes Attributes as parsed from the initial |
|
10546 * block markup. |
|
10547 * |
|
10548 * @return {WPBlock} Migrated block object. |
|
10549 */ |
|
10550 |
|
10551 function getMigratedBlock(block, parsedAttributes) { |
|
10552 var blockType = registration_getBlockType(block.name); |
|
10553 var deprecatedDefinitions = blockType.deprecated; |
|
10554 |
|
10555 if (!deprecatedDefinitions || !deprecatedDefinitions.length) { |
|
10556 return block; |
|
10557 } |
|
10558 |
|
10559 var _block = block, |
|
10560 originalContent = _block.originalContent, |
|
10561 innerBlocks = _block.innerBlocks; |
|
10562 |
|
10563 for (var i = 0; i < deprecatedDefinitions.length; i++) { |
|
10564 // A block can opt into a migration even if the block is valid by |
|
10565 // defining isEligible on its deprecation. If the block is both valid |
|
10566 // and does not opt to migrate, skip. |
|
10567 var _deprecatedDefinition = deprecatedDefinitions[i].isEligible, |
|
10568 isEligible = _deprecatedDefinition === void 0 ? external_this_lodash_["stubFalse"] : _deprecatedDefinition; |
|
10569 |
|
10570 if (block.isValid && !isEligible(parsedAttributes, innerBlocks)) { |
|
10571 continue; |
|
10572 } // Block type properties which could impact either serialization or |
|
10573 // parsing are not considered in the deprecated block type by default, |
|
10574 // and must be explicitly provided. |
|
10575 |
|
10576 |
|
10577 var deprecatedBlockType = Object.assign(Object(external_this_lodash_["omit"])(blockType, DEPRECATED_ENTRY_KEYS), deprecatedDefinitions[i]); |
|
10578 var migratedAttributes = getBlockAttributes(deprecatedBlockType, originalContent, parsedAttributes); // Ignore the deprecation if it produces a block which is not valid. |
|
10579 |
|
10580 var _getBlockContentValid = getBlockContentValidationResult(deprecatedBlockType, migratedAttributes, originalContent), |
|
10581 isValid = _getBlockContentValid.isValid, |
|
10582 validationIssues = _getBlockContentValid.validationIssues; |
|
10583 |
|
10584 if (!isValid) { |
|
10585 block = parser_objectSpread({}, block, { |
|
10586 validationIssues: [].concat(Object(toConsumableArray["a" /* default */])(Object(external_this_lodash_["get"])(block, 'validationIssues', [])), Object(toConsumableArray["a" /* default */])(validationIssues)) |
|
10587 }); |
|
10588 continue; |
|
10589 } |
|
10590 |
|
10591 var migratedInnerBlocks = innerBlocks; // A block may provide custom behavior to assign new attributes and/or |
|
10592 // inner blocks. |
|
10593 |
|
10594 var migrate = deprecatedBlockType.migrate; |
|
10595 |
|
10596 if (migrate) { |
|
10597 var _castArray = Object(external_this_lodash_["castArray"])(migrate(migratedAttributes, innerBlocks)); |
|
10598 |
|
10599 var _castArray2 = Object(slicedToArray["a" /* default */])(_castArray, 2); |
|
10600 |
|
10601 var _castArray2$ = _castArray2[0]; |
|
10602 migratedAttributes = _castArray2$ === void 0 ? parsedAttributes : _castArray2$; |
|
10603 var _castArray2$2 = _castArray2[1]; |
|
10604 migratedInnerBlocks = _castArray2$2 === void 0 ? innerBlocks : _castArray2$2; |
|
10605 } |
|
10606 |
|
10607 block = parser_objectSpread({}, block, { |
|
10608 attributes: migratedAttributes, |
|
10609 innerBlocks: migratedInnerBlocks, |
|
10610 isValid: true |
|
10611 }); |
|
10612 } |
|
10613 |
|
10614 return block; |
|
10615 } |
|
10616 /** |
|
10617 * Creates a block with fallback to the unknown type handler. |
|
10618 * |
|
10619 * @param {Object} blockNode Parsed block node. |
|
10620 * |
|
10621 * @return {?Object} An initialized block object (if possible). |
|
10622 */ |
|
10623 |
|
10624 function createBlockWithFallback(blockNode) { |
|
10625 var originalName = blockNode.blockName; |
|
10626 var attributes = blockNode.attrs, |
|
10627 _blockNode$innerBlock = blockNode.innerBlocks, |
|
10628 innerBlocks = _blockNode$innerBlock === void 0 ? [] : _blockNode$innerBlock, |
|
10629 innerHTML = blockNode.innerHTML; |
|
10630 var innerContent = blockNode.innerContent; |
|
10631 var freeformContentFallbackBlock = getFreeformContentHandlerName(); |
|
10632 var unregisteredFallbackBlock = getUnregisteredTypeHandlerName() || freeformContentFallbackBlock; |
|
10633 attributes = attributes || {}; // Trim content to avoid creation of intermediary freeform segments. |
|
10634 |
|
10635 innerHTML = innerHTML.trim(); // Use type from block content if available. Otherwise, default to the |
|
10636 // freeform content fallback. |
|
10637 |
|
10638 var name = originalName || freeformContentFallbackBlock; // Convert 'core/cover-image' block in existing content to 'core/cover'. |
|
10639 |
|
10640 if ('core/cover-image' === name) { |
|
10641 name = 'core/cover'; |
|
10642 } // Convert 'core/text' blocks in existing content to 'core/paragraph'. |
|
10643 |
|
10644 |
|
10645 if ('core/text' === name || 'core/cover-text' === name) { |
|
10646 name = 'core/paragraph'; |
|
10647 } // Convert derivative blocks such as 'core/social-link-wordpress' to the |
|
10648 // canonical form 'core/social-link'. |
|
10649 |
|
10650 |
|
10651 if (name && name.indexOf('core/social-link-') === 0) { |
|
10652 // Capture `social-link-wordpress` into `{"service":"wordpress"}` |
|
10653 attributes.service = name.substring(17); |
|
10654 name = 'core/social-link'; |
|
10655 } // Fallback content may be upgraded from classic editor expecting implicit |
|
10656 // automatic paragraphs, so preserve them. Assumes wpautop is idempotent, |
|
10657 // meaning there are no negative consequences to repeated autop calls. |
|
10658 |
|
10659 |
|
10660 if (name === freeformContentFallbackBlock) { |
|
10661 innerHTML = Object(external_this_wp_autop_["autop"])(innerHTML).trim(); |
|
10662 } // Try finding the type for known block name, else fall back again. |
|
10663 |
|
10664 |
|
10665 var blockType = registration_getBlockType(name); |
|
10666 |
|
10667 if (!blockType) { |
|
10668 // Since the constituents of the block node are extracted at the start |
|
10669 // of the present function, construct a new object rather than reuse |
|
10670 // `blockNode`. |
|
10671 var reconstitutedBlockNode = { |
|
10672 attrs: attributes, |
|
10673 blockName: originalName, |
|
10674 innerBlocks: innerBlocks, |
|
10675 innerContent: innerContent |
|
10676 }; // Preserve undelimited content for use by the unregistered type |
|
10677 // handler. A block node's `innerHTML` isn't enough, as that field only |
|
10678 // carries the block's own HTML and not its nested blocks'. |
|
10679 |
|
10680 var originalUndelimitedContent = serializeBlockNode(reconstitutedBlockNode, { |
|
10681 isCommentDelimited: false |
|
10682 }); // Preserve full block content for use by the unregistered type |
|
10683 // handler, block boundaries included. |
|
10684 |
|
10685 var originalContent = serializeBlockNode(reconstitutedBlockNode, { |
|
10686 isCommentDelimited: true |
|
10687 }); // If detected as a block which is not registered, preserve comment |
|
10688 // delimiters in content of unregistered type handler. |
|
10689 |
|
10690 if (name) { |
|
10691 innerHTML = originalContent; |
|
10692 } |
|
10693 |
|
10694 name = unregisteredFallbackBlock; |
|
10695 attributes = { |
|
10696 originalName: originalName, |
|
10697 originalContent: originalContent, |
|
10698 originalUndelimitedContent: originalUndelimitedContent |
|
10699 }; |
|
10700 blockType = registration_getBlockType(name); |
|
10701 } // Coerce inner blocks from parsed form to canonical form. |
|
10702 |
|
10703 |
|
10704 innerBlocks = innerBlocks.map(createBlockWithFallback); // Remove `undefined` innerBlocks. |
|
10705 // |
|
10706 // This is a temporary fix to prevent unrecoverable TypeErrors when handling unexpectedly |
|
10707 // empty freeform block nodes. See https://github.com/WordPress/gutenberg/pull/17164. |
|
10708 |
|
10709 innerBlocks = innerBlocks.filter(function (innerBlock) { |
|
10710 return innerBlock; |
|
10711 }); |
|
10712 var isFallbackBlock = name === freeformContentFallbackBlock || name === unregisteredFallbackBlock; // Include in set only if type was determined. |
|
10713 |
|
10714 if (!blockType || !innerHTML && isFallbackBlock) { |
|
10715 return; |
|
10716 } |
|
10717 |
|
10718 var block = createBlock(name, getBlockAttributes(blockType, innerHTML, attributes), innerBlocks); // Block validation assumes an idempotent operation from source block to serialized block |
|
10719 // provided there are no changes in attributes. The validation procedure thus compares the |
|
10720 // provided source value with the serialized output before there are any modifications to |
|
10721 // the block. When both match, the block is marked as valid. |
|
10722 |
|
10723 if (!isFallbackBlock) { |
|
10724 var _getBlockContentValid2 = getBlockContentValidationResult(blockType, block.attributes, innerHTML), |
|
10725 isValid = _getBlockContentValid2.isValid, |
|
10726 validationIssues = _getBlockContentValid2.validationIssues; |
|
10727 |
|
10728 block.isValid = isValid; |
|
10729 block.validationIssues = validationIssues; |
|
10730 } // Preserve original content for future use in case the block is parsed |
|
10731 // as invalid, or future serialization attempt results in an error. |
|
10732 |
|
10733 |
|
10734 block.originalContent = block.originalContent || innerHTML; |
|
10735 block = getMigratedBlock(block, attributes); |
|
10736 |
|
10737 if (block.validationIssues && block.validationIssues.length > 0) { |
|
10738 if (block.isValid) { |
|
10739 // eslint-disable-next-line no-console |
|
10740 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); |
|
10741 } else { |
|
10742 block.validationIssues.forEach(function (_ref) { |
|
10743 var log = _ref.log, |
|
10744 args = _ref.args; |
|
10745 return log.apply(void 0, Object(toConsumableArray["a" /* default */])(args)); |
|
10746 }); |
|
10747 } |
|
10748 } |
|
10749 |
|
10750 return block; |
|
10751 } |
|
10752 /** |
|
10753 * Serializes a block node into the native HTML-comment-powered block format. |
|
10754 * CAVEAT: This function is intended for reserializing blocks as parsed by |
|
10755 * valid parsers and skips any validation steps. This is NOT a generic |
|
10756 * serialization function for in-memory blocks. For most purposes, see the |
|
10757 * following functions available in the `@wordpress/blocks` package: |
|
10758 * |
|
10759 * @see serializeBlock |
|
10760 * @see serialize |
|
10761 * |
|
10762 * For more on the format of block nodes as returned by valid parsers: |
|
10763 * |
|
10764 * @see `@wordpress/block-serialization-default-parser` package |
|
10765 * @see `@wordpress/block-serialization-spec-parser` package |
|
10766 * |
|
10767 * @param {Object} blockNode A block node as returned by a valid parser. |
|
10768 * @param {?Object} options Serialization options. |
|
10769 * @param {?boolean} options.isCommentDelimited Whether to output HTML comments around blocks. |
|
10770 * |
|
10771 * @return {string} An HTML string representing a block. |
|
10772 */ |
|
10773 |
|
10774 function serializeBlockNode(blockNode) { |
|
10775 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
10776 var _options$isCommentDel = options.isCommentDelimited, |
|
10777 isCommentDelimited = _options$isCommentDel === void 0 ? true : _options$isCommentDel; |
|
10778 var blockName = blockNode.blockName, |
|
10779 _blockNode$attrs = blockNode.attrs, |
|
10780 attrs = _blockNode$attrs === void 0 ? {} : _blockNode$attrs, |
|
10781 _blockNode$innerBlock2 = blockNode.innerBlocks, |
|
10782 innerBlocks = _blockNode$innerBlock2 === void 0 ? [] : _blockNode$innerBlock2, |
|
10783 _blockNode$innerConte = blockNode.innerContent, |
|
10784 innerContent = _blockNode$innerConte === void 0 ? [] : _blockNode$innerConte; |
|
10785 var childIndex = 0; |
|
10786 var content = innerContent.map(function (item) { |
|
10787 return (// `null` denotes a nested block, otherwise we have an HTML fragment |
|
10788 item !== null ? item : serializeBlockNode(innerBlocks[childIndex++], options) |
|
10789 ); |
|
10790 }).join('\n').replace(/\n+/g, '\n').trim(); |
|
10791 return isCommentDelimited ? getCommentDelimitedContent(blockName, attrs, content) : content; |
|
10792 } |
|
10793 /** |
|
10794 * Creates a parse implementation for the post content which returns a list of blocks. |
|
10795 * |
|
10796 * @param {Function} parseImplementation Parse implementation. |
|
10797 * |
|
10798 * @return {Function} An implementation which parses the post content. |
|
10799 */ |
|
10800 |
|
10801 var createParse = function createParse(parseImplementation) { |
|
10802 return function (content) { |
|
10803 return parseImplementation(content).reduce(function (accumulator, blockNode) { |
|
10804 var block = createBlockWithFallback(blockNode); |
|
10805 |
|
10806 if (block) { |
|
10807 accumulator.push(block); |
|
10808 } |
|
10809 |
|
10810 return accumulator; |
|
10811 }, []); |
|
10812 }; |
|
10813 }; |
|
10814 /** |
|
10815 * Parses the post content with a PegJS grammar and returns a list of blocks. |
|
10816 * |
|
10817 * @param {string} content The post content. |
|
10818 * |
|
10819 * @return {Array} Block list. |
|
10820 */ |
|
10821 |
|
10822 |
|
10823 var parseWithGrammar = createParse(external_this_wp_blockSerializationDefaultParser_["parse"]); |
|
10824 /* harmony default export */ var parser = (parseWithGrammar); |
|
10825 |
|
10826 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/phrasing-content.js |
|
10827 |
|
10828 |
|
10829 function phrasing_content_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
10830 |
|
10831 function phrasing_content_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { phrasing_content_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { phrasing_content_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
10832 |
|
10833 /** |
|
10834 * External dependencies |
|
10835 */ |
|
10836 |
|
10837 /** |
|
10838 * All phrasing content elements. |
|
10839 * |
|
10840 * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0 |
|
10841 */ |
|
10842 |
|
10843 /** |
|
10844 * All text-level semantic elements. |
|
10845 * |
|
10846 * @see https://html.spec.whatwg.org/multipage/text-level-semantics.html |
|
10847 */ |
|
10848 |
|
10849 var textContentSchema = { |
|
10850 strong: {}, |
|
10851 em: {}, |
|
10852 s: {}, |
|
10853 del: {}, |
|
10854 ins: {}, |
|
10855 a: { |
|
10856 attributes: ['href', 'target', 'rel'] |
|
10857 }, |
|
10858 code: {}, |
|
10859 abbr: { |
|
10860 attributes: ['title'] |
|
10861 }, |
|
10862 sub: {}, |
|
10863 sup: {}, |
|
10864 br: {}, |
|
10865 small: {}, |
|
10866 // To do: fix blockquote. |
|
10867 // cite: {}, |
|
10868 q: { |
|
10869 attributes: ['cite'] |
|
10870 }, |
|
10871 dfn: { |
|
10872 attributes: ['title'] |
|
10873 }, |
|
10874 data: { |
|
10875 attributes: ['value'] |
|
10876 }, |
|
10877 time: { |
|
10878 attributes: ['datetime'] |
|
10879 }, |
|
10880 var: {}, |
|
10881 samp: {}, |
|
10882 kbd: {}, |
|
10883 i: {}, |
|
10884 b: {}, |
|
10885 u: {}, |
|
10886 mark: {}, |
|
10887 ruby: {}, |
|
10888 rt: {}, |
|
10889 rp: {}, |
|
10890 bdi: { |
|
10891 attributes: ['dir'] |
|
10892 }, |
|
10893 bdo: { |
|
10894 attributes: ['dir'] |
|
10895 }, |
|
10896 wbr: {}, |
|
10897 '#text': {} |
|
10898 }; // Recursion is needed. |
|
10899 // Possible: strong > em > strong. |
|
10900 // Impossible: strong > strong. |
|
10901 |
|
10902 Object(external_this_lodash_["without"])(Object.keys(textContentSchema), '#text', 'br').forEach(function (tag) { |
|
10903 textContentSchema[tag].children = Object(external_this_lodash_["omit"])(textContentSchema, tag); |
|
10904 }); |
|
10905 /** |
|
10906 * Embedded content elements. |
|
10907 * |
|
10908 * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#embedded-content-0 |
|
10909 */ |
|
10910 |
|
10911 var embeddedContentSchema = { |
|
10912 audio: { |
|
10913 attributes: ['src', 'preload', 'autoplay', 'mediagroup', 'loop', 'muted'] |
|
10914 }, |
|
10915 canvas: { |
|
10916 attributes: ['width', 'height'] |
|
10917 }, |
|
10918 embed: { |
|
10919 attributes: ['src', 'type', 'width', 'height'] |
|
10920 }, |
|
10921 img: { |
|
10922 attributes: ['alt', 'src', 'srcset', 'usemap', 'ismap', 'width', 'height'] |
|
10923 }, |
|
10924 object: { |
|
10925 attributes: ['data', 'type', 'name', 'usemap', 'form', 'width', 'height'] |
|
10926 }, |
|
10927 video: { |
|
10928 attributes: ['src', 'poster', 'preload', 'autoplay', 'mediagroup', 'loop', 'muted', 'controls', 'width', 'height'] |
|
10929 } |
|
10930 }; |
|
10931 /** |
|
10932 * Phrasing content elements. |
|
10933 * |
|
10934 * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0 |
|
10935 */ |
|
10936 |
|
10937 var phrasing_content_phrasingContentSchema = phrasing_content_objectSpread({}, textContentSchema, {}, embeddedContentSchema); |
|
10938 /** |
|
10939 * Get schema of possible paths for phrasing content. |
|
10940 * |
|
10941 * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content |
|
10942 * |
|
10943 * @param {string} context Set to "paste" to exclude invisible elements and |
|
10944 * sensitive data. |
|
10945 * |
|
10946 * @return {Object} Schema. |
|
10947 */ |
|
10948 |
|
10949 |
|
10950 function getPhrasingContentSchema(context) { |
|
10951 if (context !== 'paste') { |
|
10952 return phrasing_content_phrasingContentSchema; |
|
10953 } |
|
10954 |
|
10955 return Object(external_this_lodash_["omit"])(phrasing_content_objectSpread({}, phrasing_content_phrasingContentSchema, { |
|
10956 // We shouldn't paste potentially sensitive information which is not |
|
10957 // visible to the user when pasted, so strip the attributes. |
|
10958 ins: { |
|
10959 children: phrasing_content_phrasingContentSchema.ins.children |
|
10960 }, |
|
10961 del: { |
|
10962 children: phrasing_content_phrasingContentSchema.del.children |
|
10963 } |
|
10964 }), ['u', // Used to mark misspelling. Shouldn't be pasted. |
|
10965 'abbr', // Invisible. |
|
10966 'data', // Invisible. |
|
10967 'time', // Invisible. |
|
10968 'wbr', // Invisible. |
|
10969 'bdi', // Invisible. |
|
10970 'bdo' // Invisible. |
|
10971 ]); |
|
10972 } |
|
10973 /** |
|
10974 * Find out whether or not the given node is phrasing content. |
|
10975 * |
|
10976 * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content |
|
10977 * |
|
10978 * @param {Element} node The node to test. |
|
10979 * |
|
10980 * @return {boolean} True if phrasing content, false if not. |
|
10981 */ |
|
10982 |
|
10983 function isPhrasingContent(node) { |
|
10984 var tag = node.nodeName.toLowerCase(); |
|
10985 return getPhrasingContentSchema().hasOwnProperty(tag) || tag === 'span'; |
|
10986 } |
|
10987 function isTextContent(node) { |
|
10988 var tag = node.nodeName.toLowerCase(); |
|
10989 return textContentSchema.hasOwnProperty(tag) || tag === 'span'; |
|
10990 } |
|
10991 |
|
10992 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/utils.js |
|
10993 |
|
10994 |
|
10995 |
|
10996 function raw_handling_utils_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
10997 |
|
10998 function raw_handling_utils_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { raw_handling_utils_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { raw_handling_utils_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
10999 |
|
11000 /** |
|
11001 * External dependencies |
|
11002 */ |
|
11003 |
|
11004 /** |
|
11005 * WordPress dependencies |
|
11006 */ |
|
11007 |
|
11008 |
|
11009 /** |
|
11010 * Internal dependencies |
|
11011 */ |
|
11012 |
|
11013 |
|
11014 |
|
11015 /** |
|
11016 * Browser dependencies |
|
11017 */ |
|
11018 |
|
11019 var utils_window$Node = window.Node, |
|
11020 utils_ELEMENT_NODE = utils_window$Node.ELEMENT_NODE, |
|
11021 utils_TEXT_NODE = utils_window$Node.TEXT_NODE; |
|
11022 /** |
|
11023 * Given raw transforms from blocks, merges all schemas into one. |
|
11024 * |
|
11025 * @param {Array} transforms Block transforms, of the `raw` type. |
|
11026 * @param {Object} phrasingContentSchema The phrasing content schema. |
|
11027 * @param {Object} isPaste Whether the context is pasting or not. |
|
11028 * |
|
11029 * @return {Object} A complete block content schema. |
|
11030 */ |
|
11031 |
|
11032 function getBlockContentSchema(transforms, phrasingContentSchema, isPaste) { |
|
11033 var schemas = transforms.map(function (_ref) { |
|
11034 var isMatch = _ref.isMatch, |
|
11035 blockName = _ref.blockName, |
|
11036 schema = _ref.schema; |
|
11037 var hasAnchorSupport = registration_hasBlockSupport(blockName, 'anchor'); |
|
11038 schema = Object(external_this_lodash_["isFunction"])(schema) ? schema({ |
|
11039 phrasingContentSchema: phrasingContentSchema, |
|
11040 isPaste: isPaste |
|
11041 }) : schema; // If the block does not has anchor support and the transform does not |
|
11042 // provides an isMatch we can return the schema right away. |
|
11043 |
|
11044 if (!hasAnchorSupport && !isMatch) { |
|
11045 return schema; |
|
11046 } |
|
11047 |
|
11048 return Object(external_this_lodash_["mapValues"])(schema, function (value) { |
|
11049 var attributes = value.attributes || []; // If the block supports the "anchor" functionality, it needs to keep its ID attribute. |
|
11050 |
|
11051 if (hasAnchorSupport) { |
|
11052 attributes = [].concat(Object(toConsumableArray["a" /* default */])(attributes), ['id']); |
|
11053 } |
|
11054 |
|
11055 return raw_handling_utils_objectSpread({}, value, { |
|
11056 attributes: attributes, |
|
11057 isMatch: isMatch ? isMatch : undefined |
|
11058 }); |
|
11059 }); |
|
11060 }); |
|
11061 return external_this_lodash_["mergeWith"].apply(void 0, [{}].concat(Object(toConsumableArray["a" /* default */])(schemas), [function (objValue, srcValue, key) { |
|
11062 switch (key) { |
|
11063 case 'children': |
|
11064 { |
|
11065 if (objValue === '*' || srcValue === '*') { |
|
11066 return '*'; |
|
11067 } |
|
11068 |
|
11069 return raw_handling_utils_objectSpread({}, objValue, {}, srcValue); |
|
11070 } |
|
11071 |
|
11072 case 'attributes': |
|
11073 case 'require': |
|
11074 { |
|
11075 return [].concat(Object(toConsumableArray["a" /* default */])(objValue || []), Object(toConsumableArray["a" /* default */])(srcValue || [])); |
|
11076 } |
|
11077 |
|
11078 case 'isMatch': |
|
11079 { |
|
11080 // If one of the values being merge is undefined (matches everything), |
|
11081 // the result of the merge will be undefined. |
|
11082 if (!objValue || !srcValue) { |
|
11083 return undefined; |
|
11084 } // When merging two isMatch functions, the result is a new function |
|
11085 // that returns if one of the source functions returns true. |
|
11086 |
|
11087 |
|
11088 return function () { |
|
11089 return objValue.apply(void 0, arguments) || srcValue.apply(void 0, arguments); |
|
11090 }; |
|
11091 } |
|
11092 } |
|
11093 }])); |
|
11094 } |
|
11095 /** |
|
11096 * Recursively checks if an element is empty. An element is not empty if it |
|
11097 * contains text or contains elements with attributes such as images. |
|
11098 * |
|
11099 * @param {Element} element The element to check. |
|
11100 * |
|
11101 * @return {boolean} Wether or not the element is empty. |
|
11102 */ |
|
11103 |
|
11104 function isEmpty(element) { |
|
11105 if (!element.hasChildNodes()) { |
|
11106 return true; |
|
11107 } |
|
11108 |
|
11109 return Array.from(element.childNodes).every(function (node) { |
|
11110 if (node.nodeType === utils_TEXT_NODE) { |
|
11111 return !node.nodeValue.trim(); |
|
11112 } |
|
11113 |
|
11114 if (node.nodeType === utils_ELEMENT_NODE) { |
|
11115 if (node.nodeName === 'BR') { |
|
11116 return true; |
|
11117 } else if (node.hasAttributes()) { |
|
11118 return false; |
|
11119 } |
|
11120 |
|
11121 return isEmpty(node); |
|
11122 } |
|
11123 |
|
11124 return true; |
|
11125 }); |
|
11126 } |
|
11127 /** |
|
11128 * Checks wether HTML can be considered plain text. That is, it does not contain |
|
11129 * any elements that are not line breaks. |
|
11130 * |
|
11131 * @param {string} HTML The HTML to check. |
|
11132 * |
|
11133 * @return {boolean} Wether the HTML can be considered plain text. |
|
11134 */ |
|
11135 |
|
11136 function isPlain(HTML) { |
|
11137 return !/<(?!br[ />])/i.test(HTML); |
|
11138 } |
|
11139 /** |
|
11140 * Given node filters, deeply filters and mutates a NodeList. |
|
11141 * |
|
11142 * @param {NodeList} nodeList The nodeList to filter. |
|
11143 * @param {Array} filters An array of functions that can mutate with the provided node. |
|
11144 * @param {Document} doc The document of the nodeList. |
|
11145 * @param {Object} schema The schema to use. |
|
11146 */ |
|
11147 |
|
11148 function deepFilterNodeList(nodeList, filters, doc, schema) { |
|
11149 Array.from(nodeList).forEach(function (node) { |
|
11150 deepFilterNodeList(node.childNodes, filters, doc, schema); |
|
11151 filters.forEach(function (item) { |
|
11152 // Make sure the node is still attached to the document. |
|
11153 if (!doc.contains(node)) { |
|
11154 return; |
|
11155 } |
|
11156 |
|
11157 item(node, doc, schema); |
|
11158 }); |
|
11159 }); |
|
11160 } |
|
11161 /** |
|
11162 * Given node filters, deeply filters HTML tags. |
|
11163 * Filters from the deepest nodes to the top. |
|
11164 * |
|
11165 * @param {string} HTML The HTML to filter. |
|
11166 * @param {Array} filters An array of functions that can mutate with the provided node. |
|
11167 * @param {Object} schema The schema to use. |
|
11168 * |
|
11169 * @return {string} The filtered HTML. |
|
11170 */ |
|
11171 |
|
11172 function deepFilterHTML(HTML) { |
|
11173 var filters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; |
|
11174 var schema = arguments.length > 2 ? arguments[2] : undefined; |
|
11175 var doc = document.implementation.createHTMLDocument(''); |
|
11176 doc.body.innerHTML = HTML; |
|
11177 deepFilterNodeList(doc.body.childNodes, filters, doc, schema); |
|
11178 return doc.body.innerHTML; |
|
11179 } |
|
11180 /** |
|
11181 * Given a schema, unwraps or removes nodes, attributes and classes on a node |
|
11182 * list. |
|
11183 * |
|
11184 * @param {NodeList} nodeList The nodeList to filter. |
|
11185 * @param {Document} doc The document of the nodeList. |
|
11186 * @param {Object} schema An array of functions that can mutate with the provided node. |
|
11187 * @param {Object} inline Whether to clean for inline mode. |
|
11188 */ |
|
11189 |
|
11190 function cleanNodeList(nodeList, doc, schema, inline) { |
|
11191 Array.from(nodeList).forEach(function (node) { |
|
11192 var tag = node.nodeName.toLowerCase(); // It's a valid child, if the tag exists in the schema without an isMatch |
|
11193 // function, or with an isMatch function that matches the node. |
|
11194 |
|
11195 if (schema.hasOwnProperty(tag) && (!schema[tag].isMatch || schema[tag].isMatch(node))) { |
|
11196 if (node.nodeType === utils_ELEMENT_NODE) { |
|
11197 var _schema$tag = schema[tag], |
|
11198 _schema$tag$attribute = _schema$tag.attributes, |
|
11199 attributes = _schema$tag$attribute === void 0 ? [] : _schema$tag$attribute, |
|
11200 _schema$tag$classes = _schema$tag.classes, |
|
11201 classes = _schema$tag$classes === void 0 ? [] : _schema$tag$classes, |
|
11202 children = _schema$tag.children, |
|
11203 _schema$tag$require = _schema$tag.require, |
|
11204 require = _schema$tag$require === void 0 ? [] : _schema$tag$require, |
|
11205 allowEmpty = _schema$tag.allowEmpty; // If the node is empty and it's supposed to have children, |
|
11206 // remove the node. |
|
11207 |
|
11208 |
|
11209 if (children && !allowEmpty && isEmpty(node)) { |
|
11210 Object(external_this_wp_dom_["remove"])(node); |
|
11211 return; |
|
11212 } |
|
11213 |
|
11214 if (node.hasAttributes()) { |
|
11215 // Strip invalid attributes. |
|
11216 Array.from(node.attributes).forEach(function (_ref2) { |
|
11217 var name = _ref2.name; |
|
11218 |
|
11219 if (name !== 'class' && !Object(external_this_lodash_["includes"])(attributes, name)) { |
|
11220 node.removeAttribute(name); |
|
11221 } |
|
11222 }); // Strip invalid classes. |
|
11223 // In jsdom-jscore, 'node.classList' can be undefined. |
|
11224 // TODO: Explore patching this in jsdom-jscore. |
|
11225 |
|
11226 if (node.classList && node.classList.length) { |
|
11227 var mattchers = classes.map(function (item) { |
|
11228 if (typeof item === 'string') { |
|
11229 return function (className) { |
|
11230 return className === item; |
|
11231 }; |
|
11232 } else if (item instanceof RegExp) { |
|
11233 return function (className) { |
|
11234 return item.test(className); |
|
11235 }; |
|
11236 } |
|
11237 |
|
11238 return external_this_lodash_["noop"]; |
|
11239 }); |
|
11240 Array.from(node.classList).forEach(function (name) { |
|
11241 if (!mattchers.some(function (isMatch) { |
|
11242 return isMatch(name); |
|
11243 })) { |
|
11244 node.classList.remove(name); |
|
11245 } |
|
11246 }); |
|
11247 |
|
11248 if (!node.classList.length) { |
|
11249 node.removeAttribute('class'); |
|
11250 } |
|
11251 } |
|
11252 } |
|
11253 |
|
11254 if (node.hasChildNodes()) { |
|
11255 // Do not filter any content. |
|
11256 if (children === '*') { |
|
11257 return; |
|
11258 } // Continue if the node is supposed to have children. |
|
11259 |
|
11260 |
|
11261 if (children) { |
|
11262 // If a parent requires certain children, but it does |
|
11263 // not have them, drop the parent and continue. |
|
11264 if (require.length && !node.querySelector(require.join(','))) { |
|
11265 cleanNodeList(node.childNodes, doc, schema, inline); |
|
11266 Object(external_this_wp_dom_["unwrap"])(node); // If the node is at the top, phrasing content, and |
|
11267 // contains children that are block content, unwrap |
|
11268 // the node because it is invalid. |
|
11269 } else if (node.parentNode.nodeName === 'BODY' && isPhrasingContent(node)) { |
|
11270 cleanNodeList(node.childNodes, doc, schema, inline); |
|
11271 |
|
11272 if (Array.from(node.childNodes).some(function (child) { |
|
11273 return !isPhrasingContent(child); |
|
11274 })) { |
|
11275 Object(external_this_wp_dom_["unwrap"])(node); |
|
11276 } |
|
11277 } else { |
|
11278 cleanNodeList(node.childNodes, doc, children, inline); |
|
11279 } // Remove children if the node is not supposed to have any. |
|
11280 |
|
11281 } else { |
|
11282 while (node.firstChild) { |
|
11283 Object(external_this_wp_dom_["remove"])(node.firstChild); |
|
11284 } |
|
11285 } |
|
11286 } |
|
11287 } // Invalid child. Continue with schema at the same place and unwrap. |
|
11288 |
|
11289 } else { |
|
11290 cleanNodeList(node.childNodes, doc, schema, inline); // For inline mode, insert a line break when unwrapping nodes that |
|
11291 // are not phrasing content. |
|
11292 |
|
11293 if (inline && !isPhrasingContent(node) && node.nextElementSibling) { |
|
11294 Object(external_this_wp_dom_["insertAfter"])(doc.createElement('br'), node); |
|
11295 } |
|
11296 |
|
11297 Object(external_this_wp_dom_["unwrap"])(node); |
|
11298 } |
|
11299 }); |
|
11300 } |
|
11301 /** |
|
11302 * Given a schema, unwraps or removes nodes, attributes and classes on HTML. |
|
11303 * |
|
11304 * @param {string} HTML The HTML to clean up. |
|
11305 * @param {Object} schema Schema for the HTML. |
|
11306 * @param {Object} inline Whether to clean for inline mode. |
|
11307 * |
|
11308 * @return {string} The cleaned up HTML. |
|
11309 */ |
|
11310 |
|
11311 |
|
11312 function removeInvalidHTML(HTML, schema, inline) { |
|
11313 var doc = document.implementation.createHTMLDocument(''); |
|
11314 doc.body.innerHTML = HTML; |
|
11315 cleanNodeList(doc.body.childNodes, doc, schema, inline); |
|
11316 return doc.body.innerHTML; |
|
11317 } |
|
11318 /** |
|
11319 * Gets a sibling within text-level context. |
|
11320 * |
|
11321 * @param {Element} node The subject node. |
|
11322 * @param {string} which "next" or "previous". |
|
11323 */ |
|
11324 |
|
11325 function getSibling(node, which) { |
|
11326 var sibling = node["".concat(which, "Sibling")]; |
|
11327 |
|
11328 if (sibling && isPhrasingContent(sibling)) { |
|
11329 return sibling; |
|
11330 } |
|
11331 |
|
11332 var parentNode = node.parentNode; |
|
11333 |
|
11334 if (!parentNode || !isPhrasingContent(parentNode)) { |
|
11335 return; |
|
11336 } |
|
11337 |
|
11338 return getSibling(parentNode, which); |
|
11339 } |
|
11340 |
|
11341 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/normalise-blocks.js |
|
11342 /** |
|
11343 * Internal dependencies |
|
11344 */ |
|
11345 |
|
11346 |
|
11347 /** |
|
11348 * Browser dependencies |
|
11349 */ |
|
11350 |
|
11351 var normalise_blocks_window$Node = window.Node, |
|
11352 normalise_blocks_ELEMENT_NODE = normalise_blocks_window$Node.ELEMENT_NODE, |
|
11353 normalise_blocks_TEXT_NODE = normalise_blocks_window$Node.TEXT_NODE; |
|
11354 function normaliseBlocks(HTML) { |
|
11355 var decuDoc = document.implementation.createHTMLDocument(''); |
|
11356 var accuDoc = document.implementation.createHTMLDocument(''); |
|
11357 var decu = decuDoc.body; |
|
11358 var accu = accuDoc.body; |
|
11359 decu.innerHTML = HTML; |
|
11360 |
|
11361 while (decu.firstChild) { |
|
11362 var node = decu.firstChild; // Text nodes: wrap in a paragraph, or append to previous. |
|
11363 |
|
11364 if (node.nodeType === normalise_blocks_TEXT_NODE) { |
|
11365 if (!node.nodeValue.trim()) { |
|
11366 decu.removeChild(node); |
|
11367 } else { |
|
11368 if (!accu.lastChild || accu.lastChild.nodeName !== 'P') { |
|
11369 accu.appendChild(accuDoc.createElement('P')); |
|
11370 } |
|
11371 |
|
11372 accu.lastChild.appendChild(node); |
|
11373 } // Element nodes. |
|
11374 |
|
11375 } else if (node.nodeType === normalise_blocks_ELEMENT_NODE) { |
|
11376 // BR nodes: create a new paragraph on double, or append to previous. |
|
11377 if (node.nodeName === 'BR') { |
|
11378 if (node.nextSibling && node.nextSibling.nodeName === 'BR') { |
|
11379 accu.appendChild(accuDoc.createElement('P')); |
|
11380 decu.removeChild(node.nextSibling); |
|
11381 } // Don't append to an empty paragraph. |
|
11382 |
|
11383 |
|
11384 if (accu.lastChild && accu.lastChild.nodeName === 'P' && accu.lastChild.hasChildNodes()) { |
|
11385 accu.lastChild.appendChild(node); |
|
11386 } else { |
|
11387 decu.removeChild(node); |
|
11388 } |
|
11389 } else if (node.nodeName === 'P') { |
|
11390 // Only append non-empty paragraph nodes. |
|
11391 if (isEmpty(node)) { |
|
11392 decu.removeChild(node); |
|
11393 } else { |
|
11394 accu.appendChild(node); |
|
11395 } |
|
11396 } else if (isPhrasingContent(node)) { |
|
11397 if (!accu.lastChild || accu.lastChild.nodeName !== 'P') { |
|
11398 accu.appendChild(accuDoc.createElement('P')); |
|
11399 } |
|
11400 |
|
11401 accu.lastChild.appendChild(node); |
|
11402 } else { |
|
11403 accu.appendChild(node); |
|
11404 } |
|
11405 } else { |
|
11406 decu.removeChild(node); |
|
11407 } |
|
11408 } |
|
11409 |
|
11410 return accu.innerHTML; |
|
11411 } |
|
11412 |
|
11413 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/special-comment-converter.js |
|
11414 /** |
|
11415 * WordPress dependencies |
|
11416 */ |
|
11417 |
|
11418 /** |
|
11419 * Browser dependencies |
|
11420 */ |
|
11421 |
|
11422 var COMMENT_NODE = window.Node.COMMENT_NODE; |
|
11423 /** |
|
11424 * Looks for `<!--nextpage-->` and `<!--more-->` comments, as well as the |
|
11425 * `<!--more Some text-->` variant and its `<!--noteaser-->` companion, |
|
11426 * and replaces them with a custom element representing a future block. |
|
11427 * |
|
11428 * The custom element is a way to bypass the rest of the `raw-handling` |
|
11429 * transforms, which would eliminate other kinds of node with which to carry |
|
11430 * `<!--more-->`'s data: nodes with `data` attributes, empty paragraphs, etc. |
|
11431 * |
|
11432 * The custom element is then expected to be recognized by any registered |
|
11433 * block's `raw` transform. |
|
11434 * |
|
11435 * @param {Node} node The node to be processed. |
|
11436 * @param {Document} doc The document of the node. |
|
11437 * @return {void} |
|
11438 */ |
|
11439 |
|
11440 function specialCommentConverter(node, doc) { |
|
11441 if (node.nodeType !== COMMENT_NODE) { |
|
11442 return; |
|
11443 } |
|
11444 |
|
11445 if (node.nodeValue === 'nextpage') { |
|
11446 Object(external_this_wp_dom_["replace"])(node, createNextpage(doc)); |
|
11447 return; |
|
11448 } |
|
11449 |
|
11450 if (node.nodeValue.indexOf('more') === 0) { |
|
11451 // Grab any custom text in the comment. |
|
11452 var customText = node.nodeValue.slice(4).trim(); |
|
11453 /* |
|
11454 * When a `<!--more-->` comment is found, we need to look for any |
|
11455 * `<!--noteaser-->` sibling, but it may not be a direct sibling |
|
11456 * (whitespace typically lies in between) |
|
11457 */ |
|
11458 |
|
11459 var sibling = node; |
|
11460 var noTeaser = false; |
|
11461 |
|
11462 while (sibling = sibling.nextSibling) { |
|
11463 if (sibling.nodeType === COMMENT_NODE && sibling.nodeValue === 'noteaser') { |
|
11464 noTeaser = true; |
|
11465 Object(external_this_wp_dom_["remove"])(sibling); |
|
11466 break; |
|
11467 } |
|
11468 } |
|
11469 |
|
11470 Object(external_this_wp_dom_["replace"])(node, createMore(customText, noTeaser, doc)); |
|
11471 } |
|
11472 } |
|
11473 |
|
11474 function createMore(customText, noTeaser, doc) { |
|
11475 var node = doc.createElement('wp-block'); |
|
11476 node.dataset.block = 'core/more'; |
|
11477 |
|
11478 if (customText) { |
|
11479 node.dataset.customText = customText; |
|
11480 } |
|
11481 |
|
11482 if (noTeaser) { |
|
11483 // "Boolean" data attribute |
|
11484 node.dataset.noTeaser = ''; |
|
11485 } |
|
11486 |
|
11487 return node; |
|
11488 } |
|
11489 |
|
11490 function createNextpage(doc) { |
|
11491 var node = doc.createElement('wp-block'); |
|
11492 node.dataset.block = 'core/nextpage'; |
|
11493 return node; |
|
11494 } |
|
11495 |
|
11496 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/comment-remover.js |
|
11497 /** |
|
11498 * WordPress dependencies |
|
11499 */ |
|
11500 |
|
11501 /** |
|
11502 * Browser dependencies |
|
11503 */ |
|
11504 |
|
11505 var comment_remover_COMMENT_NODE = window.Node.COMMENT_NODE; |
|
11506 /** |
|
11507 * Looks for comments, and removes them. |
|
11508 * |
|
11509 * @param {Node} node The node to be processed. |
|
11510 * @return {void} |
|
11511 */ |
|
11512 |
|
11513 function commentRemover(node) { |
|
11514 if (node.nodeType === comment_remover_COMMENT_NODE) { |
|
11515 Object(external_this_wp_dom_["remove"])(node); |
|
11516 } |
|
11517 } |
|
11518 |
|
11519 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/is-inline-content.js |
|
11520 /** |
|
11521 * External dependencies |
|
11522 */ |
|
11523 |
|
11524 /** |
|
11525 * Internal dependencies |
|
11526 */ |
|
11527 |
|
11528 |
|
11529 /** |
|
11530 * Checks if the given node should be considered inline content, optionally |
|
11531 * depending on a context tag. |
|
11532 * |
|
11533 * @param {Node} node Node name. |
|
11534 * @param {string} contextTag Tag name. |
|
11535 * |
|
11536 * @return {boolean} True if the node is inline content, false if nohe. |
|
11537 */ |
|
11538 |
|
11539 function isInline(node, contextTag) { |
|
11540 if (isTextContent(node)) { |
|
11541 return true; |
|
11542 } |
|
11543 |
|
11544 if (!contextTag) { |
|
11545 return false; |
|
11546 } |
|
11547 |
|
11548 var tag = node.nodeName.toLowerCase(); |
|
11549 var inlineWhitelistTagGroups = [['ul', 'li', 'ol'], ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']]; |
|
11550 return inlineWhitelistTagGroups.some(function (tagGroup) { |
|
11551 return Object(external_this_lodash_["difference"])([tag, contextTag], tagGroup).length === 0; |
|
11552 }); |
|
11553 } |
|
11554 |
|
11555 function deepCheck(nodes, contextTag) { |
|
11556 return nodes.every(function (node) { |
|
11557 return isInline(node, contextTag) && deepCheck(Array.from(node.children), contextTag); |
|
11558 }); |
|
11559 } |
|
11560 |
|
11561 function isDoubleBR(node) { |
|
11562 return node.nodeName === 'BR' && node.previousSibling && node.previousSibling.nodeName === 'BR'; |
|
11563 } |
|
11564 |
|
11565 function isInlineContent(HTML, contextTag) { |
|
11566 var doc = document.implementation.createHTMLDocument(''); |
|
11567 doc.body.innerHTML = HTML; |
|
11568 var nodes = Array.from(doc.body.children); |
|
11569 return !nodes.some(isDoubleBR) && deepCheck(nodes, contextTag); |
|
11570 } |
|
11571 |
|
11572 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/phrasing-content-reducer.js |
|
11573 /** |
|
11574 * External dependencies |
|
11575 */ |
|
11576 |
|
11577 /** |
|
11578 * WordPress dependencies |
|
11579 */ |
|
11580 |
|
11581 |
|
11582 function phrasingContentReducer(node, doc) { |
|
11583 // In jsdom-jscore, 'node.style' can be null. |
|
11584 // TODO: Explore fixing this by patching jsdom-jscore. |
|
11585 if (node.nodeName === 'SPAN' && node.style) { |
|
11586 var _node$style = node.style, |
|
11587 fontWeight = _node$style.fontWeight, |
|
11588 fontStyle = _node$style.fontStyle, |
|
11589 textDecorationLine = _node$style.textDecorationLine, |
|
11590 textDecoration = _node$style.textDecoration, |
|
11591 verticalAlign = _node$style.verticalAlign; |
|
11592 |
|
11593 if (fontWeight === 'bold' || fontWeight === '700') { |
|
11594 Object(external_this_wp_dom_["wrap"])(doc.createElement('strong'), node); |
|
11595 } |
|
11596 |
|
11597 if (fontStyle === 'italic') { |
|
11598 Object(external_this_wp_dom_["wrap"])(doc.createElement('em'), node); |
|
11599 } // Some DOM implementations (Safari, JSDom) don't support |
|
11600 // style.textDecorationLine, so we check style.textDecoration as a |
|
11601 // fallback. |
|
11602 |
|
11603 |
|
11604 if (textDecorationLine === 'line-through' || Object(external_this_lodash_["includes"])(textDecoration, 'line-through')) { |
|
11605 Object(external_this_wp_dom_["wrap"])(doc.createElement('s'), node); |
|
11606 } |
|
11607 |
|
11608 if (verticalAlign === 'super') { |
|
11609 Object(external_this_wp_dom_["wrap"])(doc.createElement('sup'), node); |
|
11610 } else if (verticalAlign === 'sub') { |
|
11611 Object(external_this_wp_dom_["wrap"])(doc.createElement('sub'), node); |
|
11612 } |
|
11613 } else if (node.nodeName === 'B') { |
|
11614 node = Object(external_this_wp_dom_["replaceTag"])(node, 'strong'); |
|
11615 } else if (node.nodeName === 'I') { |
|
11616 node = Object(external_this_wp_dom_["replaceTag"])(node, 'em'); |
|
11617 } else if (node.nodeName === 'A') { |
|
11618 // In jsdom-jscore, 'node.target' can be null. |
|
11619 // TODO: Explore fixing this by patching jsdom-jscore. |
|
11620 if (node.target && node.target.toLowerCase() === '_blank') { |
|
11621 node.rel = 'noreferrer noopener'; |
|
11622 } else { |
|
11623 node.removeAttribute('target'); |
|
11624 node.removeAttribute('rel'); |
|
11625 } |
|
11626 } |
|
11627 } |
|
11628 |
|
11629 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/head-remover.js |
|
11630 function headRemover(node) { |
|
11631 if (node.nodeName !== 'SCRIPT' && node.nodeName !== 'NOSCRIPT' && node.nodeName !== 'TEMPLATE' && node.nodeName !== 'STYLE') { |
|
11632 return; |
|
11633 } |
|
11634 |
|
11635 node.parentNode.removeChild(node); |
|
11636 } |
|
11637 |
|
11638 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/ms-list-converter.js |
|
11639 /** |
|
11640 * Browser dependencies |
|
11641 */ |
|
11642 var _window = window, |
|
11643 ms_list_converter_parseInt = _window.parseInt; |
|
11644 |
|
11645 function isList(node) { |
|
11646 return node.nodeName === 'OL' || node.nodeName === 'UL'; |
|
11647 } |
|
11648 |
|
11649 function msListConverter(node, doc) { |
|
11650 if (node.nodeName !== 'P') { |
|
11651 return; |
|
11652 } |
|
11653 |
|
11654 var style = node.getAttribute('style'); |
|
11655 |
|
11656 if (!style) { |
|
11657 return; |
|
11658 } // Quick check. |
|
11659 |
|
11660 |
|
11661 if (style.indexOf('mso-list') === -1) { |
|
11662 return; |
|
11663 } |
|
11664 |
|
11665 var matches = /mso-list\s*:[^;]+level([0-9]+)/i.exec(style); |
|
11666 |
|
11667 if (!matches) { |
|
11668 return; |
|
11669 } |
|
11670 |
|
11671 var level = ms_list_converter_parseInt(matches[1], 10) - 1 || 0; |
|
11672 var prevNode = node.previousElementSibling; // Add new list if no previous. |
|
11673 |
|
11674 if (!prevNode || !isList(prevNode)) { |
|
11675 // See https://html.spec.whatwg.org/multipage/grouping-content.html#attr-ol-type. |
|
11676 var type = node.textContent.trim().slice(0, 1); |
|
11677 var isNumeric = /[1iIaA]/.test(type); |
|
11678 var newListNode = doc.createElement(isNumeric ? 'ol' : 'ul'); |
|
11679 |
|
11680 if (isNumeric) { |
|
11681 newListNode.setAttribute('type', type); |
|
11682 } |
|
11683 |
|
11684 node.parentNode.insertBefore(newListNode, node); |
|
11685 } |
|
11686 |
|
11687 var listNode = node.previousElementSibling; |
|
11688 var listType = listNode.nodeName; |
|
11689 var listItem = doc.createElement('li'); |
|
11690 var receivingNode = listNode; // Remove the first span with list info. |
|
11691 |
|
11692 node.removeChild(node.firstElementChild); // Add content. |
|
11693 |
|
11694 while (node.firstChild) { |
|
11695 listItem.appendChild(node.firstChild); |
|
11696 } // Change pointer depending on indentation level. |
|
11697 |
|
11698 |
|
11699 while (level--) { |
|
11700 receivingNode = receivingNode.lastElementChild || receivingNode; // If it's a list, move pointer to the last item. |
|
11701 |
|
11702 if (isList(receivingNode)) { |
|
11703 receivingNode = receivingNode.lastElementChild || receivingNode; |
|
11704 } |
|
11705 } // Make sure we append to a list. |
|
11706 |
|
11707 |
|
11708 if (!isList(receivingNode)) { |
|
11709 receivingNode = receivingNode.appendChild(doc.createElement(listType)); |
|
11710 } // Append the list item to the list. |
|
11711 |
|
11712 |
|
11713 receivingNode.appendChild(listItem); // Remove the wrapper paragraph. |
|
11714 |
|
11715 node.parentNode.removeChild(node); |
|
11716 } |
|
11717 |
|
11718 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/list-reducer.js |
|
11719 /** |
|
11720 * WordPress dependencies |
|
11721 */ |
|
11722 |
|
11723 |
|
11724 function list_reducer_isList(node) { |
|
11725 return node.nodeName === 'OL' || node.nodeName === 'UL'; |
|
11726 } |
|
11727 |
|
11728 function shallowTextContent(element) { |
|
11729 return Array.from(element.childNodes).map(function (_ref) { |
|
11730 var _ref$nodeValue = _ref.nodeValue, |
|
11731 nodeValue = _ref$nodeValue === void 0 ? '' : _ref$nodeValue; |
|
11732 return nodeValue; |
|
11733 }).join(''); |
|
11734 } |
|
11735 |
|
11736 function listReducer(node) { |
|
11737 if (!list_reducer_isList(node)) { |
|
11738 return; |
|
11739 } |
|
11740 |
|
11741 var list = node; |
|
11742 var prevElement = node.previousElementSibling; // Merge with previous list if: |
|
11743 // * There is a previous list of the same type. |
|
11744 // * There is only one list item. |
|
11745 |
|
11746 if (prevElement && prevElement.nodeName === node.nodeName && list.children.length === 1) { |
|
11747 // Move all child nodes, including any text nodes, if any. |
|
11748 while (list.firstChild) { |
|
11749 prevElement.appendChild(list.firstChild); |
|
11750 } |
|
11751 |
|
11752 list.parentNode.removeChild(list); |
|
11753 } |
|
11754 |
|
11755 var parentElement = node.parentNode; // Nested list with empty parent item. |
|
11756 |
|
11757 if (parentElement && parentElement.nodeName === 'LI' && parentElement.children.length === 1 && !/\S/.test(shallowTextContent(parentElement))) { |
|
11758 var parentListItem = parentElement; |
|
11759 var prevListItem = parentListItem.previousElementSibling; |
|
11760 var parentList = parentListItem.parentNode; |
|
11761 |
|
11762 if (prevListItem) { |
|
11763 prevListItem.appendChild(list); |
|
11764 parentList.removeChild(parentListItem); |
|
11765 } else { |
|
11766 parentList.parentNode.insertBefore(list, parentList); |
|
11767 parentList.parentNode.removeChild(parentList); |
|
11768 } |
|
11769 } // Invalid: OL/UL > OL/UL. |
|
11770 |
|
11771 |
|
11772 if (parentElement && list_reducer_isList(parentElement)) { |
|
11773 var _prevListItem = node.previousElementSibling; |
|
11774 |
|
11775 if (_prevListItem) { |
|
11776 _prevListItem.appendChild(node); |
|
11777 } else { |
|
11778 Object(external_this_wp_dom_["unwrap"])(node); |
|
11779 } |
|
11780 } |
|
11781 } |
|
11782 |
|
11783 // EXTERNAL MODULE: external {"this":["wp","blob"]} |
|
11784 var external_this_wp_blob_ = __webpack_require__(44); |
|
11785 |
|
11786 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/image-corrector.js |
|
11787 |
|
11788 |
|
11789 /** |
|
11790 * WordPress dependencies |
|
11791 */ |
|
11792 |
|
11793 /** |
|
11794 * Browser dependencies |
|
11795 */ |
|
11796 |
|
11797 var image_corrector_window = window, |
|
11798 atob = image_corrector_window.atob, |
|
11799 File = image_corrector_window.File; |
|
11800 function imageCorrector(node) { |
|
11801 if (node.nodeName !== 'IMG') { |
|
11802 return; |
|
11803 } |
|
11804 |
|
11805 if (node.src.indexOf('file:') === 0) { |
|
11806 node.src = ''; |
|
11807 } // This piece cannot be tested outside a browser env. |
|
11808 |
|
11809 |
|
11810 if (node.src.indexOf('data:') === 0) { |
|
11811 var _node$src$split = node.src.split(','), |
|
11812 _node$src$split2 = Object(slicedToArray["a" /* default */])(_node$src$split, 2), |
|
11813 properties = _node$src$split2[0], |
|
11814 data = _node$src$split2[1]; |
|
11815 |
|
11816 var _properties$slice$spl = properties.slice(5).split(';'), |
|
11817 _properties$slice$spl2 = Object(slicedToArray["a" /* default */])(_properties$slice$spl, 1), |
|
11818 type = _properties$slice$spl2[0]; |
|
11819 |
|
11820 if (!data || !type) { |
|
11821 node.src = ''; |
|
11822 return; |
|
11823 } |
|
11824 |
|
11825 var decoded; // Can throw DOMException! |
|
11826 |
|
11827 try { |
|
11828 decoded = atob(data); |
|
11829 } catch (e) { |
|
11830 node.src = ''; |
|
11831 return; |
|
11832 } |
|
11833 |
|
11834 var uint8Array = new Uint8Array(decoded.length); |
|
11835 |
|
11836 for (var i = 0; i < uint8Array.length; i++) { |
|
11837 uint8Array[i] = decoded.charCodeAt(i); |
|
11838 } |
|
11839 |
|
11840 var name = type.replace('/', '.'); |
|
11841 var file = new File([uint8Array], name, { |
|
11842 type: type |
|
11843 }); |
|
11844 node.src = Object(external_this_wp_blob_["createBlobURL"])(file); |
|
11845 } // Remove trackers and hardly visible images. |
|
11846 |
|
11847 |
|
11848 if (node.height === 1 || node.width === 1) { |
|
11849 node.parentNode.removeChild(node); |
|
11850 } |
|
11851 } |
|
11852 |
|
11853 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/blockquote-normaliser.js |
|
11854 /** |
|
11855 * Internal dependencies |
|
11856 */ |
|
11857 |
|
11858 function blockquoteNormaliser(node) { |
|
11859 if (node.nodeName !== 'BLOCKQUOTE') { |
|
11860 return; |
|
11861 } |
|
11862 |
|
11863 node.innerHTML = normaliseBlocks(node.innerHTML); |
|
11864 } |
|
11865 |
|
11866 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/figure-content-reducer.js |
|
11867 /** |
|
11868 * External dependencies |
|
11869 */ |
|
11870 |
|
11871 /** |
|
11872 * Internal dependencies |
|
11873 */ |
|
11874 |
|
11875 |
|
11876 /** |
|
11877 * Whether or not the given node is figure content. |
|
11878 * |
|
11879 * @param {Node} node The node to check. |
|
11880 * @param {Object} schema The schema to use. |
|
11881 * |
|
11882 * @return {boolean} True if figure content, false if not. |
|
11883 */ |
|
11884 |
|
11885 function isFigureContent(node, schema) { |
|
11886 var tag = node.nodeName.toLowerCase(); // We are looking for tags that can be a child of the figure tag, excluding |
|
11887 // `figcaption` and any phrasing content. |
|
11888 |
|
11889 if (tag === 'figcaption' || isTextContent(node)) { |
|
11890 return false; |
|
11891 } |
|
11892 |
|
11893 return Object(external_this_lodash_["has"])(schema, ['figure', 'children', tag]); |
|
11894 } |
|
11895 /** |
|
11896 * Whether or not the given node can have an anchor. |
|
11897 * |
|
11898 * @param {Node} node The node to check. |
|
11899 * @param {Object} schema The schema to use. |
|
11900 * |
|
11901 * @return {boolean} True if it can, false if not. |
|
11902 */ |
|
11903 |
|
11904 |
|
11905 function canHaveAnchor(node, schema) { |
|
11906 var tag = node.nodeName.toLowerCase(); |
|
11907 return Object(external_this_lodash_["has"])(schema, ['figure', 'children', 'a', 'children', tag]); |
|
11908 } |
|
11909 /** |
|
11910 * Wraps the given element in a figure element. |
|
11911 * |
|
11912 * @param {Element} element The element to wrap. |
|
11913 * @param {Element} beforeElement The element before which to place the figure. |
|
11914 */ |
|
11915 |
|
11916 |
|
11917 function wrapFigureContent(element) { |
|
11918 var beforeElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : element; |
|
11919 var figure = element.ownerDocument.createElement('figure'); |
|
11920 beforeElement.parentNode.insertBefore(figure, beforeElement); |
|
11921 figure.appendChild(element); |
|
11922 } |
|
11923 /** |
|
11924 * This filter takes figure content out of paragraphs, wraps it in a figure |
|
11925 * element, and moves any anchors with it if needed. |
|
11926 * |
|
11927 * @param {Node} node The node to filter. |
|
11928 * @param {Document} doc The document of the node. |
|
11929 * @param {Object} schema The schema to use. |
|
11930 * |
|
11931 * @return {void} |
|
11932 */ |
|
11933 |
|
11934 |
|
11935 function figureContentReducer(node, doc, schema) { |
|
11936 if (!isFigureContent(node, schema)) { |
|
11937 return; |
|
11938 } |
|
11939 |
|
11940 var nodeToInsert = node; |
|
11941 var parentNode = node.parentNode; // If the figure content can have an anchor and its parent is an anchor with |
|
11942 // only the figure content, take the anchor out instead of just the content. |
|
11943 |
|
11944 if (canHaveAnchor(node, schema) && parentNode.nodeName === 'A' && parentNode.childNodes.length === 1) { |
|
11945 nodeToInsert = node.parentNode; |
|
11946 } |
|
11947 |
|
11948 var wrapper = nodeToInsert.closest('p,div'); // If wrapped in a paragraph or div, only extract if it's aligned or if |
|
11949 // there is no text content. |
|
11950 // Otherwise, if directly at the root, wrap in a figure element. |
|
11951 |
|
11952 if (wrapper) { |
|
11953 // In jsdom-jscore, 'node.classList' can be undefined. |
|
11954 // In this case, default to extract as it offers a better UI experience on mobile. |
|
11955 if (!node.classList) { |
|
11956 wrapFigureContent(nodeToInsert, wrapper); |
|
11957 } else if (node.classList.contains('alignright') || node.classList.contains('alignleft') || node.classList.contains('aligncenter') || !wrapper.textContent.trim()) { |
|
11958 wrapFigureContent(nodeToInsert, wrapper); |
|
11959 } |
|
11960 } else if (nodeToInsert.parentNode.nodeName === 'BODY') { |
|
11961 wrapFigureContent(nodeToInsert); |
|
11962 } |
|
11963 } |
|
11964 |
|
11965 // EXTERNAL MODULE: external {"this":["wp","shortcode"]} |
|
11966 var external_this_wp_shortcode_ = __webpack_require__(125); |
|
11967 |
|
11968 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/shortcode-converter.js |
|
11969 |
|
11970 |
|
11971 |
|
11972 function shortcode_converter_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
11973 |
|
11974 function shortcode_converter_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { shortcode_converter_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { shortcode_converter_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
11975 |
|
11976 /** |
|
11977 * External dependencies |
|
11978 */ |
|
11979 |
|
11980 /** |
|
11981 * WordPress dependencies |
|
11982 */ |
|
11983 |
|
11984 |
|
11985 /** |
|
11986 * Internal dependencies |
|
11987 */ |
|
11988 |
|
11989 |
|
11990 |
|
11991 |
|
11992 |
|
11993 function segmentHTMLToShortcodeBlock(HTML) { |
|
11994 var lastIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; |
|
11995 var excludedBlockNames = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; |
|
11996 // Get all matches. |
|
11997 var transformsFrom = getBlockTransforms('from'); |
|
11998 var transformation = findTransform(transformsFrom, function (transform) { |
|
11999 return excludedBlockNames.indexOf(transform.blockName) === -1 && transform.type === 'shortcode' && Object(external_this_lodash_["some"])(Object(external_this_lodash_["castArray"])(transform.tag), function (tag) { |
|
12000 return Object(external_this_wp_shortcode_["regexp"])(tag).test(HTML); |
|
12001 }); |
|
12002 }); |
|
12003 |
|
12004 if (!transformation) { |
|
12005 return [HTML]; |
|
12006 } |
|
12007 |
|
12008 var transformTags = Object(external_this_lodash_["castArray"])(transformation.tag); |
|
12009 var transformTag = Object(external_this_lodash_["find"])(transformTags, function (tag) { |
|
12010 return Object(external_this_wp_shortcode_["regexp"])(tag).test(HTML); |
|
12011 }); |
|
12012 var match; |
|
12013 var previousIndex = lastIndex; |
|
12014 |
|
12015 if (match = Object(external_this_wp_shortcode_["next"])(transformTag, HTML, lastIndex)) { |
|
12016 lastIndex = match.index + match.content.length; |
|
12017 var beforeHTML = HTML.substr(0, match.index); |
|
12018 var afterHTML = HTML.substr(lastIndex); // If the shortcode content does not contain HTML and the shortcode is |
|
12019 // not on a new line (or in paragraph from Markdown converter), |
|
12020 // consider the shortcode as inline text, and thus skip conversion for |
|
12021 // this segment. |
|
12022 |
|
12023 if (!Object(external_this_lodash_["includes"])(match.shortcode.content || '', '<') && !(/(\n|<p>)\s*$/.test(beforeHTML) && /^\s*(\n|<\/p>)/.test(afterHTML))) { |
|
12024 return segmentHTMLToShortcodeBlock(HTML, lastIndex); |
|
12025 } // If a transformation's `isMatch` predicate fails for the inbound |
|
12026 // shortcode, try again by excluding the current block type. |
|
12027 // |
|
12028 // This is the only call to `segmentHTMLToShortcodeBlock` that should |
|
12029 // ever carry over `excludedBlockNames`. Other calls in the module |
|
12030 // should skip that argument as a way to reset the exclusion state, so |
|
12031 // that one `isMatch` fail in an HTML fragment doesn't prevent any |
|
12032 // valid matches in subsequent fragments. |
|
12033 |
|
12034 |
|
12035 if (transformation.isMatch && !transformation.isMatch(match.shortcode.attrs)) { |
|
12036 return segmentHTMLToShortcodeBlock(HTML, previousIndex, [].concat(Object(toConsumableArray["a" /* default */])(excludedBlockNames), [transformation.blockName])); |
|
12037 } |
|
12038 |
|
12039 var attributes = Object(external_this_lodash_["mapValues"])(Object(external_this_lodash_["pickBy"])(transformation.attributes, function (schema) { |
|
12040 return schema.shortcode; |
|
12041 }), // Passing all of `match` as second argument is intentionally broad |
|
12042 // but shouldn't be too relied upon. |
|
12043 // |
|
12044 // See: https://github.com/WordPress/gutenberg/pull/3610#discussion_r152546926 |
|
12045 function (schema) { |
|
12046 return schema.shortcode(match.shortcode.attrs, match); |
|
12047 }); |
|
12048 var block = createBlock(transformation.blockName, getBlockAttributes(shortcode_converter_objectSpread({}, registration_getBlockType(transformation.blockName), { |
|
12049 attributes: transformation.attributes |
|
12050 }), match.shortcode.content, attributes)); |
|
12051 return [beforeHTML, block].concat(Object(toConsumableArray["a" /* default */])(segmentHTMLToShortcodeBlock(HTML.substr(lastIndex)))); |
|
12052 } |
|
12053 |
|
12054 return [HTML]; |
|
12055 } |
|
12056 |
|
12057 /* harmony default export */ var shortcode_converter = (segmentHTMLToShortcodeBlock); |
|
12058 |
|
12059 // EXTERNAL MODULE: ./node_modules/showdown/dist/showdown.js |
|
12060 var showdown = __webpack_require__(269); |
|
12061 var showdown_default = /*#__PURE__*/__webpack_require__.n(showdown); |
|
12062 |
|
12063 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/markdown-converter.js |
|
12064 /** |
|
12065 * External dependencies |
|
12066 */ |
|
12067 // Reuse the same showdown converter. |
|
12068 |
|
12069 var converter = new showdown_default.a.Converter({ |
|
12070 noHeaderId: true, |
|
12071 tables: true, |
|
12072 literalMidWordUnderscores: true, |
|
12073 omitExtraWLInCodeBlocks: true, |
|
12074 simpleLineBreaks: true, |
|
12075 strikethrough: true |
|
12076 }); |
|
12077 /** |
|
12078 * Corrects the Slack Markdown variant of the code block. |
|
12079 * If uncorrected, it will be converted to inline code. |
|
12080 * |
|
12081 * @see https://get.slack.help/hc/en-us/articles/202288908-how-can-i-add-formatting-to-my-messages-#code-blocks |
|
12082 * |
|
12083 * @param {string} text The potential Markdown text to correct. |
|
12084 * |
|
12085 * @return {string} The corrected Markdown. |
|
12086 */ |
|
12087 |
|
12088 function slackMarkdownVariantCorrector(text) { |
|
12089 return text.replace(/((?:^|\n)```)([^\n`]+)(```(?:$|\n))/, function (match, p1, p2, p3) { |
|
12090 return "".concat(p1, "\n").concat(p2, "\n").concat(p3); |
|
12091 }); |
|
12092 } |
|
12093 /** |
|
12094 * Converts a piece of text into HTML based on any Markdown present. |
|
12095 * Also decodes any encoded HTML. |
|
12096 * |
|
12097 * @param {string} text The plain text to convert. |
|
12098 * |
|
12099 * @return {string} HTML. |
|
12100 */ |
|
12101 |
|
12102 |
|
12103 function markdownConverter(text) { |
|
12104 return converter.makeHtml(slackMarkdownVariantCorrector(text)); |
|
12105 } |
|
12106 |
|
12107 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/iframe-remover.js |
|
12108 /** |
|
12109 * Removes iframes. |
|
12110 * |
|
12111 * @param {Node} node The node to check. |
|
12112 * |
|
12113 * @return {void} |
|
12114 */ |
|
12115 function iframeRemover(node) { |
|
12116 if (node.nodeName === 'IFRAME') { |
|
12117 var text = node.ownerDocument.createTextNode(node.src); |
|
12118 node.parentNode.replaceChild(text, node); |
|
12119 } |
|
12120 } |
|
12121 |
|
12122 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/google-docs-uid-remover.js |
|
12123 /** |
|
12124 * WordPress dependencies |
|
12125 */ |
|
12126 |
|
12127 function googleDocsUIdRemover(node) { |
|
12128 if (!node.id || node.id.indexOf('docs-internal-guid-') !== 0) { |
|
12129 return; |
|
12130 } |
|
12131 |
|
12132 Object(external_this_wp_dom_["unwrap"])(node); |
|
12133 } |
|
12134 |
|
12135 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/html-formatting-remover.js |
|
12136 /** |
|
12137 * Internal dependencies |
|
12138 */ |
|
12139 |
|
12140 |
|
12141 function isFormattingSpace(character) { |
|
12142 return character === ' ' || character === '\r' || character === '\n' || character === '\t'; |
|
12143 } |
|
12144 /** |
|
12145 * Removes spacing that formats HTML. |
|
12146 * |
|
12147 * @see https://www.w3.org/TR/css-text-3/#white-space-processing |
|
12148 * |
|
12149 * @param {Node} node The node to be processed. |
|
12150 * @return {void} |
|
12151 */ |
|
12152 |
|
12153 |
|
12154 function htmlFormattingRemover(node) { |
|
12155 if (node.nodeType !== node.TEXT_NODE) { |
|
12156 return; |
|
12157 } // Ignore pre content. Note that this does not use Element#closest due to |
|
12158 // a combination of (a) node may not be Element and (b) node.parentElement |
|
12159 // does not have full support in all browsers (Internet Exporer). |
|
12160 // |
|
12161 // See: https://developer.mozilla.org/en-US/docs/Web/API/Node/parentElement#Browser_compatibility |
|
12162 |
|
12163 /** @type {Node?} */ |
|
12164 |
|
12165 |
|
12166 var parent = node; |
|
12167 |
|
12168 while (parent = parent.parentNode) { |
|
12169 if (parent.nodeType === window.Node.ELEMENT_NODE && parent.nodeName === 'PRE') { |
|
12170 return; |
|
12171 } |
|
12172 } // First, replace any sequence of HTML formatting space with a single space. |
|
12173 |
|
12174 |
|
12175 var newData = node.data.replace(/[ \r\n\t]+/g, ' '); // Remove the leading space if the text element is at the start of a block, |
|
12176 // is preceded by a line break element, or has a space in the previous |
|
12177 // node. |
|
12178 |
|
12179 if (newData[0] === ' ') { |
|
12180 var previousSibling = getSibling(node, 'previous'); |
|
12181 |
|
12182 if (!previousSibling || previousSibling.nodeName === 'BR' || previousSibling.textContent.slice(-1) === ' ') { |
|
12183 newData = newData.slice(1); |
|
12184 } |
|
12185 } // Remove the trailing space if the text element is at the end of a block, |
|
12186 // is succeded by a line break element, or has a space in the next text |
|
12187 // node. |
|
12188 |
|
12189 |
|
12190 if (newData[newData.length - 1] === ' ') { |
|
12191 var nextSibling = getSibling(node, 'next'); |
|
12192 |
|
12193 if (!nextSibling || nextSibling.nodeName === 'BR' || nextSibling.nodeType === nextSibling.TEXT_NODE && isFormattingSpace(nextSibling.textContent[0])) { |
|
12194 newData = newData.slice(0, -1); |
|
12195 } |
|
12196 } // If there's no data left, remove the node, so `previousSibling` stays |
|
12197 // accurate. Otherwise, update the node data. |
|
12198 |
|
12199 |
|
12200 if (!newData) { |
|
12201 node.parentNode.removeChild(node); |
|
12202 } else { |
|
12203 node.data = newData; |
|
12204 } |
|
12205 } |
|
12206 |
|
12207 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/br-remover.js |
|
12208 /** |
|
12209 * Internal dependencies |
|
12210 */ |
|
12211 |
|
12212 /** |
|
12213 * Removes trailing br elements from text-level content. |
|
12214 * |
|
12215 * @param {Element} node Node to check. |
|
12216 */ |
|
12217 |
|
12218 function brRemover(node) { |
|
12219 if (node.nodeName !== 'BR') { |
|
12220 return; |
|
12221 } |
|
12222 |
|
12223 if (getSibling(node, 'next')) { |
|
12224 return; |
|
12225 } |
|
12226 |
|
12227 node.parentNode.removeChild(node); |
|
12228 } |
|
12229 |
|
12230 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/empty-paragraph-remover.js |
|
12231 /** |
|
12232 * Removes empty paragraph elements. |
|
12233 * |
|
12234 * @param {Element} node Node to check. |
|
12235 */ |
|
12236 function emptyParagraphRemover(node) { |
|
12237 if (node.nodeName !== 'P') { |
|
12238 return; |
|
12239 } |
|
12240 |
|
12241 if (node.hasChildNodes()) { |
|
12242 return; |
|
12243 } |
|
12244 |
|
12245 node.parentNode.removeChild(node); |
|
12246 } |
|
12247 |
|
12248 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/paste-handler.js |
|
12249 |
|
12250 |
|
12251 function paste_handler_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
12252 |
|
12253 function paste_handler_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { paste_handler_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { paste_handler_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
12254 |
|
12255 /** |
|
12256 * External dependencies |
|
12257 */ |
|
12258 |
|
12259 /** |
|
12260 * Internal dependencies |
|
12261 */ |
|
12262 |
|
12263 |
|
12264 |
|
12265 |
|
12266 |
|
12267 |
|
12268 |
|
12269 |
|
12270 |
|
12271 |
|
12272 |
|
12273 |
|
12274 |
|
12275 |
|
12276 |
|
12277 |
|
12278 |
|
12279 |
|
12280 |
|
12281 |
|
12282 |
|
12283 |
|
12284 |
|
12285 |
|
12286 |
|
12287 /** |
|
12288 * Browser dependencies |
|
12289 */ |
|
12290 |
|
12291 var paste_handler_window = window, |
|
12292 paste_handler_console = paste_handler_window.console; |
|
12293 /** |
|
12294 * Filters HTML to only contain phrasing content. |
|
12295 * |
|
12296 * @param {string} HTML The HTML to filter. |
|
12297 * |
|
12298 * @return {string} HTML only containing phrasing content. |
|
12299 */ |
|
12300 |
|
12301 function filterInlineHTML(HTML) { |
|
12302 HTML = deepFilterHTML(HTML, [googleDocsUIdRemover, phrasingContentReducer, commentRemover]); |
|
12303 HTML = removeInvalidHTML(HTML, getPhrasingContentSchema('paste'), { |
|
12304 inline: true |
|
12305 }); |
|
12306 HTML = deepFilterHTML(HTML, [htmlFormattingRemover, brRemover]); // Allows us to ask for this information when we get a report. |
|
12307 |
|
12308 paste_handler_console.log('Processed inline HTML:\n\n', HTML); |
|
12309 return HTML; |
|
12310 } |
|
12311 |
|
12312 function getRawTransformations() { |
|
12313 return Object(external_this_lodash_["filter"])(getBlockTransforms('from'), { |
|
12314 type: 'raw' |
|
12315 }).map(function (transform) { |
|
12316 return transform.isMatch ? transform : paste_handler_objectSpread({}, transform, { |
|
12317 isMatch: function isMatch(node) { |
|
12318 return transform.selector && node.matches(transform.selector); |
|
12319 } |
|
12320 }); |
|
12321 }); |
|
12322 } |
|
12323 /** |
|
12324 * Converts HTML directly to blocks. Looks for a matching transform for each |
|
12325 * top-level tag. The HTML should be filtered to not have any text between |
|
12326 * top-level tags and formatted in a way that blocks can handle the HTML. |
|
12327 * |
|
12328 * @param {Object} $1 Named parameters. |
|
12329 * @param {string} $1.html HTML to convert. |
|
12330 * @param {Array} $1.rawTransforms Transforms that can be used. |
|
12331 * |
|
12332 * @return {Array} An array of blocks. |
|
12333 */ |
|
12334 |
|
12335 |
|
12336 function htmlToBlocks(_ref) { |
|
12337 var html = _ref.html, |
|
12338 rawTransforms = _ref.rawTransforms; |
|
12339 var doc = document.implementation.createHTMLDocument(''); |
|
12340 doc.body.innerHTML = html; |
|
12341 return Array.from(doc.body.children).map(function (node) { |
|
12342 var rawTransform = findTransform(rawTransforms, function (_ref2) { |
|
12343 var isMatch = _ref2.isMatch; |
|
12344 return isMatch(node); |
|
12345 }); |
|
12346 |
|
12347 if (!rawTransform) { |
|
12348 return createBlock( // Should not be hardcoded. |
|
12349 'core/html', getBlockAttributes('core/html', node.outerHTML)); |
|
12350 } |
|
12351 |
|
12352 var transform = rawTransform.transform, |
|
12353 blockName = rawTransform.blockName; |
|
12354 |
|
12355 if (transform) { |
|
12356 return transform(node); |
|
12357 } |
|
12358 |
|
12359 return createBlock(blockName, getBlockAttributes(blockName, node.outerHTML)); |
|
12360 }); |
|
12361 } |
|
12362 /** |
|
12363 * Converts an HTML string to known blocks. Strips everything else. |
|
12364 * |
|
12365 * @param {Object} options |
|
12366 * @param {string} [options.HTML] The HTML to convert. |
|
12367 * @param {string} [options.plainText] Plain text version. |
|
12368 * @param {string} [options.mode] Handle content as blocks or inline content. |
|
12369 * * 'AUTO': Decide based on the content passed. |
|
12370 * * 'INLINE': Always handle as inline content, and return string. |
|
12371 * * 'BLOCKS': Always handle as blocks, and return array of blocks. |
|
12372 * @param {Array} [options.tagName] The tag into which content will be inserted. |
|
12373 * |
|
12374 * @return {Array|string} A list of blocks or a string, depending on `handlerMode`. |
|
12375 */ |
|
12376 |
|
12377 |
|
12378 function pasteHandler(_ref3) { |
|
12379 var _ref3$HTML = _ref3.HTML, |
|
12380 HTML = _ref3$HTML === void 0 ? '' : _ref3$HTML, |
|
12381 _ref3$plainText = _ref3.plainText, |
|
12382 plainText = _ref3$plainText === void 0 ? '' : _ref3$plainText, |
|
12383 _ref3$mode = _ref3.mode, |
|
12384 mode = _ref3$mode === void 0 ? 'AUTO' : _ref3$mode, |
|
12385 tagName = _ref3.tagName; |
|
12386 // First of all, strip any meta tags. |
|
12387 HTML = HTML.replace(/<meta[^>]+>/g, ''); // Strip Windows markers. |
|
12388 |
|
12389 HTML = HTML.replace(/^\s*<html[^>]*>\s*<body[^>]*>(?:\s*<!--\s*StartFragment\s*-->)?/i, ''); |
|
12390 HTML = HTML.replace(/(?:<!--\s*EndFragment\s*-->\s*)?<\/body>\s*<\/html>\s*$/i, ''); // If we detect block delimiters in HTML, parse entirely as blocks. |
|
12391 |
|
12392 if (mode !== 'INLINE') { |
|
12393 // Check plain text if there is no HTML. |
|
12394 var content = HTML ? HTML : plainText; |
|
12395 |
|
12396 if (content.indexOf('<!-- wp:') !== -1) { |
|
12397 return parseWithGrammar(content); |
|
12398 } |
|
12399 } // Normalize unicode to use composed characters. |
|
12400 // This is unsupported in IE 11 but it's a nice-to-have feature, not mandatory. |
|
12401 // Not normalizing the content will only affect older browsers and won't |
|
12402 // entirely break the app. |
|
12403 // See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize |
|
12404 // See: https://core.trac.wordpress.org/ticket/30130 |
|
12405 // See: https://github.com/WordPress/gutenberg/pull/6983#pullrequestreview-125151075 |
|
12406 |
|
12407 |
|
12408 if (String.prototype.normalize) { |
|
12409 HTML = HTML.normalize(); |
|
12410 } // Parse Markdown (and encoded HTML) if: |
|
12411 // * There is a plain text version. |
|
12412 // * There is no HTML version, or it has no formatting. |
|
12413 |
|
12414 |
|
12415 if (plainText && (!HTML || isPlain(HTML))) { |
|
12416 HTML = markdownConverter(plainText); // Switch to inline mode if: |
|
12417 // * The current mode is AUTO. |
|
12418 // * The original plain text had no line breaks. |
|
12419 // * The original plain text was not an HTML paragraph. |
|
12420 // * The converted text is just a paragraph. |
|
12421 |
|
12422 if (mode === 'AUTO' && plainText.indexOf('\n') === -1 && plainText.indexOf('<p>') !== 0 && HTML.indexOf('<p>') === 0) { |
|
12423 mode = 'INLINE'; |
|
12424 } |
|
12425 } |
|
12426 |
|
12427 if (mode === 'INLINE') { |
|
12428 return filterInlineHTML(HTML); |
|
12429 } // An array of HTML strings and block objects. The blocks replace matched |
|
12430 // shortcodes. |
|
12431 |
|
12432 |
|
12433 var pieces = shortcode_converter(HTML); // The call to shortcodeConverter will always return more than one element |
|
12434 // if shortcodes are matched. The reason is when shortcodes are matched |
|
12435 // empty HTML strings are included. |
|
12436 |
|
12437 var hasShortcodes = pieces.length > 1; |
|
12438 |
|
12439 if (mode === 'AUTO' && !hasShortcodes && isInlineContent(HTML, tagName)) { |
|
12440 return filterInlineHTML(HTML); |
|
12441 } |
|
12442 |
|
12443 var rawTransforms = getRawTransformations(); |
|
12444 var phrasingContentSchema = getPhrasingContentSchema('paste'); |
|
12445 var blockContentSchema = getBlockContentSchema(rawTransforms, phrasingContentSchema, true); |
|
12446 var blocks = Object(external_this_lodash_["compact"])(Object(external_this_lodash_["flatMap"])(pieces, function (piece) { |
|
12447 // Already a block from shortcode. |
|
12448 if (typeof piece !== 'string') { |
|
12449 return piece; |
|
12450 } |
|
12451 |
|
12452 var filters = [googleDocsUIdRemover, msListConverter, headRemover, listReducer, imageCorrector, phrasingContentReducer, specialCommentConverter, commentRemover, iframeRemover, figureContentReducer, blockquoteNormaliser]; |
|
12453 |
|
12454 var schema = paste_handler_objectSpread({}, blockContentSchema, {}, phrasingContentSchema); |
|
12455 |
|
12456 piece = deepFilterHTML(piece, filters, blockContentSchema); |
|
12457 piece = removeInvalidHTML(piece, schema); |
|
12458 piece = normaliseBlocks(piece); |
|
12459 piece = deepFilterHTML(piece, [htmlFormattingRemover, brRemover, emptyParagraphRemover], blockContentSchema); // Allows us to ask for this information when we get a report. |
|
12460 |
|
12461 paste_handler_console.log('Processed HTML piece:\n\n', piece); |
|
12462 return htmlToBlocks({ |
|
12463 html: piece, |
|
12464 rawTransforms: rawTransforms |
|
12465 }); |
|
12466 })); // If we're allowed to return inline content, and there is only one inlineable block, |
|
12467 // and the original plain text content does not have any line breaks, then |
|
12468 // treat it as inline paste. |
|
12469 |
|
12470 if (mode === 'AUTO' && blocks.length === 1 && registration_hasBlockSupport(blocks[0].name, '__unstablePasteTextInline', false)) { |
|
12471 var trimmedPlainText = plainText.trim(); |
|
12472 |
|
12473 if (trimmedPlainText !== '' && trimmedPlainText.indexOf('\n') === -1) { |
|
12474 return removeInvalidHTML(getBlockContent(blocks[0]), phrasingContentSchema); |
|
12475 } |
|
12476 } |
|
12477 |
|
12478 return blocks; |
|
12479 } |
|
12480 |
|
12481 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/index.js |
|
12482 |
|
12483 |
|
12484 function raw_handling_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
12485 |
|
12486 function raw_handling_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { raw_handling_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { raw_handling_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
12487 |
|
12488 /** |
|
12489 * External dependencies |
|
12490 */ |
|
12491 |
|
12492 /** |
|
12493 * Internal dependencies |
|
12494 */ |
|
12495 |
|
12496 |
|
12497 |
|
12498 |
|
12499 |
|
12500 |
|
12501 |
|
12502 |
|
12503 |
|
12504 |
|
12505 |
|
12506 |
|
12507 |
|
12508 |
|
12509 function raw_handling_getRawTransformations() { |
|
12510 return Object(external_this_lodash_["filter"])(getBlockTransforms('from'), { |
|
12511 type: 'raw' |
|
12512 }).map(function (transform) { |
|
12513 return transform.isMatch ? transform : raw_handling_objectSpread({}, transform, { |
|
12514 isMatch: function isMatch(node) { |
|
12515 return transform.selector && node.matches(transform.selector); |
|
12516 } |
|
12517 }); |
|
12518 }); |
|
12519 } |
|
12520 /** |
|
12521 * Converts HTML directly to blocks. Looks for a matching transform for each |
|
12522 * top-level tag. The HTML should be filtered to not have any text between |
|
12523 * top-level tags and formatted in a way that blocks can handle the HTML. |
|
12524 * |
|
12525 * @param {Object} $1 Named parameters. |
|
12526 * @param {string} $1.html HTML to convert. |
|
12527 * @param {Array} $1.rawTransforms Transforms that can be used. |
|
12528 * |
|
12529 * @return {Array} An array of blocks. |
|
12530 */ |
|
12531 |
|
12532 |
|
12533 function raw_handling_htmlToBlocks(_ref) { |
|
12534 var html = _ref.html, |
|
12535 rawTransforms = _ref.rawTransforms; |
|
12536 var doc = document.implementation.createHTMLDocument(''); |
|
12537 doc.body.innerHTML = html; |
|
12538 return Array.from(doc.body.children).map(function (node) { |
|
12539 var rawTransform = findTransform(rawTransforms, function (_ref2) { |
|
12540 var isMatch = _ref2.isMatch; |
|
12541 return isMatch(node); |
|
12542 }); |
|
12543 |
|
12544 if (!rawTransform) { |
|
12545 return createBlock( // Should not be hardcoded. |
|
12546 'core/html', getBlockAttributes('core/html', node.outerHTML)); |
|
12547 } |
|
12548 |
|
12549 var transform = rawTransform.transform, |
|
12550 blockName = rawTransform.blockName; |
|
12551 |
|
12552 if (transform) { |
|
12553 return transform(node); |
|
12554 } |
|
12555 |
|
12556 return createBlock(blockName, getBlockAttributes(blockName, node.outerHTML)); |
|
12557 }); |
|
12558 } |
|
12559 /** |
|
12560 * Converts an HTML string to known blocks. |
|
12561 * |
|
12562 * @param {Object} $1 |
|
12563 * @param {string} $1.HTML The HTML to convert. |
|
12564 * |
|
12565 * @return {Array} A list of blocks. |
|
12566 */ |
|
12567 |
|
12568 |
|
12569 function rawHandler(_ref3) { |
|
12570 var _ref3$HTML = _ref3.HTML, |
|
12571 HTML = _ref3$HTML === void 0 ? '' : _ref3$HTML; |
|
12572 |
|
12573 // If we detect block delimiters, parse entirely as blocks. |
|
12574 if (HTML.indexOf('<!-- wp:') !== -1) { |
|
12575 return parseWithGrammar(HTML); |
|
12576 } // An array of HTML strings and block objects. The blocks replace matched |
|
12577 // shortcodes. |
|
12578 |
|
12579 |
|
12580 var pieces = shortcode_converter(HTML); |
|
12581 var rawTransforms = raw_handling_getRawTransformations(); |
|
12582 var phrasingContentSchema = getPhrasingContentSchema(); |
|
12583 var blockContentSchema = getBlockContentSchema(rawTransforms, phrasingContentSchema); |
|
12584 return Object(external_this_lodash_["compact"])(Object(external_this_lodash_["flatMap"])(pieces, function (piece) { |
|
12585 // Already a block from shortcode. |
|
12586 if (typeof piece !== 'string') { |
|
12587 return piece; |
|
12588 } // These filters are essential for some blocks to be able to transform |
|
12589 // from raw HTML. These filters move around some content or add |
|
12590 // additional tags, they do not remove any content. |
|
12591 |
|
12592 |
|
12593 var filters = [// Needed to adjust invalid lists. |
|
12594 listReducer, // Needed to create more and nextpage blocks. |
|
12595 specialCommentConverter, // Needed to create media blocks. |
|
12596 figureContentReducer, // Needed to create the quote block, which cannot handle text |
|
12597 // without wrapper paragraphs. |
|
12598 blockquoteNormaliser]; |
|
12599 piece = deepFilterHTML(piece, filters, blockContentSchema); |
|
12600 piece = normaliseBlocks(piece); |
|
12601 return raw_handling_htmlToBlocks({ |
|
12602 html: piece, |
|
12603 rawTransforms: rawTransforms |
|
12604 }); |
|
12605 })); |
|
12606 } |
|
12607 |
|
12608 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/categories.js |
|
12609 /** |
|
12610 * WordPress dependencies |
|
12611 */ |
|
12612 |
|
12613 /** @typedef {import('../store/reducer').WPBlockCategory} WPBlockCategory */ |
|
12614 |
|
12615 /** |
|
12616 * Returns all the block categories. |
|
12617 * |
|
12618 * @return {WPBlockCategory[]} Block categories. |
|
12619 */ |
|
12620 |
|
12621 function categories_getCategories() { |
|
12622 return Object(external_this_wp_data_["select"])('core/blocks').getCategories(); |
|
12623 } |
|
12624 /** |
|
12625 * Sets the block categories. |
|
12626 * |
|
12627 * @param {WPBlockCategory[]} categories Block categories. |
|
12628 */ |
|
12629 |
|
12630 function categories_setCategories(categories) { |
|
12631 Object(external_this_wp_data_["dispatch"])('core/blocks').setCategories(categories); |
|
12632 } |
|
12633 /** |
|
12634 * Updates a category. |
|
12635 * |
|
12636 * @param {string} slug Block category slug. |
|
12637 * @param {WPBlockCategory} category Object containing the category properties |
|
12638 * that should be updated. |
|
12639 */ |
|
12640 |
|
12641 function categories_updateCategory(slug, category) { |
|
12642 Object(external_this_wp_data_["dispatch"])('core/blocks').updateCategory(slug, category); |
|
12643 } |
|
12644 |
|
12645 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/templates.js |
|
12646 |
|
12647 |
|
12648 |
|
12649 function templates_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
12650 |
|
12651 function templates_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { templates_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { templates_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
12652 |
|
12653 /** |
|
12654 * External dependencies |
|
12655 */ |
|
12656 |
|
12657 /** |
|
12658 * WordPress dependencies |
|
12659 */ |
|
12660 |
|
12661 |
|
12662 /** |
|
12663 * Internal dependencies |
|
12664 */ |
|
12665 |
|
12666 |
|
12667 |
|
12668 /** |
|
12669 * Checks whether a list of blocks matches a template by comparing the block names. |
|
12670 * |
|
12671 * @param {Array} blocks Block list. |
|
12672 * @param {Array} template Block template. |
|
12673 * |
|
12674 * @return {boolean} Whether the list of blocks matches a templates |
|
12675 */ |
|
12676 |
|
12677 function doBlocksMatchTemplate() { |
|
12678 var blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
|
12679 var template = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; |
|
12680 return blocks.length === template.length && Object(external_this_lodash_["every"])(template, function (_ref, index) { |
|
12681 var _ref2 = Object(slicedToArray["a" /* default */])(_ref, 3), |
|
12682 name = _ref2[0], |
|
12683 innerBlocksTemplate = _ref2[2]; |
|
12684 |
|
12685 var block = blocks[index]; |
|
12686 return name === block.name && doBlocksMatchTemplate(block.innerBlocks, innerBlocksTemplate); |
|
12687 }); |
|
12688 } |
|
12689 /** |
|
12690 * Synchronize a block list with a block template. |
|
12691 * |
|
12692 * Synchronizing a block list with a block template means that we loop over the blocks |
|
12693 * keep the block as is if it matches the block at the same position in the template |
|
12694 * (If it has the same name) and if doesn't match, we create a new block based on the template. |
|
12695 * Extra blocks not present in the template are removed. |
|
12696 * |
|
12697 * @param {Array} blocks Block list. |
|
12698 * @param {Array} template Block template. |
|
12699 * |
|
12700 * @return {Array} Updated Block list. |
|
12701 */ |
|
12702 |
|
12703 function synchronizeBlocksWithTemplate() { |
|
12704 var blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
|
12705 var template = arguments.length > 1 ? arguments[1] : undefined; |
|
12706 |
|
12707 // If no template is provided, return blocks unmodified. |
|
12708 if (!template) { |
|
12709 return blocks; |
|
12710 } |
|
12711 |
|
12712 return Object(external_this_lodash_["map"])(template, function (_ref3, index) { |
|
12713 var _ref4 = Object(slicedToArray["a" /* default */])(_ref3, 3), |
|
12714 name = _ref4[0], |
|
12715 attributes = _ref4[1], |
|
12716 innerBlocksTemplate = _ref4[2]; |
|
12717 |
|
12718 var block = blocks[index]; |
|
12719 |
|
12720 if (block && block.name === name) { |
|
12721 var innerBlocks = synchronizeBlocksWithTemplate(block.innerBlocks, innerBlocksTemplate); |
|
12722 return templates_objectSpread({}, block, { |
|
12723 innerBlocks: innerBlocks |
|
12724 }); |
|
12725 } // To support old templates that were using the "children" format |
|
12726 // for the attributes using "html" strings now, we normalize the template attributes |
|
12727 // before creating the blocks. |
|
12728 |
|
12729 |
|
12730 var blockType = registration_getBlockType(name); |
|
12731 |
|
12732 var isHTMLAttribute = function isHTMLAttribute(attributeDefinition) { |
|
12733 return Object(external_this_lodash_["get"])(attributeDefinition, ['source']) === 'html'; |
|
12734 }; |
|
12735 |
|
12736 var isQueryAttribute = function isQueryAttribute(attributeDefinition) { |
|
12737 return Object(external_this_lodash_["get"])(attributeDefinition, ['source']) === 'query'; |
|
12738 }; |
|
12739 |
|
12740 var normalizeAttributes = function normalizeAttributes(schema, values) { |
|
12741 return Object(external_this_lodash_["mapValues"])(values, function (value, key) { |
|
12742 return normalizeAttribute(schema[key], value); |
|
12743 }); |
|
12744 }; |
|
12745 |
|
12746 var normalizeAttribute = function normalizeAttribute(definition, value) { |
|
12747 if (isHTMLAttribute(definition) && Object(external_this_lodash_["isArray"])(value)) { |
|
12748 // Introduce a deprecated call at this point |
|
12749 // When we're confident that "children" format should be removed from the templates. |
|
12750 return Object(external_this_wp_element_["renderToString"])(value); |
|
12751 } |
|
12752 |
|
12753 if (isQueryAttribute(definition) && value) { |
|
12754 return value.map(function (subValues) { |
|
12755 return normalizeAttributes(definition.query, subValues); |
|
12756 }); |
|
12757 } |
|
12758 |
|
12759 return value; |
|
12760 }; |
|
12761 |
|
12762 var normalizedAttributes = normalizeAttributes(Object(external_this_lodash_["get"])(blockType, ['attributes'], {}), attributes); |
|
12763 return createBlock(name, normalizedAttributes, synchronizeBlocksWithTemplate([], innerBlocksTemplate)); |
|
12764 }); |
|
12765 } |
|
12766 |
|
12767 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/index.js |
|
12768 |
|
12769 |
|
12770 |
|
12771 |
|
12772 |
|
12773 |
|
12774 |
|
12775 |
|
12776 |
|
12777 |
|
12778 |
|
12779 |
|
12780 // CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/index.js |
|
12781 // A "block" is the abstract term used to describe units of markup that, |
|
12782 // when composed together, form the content or layout of a page. |
|
12783 // The API for blocks is exposed via `wp.blocks`. |
|
12784 // |
|
12785 // Supported blocks are registered by calling `registerBlockType`. Once registered, |
|
12786 // the block is made available as an option to the editor interface. |
|
12787 // |
|
12788 // Blocks are inferred from the HTML source of a post through a parsing mechanism |
|
12789 // and then stored as objects in state, from which it is then rendered for editing. |
|
12790 |
|
12791 /** |
|
12792 * Internal dependencies |
|
12793 */ |
|
12794 |
|
12795 |
|
12796 |
|
12797 |
|
12798 |
|
12799 /***/ }), |
|
12800 |
|
12801 /***/ 5: |
|
12802 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
12803 |
|
12804 "use strict"; |
|
12805 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; }); |
|
12806 function _defineProperty(obj, key, value) { |
|
12807 if (key in obj) { |
|
12808 Object.defineProperty(obj, key, { |
|
12809 value: value, |
|
12810 enumerable: true, |
|
12811 configurable: true, |
|
12812 writable: true |
|
12813 }); |
|
12814 } else { |
|
12815 obj[key] = value; |
|
12816 } |
|
12817 |
|
12818 return obj; |
|
12819 } |
|
12820 |
|
12821 /***/ }), |
|
12822 |
|
12823 /***/ 6: |
|
12824 /***/ (function(module, exports) { |
|
12825 |
|
12826 (function() { module.exports = this["wp"]["primitives"]; }()); |
|
12827 |
|
12828 /***/ }), |
|
12829 |
|
12830 /***/ 64: |
|
12831 /***/ (function(module, exports) { |
|
12832 |
|
12833 (function() { module.exports = this["wp"]["isShallowEqual"]; }()); |
|
12834 |
|
12835 /***/ }), |
|
12836 |
|
12837 /***/ 66: |
|
12838 /***/ (function(module, exports, __webpack_require__) { |
12534 /***/ (function(module, exports, __webpack_require__) { |
12839 |
12535 |
12840 var __WEBPACK_AMD_DEFINE_RESULT__;// TinyColor v1.4.1 |
12536 var __WEBPACK_AMD_DEFINE_RESULT__;// TinyColor v1.4.2 |
12841 // https://github.com/bgrins/TinyColor |
12537 // https://github.com/bgrins/TinyColor |
12842 // Brian Grinstead, MIT License |
12538 // Brian Grinstead, MIT License |
12843 |
12539 |
12844 (function(Math) { |
12540 (function(Math) { |
12845 |
12541 |