|
1 this["wp"] = this["wp"] || {}; this["wp"]["richText"] = |
|
2 /******/ (function(modules) { // webpackBootstrap |
|
3 /******/ // The module cache |
|
4 /******/ var installedModules = {}; |
|
5 /******/ |
|
6 /******/ // The require function |
|
7 /******/ function __webpack_require__(moduleId) { |
|
8 /******/ |
|
9 /******/ // Check if module is in cache |
|
10 /******/ if(installedModules[moduleId]) { |
|
11 /******/ return installedModules[moduleId].exports; |
|
12 /******/ } |
|
13 /******/ // Create a new module (and put it into the cache) |
|
14 /******/ var module = installedModules[moduleId] = { |
|
15 /******/ i: moduleId, |
|
16 /******/ l: false, |
|
17 /******/ exports: {} |
|
18 /******/ }; |
|
19 /******/ |
|
20 /******/ // Execute the module function |
|
21 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
|
22 /******/ |
|
23 /******/ // Flag the module as loaded |
|
24 /******/ module.l = true; |
|
25 /******/ |
|
26 /******/ // Return the exports of the module |
|
27 /******/ return module.exports; |
|
28 /******/ } |
|
29 /******/ |
|
30 /******/ |
|
31 /******/ // expose the modules object (__webpack_modules__) |
|
32 /******/ __webpack_require__.m = modules; |
|
33 /******/ |
|
34 /******/ // expose the module cache |
|
35 /******/ __webpack_require__.c = installedModules; |
|
36 /******/ |
|
37 /******/ // define getter function for harmony exports |
|
38 /******/ __webpack_require__.d = function(exports, name, getter) { |
|
39 /******/ if(!__webpack_require__.o(exports, name)) { |
|
40 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); |
|
41 /******/ } |
|
42 /******/ }; |
|
43 /******/ |
|
44 /******/ // define __esModule on exports |
|
45 /******/ __webpack_require__.r = function(exports) { |
|
46 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
|
47 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
|
48 /******/ } |
|
49 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
|
50 /******/ }; |
|
51 /******/ |
|
52 /******/ // create a fake namespace object |
|
53 /******/ // mode & 1: value is a module id, require it |
|
54 /******/ // mode & 2: merge all properties of value into the ns |
|
55 /******/ // mode & 4: return value when already ns object |
|
56 /******/ // mode & 8|1: behave like require |
|
57 /******/ __webpack_require__.t = function(value, mode) { |
|
58 /******/ if(mode & 1) value = __webpack_require__(value); |
|
59 /******/ if(mode & 8) return value; |
|
60 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; |
|
61 /******/ var ns = Object.create(null); |
|
62 /******/ __webpack_require__.r(ns); |
|
63 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); |
|
64 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); |
|
65 /******/ return ns; |
|
66 /******/ }; |
|
67 /******/ |
|
68 /******/ // getDefaultExport function for compatibility with non-harmony modules |
|
69 /******/ __webpack_require__.n = function(module) { |
|
70 /******/ var getter = module && module.__esModule ? |
|
71 /******/ function getDefault() { return module['default']; } : |
|
72 /******/ function getModuleExports() { return module; }; |
|
73 /******/ __webpack_require__.d(getter, 'a', getter); |
|
74 /******/ return getter; |
|
75 /******/ }; |
|
76 /******/ |
|
77 /******/ // Object.prototype.hasOwnProperty.call |
|
78 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; |
|
79 /******/ |
|
80 /******/ // __webpack_public_path__ |
|
81 /******/ __webpack_require__.p = ""; |
|
82 /******/ |
|
83 /******/ |
|
84 /******/ // Load entry module and return exports |
|
85 /******/ return __webpack_require__(__webpack_require__.s = 361); |
|
86 /******/ }) |
|
87 /************************************************************************/ |
|
88 /******/ ({ |
|
89 |
|
90 /***/ 0: |
|
91 /***/ (function(module, exports) { |
|
92 |
|
93 (function() { module.exports = this["wp"]["element"]; }()); |
|
94 |
|
95 /***/ }), |
|
96 |
|
97 /***/ 15: |
|
98 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
99 |
|
100 "use strict"; |
|
101 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; }); |
|
102 function _defineProperty(obj, key, value) { |
|
103 if (key in obj) { |
|
104 Object.defineProperty(obj, key, { |
|
105 value: value, |
|
106 enumerable: true, |
|
107 configurable: true, |
|
108 writable: true |
|
109 }); |
|
110 } else { |
|
111 obj[key] = value; |
|
112 } |
|
113 |
|
114 return obj; |
|
115 } |
|
116 |
|
117 /***/ }), |
|
118 |
|
119 /***/ 17: |
|
120 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
121 |
|
122 "use strict"; |
|
123 |
|
124 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js |
|
125 function _arrayWithoutHoles(arr) { |
|
126 if (Array.isArray(arr)) { |
|
127 for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { |
|
128 arr2[i] = arr[i]; |
|
129 } |
|
130 |
|
131 return arr2; |
|
132 } |
|
133 } |
|
134 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js |
|
135 var iterableToArray = __webpack_require__(34); |
|
136 |
|
137 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js |
|
138 function _nonIterableSpread() { |
|
139 throw new TypeError("Invalid attempt to spread non-iterable instance"); |
|
140 } |
|
141 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js |
|
142 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _toConsumableArray; }); |
|
143 |
|
144 |
|
145 |
|
146 function _toConsumableArray(arr) { |
|
147 return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || _nonIterableSpread(); |
|
148 } |
|
149 |
|
150 /***/ }), |
|
151 |
|
152 /***/ 19: |
|
153 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
154 |
|
155 "use strict"; |
|
156 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; }); |
|
157 function _extends() { |
|
158 _extends = Object.assign || function (target) { |
|
159 for (var i = 1; i < arguments.length; i++) { |
|
160 var source = arguments[i]; |
|
161 |
|
162 for (var key in source) { |
|
163 if (Object.prototype.hasOwnProperty.call(source, key)) { |
|
164 target[key] = source[key]; |
|
165 } |
|
166 } |
|
167 } |
|
168 |
|
169 return target; |
|
170 }; |
|
171 |
|
172 return _extends.apply(this, arguments); |
|
173 } |
|
174 |
|
175 /***/ }), |
|
176 |
|
177 /***/ 2: |
|
178 /***/ (function(module, exports) { |
|
179 |
|
180 (function() { module.exports = this["lodash"]; }()); |
|
181 |
|
182 /***/ }), |
|
183 |
|
184 /***/ 26: |
|
185 /***/ (function(module, exports) { |
|
186 |
|
187 (function() { module.exports = this["wp"]["hooks"]; }()); |
|
188 |
|
189 /***/ }), |
|
190 |
|
191 /***/ 30: |
|
192 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
193 |
|
194 "use strict"; |
|
195 |
|
196 |
|
197 var LEAF_KEY, hasWeakMap; |
|
198 |
|
199 /** |
|
200 * Arbitrary value used as key for referencing cache object in WeakMap tree. |
|
201 * |
|
202 * @type {Object} |
|
203 */ |
|
204 LEAF_KEY = {}; |
|
205 |
|
206 /** |
|
207 * Whether environment supports WeakMap. |
|
208 * |
|
209 * @type {boolean} |
|
210 */ |
|
211 hasWeakMap = typeof WeakMap !== 'undefined'; |
|
212 |
|
213 /** |
|
214 * Returns the first argument as the sole entry in an array. |
|
215 * |
|
216 * @param {*} value Value to return. |
|
217 * |
|
218 * @return {Array} Value returned as entry in array. |
|
219 */ |
|
220 function arrayOf( value ) { |
|
221 return [ value ]; |
|
222 } |
|
223 |
|
224 /** |
|
225 * Returns true if the value passed is object-like, or false otherwise. A value |
|
226 * is object-like if it can support property assignment, e.g. object or array. |
|
227 * |
|
228 * @param {*} value Value to test. |
|
229 * |
|
230 * @return {boolean} Whether value is object-like. |
|
231 */ |
|
232 function isObjectLike( value ) { |
|
233 return !! value && 'object' === typeof value; |
|
234 } |
|
235 |
|
236 /** |
|
237 * Creates and returns a new cache object. |
|
238 * |
|
239 * @return {Object} Cache object. |
|
240 */ |
|
241 function createCache() { |
|
242 var cache = { |
|
243 clear: function() { |
|
244 cache.head = null; |
|
245 }, |
|
246 }; |
|
247 |
|
248 return cache; |
|
249 } |
|
250 |
|
251 /** |
|
252 * Returns true if entries within the two arrays are strictly equal by |
|
253 * reference from a starting index. |
|
254 * |
|
255 * @param {Array} a First array. |
|
256 * @param {Array} b Second array. |
|
257 * @param {number} fromIndex Index from which to start comparison. |
|
258 * |
|
259 * @return {boolean} Whether arrays are shallowly equal. |
|
260 */ |
|
261 function isShallowEqual( a, b, fromIndex ) { |
|
262 var i; |
|
263 |
|
264 if ( a.length !== b.length ) { |
|
265 return false; |
|
266 } |
|
267 |
|
268 for ( i = fromIndex; i < a.length; i++ ) { |
|
269 if ( a[ i ] !== b[ i ] ) { |
|
270 return false; |
|
271 } |
|
272 } |
|
273 |
|
274 return true; |
|
275 } |
|
276 |
|
277 /** |
|
278 * Returns a memoized selector function. The getDependants function argument is |
|
279 * called before the memoized selector and is expected to return an immutable |
|
280 * reference or array of references on which the selector depends for computing |
|
281 * its own return value. The memoize cache is preserved only as long as those |
|
282 * dependant references remain the same. If getDependants returns a different |
|
283 * reference(s), the cache is cleared and the selector value regenerated. |
|
284 * |
|
285 * @param {Function} selector Selector function. |
|
286 * @param {Function} getDependants Dependant getter returning an immutable |
|
287 * reference or array of reference used in |
|
288 * cache bust consideration. |
|
289 * |
|
290 * @return {Function} Memoized selector. |
|
291 */ |
|
292 /* harmony default export */ __webpack_exports__["a"] = (function( selector, getDependants ) { |
|
293 var rootCache, getCache; |
|
294 |
|
295 // Use object source as dependant if getter not provided |
|
296 if ( ! getDependants ) { |
|
297 getDependants = arrayOf; |
|
298 } |
|
299 |
|
300 /** |
|
301 * Returns the root cache. If WeakMap is supported, this is assigned to the |
|
302 * root WeakMap cache set, otherwise it is a shared instance of the default |
|
303 * cache object. |
|
304 * |
|
305 * @return {(WeakMap|Object)} Root cache object. |
|
306 */ |
|
307 function getRootCache() { |
|
308 return rootCache; |
|
309 } |
|
310 |
|
311 /** |
|
312 * Returns the cache for a given dependants array. When possible, a WeakMap |
|
313 * will be used to create a unique cache for each set of dependants. This |
|
314 * is feasible due to the nature of WeakMap in allowing garbage collection |
|
315 * to occur on entries where the key object is no longer referenced. Since |
|
316 * WeakMap requires the key to be an object, this is only possible when the |
|
317 * dependant is object-like. The root cache is created as a hierarchy where |
|
318 * each top-level key is the first entry in a dependants set, the value a |
|
319 * WeakMap where each key is the next dependant, and so on. This continues |
|
320 * so long as the dependants are object-like. If no dependants are object- |
|
321 * like, then the cache is shared across all invocations. |
|
322 * |
|
323 * @see isObjectLike |
|
324 * |
|
325 * @param {Array} dependants Selector dependants. |
|
326 * |
|
327 * @return {Object} Cache object. |
|
328 */ |
|
329 function getWeakMapCache( dependants ) { |
|
330 var caches = rootCache, |
|
331 isUniqueByDependants = true, |
|
332 i, dependant, map, cache; |
|
333 |
|
334 for ( i = 0; i < dependants.length; i++ ) { |
|
335 dependant = dependants[ i ]; |
|
336 |
|
337 // Can only compose WeakMap from object-like key. |
|
338 if ( ! isObjectLike( dependant ) ) { |
|
339 isUniqueByDependants = false; |
|
340 break; |
|
341 } |
|
342 |
|
343 // Does current segment of cache already have a WeakMap? |
|
344 if ( caches.has( dependant ) ) { |
|
345 // Traverse into nested WeakMap. |
|
346 caches = caches.get( dependant ); |
|
347 } else { |
|
348 // Create, set, and traverse into a new one. |
|
349 map = new WeakMap(); |
|
350 caches.set( dependant, map ); |
|
351 caches = map; |
|
352 } |
|
353 } |
|
354 |
|
355 // We use an arbitrary (but consistent) object as key for the last item |
|
356 // in the WeakMap to serve as our running cache. |
|
357 if ( ! caches.has( LEAF_KEY ) ) { |
|
358 cache = createCache(); |
|
359 cache.isUniqueByDependants = isUniqueByDependants; |
|
360 caches.set( LEAF_KEY, cache ); |
|
361 } |
|
362 |
|
363 return caches.get( LEAF_KEY ); |
|
364 } |
|
365 |
|
366 // Assign cache handler by availability of WeakMap |
|
367 getCache = hasWeakMap ? getWeakMapCache : getRootCache; |
|
368 |
|
369 /** |
|
370 * Resets root memoization cache. |
|
371 */ |
|
372 function clear() { |
|
373 rootCache = hasWeakMap ? new WeakMap() : createCache(); |
|
374 } |
|
375 |
|
376 // eslint-disable-next-line jsdoc/check-param-names |
|
377 /** |
|
378 * The augmented selector call, considering first whether dependants have |
|
379 * changed before passing it to underlying memoize function. |
|
380 * |
|
381 * @param {Object} source Source object for derivation. |
|
382 * @param {...*} extraArgs Additional arguments to pass to selector. |
|
383 * |
|
384 * @return {*} Selector result. |
|
385 */ |
|
386 function callSelector( /* source, ...extraArgs */ ) { |
|
387 var len = arguments.length, |
|
388 cache, node, i, args, dependants; |
|
389 |
|
390 // Create copy of arguments (avoid leaking deoptimization). |
|
391 args = new Array( len ); |
|
392 for ( i = 0; i < len; i++ ) { |
|
393 args[ i ] = arguments[ i ]; |
|
394 } |
|
395 |
|
396 dependants = getDependants.apply( null, args ); |
|
397 cache = getCache( dependants ); |
|
398 |
|
399 // If not guaranteed uniqueness by dependants (primitive type or lack |
|
400 // of WeakMap support), shallow compare against last dependants and, if |
|
401 // references have changed, destroy cache to recalculate result. |
|
402 if ( ! cache.isUniqueByDependants ) { |
|
403 if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) { |
|
404 cache.clear(); |
|
405 } |
|
406 |
|
407 cache.lastDependants = dependants; |
|
408 } |
|
409 |
|
410 node = cache.head; |
|
411 while ( node ) { |
|
412 // Check whether node arguments match arguments |
|
413 if ( ! isShallowEqual( node.args, args, 1 ) ) { |
|
414 node = node.next; |
|
415 continue; |
|
416 } |
|
417 |
|
418 // At this point we can assume we've found a match |
|
419 |
|
420 // Surface matched node to head if not already |
|
421 if ( node !== cache.head ) { |
|
422 // Adjust siblings to point to each other. |
|
423 node.prev.next = node.next; |
|
424 if ( node.next ) { |
|
425 node.next.prev = node.prev; |
|
426 } |
|
427 |
|
428 node.next = cache.head; |
|
429 node.prev = null; |
|
430 cache.head.prev = node; |
|
431 cache.head = node; |
|
432 } |
|
433 |
|
434 // Return immediately |
|
435 return node.val; |
|
436 } |
|
437 |
|
438 // No cached value found. Continue to insertion phase: |
|
439 |
|
440 node = { |
|
441 // Generate the result from original function |
|
442 val: selector.apply( null, args ), |
|
443 }; |
|
444 |
|
445 // Avoid including the source object in the cache. |
|
446 args[ 0 ] = null; |
|
447 node.args = args; |
|
448 |
|
449 // Don't need to check whether node is already head, since it would |
|
450 // have been returned above already if it was |
|
451 |
|
452 // Shift existing head down list |
|
453 if ( cache.head ) { |
|
454 cache.head.prev = node; |
|
455 node.next = cache.head; |
|
456 } |
|
457 |
|
458 cache.head = node; |
|
459 |
|
460 return node.val; |
|
461 } |
|
462 |
|
463 callSelector.getDependants = getDependants; |
|
464 callSelector.clear = clear; |
|
465 clear(); |
|
466 |
|
467 return callSelector; |
|
468 }); |
|
469 |
|
470 |
|
471 /***/ }), |
|
472 |
|
473 /***/ 32: |
|
474 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
475 |
|
476 "use strict"; |
|
477 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _typeof; }); |
|
478 function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); } |
|
479 |
|
480 function _typeof(obj) { |
|
481 if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { |
|
482 _typeof = function _typeof(obj) { |
|
483 return _typeof2(obj); |
|
484 }; |
|
485 } else { |
|
486 _typeof = function _typeof(obj) { |
|
487 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); |
|
488 }; |
|
489 } |
|
490 |
|
491 return _typeof(obj); |
|
492 } |
|
493 |
|
494 /***/ }), |
|
495 |
|
496 /***/ 34: |
|
497 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
498 |
|
499 "use strict"; |
|
500 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; }); |
|
501 function _iterableToArray(iter) { |
|
502 if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); |
|
503 } |
|
504 |
|
505 /***/ }), |
|
506 |
|
507 /***/ 361: |
|
508 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
509 |
|
510 "use strict"; |
|
511 __webpack_require__.r(__webpack_exports__); |
|
512 var selectors_namespaceObject = {}; |
|
513 __webpack_require__.r(selectors_namespaceObject); |
|
514 __webpack_require__.d(selectors_namespaceObject, "getFormatTypes", function() { return getFormatTypes; }); |
|
515 __webpack_require__.d(selectors_namespaceObject, "getFormatType", function() { return getFormatType; }); |
|
516 __webpack_require__.d(selectors_namespaceObject, "getFormatTypeForBareElement", function() { return getFormatTypeForBareElement; }); |
|
517 __webpack_require__.d(selectors_namespaceObject, "getFormatTypeForClassName", function() { return getFormatTypeForClassName; }); |
|
518 var actions_namespaceObject = {}; |
|
519 __webpack_require__.r(actions_namespaceObject); |
|
520 __webpack_require__.d(actions_namespaceObject, "addFormatTypes", function() { return addFormatTypes; }); |
|
521 __webpack_require__.d(actions_namespaceObject, "removeFormatTypes", function() { return removeFormatTypes; }); |
|
522 |
|
523 // EXTERNAL MODULE: external {"this":["wp","data"]} |
|
524 var external_this_wp_data_ = __webpack_require__(5); |
|
525 |
|
526 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread.js |
|
527 var objectSpread = __webpack_require__(7); |
|
528 |
|
529 // EXTERNAL MODULE: external "lodash" |
|
530 var external_lodash_ = __webpack_require__(2); |
|
531 |
|
532 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/reducer.js |
|
533 |
|
534 |
|
535 /** |
|
536 * External dependencies |
|
537 */ |
|
538 |
|
539 /** |
|
540 * WordPress dependencies |
|
541 */ |
|
542 |
|
543 |
|
544 /** |
|
545 * Reducer managing the format types |
|
546 * |
|
547 * @param {Object} state Current state. |
|
548 * @param {Object} action Dispatched action. |
|
549 * |
|
550 * @return {Object} Updated state. |
|
551 */ |
|
552 |
|
553 function reducer_formatTypes() { |
|
554 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
555 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
556 |
|
557 switch (action.type) { |
|
558 case 'ADD_FORMAT_TYPES': |
|
559 return Object(objectSpread["a" /* default */])({}, state, Object(external_lodash_["keyBy"])(action.formatTypes, 'name')); |
|
560 |
|
561 case 'REMOVE_FORMAT_TYPES': |
|
562 return Object(external_lodash_["omit"])(state, action.names); |
|
563 } |
|
564 |
|
565 return state; |
|
566 } |
|
567 /* harmony default export */ var reducer = (Object(external_this_wp_data_["combineReducers"])({ |
|
568 formatTypes: reducer_formatTypes |
|
569 })); |
|
570 |
|
571 // EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js |
|
572 var rememo = __webpack_require__(30); |
|
573 |
|
574 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/selectors.js |
|
575 /** |
|
576 * External dependencies |
|
577 */ |
|
578 |
|
579 |
|
580 /** |
|
581 * Returns all the available format types. |
|
582 * |
|
583 * @param {Object} state Data state. |
|
584 * |
|
585 * @return {Array} Format types. |
|
586 */ |
|
587 |
|
588 var getFormatTypes = Object(rememo["a" /* default */])(function (state) { |
|
589 return Object.values(state.formatTypes); |
|
590 }, function (state) { |
|
591 return [state.formatTypes]; |
|
592 }); |
|
593 /** |
|
594 * Returns a format type by name. |
|
595 * |
|
596 * @param {Object} state Data state. |
|
597 * @param {string} name Format type name. |
|
598 * |
|
599 * @return {Object?} Format type. |
|
600 */ |
|
601 |
|
602 function getFormatType(state, name) { |
|
603 return state.formatTypes[name]; |
|
604 } |
|
605 /** |
|
606 * Gets the format type, if any, that can handle a bare element (without a |
|
607 * data-format-type attribute), given the tag name of this element. |
|
608 * |
|
609 * @param {Object} state Data state. |
|
610 * @param {string} bareElementTagName The tag name of the element to find a |
|
611 * format type for. |
|
612 * @return {?Object} Format type. |
|
613 */ |
|
614 |
|
615 function getFormatTypeForBareElement(state, bareElementTagName) { |
|
616 return Object(external_lodash_["find"])(getFormatTypes(state), function (_ref) { |
|
617 var tagName = _ref.tagName; |
|
618 return bareElementTagName === tagName; |
|
619 }); |
|
620 } |
|
621 /** |
|
622 * Gets the format type, if any, that can handle an element, given its classes. |
|
623 * |
|
624 * @param {Object} state Data state. |
|
625 * @param {string} elementClassName The classes of the element to find a format |
|
626 * type for. |
|
627 * @return {?Object} Format type. |
|
628 */ |
|
629 |
|
630 function getFormatTypeForClassName(state, elementClassName) { |
|
631 return Object(external_lodash_["find"])(getFormatTypes(state), function (_ref2) { |
|
632 var className = _ref2.className; |
|
633 |
|
634 if (className === null) { |
|
635 return false; |
|
636 } |
|
637 |
|
638 return " ".concat(elementClassName, " ").indexOf(" ".concat(className, " ")) >= 0; |
|
639 }); |
|
640 } |
|
641 |
|
642 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/actions.js |
|
643 /** |
|
644 * External dependencies |
|
645 */ |
|
646 |
|
647 /** |
|
648 * Returns an action object used in signalling that format types have been |
|
649 * added. |
|
650 * |
|
651 * @param {Array|Object} formatTypes Format types received. |
|
652 * |
|
653 * @return {Object} Action object. |
|
654 */ |
|
655 |
|
656 function addFormatTypes(formatTypes) { |
|
657 return { |
|
658 type: 'ADD_FORMAT_TYPES', |
|
659 formatTypes: Object(external_lodash_["castArray"])(formatTypes) |
|
660 }; |
|
661 } |
|
662 /** |
|
663 * Returns an action object used to remove a registered format type. |
|
664 * |
|
665 * @param {string|Array} names Format name. |
|
666 * |
|
667 * @return {Object} Action object. |
|
668 */ |
|
669 |
|
670 function removeFormatTypes(names) { |
|
671 return { |
|
672 type: 'REMOVE_FORMAT_TYPES', |
|
673 names: Object(external_lodash_["castArray"])(names) |
|
674 }; |
|
675 } |
|
676 |
|
677 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/index.js |
|
678 /** |
|
679 * WordPress dependencies |
|
680 */ |
|
681 |
|
682 /** |
|
683 * Internal dependencies |
|
684 */ |
|
685 |
|
686 |
|
687 |
|
688 |
|
689 Object(external_this_wp_data_["registerStore"])('core/rich-text', { |
|
690 reducer: reducer, |
|
691 selectors: selectors_namespaceObject, |
|
692 actions: actions_namespaceObject |
|
693 }); |
|
694 |
|
695 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules |
|
696 var toConsumableArray = __webpack_require__(17); |
|
697 |
|
698 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-format-equal.js |
|
699 /** |
|
700 * Optimised equality check for format objects. |
|
701 * |
|
702 * @param {?Object} format1 Format to compare. |
|
703 * @param {?Object} format2 Format to compare. |
|
704 * |
|
705 * @return {boolean} True if formats are equal, false if not. |
|
706 */ |
|
707 function isFormatEqual(format1, format2) { |
|
708 // Both not defined. |
|
709 if (format1 === format2) { |
|
710 return true; |
|
711 } // Either not defined. |
|
712 |
|
713 |
|
714 if (!format1 || !format2) { |
|
715 return false; |
|
716 } |
|
717 |
|
718 if (format1.type !== format2.type) { |
|
719 return false; |
|
720 } |
|
721 |
|
722 var attributes1 = format1.attributes; |
|
723 var attributes2 = format2.attributes; // Both not defined. |
|
724 |
|
725 if (attributes1 === attributes2) { |
|
726 return true; |
|
727 } // Either not defined. |
|
728 |
|
729 |
|
730 if (!attributes1 || !attributes2) { |
|
731 return false; |
|
732 } |
|
733 |
|
734 var keys1 = Object.keys(attributes1); |
|
735 var keys2 = Object.keys(attributes2); |
|
736 |
|
737 if (keys1.length !== keys2.length) { |
|
738 return false; |
|
739 } |
|
740 |
|
741 var length = keys1.length; // Optimise for speed. |
|
742 |
|
743 for (var i = 0; i < length; i++) { |
|
744 var name = keys1[i]; |
|
745 |
|
746 if (attributes1[name] !== attributes2[name]) { |
|
747 return false; |
|
748 } |
|
749 } |
|
750 |
|
751 return true; |
|
752 } |
|
753 |
|
754 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/normalise-formats.js |
|
755 |
|
756 |
|
757 /** |
|
758 * Internal dependencies |
|
759 */ |
|
760 |
|
761 /** |
|
762 * Normalises formats: ensures subsequent adjacent equal formats have the same |
|
763 * reference. |
|
764 * |
|
765 * @param {Object} value Value to normalise formats of. |
|
766 * |
|
767 * @return {Object} New value with normalised formats. |
|
768 */ |
|
769 |
|
770 function normaliseFormats(value) { |
|
771 var newFormats = value.formats.slice(); |
|
772 newFormats.forEach(function (formatsAtIndex, index) { |
|
773 var formatsAtPreviousIndex = newFormats[index - 1]; |
|
774 |
|
775 if (formatsAtPreviousIndex) { |
|
776 var newFormatsAtIndex = formatsAtIndex.slice(); |
|
777 newFormatsAtIndex.forEach(function (format, formatIndex) { |
|
778 var previousFormat = formatsAtPreviousIndex[formatIndex]; |
|
779 |
|
780 if (isFormatEqual(format, previousFormat)) { |
|
781 newFormatsAtIndex[formatIndex] = previousFormat; |
|
782 } |
|
783 }); |
|
784 newFormats[index] = newFormatsAtIndex; |
|
785 } |
|
786 }); |
|
787 return Object(objectSpread["a" /* default */])({}, value, { |
|
788 formats: newFormats |
|
789 }); |
|
790 } |
|
791 |
|
792 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/apply-format.js |
|
793 |
|
794 |
|
795 |
|
796 /** |
|
797 * External dependencies |
|
798 */ |
|
799 |
|
800 /** |
|
801 * Internal dependencies |
|
802 */ |
|
803 |
|
804 |
|
805 /** |
|
806 * Apply a format object to a Rich Text value from the given `startIndex` to the |
|
807 * given `endIndex`. Indices are retrieved from the selection if none are |
|
808 * provided. |
|
809 * |
|
810 * @param {Object} value Value to modify. |
|
811 * @param {Object} format Format to apply. |
|
812 * @param {number} [startIndex] Start index. |
|
813 * @param {number} [endIndex] End index. |
|
814 * |
|
815 * @return {Object} A new value with the format applied. |
|
816 */ |
|
817 |
|
818 function applyFormat(value, format) { |
|
819 var startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : value.start; |
|
820 var endIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : value.end; |
|
821 var formats = value.formats, |
|
822 activeFormats = value.activeFormats; |
|
823 var newFormats = formats.slice(); // The selection is collapsed. |
|
824 |
|
825 if (startIndex === endIndex) { |
|
826 var startFormat = Object(external_lodash_["find"])(newFormats[startIndex], { |
|
827 type: format.type |
|
828 }); // If the caret is at a format of the same type, expand start and end to |
|
829 // the edges of the format. This is useful to apply new attributes. |
|
830 |
|
831 if (startFormat) { |
|
832 while (Object(external_lodash_["find"])(newFormats[startIndex], startFormat)) { |
|
833 applyFormats(newFormats, startIndex, format); |
|
834 startIndex--; |
|
835 } |
|
836 |
|
837 endIndex++; |
|
838 |
|
839 while (Object(external_lodash_["find"])(newFormats[endIndex], startFormat)) { |
|
840 applyFormats(newFormats, endIndex, format); |
|
841 endIndex++; |
|
842 } |
|
843 } |
|
844 } else { |
|
845 for (var index = startIndex; index < endIndex; index++) { |
|
846 applyFormats(newFormats, index, format); |
|
847 } |
|
848 } |
|
849 |
|
850 return normaliseFormats(Object(objectSpread["a" /* default */])({}, value, { |
|
851 formats: newFormats, |
|
852 // Always revise active formats. This serves as a placeholder for new |
|
853 // inputs with the format so new input appears with the format applied, |
|
854 // and ensures a format of the same type uses the latest values. |
|
855 activeFormats: [].concat(Object(toConsumableArray["a" /* default */])(Object(external_lodash_["reject"])(activeFormats, { |
|
856 type: format.type |
|
857 })), [format]) |
|
858 })); |
|
859 } |
|
860 |
|
861 function applyFormats(formats, index, format) { |
|
862 if (formats[index]) { |
|
863 var newFormatsAtIndex = formats[index].filter(function (_ref) { |
|
864 var type = _ref.type; |
|
865 return type !== format.type; |
|
866 }); |
|
867 newFormatsAtIndex.push(format); |
|
868 formats[index] = newFormatsAtIndex; |
|
869 } else { |
|
870 formats[index] = [format]; |
|
871 } |
|
872 } |
|
873 |
|
874 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/char-at.js |
|
875 /** |
|
876 * Gets the character at the specified index, or returns `undefined` if no |
|
877 * character was found. |
|
878 * |
|
879 * @param {Object} value Value to get the character from. |
|
880 * @param {string} index Index to use. |
|
881 * |
|
882 * @return {string|undefined} A one character long string, or undefined. |
|
883 */ |
|
884 function charAt(_ref, index) { |
|
885 var text = _ref.text; |
|
886 return text[index]; |
|
887 } |
|
888 |
|
889 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js |
|
890 var esm_typeof = __webpack_require__(32); |
|
891 |
|
892 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/create-element.js |
|
893 /** |
|
894 * Parse the given HTML into a body element. |
|
895 * |
|
896 * Note: The current implementation will return a shared reference, reset on |
|
897 * each call to `createElement`. Therefore, you should not hold a reference to |
|
898 * the value to operate upon asynchronously, as it may have unexpected results. |
|
899 * |
|
900 * @param {HTMLDocument} document The HTML document to use to parse. |
|
901 * @param {string} html The HTML to parse. |
|
902 * |
|
903 * @return {HTMLBodyElement} Body element with parsed HTML. |
|
904 */ |
|
905 function createElement(_ref, html) { |
|
906 var implementation = _ref.implementation; |
|
907 |
|
908 // Because `createHTMLDocument` is an expensive operation, and with this |
|
909 // function being internal to `rich-text` (full control in avoiding a risk |
|
910 // of asynchronous operations on the shared reference), a single document |
|
911 // is reused and reset for each call to the function. |
|
912 if (!createElement.body) { |
|
913 createElement.body = implementation.createHTMLDocument('').body; |
|
914 } |
|
915 |
|
916 createElement.body.innerHTML = html; |
|
917 return createElement.body; |
|
918 } |
|
919 |
|
920 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/special-characters.js |
|
921 /** |
|
922 * Line separator character. |
|
923 */ |
|
924 var LINE_SEPARATOR = "\u2028"; |
|
925 var OBJECT_REPLACEMENT_CHARACTER = "\uFFFC"; |
|
926 |
|
927 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/create.js |
|
928 |
|
929 |
|
930 |
|
931 |
|
932 /** |
|
933 * WordPress dependencies |
|
934 */ |
|
935 |
|
936 /** |
|
937 * Internal dependencies |
|
938 */ |
|
939 |
|
940 |
|
941 |
|
942 |
|
943 |
|
944 /** |
|
945 * Browser dependencies |
|
946 */ |
|
947 |
|
948 var _window$Node = window.Node, |
|
949 TEXT_NODE = _window$Node.TEXT_NODE, |
|
950 ELEMENT_NODE = _window$Node.ELEMENT_NODE; |
|
951 |
|
952 function createEmptyValue() { |
|
953 return { |
|
954 formats: [], |
|
955 replacements: [], |
|
956 text: '' |
|
957 }; |
|
958 } |
|
959 |
|
960 function simpleFindKey(object, value) { |
|
961 for (var key in object) { |
|
962 if (object[key] === value) { |
|
963 return key; |
|
964 } |
|
965 } |
|
966 } |
|
967 |
|
968 function toFormat(_ref) { |
|
969 var type = _ref.type, |
|
970 attributes = _ref.attributes; |
|
971 var formatType; |
|
972 |
|
973 if (attributes && attributes.class) { |
|
974 formatType = Object(external_this_wp_data_["select"])('core/rich-text').getFormatTypeForClassName(attributes.class); |
|
975 |
|
976 if (formatType) { |
|
977 // Preserve any additional classes. |
|
978 attributes.class = " ".concat(attributes.class, " ").replace(" ".concat(formatType.className, " "), ' ').trim(); |
|
979 |
|
980 if (!attributes.class) { |
|
981 delete attributes.class; |
|
982 } |
|
983 } |
|
984 } |
|
985 |
|
986 if (!formatType) { |
|
987 formatType = Object(external_this_wp_data_["select"])('core/rich-text').getFormatTypeForBareElement(type); |
|
988 } |
|
989 |
|
990 if (!formatType) { |
|
991 return attributes ? { |
|
992 type: type, |
|
993 attributes: attributes |
|
994 } : { |
|
995 type: type |
|
996 }; |
|
997 } |
|
998 |
|
999 if (formatType.__experimentalCreatePrepareEditableTree && !formatType.__experimentalCreateOnChangeEditableValue) { |
|
1000 return null; |
|
1001 } |
|
1002 |
|
1003 if (!attributes) { |
|
1004 return { |
|
1005 type: formatType.name |
|
1006 }; |
|
1007 } |
|
1008 |
|
1009 var registeredAttributes = {}; |
|
1010 var unregisteredAttributes = {}; |
|
1011 |
|
1012 for (var name in attributes) { |
|
1013 var key = simpleFindKey(formatType.attributes, name); |
|
1014 |
|
1015 if (key) { |
|
1016 registeredAttributes[key] = attributes[name]; |
|
1017 } else { |
|
1018 unregisteredAttributes[name] = attributes[name]; |
|
1019 } |
|
1020 } |
|
1021 |
|
1022 return { |
|
1023 type: formatType.name, |
|
1024 attributes: registeredAttributes, |
|
1025 unregisteredAttributes: unregisteredAttributes |
|
1026 }; |
|
1027 } |
|
1028 /** |
|
1029 * Create a RichText value from an `Element` tree (DOM), an HTML string or a |
|
1030 * plain text string, with optionally a `Range` object to set the selection. If |
|
1031 * called without any input, an empty value will be created. If |
|
1032 * `multilineTag` is provided, any content of direct children whose type matches |
|
1033 * `multilineTag` will be separated by two newlines. The optional functions can |
|
1034 * be used to filter out content. |
|
1035 * |
|
1036 * A value will have the following shape, which you are strongly encouraged not |
|
1037 * to modify without the use of helper functions: |
|
1038 * |
|
1039 * ```js |
|
1040 * { |
|
1041 * text: string, |
|
1042 * formats: Array, |
|
1043 * replacements: Array, |
|
1044 * ?start: number, |
|
1045 * ?end: number, |
|
1046 * } |
|
1047 * ``` |
|
1048 * |
|
1049 * As you can see, text and formatting are separated. `text` holds the text, |
|
1050 * including any replacement characters for objects and lines. `formats`, |
|
1051 * `objects` and `lines` are all sparse arrays of the same length as `text`. It |
|
1052 * holds information about the formatting at the relevant text indices. Finally |
|
1053 * `start` and `end` state which text indices are selected. They are only |
|
1054 * provided if a `Range` was given. |
|
1055 * |
|
1056 * @param {Object} [$1] Optional named arguments. |
|
1057 * @param {Element} [$1.element] Element to create value from. |
|
1058 * @param {string} [$1.text] Text to create value from. |
|
1059 * @param {string} [$1.html] HTML to create value from. |
|
1060 * @param {Range} [$1.range] Range to create value from. |
|
1061 * @param {string} [$1.multilineTag] Multiline tag if the structure is |
|
1062 * multiline. |
|
1063 * @param {Array} [$1.multilineWrapperTags] Tags where lines can be found if |
|
1064 * nesting is possible. |
|
1065 * |
|
1066 * @return {Object} A rich text value. |
|
1067 */ |
|
1068 |
|
1069 |
|
1070 function create() { |
|
1071 var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, |
|
1072 element = _ref2.element, |
|
1073 text = _ref2.text, |
|
1074 html = _ref2.html, |
|
1075 range = _ref2.range, |
|
1076 multilineTag = _ref2.multilineTag, |
|
1077 multilineWrapperTags = _ref2.multilineWrapperTags, |
|
1078 isEditableTree = _ref2.__unstableIsEditableTree; |
|
1079 |
|
1080 if (typeof text === 'string' && text.length > 0) { |
|
1081 return { |
|
1082 formats: Array(text.length), |
|
1083 replacements: Array(text.length), |
|
1084 text: text |
|
1085 }; |
|
1086 } |
|
1087 |
|
1088 if (typeof html === 'string' && html.length > 0) { |
|
1089 element = createElement(document, html); |
|
1090 } |
|
1091 |
|
1092 if (Object(esm_typeof["a" /* default */])(element) !== 'object') { |
|
1093 return createEmptyValue(); |
|
1094 } |
|
1095 |
|
1096 if (!multilineTag) { |
|
1097 return createFromElement({ |
|
1098 element: element, |
|
1099 range: range, |
|
1100 isEditableTree: isEditableTree |
|
1101 }); |
|
1102 } |
|
1103 |
|
1104 return createFromMultilineElement({ |
|
1105 element: element, |
|
1106 range: range, |
|
1107 multilineTag: multilineTag, |
|
1108 multilineWrapperTags: multilineWrapperTags, |
|
1109 isEditableTree: isEditableTree |
|
1110 }); |
|
1111 } |
|
1112 /** |
|
1113 * Helper to accumulate the value's selection start and end from the current |
|
1114 * node and range. |
|
1115 * |
|
1116 * @param {Object} accumulator Object to accumulate into. |
|
1117 * @param {Node} node Node to create value with. |
|
1118 * @param {Range} range Range to create value with. |
|
1119 * @param {Object} value Value that is being accumulated. |
|
1120 */ |
|
1121 |
|
1122 function accumulateSelection(accumulator, node, range, value) { |
|
1123 if (!range) { |
|
1124 return; |
|
1125 } |
|
1126 |
|
1127 var parentNode = node.parentNode; |
|
1128 var startContainer = range.startContainer, |
|
1129 startOffset = range.startOffset, |
|
1130 endContainer = range.endContainer, |
|
1131 endOffset = range.endOffset; |
|
1132 var currentLength = accumulator.text.length; // Selection can be extracted from value. |
|
1133 |
|
1134 if (value.start !== undefined) { |
|
1135 accumulator.start = currentLength + value.start; // Range indicates that the current node has selection. |
|
1136 } else if (node === startContainer && node.nodeType === TEXT_NODE) { |
|
1137 accumulator.start = currentLength + startOffset; // Range indicates that the current node is selected. |
|
1138 } else if (parentNode === startContainer && node === startContainer.childNodes[startOffset]) { |
|
1139 accumulator.start = currentLength; // Range indicates that the selection is after the current node. |
|
1140 } else if (parentNode === startContainer && node === startContainer.childNodes[startOffset - 1]) { |
|
1141 accumulator.start = currentLength + value.text.length; // Fallback if no child inside handled the selection. |
|
1142 } else if (node === startContainer) { |
|
1143 accumulator.start = currentLength; |
|
1144 } // Selection can be extracted from value. |
|
1145 |
|
1146 |
|
1147 if (value.end !== undefined) { |
|
1148 accumulator.end = currentLength + value.end; // Range indicates that the current node has selection. |
|
1149 } else if (node === endContainer && node.nodeType === TEXT_NODE) { |
|
1150 accumulator.end = currentLength + endOffset; // Range indicates that the current node is selected. |
|
1151 } else if (parentNode === endContainer && node === endContainer.childNodes[endOffset - 1]) { |
|
1152 accumulator.end = currentLength + value.text.length; // Range indicates that the selection is before the current node. |
|
1153 } else if (parentNode === endContainer && node === endContainer.childNodes[endOffset]) { |
|
1154 accumulator.end = currentLength; // Fallback if no child inside handled the selection. |
|
1155 } else if (node === endContainer) { |
|
1156 accumulator.end = currentLength + endOffset; |
|
1157 } |
|
1158 } |
|
1159 /** |
|
1160 * Adjusts the start and end offsets from a range based on a text filter. |
|
1161 * |
|
1162 * @param {Node} node Node of which the text should be filtered. |
|
1163 * @param {Range} range The range to filter. |
|
1164 * @param {Function} filter Function to use to filter the text. |
|
1165 * |
|
1166 * @return {?Object} Object containing range properties. |
|
1167 */ |
|
1168 |
|
1169 |
|
1170 function filterRange(node, range, filter) { |
|
1171 if (!range) { |
|
1172 return; |
|
1173 } |
|
1174 |
|
1175 var startContainer = range.startContainer, |
|
1176 endContainer = range.endContainer; |
|
1177 var startOffset = range.startOffset, |
|
1178 endOffset = range.endOffset; |
|
1179 |
|
1180 if (node === startContainer) { |
|
1181 startOffset = filter(node.nodeValue.slice(0, startOffset)).length; |
|
1182 } |
|
1183 |
|
1184 if (node === endContainer) { |
|
1185 endOffset = filter(node.nodeValue.slice(0, endOffset)).length; |
|
1186 } |
|
1187 |
|
1188 return { |
|
1189 startContainer: startContainer, |
|
1190 startOffset: startOffset, |
|
1191 endContainer: endContainer, |
|
1192 endOffset: endOffset |
|
1193 }; |
|
1194 } |
|
1195 |
|
1196 function filterString(string) { |
|
1197 // Reduce any whitespace used for HTML formatting to one space |
|
1198 // character, because it will also be displayed as such by the browser. |
|
1199 return string.replace(/[\n\r\t]+/g, ' '); |
|
1200 } |
|
1201 /** |
|
1202 * Creates a Rich Text value from a DOM element and range. |
|
1203 * |
|
1204 * @param {Object} $1 Named argements. |
|
1205 * @param {?Element} $1.element Element to create value from. |
|
1206 * @param {?Range} $1.range Range to create value from. |
|
1207 * @param {?string} $1.multilineTag Multiline tag if the structure is |
|
1208 * multiline. |
|
1209 * @param {?Array} $1.multilineWrapperTags Tags where lines can be found if |
|
1210 * nesting is possible. |
|
1211 * |
|
1212 * @return {Object} A rich text value. |
|
1213 */ |
|
1214 |
|
1215 |
|
1216 function createFromElement(_ref3) { |
|
1217 var element = _ref3.element, |
|
1218 range = _ref3.range, |
|
1219 multilineTag = _ref3.multilineTag, |
|
1220 multilineWrapperTags = _ref3.multilineWrapperTags, |
|
1221 _ref3$currentWrapperT = _ref3.currentWrapperTags, |
|
1222 currentWrapperTags = _ref3$currentWrapperT === void 0 ? [] : _ref3$currentWrapperT, |
|
1223 isEditableTree = _ref3.isEditableTree; |
|
1224 var accumulator = createEmptyValue(); |
|
1225 |
|
1226 if (!element) { |
|
1227 return accumulator; |
|
1228 } |
|
1229 |
|
1230 if (!element.hasChildNodes()) { |
|
1231 accumulateSelection(accumulator, element, range, createEmptyValue()); |
|
1232 return accumulator; |
|
1233 } |
|
1234 |
|
1235 var length = element.childNodes.length; // Optimise for speed. |
|
1236 |
|
1237 var _loop = function _loop(index) { |
|
1238 var node = element.childNodes[index]; |
|
1239 var type = node.nodeName.toLowerCase(); |
|
1240 |
|
1241 if (node.nodeType === TEXT_NODE) { |
|
1242 var text = filterString(node.nodeValue); |
|
1243 range = filterRange(node, range, filterString); |
|
1244 accumulateSelection(accumulator, node, range, { |
|
1245 text: text |
|
1246 }); // Create a sparse array of the same length as `text`, in which |
|
1247 // formats can be added. |
|
1248 |
|
1249 accumulator.formats.length += text.length; |
|
1250 accumulator.replacements.length += text.length; |
|
1251 accumulator.text += text; |
|
1252 return "continue"; |
|
1253 } |
|
1254 |
|
1255 if (node.nodeType !== ELEMENT_NODE) { |
|
1256 return "continue"; |
|
1257 } |
|
1258 |
|
1259 if (node.getAttribute('data-rich-text-padding') || isEditableTree && type === 'br' && !node.getAttribute('data-rich-text-line-break')) { |
|
1260 accumulateSelection(accumulator, node, range, createEmptyValue()); |
|
1261 return "continue"; |
|
1262 } |
|
1263 |
|
1264 if (type === 'br') { |
|
1265 accumulateSelection(accumulator, node, range, createEmptyValue()); |
|
1266 mergePair(accumulator, create({ |
|
1267 text: '\n' |
|
1268 })); |
|
1269 return "continue"; |
|
1270 } |
|
1271 |
|
1272 var lastFormats = accumulator.formats[accumulator.formats.length - 1]; |
|
1273 var lastFormat = lastFormats && lastFormats[lastFormats.length - 1]; |
|
1274 var newFormat = toFormat({ |
|
1275 type: type, |
|
1276 attributes: getAttributes({ |
|
1277 element: node |
|
1278 }) |
|
1279 }); |
|
1280 var format = isFormatEqual(newFormat, lastFormat) ? lastFormat : newFormat; |
|
1281 |
|
1282 if (multilineWrapperTags && multilineWrapperTags.indexOf(type) !== -1) { |
|
1283 var _value = createFromMultilineElement({ |
|
1284 element: node, |
|
1285 range: range, |
|
1286 multilineTag: multilineTag, |
|
1287 multilineWrapperTags: multilineWrapperTags, |
|
1288 currentWrapperTags: [].concat(Object(toConsumableArray["a" /* default */])(currentWrapperTags), [format]), |
|
1289 isEditableTree: isEditableTree |
|
1290 }); |
|
1291 |
|
1292 accumulateSelection(accumulator, node, range, _value); |
|
1293 mergePair(accumulator, _value); |
|
1294 return "continue"; |
|
1295 } |
|
1296 |
|
1297 var value = createFromElement({ |
|
1298 element: node, |
|
1299 range: range, |
|
1300 multilineTag: multilineTag, |
|
1301 multilineWrapperTags: multilineWrapperTags, |
|
1302 isEditableTree: isEditableTree |
|
1303 }); |
|
1304 accumulateSelection(accumulator, node, range, value); |
|
1305 |
|
1306 if (!format) { |
|
1307 mergePair(accumulator, value); |
|
1308 } else if (value.text.length === 0) { |
|
1309 if (format.attributes) { |
|
1310 mergePair(accumulator, { |
|
1311 formats: [,], |
|
1312 replacements: [format], |
|
1313 text: OBJECT_REPLACEMENT_CHARACTER |
|
1314 }); |
|
1315 } |
|
1316 } else { |
|
1317 mergePair(accumulator, Object(objectSpread["a" /* default */])({}, value, { |
|
1318 formats: Array.from(value.formats, function (formats) { |
|
1319 return formats ? [format].concat(Object(toConsumableArray["a" /* default */])(formats)) : [format]; |
|
1320 }) |
|
1321 })); |
|
1322 } |
|
1323 }; |
|
1324 |
|
1325 for (var index = 0; index < length; index++) { |
|
1326 var _ret = _loop(index); |
|
1327 |
|
1328 if (_ret === "continue") continue; |
|
1329 } |
|
1330 |
|
1331 return accumulator; |
|
1332 } |
|
1333 /** |
|
1334 * Creates a rich text value from a DOM element and range that should be |
|
1335 * multiline. |
|
1336 * |
|
1337 * @param {Object} $1 Named argements. |
|
1338 * @param {?Element} $1.element Element to create value from. |
|
1339 * @param {?Range} $1.range Range to create value from. |
|
1340 * @param {?string} $1.multilineTag Multiline tag if the structure is |
|
1341 * multiline. |
|
1342 * @param {?Array} $1.multilineWrapperTags Tags where lines can be found if |
|
1343 * nesting is possible. |
|
1344 * @param {boolean} $1.currentWrapperTags Whether to prepend a line |
|
1345 * separator. |
|
1346 * |
|
1347 * @return {Object} A rich text value. |
|
1348 */ |
|
1349 |
|
1350 |
|
1351 function createFromMultilineElement(_ref4) { |
|
1352 var element = _ref4.element, |
|
1353 range = _ref4.range, |
|
1354 multilineTag = _ref4.multilineTag, |
|
1355 multilineWrapperTags = _ref4.multilineWrapperTags, |
|
1356 _ref4$currentWrapperT = _ref4.currentWrapperTags, |
|
1357 currentWrapperTags = _ref4$currentWrapperT === void 0 ? [] : _ref4$currentWrapperT, |
|
1358 isEditableTree = _ref4.isEditableTree; |
|
1359 var accumulator = createEmptyValue(); |
|
1360 |
|
1361 if (!element || !element.hasChildNodes()) { |
|
1362 return accumulator; |
|
1363 } |
|
1364 |
|
1365 var length = element.children.length; // Optimise for speed. |
|
1366 |
|
1367 for (var index = 0; index < length; index++) { |
|
1368 var node = element.children[index]; |
|
1369 |
|
1370 if (node.nodeName.toLowerCase() !== multilineTag) { |
|
1371 continue; |
|
1372 } |
|
1373 |
|
1374 var value = createFromElement({ |
|
1375 element: node, |
|
1376 range: range, |
|
1377 multilineTag: multilineTag, |
|
1378 multilineWrapperTags: multilineWrapperTags, |
|
1379 currentWrapperTags: currentWrapperTags, |
|
1380 isEditableTree: isEditableTree |
|
1381 }); // Multiline value text should be separated by a line separator. |
|
1382 |
|
1383 if (index !== 0 || currentWrapperTags.length > 0) { |
|
1384 mergePair(accumulator, { |
|
1385 formats: [,], |
|
1386 replacements: currentWrapperTags.length > 0 ? [currentWrapperTags] : [,], |
|
1387 text: LINE_SEPARATOR |
|
1388 }); |
|
1389 } |
|
1390 |
|
1391 accumulateSelection(accumulator, node, range, value); |
|
1392 mergePair(accumulator, value); |
|
1393 } |
|
1394 |
|
1395 return accumulator; |
|
1396 } |
|
1397 /** |
|
1398 * Gets the attributes of an element in object shape. |
|
1399 * |
|
1400 * @param {Object} $1 Named argements. |
|
1401 * @param {Element} $1.element Element to get attributes from. |
|
1402 * |
|
1403 * @return {?Object} Attribute object or `undefined` if the element has no |
|
1404 * attributes. |
|
1405 */ |
|
1406 |
|
1407 |
|
1408 function getAttributes(_ref5) { |
|
1409 var element = _ref5.element; |
|
1410 |
|
1411 if (!element.hasAttributes()) { |
|
1412 return; |
|
1413 } |
|
1414 |
|
1415 var length = element.attributes.length; |
|
1416 var accumulator; // Optimise for speed. |
|
1417 |
|
1418 for (var i = 0; i < length; i++) { |
|
1419 var _element$attributes$i = element.attributes[i], |
|
1420 name = _element$attributes$i.name, |
|
1421 value = _element$attributes$i.value; |
|
1422 |
|
1423 if (name.indexOf('data-rich-text-') === 0) { |
|
1424 continue; |
|
1425 } |
|
1426 |
|
1427 accumulator = accumulator || {}; |
|
1428 accumulator[name] = value; |
|
1429 } |
|
1430 |
|
1431 return accumulator; |
|
1432 } |
|
1433 |
|
1434 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/concat.js |
|
1435 /** |
|
1436 * Internal dependencies |
|
1437 */ |
|
1438 |
|
1439 |
|
1440 /** |
|
1441 * Concats a pair of rich text values. Not that this mutates `a` and does NOT |
|
1442 * normalise formats! |
|
1443 * |
|
1444 * @param {Object} a Value to mutate. |
|
1445 * @param {Object} b Value to add read from. |
|
1446 * |
|
1447 * @return {Object} `a`, mutated. |
|
1448 */ |
|
1449 |
|
1450 function mergePair(a, b) { |
|
1451 a.formats = a.formats.concat(b.formats); |
|
1452 a.replacements = a.replacements.concat(b.replacements); |
|
1453 a.text += b.text; |
|
1454 return a; |
|
1455 } |
|
1456 /** |
|
1457 * Combine all Rich Text values into one. This is similar to |
|
1458 * `String.prototype.concat`. |
|
1459 * |
|
1460 * @param {...Object} values Objects to combine. |
|
1461 * |
|
1462 * @return {Object} A new value combining all given records. |
|
1463 */ |
|
1464 |
|
1465 function concat() { |
|
1466 for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) { |
|
1467 values[_key] = arguments[_key]; |
|
1468 } |
|
1469 |
|
1470 return normaliseFormats(values.reduce(mergePair, create())); |
|
1471 } |
|
1472 |
|
1473 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-active-formats.js |
|
1474 /** |
|
1475 * Gets the all format objects at the start of the selection. |
|
1476 * |
|
1477 * @param {Object} value Value to inspect. |
|
1478 * |
|
1479 * @return {?Object} Active format objects. |
|
1480 */ |
|
1481 function getActiveFormats(_ref) { |
|
1482 var formats = _ref.formats, |
|
1483 start = _ref.start, |
|
1484 end = _ref.end, |
|
1485 activeFormats = _ref.activeFormats; |
|
1486 |
|
1487 if (start === undefined) { |
|
1488 return []; |
|
1489 } |
|
1490 |
|
1491 if (start === end) { |
|
1492 // For a collapsed caret, it is possible to override the active formats. |
|
1493 if (activeFormats) { |
|
1494 return activeFormats; |
|
1495 } |
|
1496 |
|
1497 var formatsBefore = formats[start - 1] || []; |
|
1498 var formatsAfter = formats[start] || []; // By default, select the lowest amount of formats possible (which means |
|
1499 // the caret is positioned outside the format boundary). The user can |
|
1500 // then use arrow keys to define `activeFormats`. |
|
1501 |
|
1502 if (formatsBefore.length < formatsAfter.length) { |
|
1503 return formatsBefore; |
|
1504 } |
|
1505 |
|
1506 return formatsAfter; |
|
1507 } |
|
1508 |
|
1509 return formats[start] || []; |
|
1510 } |
|
1511 |
|
1512 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-active-format.js |
|
1513 /** |
|
1514 * External dependencies |
|
1515 */ |
|
1516 |
|
1517 /** |
|
1518 * Internal dependencies |
|
1519 */ |
|
1520 |
|
1521 |
|
1522 /** |
|
1523 * Gets the format object by type at the start of the selection. This can be |
|
1524 * used to get e.g. the URL of a link format at the current selection, but also |
|
1525 * to check if a format is active at the selection. Returns undefined if there |
|
1526 * is no format at the selection. |
|
1527 * |
|
1528 * @param {Object} value Value to inspect. |
|
1529 * @param {string} formatType Format type to look for. |
|
1530 * |
|
1531 * @return {Object|undefined} Active format object of the specified type, or undefined. |
|
1532 */ |
|
1533 |
|
1534 function getActiveFormat(value, formatType) { |
|
1535 return Object(external_lodash_["find"])(getActiveFormats(value), { |
|
1536 type: formatType |
|
1537 }); |
|
1538 } |
|
1539 |
|
1540 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-active-object.js |
|
1541 /** |
|
1542 * Internal dependencies |
|
1543 */ |
|
1544 |
|
1545 /** |
|
1546 * Gets the active object, if there is any. |
|
1547 * |
|
1548 * @param {Object} value Value to inspect. |
|
1549 * |
|
1550 * @return {?Object} Active object, or undefined. |
|
1551 */ |
|
1552 |
|
1553 function getActiveObject(_ref) { |
|
1554 var start = _ref.start, |
|
1555 end = _ref.end, |
|
1556 replacements = _ref.replacements, |
|
1557 text = _ref.text; |
|
1558 |
|
1559 if (start + 1 !== end || text[start] !== OBJECT_REPLACEMENT_CHARACTER) { |
|
1560 return; |
|
1561 } |
|
1562 |
|
1563 return replacements[start]; |
|
1564 } |
|
1565 |
|
1566 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-selection-end.js |
|
1567 /** |
|
1568 * Gets the end index of the current selection, or returns `undefined` if no |
|
1569 * selection exists. The selection ends right before the character at this |
|
1570 * index. |
|
1571 * |
|
1572 * @param {Object} value Value to get the selection from. |
|
1573 * |
|
1574 * @return {number|undefined} Index where the selection ends. |
|
1575 */ |
|
1576 function getSelectionEnd(_ref) { |
|
1577 var end = _ref.end; |
|
1578 return end; |
|
1579 } |
|
1580 |
|
1581 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-selection-start.js |
|
1582 /** |
|
1583 * Gets the start index of the current selection, or returns `undefined` if no |
|
1584 * selection exists. The selection starts right before the character at this |
|
1585 * index. |
|
1586 * |
|
1587 * @param {Object} value Value to get the selection from. |
|
1588 * |
|
1589 * @return {number|undefined} Index where the selection starts. |
|
1590 */ |
|
1591 function getSelectionStart(_ref) { |
|
1592 var start = _ref.start; |
|
1593 return start; |
|
1594 } |
|
1595 |
|
1596 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-text-content.js |
|
1597 /** |
|
1598 * Get the textual content of a Rich Text value. This is similar to |
|
1599 * `Element.textContent`. |
|
1600 * |
|
1601 * @param {Object} value Value to use. |
|
1602 * |
|
1603 * @return {string} The text content. |
|
1604 */ |
|
1605 function getTextContent(_ref) { |
|
1606 var text = _ref.text; |
|
1607 return text; |
|
1608 } |
|
1609 |
|
1610 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-collapsed.js |
|
1611 /** |
|
1612 * Check if the selection of a Rich Text value is collapsed or not. Collapsed |
|
1613 * means that no characters are selected, but there is a caret present. If there |
|
1614 * is no selection, `undefined` will be returned. This is similar to |
|
1615 * `window.getSelection().isCollapsed()`. |
|
1616 * |
|
1617 * @param {Object} value The rich text value to check. |
|
1618 * |
|
1619 * @return {boolean|undefined} True if the selection is collapsed, false if not, |
|
1620 * undefined if there is no selection. |
|
1621 */ |
|
1622 function isCollapsed(_ref) { |
|
1623 var start = _ref.start, |
|
1624 end = _ref.end; |
|
1625 |
|
1626 if (start === undefined || end === undefined) { |
|
1627 return; |
|
1628 } |
|
1629 |
|
1630 return start === end; |
|
1631 } |
|
1632 |
|
1633 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-empty.js |
|
1634 /** |
|
1635 * Internal dependencies |
|
1636 */ |
|
1637 |
|
1638 /** |
|
1639 * Check if a Rich Text value is Empty, meaning it contains no text or any |
|
1640 * objects (such as images). |
|
1641 * |
|
1642 * @param {Object} value Value to use. |
|
1643 * |
|
1644 * @return {boolean} True if the value is empty, false if not. |
|
1645 */ |
|
1646 |
|
1647 function isEmpty(_ref) { |
|
1648 var text = _ref.text; |
|
1649 return text.length === 0; |
|
1650 } |
|
1651 /** |
|
1652 * Check if the current collapsed selection is on an empty line in case of a |
|
1653 * multiline value. |
|
1654 * |
|
1655 * @param {Object} value Value te check. |
|
1656 * |
|
1657 * @return {boolean} True if the line is empty, false if not. |
|
1658 */ |
|
1659 |
|
1660 function isEmptyLine(_ref2) { |
|
1661 var text = _ref2.text, |
|
1662 start = _ref2.start, |
|
1663 end = _ref2.end; |
|
1664 |
|
1665 if (start !== end) { |
|
1666 return false; |
|
1667 } |
|
1668 |
|
1669 if (text.length === 0) { |
|
1670 return true; |
|
1671 } |
|
1672 |
|
1673 if (start === 0 && text.slice(0, 1) === LINE_SEPARATOR) { |
|
1674 return true; |
|
1675 } |
|
1676 |
|
1677 if (start === text.length && text.slice(-1) === LINE_SEPARATOR) { |
|
1678 return true; |
|
1679 } |
|
1680 |
|
1681 return text.slice(start - 1, end + 1) === "".concat(LINE_SEPARATOR).concat(LINE_SEPARATOR); |
|
1682 } |
|
1683 |
|
1684 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/join.js |
|
1685 /** |
|
1686 * Internal dependencies |
|
1687 */ |
|
1688 |
|
1689 |
|
1690 /** |
|
1691 * Combine an array of Rich Text values into one, optionally separated by |
|
1692 * `separator`, which can be a Rich Text value, HTML string, or plain text |
|
1693 * string. This is similar to `Array.prototype.join`. |
|
1694 * |
|
1695 * @param {Array<Object>} values An array of values to join. |
|
1696 * @param {string|Object} [separator] Separator string or value. |
|
1697 * |
|
1698 * @return {Object} A new combined value. |
|
1699 */ |
|
1700 |
|
1701 function join(values) { |
|
1702 var separator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; |
|
1703 |
|
1704 if (typeof separator === 'string') { |
|
1705 separator = create({ |
|
1706 text: separator |
|
1707 }); |
|
1708 } |
|
1709 |
|
1710 return normaliseFormats(values.reduce(function (accumlator, _ref) { |
|
1711 var formats = _ref.formats, |
|
1712 replacements = _ref.replacements, |
|
1713 text = _ref.text; |
|
1714 return { |
|
1715 formats: accumlator.formats.concat(separator.formats, formats), |
|
1716 replacements: accumlator.replacements.concat(separator.replacements, replacements), |
|
1717 text: accumlator.text + separator.text + text |
|
1718 }; |
|
1719 })); |
|
1720 } |
|
1721 |
|
1722 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js |
|
1723 var defineProperty = __webpack_require__(15); |
|
1724 |
|
1725 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js |
|
1726 var esm_extends = __webpack_require__(19); |
|
1727 |
|
1728 // EXTERNAL MODULE: external {"this":["wp","element"]} |
|
1729 var external_this_wp_element_ = __webpack_require__(0); |
|
1730 |
|
1731 // EXTERNAL MODULE: ./node_modules/memize/index.js |
|
1732 var memize = __webpack_require__(41); |
|
1733 var memize_default = /*#__PURE__*/__webpack_require__.n(memize); |
|
1734 |
|
1735 // EXTERNAL MODULE: external {"this":["wp","hooks"]} |
|
1736 var external_this_wp_hooks_ = __webpack_require__(26); |
|
1737 |
|
1738 // EXTERNAL MODULE: external {"this":["wp","compose"]} |
|
1739 var external_this_wp_compose_ = __webpack_require__(6); |
|
1740 |
|
1741 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/register-format-type.js |
|
1742 |
|
1743 |
|
1744 |
|
1745 |
|
1746 |
|
1747 |
|
1748 /** |
|
1749 * External dependencies |
|
1750 */ |
|
1751 |
|
1752 |
|
1753 /** |
|
1754 * WordPress dependencies |
|
1755 */ |
|
1756 |
|
1757 |
|
1758 |
|
1759 |
|
1760 /** |
|
1761 * Shared reference to an empty array for cases where it is important to avoid |
|
1762 * returning a new array reference on every invocation, as in a connected or |
|
1763 * other pure component which performs `shouldComponentUpdate` check on props. |
|
1764 * This should be used as a last resort, since the normalized data should be |
|
1765 * maintained by the reducer result in state. |
|
1766 * |
|
1767 * @type {Array} |
|
1768 */ |
|
1769 |
|
1770 var EMPTY_ARRAY = []; |
|
1771 /** |
|
1772 * Registers a new format provided a unique name and an object defining its |
|
1773 * behavior. |
|
1774 * |
|
1775 * @param {string} name Format name. |
|
1776 * @param {Object} settings Format settings. |
|
1777 * @param {string} settings.tagName The HTML tag this format will wrap the selection with. |
|
1778 * @param {string} [settings.className] A class to match the format. |
|
1779 * @param {string} settings.title Name of the format. |
|
1780 * @param {Function} settings.edit Should return a component for the user to interact with the new registered format. |
|
1781 * |
|
1782 * @return {WPFormat|undefined} The format, if it has been successfully registered; |
|
1783 * otherwise `undefined`. |
|
1784 */ |
|
1785 |
|
1786 function registerFormatType(name, settings) { |
|
1787 settings = Object(objectSpread["a" /* default */])({ |
|
1788 name: name |
|
1789 }, settings); |
|
1790 |
|
1791 if (typeof settings.name !== 'string') { |
|
1792 window.console.error('Format names must be strings.'); |
|
1793 return; |
|
1794 } |
|
1795 |
|
1796 if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(settings.name)) { |
|
1797 window.console.error('Format names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-format'); |
|
1798 return; |
|
1799 } |
|
1800 |
|
1801 if (Object(external_this_wp_data_["select"])('core/rich-text').getFormatType(settings.name)) { |
|
1802 window.console.error('Format "' + settings.name + '" is already registered.'); |
|
1803 return; |
|
1804 } |
|
1805 |
|
1806 if (typeof settings.tagName !== 'string' || settings.tagName === '') { |
|
1807 window.console.error('Format tag names must be a string.'); |
|
1808 return; |
|
1809 } |
|
1810 |
|
1811 if ((typeof settings.className !== 'string' || settings.className === '') && settings.className !== null) { |
|
1812 window.console.error('Format class names must be a string, or null to handle bare elements.'); |
|
1813 return; |
|
1814 } |
|
1815 |
|
1816 if (!/^[_a-zA-Z]+[a-zA-Z0-9-]*$/.test(settings.className)) { |
|
1817 window.console.error('A class name must begin with a letter, followed by any number of hyphens, letters, or numbers.'); |
|
1818 return; |
|
1819 } |
|
1820 |
|
1821 if (settings.className === null) { |
|
1822 var formatTypeForBareElement = Object(external_this_wp_data_["select"])('core/rich-text').getFormatTypeForBareElement(settings.tagName); |
|
1823 |
|
1824 if (formatTypeForBareElement) { |
|
1825 window.console.error("Format \"".concat(formatTypeForBareElement.name, "\" is already registered to handle bare tag name \"").concat(settings.tagName, "\".")); |
|
1826 return; |
|
1827 } |
|
1828 } else { |
|
1829 var formatTypeForClassName = Object(external_this_wp_data_["select"])('core/rich-text').getFormatTypeForClassName(settings.className); |
|
1830 |
|
1831 if (formatTypeForClassName) { |
|
1832 window.console.error("Format \"".concat(formatTypeForClassName.name, "\" is already registered to handle class name \"").concat(settings.className, "\".")); |
|
1833 return; |
|
1834 } |
|
1835 } |
|
1836 |
|
1837 if (!('title' in settings) || settings.title === '') { |
|
1838 window.console.error('The format "' + settings.name + '" must have a title.'); |
|
1839 return; |
|
1840 } |
|
1841 |
|
1842 if ('keywords' in settings && settings.keywords.length > 3) { |
|
1843 window.console.error('The format "' + settings.name + '" can have a maximum of 3 keywords.'); |
|
1844 return; |
|
1845 } |
|
1846 |
|
1847 if (typeof settings.title !== 'string') { |
|
1848 window.console.error('Format titles must be strings.'); |
|
1849 return; |
|
1850 } |
|
1851 |
|
1852 Object(external_this_wp_data_["dispatch"])('core/rich-text').addFormatTypes(settings); |
|
1853 var getFunctionStackMemoized = memize_default()(function () { |
|
1854 var previousStack = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : EMPTY_ARRAY; |
|
1855 var newFunction = arguments.length > 1 ? arguments[1] : undefined; |
|
1856 return [].concat(Object(toConsumableArray["a" /* default */])(previousStack), [newFunction]); |
|
1857 }); |
|
1858 |
|
1859 if (settings.__experimentalCreatePrepareEditableTree) { |
|
1860 Object(external_this_wp_hooks_["addFilter"])('experimentalRichText', name, function (OriginalComponent) { |
|
1861 var Component = OriginalComponent; |
|
1862 |
|
1863 if (settings.__experimentalCreatePrepareEditableTree || settings.__experimentalCreateFormatToValue || settings.__experimentalCreateValueToFormat) { |
|
1864 Component = function Component(props) { |
|
1865 var additionalProps = {}; |
|
1866 |
|
1867 if (settings.__experimentalCreatePrepareEditableTree) { |
|
1868 additionalProps.prepareEditableTree = getFunctionStackMemoized(props.prepareEditableTree, settings.__experimentalCreatePrepareEditableTree(props["format_".concat(name)], { |
|
1869 richTextIdentifier: props.identifier, |
|
1870 blockClientId: props.clientId |
|
1871 })); |
|
1872 } |
|
1873 |
|
1874 if (settings.__experimentalCreateOnChangeEditableValue) { |
|
1875 var dispatchProps = Object.keys(props).reduce(function (accumulator, propKey) { |
|
1876 var propValue = props[propKey]; |
|
1877 var keyPrefix = "format_".concat(name, "_dispatch_"); |
|
1878 |
|
1879 if (propKey.startsWith(keyPrefix)) { |
|
1880 var realKey = propKey.replace(keyPrefix, ''); |
|
1881 accumulator[realKey] = propValue; |
|
1882 } |
|
1883 |
|
1884 return accumulator; |
|
1885 }, {}); |
|
1886 additionalProps.onChangeEditableValue = getFunctionStackMemoized(props.onChangeEditableValue, settings.__experimentalCreateOnChangeEditableValue(Object(objectSpread["a" /* default */])({}, props["format_".concat(name)], dispatchProps), { |
|
1887 richTextIdentifier: props.identifier, |
|
1888 blockClientId: props.clientId |
|
1889 })); |
|
1890 } |
|
1891 |
|
1892 return Object(external_this_wp_element_["createElement"])(OriginalComponent, Object(esm_extends["a" /* default */])({}, props, additionalProps)); |
|
1893 }; |
|
1894 } |
|
1895 |
|
1896 var hocs = []; |
|
1897 |
|
1898 if (settings.__experimentalGetPropsForEditableTreePreparation) { |
|
1899 hocs.push(Object(external_this_wp_data_["withSelect"])(function (sel, _ref) { |
|
1900 var clientId = _ref.clientId, |
|
1901 identifier = _ref.identifier; |
|
1902 return Object(defineProperty["a" /* default */])({}, "format_".concat(name), settings.__experimentalGetPropsForEditableTreePreparation(sel, { |
|
1903 richTextIdentifier: identifier, |
|
1904 blockClientId: clientId |
|
1905 })); |
|
1906 })); |
|
1907 } |
|
1908 |
|
1909 if (settings.__experimentalGetPropsForEditableTreeChangeHandler) { |
|
1910 hocs.push(Object(external_this_wp_data_["withDispatch"])(function (disp, _ref3) { |
|
1911 var clientId = _ref3.clientId, |
|
1912 identifier = _ref3.identifier; |
|
1913 |
|
1914 var dispatchProps = settings.__experimentalGetPropsForEditableTreeChangeHandler(disp, { |
|
1915 richTextIdentifier: identifier, |
|
1916 blockClientId: clientId |
|
1917 }); |
|
1918 |
|
1919 return Object(external_lodash_["mapKeys"])(dispatchProps, function (value, key) { |
|
1920 return "format_".concat(name, "_dispatch_").concat(key); |
|
1921 }); |
|
1922 })); |
|
1923 } |
|
1924 |
|
1925 return Object(external_this_wp_compose_["compose"])(hocs)(Component); |
|
1926 }); |
|
1927 } |
|
1928 |
|
1929 return settings; |
|
1930 } |
|
1931 |
|
1932 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/remove-format.js |
|
1933 |
|
1934 |
|
1935 /** |
|
1936 * External dependencies |
|
1937 */ |
|
1938 |
|
1939 /** |
|
1940 * Internal dependencies |
|
1941 */ |
|
1942 |
|
1943 |
|
1944 /** |
|
1945 * Remove any format object from a Rich Text value by type from the given |
|
1946 * `startIndex` to the given `endIndex`. Indices are retrieved from the |
|
1947 * selection if none are provided. |
|
1948 * |
|
1949 * @param {Object} value Value to modify. |
|
1950 * @param {string} formatType Format type to remove. |
|
1951 * @param {number} [startIndex] Start index. |
|
1952 * @param {number} [endIndex] End index. |
|
1953 * |
|
1954 * @return {Object} A new value with the format applied. |
|
1955 */ |
|
1956 |
|
1957 function removeFormat(value, formatType) { |
|
1958 var startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : value.start; |
|
1959 var endIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : value.end; |
|
1960 var formats = value.formats, |
|
1961 activeFormats = value.activeFormats; |
|
1962 var newFormats = formats.slice(); // If the selection is collapsed, expand start and end to the edges of the |
|
1963 // format. |
|
1964 |
|
1965 if (startIndex === endIndex) { |
|
1966 var format = Object(external_lodash_["find"])(newFormats[startIndex], { |
|
1967 type: formatType |
|
1968 }); |
|
1969 |
|
1970 if (format) { |
|
1971 while (Object(external_lodash_["find"])(newFormats[startIndex], format)) { |
|
1972 filterFormats(newFormats, startIndex, formatType); |
|
1973 startIndex--; |
|
1974 } |
|
1975 |
|
1976 endIndex++; |
|
1977 |
|
1978 while (Object(external_lodash_["find"])(newFormats[endIndex], format)) { |
|
1979 filterFormats(newFormats, endIndex, formatType); |
|
1980 endIndex++; |
|
1981 } |
|
1982 } |
|
1983 } else { |
|
1984 for (var i = startIndex; i < endIndex; i++) { |
|
1985 if (newFormats[i]) { |
|
1986 filterFormats(newFormats, i, formatType); |
|
1987 } |
|
1988 } |
|
1989 } |
|
1990 |
|
1991 return normaliseFormats(Object(objectSpread["a" /* default */])({}, value, { |
|
1992 formats: newFormats, |
|
1993 activeFormats: Object(external_lodash_["reject"])(activeFormats, { |
|
1994 type: formatType |
|
1995 }) |
|
1996 })); |
|
1997 } |
|
1998 |
|
1999 function filterFormats(formats, index, formatType) { |
|
2000 var newFormats = formats[index].filter(function (_ref) { |
|
2001 var type = _ref.type; |
|
2002 return type !== formatType; |
|
2003 }); |
|
2004 |
|
2005 if (newFormats.length) { |
|
2006 formats[index] = newFormats; |
|
2007 } else { |
|
2008 delete formats[index]; |
|
2009 } |
|
2010 } |
|
2011 |
|
2012 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/insert.js |
|
2013 /** |
|
2014 * Internal dependencies |
|
2015 */ |
|
2016 |
|
2017 |
|
2018 /** |
|
2019 * Insert a Rich Text value, an HTML string, or a plain text string, into a |
|
2020 * Rich Text value at the given `startIndex`. Any content between `startIndex` |
|
2021 * and `endIndex` will be removed. Indices are retrieved from the selection if |
|
2022 * none are provided. |
|
2023 * |
|
2024 * @param {Object} value Value to modify. |
|
2025 * @param {Object|string} valueToInsert Value to insert. |
|
2026 * @param {number} [startIndex] Start index. |
|
2027 * @param {number} [endIndex] End index. |
|
2028 * |
|
2029 * @return {Object} A new value with the value inserted. |
|
2030 */ |
|
2031 |
|
2032 function insert(value, valueToInsert) { |
|
2033 var startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : value.start; |
|
2034 var endIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : value.end; |
|
2035 var formats = value.formats, |
|
2036 replacements = value.replacements, |
|
2037 text = value.text; |
|
2038 |
|
2039 if (typeof valueToInsert === 'string') { |
|
2040 valueToInsert = create({ |
|
2041 text: valueToInsert |
|
2042 }); |
|
2043 } |
|
2044 |
|
2045 var index = startIndex + valueToInsert.text.length; |
|
2046 return normaliseFormats({ |
|
2047 formats: formats.slice(0, startIndex).concat(valueToInsert.formats, formats.slice(endIndex)), |
|
2048 replacements: replacements.slice(0, startIndex).concat(valueToInsert.replacements, replacements.slice(endIndex)), |
|
2049 text: text.slice(0, startIndex) + valueToInsert.text + text.slice(endIndex), |
|
2050 start: index, |
|
2051 end: index |
|
2052 }); |
|
2053 } |
|
2054 |
|
2055 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/remove.js |
|
2056 /** |
|
2057 * Internal dependencies |
|
2058 */ |
|
2059 |
|
2060 |
|
2061 /** |
|
2062 * Remove content from a Rich Text value between the given `startIndex` and |
|
2063 * `endIndex`. Indices are retrieved from the selection if none are provided. |
|
2064 * |
|
2065 * @param {Object} value Value to modify. |
|
2066 * @param {number} [startIndex] Start index. |
|
2067 * @param {number} [endIndex] End index. |
|
2068 * |
|
2069 * @return {Object} A new value with the content removed. |
|
2070 */ |
|
2071 |
|
2072 function remove_remove(value, startIndex, endIndex) { |
|
2073 return insert(value, create(), startIndex, endIndex); |
|
2074 } |
|
2075 |
|
2076 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/replace.js |
|
2077 |
|
2078 |
|
2079 /** |
|
2080 * Internal dependencies |
|
2081 */ |
|
2082 |
|
2083 /** |
|
2084 * Search a Rich Text value and replace the match(es) with `replacement`. This |
|
2085 * is similar to `String.prototype.replace`. |
|
2086 * |
|
2087 * @param {Object} value The value to modify. |
|
2088 * @param {RegExp|string} pattern A RegExp object or literal. Can also be |
|
2089 * a string. It is treated as a verbatim |
|
2090 * string and is not interpreted as a |
|
2091 * regular expression. Only the first |
|
2092 * occurrence will be replaced. |
|
2093 * @param {Function|string} replacement The match or matches are replaced with |
|
2094 * the specified or the value returned by |
|
2095 * the specified function. |
|
2096 * |
|
2097 * @return {Object} A new value with replacements applied. |
|
2098 */ |
|
2099 |
|
2100 function replace(_ref, pattern, replacement) { |
|
2101 var formats = _ref.formats, |
|
2102 replacements = _ref.replacements, |
|
2103 text = _ref.text, |
|
2104 start = _ref.start, |
|
2105 end = _ref.end; |
|
2106 text = text.replace(pattern, function (match) { |
|
2107 for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
|
2108 rest[_key - 1] = arguments[_key]; |
|
2109 } |
|
2110 |
|
2111 var offset = rest[rest.length - 2]; |
|
2112 var newText = replacement; |
|
2113 var newFormats; |
|
2114 var newReplacements; |
|
2115 |
|
2116 if (typeof newText === 'function') { |
|
2117 newText = replacement.apply(void 0, [match].concat(rest)); |
|
2118 } |
|
2119 |
|
2120 if (Object(esm_typeof["a" /* default */])(newText) === 'object') { |
|
2121 newFormats = newText.formats; |
|
2122 newReplacements = newText.replacements; |
|
2123 newText = newText.text; |
|
2124 } else { |
|
2125 newFormats = Array(newText.length); |
|
2126 newReplacements = Array(newText.length); |
|
2127 |
|
2128 if (formats[offset]) { |
|
2129 newFormats = newFormats.fill(formats[offset]); |
|
2130 } |
|
2131 } |
|
2132 |
|
2133 formats = formats.slice(0, offset).concat(newFormats, formats.slice(offset + match.length)); |
|
2134 replacements = replacements.slice(0, offset).concat(newReplacements, replacements.slice(offset + match.length)); |
|
2135 |
|
2136 if (start) { |
|
2137 start = end = offset + newText.length; |
|
2138 } |
|
2139 |
|
2140 return newText; |
|
2141 }); |
|
2142 return normaliseFormats({ |
|
2143 formats: formats, |
|
2144 replacements: replacements, |
|
2145 text: text, |
|
2146 start: start, |
|
2147 end: end |
|
2148 }); |
|
2149 } |
|
2150 |
|
2151 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/insert-line-break.js |
|
2152 /** |
|
2153 * Internal dependencies |
|
2154 */ |
|
2155 |
|
2156 /** |
|
2157 * Inserts a line break at the given or selected position. |
|
2158 * |
|
2159 * @param {Object} value Value to modify. |
|
2160 * |
|
2161 * @return {Object} The value with the line break inserted. |
|
2162 */ |
|
2163 |
|
2164 function insertLineBreak(value) { |
|
2165 return insert(value, '\n'); |
|
2166 } |
|
2167 |
|
2168 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/insert-line-separator.js |
|
2169 /** |
|
2170 * Internal dependencies |
|
2171 */ |
|
2172 |
|
2173 |
|
2174 |
|
2175 /** |
|
2176 * Insert a line break character into a Rich Text value at the given |
|
2177 * `startIndex`. Any content between `startIndex` and `endIndex` will be |
|
2178 * removed. Indices are retrieved from the selection if none are provided. |
|
2179 * |
|
2180 * @param {Object} value Value to modify. |
|
2181 * @param {number} [startIndex] Start index. |
|
2182 * @param {number} [endIndex] End index. |
|
2183 * |
|
2184 * @return {Object} A new value with the value inserted. |
|
2185 */ |
|
2186 |
|
2187 function insertLineSeparator(value) { |
|
2188 var startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : value.start; |
|
2189 var endIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : value.end; |
|
2190 var beforeText = getTextContent(value).slice(0, startIndex); |
|
2191 var previousLineSeparatorIndex = beforeText.lastIndexOf(LINE_SEPARATOR); |
|
2192 var previousLineSeparatorFormats = value.replacements[previousLineSeparatorIndex]; |
|
2193 var replacements = [,]; |
|
2194 |
|
2195 if (previousLineSeparatorFormats) { |
|
2196 replacements = [previousLineSeparatorFormats]; |
|
2197 } |
|
2198 |
|
2199 var valueToInsert = { |
|
2200 formats: [,], |
|
2201 replacements: replacements, |
|
2202 text: LINE_SEPARATOR |
|
2203 }; |
|
2204 return insert(value, valueToInsert, startIndex, endIndex); |
|
2205 } |
|
2206 |
|
2207 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/insert-object.js |
|
2208 /** |
|
2209 * Internal dependencies |
|
2210 */ |
|
2211 |
|
2212 var insert_object_OBJECT_REPLACEMENT_CHARACTER = "\uFFFC"; |
|
2213 /** |
|
2214 * Insert a format as an object into a Rich Text value at the given |
|
2215 * `startIndex`. Any content between `startIndex` and `endIndex` will be |
|
2216 * removed. Indices are retrieved from the selection if none are provided. |
|
2217 * |
|
2218 * @param {Object} value Value to modify. |
|
2219 * @param {Object} formatToInsert Format to insert as object. |
|
2220 * @param {number} [startIndex] Start index. |
|
2221 * @param {number} [endIndex] End index. |
|
2222 * |
|
2223 * @return {Object} A new value with the object inserted. |
|
2224 */ |
|
2225 |
|
2226 function insertObject(value, formatToInsert, startIndex, endIndex) { |
|
2227 var valueToInsert = { |
|
2228 formats: [,], |
|
2229 replacements: [formatToInsert], |
|
2230 text: insert_object_OBJECT_REPLACEMENT_CHARACTER |
|
2231 }; |
|
2232 return insert(value, valueToInsert, startIndex, endIndex); |
|
2233 } |
|
2234 |
|
2235 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/slice.js |
|
2236 |
|
2237 |
|
2238 /** |
|
2239 * Slice a Rich Text value from `startIndex` to `endIndex`. Indices are |
|
2240 * retrieved from the selection if none are provided. This is similar to |
|
2241 * `String.prototype.slice`. |
|
2242 * |
|
2243 * @param {Object} value Value to modify. |
|
2244 * @param {number} [startIndex] Start index. |
|
2245 * @param {number} [endIndex] End index. |
|
2246 * |
|
2247 * @return {Object} A new extracted value. |
|
2248 */ |
|
2249 function slice(value) { |
|
2250 var startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : value.start; |
|
2251 var endIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : value.end; |
|
2252 var formats = value.formats, |
|
2253 replacements = value.replacements, |
|
2254 text = value.text; |
|
2255 |
|
2256 if (startIndex === undefined || endIndex === undefined) { |
|
2257 return Object(objectSpread["a" /* default */])({}, value); |
|
2258 } |
|
2259 |
|
2260 return { |
|
2261 formats: formats.slice(startIndex, endIndex), |
|
2262 replacements: replacements.slice(startIndex, endIndex), |
|
2263 text: text.slice(startIndex, endIndex) |
|
2264 }; |
|
2265 } |
|
2266 |
|
2267 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/split.js |
|
2268 /** |
|
2269 * Internal dependencies |
|
2270 */ |
|
2271 |
|
2272 /** |
|
2273 * Split a Rich Text value in two at the given `startIndex` and `endIndex`, or |
|
2274 * split at the given separator. This is similar to `String.prototype.split`. |
|
2275 * Indices are retrieved from the selection if none are provided. |
|
2276 * |
|
2277 * @param {Object} value Value to modify. |
|
2278 * @param {number|string} [string] Start index, or string at which to split. |
|
2279 * @param {number} [endStr] End index. |
|
2280 * |
|
2281 * @return {Array} An array of new values. |
|
2282 */ |
|
2283 |
|
2284 function split(_ref, string) { |
|
2285 var formats = _ref.formats, |
|
2286 replacements = _ref.replacements, |
|
2287 text = _ref.text, |
|
2288 start = _ref.start, |
|
2289 end = _ref.end; |
|
2290 |
|
2291 if (typeof string !== 'string') { |
|
2292 return splitAtSelection.apply(void 0, arguments); |
|
2293 } |
|
2294 |
|
2295 var nextStart = 0; |
|
2296 return text.split(string).map(function (substring) { |
|
2297 var startIndex = nextStart; |
|
2298 var value = { |
|
2299 formats: formats.slice(startIndex, startIndex + substring.length), |
|
2300 replacements: replacements.slice(startIndex, startIndex + substring.length), |
|
2301 text: substring |
|
2302 }; |
|
2303 nextStart += string.length + substring.length; |
|
2304 |
|
2305 if (start !== undefined && end !== undefined) { |
|
2306 if (start >= startIndex && start < nextStart) { |
|
2307 value.start = start - startIndex; |
|
2308 } else if (start < startIndex && end > startIndex) { |
|
2309 value.start = 0; |
|
2310 } |
|
2311 |
|
2312 if (end >= startIndex && end < nextStart) { |
|
2313 value.end = end - startIndex; |
|
2314 } else if (start < nextStart && end > nextStart) { |
|
2315 value.end = substring.length; |
|
2316 } |
|
2317 } |
|
2318 |
|
2319 return value; |
|
2320 }); |
|
2321 } |
|
2322 |
|
2323 function splitAtSelection(_ref2) { |
|
2324 var formats = _ref2.formats, |
|
2325 replacements = _ref2.replacements, |
|
2326 text = _ref2.text, |
|
2327 start = _ref2.start, |
|
2328 end = _ref2.end; |
|
2329 var startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : start; |
|
2330 var endIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : end; |
|
2331 var before = { |
|
2332 formats: formats.slice(0, startIndex), |
|
2333 replacements: replacements.slice(0, startIndex), |
|
2334 text: text.slice(0, startIndex) |
|
2335 }; |
|
2336 var after = { |
|
2337 formats: formats.slice(endIndex), |
|
2338 replacements: replacements.slice(endIndex), |
|
2339 text: text.slice(endIndex), |
|
2340 start: 0, |
|
2341 end: 0 |
|
2342 }; |
|
2343 return [// Ensure newlines are trimmed. |
|
2344 replace(before, /\u2028+$/, ''), replace(after, /^\u2028+/, '')]; |
|
2345 } |
|
2346 |
|
2347 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-format-type.js |
|
2348 /** |
|
2349 * WordPress dependencies |
|
2350 */ |
|
2351 |
|
2352 /** |
|
2353 * Returns a registered format type. |
|
2354 * |
|
2355 * @param {string} name Format name. |
|
2356 * |
|
2357 * @return {?Object} Format type. |
|
2358 */ |
|
2359 |
|
2360 function get_format_type_getFormatType(name) { |
|
2361 return Object(external_this_wp_data_["select"])('core/rich-text').getFormatType(name); |
|
2362 } |
|
2363 |
|
2364 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/to-tree.js |
|
2365 |
|
2366 |
|
2367 |
|
2368 /** |
|
2369 * Internal dependencies |
|
2370 */ |
|
2371 |
|
2372 |
|
2373 |
|
2374 /** |
|
2375 * Converts a format object to information that can be used to create an element |
|
2376 * from (type, attributes and object). |
|
2377 * |
|
2378 * @param {Object} $1 Named parameters. |
|
2379 * @param {string} $1.type The format type. |
|
2380 * @param {Object} $1.attributes The format attributes. |
|
2381 * @param {Object} $1.unregisteredAttributes The unregistered format |
|
2382 * attributes. |
|
2383 * @param {boolean} $1.object Wether or not it is an object |
|
2384 * format. |
|
2385 * @param {boolean} $1.boundaryClass Wether or not to apply a boundary |
|
2386 * class. |
|
2387 * @return {Object} Information to be used for |
|
2388 * element creation. |
|
2389 */ |
|
2390 |
|
2391 function fromFormat(_ref) { |
|
2392 var type = _ref.type, |
|
2393 attributes = _ref.attributes, |
|
2394 unregisteredAttributes = _ref.unregisteredAttributes, |
|
2395 object = _ref.object, |
|
2396 boundaryClass = _ref.boundaryClass; |
|
2397 var formatType = get_format_type_getFormatType(type); |
|
2398 var elementAttributes = {}; |
|
2399 |
|
2400 if (boundaryClass) { |
|
2401 elementAttributes['data-rich-text-format-boundary'] = 'true'; |
|
2402 } |
|
2403 |
|
2404 if (!formatType) { |
|
2405 if (attributes) { |
|
2406 elementAttributes = Object(objectSpread["a" /* default */])({}, attributes, elementAttributes); |
|
2407 } |
|
2408 |
|
2409 return { |
|
2410 type: type, |
|
2411 attributes: elementAttributes, |
|
2412 object: object |
|
2413 }; |
|
2414 } |
|
2415 |
|
2416 elementAttributes = Object(objectSpread["a" /* default */])({}, unregisteredAttributes, elementAttributes); |
|
2417 |
|
2418 for (var name in attributes) { |
|
2419 var key = formatType.attributes ? formatType.attributes[name] : false; |
|
2420 |
|
2421 if (key) { |
|
2422 elementAttributes[key] = attributes[name]; |
|
2423 } else { |
|
2424 elementAttributes[name] = attributes[name]; |
|
2425 } |
|
2426 } |
|
2427 |
|
2428 if (formatType.className) { |
|
2429 if (elementAttributes.class) { |
|
2430 elementAttributes.class = "".concat(formatType.className, " ").concat(elementAttributes.class); |
|
2431 } else { |
|
2432 elementAttributes.class = formatType.className; |
|
2433 } |
|
2434 } |
|
2435 |
|
2436 return { |
|
2437 type: formatType.tagName, |
|
2438 object: formatType.object, |
|
2439 attributes: elementAttributes |
|
2440 }; |
|
2441 } |
|
2442 |
|
2443 var padding = { |
|
2444 type: 'br', |
|
2445 attributes: { |
|
2446 'data-rich-text-padding': 'true' |
|
2447 }, |
|
2448 object: true |
|
2449 }; |
|
2450 function toTree(_ref2) { |
|
2451 var value = _ref2.value, |
|
2452 multilineTag = _ref2.multilineTag, |
|
2453 createEmpty = _ref2.createEmpty, |
|
2454 append = _ref2.append, |
|
2455 getLastChild = _ref2.getLastChild, |
|
2456 getParent = _ref2.getParent, |
|
2457 isText = _ref2.isText, |
|
2458 getText = _ref2.getText, |
|
2459 remove = _ref2.remove, |
|
2460 appendText = _ref2.appendText, |
|
2461 onStartIndex = _ref2.onStartIndex, |
|
2462 onEndIndex = _ref2.onEndIndex, |
|
2463 isEditableTree = _ref2.isEditableTree; |
|
2464 var formats = value.formats, |
|
2465 replacements = value.replacements, |
|
2466 text = value.text, |
|
2467 start = value.start, |
|
2468 end = value.end; |
|
2469 var formatsLength = formats.length + 1; |
|
2470 var tree = createEmpty(); |
|
2471 var multilineFormat = { |
|
2472 type: multilineTag |
|
2473 }; |
|
2474 var activeFormats = getActiveFormats(value); |
|
2475 var deepestActiveFormat = activeFormats[activeFormats.length - 1]; |
|
2476 var lastSeparatorFormats; |
|
2477 var lastCharacterFormats; |
|
2478 var lastCharacter; // If we're building a multiline tree, start off with a multiline element. |
|
2479 |
|
2480 if (multilineTag) { |
|
2481 append(append(tree, { |
|
2482 type: multilineTag |
|
2483 }), ''); |
|
2484 lastCharacterFormats = lastSeparatorFormats = [multilineFormat]; |
|
2485 } else { |
|
2486 append(tree, ''); |
|
2487 } |
|
2488 |
|
2489 var _loop = function _loop(i) { |
|
2490 var character = text.charAt(i); |
|
2491 var shouldInsertPadding = isEditableTree && ( // Pad the line if the line is empty. |
|
2492 !lastCharacter || lastCharacter === LINE_SEPARATOR || // Pad the line if the previous character is a line break, otherwise |
|
2493 // the line break won't be visible. |
|
2494 lastCharacter === '\n'); |
|
2495 var characterFormats = formats[i]; // Set multiline tags in queue for building the tree. |
|
2496 |
|
2497 if (multilineTag) { |
|
2498 if (character === LINE_SEPARATOR) { |
|
2499 characterFormats = lastSeparatorFormats = (replacements[i] || []).reduce(function (accumulator, format) { |
|
2500 accumulator.push(format, multilineFormat); |
|
2501 return accumulator; |
|
2502 }, [multilineFormat]); |
|
2503 } else { |
|
2504 characterFormats = [].concat(Object(toConsumableArray["a" /* default */])(lastSeparatorFormats), Object(toConsumableArray["a" /* default */])(characterFormats || [])); |
|
2505 } |
|
2506 } |
|
2507 |
|
2508 var pointer = getLastChild(tree); |
|
2509 |
|
2510 if (shouldInsertPadding && character === LINE_SEPARATOR) { |
|
2511 var node = pointer; |
|
2512 |
|
2513 while (!isText(node)) { |
|
2514 node = getLastChild(node); |
|
2515 } |
|
2516 |
|
2517 append(getParent(node), padding); |
|
2518 append(getParent(node), ''); |
|
2519 } // Set selection for the start of line. |
|
2520 |
|
2521 |
|
2522 if (lastCharacter === LINE_SEPARATOR) { |
|
2523 var _node = pointer; |
|
2524 |
|
2525 while (!isText(_node)) { |
|
2526 _node = getLastChild(_node); |
|
2527 } |
|
2528 |
|
2529 if (onStartIndex && start === i) { |
|
2530 onStartIndex(tree, _node); |
|
2531 } |
|
2532 |
|
2533 if (onEndIndex && end === i) { |
|
2534 onEndIndex(tree, _node); |
|
2535 } |
|
2536 } |
|
2537 |
|
2538 if (characterFormats) { |
|
2539 characterFormats.forEach(function (format, formatIndex) { |
|
2540 if (pointer && lastCharacterFormats && format === lastCharacterFormats[formatIndex] && ( // Do not reuse the last element if the character is a |
|
2541 // line separator. |
|
2542 character !== LINE_SEPARATOR || characterFormats.length - 1 !== formatIndex)) { |
|
2543 pointer = getLastChild(pointer); |
|
2544 return; |
|
2545 } |
|
2546 |
|
2547 var type = format.type, |
|
2548 attributes = format.attributes, |
|
2549 unregisteredAttributes = format.unregisteredAttributes; |
|
2550 var boundaryClass = isEditableTree && character !== LINE_SEPARATOR && format === deepestActiveFormat; |
|
2551 var parent = getParent(pointer); |
|
2552 var newNode = append(parent, fromFormat({ |
|
2553 type: type, |
|
2554 attributes: attributes, |
|
2555 unregisteredAttributes: unregisteredAttributes, |
|
2556 boundaryClass: boundaryClass |
|
2557 })); |
|
2558 |
|
2559 if (isText(pointer) && getText(pointer).length === 0) { |
|
2560 remove(pointer); |
|
2561 } |
|
2562 |
|
2563 pointer = append(newNode, ''); |
|
2564 }); |
|
2565 } // No need for further processing if the character is a line separator. |
|
2566 |
|
2567 |
|
2568 if (character === LINE_SEPARATOR) { |
|
2569 lastCharacterFormats = characterFormats; |
|
2570 lastCharacter = character; |
|
2571 return "continue"; |
|
2572 } // If there is selection at 0, handle it before characters are inserted. |
|
2573 |
|
2574 |
|
2575 if (i === 0) { |
|
2576 if (onStartIndex && start === 0) { |
|
2577 onStartIndex(tree, pointer); |
|
2578 } |
|
2579 |
|
2580 if (onEndIndex && end === 0) { |
|
2581 onEndIndex(tree, pointer); |
|
2582 } |
|
2583 } |
|
2584 |
|
2585 if (character === OBJECT_REPLACEMENT_CHARACTER) { |
|
2586 pointer = append(getParent(pointer), fromFormat(Object(objectSpread["a" /* default */])({}, replacements[i], { |
|
2587 object: true |
|
2588 }))); // Ensure pointer is text node. |
|
2589 |
|
2590 pointer = append(getParent(pointer), ''); |
|
2591 } else if (character === '\n') { |
|
2592 pointer = append(getParent(pointer), { |
|
2593 type: 'br', |
|
2594 attributes: isEditableTree ? { |
|
2595 'data-rich-text-line-break': 'true' |
|
2596 } : undefined, |
|
2597 object: true |
|
2598 }); // Ensure pointer is text node. |
|
2599 |
|
2600 pointer = append(getParent(pointer), ''); |
|
2601 } else if (!isText(pointer)) { |
|
2602 pointer = append(getParent(pointer), character); |
|
2603 } else { |
|
2604 appendText(pointer, character); |
|
2605 } |
|
2606 |
|
2607 if (onStartIndex && start === i + 1) { |
|
2608 onStartIndex(tree, pointer); |
|
2609 } |
|
2610 |
|
2611 if (onEndIndex && end === i + 1) { |
|
2612 onEndIndex(tree, pointer); |
|
2613 } |
|
2614 |
|
2615 if (shouldInsertPadding && i === text.length) { |
|
2616 append(getParent(pointer), padding); |
|
2617 } |
|
2618 |
|
2619 lastCharacterFormats = characterFormats; |
|
2620 lastCharacter = character; |
|
2621 }; |
|
2622 |
|
2623 for (var i = 0; i < formatsLength; i++) { |
|
2624 var _ret = _loop(i); |
|
2625 |
|
2626 if (_ret === "continue") continue; |
|
2627 } |
|
2628 |
|
2629 return tree; |
|
2630 } |
|
2631 |
|
2632 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/to-dom.js |
|
2633 |
|
2634 |
|
2635 |
|
2636 /** |
|
2637 * Internal dependencies |
|
2638 */ |
|
2639 |
|
2640 |
|
2641 /** |
|
2642 * Browser dependencies |
|
2643 */ |
|
2644 |
|
2645 var to_dom_TEXT_NODE = window.Node.TEXT_NODE; |
|
2646 /** |
|
2647 * Creates a path as an array of indices from the given root node to the given |
|
2648 * node. |
|
2649 * |
|
2650 * @param {Node} node Node to find the path of. |
|
2651 * @param {HTMLElement} rootNode Root node to find the path from. |
|
2652 * @param {Array} path Initial path to build on. |
|
2653 * |
|
2654 * @return {Array} The path from the root node to the node. |
|
2655 */ |
|
2656 |
|
2657 function createPathToNode(node, rootNode, path) { |
|
2658 var parentNode = node.parentNode; |
|
2659 var i = 0; |
|
2660 |
|
2661 while (node = node.previousSibling) { |
|
2662 i++; |
|
2663 } |
|
2664 |
|
2665 path = [i].concat(Object(toConsumableArray["a" /* default */])(path)); |
|
2666 |
|
2667 if (parentNode !== rootNode) { |
|
2668 path = createPathToNode(parentNode, rootNode, path); |
|
2669 } |
|
2670 |
|
2671 return path; |
|
2672 } |
|
2673 /** |
|
2674 * Gets a node given a path (array of indices) from the given node. |
|
2675 * |
|
2676 * @param {HTMLElement} node Root node to find the wanted node in. |
|
2677 * @param {Array} path Path (indices) to the wanted node. |
|
2678 * |
|
2679 * @return {Object} Object with the found node and the remaining offset (if any). |
|
2680 */ |
|
2681 |
|
2682 |
|
2683 function getNodeByPath(node, path) { |
|
2684 path = Object(toConsumableArray["a" /* default */])(path); |
|
2685 |
|
2686 while (node && path.length > 1) { |
|
2687 node = node.childNodes[path.shift()]; |
|
2688 } |
|
2689 |
|
2690 return { |
|
2691 node: node, |
|
2692 offset: path[0] |
|
2693 }; |
|
2694 } |
|
2695 /** |
|
2696 * Returns a new instance of a DOM tree upon which RichText operations can be |
|
2697 * applied. |
|
2698 * |
|
2699 * Note: The current implementation will return a shared reference, reset on |
|
2700 * each call to `createEmpty`. Therefore, you should not hold a reference to |
|
2701 * the value to operate upon asynchronously, as it may have unexpected results. |
|
2702 * |
|
2703 * @return {WPRichTextTree} RichText tree. |
|
2704 */ |
|
2705 |
|
2706 |
|
2707 var to_dom_createEmpty = function createEmpty() { |
|
2708 return createElement(document, ''); |
|
2709 }; |
|
2710 |
|
2711 function to_dom_append(element, child) { |
|
2712 if (typeof child === 'string') { |
|
2713 child = element.ownerDocument.createTextNode(child); |
|
2714 } |
|
2715 |
|
2716 var _child = child, |
|
2717 type = _child.type, |
|
2718 attributes = _child.attributes; |
|
2719 |
|
2720 if (type) { |
|
2721 child = element.ownerDocument.createElement(type); |
|
2722 |
|
2723 for (var key in attributes) { |
|
2724 child.setAttribute(key, attributes[key]); |
|
2725 } |
|
2726 } |
|
2727 |
|
2728 return element.appendChild(child); |
|
2729 } |
|
2730 |
|
2731 function to_dom_appendText(node, text) { |
|
2732 node.appendData(text); |
|
2733 } |
|
2734 |
|
2735 function to_dom_getLastChild(_ref) { |
|
2736 var lastChild = _ref.lastChild; |
|
2737 return lastChild; |
|
2738 } |
|
2739 |
|
2740 function to_dom_getParent(_ref2) { |
|
2741 var parentNode = _ref2.parentNode; |
|
2742 return parentNode; |
|
2743 } |
|
2744 |
|
2745 function to_dom_isText(_ref3) { |
|
2746 var nodeType = _ref3.nodeType; |
|
2747 return nodeType === to_dom_TEXT_NODE; |
|
2748 } |
|
2749 |
|
2750 function to_dom_getText(_ref4) { |
|
2751 var nodeValue = _ref4.nodeValue; |
|
2752 return nodeValue; |
|
2753 } |
|
2754 |
|
2755 function to_dom_remove(node) { |
|
2756 return node.parentNode.removeChild(node); |
|
2757 } |
|
2758 |
|
2759 function prepareFormats() { |
|
2760 var prepareEditableTree = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
|
2761 var value = arguments.length > 1 ? arguments[1] : undefined; |
|
2762 return prepareEditableTree.reduce(function (accumlator, fn) { |
|
2763 return fn(accumlator, value.text); |
|
2764 }, value.formats); |
|
2765 } |
|
2766 |
|
2767 function toDom(_ref5) { |
|
2768 var value = _ref5.value, |
|
2769 multilineTag = _ref5.multilineTag, |
|
2770 prepareEditableTree = _ref5.prepareEditableTree, |
|
2771 _ref5$isEditableTree = _ref5.isEditableTree, |
|
2772 isEditableTree = _ref5$isEditableTree === void 0 ? true : _ref5$isEditableTree; |
|
2773 var startPath = []; |
|
2774 var endPath = []; |
|
2775 var tree = toTree({ |
|
2776 value: Object(objectSpread["a" /* default */])({}, value, { |
|
2777 formats: prepareFormats(prepareEditableTree, value) |
|
2778 }), |
|
2779 multilineTag: multilineTag, |
|
2780 createEmpty: to_dom_createEmpty, |
|
2781 append: to_dom_append, |
|
2782 getLastChild: to_dom_getLastChild, |
|
2783 getParent: to_dom_getParent, |
|
2784 isText: to_dom_isText, |
|
2785 getText: to_dom_getText, |
|
2786 remove: to_dom_remove, |
|
2787 appendText: to_dom_appendText, |
|
2788 onStartIndex: function onStartIndex(body, pointer) { |
|
2789 startPath = createPathToNode(pointer, body, [pointer.nodeValue.length]); |
|
2790 }, |
|
2791 onEndIndex: function onEndIndex(body, pointer) { |
|
2792 endPath = createPathToNode(pointer, body, [pointer.nodeValue.length]); |
|
2793 }, |
|
2794 isEditableTree: isEditableTree |
|
2795 }); |
|
2796 return { |
|
2797 body: tree, |
|
2798 selection: { |
|
2799 startPath: startPath, |
|
2800 endPath: endPath |
|
2801 } |
|
2802 }; |
|
2803 } |
|
2804 /** |
|
2805 * Create an `Element` tree from a Rich Text value and applies the difference to |
|
2806 * the `Element` tree contained by `current`. If a `multilineTag` is provided, |
|
2807 * text separated by two new lines will be wrapped in an `Element` of that type. |
|
2808 * |
|
2809 * @param {Object} $1 Named arguments. |
|
2810 * @param {Object} $1.value Value to apply. |
|
2811 * @param {HTMLElement} $1.current The live root node to apply the element tree to. |
|
2812 * @param {string} [$1.multilineTag] Multiline tag. |
|
2813 * @param {Array} [$1.multilineWrapperTags] Tags where lines can be found if nesting is possible. |
|
2814 */ |
|
2815 |
|
2816 function apply(_ref6) { |
|
2817 var value = _ref6.value, |
|
2818 current = _ref6.current, |
|
2819 multilineTag = _ref6.multilineTag, |
|
2820 prepareEditableTree = _ref6.prepareEditableTree, |
|
2821 __unstableDomOnly = _ref6.__unstableDomOnly; |
|
2822 |
|
2823 // Construct a new element tree in memory. |
|
2824 var _toDom = toDom({ |
|
2825 value: value, |
|
2826 multilineTag: multilineTag, |
|
2827 prepareEditableTree: prepareEditableTree |
|
2828 }), |
|
2829 body = _toDom.body, |
|
2830 selection = _toDom.selection; |
|
2831 |
|
2832 applyValue(body, current); |
|
2833 |
|
2834 if (value.start !== undefined && !__unstableDomOnly) { |
|
2835 applySelection(selection, current); |
|
2836 } |
|
2837 } |
|
2838 function applyValue(future, current) { |
|
2839 var i = 0; |
|
2840 var futureChild; |
|
2841 |
|
2842 while (futureChild = future.firstChild) { |
|
2843 var currentChild = current.childNodes[i]; |
|
2844 |
|
2845 if (!currentChild) { |
|
2846 current.appendChild(futureChild); |
|
2847 } else if (!currentChild.isEqualNode(futureChild)) { |
|
2848 if (currentChild.nodeName !== futureChild.nodeName || currentChild.nodeType === to_dom_TEXT_NODE && currentChild.data !== futureChild.data) { |
|
2849 current.replaceChild(futureChild, currentChild); |
|
2850 } else { |
|
2851 var currentAttributes = currentChild.attributes; |
|
2852 var futureAttributes = futureChild.attributes; |
|
2853 |
|
2854 if (currentAttributes) { |
|
2855 for (var ii = 0; ii < currentAttributes.length; ii++) { |
|
2856 var name = currentAttributes[ii].name; |
|
2857 |
|
2858 if (!futureChild.getAttribute(name)) { |
|
2859 currentChild.removeAttribute(name); |
|
2860 } |
|
2861 } |
|
2862 } |
|
2863 |
|
2864 if (futureAttributes) { |
|
2865 for (var _ii = 0; _ii < futureAttributes.length; _ii++) { |
|
2866 var _futureAttributes$_ii = futureAttributes[_ii], |
|
2867 name = _futureAttributes$_ii.name, |
|
2868 value = _futureAttributes$_ii.value; |
|
2869 |
|
2870 if (currentChild.getAttribute(name) !== value) { |
|
2871 currentChild.setAttribute(name, value); |
|
2872 } |
|
2873 } |
|
2874 } |
|
2875 |
|
2876 applyValue(futureChild, currentChild); |
|
2877 future.removeChild(futureChild); |
|
2878 } |
|
2879 } else { |
|
2880 future.removeChild(futureChild); |
|
2881 } |
|
2882 |
|
2883 i++; |
|
2884 } |
|
2885 |
|
2886 while (current.childNodes[i]) { |
|
2887 current.removeChild(current.childNodes[i]); |
|
2888 } |
|
2889 } |
|
2890 /** |
|
2891 * Returns true if two ranges are equal, or false otherwise. Ranges are |
|
2892 * considered equal if their start and end occur in the same container and |
|
2893 * offset. |
|
2894 * |
|
2895 * @param {Range} a First range object to test. |
|
2896 * @param {Range} b First range object to test. |
|
2897 * |
|
2898 * @return {boolean} Whether the two ranges are equal. |
|
2899 */ |
|
2900 |
|
2901 function isRangeEqual(a, b) { |
|
2902 return a.startContainer === b.startContainer && a.startOffset === b.startOffset && a.endContainer === b.endContainer && a.endOffset === b.endOffset; |
|
2903 } |
|
2904 |
|
2905 function applySelection(_ref7, current) { |
|
2906 var startPath = _ref7.startPath, |
|
2907 endPath = _ref7.endPath; |
|
2908 |
|
2909 var _getNodeByPath = getNodeByPath(current, startPath), |
|
2910 startContainer = _getNodeByPath.node, |
|
2911 startOffset = _getNodeByPath.offset; |
|
2912 |
|
2913 var _getNodeByPath2 = getNodeByPath(current, endPath), |
|
2914 endContainer = _getNodeByPath2.node, |
|
2915 endOffset = _getNodeByPath2.offset; |
|
2916 |
|
2917 var selection = window.getSelection(); |
|
2918 var ownerDocument = current.ownerDocument; |
|
2919 var range = ownerDocument.createRange(); |
|
2920 range.setStart(startContainer, startOffset); |
|
2921 range.setEnd(endContainer, endOffset); |
|
2922 |
|
2923 if (selection.rangeCount > 0) { |
|
2924 // If the to be added range and the live range are the same, there's no |
|
2925 // need to remove the live range and add the equivalent range. |
|
2926 if (isRangeEqual(range, selection.getRangeAt(0))) { |
|
2927 // Set back focus if focus is lost. |
|
2928 if (ownerDocument.activeElement !== current) { |
|
2929 current.focus(); |
|
2930 } |
|
2931 |
|
2932 return; |
|
2933 } |
|
2934 |
|
2935 selection.removeAllRanges(); |
|
2936 } |
|
2937 |
|
2938 selection.addRange(range); |
|
2939 } |
|
2940 |
|
2941 // EXTERNAL MODULE: external {"this":["wp","escapeHtml"]} |
|
2942 var external_this_wp_escapeHtml_ = __webpack_require__(69); |
|
2943 |
|
2944 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/to-html-string.js |
|
2945 /** |
|
2946 * WordPress dependencies |
|
2947 */ |
|
2948 |
|
2949 /** |
|
2950 * Internal dependencies |
|
2951 */ |
|
2952 |
|
2953 |
|
2954 /** |
|
2955 * Create an HTML string from a Rich Text value. If a `multilineTag` is |
|
2956 * provided, text separated by a line separator will be wrapped in it. |
|
2957 * |
|
2958 * @param {Object} $1 Named argements. |
|
2959 * @param {Object} $1.value Rich text value. |
|
2960 * @param {string} [$1.multilineTag] Multiline tag. |
|
2961 * |
|
2962 * @return {string} HTML string. |
|
2963 */ |
|
2964 |
|
2965 function toHTMLString(_ref) { |
|
2966 var value = _ref.value, |
|
2967 multilineTag = _ref.multilineTag; |
|
2968 var tree = toTree({ |
|
2969 value: value, |
|
2970 multilineTag: multilineTag, |
|
2971 createEmpty: to_html_string_createEmpty, |
|
2972 append: to_html_string_append, |
|
2973 getLastChild: to_html_string_getLastChild, |
|
2974 getParent: to_html_string_getParent, |
|
2975 isText: to_html_string_isText, |
|
2976 getText: to_html_string_getText, |
|
2977 remove: to_html_string_remove, |
|
2978 appendText: to_html_string_appendText |
|
2979 }); |
|
2980 return createChildrenHTML(tree.children); |
|
2981 } |
|
2982 |
|
2983 function to_html_string_createEmpty() { |
|
2984 return {}; |
|
2985 } |
|
2986 |
|
2987 function to_html_string_getLastChild(_ref2) { |
|
2988 var children = _ref2.children; |
|
2989 return children && children[children.length - 1]; |
|
2990 } |
|
2991 |
|
2992 function to_html_string_append(parent, object) { |
|
2993 if (typeof object === 'string') { |
|
2994 object = { |
|
2995 text: object |
|
2996 }; |
|
2997 } |
|
2998 |
|
2999 object.parent = parent; |
|
3000 parent.children = parent.children || []; |
|
3001 parent.children.push(object); |
|
3002 return object; |
|
3003 } |
|
3004 |
|
3005 function to_html_string_appendText(object, text) { |
|
3006 object.text += text; |
|
3007 } |
|
3008 |
|
3009 function to_html_string_getParent(_ref3) { |
|
3010 var parent = _ref3.parent; |
|
3011 return parent; |
|
3012 } |
|
3013 |
|
3014 function to_html_string_isText(_ref4) { |
|
3015 var text = _ref4.text; |
|
3016 return typeof text === 'string'; |
|
3017 } |
|
3018 |
|
3019 function to_html_string_getText(_ref5) { |
|
3020 var text = _ref5.text; |
|
3021 return text; |
|
3022 } |
|
3023 |
|
3024 function to_html_string_remove(object) { |
|
3025 var index = object.parent.children.indexOf(object); |
|
3026 |
|
3027 if (index !== -1) { |
|
3028 object.parent.children.splice(index, 1); |
|
3029 } |
|
3030 |
|
3031 return object; |
|
3032 } |
|
3033 |
|
3034 function createElementHTML(_ref6) { |
|
3035 var type = _ref6.type, |
|
3036 attributes = _ref6.attributes, |
|
3037 object = _ref6.object, |
|
3038 children = _ref6.children; |
|
3039 var attributeString = ''; |
|
3040 |
|
3041 for (var key in attributes) { |
|
3042 if (!Object(external_this_wp_escapeHtml_["isValidAttributeName"])(key)) { |
|
3043 continue; |
|
3044 } |
|
3045 |
|
3046 attributeString += " ".concat(key, "=\"").concat(Object(external_this_wp_escapeHtml_["escapeAttribute"])(attributes[key]), "\""); |
|
3047 } |
|
3048 |
|
3049 if (object) { |
|
3050 return "<".concat(type).concat(attributeString, ">"); |
|
3051 } |
|
3052 |
|
3053 return "<".concat(type).concat(attributeString, ">").concat(createChildrenHTML(children), "</").concat(type, ">"); |
|
3054 } |
|
3055 |
|
3056 function createChildrenHTML() { |
|
3057 var children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
|
3058 return children.map(function (child) { |
|
3059 return child.text === undefined ? createElementHTML(child) : Object(external_this_wp_escapeHtml_["escapeHTML"])(child.text); |
|
3060 }).join(''); |
|
3061 } |
|
3062 |
|
3063 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/toggle-format.js |
|
3064 /** |
|
3065 * Internal dependencies |
|
3066 */ |
|
3067 |
|
3068 |
|
3069 |
|
3070 /** |
|
3071 * Toggles a format object to a Rich Text value at the current selection. |
|
3072 * |
|
3073 * @param {Object} value Value to modify. |
|
3074 * @param {Object} format Format to apply or remove. |
|
3075 * |
|
3076 * @return {Object} A new value with the format applied or removed. |
|
3077 */ |
|
3078 |
|
3079 function toggleFormat(value, format) { |
|
3080 if (getActiveFormat(value, format.type)) { |
|
3081 return removeFormat(value, format.type); |
|
3082 } |
|
3083 |
|
3084 return applyFormat(value, format); |
|
3085 } |
|
3086 |
|
3087 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/unregister-format-type.js |
|
3088 /** |
|
3089 * WordPress dependencies |
|
3090 */ |
|
3091 |
|
3092 |
|
3093 /** |
|
3094 * Unregisters a format. |
|
3095 * |
|
3096 * @param {string} name Format name. |
|
3097 * |
|
3098 * @return {WPFormat|undefined} The previous format value, if it has been successfully |
|
3099 * unregistered; otherwise `undefined`. |
|
3100 */ |
|
3101 |
|
3102 function unregisterFormatType(name) { |
|
3103 var oldFormat = Object(external_this_wp_data_["select"])('core/rich-text').getFormatType(name); |
|
3104 |
|
3105 if (!oldFormat) { |
|
3106 window.console.error("Format ".concat(name, " is not registered.")); |
|
3107 return; |
|
3108 } |
|
3109 |
|
3110 if (oldFormat.__experimentalCreatePrepareEditableTree && oldFormat.__experimentalGetPropsForEditableTreePreparation) { |
|
3111 Object(external_this_wp_hooks_["removeFilter"])('experimentalRichText', name); |
|
3112 } |
|
3113 |
|
3114 Object(external_this_wp_data_["dispatch"])('core/rich-text').removeFormatTypes(name); |
|
3115 return oldFormat; |
|
3116 } |
|
3117 |
|
3118 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-line-index.js |
|
3119 /** |
|
3120 * Internal dependencies |
|
3121 */ |
|
3122 |
|
3123 /** |
|
3124 * Gets the currently selected line index, or the first line index if the |
|
3125 * selection spans over multiple items. |
|
3126 * |
|
3127 * @param {Object} value Value to get the line index from. |
|
3128 * @param {boolean} startIndex Optional index that should be contained by the |
|
3129 * line. Defaults to the selection start of the |
|
3130 * value. |
|
3131 * |
|
3132 * @return {?boolean} The line index. Undefined if not found. |
|
3133 */ |
|
3134 |
|
3135 function getLineIndex(_ref) { |
|
3136 var start = _ref.start, |
|
3137 text = _ref.text; |
|
3138 var startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : start; |
|
3139 var index = startIndex; |
|
3140 |
|
3141 while (index--) { |
|
3142 if (text[index] === LINE_SEPARATOR) { |
|
3143 return index; |
|
3144 } |
|
3145 } |
|
3146 } |
|
3147 |
|
3148 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/indent-list-items.js |
|
3149 |
|
3150 |
|
3151 /** |
|
3152 * Internal dependencies |
|
3153 */ |
|
3154 |
|
3155 |
|
3156 /** |
|
3157 * Gets the line index of the first previous list item with higher indentation. |
|
3158 * |
|
3159 * @param {Object} value Value to search. |
|
3160 * @param {number} lineIndex Line index of the list item to compare with. |
|
3161 * |
|
3162 * @return {boolean} The line index. |
|
3163 */ |
|
3164 |
|
3165 function getTargetLevelLineIndex(_ref, lineIndex) { |
|
3166 var text = _ref.text, |
|
3167 replacements = _ref.replacements; |
|
3168 var startFormats = replacements[lineIndex] || []; |
|
3169 var index = lineIndex; |
|
3170 |
|
3171 while (index-- >= 0) { |
|
3172 if (text[index] !== LINE_SEPARATOR) { |
|
3173 continue; |
|
3174 } |
|
3175 |
|
3176 var formatsAtIndex = replacements[index] || []; // Return the first line index that is one level higher. If the level is |
|
3177 // lower or equal, there is no result. |
|
3178 |
|
3179 if (formatsAtIndex.length === startFormats.length + 1) { |
|
3180 return index; |
|
3181 } else if (formatsAtIndex.length <= startFormats.length) { |
|
3182 return; |
|
3183 } |
|
3184 } |
|
3185 } |
|
3186 /** |
|
3187 * Indents any selected list items if possible. |
|
3188 * |
|
3189 * @param {Object} value Value to change. |
|
3190 * @param {Object} rootFormat Root format. |
|
3191 * |
|
3192 * @return {Object} The changed value. |
|
3193 */ |
|
3194 |
|
3195 |
|
3196 function indentListItems(value, rootFormat) { |
|
3197 var lineIndex = getLineIndex(value); // There is only one line, so the line cannot be indented. |
|
3198 |
|
3199 if (lineIndex === undefined) { |
|
3200 return value; |
|
3201 } |
|
3202 |
|
3203 var text = value.text, |
|
3204 replacements = value.replacements, |
|
3205 end = value.end; |
|
3206 var previousLineIndex = getLineIndex(value, lineIndex); |
|
3207 var formatsAtLineIndex = replacements[lineIndex] || []; |
|
3208 var formatsAtPreviousLineIndex = replacements[previousLineIndex] || []; // The the indentation of the current line is greater than previous line, |
|
3209 // then the line cannot be furter indented. |
|
3210 |
|
3211 if (formatsAtLineIndex.length > formatsAtPreviousLineIndex.length) { |
|
3212 return value; |
|
3213 } |
|
3214 |
|
3215 var newFormats = replacements.slice(); |
|
3216 var targetLevelLineIndex = getTargetLevelLineIndex(value, lineIndex); |
|
3217 |
|
3218 for (var index = lineIndex; index < end; index++) { |
|
3219 if (text[index] !== LINE_SEPARATOR) { |
|
3220 continue; |
|
3221 } // Get the previous list, and if there's a child list, take over the |
|
3222 // formats. If not, duplicate the last level and create a new level. |
|
3223 |
|
3224 |
|
3225 if (targetLevelLineIndex) { |
|
3226 var targetFormats = replacements[targetLevelLineIndex] || []; |
|
3227 newFormats[index] = targetFormats.concat((newFormats[index] || []).slice(targetFormats.length - 1)); |
|
3228 } else { |
|
3229 var _targetFormats = replacements[previousLineIndex] || []; |
|
3230 |
|
3231 var lastformat = _targetFormats[_targetFormats.length - 1] || rootFormat; |
|
3232 newFormats[index] = _targetFormats.concat([lastformat], (newFormats[index] || []).slice(_targetFormats.length)); |
|
3233 } |
|
3234 } |
|
3235 |
|
3236 return Object(objectSpread["a" /* default */])({}, value, { |
|
3237 replacements: newFormats |
|
3238 }); |
|
3239 } |
|
3240 |
|
3241 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-parent-line-index.js |
|
3242 /** |
|
3243 * Internal dependencies |
|
3244 */ |
|
3245 |
|
3246 /** |
|
3247 * Gets the index of the first parent list. To get the parent list formats, we |
|
3248 * go through every list item until we find one with exactly one format type |
|
3249 * less. |
|
3250 * |
|
3251 * @param {Object} value Value to search. |
|
3252 * @param {number} lineIndex Line index of a child list item. |
|
3253 * |
|
3254 * @return {Array} The parent list line index. |
|
3255 */ |
|
3256 |
|
3257 function getParentLineIndex(_ref, lineIndex) { |
|
3258 var text = _ref.text, |
|
3259 replacements = _ref.replacements; |
|
3260 var startFormats = replacements[lineIndex] || []; |
|
3261 var index = lineIndex; |
|
3262 |
|
3263 while (index-- >= 0) { |
|
3264 if (text[index] !== LINE_SEPARATOR) { |
|
3265 continue; |
|
3266 } |
|
3267 |
|
3268 var formatsAtIndex = replacements[index] || []; |
|
3269 |
|
3270 if (formatsAtIndex.length === startFormats.length - 1) { |
|
3271 return index; |
|
3272 } |
|
3273 } |
|
3274 } |
|
3275 |
|
3276 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-last-child-index.js |
|
3277 /** |
|
3278 * Internal dependencies |
|
3279 */ |
|
3280 |
|
3281 /** |
|
3282 * Gets the line index of the last child in the list. |
|
3283 * |
|
3284 * @param {Object} value Value to search. |
|
3285 * @param {number} lineIndex Line index of a list item in the list. |
|
3286 * |
|
3287 * @return {Array} The index of the last child. |
|
3288 */ |
|
3289 |
|
3290 function getLastChildIndex(_ref, lineIndex) { |
|
3291 var text = _ref.text, |
|
3292 replacements = _ref.replacements; |
|
3293 var lineFormats = replacements[lineIndex] || []; // Use the given line index in case there are no next children. |
|
3294 |
|
3295 var childIndex = lineIndex; // `lineIndex` could be `undefined` if it's the first line. |
|
3296 |
|
3297 for (var index = lineIndex || 0; index < text.length; index++) { |
|
3298 // We're only interested in line indices. |
|
3299 if (text[index] !== LINE_SEPARATOR) { |
|
3300 continue; |
|
3301 } |
|
3302 |
|
3303 var formatsAtIndex = replacements[index] || []; // If the amout of formats is equal or more, store it, then return the |
|
3304 // last one if the amount of formats is less. |
|
3305 |
|
3306 if (formatsAtIndex.length >= lineFormats.length) { |
|
3307 childIndex = index; |
|
3308 } else { |
|
3309 return childIndex; |
|
3310 } |
|
3311 } // If the end of the text is reached, return the last child index. |
|
3312 |
|
3313 |
|
3314 return childIndex; |
|
3315 } |
|
3316 |
|
3317 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/outdent-list-items.js |
|
3318 |
|
3319 |
|
3320 /** |
|
3321 * Internal dependencies |
|
3322 */ |
|
3323 |
|
3324 |
|
3325 |
|
3326 |
|
3327 /** |
|
3328 * Outdents any selected list items if possible. |
|
3329 * |
|
3330 * @param {Object} value Value to change. |
|
3331 * |
|
3332 * @return {Object} The changed value. |
|
3333 */ |
|
3334 |
|
3335 function outdentListItems(value) { |
|
3336 var text = value.text, |
|
3337 replacements = value.replacements, |
|
3338 start = value.start, |
|
3339 end = value.end; |
|
3340 var startingLineIndex = getLineIndex(value, start); // Return early if the starting line index cannot be further outdented. |
|
3341 |
|
3342 if (replacements[startingLineIndex] === undefined) { |
|
3343 return value; |
|
3344 } |
|
3345 |
|
3346 var newFormats = replacements.slice(0); |
|
3347 var parentFormats = replacements[getParentLineIndex(value, startingLineIndex)] || []; |
|
3348 var endingLineIndex = getLineIndex(value, end); |
|
3349 var lastChildIndex = getLastChildIndex(value, endingLineIndex); // Outdent all list items from the starting line index until the last child |
|
3350 // index of the ending list. All children of the ending list need to be |
|
3351 // outdented, otherwise they'll be orphaned. |
|
3352 |
|
3353 for (var index = startingLineIndex; index <= lastChildIndex; index++) { |
|
3354 // Skip indices that are not line separators. |
|
3355 if (text[index] !== LINE_SEPARATOR) { |
|
3356 continue; |
|
3357 } // In the case of level 0, the formats at the index are undefined. |
|
3358 |
|
3359 |
|
3360 var currentFormats = newFormats[index] || []; // Omit the indentation level where the selection starts. |
|
3361 |
|
3362 newFormats[index] = parentFormats.concat(currentFormats.slice(parentFormats.length + 1)); |
|
3363 |
|
3364 if (newFormats[index].length === 0) { |
|
3365 delete newFormats[index]; |
|
3366 } |
|
3367 } |
|
3368 |
|
3369 return Object(objectSpread["a" /* default */])({}, value, { |
|
3370 replacements: newFormats |
|
3371 }); |
|
3372 } |
|
3373 |
|
3374 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/change-list-type.js |
|
3375 |
|
3376 |
|
3377 /** |
|
3378 * Internal dependencies |
|
3379 */ |
|
3380 |
|
3381 |
|
3382 |
|
3383 /** |
|
3384 * Changes the list type of the selected indented list, if any. Looks at the |
|
3385 * currently selected list item and takes the parent list, then changes the list |
|
3386 * type of this list. When multiple lines are selected, the parent lists are |
|
3387 * takes and changed. |
|
3388 * |
|
3389 * @param {Object} value Value to change. |
|
3390 * @param {Object} newFormat The new list format object. Choose between |
|
3391 * `{ type: 'ol' }` and `{ type: 'ul' }`. |
|
3392 * |
|
3393 * @return {Object} The changed value. |
|
3394 */ |
|
3395 |
|
3396 function changeListType(value, newFormat) { |
|
3397 var text = value.text, |
|
3398 replacements = value.replacements, |
|
3399 start = value.start, |
|
3400 end = value.end; |
|
3401 var startingLineIndex = getLineIndex(value, start); |
|
3402 var startLineFormats = replacements[startingLineIndex] || []; |
|
3403 var endLineFormats = replacements[getLineIndex(value, end)] || []; |
|
3404 var startIndex = getParentLineIndex(value, startingLineIndex); |
|
3405 var newReplacements = replacements.slice(); |
|
3406 var startCount = startLineFormats.length - 1; |
|
3407 var endCount = endLineFormats.length - 1; |
|
3408 var changed; |
|
3409 |
|
3410 for (var index = startIndex + 1 || 0; index < text.length; index++) { |
|
3411 if (text[index] !== LINE_SEPARATOR) { |
|
3412 continue; |
|
3413 } |
|
3414 |
|
3415 if ((newReplacements[index] || []).length <= startCount) { |
|
3416 break; |
|
3417 } |
|
3418 |
|
3419 if (!newReplacements[index]) { |
|
3420 continue; |
|
3421 } |
|
3422 |
|
3423 changed = true; |
|
3424 newReplacements[index] = newReplacements[index].map(function (format, i) { |
|
3425 return i < startCount || i > endCount ? format : newFormat; |
|
3426 }); |
|
3427 } |
|
3428 |
|
3429 if (!changed) { |
|
3430 return value; |
|
3431 } |
|
3432 |
|
3433 return Object(objectSpread["a" /* default */])({}, value, { |
|
3434 replacements: newReplacements |
|
3435 }); |
|
3436 } |
|
3437 |
|
3438 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/update-formats.js |
|
3439 /** |
|
3440 * Internal dependencies |
|
3441 */ |
|
3442 |
|
3443 /** |
|
3444 * Efficiently updates all the formats from `start` (including) until `end` |
|
3445 * (excluding) with the active formats. Mutates `value`. |
|
3446 * |
|
3447 * @param {Object} $1 Named paramentes. |
|
3448 * @param {Object} $1.value Value te update. |
|
3449 * @param {number} $1.start Index to update from. |
|
3450 * @param {number} $1.end Index to update until. |
|
3451 * @param {Array} $1.formats Replacement formats. |
|
3452 * |
|
3453 * @return {Object} Mutated value. |
|
3454 */ |
|
3455 |
|
3456 function updateFormats(_ref) { |
|
3457 var value = _ref.value, |
|
3458 start = _ref.start, |
|
3459 end = _ref.end, |
|
3460 formats = _ref.formats; |
|
3461 var formatsBefore = value.formats[start - 1] || []; |
|
3462 var formatsAfter = value.formats[end] || []; // First, fix the references. If any format right before or after are |
|
3463 // equal, the replacement format should use the same reference. |
|
3464 |
|
3465 value.activeFormats = formats.map(function (format, index) { |
|
3466 if (formatsBefore[index]) { |
|
3467 if (isFormatEqual(format, formatsBefore[index])) { |
|
3468 return formatsBefore[index]; |
|
3469 } |
|
3470 } else if (formatsAfter[index]) { |
|
3471 if (isFormatEqual(format, formatsAfter[index])) { |
|
3472 return formatsAfter[index]; |
|
3473 } |
|
3474 } |
|
3475 |
|
3476 return format; |
|
3477 }); |
|
3478 |
|
3479 while (--end >= start) { |
|
3480 if (value.activeFormats.length > 0) { |
|
3481 value.formats[end] = value.activeFormats; |
|
3482 } else { |
|
3483 delete value.formats[end]; |
|
3484 } |
|
3485 } |
|
3486 |
|
3487 return value; |
|
3488 } |
|
3489 |
|
3490 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/index.js |
|
3491 /* concated harmony reexport applyFormat */__webpack_require__.d(__webpack_exports__, "applyFormat", function() { return applyFormat; }); |
|
3492 /* concated harmony reexport charAt */__webpack_require__.d(__webpack_exports__, "charAt", function() { return charAt; }); |
|
3493 /* concated harmony reexport concat */__webpack_require__.d(__webpack_exports__, "concat", function() { return concat; }); |
|
3494 /* concated harmony reexport create */__webpack_require__.d(__webpack_exports__, "create", function() { return create; }); |
|
3495 /* concated harmony reexport getActiveFormat */__webpack_require__.d(__webpack_exports__, "getActiveFormat", function() { return getActiveFormat; }); |
|
3496 /* concated harmony reexport getActiveObject */__webpack_require__.d(__webpack_exports__, "getActiveObject", function() { return getActiveObject; }); |
|
3497 /* concated harmony reexport getSelectionEnd */__webpack_require__.d(__webpack_exports__, "getSelectionEnd", function() { return getSelectionEnd; }); |
|
3498 /* concated harmony reexport getSelectionStart */__webpack_require__.d(__webpack_exports__, "getSelectionStart", function() { return getSelectionStart; }); |
|
3499 /* concated harmony reexport getTextContent */__webpack_require__.d(__webpack_exports__, "getTextContent", function() { return getTextContent; }); |
|
3500 /* concated harmony reexport isCollapsed */__webpack_require__.d(__webpack_exports__, "isCollapsed", function() { return isCollapsed; }); |
|
3501 /* concated harmony reexport isEmpty */__webpack_require__.d(__webpack_exports__, "isEmpty", function() { return isEmpty; }); |
|
3502 /* concated harmony reexport isEmptyLine */__webpack_require__.d(__webpack_exports__, "isEmptyLine", function() { return isEmptyLine; }); |
|
3503 /* concated harmony reexport join */__webpack_require__.d(__webpack_exports__, "join", function() { return join; }); |
|
3504 /* concated harmony reexport registerFormatType */__webpack_require__.d(__webpack_exports__, "registerFormatType", function() { return registerFormatType; }); |
|
3505 /* concated harmony reexport removeFormat */__webpack_require__.d(__webpack_exports__, "removeFormat", function() { return removeFormat; }); |
|
3506 /* concated harmony reexport remove */__webpack_require__.d(__webpack_exports__, "remove", function() { return remove_remove; }); |
|
3507 /* concated harmony reexport replace */__webpack_require__.d(__webpack_exports__, "replace", function() { return replace; }); |
|
3508 /* concated harmony reexport insert */__webpack_require__.d(__webpack_exports__, "insert", function() { return insert; }); |
|
3509 /* concated harmony reexport insertLineBreak */__webpack_require__.d(__webpack_exports__, "insertLineBreak", function() { return insertLineBreak; }); |
|
3510 /* concated harmony reexport insertLineSeparator */__webpack_require__.d(__webpack_exports__, "insertLineSeparator", function() { return insertLineSeparator; }); |
|
3511 /* concated harmony reexport insertObject */__webpack_require__.d(__webpack_exports__, "insertObject", function() { return insertObject; }); |
|
3512 /* concated harmony reexport slice */__webpack_require__.d(__webpack_exports__, "slice", function() { return slice; }); |
|
3513 /* concated harmony reexport split */__webpack_require__.d(__webpack_exports__, "split", function() { return split; }); |
|
3514 /* concated harmony reexport apply */__webpack_require__.d(__webpack_exports__, "apply", function() { return apply; }); |
|
3515 /* concated harmony reexport unstableToDom */__webpack_require__.d(__webpack_exports__, "unstableToDom", function() { return toDom; }); |
|
3516 /* concated harmony reexport toHTMLString */__webpack_require__.d(__webpack_exports__, "toHTMLString", function() { return toHTMLString; }); |
|
3517 /* concated harmony reexport toggleFormat */__webpack_require__.d(__webpack_exports__, "toggleFormat", function() { return toggleFormat; }); |
|
3518 /* concated harmony reexport LINE_SEPARATOR */__webpack_require__.d(__webpack_exports__, "LINE_SEPARATOR", function() { return LINE_SEPARATOR; }); |
|
3519 /* concated harmony reexport unregisterFormatType */__webpack_require__.d(__webpack_exports__, "unregisterFormatType", function() { return unregisterFormatType; }); |
|
3520 /* concated harmony reexport indentListItems */__webpack_require__.d(__webpack_exports__, "indentListItems", function() { return indentListItems; }); |
|
3521 /* concated harmony reexport outdentListItems */__webpack_require__.d(__webpack_exports__, "outdentListItems", function() { return outdentListItems; }); |
|
3522 /* concated harmony reexport changeListType */__webpack_require__.d(__webpack_exports__, "changeListType", function() { return changeListType; }); |
|
3523 /* concated harmony reexport __unstableUpdateFormats */__webpack_require__.d(__webpack_exports__, "__unstableUpdateFormats", function() { return updateFormats; }); |
|
3524 /* concated harmony reexport __unstableGetActiveFormats */__webpack_require__.d(__webpack_exports__, "__unstableGetActiveFormats", function() { return getActiveFormats; }); |
|
3525 /** |
|
3526 * Internal dependencies |
|
3527 */ |
|
3528 |
|
3529 |
|
3530 |
|
3531 |
|
3532 |
|
3533 |
|
3534 |
|
3535 |
|
3536 |
|
3537 |
|
3538 |
|
3539 |
|
3540 |
|
3541 |
|
3542 |
|
3543 |
|
3544 |
|
3545 |
|
3546 |
|
3547 |
|
3548 |
|
3549 |
|
3550 |
|
3551 |
|
3552 |
|
3553 |
|
3554 |
|
3555 |
|
3556 |
|
3557 |
|
3558 |
|
3559 |
|
3560 |
|
3561 |
|
3562 |
|
3563 /***/ }), |
|
3564 |
|
3565 /***/ 41: |
|
3566 /***/ (function(module, exports, __webpack_require__) { |
|
3567 |
|
3568 module.exports = function memize( fn, options ) { |
|
3569 var size = 0, |
|
3570 maxSize, head, tail; |
|
3571 |
|
3572 if ( options && options.maxSize ) { |
|
3573 maxSize = options.maxSize; |
|
3574 } |
|
3575 |
|
3576 function memoized( /* ...args */ ) { |
|
3577 var node = head, |
|
3578 len = arguments.length, |
|
3579 args, i; |
|
3580 |
|
3581 searchCache: while ( node ) { |
|
3582 // Perform a shallow equality test to confirm that whether the node |
|
3583 // under test is a candidate for the arguments passed. Two arrays |
|
3584 // are shallowly equal if their length matches and each entry is |
|
3585 // strictly equal between the two sets. Avoid abstracting to a |
|
3586 // function which could incur an arguments leaking deoptimization. |
|
3587 |
|
3588 // Check whether node arguments match arguments length |
|
3589 if ( node.args.length !== arguments.length ) { |
|
3590 node = node.next; |
|
3591 continue; |
|
3592 } |
|
3593 |
|
3594 // Check whether node arguments match arguments values |
|
3595 for ( i = 0; i < len; i++ ) { |
|
3596 if ( node.args[ i ] !== arguments[ i ] ) { |
|
3597 node = node.next; |
|
3598 continue searchCache; |
|
3599 } |
|
3600 } |
|
3601 |
|
3602 // At this point we can assume we've found a match |
|
3603 |
|
3604 // Surface matched node to head if not already |
|
3605 if ( node !== head ) { |
|
3606 // As tail, shift to previous. Must only shift if not also |
|
3607 // head, since if both head and tail, there is no previous. |
|
3608 if ( node === tail ) { |
|
3609 tail = node.prev; |
|
3610 } |
|
3611 |
|
3612 // Adjust siblings to point to each other. If node was tail, |
|
3613 // this also handles new tail's empty `next` assignment. |
|
3614 node.prev.next = node.next; |
|
3615 if ( node.next ) { |
|
3616 node.next.prev = node.prev; |
|
3617 } |
|
3618 |
|
3619 node.next = head; |
|
3620 node.prev = null; |
|
3621 head.prev = node; |
|
3622 head = node; |
|
3623 } |
|
3624 |
|
3625 // Return immediately |
|
3626 return node.val; |
|
3627 } |
|
3628 |
|
3629 // No cached value found. Continue to insertion phase: |
|
3630 |
|
3631 // Create a copy of arguments (avoid leaking deoptimization) |
|
3632 args = new Array( len ); |
|
3633 for ( i = 0; i < len; i++ ) { |
|
3634 args[ i ] = arguments[ i ]; |
|
3635 } |
|
3636 |
|
3637 node = { |
|
3638 args: args, |
|
3639 |
|
3640 // Generate the result from original function |
|
3641 val: fn.apply( null, args ) |
|
3642 }; |
|
3643 |
|
3644 // Don't need to check whether node is already head, since it would |
|
3645 // have been returned above already if it was |
|
3646 |
|
3647 // Shift existing head down list |
|
3648 if ( head ) { |
|
3649 head.prev = node; |
|
3650 node.next = head; |
|
3651 } else { |
|
3652 // If no head, follows that there's no tail (at initial or reset) |
|
3653 tail = node; |
|
3654 } |
|
3655 |
|
3656 // Trim tail if we're reached max size and are pending cache insertion |
|
3657 if ( size === maxSize ) { |
|
3658 tail = tail.prev; |
|
3659 tail.next = null; |
|
3660 } else { |
|
3661 size++; |
|
3662 } |
|
3663 |
|
3664 head = node; |
|
3665 |
|
3666 return node.val; |
|
3667 } |
|
3668 |
|
3669 memoized.clear = function() { |
|
3670 head = null; |
|
3671 tail = null; |
|
3672 size = 0; |
|
3673 }; |
|
3674 |
|
3675 if ( false ) {} |
|
3676 |
|
3677 return memoized; |
|
3678 }; |
|
3679 |
|
3680 |
|
3681 /***/ }), |
|
3682 |
|
3683 /***/ 5: |
|
3684 /***/ (function(module, exports) { |
|
3685 |
|
3686 (function() { module.exports = this["wp"]["data"]; }()); |
|
3687 |
|
3688 /***/ }), |
|
3689 |
|
3690 /***/ 6: |
|
3691 /***/ (function(module, exports) { |
|
3692 |
|
3693 (function() { module.exports = this["wp"]["compose"]; }()); |
|
3694 |
|
3695 /***/ }), |
|
3696 |
|
3697 /***/ 69: |
|
3698 /***/ (function(module, exports) { |
|
3699 |
|
3700 (function() { module.exports = this["wp"]["escapeHtml"]; }()); |
|
3701 |
|
3702 /***/ }), |
|
3703 |
|
3704 /***/ 7: |
|
3705 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
3706 |
|
3707 "use strict"; |
|
3708 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectSpread; }); |
|
3709 /* harmony import */ var _defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15); |
|
3710 |
|
3711 function _objectSpread(target) { |
|
3712 for (var i = 1; i < arguments.length; i++) { |
|
3713 var source = arguments[i] != null ? arguments[i] : {}; |
|
3714 var ownKeys = Object.keys(source); |
|
3715 |
|
3716 if (typeof Object.getOwnPropertySymbols === 'function') { |
|
3717 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { |
|
3718 return Object.getOwnPropertyDescriptor(source, sym).enumerable; |
|
3719 })); |
|
3720 } |
|
3721 |
|
3722 ownKeys.forEach(function (key) { |
|
3723 Object(_defineProperty__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(target, key, source[key]); |
|
3724 }); |
|
3725 } |
|
3726 |
|
3727 return target; |
|
3728 } |
|
3729 |
|
3730 /***/ }) |
|
3731 |
|
3732 /******/ }); |