changeset 16 | a86126ab1dd4 |
parent 9 | 177826044cd9 |
child 18 | be944660c56a |
15:3d4e9c994f10 | 16:a86126ab1dd4 |
---|---|
80 /******/ // __webpack_public_path__ |
80 /******/ // __webpack_public_path__ |
81 /******/ __webpack_require__.p = ""; |
81 /******/ __webpack_require__.p = ""; |
82 /******/ |
82 /******/ |
83 /******/ |
83 /******/ |
84 /******/ // Load entry module and return exports |
84 /******/ // Load entry module and return exports |
85 /******/ return __webpack_require__(__webpack_require__.s = 361); |
85 /******/ return __webpack_require__(__webpack_require__.s = 440); |
86 /******/ }) |
86 /******/ }) |
87 /************************************************************************/ |
87 /************************************************************************/ |
88 /******/ ({ |
88 /******/ ({ |
89 |
89 |
90 /***/ 0: |
90 /***/ 0: |
92 |
92 |
93 (function() { module.exports = this["wp"]["element"]; }()); |
93 (function() { module.exports = this["wp"]["element"]; }()); |
94 |
94 |
95 /***/ }), |
95 /***/ }), |
96 |
96 |
97 /***/ 11: |
|
98 /***/ (function(module, exports, __webpack_require__) { |
|
99 |
|
100 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! |
|
101 Copyright (c) 2017 Jed Watson. |
|
102 Licensed under the MIT License (MIT), see |
|
103 http://jedwatson.github.io/classnames |
|
104 */ |
|
105 /* global define */ |
|
106 |
|
107 (function () { |
|
108 'use strict'; |
|
109 |
|
110 var hasOwn = {}.hasOwnProperty; |
|
111 |
|
112 function classNames () { |
|
113 var classes = []; |
|
114 |
|
115 for (var i = 0; i < arguments.length; i++) { |
|
116 var arg = arguments[i]; |
|
117 if (!arg) continue; |
|
118 |
|
119 var argType = typeof arg; |
|
120 |
|
121 if (argType === 'string' || argType === 'number') { |
|
122 classes.push(arg); |
|
123 } else if (Array.isArray(arg) && arg.length) { |
|
124 var inner = classNames.apply(null, arg); |
|
125 if (inner) { |
|
126 classes.push(inner); |
|
127 } |
|
128 } else if (argType === 'object') { |
|
129 for (var key in arg) { |
|
130 if (hasOwn.call(arg, key) && arg[key]) { |
|
131 classes.push(key); |
|
132 } |
|
133 } |
|
134 } |
|
135 } |
|
136 |
|
137 return classes.join(' '); |
|
138 } |
|
139 |
|
140 if ( true && module.exports) { |
|
141 classNames.default = classNames; |
|
142 module.exports = classNames; |
|
143 } else if (true) { |
|
144 // register as 'classnames', consistent with npm package name |
|
145 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () { |
|
146 return classNames; |
|
147 }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), |
|
148 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); |
|
149 } else {} |
|
150 }()); |
|
151 |
|
152 |
|
153 /***/ }), |
|
154 |
|
155 /***/ 14: |
|
156 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
157 |
|
158 "use strict"; |
|
159 |
|
160 // EXPORTS |
|
161 __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _slicedToArray; }); |
|
162 |
|
163 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js |
|
164 var arrayWithHoles = __webpack_require__(38); |
|
165 |
|
166 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js |
|
167 function _iterableToArrayLimit(arr, i) { |
|
168 if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; |
|
169 var _arr = []; |
|
170 var _n = true; |
|
171 var _d = false; |
|
172 var _e = undefined; |
|
173 |
|
174 try { |
|
175 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { |
|
176 _arr.push(_s.value); |
|
177 |
|
178 if (i && _arr.length === i) break; |
|
179 } |
|
180 } catch (err) { |
|
181 _d = true; |
|
182 _e = err; |
|
183 } finally { |
|
184 try { |
|
185 if (!_n && _i["return"] != null) _i["return"](); |
|
186 } finally { |
|
187 if (_d) throw _e; |
|
188 } |
|
189 } |
|
190 |
|
191 return _arr; |
|
192 } |
|
193 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js |
|
194 var unsupportedIterableToArray = __webpack_require__(29); |
|
195 |
|
196 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js |
|
197 var nonIterableRest = __webpack_require__(39); |
|
198 |
|
199 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 function _slicedToArray(arr, i) { |
|
205 return Object(arrayWithHoles["a" /* default */])(arr) || _iterableToArrayLimit(arr, i) || Object(unsupportedIterableToArray["a" /* default */])(arr, i) || Object(nonIterableRest["a" /* default */])(); |
|
206 } |
|
207 |
|
208 /***/ }), |
|
209 |
|
97 /***/ 15: |
210 /***/ 15: |
98 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
211 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
99 |
212 |
100 "use strict"; |
213 "use strict"; |
101 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; }); |
214 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectWithoutProperties; }); |
102 function _defineProperty(obj, key, value) { |
215 /* harmony import */ var _objectWithoutPropertiesLoose__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(41); |
103 if (key in obj) { |
216 |
104 Object.defineProperty(obj, key, { |
217 function _objectWithoutProperties(source, excluded) { |
105 value: value, |
218 if (source == null) return {}; |
106 enumerable: true, |
219 var target = Object(_objectWithoutPropertiesLoose__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(source, excluded); |
107 configurable: true, |
220 var key, i; |
108 writable: true |
221 |
109 }); |
222 if (Object.getOwnPropertySymbols) { |
110 } else { |
223 var sourceSymbolKeys = Object.getOwnPropertySymbols(source); |
111 obj[key] = value; |
224 |
112 } |
225 for (i = 0; i < sourceSymbolKeys.length; i++) { |
113 |
226 key = sourceSymbolKeys[i]; |
114 return obj; |
227 if (excluded.indexOf(key) >= 0) continue; |
228 if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; |
|
229 target[key] = source[key]; |
|
230 } |
|
231 } |
|
232 |
|
233 return target; |
|
115 } |
234 } |
116 |
235 |
117 /***/ }), |
236 /***/ }), |
118 |
237 |
119 /***/ 17: |
238 /***/ 18: |
120 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
239 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
121 |
240 |
122 "use strict"; |
241 "use strict"; |
123 |
242 |
243 // EXPORTS |
|
244 __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _toConsumableArray; }); |
|
245 |
|
246 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js |
|
247 var arrayLikeToArray = __webpack_require__(26); |
|
248 |
|
124 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js |
249 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js |
250 |
|
125 function _arrayWithoutHoles(arr) { |
251 function _arrayWithoutHoles(arr) { |
126 if (Array.isArray(arr)) { |
252 if (Array.isArray(arr)) return Object(arrayLikeToArray["a" /* default */])(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 } |
253 } |
134 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js |
254 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js |
135 var iterableToArray = __webpack_require__(34); |
255 var iterableToArray = __webpack_require__(35); |
256 |
|
257 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js |
|
258 var unsupportedIterableToArray = __webpack_require__(29); |
|
136 |
259 |
137 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js |
260 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js |
138 function _nonIterableSpread() { |
261 function _nonIterableSpread() { |
139 throw new TypeError("Invalid attempt to spread non-iterable instance"); |
262 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
140 } |
263 } |
141 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js |
264 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js |
142 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _toConsumableArray; }); |
265 |
143 |
266 |
144 |
267 |
145 |
268 |
146 function _toConsumableArray(arr) { |
269 function _toConsumableArray(arr) { |
147 return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || _nonIterableSpread(); |
270 return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || Object(unsupportedIterableToArray["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 } |
271 } |
174 |
272 |
175 /***/ }), |
273 /***/ }), |
176 |
274 |
177 /***/ 2: |
275 /***/ 2: |
179 |
277 |
180 (function() { module.exports = this["lodash"]; }()); |
278 (function() { module.exports = this["lodash"]; }()); |
181 |
279 |
182 /***/ }), |
280 /***/ }), |
183 |
281 |
282 /***/ 21: |
|
283 /***/ (function(module, exports) { |
|
284 |
|
285 (function() { module.exports = this["wp"]["keycodes"]; }()); |
|
286 |
|
287 /***/ }), |
|
288 |
|
184 /***/ 26: |
289 /***/ 26: |
290 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
291 |
|
292 "use strict"; |
|
293 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayLikeToArray; }); |
|
294 function _arrayLikeToArray(arr, len) { |
|
295 if (len == null || len > arr.length) len = arr.length; |
|
296 |
|
297 for (var i = 0, arr2 = new Array(len); i < len; i++) { |
|
298 arr2[i] = arr[i]; |
|
299 } |
|
300 |
|
301 return arr2; |
|
302 } |
|
303 |
|
304 /***/ }), |
|
305 |
|
306 /***/ 29: |
|
307 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
308 |
|
309 "use strict"; |
|
310 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; }); |
|
311 /* harmony import */ var _arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(26); |
|
312 |
|
313 function _unsupportedIterableToArray(o, minLen) { |
|
314 if (!o) return; |
|
315 if (typeof o === "string") return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen); |
|
316 var n = Object.prototype.toString.call(o).slice(8, -1); |
|
317 if (n === "Object" && o.constructor) n = o.constructor.name; |
|
318 if (n === "Map" || n === "Set") return Array.from(o); |
|
319 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen); |
|
320 } |
|
321 |
|
322 /***/ }), |
|
323 |
|
324 /***/ 35: |
|
325 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
326 |
|
327 "use strict"; |
|
328 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; }); |
|
329 function _iterableToArray(iter) { |
|
330 if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); |
|
331 } |
|
332 |
|
333 /***/ }), |
|
334 |
|
335 /***/ 37: |
|
185 /***/ (function(module, exports) { |
336 /***/ (function(module, exports) { |
186 |
337 |
187 (function() { module.exports = this["wp"]["hooks"]; }()); |
338 (function() { module.exports = this["wp"]["deprecated"]; }()); |
188 |
339 |
189 /***/ }), |
340 /***/ }), |
190 |
341 |
191 /***/ 30: |
342 /***/ 38: |
343 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
344 |
|
345 "use strict"; |
|
346 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; }); |
|
347 function _arrayWithHoles(arr) { |
|
348 if (Array.isArray(arr)) return arr; |
|
349 } |
|
350 |
|
351 /***/ }), |
|
352 |
|
353 /***/ 39: |
|
354 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
355 |
|
356 "use strict"; |
|
357 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; }); |
|
358 function _nonIterableRest() { |
|
359 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
|
360 } |
|
361 |
|
362 /***/ }), |
|
363 |
|
364 /***/ 4: |
|
365 /***/ (function(module, exports) { |
|
366 |
|
367 (function() { module.exports = this["wp"]["data"]; }()); |
|
368 |
|
369 /***/ }), |
|
370 |
|
371 /***/ 40: |
|
372 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
373 |
|
374 "use strict"; |
|
375 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _typeof; }); |
|
376 function _typeof(obj) { |
|
377 "@babel/helpers - typeof"; |
|
378 |
|
379 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { |
|
380 _typeof = function _typeof(obj) { |
|
381 return typeof obj; |
|
382 }; |
|
383 } else { |
|
384 _typeof = function _typeof(obj) { |
|
385 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; |
|
386 }; |
|
387 } |
|
388 |
|
389 return _typeof(obj); |
|
390 } |
|
391 |
|
392 /***/ }), |
|
393 |
|
394 /***/ 41: |
|
395 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
396 |
|
397 "use strict"; |
|
398 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectWithoutPropertiesLoose; }); |
|
399 function _objectWithoutPropertiesLoose(source, excluded) { |
|
400 if (source == null) return {}; |
|
401 var target = {}; |
|
402 var sourceKeys = Object.keys(source); |
|
403 var key, i; |
|
404 |
|
405 for (i = 0; i < sourceKeys.length; i++) { |
|
406 key = sourceKeys[i]; |
|
407 if (excluded.indexOf(key) >= 0) continue; |
|
408 target[key] = source[key]; |
|
409 } |
|
410 |
|
411 return target; |
|
412 } |
|
413 |
|
414 /***/ }), |
|
415 |
|
416 /***/ 42: |
|
192 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
417 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
193 |
418 |
194 "use strict"; |
419 "use strict"; |
195 |
420 |
196 |
421 |
468 }); |
693 }); |
469 |
694 |
470 |
695 |
471 /***/ }), |
696 /***/ }), |
472 |
697 |
473 /***/ 32: |
698 /***/ 440: |
474 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
699 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
475 |
700 |
476 "use strict"; |
701 "use strict"; |
477 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _typeof; }); |
702 // ESM COMPAT FLAG |
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__); |
703 __webpack_require__.r(__webpack_exports__); |
704 |
|
705 // EXPORTS |
|
706 __webpack_require__.d(__webpack_exports__, "applyFormat", function() { return /* reexport */ applyFormat; }); |
|
707 __webpack_require__.d(__webpack_exports__, "concat", function() { return /* reexport */ concat; }); |
|
708 __webpack_require__.d(__webpack_exports__, "create", function() { return /* reexport */ create; }); |
|
709 __webpack_require__.d(__webpack_exports__, "getActiveFormat", function() { return /* reexport */ getActiveFormat; }); |
|
710 __webpack_require__.d(__webpack_exports__, "getActiveObject", function() { return /* reexport */ getActiveObject; }); |
|
711 __webpack_require__.d(__webpack_exports__, "getTextContent", function() { return /* reexport */ getTextContent; }); |
|
712 __webpack_require__.d(__webpack_exports__, "__unstableIsListRootSelected", function() { return /* reexport */ isListRootSelected; }); |
|
713 __webpack_require__.d(__webpack_exports__, "__unstableIsActiveListType", function() { return /* reexport */ isActiveListType; }); |
|
714 __webpack_require__.d(__webpack_exports__, "isCollapsed", function() { return /* reexport */ isCollapsed; }); |
|
715 __webpack_require__.d(__webpack_exports__, "isEmpty", function() { return /* reexport */ isEmpty; }); |
|
716 __webpack_require__.d(__webpack_exports__, "__unstableIsEmptyLine", function() { return /* reexport */ isEmptyLine; }); |
|
717 __webpack_require__.d(__webpack_exports__, "join", function() { return /* reexport */ join; }); |
|
718 __webpack_require__.d(__webpack_exports__, "registerFormatType", function() { return /* reexport */ registerFormatType; }); |
|
719 __webpack_require__.d(__webpack_exports__, "removeFormat", function() { return /* reexport */ removeFormat; }); |
|
720 __webpack_require__.d(__webpack_exports__, "remove", function() { return /* reexport */ remove_remove; }); |
|
721 __webpack_require__.d(__webpack_exports__, "replace", function() { return /* reexport */ replace_replace; }); |
|
722 __webpack_require__.d(__webpack_exports__, "insert", function() { return /* reexport */ insert; }); |
|
723 __webpack_require__.d(__webpack_exports__, "__unstableInsertLineSeparator", function() { return /* reexport */ insertLineSeparator; }); |
|
724 __webpack_require__.d(__webpack_exports__, "__unstableRemoveLineSeparator", function() { return /* reexport */ removeLineSeparator; }); |
|
725 __webpack_require__.d(__webpack_exports__, "insertObject", function() { return /* reexport */ insertObject; }); |
|
726 __webpack_require__.d(__webpack_exports__, "slice", function() { return /* reexport */ slice; }); |
|
727 __webpack_require__.d(__webpack_exports__, "split", function() { return /* reexport */ split; }); |
|
728 __webpack_require__.d(__webpack_exports__, "__unstableToDom", function() { return /* reexport */ toDom; }); |
|
729 __webpack_require__.d(__webpack_exports__, "toHTMLString", function() { return /* reexport */ toHTMLString; }); |
|
730 __webpack_require__.d(__webpack_exports__, "toggleFormat", function() { return /* reexport */ toggleFormat; }); |
|
731 __webpack_require__.d(__webpack_exports__, "__UNSTABLE_LINE_SEPARATOR", function() { return /* reexport */ LINE_SEPARATOR; }); |
|
732 __webpack_require__.d(__webpack_exports__, "unregisterFormatType", function() { return /* reexport */ unregisterFormatType; }); |
|
733 __webpack_require__.d(__webpack_exports__, "__unstableCanIndentListItems", function() { return /* reexport */ canIndentListItems; }); |
|
734 __webpack_require__.d(__webpack_exports__, "__unstableCanOutdentListItems", function() { return /* reexport */ canOutdentListItems; }); |
|
735 __webpack_require__.d(__webpack_exports__, "__unstableIndentListItems", function() { return /* reexport */ indentListItems; }); |
|
736 __webpack_require__.d(__webpack_exports__, "__unstableOutdentListItems", function() { return /* reexport */ outdentListItems; }); |
|
737 __webpack_require__.d(__webpack_exports__, "__unstableChangeListType", function() { return /* reexport */ changeListType; }); |
|
738 __webpack_require__.d(__webpack_exports__, "__unstableCreateElement", function() { return /* reexport */ createElement; }); |
|
739 __webpack_require__.d(__webpack_exports__, "__experimentalRichText", function() { return /* reexport */ component; }); |
|
740 __webpack_require__.d(__webpack_exports__, "__unstableFormatEdit", function() { return /* reexport */ FormatEdit; }); |
|
741 |
|
742 // NAMESPACE OBJECT: ./node_modules/@wordpress/rich-text/build-module/store/selectors.js |
|
512 var selectors_namespaceObject = {}; |
743 var selectors_namespaceObject = {}; |
513 __webpack_require__.r(selectors_namespaceObject); |
744 __webpack_require__.r(selectors_namespaceObject); |
514 __webpack_require__.d(selectors_namespaceObject, "getFormatTypes", function() { return getFormatTypes; }); |
745 __webpack_require__.d(selectors_namespaceObject, "getFormatTypes", function() { return getFormatTypes; }); |
515 __webpack_require__.d(selectors_namespaceObject, "getFormatType", function() { return getFormatType; }); |
746 __webpack_require__.d(selectors_namespaceObject, "getFormatType", function() { return getFormatType; }); |
516 __webpack_require__.d(selectors_namespaceObject, "getFormatTypeForBareElement", function() { return getFormatTypeForBareElement; }); |
747 __webpack_require__.d(selectors_namespaceObject, "getFormatTypeForBareElement", function() { return getFormatTypeForBareElement; }); |
517 __webpack_require__.d(selectors_namespaceObject, "getFormatTypeForClassName", function() { return getFormatTypeForClassName; }); |
748 __webpack_require__.d(selectors_namespaceObject, "getFormatTypeForClassName", function() { return getFormatTypeForClassName; }); |
749 |
|
750 // NAMESPACE OBJECT: ./node_modules/@wordpress/rich-text/build-module/store/actions.js |
|
518 var actions_namespaceObject = {}; |
751 var actions_namespaceObject = {}; |
519 __webpack_require__.r(actions_namespaceObject); |
752 __webpack_require__.r(actions_namespaceObject); |
520 __webpack_require__.d(actions_namespaceObject, "addFormatTypes", function() { return addFormatTypes; }); |
753 __webpack_require__.d(actions_namespaceObject, "addFormatTypes", function() { return addFormatTypes; }); |
521 __webpack_require__.d(actions_namespaceObject, "removeFormatTypes", function() { return removeFormatTypes; }); |
754 __webpack_require__.d(actions_namespaceObject, "removeFormatTypes", function() { return removeFormatTypes; }); |
522 |
755 |
523 // EXTERNAL MODULE: external {"this":["wp","data"]} |
756 // EXTERNAL MODULE: external {"this":["wp","data"]} |
524 var external_this_wp_data_ = __webpack_require__(5); |
757 var external_this_wp_data_ = __webpack_require__(4); |
525 |
758 |
526 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread.js |
759 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js |
527 var objectSpread = __webpack_require__(7); |
760 var defineProperty = __webpack_require__(5); |
528 |
761 |
529 // EXTERNAL MODULE: external "lodash" |
762 // EXTERNAL MODULE: external {"this":"lodash"} |
530 var external_lodash_ = __webpack_require__(2); |
763 var external_this_lodash_ = __webpack_require__(2); |
531 |
764 |
532 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/reducer.js |
765 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/reducer.js |
533 |
766 |
767 |
|
768 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
769 |
|
770 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
534 |
771 |
535 /** |
772 /** |
536 * External dependencies |
773 * External dependencies |
537 */ |
774 */ |
538 |
775 |
554 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
791 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
555 var action = arguments.length > 1 ? arguments[1] : undefined; |
792 var action = arguments.length > 1 ? arguments[1] : undefined; |
556 |
793 |
557 switch (action.type) { |
794 switch (action.type) { |
558 case 'ADD_FORMAT_TYPES': |
795 case 'ADD_FORMAT_TYPES': |
559 return Object(objectSpread["a" /* default */])({}, state, Object(external_lodash_["keyBy"])(action.formatTypes, 'name')); |
796 return _objectSpread({}, state, {}, Object(external_this_lodash_["keyBy"])(action.formatTypes, 'name')); |
560 |
797 |
561 case 'REMOVE_FORMAT_TYPES': |
798 case 'REMOVE_FORMAT_TYPES': |
562 return Object(external_lodash_["omit"])(state, action.names); |
799 return Object(external_this_lodash_["omit"])(state, action.names); |
563 } |
800 } |
564 |
801 |
565 return state; |
802 return state; |
566 } |
803 } |
567 /* harmony default export */ var reducer = (Object(external_this_wp_data_["combineReducers"])({ |
804 /* harmony default export */ var reducer = (Object(external_this_wp_data_["combineReducers"])({ |
568 formatTypes: reducer_formatTypes |
805 formatTypes: reducer_formatTypes |
569 })); |
806 })); |
570 |
807 |
571 // EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js |
808 // EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js |
572 var rememo = __webpack_require__(30); |
809 var rememo = __webpack_require__(42); |
573 |
810 |
574 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/selectors.js |
811 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/selectors.js |
575 /** |
812 /** |
576 * External dependencies |
813 * External dependencies |
577 */ |
814 */ |
611 * format type for. |
848 * format type for. |
612 * @return {?Object} Format type. |
849 * @return {?Object} Format type. |
613 */ |
850 */ |
614 |
851 |
615 function getFormatTypeForBareElement(state, bareElementTagName) { |
852 function getFormatTypeForBareElement(state, bareElementTagName) { |
616 return Object(external_lodash_["find"])(getFormatTypes(state), function (_ref) { |
853 return Object(external_this_lodash_["find"])(getFormatTypes(state), function (_ref) { |
617 var tagName = _ref.tagName; |
854 var className = _ref.className, |
618 return bareElementTagName === tagName; |
855 tagName = _ref.tagName; |
856 return className === null && bareElementTagName === tagName; |
|
619 }); |
857 }); |
620 } |
858 } |
621 /** |
859 /** |
622 * Gets the format type, if any, that can handle an element, given its classes. |
860 * Gets the format type, if any, that can handle an element, given its classes. |
623 * |
861 * |
626 * type for. |
864 * type for. |
627 * @return {?Object} Format type. |
865 * @return {?Object} Format type. |
628 */ |
866 */ |
629 |
867 |
630 function getFormatTypeForClassName(state, elementClassName) { |
868 function getFormatTypeForClassName(state, elementClassName) { |
631 return Object(external_lodash_["find"])(getFormatTypes(state), function (_ref2) { |
869 return Object(external_this_lodash_["find"])(getFormatTypes(state), function (_ref2) { |
632 var className = _ref2.className; |
870 var className = _ref2.className; |
633 |
871 |
634 if (className === null) { |
872 if (className === null) { |
635 return false; |
873 return false; |
636 } |
874 } |
654 */ |
892 */ |
655 |
893 |
656 function addFormatTypes(formatTypes) { |
894 function addFormatTypes(formatTypes) { |
657 return { |
895 return { |
658 type: 'ADD_FORMAT_TYPES', |
896 type: 'ADD_FORMAT_TYPES', |
659 formatTypes: Object(external_lodash_["castArray"])(formatTypes) |
897 formatTypes: Object(external_this_lodash_["castArray"])(formatTypes) |
660 }; |
898 }; |
661 } |
899 } |
662 /** |
900 /** |
663 * Returns an action object used to remove a registered format type. |
901 * Returns an action object used to remove a registered format type. |
664 * |
902 * |
668 */ |
906 */ |
669 |
907 |
670 function removeFormatTypes(names) { |
908 function removeFormatTypes(names) { |
671 return { |
909 return { |
672 type: 'REMOVE_FORMAT_TYPES', |
910 type: 'REMOVE_FORMAT_TYPES', |
673 names: Object(external_lodash_["castArray"])(names) |
911 names: Object(external_this_lodash_["castArray"])(names) |
674 }; |
912 }; |
675 } |
913 } |
676 |
914 |
677 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/index.js |
915 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/store/index.js |
678 /** |
916 /** |
691 selectors: selectors_namespaceObject, |
929 selectors: selectors_namespaceObject, |
692 actions: actions_namespaceObject |
930 actions: actions_namespaceObject |
693 }); |
931 }); |
694 |
932 |
695 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules |
933 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules |
696 var toConsumableArray = __webpack_require__(17); |
934 var toConsumableArray = __webpack_require__(18); |
697 |
935 |
698 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-format-equal.js |
936 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-format-equal.js |
699 /** |
937 /** |
700 * Optimised equality check for format objects. |
938 * Optimised equality check for format objects. |
701 * |
939 * |
752 } |
990 } |
753 |
991 |
754 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/normalise-formats.js |
992 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/normalise-formats.js |
755 |
993 |
756 |
994 |
995 function normalise_formats_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
996 |
|
997 function normalise_formats_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { normalise_formats_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { normalise_formats_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
998 |
|
757 /** |
999 /** |
758 * Internal dependencies |
1000 * Internal dependencies |
759 */ |
1001 */ |
760 |
1002 |
761 /** |
1003 /** |
782 } |
1024 } |
783 }); |
1025 }); |
784 newFormats[index] = newFormatsAtIndex; |
1026 newFormats[index] = newFormatsAtIndex; |
785 } |
1027 } |
786 }); |
1028 }); |
787 return Object(objectSpread["a" /* default */])({}, value, { |
1029 return normalise_formats_objectSpread({}, value, { |
788 formats: newFormats |
1030 formats: newFormats |
789 }); |
1031 }); |
790 } |
1032 } |
791 |
1033 |
792 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/apply-format.js |
1034 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/apply-format.js |
793 |
1035 |
794 |
1036 |
795 |
1037 |
1038 function apply_format_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
1039 |
|
1040 function apply_format_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { apply_format_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { apply_format_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
1041 |
|
796 /** |
1042 /** |
797 * External dependencies |
1043 * External dependencies |
798 */ |
1044 */ |
799 |
1045 |
800 /** |
1046 /** |
801 * Internal dependencies |
1047 * Internal dependencies |
802 */ |
1048 */ |
803 |
1049 |
804 |
1050 |
1051 |
|
1052 function replace(array, index, value) { |
|
1053 array = array.slice(); |
|
1054 array[index] = value; |
|
1055 return array; |
|
1056 } |
|
805 /** |
1057 /** |
806 * Apply a format object to a Rich Text value from the given `startIndex` to the |
1058 * 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 |
1059 * given `endIndex`. Indices are retrieved from the selection if none are |
808 * provided. |
1060 * provided. |
809 * |
1061 * |
812 * @param {number} [startIndex] Start index. |
1064 * @param {number} [startIndex] Start index. |
813 * @param {number} [endIndex] End index. |
1065 * @param {number} [endIndex] End index. |
814 * |
1066 * |
815 * @return {Object} A new value with the format applied. |
1067 * @return {Object} A new value with the format applied. |
816 */ |
1068 */ |
1069 |
|
817 |
1070 |
818 function applyFormat(value, format) { |
1071 function applyFormat(value, format) { |
819 var startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : value.start; |
1072 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; |
1073 var endIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : value.end; |
821 var formats = value.formats, |
1074 var formats = value.formats, |
822 activeFormats = value.activeFormats; |
1075 activeFormats = value.activeFormats; |
823 var newFormats = formats.slice(); // The selection is collapsed. |
1076 var newFormats = formats.slice(); // The selection is collapsed. |
824 |
1077 |
825 if (startIndex === endIndex) { |
1078 if (startIndex === endIndex) { |
826 var startFormat = Object(external_lodash_["find"])(newFormats[startIndex], { |
1079 var startFormat = Object(external_this_lodash_["find"])(newFormats[startIndex], { |
827 type: format.type |
1080 type: format.type |
828 }); // If the caret is at a format of the same type, expand start and end to |
1081 }); // 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. |
1082 // the edges of the format. This is useful to apply new attributes. |
830 |
1083 |
831 if (startFormat) { |
1084 if (startFormat) { |
832 while (Object(external_lodash_["find"])(newFormats[startIndex], startFormat)) { |
1085 var index = newFormats[startIndex].indexOf(startFormat); |
833 applyFormats(newFormats, startIndex, format); |
1086 |
1087 while (newFormats[startIndex] && newFormats[startIndex][index] === startFormat) { |
|
1088 newFormats[startIndex] = replace(newFormats[startIndex], index, format); |
|
834 startIndex--; |
1089 startIndex--; |
835 } |
1090 } |
836 |
1091 |
837 endIndex++; |
1092 endIndex++; |
838 |
1093 |
839 while (Object(external_lodash_["find"])(newFormats[endIndex], startFormat)) { |
1094 while (newFormats[endIndex] && newFormats[endIndex][index] === startFormat) { |
840 applyFormats(newFormats, endIndex, format); |
1095 newFormats[endIndex] = replace(newFormats[endIndex], index, format); |
841 endIndex++; |
1096 endIndex++; |
842 } |
1097 } |
843 } |
1098 } |
844 } else { |
1099 } else { |
845 for (var index = startIndex; index < endIndex; index++) { |
1100 // Determine the highest position the new format can be inserted at. |
846 applyFormats(newFormats, index, format); |
1101 var position = +Infinity; |
847 } |
1102 |
848 } |
1103 for (var _index = startIndex; _index < endIndex; _index++) { |
849 |
1104 if (newFormats[_index]) { |
850 return normaliseFormats(Object(objectSpread["a" /* default */])({}, value, { |
1105 newFormats[_index] = newFormats[_index].filter(function (_ref) { |
1106 var type = _ref.type; |
|
1107 return type !== format.type; |
|
1108 }); |
|
1109 var length = newFormats[_index].length; |
|
1110 |
|
1111 if (length < position) { |
|
1112 position = length; |
|
1113 } |
|
1114 } else { |
|
1115 newFormats[_index] = []; |
|
1116 position = 0; |
|
1117 } |
|
1118 } |
|
1119 |
|
1120 for (var _index2 = startIndex; _index2 < endIndex; _index2++) { |
|
1121 newFormats[_index2].splice(position, 0, format); |
|
1122 } |
|
1123 } |
|
1124 |
|
1125 return normaliseFormats(apply_format_objectSpread({}, value, { |
|
851 formats: newFormats, |
1126 formats: newFormats, |
852 // Always revise active formats. This serves as a placeholder for new |
1127 // Always revise active formats. This serves as a placeholder for new |
853 // inputs with the format so new input appears with the format applied, |
1128 // 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. |
1129 // and ensures a format of the same type uses the latest values. |
855 activeFormats: [].concat(Object(toConsumableArray["a" /* default */])(Object(external_lodash_["reject"])(activeFormats, { |
1130 activeFormats: [].concat(Object(toConsumableArray["a" /* default */])(Object(external_this_lodash_["reject"])(activeFormats, { |
856 type: format.type |
1131 type: format.type |
857 })), [format]) |
1132 })), [format]) |
858 })); |
1133 })); |
859 } |
1134 } |
860 |
1135 |
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 |
1136 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js |
890 var esm_typeof = __webpack_require__(32); |
1137 var esm_typeof = __webpack_require__(40); |
891 |
1138 |
892 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/create-element.js |
1139 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/create-element.js |
893 /** |
1140 /** |
894 * Parse the given HTML into a body element. |
1141 * Parse the given HTML into a body element. |
895 * |
1142 * |
917 return createElement.body; |
1164 return createElement.body; |
918 } |
1165 } |
919 |
1166 |
920 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/special-characters.js |
1167 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/special-characters.js |
921 /** |
1168 /** |
922 * Line separator character. |
1169 * Line separator character, used for multiline text. |
923 */ |
1170 */ |
924 var LINE_SEPARATOR = "\u2028"; |
1171 var LINE_SEPARATOR = "\u2028"; |
1172 /** |
|
1173 * Object replacement character, used as a placeholder for objects. |
|
1174 */ |
|
1175 |
|
925 var OBJECT_REPLACEMENT_CHARACTER = "\uFFFC"; |
1176 var OBJECT_REPLACEMENT_CHARACTER = "\uFFFC"; |
1177 /** |
|
1178 * Zero width non-breaking space, used as padding in the editable DOM tree when |
|
1179 * it is empty otherwise. |
|
1180 */ |
|
1181 |
|
1182 var ZWNBSP = "\uFEFF"; |
|
926 |
1183 |
927 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/create.js |
1184 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/create.js |
928 |
1185 |
929 |
1186 |
930 |
1187 |
931 |
1188 |
1189 function create_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
1190 |
|
1191 function create_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { create_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { create_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
1192 |
|
932 /** |
1193 /** |
933 * WordPress dependencies |
1194 * WordPress dependencies |
934 */ |
1195 */ |
935 |
1196 |
936 /** |
1197 /** |
939 |
1200 |
940 |
1201 |
941 |
1202 |
942 |
1203 |
943 |
1204 |
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 |
1205 |
952 function createEmptyValue() { |
1206 function createEmptyValue() { |
953 return { |
1207 return { |
954 formats: [], |
1208 formats: [], |
955 replacements: [], |
1209 replacements: [], |
1060 * @param {Range} [$1.range] Range to create value from. |
1314 * @param {Range} [$1.range] Range to create value from. |
1061 * @param {string} [$1.multilineTag] Multiline tag if the structure is |
1315 * @param {string} [$1.multilineTag] Multiline tag if the structure is |
1062 * multiline. |
1316 * multiline. |
1063 * @param {Array} [$1.multilineWrapperTags] Tags where lines can be found if |
1317 * @param {Array} [$1.multilineWrapperTags] Tags where lines can be found if |
1064 * nesting is possible. |
1318 * nesting is possible. |
1319 * @param {?boolean} [$1.preserveWhiteSpace] Whether or not to collapse white |
|
1320 * space characters. |
|
1065 * |
1321 * |
1066 * @return {Object} A rich text value. |
1322 * @return {Object} A rich text value. |
1067 */ |
1323 */ |
1068 |
1324 |
1069 |
1325 |
1073 text = _ref2.text, |
1329 text = _ref2.text, |
1074 html = _ref2.html, |
1330 html = _ref2.html, |
1075 range = _ref2.range, |
1331 range = _ref2.range, |
1076 multilineTag = _ref2.multilineTag, |
1332 multilineTag = _ref2.multilineTag, |
1077 multilineWrapperTags = _ref2.multilineWrapperTags, |
1333 multilineWrapperTags = _ref2.multilineWrapperTags, |
1078 isEditableTree = _ref2.__unstableIsEditableTree; |
1334 isEditableTree = _ref2.__unstableIsEditableTree, |
1335 preserveWhiteSpace = _ref2.preserveWhiteSpace; |
|
1079 |
1336 |
1080 if (typeof text === 'string' && text.length > 0) { |
1337 if (typeof text === 'string' && text.length > 0) { |
1081 return { |
1338 return { |
1082 formats: Array(text.length), |
1339 formats: Array(text.length), |
1083 replacements: Array(text.length), |
1340 replacements: Array(text.length), |
1084 text: text |
1341 text: text |
1085 }; |
1342 }; |
1086 } |
1343 } |
1087 |
1344 |
1088 if (typeof html === 'string' && html.length > 0) { |
1345 if (typeof html === 'string' && html.length > 0) { |
1346 // It does not matter which document this is, we're just using it to |
|
1347 // parse. |
|
1089 element = createElement(document, html); |
1348 element = createElement(document, html); |
1090 } |
1349 } |
1091 |
1350 |
1092 if (Object(esm_typeof["a" /* default */])(element) !== 'object') { |
1351 if (Object(esm_typeof["a" /* default */])(element) !== 'object') { |
1093 return createEmptyValue(); |
1352 return createEmptyValue(); |
1095 |
1354 |
1096 if (!multilineTag) { |
1355 if (!multilineTag) { |
1097 return createFromElement({ |
1356 return createFromElement({ |
1098 element: element, |
1357 element: element, |
1099 range: range, |
1358 range: range, |
1100 isEditableTree: isEditableTree |
1359 isEditableTree: isEditableTree, |
1360 preserveWhiteSpace: preserveWhiteSpace |
|
1101 }); |
1361 }); |
1102 } |
1362 } |
1103 |
1363 |
1104 return createFromMultilineElement({ |
1364 return createFromMultilineElement({ |
1105 element: element, |
1365 element: element, |
1106 range: range, |
1366 range: range, |
1107 multilineTag: multilineTag, |
1367 multilineTag: multilineTag, |
1108 multilineWrapperTags: multilineWrapperTags, |
1368 multilineWrapperTags: multilineWrapperTags, |
1109 isEditableTree: isEditableTree |
1369 isEditableTree: isEditableTree, |
1370 preserveWhiteSpace: preserveWhiteSpace |
|
1110 }); |
1371 }); |
1111 } |
1372 } |
1112 /** |
1373 /** |
1113 * Helper to accumulate the value's selection start and end from the current |
1374 * Helper to accumulate the value's selection start and end from the current |
1114 * node and range. |
1375 * node and range. |
1131 endOffset = range.endOffset; |
1392 endOffset = range.endOffset; |
1132 var currentLength = accumulator.text.length; // Selection can be extracted from value. |
1393 var currentLength = accumulator.text.length; // Selection can be extracted from value. |
1133 |
1394 |
1134 if (value.start !== undefined) { |
1395 if (value.start !== undefined) { |
1135 accumulator.start = currentLength + value.start; // Range indicates that the current node has selection. |
1396 accumulator.start = currentLength + value.start; // Range indicates that the current node has selection. |
1136 } else if (node === startContainer && node.nodeType === TEXT_NODE) { |
1397 } else if (node === startContainer && node.nodeType === node.TEXT_NODE) { |
1137 accumulator.start = currentLength + startOffset; // Range indicates that the current node is selected. |
1398 accumulator.start = currentLength + startOffset; // Range indicates that the current node is selected. |
1138 } else if (parentNode === startContainer && node === startContainer.childNodes[startOffset]) { |
1399 } else if (parentNode === startContainer && node === startContainer.childNodes[startOffset]) { |
1139 accumulator.start = currentLength; // Range indicates that the selection is after the current node. |
1400 accumulator.start = currentLength; // Range indicates that the selection is after the current node. |
1140 } else if (parentNode === startContainer && node === startContainer.childNodes[startOffset - 1]) { |
1401 } else if (parentNode === startContainer && node === startContainer.childNodes[startOffset - 1]) { |
1141 accumulator.start = currentLength + value.text.length; // Fallback if no child inside handled the selection. |
1402 accumulator.start = currentLength + value.text.length; // Fallback if no child inside handled the selection. |
1144 } // Selection can be extracted from value. |
1405 } // Selection can be extracted from value. |
1145 |
1406 |
1146 |
1407 |
1147 if (value.end !== undefined) { |
1408 if (value.end !== undefined) { |
1148 accumulator.end = currentLength + value.end; // Range indicates that the current node has selection. |
1409 accumulator.end = currentLength + value.end; // Range indicates that the current node has selection. |
1149 } else if (node === endContainer && node.nodeType === TEXT_NODE) { |
1410 } else if (node === endContainer && node.nodeType === node.TEXT_NODE) { |
1150 accumulator.end = currentLength + endOffset; // Range indicates that the current node is selected. |
1411 accumulator.end = currentLength + endOffset; // Range indicates that the current node is selected. |
1151 } else if (parentNode === endContainer && node === endContainer.childNodes[endOffset - 1]) { |
1412 } 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. |
1413 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]) { |
1414 } else if (parentNode === endContainer && node === endContainer.childNodes[endOffset]) { |
1154 accumulator.end = currentLength; // Fallback if no child inside handled the selection. |
1415 accumulator.end = currentLength; // Fallback if no child inside handled the selection. |
1190 startOffset: startOffset, |
1451 startOffset: startOffset, |
1191 endContainer: endContainer, |
1452 endContainer: endContainer, |
1192 endOffset: endOffset |
1453 endOffset: endOffset |
1193 }; |
1454 }; |
1194 } |
1455 } |
1195 |
1456 /** |
1196 function filterString(string) { |
1457 * Collapse any whitespace used for HTML formatting to one space character, |
1197 // Reduce any whitespace used for HTML formatting to one space |
1458 * because it will also be displayed as such by the browser. |
1198 // character, because it will also be displayed as such by the browser. |
1459 * |
1460 * @param {string} string |
|
1461 */ |
|
1462 |
|
1463 |
|
1464 function collapseWhiteSpace(string) { |
|
1199 return string.replace(/[\n\r\t]+/g, ' '); |
1465 return string.replace(/[\n\r\t]+/g, ' '); |
1466 } |
|
1467 |
|
1468 var ZWNBSPRegExp = new RegExp(ZWNBSP, 'g'); |
|
1469 /** |
|
1470 * Removes padding (zero width non breaking spaces) added by `toTree`. |
|
1471 * |
|
1472 * @param {string} string |
|
1473 */ |
|
1474 |
|
1475 function removePadding(string) { |
|
1476 return string.replace(ZWNBSPRegExp, ''); |
|
1200 } |
1477 } |
1201 /** |
1478 /** |
1202 * Creates a Rich Text value from a DOM element and range. |
1479 * Creates a Rich Text value from a DOM element and range. |
1203 * |
1480 * |
1204 * @param {Object} $1 Named argements. |
1481 * @param {Object} $1 Named argements. |
1206 * @param {?Range} $1.range Range to create value from. |
1483 * @param {?Range} $1.range Range to create value from. |
1207 * @param {?string} $1.multilineTag Multiline tag if the structure is |
1484 * @param {?string} $1.multilineTag Multiline tag if the structure is |
1208 * multiline. |
1485 * multiline. |
1209 * @param {?Array} $1.multilineWrapperTags Tags where lines can be found if |
1486 * @param {?Array} $1.multilineWrapperTags Tags where lines can be found if |
1210 * nesting is possible. |
1487 * nesting is possible. |
1488 * @param {?boolean} $1.preserveWhiteSpace Whether or not to collapse white |
|
1489 * space characters. |
|
1211 * |
1490 * |
1212 * @return {Object} A rich text value. |
1491 * @return {Object} A rich text value. |
1213 */ |
1492 */ |
1214 |
1493 |
1215 |
1494 |
1218 range = _ref3.range, |
1497 range = _ref3.range, |
1219 multilineTag = _ref3.multilineTag, |
1498 multilineTag = _ref3.multilineTag, |
1220 multilineWrapperTags = _ref3.multilineWrapperTags, |
1499 multilineWrapperTags = _ref3.multilineWrapperTags, |
1221 _ref3$currentWrapperT = _ref3.currentWrapperTags, |
1500 _ref3$currentWrapperT = _ref3.currentWrapperTags, |
1222 currentWrapperTags = _ref3$currentWrapperT === void 0 ? [] : _ref3$currentWrapperT, |
1501 currentWrapperTags = _ref3$currentWrapperT === void 0 ? [] : _ref3$currentWrapperT, |
1223 isEditableTree = _ref3.isEditableTree; |
1502 isEditableTree = _ref3.isEditableTree, |
1503 preserveWhiteSpace = _ref3.preserveWhiteSpace; |
|
1224 var accumulator = createEmptyValue(); |
1504 var accumulator = createEmptyValue(); |
1225 |
1505 |
1226 if (!element) { |
1506 if (!element) { |
1227 return accumulator; |
1507 return accumulator; |
1228 } |
1508 } |
1236 |
1516 |
1237 var _loop = function _loop(index) { |
1517 var _loop = function _loop(index) { |
1238 var node = element.childNodes[index]; |
1518 var node = element.childNodes[index]; |
1239 var type = node.nodeName.toLowerCase(); |
1519 var type = node.nodeName.toLowerCase(); |
1240 |
1520 |
1241 if (node.nodeType === TEXT_NODE) { |
1521 if (node.nodeType === node.TEXT_NODE) { |
1242 var text = filterString(node.nodeValue); |
1522 var filter = removePadding; |
1243 range = filterRange(node, range, filterString); |
1523 |
1524 if (!preserveWhiteSpace) { |
|
1525 filter = function filter(string) { |
|
1526 return removePadding(collapseWhiteSpace(string)); |
|
1527 }; |
|
1528 } |
|
1529 |
|
1530 var text = filter(node.nodeValue); |
|
1531 range = filterRange(node, range, filter); |
|
1244 accumulateSelection(accumulator, node, range, { |
1532 accumulateSelection(accumulator, node, range, { |
1245 text: text |
1533 text: text |
1246 }); // Create a sparse array of the same length as `text`, in which |
1534 }); // Create a sparse array of the same length as `text`, in which |
1247 // formats can be added. |
1535 // formats can be added. |
1248 |
1536 |
1250 accumulator.replacements.length += text.length; |
1538 accumulator.replacements.length += text.length; |
1251 accumulator.text += text; |
1539 accumulator.text += text; |
1252 return "continue"; |
1540 return "continue"; |
1253 } |
1541 } |
1254 |
1542 |
1255 if (node.nodeType !== ELEMENT_NODE) { |
1543 if (node.nodeType !== node.ELEMENT_NODE) { |
1256 return "continue"; |
1544 return "continue"; |
1257 } |
1545 } |
1258 |
1546 |
1259 if (node.getAttribute('data-rich-text-padding') || isEditableTree && type === 'br' && !node.getAttribute('data-rich-text-line-break')) { |
1547 if (isEditableTree && ( // Ignore any placeholders. |
1548 node.getAttribute('data-rich-text-placeholder') || // Ignore any line breaks that are not inserted by us. |
|
1549 type === 'br' && !node.getAttribute('data-rich-text-line-break'))) { |
|
1260 accumulateSelection(accumulator, node, range, createEmptyValue()); |
1550 accumulateSelection(accumulator, node, range, createEmptyValue()); |
1261 return "continue"; |
1551 return "continue"; |
1262 } |
1552 } |
1263 |
1553 |
1264 if (type === 'br') { |
1554 if (type === 'br') { |
1284 element: node, |
1574 element: node, |
1285 range: range, |
1575 range: range, |
1286 multilineTag: multilineTag, |
1576 multilineTag: multilineTag, |
1287 multilineWrapperTags: multilineWrapperTags, |
1577 multilineWrapperTags: multilineWrapperTags, |
1288 currentWrapperTags: [].concat(Object(toConsumableArray["a" /* default */])(currentWrapperTags), [format]), |
1578 currentWrapperTags: [].concat(Object(toConsumableArray["a" /* default */])(currentWrapperTags), [format]), |
1289 isEditableTree: isEditableTree |
1579 isEditableTree: isEditableTree, |
1580 preserveWhiteSpace: preserveWhiteSpace |
|
1290 }); |
1581 }); |
1291 |
1582 |
1292 accumulateSelection(accumulator, node, range, _value); |
1583 accumulateSelection(accumulator, node, range, _value); |
1293 mergePair(accumulator, _value); |
1584 mergePair(accumulator, _value); |
1294 return "continue"; |
1585 return "continue"; |
1297 var value = createFromElement({ |
1588 var value = createFromElement({ |
1298 element: node, |
1589 element: node, |
1299 range: range, |
1590 range: range, |
1300 multilineTag: multilineTag, |
1591 multilineTag: multilineTag, |
1301 multilineWrapperTags: multilineWrapperTags, |
1592 multilineWrapperTags: multilineWrapperTags, |
1302 isEditableTree: isEditableTree |
1593 isEditableTree: isEditableTree, |
1594 preserveWhiteSpace: preserveWhiteSpace |
|
1303 }); |
1595 }); |
1304 accumulateSelection(accumulator, node, range, value); |
1596 accumulateSelection(accumulator, node, range, value); |
1305 |
1597 |
1306 if (!format) { |
1598 if (!format) { |
1307 mergePair(accumulator, value); |
1599 mergePair(accumulator, value); |
1312 replacements: [format], |
1604 replacements: [format], |
1313 text: OBJECT_REPLACEMENT_CHARACTER |
1605 text: OBJECT_REPLACEMENT_CHARACTER |
1314 }); |
1606 }); |
1315 } |
1607 } |
1316 } else { |
1608 } else { |
1317 mergePair(accumulator, Object(objectSpread["a" /* default */])({}, value, { |
1609 // Indices should share a reference to the same formats array. |
1318 formats: Array.from(value.formats, function (formats) { |
1610 // Only create a new reference if `formats` changes. |
1319 return formats ? [format].concat(Object(toConsumableArray["a" /* default */])(formats)) : [format]; |
1611 function mergeFormats(formats) { |
1320 }) |
1612 if (mergeFormats.formats === formats) { |
1613 return mergeFormats.newFormats; |
|
1614 } |
|
1615 |
|
1616 var newFormats = formats ? [format].concat(Object(toConsumableArray["a" /* default */])(formats)) : [format]; |
|
1617 mergeFormats.formats = formats; |
|
1618 mergeFormats.newFormats = newFormats; |
|
1619 return newFormats; |
|
1620 } // Since the formats parameter can be `undefined`, preset |
|
1621 // `mergeFormats` with a new reference. |
|
1622 |
|
1623 |
|
1624 mergeFormats.newFormats = [format]; |
|
1625 mergePair(accumulator, create_objectSpread({}, value, { |
|
1626 formats: Array.from(value.formats, mergeFormats) |
|
1321 })); |
1627 })); |
1322 } |
1628 } |
1323 }; |
1629 }; |
1324 |
1630 |
1325 for (var index = 0; index < length; index++) { |
1631 for (var index = 0; index < length; index++) { |
1332 } |
1638 } |
1333 /** |
1639 /** |
1334 * Creates a rich text value from a DOM element and range that should be |
1640 * Creates a rich text value from a DOM element and range that should be |
1335 * multiline. |
1641 * multiline. |
1336 * |
1642 * |
1337 * @param {Object} $1 Named argements. |
1643 * @param {Object} $1 Named argements. |
1338 * @param {?Element} $1.element Element to create value from. |
1644 * @param {?Element} $1.element Element to create value from. |
1339 * @param {?Range} $1.range Range to create value from. |
1645 * @param {?Range} $1.range Range to create value from. |
1340 * @param {?string} $1.multilineTag Multiline tag if the structure is |
1646 * @param {?string} $1.multilineTag Multiline tag if the structure is |
1341 * multiline. |
1647 * multiline. |
1342 * @param {?Array} $1.multilineWrapperTags Tags where lines can be found if |
1648 * @param {?Array} $1.multilineWrapperTags Tags where lines can be found if |
1343 * nesting is possible. |
1649 * nesting is possible. |
1344 * @param {boolean} $1.currentWrapperTags Whether to prepend a line |
1650 * @param {boolean} $1.currentWrapperTags Whether to prepend a line |
1345 * separator. |
1651 * separator. |
1652 * @param {?boolean} $1.preserveWhiteSpace Whether or not to collapse white |
|
1653 * space characters. |
|
1346 * |
1654 * |
1347 * @return {Object} A rich text value. |
1655 * @return {Object} A rich text value. |
1348 */ |
1656 */ |
1349 |
1657 |
1350 |
1658 |
1353 range = _ref4.range, |
1661 range = _ref4.range, |
1354 multilineTag = _ref4.multilineTag, |
1662 multilineTag = _ref4.multilineTag, |
1355 multilineWrapperTags = _ref4.multilineWrapperTags, |
1663 multilineWrapperTags = _ref4.multilineWrapperTags, |
1356 _ref4$currentWrapperT = _ref4.currentWrapperTags, |
1664 _ref4$currentWrapperT = _ref4.currentWrapperTags, |
1357 currentWrapperTags = _ref4$currentWrapperT === void 0 ? [] : _ref4$currentWrapperT, |
1665 currentWrapperTags = _ref4$currentWrapperT === void 0 ? [] : _ref4$currentWrapperT, |
1358 isEditableTree = _ref4.isEditableTree; |
1666 isEditableTree = _ref4.isEditableTree, |
1667 preserveWhiteSpace = _ref4.preserveWhiteSpace; |
|
1359 var accumulator = createEmptyValue(); |
1668 var accumulator = createEmptyValue(); |
1360 |
1669 |
1361 if (!element || !element.hasChildNodes()) { |
1670 if (!element || !element.hasChildNodes()) { |
1362 return accumulator; |
1671 return accumulator; |
1363 } |
1672 } |
1375 element: node, |
1684 element: node, |
1376 range: range, |
1685 range: range, |
1377 multilineTag: multilineTag, |
1686 multilineTag: multilineTag, |
1378 multilineWrapperTags: multilineWrapperTags, |
1687 multilineWrapperTags: multilineWrapperTags, |
1379 currentWrapperTags: currentWrapperTags, |
1688 currentWrapperTags: currentWrapperTags, |
1380 isEditableTree: isEditableTree |
1689 isEditableTree: isEditableTree, |
1690 preserveWhiteSpace: preserveWhiteSpace |
|
1381 }); // Multiline value text should be separated by a line separator. |
1691 }); // Multiline value text should be separated by a line separator. |
1382 |
1692 |
1383 if (index !== 0 || currentWrapperTags.length > 0) { |
1693 if (index !== 0 || currentWrapperTags.length > 0) { |
1384 mergePair(accumulator, { |
1694 mergePair(accumulator, { |
1385 formats: [,], |
1695 formats: [,], |
1472 |
1782 |
1473 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-active-formats.js |
1783 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-active-formats.js |
1474 /** |
1784 /** |
1475 * Gets the all format objects at the start of the selection. |
1785 * Gets the all format objects at the start of the selection. |
1476 * |
1786 * |
1477 * @param {Object} value Value to inspect. |
1787 * @param {Object} value Value to inspect. |
1788 * @param {Array<Array>} value.formats Formats object data values. |
|
1789 * @param {number} value.start Index to start from. |
|
1790 * @param {number} value.end Index to end. |
|
1791 * @param {Array} value.activeFormats Array to return if there are active formats. |
|
1792 * @param {Array} EMPTY_ACTIVE_FORMATS Array to return if there are no active |
|
1793 * formats. |
|
1478 * |
1794 * |
1479 * @return {?Object} Active format objects. |
1795 * @return {?Object} Active format objects. |
1480 */ |
1796 */ |
1481 function getActiveFormats(_ref) { |
1797 function getActiveFormats(_ref) { |
1482 var formats = _ref.formats, |
1798 var formats = _ref.formats, |
1483 start = _ref.start, |
1799 start = _ref.start, |
1484 end = _ref.end, |
1800 end = _ref.end, |
1485 activeFormats = _ref.activeFormats; |
1801 activeFormats = _ref.activeFormats; |
1802 var EMPTY_ACTIVE_FORMATS = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; |
|
1486 |
1803 |
1487 if (start === undefined) { |
1804 if (start === undefined) { |
1488 return []; |
1805 return EMPTY_ACTIVE_FORMATS; |
1489 } |
1806 } |
1490 |
1807 |
1491 if (start === end) { |
1808 if (start === end) { |
1492 // For a collapsed caret, it is possible to override the active formats. |
1809 // For a collapsed caret, it is possible to override the active formats. |
1493 if (activeFormats) { |
1810 if (activeFormats) { |
1494 return activeFormats; |
1811 return activeFormats; |
1495 } |
1812 } |
1496 |
1813 |
1497 var formatsBefore = formats[start - 1] || []; |
1814 var formatsBefore = formats[start - 1] || EMPTY_ACTIVE_FORMATS; |
1498 var formatsAfter = formats[start] || []; // By default, select the lowest amount of formats possible (which means |
1815 var formatsAfter = formats[start] || EMPTY_ACTIVE_FORMATS; // By default, select the lowest amount of formats possible (which means |
1499 // the caret is positioned outside the format boundary). The user can |
1816 // the caret is positioned outside the format boundary). The user can |
1500 // then use arrow keys to define `activeFormats`. |
1817 // then use arrow keys to define `activeFormats`. |
1501 |
1818 |
1502 if (formatsBefore.length < formatsAfter.length) { |
1819 if (formatsBefore.length < formatsAfter.length) { |
1503 return formatsBefore; |
1820 return formatsBefore; |
1504 } |
1821 } |
1505 |
1822 |
1506 return formatsAfter; |
1823 return formatsAfter; |
1507 } |
1824 } |
1508 |
1825 |
1509 return formats[start] || []; |
1826 return formats[start] || EMPTY_ACTIVE_FORMATS; |
1510 } |
1827 } |
1511 |
1828 |
1512 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-active-format.js |
1829 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-active-format.js |
1513 /** |
1830 /** |
1514 * External dependencies |
1831 * External dependencies |
1530 * |
1847 * |
1531 * @return {Object|undefined} Active format object of the specified type, or undefined. |
1848 * @return {Object|undefined} Active format object of the specified type, or undefined. |
1532 */ |
1849 */ |
1533 |
1850 |
1534 function getActiveFormat(value, formatType) { |
1851 function getActiveFormat(value, formatType) { |
1535 return Object(external_lodash_["find"])(getActiveFormats(value), { |
1852 return Object(external_this_lodash_["find"])(getActiveFormats(value), { |
1536 type: formatType |
1853 type: formatType |
1537 }); |
1854 }); |
1538 } |
1855 } |
1539 |
1856 |
1540 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-active-object.js |
1857 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-active-object.js |
1561 } |
1878 } |
1562 |
1879 |
1563 return replacements[start]; |
1880 return replacements[start]; |
1564 } |
1881 } |
1565 |
1882 |
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 |
1883 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-text-content.js |
1597 /** |
1884 /** |
1598 * Get the textual content of a Rich Text value. This is similar to |
1885 * Get the textual content of a Rich Text value. This is similar to |
1599 * `Element.textContent`. |
1886 * `Element.textContent`. |
1600 * |
1887 * |
1603 * @return {string} The text content. |
1890 * @return {string} The text content. |
1604 */ |
1891 */ |
1605 function getTextContent(_ref) { |
1892 function getTextContent(_ref) { |
1606 var text = _ref.text; |
1893 var text = _ref.text; |
1607 return text; |
1894 return text; |
1895 } |
|
1896 |
|
1897 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-line-index.js |
|
1898 /** |
|
1899 * Internal dependencies |
|
1900 */ |
|
1901 |
|
1902 /** |
|
1903 * Gets the currently selected line index, or the first line index if the |
|
1904 * selection spans over multiple items. |
|
1905 * |
|
1906 * @param {Object} value Value to get the line index from. |
|
1907 * @param {boolean} startIndex Optional index that should be contained by the |
|
1908 * line. Defaults to the selection start of the |
|
1909 * value. |
|
1910 * |
|
1911 * @return {?boolean} The line index. Undefined if not found. |
|
1912 */ |
|
1913 |
|
1914 function getLineIndex(_ref) { |
|
1915 var start = _ref.start, |
|
1916 text = _ref.text; |
|
1917 var startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : start; |
|
1918 var index = startIndex; |
|
1919 |
|
1920 while (index--) { |
|
1921 if (text[index] === LINE_SEPARATOR) { |
|
1922 return index; |
|
1923 } |
|
1924 } |
|
1925 } |
|
1926 |
|
1927 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-list-root-selected.js |
|
1928 /** |
|
1929 * Internal dependencies |
|
1930 */ |
|
1931 |
|
1932 /** |
|
1933 * Whether or not the root list is selected. |
|
1934 * |
|
1935 * @param {Object} value The value to check. |
|
1936 * |
|
1937 * @return {boolean} True if the root list or nothing is selected, false if an |
|
1938 * inner list is selected. |
|
1939 */ |
|
1940 |
|
1941 function isListRootSelected(value) { |
|
1942 var replacements = value.replacements, |
|
1943 start = value.start; |
|
1944 var lineIndex = getLineIndex(value, start); |
|
1945 var replacement = replacements[lineIndex]; |
|
1946 return !replacement || replacement.length < 1; |
|
1947 } |
|
1948 |
|
1949 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-active-list-type.js |
|
1950 /** |
|
1951 * Internal dependencies |
|
1952 */ |
|
1953 |
|
1954 /** |
|
1955 * Wether or not the selected list has the given tag name. |
|
1956 * |
|
1957 * @param {Object} value The value to check. |
|
1958 * @param {string} type The tag name the list should have. |
|
1959 * @param {string} rootType The current root tag name, to compare with in case |
|
1960 * nothing is selected. |
|
1961 * |
|
1962 * @return {boolean} True if the current list type matches `type`, false if not. |
|
1963 */ |
|
1964 |
|
1965 function isActiveListType(value, type, rootType) { |
|
1966 var replacements = value.replacements, |
|
1967 start = value.start; |
|
1968 var lineIndex = getLineIndex(value, start); |
|
1969 var replacement = replacements[lineIndex]; |
|
1970 |
|
1971 if (!replacement || replacement.length === 0) { |
|
1972 return type === rootType; |
|
1973 } |
|
1974 |
|
1975 var lastFormat = replacement[replacement.length - 1]; |
|
1976 return lastFormat.type === type; |
|
1608 } |
1977 } |
1609 |
1978 |
1610 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-collapsed.js |
1979 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/is-collapsed.js |
1611 /** |
1980 /** |
1612 * Check if the selection of a Rich Text value is collapsed or not. Collapsed |
1981 * Check if the selection of a Rich Text value is collapsed or not. Collapsed |
1717 text: accumlator.text + separator.text + text |
2086 text: accumlator.text + separator.text + text |
1718 }; |
2087 }; |
1719 })); |
2088 })); |
1720 } |
2089 } |
1721 |
2090 |
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 |
2091 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/register-format-type.js |
1742 |
2092 |
1743 |
2093 |
1744 |
2094 function register_format_type_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
1745 |
2095 |
1746 |
2096 function register_format_type_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { register_format_type_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { register_format_type_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
1747 |
|
1748 /** |
|
1749 * External dependencies |
|
1750 */ |
|
1751 |
|
1752 |
2097 |
1753 /** |
2098 /** |
1754 * WordPress dependencies |
2099 * WordPress dependencies |
1755 */ |
2100 */ |
1756 |
2101 |
1757 |
2102 /** |
1758 |
2103 * @typedef {Object} WPFormat |
1759 |
2104 * |
1760 /** |
2105 * @property {string} name A string identifying the format. Must be |
1761 * Shared reference to an empty array for cases where it is important to avoid |
2106 * unique across all registered formats. |
1762 * returning a new array reference on every invocation, as in a connected or |
2107 * @property {string} tagName The HTML tag this format will wrap the |
1763 * other pure component which performs `shouldComponentUpdate` check on props. |
2108 * selection with. |
1764 * This should be used as a last resort, since the normalized data should be |
2109 * @property {string} [className] A class to match the format. |
1765 * maintained by the reducer result in state. |
2110 * @property {string} title Name of the format. |
1766 * |
2111 * @property {Function} edit Should return a component for the user to |
1767 * @type {Array} |
2112 * interact with the new registered format. |
1768 */ |
2113 */ |
1769 |
2114 |
1770 var EMPTY_ARRAY = []; |
|
1771 /** |
2115 /** |
1772 * Registers a new format provided a unique name and an object defining its |
2116 * Registers a new format provided a unique name and an object defining its |
1773 * behavior. |
2117 * behavior. |
1774 * |
2118 * |
1775 * @param {string} name Format name. |
2119 * @param {string} name Format name. |
1776 * @param {Object} settings Format settings. |
2120 * @param {WPFormat} 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 * |
2121 * |
1782 * @return {WPFormat|undefined} The format, if it has been successfully registered; |
2122 * @return {WPFormat|undefined} The format, if it has been successfully registered; |
1783 * otherwise `undefined`. |
2123 * otherwise `undefined`. |
1784 */ |
2124 */ |
1785 |
2125 |
1786 function registerFormatType(name, settings) { |
2126 function registerFormatType(name, settings) { |
1787 settings = Object(objectSpread["a" /* default */])({ |
2127 settings = register_format_type_objectSpread({ |
1788 name: name |
2128 name: name |
1789 }, settings); |
2129 }, settings); |
1790 |
2130 |
1791 if (typeof settings.name !== 'string') { |
2131 if (typeof settings.name !== 'string') { |
1792 window.console.error('Format names must be strings.'); |
2132 window.console.error('Format names must be strings.'); |
1848 window.console.error('Format titles must be strings.'); |
2188 window.console.error('Format titles must be strings.'); |
1849 return; |
2189 return; |
1850 } |
2190 } |
1851 |
2191 |
1852 Object(external_this_wp_data_["dispatch"])('core/rich-text').addFormatTypes(settings); |
2192 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; |
2193 return settings; |
1930 } |
2194 } |
1931 |
2195 |
1932 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/remove-format.js |
2196 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/remove-format.js |
1933 |
2197 |
2198 |
|
2199 function remove_format_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
2200 |
|
2201 function remove_format_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { remove_format_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { remove_format_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
1934 |
2202 |
1935 /** |
2203 /** |
1936 * External dependencies |
2204 * External dependencies |
1937 */ |
2205 */ |
1938 |
2206 |
1961 activeFormats = value.activeFormats; |
2229 activeFormats = value.activeFormats; |
1962 var newFormats = formats.slice(); // If the selection is collapsed, expand start and end to the edges of the |
2230 var newFormats = formats.slice(); // If the selection is collapsed, expand start and end to the edges of the |
1963 // format. |
2231 // format. |
1964 |
2232 |
1965 if (startIndex === endIndex) { |
2233 if (startIndex === endIndex) { |
1966 var format = Object(external_lodash_["find"])(newFormats[startIndex], { |
2234 var format = Object(external_this_lodash_["find"])(newFormats[startIndex], { |
1967 type: formatType |
2235 type: formatType |
1968 }); |
2236 }); |
1969 |
2237 |
1970 if (format) { |
2238 if (format) { |
1971 while (Object(external_lodash_["find"])(newFormats[startIndex], format)) { |
2239 while (Object(external_this_lodash_["find"])(newFormats[startIndex], format)) { |
1972 filterFormats(newFormats, startIndex, formatType); |
2240 filterFormats(newFormats, startIndex, formatType); |
1973 startIndex--; |
2241 startIndex--; |
1974 } |
2242 } |
1975 |
2243 |
1976 endIndex++; |
2244 endIndex++; |
1977 |
2245 |
1978 while (Object(external_lodash_["find"])(newFormats[endIndex], format)) { |
2246 while (Object(external_this_lodash_["find"])(newFormats[endIndex], format)) { |
1979 filterFormats(newFormats, endIndex, formatType); |
2247 filterFormats(newFormats, endIndex, formatType); |
1980 endIndex++; |
2248 endIndex++; |
1981 } |
2249 } |
1982 } |
2250 } |
1983 } else { |
2251 } else { |
1986 filterFormats(newFormats, i, formatType); |
2254 filterFormats(newFormats, i, formatType); |
1987 } |
2255 } |
1988 } |
2256 } |
1989 } |
2257 } |
1990 |
2258 |
1991 return normaliseFormats(Object(objectSpread["a" /* default */])({}, value, { |
2259 return normaliseFormats(remove_format_objectSpread({}, value, { |
1992 formats: newFormats, |
2260 formats: newFormats, |
1993 activeFormats: Object(external_lodash_["reject"])(activeFormats, { |
2261 activeFormats: Object(external_this_lodash_["reject"])(activeFormats, { |
1994 type: formatType |
2262 type: formatType |
1995 }) |
2263 }) |
1996 })); |
2264 })); |
1997 } |
2265 } |
1998 |
2266 |
2095 * the specified function. |
2363 * the specified function. |
2096 * |
2364 * |
2097 * @return {Object} A new value with replacements applied. |
2365 * @return {Object} A new value with replacements applied. |
2098 */ |
2366 */ |
2099 |
2367 |
2100 function replace(_ref, pattern, replacement) { |
2368 function replace_replace(_ref, pattern, replacement) { |
2101 var formats = _ref.formats, |
2369 var formats = _ref.formats, |
2102 replacements = _ref.replacements, |
2370 replacements = _ref.replacements, |
2103 text = _ref.text, |
2371 text = _ref.text, |
2104 start = _ref.start, |
2372 start = _ref.start, |
2105 end = _ref.end; |
2373 end = _ref.end; |
2146 start: start, |
2414 start: start, |
2147 end: end |
2415 end: end |
2148 }); |
2416 }); |
2149 } |
2417 } |
2150 |
2418 |
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 |
2419 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/insert-line-separator.js |
2169 /** |
2420 /** |
2170 * Internal dependencies |
2421 * Internal dependencies |
2171 */ |
2422 */ |
2172 |
2423 |
2202 text: LINE_SEPARATOR |
2453 text: LINE_SEPARATOR |
2203 }; |
2454 }; |
2204 return insert(value, valueToInsert, startIndex, endIndex); |
2455 return insert(value, valueToInsert, startIndex, endIndex); |
2205 } |
2456 } |
2206 |
2457 |
2458 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/remove-line-separator.js |
|
2459 |
|
2460 |
|
2461 function remove_line_separator_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
2462 |
|
2463 function remove_line_separator_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { remove_line_separator_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { remove_line_separator_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
2464 |
|
2465 /** |
|
2466 * Internal dependencies |
|
2467 */ |
|
2468 |
|
2469 |
|
2470 |
|
2471 /** |
|
2472 * Removes a line separator character, if existing, from a Rich Text value at the current |
|
2473 * indices. If no line separator exists on the indices it will return undefined. |
|
2474 * |
|
2475 * @param {Object} value Value to modify. |
|
2476 * @param {boolean} backward indicates if are removing from the start index or the end index. |
|
2477 * |
|
2478 * @return {Object|undefined} A new value with the line separator removed. Or undefined if no line separator is found on the position. |
|
2479 */ |
|
2480 |
|
2481 function removeLineSeparator(value) { |
|
2482 var backward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; |
|
2483 var replacements = value.replacements, |
|
2484 text = value.text, |
|
2485 start = value.start, |
|
2486 end = value.end; |
|
2487 var collapsed = isCollapsed(value); |
|
2488 var index = start - 1; |
|
2489 var removeStart = collapsed ? start - 1 : start; |
|
2490 var removeEnd = end; |
|
2491 |
|
2492 if (!backward) { |
|
2493 index = end; |
|
2494 removeStart = start; |
|
2495 removeEnd = collapsed ? end + 1 : end; |
|
2496 } |
|
2497 |
|
2498 if (text[index] !== LINE_SEPARATOR) { |
|
2499 return; |
|
2500 } |
|
2501 |
|
2502 var newValue; // If the line separator that is about te be removed |
|
2503 // contains wrappers, remove the wrappers first. |
|
2504 |
|
2505 if (collapsed && replacements[index] && replacements[index].length) { |
|
2506 var newReplacements = replacements.slice(); |
|
2507 newReplacements[index] = replacements[index].slice(0, -1); |
|
2508 newValue = remove_line_separator_objectSpread({}, value, { |
|
2509 replacements: newReplacements |
|
2510 }); |
|
2511 } else { |
|
2512 newValue = remove_remove(value, removeStart, removeEnd); |
|
2513 } |
|
2514 |
|
2515 return newValue; |
|
2516 } |
|
2517 |
|
2207 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/insert-object.js |
2518 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/insert-object.js |
2208 /** |
2519 /** |
2209 * Internal dependencies |
2520 * Internal dependencies |
2210 */ |
2521 */ |
2211 |
2522 |
2233 } |
2544 } |
2234 |
2545 |
2235 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/slice.js |
2546 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/slice.js |
2236 |
2547 |
2237 |
2548 |
2549 function slice_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
2550 |
|
2551 function slice_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { slice_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { slice_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
2552 |
|
2238 /** |
2553 /** |
2239 * Slice a Rich Text value from `startIndex` to `endIndex`. Indices are |
2554 * Slice a Rich Text value from `startIndex` to `endIndex`. Indices are |
2240 * retrieved from the selection if none are provided. This is similar to |
2555 * retrieved from the selection if none are provided. This is similar to |
2241 * `String.prototype.slice`. |
2556 * `String.prototype.slice`. |
2242 * |
2557 * |
2252 var formats = value.formats, |
2567 var formats = value.formats, |
2253 replacements = value.replacements, |
2568 replacements = value.replacements, |
2254 text = value.text; |
2569 text = value.text; |
2255 |
2570 |
2256 if (startIndex === undefined || endIndex === undefined) { |
2571 if (startIndex === undefined || endIndex === undefined) { |
2257 return Object(objectSpread["a" /* default */])({}, value); |
2572 return slice_objectSpread({}, value); |
2258 } |
2573 } |
2259 |
2574 |
2260 return { |
2575 return { |
2261 formats: formats.slice(startIndex, endIndex), |
2576 formats: formats.slice(startIndex, endIndex), |
2262 replacements: replacements.slice(startIndex, endIndex), |
2577 replacements: replacements.slice(startIndex, endIndex), |
2272 /** |
2587 /** |
2273 * Split a Rich Text value in two at the given `startIndex` and `endIndex`, or |
2588 * 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`. |
2589 * split at the given separator. This is similar to `String.prototype.split`. |
2275 * Indices are retrieved from the selection if none are provided. |
2590 * Indices are retrieved from the selection if none are provided. |
2276 * |
2591 * |
2277 * @param {Object} value Value to modify. |
2592 * @param {Object} value |
2593 * @param {Object[]} value.formats |
|
2594 * @param {Object[]} value.replacements |
|
2595 * @param {string} value.text |
|
2596 * @param {number} value.start |
|
2597 * @param {number} value.end |
|
2278 * @param {number|string} [string] Start index, or string at which to split. |
2598 * @param {number|string} [string] Start index, or string at which to split. |
2279 * @param {number} [endStr] End index. |
|
2280 * |
2599 * |
2281 * @return {Array} An array of new values. |
2600 * @return {Array} An array of new values. |
2282 */ |
2601 */ |
2283 |
2602 |
2284 function split(_ref, string) { |
2603 function split(_ref, string) { |
2339 text: text.slice(endIndex), |
2658 text: text.slice(endIndex), |
2340 start: 0, |
2659 start: 0, |
2341 end: 0 |
2660 end: 0 |
2342 }; |
2661 }; |
2343 return [// Ensure newlines are trimmed. |
2662 return [// Ensure newlines are trimmed. |
2344 replace(before, /\u2028+$/, ''), replace(after, /^\u2028+/, '')]; |
2663 replace_replace(before, /\u2028+$/, ''), replace_replace(after, /^\u2028+/, '')]; |
2345 } |
2664 } |
2346 |
2665 |
2347 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-format-type.js |
2666 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-format-type.js |
2348 /** |
2667 /** |
2349 * WordPress dependencies |
2668 * WordPress dependencies |
2362 } |
2681 } |
2363 |
2682 |
2364 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/to-tree.js |
2683 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/to-tree.js |
2365 |
2684 |
2366 |
2685 |
2686 |
|
2687 function to_tree_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
2688 |
|
2689 function to_tree_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { to_tree_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { to_tree_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
2367 |
2690 |
2368 /** |
2691 /** |
2369 * Internal dependencies |
2692 * Internal dependencies |
2370 */ |
2693 */ |
2371 |
2694 |
2401 elementAttributes['data-rich-text-format-boundary'] = 'true'; |
2724 elementAttributes['data-rich-text-format-boundary'] = 'true'; |
2402 } |
2725 } |
2403 |
2726 |
2404 if (!formatType) { |
2727 if (!formatType) { |
2405 if (attributes) { |
2728 if (attributes) { |
2406 elementAttributes = Object(objectSpread["a" /* default */])({}, attributes, elementAttributes); |
2729 elementAttributes = to_tree_objectSpread({}, attributes, {}, elementAttributes); |
2407 } |
2730 } |
2408 |
2731 |
2409 return { |
2732 return { |
2410 type: type, |
2733 type: type, |
2411 attributes: elementAttributes, |
2734 attributes: elementAttributes, |
2412 object: object |
2735 object: object |
2413 }; |
2736 }; |
2414 } |
2737 } |
2415 |
2738 |
2416 elementAttributes = Object(objectSpread["a" /* default */])({}, unregisteredAttributes, elementAttributes); |
2739 elementAttributes = to_tree_objectSpread({}, unregisteredAttributes, {}, elementAttributes); |
2417 |
2740 |
2418 for (var name in attributes) { |
2741 for (var name in attributes) { |
2419 var key = formatType.attributes ? formatType.attributes[name] : false; |
2742 var key = formatType.attributes ? formatType.attributes[name] : false; |
2420 |
2743 |
2421 if (key) { |
2744 if (key) { |
2437 type: formatType.tagName, |
2760 type: formatType.tagName, |
2438 object: formatType.object, |
2761 object: formatType.object, |
2439 attributes: elementAttributes |
2762 attributes: elementAttributes |
2440 }; |
2763 }; |
2441 } |
2764 } |
2442 |
2765 /** |
2443 var padding = { |
2766 * Checks if both arrays of formats up until a certain index are equal. |
2444 type: 'br', |
2767 * |
2445 attributes: { |
2768 * @param {Array} a Array of formats to compare. |
2446 'data-rich-text-padding': 'true' |
2769 * @param {Array} b Array of formats to compare. |
2447 }, |
2770 * @param {number} index Index to check until. |
2448 object: true |
2771 */ |
2449 }; |
2772 |
2773 |
|
2774 function isEqualUntil(a, b, index) { |
|
2775 do { |
|
2776 if (a[index] !== b[index]) { |
|
2777 return false; |
|
2778 } |
|
2779 } while (index--); |
|
2780 |
|
2781 return true; |
|
2782 } |
|
2783 |
|
2450 function toTree(_ref2) { |
2784 function toTree(_ref2) { |
2451 var value = _ref2.value, |
2785 var value = _ref2.value, |
2452 multilineTag = _ref2.multilineTag, |
2786 multilineTag = _ref2.multilineTag, |
2787 preserveWhiteSpace = _ref2.preserveWhiteSpace, |
|
2453 createEmpty = _ref2.createEmpty, |
2788 createEmpty = _ref2.createEmpty, |
2454 append = _ref2.append, |
2789 append = _ref2.append, |
2455 getLastChild = _ref2.getLastChild, |
2790 getLastChild = _ref2.getLastChild, |
2456 getParent = _ref2.getParent, |
2791 getParent = _ref2.getParent, |
2457 isText = _ref2.isText, |
2792 isText = _ref2.isText, |
2458 getText = _ref2.getText, |
2793 getText = _ref2.getText, |
2459 remove = _ref2.remove, |
2794 remove = _ref2.remove, |
2460 appendText = _ref2.appendText, |
2795 appendText = _ref2.appendText, |
2461 onStartIndex = _ref2.onStartIndex, |
2796 onStartIndex = _ref2.onStartIndex, |
2462 onEndIndex = _ref2.onEndIndex, |
2797 onEndIndex = _ref2.onEndIndex, |
2463 isEditableTree = _ref2.isEditableTree; |
2798 isEditableTree = _ref2.isEditableTree, |
2799 placeholder = _ref2.placeholder; |
|
2464 var formats = value.formats, |
2800 var formats = value.formats, |
2465 replacements = value.replacements, |
2801 replacements = value.replacements, |
2466 text = value.text, |
2802 text = value.text, |
2467 start = value.start, |
2803 start = value.start, |
2468 end = value.end; |
2804 end = value.end; |
2512 |
2848 |
2513 while (!isText(node)) { |
2849 while (!isText(node)) { |
2514 node = getLastChild(node); |
2850 node = getLastChild(node); |
2515 } |
2851 } |
2516 |
2852 |
2517 append(getParent(node), padding); |
2853 append(getParent(node), ZWNBSP); |
2518 append(getParent(node), ''); |
|
2519 } // Set selection for the start of line. |
2854 } // Set selection for the start of line. |
2520 |
2855 |
2521 |
2856 |
2522 if (lastCharacter === LINE_SEPARATOR) { |
2857 if (lastCharacter === LINE_SEPARATOR) { |
2523 var _node = pointer; |
2858 var _node = pointer; |
2535 } |
2870 } |
2536 } |
2871 } |
2537 |
2872 |
2538 if (characterFormats) { |
2873 if (characterFormats) { |
2539 characterFormats.forEach(function (format, formatIndex) { |
2874 characterFormats.forEach(function (format, formatIndex) { |
2540 if (pointer && lastCharacterFormats && format === lastCharacterFormats[formatIndex] && ( // Do not reuse the last element if the character is a |
2875 if (pointer && lastCharacterFormats && // Reuse the last element if all formats remain the same. |
2876 isEqualUntil(characterFormats, lastCharacterFormats, formatIndex) && ( // Do not reuse the last element if the character is a |
|
2541 // line separator. |
2877 // line separator. |
2542 character !== LINE_SEPARATOR || characterFormats.length - 1 !== formatIndex)) { |
2878 character !== LINE_SEPARATOR || characterFormats.length - 1 !== formatIndex)) { |
2543 pointer = getLastChild(pointer); |
2879 pointer = getLastChild(pointer); |
2544 return; |
2880 return; |
2545 } |
2881 } |
2581 onEndIndex(tree, pointer); |
2917 onEndIndex(tree, pointer); |
2582 } |
2918 } |
2583 } |
2919 } |
2584 |
2920 |
2585 if (character === OBJECT_REPLACEMENT_CHARACTER) { |
2921 if (character === OBJECT_REPLACEMENT_CHARACTER) { |
2586 pointer = append(getParent(pointer), fromFormat(Object(objectSpread["a" /* default */])({}, replacements[i], { |
2922 pointer = append(getParent(pointer), fromFormat(to_tree_objectSpread({}, replacements[i], { |
2587 object: true |
2923 object: true |
2588 }))); // Ensure pointer is text node. |
2924 }))); // Ensure pointer is text node. |
2589 |
2925 |
2590 pointer = append(getParent(pointer), ''); |
2926 pointer = append(getParent(pointer), ''); |
2591 } else if (character === '\n') { |
2927 } else if (!preserveWhiteSpace && character === '\n') { |
2592 pointer = append(getParent(pointer), { |
2928 pointer = append(getParent(pointer), { |
2593 type: 'br', |
2929 type: 'br', |
2594 attributes: isEditableTree ? { |
2930 attributes: isEditableTree ? { |
2595 'data-rich-text-line-break': 'true' |
2931 'data-rich-text-line-break': 'true' |
2596 } : undefined, |
2932 } : undefined, |
2611 if (onEndIndex && end === i + 1) { |
2947 if (onEndIndex && end === i + 1) { |
2612 onEndIndex(tree, pointer); |
2948 onEndIndex(tree, pointer); |
2613 } |
2949 } |
2614 |
2950 |
2615 if (shouldInsertPadding && i === text.length) { |
2951 if (shouldInsertPadding && i === text.length) { |
2616 append(getParent(pointer), padding); |
2952 append(getParent(pointer), ZWNBSP); |
2953 |
|
2954 if (placeholder && text.length === 0) { |
|
2955 append(getParent(pointer), { |
|
2956 type: 'span', |
|
2957 attributes: { |
|
2958 'data-rich-text-placeholder': placeholder, |
|
2959 // Necessary to prevent the placeholder from catching |
|
2960 // selection. The placeholder is also not editable after |
|
2961 // all. |
|
2962 contenteditable: 'false' |
|
2963 } |
|
2964 }); |
|
2965 } |
|
2617 } |
2966 } |
2618 |
2967 |
2619 lastCharacterFormats = characterFormats; |
2968 lastCharacterFormats = characterFormats; |
2620 lastCharacter = character; |
2969 lastCharacter = character; |
2621 }; |
2970 }; |
2631 |
2980 |
2632 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/to-dom.js |
2981 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/to-dom.js |
2633 |
2982 |
2634 |
2983 |
2635 |
2984 |
2985 function to_dom_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
2986 |
|
2987 function to_dom_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { to_dom_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { to_dom_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
2988 |
|
2636 /** |
2989 /** |
2637 * Internal dependencies |
2990 * Internal dependencies |
2638 */ |
2991 */ |
2639 |
2992 |
2640 |
2993 |
2641 /** |
|
2642 * Browser dependencies |
|
2643 */ |
|
2644 |
|
2645 var to_dom_TEXT_NODE = window.Node.TEXT_NODE; |
|
2646 /** |
2994 /** |
2647 * Creates a path as an array of indices from the given root node to the given |
2995 * Creates a path as an array of indices from the given root node to the given |
2648 * node. |
2996 * node. |
2649 * |
2997 * |
2650 * @param {Node} node Node to find the path of. |
2998 * @param {Node} node Node to find the path of. |
2690 return { |
3038 return { |
2691 node: node, |
3039 node: node, |
2692 offset: path[0] |
3040 offset: path[0] |
2693 }; |
3041 }; |
2694 } |
3042 } |
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 |
3043 |
2711 function to_dom_append(element, child) { |
3044 function to_dom_append(element, child) { |
2712 if (typeof child === 'string') { |
3045 if (typeof child === 'string') { |
2713 child = element.ownerDocument.createTextNode(child); |
3046 child = element.ownerDocument.createTextNode(child); |
2714 } |
3047 } |
2740 function to_dom_getParent(_ref2) { |
3073 function to_dom_getParent(_ref2) { |
2741 var parentNode = _ref2.parentNode; |
3074 var parentNode = _ref2.parentNode; |
2742 return parentNode; |
3075 return parentNode; |
2743 } |
3076 } |
2744 |
3077 |
2745 function to_dom_isText(_ref3) { |
3078 function to_dom_isText(node) { |
2746 var nodeType = _ref3.nodeType; |
3079 return node.nodeType === node.TEXT_NODE; |
2747 return nodeType === to_dom_TEXT_NODE; |
3080 } |
2748 } |
3081 |
2749 |
3082 function to_dom_getText(_ref3) { |
2750 function to_dom_getText(_ref4) { |
3083 var nodeValue = _ref3.nodeValue; |
2751 var nodeValue = _ref4.nodeValue; |
|
2752 return nodeValue; |
3084 return nodeValue; |
2753 } |
3085 } |
2754 |
3086 |
2755 function to_dom_remove(node) { |
3087 function to_dom_remove(node) { |
2756 return node.parentNode.removeChild(node); |
3088 return node.parentNode.removeChild(node); |
2757 } |
3089 } |
2758 |
3090 |
2759 function prepareFormats() { |
3091 function toDom(_ref4) { |
2760 var prepareEditableTree = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
3092 var value = _ref4.value, |
2761 var value = arguments.length > 1 ? arguments[1] : undefined; |
3093 multilineTag = _ref4.multilineTag, |
2762 return prepareEditableTree.reduce(function (accumlator, fn) { |
3094 prepareEditableTree = _ref4.prepareEditableTree, |
2763 return fn(accumlator, value.text); |
3095 _ref4$isEditableTree = _ref4.isEditableTree, |
2764 }, value.formats); |
3096 isEditableTree = _ref4$isEditableTree === void 0 ? true : _ref4$isEditableTree, |
2765 } |
3097 placeholder = _ref4.placeholder, |
2766 |
3098 _ref4$doc = _ref4.doc, |
2767 function toDom(_ref5) { |
3099 doc = _ref4$doc === void 0 ? document : _ref4$doc; |
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 = []; |
3100 var startPath = []; |
2774 var endPath = []; |
3101 var endPath = []; |
3102 |
|
3103 if (prepareEditableTree) { |
|
3104 value = to_dom_objectSpread({}, value, { |
|
3105 formats: prepareEditableTree(value) |
|
3106 }); |
|
3107 } |
|
3108 /** |
|
3109 * Returns a new instance of a DOM tree upon which RichText operations can be |
|
3110 * applied. |
|
3111 * |
|
3112 * Note: The current implementation will return a shared reference, reset on |
|
3113 * each call to `createEmpty`. Therefore, you should not hold a reference to |
|
3114 * the value to operate upon asynchronously, as it may have unexpected results. |
|
3115 * |
|
3116 * @return {Object} RichText tree. |
|
3117 */ |
|
3118 |
|
3119 |
|
3120 var createEmpty = function createEmpty() { |
|
3121 return createElement(doc, ''); |
|
3122 }; |
|
3123 |
|
2775 var tree = toTree({ |
3124 var tree = toTree({ |
2776 value: Object(objectSpread["a" /* default */])({}, value, { |
3125 value: value, |
2777 formats: prepareFormats(prepareEditableTree, value) |
|
2778 }), |
|
2779 multilineTag: multilineTag, |
3126 multilineTag: multilineTag, |
2780 createEmpty: to_dom_createEmpty, |
3127 createEmpty: createEmpty, |
2781 append: to_dom_append, |
3128 append: to_dom_append, |
2782 getLastChild: to_dom_getLastChild, |
3129 getLastChild: to_dom_getLastChild, |
2783 getParent: to_dom_getParent, |
3130 getParent: to_dom_getParent, |
2784 isText: to_dom_isText, |
3131 isText: to_dom_isText, |
2785 getText: to_dom_getText, |
3132 getText: to_dom_getText, |
2789 startPath = createPathToNode(pointer, body, [pointer.nodeValue.length]); |
3136 startPath = createPathToNode(pointer, body, [pointer.nodeValue.length]); |
2790 }, |
3137 }, |
2791 onEndIndex: function onEndIndex(body, pointer) { |
3138 onEndIndex: function onEndIndex(body, pointer) { |
2792 endPath = createPathToNode(pointer, body, [pointer.nodeValue.length]); |
3139 endPath = createPathToNode(pointer, body, [pointer.nodeValue.length]); |
2793 }, |
3140 }, |
2794 isEditableTree: isEditableTree |
3141 isEditableTree: isEditableTree, |
3142 placeholder: placeholder |
|
2795 }); |
3143 }); |
2796 return { |
3144 return { |
2797 body: tree, |
3145 body: tree, |
2798 selection: { |
3146 selection: { |
2799 startPath: startPath, |
3147 startPath: startPath, |
2811 * @param {HTMLElement} $1.current The live root node to apply the element tree to. |
3159 * @param {HTMLElement} $1.current The live root node to apply the element tree to. |
2812 * @param {string} [$1.multilineTag] Multiline tag. |
3160 * @param {string} [$1.multilineTag] Multiline tag. |
2813 * @param {Array} [$1.multilineWrapperTags] Tags where lines can be found if nesting is possible. |
3161 * @param {Array} [$1.multilineWrapperTags] Tags where lines can be found if nesting is possible. |
2814 */ |
3162 */ |
2815 |
3163 |
2816 function apply(_ref6) { |
3164 function apply(_ref5) { |
2817 var value = _ref6.value, |
3165 var value = _ref5.value, |
2818 current = _ref6.current, |
3166 current = _ref5.current, |
2819 multilineTag = _ref6.multilineTag, |
3167 multilineTag = _ref5.multilineTag, |
2820 prepareEditableTree = _ref6.prepareEditableTree, |
3168 prepareEditableTree = _ref5.prepareEditableTree, |
2821 __unstableDomOnly = _ref6.__unstableDomOnly; |
3169 __unstableDomOnly = _ref5.__unstableDomOnly, |
3170 placeholder = _ref5.placeholder; |
|
2822 |
3171 |
2823 // Construct a new element tree in memory. |
3172 // Construct a new element tree in memory. |
2824 var _toDom = toDom({ |
3173 var _toDom = toDom({ |
2825 value: value, |
3174 value: value, |
2826 multilineTag: multilineTag, |
3175 multilineTag: multilineTag, |
2827 prepareEditableTree: prepareEditableTree |
3176 prepareEditableTree: prepareEditableTree, |
3177 placeholder: placeholder, |
|
3178 doc: current.ownerDocument |
|
2828 }), |
3179 }), |
2829 body = _toDom.body, |
3180 body = _toDom.body, |
2830 selection = _toDom.selection; |
3181 selection = _toDom.selection; |
2831 |
3182 |
2832 applyValue(body, current); |
3183 applyValue(body, current); |
2843 var currentChild = current.childNodes[i]; |
3194 var currentChild = current.childNodes[i]; |
2844 |
3195 |
2845 if (!currentChild) { |
3196 if (!currentChild) { |
2846 current.appendChild(futureChild); |
3197 current.appendChild(futureChild); |
2847 } else if (!currentChild.isEqualNode(futureChild)) { |
3198 } else if (!currentChild.isEqualNode(futureChild)) { |
2848 if (currentChild.nodeName !== futureChild.nodeName || currentChild.nodeType === to_dom_TEXT_NODE && currentChild.data !== futureChild.data) { |
3199 if (currentChild.nodeName !== futureChild.nodeName || currentChild.nodeType === currentChild.TEXT_NODE && currentChild.data !== futureChild.data) { |
2849 current.replaceChild(futureChild, currentChild); |
3200 current.replaceChild(futureChild, currentChild); |
2850 } else { |
3201 } else { |
2851 var currentAttributes = currentChild.attributes; |
3202 var currentAttributes = currentChild.attributes; |
2852 var futureAttributes = futureChild.attributes; |
3203 var futureAttributes = futureChild.attributes; |
2853 |
3204 |
2854 if (currentAttributes) { |
3205 if (currentAttributes) { |
2855 for (var ii = 0; ii < currentAttributes.length; ii++) { |
3206 var ii = currentAttributes.length; // Reverse loop because `removeAttribute` on `currentChild` |
3207 // changes `currentAttributes`. |
|
3208 |
|
3209 while (ii--) { |
|
2856 var name = currentAttributes[ii].name; |
3210 var name = currentAttributes[ii].name; |
2857 |
3211 |
2858 if (!futureChild.getAttribute(name)) { |
3212 if (!futureChild.getAttribute(name)) { |
2859 currentChild.removeAttribute(name); |
3213 currentChild.removeAttribute(name); |
2860 } |
3214 } |
2862 } |
3216 } |
2863 |
3217 |
2864 if (futureAttributes) { |
3218 if (futureAttributes) { |
2865 for (var _ii = 0; _ii < futureAttributes.length; _ii++) { |
3219 for (var _ii = 0; _ii < futureAttributes.length; _ii++) { |
2866 var _futureAttributes$_ii = futureAttributes[_ii], |
3220 var _futureAttributes$_ii = futureAttributes[_ii], |
2867 name = _futureAttributes$_ii.name, |
3221 _name = _futureAttributes$_ii.name, |
2868 value = _futureAttributes$_ii.value; |
3222 value = _futureAttributes$_ii.value; |
2869 |
3223 |
2870 if (currentChild.getAttribute(name) !== value) { |
3224 if (currentChild.getAttribute(_name) !== value) { |
2871 currentChild.setAttribute(name, value); |
3225 currentChild.setAttribute(_name, value); |
2872 } |
3226 } |
2873 } |
3227 } |
2874 } |
3228 } |
2875 |
3229 |
2876 applyValue(futureChild, currentChild); |
3230 applyValue(futureChild, currentChild); |
2900 |
3254 |
2901 function isRangeEqual(a, b) { |
3255 function isRangeEqual(a, b) { |
2902 return a.startContainer === b.startContainer && a.startOffset === b.startOffset && a.endContainer === b.endContainer && a.endOffset === b.endOffset; |
3256 return a.startContainer === b.startContainer && a.startOffset === b.startOffset && a.endContainer === b.endContainer && a.endOffset === b.endOffset; |
2903 } |
3257 } |
2904 |
3258 |
2905 function applySelection(_ref7, current) { |
3259 function applySelection(_ref6, current) { |
2906 var startPath = _ref7.startPath, |
3260 var startPath = _ref6.startPath, |
2907 endPath = _ref7.endPath; |
3261 endPath = _ref6.endPath; |
2908 |
3262 |
2909 var _getNodeByPath = getNodeByPath(current, startPath), |
3263 var _getNodeByPath = getNodeByPath(current, startPath), |
2910 startContainer = _getNodeByPath.node, |
3264 startContainer = _getNodeByPath.node, |
2911 startOffset = _getNodeByPath.offset; |
3265 startOffset = _getNodeByPath.offset; |
2912 |
3266 |
2913 var _getNodeByPath2 = getNodeByPath(current, endPath), |
3267 var _getNodeByPath2 = getNodeByPath(current, endPath), |
2914 endContainer = _getNodeByPath2.node, |
3268 endContainer = _getNodeByPath2.node, |
2915 endOffset = _getNodeByPath2.offset; |
3269 endOffset = _getNodeByPath2.offset; |
2916 |
3270 |
2917 var selection = window.getSelection(); |
|
2918 var ownerDocument = current.ownerDocument; |
3271 var ownerDocument = current.ownerDocument; |
3272 var defaultView = ownerDocument.defaultView; |
|
3273 var selection = defaultView.getSelection(); |
|
2919 var range = ownerDocument.createRange(); |
3274 var range = ownerDocument.createRange(); |
2920 range.setStart(startContainer, startOffset); |
3275 range.setStart(startContainer, startOffset); |
2921 range.setEnd(endContainer, endOffset); |
3276 range.setEnd(endContainer, endOffset); |
3277 var activeElement = ownerDocument.activeElement; |
|
2922 |
3278 |
2923 if (selection.rangeCount > 0) { |
3279 if (selection.rangeCount > 0) { |
2924 // If the to be added range and the live range are the same, there's no |
3280 // 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. |
3281 // need to remove the live range and add the equivalent range. |
2926 if (isRangeEqual(range, selection.getRangeAt(0))) { |
3282 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; |
3283 return; |
2933 } |
3284 } |
2934 |
3285 |
2935 selection.removeAllRanges(); |
3286 selection.removeAllRanges(); |
2936 } |
3287 } |
2937 |
3288 |
2938 selection.addRange(range); |
3289 selection.addRange(range); // This function is not intended to cause a shift in focus. Since the above |
3290 // selection manipulations may shift focus, ensure that focus is restored to |
|
3291 // its previous state. |
|
3292 |
|
3293 if (activeElement !== ownerDocument.activeElement) { |
|
3294 // The `instanceof` checks protect against edge cases where the focused |
|
3295 // element is not of the interface HTMLElement (does not have a `focus` |
|
3296 // or `blur` property). |
|
3297 // |
|
3298 // See: https://github.com/Microsoft/TypeScript/issues/5901#issuecomment-431649653 |
|
3299 if (activeElement instanceof defaultView.HTMLElement) { |
|
3300 activeElement.focus(); |
|
3301 } |
|
3302 } |
|
2939 } |
3303 } |
2940 |
3304 |
2941 // EXTERNAL MODULE: external {"this":["wp","escapeHtml"]} |
3305 // EXTERNAL MODULE: external {"this":["wp","escapeHtml"]} |
2942 var external_this_wp_escapeHtml_ = __webpack_require__(69); |
3306 var external_this_wp_escapeHtml_ = __webpack_require__(89); |
2943 |
3307 |
2944 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/to-html-string.js |
3308 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/to-html-string.js |
2945 /** |
3309 /** |
2946 * WordPress dependencies |
3310 * WordPress dependencies |
2947 */ |
3311 */ |
2953 |
3317 |
2954 /** |
3318 /** |
2955 * Create an HTML string from a Rich Text value. If a `multilineTag` is |
3319 * 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. |
3320 * provided, text separated by a line separator will be wrapped in it. |
2957 * |
3321 * |
2958 * @param {Object} $1 Named argements. |
3322 * @param {Object} $1 Named argements. |
2959 * @param {Object} $1.value Rich text value. |
3323 * @param {Object} $1.value Rich text value. |
2960 * @param {string} [$1.multilineTag] Multiline tag. |
3324 * @param {string} [$1.multilineTag] Multiline tag. |
3325 * @param {?boolean} [$1.preserveWhiteSpace] Whether or not to use newline |
|
3326 * characters for line breaks. |
|
2961 * |
3327 * |
2962 * @return {string} HTML string. |
3328 * @return {string} HTML string. |
2963 */ |
3329 */ |
2964 |
3330 |
2965 function toHTMLString(_ref) { |
3331 function toHTMLString(_ref) { |
2966 var value = _ref.value, |
3332 var value = _ref.value, |
2967 multilineTag = _ref.multilineTag; |
3333 multilineTag = _ref.multilineTag, |
3334 preserveWhiteSpace = _ref.preserveWhiteSpace; |
|
2968 var tree = toTree({ |
3335 var tree = toTree({ |
2969 value: value, |
3336 value: value, |
2970 multilineTag: multilineTag, |
3337 multilineTag: multilineTag, |
3338 preserveWhiteSpace: preserveWhiteSpace, |
|
2971 createEmpty: to_html_string_createEmpty, |
3339 createEmpty: to_html_string_createEmpty, |
2972 append: to_html_string_append, |
3340 append: to_html_string_append, |
2973 getLastChild: to_html_string_getLastChild, |
3341 getLastChild: to_html_string_getLastChild, |
2974 getParent: to_html_string_getParent, |
3342 getParent: to_html_string_getParent, |
2975 isText: to_html_string_isText, |
3343 isText: to_html_string_isText, |
3054 } |
3422 } |
3055 |
3423 |
3056 function createChildrenHTML() { |
3424 function createChildrenHTML() { |
3057 var children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
3425 var children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
3058 return children.map(function (child) { |
3426 return children.map(function (child) { |
3059 return child.text === undefined ? createElementHTML(child) : Object(external_this_wp_escapeHtml_["escapeHTML"])(child.text); |
3427 return child.text === undefined ? createElementHTML(child) : Object(external_this_wp_escapeHtml_["escapeEditableHTML"])(child.text); |
3060 }).join(''); |
3428 }).join(''); |
3061 } |
3429 } |
3062 |
3430 |
3063 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/toggle-format.js |
3431 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/toggle-format.js |
3064 /** |
3432 /** |
3087 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/unregister-format-type.js |
3455 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/unregister-format-type.js |
3088 /** |
3456 /** |
3089 * WordPress dependencies |
3457 * WordPress dependencies |
3090 */ |
3458 */ |
3091 |
3459 |
3460 /** @typedef {import('./register-format-type').WPFormat} WPFormat */ |
|
3092 |
3461 |
3093 /** |
3462 /** |
3094 * Unregisters a format. |
3463 * Unregisters a format. |
3095 * |
3464 * |
3096 * @param {string} name Format name. |
3465 * @param {string} name Format name. |
3105 if (!oldFormat) { |
3474 if (!oldFormat) { |
3106 window.console.error("Format ".concat(name, " is not registered.")); |
3475 window.console.error("Format ".concat(name, " is not registered.")); |
3107 return; |
3476 return; |
3108 } |
3477 } |
3109 |
3478 |
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); |
3479 Object(external_this_wp_data_["dispatch"])('core/rich-text').removeFormatTypes(name); |
3115 return oldFormat; |
3480 return oldFormat; |
3116 } |
3481 } |
3117 |
3482 |
3118 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-line-index.js |
3483 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/can-indent-list-items.js |
3119 /** |
3484 /** |
3120 * Internal dependencies |
3485 * Internal dependencies |
3121 */ |
3486 */ |
3122 |
3487 |
3123 /** |
3488 /** |
3124 * Gets the currently selected line index, or the first line index if the |
3489 * Checks if the selected list item can be indented. |
3125 * selection spans over multiple items. |
3490 * |
3126 * |
3491 * @param {Object} value Value to check. |
3127 * @param {Object} value Value to get the line index from. |
3492 * |
3128 * @param {boolean} startIndex Optional index that should be contained by the |
3493 * @return {boolean} Whether or not the selected list item can be indented. |
3129 * line. Defaults to the selection start of the |
3494 */ |
3130 * value. |
3495 |
3131 * |
3496 function canIndentListItems(value) { |
3132 * @return {?boolean} The line index. Undefined if not found. |
3497 var lineIndex = getLineIndex(value); // There is only one line, so the line cannot be indented. |
3133 */ |
3498 |
3134 |
3499 if (lineIndex === undefined) { |
3135 function getLineIndex(_ref) { |
3500 return false; |
3136 var start = _ref.start, |
3501 } |
3137 text = _ref.text; |
3502 |
3138 var startIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : start; |
3503 var replacements = value.replacements; |
3139 var index = startIndex; |
3504 var previousLineIndex = getLineIndex(value, lineIndex); |
3140 |
3505 var formatsAtLineIndex = replacements[lineIndex] || []; |
3141 while (index--) { |
3506 var formatsAtPreviousLineIndex = replacements[previousLineIndex] || []; // If the indentation of the current line is greater than previous line, |
3142 if (text[index] === LINE_SEPARATOR) { |
3507 // then the line cannot be furter indented. |
3143 return index; |
3508 |
3144 } |
3509 return formatsAtLineIndex.length <= formatsAtPreviousLineIndex.length; |
3145 } |
3510 } |
3511 |
|
3512 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/can-outdent-list-items.js |
|
3513 /** |
|
3514 * Internal dependencies |
|
3515 */ |
|
3516 |
|
3517 /** |
|
3518 * Checks if the selected list item can be outdented. |
|
3519 * |
|
3520 * @param {Object} value Value to check. |
|
3521 * |
|
3522 * @return {boolean} Whether or not the selected list item can be outdented. |
|
3523 */ |
|
3524 |
|
3525 function canOutdentListItems(value) { |
|
3526 var replacements = value.replacements, |
|
3527 start = value.start; |
|
3528 var startingLineIndex = getLineIndex(value, start); |
|
3529 return replacements[startingLineIndex] !== undefined; |
|
3146 } |
3530 } |
3147 |
3531 |
3148 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/indent-list-items.js |
3532 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/indent-list-items.js |
3149 |
3533 |
3150 |
3534 |
3535 function indent_list_items_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
3536 |
|
3537 function indent_list_items_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { indent_list_items_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { indent_list_items_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
3538 |
|
3151 /** |
3539 /** |
3152 * Internal dependencies |
3540 * Internal dependencies |
3153 */ |
3541 */ |
3542 |
|
3154 |
3543 |
3155 |
3544 |
3156 /** |
3545 /** |
3157 * Gets the line index of the first previous list item with higher indentation. |
3546 * Gets the line index of the first previous list item with higher indentation. |
3158 * |
3547 * |
3192 * @return {Object} The changed value. |
3581 * @return {Object} The changed value. |
3193 */ |
3582 */ |
3194 |
3583 |
3195 |
3584 |
3196 function indentListItems(value, rootFormat) { |
3585 function indentListItems(value, rootFormat) { |
3197 var lineIndex = getLineIndex(value); // There is only one line, so the line cannot be indented. |
3586 if (!canIndentListItems(value)) { |
3198 |
|
3199 if (lineIndex === undefined) { |
|
3200 return value; |
3587 return value; |
3201 } |
3588 } |
3202 |
3589 |
3590 var lineIndex = getLineIndex(value); |
|
3591 var previousLineIndex = getLineIndex(value, lineIndex); |
|
3203 var text = value.text, |
3592 var text = value.text, |
3204 replacements = value.replacements, |
3593 replacements = value.replacements, |
3205 end = value.end; |
3594 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(); |
3595 var newFormats = replacements.slice(); |
3216 var targetLevelLineIndex = getTargetLevelLineIndex(value, lineIndex); |
3596 var targetLevelLineIndex = getTargetLevelLineIndex(value, lineIndex); |
3217 |
3597 |
3218 for (var index = lineIndex; index < end; index++) { |
3598 for (var index = lineIndex; index < end; index++) { |
3219 if (text[index] !== LINE_SEPARATOR) { |
3599 if (text[index] !== LINE_SEPARATOR) { |
3231 var lastformat = _targetFormats[_targetFormats.length - 1] || rootFormat; |
3611 var lastformat = _targetFormats[_targetFormats.length - 1] || rootFormat; |
3232 newFormats[index] = _targetFormats.concat([lastformat], (newFormats[index] || []).slice(_targetFormats.length)); |
3612 newFormats[index] = _targetFormats.concat([lastformat], (newFormats[index] || []).slice(_targetFormats.length)); |
3233 } |
3613 } |
3234 } |
3614 } |
3235 |
3615 |
3236 return Object(objectSpread["a" /* default */])({}, value, { |
3616 return indent_list_items_objectSpread({}, value, { |
3237 replacements: newFormats |
3617 replacements: newFormats |
3238 }); |
3618 }); |
3239 } |
3619 } |
3240 |
3620 |
3241 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-parent-line-index.js |
3621 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/get-parent-line-index.js |
3315 } |
3695 } |
3316 |
3696 |
3317 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/outdent-list-items.js |
3697 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/outdent-list-items.js |
3318 |
3698 |
3319 |
3699 |
3700 function outdent_list_items_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
3701 |
|
3702 function outdent_list_items_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { outdent_list_items_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { outdent_list_items_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
3703 |
|
3320 /** |
3704 /** |
3321 * Internal dependencies |
3705 * Internal dependencies |
3322 */ |
3706 */ |
3323 |
3707 |
3324 |
3708 |
3325 |
3709 |
3326 |
3710 |
3711 |
|
3327 /** |
3712 /** |
3328 * Outdents any selected list items if possible. |
3713 * Outdents any selected list items if possible. |
3329 * |
3714 * |
3330 * @param {Object} value Value to change. |
3715 * @param {Object} value Value to change. |
3331 * |
3716 * |
3332 * @return {Object} The changed value. |
3717 * @return {Object} The changed value. |
3333 */ |
3718 */ |
3334 |
3719 |
3335 function outdentListItems(value) { |
3720 function outdentListItems(value) { |
3721 if (!canOutdentListItems(value)) { |
|
3722 return value; |
|
3723 } |
|
3724 |
|
3336 var text = value.text, |
3725 var text = value.text, |
3337 replacements = value.replacements, |
3726 replacements = value.replacements, |
3338 start = value.start, |
3727 start = value.start, |
3339 end = value.end; |
3728 end = value.end; |
3340 var startingLineIndex = getLineIndex(value, start); // Return early if the starting line index cannot be further outdented. |
3729 var startingLineIndex = getLineIndex(value, start); |
3341 |
|
3342 if (replacements[startingLineIndex] === undefined) { |
|
3343 return value; |
|
3344 } |
|
3345 |
|
3346 var newFormats = replacements.slice(0); |
3730 var newFormats = replacements.slice(0); |
3347 var parentFormats = replacements[getParentLineIndex(value, startingLineIndex)] || []; |
3731 var parentFormats = replacements[getParentLineIndex(value, startingLineIndex)] || []; |
3348 var endingLineIndex = getLineIndex(value, end); |
3732 var endingLineIndex = getLineIndex(value, end); |
3349 var lastChildIndex = getLastChildIndex(value, endingLineIndex); // Outdent all list items from the starting line index until the last child |
3733 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 |
3734 // index of the ending list. All children of the ending list need to be |
3364 if (newFormats[index].length === 0) { |
3748 if (newFormats[index].length === 0) { |
3365 delete newFormats[index]; |
3749 delete newFormats[index]; |
3366 } |
3750 } |
3367 } |
3751 } |
3368 |
3752 |
3369 return Object(objectSpread["a" /* default */])({}, value, { |
3753 return outdent_list_items_objectSpread({}, value, { |
3370 replacements: newFormats |
3754 replacements: newFormats |
3371 }); |
3755 }); |
3372 } |
3756 } |
3373 |
3757 |
3374 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/change-list-type.js |
3758 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/change-list-type.js |
3375 |
3759 |
3760 |
|
3761 function change_list_type_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
3762 |
|
3763 function change_list_type_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { change_list_type_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { change_list_type_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
3376 |
3764 |
3377 /** |
3765 /** |
3378 * Internal dependencies |
3766 * Internal dependencies |
3379 */ |
3767 */ |
3380 |
3768 |
3428 |
3816 |
3429 if (!changed) { |
3817 if (!changed) { |
3430 return value; |
3818 return value; |
3431 } |
3819 } |
3432 |
3820 |
3433 return Object(objectSpread["a" /* default */])({}, value, { |
3821 return change_list_type_objectSpread({}, value, { |
3434 replacements: newReplacements |
3822 replacements: newReplacements |
3823 }); |
|
3824 } |
|
3825 |
|
3826 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js |
|
3827 var esm_extends = __webpack_require__(8); |
|
3828 |
|
3829 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules |
|
3830 var slicedToArray = __webpack_require__(14); |
|
3831 |
|
3832 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js |
|
3833 var objectWithoutProperties = __webpack_require__(15); |
|
3834 |
|
3835 // EXTERNAL MODULE: external {"this":["wp","element"]} |
|
3836 var external_this_wp_element_ = __webpack_require__(0); |
|
3837 |
|
3838 // EXTERNAL MODULE: ./node_modules/classnames/index.js |
|
3839 var classnames = __webpack_require__(11); |
|
3840 var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames); |
|
3841 |
|
3842 // EXTERNAL MODULE: external {"this":["wp","keycodes"]} |
|
3843 var external_this_wp_keycodes_ = __webpack_require__(21); |
|
3844 |
|
3845 // EXTERNAL MODULE: external {"this":["wp","deprecated"]} |
|
3846 var external_this_wp_deprecated_ = __webpack_require__(37); |
|
3847 var external_this_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_deprecated_); |
|
3848 |
|
3849 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/format-edit.js |
|
3850 |
|
3851 |
|
3852 /** |
|
3853 * Internal dependencies |
|
3854 */ |
|
3855 |
|
3856 |
|
3857 /** |
|
3858 * Set of all interactive content tags. |
|
3859 * |
|
3860 * @see https://html.spec.whatwg.org/multipage/dom.html#interactive-content |
|
3861 */ |
|
3862 |
|
3863 var interactiveContentTags = new Set(['a', 'audio', 'button', 'details', 'embed', 'iframe', 'input', 'label', 'select', 'textarea', 'video']); |
|
3864 function FormatEdit(_ref) { |
|
3865 var formatTypes = _ref.formatTypes, |
|
3866 onChange = _ref.onChange, |
|
3867 onFocus = _ref.onFocus, |
|
3868 value = _ref.value, |
|
3869 allowedFormats = _ref.allowedFormats, |
|
3870 withoutInteractiveFormatting = _ref.withoutInteractiveFormatting; |
|
3871 return formatTypes.map(function (_ref2) { |
|
3872 var name = _ref2.name, |
|
3873 Edit = _ref2.edit, |
|
3874 tagName = _ref2.tagName; |
|
3875 |
|
3876 if (!Edit) { |
|
3877 return null; |
|
3878 } |
|
3879 |
|
3880 if (allowedFormats && allowedFormats.indexOf(name) === -1) { |
|
3881 return null; |
|
3882 } |
|
3883 |
|
3884 if (withoutInteractiveFormatting && interactiveContentTags.has(tagName)) { |
|
3885 return null; |
|
3886 } |
|
3887 |
|
3888 var activeFormat = getActiveFormat(value, name); |
|
3889 var isActive = activeFormat !== undefined; |
|
3890 var activeObject = getActiveObject(value); |
|
3891 var isObjectActive = activeObject !== undefined && activeObject.type === name; |
|
3892 return Object(external_this_wp_element_["createElement"])(Edit, { |
|
3893 key: name, |
|
3894 isActive: isActive, |
|
3895 activeAttributes: isActive ? activeFormat.attributes || {} : {}, |
|
3896 isObjectActive: isObjectActive, |
|
3897 activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {}, |
|
3898 value: value, |
|
3899 onChange: onChange, |
|
3900 onFocus: onFocus |
|
3901 }); |
|
3435 }); |
3902 }); |
3436 } |
3903 } |
3437 |
3904 |
3438 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/update-formats.js |
3905 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/update-formats.js |
3439 /** |
3906 /** |
3485 } |
3952 } |
3486 |
3953 |
3487 return value; |
3954 return value; |
3488 } |
3955 } |
3489 |
3956 |
3957 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/with-format-types.js |
|
3958 |
|
3959 |
|
3960 |
|
3961 |
|
3962 function with_format_types_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
3963 |
|
3964 function with_format_types_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { with_format_types_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { with_format_types_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
3965 |
|
3966 /** |
|
3967 * External dependencies |
|
3968 */ |
|
3969 |
|
3970 /** |
|
3971 * WordPress dependencies |
|
3972 */ |
|
3973 |
|
3974 |
|
3975 |
|
3976 |
|
3977 function formatTypesSelector(select) { |
|
3978 return select('core/rich-text').getFormatTypes(); |
|
3979 } |
|
3980 /** |
|
3981 * This higher-order component provides RichText with the `formatTypes` prop |
|
3982 * and its derived props from experimental format type settings. |
|
3983 * |
|
3984 * @param {WPComponent} RichText The rich text component to add props for. |
|
3985 * |
|
3986 * @return {WPComponent} New enhanced component. |
|
3987 */ |
|
3988 |
|
3989 |
|
3990 function withFormatTypes(RichText) { |
|
3991 return function WithFormatTypes(props) { |
|
3992 var clientId = props.clientId, |
|
3993 identifier = props.identifier; |
|
3994 var formatTypes = Object(external_this_wp_data_["useSelect"])(formatTypesSelector, []); |
|
3995 var selectProps = Object(external_this_wp_data_["useSelect"])(function (select) { |
|
3996 return formatTypes.reduce(function (acc, settings) { |
|
3997 if (!settings.__experimentalGetPropsForEditableTreePreparation) { |
|
3998 return acc; |
|
3999 } |
|
4000 |
|
4001 var selectPrefix = "format_prepare_props_(".concat(settings.name, ")_"); |
|
4002 return with_format_types_objectSpread({}, acc, {}, Object(external_this_lodash_["mapKeys"])(settings.__experimentalGetPropsForEditableTreePreparation(select, { |
|
4003 richTextIdentifier: identifier, |
|
4004 blockClientId: clientId |
|
4005 }), function (value, key) { |
|
4006 return selectPrefix + key; |
|
4007 })); |
|
4008 }, {}); |
|
4009 }, [formatTypes, clientId, identifier]); |
|
4010 |
|
4011 var dispatchProps = Object(external_this_wp_data_["__unstableUseDispatchWithMap"])(function (dispatch) { |
|
4012 return formatTypes.reduce(function (acc, settings) { |
|
4013 if (!settings.__experimentalGetPropsForEditableTreeChangeHandler) { |
|
4014 return acc; |
|
4015 } |
|
4016 |
|
4017 var dispatchPrefix = "format_on_change_props_(".concat(settings.name, ")_"); |
|
4018 return with_format_types_objectSpread({}, acc, {}, Object(external_this_lodash_["mapKeys"])(settings.__experimentalGetPropsForEditableTreeChangeHandler(dispatch, { |
|
4019 richTextIdentifier: identifier, |
|
4020 blockClientId: clientId |
|
4021 }), function (value, key) { |
|
4022 return dispatchPrefix + key; |
|
4023 })); |
|
4024 }, {}); |
|
4025 }, [formatTypes, clientId, identifier]); |
|
4026 |
|
4027 var newProps = Object(external_this_wp_element_["useMemo"])(function () { |
|
4028 return formatTypes.reduce(function (acc, settings) { |
|
4029 if (!settings.__experimentalCreatePrepareEditableTree) { |
|
4030 return acc; |
|
4031 } |
|
4032 |
|
4033 var args = { |
|
4034 richTextIdentifier: identifier, |
|
4035 blockClientId: clientId |
|
4036 }; |
|
4037 |
|
4038 var combined = with_format_types_objectSpread({}, selectProps, {}, dispatchProps); |
|
4039 |
|
4040 var name = settings.name; |
|
4041 var selectPrefix = "format_prepare_props_(".concat(name, ")_"); |
|
4042 var dispatchPrefix = "format_on_change_props_(".concat(name, ")_"); |
|
4043 var propsByPrefix = Object.keys(combined).reduce(function (accumulator, key) { |
|
4044 if (key.startsWith(selectPrefix)) { |
|
4045 accumulator[key.slice(selectPrefix.length)] = combined[key]; |
|
4046 } |
|
4047 |
|
4048 if (key.startsWith(dispatchPrefix)) { |
|
4049 accumulator[key.slice(dispatchPrefix.length)] = combined[key]; |
|
4050 } |
|
4051 |
|
4052 return accumulator; |
|
4053 }, {}); |
|
4054 |
|
4055 if (settings.__experimentalCreateOnChangeEditableValue) { |
|
4056 var _objectSpread2; |
|
4057 |
|
4058 return with_format_types_objectSpread({}, acc, (_objectSpread2 = {}, Object(defineProperty["a" /* default */])(_objectSpread2, "format_value_functions_(".concat(name, ")"), settings.__experimentalCreatePrepareEditableTree(propsByPrefix, args)), Object(defineProperty["a" /* default */])(_objectSpread2, "format_on_change_functions_(".concat(name, ")"), settings.__experimentalCreateOnChangeEditableValue(propsByPrefix, args)), _objectSpread2)); |
|
4059 } |
|
4060 |
|
4061 return with_format_types_objectSpread({}, acc, Object(defineProperty["a" /* default */])({}, "format_prepare_functions_(".concat(name, ")"), settings.__experimentalCreatePrepareEditableTree(propsByPrefix, args))); |
|
4062 }, {}); |
|
4063 }, [formatTypes, clientId, identifier, selectProps, dispatchProps]); |
|
4064 return Object(external_this_wp_element_["createElement"])(RichText, Object(esm_extends["a" /* default */])({}, props, selectProps, newProps, { |
|
4065 formatTypes: formatTypes |
|
4066 })); |
|
4067 }; |
|
4068 } |
|
4069 |
|
4070 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-boundary-style.js |
|
4071 /** |
|
4072 * WordPress dependencies |
|
4073 */ |
|
4074 |
|
4075 /** |
|
4076 * Calculates and renders the format boundary style when the active formats |
|
4077 * change. |
|
4078 */ |
|
4079 |
|
4080 function useBoundaryStyle(_ref) { |
|
4081 var activeFormats = _ref.activeFormats, |
|
4082 ref = _ref.ref; |
|
4083 Object(external_this_wp_element_["useEffect"])(function () { |
|
4084 // There's no need to recalculate the boundary styles if no formats are |
|
4085 // active, because no boundary styles will be visible. |
|
4086 if (!activeFormats || !activeFormats.length) { |
|
4087 return; |
|
4088 } |
|
4089 |
|
4090 var boundarySelector = '*[data-rich-text-format-boundary]'; |
|
4091 var element = ref.current.querySelector(boundarySelector); |
|
4092 |
|
4093 if (!element) { |
|
4094 return; |
|
4095 } |
|
4096 |
|
4097 var ownerDocument = element.ownerDocument; |
|
4098 var defaultView = ownerDocument.defaultView; |
|
4099 var computedStyle = defaultView.getComputedStyle(element); |
|
4100 var newColor = computedStyle.color.replace(')', ', 0.2)').replace('rgb', 'rgba'); |
|
4101 var selector = ".rich-text:focus ".concat(boundarySelector); |
|
4102 var rule = "background-color: ".concat(newColor); |
|
4103 var style = "".concat(selector, " {").concat(rule, "}"); |
|
4104 var globalStyleId = 'rich-text-boundary-style'; |
|
4105 var globalStyle = ownerDocument.getElementById(globalStyleId); |
|
4106 |
|
4107 if (!globalStyle) { |
|
4108 globalStyle = ownerDocument.createElement('style'); |
|
4109 globalStyle.id = globalStyleId; |
|
4110 ownerDocument.head.appendChild(globalStyle); |
|
4111 } |
|
4112 |
|
4113 if (globalStyle.innerHTML !== style) { |
|
4114 globalStyle.innerHTML = style; |
|
4115 } |
|
4116 }, [activeFormats]); |
|
4117 } |
|
4118 |
|
4119 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/use-inline-warning.js |
|
4120 /** |
|
4121 * WordPress dependencies |
|
4122 */ |
|
4123 |
|
4124 function useInlineWarning(_ref) { |
|
4125 var ref = _ref.ref; |
|
4126 Object(external_this_wp_element_["useEffect"])(function () { |
|
4127 if (false) { var computedStyle, defaultView, target; } |
|
4128 }, []); |
|
4129 } |
|
4130 |
|
4131 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/component/index.js |
|
4132 |
|
4133 |
|
4134 |
|
4135 |
|
4136 |
|
4137 |
|
4138 function component_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } |
|
4139 |
|
4140 function component_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { component_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { component_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } |
|
4141 |
|
4142 /** |
|
4143 * External dependencies |
|
4144 */ |
|
4145 |
|
4146 |
|
4147 /** |
|
4148 * WordPress dependencies |
|
4149 */ |
|
4150 |
|
4151 |
|
4152 |
|
4153 |
|
4154 /** |
|
4155 * Internal dependencies |
|
4156 */ |
|
4157 |
|
4158 |
|
4159 |
|
4160 |
|
4161 |
|
4162 |
|
4163 |
|
4164 |
|
4165 |
|
4166 |
|
4167 |
|
4168 |
|
4169 |
|
4170 |
|
4171 |
|
4172 |
|
4173 |
|
4174 |
|
4175 /** @typedef {import('@wordpress/element').WPSyntheticEvent} WPSyntheticEvent */ |
|
4176 |
|
4177 /** |
|
4178 * All inserting input types that would insert HTML into the DOM. |
|
4179 * |
|
4180 * @see https://www.w3.org/TR/input-events-2/#interface-InputEvent-Attributes |
|
4181 * |
|
4182 * @type {Set} |
|
4183 */ |
|
4184 |
|
4185 var INSERTION_INPUT_TYPES_TO_IGNORE = new Set(['insertParagraph', 'insertOrderedList', 'insertUnorderedList', 'insertHorizontalRule', 'insertLink']); |
|
4186 /** |
|
4187 * In HTML, leading and trailing spaces are not visible, and multiple spaces |
|
4188 * elsewhere are visually reduced to one space. This rule prevents spaces from |
|
4189 * collapsing so all space is visible in the editor and can be removed. It also |
|
4190 * prevents some browsers from inserting non-breaking spaces at the end of a |
|
4191 * line to prevent the space from visually disappearing. Sometimes these non |
|
4192 * breaking spaces can linger in the editor causing unwanted non breaking spaces |
|
4193 * in between words. If also prevent Firefox from inserting a trailing `br` node |
|
4194 * to visualise any trailing space, causing the element to be saved. |
|
4195 * |
|
4196 * > Authors are encouraged to set the 'white-space' property on editing hosts |
|
4197 * > and on markup that was originally created through these editing mechanisms |
|
4198 * > to the value 'pre-wrap'. Default HTML whitespace handling is not well |
|
4199 * > suited to WYSIWYG editing, and line wrapping will not work correctly in |
|
4200 * > some corner cases if 'white-space' is left at its default value. |
|
4201 * |
|
4202 * https://html.spec.whatwg.org/multipage/interaction.html#best-practices-for-in-page-editors |
|
4203 * |
|
4204 * @type {string} |
|
4205 */ |
|
4206 |
|
4207 var whiteSpace = 'pre-wrap'; |
|
4208 /** |
|
4209 * Default style object for the editable element. |
|
4210 * |
|
4211 * @type {Object<string,string>} |
|
4212 */ |
|
4213 |
|
4214 var defaultStyle = { |
|
4215 whiteSpace: whiteSpace |
|
4216 }; |
|
4217 var EMPTY_ACTIVE_FORMATS = []; |
|
4218 |
|
4219 function createPrepareEditableTree(props, prefix) { |
|
4220 var fns = Object.keys(props).reduce(function (accumulator, key) { |
|
4221 if (key.startsWith(prefix)) { |
|
4222 accumulator.push(props[key]); |
|
4223 } |
|
4224 |
|
4225 return accumulator; |
|
4226 }, []); |
|
4227 return function (value) { |
|
4228 return fns.reduce(function (accumulator, fn) { |
|
4229 return fn(accumulator, value.text); |
|
4230 }, value.formats); |
|
4231 }; |
|
4232 } |
|
4233 /** |
|
4234 * If the selection is set on the placeholder element, collapse the selection to |
|
4235 * the start (before the placeholder). |
|
4236 * |
|
4237 * @param {Window} defaultView |
|
4238 */ |
|
4239 |
|
4240 |
|
4241 function fixPlaceholderSelection(defaultView) { |
|
4242 var selection = defaultView.getSelection(); |
|
4243 var anchorNode = selection.anchorNode, |
|
4244 anchorOffset = selection.anchorOffset; |
|
4245 |
|
4246 if (anchorNode.nodeType !== anchorNode.ELEMENT_NODE) { |
|
4247 return; |
|
4248 } |
|
4249 |
|
4250 var targetNode = anchorNode.childNodes[anchorOffset]; |
|
4251 |
|
4252 if (!targetNode || targetNode.nodeType !== targetNode.ELEMENT_NODE || !targetNode.getAttribute('data-rich-text-placeholder')) { |
|
4253 return; |
|
4254 } |
|
4255 |
|
4256 selection.collapseToStart(); |
|
4257 } |
|
4258 |
|
4259 function component_RichText(_ref) { |
|
4260 var _ref$tagName = _ref.tagName, |
|
4261 TagName = _ref$tagName === void 0 ? 'div' : _ref$tagName, |
|
4262 _ref$value = _ref.value, |
|
4263 value = _ref$value === void 0 ? '' : _ref$value, |
|
4264 selectionStart = _ref.selectionStart, |
|
4265 selectionEnd = _ref.selectionEnd, |
|
4266 children = _ref.children, |
|
4267 allowedFormats = _ref.allowedFormats, |
|
4268 withoutInteractiveFormatting = _ref.withoutInteractiveFormatting, |
|
4269 formatTypes = _ref.formatTypes, |
|
4270 style = _ref.style, |
|
4271 className = _ref.className, |
|
4272 placeholder = _ref.placeholder, |
|
4273 disabled = _ref.disabled, |
|
4274 preserveWhiteSpace = _ref.preserveWhiteSpace, |
|
4275 onPaste = _ref.onPaste, |
|
4276 _ref$format = _ref.format, |
|
4277 format = _ref$format === void 0 ? 'string' : _ref$format, |
|
4278 onDelete = _ref.onDelete, |
|
4279 onEnter = _ref.onEnter, |
|
4280 onSelectionChange = _ref.onSelectionChange, |
|
4281 onChange = _ref.onChange, |
|
4282 onFocus = _ref.unstableOnFocus, |
|
4283 setFocusedElement = _ref.setFocusedElement, |
|
4284 instanceId = _ref.instanceId, |
|
4285 multilineTag = _ref.__unstableMultilineTag, |
|
4286 multilineRootTag = _ref.__unstableMultilineRootTag, |
|
4287 disableFormats = _ref.__unstableDisableFormats, |
|
4288 didAutomaticChange = _ref.__unstableDidAutomaticChange, |
|
4289 inputRule = _ref.__unstableInputRule, |
|
4290 markAutomaticChange = _ref.__unstableMarkAutomaticChange, |
|
4291 allowPrefixTransformations = _ref.__unstableAllowPrefixTransformations, |
|
4292 undo = _ref.__unstableUndo, |
|
4293 isCaretWithinFormattedText = _ref.__unstableIsCaretWithinFormattedText, |
|
4294 onEnterFormattedText = _ref.__unstableOnEnterFormattedText, |
|
4295 onExitFormattedText = _ref.__unstableOnExitFormattedText, |
|
4296 onCreateUndoLevel = _ref.__unstableOnCreateUndoLevel, |
|
4297 isSelected = _ref.__unstableIsSelected, |
|
4298 ref = _ref.forwardedRef, |
|
4299 remainingProps = Object(objectWithoutProperties["a" /* default */])(_ref, ["tagName", "value", "selectionStart", "selectionEnd", "children", "allowedFormats", "withoutInteractiveFormatting", "formatTypes", "style", "className", "placeholder", "disabled", "preserveWhiteSpace", "onPaste", "format", "onDelete", "onEnter", "onSelectionChange", "onChange", "unstableOnFocus", "setFocusedElement", "instanceId", "__unstableMultilineTag", "__unstableMultilineRootTag", "__unstableDisableFormats", "__unstableDidAutomaticChange", "__unstableInputRule", "__unstableMarkAutomaticChange", "__unstableAllowPrefixTransformations", "__unstableUndo", "__unstableIsCaretWithinFormattedText", "__unstableOnEnterFormattedText", "__unstableOnExitFormattedText", "__unstableOnCreateUndoLevel", "__unstableIsSelected", "forwardedRef"]); |
|
4300 |
|
4301 var _useState = Object(external_this_wp_element_["useState"])(), |
|
4302 _useState2 = Object(slicedToArray["a" /* default */])(_useState, 2), |
|
4303 _useState2$ = _useState2[0], |
|
4304 activeFormats = _useState2$ === void 0 ? [] : _useState2$, |
|
4305 setActiveFormats = _useState2[1]; // For backward compatibility, fall back to tagName if it's a string. |
|
4306 // tagName can now be a component for light blocks. |
|
4307 |
|
4308 |
|
4309 if (!multilineRootTag && typeof TagName === 'string') { |
|
4310 multilineRootTag = TagName; |
|
4311 } |
|
4312 |
|
4313 function getDoc() { |
|
4314 return ref.current.ownerDocument; |
|
4315 } |
|
4316 |
|
4317 function getWin() { |
|
4318 return getDoc().defaultView; |
|
4319 } |
|
4320 /** |
|
4321 * Converts the outside data structure to our internal representation. |
|
4322 * |
|
4323 * @param {*} string The outside value, data type depends on props. |
|
4324 * |
|
4325 * @return {Object} An internal rich-text value. |
|
4326 */ |
|
4327 |
|
4328 |
|
4329 function formatToValue(string) { |
|
4330 if (disableFormats) { |
|
4331 return { |
|
4332 text: string, |
|
4333 formats: Array(string.length), |
|
4334 replacements: Array(string.length) |
|
4335 }; |
|
4336 } |
|
4337 |
|
4338 if (format !== 'string') { |
|
4339 return string; |
|
4340 } |
|
4341 |
|
4342 var prepare = createPrepareEditableTree(remainingProps, 'format_value_functions'); |
|
4343 var result = create({ |
|
4344 html: string, |
|
4345 multilineTag: multilineTag, |
|
4346 multilineWrapperTags: multilineTag === 'li' ? ['ul', 'ol'] : undefined, |
|
4347 preserveWhiteSpace: preserveWhiteSpace |
|
4348 }); |
|
4349 result.formats = prepare(result); |
|
4350 return result; |
|
4351 } |
|
4352 /** |
|
4353 * Removes editor only formats from the value. |
|
4354 * |
|
4355 * Editor only formats are applied using `prepareEditableTree`, so we need to |
|
4356 * remove them before converting the internal state |
|
4357 * |
|
4358 * @param {Object} val The internal rich-text value. |
|
4359 * |
|
4360 * @return {Object} A new rich-text value. |
|
4361 */ |
|
4362 |
|
4363 |
|
4364 function removeEditorOnlyFormats(val) { |
|
4365 formatTypes.forEach(function (formatType) { |
|
4366 // Remove formats created by prepareEditableTree, because they are editor only. |
|
4367 if (formatType.__experimentalCreatePrepareEditableTree) { |
|
4368 val = removeFormat(val, formatType.name, 0, val.text.length); |
|
4369 } |
|
4370 }); |
|
4371 return val; |
|
4372 } |
|
4373 /** |
|
4374 * Converts the internal value to the external data format. |
|
4375 * |
|
4376 * @param {Object} val The internal rich-text value. |
|
4377 * |
|
4378 * @return {*} The external data format, data type depends on props. |
|
4379 */ |
|
4380 |
|
4381 |
|
4382 function valueToFormat(val) { |
|
4383 if (disableFormats) { |
|
4384 return val.text; |
|
4385 } |
|
4386 |
|
4387 val = removeEditorOnlyFormats(val); |
|
4388 |
|
4389 if (format !== 'string') { |
|
4390 return; |
|
4391 } |
|
4392 |
|
4393 return toHTMLString({ |
|
4394 value: val, |
|
4395 multilineTag: multilineTag, |
|
4396 preserveWhiteSpace: preserveWhiteSpace |
|
4397 }); |
|
4398 } // Internal values are updated synchronously, unlike props and state. |
|
4399 |
|
4400 |
|
4401 var _value = Object(external_this_wp_element_["useRef"])(value); |
|
4402 |
|
4403 var record = Object(external_this_wp_element_["useRef"])(Object(external_this_wp_element_["useMemo"])(function () { |
|
4404 var initialRecord = formatToValue(value); |
|
4405 initialRecord.start = selectionStart; |
|
4406 initialRecord.end = selectionEnd; |
|
4407 return initialRecord; |
|
4408 }, [])); |
|
4409 |
|
4410 function createRecord() { |
|
4411 var selection = getWin().getSelection(); |
|
4412 var range = selection.rangeCount > 0 ? selection.getRangeAt(0) : null; |
|
4413 return create({ |
|
4414 element: ref.current, |
|
4415 range: range, |
|
4416 multilineTag: multilineTag, |
|
4417 multilineWrapperTags: multilineTag === 'li' ? ['ul', 'ol'] : undefined, |
|
4418 __unstableIsEditableTree: true, |
|
4419 preserveWhiteSpace: preserveWhiteSpace |
|
4420 }); |
|
4421 } |
|
4422 |
|
4423 function applyRecord(newRecord) { |
|
4424 var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, |
|
4425 domOnly = _ref2.domOnly; |
|
4426 |
|
4427 apply({ |
|
4428 value: newRecord, |
|
4429 current: ref.current, |
|
4430 multilineTag: multilineTag, |
|
4431 multilineWrapperTags: multilineTag === 'li' ? ['ul', 'ol'] : undefined, |
|
4432 prepareEditableTree: createPrepareEditableTree(remainingProps, 'format_prepare_functions'), |
|
4433 __unstableDomOnly: domOnly, |
|
4434 placeholder: placeholder |
|
4435 }); |
|
4436 } |
|
4437 /** |
|
4438 * Handles a paste event. |
|
4439 * |
|
4440 * Saves the pasted data as plain text in `pastedPlainText`. |
|
4441 * |
|
4442 * @param {ClipboardEvent} event The paste event. |
|
4443 */ |
|
4444 |
|
4445 |
|
4446 function handlePaste(event) { |
|
4447 if (!isSelected) { |
|
4448 event.preventDefault(); |
|
4449 return; |
|
4450 } |
|
4451 |
|
4452 var clipboardData = event.clipboardData; |
|
4453 var items = clipboardData.items, |
|
4454 files = clipboardData.files; // In Edge these properties can be null instead of undefined, so a more |
|
4455 // rigorous test is required over using default values. |
|
4456 |
|
4457 items = Object(external_this_lodash_["isNil"])(items) ? [] : items; |
|
4458 files = Object(external_this_lodash_["isNil"])(files) ? [] : files; |
|
4459 var plainText = ''; |
|
4460 var html = ''; // IE11 only supports `Text` as an argument for `getData` and will |
|
4461 // otherwise throw an invalid argument error, so we try the standard |
|
4462 // arguments first, then fallback to `Text` if they fail. |
|
4463 |
|
4464 try { |
|
4465 plainText = clipboardData.getData('text/plain'); |
|
4466 html = clipboardData.getData('text/html'); |
|
4467 } catch (error1) { |
|
4468 try { |
|
4469 html = clipboardData.getData('Text'); |
|
4470 } catch (error2) { |
|
4471 // Some browsers like UC Browser paste plain text by default and |
|
4472 // don't support clipboardData at all, so allow default |
|
4473 // behaviour. |
|
4474 return; |
|
4475 } |
|
4476 } |
|
4477 |
|
4478 event.preventDefault(); // Allows us to ask for this information when we get a report. |
|
4479 |
|
4480 window.console.log('Received HTML:\n\n', html); |
|
4481 window.console.log('Received plain text:\n\n', plainText); |
|
4482 |
|
4483 if (disableFormats) { |
|
4484 handleChange(insert(record.current, plainText)); |
|
4485 return; |
|
4486 } |
|
4487 |
|
4488 var transformed = formatTypes.reduce(function (accumlator, _ref3) { |
|
4489 var __unstablePasteRule = _ref3.__unstablePasteRule; |
|
4490 |
|
4491 // Only allow one transform. |
|
4492 if (__unstablePasteRule && accumlator === record.current) { |
|
4493 accumlator = __unstablePasteRule(record.current, { |
|
4494 html: html, |
|
4495 plainText: plainText |
|
4496 }); |
|
4497 } |
|
4498 |
|
4499 return accumlator; |
|
4500 }, record.current); |
|
4501 |
|
4502 if (transformed !== record.current) { |
|
4503 handleChange(transformed); |
|
4504 return; |
|
4505 } |
|
4506 |
|
4507 if (onPaste) { |
|
4508 files = Array.from(files); |
|
4509 Array.from(items).forEach(function (item) { |
|
4510 if (!item.getAsFile) { |
|
4511 return; |
|
4512 } |
|
4513 |
|
4514 var file = item.getAsFile(); |
|
4515 |
|
4516 if (!file) { |
|
4517 return; |
|
4518 } |
|
4519 |
|
4520 var name = file.name, |
|
4521 type = file.type, |
|
4522 size = file.size; |
|
4523 |
|
4524 if (!Object(external_this_lodash_["find"])(files, { |
|
4525 name: name, |
|
4526 type: type, |
|
4527 size: size |
|
4528 })) { |
|
4529 files.push(file); |
|
4530 } |
|
4531 }); |
|
4532 onPaste({ |
|
4533 value: removeEditorOnlyFormats(record.current), |
|
4534 onChange: handleChange, |
|
4535 html: html, |
|
4536 plainText: plainText, |
|
4537 files: files, |
|
4538 activeFormats: activeFormats |
|
4539 }); |
|
4540 } |
|
4541 } |
|
4542 /** |
|
4543 * Handles delete on keydown: |
|
4544 * - outdent list items, |
|
4545 * - delete content if everything is selected, |
|
4546 * - trigger the onDelete prop when selection is uncollapsed and at an edge. |
|
4547 * |
|
4548 * @param {WPSyntheticEvent} event A synthetic keyboard event. |
|
4549 */ |
|
4550 |
|
4551 |
|
4552 function handleDelete(event) { |
|
4553 var keyCode = event.keyCode; |
|
4554 |
|
4555 if (keyCode !== external_this_wp_keycodes_["DELETE"] && keyCode !== external_this_wp_keycodes_["BACKSPACE"] && keyCode !== external_this_wp_keycodes_["ESCAPE"]) { |
|
4556 return; |
|
4557 } |
|
4558 |
|
4559 if (didAutomaticChange) { |
|
4560 event.preventDefault(); |
|
4561 undo(); |
|
4562 return; |
|
4563 } |
|
4564 |
|
4565 if (keyCode === external_this_wp_keycodes_["ESCAPE"]) { |
|
4566 return; |
|
4567 } |
|
4568 |
|
4569 var currentValue = createRecord(); |
|
4570 var start = currentValue.start, |
|
4571 end = currentValue.end, |
|
4572 text = currentValue.text; |
|
4573 var isReverse = keyCode === external_this_wp_keycodes_["BACKSPACE"]; // Always handle full content deletion ourselves. |
|
4574 |
|
4575 if (start === 0 && end !== 0 && end === text.length) { |
|
4576 handleChange(remove_remove(currentValue)); |
|
4577 event.preventDefault(); |
|
4578 return; |
|
4579 } |
|
4580 |
|
4581 if (multilineTag) { |
|
4582 var newValue; // Check to see if we should remove the first item if empty. |
|
4583 |
|
4584 if (isReverse && currentValue.start === 0 && currentValue.end === 0 && isEmptyLine(currentValue)) { |
|
4585 newValue = removeLineSeparator(currentValue, !isReverse); |
|
4586 } else { |
|
4587 newValue = removeLineSeparator(currentValue, isReverse); |
|
4588 } |
|
4589 |
|
4590 if (newValue) { |
|
4591 handleChange(newValue); |
|
4592 event.preventDefault(); |
|
4593 return; |
|
4594 } |
|
4595 } // Only process delete if the key press occurs at an uncollapsed edge. |
|
4596 |
|
4597 |
|
4598 if (!onDelete || !isCollapsed(currentValue) || activeFormats.length || isReverse && start !== 0 || !isReverse && end !== text.length) { |
|
4599 return; |
|
4600 } |
|
4601 |
|
4602 onDelete({ |
|
4603 isReverse: isReverse, |
|
4604 value: currentValue |
|
4605 }); |
|
4606 event.preventDefault(); |
|
4607 } |
|
4608 /** |
|
4609 * Triggers the `onEnter` prop on keydown. |
|
4610 * |
|
4611 * @param {WPSyntheticEvent} event A synthetic keyboard event. |
|
4612 */ |
|
4613 |
|
4614 |
|
4615 function handleEnter(event) { |
|
4616 if (event.keyCode !== external_this_wp_keycodes_["ENTER"]) { |
|
4617 return; |
|
4618 } |
|
4619 |
|
4620 event.preventDefault(); |
|
4621 |
|
4622 if (!onEnter) { |
|
4623 return; |
|
4624 } |
|
4625 |
|
4626 onEnter({ |
|
4627 value: removeEditorOnlyFormats(createRecord()), |
|
4628 onChange: handleChange, |
|
4629 shiftKey: event.shiftKey |
|
4630 }); |
|
4631 } |
|
4632 /** |
|
4633 * Indents list items on space keydown. |
|
4634 * |
|
4635 * @param {WPSyntheticEvent} event A synthetic keyboard event. |
|
4636 */ |
|
4637 |
|
4638 |
|
4639 function handleSpace(event) { |
|
4640 var keyCode = event.keyCode, |
|
4641 shiftKey = event.shiftKey, |
|
4642 altKey = event.altKey, |
|
4643 metaKey = event.metaKey, |
|
4644 ctrlKey = event.ctrlKey; |
|
4645 |
|
4646 if ( // Only override when no modifiers are pressed. |
|
4647 shiftKey || altKey || metaKey || ctrlKey || keyCode !== external_this_wp_keycodes_["SPACE"] || multilineTag !== 'li') { |
|
4648 return; |
|
4649 } |
|
4650 |
|
4651 var currentValue = createRecord(); |
|
4652 |
|
4653 if (!isCollapsed(currentValue)) { |
|
4654 return; |
|
4655 } |
|
4656 |
|
4657 var text = currentValue.text, |
|
4658 start = currentValue.start; |
|
4659 var characterBefore = text[start - 1]; // The caret must be at the start of a line. |
|
4660 |
|
4661 if (characterBefore && characterBefore !== LINE_SEPARATOR) { |
|
4662 return; |
|
4663 } |
|
4664 |
|
4665 handleChange(indentListItems(currentValue, { |
|
4666 type: multilineRootTag |
|
4667 })); |
|
4668 event.preventDefault(); |
|
4669 } |
|
4670 /** |
|
4671 * Handles horizontal keyboard navigation when no modifiers are pressed. The |
|
4672 * navigation is handled separately to move correctly around format |
|
4673 * boundaries. |
|
4674 * |
|
4675 * @param {WPSyntheticEvent} event A synthetic keyboard event. |
|
4676 */ |
|
4677 |
|
4678 |
|
4679 function handleHorizontalNavigation(event) { |
|
4680 var keyCode = event.keyCode, |
|
4681 shiftKey = event.shiftKey, |
|
4682 altKey = event.altKey, |
|
4683 metaKey = event.metaKey, |
|
4684 ctrlKey = event.ctrlKey; |
|
4685 |
|
4686 if ( // Only override left and right keys without modifiers pressed. |
|
4687 shiftKey || altKey || metaKey || ctrlKey || keyCode !== external_this_wp_keycodes_["LEFT"] && keyCode !== external_this_wp_keycodes_["RIGHT"]) { |
|
4688 return; |
|
4689 } |
|
4690 |
|
4691 var _record$current = record.current, |
|
4692 text = _record$current.text, |
|
4693 formats = _record$current.formats, |
|
4694 start = _record$current.start, |
|
4695 end = _record$current.end, |
|
4696 _record$current$activ = _record$current.activeFormats, |
|
4697 currentActiveFormats = _record$current$activ === void 0 ? [] : _record$current$activ; |
|
4698 var collapsed = isCollapsed(record.current); // To do: ideally, we should look at visual position instead. |
|
4699 |
|
4700 var _getWin$getComputedSt = getWin().getComputedStyle(ref.current), |
|
4701 direction = _getWin$getComputedSt.direction; |
|
4702 |
|
4703 var reverseKey = direction === 'rtl' ? external_this_wp_keycodes_["RIGHT"] : external_this_wp_keycodes_["LEFT"]; |
|
4704 var isReverse = event.keyCode === reverseKey; // If the selection is collapsed and at the very start, do nothing if |
|
4705 // navigating backward. |
|
4706 // If the selection is collapsed and at the very end, do nothing if |
|
4707 // navigating forward. |
|
4708 |
|
4709 if (collapsed && currentActiveFormats.length === 0) { |
|
4710 if (start === 0 && isReverse) { |
|
4711 return; |
|
4712 } |
|
4713 |
|
4714 if (end === text.length && !isReverse) { |
|
4715 return; |
|
4716 } |
|
4717 } // If the selection is not collapsed, let the browser handle collapsing |
|
4718 // the selection for now. Later we could expand this logic to set |
|
4719 // boundary positions if needed. |
|
4720 |
|
4721 |
|
4722 if (!collapsed) { |
|
4723 return; |
|
4724 } // In all other cases, prevent default behaviour. |
|
4725 |
|
4726 |
|
4727 event.preventDefault(); |
|
4728 var formatsBefore = formats[start - 1] || EMPTY_ACTIVE_FORMATS; |
|
4729 var formatsAfter = formats[start] || EMPTY_ACTIVE_FORMATS; |
|
4730 var newActiveFormatsLength = currentActiveFormats.length; |
|
4731 var source = formatsAfter; |
|
4732 |
|
4733 if (formatsBefore.length > formatsAfter.length) { |
|
4734 source = formatsBefore; |
|
4735 } // If the amount of formats before the caret and after the caret is |
|
4736 // different, the caret is at a format boundary. |
|
4737 |
|
4738 |
|
4739 if (formatsBefore.length < formatsAfter.length) { |
|
4740 if (!isReverse && currentActiveFormats.length < formatsAfter.length) { |
|
4741 newActiveFormatsLength++; |
|
4742 } |
|
4743 |
|
4744 if (isReverse && currentActiveFormats.length > formatsBefore.length) { |
|
4745 newActiveFormatsLength--; |
|
4746 } |
|
4747 } else if (formatsBefore.length > formatsAfter.length) { |
|
4748 if (!isReverse && currentActiveFormats.length > formatsAfter.length) { |
|
4749 newActiveFormatsLength--; |
|
4750 } |
|
4751 |
|
4752 if (isReverse && currentActiveFormats.length < formatsBefore.length) { |
|
4753 newActiveFormatsLength++; |
|
4754 } |
|
4755 } |
|
4756 |
|
4757 if (newActiveFormatsLength !== currentActiveFormats.length) { |
|
4758 var _newActiveFormats = source.slice(0, newActiveFormatsLength); |
|
4759 |
|
4760 var _newValue = component_objectSpread({}, record.current, { |
|
4761 activeFormats: _newActiveFormats |
|
4762 }); |
|
4763 |
|
4764 record.current = _newValue; |
|
4765 applyRecord(_newValue); |
|
4766 setActiveFormats(_newActiveFormats); |
|
4767 return; |
|
4768 } |
|
4769 |
|
4770 var newPos = start + (isReverse ? -1 : 1); |
|
4771 var newActiveFormats = isReverse ? formatsBefore : formatsAfter; |
|
4772 |
|
4773 var newValue = component_objectSpread({}, record.current, { |
|
4774 start: newPos, |
|
4775 end: newPos, |
|
4776 activeFormats: newActiveFormats |
|
4777 }); |
|
4778 |
|
4779 record.current = newValue; |
|
4780 applyRecord(newValue); |
|
4781 onSelectionChange(newPos, newPos); |
|
4782 setActiveFormats(newActiveFormats); |
|
4783 } |
|
4784 |
|
4785 function handleKeyDown(event) { |
|
4786 if (event.defaultPrevented) { |
|
4787 return; |
|
4788 } |
|
4789 |
|
4790 handleDelete(event); |
|
4791 handleEnter(event); |
|
4792 handleSpace(event); |
|
4793 handleHorizontalNavigation(event); |
|
4794 } |
|
4795 |
|
4796 var lastHistoryValue = Object(external_this_wp_element_["useRef"])(value); |
|
4797 |
|
4798 function createUndoLevel() { |
|
4799 // If the content is the same, no level needs to be created. |
|
4800 if (lastHistoryValue.current === _value.current) { |
|
4801 return; |
|
4802 } |
|
4803 |
|
4804 onCreateUndoLevel(); |
|
4805 lastHistoryValue.current = _value.current; |
|
4806 } |
|
4807 |
|
4808 var isComposing = Object(external_this_wp_element_["useRef"])(false); |
|
4809 var timeout = Object(external_this_wp_element_["useRef"])(); |
|
4810 /** |
|
4811 * Handle input on the next selection change event. |
|
4812 * |
|
4813 * @param {WPSyntheticEvent} event Synthetic input event. |
|
4814 */ |
|
4815 |
|
4816 function handleInput(event) { |
|
4817 // Do not trigger a change if characters are being composed. Browsers |
|
4818 // will usually emit a final `input` event when the characters are |
|
4819 // composed. |
|
4820 // As of December 2019, Safari doesn't support nativeEvent.isComposing. |
|
4821 if (isComposing.current) { |
|
4822 return; |
|
4823 } |
|
4824 |
|
4825 var inputType; |
|
4826 |
|
4827 if (event) { |
|
4828 inputType = event.inputType; |
|
4829 } |
|
4830 |
|
4831 if (!inputType && event && event.nativeEvent) { |
|
4832 inputType = event.nativeEvent.inputType; |
|
4833 } // The browser formatted something or tried to insert HTML. |
|
4834 // Overwrite it. It will be handled later by the format library if |
|
4835 // needed. |
|
4836 |
|
4837 |
|
4838 if (inputType && (inputType.indexOf('format') === 0 || INSERTION_INPUT_TYPES_TO_IGNORE.has(inputType))) { |
|
4839 applyRecord(record.current); |
|
4840 return; |
|
4841 } |
|
4842 |
|
4843 var currentValue = createRecord(); |
|
4844 var _record$current2 = record.current, |
|
4845 start = _record$current2.start, |
|
4846 _record$current2$acti = _record$current2.activeFormats, |
|
4847 oldActiveFormats = _record$current2$acti === void 0 ? [] : _record$current2$acti; // Update the formats between the last and new caret position. |
|
4848 |
|
4849 var change = updateFormats({ |
|
4850 value: currentValue, |
|
4851 start: start, |
|
4852 end: currentValue.start, |
|
4853 formats: oldActiveFormats |
|
4854 }); |
|
4855 handleChange(change, { |
|
4856 withoutHistory: true |
|
4857 }); // Create an undo level when input stops for over a second. |
|
4858 |
|
4859 getWin().clearTimeout(timeout.current); |
|
4860 timeout.current = getWin().setTimeout(createUndoLevel, 1000); // Only run input rules when inserting text. |
|
4861 |
|
4862 if (inputType !== 'insertText') { |
|
4863 return; |
|
4864 } |
|
4865 |
|
4866 if (allowPrefixTransformations && inputRule) { |
|
4867 inputRule(change, valueToFormat); |
|
4868 } |
|
4869 |
|
4870 var transformed = formatTypes.reduce(function (accumlator, _ref4) { |
|
4871 var __unstableInputRule = _ref4.__unstableInputRule; |
|
4872 |
|
4873 if (__unstableInputRule) { |
|
4874 accumlator = __unstableInputRule(accumlator); |
|
4875 } |
|
4876 |
|
4877 return accumlator; |
|
4878 }, change); |
|
4879 |
|
4880 if (transformed !== change) { |
|
4881 createUndoLevel(); |
|
4882 handleChange(component_objectSpread({}, transformed, { |
|
4883 activeFormats: oldActiveFormats |
|
4884 })); |
|
4885 markAutomaticChange(); |
|
4886 } |
|
4887 } |
|
4888 |
|
4889 function handleCompositionStart() { |
|
4890 isComposing.current = true; // Do not update the selection when characters are being composed as |
|
4891 // this rerenders the component and might distroy internal browser |
|
4892 // editing state. |
|
4893 |
|
4894 getDoc().removeEventListener('selectionchange', handleSelectionChange); |
|
4895 } |
|
4896 |
|
4897 function handleCompositionEnd() { |
|
4898 isComposing.current = false; // Ensure the value is up-to-date for browsers that don't emit a final |
|
4899 // input event after composition. |
|
4900 |
|
4901 handleInput({ |
|
4902 inputType: 'insertText' |
|
4903 }); // Tracking selection changes can be resumed. |
|
4904 |
|
4905 getDoc().addEventListener('selectionchange', handleSelectionChange); |
|
4906 } |
|
4907 |
|
4908 var didMount = Object(external_this_wp_element_["useRef"])(false); |
|
4909 /** |
|
4910 * Syncs the selection to local state. A callback for the `selectionchange` |
|
4911 * native events, `keyup`, `mouseup` and `touchend` synthetic events, and |
|
4912 * animation frames after the `focus` event. |
|
4913 * |
|
4914 * @param {Event|WPSyntheticEvent|DOMHighResTimeStamp} event |
|
4915 */ |
|
4916 |
|
4917 function handleSelectionChange(event) { |
|
4918 if (!ref.current) { |
|
4919 return; |
|
4920 } |
|
4921 |
|
4922 if (document.activeElement !== ref.current) { |
|
4923 return; |
|
4924 } |
|
4925 |
|
4926 if (event.type !== 'selectionchange' && !isSelected) { |
|
4927 return; |
|
4928 } |
|
4929 |
|
4930 if (disabled) { |
|
4931 return; |
|
4932 } // In case of a keyboard event, ignore selection changes during |
|
4933 // composition. |
|
4934 |
|
4935 |
|
4936 if (isComposing.current) { |
|
4937 return; |
|
4938 } |
|
4939 |
|
4940 var _createRecord = createRecord(), |
|
4941 start = _createRecord.start, |
|
4942 end = _createRecord.end, |
|
4943 text = _createRecord.text; |
|
4944 |
|
4945 var oldRecord = record.current; // Fallback mechanism for IE11, which doesn't support the input event. |
|
4946 // Any input results in a selection change. |
|
4947 |
|
4948 if (text !== oldRecord.text) { |
|
4949 handleInput(); |
|
4950 return; |
|
4951 } |
|
4952 |
|
4953 if (start === oldRecord.start && end === oldRecord.end) { |
|
4954 // Sometimes the browser may set the selection on the placeholder |
|
4955 // element, in which case the caret is not visible. We need to set |
|
4956 // the caret before the placeholder if that's the case. |
|
4957 if (oldRecord.text.length === 0 && start === 0) { |
|
4958 fixPlaceholderSelection(getWin()); |
|
4959 } |
|
4960 |
|
4961 return; |
|
4962 } |
|
4963 |
|
4964 var newValue = component_objectSpread({}, oldRecord, { |
|
4965 start: start, |
|
4966 end: end, |
|
4967 // Allow `getActiveFormats` to get new `activeFormats`. |
|
4968 activeFormats: undefined |
|
4969 }); |
|
4970 |
|
4971 var newActiveFormats = getActiveFormats(newValue, EMPTY_ACTIVE_FORMATS); // Update the value with the new active formats. |
|
4972 |
|
4973 newValue.activeFormats = newActiveFormats; |
|
4974 |
|
4975 if (!isCaretWithinFormattedText && newActiveFormats.length) { |
|
4976 onEnterFormattedText(); |
|
4977 } else if (isCaretWithinFormattedText && !newActiveFormats.length) { |
|
4978 onExitFormattedText(); |
|
4979 } // It is important that the internal value is updated first, |
|
4980 // otherwise the value will be wrong on render! |
|
4981 |
|
4982 |
|
4983 record.current = newValue; |
|
4984 applyRecord(newValue, { |
|
4985 domOnly: true |
|
4986 }); |
|
4987 onSelectionChange(start, end); |
|
4988 setActiveFormats(newActiveFormats); |
|
4989 } |
|
4990 /** |
|
4991 * Sync the value to global state. The node tree and selection will also be |
|
4992 * updated if differences are found. |
|
4993 * |
|
4994 * @param {Object} newRecord The record to sync and apply. |
|
4995 * @param {Object} $2 Named options. |
|
4996 * @param {boolean} $2.withoutHistory If true, no undo level will be |
|
4997 * created. |
|
4998 */ |
|
4999 |
|
5000 |
|
5001 function handleChange(newRecord) { |
|
5002 var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, |
|
5003 withoutHistory = _ref5.withoutHistory; |
|
5004 |
|
5005 if (disableFormats) { |
|
5006 newRecord.formats = Array(newRecord.text.length); |
|
5007 newRecord.replacements = Array(newRecord.text.length); |
|
5008 } |
|
5009 |
|
5010 applyRecord(newRecord); |
|
5011 var start = newRecord.start, |
|
5012 end = newRecord.end, |
|
5013 _newRecord$activeForm = newRecord.activeFormats, |
|
5014 newActiveFormats = _newRecord$activeForm === void 0 ? [] : _newRecord$activeForm; |
|
5015 var changeHandlers = Object(external_this_lodash_["pickBy"])(remainingProps, function (v, key) { |
|
5016 return key.startsWith('format_on_change_functions_'); |
|
5017 }); |
|
5018 Object.values(changeHandlers).forEach(function (changeHandler) { |
|
5019 changeHandler(newRecord.formats, newRecord.text); |
|
5020 }); |
|
5021 _value.current = valueToFormat(newRecord); |
|
5022 record.current = newRecord; // Selection must be updated first, so it is recorded in history when |
|
5023 // the content change happens. |
|
5024 |
|
5025 onSelectionChange(start, end); |
|
5026 onChange(_value.current); |
|
5027 setActiveFormats(newActiveFormats); |
|
5028 |
|
5029 if (!withoutHistory) { |
|
5030 createUndoLevel(); |
|
5031 } |
|
5032 } |
|
5033 /** |
|
5034 * Select object when they are clicked. The browser will not set any |
|
5035 * selection when clicking e.g. an image. |
|
5036 * |
|
5037 * @param {WPSyntheticEvent} event Synthetic mousedown or touchstart event. |
|
5038 */ |
|
5039 |
|
5040 |
|
5041 function handlePointerDown(event) { |
|
5042 var target = event.target; // If the child element has no text content, it must be an object. |
|
5043 |
|
5044 if (target === ref.current || target.textContent) { |
|
5045 return; |
|
5046 } |
|
5047 |
|
5048 var parentNode = target.parentNode; |
|
5049 var index = Array.from(parentNode.childNodes).indexOf(target); |
|
5050 var range = getDoc().createRange(); |
|
5051 var selection = getWin().getSelection(); |
|
5052 range.setStart(target.parentNode, index); |
|
5053 range.setEnd(target.parentNode, index + 1); |
|
5054 selection.removeAllRanges(); |
|
5055 selection.addRange(range); |
|
5056 } |
|
5057 |
|
5058 var rafId = Object(external_this_wp_element_["useRef"])(); |
|
5059 /** |
|
5060 * Handles a focus event on the contenteditable field, calling the |
|
5061 * `unstableOnFocus` prop callback if one is defined. The callback does not |
|
5062 * receive any arguments. |
|
5063 * |
|
5064 * This is marked as a private API and the `unstableOnFocus` prop is not |
|
5065 * documented, as the current requirements where it is used are subject to |
|
5066 * future refactoring following `isSelected` handling. |
|
5067 * |
|
5068 * In contrast with `setFocusedElement`, this is only triggered in response |
|
5069 * to focus within the contenteditable field, whereas `setFocusedElement` |
|
5070 * is triggered on focus within any `RichText` descendent element. |
|
5071 * |
|
5072 * @see setFocusedElement |
|
5073 * |
|
5074 * @private |
|
5075 */ |
|
5076 |
|
5077 function handleFocus() { |
|
5078 if (onFocus) { |
|
5079 onFocus(); |
|
5080 } |
|
5081 |
|
5082 if (!isSelected) { |
|
5083 // We know for certain that on focus, the old selection is invalid. |
|
5084 // It will be recalculated on the next mouseup, keyup, or touchend |
|
5085 // event. |
|
5086 var index = undefined; |
|
5087 record.current = component_objectSpread({}, record.current, { |
|
5088 start: index, |
|
5089 end: index, |
|
5090 activeFormats: EMPTY_ACTIVE_FORMATS |
|
5091 }); |
|
5092 onSelectionChange(index, index); |
|
5093 setActiveFormats(EMPTY_ACTIVE_FORMATS); |
|
5094 } else { |
|
5095 onSelectionChange(record.current.start, record.current.end); |
|
5096 setActiveFormats(getActiveFormats(component_objectSpread({}, record.current, { |
|
5097 activeFormats: undefined |
|
5098 }), EMPTY_ACTIVE_FORMATS)); |
|
5099 } // Update selection as soon as possible, which is at the next animation |
|
5100 // frame. The event listener for selection changes may be added too late |
|
5101 // at this point, but this focus event is still too early to calculate |
|
5102 // the selection. |
|
5103 |
|
5104 |
|
5105 rafId.current = getWin().requestAnimationFrame(handleSelectionChange); |
|
5106 getDoc().addEventListener('selectionchange', handleSelectionChange); |
|
5107 |
|
5108 if (setFocusedElement) { |
|
5109 external_this_wp_deprecated_default()('wp.blockEditor.RichText setFocusedElement prop', { |
|
5110 alternative: 'selection state from the block editor store.' |
|
5111 }); |
|
5112 setFocusedElement(instanceId); |
|
5113 } |
|
5114 } |
|
5115 |
|
5116 function handleBlur() { |
|
5117 getDoc().removeEventListener('selectionchange', handleSelectionChange); |
|
5118 } |
|
5119 |
|
5120 function applyFromProps() { |
|
5121 _value.current = value; |
|
5122 record.current = formatToValue(value); |
|
5123 record.current.start = selectionStart; |
|
5124 record.current.end = selectionEnd; |
|
5125 applyRecord(record.current); |
|
5126 } |
|
5127 |
|
5128 Object(external_this_wp_element_["useEffect"])(function () { |
|
5129 if (didMount.current) { |
|
5130 applyFromProps(); |
|
5131 } |
|
5132 }, [TagName, placeholder]); |
|
5133 Object(external_this_wp_element_["useEffect"])(function () { |
|
5134 if (didMount.current && value !== _value.current) { |
|
5135 applyFromProps(); |
|
5136 } |
|
5137 }, [value]); |
|
5138 Object(external_this_wp_element_["useEffect"])(function () { |
|
5139 if (!didMount.current) { |
|
5140 return; |
|
5141 } |
|
5142 |
|
5143 if (isSelected && (selectionStart !== record.current.start || selectionEnd !== record.current.end)) { |
|
5144 applyFromProps(); |
|
5145 } else { |
|
5146 record.current = component_objectSpread({}, record.current, { |
|
5147 start: selectionStart, |
|
5148 end: selectionEnd |
|
5149 }); |
|
5150 } |
|
5151 }, [selectionStart, selectionEnd, isSelected]); |
|
5152 var prefix = 'format_prepare_props_'; |
|
5153 |
|
5154 var predicate = function predicate(v, key) { |
|
5155 return key.startsWith(prefix); |
|
5156 }; |
|
5157 |
|
5158 var prepareProps = Object(external_this_lodash_["pickBy"])(remainingProps, predicate); |
|
5159 Object(external_this_wp_element_["useEffect"])(function () { |
|
5160 if (didMount.current) { |
|
5161 applyFromProps(); |
|
5162 } |
|
5163 }, Object.values(prepareProps)); |
|
5164 Object(external_this_wp_element_["useLayoutEffect"])(function () { |
|
5165 applyRecord(record.current, { |
|
5166 domOnly: true |
|
5167 }); |
|
5168 didMount.current = true; |
|
5169 return function () { |
|
5170 getDoc().removeEventListener('selectionchange', handleSelectionChange); |
|
5171 getWin().cancelAnimationFrame(rafId.current); |
|
5172 getWin().clearTimeout(timeout.current); |
|
5173 }; |
|
5174 }, []); |
|
5175 |
|
5176 function focus() { |
|
5177 ref.current.focus(); |
|
5178 applyRecord(record.current); |
|
5179 } |
|
5180 |
|
5181 var ariaProps = Object(external_this_lodash_["pickBy"])(remainingProps, function (v, key) { |
|
5182 return Object(external_this_lodash_["startsWith"])(key, 'aria-'); |
|
5183 }); |
|
5184 |
|
5185 var editableProps = component_objectSpread({ |
|
5186 // Overridable props. |
|
5187 role: 'textbox', |
|
5188 'aria-multiline': true, |
|
5189 'aria-label': placeholder |
|
5190 }, ariaProps, { |
|
5191 ref: ref, |
|
5192 style: style ? component_objectSpread({}, style, { |
|
5193 whiteSpace: whiteSpace |
|
5194 }) : defaultStyle, |
|
5195 className: classnames_default()('rich-text', className), |
|
5196 onPaste: handlePaste, |
|
5197 onInput: handleInput, |
|
5198 onCompositionStart: handleCompositionStart, |
|
5199 onCompositionEnd: handleCompositionEnd, |
|
5200 onKeyDown: handleKeyDown, |
|
5201 onFocus: handleFocus, |
|
5202 onBlur: handleBlur, |
|
5203 onMouseDown: handlePointerDown, |
|
5204 onTouchStart: handlePointerDown, |
|
5205 // Selection updates must be done at these events as they |
|
5206 // happen before the `selectionchange` event. In some cases, |
|
5207 // the `selectionchange` event may not even fire, for |
|
5208 // example when the window receives focus again on click. |
|
5209 onKeyUp: handleSelectionChange, |
|
5210 onMouseUp: handleSelectionChange, |
|
5211 onTouchEnd: handleSelectionChange, |
|
5212 // Do not set the attribute if disabled. |
|
5213 contentEditable: disabled ? undefined : true, |
|
5214 suppressContentEditableWarning: !disabled |
|
5215 }); |
|
5216 |
|
5217 useBoundaryStyle({ |
|
5218 ref: ref, |
|
5219 activeFormats: activeFormats |
|
5220 }); |
|
5221 useInlineWarning({ |
|
5222 ref: ref |
|
5223 }); |
|
5224 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, isSelected && Object(external_this_wp_element_["createElement"])(FormatEdit, { |
|
5225 allowedFormats: allowedFormats, |
|
5226 withoutInteractiveFormatting: withoutInteractiveFormatting, |
|
5227 value: record.current, |
|
5228 onChange: handleChange, |
|
5229 onFocus: focus, |
|
5230 formatTypes: formatTypes |
|
5231 }), children && children({ |
|
5232 isSelected: isSelected, |
|
5233 value: record.current, |
|
5234 onChange: handleChange, |
|
5235 onFocus: focus, |
|
5236 editableProps: editableProps, |
|
5237 editableTagName: TagName |
|
5238 }), !children && Object(external_this_wp_element_["createElement"])(TagName, editableProps)); |
|
5239 } |
|
5240 |
|
5241 var RichTextWrapper = withFormatTypes(component_RichText); |
|
5242 /** |
|
5243 * Renders a rich content input, providing users with the option to format the |
|
5244 * content. |
|
5245 */ |
|
5246 |
|
5247 /* harmony default export */ var component = (Object(external_this_wp_element_["forwardRef"])(function (props, ref) { |
|
5248 return Object(external_this_wp_element_["createElement"])(RichTextWrapper, Object(esm_extends["a" /* default */])({}, props, { |
|
5249 forwardedRef: ref |
|
5250 })); |
|
5251 })); |
|
5252 |
|
3490 // CONCATENATED MODULE: ./node_modules/@wordpress/rich-text/build-module/index.js |
5253 // 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 /** |
5254 /** |
3526 * Internal dependencies |
5255 * Internal dependencies |
3527 */ |
5256 */ |
3528 |
5257 |
3529 |
5258 |
3558 |
5287 |
3559 |
5288 |
3560 |
5289 |
3561 |
5290 |
3562 |
5291 |
5292 |
|
5293 |
|
3563 /***/ }), |
5294 /***/ }), |
3564 |
5295 |
3565 /***/ 41: |
5296 /***/ 5: |
3566 /***/ (function(module, exports, __webpack_require__) { |
5297 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
3567 |
5298 |
3568 module.exports = function memize( fn, options ) { |
5299 "use strict"; |
3569 var size = 0, |
5300 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; }); |
3570 maxSize, head, tail; |
5301 function _defineProperty(obj, key, value) { |
3571 |
5302 if (key in obj) { |
3572 if ( options && options.maxSize ) { |
5303 Object.defineProperty(obj, key, { |
3573 maxSize = options.maxSize; |
5304 value: value, |
3574 } |
5305 enumerable: true, |
3575 |
5306 configurable: true, |
3576 function memoized( /* ...args */ ) { |
5307 writable: true |
3577 var node = head, |
5308 }); |
3578 len = arguments.length, |
5309 } else { |
3579 args, i; |
5310 obj[key] = value; |
3580 |
5311 } |
3581 searchCache: while ( node ) { |
5312 |
3582 // Perform a shallow equality test to confirm that whether the node |
5313 return obj; |
3583 // under test is a candidate for the arguments passed. Two arrays |
5314 } |
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 |
5315 |
3681 /***/ }), |
5316 /***/ }), |
3682 |
5317 |
3683 /***/ 5: |
5318 /***/ 8: |
5319 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
5320 |
|
5321 "use strict"; |
|
5322 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; }); |
|
5323 function _extends() { |
|
5324 _extends = Object.assign || function (target) { |
|
5325 for (var i = 1; i < arguments.length; i++) { |
|
5326 var source = arguments[i]; |
|
5327 |
|
5328 for (var key in source) { |
|
5329 if (Object.prototype.hasOwnProperty.call(source, key)) { |
|
5330 target[key] = source[key]; |
|
5331 } |
|
5332 } |
|
5333 } |
|
5334 |
|
5335 return target; |
|
5336 }; |
|
5337 |
|
5338 return _extends.apply(this, arguments); |
|
5339 } |
|
5340 |
|
5341 /***/ }), |
|
5342 |
|
5343 /***/ 89: |
|
3684 /***/ (function(module, exports) { |
5344 /***/ (function(module, exports) { |
3685 |
5345 |
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"]; }()); |
5346 (function() { module.exports = this["wp"]["escapeHtml"]; }()); |
3701 |
5347 |
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 /***/ }) |
5348 /***/ }) |
3731 |
5349 |
3732 /******/ }); |
5350 /******/ }); |