changeset 9 | 177826044cd9 |
child 16 | a86126ab1dd4 |
8:c7c34916027a | 9:177826044cd9 |
---|---|
1 this["wp"] = this["wp"] || {}; this["wp"]["blockEditor"] = |
|
2 /******/ (function(modules) { // webpackBootstrap |
|
3 /******/ // The module cache |
|
4 /******/ var installedModules = {}; |
|
5 /******/ |
|
6 /******/ // The require function |
|
7 /******/ function __webpack_require__(moduleId) { |
|
8 /******/ |
|
9 /******/ // Check if module is in cache |
|
10 /******/ if(installedModules[moduleId]) { |
|
11 /******/ return installedModules[moduleId].exports; |
|
12 /******/ } |
|
13 /******/ // Create a new module (and put it into the cache) |
|
14 /******/ var module = installedModules[moduleId] = { |
|
15 /******/ i: moduleId, |
|
16 /******/ l: false, |
|
17 /******/ exports: {} |
|
18 /******/ }; |
|
19 /******/ |
|
20 /******/ // Execute the module function |
|
21 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
|
22 /******/ |
|
23 /******/ // Flag the module as loaded |
|
24 /******/ module.l = true; |
|
25 /******/ |
|
26 /******/ // Return the exports of the module |
|
27 /******/ return module.exports; |
|
28 /******/ } |
|
29 /******/ |
|
30 /******/ |
|
31 /******/ // expose the modules object (__webpack_modules__) |
|
32 /******/ __webpack_require__.m = modules; |
|
33 /******/ |
|
34 /******/ // expose the module cache |
|
35 /******/ __webpack_require__.c = installedModules; |
|
36 /******/ |
|
37 /******/ // define getter function for harmony exports |
|
38 /******/ __webpack_require__.d = function(exports, name, getter) { |
|
39 /******/ if(!__webpack_require__.o(exports, name)) { |
|
40 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); |
|
41 /******/ } |
|
42 /******/ }; |
|
43 /******/ |
|
44 /******/ // define __esModule on exports |
|
45 /******/ __webpack_require__.r = function(exports) { |
|
46 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
|
47 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
|
48 /******/ } |
|
49 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
|
50 /******/ }; |
|
51 /******/ |
|
52 /******/ // create a fake namespace object |
|
53 /******/ // mode & 1: value is a module id, require it |
|
54 /******/ // mode & 2: merge all properties of value into the ns |
|
55 /******/ // mode & 4: return value when already ns object |
|
56 /******/ // mode & 8|1: behave like require |
|
57 /******/ __webpack_require__.t = function(value, mode) { |
|
58 /******/ if(mode & 1) value = __webpack_require__(value); |
|
59 /******/ if(mode & 8) return value; |
|
60 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; |
|
61 /******/ var ns = Object.create(null); |
|
62 /******/ __webpack_require__.r(ns); |
|
63 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); |
|
64 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); |
|
65 /******/ return ns; |
|
66 /******/ }; |
|
67 /******/ |
|
68 /******/ // getDefaultExport function for compatibility with non-harmony modules |
|
69 /******/ __webpack_require__.n = function(module) { |
|
70 /******/ var getter = module && module.__esModule ? |
|
71 /******/ function getDefault() { return module['default']; } : |
|
72 /******/ function getModuleExports() { return module; }; |
|
73 /******/ __webpack_require__.d(getter, 'a', getter); |
|
74 /******/ return getter; |
|
75 /******/ }; |
|
76 /******/ |
|
77 /******/ // Object.prototype.hasOwnProperty.call |
|
78 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; |
|
79 /******/ |
|
80 /******/ // __webpack_public_path__ |
|
81 /******/ __webpack_require__.p = ""; |
|
82 /******/ |
|
83 /******/ |
|
84 /******/ // Load entry module and return exports |
|
85 /******/ return __webpack_require__(__webpack_require__.s = 357); |
|
86 /******/ }) |
|
87 /************************************************************************/ |
|
88 /******/ ({ |
|
89 |
|
90 /***/ 0: |
|
91 /***/ (function(module, exports) { |
|
92 |
|
93 (function() { module.exports = this["wp"]["element"]; }()); |
|
94 |
|
95 /***/ }), |
|
96 |
|
97 /***/ 1: |
|
98 /***/ (function(module, exports) { |
|
99 |
|
100 (function() { module.exports = this["wp"]["i18n"]; }()); |
|
101 |
|
102 /***/ }), |
|
103 |
|
104 /***/ 10: |
|
105 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
106 |
|
107 "use strict"; |
|
108 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; }); |
|
109 function _classCallCheck(instance, Constructor) { |
|
110 if (!(instance instanceof Constructor)) { |
|
111 throw new TypeError("Cannot call a class as a function"); |
|
112 } |
|
113 } |
|
114 |
|
115 /***/ }), |
|
116 |
|
117 /***/ 11: |
|
118 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
119 |
|
120 "use strict"; |
|
121 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _possibleConstructorReturn; }); |
|
122 /* harmony import */ var _helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(32); |
|
123 /* harmony import */ var _assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3); |
|
124 |
|
125 |
|
126 function _possibleConstructorReturn(self, call) { |
|
127 if (call && (Object(_helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(call) === "object" || typeof call === "function")) { |
|
128 return call; |
|
129 } |
|
130 |
|
131 return Object(_assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(self); |
|
132 } |
|
133 |
|
134 /***/ }), |
|
135 |
|
136 /***/ 111: |
|
137 /***/ (function(module, exports, __webpack_require__) { |
|
138 |
|
139 "use strict"; |
|
140 |
|
141 var __extends = (this && this.__extends) || (function () { |
|
142 var extendStatics = Object.setPrototypeOf || |
|
143 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
|
144 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; |
|
145 return function (d, b) { |
|
146 extendStatics(d, b); |
|
147 function __() { this.constructor = d; } |
|
148 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
|
149 }; |
|
150 })(); |
|
151 var __assign = (this && this.__assign) || Object.assign || function(t) { |
|
152 for (var s, i = 1, n = arguments.length; i < n; i++) { |
|
153 s = arguments[i]; |
|
154 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) |
|
155 t[p] = s[p]; |
|
156 } |
|
157 return t; |
|
158 }; |
|
159 var __rest = (this && this.__rest) || function (s, e) { |
|
160 var t = {}; |
|
161 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) |
|
162 t[p] = s[p]; |
|
163 if (s != null && typeof Object.getOwnPropertySymbols === "function") |
|
164 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) |
|
165 t[p[i]] = s[p[i]]; |
|
166 return t; |
|
167 }; |
|
168 exports.__esModule = true; |
|
169 var React = __webpack_require__(27); |
|
170 var PropTypes = __webpack_require__(31); |
|
171 var autosize = __webpack_require__(112); |
|
172 var _getLineHeight = __webpack_require__(113); |
|
173 var getLineHeight = _getLineHeight; |
|
174 var UPDATE = 'autosize:update'; |
|
175 var DESTROY = 'autosize:destroy'; |
|
176 var RESIZED = 'autosize:resized'; |
|
177 /** |
|
178 * A light replacement for built-in textarea component |
|
179 * which automaticaly adjusts its height to match the content |
|
180 */ |
|
181 var TextareaAutosize = /** @class */ (function (_super) { |
|
182 __extends(TextareaAutosize, _super); |
|
183 function TextareaAutosize() { |
|
184 var _this = _super !== null && _super.apply(this, arguments) || this; |
|
185 _this.state = { |
|
186 lineHeight: null |
|
187 }; |
|
188 _this.dispatchEvent = function (EVENT_TYPE) { |
|
189 var event = document.createEvent('Event'); |
|
190 event.initEvent(EVENT_TYPE, true, false); |
|
191 _this.textarea.dispatchEvent(event); |
|
192 }; |
|
193 _this.updateLineHeight = function () { |
|
194 _this.setState({ |
|
195 lineHeight: getLineHeight(_this.textarea) |
|
196 }); |
|
197 }; |
|
198 _this.onChange = function (e) { |
|
199 var onChange = _this.props.onChange; |
|
200 _this.currentValue = e.currentTarget.value; |
|
201 onChange && onChange(e); |
|
202 }; |
|
203 _this.saveDOMNodeRef = function (ref) { |
|
204 var innerRef = _this.props.innerRef; |
|
205 if (innerRef) { |
|
206 innerRef(ref); |
|
207 } |
|
208 _this.textarea = ref; |
|
209 }; |
|
210 _this.getLocals = function () { |
|
211 var _a = _this, _b = _a.props, onResize = _b.onResize, maxRows = _b.maxRows, onChange = _b.onChange, style = _b.style, innerRef = _b.innerRef, props = __rest(_b, ["onResize", "maxRows", "onChange", "style", "innerRef"]), lineHeight = _a.state.lineHeight, saveDOMNodeRef = _a.saveDOMNodeRef; |
|
212 var maxHeight = maxRows && lineHeight ? lineHeight * maxRows : null; |
|
213 return __assign({}, props, { saveDOMNodeRef: saveDOMNodeRef, style: maxHeight ? __assign({}, style, { maxHeight: maxHeight }) : style, onChange: _this.onChange }); |
|
214 }; |
|
215 return _this; |
|
216 } |
|
217 TextareaAutosize.prototype.componentDidMount = function () { |
|
218 var _this = this; |
|
219 var _a = this.props, onResize = _a.onResize, maxRows = _a.maxRows; |
|
220 if (typeof maxRows === 'number') { |
|
221 this.updateLineHeight(); |
|
222 } |
|
223 /* |
|
224 the defer is needed to: |
|
225 - force "autosize" to activate the scrollbar when this.props.maxRows is passed |
|
226 - support StyledComponents (see #71) |
|
227 */ |
|
228 setTimeout(function () { return autosize(_this.textarea); }); |
|
229 if (onResize) { |
|
230 this.textarea.addEventListener(RESIZED, onResize); |
|
231 } |
|
232 }; |
|
233 TextareaAutosize.prototype.componentWillUnmount = function () { |
|
234 var onResize = this.props.onResize; |
|
235 if (onResize) { |
|
236 this.textarea.removeEventListener(RESIZED, onResize); |
|
237 } |
|
238 this.dispatchEvent(DESTROY); |
|
239 }; |
|
240 TextareaAutosize.prototype.render = function () { |
|
241 var _a = this.getLocals(), children = _a.children, saveDOMNodeRef = _a.saveDOMNodeRef, locals = __rest(_a, ["children", "saveDOMNodeRef"]); |
|
242 return (React.createElement("textarea", __assign({}, locals, { ref: saveDOMNodeRef }), children)); |
|
243 }; |
|
244 TextareaAutosize.prototype.componentDidUpdate = function (prevProps) { |
|
245 if (this.props.value !== this.currentValue || this.props.rows !== prevProps.rows) { |
|
246 this.dispatchEvent(UPDATE); |
|
247 } |
|
248 }; |
|
249 TextareaAutosize.defaultProps = { |
|
250 rows: 1 |
|
251 }; |
|
252 TextareaAutosize.propTypes = { |
|
253 rows: PropTypes.number, |
|
254 maxRows: PropTypes.number, |
|
255 onResize: PropTypes.func, |
|
256 innerRef: PropTypes.func |
|
257 }; |
|
258 return TextareaAutosize; |
|
259 }(React.Component)); |
|
260 exports["default"] = TextareaAutosize; |
|
261 |
|
262 |
|
263 /***/ }), |
|
264 |
|
265 /***/ 112: |
|
266 /***/ (function(module, exports, __webpack_require__) { |
|
267 |
|
268 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! |
|
269 autosize 4.0.2 |
|
270 license: MIT |
|
271 http://www.jacklmoore.com/autosize |
|
272 */ |
|
273 (function (global, factory) { |
|
274 if (true) { |
|
275 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), |
|
276 __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? |
|
277 (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), |
|
278 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); |
|
279 } else { var mod; } |
|
280 })(this, function (module, exports) { |
|
281 'use strict'; |
|
282 |
|
283 var map = typeof Map === "function" ? new Map() : function () { |
|
284 var keys = []; |
|
285 var values = []; |
|
286 |
|
287 return { |
|
288 has: function has(key) { |
|
289 return keys.indexOf(key) > -1; |
|
290 }, |
|
291 get: function get(key) { |
|
292 return values[keys.indexOf(key)]; |
|
293 }, |
|
294 set: function set(key, value) { |
|
295 if (keys.indexOf(key) === -1) { |
|
296 keys.push(key); |
|
297 values.push(value); |
|
298 } |
|
299 }, |
|
300 delete: function _delete(key) { |
|
301 var index = keys.indexOf(key); |
|
302 if (index > -1) { |
|
303 keys.splice(index, 1); |
|
304 values.splice(index, 1); |
|
305 } |
|
306 } |
|
307 }; |
|
308 }(); |
|
309 |
|
310 var createEvent = function createEvent(name) { |
|
311 return new Event(name, { bubbles: true }); |
|
312 }; |
|
313 try { |
|
314 new Event('test'); |
|
315 } catch (e) { |
|
316 // IE does not support `new Event()` |
|
317 createEvent = function createEvent(name) { |
|
318 var evt = document.createEvent('Event'); |
|
319 evt.initEvent(name, true, false); |
|
320 return evt; |
|
321 }; |
|
322 } |
|
323 |
|
324 function assign(ta) { |
|
325 if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || map.has(ta)) return; |
|
326 |
|
327 var heightOffset = null; |
|
328 var clientWidth = null; |
|
329 var cachedHeight = null; |
|
330 |
|
331 function init() { |
|
332 var style = window.getComputedStyle(ta, null); |
|
333 |
|
334 if (style.resize === 'vertical') { |
|
335 ta.style.resize = 'none'; |
|
336 } else if (style.resize === 'both') { |
|
337 ta.style.resize = 'horizontal'; |
|
338 } |
|
339 |
|
340 if (style.boxSizing === 'content-box') { |
|
341 heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom)); |
|
342 } else { |
|
343 heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth); |
|
344 } |
|
345 // Fix when a textarea is not on document body and heightOffset is Not a Number |
|
346 if (isNaN(heightOffset)) { |
|
347 heightOffset = 0; |
|
348 } |
|
349 |
|
350 update(); |
|
351 } |
|
352 |
|
353 function changeOverflow(value) { |
|
354 { |
|
355 // Chrome/Safari-specific fix: |
|
356 // When the textarea y-overflow is hidden, Chrome/Safari do not reflow the text to account for the space |
|
357 // made available by removing the scrollbar. The following forces the necessary text reflow. |
|
358 var width = ta.style.width; |
|
359 ta.style.width = '0px'; |
|
360 // Force reflow: |
|
361 /* jshint ignore:start */ |
|
362 ta.offsetWidth; |
|
363 /* jshint ignore:end */ |
|
364 ta.style.width = width; |
|
365 } |
|
366 |
|
367 ta.style.overflowY = value; |
|
368 } |
|
369 |
|
370 function getParentOverflows(el) { |
|
371 var arr = []; |
|
372 |
|
373 while (el && el.parentNode && el.parentNode instanceof Element) { |
|
374 if (el.parentNode.scrollTop) { |
|
375 arr.push({ |
|
376 node: el.parentNode, |
|
377 scrollTop: el.parentNode.scrollTop |
|
378 }); |
|
379 } |
|
380 el = el.parentNode; |
|
381 } |
|
382 |
|
383 return arr; |
|
384 } |
|
385 |
|
386 function resize() { |
|
387 if (ta.scrollHeight === 0) { |
|
388 // If the scrollHeight is 0, then the element probably has display:none or is detached from the DOM. |
|
389 return; |
|
390 } |
|
391 |
|
392 var overflows = getParentOverflows(ta); |
|
393 var docTop = document.documentElement && document.documentElement.scrollTop; // Needed for Mobile IE (ticket #240) |
|
394 |
|
395 ta.style.height = ''; |
|
396 ta.style.height = ta.scrollHeight + heightOffset + 'px'; |
|
397 |
|
398 // used to check if an update is actually necessary on window.resize |
|
399 clientWidth = ta.clientWidth; |
|
400 |
|
401 // prevents scroll-position jumping |
|
402 overflows.forEach(function (el) { |
|
403 el.node.scrollTop = el.scrollTop; |
|
404 }); |
|
405 |
|
406 if (docTop) { |
|
407 document.documentElement.scrollTop = docTop; |
|
408 } |
|
409 } |
|
410 |
|
411 function update() { |
|
412 resize(); |
|
413 |
|
414 var styleHeight = Math.round(parseFloat(ta.style.height)); |
|
415 var computed = window.getComputedStyle(ta, null); |
|
416 |
|
417 // Using offsetHeight as a replacement for computed.height in IE, because IE does not account use of border-box |
|
418 var actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(computed.height)) : ta.offsetHeight; |
|
419 |
|
420 // The actual height not matching the style height (set via the resize method) indicates that |
|
421 // the max-height has been exceeded, in which case the overflow should be allowed. |
|
422 if (actualHeight < styleHeight) { |
|
423 if (computed.overflowY === 'hidden') { |
|
424 changeOverflow('scroll'); |
|
425 resize(); |
|
426 actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight; |
|
427 } |
|
428 } else { |
|
429 // Normally keep overflow set to hidden, to avoid flash of scrollbar as the textarea expands. |
|
430 if (computed.overflowY !== 'hidden') { |
|
431 changeOverflow('hidden'); |
|
432 resize(); |
|
433 actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight; |
|
434 } |
|
435 } |
|
436 |
|
437 if (cachedHeight !== actualHeight) { |
|
438 cachedHeight = actualHeight; |
|
439 var evt = createEvent('autosize:resized'); |
|
440 try { |
|
441 ta.dispatchEvent(evt); |
|
442 } catch (err) { |
|
443 // Firefox will throw an error on dispatchEvent for a detached element |
|
444 // https://bugzilla.mozilla.org/show_bug.cgi?id=889376 |
|
445 } |
|
446 } |
|
447 } |
|
448 |
|
449 var pageResize = function pageResize() { |
|
450 if (ta.clientWidth !== clientWidth) { |
|
451 update(); |
|
452 } |
|
453 }; |
|
454 |
|
455 var destroy = function (style) { |
|
456 window.removeEventListener('resize', pageResize, false); |
|
457 ta.removeEventListener('input', update, false); |
|
458 ta.removeEventListener('keyup', update, false); |
|
459 ta.removeEventListener('autosize:destroy', destroy, false); |
|
460 ta.removeEventListener('autosize:update', update, false); |
|
461 |
|
462 Object.keys(style).forEach(function (key) { |
|
463 ta.style[key] = style[key]; |
|
464 }); |
|
465 |
|
466 map.delete(ta); |
|
467 }.bind(ta, { |
|
468 height: ta.style.height, |
|
469 resize: ta.style.resize, |
|
470 overflowY: ta.style.overflowY, |
|
471 overflowX: ta.style.overflowX, |
|
472 wordWrap: ta.style.wordWrap |
|
473 }); |
|
474 |
|
475 ta.addEventListener('autosize:destroy', destroy, false); |
|
476 |
|
477 // IE9 does not fire onpropertychange or oninput for deletions, |
|
478 // so binding to onkeyup to catch most of those events. |
|
479 // There is no way that I know of to detect something like 'cut' in IE9. |
|
480 if ('onpropertychange' in ta && 'oninput' in ta) { |
|
481 ta.addEventListener('keyup', update, false); |
|
482 } |
|
483 |
|
484 window.addEventListener('resize', pageResize, false); |
|
485 ta.addEventListener('input', update, false); |
|
486 ta.addEventListener('autosize:update', update, false); |
|
487 ta.style.overflowX = 'hidden'; |
|
488 ta.style.wordWrap = 'break-word'; |
|
489 |
|
490 map.set(ta, { |
|
491 destroy: destroy, |
|
492 update: update |
|
493 }); |
|
494 |
|
495 init(); |
|
496 } |
|
497 |
|
498 function destroy(ta) { |
|
499 var methods = map.get(ta); |
|
500 if (methods) { |
|
501 methods.destroy(); |
|
502 } |
|
503 } |
|
504 |
|
505 function update(ta) { |
|
506 var methods = map.get(ta); |
|
507 if (methods) { |
|
508 methods.update(); |
|
509 } |
|
510 } |
|
511 |
|
512 var autosize = null; |
|
513 |
|
514 // Do nothing in Node.js environment and IE8 (or lower) |
|
515 if (typeof window === 'undefined' || typeof window.getComputedStyle !== 'function') { |
|
516 autosize = function autosize(el) { |
|
517 return el; |
|
518 }; |
|
519 autosize.destroy = function (el) { |
|
520 return el; |
|
521 }; |
|
522 autosize.update = function (el) { |
|
523 return el; |
|
524 }; |
|
525 } else { |
|
526 autosize = function autosize(el, options) { |
|
527 if (el) { |
|
528 Array.prototype.forEach.call(el.length ? el : [el], function (x) { |
|
529 return assign(x, options); |
|
530 }); |
|
531 } |
|
532 return el; |
|
533 }; |
|
534 autosize.destroy = function (el) { |
|
535 if (el) { |
|
536 Array.prototype.forEach.call(el.length ? el : [el], destroy); |
|
537 } |
|
538 return el; |
|
539 }; |
|
540 autosize.update = function (el) { |
|
541 if (el) { |
|
542 Array.prototype.forEach.call(el.length ? el : [el], update); |
|
543 } |
|
544 return el; |
|
545 }; |
|
546 } |
|
547 |
|
548 exports.default = autosize; |
|
549 module.exports = exports['default']; |
|
550 }); |
|
551 |
|
552 /***/ }), |
|
553 |
|
554 /***/ 113: |
|
555 /***/ (function(module, exports, __webpack_require__) { |
|
556 |
|
557 // Load in dependencies |
|
558 var computedStyle = __webpack_require__(114); |
|
559 |
|
560 /** |
|
561 * Calculate the `line-height` of a given node |
|
562 * @param {HTMLElement} node Element to calculate line height of. Must be in the DOM. |
|
563 * @returns {Number} `line-height` of the element in pixels |
|
564 */ |
|
565 function lineHeight(node) { |
|
566 // Grab the line-height via style |
|
567 var lnHeightStr = computedStyle(node, 'line-height'); |
|
568 var lnHeight = parseFloat(lnHeightStr, 10); |
|
569 |
|
570 // If the lineHeight did not contain a unit (i.e. it was numeric), convert it to ems (e.g. '2.3' === '2.3em') |
|
571 if (lnHeightStr === lnHeight + '') { |
|
572 // Save the old lineHeight style and update the em unit to the element |
|
573 var _lnHeightStyle = node.style.lineHeight; |
|
574 node.style.lineHeight = lnHeightStr + 'em'; |
|
575 |
|
576 // Calculate the em based height |
|
577 lnHeightStr = computedStyle(node, 'line-height'); |
|
578 lnHeight = parseFloat(lnHeightStr, 10); |
|
579 |
|
580 // Revert the lineHeight style |
|
581 if (_lnHeightStyle) { |
|
582 node.style.lineHeight = _lnHeightStyle; |
|
583 } else { |
|
584 delete node.style.lineHeight; |
|
585 } |
|
586 } |
|
587 |
|
588 // If the lineHeight is in `pt`, convert it to pixels (4px for 3pt) |
|
589 // DEV: `em` units are converted to `pt` in IE6 |
|
590 // Conversion ratio from https://developer.mozilla.org/en-US/docs/Web/CSS/length |
|
591 if (lnHeightStr.indexOf('pt') !== -1) { |
|
592 lnHeight *= 4; |
|
593 lnHeight /= 3; |
|
594 // Otherwise, if the lineHeight is in `mm`, convert it to pixels (96px for 25.4mm) |
|
595 } else if (lnHeightStr.indexOf('mm') !== -1) { |
|
596 lnHeight *= 96; |
|
597 lnHeight /= 25.4; |
|
598 // Otherwise, if the lineHeight is in `cm`, convert it to pixels (96px for 2.54cm) |
|
599 } else if (lnHeightStr.indexOf('cm') !== -1) { |
|
600 lnHeight *= 96; |
|
601 lnHeight /= 2.54; |
|
602 // Otherwise, if the lineHeight is in `in`, convert it to pixels (96px for 1in) |
|
603 } else if (lnHeightStr.indexOf('in') !== -1) { |
|
604 lnHeight *= 96; |
|
605 // Otherwise, if the lineHeight is in `pc`, convert it to pixels (12pt for 1pc) |
|
606 } else if (lnHeightStr.indexOf('pc') !== -1) { |
|
607 lnHeight *= 16; |
|
608 } |
|
609 |
|
610 // Continue our computation |
|
611 lnHeight = Math.round(lnHeight); |
|
612 |
|
613 // If the line-height is "normal", calculate by font-size |
|
614 if (lnHeightStr === 'normal') { |
|
615 // Create a temporary node |
|
616 var nodeName = node.nodeName; |
|
617 var _node = document.createElement(nodeName); |
|
618 _node.innerHTML = ' '; |
|
619 |
|
620 // If we have a text area, reset it to only 1 row |
|
621 // https://github.com/twolfson/line-height/issues/4 |
|
622 if (nodeName.toUpperCase() === 'TEXTAREA') { |
|
623 _node.setAttribute('rows', '1'); |
|
624 } |
|
625 |
|
626 // Set the font-size of the element |
|
627 var fontSizeStr = computedStyle(node, 'font-size'); |
|
628 _node.style.fontSize = fontSizeStr; |
|
629 |
|
630 // Remove default padding/border which can affect offset height |
|
631 // https://github.com/twolfson/line-height/issues/4 |
|
632 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight |
|
633 _node.style.padding = '0px'; |
|
634 _node.style.border = '0px'; |
|
635 |
|
636 // Append it to the body |
|
637 var body = document.body; |
|
638 body.appendChild(_node); |
|
639 |
|
640 // Assume the line height of the element is the height |
|
641 var height = _node.offsetHeight; |
|
642 lnHeight = height; |
|
643 |
|
644 // Remove our child from the DOM |
|
645 body.removeChild(_node); |
|
646 } |
|
647 |
|
648 // Return the calculated height |
|
649 return lnHeight; |
|
650 } |
|
651 |
|
652 // Export lineHeight |
|
653 module.exports = lineHeight; |
|
654 |
|
655 |
|
656 /***/ }), |
|
657 |
|
658 /***/ 114: |
|
659 /***/ (function(module, exports) { |
|
660 |
|
661 // This code has been refactored for 140 bytes |
|
662 // You can see the original here: https://github.com/twolfson/computedStyle/blob/04cd1da2e30fa45844f95f5cb1ac898e9b9ef050/lib/computedStyle.js |
|
663 var computedStyle = function (el, prop, getComputedStyle) { |
|
664 getComputedStyle = window.getComputedStyle; |
|
665 |
|
666 // In one fell swoop |
|
667 return ( |
|
668 // If we have getComputedStyle |
|
669 getComputedStyle ? |
|
670 // Query it |
|
671 // TODO: From CSS-Query notes, we might need (node, null) for FF |
|
672 getComputedStyle(el) : |
|
673 |
|
674 // Otherwise, we are in IE and use currentStyle |
|
675 el.currentStyle |
|
676 )[ |
|
677 // Switch to camelCase for CSSOM |
|
678 // DEV: Grabbed from jQuery |
|
679 // https://github.com/jquery/jquery/blob/1.9-stable/src/css.js#L191-L194 |
|
680 // https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L593-L597 |
|
681 prop.replace(/-(\w)/gi, function (word, letter) { |
|
682 return letter.toUpperCase(); |
|
683 }) |
|
684 ]; |
|
685 }; |
|
686 |
|
687 module.exports = computedStyle; |
|
688 |
|
689 |
|
690 /***/ }), |
|
691 |
|
692 /***/ 115: |
|
693 /***/ (function(module, exports, __webpack_require__) { |
|
694 |
|
695 "use strict"; |
|
696 |
|
697 |
|
698 var util = __webpack_require__(116); |
|
699 |
|
700 function scrollIntoView(elem, container, config) { |
|
701 config = config || {}; |
|
702 // document 归一化到 window |
|
703 if (container.nodeType === 9) { |
|
704 container = util.getWindow(container); |
|
705 } |
|
706 |
|
707 var allowHorizontalScroll = config.allowHorizontalScroll; |
|
708 var onlyScrollIfNeeded = config.onlyScrollIfNeeded; |
|
709 var alignWithTop = config.alignWithTop; |
|
710 var alignWithLeft = config.alignWithLeft; |
|
711 var offsetTop = config.offsetTop || 0; |
|
712 var offsetLeft = config.offsetLeft || 0; |
|
713 var offsetBottom = config.offsetBottom || 0; |
|
714 var offsetRight = config.offsetRight || 0; |
|
715 |
|
716 allowHorizontalScroll = allowHorizontalScroll === undefined ? true : allowHorizontalScroll; |
|
717 |
|
718 var isWin = util.isWindow(container); |
|
719 var elemOffset = util.offset(elem); |
|
720 var eh = util.outerHeight(elem); |
|
721 var ew = util.outerWidth(elem); |
|
722 var containerOffset = undefined; |
|
723 var ch = undefined; |
|
724 var cw = undefined; |
|
725 var containerScroll = undefined; |
|
726 var diffTop = undefined; |
|
727 var diffBottom = undefined; |
|
728 var win = undefined; |
|
729 var winScroll = undefined; |
|
730 var ww = undefined; |
|
731 var wh = undefined; |
|
732 |
|
733 if (isWin) { |
|
734 win = container; |
|
735 wh = util.height(win); |
|
736 ww = util.width(win); |
|
737 winScroll = { |
|
738 left: util.scrollLeft(win), |
|
739 top: util.scrollTop(win) |
|
740 }; |
|
741 // elem 相对 container 可视视窗的距离 |
|
742 diffTop = { |
|
743 left: elemOffset.left - winScroll.left - offsetLeft, |
|
744 top: elemOffset.top - winScroll.top - offsetTop |
|
745 }; |
|
746 diffBottom = { |
|
747 left: elemOffset.left + ew - (winScroll.left + ww) + offsetRight, |
|
748 top: elemOffset.top + eh - (winScroll.top + wh) + offsetBottom |
|
749 }; |
|
750 containerScroll = winScroll; |
|
751 } else { |
|
752 containerOffset = util.offset(container); |
|
753 ch = container.clientHeight; |
|
754 cw = container.clientWidth; |
|
755 containerScroll = { |
|
756 left: container.scrollLeft, |
|
757 top: container.scrollTop |
|
758 }; |
|
759 // elem 相对 container 可视视窗的距离 |
|
760 // 注意边框, offset 是边框到根节点 |
|
761 diffTop = { |
|
762 left: elemOffset.left - (containerOffset.left + (parseFloat(util.css(container, 'borderLeftWidth')) || 0)) - offsetLeft, |
|
763 top: elemOffset.top - (containerOffset.top + (parseFloat(util.css(container, 'borderTopWidth')) || 0)) - offsetTop |
|
764 }; |
|
765 diffBottom = { |
|
766 left: elemOffset.left + ew - (containerOffset.left + cw + (parseFloat(util.css(container, 'borderRightWidth')) || 0)) + offsetRight, |
|
767 top: elemOffset.top + eh - (containerOffset.top + ch + (parseFloat(util.css(container, 'borderBottomWidth')) || 0)) + offsetBottom |
|
768 }; |
|
769 } |
|
770 |
|
771 if (diffTop.top < 0 || diffBottom.top > 0) { |
|
772 // 强制向上 |
|
773 if (alignWithTop === true) { |
|
774 util.scrollTop(container, containerScroll.top + diffTop.top); |
|
775 } else if (alignWithTop === false) { |
|
776 util.scrollTop(container, containerScroll.top + diffBottom.top); |
|
777 } else { |
|
778 // 自动调整 |
|
779 if (diffTop.top < 0) { |
|
780 util.scrollTop(container, containerScroll.top + diffTop.top); |
|
781 } else { |
|
782 util.scrollTop(container, containerScroll.top + diffBottom.top); |
|
783 } |
|
784 } |
|
785 } else { |
|
786 if (!onlyScrollIfNeeded) { |
|
787 alignWithTop = alignWithTop === undefined ? true : !!alignWithTop; |
|
788 if (alignWithTop) { |
|
789 util.scrollTop(container, containerScroll.top + diffTop.top); |
|
790 } else { |
|
791 util.scrollTop(container, containerScroll.top + diffBottom.top); |
|
792 } |
|
793 } |
|
794 } |
|
795 |
|
796 if (allowHorizontalScroll) { |
|
797 if (diffTop.left < 0 || diffBottom.left > 0) { |
|
798 // 强制向上 |
|
799 if (alignWithLeft === true) { |
|
800 util.scrollLeft(container, containerScroll.left + diffTop.left); |
|
801 } else if (alignWithLeft === false) { |
|
802 util.scrollLeft(container, containerScroll.left + diffBottom.left); |
|
803 } else { |
|
804 // 自动调整 |
|
805 if (diffTop.left < 0) { |
|
806 util.scrollLeft(container, containerScroll.left + diffTop.left); |
|
807 } else { |
|
808 util.scrollLeft(container, containerScroll.left + diffBottom.left); |
|
809 } |
|
810 } |
|
811 } else { |
|
812 if (!onlyScrollIfNeeded) { |
|
813 alignWithLeft = alignWithLeft === undefined ? true : !!alignWithLeft; |
|
814 if (alignWithLeft) { |
|
815 util.scrollLeft(container, containerScroll.left + diffTop.left); |
|
816 } else { |
|
817 util.scrollLeft(container, containerScroll.left + diffBottom.left); |
|
818 } |
|
819 } |
|
820 } |
|
821 } |
|
822 } |
|
823 |
|
824 module.exports = scrollIntoView; |
|
825 |
|
826 /***/ }), |
|
827 |
|
828 /***/ 116: |
|
829 /***/ (function(module, exports, __webpack_require__) { |
|
830 |
|
831 "use strict"; |
|
832 |
|
833 |
|
834 var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; |
|
835 |
|
836 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; |
|
837 |
|
838 var RE_NUM = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source; |
|
839 |
|
840 function getClientPosition(elem) { |
|
841 var box = undefined; |
|
842 var x = undefined; |
|
843 var y = undefined; |
|
844 var doc = elem.ownerDocument; |
|
845 var body = doc.body; |
|
846 var docElem = doc && doc.documentElement; |
|
847 // 根据 GBS 最新数据,A-Grade Browsers 都已支持 getBoundingClientRect 方法,不用再考虑传统的实现方式 |
|
848 box = elem.getBoundingClientRect(); |
|
849 |
|
850 // 注:jQuery 还考虑减去 docElem.clientLeft/clientTop |
|
851 // 但测试发现,这样反而会导致当 html 和 body 有边距/边框样式时,获取的值不正确 |
|
852 // 此外,ie6 会忽略 html 的 margin 值,幸运地是没有谁会去设置 html 的 margin |
|
853 |
|
854 x = box.left; |
|
855 y = box.top; |
|
856 |
|
857 // In IE, most of the time, 2 extra pixels are added to the top and left |
|
858 // due to the implicit 2-pixel inset border. In IE6/7 quirks mode and |
|
859 // IE6 standards mode, this border can be overridden by setting the |
|
860 // document element's border to zero -- thus, we cannot rely on the |
|
861 // offset always being 2 pixels. |
|
862 |
|
863 // In quirks mode, the offset can be determined by querying the body's |
|
864 // clientLeft/clientTop, but in standards mode, it is found by querying |
|
865 // the document element's clientLeft/clientTop. Since we already called |
|
866 // getClientBoundingRect we have already forced a reflow, so it is not |
|
867 // too expensive just to query them all. |
|
868 |
|
869 // ie 下应该减去窗口的边框吧,毕竟默认 absolute 都是相对窗口定位的 |
|
870 // 窗口边框标准是设 documentElement ,quirks 时设置 body |
|
871 // 最好禁止在 body 和 html 上边框 ,但 ie < 9 html 默认有 2px ,减去 |
|
872 // 但是非 ie 不可能设置窗口边框,body html 也不是窗口 ,ie 可以通过 html,body 设置 |
|
873 // 标准 ie 下 docElem.clientTop 就是 border-top |
|
874 // ie7 html 即窗口边框改变不了。永远为 2 |
|
875 // 但标准 firefox/chrome/ie9 下 docElem.clientTop 是窗口边框,即使设了 border-top 也为 0 |
|
876 |
|
877 x -= docElem.clientLeft || body.clientLeft || 0; |
|
878 y -= docElem.clientTop || body.clientTop || 0; |
|
879 |
|
880 return { |
|
881 left: x, |
|
882 top: y |
|
883 }; |
|
884 } |
|
885 |
|
886 function getScroll(w, top) { |
|
887 var ret = w['page' + (top ? 'Y' : 'X') + 'Offset']; |
|
888 var method = 'scroll' + (top ? 'Top' : 'Left'); |
|
889 if (typeof ret !== 'number') { |
|
890 var d = w.document; |
|
891 // ie6,7,8 standard mode |
|
892 ret = d.documentElement[method]; |
|
893 if (typeof ret !== 'number') { |
|
894 // quirks mode |
|
895 ret = d.body[method]; |
|
896 } |
|
897 } |
|
898 return ret; |
|
899 } |
|
900 |
|
901 function getScrollLeft(w) { |
|
902 return getScroll(w); |
|
903 } |
|
904 |
|
905 function getScrollTop(w) { |
|
906 return getScroll(w, true); |
|
907 } |
|
908 |
|
909 function getOffset(el) { |
|
910 var pos = getClientPosition(el); |
|
911 var doc = el.ownerDocument; |
|
912 var w = doc.defaultView || doc.parentWindow; |
|
913 pos.left += getScrollLeft(w); |
|
914 pos.top += getScrollTop(w); |
|
915 return pos; |
|
916 } |
|
917 function _getComputedStyle(elem, name, computedStyle_) { |
|
918 var val = ''; |
|
919 var d = elem.ownerDocument; |
|
920 var computedStyle = computedStyle_ || d.defaultView.getComputedStyle(elem, null); |
|
921 |
|
922 // https://github.com/kissyteam/kissy/issues/61 |
|
923 if (computedStyle) { |
|
924 val = computedStyle.getPropertyValue(name) || computedStyle[name]; |
|
925 } |
|
926 |
|
927 return val; |
|
928 } |
|
929 |
|
930 var _RE_NUM_NO_PX = new RegExp('^(' + RE_NUM + ')(?!px)[a-z%]+$', 'i'); |
|
931 var RE_POS = /^(top|right|bottom|left)$/; |
|
932 var CURRENT_STYLE = 'currentStyle'; |
|
933 var RUNTIME_STYLE = 'runtimeStyle'; |
|
934 var LEFT = 'left'; |
|
935 var PX = 'px'; |
|
936 |
|
937 function _getComputedStyleIE(elem, name) { |
|
938 // currentStyle maybe null |
|
939 // http://msdn.microsoft.com/en-us/library/ms535231.aspx |
|
940 var ret = elem[CURRENT_STYLE] && elem[CURRENT_STYLE][name]; |
|
941 |
|
942 // 当 width/height 设置为百分比时,通过 pixelLeft 方式转换的 width/height 值 |
|
943 // 一开始就处理了! CUSTOM_STYLE.height,CUSTOM_STYLE.width ,cssHook 解决@2011-08-19 |
|
944 // 在 ie 下不对,需要直接用 offset 方式 |
|
945 // borderWidth 等值也有问题,但考虑到 borderWidth 设为百分比的概率很小,这里就不考虑了 |
|
946 |
|
947 // From the awesome hack by Dean Edwards |
|
948 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 |
|
949 // If we're not dealing with a regular pixel number |
|
950 // but a number that has a weird ending, we need to convert it to pixels |
|
951 // exclude left right for relativity |
|
952 if (_RE_NUM_NO_PX.test(ret) && !RE_POS.test(name)) { |
|
953 // Remember the original values |
|
954 var style = elem.style; |
|
955 var left = style[LEFT]; |
|
956 var rsLeft = elem[RUNTIME_STYLE][LEFT]; |
|
957 |
|
958 // prevent flashing of content |
|
959 elem[RUNTIME_STYLE][LEFT] = elem[CURRENT_STYLE][LEFT]; |
|
960 |
|
961 // Put in the new values to get a computed value out |
|
962 style[LEFT] = name === 'fontSize' ? '1em' : ret || 0; |
|
963 ret = style.pixelLeft + PX; |
|
964 |
|
965 // Revert the changed values |
|
966 style[LEFT] = left; |
|
967 |
|
968 elem[RUNTIME_STYLE][LEFT] = rsLeft; |
|
969 } |
|
970 return ret === '' ? 'auto' : ret; |
|
971 } |
|
972 |
|
973 var getComputedStyleX = undefined; |
|
974 if (typeof window !== 'undefined') { |
|
975 getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE; |
|
976 } |
|
977 |
|
978 function each(arr, fn) { |
|
979 for (var i = 0; i < arr.length; i++) { |
|
980 fn(arr[i]); |
|
981 } |
|
982 } |
|
983 |
|
984 function isBorderBoxFn(elem) { |
|
985 return getComputedStyleX(elem, 'boxSizing') === 'border-box'; |
|
986 } |
|
987 |
|
988 var BOX_MODELS = ['margin', 'border', 'padding']; |
|
989 var CONTENT_INDEX = -1; |
|
990 var PADDING_INDEX = 2; |
|
991 var BORDER_INDEX = 1; |
|
992 var MARGIN_INDEX = 0; |
|
993 |
|
994 function swap(elem, options, callback) { |
|
995 var old = {}; |
|
996 var style = elem.style; |
|
997 var name = undefined; |
|
998 |
|
999 // Remember the old values, and insert the new ones |
|
1000 for (name in options) { |
|
1001 if (options.hasOwnProperty(name)) { |
|
1002 old[name] = style[name]; |
|
1003 style[name] = options[name]; |
|
1004 } |
|
1005 } |
|
1006 |
|
1007 callback.call(elem); |
|
1008 |
|
1009 // Revert the old values |
|
1010 for (name in options) { |
|
1011 if (options.hasOwnProperty(name)) { |
|
1012 style[name] = old[name]; |
|
1013 } |
|
1014 } |
|
1015 } |
|
1016 |
|
1017 function getPBMWidth(elem, props, which) { |
|
1018 var value = 0; |
|
1019 var prop = undefined; |
|
1020 var j = undefined; |
|
1021 var i = undefined; |
|
1022 for (j = 0; j < props.length; j++) { |
|
1023 prop = props[j]; |
|
1024 if (prop) { |
|
1025 for (i = 0; i < which.length; i++) { |
|
1026 var cssProp = undefined; |
|
1027 if (prop === 'border') { |
|
1028 cssProp = prop + which[i] + 'Width'; |
|
1029 } else { |
|
1030 cssProp = prop + which[i]; |
|
1031 } |
|
1032 value += parseFloat(getComputedStyleX(elem, cssProp)) || 0; |
|
1033 } |
|
1034 } |
|
1035 } |
|
1036 return value; |
|
1037 } |
|
1038 |
|
1039 /** |
|
1040 * A crude way of determining if an object is a window |
|
1041 * @member util |
|
1042 */ |
|
1043 function isWindow(obj) { |
|
1044 // must use == for ie8 |
|
1045 /* eslint eqeqeq:0 */ |
|
1046 return obj != null && obj == obj.window; |
|
1047 } |
|
1048 |
|
1049 var domUtils = {}; |
|
1050 |
|
1051 each(['Width', 'Height'], function (name) { |
|
1052 domUtils['doc' + name] = function (refWin) { |
|
1053 var d = refWin.document; |
|
1054 return Math.max( |
|
1055 // firefox chrome documentElement.scrollHeight< body.scrollHeight |
|
1056 // ie standard mode : documentElement.scrollHeight> body.scrollHeight |
|
1057 d.documentElement['scroll' + name], |
|
1058 // quirks : documentElement.scrollHeight 最大等于可视窗口多一点? |
|
1059 d.body['scroll' + name], domUtils['viewport' + name](d)); |
|
1060 }; |
|
1061 |
|
1062 domUtils['viewport' + name] = function (win) { |
|
1063 // pc browser includes scrollbar in window.innerWidth |
|
1064 var prop = 'client' + name; |
|
1065 var doc = win.document; |
|
1066 var body = doc.body; |
|
1067 var documentElement = doc.documentElement; |
|
1068 var documentElementProp = documentElement[prop]; |
|
1069 // 标准模式取 documentElement |
|
1070 // backcompat 取 body |
|
1071 return doc.compatMode === 'CSS1Compat' && documentElementProp || body && body[prop] || documentElementProp; |
|
1072 }; |
|
1073 }); |
|
1074 |
|
1075 /* |
|
1076 得到元素的大小信息 |
|
1077 @param elem |
|
1078 @param name |
|
1079 @param {String} [extra] 'padding' : (css width) + padding |
|
1080 'border' : (css width) + padding + border |
|
1081 'margin' : (css width) + padding + border + margin |
|
1082 */ |
|
1083 function getWH(elem, name, extra) { |
|
1084 if (isWindow(elem)) { |
|
1085 return name === 'width' ? domUtils.viewportWidth(elem) : domUtils.viewportHeight(elem); |
|
1086 } else if (elem.nodeType === 9) { |
|
1087 return name === 'width' ? domUtils.docWidth(elem) : domUtils.docHeight(elem); |
|
1088 } |
|
1089 var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom']; |
|
1090 var borderBoxValue = name === 'width' ? elem.offsetWidth : elem.offsetHeight; |
|
1091 var computedStyle = getComputedStyleX(elem); |
|
1092 var isBorderBox = isBorderBoxFn(elem, computedStyle); |
|
1093 var cssBoxValue = 0; |
|
1094 if (borderBoxValue == null || borderBoxValue <= 0) { |
|
1095 borderBoxValue = undefined; |
|
1096 // Fall back to computed then un computed css if necessary |
|
1097 cssBoxValue = getComputedStyleX(elem, name); |
|
1098 if (cssBoxValue == null || Number(cssBoxValue) < 0) { |
|
1099 cssBoxValue = elem.style[name] || 0; |
|
1100 } |
|
1101 // Normalize '', auto, and prepare for extra |
|
1102 cssBoxValue = parseFloat(cssBoxValue) || 0; |
|
1103 } |
|
1104 if (extra === undefined) { |
|
1105 extra = isBorderBox ? BORDER_INDEX : CONTENT_INDEX; |
|
1106 } |
|
1107 var borderBoxValueOrIsBorderBox = borderBoxValue !== undefined || isBorderBox; |
|
1108 var val = borderBoxValue || cssBoxValue; |
|
1109 if (extra === CONTENT_INDEX) { |
|
1110 if (borderBoxValueOrIsBorderBox) { |
|
1111 return val - getPBMWidth(elem, ['border', 'padding'], which, computedStyle); |
|
1112 } |
|
1113 return cssBoxValue; |
|
1114 } |
|
1115 if (borderBoxValueOrIsBorderBox) { |
|
1116 var padding = extra === PADDING_INDEX ? -getPBMWidth(elem, ['border'], which, computedStyle) : getPBMWidth(elem, ['margin'], which, computedStyle); |
|
1117 return val + (extra === BORDER_INDEX ? 0 : padding); |
|
1118 } |
|
1119 return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra), which, computedStyle); |
|
1120 } |
|
1121 |
|
1122 var cssShow = { |
|
1123 position: 'absolute', |
|
1124 visibility: 'hidden', |
|
1125 display: 'block' |
|
1126 }; |
|
1127 |
|
1128 // fix #119 : https://github.com/kissyteam/kissy/issues/119 |
|
1129 function getWHIgnoreDisplay(elem) { |
|
1130 var val = undefined; |
|
1131 var args = arguments; |
|
1132 // in case elem is window |
|
1133 // elem.offsetWidth === undefined |
|
1134 if (elem.offsetWidth !== 0) { |
|
1135 val = getWH.apply(undefined, args); |
|
1136 } else { |
|
1137 swap(elem, cssShow, function () { |
|
1138 val = getWH.apply(undefined, args); |
|
1139 }); |
|
1140 } |
|
1141 return val; |
|
1142 } |
|
1143 |
|
1144 function css(el, name, v) { |
|
1145 var value = v; |
|
1146 if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') { |
|
1147 for (var i in name) { |
|
1148 if (name.hasOwnProperty(i)) { |
|
1149 css(el, i, name[i]); |
|
1150 } |
|
1151 } |
|
1152 return undefined; |
|
1153 } |
|
1154 if (typeof value !== 'undefined') { |
|
1155 if (typeof value === 'number') { |
|
1156 value += 'px'; |
|
1157 } |
|
1158 el.style[name] = value; |
|
1159 return undefined; |
|
1160 } |
|
1161 return getComputedStyleX(el, name); |
|
1162 } |
|
1163 |
|
1164 each(['width', 'height'], function (name) { |
|
1165 var first = name.charAt(0).toUpperCase() + name.slice(1); |
|
1166 domUtils['outer' + first] = function (el, includeMargin) { |
|
1167 return el && getWHIgnoreDisplay(el, name, includeMargin ? MARGIN_INDEX : BORDER_INDEX); |
|
1168 }; |
|
1169 var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom']; |
|
1170 |
|
1171 domUtils[name] = function (elem, val) { |
|
1172 if (val !== undefined) { |
|
1173 if (elem) { |
|
1174 var computedStyle = getComputedStyleX(elem); |
|
1175 var isBorderBox = isBorderBoxFn(elem); |
|
1176 if (isBorderBox) { |
|
1177 val += getPBMWidth(elem, ['padding', 'border'], which, computedStyle); |
|
1178 } |
|
1179 return css(elem, name, val); |
|
1180 } |
|
1181 return undefined; |
|
1182 } |
|
1183 return elem && getWHIgnoreDisplay(elem, name, CONTENT_INDEX); |
|
1184 }; |
|
1185 }); |
|
1186 |
|
1187 // 设置 elem 相对 elem.ownerDocument 的坐标 |
|
1188 function setOffset(elem, offset) { |
|
1189 // set position first, in-case top/left are set even on static elem |
|
1190 if (css(elem, 'position') === 'static') { |
|
1191 elem.style.position = 'relative'; |
|
1192 } |
|
1193 |
|
1194 var old = getOffset(elem); |
|
1195 var ret = {}; |
|
1196 var current = undefined; |
|
1197 var key = undefined; |
|
1198 |
|
1199 for (key in offset) { |
|
1200 if (offset.hasOwnProperty(key)) { |
|
1201 current = parseFloat(css(elem, key)) || 0; |
|
1202 ret[key] = current + offset[key] - old[key]; |
|
1203 } |
|
1204 } |
|
1205 css(elem, ret); |
|
1206 } |
|
1207 |
|
1208 module.exports = _extends({ |
|
1209 getWindow: function getWindow(node) { |
|
1210 var doc = node.ownerDocument || node; |
|
1211 return doc.defaultView || doc.parentWindow; |
|
1212 }, |
|
1213 offset: function offset(el, value) { |
|
1214 if (typeof value !== 'undefined') { |
|
1215 setOffset(el, value); |
|
1216 } else { |
|
1217 return getOffset(el); |
|
1218 } |
|
1219 }, |
|
1220 |
|
1221 isWindow: isWindow, |
|
1222 each: each, |
|
1223 css: css, |
|
1224 clone: function clone(obj) { |
|
1225 var ret = {}; |
|
1226 for (var i in obj) { |
|
1227 if (obj.hasOwnProperty(i)) { |
|
1228 ret[i] = obj[i]; |
|
1229 } |
|
1230 } |
|
1231 var overflow = obj.overflow; |
|
1232 if (overflow) { |
|
1233 for (var i in obj) { |
|
1234 if (obj.hasOwnProperty(i)) { |
|
1235 ret.overflow[i] = obj.overflow[i]; |
|
1236 } |
|
1237 } |
|
1238 } |
|
1239 return ret; |
|
1240 }, |
|
1241 scrollLeft: function scrollLeft(w, v) { |
|
1242 if (isWindow(w)) { |
|
1243 if (v === undefined) { |
|
1244 return getScrollLeft(w); |
|
1245 } |
|
1246 window.scrollTo(v, getScrollTop(w)); |
|
1247 } else { |
|
1248 if (v === undefined) { |
|
1249 return w.scrollLeft; |
|
1250 } |
|
1251 w.scrollLeft = v; |
|
1252 } |
|
1253 }, |
|
1254 scrollTop: function scrollTop(w, v) { |
|
1255 if (isWindow(w)) { |
|
1256 if (v === undefined) { |
|
1257 return getScrollTop(w); |
|
1258 } |
|
1259 window.scrollTo(getScrollLeft(w), v); |
|
1260 } else { |
|
1261 if (v === undefined) { |
|
1262 return w.scrollTop; |
|
1263 } |
|
1264 w.scrollTop = v; |
|
1265 } |
|
1266 }, |
|
1267 |
|
1268 viewportWidth: 0, |
|
1269 viewportHeight: 0 |
|
1270 }, domUtils); |
|
1271 |
|
1272 /***/ }), |
|
1273 |
|
1274 /***/ 12: |
|
1275 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1276 |
|
1277 "use strict"; |
|
1278 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _getPrototypeOf; }); |
|
1279 function _getPrototypeOf(o) { |
|
1280 _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { |
|
1281 return o.__proto__ || Object.getPrototypeOf(o); |
|
1282 }; |
|
1283 return _getPrototypeOf(o); |
|
1284 } |
|
1285 |
|
1286 /***/ }), |
|
1287 |
|
1288 /***/ 13: |
|
1289 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1290 |
|
1291 "use strict"; |
|
1292 |
|
1293 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js |
|
1294 function _setPrototypeOf(o, p) { |
|
1295 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { |
|
1296 o.__proto__ = p; |
|
1297 return o; |
|
1298 }; |
|
1299 |
|
1300 return _setPrototypeOf(o, p); |
|
1301 } |
|
1302 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js |
|
1303 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _inherits; }); |
|
1304 |
|
1305 function _inherits(subClass, superClass) { |
|
1306 if (typeof superClass !== "function" && superClass !== null) { |
|
1307 throw new TypeError("Super expression must either be null or a function"); |
|
1308 } |
|
1309 |
|
1310 subClass.prototype = Object.create(superClass && superClass.prototype, { |
|
1311 constructor: { |
|
1312 value: subClass, |
|
1313 writable: true, |
|
1314 configurable: true |
|
1315 } |
|
1316 }); |
|
1317 if (superClass) _setPrototypeOf(subClass, superClass); |
|
1318 } |
|
1319 |
|
1320 /***/ }), |
|
1321 |
|
1322 /***/ 135: |
|
1323 /***/ (function(module, exports) { |
|
1324 |
|
1325 (function() { module.exports = this["wp"]["tokenList"]; }()); |
|
1326 |
|
1327 /***/ }), |
|
1328 |
|
1329 /***/ 14: |
|
1330 /***/ (function(module, exports) { |
|
1331 |
|
1332 (function() { module.exports = this["wp"]["blocks"]; }()); |
|
1333 |
|
1334 /***/ }), |
|
1335 |
|
1336 /***/ 15: |
|
1337 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1338 |
|
1339 "use strict"; |
|
1340 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; }); |
|
1341 function _defineProperty(obj, key, value) { |
|
1342 if (key in obj) { |
|
1343 Object.defineProperty(obj, key, { |
|
1344 value: value, |
|
1345 enumerable: true, |
|
1346 configurable: true, |
|
1347 writable: true |
|
1348 }); |
|
1349 } else { |
|
1350 obj[key] = value; |
|
1351 } |
|
1352 |
|
1353 return obj; |
|
1354 } |
|
1355 |
|
1356 /***/ }), |
|
1357 |
|
1358 /***/ 16: |
|
1359 /***/ (function(module, exports, __webpack_require__) { |
|
1360 |
|
1361 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! |
|
1362 Copyright (c) 2017 Jed Watson. |
|
1363 Licensed under the MIT License (MIT), see |
|
1364 http://jedwatson.github.io/classnames |
|
1365 */ |
|
1366 /* global define */ |
|
1367 |
|
1368 (function () { |
|
1369 'use strict'; |
|
1370 |
|
1371 var hasOwn = {}.hasOwnProperty; |
|
1372 |
|
1373 function classNames () { |
|
1374 var classes = []; |
|
1375 |
|
1376 for (var i = 0; i < arguments.length; i++) { |
|
1377 var arg = arguments[i]; |
|
1378 if (!arg) continue; |
|
1379 |
|
1380 var argType = typeof arg; |
|
1381 |
|
1382 if (argType === 'string' || argType === 'number') { |
|
1383 classes.push(arg); |
|
1384 } else if (Array.isArray(arg) && arg.length) { |
|
1385 var inner = classNames.apply(null, arg); |
|
1386 if (inner) { |
|
1387 classes.push(inner); |
|
1388 } |
|
1389 } else if (argType === 'object') { |
|
1390 for (var key in arg) { |
|
1391 if (hasOwn.call(arg, key) && arg[key]) { |
|
1392 classes.push(key); |
|
1393 } |
|
1394 } |
|
1395 } |
|
1396 } |
|
1397 |
|
1398 return classes.join(' '); |
|
1399 } |
|
1400 |
|
1401 if ( true && module.exports) { |
|
1402 classNames.default = classNames; |
|
1403 module.exports = classNames; |
|
1404 } else if (true) { |
|
1405 // register as 'classnames', consistent with npm package name |
|
1406 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () { |
|
1407 return classNames; |
|
1408 }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), |
|
1409 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); |
|
1410 } else {} |
|
1411 }()); |
|
1412 |
|
1413 |
|
1414 /***/ }), |
|
1415 |
|
1416 /***/ 17: |
|
1417 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1418 |
|
1419 "use strict"; |
|
1420 |
|
1421 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js |
|
1422 function _arrayWithoutHoles(arr) { |
|
1423 if (Array.isArray(arr)) { |
|
1424 for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { |
|
1425 arr2[i] = arr[i]; |
|
1426 } |
|
1427 |
|
1428 return arr2; |
|
1429 } |
|
1430 } |
|
1431 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js |
|
1432 var iterableToArray = __webpack_require__(34); |
|
1433 |
|
1434 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js |
|
1435 function _nonIterableSpread() { |
|
1436 throw new TypeError("Invalid attempt to spread non-iterable instance"); |
|
1437 } |
|
1438 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js |
|
1439 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _toConsumableArray; }); |
|
1440 |
|
1441 |
|
1442 |
|
1443 function _toConsumableArray(arr) { |
|
1444 return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || _nonIterableSpread(); |
|
1445 } |
|
1446 |
|
1447 /***/ }), |
|
1448 |
|
1449 /***/ 18: |
|
1450 /***/ (function(module, exports) { |
|
1451 |
|
1452 (function() { module.exports = this["wp"]["keycodes"]; }()); |
|
1453 |
|
1454 /***/ }), |
|
1455 |
|
1456 /***/ 19: |
|
1457 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1458 |
|
1459 "use strict"; |
|
1460 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; }); |
|
1461 function _extends() { |
|
1462 _extends = Object.assign || function (target) { |
|
1463 for (var i = 1; i < arguments.length; i++) { |
|
1464 var source = arguments[i]; |
|
1465 |
|
1466 for (var key in source) { |
|
1467 if (Object.prototype.hasOwnProperty.call(source, key)) { |
|
1468 target[key] = source[key]; |
|
1469 } |
|
1470 } |
|
1471 } |
|
1472 |
|
1473 return target; |
|
1474 }; |
|
1475 |
|
1476 return _extends.apply(this, arguments); |
|
1477 } |
|
1478 |
|
1479 /***/ }), |
|
1480 |
|
1481 /***/ 2: |
|
1482 /***/ (function(module, exports) { |
|
1483 |
|
1484 (function() { module.exports = this["lodash"]; }()); |
|
1485 |
|
1486 /***/ }), |
|
1487 |
|
1488 /***/ 20: |
|
1489 /***/ (function(module, exports) { |
|
1490 |
|
1491 (function() { module.exports = this["wp"]["richText"]; }()); |
|
1492 |
|
1493 /***/ }), |
|
1494 |
|
1495 /***/ 207: |
|
1496 /***/ (function(module, exports, __webpack_require__) { |
|
1497 |
|
1498 /*! |
|
1499 |
|
1500 diff v3.5.0 |
|
1501 |
|
1502 Software License Agreement (BSD License) |
|
1503 |
|
1504 Copyright (c) 2009-2015, Kevin Decker <kpdecker@gmail.com> |
|
1505 |
|
1506 All rights reserved. |
|
1507 |
|
1508 Redistribution and use of this software in source and binary forms, with or without modification, |
|
1509 are permitted provided that the following conditions are met: |
|
1510 |
|
1511 * Redistributions of source code must retain the above |
|
1512 copyright notice, this list of conditions and the |
|
1513 following disclaimer. |
|
1514 |
|
1515 * Redistributions in binary form must reproduce the above |
|
1516 copyright notice, this list of conditions and the |
|
1517 following disclaimer in the documentation and/or other |
|
1518 materials provided with the distribution. |
|
1519 |
|
1520 * Neither the name of Kevin Decker nor the names of its |
|
1521 contributors may be used to endorse or promote products |
|
1522 derived from this software without specific prior |
|
1523 written permission. |
|
1524 |
|
1525 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR |
|
1526 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
|
1527 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
|
1528 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
1529 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
1530 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER |
|
1531 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
|
1532 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
1533 @license |
|
1534 */ |
|
1535 (function webpackUniversalModuleDefinition(root, factory) { |
|
1536 if(true) |
|
1537 module.exports = factory(); |
|
1538 else {} |
|
1539 })(this, function() { |
|
1540 return /******/ (function(modules) { // webpackBootstrap |
|
1541 /******/ // The module cache |
|
1542 /******/ var installedModules = {}; |
|
1543 |
|
1544 /******/ // The require function |
|
1545 /******/ function __webpack_require__(moduleId) { |
|
1546 |
|
1547 /******/ // Check if module is in cache |
|
1548 /******/ if(installedModules[moduleId]) |
|
1549 /******/ return installedModules[moduleId].exports; |
|
1550 |
|
1551 /******/ // Create a new module (and put it into the cache) |
|
1552 /******/ var module = installedModules[moduleId] = { |
|
1553 /******/ exports: {}, |
|
1554 /******/ id: moduleId, |
|
1555 /******/ loaded: false |
|
1556 /******/ }; |
|
1557 |
|
1558 /******/ // Execute the module function |
|
1559 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
|
1560 |
|
1561 /******/ // Flag the module as loaded |
|
1562 /******/ module.loaded = true; |
|
1563 |
|
1564 /******/ // Return the exports of the module |
|
1565 /******/ return module.exports; |
|
1566 /******/ } |
|
1567 |
|
1568 |
|
1569 /******/ // expose the modules object (__webpack_modules__) |
|
1570 /******/ __webpack_require__.m = modules; |
|
1571 |
|
1572 /******/ // expose the module cache |
|
1573 /******/ __webpack_require__.c = installedModules; |
|
1574 |
|
1575 /******/ // __webpack_public_path__ |
|
1576 /******/ __webpack_require__.p = ""; |
|
1577 |
|
1578 /******/ // Load entry module and return exports |
|
1579 /******/ return __webpack_require__(0); |
|
1580 /******/ }) |
|
1581 /************************************************************************/ |
|
1582 /******/ ([ |
|
1583 /* 0 */ |
|
1584 /***/ (function(module, exports, __webpack_require__) { |
|
1585 |
|
1586 /*istanbul ignore start*/'use strict'; |
|
1587 |
|
1588 exports.__esModule = true; |
|
1589 exports.canonicalize = exports.convertChangesToXML = exports.convertChangesToDMP = exports.merge = exports.parsePatch = exports.applyPatches = exports.applyPatch = exports.createPatch = exports.createTwoFilesPatch = exports.structuredPatch = exports.diffArrays = exports.diffJson = exports.diffCss = exports.diffSentences = exports.diffTrimmedLines = exports.diffLines = exports.diffWordsWithSpace = exports.diffWords = exports.diffChars = exports.Diff = undefined; |
|
1590 |
|
1591 /*istanbul ignore end*/var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/; |
|
1592 |
|
1593 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base); |
|
1594 |
|
1595 /*istanbul ignore end*/var /*istanbul ignore start*/_character = __webpack_require__(2) /*istanbul ignore end*/; |
|
1596 |
|
1597 var /*istanbul ignore start*/_word = __webpack_require__(3) /*istanbul ignore end*/; |
|
1598 |
|
1599 var /*istanbul ignore start*/_line = __webpack_require__(5) /*istanbul ignore end*/; |
|
1600 |
|
1601 var /*istanbul ignore start*/_sentence = __webpack_require__(6) /*istanbul ignore end*/; |
|
1602 |
|
1603 var /*istanbul ignore start*/_css = __webpack_require__(7) /*istanbul ignore end*/; |
|
1604 |
|
1605 var /*istanbul ignore start*/_json = __webpack_require__(8) /*istanbul ignore end*/; |
|
1606 |
|
1607 var /*istanbul ignore start*/_array = __webpack_require__(9) /*istanbul ignore end*/; |
|
1608 |
|
1609 var /*istanbul ignore start*/_apply = __webpack_require__(10) /*istanbul ignore end*/; |
|
1610 |
|
1611 var /*istanbul ignore start*/_parse = __webpack_require__(11) /*istanbul ignore end*/; |
|
1612 |
|
1613 var /*istanbul ignore start*/_merge = __webpack_require__(13) /*istanbul ignore end*/; |
|
1614 |
|
1615 var /*istanbul ignore start*/_create = __webpack_require__(14) /*istanbul ignore end*/; |
|
1616 |
|
1617 var /*istanbul ignore start*/_dmp = __webpack_require__(16) /*istanbul ignore end*/; |
|
1618 |
|
1619 var /*istanbul ignore start*/_xml = __webpack_require__(17) /*istanbul ignore end*/; |
|
1620 |
|
1621 /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
|
1622 |
|
1623 /* See LICENSE file for terms of use */ |
|
1624 |
|
1625 /* |
|
1626 * Text diff implementation. |
|
1627 * |
|
1628 * This library supports the following APIS: |
|
1629 * JsDiff.diffChars: Character by character diff |
|
1630 * JsDiff.diffWords: Word (as defined by \b regex) diff which ignores whitespace |
|
1631 * JsDiff.diffLines: Line based diff |
|
1632 * |
|
1633 * JsDiff.diffCss: Diff targeted at CSS content |
|
1634 * |
|
1635 * These methods are based on the implementation proposed in |
|
1636 * "An O(ND) Difference Algorithm and its Variations" (Myers, 1986). |
|
1637 * http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.4.6927 |
|
1638 */ |
|
1639 exports. /*istanbul ignore end*/Diff = _base2['default']; |
|
1640 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffChars = _character.diffChars; |
|
1641 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWords = _word.diffWords; |
|
1642 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = _word.diffWordsWithSpace; |
|
1643 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffLines = _line.diffLines; |
|
1644 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = _line.diffTrimmedLines; |
|
1645 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffSentences = _sentence.diffSentences; |
|
1646 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffCss = _css.diffCss; |
|
1647 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffJson = _json.diffJson; |
|
1648 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffArrays = _array.diffArrays; |
|
1649 /*istanbul ignore start*/exports. /*istanbul ignore end*/structuredPatch = _create.structuredPatch; |
|
1650 /*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = _create.createTwoFilesPatch; |
|
1651 /*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = _create.createPatch; |
|
1652 /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatch = _apply.applyPatch; |
|
1653 /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = _apply.applyPatches; |
|
1654 /*istanbul ignore start*/exports. /*istanbul ignore end*/parsePatch = _parse.parsePatch; |
|
1655 /*istanbul ignore start*/exports. /*istanbul ignore end*/merge = _merge.merge; |
|
1656 /*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToDMP = _dmp.convertChangesToDMP; |
|
1657 /*istanbul ignore start*/exports. /*istanbul ignore end*/convertChangesToXML = _xml.convertChangesToXML; |
|
1658 /*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = _json.canonicalize; |
|
1659 //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJEaWZmIiwiZGlmZkNoYXJzIiwiZGlmZldvcmRzIiwiZGlmZldvcmRzV2l0aFNwYWNlIiwiZGlmZkxpbmVzIiwiZGlmZlRyaW1tZWRMaW5lcyIsImRpZmZTZW50ZW5jZXMiLCJkaWZmQ3NzIiwiZGlmZkpzb24iLCJkaWZmQXJyYXlzIiwic3RydWN0dXJlZFBhdGNoIiwiY3JlYXRlVHdvRmlsZXNQYXRjaCIsImNyZWF0ZVBhdGNoIiwiYXBwbHlQYXRjaCIsImFwcGx5UGF0Y2hlcyIsInBhcnNlUGF0Y2giLCJtZXJnZSIsImNvbnZlcnRDaGFuZ2VzVG9ETVAiLCJjb252ZXJ0Q2hhbmdlc1RvWE1MIiwiY2Fub25pY2FsaXplIl0sIm1hcHBpbmdzIjoiOzs7Ozt1QkFnQkE7Ozs7dUJBQ0E7O0FBQ0E7O0FBQ0E7O0FBQ0E7O0FBRUE7O0FBQ0E7O0FBRUE7O0FBRUE7O0FBQ0E7O0FBQ0E7O0FBQ0E7O0FBRUE7O0FBQ0E7Ozs7QUFqQ0E7O0FBRUE7Ozs7Ozs7Ozs7Ozs7O2dDQWtDRUEsSTt5REFFQUMsUzt5REFDQU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cbiAgZGlmZkNzcyxcbiAgZGlmZkpzb24sXG5cbiAgZGlmZkFycmF5cyxcblxuICBzdHJ1Y3R1cmVkUGF0Y2gsXG4gIGNyZWF0ZVR3b0ZpbGVzUGF0Y2gsXG4gIGNyZWF0ZVBhdGNoLFxuICBhcHBseVBhdGNoLFxuICBhcHBseVBhdGNoZXMsXG4gIHBhcnNlUGF0Y2gsXG4gIG1lcmdlLFxuICBjb252ZXJ0Q2hhbmdlc1RvRE1QLFxuICBjb252ZXJ0Q2hhbmdlc1RvWE1MLFxuICBjYW5vbmljYWxpemVcbn07XG4iXX0= |
|
1660 |
|
1661 |
|
1662 /***/ }), |
|
1663 /* 1 */ |
|
1664 /***/ (function(module, exports) { |
|
1665 |
|
1666 /*istanbul ignore start*/'use strict'; |
|
1667 |
|
1668 exports.__esModule = true; |
|
1669 exports['default'] = /*istanbul ignore end*/Diff; |
|
1670 function Diff() {} |
|
1671 |
|
1672 Diff.prototype = { |
|
1673 /*istanbul ignore start*/ /*istanbul ignore end*/diff: function diff(oldString, newString) { |
|
1674 /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; |
|
1675 |
|
1676 var callback = options.callback; |
|
1677 if (typeof options === 'function') { |
|
1678 callback = options; |
|
1679 options = {}; |
|
1680 } |
|
1681 this.options = options; |
|
1682 |
|
1683 var self = this; |
|
1684 |
|
1685 function done(value) { |
|
1686 if (callback) { |
|
1687 setTimeout(function () { |
|
1688 callback(undefined, value); |
|
1689 }, 0); |
|
1690 return true; |
|
1691 } else { |
|
1692 return value; |
|
1693 } |
|
1694 } |
|
1695 |
|
1696 // Allow subclasses to massage the input prior to running |
|
1697 oldString = this.castInput(oldString); |
|
1698 newString = this.castInput(newString); |
|
1699 |
|
1700 oldString = this.removeEmpty(this.tokenize(oldString)); |
|
1701 newString = this.removeEmpty(this.tokenize(newString)); |
|
1702 |
|
1703 var newLen = newString.length, |
|
1704 oldLen = oldString.length; |
|
1705 var editLength = 1; |
|
1706 var maxEditLength = newLen + oldLen; |
|
1707 var bestPath = [{ newPos: -1, components: [] }]; |
|
1708 |
|
1709 // Seed editLength = 0, i.e. the content starts with the same values |
|
1710 var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0); |
|
1711 if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) { |
|
1712 // Identity per the equality and tokenizer |
|
1713 return done([{ value: this.join(newString), count: newString.length }]); |
|
1714 } |
|
1715 |
|
1716 // Main worker method. checks all permutations of a given edit length for acceptance. |
|
1717 function execEditLength() { |
|
1718 for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) { |
|
1719 var basePath = /*istanbul ignore start*/void 0 /*istanbul ignore end*/; |
|
1720 var addPath = bestPath[diagonalPath - 1], |
|
1721 removePath = bestPath[diagonalPath + 1], |
|
1722 _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath; |
|
1723 if (addPath) { |
|
1724 // No one else is going to attempt to use this value, clear it |
|
1725 bestPath[diagonalPath - 1] = undefined; |
|
1726 } |
|
1727 |
|
1728 var canAdd = addPath && addPath.newPos + 1 < newLen, |
|
1729 canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen; |
|
1730 if (!canAdd && !canRemove) { |
|
1731 // If this path is a terminal then prune |
|
1732 bestPath[diagonalPath] = undefined; |
|
1733 continue; |
|
1734 } |
|
1735 |
|
1736 // Select the diagonal that we want to branch from. We select the prior |
|
1737 // path whose position in the new string is the farthest from the origin |
|
1738 // and does not pass the bounds of the diff graph |
|
1739 if (!canAdd || canRemove && addPath.newPos < removePath.newPos) { |
|
1740 basePath = clonePath(removePath); |
|
1741 self.pushComponent(basePath.components, undefined, true); |
|
1742 } else { |
|
1743 basePath = addPath; // No need to clone, we've pulled it from the list |
|
1744 basePath.newPos++; |
|
1745 self.pushComponent(basePath.components, true, undefined); |
|
1746 } |
|
1747 |
|
1748 _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); |
|
1749 |
|
1750 // If we have hit the end of both strings, then we are done |
|
1751 if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) { |
|
1752 return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken)); |
|
1753 } else { |
|
1754 // Otherwise track this path as a potential candidate and continue. |
|
1755 bestPath[diagonalPath] = basePath; |
|
1756 } |
|
1757 } |
|
1758 |
|
1759 editLength++; |
|
1760 } |
|
1761 |
|
1762 // Performs the length of edit iteration. Is a bit fugly as this has to support the |
|
1763 // sync and async mode which is never fun. Loops over execEditLength until a value |
|
1764 // is produced. |
|
1765 if (callback) { |
|
1766 (function exec() { |
|
1767 setTimeout(function () { |
|
1768 // This should not happen, but we want to be safe. |
|
1769 /* istanbul ignore next */ |
|
1770 if (editLength > maxEditLength) { |
|
1771 return callback(); |
|
1772 } |
|
1773 |
|
1774 if (!execEditLength()) { |
|
1775 exec(); |
|
1776 } |
|
1777 }, 0); |
|
1778 })(); |
|
1779 } else { |
|
1780 while (editLength <= maxEditLength) { |
|
1781 var ret = execEditLength(); |
|
1782 if (ret) { |
|
1783 return ret; |
|
1784 } |
|
1785 } |
|
1786 } |
|
1787 }, |
|
1788 /*istanbul ignore start*/ /*istanbul ignore end*/pushComponent: function pushComponent(components, added, removed) { |
|
1789 var last = components[components.length - 1]; |
|
1790 if (last && last.added === added && last.removed === removed) { |
|
1791 // We need to clone here as the component clone operation is just |
|
1792 // as shallow array clone |
|
1793 components[components.length - 1] = { count: last.count + 1, added: added, removed: removed }; |
|
1794 } else { |
|
1795 components.push({ count: 1, added: added, removed: removed }); |
|
1796 } |
|
1797 }, |
|
1798 /*istanbul ignore start*/ /*istanbul ignore end*/extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) { |
|
1799 var newLen = newString.length, |
|
1800 oldLen = oldString.length, |
|
1801 newPos = basePath.newPos, |
|
1802 oldPos = newPos - diagonalPath, |
|
1803 commonCount = 0; |
|
1804 while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) { |
|
1805 newPos++; |
|
1806 oldPos++; |
|
1807 commonCount++; |
|
1808 } |
|
1809 |
|
1810 if (commonCount) { |
|
1811 basePath.components.push({ count: commonCount }); |
|
1812 } |
|
1813 |
|
1814 basePath.newPos = newPos; |
|
1815 return oldPos; |
|
1816 }, |
|
1817 /*istanbul ignore start*/ /*istanbul ignore end*/equals: function equals(left, right) { |
|
1818 if (this.options.comparator) { |
|
1819 return this.options.comparator(left, right); |
|
1820 } else { |
|
1821 return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase(); |
|
1822 } |
|
1823 }, |
|
1824 /*istanbul ignore start*/ /*istanbul ignore end*/removeEmpty: function removeEmpty(array) { |
|
1825 var ret = []; |
|
1826 for (var i = 0; i < array.length; i++) { |
|
1827 if (array[i]) { |
|
1828 ret.push(array[i]); |
|
1829 } |
|
1830 } |
|
1831 return ret; |
|
1832 }, |
|
1833 /*istanbul ignore start*/ /*istanbul ignore end*/castInput: function castInput(value) { |
|
1834 return value; |
|
1835 }, |
|
1836 /*istanbul ignore start*/ /*istanbul ignore end*/tokenize: function tokenize(value) { |
|
1837 return value.split(''); |
|
1838 }, |
|
1839 /*istanbul ignore start*/ /*istanbul ignore end*/join: function join(chars) { |
|
1840 return chars.join(''); |
|
1841 } |
|
1842 }; |
|
1843 |
|
1844 function buildValues(diff, components, newString, oldString, useLongestToken) { |
|
1845 var componentPos = 0, |
|
1846 componentLen = components.length, |
|
1847 newPos = 0, |
|
1848 oldPos = 0; |
|
1849 |
|
1850 for (; componentPos < componentLen; componentPos++) { |
|
1851 var component = components[componentPos]; |
|
1852 if (!component.removed) { |
|
1853 if (!component.added && useLongestToken) { |
|
1854 var value = newString.slice(newPos, newPos + component.count); |
|
1855 value = value.map(function (value, i) { |
|
1856 var oldValue = oldString[oldPos + i]; |
|
1857 return oldValue.length > value.length ? oldValue : value; |
|
1858 }); |
|
1859 |
|
1860 component.value = diff.join(value); |
|
1861 } else { |
|
1862 component.value = diff.join(newString.slice(newPos, newPos + component.count)); |
|
1863 } |
|
1864 newPos += component.count; |
|
1865 |
|
1866 // Common case |
|
1867 if (!component.added) { |
|
1868 oldPos += component.count; |
|
1869 } |
|
1870 } else { |
|
1871 component.value = diff.join(oldString.slice(oldPos, oldPos + component.count)); |
|
1872 oldPos += component.count; |
|
1873 |
|
1874 // Reverse add and remove so removes are output first to match common convention |
|
1875 // The diffing algorithm is tied to add then remove output and this is the simplest |
|
1876 // route to get the desired output with minimal overhead. |
|
1877 if (componentPos && components[componentPos - 1].added) { |
|
1878 var tmp = components[componentPos - 1]; |
|
1879 components[componentPos - 1] = components[componentPos]; |
|
1880 components[componentPos] = tmp; |
|
1881 } |
|
1882 } |
|
1883 } |
|
1884 |
|
1885 // Special case handle for when one terminal is ignored (i.e. whitespace). |
|
1886 // For this case we merge the terminal into the prior string and drop the change. |
|
1887 // This is only available for string mode. |
|
1888 var lastComponent = components[componentLen - 1]; |
|
1889 if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) { |
|
1890 components[componentLen - 2].value += lastComponent.value; |
|
1891 components.pop(); |
|
1892 } |
|
1893 |
|
1894 return components; |
|
1895 } |
|
1896 |
|
1897 function clonePath(path) { |
|
1898 return { newPos: path.newPos, components: path.components.slice(0) }; |
|
1899 } |
|
1900 //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9kaWZmL2Jhc2UuanMiXSwibmFtZXMiOlsiRGlmZiIsInByb3RvdHlwZSIsImRpZmYiLCJvbGRTdHJpbmciLCJuZXdTdHJpbmciLCJvcHRpb25zIiwiY2FsbGJhY2siLCJzZWxmIiwiZG9uZSIsInZhbHVlIiwic2V0VGltZW91dCIsInVuZGVmaW5lZCIsImNhc3RJbnB1dCIsInJlbW92ZUVtcHR5IiwidG9rZW5pemUiLCJuZXdMZW4iLCJsZW5ndGgiLCJ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vbmVudC5yZW1vdmVkKVxuICAgICAgJiYgZGlmZi5lcXVhbHMoJycsIGxhc3RDb21wb25lbnQudmFsdWUpKSB7XG4gICAgY29tcG9uZW50c1tjb21wb25lbnRMZW4gLSAyXS52YWx1ZSArPSBsYXN0Q29tcG9uZW50LnZhbHVlO1xuICAgIGNvbXBvbmVudHMucG9wKCk7XG4gIH1cblxuICByZXR1cm4gY29tcG9uZW50cztcbn1cblxuZnVuY3Rpb24gY2xvbmVQYXRoKHBhdGgpIHtcbiAgcmV0dXJuIHsgbmV3UG9zOiBwYXRoLm5ld1BvcywgY29tcG9uZW50czogcGF0aC5jb21wb25lbnRzLnNsaWNlKDApIH07XG59XG4iXX0= |
|
1901 |
|
1902 |
|
1903 /***/ }), |
|
1904 /* 2 */ |
|
1905 /***/ (function(module, exports, __webpack_require__) { |
|
1906 |
|
1907 /*istanbul ignore start*/'use strict'; |
|
1908 |
|
1909 exports.__esModule = true; |
|
1910 exports.characterDiff = undefined; |
|
1911 exports. /*istanbul ignore end*/diffChars = diffChars; |
|
1912 |
|
1913 var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/; |
|
1914 |
|
1915 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base); |
|
1916 |
|
1917 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
|
1918 |
|
1919 /*istanbul ignore end*/var characterDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/characterDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/(); |
|
1920 function diffChars(oldStr, newStr, options) { |
|
1921 return characterDiff.diff(oldStr, newStr, options); |
|
1922 } |
|
1923 //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9kaWZmL2NoYXJhY3Rlci5qcyJdLCJuYW1lcyI6WyJkaWZmQ2hhcnMiLCJjaGFyYWN0ZXJEaWZmIiwib2xkU3RyIiwibmV3U3RyIiwib3B0aW9ucyIsImRpZmYiXSwibWFwcGluZ3MiOiI7Ozs7Z0NBR2dCQSxTLEdBQUFBLFM7O0FBSGhCOzs7Ozs7dUJBRU8sSUFBTUMseUZBQWdCLHdFQUF0QjtBQUNBLFNBQVNELFNBQVQsQ0FBbUJFLE1BQW5CLEVBQTJCQyxNQUEzQixFQUFtQ0MsT0FBbkMsRUFBNEM7QUFBRSxTQUFPSCxjQUFjSSxJQUFkLENBQW1CSCxNQUFuQixFQUEyQkMsTUFBM0IsRUFBbUNDLE9BQW5DLENBQVA7QUFBcUQiLCJmaWxlIjoiY2hhcmFjdGVyLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IERpZmYgZnJvbSAnLi9iYXNlJztcblxuZXhwb3J0IGNvbnN0IGNoYXJhY3RlckRpZmYgPSBuZXcgRGlmZigpO1xuZXhwb3J0IGZ1bmN0aW9uIGRpZmZDaGFycyhvbGRTdHIsIG5ld1N0ciwgb3B0aW9ucykgeyByZXR1cm4gY2hhcmFjdGVyRGlmZi5kaWZmKG9sZFN0ciwgbmV3U3RyLCBvcHRpb25zKTsgfVxuIl19 |
|
1924 |
|
1925 |
|
1926 /***/ }), |
|
1927 /* 3 */ |
|
1928 /***/ (function(module, exports, __webpack_require__) { |
|
1929 |
|
1930 /*istanbul ignore start*/'use strict'; |
|
1931 |
|
1932 exports.__esModule = true; |
|
1933 exports.wordDiff = undefined; |
|
1934 exports. /*istanbul ignore end*/diffWords = diffWords; |
|
1935 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffWordsWithSpace = diffWordsWithSpace; |
|
1936 |
|
1937 var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/; |
|
1938 |
|
1939 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base); |
|
1940 |
|
1941 /*istanbul ignore end*/var /*istanbul ignore start*/_params = __webpack_require__(4) /*istanbul ignore end*/; |
|
1942 |
|
1943 /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
|
1944 |
|
1945 /*istanbul ignore end*/ // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode |
|
1946 // |
|
1947 // Ranges and exceptions: |
|
1948 // Latin-1 Supplement, 0080–00FF |
|
1949 // - U+00D7 × Multiplication sign |
|
1950 // - U+00F7 ÷ Division sign |
|
1951 // Latin Extended-A, 0100–017F |
|
1952 // Latin Extended-B, 0180–024F |
|
1953 // IPA Extensions, 0250–02AF |
|
1954 // Spacing Modifier Letters, 02B0–02FF |
|
1955 // - U+02C7 ˇ ˇ Caron |
|
1956 // - U+02D8 ˘ ˘ Breve |
|
1957 // - U+02D9 ˙ ˙ Dot Above |
|
1958 // - U+02DA ˚ ˚ Ring Above |
|
1959 // - U+02DB ˛ ˛ Ogonek |
|
1960 // - U+02DC ˜ ˜ Small Tilde |
|
1961 // - U+02DD ˝ ˝ Double Acute Accent |
|
1962 // Latin Extended Additional, 1E00–1EFF |
|
1963 var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/; |
|
1964 |
|
1965 var reWhitespace = /\S/; |
|
1966 |
|
1967 var wordDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/wordDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/(); |
|
1968 wordDiff.equals = function (left, right) { |
|
1969 if (this.options.ignoreCase) { |
|
1970 left = left.toLowerCase(); |
|
1971 right = right.toLowerCase(); |
|
1972 } |
|
1973 return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right); |
|
1974 }; |
|
1975 wordDiff.tokenize = function (value) { |
|
1976 var tokens = value.split(/(\s+|\b)/); |
|
1977 |
|
1978 // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set. |
|
1979 for (var i = 0; i < tokens.length - 1; i++) { |
|
1980 // If we have an empty string in the next field and we have only word chars before and after, merge |
|
1981 if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) { |
|
1982 tokens[i] += tokens[i + 2]; |
|
1983 tokens.splice(i + 1, 2); |
|
1984 i--; |
|
1985 } |
|
1986 } |
|
1987 |
|
1988 return tokens; |
|
1989 }; |
|
1990 |
|
1991 function diffWords(oldStr, newStr, options) { |
|
1992 options = /*istanbul ignore start*/(0, _params.generateOptions) /*istanbul ignore end*/(options, { ignoreWhitespace: true }); |
|
1993 return wordDiff.diff(oldStr, newStr, options); |
|
1994 } |
|
1995 |
|
1996 function diffWordsWithSpace(oldStr, newStr, options) { |
|
1997 return wordDiff.diff(oldStr, newStr, options); |
|
1998 } |
|
1999 //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9kaWZmL3dvcmQuanMiXSwibmFtZXMiOlsiZGlmZldvcmRzIiwiZGlmZldvcmRzV2l0aFNwYWNlIiwiZXh0ZW5kZWRXb3JkQ2hhcnMiLCJyZVdoaXRlc3BhY2UiLCJ3b3JkRGlmZiIsImVxdWFscyIsImxlZnQiLCJyaWdodCIsIm9wdGlvbnMiLCJpZ25vcmVDYXNlIiwidG9Mb3dlckNhc2UiLCJpZ25vcmVXaGl0ZXNwYWNlIiwidGVzdCIsInRva2VuaXplIiwidmFsdWUiLCJ0b2tlbnMiLCJzcGxpdCIsImkiLCJsZW5ndGgiLCJzcGxpY2UiLCJvbGRTdHIiLCJuZXdTdHIiLCJkaWZmIl0sIm1hcHBpbmdzIjoiOzs7O2dDQW1EZ0JBLFMsR0FBQUEsUzt5REFLQUMsa0IsR0FBQUEsa0I7O0FBeERoQjs7Ozt1QkFDQTs7Ozt3QkFFQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQS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Zi5kaWZmKG9sZFN0ciwgbmV3U3RyLCBvcHRpb25zKTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIGRpZmZXb3Jkc1dpdGhTcGFjZShvbGRTdHIsIG5ld1N0ciwgb3B0aW9ucykge1xuICByZXR1cm4gd29yZERpZmYuZGlmZihvbGRTdHIsIG5ld1N0ciwgb3B0aW9ucyk7XG59XG4iXX0= |
|
2000 |
|
2001 |
|
2002 /***/ }), |
|
2003 /* 4 */ |
|
2004 /***/ (function(module, exports) { |
|
2005 |
|
2006 /*istanbul ignore start*/'use strict'; |
|
2007 |
|
2008 exports.__esModule = true; |
|
2009 exports. /*istanbul ignore end*/generateOptions = generateOptions; |
|
2010 function generateOptions(options, defaults) { |
|
2011 if (typeof options === 'function') { |
|
2012 defaults.callback = options; |
|
2013 } else if (options) { |
|
2014 for (var name in options) { |
|
2015 /* istanbul ignore else */ |
|
2016 if (options.hasOwnProperty(name)) { |
|
2017 defaults[name] = options[name]; |
|
2018 } |
|
2019 } |
|
2020 } |
|
2021 return defaults; |
|
2022 } |
|
2023 //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsL3BhcmFtcy5qcyJdLCJuYW1lcyI6WyJnZW5lcmF0ZU9wdGlvbnMiLCJvcHRpb25zIiwiZGVmYXVsdHMiLCJjYWxsYmFjayIsIm5hbWUiLCJoYXNPd25Qcm9wZXJ0eSJdLCJtYXBwaW5ncyI6Ijs7O2dDQUFnQkEsZSxHQUFBQSxlO0FBQVQsU0FBU0EsZUFBVCxDQUF5QkMsT0FBekIsRUFBa0NDLFFBQWxDLEVBQTRDO0FBQ2pELE1BQUksT0FBT0QsT0FBUCxLQUFtQixVQUF2QixFQUFtQztBQUNqQ0MsYUFBU0MsUUFBVCxHQUFvQkYsT0FBcEI7QUFDRCxHQUZELE1BRU8sSUFBSUEsT0FBSixFQUFhO0FBQ2xCLFNBQUssSUFBSUcsSUFBVCxJQUFpQkgsT0FBakIsRUFBMEI7QUFDeEI7QUFDQSxVQUFJQSxRQUFRSSxjQUFSLENBQXVCRCxJQUF2QixDQUFKLEVBQWtDO0FBQ2hDRixpQkFBU0UsSUFBVCxJQUFpQkgsUUFBUUcsSUFBUixDQUFqQjtBQUNEO0FBQ0Y7QUFDRjtBQUNELFNBQU9GLFFBQVA7QUFDRCIsImZpbGUiOiJwYXJhbXMuanMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZnVuY3Rpb24gZ2VuZXJhdGVPcHRpb25zKG9wdGlvbnMsIGRlZmF1bHRzKSB7XG4gIGlmICh0eXBlb2Ygb3B0aW9ucyA9PT0gJ2Z1bmN0aW9uJykge1xuICAgIGRlZmF1bHRzLmNhbGxiYWNrID0gb3B0aW9ucztcbiAgfSBlbHNlIGlmIChvcHRpb25zKSB7XG4gICAgZm9yIChsZXQgbmFtZSBpbiBvcHRpb25zKSB7XG4gICAgICAvKiBpc3RhbmJ1bCBpZ25vcmUgZWxzZSAqL1xuICAgICAgaWYgKG9wdGlvbnMuaGFzT3duUHJvcGVydHkobmFtZSkpIHtcbiAgICAgICAgZGVmYXVsdHNbbmFtZV0gPSBvcHRpb25zW25hbWVdO1xuICAgICAgfVxuICAgIH1cbiAgfVxuICByZXR1cm4gZGVmYXVsdHM7XG59XG4iXX0= |
|
2024 |
|
2025 |
|
2026 /***/ }), |
|
2027 /* 5 */ |
|
2028 /***/ (function(module, exports, __webpack_require__) { |
|
2029 |
|
2030 /*istanbul ignore start*/'use strict'; |
|
2031 |
|
2032 exports.__esModule = true; |
|
2033 exports.lineDiff = undefined; |
|
2034 exports. /*istanbul ignore end*/diffLines = diffLines; |
|
2035 /*istanbul ignore start*/exports. /*istanbul ignore end*/diffTrimmedLines = diffTrimmedLines; |
|
2036 |
|
2037 var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/; |
|
2038 |
|
2039 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base); |
|
2040 |
|
2041 /*istanbul ignore end*/var /*istanbul ignore start*/_params = __webpack_require__(4) /*istanbul ignore end*/; |
|
2042 |
|
2043 /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
|
2044 |
|
2045 /*istanbul ignore end*/var lineDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/lineDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/(); |
|
2046 lineDiff.tokenize = function (value) { |
|
2047 var retLines = [], |
|
2048 linesAndNewlines = value.split(/(\n|\r\n)/); |
|
2049 |
|
2050 // Ignore the final empty token that occurs if the string ends with a new line |
|
2051 if (!linesAndNewlines[linesAndNewlines.length - 1]) { |
|
2052 linesAndNewlines.pop(); |
|
2053 } |
|
2054 |
|
2055 // Merge the content and line separators into single tokens |
|
2056 for (var i = 0; i < linesAndNewlines.length; i++) { |
|
2057 var line = linesAndNewlines[i]; |
|
2058 |
|
2059 if (i % 2 && !this.options.newlineIsToken) { |
|
2060 retLines[retLines.length - 1] += line; |
|
2061 } else { |
|
2062 if (this.options.ignoreWhitespace) { |
|
2063 line = line.trim(); |
|
2064 } |
|
2065 retLines.push(line); |
|
2066 } |
|
2067 } |
|
2068 |
|
2069 return retLines; |
|
2070 }; |
|
2071 |
|
2072 function diffLines(oldStr, newStr, callback) { |
|
2073 return lineDiff.diff(oldStr, newStr, callback); |
|
2074 } |
|
2075 function diffTrimmedLines(oldStr, newStr, callback) { |
|
2076 var options = /*istanbul ignore start*/(0, _params.generateOptions) /*istanbul ignore end*/(callback, { ignoreWhitespace: true }); |
|
2077 return lineDiff.diff(oldStr, newStr, options); |
|
2078 } |
|
2079 //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9kaWZmL2xpbmUuanMiXSwibmFtZXMiOlsiZGlmZkxpbmVzIiwiZGlmZlRyaW1tZWRMaW5lcyIsImxpbmVEaWZ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lbmd0aCAtIDFdKSB7XG4gICAgbGluZXNBbmROZXdsaW5lcy5wb3AoKTtcbiAgfVxuXG4gIC8vIE1lcmdlIHRoZSBjb250ZW50IGFuZCBsaW5lIHNlcGFyYXRvcnMgaW50byBzaW5nbGUgdG9rZW5zXG4gIGZvciAobGV0IGkgPSAwOyBpIDwgbGluZXNBbmROZXdsaW5lcy5sZW5ndGg7IGkrKykge1xuICAgIGxldCBsaW5lID0gbGluZXNBbmROZXdsaW5lc1tpXTtcblxuICAgIGlmIChpICUgMiAmJiAhdGhpcy5vcHRpb25zLm5ld2xpbmVJc1Rva2VuKSB7XG4gICAgICByZXRMaW5lc1tyZXRMaW5lcy5sZW5ndGggLSAxXSArPSBsaW5lO1xuICAgIH0gZWxzZSB7XG4gICAgICBpZiAodGhpcy5vcHRpb25zLmlnbm9yZVdoaXRlc3BhY2UpIHtcbiAgICAgICAgbGluZSA9IGxpbmUudHJpbSgpO1xuICAgICAgfVxuICAgICAgcmV0TGluZXMucHVzaChsaW5lKTtcbiAgICB9XG4gIH1cblxuICByZXR1cm4gcmV0TGluZXM7XG59O1xuXG5leHBvcnQgZnVuY3Rpb24gZGlmZkxpbmVzKG9sZFN0ciwgbmV3U3RyLCBjYWxsYmFjaykgeyByZXR1cm4gbGluZURpZmYuZGlmZihvbGRTdHIsIG5ld1N0ciwgY2FsbGJhY2spOyB9XG5leHBvcnQgZnVuY3Rpb24gZGlmZlRyaW1tZWRMaW5lcyhvbGRTdHIsIG5ld1N0ciwgY2FsbGJhY2spIHtcbiAgbGV0IG9wdGlvbnMgPSBnZW5lcmF0ZU9wdGlvbnMoY2FsbGJhY2ssIHtpZ25vcmVXaGl0ZXNwYWNlOiB0cnVlfSk7XG4gIHJldHVybiBsaW5lRGlmZi5kaWZmKG9sZFN0ciwgbmV3U3RyLCBvcHRpb25zKTtcbn1cbiJdfQ== |
|
2080 |
|
2081 |
|
2082 /***/ }), |
|
2083 /* 6 */ |
|
2084 /***/ (function(module, exports, __webpack_require__) { |
|
2085 |
|
2086 /*istanbul ignore start*/'use strict'; |
|
2087 |
|
2088 exports.__esModule = true; |
|
2089 exports.sentenceDiff = undefined; |
|
2090 exports. /*istanbul ignore end*/diffSentences = diffSentences; |
|
2091 |
|
2092 var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/; |
|
2093 |
|
2094 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base); |
|
2095 |
|
2096 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
|
2097 |
|
2098 /*istanbul ignore end*/var sentenceDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/sentenceDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/(); |
|
2099 sentenceDiff.tokenize = function (value) { |
|
2100 return value.split(/(\S.+?[.!?])(?=\s+|$)/); |
|
2101 }; |
|
2102 |
|
2103 function diffSentences(oldStr, newStr, callback) { |
|
2104 return sentenceDiff.diff(oldStr, newStr, callback); |
|
2105 } |
|
2106 //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9kaWZmL3NlbnRlbmNlLmpzIl0sIm5hbWVzIjpbImRpZmZTZW50ZW5jZXMiLCJzZW50ZW5jZURpZmYiLCJ0b2tlbml6ZSIsInZhbHVlIiwic3BsaXQiLCJvbGRTdHIiLCJuZXdTdHIiLCJjYWxsYmFjayIsImRpZmYiXSwibWFwcGluZ3MiOiI7Ozs7Z0NBUWdCQSxhLEdBQUFBLGE7O0FBUmhCOzs7Ozs7dUJBR08sSUFBTUMsdUZBQWUsd0VBQXJCO0FBQ1BBLGFBQWFDLFFBQWIsR0FBd0IsVUFBU0MsS0FBVCxFQUFnQjtBQUN0QyxTQUFPQSxNQUFNQyxLQUFOLENBQVksdUJBQVosQ0FBUDtBQUNELENBRkQ7O0FBSU8sU0FBU0osYUFBVCxDQUF1QkssTUFBdkIsRUFBK0JDLE1BQS9CLEVBQXVDQyxRQUF2QyxFQUFpRDtBQUFFLFNBQU9OLGFBQWFPLElBQWIsQ0FBa0JILE1BQWxCLEVBQTBCQyxNQUExQixFQUFrQ0MsUUFBbEMsQ0FBUDtBQUFxRCIsImZpbGUiOiJzZW50ZW5jZS5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBEaWZmIGZyb20gJy4vYmFzZSc7XG5cblxuZXhwb3J0IGNvbnN0IHNlbnRlbmNlRGlmZiA9IG5ldyBEaWZmKCk7XG5zZW50ZW5jZURpZmYudG9rZW5pemUgPSBmdW5jdGlvbih2YWx1ZSkge1xuICByZXR1cm4gdmFsdWUuc3BsaXQoLyhcXFMuKz9bLiE/XSkoPz1cXHMrfCQpLyk7XG59O1xuXG5leHBvcnQgZnVuY3Rpb24gZGlmZlNlbnRlbmNlcyhvbGRTdHIsIG5ld1N0ciwgY2FsbGJhY2spIHsgcmV0dXJuIHNlbnRlbmNlRGlmZi5kaWZmKG9sZFN0ciwgbmV3U3RyLCBjYWxsYmFjayk7IH1cbiJdfQ== |
|
2107 |
|
2108 |
|
2109 /***/ }), |
|
2110 /* 7 */ |
|
2111 /***/ (function(module, exports, __webpack_require__) { |
|
2112 |
|
2113 /*istanbul ignore start*/'use strict'; |
|
2114 |
|
2115 exports.__esModule = true; |
|
2116 exports.cssDiff = undefined; |
|
2117 exports. /*istanbul ignore end*/diffCss = diffCss; |
|
2118 |
|
2119 var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/; |
|
2120 |
|
2121 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base); |
|
2122 |
|
2123 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
|
2124 |
|
2125 /*istanbul ignore end*/var cssDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/cssDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/(); |
|
2126 cssDiff.tokenize = function (value) { |
|
2127 return value.split(/([{}:;,]|\s+)/); |
|
2128 }; |
|
2129 |
|
2130 function diffCss(oldStr, newStr, callback) { |
|
2131 return cssDiff.diff(oldStr, newStr, callback); |
|
2132 } |
|
2133 //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9kaWZmL2Nzcy5qcyJdLCJuYW1lcyI6WyJkaWZmQ3NzIiwiY3NzRGlmZiIsInRva2VuaXplIiwidmFsdWUiLCJzcGxpdCIsIm9sZFN0ciIsIm5ld1N0ciIsImNhbGxiYWNrIiwiZGlmZiJdLCJtYXBwaW5ncyI6Ijs7OztnQ0FPZ0JBLE8sR0FBQUEsTzs7QUFQaEI7Ozs7Ozt1QkFFTyxJQUFNQyw2RUFBVSx3RUFBaEI7QUFDUEEsUUFBUUMsUUFBUixHQUFtQixVQUFTQyxLQUFULEVBQWdCO0FBQ2pDLFNBQU9BLE1BQU1DLEtBQU4sQ0FBWSxlQUFaLENBQVA7QUFDRCxDQUZEOztBQUlPLFNBQVNKLE9BQVQsQ0FBaUJLLE1BQWpCLEVBQXlCQyxNQUF6QixFQUFpQ0MsUUFBakMsRUFBMkM7QUFBRSxTQUFPTixRQUFRTyxJQUFSLENBQWFILE1BQWIsRUFBcUJDLE1BQXJCLEVBQTZCQyxRQUE3QixDQUFQO0FBQWdEIiwiZmlsZSI6ImNzcy5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBEaWZmIGZyb20gJy4vYmFzZSc7XG5cbmV4cG9ydCBjb25zdCBjc3NEaWZmID0gbmV3IERpZmYoKTtcbmNzc0RpZmYudG9rZW5pemUgPSBmdW5jdGlvbih2YWx1ZSkge1xuICByZXR1cm4gdmFsdWUuc3BsaXQoLyhbe306OyxdfFxccyspLyk7XG59O1xuXG5leHBvcnQgZnVuY3Rpb24gZGlmZkNzcyhvbGRTdHIsIG5ld1N0ciwgY2FsbGJhY2spIHsgcmV0dXJuIGNzc0RpZmYuZGlmZihvbGRTdHIsIG5ld1N0ciwgY2FsbGJhY2spOyB9XG4iXX0= |
|
2134 |
|
2135 |
|
2136 /***/ }), |
|
2137 /* 8 */ |
|
2138 /***/ (function(module, exports, __webpack_require__) { |
|
2139 |
|
2140 /*istanbul ignore start*/'use strict'; |
|
2141 |
|
2142 exports.__esModule = true; |
|
2143 exports.jsonDiff = undefined; |
|
2144 |
|
2145 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; |
|
2146 |
|
2147 exports. /*istanbul ignore end*/diffJson = diffJson; |
|
2148 /*istanbul ignore start*/exports. /*istanbul ignore end*/canonicalize = canonicalize; |
|
2149 |
|
2150 var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/; |
|
2151 |
|
2152 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base); |
|
2153 |
|
2154 /*istanbul ignore end*/var /*istanbul ignore start*/_line = __webpack_require__(5) /*istanbul ignore end*/; |
|
2155 |
|
2156 /*istanbul ignore start*/function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
|
2157 |
|
2158 /*istanbul ignore end*/var objectPrototypeToString = Object.prototype.toString; |
|
2159 |
|
2160 var jsonDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/jsonDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/(); |
|
2161 // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a |
|
2162 // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output: |
|
2163 jsonDiff.useLongestToken = true; |
|
2164 |
|
2165 jsonDiff.tokenize = /*istanbul ignore start*/_line.lineDiff /*istanbul ignore end*/.tokenize; |
|
2166 jsonDiff.castInput = function (value) { |
|
2167 /*istanbul ignore start*/var _options = /*istanbul ignore end*/this.options, |
|
2168 undefinedReplacement = _options.undefinedReplacement, |
|
2169 _options$stringifyRep = _options.stringifyReplacer, |
|
2170 stringifyReplacer = _options$stringifyRep === undefined ? function (k, v) /*istanbul ignore start*/{ |
|
2171 return (/*istanbul ignore end*/typeof v === 'undefined' ? undefinedReplacement : v |
|
2172 ); |
|
2173 } : _options$stringifyRep; |
|
2174 |
|
2175 |
|
2176 return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' '); |
|
2177 }; |
|
2178 jsonDiff.equals = function (left, right) { |
|
2179 return (/*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1')) |
|
2180 ); |
|
2181 }; |
|
2182 |
|
2183 function diffJson(oldObj, newObj, options) { |
|
2184 return jsonDiff.diff(oldObj, newObj, options); |
|
2185 } |
|
2186 |
|
2187 // This function handles the presence of circular references by bailing out when encountering an |
|
2188 // object that is already on the "stack" of items being processed. Accepts an optional replacer |
|
2189 function canonicalize(obj, stack, replacementStack, replacer, key) { |
|
2190 stack = stack || []; |
|
2191 replacementStack = replacementStack || []; |
|
2192 |
|
2193 if (replacer) { |
|
2194 obj = replacer(key, obj); |
|
2195 } |
|
2196 |
|
2197 var i = /*istanbul ignore start*/void 0 /*istanbul ignore end*/; |
|
2198 |
|
2199 for (i = 0; i < stack.length; i += 1) { |
|
2200 if (stack[i] === obj) { |
|
2201 return replacementStack[i]; |
|
2202 } |
|
2203 } |
|
2204 |
|
2205 var canonicalizedObj = /*istanbul ignore start*/void 0 /*istanbul ignore end*/; |
|
2206 |
|
2207 if ('[object Array]' === objectPrototypeToString.call(obj)) { |
|
2208 stack.push(obj); |
|
2209 canonicalizedObj = new Array(obj.length); |
|
2210 replacementStack.push(canonicalizedObj); |
|
2211 for (i = 0; i < obj.length; i += 1) { |
|
2212 canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key); |
|
2213 } |
|
2214 stack.pop(); |
|
2215 replacementStack.pop(); |
|
2216 return canonicalizedObj; |
|
2217 } |
|
2218 |
|
2219 if (obj && obj.toJSON) { |
|
2220 obj = obj.toJSON(); |
|
2221 } |
|
2222 |
|
2223 if ( /*istanbul ignore start*/(typeof /*istanbul ignore end*/obj === 'undefined' ? 'undefined' : _typeof(obj)) === 'object' && obj !== null) { |
|
2224 stack.push(obj); |
|
2225 canonicalizedObj = {}; |
|
2226 replacementStack.push(canonicalizedObj); |
|
2227 var sortedKeys = [], |
|
2228 _key = /*istanbul ignore start*/void 0 /*istanbul ignore end*/; |
|
2229 for (_key in obj) { |
|
2230 /* istanbul ignore else */ |
|
2231 if (obj.hasOwnProperty(_key)) { |
|
2232 sortedKeys.push(_key); |
|
2233 } |
|
2234 } |
|
2235 sortedKeys.sort(); |
|
2236 for (i = 0; i < sortedKeys.length; i += 1) { |
|
2237 _key = sortedKeys[i]; |
|
2238 canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key); |
|
2239 } |
|
2240 stack.pop(); |
|
2241 replacementStack.pop(); |
|
2242 } else { |
|
2243 canonicalizedObj = obj; |
|
2244 } |
|
2245 return canonicalizedObj; |
|
2246 } |
|
2247 //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9kaWZmL2pzb24uanMiXSwibmFtZXMiOlsiZGlmZkpzb24iLCJjYW5vbmljYWxpemUiLCJvYmplY3RQcm90b3R5cGVUb1N0cmluZyIsIk9iamVjdCIsInByb3RvdHlwZSIsInRvU3RyaW5nIiwianNvbkRpZmYiLCJ1c2VMb25nZXN0VG9rZW4iLCJ0b2tlbml6ZSIsImNhc3RJbnB1dCIsInZhbHVlIiwib3B0aW9ucyIsInVuZGVmaW5lZFJlcGxhY2VtZW50Iiwic3RyaW5naWZ5UmVwbGFjZXIiLCJrIiwidiIsIkpTT04iLCJzdHJpbmdpZnkiLCJlcXVhbHMiLCJsZWZ0IiwicmlnaHQiLCJjYWxsIiwic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0JyAmJiBvYmogIT09IG51bGwpIHtcbiAgICBzdGFjay5wdXNoKG9iaik7XG4gICAgY2Fub25pY2FsaXplZE9iaiA9IHt9O1xuICAgIHJlcGxhY2VtZW50U3RhY2sucHVzaChjYW5vbmljYWxpemVkT2JqKTtcbiAgICBsZXQgc29ydGVkS2V5cyA9IFtdLFxuICAgICAgICBrZXk7XG4gICAgZm9yIChrZXkgaW4gb2JqKSB7XG4gICAgICAvKiBpc3RhbmJ1bCBpZ25vcmUgZWxzZSAqL1xuICAgICAgaWYgKG9iai5oYXNPd25Qcm9wZXJ0eShrZXkpKSB7XG4gICAgICAgIHNvcnRlZEtleXMucHVzaChrZXkpO1xuICAgICAgfVxuICAgIH1cbiAgICBzb3J0ZWRLZXlzLnNvcnQoKTtcbiAgICBmb3IgKGkgPSAwOyBpIDwgc29ydGVkS2V5cy5sZW5ndGg7IGkgKz0gMSkge1xuICAgICAga2V5ID0gc29ydGVkS2V5c1tpXTtcbiAgICAgIGNhbm9uaWNhbGl6ZWRPYmpba2V5XSA9IGNhbm9uaWNhbGl6ZShvYmpba2V5XSwgc3RhY2ssIHJlcGxhY2VtZW50U3RhY2ssIHJlcGxhY2VyLCBrZXkpO1xuICAgIH1cbiAgICBzdGFjay5wb3AoKTtcbiAgICByZXBsYWNlbWVudFN0YWNrLnBvcCgpO1xuICB9IGVsc2Uge1xuICAgIGNhbm9uaWNhbGl6ZWRPYmogPSBvYmo7XG4gIH1cbiAgcmV0dXJuIGNhbm9uaWNhbGl6ZWRPYmo7XG59XG4iXX0= |
|
2248 |
|
2249 |
|
2250 /***/ }), |
|
2251 /* 9 */ |
|
2252 /***/ (function(module, exports, __webpack_require__) { |
|
2253 |
|
2254 /*istanbul ignore start*/'use strict'; |
|
2255 |
|
2256 exports.__esModule = true; |
|
2257 exports.arrayDiff = undefined; |
|
2258 exports. /*istanbul ignore end*/diffArrays = diffArrays; |
|
2259 |
|
2260 var /*istanbul ignore start*/_base = __webpack_require__(1) /*istanbul ignore end*/; |
|
2261 |
|
2262 /*istanbul ignore start*/var _base2 = _interopRequireDefault(_base); |
|
2263 |
|
2264 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
|
2265 |
|
2266 /*istanbul ignore end*/var arrayDiff = /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayDiff = new /*istanbul ignore start*/_base2['default'] /*istanbul ignore end*/(); |
|
2267 arrayDiff.tokenize = function (value) { |
|
2268 return value.slice(); |
|
2269 }; |
|
2270 arrayDiff.join = arrayDiff.removeEmpty = function (value) { |
|
2271 return value; |
|
2272 }; |
|
2273 |
|
2274 function diffArrays(oldArr, newArr, callback) { |
|
2275 return arrayDiff.diff(oldArr, newArr, callback); |
|
2276 } |
|
2277 //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9kaWZmL2FycmF5LmpzIl0sIm5hbWVzIjpbImRpZmZBcnJheXMiLCJhcnJheURpZmYiLCJ0b2tlbml6ZSIsInZhbHVlIiwic2xpY2UiLCJqb2luIiwicmVtb3ZlRW1wdHkiLCJvbGRBcnIiLCJuZXdBcnIiLCJjYWxsYmFjayIsImRpZmYiXSwibWFwcGluZ3MiOiI7Ozs7Z0NBVWdCQSxVLEdBQUFBLFU7O0FBVmhCOzs7Ozs7dUJBRU8sSUFBTUMsaUZBQVksd0VBQWxCO0FBQ1BBLFVBQVVDLFFBQVYsR0FBcUIsVUFBU0MsS0FBVCxFQUFnQjtBQUNuQyxTQUFPQSxNQUFNQyxLQUFOLEVBQVA7QUFDRCxDQUZEO0FBR0FILFVBQVVJLElBQVYsR0FBaUJKLFVBQVVLLFdBQVYsR0FBd0IsVUFBU0gsS0FBVCxFQUFnQjtBQUN2RCxTQUFPQSxLQUFQO0FBQ0QsQ0FGRDs7QUFJTyxTQUFTSCxVQUFULENBQW9CTyxNQUFwQixFQUE0QkMsTUFBNUIsRUFBb0NDLFFBQXBDLEVBQThDO0FBQUUsU0FBT1IsVUFBVVMsSUFBVixDQUFlSCxNQUFmLEVBQXVCQyxNQUF2QixFQUErQkMsUUFBL0IsQ0FBUDtBQUFrRCIsImZpbGUiOiJhcnJheS5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBEaWZmIGZyb20gJy4vYmFzZSc7XG5cbmV4cG9ydCBjb25zdCBhcnJheURpZmYgPSBuZXcgRGlmZigpO1xuYXJyYXlEaWZmLnRva2VuaXplID0gZnVuY3Rpb24odmFsdWUpIHtcbiAgcmV0dXJuIHZhbHVlLnNsaWNlKCk7XG59O1xuYXJyYXlEaWZmLmpvaW4gPSBhcnJheURpZmYucmVtb3ZlRW1wdHkgPSBmdW5jdGlvbih2YWx1ZSkge1xuICByZXR1cm4gdmFsdWU7XG59O1xuXG5leHBvcnQgZnVuY3Rpb24gZGlmZkFycmF5cyhvbGRBcnIsIG5ld0FyciwgY2FsbGJhY2spIHsgcmV0dXJuIGFycmF5RGlmZi5kaWZmKG9sZEFyciwgbmV3QXJyLCBjYWxsYmFjayk7IH1cbiJdfQ== |
|
2278 |
|
2279 |
|
2280 /***/ }), |
|
2281 /* 10 */ |
|
2282 /***/ (function(module, exports, __webpack_require__) { |
|
2283 |
|
2284 /*istanbul ignore start*/'use strict'; |
|
2285 |
|
2286 exports.__esModule = true; |
|
2287 exports. /*istanbul ignore end*/applyPatch = applyPatch; |
|
2288 /*istanbul ignore start*/exports. /*istanbul ignore end*/applyPatches = applyPatches; |
|
2289 |
|
2290 var /*istanbul ignore start*/_parse = __webpack_require__(11) /*istanbul ignore end*/; |
|
2291 |
|
2292 var /*istanbul ignore start*/_distanceIterator = __webpack_require__(12) /*istanbul ignore end*/; |
|
2293 |
|
2294 /*istanbul ignore start*/var _distanceIterator2 = _interopRequireDefault(_distanceIterator); |
|
2295 |
|
2296 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
|
2297 |
|
2298 /*istanbul ignore end*/function applyPatch(source, uniDiff) { |
|
2299 /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; |
|
2300 |
|
2301 if (typeof uniDiff === 'string') { |
|
2302 uniDiff = /*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(uniDiff); |
|
2303 } |
|
2304 |
|
2305 if (Array.isArray(uniDiff)) { |
|
2306 if (uniDiff.length > 1) { |
|
2307 throw new Error('applyPatch only works with a single input.'); |
|
2308 } |
|
2309 |
|
2310 uniDiff = uniDiff[0]; |
|
2311 } |
|
2312 |
|
2313 // Apply the diff to the input |
|
2314 var lines = source.split(/\r\n|[\n\v\f\r\x85]/), |
|
2315 delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [], |
|
2316 hunks = uniDiff.hunks, |
|
2317 compareLine = options.compareLine || function (lineNumber, line, operation, patchContent) /*istanbul ignore start*/{ |
|
2318 return (/*istanbul ignore end*/line === patchContent |
|
2319 ); |
|
2320 }, |
|
2321 errorCount = 0, |
|
2322 fuzzFactor = options.fuzzFactor || 0, |
|
2323 minLine = 0, |
|
2324 offset = 0, |
|
2325 removeEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/, |
|
2326 addEOFNL = /*istanbul ignore start*/void 0 /*istanbul ignore end*/; |
|
2327 |
|
2328 /** |
|
2329 * Checks if the hunk exactly fits on the provided location |
|
2330 */ |
|
2331 function hunkFits(hunk, toPos) { |
|
2332 for (var j = 0; j < hunk.lines.length; j++) { |
|
2333 var line = hunk.lines[j], |
|
2334 operation = line.length > 0 ? line[0] : ' ', |
|
2335 content = line.length > 0 ? line.substr(1) : line; |
|
2336 |
|
2337 if (operation === ' ' || operation === '-') { |
|
2338 // Context sanity check |
|
2339 if (!compareLine(toPos + 1, lines[toPos], operation, content)) { |
|
2340 errorCount++; |
|
2341 |
|
2342 if (errorCount > fuzzFactor) { |
|
2343 return false; |
|
2344 } |
|
2345 } |
|
2346 toPos++; |
|
2347 } |
|
2348 } |
|
2349 |
|
2350 return true; |
|
2351 } |
|
2352 |
|
2353 // Search best fit offsets for each hunk based on the previous ones |
|
2354 for (var i = 0; i < hunks.length; i++) { |
|
2355 var hunk = hunks[i], |
|
2356 maxLine = lines.length - hunk.oldLines, |
|
2357 localOffset = 0, |
|
2358 toPos = offset + hunk.oldStart - 1; |
|
2359 |
|
2360 var iterator = /*istanbul ignore start*/(0, _distanceIterator2['default']) /*istanbul ignore end*/(toPos, minLine, maxLine); |
|
2361 |
|
2362 for (; localOffset !== undefined; localOffset = iterator()) { |
|
2363 if (hunkFits(hunk, toPos + localOffset)) { |
|
2364 hunk.offset = offset += localOffset; |
|
2365 break; |
|
2366 } |
|
2367 } |
|
2368 |
|
2369 if (localOffset === undefined) { |
|
2370 return false; |
|
2371 } |
|
2372 |
|
2373 // Set lower text limit to end of the current hunk, so next ones don't try |
|
2374 // to fit over already patched text |
|
2375 minLine = hunk.offset + hunk.oldStart + hunk.oldLines; |
|
2376 } |
|
2377 |
|
2378 // Apply patch hunks |
|
2379 var diffOffset = 0; |
|
2380 for (var _i = 0; _i < hunks.length; _i++) { |
|
2381 var _hunk = hunks[_i], |
|
2382 _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1; |
|
2383 diffOffset += _hunk.newLines - _hunk.oldLines; |
|
2384 |
|
2385 if (_toPos < 0) { |
|
2386 // Creating a new file |
|
2387 _toPos = 0; |
|
2388 } |
|
2389 |
|
2390 for (var j = 0; j < _hunk.lines.length; j++) { |
|
2391 var line = _hunk.lines[j], |
|
2392 operation = line.length > 0 ? line[0] : ' ', |
|
2393 content = line.length > 0 ? line.substr(1) : line, |
|
2394 delimiter = _hunk.linedelimiters[j]; |
|
2395 |
|
2396 if (operation === ' ') { |
|
2397 _toPos++; |
|
2398 } else if (operation === '-') { |
|
2399 lines.splice(_toPos, 1); |
|
2400 delimiters.splice(_toPos, 1); |
|
2401 /* istanbul ignore else */ |
|
2402 } else if (operation === '+') { |
|
2403 lines.splice(_toPos, 0, content); |
|
2404 delimiters.splice(_toPos, 0, delimiter); |
|
2405 _toPos++; |
|
2406 } else if (operation === '\\') { |
|
2407 var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null; |
|
2408 if (previousOperation === '+') { |
|
2409 removeEOFNL = true; |
|
2410 } else if (previousOperation === '-') { |
|
2411 addEOFNL = true; |
|
2412 } |
|
2413 } |
|
2414 } |
|
2415 } |
|
2416 |
|
2417 // Handle EOFNL insertion/removal |
|
2418 if (removeEOFNL) { |
|
2419 while (!lines[lines.length - 1]) { |
|
2420 lines.pop(); |
|
2421 delimiters.pop(); |
|
2422 } |
|
2423 } else if (addEOFNL) { |
|
2424 lines.push(''); |
|
2425 delimiters.push('\n'); |
|
2426 } |
|
2427 for (var _k = 0; _k < lines.length - 1; _k++) { |
|
2428 lines[_k] = lines[_k] + delimiters[_k]; |
|
2429 } |
|
2430 return lines.join(''); |
|
2431 } |
|
2432 |
|
2433 // Wrapper that supports multiple file patches via callbacks. |
|
2434 function applyPatches(uniDiff, options) { |
|
2435 if (typeof uniDiff === 'string') { |
|
2436 uniDiff = /*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(uniDiff); |
|
2437 } |
|
2438 |
|
2439 var currentIndex = 0; |
|
2440 function processIndex() { |
|
2441 var index = uniDiff[currentIndex++]; |
|
2442 if (!index) { |
|
2443 return options.complete(); |
|
2444 } |
|
2445 |
|
2446 options.loadFile(index, function (err, data) { |
|
2447 if (err) { |
|
2448 return options.complete(err); |
|
2449 } |
|
2450 |
|
2451 var updatedContent = applyPatch(data, index, options); |
|
2452 options.patched(index, updatedContent, function (err) { |
|
2453 if (err) { |
|
2454 return options.complete(err); |
|
2455 } |
|
2456 |
|
2457 processIndex(); |
|
2458 }); |
|
2459 }); |
|
2460 } |
|
2461 processIndex(); |
|
2462 } |
|
2463 //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wYXRjaC9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Y2FsbGJhY2tzLlxuZXhwb3J0IGZ1bmN0aW9uIGFwcGx5UGF0Y2hlcyh1bmlEaWZmLCBvcHRpb25zKSB7XG4gIGlmICh0eXBlb2YgdW5pRGlmZiA9PT0gJ3N0cmluZycpIHtcbiAgICB1bmlEaWZmID0gcGFyc2VQYXRjaCh1bmlEaWZmKTtcbiAgfVxuXG4gIGxldCBjdXJyZW50SW5kZXggPSAwO1xuICBmdW5jdGlvbiBwcm9jZXNzSW5kZXgoKSB7XG4gICAgbGV0IGluZGV4ID0gdW5pRGlmZltjdXJyZW50SW5kZXgrK107XG4gICAgaWYgKCFpbmRleCkge1xuICAgICAgcmV0dXJuIG9wdGlvbnMuY29tcGxldGUoKTtcbiAgICB9XG5cbiAgICBvcHRpb25zLmxvYWRGaWxlKGluZGV4LCBmdW5jdGlvbihlcnIsIGRhdGEpIHtcbiAgICAgIGlmIChlcnIpIHtcbiAgICAgICAgcmV0dXJuIG9wdGlvbnMuY29tcGxldGUoZXJyKTtcbiAgICAgIH1cblxuICAgICAgbGV0IHVwZGF0ZWRDb250ZW50ID0gYXBwbHlQYXRjaChkYXRhLCBpbmRleCwgb3B0aW9ucyk7XG4gICAgICBvcHRpb25zLnBhdGNoZWQoaW5kZXgsIHVwZGF0ZWRDb250ZW50LCBmdW5jdGlvbihlcnIpIHtcbiAgICAgICAgaWYgKGVycikge1xuICAgICAgICAgIHJldHVybiBvcHRpb25zLmNvbXBsZXRlKGVycik7XG4gICAgICAgIH1cblxuICAgICAgICBwcm9jZXNzSW5kZXgoKTtcbiAgICAgIH0pO1xuICAgIH0pO1xuICB9XG4gIHByb2Nlc3NJbmRleCgpO1xufVxuIl19 |
|
2464 |
|
2465 |
|
2466 /***/ }), |
|
2467 /* 11 */ |
|
2468 /***/ (function(module, exports) { |
|
2469 |
|
2470 /*istanbul ignore start*/'use strict'; |
|
2471 |
|
2472 exports.__esModule = true; |
|
2473 exports. /*istanbul ignore end*/parsePatch = parsePatch; |
|
2474 function parsePatch(uniDiff) { |
|
2475 /*istanbul ignore start*/var /*istanbul ignore end*/options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
2476 |
|
2477 var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/), |
|
2478 delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [], |
|
2479 list = [], |
|
2480 i = 0; |
|
2481 |
|
2482 function parseIndex() { |
|
2483 var index = {}; |
|
2484 list.push(index); |
|
2485 |
|
2486 // Parse diff metadata |
|
2487 while (i < diffstr.length) { |
|
2488 var line = diffstr[i]; |
|
2489 |
|
2490 // File header found, end parsing diff metadata |
|
2491 if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) { |
|
2492 break; |
|
2493 } |
|
2494 |
|
2495 // Diff index |
|
2496 var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line); |
|
2497 if (header) { |
|
2498 index.index = header[1]; |
|
2499 } |
|
2500 |
|
2501 i++; |
|
2502 } |
|
2503 |
|
2504 // Parse file headers if they are defined. Unified diff requires them, but |
|
2505 // there's no technical issues to have an isolated hunk without file header |
|
2506 parseFileHeader(index); |
|
2507 parseFileHeader(index); |
|
2508 |
|
2509 // Parse hunks |
|
2510 index.hunks = []; |
|
2511 |
|
2512 while (i < diffstr.length) { |
|
2513 var _line = diffstr[i]; |
|
2514 |
|
2515 if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) { |
|
2516 break; |
|
2517 } else if (/^@@/.test(_line)) { |
|
2518 index.hunks.push(parseHunk()); |
|
2519 } else if (_line && options.strict) { |
|
2520 // Ignore unexpected content unless in strict mode |
|
2521 throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line)); |
|
2522 } else { |
|
2523 i++; |
|
2524 } |
|
2525 } |
|
2526 } |
|
2527 |
|
2528 // Parses the --- and +++ headers, if none are found, no lines |
|
2529 // are consumed. |
|
2530 function parseFileHeader(index) { |
|
2531 var fileHeader = /^(---|\+\+\+)\s+(.*)$/.exec(diffstr[i]); |
|
2532 if (fileHeader) { |
|
2533 var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new'; |
|
2534 var data = fileHeader[2].split('\t', 2); |
|
2535 var fileName = data[0].replace(/\\\\/g, '\\'); |
|
2536 if (/^".*"$/.test(fileName)) { |
|
2537 fileName = fileName.substr(1, fileName.length - 2); |
|
2538 } |
|
2539 index[keyPrefix + 'FileName'] = fileName; |
|
2540 index[keyPrefix + 'Header'] = (data[1] || '').trim(); |
|
2541 |
|
2542 i++; |
|
2543 } |
|
2544 } |
|
2545 |
|
2546 // Parses a hunk |
|
2547 // This assumes that we are at the start of a hunk. |
|
2548 function parseHunk() { |
|
2549 var chunkHeaderIndex = i, |
|
2550 chunkHeaderLine = diffstr[i++], |
|
2551 chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/); |
|
2552 |
|
2553 var hunk = { |
|
2554 oldStart: +chunkHeader[1], |
|
2555 oldLines: +chunkHeader[2] || 1, |
|
2556 newStart: +chunkHeader[3], |
|
2557 newLines: +chunkHeader[4] || 1, |
|
2558 lines: [], |
|
2559 linedelimiters: [] |
|
2560 }; |
|
2561 |
|
2562 var addCount = 0, |
|
2563 removeCount = 0; |
|
2564 for (; i < diffstr.length; i++) { |
|
2565 // Lines starting with '---' could be mistaken for the "remove line" operation |
|
2566 // But they could be the header for the next file. Therefore prune such cases out. |
|
2567 if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) { |
|
2568 break; |
|
2569 } |
|
2570 var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0]; |
|
2571 |
|
2572 if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') { |
|
2573 hunk.lines.push(diffstr[i]); |
|
2574 hunk.linedelimiters.push(delimiters[i] || '\n'); |
|
2575 |
|
2576 if (operation === '+') { |
|
2577 addCount++; |
|
2578 } else if (operation === '-') { |
|
2579 removeCount++; |
|
2580 } else if (operation === ' ') { |
|
2581 addCount++; |
|
2582 removeCount++; |
|
2583 } |
|
2584 } else { |
|
2585 break; |
|
2586 } |
|
2587 } |
|
2588 |
|
2589 // Handle the empty block count case |
|
2590 if (!addCount && hunk.newLines === 1) { |
|
2591 hunk.newLines = 0; |
|
2592 } |
|
2593 if (!removeCount && hunk.oldLines === 1) { |
|
2594 hunk.oldLines = 0; |
|
2595 } |
|
2596 |
|
2597 // Perform optional sanity checking |
|
2598 if (options.strict) { |
|
2599 if (addCount !== hunk.newLines) { |
|
2600 throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1)); |
|
2601 } |
|
2602 if (removeCount !== hunk.oldLines) { |
|
2603 throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1)); |
|
2604 } |
|
2605 } |
|
2606 |
|
2607 return hunk; |
|
2608 } |
|
2609 |
|
2610 while (i < diffstr.length) { |
|
2611 parseIndex(); |
|
2612 } |
|
2613 |
|
2614 return list; |
|
2615 } |
|
2616 //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wYXRjaC9wYXJzZS5qcyJdLCJuYW1lcyI6WyJwYXJzZVBhdGNoIiwidW5pRGlmZiIsIm9wdGlvbnMiLCJkaWZmc3RyIiwic3BsaXQiLCJkZWxpbWl0ZXJzIiwibWF0Y2giLCJsaXN0IiwiaSIsInBhcnNlSW5kZXgiLCJpbmRleCIsInB1c2giLCJsZW5ndGgiLCJsaW5lIiwidGVzdCIsImhlYWRlciIsImV4ZWMiLCJwYXJzZUZpbGVIZWFkZXIiLCJodW5rcyIsInBhcnNlSHVuayIsInN0cmljdCIsIkVycm9yIiwiSlNPTiIsInN0cmluZ2lmeSIsImZpbGVIZWFkZXIiLCJrZXlQcmVmaXgiLCJkYXRhIiwiZmlsZU5hbWUiLCJ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mV4dCBmaWxlLiBUaGVyZWZvcmUgcHJ1bmUgc3VjaCBjYXNlcyBvdXQuXG4gICAgICBpZiAoZGlmZnN0cltpXS5pbmRleE9mKCctLS0gJykgPT09IDBcbiAgICAgICAgICAgICYmIChpICsgMiA8IGRpZmZzdHIubGVuZ3RoKVxuICAgICAgICAgICAgJiYgZGlmZnN0cltpICsgMV0uaW5kZXhPZignKysrICcpID09PSAwXG4gICAgICAgICAgICAmJiBkaWZmc3RyW2kgKyAyXS5pbmRleE9mKCdAQCcpID09PSAwKSB7XG4gICAgICAgICAgYnJlYWs7XG4gICAgICB9XG4gICAgICBsZXQgb3BlcmF0aW9uID0gKGRpZmZzdHJbaV0ubGVuZ3RoID09IDAgJiYgaSAhPSAoZGlmZnN0ci5sZW5ndGggLSAxKSkgPyAnICcgOiBkaWZmc3RyW2ldWzBdO1xuXG4gICAgICBpZiAob3BlcmF0aW9uID09PSAnKycgfHwgb3BlcmF0aW9uID09PSAnLScgfHwgb3BlcmF0aW9uID09PSAnICcgfHwgb3BlcmF0aW9uID09PSAnXFxcXCcpIHtcbiAgICAgICAgaHVuay5saW5lcy5wdXNoKGRpZmZzdHJbaV0pO1xuICAgICAgICBodW5rLmxpbmVkZWxpbWl0ZXJzLnB1c2goZGVsaW1pdGVyc1tpXSB8fCAnXFxuJyk7XG5cbiAgICAgICAgaWYgKG9wZXJhdGlvbiA9PT0gJysnKSB7XG4gICAgICAgICAgYWRkQ291bnQrKztcbiAgICAgICAgfSBlbHNlIGlmIChvcGVyYXRpb24gPT09ICctJykge1xuICAgICAgICAgIHJlbW92ZUNvdW50Kys7XG4gICAgICAgIH0gZWxzZSBpZiAob3BlcmF0aW9uID09PSAnICcpIHtcbiAgICAgICAgICBhZGRDb3VudCsrO1xuICAgICAgICAgIHJlbW92ZUNvdW50Kys7XG4gICAgICAgIH1cbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIGJyZWFrO1xuICAgICAgfVxuICAgIH1cblxuICAgIC8vIEhhbmRsZSB0aGUgZW1wdHkgYmxvY2sgY291bnQgY2FzZVxuICAgIGlmICghYWRkQ291bnQgJiYgaHVuay5uZXdMaW5lcyA9PT0gMSkge1xuICAgICAgaHVuay5uZXdMaW5lcyA9IDA7XG4gICAgfVxuICAgIGlmICghcmVtb3ZlQ291bnQgJiYgaHVuay5vbGRMaW5lcyA9PT0gMSkge1xuICAgICAgaHVuay5vbGRMaW5lcyA9IDA7XG4gICAgfVxuXG4gICAgLy8gUGVyZm9ybSBvcHRpb25hbCBzYW5pdHkgY2hlY2tpbmdcbiAgICBpZiAob3B0aW9ucy5zdHJpY3QpIHtcbiAgICAgIGlmIChhZGRDb3VudCAhPT0gaHVuay5uZXdMaW5lcykge1xuICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ0FkZGVkIGxpbmUgY291bnQgZGlkIG5vdCBtYXRjaCBmb3IgaHVuayBhdCBsaW5lICcgKyAoY2h1bmtIZWFkZXJJbmRleCArIDEpKTtcbiAgICAgIH1cbiAgICAgIGlmIChyZW1vdmVDb3VudCAhPT0gaHVuay5vbGRMaW5lcykge1xuICAgICAgICB0aHJvdyBuZXcgRXJyb3IoJ1JlbW92ZWQgbGluZSBjb3VudCBkaWQgbm90IG1hdGNoIGZvciBodW5rIGF0IGxpbmUgJyArIChjaHVua0hlYWRlckluZGV4ICsgMSkpO1xuICAgICAgfVxuICAgIH1cblxuICAgIHJldHVybiBodW5rO1xuICB9XG5cbiAgd2hpbGUgKGkgPCBkaWZmc3RyLmxlbmd0aCkge1xuICAgIHBhcnNlSW5kZXgoKTtcbiAgfVxuXG4gIHJldHVybiBsaXN0O1xufVxuIl19 |
|
2617 |
|
2618 |
|
2619 /***/ }), |
|
2620 /* 12 */ |
|
2621 /***/ (function(module, exports) { |
|
2622 |
|
2623 /*istanbul ignore start*/"use strict"; |
|
2624 |
|
2625 exports.__esModule = true; |
|
2626 |
|
2627 exports["default"] = /*istanbul ignore end*/function (start, minLine, maxLine) { |
|
2628 var wantForward = true, |
|
2629 backwardExhausted = false, |
|
2630 forwardExhausted = false, |
|
2631 localOffset = 1; |
|
2632 |
|
2633 return function iterator() { |
|
2634 if (wantForward && !forwardExhausted) { |
|
2635 if (backwardExhausted) { |
|
2636 localOffset++; |
|
2637 } else { |
|
2638 wantForward = false; |
|
2639 } |
|
2640 |
|
2641 // Check if trying to fit beyond text length, and if not, check it fits |
|
2642 // after offset location (or desired location on first iteration) |
|
2643 if (start + localOffset <= maxLine) { |
|
2644 return localOffset; |
|
2645 } |
|
2646 |
|
2647 forwardExhausted = true; |
|
2648 } |
|
2649 |
|
2650 if (!backwardExhausted) { |
|
2651 if (!forwardExhausted) { |
|
2652 wantForward = true; |
|
2653 } |
|
2654 |
|
2655 // Check if trying to fit before text beginning, and if not, check it fits |
|
2656 // before offset location |
|
2657 if (minLine <= start - localOffset) { |
|
2658 return -localOffset++; |
|
2659 } |
|
2660 |
|
2661 backwardExhausted = true; |
|
2662 return iterator(); |
|
2663 } |
|
2664 |
|
2665 // We tried to fit hunk before text beginning and beyond text length, then |
|
2666 // hunk can't fit on the text. Return undefined |
|
2667 }; |
|
2668 }; |
|
2669 //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsL2Rpc3RhbmNlLWl0ZXJhdG9yLmpzIl0sIm5hbWVzIjpbInN0YXJ0IiwibWluTGluZSIsIm1heExpbmUiLCJ3YW50Rm9yd2FyZCIsImJhY2t3YXJkRXhoYXVzdGVkIiwiZm9yd2FyZEV4aGF1c3RlZCIsImxvY2FsT2Zmc2V0IiwiaXRlcmF0b3IiXSwibWFwcGluZ3MiOiI7Ozs7NENBR2UsVUFBU0EsS0FBVCxFQUFnQkMsT0FBaEIsRUFBeUJDLE9BQXpCLEVBQWtDO0FBQy9DLE1BQUlDLGNBQWMsSUFBbEI7QUFBQSxNQUNJQyxvQkFBb0IsS0FEeEI7QUFBQSxNQUVJQyxtQkFBbUIsS0FGdkI7Q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YWxPZmZzZXQpIHtcbiAgICAgICAgcmV0dXJuIC1sb2NhbE9mZnNldCsrO1xuICAgICAgfVxuXG4gICAgICBiYWNrd2FyZEV4aGF1c3RlZCA9IHRydWU7XG4gICAgICByZXR1cm4gaXRlcmF0b3IoKTtcbiAgICB9XG5cbiAgICAvLyBXZSB0cmllZCB0byBmaXQgaHVuayBiZWZvcmUgdGV4dCBiZWdpbm5pbmcgYW5kIGJleW9uZCB0ZXh0IGxlbmd0aCwgdGhlblxuICAgIC8vIGh1bmsgY2FuJ3QgZml0IG9uIHRoZSB0ZXh0LiBSZXR1cm4gdW5kZWZpbmVkXG4gIH07XG59XG4iXX0= |
|
2670 |
|
2671 |
|
2672 /***/ }), |
|
2673 /* 13 */ |
|
2674 /***/ (function(module, exports, __webpack_require__) { |
|
2675 |
|
2676 /*istanbul ignore start*/'use strict'; |
|
2677 |
|
2678 exports.__esModule = true; |
|
2679 exports. /*istanbul ignore end*/calcLineCount = calcLineCount; |
|
2680 /*istanbul ignore start*/exports. /*istanbul ignore end*/merge = merge; |
|
2681 |
|
2682 var /*istanbul ignore start*/_create = __webpack_require__(14) /*istanbul ignore end*/; |
|
2683 |
|
2684 var /*istanbul ignore start*/_parse = __webpack_require__(11) /*istanbul ignore end*/; |
|
2685 |
|
2686 var /*istanbul ignore start*/_array = __webpack_require__(15) /*istanbul ignore end*/; |
|
2687 |
|
2688 /*istanbul ignore start*/function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } |
|
2689 |
|
2690 /*istanbul ignore end*/function calcLineCount(hunk) { |
|
2691 /*istanbul ignore start*/var _calcOldNewLineCount = /*istanbul ignore end*/calcOldNewLineCount(hunk.lines), |
|
2692 oldLines = _calcOldNewLineCount.oldLines, |
|
2693 newLines = _calcOldNewLineCount.newLines; |
|
2694 |
|
2695 if (oldLines !== undefined) { |
|
2696 hunk.oldLines = oldLines; |
|
2697 } else { |
|
2698 delete hunk.oldLines; |
|
2699 } |
|
2700 |
|
2701 if (newLines !== undefined) { |
|
2702 hunk.newLines = newLines; |
|
2703 } else { |
|
2704 delete hunk.newLines; |
|
2705 } |
|
2706 } |
|
2707 |
|
2708 function merge(mine, theirs, base) { |
|
2709 mine = loadPatch(mine, base); |
|
2710 theirs = loadPatch(theirs, base); |
|
2711 |
|
2712 var ret = {}; |
|
2713 |
|
2714 // For index we just let it pass through as it doesn't have any necessary meaning. |
|
2715 // Leaving sanity checks on this to the API consumer that may know more about the |
|
2716 // meaning in their own context. |
|
2717 if (mine.index || theirs.index) { |
|
2718 ret.index = mine.index || theirs.index; |
|
2719 } |
|
2720 |
|
2721 if (mine.newFileName || theirs.newFileName) { |
|
2722 if (!fileNameChanged(mine)) { |
|
2723 // No header or no change in ours, use theirs (and ours if theirs does not exist) |
|
2724 ret.oldFileName = theirs.oldFileName || mine.oldFileName; |
|
2725 ret.newFileName = theirs.newFileName || mine.newFileName; |
|
2726 ret.oldHeader = theirs.oldHeader || mine.oldHeader; |
|
2727 ret.newHeader = theirs.newHeader || mine.newHeader; |
|
2728 } else if (!fileNameChanged(theirs)) { |
|
2729 // No header or no change in theirs, use ours |
|
2730 ret.oldFileName = mine.oldFileName; |
|
2731 ret.newFileName = mine.newFileName; |
|
2732 ret.oldHeader = mine.oldHeader; |
|
2733 ret.newHeader = mine.newHeader; |
|
2734 } else { |
|
2735 // Both changed... figure it out |
|
2736 ret.oldFileName = selectField(ret, mine.oldFileName, theirs.oldFileName); |
|
2737 ret.newFileName = selectField(ret, mine.newFileName, theirs.newFileName); |
|
2738 ret.oldHeader = selectField(ret, mine.oldHeader, theirs.oldHeader); |
|
2739 ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader); |
|
2740 } |
|
2741 } |
|
2742 |
|
2743 ret.hunks = []; |
|
2744 |
|
2745 var mineIndex = 0, |
|
2746 theirsIndex = 0, |
|
2747 mineOffset = 0, |
|
2748 theirsOffset = 0; |
|
2749 |
|
2750 while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) { |
|
2751 var mineCurrent = mine.hunks[mineIndex] || { oldStart: Infinity }, |
|
2752 theirsCurrent = theirs.hunks[theirsIndex] || { oldStart: Infinity }; |
|
2753 |
|
2754 if (hunkBefore(mineCurrent, theirsCurrent)) { |
|
2755 // This patch does not overlap with any of the others, yay. |
|
2756 ret.hunks.push(cloneHunk(mineCurrent, mineOffset)); |
|
2757 mineIndex++; |
|
2758 theirsOffset += mineCurrent.newLines - mineCurrent.oldLines; |
|
2759 } else if (hunkBefore(theirsCurrent, mineCurrent)) { |
|
2760 // This patch does not overlap with any of the others, yay. |
|
2761 ret.hunks.push(cloneHunk(theirsCurrent, theirsOffset)); |
|
2762 theirsIndex++; |
|
2763 mineOffset += theirsCurrent.newLines - theirsCurrent.oldLines; |
|
2764 } else { |
|
2765 // Overlap, merge as best we can |
|
2766 var mergedHunk = { |
|
2767 oldStart: Math.min(mineCurrent.oldStart, theirsCurrent.oldStart), |
|
2768 oldLines: 0, |
|
2769 newStart: Math.min(mineCurrent.newStart + mineOffset, theirsCurrent.oldStart + theirsOffset), |
|
2770 newLines: 0, |
|
2771 lines: [] |
|
2772 }; |
|
2773 mergeLines(mergedHunk, mineCurrent.oldStart, mineCurrent.lines, theirsCurrent.oldStart, theirsCurrent.lines); |
|
2774 theirsIndex++; |
|
2775 mineIndex++; |
|
2776 |
|
2777 ret.hunks.push(mergedHunk); |
|
2778 } |
|
2779 } |
|
2780 |
|
2781 return ret; |
|
2782 } |
|
2783 |
|
2784 function loadPatch(param, base) { |
|
2785 if (typeof param === 'string') { |
|
2786 if (/^@@/m.test(param) || /^Index:/m.test(param)) { |
|
2787 return (/*istanbul ignore start*/(0, _parse.parsePatch) /*istanbul ignore end*/(param)[0] |
|
2788 ); |
|
2789 } |
|
2790 |
|
2791 if (!base) { |
|
2792 throw new Error('Must provide a base reference or pass in a patch'); |
|
2793 } |
|
2794 return (/*istanbul ignore start*/(0, _create.structuredPatch) /*istanbul ignore end*/(undefined, undefined, base, param) |
|
2795 ); |
|
2796 } |
|
2797 |
|
2798 return param; |
|
2799 } |
|
2800 |
|
2801 function fileNameChanged(patch) { |
|
2802 return patch.newFileName && patch.newFileName !== patch.oldFileName; |
|
2803 } |
|
2804 |
|
2805 function selectField(index, mine, theirs) { |
|
2806 if (mine === theirs) { |
|
2807 return mine; |
|
2808 } else { |
|
2809 index.conflict = true; |
|
2810 return { mine: mine, theirs: theirs }; |
|
2811 } |
|
2812 } |
|
2813 |
|
2814 function hunkBefore(test, check) { |
|
2815 return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart; |
|
2816 } |
|
2817 |
|
2818 function cloneHunk(hunk, offset) { |
|
2819 return { |
|
2820 oldStart: hunk.oldStart, oldLines: hunk.oldLines, |
|
2821 newStart: hunk.newStart + offset, newLines: hunk.newLines, |
|
2822 lines: hunk.lines |
|
2823 }; |
|
2824 } |
|
2825 |
|
2826 function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) { |
|
2827 // This will generally result in a conflicted hunk, but there are cases where the context |
|
2828 // is the only overlap where we can successfully merge the content here. |
|
2829 var mine = { offset: mineOffset, lines: mineLines, index: 0 }, |
|
2830 their = { offset: theirOffset, lines: theirLines, index: 0 }; |
|
2831 |
|
2832 // Handle any leading content |
|
2833 insertLeading(hunk, mine, their); |
|
2834 insertLeading(hunk, their, mine); |
|
2835 |
|
2836 // Now in the overlap content. Scan through and select the best changes from each. |
|
2837 while (mine.index < mine.lines.length && their.index < their.lines.length) { |
|
2838 var mineCurrent = mine.lines[mine.index], |
|
2839 theirCurrent = their.lines[their.index]; |
|
2840 |
|
2841 if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) { |
|
2842 // Both modified ... |
|
2843 mutualChange(hunk, mine, their); |
|
2844 } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') { |
|
2845 /*istanbul ignore start*/var _hunk$lines; |
|
2846 |
|
2847 /*istanbul ignore end*/ // Mine inserted |
|
2848 /*istanbul ignore start*/(_hunk$lines = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/collectChange(mine))); |
|
2849 } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') { |
|
2850 /*istanbul ignore start*/var _hunk$lines2; |
|
2851 |
|
2852 /*istanbul ignore end*/ // Theirs inserted |
|
2853 /*istanbul ignore start*/(_hunk$lines2 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines2 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/collectChange(their))); |
|
2854 } else if (mineCurrent[0] === '-' && theirCurrent[0] === ' ') { |
|
2855 // Mine removed or edited |
|
2856 removal(hunk, mine, their); |
|
2857 } else if (theirCurrent[0] === '-' && mineCurrent[0] === ' ') { |
|
2858 // Their removed or edited |
|
2859 removal(hunk, their, mine, true); |
|
2860 } else if (mineCurrent === theirCurrent) { |
|
2861 // Context identity |
|
2862 hunk.lines.push(mineCurrent); |
|
2863 mine.index++; |
|
2864 their.index++; |
|
2865 } else { |
|
2866 // Context mismatch |
|
2867 conflict(hunk, collectChange(mine), collectChange(their)); |
|
2868 } |
|
2869 } |
|
2870 |
|
2871 // Now push anything that may be remaining |
|
2872 insertTrailing(hunk, mine); |
|
2873 insertTrailing(hunk, their); |
|
2874 |
|
2875 calcLineCount(hunk); |
|
2876 } |
|
2877 |
|
2878 function mutualChange(hunk, mine, their) { |
|
2879 var myChanges = collectChange(mine), |
|
2880 theirChanges = collectChange(their); |
|
2881 |
|
2882 if (allRemoves(myChanges) && allRemoves(theirChanges)) { |
|
2883 // Special case for remove changes that are supersets of one another |
|
2884 if ( /*istanbul ignore start*/(0, _array.arrayStartsWith) /*istanbul ignore end*/(myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) { |
|
2885 /*istanbul ignore start*/var _hunk$lines3; |
|
2886 |
|
2887 /*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines3 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines3 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/myChanges)); |
|
2888 return; |
|
2889 } else if ( /*istanbul ignore start*/(0, _array.arrayStartsWith) /*istanbul ignore end*/(theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) { |
|
2890 /*istanbul ignore start*/var _hunk$lines4; |
|
2891 |
|
2892 /*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines4 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines4 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/theirChanges)); |
|
2893 return; |
|
2894 } |
|
2895 } else if ( /*istanbul ignore start*/(0, _array.arrayEqual) /*istanbul ignore end*/(myChanges, theirChanges)) { |
|
2896 /*istanbul ignore start*/var _hunk$lines5; |
|
2897 |
|
2898 /*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines5 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines5 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/myChanges)); |
|
2899 return; |
|
2900 } |
|
2901 |
|
2902 conflict(hunk, myChanges, theirChanges); |
|
2903 } |
|
2904 |
|
2905 function removal(hunk, mine, their, swap) { |
|
2906 var myChanges = collectChange(mine), |
|
2907 theirChanges = collectContext(their, myChanges); |
|
2908 if (theirChanges.merged) { |
|
2909 /*istanbul ignore start*/var _hunk$lines6; |
|
2910 |
|
2911 /*istanbul ignore end*/ /*istanbul ignore start*/(_hunk$lines6 = /*istanbul ignore end*/hunk.lines).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_hunk$lines6 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/theirChanges.merged)); |
|
2912 } else { |
|
2913 conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges); |
|
2914 } |
|
2915 } |
|
2916 |
|
2917 function conflict(hunk, mine, their) { |
|
2918 hunk.conflict = true; |
|
2919 hunk.lines.push({ |
|
2920 conflict: true, |
|
2921 mine: mine, |
|
2922 theirs: their |
|
2923 }); |
|
2924 } |
|
2925 |
|
2926 function insertLeading(hunk, insert, their) { |
|
2927 while (insert.offset < their.offset && insert.index < insert.lines.length) { |
|
2928 var line = insert.lines[insert.index++]; |
|
2929 hunk.lines.push(line); |
|
2930 insert.offset++; |
|
2931 } |
|
2932 } |
|
2933 function insertTrailing(hunk, insert) { |
|
2934 while (insert.index < insert.lines.length) { |
|
2935 var line = insert.lines[insert.index++]; |
|
2936 hunk.lines.push(line); |
|
2937 } |
|
2938 } |
|
2939 |
|
2940 function collectChange(state) { |
|
2941 var ret = [], |
|
2942 operation = state.lines[state.index][0]; |
|
2943 while (state.index < state.lines.length) { |
|
2944 var line = state.lines[state.index]; |
|
2945 |
|
2946 // Group additions that are immediately after subtractions and treat them as one "atomic" modify change. |
|
2947 if (operation === '-' && line[0] === '+') { |
|
2948 operation = '+'; |
|
2949 } |
|
2950 |
|
2951 if (operation === line[0]) { |
|
2952 ret.push(line); |
|
2953 state.index++; |
|
2954 } else { |
|
2955 break; |
|
2956 } |
|
2957 } |
|
2958 |
|
2959 return ret; |
|
2960 } |
|
2961 function collectContext(state, matchChanges) { |
|
2962 var changes = [], |
|
2963 merged = [], |
|
2964 matchIndex = 0, |
|
2965 contextChanges = false, |
|
2966 conflicted = false; |
|
2967 while (matchIndex < matchChanges.length && state.index < state.lines.length) { |
|
2968 var change = state.lines[state.index], |
|
2969 match = matchChanges[matchIndex]; |
|
2970 |
|
2971 // Once we've hit our add, then we are done |
|
2972 if (match[0] === '+') { |
|
2973 break; |
|
2974 } |
|
2975 |
|
2976 contextChanges = contextChanges || change[0] !== ' '; |
|
2977 |
|
2978 merged.push(match); |
|
2979 matchIndex++; |
|
2980 |
|
2981 // Consume any additions in the other block as a conflict to attempt |
|
2982 // to pull in the remaining context after this |
|
2983 if (change[0] === '+') { |
|
2984 conflicted = true; |
|
2985 |
|
2986 while (change[0] === '+') { |
|
2987 changes.push(change); |
|
2988 change = state.lines[++state.index]; |
|
2989 } |
|
2990 } |
|
2991 |
|
2992 if (match.substr(1) === change.substr(1)) { |
|
2993 changes.push(change); |
|
2994 state.index++; |
|
2995 } else { |
|
2996 conflicted = true; |
|
2997 } |
|
2998 } |
|
2999 |
|
3000 if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) { |
|
3001 conflicted = true; |
|
3002 } |
|
3003 |
|
3004 if (conflicted) { |
|
3005 return changes; |
|
3006 } |
|
3007 |
|
3008 while (matchIndex < matchChanges.length) { |
|
3009 merged.push(matchChanges[matchIndex++]); |
|
3010 } |
|
3011 |
|
3012 return { |
|
3013 merged: merged, |
|
3014 changes: changes |
|
3015 }; |
|
3016 } |
|
3017 |
|
3018 function allRemoves(changes) { |
|
3019 return changes.reduce(function (prev, change) { |
|
3020 return prev && change[0] === '-'; |
|
3021 }, true); |
|
3022 } |
|
3023 function skipRemoveSuperset(state, removeChanges, delta) { |
|
3024 for (var i = 0; i < delta; i++) { |
|
3025 var changeContent = removeChanges[removeChanges.length - delta + i].substr(1); |
|
3026 if (state.lines[state.index + i] !== ' ' + changeContent) { |
|
3027 return false; |
|
3028 } |
|
3029 } |
|
3030 |
|
3031 state.index += delta; |
|
3032 return true; |
|
3033 } |
|
3034 |
|
3035 function calcOldNewLineCount(lines) { |
|
3036 var oldLines = 0; |
|
3037 var newLines = 0; |
|
3038 |
|
3039 lines.forEach(function (line) { |
|
3040 if (typeof line !== 'string') { |
|
3041 var myCount = calcOldNewLineCount(line.mine); |
|
3042 var theirCount = calcOldNewLineCount(line.theirs); |
|
3043 |
|
3044 if (oldLines !== undefined) { |
|
3045 if (myCount.oldLines === theirCount.oldLines) { |
|
3046 oldLines += myCount.oldLines; |
|
3047 } else { |
|
3048 oldLines = undefined; |
|
3049 } |
|
3050 } |
|
3051 |
|
3052 if (newLines !== undefined) { |
|
3053 if (myCount.newLines === theirCount.newLines) { |
|
3054 newLines += myCount.newLines; |
|
3055 } else { |
|
3056 newLines = undefined; |
|
3057 } |
|
3058 } |
|
3059 } else { |
|
3060 if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) { |
|
3061 newLines++; |
|
3062 } |
|
3063 if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) { |
|
3064 oldLines++; |
|
3065 } |
|
3066 } |
|
3067 }); |
|
3068 |
|
3069 return { oldLines: oldLines, newLines: newLines }; |
|
3070 } |
|
3071 //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wYXRjaC9tZXJnZS5qcyJdLCJuYW1lcyI6WyJjYWxjTGluZUNvdW50IiwibWVyZ2UiLCJodW5rIiwiY2FsY09sZE5ld0xpbmVDb3VudCIsImxpbmVzIiwib2xkTGluZXMiLCJuZXdMaW5lcyIsInVuZGVmaW5lZCIsIm1pbmUiLCJ0aGVpcnMiLCJiYXNlIiwibG9hZFBhdGNoIiwicmV0IiwiaW5kZXgiLCJuZXdGaWxlTmFtZSIsImZpbGVOYW1lQ2hhbmdlZCIsIm9sZEZpbGVOYW1lIiwib2xkSGVhZGVyIiwibmV3SGVhZGVyIiwic2VsZWN0RmllbGQiLCJodW5rcyIsIm1pbmVJbmRleCIsInRoZWlyc0luZGV4IiwibWluZU9mZnNldCIsInRoZWlyc09mZnNldCIsImxlbmd0aCI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T09IHRoZWlyQ291bnQub2xkTGluZXMpIHtcbiAgICAgICAgICBvbGRMaW5lcyArPSBteUNvdW50Lm9sZExpbmVzO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIG9sZExpbmVzID0gdW5kZWZpbmVkO1xuICAgICAgICB9XG4gICAgICB9XG5cbiAgICAgIGlmIChuZXdMaW5lcyAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgIGlmIChteUNvdW50Lm5ld0xpbmVzID09PSB0aGVpckNvdW50Lm5ld0xpbmVzKSB7XG4gICAgICAgICAgbmV3TGluZXMgKz0gbXlDb3VudC5uZXdMaW5lcztcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBuZXdMaW5lcyA9IHVuZGVmaW5lZDtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH0gZWxzZSB7XG4gICAgICBpZiAobmV3TGluZXMgIT09IHVuZGVmaW5lZCAmJiAobGluZVswXSA9PT0gJysnIHx8IGxpbmVbMF0gPT09ICcgJykpIHtcbiAgICAgICAgbmV3TGluZXMrKztcbiAgICAgIH1cbiAgICAgIGlmIChvbGRMaW5lcyAhPT0gdW5kZWZpbmVkICYmIChsaW5lWzBdID09PSAnLScgfHwgbGluZVswXSA9PT0gJyAnKSkge1xuICAgICAgICBvbGRMaW5lcysrO1xuICAgICAgfVxuICAgIH1cbiAgfSk7XG5cbiAgcmV0dXJuIHtvbGRMaW5lcywgbmV3TGluZXN9O1xufVxuIl19 |
|
3072 |
|
3073 |
|
3074 /***/ }), |
|
3075 /* 14 */ |
|
3076 /***/ (function(module, exports, __webpack_require__) { |
|
3077 |
|
3078 /*istanbul ignore start*/'use strict'; |
|
3079 |
|
3080 exports.__esModule = true; |
|
3081 exports. /*istanbul ignore end*/structuredPatch = structuredPatch; |
|
3082 /*istanbul ignore start*/exports. /*istanbul ignore end*/createTwoFilesPatch = createTwoFilesPatch; |
|
3083 /*istanbul ignore start*/exports. /*istanbul ignore end*/createPatch = createPatch; |
|
3084 |
|
3085 var /*istanbul ignore start*/_line = __webpack_require__(5) /*istanbul ignore end*/; |
|
3086 |
|
3087 /*istanbul ignore start*/function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } |
|
3088 |
|
3089 /*istanbul ignore end*/function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) { |
|
3090 if (!options) { |
|
3091 options = {}; |
|
3092 } |
|
3093 if (typeof options.context === 'undefined') { |
|
3094 options.context = 4; |
|
3095 } |
|
3096 |
|
3097 var diff = /*istanbul ignore start*/(0, _line.diffLines) /*istanbul ignore end*/(oldStr, newStr, options); |
|
3098 diff.push({ value: '', lines: [] }); // Append an empty value to make cleanup easier |
|
3099 |
|
3100 function contextLines(lines) { |
|
3101 return lines.map(function (entry) { |
|
3102 return ' ' + entry; |
|
3103 }); |
|
3104 } |
|
3105 |
|
3106 var hunks = []; |
|
3107 var oldRangeStart = 0, |
|
3108 newRangeStart = 0, |
|
3109 curRange = [], |
|
3110 oldLine = 1, |
|
3111 newLine = 1; |
|
3112 |
|
3113 /*istanbul ignore start*/var _loop = function _loop( /*istanbul ignore end*/i) { |
|
3114 var current = diff[i], |
|
3115 lines = current.lines || current.value.replace(/\n$/, '').split('\n'); |
|
3116 current.lines = lines; |
|
3117 |
|
3118 if (current.added || current.removed) { |
|
3119 /*istanbul ignore start*/var _curRange; |
|
3120 |
|
3121 /*istanbul ignore end*/ // If we have previous context, start with that |
|
3122 if (!oldRangeStart) { |
|
3123 var prev = diff[i - 1]; |
|
3124 oldRangeStart = oldLine; |
|
3125 newRangeStart = newLine; |
|
3126 |
|
3127 if (prev) { |
|
3128 curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : []; |
|
3129 oldRangeStart -= curRange.length; |
|
3130 newRangeStart -= curRange.length; |
|
3131 } |
|
3132 } |
|
3133 |
|
3134 // Output our changes |
|
3135 /*istanbul ignore start*/(_curRange = /*istanbul ignore end*/curRange).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_curRange /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/lines.map(function (entry) { |
|
3136 return (current.added ? '+' : '-') + entry; |
|
3137 }))); |
|
3138 |
|
3139 // Track the updated file position |
|
3140 if (current.added) { |
|
3141 newLine += lines.length; |
|
3142 } else { |
|
3143 oldLine += lines.length; |
|
3144 } |
|
3145 } else { |
|
3146 // Identical context lines. Track line changes |
|
3147 if (oldRangeStart) { |
|
3148 // Close out any changes that have been output (or join overlapping) |
|
3149 if (lines.length <= options.context * 2 && i < diff.length - 2) { |
|
3150 /*istanbul ignore start*/var _curRange2; |
|
3151 |
|
3152 /*istanbul ignore end*/ // Overlapping |
|
3153 /*istanbul ignore start*/(_curRange2 = /*istanbul ignore end*/curRange).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_curRange2 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/contextLines(lines))); |
|
3154 } else { |
|
3155 /*istanbul ignore start*/var _curRange3; |
|
3156 |
|
3157 /*istanbul ignore end*/ // end the range and output |
|
3158 var contextSize = Math.min(lines.length, options.context); |
|
3159 /*istanbul ignore start*/(_curRange3 = /*istanbul ignore end*/curRange).push. /*istanbul ignore start*/apply /*istanbul ignore end*/( /*istanbul ignore start*/_curRange3 /*istanbul ignore end*/, /*istanbul ignore start*/_toConsumableArray( /*istanbul ignore end*/contextLines(lines.slice(0, contextSize)))); |
|
3160 |
|
3161 var hunk = { |
|
3162 oldStart: oldRangeStart, |
|
3163 oldLines: oldLine - oldRangeStart + contextSize, |
|
3164 newStart: newRangeStart, |
|
3165 newLines: newLine - newRangeStart + contextSize, |
|
3166 lines: curRange |
|
3167 }; |
|
3168 if (i >= diff.length - 2 && lines.length <= options.context) { |
|
3169 // EOF is inside this hunk |
|
3170 var oldEOFNewline = /\n$/.test(oldStr); |
|
3171 var newEOFNewline = /\n$/.test(newStr); |
|
3172 if (lines.length == 0 && !oldEOFNewline) { |
|
3173 // special case: old has no eol and no trailing context; no-nl can end up before adds |
|
3174 curRange.splice(hunk.oldLines, 0, '\\ No newline at end of file'); |
|
3175 } else if (!oldEOFNewline || !newEOFNewline) { |
|
3176 curRange.push('\\ No newline at end of file'); |
|
3177 } |
|
3178 } |
|
3179 hunks.push(hunk); |
|
3180 |
|
3181 oldRangeStart = 0; |
|
3182 newRangeStart = 0; |
|
3183 curRange = []; |
|
3184 } |
|
3185 } |
|
3186 oldLine += lines.length; |
|
3187 newLine += lines.length; |
|
3188 } |
|
3189 }; |
|
3190 |
|
3191 for (var i = 0; i < diff.length; i++) { |
|
3192 /*istanbul ignore start*/_loop( /*istanbul ignore end*/i); |
|
3193 } |
|
3194 |
|
3195 return { |
|
3196 oldFileName: oldFileName, newFileName: newFileName, |
|
3197 oldHeader: oldHeader, newHeader: newHeader, |
|
3198 hunks: hunks |
|
3199 }; |
|
3200 } |
|
3201 |
|
3202 function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) { |
|
3203 var diff = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options); |
|
3204 |
|
3205 var ret = []; |
|
3206 if (oldFileName == newFileName) { |
|
3207 ret.push('Index: ' + oldFileName); |
|
3208 } |
|
3209 ret.push('==================================================================='); |
|
3210 ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader)); |
|
3211 ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader)); |
|
3212 |
|
3213 for (var i = 0; i < diff.hunks.length; i++) { |
|
3214 var hunk = diff.hunks[i]; |
|
3215 ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@'); |
|
3216 ret.push.apply(ret, hunk.lines); |
|
3217 } |
|
3218 |
|
3219 return ret.join('\n') + '\n'; |
|
3220 } |
|
3221 |
|
3222 function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) { |
|
3223 return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options); |
|
3224 } |
|
3225 //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wYXRjaC9jcmVhdGUuanMiXSwibmFtZXMiOlsic3RydWN0dXJlZFBhdGNoIiwiY3JlYXRlVHdvRmlsZXNQYXRjaCIsImNyZWF0ZVBhdGNoIiwib2xkRmlsZU5hbWUiLCJuZXdGaWxlTmFtZSIsIm9sZFN0ciIsIm5ld1N0ciIsIm9sZEhlYWRlciIsIm5ld0hlYWRlciIsIm9wdGlvbnMiLCJjb250ZXh0IiwiZGlmZiIsInB1c2giLCJ2YWx1ZSIsImxpbmVzIiwiY29udGV4dExpbmVzIiwibWFwIiwiZW50cnkiLCJodW5rcyIsIm9sZFJhbmdlU3RhcnQiLCJuZXdSYW5nZVN0YXJ0IiwiY3VyUmFuZ2UiLCJvbGRMaW5lIiwibmV3TGluZSIsImkiLCJjdXJyZW50IiwicmVwbGFjZSIsInNwbGl0IiwiYWRkZWQiLCJyZW1vdmVkIiwicHJldiIsInNsaWNlIiwibGVuZ3RoIiwiY29udGV4dFNpemUiLCJNYXRoIiwibWluIiwiaHVuayIsIm9sZFN0YXJ0Iiwib2xkTGluZXMiLCJuZXdTdGFydCIsIm5ld0xpbmVzIiwib2xkRU9GTmV3bGluZSIsInRlc3QiLCJuZXdFT0ZOZXdsaW5lIiwic3BsaWNlIiwicmV0IiwiYXBwbHkiLCJqb2luIiwiZmlsZU5hbWUiXSwibWFwcGluZ3MiOiI7OztnQ0FFZ0JBLGUsR0FBQUEsZTt5REFpR0FDLG1CLEdBQUFBLG1CO3lEQXdCQUMsVyxHQUFBQSxXOztBQTNIaEI7Ozs7dUJBRU8sU0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Zi5uZXdIZWFkZXIpKTtcblxuICBmb3IgKGxldCBpID0gMDsgaSA8IGRpZmYuaHVua3MubGVuZ3RoOyBpKyspIHtcbiAgICBjb25zdCBodW5rID0gZGlmZi5odW5rc1tpXTtcbiAgICByZXQucHVzaChcbiAgICAgICdAQCAtJyArIGh1bmsub2xkU3RhcnQgKyAnLCcgKyBodW5rLm9sZExpbmVzXG4gICAgICArICcgKycgKyBodW5rLm5ld1N0YXJ0ICsgJywnICsgaHVuay5uZXdMaW5lc1xuICAgICAgKyAnIEBAJ1xuICAgICk7XG4gICAgcmV0LnB1c2guYXBwbHkocmV0LCBodW5rLmxpbmVzKTtcbiAgfVxuXG4gIHJldHVybiByZXQuam9pbignXFxuJykgKyAnXFxuJztcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIGNyZWF0ZVBhdGNoKGZpbGVOYW1lLCBvbGRTdHIsIG5ld1N0ciwgb2xkSGVhZGVyLCBuZXdIZWFkZXIsIG9wdGlvbnMpIHtcbiAgcmV0dXJuIGNyZWF0ZVR3b0ZpbGVzUGF0Y2goZmlsZU5hbWUsIGZpbGVOYW1lLCBvbGRTdHIsIG5ld1N0ciwgb2xkSGVhZGVyLCBuZXdIZWFkZXIsIG9wdGlvbnMpO1xufVxuIl19 |
|
3226 |
|
3227 |
|
3228 /***/ }), |
|
3229 /* 15 */ |
|
3230 /***/ (function(module, exports) { |
|
3231 |
|
3232 /*istanbul ignore start*/"use strict"; |
|
3233 |
|
3234 exports.__esModule = true; |
|
3235 exports. /*istanbul ignore end*/arrayEqual = arrayEqual; |
|
3236 /*istanbul ignore start*/exports. /*istanbul ignore end*/arrayStartsWith = arrayStartsWith; |
|
3237 function arrayEqual(a, b) { |
|
3238 if (a.length !== b.length) { |
|
3239 return false; |
|
3240 } |
|
3241 |
|
3242 return arrayStartsWith(a, b); |
|
3243 } |
|
3244 |
|
3245 function arrayStartsWith(array, start) { |
|
3246 if (start.length > array.length) { |
|
3247 return false; |
|
3248 } |
|
3249 |
|
3250 for (var i = 0; i < start.length; i++) { |
|
3251 if (start[i] !== array[i]) { |
|
3252 return false; |
|
3253 } |
|
3254 } |
|
3255 |
|
3256 return true; |
|
3257 } |
|
3258 //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlsL2FycmF5LmpzIl0sIm5hbWVzIjpbImFycmF5RXF1YWwiLCJhcnJheVN0YXJ0c1dpdGgiLCJhIiwiYiIsImxlbmd0aCIsImFycmF5Iiwic3RhcnQiLCJpIl0sIm1hcHBpbmdzIjoiOzs7Z0NBQWdCQSxVLEdBQUFBLFU7eURBUUFDLGUsR0FBQUEsZTtBQVJULFNBQVNELFVBQVQsQ0FBb0JFLENBQXBCLEVBQXVCQyxDQUF2QixFQUEwQjtBQUMvQixNQUFJRCxFQUFFRSxNQUFGLEtBQWFELEVBQUVDLE1BQW5CLEVBQTJCO0FBQ3pCLFdBQU8sS0FBUDtBQUNEOztBQUVELFNBQU9ILGdCQUFnQkMsQ0FBaEIsRUFBbUJDLENBQW5CLENBQVA7QUFDRDs7QUFFTSxTQUFTRixlQUFULENBQXlCSSxLQUF6QixFQUFnQ0MsS0FBaEMsRUFBdUM7QUFDNUMsTUFBSUEsTUFBTUYsTUFBTixHQUFlQyxNQUFNRCxNQUF6QixFQUFpQztBQUMvQixXQUFPLEtBQVA7QUFDRDs7QUFFRCxPQUFLLElBQUlHLElBQUksQ0FBYixFQUFnQkEsSUFBSUQsTUFBTUYsTUFBMUIsRUFBa0NHLEdBQWxDLEVBQXVDO0FBQ3JDLFFBQUlELE1BQU1DLENBQU4sTUFBYUYsTUFBTUUsQ0FBTixDQUFqQixFQUEyQjtBQUN6QixhQUFPLEtBQVA7QUFDRDtBQUNGOztBQUVELFNBQU8sSUFBUDtBQUNEIiwiZmlsZSI6ImFycmF5LmpzIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0IGZ1bmN0aW9uIGFycmF5RXF1YWwoYSwgYikge1xuICBpZiAoYS5sZW5ndGggIT09IGIubGVuZ3RoKSB7XG4gICAgcmV0dXJuIGZhbHNlO1xuICB9XG5cbiAgcmV0dXJuIGFycmF5U3RhcnRzV2l0aChhLCBiKTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIGFycmF5U3RhcnRzV2l0aChhcnJheSwgc3RhcnQpIHtcbiAgaWYgKHN0YXJ0Lmxlbmd0aCA+IGFycmF5Lmxlbmd0aCkge1xuICAgIHJldHVybiBmYWxzZTtcbiAgfVxuXG4gIGZvciAobGV0IGkgPSAwOyBpIDwgc3RhcnQubGVuZ3RoOyBpKyspIHtcbiAgICBpZiAoc3RhcnRbaV0gIT09IGFycmF5W2ldKSB7XG4gICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxuICB9XG5cbiAgcmV0dXJuIHRydWU7XG59XG4iXX0= |
|
3259 |
|
3260 |
|
3261 /***/ }), |
|
3262 /* 16 */ |
|
3263 /***/ (function(module, exports) { |
|
3264 |
|
3265 /*istanbul ignore start*/"use strict"; |
|
3266 |
|
3267 exports.__esModule = true; |
|
3268 exports. /*istanbul ignore end*/convertChangesToDMP = convertChangesToDMP; |
|
3269 // See: http://code.google.com/p/google-diff-match-patch/wiki/API |
|
3270 function convertChangesToDMP(changes) { |
|
3271 var ret = [], |
|
3272 change = /*istanbul ignore start*/void 0 /*istanbul ignore end*/, |
|
3273 operation = /*istanbul ignore start*/void 0 /*istanbul ignore end*/; |
|
3274 for (var i = 0; i < changes.length; i++) { |
|
3275 change = changes[i]; |
|
3276 if (change.added) { |
|
3277 operation = 1; |
|
3278 } else if (change.removed) { |
|
3279 operation = -1; |
|
3280 } else { |
|
3281 operation = 0; |
|
3282 } |
|
3283 |
|
3284 ret.push([operation, change.value]); |
|
3285 } |
|
3286 return ret; |
|
3287 } |
|
3288 //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb252ZXJ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ciAobGV0IGkgPSAwOyBpIDwgY2hhbmdlcy5sZW5ndGg7IGkrKykge1xuICAgIGNoYW5nZSA9IGNoYW5nZXNbaV07XG4gICAgaWYgKGNoYW5nZS5hZGRlZCkge1xuICAgICAgb3BlcmF0aW9uID0gMTtcbiAgICB9IGVsc2UgaWYgKGNoYW5nZS5yZW1vdmVkKSB7XG4gICAgICBvcGVyYXRpb24gPSAtMTtcbiAgICB9IGVsc2Uge1xuICAgICAgb3BlcmF0aW9uID0gMDtcbiAgICB9XG5cbiAgICByZXQucHVzaChbb3BlcmF0aW9uLCBjaGFuZ2UudmFsdWVdKTtcbiAgfVxuICByZXR1cm4gcmV0O1xufVxuIl19 |
|
3289 |
|
3290 |
|
3291 /***/ }), |
|
3292 /* 17 */ |
|
3293 /***/ (function(module, exports) { |
|
3294 |
|
3295 /*istanbul ignore start*/'use strict'; |
|
3296 |
|
3297 exports.__esModule = true; |
|
3298 exports. /*istanbul ignore end*/convertChangesToXML = convertChangesToXML; |
|
3299 function convertChangesToXML(changes) { |
|
3300 var ret = []; |
|
3301 for (var i = 0; i < changes.length; i++) { |
|
3302 var change = changes[i]; |
|
3303 if (change.added) { |
|
3304 ret.push('<ins>'); |
|
3305 } else if (change.removed) { |
|
3306 ret.push('<del>'); |
|
3307 } |
|
3308 |
|
3309 ret.push(escapeHTML(change.value)); |
|
3310 |
|
3311 if (change.added) { |
|
3312 ret.push('</ins>'); |
|
3313 } else if (change.removed) { |
|
3314 ret.push('</del>'); |
|
3315 } |
|
3316 } |
|
3317 return ret.join(''); |
|
3318 } |
|
3319 |
|
3320 function escapeHTML(s) { |
|
3321 var n = s; |
|
3322 n = n.replace(/&/g, '&'); |
|
3323 n = n.replace(/</g, '<'); |
|
3324 n = n.replace(/>/g, '>'); |
|
3325 n = n.replace(/"/g, '"'); |
|
3326 |
|
3327 return n; |
|
3328 } |
|
3329 |
|
3330 |
|
3331 /***/ }) |
|
3332 /******/ ]) |
|
3333 }); |
|
3334 ; |
|
3335 |
|
3336 /***/ }), |
|
3337 |
|
3338 /***/ 21: |
|
3339 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
3340 |
|
3341 "use strict"; |
|
3342 |
|
3343 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js |
|
3344 function _objectWithoutPropertiesLoose(source, excluded) { |
|
3345 if (source == null) return {}; |
|
3346 var target = {}; |
|
3347 var sourceKeys = Object.keys(source); |
|
3348 var key, i; |
|
3349 |
|
3350 for (i = 0; i < sourceKeys.length; i++) { |
|
3351 key = sourceKeys[i]; |
|
3352 if (excluded.indexOf(key) >= 0) continue; |
|
3353 target[key] = source[key]; |
|
3354 } |
|
3355 |
|
3356 return target; |
|
3357 } |
|
3358 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js |
|
3359 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectWithoutProperties; }); |
|
3360 |
|
3361 function _objectWithoutProperties(source, excluded) { |
|
3362 if (source == null) return {}; |
|
3363 var target = _objectWithoutPropertiesLoose(source, excluded); |
|
3364 var key, i; |
|
3365 |
|
3366 if (Object.getOwnPropertySymbols) { |
|
3367 var sourceSymbolKeys = Object.getOwnPropertySymbols(source); |
|
3368 |
|
3369 for (i = 0; i < sourceSymbolKeys.length; i++) { |
|
3370 key = sourceSymbolKeys[i]; |
|
3371 if (excluded.indexOf(key) >= 0) continue; |
|
3372 if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; |
|
3373 target[key] = source[key]; |
|
3374 } |
|
3375 } |
|
3376 |
|
3377 return target; |
|
3378 } |
|
3379 |
|
3380 /***/ }), |
|
3381 |
|
3382 /***/ 23: |
|
3383 /***/ (function(module, exports, __webpack_require__) { |
|
3384 |
|
3385 module.exports = __webpack_require__(54); |
|
3386 |
|
3387 |
|
3388 /***/ }), |
|
3389 |
|
3390 /***/ 24: |
|
3391 /***/ (function(module, exports) { |
|
3392 |
|
3393 (function() { module.exports = this["wp"]["dom"]; }()); |
|
3394 |
|
3395 /***/ }), |
|
3396 |
|
3397 /***/ 25: |
|
3398 /***/ (function(module, exports) { |
|
3399 |
|
3400 (function() { module.exports = this["wp"]["url"]; }()); |
|
3401 |
|
3402 /***/ }), |
|
3403 |
|
3404 /***/ 26: |
|
3405 /***/ (function(module, exports) { |
|
3406 |
|
3407 (function() { module.exports = this["wp"]["hooks"]; }()); |
|
3408 |
|
3409 /***/ }), |
|
3410 |
|
3411 /***/ 27: |
|
3412 /***/ (function(module, exports) { |
|
3413 |
|
3414 (function() { module.exports = this["React"]; }()); |
|
3415 |
|
3416 /***/ }), |
|
3417 |
|
3418 /***/ 28: |
|
3419 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
3420 |
|
3421 "use strict"; |
|
3422 |
|
3423 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js |
|
3424 var arrayWithHoles = __webpack_require__(37); |
|
3425 |
|
3426 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js |
|
3427 function _iterableToArrayLimit(arr, i) { |
|
3428 var _arr = []; |
|
3429 var _n = true; |
|
3430 var _d = false; |
|
3431 var _e = undefined; |
|
3432 |
|
3433 try { |
|
3434 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { |
|
3435 _arr.push(_s.value); |
|
3436 |
|
3437 if (i && _arr.length === i) break; |
|
3438 } |
|
3439 } catch (err) { |
|
3440 _d = true; |
|
3441 _e = err; |
|
3442 } finally { |
|
3443 try { |
|
3444 if (!_n && _i["return"] != null) _i["return"](); |
|
3445 } finally { |
|
3446 if (_d) throw _e; |
|
3447 } |
|
3448 } |
|
3449 |
|
3450 return _arr; |
|
3451 } |
|
3452 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js |
|
3453 var nonIterableRest = __webpack_require__(38); |
|
3454 |
|
3455 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js |
|
3456 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _slicedToArray; }); |
|
3457 |
|
3458 |
|
3459 |
|
3460 function _slicedToArray(arr, i) { |
|
3461 return Object(arrayWithHoles["a" /* default */])(arr) || _iterableToArrayLimit(arr, i) || Object(nonIterableRest["a" /* default */])(); |
|
3462 } |
|
3463 |
|
3464 /***/ }), |
|
3465 |
|
3466 /***/ 3: |
|
3467 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
3468 |
|
3469 "use strict"; |
|
3470 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _assertThisInitialized; }); |
|
3471 function _assertThisInitialized(self) { |
|
3472 if (self === void 0) { |
|
3473 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); |
|
3474 } |
|
3475 |
|
3476 return self; |
|
3477 } |
|
3478 |
|
3479 /***/ }), |
|
3480 |
|
3481 /***/ 30: |
|
3482 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
3483 |
|
3484 "use strict"; |
|
3485 |
|
3486 |
|
3487 var LEAF_KEY, hasWeakMap; |
|
3488 |
|
3489 /** |
|
3490 * Arbitrary value used as key for referencing cache object in WeakMap tree. |
|
3491 * |
|
3492 * @type {Object} |
|
3493 */ |
|
3494 LEAF_KEY = {}; |
|
3495 |
|
3496 /** |
|
3497 * Whether environment supports WeakMap. |
|
3498 * |
|
3499 * @type {boolean} |
|
3500 */ |
|
3501 hasWeakMap = typeof WeakMap !== 'undefined'; |
|
3502 |
|
3503 /** |
|
3504 * Returns the first argument as the sole entry in an array. |
|
3505 * |
|
3506 * @param {*} value Value to return. |
|
3507 * |
|
3508 * @return {Array} Value returned as entry in array. |
|
3509 */ |
|
3510 function arrayOf( value ) { |
|
3511 return [ value ]; |
|
3512 } |
|
3513 |
|
3514 /** |
|
3515 * Returns true if the value passed is object-like, or false otherwise. A value |
|
3516 * is object-like if it can support property assignment, e.g. object or array. |
|
3517 * |
|
3518 * @param {*} value Value to test. |
|
3519 * |
|
3520 * @return {boolean} Whether value is object-like. |
|
3521 */ |
|
3522 function isObjectLike( value ) { |
|
3523 return !! value && 'object' === typeof value; |
|
3524 } |
|
3525 |
|
3526 /** |
|
3527 * Creates and returns a new cache object. |
|
3528 * |
|
3529 * @return {Object} Cache object. |
|
3530 */ |
|
3531 function createCache() { |
|
3532 var cache = { |
|
3533 clear: function() { |
|
3534 cache.head = null; |
|
3535 }, |
|
3536 }; |
|
3537 |
|
3538 return cache; |
|
3539 } |
|
3540 |
|
3541 /** |
|
3542 * Returns true if entries within the two arrays are strictly equal by |
|
3543 * reference from a starting index. |
|
3544 * |
|
3545 * @param {Array} a First array. |
|
3546 * @param {Array} b Second array. |
|
3547 * @param {number} fromIndex Index from which to start comparison. |
|
3548 * |
|
3549 * @return {boolean} Whether arrays are shallowly equal. |
|
3550 */ |
|
3551 function isShallowEqual( a, b, fromIndex ) { |
|
3552 var i; |
|
3553 |
|
3554 if ( a.length !== b.length ) { |
|
3555 return false; |
|
3556 } |
|
3557 |
|
3558 for ( i = fromIndex; i < a.length; i++ ) { |
|
3559 if ( a[ i ] !== b[ i ] ) { |
|
3560 return false; |
|
3561 } |
|
3562 } |
|
3563 |
|
3564 return true; |
|
3565 } |
|
3566 |
|
3567 /** |
|
3568 * Returns a memoized selector function. The getDependants function argument is |
|
3569 * called before the memoized selector and is expected to return an immutable |
|
3570 * reference or array of references on which the selector depends for computing |
|
3571 * its own return value. The memoize cache is preserved only as long as those |
|
3572 * dependant references remain the same. If getDependants returns a different |
|
3573 * reference(s), the cache is cleared and the selector value regenerated. |
|
3574 * |
|
3575 * @param {Function} selector Selector function. |
|
3576 * @param {Function} getDependants Dependant getter returning an immutable |
|
3577 * reference or array of reference used in |
|
3578 * cache bust consideration. |
|
3579 * |
|
3580 * @return {Function} Memoized selector. |
|
3581 */ |
|
3582 /* harmony default export */ __webpack_exports__["a"] = (function( selector, getDependants ) { |
|
3583 var rootCache, getCache; |
|
3584 |
|
3585 // Use object source as dependant if getter not provided |
|
3586 if ( ! getDependants ) { |
|
3587 getDependants = arrayOf; |
|
3588 } |
|
3589 |
|
3590 /** |
|
3591 * Returns the root cache. If WeakMap is supported, this is assigned to the |
|
3592 * root WeakMap cache set, otherwise it is a shared instance of the default |
|
3593 * cache object. |
|
3594 * |
|
3595 * @return {(WeakMap|Object)} Root cache object. |
|
3596 */ |
|
3597 function getRootCache() { |
|
3598 return rootCache; |
|
3599 } |
|
3600 |
|
3601 /** |
|
3602 * Returns the cache for a given dependants array. When possible, a WeakMap |
|
3603 * will be used to create a unique cache for each set of dependants. This |
|
3604 * is feasible due to the nature of WeakMap in allowing garbage collection |
|
3605 * to occur on entries where the key object is no longer referenced. Since |
|
3606 * WeakMap requires the key to be an object, this is only possible when the |
|
3607 * dependant is object-like. The root cache is created as a hierarchy where |
|
3608 * each top-level key is the first entry in a dependants set, the value a |
|
3609 * WeakMap where each key is the next dependant, and so on. This continues |
|
3610 * so long as the dependants are object-like. If no dependants are object- |
|
3611 * like, then the cache is shared across all invocations. |
|
3612 * |
|
3613 * @see isObjectLike |
|
3614 * |
|
3615 * @param {Array} dependants Selector dependants. |
|
3616 * |
|
3617 * @return {Object} Cache object. |
|
3618 */ |
|
3619 function getWeakMapCache( dependants ) { |
|
3620 var caches = rootCache, |
|
3621 isUniqueByDependants = true, |
|
3622 i, dependant, map, cache; |
|
3623 |
|
3624 for ( i = 0; i < dependants.length; i++ ) { |
|
3625 dependant = dependants[ i ]; |
|
3626 |
|
3627 // Can only compose WeakMap from object-like key. |
|
3628 if ( ! isObjectLike( dependant ) ) { |
|
3629 isUniqueByDependants = false; |
|
3630 break; |
|
3631 } |
|
3632 |
|
3633 // Does current segment of cache already have a WeakMap? |
|
3634 if ( caches.has( dependant ) ) { |
|
3635 // Traverse into nested WeakMap. |
|
3636 caches = caches.get( dependant ); |
|
3637 } else { |
|
3638 // Create, set, and traverse into a new one. |
|
3639 map = new WeakMap(); |
|
3640 caches.set( dependant, map ); |
|
3641 caches = map; |
|
3642 } |
|
3643 } |
|
3644 |
|
3645 // We use an arbitrary (but consistent) object as key for the last item |
|
3646 // in the WeakMap to serve as our running cache. |
|
3647 if ( ! caches.has( LEAF_KEY ) ) { |
|
3648 cache = createCache(); |
|
3649 cache.isUniqueByDependants = isUniqueByDependants; |
|
3650 caches.set( LEAF_KEY, cache ); |
|
3651 } |
|
3652 |
|
3653 return caches.get( LEAF_KEY ); |
|
3654 } |
|
3655 |
|
3656 // Assign cache handler by availability of WeakMap |
|
3657 getCache = hasWeakMap ? getWeakMapCache : getRootCache; |
|
3658 |
|
3659 /** |
|
3660 * Resets root memoization cache. |
|
3661 */ |
|
3662 function clear() { |
|
3663 rootCache = hasWeakMap ? new WeakMap() : createCache(); |
|
3664 } |
|
3665 |
|
3666 // eslint-disable-next-line jsdoc/check-param-names |
|
3667 /** |
|
3668 * The augmented selector call, considering first whether dependants have |
|
3669 * changed before passing it to underlying memoize function. |
|
3670 * |
|
3671 * @param {Object} source Source object for derivation. |
|
3672 * @param {...*} extraArgs Additional arguments to pass to selector. |
|
3673 * |
|
3674 * @return {*} Selector result. |
|
3675 */ |
|
3676 function callSelector( /* source, ...extraArgs */ ) { |
|
3677 var len = arguments.length, |
|
3678 cache, node, i, args, dependants; |
|
3679 |
|
3680 // Create copy of arguments (avoid leaking deoptimization). |
|
3681 args = new Array( len ); |
|
3682 for ( i = 0; i < len; i++ ) { |
|
3683 args[ i ] = arguments[ i ]; |
|
3684 } |
|
3685 |
|
3686 dependants = getDependants.apply( null, args ); |
|
3687 cache = getCache( dependants ); |
|
3688 |
|
3689 // If not guaranteed uniqueness by dependants (primitive type or lack |
|
3690 // of WeakMap support), shallow compare against last dependants and, if |
|
3691 // references have changed, destroy cache to recalculate result. |
|
3692 if ( ! cache.isUniqueByDependants ) { |
|
3693 if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) { |
|
3694 cache.clear(); |
|
3695 } |
|
3696 |
|
3697 cache.lastDependants = dependants; |
|
3698 } |
|
3699 |
|
3700 node = cache.head; |
|
3701 while ( node ) { |
|
3702 // Check whether node arguments match arguments |
|
3703 if ( ! isShallowEqual( node.args, args, 1 ) ) { |
|
3704 node = node.next; |
|
3705 continue; |
|
3706 } |
|
3707 |
|
3708 // At this point we can assume we've found a match |
|
3709 |
|
3710 // Surface matched node to head if not already |
|
3711 if ( node !== cache.head ) { |
|
3712 // Adjust siblings to point to each other. |
|
3713 node.prev.next = node.next; |
|
3714 if ( node.next ) { |
|
3715 node.next.prev = node.prev; |
|
3716 } |
|
3717 |
|
3718 node.next = cache.head; |
|
3719 node.prev = null; |
|
3720 cache.head.prev = node; |
|
3721 cache.head = node; |
|
3722 } |
|
3723 |
|
3724 // Return immediately |
|
3725 return node.val; |
|
3726 } |
|
3727 |
|
3728 // No cached value found. Continue to insertion phase: |
|
3729 |
|
3730 node = { |
|
3731 // Generate the result from original function |
|
3732 val: selector.apply( null, args ), |
|
3733 }; |
|
3734 |
|
3735 // Avoid including the source object in the cache. |
|
3736 args[ 0 ] = null; |
|
3737 node.args = args; |
|
3738 |
|
3739 // Don't need to check whether node is already head, since it would |
|
3740 // have been returned above already if it was |
|
3741 |
|
3742 // Shift existing head down list |
|
3743 if ( cache.head ) { |
|
3744 cache.head.prev = node; |
|
3745 node.next = cache.head; |
|
3746 } |
|
3747 |
|
3748 cache.head = node; |
|
3749 |
|
3750 return node.val; |
|
3751 } |
|
3752 |
|
3753 callSelector.getDependants = getDependants; |
|
3754 callSelector.clear = clear; |
|
3755 clear(); |
|
3756 |
|
3757 return callSelector; |
|
3758 }); |
|
3759 |
|
3760 |
|
3761 /***/ }), |
|
3762 |
|
3763 /***/ 31: |
|
3764 /***/ (function(module, exports, __webpack_require__) { |
|
3765 |
|
3766 /** |
|
3767 * Copyright (c) 2013-present, Facebook, Inc. |
|
3768 * |
|
3769 * This source code is licensed under the MIT license found in the |
|
3770 * LICENSE file in the root directory of this source tree. |
|
3771 */ |
|
3772 |
|
3773 if (false) { var throwOnDirectAccess, isValidElement, REACT_ELEMENT_TYPE; } else { |
|
3774 // By explicitly using `prop-types` you are opting into new production behavior. |
|
3775 // http://fb.me/prop-types-in-prod |
|
3776 module.exports = __webpack_require__(89)(); |
|
3777 } |
|
3778 |
|
3779 |
|
3780 /***/ }), |
|
3781 |
|
3782 /***/ 32: |
|
3783 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
3784 |
|
3785 "use strict"; |
|
3786 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _typeof; }); |
|
3787 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); } |
|
3788 |
|
3789 function _typeof(obj) { |
|
3790 if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { |
|
3791 _typeof = function _typeof(obj) { |
|
3792 return _typeof2(obj); |
|
3793 }; |
|
3794 } else { |
|
3795 _typeof = function _typeof(obj) { |
|
3796 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); |
|
3797 }; |
|
3798 } |
|
3799 |
|
3800 return _typeof(obj); |
|
3801 } |
|
3802 |
|
3803 /***/ }), |
|
3804 |
|
3805 /***/ 33: |
|
3806 /***/ (function(module, exports) { |
|
3807 |
|
3808 (function() { module.exports = this["wp"]["apiFetch"]; }()); |
|
3809 |
|
3810 /***/ }), |
|
3811 |
|
3812 /***/ 34: |
|
3813 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
3814 |
|
3815 "use strict"; |
|
3816 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; }); |
|
3817 function _iterableToArray(iter) { |
|
3818 if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); |
|
3819 } |
|
3820 |
|
3821 /***/ }), |
|
3822 |
|
3823 /***/ 35: |
|
3824 /***/ (function(module, exports) { |
|
3825 |
|
3826 (function() { module.exports = this["wp"]["blob"]; }()); |
|
3827 |
|
3828 /***/ }), |
|
3829 |
|
3830 /***/ 357: |
|
3831 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
3832 |
|
3833 "use strict"; |
|
3834 __webpack_require__.r(__webpack_exports__); |
|
3835 var actions_namespaceObject = {}; |
|
3836 __webpack_require__.r(actions_namespaceObject); |
|
3837 __webpack_require__.d(actions_namespaceObject, "resetBlocks", function() { return resetBlocks; }); |
|
3838 __webpack_require__.d(actions_namespaceObject, "receiveBlocks", function() { return receiveBlocks; }); |
|
3839 __webpack_require__.d(actions_namespaceObject, "updateBlockAttributes", function() { return updateBlockAttributes; }); |
|
3840 __webpack_require__.d(actions_namespaceObject, "updateBlock", function() { return updateBlock; }); |
|
3841 __webpack_require__.d(actions_namespaceObject, "selectBlock", function() { return actions_selectBlock; }); |
|
3842 __webpack_require__.d(actions_namespaceObject, "selectPreviousBlock", function() { return selectPreviousBlock; }); |
|
3843 __webpack_require__.d(actions_namespaceObject, "selectNextBlock", function() { return selectNextBlock; }); |
|
3844 __webpack_require__.d(actions_namespaceObject, "startMultiSelect", function() { return startMultiSelect; }); |
|
3845 __webpack_require__.d(actions_namespaceObject, "stopMultiSelect", function() { return stopMultiSelect; }); |
|
3846 __webpack_require__.d(actions_namespaceObject, "multiSelect", function() { return actions_multiSelect; }); |
|
3847 __webpack_require__.d(actions_namespaceObject, "clearSelectedBlock", function() { return clearSelectedBlock; }); |
|
3848 __webpack_require__.d(actions_namespaceObject, "toggleSelection", function() { return toggleSelection; }); |
|
3849 __webpack_require__.d(actions_namespaceObject, "replaceBlocks", function() { return actions_replaceBlocks; }); |
|
3850 __webpack_require__.d(actions_namespaceObject, "replaceBlock", function() { return replaceBlock; }); |
|
3851 __webpack_require__.d(actions_namespaceObject, "moveBlocksDown", function() { return actions_moveBlocksDown; }); |
|
3852 __webpack_require__.d(actions_namespaceObject, "moveBlocksUp", function() { return actions_moveBlocksUp; }); |
|
3853 __webpack_require__.d(actions_namespaceObject, "moveBlockToPosition", function() { return moveBlockToPosition; }); |
|
3854 __webpack_require__.d(actions_namespaceObject, "insertBlock", function() { return actions_insertBlock; }); |
|
3855 __webpack_require__.d(actions_namespaceObject, "insertBlocks", function() { return actions_insertBlocks; }); |
|
3856 __webpack_require__.d(actions_namespaceObject, "showInsertionPoint", function() { return actions_showInsertionPoint; }); |
|
3857 __webpack_require__.d(actions_namespaceObject, "hideInsertionPoint", function() { return actions_hideInsertionPoint; }); |
|
3858 __webpack_require__.d(actions_namespaceObject, "setTemplateValidity", function() { return setTemplateValidity; }); |
|
3859 __webpack_require__.d(actions_namespaceObject, "synchronizeTemplate", function() { return synchronizeTemplate; }); |
|
3860 __webpack_require__.d(actions_namespaceObject, "mergeBlocks", function() { return mergeBlocks; }); |
|
3861 __webpack_require__.d(actions_namespaceObject, "removeBlocks", function() { return actions_removeBlocks; }); |
|
3862 __webpack_require__.d(actions_namespaceObject, "removeBlock", function() { return removeBlock; }); |
|
3863 __webpack_require__.d(actions_namespaceObject, "replaceInnerBlocks", function() { return actions_replaceInnerBlocks; }); |
|
3864 __webpack_require__.d(actions_namespaceObject, "toggleBlockMode", function() { return toggleBlockMode; }); |
|
3865 __webpack_require__.d(actions_namespaceObject, "startTyping", function() { return startTyping; }); |
|
3866 __webpack_require__.d(actions_namespaceObject, "stopTyping", function() { return stopTyping; }); |
|
3867 __webpack_require__.d(actions_namespaceObject, "enterFormattedText", function() { return enterFormattedText; }); |
|
3868 __webpack_require__.d(actions_namespaceObject, "exitFormattedText", function() { return exitFormattedText; }); |
|
3869 __webpack_require__.d(actions_namespaceObject, "insertDefaultBlock", function() { return actions_insertDefaultBlock; }); |
|
3870 __webpack_require__.d(actions_namespaceObject, "updateBlockListSettings", function() { return updateBlockListSettings; }); |
|
3871 __webpack_require__.d(actions_namespaceObject, "updateSettings", function() { return updateSettings; }); |
|
3872 __webpack_require__.d(actions_namespaceObject, "__unstableSaveReusableBlock", function() { return __unstableSaveReusableBlock; }); |
|
3873 __webpack_require__.d(actions_namespaceObject, "__unstableMarkLastChangeAsPersistent", function() { return __unstableMarkLastChangeAsPersistent; }); |
|
3874 var selectors_namespaceObject = {}; |
|
3875 __webpack_require__.r(selectors_namespaceObject); |
|
3876 __webpack_require__.d(selectors_namespaceObject, "INSERTER_UTILITY_HIGH", function() { return INSERTER_UTILITY_HIGH; }); |
|
3877 __webpack_require__.d(selectors_namespaceObject, "INSERTER_UTILITY_MEDIUM", function() { return INSERTER_UTILITY_MEDIUM; }); |
|
3878 __webpack_require__.d(selectors_namespaceObject, "INSERTER_UTILITY_LOW", function() { return INSERTER_UTILITY_LOW; }); |
|
3879 __webpack_require__.d(selectors_namespaceObject, "INSERTER_UTILITY_NONE", function() { return INSERTER_UTILITY_NONE; }); |
|
3880 __webpack_require__.d(selectors_namespaceObject, "getBlockDependantsCacheBust", function() { return getBlockDependantsCacheBust; }); |
|
3881 __webpack_require__.d(selectors_namespaceObject, "getBlockName", function() { return selectors_getBlockName; }); |
|
3882 __webpack_require__.d(selectors_namespaceObject, "isBlockValid", function() { return selectors_isBlockValid; }); |
|
3883 __webpack_require__.d(selectors_namespaceObject, "getBlockAttributes", function() { return getBlockAttributes; }); |
|
3884 __webpack_require__.d(selectors_namespaceObject, "getBlock", function() { return selectors_getBlock; }); |
|
3885 __webpack_require__.d(selectors_namespaceObject, "__unstableGetBlockWithoutInnerBlocks", function() { return selectors_unstableGetBlockWithoutInnerBlocks; }); |
|
3886 __webpack_require__.d(selectors_namespaceObject, "getBlocks", function() { return getBlocks; }); |
|
3887 __webpack_require__.d(selectors_namespaceObject, "getClientIdsOfDescendants", function() { return selectors_getClientIdsOfDescendants; }); |
|
3888 __webpack_require__.d(selectors_namespaceObject, "getClientIdsWithDescendants", function() { return getClientIdsWithDescendants; }); |
|
3889 __webpack_require__.d(selectors_namespaceObject, "getGlobalBlockCount", function() { return getGlobalBlockCount; }); |
|
3890 __webpack_require__.d(selectors_namespaceObject, "getBlocksByClientId", function() { return selectors_getBlocksByClientId; }); |
|
3891 __webpack_require__.d(selectors_namespaceObject, "getBlockCount", function() { return selectors_getBlockCount; }); |
|
3892 __webpack_require__.d(selectors_namespaceObject, "getBlockSelectionStart", function() { return getBlockSelectionStart; }); |
|
3893 __webpack_require__.d(selectors_namespaceObject, "getBlockSelectionEnd", function() { return getBlockSelectionEnd; }); |
|
3894 __webpack_require__.d(selectors_namespaceObject, "getSelectedBlockCount", function() { return selectors_getSelectedBlockCount; }); |
|
3895 __webpack_require__.d(selectors_namespaceObject, "hasSelectedBlock", function() { return hasSelectedBlock; }); |
|
3896 __webpack_require__.d(selectors_namespaceObject, "getSelectedBlockClientId", function() { return selectors_getSelectedBlockClientId; }); |
|
3897 __webpack_require__.d(selectors_namespaceObject, "getSelectedBlock", function() { return selectors_getSelectedBlock; }); |
|
3898 __webpack_require__.d(selectors_namespaceObject, "getBlockRootClientId", function() { return selectors_getBlockRootClientId; }); |
|
3899 __webpack_require__.d(selectors_namespaceObject, "getBlockHierarchyRootClientId", function() { return getBlockHierarchyRootClientId; }); |
|
3900 __webpack_require__.d(selectors_namespaceObject, "getAdjacentBlockClientId", function() { return getAdjacentBlockClientId; }); |
|
3901 __webpack_require__.d(selectors_namespaceObject, "getPreviousBlockClientId", function() { return getPreviousBlockClientId; }); |
|
3902 __webpack_require__.d(selectors_namespaceObject, "getNextBlockClientId", function() { return getNextBlockClientId; }); |
|
3903 __webpack_require__.d(selectors_namespaceObject, "getSelectedBlocksInitialCaretPosition", function() { return selectors_getSelectedBlocksInitialCaretPosition; }); |
|
3904 __webpack_require__.d(selectors_namespaceObject, "getMultiSelectedBlockClientIds", function() { return selectors_getMultiSelectedBlockClientIds; }); |
|
3905 __webpack_require__.d(selectors_namespaceObject, "getMultiSelectedBlocks", function() { return getMultiSelectedBlocks; }); |
|
3906 __webpack_require__.d(selectors_namespaceObject, "getFirstMultiSelectedBlockClientId", function() { return getFirstMultiSelectedBlockClientId; }); |
|
3907 __webpack_require__.d(selectors_namespaceObject, "getLastMultiSelectedBlockClientId", function() { return getLastMultiSelectedBlockClientId; }); |
|
3908 __webpack_require__.d(selectors_namespaceObject, "isFirstMultiSelectedBlock", function() { return selectors_isFirstMultiSelectedBlock; }); |
|
3909 __webpack_require__.d(selectors_namespaceObject, "isBlockMultiSelected", function() { return selectors_isBlockMultiSelected; }); |
|
3910 __webpack_require__.d(selectors_namespaceObject, "isAncestorMultiSelected", function() { return selectors_isAncestorMultiSelected; }); |
|
3911 __webpack_require__.d(selectors_namespaceObject, "getMultiSelectedBlocksStartClientId", function() { return getMultiSelectedBlocksStartClientId; }); |
|
3912 __webpack_require__.d(selectors_namespaceObject, "getMultiSelectedBlocksEndClientId", function() { return getMultiSelectedBlocksEndClientId; }); |
|
3913 __webpack_require__.d(selectors_namespaceObject, "getBlockOrder", function() { return selectors_getBlockOrder; }); |
|
3914 __webpack_require__.d(selectors_namespaceObject, "getBlockIndex", function() { return selectors_getBlockIndex; }); |
|
3915 __webpack_require__.d(selectors_namespaceObject, "isBlockSelected", function() { return selectors_isBlockSelected; }); |
|
3916 __webpack_require__.d(selectors_namespaceObject, "hasSelectedInnerBlock", function() { return selectors_hasSelectedInnerBlock; }); |
|
3917 __webpack_require__.d(selectors_namespaceObject, "isBlockWithinSelection", function() { return isBlockWithinSelection; }); |
|
3918 __webpack_require__.d(selectors_namespaceObject, "hasMultiSelection", function() { return selectors_hasMultiSelection; }); |
|
3919 __webpack_require__.d(selectors_namespaceObject, "isMultiSelecting", function() { return selectors_isMultiSelecting; }); |
|
3920 __webpack_require__.d(selectors_namespaceObject, "isSelectionEnabled", function() { return selectors_isSelectionEnabled; }); |
|
3921 __webpack_require__.d(selectors_namespaceObject, "getBlockMode", function() { return selectors_getBlockMode; }); |
|
3922 __webpack_require__.d(selectors_namespaceObject, "isTyping", function() { return selectors_isTyping; }); |
|
3923 __webpack_require__.d(selectors_namespaceObject, "isCaretWithinFormattedText", function() { return selectors_isCaretWithinFormattedText; }); |
|
3924 __webpack_require__.d(selectors_namespaceObject, "getBlockInsertionPoint", function() { return getBlockInsertionPoint; }); |
|
3925 __webpack_require__.d(selectors_namespaceObject, "isBlockInsertionPointVisible", function() { return isBlockInsertionPointVisible; }); |
|
3926 __webpack_require__.d(selectors_namespaceObject, "isValidTemplate", function() { return isValidTemplate; }); |
|
3927 __webpack_require__.d(selectors_namespaceObject, "getTemplate", function() { return getTemplate; }); |
|
3928 __webpack_require__.d(selectors_namespaceObject, "getTemplateLock", function() { return selectors_getTemplateLock; }); |
|
3929 __webpack_require__.d(selectors_namespaceObject, "canInsertBlockType", function() { return selectors_canInsertBlockType; }); |
|
3930 __webpack_require__.d(selectors_namespaceObject, "getInserterItems", function() { return selectors_getInserterItems; }); |
|
3931 __webpack_require__.d(selectors_namespaceObject, "hasInserterItems", function() { return hasInserterItems; }); |
|
3932 __webpack_require__.d(selectors_namespaceObject, "getBlockListSettings", function() { return getBlockListSettings; }); |
|
3933 __webpack_require__.d(selectors_namespaceObject, "getSettings", function() { return selectors_getSettings; }); |
|
3934 __webpack_require__.d(selectors_namespaceObject, "isLastBlockChangePersistent", function() { return isLastBlockChangePersistent; }); |
|
3935 __webpack_require__.d(selectors_namespaceObject, "__unstableIsLastBlockChangeIgnored", function() { return __unstableIsLastBlockChangeIgnored; }); |
|
3936 |
|
3937 // EXTERNAL MODULE: external {"this":["wp","blocks"]} |
|
3938 var external_this_wp_blocks_ = __webpack_require__(14); |
|
3939 |
|
3940 // EXTERNAL MODULE: external {"this":["wp","coreData"]} |
|
3941 var external_this_wp_coreData_ = __webpack_require__(72); |
|
3942 |
|
3943 // EXTERNAL MODULE: external {"this":["wp","richText"]} |
|
3944 var external_this_wp_richText_ = __webpack_require__(20); |
|
3945 |
|
3946 // EXTERNAL MODULE: external {"this":["wp","viewport"]} |
|
3947 var external_this_wp_viewport_ = __webpack_require__(40); |
|
3948 |
|
3949 // EXTERNAL MODULE: external {"this":["wp","data"]} |
|
3950 var external_this_wp_data_ = __webpack_require__(5); |
|
3951 |
|
3952 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread.js |
|
3953 var objectSpread = __webpack_require__(7); |
|
3954 |
|
3955 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js + 1 modules |
|
3956 var objectWithoutProperties = __webpack_require__(21); |
|
3957 |
|
3958 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules |
|
3959 var toConsumableArray = __webpack_require__(17); |
|
3960 |
|
3961 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js |
|
3962 var defineProperty = __webpack_require__(15); |
|
3963 |
|
3964 // EXTERNAL MODULE: external "lodash" |
|
3965 var external_lodash_ = __webpack_require__(2); |
|
3966 |
|
3967 // EXTERNAL MODULE: external {"this":["wp","i18n"]} |
|
3968 var external_this_wp_i18n_ = __webpack_require__(1); |
|
3969 |
|
3970 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/defaults.js |
|
3971 /** |
|
3972 * WordPress dependencies |
|
3973 */ |
|
3974 |
|
3975 var PREFERENCES_DEFAULTS = { |
|
3976 insertUsage: {} |
|
3977 }; |
|
3978 /** |
|
3979 * The default editor settings |
|
3980 * |
|
3981 * alignWide boolean Enable/Disable Wide/Full Alignments |
|
3982 * availableLegacyWidgets Array Array of objects representing the legacy widgets available. |
|
3983 * colors Array Palette colors |
|
3984 * disableCustomColors boolean Whether or not the custom colors are disabled |
|
3985 * fontSizes Array Available font sizes |
|
3986 * disableCustomFontSizes boolean Whether or not the custom font sizes are disabled |
|
3987 * imageSizes Array Available image sizes |
|
3988 * maxWidth number Max width to constraint resizing |
|
3989 * allowedBlockTypes boolean|Array Allowed block types |
|
3990 * hasFixedToolbar boolean Whether or not the editor toolbar is fixed |
|
3991 * hasPermissionsToManageWidgets boolean Whether or not the user is able to manage widgets. |
|
3992 * focusMode boolean Whether the focus mode is enabled or not |
|
3993 * styles Array Editor Styles |
|
3994 * isRTL boolean Whether the editor is in RTL mode |
|
3995 * bodyPlaceholder string Empty post placeholder |
|
3996 * titlePlaceholder string Empty title placeholder |
|
3997 */ |
|
3998 |
|
3999 var SETTINGS_DEFAULTS = { |
|
4000 alignWide: false, |
|
4001 colors: [{ |
|
4002 name: Object(external_this_wp_i18n_["__"])('Pale pink'), |
|
4003 slug: 'pale-pink', |
|
4004 color: '#f78da7' |
|
4005 }, { |
|
4006 name: Object(external_this_wp_i18n_["__"])('Vivid red'), |
|
4007 slug: 'vivid-red', |
|
4008 color: '#cf2e2e' |
|
4009 }, { |
|
4010 name: Object(external_this_wp_i18n_["__"])('Luminous vivid orange'), |
|
4011 slug: 'luminous-vivid-orange', |
|
4012 color: '#ff6900' |
|
4013 }, { |
|
4014 name: Object(external_this_wp_i18n_["__"])('Luminous vivid amber'), |
|
4015 slug: 'luminous-vivid-amber', |
|
4016 color: '#fcb900' |
|
4017 }, { |
|
4018 name: Object(external_this_wp_i18n_["__"])('Light green cyan'), |
|
4019 slug: 'light-green-cyan', |
|
4020 color: '#7bdcb5' |
|
4021 }, { |
|
4022 name: Object(external_this_wp_i18n_["__"])('Vivid green cyan'), |
|
4023 slug: 'vivid-green-cyan', |
|
4024 color: '#00d084' |
|
4025 }, { |
|
4026 name: Object(external_this_wp_i18n_["__"])('Pale cyan blue'), |
|
4027 slug: 'pale-cyan-blue', |
|
4028 color: '#8ed1fc' |
|
4029 }, { |
|
4030 name: Object(external_this_wp_i18n_["__"])('Vivid cyan blue'), |
|
4031 slug: 'vivid-cyan-blue', |
|
4032 color: '#0693e3' |
|
4033 }, { |
|
4034 name: Object(external_this_wp_i18n_["__"])('Very light gray'), |
|
4035 slug: 'very-light-gray', |
|
4036 color: '#eeeeee' |
|
4037 }, { |
|
4038 name: Object(external_this_wp_i18n_["__"])('Cyan bluish gray'), |
|
4039 slug: 'cyan-bluish-gray', |
|
4040 color: '#abb8c3' |
|
4041 }, { |
|
4042 name: Object(external_this_wp_i18n_["__"])('Very dark gray'), |
|
4043 slug: 'very-dark-gray', |
|
4044 color: '#313131' |
|
4045 }], |
|
4046 fontSizes: [{ |
|
4047 name: Object(external_this_wp_i18n_["_x"])('Small', 'font size name'), |
|
4048 size: 13, |
|
4049 slug: 'small' |
|
4050 }, { |
|
4051 name: Object(external_this_wp_i18n_["_x"])('Normal', 'font size name'), |
|
4052 size: 16, |
|
4053 slug: 'normal' |
|
4054 }, { |
|
4055 name: Object(external_this_wp_i18n_["_x"])('Medium', 'font size name'), |
|
4056 size: 20, |
|
4057 slug: 'medium' |
|
4058 }, { |
|
4059 name: Object(external_this_wp_i18n_["_x"])('Large', 'font size name'), |
|
4060 size: 36, |
|
4061 slug: 'large' |
|
4062 }, { |
|
4063 name: Object(external_this_wp_i18n_["_x"])('Huge', 'font size name'), |
|
4064 size: 48, |
|
4065 slug: 'huge' |
|
4066 }], |
|
4067 imageSizes: [{ |
|
4068 slug: 'thumbnail', |
|
4069 label: Object(external_this_wp_i18n_["__"])('Thumbnail') |
|
4070 }, { |
|
4071 slug: 'medium', |
|
4072 label: Object(external_this_wp_i18n_["__"])('Medium') |
|
4073 }, { |
|
4074 slug: 'large', |
|
4075 label: Object(external_this_wp_i18n_["__"])('Large') |
|
4076 }, { |
|
4077 slug: 'full', |
|
4078 label: Object(external_this_wp_i18n_["__"])('Full Size') |
|
4079 }], |
|
4080 // This is current max width of the block inner area |
|
4081 // It's used to constraint image resizing and this value could be overridden later by themes |
|
4082 maxWidth: 580, |
|
4083 // Allowed block types for the editor, defaulting to true (all supported). |
|
4084 allowedBlockTypes: true, |
|
4085 // Maximum upload size in bytes allowed for the site. |
|
4086 maxUploadFileSize: 0, |
|
4087 // List of allowed mime types and file extensions. |
|
4088 allowedMimeTypes: null, |
|
4089 availableLegacyWidgets: {}, |
|
4090 hasPermissionsToManageWidgets: false |
|
4091 }; |
|
4092 |
|
4093 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/array.js |
|
4094 |
|
4095 |
|
4096 /** |
|
4097 * External dependencies |
|
4098 */ |
|
4099 |
|
4100 /** |
|
4101 * Insert one or multiple elements into a given position of an array. |
|
4102 * |
|
4103 * @param {Array} array Source array. |
|
4104 * @param {*} elements Elements to insert. |
|
4105 * @param {number} index Insert Position. |
|
4106 * |
|
4107 * @return {Array} Result. |
|
4108 */ |
|
4109 |
|
4110 function insertAt(array, elements, index) { |
|
4111 return [].concat(Object(toConsumableArray["a" /* default */])(array.slice(0, index)), Object(toConsumableArray["a" /* default */])(Object(external_lodash_["castArray"])(elements)), Object(toConsumableArray["a" /* default */])(array.slice(index))); |
|
4112 } |
|
4113 /** |
|
4114 * Moves an element in an array. |
|
4115 * |
|
4116 * @param {Array} array Source array. |
|
4117 * @param {number} from Source index. |
|
4118 * @param {number} to Destination index. |
|
4119 * @param {number} count Number of elements to move. |
|
4120 * |
|
4121 * @return {Array} Result. |
|
4122 */ |
|
4123 |
|
4124 function moveTo(array, from, to) { |
|
4125 var count = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1; |
|
4126 |
|
4127 var withoutMovedElements = Object(toConsumableArray["a" /* default */])(array); |
|
4128 |
|
4129 withoutMovedElements.splice(from, count); |
|
4130 return insertAt(withoutMovedElements, array.slice(from, from + count), to); |
|
4131 } |
|
4132 |
|
4133 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/reducer.js |
|
4134 |
|
4135 |
|
4136 |
|
4137 |
|
4138 |
|
4139 /** |
|
4140 * External dependencies |
|
4141 */ |
|
4142 |
|
4143 /** |
|
4144 * WordPress dependencies |
|
4145 */ |
|
4146 |
|
4147 |
|
4148 |
|
4149 /** |
|
4150 * Internal dependencies |
|
4151 */ |
|
4152 |
|
4153 |
|
4154 |
|
4155 /** |
|
4156 * Given an array of blocks, returns an object where each key is a nesting |
|
4157 * context, the value of which is an array of block client IDs existing within |
|
4158 * that nesting context. |
|
4159 * |
|
4160 * @param {Array} blocks Blocks to map. |
|
4161 * @param {?string} rootClientId Assumed root client ID. |
|
4162 * |
|
4163 * @return {Object} Block order map object. |
|
4164 */ |
|
4165 |
|
4166 function mapBlockOrder(blocks) { |
|
4167 var rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; |
|
4168 |
|
4169 var result = Object(defineProperty["a" /* default */])({}, rootClientId, []); |
|
4170 |
|
4171 blocks.forEach(function (block) { |
|
4172 var clientId = block.clientId, |
|
4173 innerBlocks = block.innerBlocks; |
|
4174 result[rootClientId].push(clientId); |
|
4175 Object.assign(result, mapBlockOrder(innerBlocks, clientId)); |
|
4176 }); |
|
4177 return result; |
|
4178 } |
|
4179 /** |
|
4180 * Helper method to iterate through all blocks, recursing into inner blocks, |
|
4181 * applying a transformation function to each one. |
|
4182 * Returns a flattened object with the transformed blocks. |
|
4183 * |
|
4184 * @param {Array} blocks Blocks to flatten. |
|
4185 * @param {Function} transform Transforming function to be applied to each block. |
|
4186 * |
|
4187 * @return {Object} Flattened object. |
|
4188 */ |
|
4189 |
|
4190 |
|
4191 function flattenBlocks(blocks, transform) { |
|
4192 var result = {}; |
|
4193 |
|
4194 var stack = Object(toConsumableArray["a" /* default */])(blocks); |
|
4195 |
|
4196 while (stack.length) { |
|
4197 var _stack$shift = stack.shift(), |
|
4198 innerBlocks = _stack$shift.innerBlocks, |
|
4199 block = Object(objectWithoutProperties["a" /* default */])(_stack$shift, ["innerBlocks"]); |
|
4200 |
|
4201 stack.push.apply(stack, Object(toConsumableArray["a" /* default */])(innerBlocks)); |
|
4202 result[block.clientId] = transform(block); |
|
4203 } |
|
4204 |
|
4205 return result; |
|
4206 } |
|
4207 /** |
|
4208 * Given an array of blocks, returns an object containing all blocks, without |
|
4209 * attributes, recursing into inner blocks. Keys correspond to the block client |
|
4210 * ID, the value of which is the attributes object. |
|
4211 * |
|
4212 * @param {Array} blocks Blocks to flatten. |
|
4213 * |
|
4214 * @return {Object} Flattened block attributes object. |
|
4215 */ |
|
4216 |
|
4217 |
|
4218 function getFlattenedBlocksWithoutAttributes(blocks) { |
|
4219 return flattenBlocks(blocks, function (block) { |
|
4220 return Object(external_lodash_["omit"])(block, 'attributes'); |
|
4221 }); |
|
4222 } |
|
4223 /** |
|
4224 * Given an array of blocks, returns an object containing all block attributes, |
|
4225 * recursing into inner blocks. Keys correspond to the block client ID, the |
|
4226 * value of which is the attributes object. |
|
4227 * |
|
4228 * @param {Array} blocks Blocks to flatten. |
|
4229 * |
|
4230 * @return {Object} Flattened block attributes object. |
|
4231 */ |
|
4232 |
|
4233 |
|
4234 function getFlattenedBlockAttributes(blocks) { |
|
4235 return flattenBlocks(blocks, function (block) { |
|
4236 return block.attributes; |
|
4237 }); |
|
4238 } |
|
4239 /** |
|
4240 * Given a block order map object, returns *all* of the block client IDs that are |
|
4241 * a descendant of the given root client ID. |
|
4242 * |
|
4243 * Calling this with `rootClientId` set to `''` results in a list of client IDs |
|
4244 * that are in the post. That is, it excludes blocks like fetched reusable |
|
4245 * blocks which are stored into state but not visible. |
|
4246 * |
|
4247 * @param {Object} blocksOrder Object that maps block client IDs to a list of |
|
4248 * nested block client IDs. |
|
4249 * @param {?string} rootClientId The root client ID to search. Defaults to ''. |
|
4250 * |
|
4251 * @return {Array} List of descendant client IDs. |
|
4252 */ |
|
4253 |
|
4254 |
|
4255 function getNestedBlockClientIds(blocksOrder) { |
|
4256 var rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; |
|
4257 return Object(external_lodash_["reduce"])(blocksOrder[rootClientId], function (result, clientId) { |
|
4258 return [].concat(Object(toConsumableArray["a" /* default */])(result), [clientId], Object(toConsumableArray["a" /* default */])(getNestedBlockClientIds(blocksOrder, clientId))); |
|
4259 }, []); |
|
4260 } |
|
4261 /** |
|
4262 * Returns an object against which it is safe to perform mutating operations, |
|
4263 * given the original object and its current working copy. |
|
4264 * |
|
4265 * @param {Object} original Original object. |
|
4266 * @param {Object} working Working object. |
|
4267 * |
|
4268 * @return {Object} Mutation-safe object. |
|
4269 */ |
|
4270 |
|
4271 |
|
4272 function getMutateSafeObject(original, working) { |
|
4273 if (original === working) { |
|
4274 return Object(objectSpread["a" /* default */])({}, original); |
|
4275 } |
|
4276 |
|
4277 return working; |
|
4278 } |
|
4279 /** |
|
4280 * Returns true if the two object arguments have the same keys, or false |
|
4281 * otherwise. |
|
4282 * |
|
4283 * @param {Object} a First object. |
|
4284 * @param {Object} b Second object. |
|
4285 * |
|
4286 * @return {boolean} Whether the two objects have the same keys. |
|
4287 */ |
|
4288 |
|
4289 |
|
4290 function hasSameKeys(a, b) { |
|
4291 return Object(external_lodash_["isEqual"])(Object(external_lodash_["keys"])(a), Object(external_lodash_["keys"])(b)); |
|
4292 } |
|
4293 /** |
|
4294 * Returns true if, given the currently dispatching action and the previously |
|
4295 * dispatched action, the two actions are updating the same block attribute, or |
|
4296 * false otherwise. |
|
4297 * |
|
4298 * @param {Object} action Currently dispatching action. |
|
4299 * @param {Object} lastAction Previously dispatched action. |
|
4300 * |
|
4301 * @return {boolean} Whether actions are updating the same block attribute. |
|
4302 */ |
|
4303 |
|
4304 function isUpdatingSameBlockAttribute(action, lastAction) { |
|
4305 return action.type === 'UPDATE_BLOCK_ATTRIBUTES' && lastAction !== undefined && lastAction.type === 'UPDATE_BLOCK_ATTRIBUTES' && action.clientId === lastAction.clientId && hasSameKeys(action.attributes, lastAction.attributes); |
|
4306 } |
|
4307 /** |
|
4308 * Higher-order reducer intended to augment the blocks reducer, assigning an |
|
4309 * `isPersistentChange` property value corresponding to whether a change in |
|
4310 * state can be considered as persistent. All changes are considered persistent |
|
4311 * except when updating the same block attribute as in the previous action. |
|
4312 * |
|
4313 * @param {Function} reducer Original reducer function. |
|
4314 * |
|
4315 * @return {Function} Enhanced reducer function. |
|
4316 */ |
|
4317 |
|
4318 function withPersistentBlockChange(reducer) { |
|
4319 var lastAction; |
|
4320 return function (state, action) { |
|
4321 var nextState = reducer(state, action); |
|
4322 var isExplicitPersistentChange = action.type === 'MARK_LAST_CHANGE_AS_PERSISTENT'; // Defer to previous state value (or default) unless changing or |
|
4323 // explicitly marking as persistent. |
|
4324 |
|
4325 if (state === nextState && !isExplicitPersistentChange) { |
|
4326 var nextIsPersistentChange = Object(external_lodash_["get"])(state, ['isPersistentChange'], true); |
|
4327 |
|
4328 if (state.isPersistentChange === nextIsPersistentChange) { |
|
4329 return state; |
|
4330 } |
|
4331 |
|
4332 return Object(objectSpread["a" /* default */])({}, nextState, { |
|
4333 isPersistentChange: nextIsPersistentChange |
|
4334 }); |
|
4335 } |
|
4336 |
|
4337 nextState = Object(objectSpread["a" /* default */])({}, nextState, { |
|
4338 isPersistentChange: isExplicitPersistentChange || !isUpdatingSameBlockAttribute(action, lastAction) |
|
4339 }); // In comparing against the previous action, consider only those which |
|
4340 // would have qualified as one which would have been ignored or not |
|
4341 // have resulted in a changed state. |
|
4342 |
|
4343 lastAction = action; |
|
4344 return nextState; |
|
4345 }; |
|
4346 } |
|
4347 /** |
|
4348 * Higher-order reducer intended to augment the blocks reducer, assigning an |
|
4349 * `isIgnoredChange` property value corresponding to whether a change in state |
|
4350 * can be considered as ignored. A change is considered ignored when the result |
|
4351 * of an action not incurred by direct user interaction. |
|
4352 * |
|
4353 * @param {Function} reducer Original reducer function. |
|
4354 * |
|
4355 * @return {Function} Enhanced reducer function. |
|
4356 */ |
|
4357 |
|
4358 |
|
4359 function withIgnoredBlockChange(reducer) { |
|
4360 /** |
|
4361 * Set of action types for which a blocks state change should be ignored. |
|
4362 * |
|
4363 * @type {Set} |
|
4364 */ |
|
4365 var IGNORED_ACTION_TYPES = new Set(['RECEIVE_BLOCKS']); |
|
4366 return function (state, action) { |
|
4367 var nextState = reducer(state, action); |
|
4368 |
|
4369 if (nextState !== state) { |
|
4370 nextState.isIgnoredChange = IGNORED_ACTION_TYPES.has(action.type); |
|
4371 } |
|
4372 |
|
4373 return nextState; |
|
4374 }; |
|
4375 } |
|
4376 /** |
|
4377 * Higher-order reducer targeting the combined blocks reducer, augmenting |
|
4378 * block client IDs in remove action to include cascade of inner blocks. |
|
4379 * |
|
4380 * @param {Function} reducer Original reducer function. |
|
4381 * |
|
4382 * @return {Function} Enhanced reducer function. |
|
4383 */ |
|
4384 |
|
4385 |
|
4386 var reducer_withInnerBlocksRemoveCascade = function withInnerBlocksRemoveCascade(reducer) { |
|
4387 return function (state, action) { |
|
4388 if (state && action.type === 'REMOVE_BLOCKS') { |
|
4389 var clientIds = Object(toConsumableArray["a" /* default */])(action.clientIds); // For each removed client ID, include its inner blocks to remove, |
|
4390 // recursing into those so long as inner blocks exist. |
|
4391 |
|
4392 |
|
4393 for (var i = 0; i < clientIds.length; i++) { |
|
4394 clientIds.push.apply(clientIds, Object(toConsumableArray["a" /* default */])(state.order[clientIds[i]])); |
|
4395 } |
|
4396 |
|
4397 action = Object(objectSpread["a" /* default */])({}, action, { |
|
4398 clientIds: clientIds |
|
4399 }); |
|
4400 } |
|
4401 |
|
4402 return reducer(state, action); |
|
4403 }; |
|
4404 }; |
|
4405 /** |
|
4406 * Higher-order reducer which targets the combined blocks reducer and handles |
|
4407 * the `RESET_BLOCKS` action. When dispatched, this action will replace all |
|
4408 * blocks that exist in the post, leaving blocks that exist only in state (e.g. |
|
4409 * reusable blocks) alone. |
|
4410 * |
|
4411 * @param {Function} reducer Original reducer function. |
|
4412 * |
|
4413 * @return {Function} Enhanced reducer function. |
|
4414 */ |
|
4415 |
|
4416 |
|
4417 var reducer_withBlockReset = function withBlockReset(reducer) { |
|
4418 return function (state, action) { |
|
4419 if (state && action.type === 'RESET_BLOCKS') { |
|
4420 var visibleClientIds = getNestedBlockClientIds(state.order); |
|
4421 return Object(objectSpread["a" /* default */])({}, state, { |
|
4422 byClientId: Object(objectSpread["a" /* default */])({}, Object(external_lodash_["omit"])(state.byClientId, visibleClientIds), getFlattenedBlocksWithoutAttributes(action.blocks)), |
|
4423 attributes: Object(objectSpread["a" /* default */])({}, Object(external_lodash_["omit"])(state.attributes, visibleClientIds), getFlattenedBlockAttributes(action.blocks)), |
|
4424 order: Object(objectSpread["a" /* default */])({}, Object(external_lodash_["omit"])(state.order, visibleClientIds), mapBlockOrder(action.blocks)) |
|
4425 }); |
|
4426 } |
|
4427 |
|
4428 return reducer(state, action); |
|
4429 }; |
|
4430 }; |
|
4431 /** |
|
4432 * Higher-order reducer which targets the combined blocks reducer and handles |
|
4433 * the `REPLACE_INNER_BLOCKS` action. When dispatched, this action the state should become equivalent |
|
4434 * to the execution of a `REMOVE_BLOCKS` action containing all the child's of the root block followed by |
|
4435 * the execution of `INSERT_BLOCKS` with the new blocks. |
|
4436 * |
|
4437 * @param {Function} reducer Original reducer function. |
|
4438 * |
|
4439 * @return {Function} Enhanced reducer function. |
|
4440 */ |
|
4441 |
|
4442 |
|
4443 var reducer_withReplaceInnerBlocks = function withReplaceInnerBlocks(reducer) { |
|
4444 return function (state, action) { |
|
4445 if (action.type !== 'REPLACE_INNER_BLOCKS') { |
|
4446 return reducer(state, action); |
|
4447 } |
|
4448 |
|
4449 var stateAfterBlocksRemoval = state; |
|
4450 |
|
4451 if (state.order[action.rootClientId]) { |
|
4452 stateAfterBlocksRemoval = reducer(stateAfterBlocksRemoval, { |
|
4453 type: 'REMOVE_BLOCKS', |
|
4454 clientIds: state.order[action.rootClientId] |
|
4455 }); |
|
4456 } |
|
4457 |
|
4458 var stateAfterInsert = stateAfterBlocksRemoval; |
|
4459 |
|
4460 if (action.blocks.length) { |
|
4461 stateAfterInsert = reducer(stateAfterInsert, Object(objectSpread["a" /* default */])({}, action, { |
|
4462 type: 'INSERT_BLOCKS', |
|
4463 index: 0 |
|
4464 })); |
|
4465 } |
|
4466 |
|
4467 return stateAfterInsert; |
|
4468 }; |
|
4469 }; |
|
4470 /** |
|
4471 * Higher-order reducer which targets the combined blocks reducer and handles |
|
4472 * the `SAVE_REUSABLE_BLOCK_SUCCESS` action. This action can't be handled by |
|
4473 * regular reducers and needs a higher-order reducer since it needs access to |
|
4474 * both `byClientId` and `attributes` simultaneously. |
|
4475 * |
|
4476 * @param {Function} reducer Original reducer function. |
|
4477 * |
|
4478 * @return {Function} Enhanced reducer function. |
|
4479 */ |
|
4480 |
|
4481 |
|
4482 var reducer_withSaveReusableBlock = function withSaveReusableBlock(reducer) { |
|
4483 return function (state, action) { |
|
4484 if (state && action.type === 'SAVE_REUSABLE_BLOCK_SUCCESS') { |
|
4485 var id = action.id, |
|
4486 updatedId = action.updatedId; // If a temporary reusable block is saved, we swap the temporary id with the final one |
|
4487 |
|
4488 if (id === updatedId) { |
|
4489 return state; |
|
4490 } |
|
4491 |
|
4492 state = Object(objectSpread["a" /* default */])({}, state); |
|
4493 state.attributes = Object(external_lodash_["mapValues"])(state.attributes, function (attributes, clientId) { |
|
4494 var name = state.byClientId[clientId].name; |
|
4495 |
|
4496 if (name === 'core/block' && attributes.ref === id) { |
|
4497 return Object(objectSpread["a" /* default */])({}, attributes, { |
|
4498 ref: updatedId |
|
4499 }); |
|
4500 } |
|
4501 |
|
4502 return attributes; |
|
4503 }); |
|
4504 } |
|
4505 |
|
4506 return reducer(state, action); |
|
4507 }; |
|
4508 }; |
|
4509 /** |
|
4510 * Reducer returning the blocks state. |
|
4511 * |
|
4512 * @param {Object} state Current state. |
|
4513 * @param {Object} action Dispatched action. |
|
4514 * |
|
4515 * @returns {Object} Updated state. |
|
4516 */ |
|
4517 |
|
4518 |
|
4519 var reducer_blocks = Object(external_lodash_["flow"])(external_this_wp_data_["combineReducers"], reducer_withInnerBlocksRemoveCascade, reducer_withReplaceInnerBlocks, // needs to be after withInnerBlocksRemoveCascade |
|
4520 reducer_withBlockReset, reducer_withSaveReusableBlock, withPersistentBlockChange, withIgnoredBlockChange)({ |
|
4521 byClientId: function byClientId() { |
|
4522 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
4523 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
4524 |
|
4525 switch (action.type) { |
|
4526 case 'RESET_BLOCKS': |
|
4527 return getFlattenedBlocksWithoutAttributes(action.blocks); |
|
4528 |
|
4529 case 'RECEIVE_BLOCKS': |
|
4530 return Object(objectSpread["a" /* default */])({}, state, getFlattenedBlocksWithoutAttributes(action.blocks)); |
|
4531 |
|
4532 case 'UPDATE_BLOCK': |
|
4533 // Ignore updates if block isn't known |
|
4534 if (!state[action.clientId]) { |
|
4535 return state; |
|
4536 } // Do nothing if only attributes change. |
|
4537 |
|
4538 |
|
4539 var changes = Object(external_lodash_["omit"])(action.updates, 'attributes'); |
|
4540 |
|
4541 if (Object(external_lodash_["isEmpty"])(changes)) { |
|
4542 return state; |
|
4543 } |
|
4544 |
|
4545 return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, action.clientId, Object(objectSpread["a" /* default */])({}, state[action.clientId], changes))); |
|
4546 |
|
4547 case 'INSERT_BLOCKS': |
|
4548 return Object(objectSpread["a" /* default */])({}, state, getFlattenedBlocksWithoutAttributes(action.blocks)); |
|
4549 |
|
4550 case 'REPLACE_BLOCKS': |
|
4551 if (!action.blocks) { |
|
4552 return state; |
|
4553 } |
|
4554 |
|
4555 return Object(objectSpread["a" /* default */])({}, Object(external_lodash_["omit"])(state, action.clientIds), getFlattenedBlocksWithoutAttributes(action.blocks)); |
|
4556 |
|
4557 case 'REMOVE_BLOCKS': |
|
4558 return Object(external_lodash_["omit"])(state, action.clientIds); |
|
4559 } |
|
4560 |
|
4561 return state; |
|
4562 }, |
|
4563 attributes: function attributes() { |
|
4564 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
4565 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
4566 |
|
4567 switch (action.type) { |
|
4568 case 'RESET_BLOCKS': |
|
4569 return getFlattenedBlockAttributes(action.blocks); |
|
4570 |
|
4571 case 'RECEIVE_BLOCKS': |
|
4572 return Object(objectSpread["a" /* default */])({}, state, getFlattenedBlockAttributes(action.blocks)); |
|
4573 |
|
4574 case 'UPDATE_BLOCK': |
|
4575 // Ignore updates if block isn't known or there are no attribute changes. |
|
4576 if (!state[action.clientId] || !action.updates.attributes) { |
|
4577 return state; |
|
4578 } |
|
4579 |
|
4580 return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, action.clientId, Object(objectSpread["a" /* default */])({}, state[action.clientId], action.updates.attributes))); |
|
4581 |
|
4582 case 'UPDATE_BLOCK_ATTRIBUTES': |
|
4583 // Ignore updates if block isn't known |
|
4584 if (!state[action.clientId]) { |
|
4585 return state; |
|
4586 } // Consider as updates only changed values |
|
4587 |
|
4588 |
|
4589 var nextAttributes = Object(external_lodash_["reduce"])(action.attributes, function (result, value, key) { |
|
4590 if (value !== result[key]) { |
|
4591 result = getMutateSafeObject(state[action.clientId], result); |
|
4592 result[key] = value; |
|
4593 } |
|
4594 |
|
4595 return result; |
|
4596 }, state[action.clientId]); // Skip update if nothing has been changed. The reference will |
|
4597 // match the original block if `reduce` had no changed values. |
|
4598 |
|
4599 if (nextAttributes === state[action.clientId]) { |
|
4600 return state; |
|
4601 } // Otherwise replace attributes in state |
|
4602 |
|
4603 |
|
4604 return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, action.clientId, nextAttributes)); |
|
4605 |
|
4606 case 'INSERT_BLOCKS': |
|
4607 return Object(objectSpread["a" /* default */])({}, state, getFlattenedBlockAttributes(action.blocks)); |
|
4608 |
|
4609 case 'REPLACE_BLOCKS': |
|
4610 if (!action.blocks) { |
|
4611 return state; |
|
4612 } |
|
4613 |
|
4614 return Object(objectSpread["a" /* default */])({}, Object(external_lodash_["omit"])(state, action.clientIds), getFlattenedBlockAttributes(action.blocks)); |
|
4615 |
|
4616 case 'REMOVE_BLOCKS': |
|
4617 return Object(external_lodash_["omit"])(state, action.clientIds); |
|
4618 } |
|
4619 |
|
4620 return state; |
|
4621 }, |
|
4622 order: function order() { |
|
4623 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
4624 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
4625 |
|
4626 switch (action.type) { |
|
4627 case 'RESET_BLOCKS': |
|
4628 return mapBlockOrder(action.blocks); |
|
4629 |
|
4630 case 'RECEIVE_BLOCKS': |
|
4631 return Object(objectSpread["a" /* default */])({}, state, Object(external_lodash_["omit"])(mapBlockOrder(action.blocks), '')); |
|
4632 |
|
4633 case 'INSERT_BLOCKS': |
|
4634 { |
|
4635 var _action$rootClientId = action.rootClientId, |
|
4636 rootClientId = _action$rootClientId === void 0 ? '' : _action$rootClientId; |
|
4637 var subState = state[rootClientId] || []; |
|
4638 var mappedBlocks = mapBlockOrder(action.blocks, rootClientId); |
|
4639 var _action$index = action.index, |
|
4640 index = _action$index === void 0 ? subState.length : _action$index; |
|
4641 return Object(objectSpread["a" /* default */])({}, state, mappedBlocks, Object(defineProperty["a" /* default */])({}, rootClientId, insertAt(subState, mappedBlocks[rootClientId], index))); |
|
4642 } |
|
4643 |
|
4644 case 'MOVE_BLOCK_TO_POSITION': |
|
4645 { |
|
4646 var _objectSpread7; |
|
4647 |
|
4648 var _action$fromRootClien = action.fromRootClientId, |
|
4649 fromRootClientId = _action$fromRootClien === void 0 ? '' : _action$fromRootClien, |
|
4650 _action$toRootClientI = action.toRootClientId, |
|
4651 toRootClientId = _action$toRootClientI === void 0 ? '' : _action$toRootClientI, |
|
4652 clientId = action.clientId; |
|
4653 |
|
4654 var _action$index2 = action.index, |
|
4655 _index = _action$index2 === void 0 ? state[toRootClientId].length : _action$index2; // Moving inside the same parent block |
|
4656 |
|
4657 |
|
4658 if (fromRootClientId === toRootClientId) { |
|
4659 var _subState = state[toRootClientId]; |
|
4660 |
|
4661 var fromIndex = _subState.indexOf(clientId); |
|
4662 |
|
4663 return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, toRootClientId, moveTo(state[toRootClientId], fromIndex, _index))); |
|
4664 } // Moving from a parent block to another |
|
4665 |
|
4666 |
|
4667 return Object(objectSpread["a" /* default */])({}, state, (_objectSpread7 = {}, Object(defineProperty["a" /* default */])(_objectSpread7, fromRootClientId, Object(external_lodash_["without"])(state[fromRootClientId], clientId)), Object(defineProperty["a" /* default */])(_objectSpread7, toRootClientId, insertAt(state[toRootClientId], clientId, _index)), _objectSpread7)); |
|
4668 } |
|
4669 |
|
4670 case 'MOVE_BLOCKS_UP': |
|
4671 { |
|
4672 var clientIds = action.clientIds, |
|
4673 _action$rootClientId2 = action.rootClientId, |
|
4674 _rootClientId = _action$rootClientId2 === void 0 ? '' : _action$rootClientId2; |
|
4675 |
|
4676 var firstClientId = Object(external_lodash_["first"])(clientIds); |
|
4677 var _subState2 = state[_rootClientId]; |
|
4678 |
|
4679 if (!_subState2.length || firstClientId === Object(external_lodash_["first"])(_subState2)) { |
|
4680 return state; |
|
4681 } |
|
4682 |
|
4683 var firstIndex = _subState2.indexOf(firstClientId); |
|
4684 |
|
4685 return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, _rootClientId, moveTo(_subState2, firstIndex, firstIndex - 1, clientIds.length))); |
|
4686 } |
|
4687 |
|
4688 case 'MOVE_BLOCKS_DOWN': |
|
4689 { |
|
4690 var _clientIds = action.clientIds, |
|
4691 _action$rootClientId3 = action.rootClientId, |
|
4692 _rootClientId2 = _action$rootClientId3 === void 0 ? '' : _action$rootClientId3; |
|
4693 |
|
4694 var _firstClientId = Object(external_lodash_["first"])(_clientIds); |
|
4695 |
|
4696 var lastClientId = Object(external_lodash_["last"])(_clientIds); |
|
4697 var _subState3 = state[_rootClientId2]; |
|
4698 |
|
4699 if (!_subState3.length || lastClientId === Object(external_lodash_["last"])(_subState3)) { |
|
4700 return state; |
|
4701 } |
|
4702 |
|
4703 var _firstIndex = _subState3.indexOf(_firstClientId); |
|
4704 |
|
4705 return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, _rootClientId2, moveTo(_subState3, _firstIndex, _firstIndex + 1, _clientIds.length))); |
|
4706 } |
|
4707 |
|
4708 case 'REPLACE_BLOCKS': |
|
4709 { |
|
4710 var _clientIds2 = action.clientIds; |
|
4711 |
|
4712 if (!action.blocks) { |
|
4713 return state; |
|
4714 } |
|
4715 |
|
4716 var _mappedBlocks = mapBlockOrder(action.blocks); |
|
4717 |
|
4718 return Object(external_lodash_["flow"])([function (nextState) { |
|
4719 return Object(external_lodash_["omit"])(nextState, _clientIds2); |
|
4720 }, function (nextState) { |
|
4721 return Object(objectSpread["a" /* default */])({}, nextState, Object(external_lodash_["omit"])(_mappedBlocks, '')); |
|
4722 }, function (nextState) { |
|
4723 return Object(external_lodash_["mapValues"])(nextState, function (subState) { |
|
4724 return Object(external_lodash_["reduce"])(subState, function (result, clientId) { |
|
4725 if (clientId === _clientIds2[0]) { |
|
4726 return [].concat(Object(toConsumableArray["a" /* default */])(result), Object(toConsumableArray["a" /* default */])(_mappedBlocks[''])); |
|
4727 } |
|
4728 |
|
4729 if (_clientIds2.indexOf(clientId) === -1) { |
|
4730 result.push(clientId); |
|
4731 } |
|
4732 |
|
4733 return result; |
|
4734 }, []); |
|
4735 }); |
|
4736 }])(state); |
|
4737 } |
|
4738 |
|
4739 case 'REMOVE_BLOCKS': |
|
4740 return Object(external_lodash_["flow"])([// Remove inner block ordering for removed blocks |
|
4741 function (nextState) { |
|
4742 return Object(external_lodash_["omit"])(nextState, action.clientIds); |
|
4743 }, // Remove deleted blocks from other blocks' orderings |
|
4744 function (nextState) { |
|
4745 return Object(external_lodash_["mapValues"])(nextState, function (subState) { |
|
4746 return external_lodash_["without"].apply(void 0, [subState].concat(Object(toConsumableArray["a" /* default */])(action.clientIds))); |
|
4747 }); |
|
4748 }])(state); |
|
4749 } |
|
4750 |
|
4751 return state; |
|
4752 } |
|
4753 }); |
|
4754 /** |
|
4755 * Reducer returning typing state. |
|
4756 * |
|
4757 * @param {boolean} state Current state. |
|
4758 * @param {Object} action Dispatched action. |
|
4759 * |
|
4760 * @return {boolean} Updated state. |
|
4761 */ |
|
4762 |
|
4763 function reducer_isTyping() { |
|
4764 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
|
4765 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
4766 |
|
4767 switch (action.type) { |
|
4768 case 'START_TYPING': |
|
4769 return true; |
|
4770 |
|
4771 case 'STOP_TYPING': |
|
4772 return false; |
|
4773 } |
|
4774 |
|
4775 return state; |
|
4776 } |
|
4777 /** |
|
4778 * Reducer returning whether the caret is within formatted text. |
|
4779 * |
|
4780 * @param {boolean} state Current state. |
|
4781 * @param {Object} action Dispatched action. |
|
4782 * |
|
4783 * @return {boolean} Updated state. |
|
4784 */ |
|
4785 |
|
4786 function reducer_isCaretWithinFormattedText() { |
|
4787 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
|
4788 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
4789 |
|
4790 switch (action.type) { |
|
4791 case 'ENTER_FORMATTED_TEXT': |
|
4792 return true; |
|
4793 |
|
4794 case 'EXIT_FORMATTED_TEXT': |
|
4795 return false; |
|
4796 } |
|
4797 |
|
4798 return state; |
|
4799 } |
|
4800 /** |
|
4801 * Reducer returning the block selection's state. |
|
4802 * |
|
4803 * @param {Object} state Current state. |
|
4804 * @param {Object} action Dispatched action. |
|
4805 * |
|
4806 * @return {Object} Updated state. |
|
4807 */ |
|
4808 |
|
4809 function blockSelection() { |
|
4810 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { |
|
4811 start: null, |
|
4812 end: null, |
|
4813 isMultiSelecting: false, |
|
4814 isEnabled: true, |
|
4815 initialPosition: null |
|
4816 }; |
|
4817 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
4818 |
|
4819 switch (action.type) { |
|
4820 case 'CLEAR_SELECTED_BLOCK': |
|
4821 if (state.start === null && state.end === null && !state.isMultiSelecting) { |
|
4822 return state; |
|
4823 } |
|
4824 |
|
4825 return Object(objectSpread["a" /* default */])({}, state, { |
|
4826 start: null, |
|
4827 end: null, |
|
4828 isMultiSelecting: false, |
|
4829 initialPosition: null |
|
4830 }); |
|
4831 |
|
4832 case 'START_MULTI_SELECT': |
|
4833 if (state.isMultiSelecting) { |
|
4834 return state; |
|
4835 } |
|
4836 |
|
4837 return Object(objectSpread["a" /* default */])({}, state, { |
|
4838 isMultiSelecting: true, |
|
4839 initialPosition: null |
|
4840 }); |
|
4841 |
|
4842 case 'STOP_MULTI_SELECT': |
|
4843 if (!state.isMultiSelecting) { |
|
4844 return state; |
|
4845 } |
|
4846 |
|
4847 return Object(objectSpread["a" /* default */])({}, state, { |
|
4848 isMultiSelecting: false, |
|
4849 initialPosition: null |
|
4850 }); |
|
4851 |
|
4852 case 'MULTI_SELECT': |
|
4853 return Object(objectSpread["a" /* default */])({}, state, { |
|
4854 start: action.start, |
|
4855 end: action.end, |
|
4856 initialPosition: null |
|
4857 }); |
|
4858 |
|
4859 case 'SELECT_BLOCK': |
|
4860 if (action.clientId === state.start && action.clientId === state.end) { |
|
4861 return state; |
|
4862 } |
|
4863 |
|
4864 return Object(objectSpread["a" /* default */])({}, state, { |
|
4865 start: action.clientId, |
|
4866 end: action.clientId, |
|
4867 initialPosition: action.initialPosition |
|
4868 }); |
|
4869 |
|
4870 case 'REPLACE_INNER_BLOCKS': // REPLACE_INNER_BLOCKS and INSERT_BLOCKS should follow the same logic. |
|
4871 |
|
4872 case 'INSERT_BLOCKS': |
|
4873 { |
|
4874 if (action.updateSelection) { |
|
4875 return Object(objectSpread["a" /* default */])({}, state, { |
|
4876 start: action.blocks[0].clientId, |
|
4877 end: action.blocks[0].clientId, |
|
4878 initialPosition: null, |
|
4879 isMultiSelecting: false |
|
4880 }); |
|
4881 } |
|
4882 |
|
4883 return state; |
|
4884 } |
|
4885 |
|
4886 case 'REMOVE_BLOCKS': |
|
4887 if (!action.clientIds || !action.clientIds.length || action.clientIds.indexOf(state.start) === -1) { |
|
4888 return state; |
|
4889 } |
|
4890 |
|
4891 return Object(objectSpread["a" /* default */])({}, state, { |
|
4892 start: null, |
|
4893 end: null, |
|
4894 initialPosition: null, |
|
4895 isMultiSelecting: false |
|
4896 }); |
|
4897 |
|
4898 case 'REPLACE_BLOCKS': |
|
4899 if (action.clientIds.indexOf(state.start) === -1) { |
|
4900 return state; |
|
4901 } // If there are replacement blocks, assign last block as the next |
|
4902 // selected block, otherwise set to null. |
|
4903 |
|
4904 |
|
4905 var lastBlock = Object(external_lodash_["last"])(action.blocks); |
|
4906 var nextSelectedBlockClientId = lastBlock ? lastBlock.clientId : null; |
|
4907 |
|
4908 if (nextSelectedBlockClientId === state.start && nextSelectedBlockClientId === state.end) { |
|
4909 return state; |
|
4910 } |
|
4911 |
|
4912 return Object(objectSpread["a" /* default */])({}, state, { |
|
4913 start: nextSelectedBlockClientId, |
|
4914 end: nextSelectedBlockClientId, |
|
4915 initialPosition: null, |
|
4916 isMultiSelecting: false |
|
4917 }); |
|
4918 |
|
4919 case 'TOGGLE_SELECTION': |
|
4920 return Object(objectSpread["a" /* default */])({}, state, { |
|
4921 isEnabled: action.isSelectionEnabled |
|
4922 }); |
|
4923 } |
|
4924 |
|
4925 return state; |
|
4926 } |
|
4927 function blocksMode() { |
|
4928 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
4929 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
4930 |
|
4931 if (action.type === 'TOGGLE_BLOCK_MODE') { |
|
4932 var clientId = action.clientId; |
|
4933 return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, clientId, state[clientId] && state[clientId] === 'html' ? 'visual' : 'html')); |
|
4934 } |
|
4935 |
|
4936 return state; |
|
4937 } |
|
4938 /** |
|
4939 * Reducer returning the block insertion point visibility, either null if there |
|
4940 * is not an explicit insertion point assigned, or an object of its `index` and |
|
4941 * `rootClientId`. |
|
4942 * |
|
4943 * @param {Object} state Current state. |
|
4944 * @param {Object} action Dispatched action. |
|
4945 * |
|
4946 * @return {Object} Updated state. |
|
4947 */ |
|
4948 |
|
4949 function insertionPoint() { |
|
4950 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; |
|
4951 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
4952 |
|
4953 switch (action.type) { |
|
4954 case 'SHOW_INSERTION_POINT': |
|
4955 var rootClientId = action.rootClientId, |
|
4956 index = action.index; |
|
4957 return { |
|
4958 rootClientId: rootClientId, |
|
4959 index: index |
|
4960 }; |
|
4961 |
|
4962 case 'HIDE_INSERTION_POINT': |
|
4963 return null; |
|
4964 } |
|
4965 |
|
4966 return state; |
|
4967 } |
|
4968 /** |
|
4969 * Reducer returning whether the post blocks match the defined template or not. |
|
4970 * |
|
4971 * @param {Object} state Current state. |
|
4972 * @param {Object} action Dispatched action. |
|
4973 * |
|
4974 * @return {boolean} Updated state. |
|
4975 */ |
|
4976 |
|
4977 function reducer_template() { |
|
4978 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { |
|
4979 isValid: true |
|
4980 }; |
|
4981 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
4982 |
|
4983 switch (action.type) { |
|
4984 case 'SET_TEMPLATE_VALIDITY': |
|
4985 return Object(objectSpread["a" /* default */])({}, state, { |
|
4986 isValid: action.isValid |
|
4987 }); |
|
4988 } |
|
4989 |
|
4990 return state; |
|
4991 } |
|
4992 /** |
|
4993 * Reducer returning the editor setting. |
|
4994 * |
|
4995 * @param {Object} state Current state. |
|
4996 * @param {Object} action Dispatched action. |
|
4997 * |
|
4998 * @return {Object} Updated state. |
|
4999 */ |
|
5000 |
|
5001 function reducer_settings() { |
|
5002 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SETTINGS_DEFAULTS; |
|
5003 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
5004 |
|
5005 switch (action.type) { |
|
5006 case 'UPDATE_SETTINGS': |
|
5007 return Object(objectSpread["a" /* default */])({}, state, action.settings); |
|
5008 } |
|
5009 |
|
5010 return state; |
|
5011 } |
|
5012 /** |
|
5013 * Reducer returning the user preferences. |
|
5014 * |
|
5015 * @param {Object} state Current state. |
|
5016 * @param {Object} action Dispatched action. |
|
5017 * |
|
5018 * @return {string} Updated state. |
|
5019 */ |
|
5020 |
|
5021 function preferences() { |
|
5022 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : PREFERENCES_DEFAULTS; |
|
5023 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
5024 |
|
5025 switch (action.type) { |
|
5026 case 'INSERT_BLOCKS': |
|
5027 case 'REPLACE_BLOCKS': |
|
5028 return action.blocks.reduce(function (prevState, block) { |
|
5029 var id = block.name; |
|
5030 var insert = { |
|
5031 name: block.name |
|
5032 }; |
|
5033 |
|
5034 if (Object(external_this_wp_blocks_["isReusableBlock"])(block)) { |
|
5035 insert.ref = block.attributes.ref; |
|
5036 id += '/' + block.attributes.ref; |
|
5037 } |
|
5038 |
|
5039 return Object(objectSpread["a" /* default */])({}, prevState, { |
|
5040 insertUsage: Object(objectSpread["a" /* default */])({}, prevState.insertUsage, Object(defineProperty["a" /* default */])({}, id, { |
|
5041 time: action.time, |
|
5042 count: prevState.insertUsage[id] ? prevState.insertUsage[id].count + 1 : 1, |
|
5043 insert: insert |
|
5044 })) |
|
5045 }); |
|
5046 }, state); |
|
5047 } |
|
5048 |
|
5049 return state; |
|
5050 } |
|
5051 /** |
|
5052 * Reducer returning an object where each key is a block client ID, its value |
|
5053 * representing the settings for its nested blocks. |
|
5054 * |
|
5055 * @param {Object} state Current state. |
|
5056 * @param {Object} action Dispatched action. |
|
5057 * |
|
5058 * @return {Object} Updated state. |
|
5059 */ |
|
5060 |
|
5061 var reducer_blockListSettings = function blockListSettings() { |
|
5062 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
5063 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
5064 |
|
5065 switch (action.type) { |
|
5066 // Even if the replaced blocks have the same client ID, our logic |
|
5067 // should correct the state. |
|
5068 case 'REPLACE_BLOCKS': |
|
5069 case 'REMOVE_BLOCKS': |
|
5070 { |
|
5071 return Object(external_lodash_["omit"])(state, action.clientIds); |
|
5072 } |
|
5073 |
|
5074 case 'UPDATE_BLOCK_LIST_SETTINGS': |
|
5075 { |
|
5076 var clientId = action.clientId; |
|
5077 |
|
5078 if (!action.settings) { |
|
5079 if (state.hasOwnProperty(clientId)) { |
|
5080 return Object(external_lodash_["omit"])(state, clientId); |
|
5081 } |
|
5082 |
|
5083 return state; |
|
5084 } |
|
5085 |
|
5086 if (Object(external_lodash_["isEqual"])(state[clientId], action.settings)) { |
|
5087 return state; |
|
5088 } |
|
5089 |
|
5090 return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, clientId, action.settings)); |
|
5091 } |
|
5092 } |
|
5093 |
|
5094 return state; |
|
5095 }; |
|
5096 /* harmony default export */ var store_reducer = (Object(external_this_wp_data_["combineReducers"])({ |
|
5097 blocks: reducer_blocks, |
|
5098 isTyping: reducer_isTyping, |
|
5099 isCaretWithinFormattedText: reducer_isCaretWithinFormattedText, |
|
5100 blockSelection: blockSelection, |
|
5101 blocksMode: blocksMode, |
|
5102 blockListSettings: reducer_blockListSettings, |
|
5103 insertionPoint: insertionPoint, |
|
5104 template: reducer_template, |
|
5105 settings: reducer_settings, |
|
5106 preferences: preferences |
|
5107 })); |
|
5108 |
|
5109 // EXTERNAL MODULE: ./node_modules/refx/refx.js |
|
5110 var refx = __webpack_require__(70); |
|
5111 var refx_default = /*#__PURE__*/__webpack_require__.n(refx); |
|
5112 |
|
5113 // EXTERNAL MODULE: ./node_modules/redux-multi/lib/index.js |
|
5114 var lib = __webpack_require__(97); |
|
5115 var lib_default = /*#__PURE__*/__webpack_require__.n(lib); |
|
5116 |
|
5117 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules |
|
5118 var slicedToArray = __webpack_require__(28); |
|
5119 |
|
5120 // EXTERNAL MODULE: external {"this":["wp","a11y"]} |
|
5121 var external_this_wp_a11y_ = __webpack_require__(48); |
|
5122 |
|
5123 // EXTERNAL MODULE: ./node_modules/@babel/runtime/regenerator/index.js |
|
5124 var regenerator = __webpack_require__(23); |
|
5125 var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator); |
|
5126 |
|
5127 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/controls.js |
|
5128 |
|
5129 |
|
5130 /** |
|
5131 * WordPress dependencies |
|
5132 */ |
|
5133 |
|
5134 /** |
|
5135 * Calls a selector using the current state. |
|
5136 * |
|
5137 * @param {string} storeName Store name. |
|
5138 * @param {string} selectorName Selector name. |
|
5139 * @param {Array} args Selector arguments. |
|
5140 * |
|
5141 * @return {Object} control descriptor. |
|
5142 */ |
|
5143 |
|
5144 function controls_select(storeName, selectorName) { |
|
5145 for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { |
|
5146 args[_key - 2] = arguments[_key]; |
|
5147 } |
|
5148 |
|
5149 return { |
|
5150 type: 'SELECT', |
|
5151 storeName: storeName, |
|
5152 selectorName: selectorName, |
|
5153 args: args |
|
5154 }; |
|
5155 } |
|
5156 var controls_controls = { |
|
5157 SELECT: Object(external_this_wp_data_["createRegistryControl"])(function (registry) { |
|
5158 return function (_ref) { |
|
5159 var _registry$select; |
|
5160 |
|
5161 var storeName = _ref.storeName, |
|
5162 selectorName = _ref.selectorName, |
|
5163 args = _ref.args; |
|
5164 return (_registry$select = registry.select(storeName))[selectorName].apply(_registry$select, Object(toConsumableArray["a" /* default */])(args)); |
|
5165 }; |
|
5166 }) |
|
5167 }; |
|
5168 /* harmony default export */ var store_controls = (controls_controls); |
|
5169 |
|
5170 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/actions.js |
|
5171 |
|
5172 |
|
5173 var _marked = |
|
5174 /*#__PURE__*/ |
|
5175 regenerator_default.a.mark(ensureDefaultBlock), |
|
5176 _marked2 = |
|
5177 /*#__PURE__*/ |
|
5178 regenerator_default.a.mark(selectPreviousBlock), |
|
5179 _marked3 = |
|
5180 /*#__PURE__*/ |
|
5181 regenerator_default.a.mark(selectNextBlock), |
|
5182 _marked4 = |
|
5183 /*#__PURE__*/ |
|
5184 regenerator_default.a.mark(actions_replaceBlocks), |
|
5185 _marked5 = |
|
5186 /*#__PURE__*/ |
|
5187 regenerator_default.a.mark(moveBlockToPosition), |
|
5188 _marked6 = |
|
5189 /*#__PURE__*/ |
|
5190 regenerator_default.a.mark(actions_insertBlocks), |
|
5191 _marked7 = |
|
5192 /*#__PURE__*/ |
|
5193 regenerator_default.a.mark(actions_removeBlocks); |
|
5194 |
|
5195 /** |
|
5196 * External dependencies |
|
5197 */ |
|
5198 |
|
5199 /** |
|
5200 * WordPress dependencies |
|
5201 */ |
|
5202 |
|
5203 |
|
5204 /** |
|
5205 * Internal dependencies |
|
5206 */ |
|
5207 |
|
5208 |
|
5209 /** |
|
5210 * Generator which will yield a default block insert action if there |
|
5211 * are no other blocks at the root of the editor. This generator should be used |
|
5212 * in actions which may result in no blocks remaining in the editor (removal, |
|
5213 * replacement, etc). |
|
5214 */ |
|
5215 |
|
5216 function ensureDefaultBlock() { |
|
5217 var count; |
|
5218 return regenerator_default.a.wrap(function ensureDefaultBlock$(_context) { |
|
5219 while (1) { |
|
5220 switch (_context.prev = _context.next) { |
|
5221 case 0: |
|
5222 _context.next = 2; |
|
5223 return controls_select('core/block-editor', 'getBlockCount'); |
|
5224 |
|
5225 case 2: |
|
5226 count = _context.sent; |
|
5227 |
|
5228 if (!(count === 0)) { |
|
5229 _context.next = 6; |
|
5230 break; |
|
5231 } |
|
5232 |
|
5233 _context.next = 6; |
|
5234 return actions_insertDefaultBlock(); |
|
5235 |
|
5236 case 6: |
|
5237 case "end": |
|
5238 return _context.stop(); |
|
5239 } |
|
5240 } |
|
5241 }, _marked, this); |
|
5242 } |
|
5243 /** |
|
5244 * Returns an action object used in signalling that blocks state should be |
|
5245 * reset to the specified array of blocks, taking precedence over any other |
|
5246 * content reflected as an edit in state. |
|
5247 * |
|
5248 * @param {Array} blocks Array of blocks. |
|
5249 * |
|
5250 * @return {Object} Action object. |
|
5251 */ |
|
5252 |
|
5253 |
|
5254 function resetBlocks(blocks) { |
|
5255 return { |
|
5256 type: 'RESET_BLOCKS', |
|
5257 blocks: blocks |
|
5258 }; |
|
5259 } |
|
5260 /** |
|
5261 * Returns an action object used in signalling that blocks have been received. |
|
5262 * Unlike resetBlocks, these should be appended to the existing known set, not |
|
5263 * replacing. |
|
5264 * |
|
5265 * @param {Object[]} blocks Array of block objects. |
|
5266 * |
|
5267 * @return {Object} Action object. |
|
5268 */ |
|
5269 |
|
5270 function receiveBlocks(blocks) { |
|
5271 return { |
|
5272 type: 'RECEIVE_BLOCKS', |
|
5273 blocks: blocks |
|
5274 }; |
|
5275 } |
|
5276 /** |
|
5277 * Returns an action object used in signalling that the block attributes with |
|
5278 * the specified client ID has been updated. |
|
5279 * |
|
5280 * @param {string} clientId Block client ID. |
|
5281 * @param {Object} attributes Block attributes to be merged. |
|
5282 * |
|
5283 * @return {Object} Action object. |
|
5284 */ |
|
5285 |
|
5286 function updateBlockAttributes(clientId, attributes) { |
|
5287 return { |
|
5288 type: 'UPDATE_BLOCK_ATTRIBUTES', |
|
5289 clientId: clientId, |
|
5290 attributes: attributes |
|
5291 }; |
|
5292 } |
|
5293 /** |
|
5294 * Returns an action object used in signalling that the block with the |
|
5295 * specified client ID has been updated. |
|
5296 * |
|
5297 * @param {string} clientId Block client ID. |
|
5298 * @param {Object} updates Block attributes to be merged. |
|
5299 * |
|
5300 * @return {Object} Action object. |
|
5301 */ |
|
5302 |
|
5303 function updateBlock(clientId, updates) { |
|
5304 return { |
|
5305 type: 'UPDATE_BLOCK', |
|
5306 clientId: clientId, |
|
5307 updates: updates |
|
5308 }; |
|
5309 } |
|
5310 /** |
|
5311 * Returns an action object used in signalling that the block with the |
|
5312 * specified client ID has been selected, optionally accepting a position |
|
5313 * value reflecting its selection directionality. An initialPosition of -1 |
|
5314 * reflects a reverse selection. |
|
5315 * |
|
5316 * @param {string} clientId Block client ID. |
|
5317 * @param {?number} initialPosition Optional initial position. Pass as -1 to |
|
5318 * reflect reverse selection. |
|
5319 * |
|
5320 * @return {Object} Action object. |
|
5321 */ |
|
5322 |
|
5323 function actions_selectBlock(clientId) { |
|
5324 var initialPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; |
|
5325 return { |
|
5326 type: 'SELECT_BLOCK', |
|
5327 initialPosition: initialPosition, |
|
5328 clientId: clientId |
|
5329 }; |
|
5330 } |
|
5331 /** |
|
5332 * Yields action objects used in signalling that the block preceding the given |
|
5333 * clientId should be selected. |
|
5334 * |
|
5335 * @param {string} clientId Block client ID. |
|
5336 */ |
|
5337 |
|
5338 function selectPreviousBlock(clientId) { |
|
5339 var previousBlockClientId; |
|
5340 return regenerator_default.a.wrap(function selectPreviousBlock$(_context2) { |
|
5341 while (1) { |
|
5342 switch (_context2.prev = _context2.next) { |
|
5343 case 0: |
|
5344 _context2.next = 2; |
|
5345 return controls_select('core/block-editor', 'getPreviousBlockClientId', clientId); |
|
5346 |
|
5347 case 2: |
|
5348 previousBlockClientId = _context2.sent; |
|
5349 _context2.next = 5; |
|
5350 return actions_selectBlock(previousBlockClientId, -1); |
|
5351 |
|
5352 case 5: |
|
5353 case "end": |
|
5354 return _context2.stop(); |
|
5355 } |
|
5356 } |
|
5357 }, _marked2, this); |
|
5358 } |
|
5359 /** |
|
5360 * Yields action objects used in signalling that the block following the given |
|
5361 * clientId should be selected. |
|
5362 * |
|
5363 * @param {string} clientId Block client ID. |
|
5364 */ |
|
5365 |
|
5366 function selectNextBlock(clientId) { |
|
5367 var nextBlockClientId; |
|
5368 return regenerator_default.a.wrap(function selectNextBlock$(_context3) { |
|
5369 while (1) { |
|
5370 switch (_context3.prev = _context3.next) { |
|
5371 case 0: |
|
5372 _context3.next = 2; |
|
5373 return controls_select('core/block-editor', 'getNextBlockClientId', clientId); |
|
5374 |
|
5375 case 2: |
|
5376 nextBlockClientId = _context3.sent; |
|
5377 _context3.next = 5; |
|
5378 return actions_selectBlock(nextBlockClientId); |
|
5379 |
|
5380 case 5: |
|
5381 case "end": |
|
5382 return _context3.stop(); |
|
5383 } |
|
5384 } |
|
5385 }, _marked3, this); |
|
5386 } |
|
5387 /** |
|
5388 * Returns an action object used in signalling that a block multi-selection has started. |
|
5389 * |
|
5390 * @return {Object} Action object. |
|
5391 */ |
|
5392 |
|
5393 function startMultiSelect() { |
|
5394 return { |
|
5395 type: 'START_MULTI_SELECT' |
|
5396 }; |
|
5397 } |
|
5398 /** |
|
5399 * Returns an action object used in signalling that block multi-selection stopped. |
|
5400 * |
|
5401 * @return {Object} Action object. |
|
5402 */ |
|
5403 |
|
5404 function stopMultiSelect() { |
|
5405 return { |
|
5406 type: 'STOP_MULTI_SELECT' |
|
5407 }; |
|
5408 } |
|
5409 /** |
|
5410 * Returns an action object used in signalling that block multi-selection changed. |
|
5411 * |
|
5412 * @param {string} start First block of the multi selection. |
|
5413 * @param {string} end Last block of the multiselection. |
|
5414 * |
|
5415 * @return {Object} Action object. |
|
5416 */ |
|
5417 |
|
5418 function actions_multiSelect(start, end) { |
|
5419 return { |
|
5420 type: 'MULTI_SELECT', |
|
5421 start: start, |
|
5422 end: end |
|
5423 }; |
|
5424 } |
|
5425 /** |
|
5426 * Returns an action object used in signalling that the block selection is cleared. |
|
5427 * |
|
5428 * @return {Object} Action object. |
|
5429 */ |
|
5430 |
|
5431 function clearSelectedBlock() { |
|
5432 return { |
|
5433 type: 'CLEAR_SELECTED_BLOCK' |
|
5434 }; |
|
5435 } |
|
5436 /** |
|
5437 * Returns an action object that enables or disables block selection. |
|
5438 * |
|
5439 * @param {boolean} [isSelectionEnabled=true] Whether block selection should |
|
5440 * be enabled. |
|
5441 |
|
5442 * @return {Object} Action object. |
|
5443 */ |
|
5444 |
|
5445 function toggleSelection() { |
|
5446 var isSelectionEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; |
|
5447 return { |
|
5448 type: 'TOGGLE_SELECTION', |
|
5449 isSelectionEnabled: isSelectionEnabled |
|
5450 }; |
|
5451 } |
|
5452 /** |
|
5453 * Returns an action object signalling that a blocks should be replaced with |
|
5454 * one or more replacement blocks. |
|
5455 * |
|
5456 * @param {(string|string[])} clientIds Block client ID(s) to replace. |
|
5457 * @param {(Object|Object[])} blocks Replacement block(s). |
|
5458 * |
|
5459 * @yields {Object} Action object. |
|
5460 */ |
|
5461 |
|
5462 function actions_replaceBlocks(clientIds, blocks) { |
|
5463 var rootClientId, index, block, canInsertBlock; |
|
5464 return regenerator_default.a.wrap(function replaceBlocks$(_context4) { |
|
5465 while (1) { |
|
5466 switch (_context4.prev = _context4.next) { |
|
5467 case 0: |
|
5468 clientIds = Object(external_lodash_["castArray"])(clientIds); |
|
5469 blocks = Object(external_lodash_["castArray"])(blocks); |
|
5470 _context4.next = 4; |
|
5471 return controls_select('core/block-editor', 'getBlockRootClientId', Object(external_lodash_["first"])(clientIds)); |
|
5472 |
|
5473 case 4: |
|
5474 rootClientId = _context4.sent; |
|
5475 index = 0; |
|
5476 |
|
5477 case 6: |
|
5478 if (!(index < blocks.length)) { |
|
5479 _context4.next = 16; |
|
5480 break; |
|
5481 } |
|
5482 |
|
5483 block = blocks[index]; |
|
5484 _context4.next = 10; |
|
5485 return controls_select('core/block-editor', 'canInsertBlockType', block.name, rootClientId); |
|
5486 |
|
5487 case 10: |
|
5488 canInsertBlock = _context4.sent; |
|
5489 |
|
5490 if (canInsertBlock) { |
|
5491 _context4.next = 13; |
|
5492 break; |
|
5493 } |
|
5494 |
|
5495 return _context4.abrupt("return"); |
|
5496 |
|
5497 case 13: |
|
5498 index++; |
|
5499 _context4.next = 6; |
|
5500 break; |
|
5501 |
|
5502 case 16: |
|
5503 _context4.next = 18; |
|
5504 return { |
|
5505 type: 'REPLACE_BLOCKS', |
|
5506 clientIds: clientIds, |
|
5507 blocks: blocks, |
|
5508 time: Date.now() |
|
5509 }; |
|
5510 |
|
5511 case 18: |
|
5512 return _context4.delegateYield(ensureDefaultBlock(), "t0", 19); |
|
5513 |
|
5514 case 19: |
|
5515 case "end": |
|
5516 return _context4.stop(); |
|
5517 } |
|
5518 } |
|
5519 }, _marked4, this); |
|
5520 } |
|
5521 /** |
|
5522 * Returns an action object signalling that a single block should be replaced |
|
5523 * with one or more replacement blocks. |
|
5524 * |
|
5525 * @param {(string|string[])} clientId Block client ID to replace. |
|
5526 * @param {(Object|Object[])} block Replacement block(s). |
|
5527 * |
|
5528 * @return {Object} Action object. |
|
5529 */ |
|
5530 |
|
5531 function replaceBlock(clientId, block) { |
|
5532 return actions_replaceBlocks(clientId, block); |
|
5533 } |
|
5534 /** |
|
5535 * Higher-order action creator which, given the action type to dispatch creates |
|
5536 * an action creator for managing block movement. |
|
5537 * |
|
5538 * @param {string} type Action type to dispatch. |
|
5539 * |
|
5540 * @return {Function} Action creator. |
|
5541 */ |
|
5542 |
|
5543 function createOnMove(type) { |
|
5544 return function (clientIds, rootClientId) { |
|
5545 return { |
|
5546 clientIds: Object(external_lodash_["castArray"])(clientIds), |
|
5547 type: type, |
|
5548 rootClientId: rootClientId |
|
5549 }; |
|
5550 }; |
|
5551 } |
|
5552 |
|
5553 var actions_moveBlocksDown = createOnMove('MOVE_BLOCKS_DOWN'); |
|
5554 var actions_moveBlocksUp = createOnMove('MOVE_BLOCKS_UP'); |
|
5555 /** |
|
5556 * Returns an action object signalling that an indexed block should be moved |
|
5557 * to a new index. |
|
5558 * |
|
5559 * @param {?string} clientId The client ID of the block. |
|
5560 * @param {?string} fromRootClientId Root client ID source. |
|
5561 * @param {?string} toRootClientId Root client ID destination. |
|
5562 * @param {number} index The index to move the block into. |
|
5563 * |
|
5564 * @yields {Object} Action object. |
|
5565 */ |
|
5566 |
|
5567 function moveBlockToPosition(clientId, fromRootClientId, toRootClientId, index) { |
|
5568 var templateLock, action, blockName, canInsertBlock; |
|
5569 return regenerator_default.a.wrap(function moveBlockToPosition$(_context5) { |
|
5570 while (1) { |
|
5571 switch (_context5.prev = _context5.next) { |
|
5572 case 0: |
|
5573 _context5.next = 2; |
|
5574 return controls_select('core/block-editor', 'getTemplateLock', fromRootClientId); |
|
5575 |
|
5576 case 2: |
|
5577 templateLock = _context5.sent; |
|
5578 |
|
5579 if (!(templateLock === 'all')) { |
|
5580 _context5.next = 5; |
|
5581 break; |
|
5582 } |
|
5583 |
|
5584 return _context5.abrupt("return"); |
|
5585 |
|
5586 case 5: |
|
5587 action = { |
|
5588 type: 'MOVE_BLOCK_TO_POSITION', |
|
5589 fromRootClientId: fromRootClientId, |
|
5590 toRootClientId: toRootClientId, |
|
5591 clientId: clientId, |
|
5592 index: index |
|
5593 }; // If moving inside the same root block the move is always possible. |
|
5594 |
|
5595 if (!(fromRootClientId === toRootClientId)) { |
|
5596 _context5.next = 10; |
|
5597 break; |
|
5598 } |
|
5599 |
|
5600 _context5.next = 9; |
|
5601 return action; |
|
5602 |
|
5603 case 9: |
|
5604 return _context5.abrupt("return"); |
|
5605 |
|
5606 case 10: |
|
5607 _context5.next = 12; |
|
5608 return controls_select('core/block-editor', 'getBlockName', clientId); |
|
5609 |
|
5610 case 12: |
|
5611 blockName = _context5.sent; |
|
5612 _context5.next = 15; |
|
5613 return controls_select('core/block-editor', 'canInsertBlockType', blockName, toRootClientId); |
|
5614 |
|
5615 case 15: |
|
5616 canInsertBlock = _context5.sent; |
|
5617 |
|
5618 if (!canInsertBlock) { |
|
5619 _context5.next = 19; |
|
5620 break; |
|
5621 } |
|
5622 |
|
5623 _context5.next = 19; |
|
5624 return action; |
|
5625 |
|
5626 case 19: |
|
5627 case "end": |
|
5628 return _context5.stop(); |
|
5629 } |
|
5630 } |
|
5631 }, _marked5, this); |
|
5632 } |
|
5633 /** |
|
5634 * Returns an action object used in signalling that a single block should be |
|
5635 * inserted, optionally at a specific index respective a root block list. |
|
5636 * |
|
5637 * @param {Object} block Block object to insert. |
|
5638 * @param {?number} index Index at which block should be inserted. |
|
5639 * @param {?string} rootClientId Optional root client ID of block list on which to insert. |
|
5640 * @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to true. |
|
5641 * |
|
5642 * @return {Object} Action object. |
|
5643 */ |
|
5644 |
|
5645 function actions_insertBlock(block, index, rootClientId) { |
|
5646 var updateSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; |
|
5647 return actions_insertBlocks([block], index, rootClientId, updateSelection); |
|
5648 } |
|
5649 /** |
|
5650 * Returns an action object used in signalling that an array of blocks should |
|
5651 * be inserted, optionally at a specific index respective a root block list. |
|
5652 * |
|
5653 * @param {Object[]} blocks Block objects to insert. |
|
5654 * @param {?number} index Index at which block should be inserted. |
|
5655 * @param {?string} rootClientId Optional root client ID of block list on which to insert. |
|
5656 * @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to true. |
|
5657 * |
|
5658 * @return {Object} Action object. |
|
5659 */ |
|
5660 |
|
5661 function actions_insertBlocks(blocks, index, rootClientId) { |
|
5662 var updateSelection, |
|
5663 allowedBlocks, |
|
5664 _iteratorNormalCompletion, |
|
5665 _didIteratorError, |
|
5666 _iteratorError, |
|
5667 _iterator, |
|
5668 _step, |
|
5669 block, |
|
5670 isValid, |
|
5671 _args6 = arguments; |
|
5672 |
|
5673 return regenerator_default.a.wrap(function insertBlocks$(_context6) { |
|
5674 while (1) { |
|
5675 switch (_context6.prev = _context6.next) { |
|
5676 case 0: |
|
5677 updateSelection = _args6.length > 3 && _args6[3] !== undefined ? _args6[3] : true; |
|
5678 blocks = Object(external_lodash_["castArray"])(blocks); |
|
5679 allowedBlocks = []; |
|
5680 _iteratorNormalCompletion = true; |
|
5681 _didIteratorError = false; |
|
5682 _iteratorError = undefined; |
|
5683 _context6.prev = 6; |
|
5684 _iterator = blocks[Symbol.iterator](); |
|
5685 |
|
5686 case 8: |
|
5687 if (_iteratorNormalCompletion = (_step = _iterator.next()).done) { |
|
5688 _context6.next = 17; |
|
5689 break; |
|
5690 } |
|
5691 |
|
5692 block = _step.value; |
|
5693 _context6.next = 12; |
|
5694 return controls_select('core/block-editor', 'canInsertBlockType', block.name, rootClientId); |
|
5695 |
|
5696 case 12: |
|
5697 isValid = _context6.sent; |
|
5698 |
|
5699 if (isValid) { |
|
5700 allowedBlocks.push(block); |
|
5701 } |
|
5702 |
|
5703 case 14: |
|
5704 _iteratorNormalCompletion = true; |
|
5705 _context6.next = 8; |
|
5706 break; |
|
5707 |
|
5708 case 17: |
|
5709 _context6.next = 23; |
|
5710 break; |
|
5711 |
|
5712 case 19: |
|
5713 _context6.prev = 19; |
|
5714 _context6.t0 = _context6["catch"](6); |
|
5715 _didIteratorError = true; |
|
5716 _iteratorError = _context6.t0; |
|
5717 |
|
5718 case 23: |
|
5719 _context6.prev = 23; |
|
5720 _context6.prev = 24; |
|
5721 |
|
5722 if (!_iteratorNormalCompletion && _iterator.return != null) { |
|
5723 _iterator.return(); |
|
5724 } |
|
5725 |
|
5726 case 26: |
|
5727 _context6.prev = 26; |
|
5728 |
|
5729 if (!_didIteratorError) { |
|
5730 _context6.next = 29; |
|
5731 break; |
|
5732 } |
|
5733 |
|
5734 throw _iteratorError; |
|
5735 |
|
5736 case 29: |
|
5737 return _context6.finish(26); |
|
5738 |
|
5739 case 30: |
|
5740 return _context6.finish(23); |
|
5741 |
|
5742 case 31: |
|
5743 if (!allowedBlocks.length) { |
|
5744 _context6.next = 33; |
|
5745 break; |
|
5746 } |
|
5747 |
|
5748 return _context6.abrupt("return", { |
|
5749 type: 'INSERT_BLOCKS', |
|
5750 blocks: allowedBlocks, |
|
5751 index: index, |
|
5752 rootClientId: rootClientId, |
|
5753 time: Date.now(), |
|
5754 updateSelection: updateSelection |
|
5755 }); |
|
5756 |
|
5757 case 33: |
|
5758 case "end": |
|
5759 return _context6.stop(); |
|
5760 } |
|
5761 } |
|
5762 }, _marked6, this, [[6, 19, 23, 31], [24,, 26, 30]]); |
|
5763 } |
|
5764 /** |
|
5765 * Returns an action object used in signalling that the insertion point should |
|
5766 * be shown. |
|
5767 * |
|
5768 * @param {?string} rootClientId Optional root client ID of block list on |
|
5769 * which to insert. |
|
5770 * @param {?number} index Index at which block should be inserted. |
|
5771 * |
|
5772 * @return {Object} Action object. |
|
5773 */ |
|
5774 |
|
5775 function actions_showInsertionPoint(rootClientId, index) { |
|
5776 return { |
|
5777 type: 'SHOW_INSERTION_POINT', |
|
5778 rootClientId: rootClientId, |
|
5779 index: index |
|
5780 }; |
|
5781 } |
|
5782 /** |
|
5783 * Returns an action object hiding the insertion point. |
|
5784 * |
|
5785 * @return {Object} Action object. |
|
5786 */ |
|
5787 |
|
5788 function actions_hideInsertionPoint() { |
|
5789 return { |
|
5790 type: 'HIDE_INSERTION_POINT' |
|
5791 }; |
|
5792 } |
|
5793 /** |
|
5794 * Returns an action object resetting the template validity. |
|
5795 * |
|
5796 * @param {boolean} isValid template validity flag. |
|
5797 * |
|
5798 * @return {Object} Action object. |
|
5799 */ |
|
5800 |
|
5801 function setTemplateValidity(isValid) { |
|
5802 return { |
|
5803 type: 'SET_TEMPLATE_VALIDITY', |
|
5804 isValid: isValid |
|
5805 }; |
|
5806 } |
|
5807 /** |
|
5808 * Returns an action object synchronize the template with the list of blocks |
|
5809 * |
|
5810 * @return {Object} Action object. |
|
5811 */ |
|
5812 |
|
5813 function synchronizeTemplate() { |
|
5814 return { |
|
5815 type: 'SYNCHRONIZE_TEMPLATE' |
|
5816 }; |
|
5817 } |
|
5818 /** |
|
5819 * Returns an action object used in signalling that two blocks should be merged |
|
5820 * |
|
5821 * @param {string} firstBlockClientId Client ID of the first block to merge. |
|
5822 * @param {string} secondBlockClientId Client ID of the second block to merge. |
|
5823 * |
|
5824 * @return {Object} Action object. |
|
5825 */ |
|
5826 |
|
5827 function mergeBlocks(firstBlockClientId, secondBlockClientId) { |
|
5828 return { |
|
5829 type: 'MERGE_BLOCKS', |
|
5830 blocks: [firstBlockClientId, secondBlockClientId] |
|
5831 }; |
|
5832 } |
|
5833 /** |
|
5834 * Yields action objects used in signalling that the blocks corresponding to |
|
5835 * the set of specified client IDs are to be removed. |
|
5836 * |
|
5837 * @param {string|string[]} clientIds Client IDs of blocks to remove. |
|
5838 * @param {boolean} selectPrevious True if the previous block should be |
|
5839 * selected when a block is removed. |
|
5840 */ |
|
5841 |
|
5842 function actions_removeBlocks(clientIds) { |
|
5843 var selectPrevious, |
|
5844 _args7 = arguments; |
|
5845 return regenerator_default.a.wrap(function removeBlocks$(_context7) { |
|
5846 while (1) { |
|
5847 switch (_context7.prev = _context7.next) { |
|
5848 case 0: |
|
5849 selectPrevious = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : true; |
|
5850 clientIds = Object(external_lodash_["castArray"])(clientIds); |
|
5851 |
|
5852 if (!selectPrevious) { |
|
5853 _context7.next = 5; |
|
5854 break; |
|
5855 } |
|
5856 |
|
5857 _context7.next = 5; |
|
5858 return selectPreviousBlock(clientIds[0]); |
|
5859 |
|
5860 case 5: |
|
5861 _context7.next = 7; |
|
5862 return { |
|
5863 type: 'REMOVE_BLOCKS', |
|
5864 clientIds: clientIds |
|
5865 }; |
|
5866 |
|
5867 case 7: |
|
5868 return _context7.delegateYield(ensureDefaultBlock(), "t0", 8); |
|
5869 |
|
5870 case 8: |
|
5871 case "end": |
|
5872 return _context7.stop(); |
|
5873 } |
|
5874 } |
|
5875 }, _marked7, this); |
|
5876 } |
|
5877 /** |
|
5878 * Returns an action object used in signalling that the block with the |
|
5879 * specified client ID is to be removed. |
|
5880 * |
|
5881 * @param {string} clientId Client ID of block to remove. |
|
5882 * @param {boolean} selectPrevious True if the previous block should be |
|
5883 * selected when a block is removed. |
|
5884 * |
|
5885 * @return {Object} Action object. |
|
5886 */ |
|
5887 |
|
5888 function removeBlock(clientId, selectPrevious) { |
|
5889 return actions_removeBlocks([clientId], selectPrevious); |
|
5890 } |
|
5891 /** |
|
5892 * Returns an action object used in signalling that the inner blocks with the |
|
5893 * specified client ID should be replaced. |
|
5894 * |
|
5895 * @param {string} rootClientId Client ID of the block whose InnerBlocks will re replaced. |
|
5896 * @param {Object[]} blocks Block objects to insert as new InnerBlocks |
|
5897 * @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to true. |
|
5898 * |
|
5899 * @return {Object} Action object. |
|
5900 */ |
|
5901 |
|
5902 function actions_replaceInnerBlocks(rootClientId, blocks) { |
|
5903 var updateSelection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; |
|
5904 return { |
|
5905 type: 'REPLACE_INNER_BLOCKS', |
|
5906 rootClientId: rootClientId, |
|
5907 blocks: blocks, |
|
5908 updateSelection: updateSelection, |
|
5909 time: Date.now() |
|
5910 }; |
|
5911 } |
|
5912 /** |
|
5913 * Returns an action object used to toggle the block editing mode between |
|
5914 * visual and HTML modes. |
|
5915 * |
|
5916 * @param {string} clientId Block client ID. |
|
5917 * |
|
5918 * @return {Object} Action object. |
|
5919 */ |
|
5920 |
|
5921 function toggleBlockMode(clientId) { |
|
5922 return { |
|
5923 type: 'TOGGLE_BLOCK_MODE', |
|
5924 clientId: clientId |
|
5925 }; |
|
5926 } |
|
5927 /** |
|
5928 * Returns an action object used in signalling that the user has begun to type. |
|
5929 * |
|
5930 * @return {Object} Action object. |
|
5931 */ |
|
5932 |
|
5933 function startTyping() { |
|
5934 return { |
|
5935 type: 'START_TYPING' |
|
5936 }; |
|
5937 } |
|
5938 /** |
|
5939 * Returns an action object used in signalling that the user has stopped typing. |
|
5940 * |
|
5941 * @return {Object} Action object. |
|
5942 */ |
|
5943 |
|
5944 function stopTyping() { |
|
5945 return { |
|
5946 type: 'STOP_TYPING' |
|
5947 }; |
|
5948 } |
|
5949 /** |
|
5950 * Returns an action object used in signalling that the caret has entered formatted text. |
|
5951 * |
|
5952 * @return {Object} Action object. |
|
5953 */ |
|
5954 |
|
5955 function enterFormattedText() { |
|
5956 return { |
|
5957 type: 'ENTER_FORMATTED_TEXT' |
|
5958 }; |
|
5959 } |
|
5960 /** |
|
5961 * Returns an action object used in signalling that the user caret has exited formatted text. |
|
5962 * |
|
5963 * @return {Object} Action object. |
|
5964 */ |
|
5965 |
|
5966 function exitFormattedText() { |
|
5967 return { |
|
5968 type: 'EXIT_FORMATTED_TEXT' |
|
5969 }; |
|
5970 } |
|
5971 /** |
|
5972 * Returns an action object used in signalling that a new block of the default |
|
5973 * type should be added to the block list. |
|
5974 * |
|
5975 * @param {?Object} attributes Optional attributes of the block to assign. |
|
5976 * @param {?string} rootClientId Optional root client ID of block list on which |
|
5977 * to append. |
|
5978 * @param {?number} index Optional index where to insert the default block |
|
5979 * |
|
5980 * @return {Object} Action object |
|
5981 */ |
|
5982 |
|
5983 function actions_insertDefaultBlock(attributes, rootClientId, index) { |
|
5984 var block = Object(external_this_wp_blocks_["createBlock"])(Object(external_this_wp_blocks_["getDefaultBlockName"])(), attributes); |
|
5985 return actions_insertBlock(block, index, rootClientId); |
|
5986 } |
|
5987 /** |
|
5988 * Returns an action object that changes the nested settings of a given block. |
|
5989 * |
|
5990 * @param {string} clientId Client ID of the block whose nested setting are |
|
5991 * being received. |
|
5992 * @param {Object} settings Object with the new settings for the nested block. |
|
5993 * |
|
5994 * @return {Object} Action object |
|
5995 */ |
|
5996 |
|
5997 function updateBlockListSettings(clientId, settings) { |
|
5998 return { |
|
5999 type: 'UPDATE_BLOCK_LIST_SETTINGS', |
|
6000 clientId: clientId, |
|
6001 settings: settings |
|
6002 }; |
|
6003 } |
|
6004 /* |
|
6005 * Returns an action object used in signalling that the block editor settings have been updated. |
|
6006 * |
|
6007 * @param {Object} settings Updated settings |
|
6008 * |
|
6009 * @return {Object} Action object |
|
6010 */ |
|
6011 |
|
6012 function updateSettings(settings) { |
|
6013 return { |
|
6014 type: 'UPDATE_SETTINGS', |
|
6015 settings: settings |
|
6016 }; |
|
6017 } |
|
6018 /** |
|
6019 * Returns an action object used in signalling that a temporary reusable blocks have been saved |
|
6020 * in order to switch its temporary id with the real id. |
|
6021 * |
|
6022 * @param {string} id Reusable block's id. |
|
6023 * @param {string} updatedId Updated block's id. |
|
6024 * |
|
6025 * @return {Object} Action object. |
|
6026 */ |
|
6027 |
|
6028 function __unstableSaveReusableBlock(id, updatedId) { |
|
6029 return { |
|
6030 type: 'SAVE_REUSABLE_BLOCK_SUCCESS', |
|
6031 id: id, |
|
6032 updatedId: updatedId |
|
6033 }; |
|
6034 } |
|
6035 /** |
|
6036 * Returns an action object used in signalling that the last block change should be marked explicitely as persistent. |
|
6037 * |
|
6038 * @return {Object} Action object. |
|
6039 */ |
|
6040 |
|
6041 function __unstableMarkLastChangeAsPersistent() { |
|
6042 return { |
|
6043 type: 'MARK_LAST_CHANGE_AS_PERSISTENT' |
|
6044 }; |
|
6045 } |
|
6046 |
|
6047 // EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js |
|
6048 var rememo = __webpack_require__(30); |
|
6049 |
|
6050 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/selectors.js |
|
6051 |
|
6052 |
|
6053 |
|
6054 /** |
|
6055 * External dependencies |
|
6056 */ |
|
6057 |
|
6058 |
|
6059 /** |
|
6060 * WordPress dependencies |
|
6061 */ |
|
6062 |
|
6063 |
|
6064 /*** |
|
6065 * Module constants |
|
6066 */ |
|
6067 |
|
6068 var INSERTER_UTILITY_HIGH = 3; |
|
6069 var INSERTER_UTILITY_MEDIUM = 2; |
|
6070 var INSERTER_UTILITY_LOW = 1; |
|
6071 var INSERTER_UTILITY_NONE = 0; |
|
6072 var MILLISECONDS_PER_HOUR = 3600 * 1000; |
|
6073 var MILLISECONDS_PER_DAY = 24 * 3600 * 1000; |
|
6074 var MILLISECONDS_PER_WEEK = 7 * 24 * 3600 * 1000; |
|
6075 /** |
|
6076 * Shared reference to an empty array for cases where it is important to avoid |
|
6077 * returning a new array reference on every invocation, as in a connected or |
|
6078 * other pure component which performs `shouldComponentUpdate` check on props. |
|
6079 * This should be used as a last resort, since the normalized data should be |
|
6080 * maintained by the reducer result in state. |
|
6081 * |
|
6082 * @type {Array} |
|
6083 */ |
|
6084 |
|
6085 var EMPTY_ARRAY = []; |
|
6086 /** |
|
6087 * Shared reference to an empty object for cases where it is important to avoid |
|
6088 * returning a new object reference on every invocation. |
|
6089 * |
|
6090 * @type {Object} |
|
6091 */ |
|
6092 |
|
6093 var EMPTY_OBJECT = {}; |
|
6094 /** |
|
6095 * Returns a new reference when the inner blocks of a given block client ID |
|
6096 * change. This is used exclusively as a memoized selector dependant, relying |
|
6097 * on this selector's shared return value and recursively those of its inner |
|
6098 * blocks defined as dependencies. This abuses mechanics of the selector |
|
6099 * memoization to return from the original selector function only when |
|
6100 * dependants change. |
|
6101 * |
|
6102 * @param {Object} state Editor state. |
|
6103 * @param {string} clientId Block client ID. |
|
6104 * |
|
6105 * @return {*} A value whose reference will change only when inner blocks of |
|
6106 * the given block client ID change. |
|
6107 */ |
|
6108 |
|
6109 var getBlockDependantsCacheBust = Object(rememo["a" /* default */])(function () { |
|
6110 return []; |
|
6111 }, function (state, clientId) { |
|
6112 return Object(external_lodash_["map"])(selectors_getBlockOrder(state, clientId), function (innerBlockClientId) { |
|
6113 return selectors_getBlock(state, innerBlockClientId); |
|
6114 }); |
|
6115 }); |
|
6116 /** |
|
6117 * Returns a block's name given its client ID, or null if no block exists with |
|
6118 * the client ID. |
|
6119 * |
|
6120 * @param {Object} state Editor state. |
|
6121 * @param {string} clientId Block client ID. |
|
6122 * |
|
6123 * @return {string} Block name. |
|
6124 */ |
|
6125 |
|
6126 function selectors_getBlockName(state, clientId) { |
|
6127 var block = state.blocks.byClientId[clientId]; |
|
6128 return block ? block.name : null; |
|
6129 } |
|
6130 /** |
|
6131 * Returns whether a block is valid or not. |
|
6132 * |
|
6133 * @param {Object} state Editor state. |
|
6134 * @param {string} clientId Block client ID. |
|
6135 * |
|
6136 * @return {boolean} Is Valid. |
|
6137 */ |
|
6138 |
|
6139 function selectors_isBlockValid(state, clientId) { |
|
6140 var block = state.blocks.byClientId[clientId]; |
|
6141 return !!block && block.isValid; |
|
6142 } |
|
6143 /** |
|
6144 * Returns a block's attributes given its client ID, or null if no block exists with |
|
6145 * the client ID. |
|
6146 * |
|
6147 * @param {Object} state Editor state. |
|
6148 * @param {string} clientId Block client ID. |
|
6149 * |
|
6150 * @return {Object?} Block attributes. |
|
6151 */ |
|
6152 |
|
6153 var getBlockAttributes = Object(rememo["a" /* default */])(function (state, clientId) { |
|
6154 var block = state.blocks.byClientId[clientId]; |
|
6155 |
|
6156 if (!block) { |
|
6157 return null; |
|
6158 } |
|
6159 |
|
6160 var attributes = state.blocks.attributes[clientId]; // Inject custom source attribute values. |
|
6161 // |
|
6162 // TODO: Create generic external sourcing pattern, not explicitly |
|
6163 // targeting meta attributes. |
|
6164 |
|
6165 var type = Object(external_this_wp_blocks_["getBlockType"])(block.name); |
|
6166 |
|
6167 if (type) { |
|
6168 attributes = Object(external_lodash_["reduce"])(type.attributes, function (result, value, key) { |
|
6169 if (value.source === 'meta') { |
|
6170 if (result === attributes) { |
|
6171 result = Object(objectSpread["a" /* default */])({}, result); |
|
6172 } |
|
6173 |
|
6174 result[key] = getPostMeta(state, value.meta); |
|
6175 } |
|
6176 |
|
6177 return result; |
|
6178 }, attributes); |
|
6179 } |
|
6180 |
|
6181 return attributes; |
|
6182 }, function (state, clientId) { |
|
6183 return [state.blocks.byClientId[clientId], state.blocks.attributes[clientId], getPostMeta(state)]; |
|
6184 }); |
|
6185 /** |
|
6186 * Returns a block given its client ID. This is a parsed copy of the block, |
|
6187 * containing its `blockName`, `clientId`, and current `attributes` state. This |
|
6188 * is not the block's registration settings, which must be retrieved from the |
|
6189 * blocks module registration store. |
|
6190 * |
|
6191 * @param {Object} state Editor state. |
|
6192 * @param {string} clientId Block client ID. |
|
6193 * |
|
6194 * @return {Object} Parsed block object. |
|
6195 */ |
|
6196 |
|
6197 var selectors_getBlock = Object(rememo["a" /* default */])(function (state, clientId) { |
|
6198 var block = state.blocks.byClientId[clientId]; |
|
6199 |
|
6200 if (!block) { |
|
6201 return null; |
|
6202 } |
|
6203 |
|
6204 return Object(objectSpread["a" /* default */])({}, block, { |
|
6205 attributes: getBlockAttributes(state, clientId), |
|
6206 innerBlocks: getBlocks(state, clientId) |
|
6207 }); |
|
6208 }, function (state, clientId) { |
|
6209 return [].concat(Object(toConsumableArray["a" /* default */])(getBlockAttributes.getDependants(state, clientId)), [getBlockDependantsCacheBust(state, clientId)]); |
|
6210 }); |
|
6211 var selectors_unstableGetBlockWithoutInnerBlocks = Object(rememo["a" /* default */])(function (state, clientId) { |
|
6212 var block = state.blocks.byClientId[clientId]; |
|
6213 |
|
6214 if (!block) { |
|
6215 return null; |
|
6216 } |
|
6217 |
|
6218 return Object(objectSpread["a" /* default */])({}, block, { |
|
6219 attributes: getBlockAttributes(state, clientId) |
|
6220 }); |
|
6221 }, function (state, clientId) { |
|
6222 return [state.blocks.byClientId[clientId]].concat(Object(toConsumableArray["a" /* default */])(getBlockAttributes.getDependants(state, clientId))); |
|
6223 }); |
|
6224 /** |
|
6225 * Returns all block objects for the current post being edited as an array in |
|
6226 * the order they appear in the post. |
|
6227 * |
|
6228 * Note: It's important to memoize this selector to avoid return a new instance |
|
6229 * on each call |
|
6230 * |
|
6231 * @param {Object} state Editor state. |
|
6232 * @param {?String} rootClientId Optional root client ID of block list. |
|
6233 * |
|
6234 * @return {Object[]} Post blocks. |
|
6235 */ |
|
6236 |
|
6237 var getBlocks = Object(rememo["a" /* default */])(function (state, rootClientId) { |
|
6238 return Object(external_lodash_["map"])(selectors_getBlockOrder(state, rootClientId), function (clientId) { |
|
6239 return selectors_getBlock(state, clientId); |
|
6240 }); |
|
6241 }, function (state) { |
|
6242 return [state.blocks.byClientId, state.blocks.order, state.blocks.attributes]; |
|
6243 }); |
|
6244 /** |
|
6245 * Returns an array containing the clientIds of all descendants |
|
6246 * of the blocks given. |
|
6247 * |
|
6248 * @param {Object} state Global application state. |
|
6249 * @param {Array} clientIds Array of blocks to inspect. |
|
6250 * |
|
6251 * @return {Array} ids of descendants. |
|
6252 */ |
|
6253 |
|
6254 var selectors_getClientIdsOfDescendants = function getClientIdsOfDescendants(state, clientIds) { |
|
6255 return Object(external_lodash_["flatMap"])(clientIds, function (clientId) { |
|
6256 var descendants = selectors_getBlockOrder(state, clientId); |
|
6257 return [].concat(Object(toConsumableArray["a" /* default */])(descendants), Object(toConsumableArray["a" /* default */])(getClientIdsOfDescendants(state, descendants))); |
|
6258 }); |
|
6259 }; |
|
6260 /** |
|
6261 * Returns an array containing the clientIds of the top-level blocks |
|
6262 * and their descendants of any depth (for nested blocks). |
|
6263 * |
|
6264 * @param {Object} state Global application state. |
|
6265 * |
|
6266 * @return {Array} ids of top-level and descendant blocks. |
|
6267 */ |
|
6268 |
|
6269 var getClientIdsWithDescendants = Object(rememo["a" /* default */])(function (state) { |
|
6270 var topLevelIds = selectors_getBlockOrder(state); |
|
6271 return [].concat(Object(toConsumableArray["a" /* default */])(topLevelIds), Object(toConsumableArray["a" /* default */])(selectors_getClientIdsOfDescendants(state, topLevelIds))); |
|
6272 }, function (state) { |
|
6273 return [state.blocks.order]; |
|
6274 }); |
|
6275 /** |
|
6276 * Returns the total number of blocks, or the total number of blocks with a specific name in a post. |
|
6277 * The number returned includes nested blocks. |
|
6278 * |
|
6279 * @param {Object} state Global application state. |
|
6280 * @param {?String} blockName Optional block name, if specified only blocks of that type will be counted. |
|
6281 * |
|
6282 * @return {number} Number of blocks in the post, or number of blocks with name equal to blockName. |
|
6283 */ |
|
6284 |
|
6285 var getGlobalBlockCount = Object(rememo["a" /* default */])(function (state, blockName) { |
|
6286 var clientIds = getClientIdsWithDescendants(state); |
|
6287 |
|
6288 if (!blockName) { |
|
6289 return clientIds.length; |
|
6290 } |
|
6291 |
|
6292 return Object(external_lodash_["reduce"])(clientIds, function (count, clientId) { |
|
6293 var block = state.blocks.byClientId[clientId]; |
|
6294 return block.name === blockName ? count + 1 : count; |
|
6295 }, 0); |
|
6296 }, function (state) { |
|
6297 return [state.blocks.order, state.blocks.byClientId]; |
|
6298 }); |
|
6299 /** |
|
6300 * Given an array of block client IDs, returns the corresponding array of block |
|
6301 * objects. |
|
6302 * |
|
6303 * @param {Object} state Editor state. |
|
6304 * @param {string[]} clientIds Client IDs for which blocks are to be returned. |
|
6305 * |
|
6306 * @return {WPBlock[]} Block objects. |
|
6307 */ |
|
6308 |
|
6309 var selectors_getBlocksByClientId = Object(rememo["a" /* default */])(function (state, clientIds) { |
|
6310 return Object(external_lodash_["map"])(Object(external_lodash_["castArray"])(clientIds), function (clientId) { |
|
6311 return selectors_getBlock(state, clientId); |
|
6312 }); |
|
6313 }, function (state) { |
|
6314 return [getPostMeta(state), state.blocks.byClientId, state.blocks.order, state.blocks.attributes]; |
|
6315 }); |
|
6316 /** |
|
6317 * Returns the number of blocks currently present in the post. |
|
6318 * |
|
6319 * @param {Object} state Editor state. |
|
6320 * @param {?string} rootClientId Optional root client ID of block list. |
|
6321 * |
|
6322 * @return {number} Number of blocks in the post. |
|
6323 */ |
|
6324 |
|
6325 function selectors_getBlockCount(state, rootClientId) { |
|
6326 return selectors_getBlockOrder(state, rootClientId).length; |
|
6327 } |
|
6328 /** |
|
6329 * Returns the current block selection start. This value may be null, and it |
|
6330 * may represent either a singular block selection or multi-selection start. |
|
6331 * A selection is singular if its start and end match. |
|
6332 * |
|
6333 * @param {Object} state Global application state. |
|
6334 * |
|
6335 * @return {?string} Client ID of block selection start. |
|
6336 */ |
|
6337 |
|
6338 function getBlockSelectionStart(state) { |
|
6339 return state.blockSelection.start; |
|
6340 } |
|
6341 /** |
|
6342 * Returns the current block selection end. This value may be null, and it |
|
6343 * may represent either a singular block selection or multi-selection end. |
|
6344 * A selection is singular if its start and end match. |
|
6345 * |
|
6346 * @param {Object} state Global application state. |
|
6347 * |
|
6348 * @return {?string} Client ID of block selection end. |
|
6349 */ |
|
6350 |
|
6351 function getBlockSelectionEnd(state) { |
|
6352 return state.blockSelection.end; |
|
6353 } |
|
6354 /** |
|
6355 * Returns the number of blocks currently selected in the post. |
|
6356 * |
|
6357 * @param {Object} state Global application state. |
|
6358 * |
|
6359 * @return {number} Number of blocks selected in the post. |
|
6360 */ |
|
6361 |
|
6362 function selectors_getSelectedBlockCount(state) { |
|
6363 var multiSelectedBlockCount = selectors_getMultiSelectedBlockClientIds(state).length; |
|
6364 |
|
6365 if (multiSelectedBlockCount) { |
|
6366 return multiSelectedBlockCount; |
|
6367 } |
|
6368 |
|
6369 return state.blockSelection.start ? 1 : 0; |
|
6370 } |
|
6371 /** |
|
6372 * Returns true if there is a single selected block, or false otherwise. |
|
6373 * |
|
6374 * @param {Object} state Editor state. |
|
6375 * |
|
6376 * @return {boolean} Whether a single block is selected. |
|
6377 */ |
|
6378 |
|
6379 function hasSelectedBlock(state) { |
|
6380 var _state$blockSelection = state.blockSelection, |
|
6381 start = _state$blockSelection.start, |
|
6382 end = _state$blockSelection.end; |
|
6383 return !!start && start === end; |
|
6384 } |
|
6385 /** |
|
6386 * Returns the currently selected block client ID, or null if there is no |
|
6387 * selected block. |
|
6388 * |
|
6389 * @param {Object} state Editor state. |
|
6390 * |
|
6391 * @return {?string} Selected block client ID. |
|
6392 */ |
|
6393 |
|
6394 function selectors_getSelectedBlockClientId(state) { |
|
6395 var _state$blockSelection2 = state.blockSelection, |
|
6396 start = _state$blockSelection2.start, |
|
6397 end = _state$blockSelection2.end; // We need to check the block exists because the current blockSelection |
|
6398 // reducer doesn't take into account when blocks are reset via undo. To be |
|
6399 // removed when that's fixed. |
|
6400 |
|
6401 return start && start === end && !!state.blocks.byClientId[start] ? start : null; |
|
6402 } |
|
6403 /** |
|
6404 * Returns the currently selected block, or null if there is no selected block. |
|
6405 * |
|
6406 * @param {Object} state Global application state. |
|
6407 * |
|
6408 * @return {?Object} Selected block. |
|
6409 */ |
|
6410 |
|
6411 function selectors_getSelectedBlock(state) { |
|
6412 var clientId = selectors_getSelectedBlockClientId(state); |
|
6413 return clientId ? selectors_getBlock(state, clientId) : null; |
|
6414 } |
|
6415 /** |
|
6416 * Given a block client ID, returns the root block from which the block is |
|
6417 * nested, an empty string for top-level blocks, or null if the block does not |
|
6418 * exist. |
|
6419 * |
|
6420 * @param {Object} state Editor state. |
|
6421 * @param {string} clientId Block from which to find root client ID. |
|
6422 * |
|
6423 * @return {?string} Root client ID, if exists |
|
6424 */ |
|
6425 |
|
6426 var selectors_getBlockRootClientId = Object(rememo["a" /* default */])(function (state, clientId) { |
|
6427 var order = state.blocks.order; |
|
6428 |
|
6429 for (var rootClientId in order) { |
|
6430 if (Object(external_lodash_["includes"])(order[rootClientId], clientId)) { |
|
6431 return rootClientId; |
|
6432 } |
|
6433 } |
|
6434 |
|
6435 return null; |
|
6436 }, function (state) { |
|
6437 return [state.blocks.order]; |
|
6438 }); |
|
6439 /** |
|
6440 * Given a block client ID, returns the root of the hierarchy from which the block is nested, return the block itself for root level blocks. |
|
6441 * |
|
6442 * @param {Object} state Editor state. |
|
6443 * @param {string} clientId Block from which to find root client ID. |
|
6444 * |
|
6445 * @return {string} Root client ID |
|
6446 */ |
|
6447 |
|
6448 var getBlockHierarchyRootClientId = Object(rememo["a" /* default */])(function (state, clientId) { |
|
6449 var rootClientId = clientId; |
|
6450 var current = clientId; |
|
6451 |
|
6452 while (rootClientId) { |
|
6453 current = rootClientId; |
|
6454 rootClientId = selectors_getBlockRootClientId(state, current); |
|
6455 } |
|
6456 |
|
6457 return current; |
|
6458 }, function (state) { |
|
6459 return [state.blocks.order]; |
|
6460 }); |
|
6461 /** |
|
6462 * Returns the client ID of the block adjacent one at the given reference |
|
6463 * startClientId and modifier directionality. Defaults start startClientId to |
|
6464 * the selected block, and direction as next block. Returns null if there is no |
|
6465 * adjacent block. |
|
6466 * |
|
6467 * @param {Object} state Editor state. |
|
6468 * @param {?string} startClientId Optional client ID of block from which to |
|
6469 * search. |
|
6470 * @param {?number} modifier Directionality multiplier (1 next, -1 |
|
6471 * previous). |
|
6472 * |
|
6473 * @return {?string} Return the client ID of the block, or null if none exists. |
|
6474 */ |
|
6475 |
|
6476 function getAdjacentBlockClientId(state, startClientId) { |
|
6477 var modifier = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1; |
|
6478 |
|
6479 // Default to selected block. |
|
6480 if (startClientId === undefined) { |
|
6481 startClientId = selectors_getSelectedBlockClientId(state); |
|
6482 } // Try multi-selection starting at extent based on modifier. |
|
6483 |
|
6484 |
|
6485 if (startClientId === undefined) { |
|
6486 if (modifier < 0) { |
|
6487 startClientId = getFirstMultiSelectedBlockClientId(state); |
|
6488 } else { |
|
6489 startClientId = getLastMultiSelectedBlockClientId(state); |
|
6490 } |
|
6491 } // Validate working start client ID. |
|
6492 |
|
6493 |
|
6494 if (!startClientId) { |
|
6495 return null; |
|
6496 } // Retrieve start block root client ID, being careful to allow the falsey |
|
6497 // empty string top-level root by explicitly testing against null. |
|
6498 |
|
6499 |
|
6500 var rootClientId = selectors_getBlockRootClientId(state, startClientId); |
|
6501 |
|
6502 if (rootClientId === null) { |
|
6503 return null; |
|
6504 } |
|
6505 |
|
6506 var order = state.blocks.order; |
|
6507 var orderSet = order[rootClientId]; |
|
6508 var index = orderSet.indexOf(startClientId); |
|
6509 var nextIndex = index + 1 * modifier; // Block was first in set and we're attempting to get previous. |
|
6510 |
|
6511 if (nextIndex < 0) { |
|
6512 return null; |
|
6513 } // Block was last in set and we're attempting to get next. |
|
6514 |
|
6515 |
|
6516 if (nextIndex === orderSet.length) { |
|
6517 return null; |
|
6518 } // Assume incremented index is within the set. |
|
6519 |
|
6520 |
|
6521 return orderSet[nextIndex]; |
|
6522 } |
|
6523 /** |
|
6524 * Returns the previous block's client ID from the given reference start ID. |
|
6525 * Defaults start to the selected block. Returns null if there is no previous |
|
6526 * block. |
|
6527 * |
|
6528 * @param {Object} state Editor state. |
|
6529 * @param {?string} startClientId Optional client ID of block from which to |
|
6530 * search. |
|
6531 * |
|
6532 * @return {?string} Adjacent block's client ID, or null if none exists. |
|
6533 */ |
|
6534 |
|
6535 function getPreviousBlockClientId(state, startClientId) { |
|
6536 return getAdjacentBlockClientId(state, startClientId, -1); |
|
6537 } |
|
6538 /** |
|
6539 * Returns the next block's client ID from the given reference start ID. |
|
6540 * Defaults start to the selected block. Returns null if there is no next |
|
6541 * block. |
|
6542 * |
|
6543 * @param {Object} state Editor state. |
|
6544 * @param {?string} startClientId Optional client ID of block from which to |
|
6545 * search. |
|
6546 * |
|
6547 * @return {?string} Adjacent block's client ID, or null if none exists. |
|
6548 */ |
|
6549 |
|
6550 function getNextBlockClientId(state, startClientId) { |
|
6551 return getAdjacentBlockClientId(state, startClientId, 1); |
|
6552 } |
|
6553 /** |
|
6554 * Returns the initial caret position for the selected block. |
|
6555 * This position is to used to position the caret properly when the selected block changes. |
|
6556 * |
|
6557 * @param {Object} state Global application state. |
|
6558 * |
|
6559 * @return {?Object} Selected block. |
|
6560 */ |
|
6561 |
|
6562 function selectors_getSelectedBlocksInitialCaretPosition(state) { |
|
6563 var _state$blockSelection3 = state.blockSelection, |
|
6564 start = _state$blockSelection3.start, |
|
6565 end = _state$blockSelection3.end; |
|
6566 |
|
6567 if (start !== end || !start) { |
|
6568 return null; |
|
6569 } |
|
6570 |
|
6571 return state.blockSelection.initialPosition; |
|
6572 } |
|
6573 /** |
|
6574 * Returns the current multi-selection set of block client IDs, or an empty |
|
6575 * array if there is no multi-selection. |
|
6576 * |
|
6577 * @param {Object} state Editor state. |
|
6578 * |
|
6579 * @return {Array} Multi-selected block client IDs. |
|
6580 */ |
|
6581 |
|
6582 var selectors_getMultiSelectedBlockClientIds = Object(rememo["a" /* default */])(function (state) { |
|
6583 var _state$blockSelection4 = state.blockSelection, |
|
6584 start = _state$blockSelection4.start, |
|
6585 end = _state$blockSelection4.end; |
|
6586 |
|
6587 if (start === end) { |
|
6588 return []; |
|
6589 } // Retrieve root client ID to aid in retrieving relevant nested block |
|
6590 // order, being careful to allow the falsey empty string top-level root |
|
6591 // by explicitly testing against null. |
|
6592 |
|
6593 |
|
6594 var rootClientId = selectors_getBlockRootClientId(state, start); |
|
6595 |
|
6596 if (rootClientId === null) { |
|
6597 return []; |
|
6598 } |
|
6599 |
|
6600 var blockOrder = selectors_getBlockOrder(state, rootClientId); |
|
6601 var startIndex = blockOrder.indexOf(start); |
|
6602 var endIndex = blockOrder.indexOf(end); |
|
6603 |
|
6604 if (startIndex > endIndex) { |
|
6605 return blockOrder.slice(endIndex, startIndex + 1); |
|
6606 } |
|
6607 |
|
6608 return blockOrder.slice(startIndex, endIndex + 1); |
|
6609 }, function (state) { |
|
6610 return [state.blocks.order, state.blockSelection.start, state.blockSelection.end]; |
|
6611 }); |
|
6612 /** |
|
6613 * Returns the current multi-selection set of blocks, or an empty array if |
|
6614 * there is no multi-selection. |
|
6615 * |
|
6616 * @param {Object} state Editor state. |
|
6617 * |
|
6618 * @return {Array} Multi-selected block objects. |
|
6619 */ |
|
6620 |
|
6621 var getMultiSelectedBlocks = Object(rememo["a" /* default */])(function (state) { |
|
6622 var multiSelectedBlockClientIds = selectors_getMultiSelectedBlockClientIds(state); |
|
6623 |
|
6624 if (!multiSelectedBlockClientIds.length) { |
|
6625 return EMPTY_ARRAY; |
|
6626 } |
|
6627 |
|
6628 return multiSelectedBlockClientIds.map(function (clientId) { |
|
6629 return selectors_getBlock(state, clientId); |
|
6630 }); |
|
6631 }, function (state) { |
|
6632 return [].concat(Object(toConsumableArray["a" /* default */])(selectors_getMultiSelectedBlockClientIds.getDependants(state)), [state.blocks.byClientId, state.blocks.order, state.blocks.attributes, getPostMeta(state)]); |
|
6633 }); |
|
6634 /** |
|
6635 * Returns the client ID of the first block in the multi-selection set, or null |
|
6636 * if there is no multi-selection. |
|
6637 * |
|
6638 * @param {Object} state Editor state. |
|
6639 * |
|
6640 * @return {?string} First block client ID in the multi-selection set. |
|
6641 */ |
|
6642 |
|
6643 function getFirstMultiSelectedBlockClientId(state) { |
|
6644 return Object(external_lodash_["first"])(selectors_getMultiSelectedBlockClientIds(state)) || null; |
|
6645 } |
|
6646 /** |
|
6647 * Returns the client ID of the last block in the multi-selection set, or null |
|
6648 * if there is no multi-selection. |
|
6649 * |
|
6650 * @param {Object} state Editor state. |
|
6651 * |
|
6652 * @return {?string} Last block client ID in the multi-selection set. |
|
6653 */ |
|
6654 |
|
6655 function getLastMultiSelectedBlockClientId(state) { |
|
6656 return Object(external_lodash_["last"])(selectors_getMultiSelectedBlockClientIds(state)) || null; |
|
6657 } |
|
6658 /** |
|
6659 * Checks if possibleAncestorId is an ancestor of possibleDescendentId. |
|
6660 * |
|
6661 * @param {Object} state Editor state. |
|
6662 * @param {string} possibleAncestorId Possible ancestor client ID. |
|
6663 * @param {string} possibleDescendentId Possible descent client ID. |
|
6664 * |
|
6665 * @return {boolean} True if possibleAncestorId is an ancestor |
|
6666 * of possibleDescendentId, and false otherwise. |
|
6667 */ |
|
6668 |
|
6669 var isAncestorOf = Object(rememo["a" /* default */])(function (state, possibleAncestorId, possibleDescendentId) { |
|
6670 var idToCheck = possibleDescendentId; |
|
6671 |
|
6672 while (possibleAncestorId !== idToCheck && idToCheck) { |
|
6673 idToCheck = selectors_getBlockRootClientId(state, idToCheck); |
|
6674 } |
|
6675 |
|
6676 return possibleAncestorId === idToCheck; |
|
6677 }, function (state) { |
|
6678 return [state.blocks.order]; |
|
6679 }); |
|
6680 /** |
|
6681 * Returns true if a multi-selection exists, and the block corresponding to the |
|
6682 * specified client ID is the first block of the multi-selection set, or false |
|
6683 * otherwise. |
|
6684 * |
|
6685 * @param {Object} state Editor state. |
|
6686 * @param {string} clientId Block client ID. |
|
6687 * |
|
6688 * @return {boolean} Whether block is first in multi-selection. |
|
6689 */ |
|
6690 |
|
6691 function selectors_isFirstMultiSelectedBlock(state, clientId) { |
|
6692 return getFirstMultiSelectedBlockClientId(state) === clientId; |
|
6693 } |
|
6694 /** |
|
6695 * Returns true if the client ID occurs within the block multi-selection, or |
|
6696 * false otherwise. |
|
6697 * |
|
6698 * @param {Object} state Editor state. |
|
6699 * @param {string} clientId Block client ID. |
|
6700 * |
|
6701 * @return {boolean} Whether block is in multi-selection set. |
|
6702 */ |
|
6703 |
|
6704 function selectors_isBlockMultiSelected(state, clientId) { |
|
6705 return selectors_getMultiSelectedBlockClientIds(state).indexOf(clientId) !== -1; |
|
6706 } |
|
6707 /** |
|
6708 * Returns true if an ancestor of the block is multi-selected, or false |
|
6709 * otherwise. |
|
6710 * |
|
6711 * @param {Object} state Editor state. |
|
6712 * @param {string} clientId Block client ID. |
|
6713 * |
|
6714 * @return {boolean} Whether an ancestor of the block is in multi-selection |
|
6715 * set. |
|
6716 */ |
|
6717 |
|
6718 var selectors_isAncestorMultiSelected = Object(rememo["a" /* default */])(function (state, clientId) { |
|
6719 var ancestorClientId = clientId; |
|
6720 var isMultiSelected = false; |
|
6721 |
|
6722 while (ancestorClientId && !isMultiSelected) { |
|
6723 ancestorClientId = selectors_getBlockRootClientId(state, ancestorClientId); |
|
6724 isMultiSelected = selectors_isBlockMultiSelected(state, ancestorClientId); |
|
6725 } |
|
6726 |
|
6727 return isMultiSelected; |
|
6728 }, function (state) { |
|
6729 return [state.blocks.order, state.blockSelection.start, state.blockSelection.end]; |
|
6730 }); |
|
6731 /** |
|
6732 * Returns the client ID of the block which begins the multi-selection set, or |
|
6733 * null if there is no multi-selection. |
|
6734 * |
|
6735 * This is not necessarily the first client ID in the selection. |
|
6736 * |
|
6737 * @see getFirstMultiSelectedBlockClientId |
|
6738 * |
|
6739 * @param {Object} state Editor state. |
|
6740 * |
|
6741 * @return {?string} Client ID of block beginning multi-selection. |
|
6742 */ |
|
6743 |
|
6744 function getMultiSelectedBlocksStartClientId(state) { |
|
6745 var _state$blockSelection5 = state.blockSelection, |
|
6746 start = _state$blockSelection5.start, |
|
6747 end = _state$blockSelection5.end; |
|
6748 |
|
6749 if (start === end) { |
|
6750 return null; |
|
6751 } |
|
6752 |
|
6753 return start || null; |
|
6754 } |
|
6755 /** |
|
6756 * Returns the client ID of the block which ends the multi-selection set, or |
|
6757 * null if there is no multi-selection. |
|
6758 * |
|
6759 * This is not necessarily the last client ID in the selection. |
|
6760 * |
|
6761 * @see getLastMultiSelectedBlockClientId |
|
6762 * |
|
6763 * @param {Object} state Editor state. |
|
6764 * |
|
6765 * @return {?string} Client ID of block ending multi-selection. |
|
6766 */ |
|
6767 |
|
6768 function getMultiSelectedBlocksEndClientId(state) { |
|
6769 var _state$blockSelection6 = state.blockSelection, |
|
6770 start = _state$blockSelection6.start, |
|
6771 end = _state$blockSelection6.end; |
|
6772 |
|
6773 if (start === end) { |
|
6774 return null; |
|
6775 } |
|
6776 |
|
6777 return end || null; |
|
6778 } |
|
6779 /** |
|
6780 * Returns an array containing all block client IDs in the editor in the order |
|
6781 * they appear. Optionally accepts a root client ID of the block list for which |
|
6782 * the order should be returned, defaulting to the top-level block order. |
|
6783 * |
|
6784 * @param {Object} state Editor state. |
|
6785 * @param {?string} rootClientId Optional root client ID of block list. |
|
6786 * |
|
6787 * @return {Array} Ordered client IDs of editor blocks. |
|
6788 */ |
|
6789 |
|
6790 function selectors_getBlockOrder(state, rootClientId) { |
|
6791 return state.blocks.order[rootClientId || ''] || EMPTY_ARRAY; |
|
6792 } |
|
6793 /** |
|
6794 * Returns the index at which the block corresponding to the specified client |
|
6795 * ID occurs within the block order, or `-1` if the block does not exist. |
|
6796 * |
|
6797 * @param {Object} state Editor state. |
|
6798 * @param {string} clientId Block client ID. |
|
6799 * @param {?string} rootClientId Optional root client ID of block list. |
|
6800 * |
|
6801 * @return {number} Index at which block exists in order. |
|
6802 */ |
|
6803 |
|
6804 function selectors_getBlockIndex(state, clientId, rootClientId) { |
|
6805 return selectors_getBlockOrder(state, rootClientId).indexOf(clientId); |
|
6806 } |
|
6807 /** |
|
6808 * Returns true if the block corresponding to the specified client ID is |
|
6809 * currently selected and no multi-selection exists, or false otherwise. |
|
6810 * |
|
6811 * @param {Object} state Editor state. |
|
6812 * @param {string} clientId Block client ID. |
|
6813 * |
|
6814 * @return {boolean} Whether block is selected and multi-selection exists. |
|
6815 */ |
|
6816 |
|
6817 function selectors_isBlockSelected(state, clientId) { |
|
6818 var _state$blockSelection7 = state.blockSelection, |
|
6819 start = _state$blockSelection7.start, |
|
6820 end = _state$blockSelection7.end; |
|
6821 |
|
6822 if (start !== end) { |
|
6823 return false; |
|
6824 } |
|
6825 |
|
6826 return start === clientId; |
|
6827 } |
|
6828 /** |
|
6829 * Returns true if one of the block's inner blocks is selected. |
|
6830 * |
|
6831 * @param {Object} state Editor state. |
|
6832 * @param {string} clientId Block client ID. |
|
6833 * @param {boolean} deep Perform a deep check. |
|
6834 * |
|
6835 * @return {boolean} Whether the block as an inner block selected |
|
6836 */ |
|
6837 |
|
6838 function selectors_hasSelectedInnerBlock(state, clientId) { |
|
6839 var deep = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; |
|
6840 return Object(external_lodash_["some"])(selectors_getBlockOrder(state, clientId), function (innerClientId) { |
|
6841 return selectors_isBlockSelected(state, innerClientId) || selectors_isBlockMultiSelected(state, innerClientId) || deep && selectors_hasSelectedInnerBlock(state, innerClientId, deep); |
|
6842 }); |
|
6843 } |
|
6844 /** |
|
6845 * Returns true if the block corresponding to the specified client ID is |
|
6846 * currently selected but isn't the last of the selected blocks. Here "last" |
|
6847 * refers to the block sequence in the document, _not_ the sequence of |
|
6848 * multi-selection, which is why `state.blockSelection.end` isn't used. |
|
6849 * |
|
6850 * @param {Object} state Editor state. |
|
6851 * @param {string} clientId Block client ID. |
|
6852 * |
|
6853 * @return {boolean} Whether block is selected and not the last in the |
|
6854 * selection. |
|
6855 */ |
|
6856 |
|
6857 function isBlockWithinSelection(state, clientId) { |
|
6858 if (!clientId) { |
|
6859 return false; |
|
6860 } |
|
6861 |
|
6862 var clientIds = selectors_getMultiSelectedBlockClientIds(state); |
|
6863 var index = clientIds.indexOf(clientId); |
|
6864 return index > -1 && index < clientIds.length - 1; |
|
6865 } |
|
6866 /** |
|
6867 * Returns true if a multi-selection has been made, or false otherwise. |
|
6868 * |
|
6869 * @param {Object} state Editor state. |
|
6870 * |
|
6871 * @return {boolean} Whether multi-selection has been made. |
|
6872 */ |
|
6873 |
|
6874 function selectors_hasMultiSelection(state) { |
|
6875 var _state$blockSelection8 = state.blockSelection, |
|
6876 start = _state$blockSelection8.start, |
|
6877 end = _state$blockSelection8.end; |
|
6878 return start !== end; |
|
6879 } |
|
6880 /** |
|
6881 * Whether in the process of multi-selecting or not. This flag is only true |
|
6882 * while the multi-selection is being selected (by mouse move), and is false |
|
6883 * once the multi-selection has been settled. |
|
6884 * |
|
6885 * @see hasMultiSelection |
|
6886 * |
|
6887 * @param {Object} state Global application state. |
|
6888 * |
|
6889 * @return {boolean} True if multi-selecting, false if not. |
|
6890 */ |
|
6891 |
|
6892 function selectors_isMultiSelecting(state) { |
|
6893 return state.blockSelection.isMultiSelecting; |
|
6894 } |
|
6895 /** |
|
6896 * Selector that returns if multi-selection is enabled or not. |
|
6897 * |
|
6898 * @param {Object} state Global application state. |
|
6899 * |
|
6900 * @return {boolean} True if it should be possible to multi-select blocks, false if multi-selection is disabled. |
|
6901 */ |
|
6902 |
|
6903 function selectors_isSelectionEnabled(state) { |
|
6904 return state.blockSelection.isEnabled; |
|
6905 } |
|
6906 /** |
|
6907 * Returns the block's editing mode, defaulting to "visual" if not explicitly |
|
6908 * assigned. |
|
6909 * |
|
6910 * @param {Object} state Editor state. |
|
6911 * @param {string} clientId Block client ID. |
|
6912 * |
|
6913 * @return {Object} Block editing mode. |
|
6914 */ |
|
6915 |
|
6916 function selectors_getBlockMode(state, clientId) { |
|
6917 return state.blocksMode[clientId] || 'visual'; |
|
6918 } |
|
6919 /** |
|
6920 * Returns true if the user is typing, or false otherwise. |
|
6921 * |
|
6922 * @param {Object} state Global application state. |
|
6923 * |
|
6924 * @return {boolean} Whether user is typing. |
|
6925 */ |
|
6926 |
|
6927 function selectors_isTyping(state) { |
|
6928 return state.isTyping; |
|
6929 } |
|
6930 /** |
|
6931 * Returns true if the caret is within formatted text, or false otherwise. |
|
6932 * |
|
6933 * @param {Object} state Global application state. |
|
6934 * |
|
6935 * @return {boolean} Whether the caret is within formatted text. |
|
6936 */ |
|
6937 |
|
6938 function selectors_isCaretWithinFormattedText(state) { |
|
6939 return state.isCaretWithinFormattedText; |
|
6940 } |
|
6941 /** |
|
6942 * Returns the insertion point, the index at which the new inserted block would |
|
6943 * be placed. Defaults to the last index. |
|
6944 * |
|
6945 * @param {Object} state Editor state. |
|
6946 * |
|
6947 * @return {Object} Insertion point object with `rootClientId`, `index`. |
|
6948 */ |
|
6949 |
|
6950 function getBlockInsertionPoint(state) { |
|
6951 var rootClientId, index; |
|
6952 var insertionPoint = state.insertionPoint, |
|
6953 blockSelection = state.blockSelection; |
|
6954 |
|
6955 if (insertionPoint !== null) { |
|
6956 return insertionPoint; |
|
6957 } |
|
6958 |
|
6959 var end = blockSelection.end; |
|
6960 |
|
6961 if (end) { |
|
6962 rootClientId = selectors_getBlockRootClientId(state, end) || undefined; |
|
6963 index = selectors_getBlockIndex(state, end, rootClientId) + 1; |
|
6964 } else { |
|
6965 index = selectors_getBlockOrder(state).length; |
|
6966 } |
|
6967 |
|
6968 return { |
|
6969 rootClientId: rootClientId, |
|
6970 index: index |
|
6971 }; |
|
6972 } |
|
6973 /** |
|
6974 * Returns true if we should show the block insertion point. |
|
6975 * |
|
6976 * @param {Object} state Global application state. |
|
6977 * |
|
6978 * @return {?boolean} Whether the insertion point is visible or not. |
|
6979 */ |
|
6980 |
|
6981 function isBlockInsertionPointVisible(state) { |
|
6982 return state.insertionPoint !== null; |
|
6983 } |
|
6984 /** |
|
6985 * Returns whether the blocks matches the template or not. |
|
6986 * |
|
6987 * @param {boolean} state |
|
6988 * @return {?boolean} Whether the template is valid or not. |
|
6989 */ |
|
6990 |
|
6991 function isValidTemplate(state) { |
|
6992 return state.template.isValid; |
|
6993 } |
|
6994 /** |
|
6995 * Returns the defined block template |
|
6996 * |
|
6997 * @param {boolean} state |
|
6998 * @return {?Array} Block Template |
|
6999 */ |
|
7000 |
|
7001 function getTemplate(state) { |
|
7002 return state.settings.template; |
|
7003 } |
|
7004 /** |
|
7005 * Returns the defined block template lock. Optionally accepts a root block |
|
7006 * client ID as context, otherwise defaulting to the global context. |
|
7007 * |
|
7008 * @param {Object} state Editor state. |
|
7009 * @param {?string} rootClientId Optional block root client ID. |
|
7010 * |
|
7011 * @return {?string} Block Template Lock |
|
7012 */ |
|
7013 |
|
7014 function selectors_getTemplateLock(state, rootClientId) { |
|
7015 if (!rootClientId) { |
|
7016 return state.settings.templateLock; |
|
7017 } |
|
7018 |
|
7019 var blockListSettings = getBlockListSettings(state, rootClientId); |
|
7020 |
|
7021 if (!blockListSettings) { |
|
7022 return null; |
|
7023 } |
|
7024 |
|
7025 return blockListSettings.templateLock; |
|
7026 } |
|
7027 /** |
|
7028 * Determines if the given block type is allowed to be inserted into the block list. |
|
7029 * This function is not exported and not memoized because using a memoized selector |
|
7030 * inside another memoized selector is just a waste of time. |
|
7031 * |
|
7032 * @param {Object} state Editor state. |
|
7033 * @param {string} blockName The name of the block type, e.g.' core/paragraph'. |
|
7034 * @param {?string} rootClientId Optional root client ID of block list. |
|
7035 * |
|
7036 * @return {boolean} Whether the given block type is allowed to be inserted. |
|
7037 */ |
|
7038 |
|
7039 var selectors_canInsertBlockTypeUnmemoized = function canInsertBlockTypeUnmemoized(state, blockName) { |
|
7040 var rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; |
|
7041 |
|
7042 var checkAllowList = function checkAllowList(list, item) { |
|
7043 var defaultResult = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; |
|
7044 |
|
7045 if (Object(external_lodash_["isBoolean"])(list)) { |
|
7046 return list; |
|
7047 } |
|
7048 |
|
7049 if (Object(external_lodash_["isArray"])(list)) { |
|
7050 return Object(external_lodash_["includes"])(list, item); |
|
7051 } |
|
7052 |
|
7053 return defaultResult; |
|
7054 }; |
|
7055 |
|
7056 var blockType = Object(external_this_wp_blocks_["getBlockType"])(blockName); |
|
7057 |
|
7058 if (!blockType) { |
|
7059 return false; |
|
7060 } |
|
7061 |
|
7062 var _getSettings = selectors_getSettings(state), |
|
7063 allowedBlockTypes = _getSettings.allowedBlockTypes; |
|
7064 |
|
7065 var isBlockAllowedInEditor = checkAllowList(allowedBlockTypes, blockName, true); |
|
7066 |
|
7067 if (!isBlockAllowedInEditor) { |
|
7068 return false; |
|
7069 } |
|
7070 |
|
7071 var isLocked = !!selectors_getTemplateLock(state, rootClientId); |
|
7072 |
|
7073 if (isLocked) { |
|
7074 return false; |
|
7075 } |
|
7076 |
|
7077 var parentBlockListSettings = getBlockListSettings(state, rootClientId); |
|
7078 var parentAllowedBlocks = Object(external_lodash_["get"])(parentBlockListSettings, ['allowedBlocks']); |
|
7079 var hasParentAllowedBlock = checkAllowList(parentAllowedBlocks, blockName); |
|
7080 var blockAllowedParentBlocks = blockType.parent; |
|
7081 var parentName = selectors_getBlockName(state, rootClientId); |
|
7082 var hasBlockAllowedParent = checkAllowList(blockAllowedParentBlocks, parentName); |
|
7083 |
|
7084 if (hasParentAllowedBlock !== null && hasBlockAllowedParent !== null) { |
|
7085 return hasParentAllowedBlock || hasBlockAllowedParent; |
|
7086 } else if (hasParentAllowedBlock !== null) { |
|
7087 return hasParentAllowedBlock; |
|
7088 } else if (hasBlockAllowedParent !== null) { |
|
7089 return hasBlockAllowedParent; |
|
7090 } |
|
7091 |
|
7092 return true; |
|
7093 }; |
|
7094 /** |
|
7095 * Determines if the given block type is allowed to be inserted into the block list. |
|
7096 * |
|
7097 * @param {Object} state Editor state. |
|
7098 * @param {string} blockName The name of the block type, e.g.' core/paragraph'. |
|
7099 * @param {?string} rootClientId Optional root client ID of block list. |
|
7100 * |
|
7101 * @return {boolean} Whether the given block type is allowed to be inserted. |
|
7102 */ |
|
7103 |
|
7104 |
|
7105 var selectors_canInsertBlockType = Object(rememo["a" /* default */])(selectors_canInsertBlockTypeUnmemoized, function (state, blockName, rootClientId) { |
|
7106 return [state.blockListSettings[rootClientId], state.blocks.byClientId[rootClientId], state.settings.allowedBlockTypes, state.settings.templateLock]; |
|
7107 }); |
|
7108 /** |
|
7109 * Returns information about how recently and frequently a block has been inserted. |
|
7110 * |
|
7111 * @param {Object} state Global application state. |
|
7112 * @param {string} id A string which identifies the insert, e.g. 'core/block/12' |
|
7113 * |
|
7114 * @return {?{ time: number, count: number }} An object containing `time` which is when the last |
|
7115 * insert occurred as a UNIX epoch, and `count` which is |
|
7116 * the number of inserts that have occurred. |
|
7117 */ |
|
7118 |
|
7119 function getInsertUsage(state, id) { |
|
7120 return state.preferences.insertUsage[id] || null; |
|
7121 } |
|
7122 /** |
|
7123 * Returns whether we can show a block type in the inserter |
|
7124 * |
|
7125 * @param {Object} state Global State |
|
7126 * @param {Object} blockType BlockType |
|
7127 * @param {?string} rootClientId Optional root client ID of block list. |
|
7128 * |
|
7129 * @return {boolean} Whether the given block type is allowed to be shown in the inserter. |
|
7130 */ |
|
7131 |
|
7132 |
|
7133 var selectors_canIncludeBlockTypeInInserter = function canIncludeBlockTypeInInserter(state, blockType, rootClientId) { |
|
7134 if (!Object(external_this_wp_blocks_["hasBlockSupport"])(blockType, 'inserter', true)) { |
|
7135 return false; |
|
7136 } |
|
7137 |
|
7138 return selectors_canInsertBlockTypeUnmemoized(state, blockType.name, rootClientId); |
|
7139 }; |
|
7140 /** |
|
7141 * Returns whether we can show a reusable block in the inserter |
|
7142 * |
|
7143 * @param {Object} state Global State |
|
7144 * @param {Object} reusableBlock Reusable block object |
|
7145 * @param {?string} rootClientId Optional root client ID of block list. |
|
7146 * |
|
7147 * @return {boolean} Whether the given block type is allowed to be shown in the inserter. |
|
7148 */ |
|
7149 |
|
7150 |
|
7151 var selectors_canIncludeReusableBlockInInserter = function canIncludeReusableBlockInInserter(state, reusableBlock, rootClientId) { |
|
7152 if (!selectors_canInsertBlockTypeUnmemoized(state, 'core/block', rootClientId)) { |
|
7153 return false; |
|
7154 } |
|
7155 |
|
7156 var referencedBlockName = selectors_getBlockName(state, reusableBlock.clientId); |
|
7157 |
|
7158 if (!referencedBlockName) { |
|
7159 return false; |
|
7160 } |
|
7161 |
|
7162 var referencedBlockType = Object(external_this_wp_blocks_["getBlockType"])(referencedBlockName); |
|
7163 |
|
7164 if (!referencedBlockType) { |
|
7165 return false; |
|
7166 } |
|
7167 |
|
7168 if (!selectors_canInsertBlockTypeUnmemoized(state, referencedBlockName, rootClientId)) { |
|
7169 return false; |
|
7170 } |
|
7171 |
|
7172 if (isAncestorOf(state, reusableBlock.clientId, rootClientId)) { |
|
7173 return false; |
|
7174 } |
|
7175 |
|
7176 return true; |
|
7177 }; |
|
7178 /** |
|
7179 * Determines the items that appear in the inserter. Includes both static |
|
7180 * items (e.g. a regular block type) and dynamic items (e.g. a reusable block). |
|
7181 * |
|
7182 * Each item object contains what's necessary to display a button in the |
|
7183 * inserter and handle its selection. |
|
7184 * |
|
7185 * The 'utility' property indicates how useful we think an item will be to the |
|
7186 * user. There are 4 levels of utility: |
|
7187 * |
|
7188 * 1. Blocks that are contextually useful (utility = 3) |
|
7189 * 2. Blocks that have been previously inserted (utility = 2) |
|
7190 * 3. Blocks that are in the common category (utility = 1) |
|
7191 * 4. All other blocks (utility = 0) |
|
7192 * |
|
7193 * The 'frecency' property is a heuristic (https://en.wikipedia.org/wiki/Frecency) |
|
7194 * that combines block usage frequenty and recency. |
|
7195 * |
|
7196 * Items are returned ordered descendingly by their 'utility' and 'frecency'. |
|
7197 * |
|
7198 * @param {Object} state Editor state. |
|
7199 * @param {?string} rootClientId Optional root client ID of block list. |
|
7200 * |
|
7201 * @return {Editor.InserterItem[]} Items that appear in inserter. |
|
7202 * |
|
7203 * @typedef {Object} Editor.InserterItem |
|
7204 * @property {string} id Unique identifier for the item. |
|
7205 * @property {string} name The type of block to create. |
|
7206 * @property {Object} initialAttributes Attributes to pass to the newly created block. |
|
7207 * @property {string} title Title of the item, as it appears in the inserter. |
|
7208 * @property {string} icon Dashicon for the item, as it appears in the inserter. |
|
7209 * @property {string} category Block category that the item is associated with. |
|
7210 * @property {string[]} keywords Keywords that can be searched to find this item. |
|
7211 * @property {boolean} isDisabled Whether or not the user should be prevented from inserting |
|
7212 * this item. |
|
7213 * @property {number} utility How useful we think this item is, between 0 and 3. |
|
7214 * @property {number} frecency Hueristic that combines frequency and recency. |
|
7215 */ |
|
7216 |
|
7217 |
|
7218 var selectors_getInserterItems = Object(rememo["a" /* default */])(function (state) { |
|
7219 var rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; |
|
7220 |
|
7221 var calculateUtility = function calculateUtility(category, count, isContextual) { |
|
7222 if (isContextual) { |
|
7223 return INSERTER_UTILITY_HIGH; |
|
7224 } else if (count > 0) { |
|
7225 return INSERTER_UTILITY_MEDIUM; |
|
7226 } else if (category === 'common') { |
|
7227 return INSERTER_UTILITY_LOW; |
|
7228 } |
|
7229 |
|
7230 return INSERTER_UTILITY_NONE; |
|
7231 }; |
|
7232 |
|
7233 var calculateFrecency = function calculateFrecency(time, count) { |
|
7234 if (!time) { |
|
7235 return count; |
|
7236 } // The selector is cached, which means Date.now() is the last time that the |
|
7237 // relevant state changed. This suits our needs. |
|
7238 |
|
7239 |
|
7240 var duration = Date.now() - time; |
|
7241 |
|
7242 switch (true) { |
|
7243 case duration < MILLISECONDS_PER_HOUR: |
|
7244 return count * 4; |
|
7245 |
|
7246 case duration < MILLISECONDS_PER_DAY: |
|
7247 return count * 2; |
|
7248 |
|
7249 case duration < MILLISECONDS_PER_WEEK: |
|
7250 return count / 2; |
|
7251 |
|
7252 default: |
|
7253 return count / 4; |
|
7254 } |
|
7255 }; |
|
7256 |
|
7257 var buildBlockTypeInserterItem = function buildBlockTypeInserterItem(blockType) { |
|
7258 var id = blockType.name; |
|
7259 var isDisabled = false; |
|
7260 |
|
7261 if (!Object(external_this_wp_blocks_["hasBlockSupport"])(blockType.name, 'multiple', true)) { |
|
7262 isDisabled = Object(external_lodash_["some"])(selectors_getBlocksByClientId(state, getClientIdsWithDescendants(state)), { |
|
7263 name: blockType.name |
|
7264 }); |
|
7265 } |
|
7266 |
|
7267 var isContextual = Object(external_lodash_["isArray"])(blockType.parent); |
|
7268 |
|
7269 var _ref = getInsertUsage(state, id) || {}, |
|
7270 time = _ref.time, |
|
7271 _ref$count = _ref.count, |
|
7272 count = _ref$count === void 0 ? 0 : _ref$count; |
|
7273 |
|
7274 return { |
|
7275 id: id, |
|
7276 name: blockType.name, |
|
7277 initialAttributes: {}, |
|
7278 title: blockType.title, |
|
7279 icon: blockType.icon, |
|
7280 category: blockType.category, |
|
7281 keywords: blockType.keywords, |
|
7282 isDisabled: isDisabled, |
|
7283 utility: calculateUtility(blockType.category, count, isContextual), |
|
7284 frecency: calculateFrecency(time, count), |
|
7285 hasChildBlocksWithInserterSupport: Object(external_this_wp_blocks_["hasChildBlocksWithInserterSupport"])(blockType.name) |
|
7286 }; |
|
7287 }; |
|
7288 |
|
7289 var buildReusableBlockInserterItem = function buildReusableBlockInserterItem(reusableBlock) { |
|
7290 var id = "core/block/".concat(reusableBlock.id); |
|
7291 var referencedBlockName = selectors_getBlockName(state, reusableBlock.clientId); |
|
7292 var referencedBlockType = Object(external_this_wp_blocks_["getBlockType"])(referencedBlockName); |
|
7293 |
|
7294 var _ref2 = getInsertUsage(state, id) || {}, |
|
7295 time = _ref2.time, |
|
7296 _ref2$count = _ref2.count, |
|
7297 count = _ref2$count === void 0 ? 0 : _ref2$count; |
|
7298 |
|
7299 var utility = calculateUtility('reusable', count, false); |
|
7300 var frecency = calculateFrecency(time, count); |
|
7301 return { |
|
7302 id: id, |
|
7303 name: 'core/block', |
|
7304 initialAttributes: { |
|
7305 ref: reusableBlock.id |
|
7306 }, |
|
7307 title: reusableBlock.title, |
|
7308 icon: referencedBlockType.icon, |
|
7309 category: 'reusable', |
|
7310 keywords: [], |
|
7311 isDisabled: false, |
|
7312 utility: utility, |
|
7313 frecency: frecency |
|
7314 }; |
|
7315 }; |
|
7316 |
|
7317 var blockTypeInserterItems = Object(external_this_wp_blocks_["getBlockTypes"])().filter(function (blockType) { |
|
7318 return selectors_canIncludeBlockTypeInInserter(state, blockType, rootClientId); |
|
7319 }).map(buildBlockTypeInserterItem); |
|
7320 var reusableBlockInserterItems = getReusableBlocks(state).filter(function (block) { |
|
7321 return selectors_canIncludeReusableBlockInInserter(state, block, rootClientId); |
|
7322 }).map(buildReusableBlockInserterItem); |
|
7323 return Object(external_lodash_["orderBy"])([].concat(Object(toConsumableArray["a" /* default */])(blockTypeInserterItems), Object(toConsumableArray["a" /* default */])(reusableBlockInserterItems)), ['utility', 'frecency'], ['desc', 'desc']); |
|
7324 }, function (state, rootClientId) { |
|
7325 return [state.blockListSettings[rootClientId], state.blocks.byClientId, state.blocks.order, state.preferences.insertUsage, state.settings.allowedBlockTypes, state.settings.templateLock, getReusableBlocks(state), Object(external_this_wp_blocks_["getBlockTypes"])()]; |
|
7326 }); |
|
7327 /** |
|
7328 * Determines whether there are items to show in the inserter. |
|
7329 * @param {Object} state Editor state. |
|
7330 * @param {?string} rootClientId Optional root client ID of block list. |
|
7331 * |
|
7332 * @return {boolean} Items that appear in inserter. |
|
7333 */ |
|
7334 |
|
7335 var hasInserterItems = Object(rememo["a" /* default */])(function (state) { |
|
7336 var rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; |
|
7337 var hasBlockType = Object(external_lodash_["some"])(Object(external_this_wp_blocks_["getBlockTypes"])(), function (blockType) { |
|
7338 return selectors_canIncludeBlockTypeInInserter(state, blockType, rootClientId); |
|
7339 }); |
|
7340 |
|
7341 if (hasBlockType) { |
|
7342 return true; |
|
7343 } |
|
7344 |
|
7345 var hasReusableBlock = Object(external_lodash_["some"])(getReusableBlocks(state), function (block) { |
|
7346 return selectors_canIncludeReusableBlockInInserter(state, block, rootClientId); |
|
7347 }); |
|
7348 return hasReusableBlock; |
|
7349 }, function (state, rootClientId) { |
|
7350 return [state.blockListSettings[rootClientId], state.blocks.byClientId, state.settings.allowedBlockTypes, state.settings.templateLock, getReusableBlocks(state), Object(external_this_wp_blocks_["getBlockTypes"])()]; |
|
7351 }); |
|
7352 /** |
|
7353 * Returns the Block List settings of a block, if any exist. |
|
7354 * |
|
7355 * @param {Object} state Editor state. |
|
7356 * @param {?string} clientId Block client ID. |
|
7357 * |
|
7358 * @return {?Object} Block settings of the block if set. |
|
7359 */ |
|
7360 |
|
7361 function getBlockListSettings(state, clientId) { |
|
7362 return state.blockListSettings[clientId]; |
|
7363 } |
|
7364 /** |
|
7365 * Returns the editor settings. |
|
7366 * |
|
7367 * @param {Object} state Editor state. |
|
7368 * |
|
7369 * @return {Object} The editor settings object. |
|
7370 */ |
|
7371 |
|
7372 function selectors_getSettings(state) { |
|
7373 return state.settings; |
|
7374 } |
|
7375 /** |
|
7376 * Returns true if the most recent block change is be considered persistent, or |
|
7377 * false otherwise. A persistent change is one committed by BlockEditorProvider |
|
7378 * via its `onChange` callback, in addition to `onInput`. |
|
7379 * |
|
7380 * @param {Object} state Block editor state. |
|
7381 * |
|
7382 * @return {boolean} Whether the most recent block change was persistent. |
|
7383 */ |
|
7384 |
|
7385 function isLastBlockChangePersistent(state) { |
|
7386 return state.blocks.isPersistentChange; |
|
7387 } |
|
7388 /** |
|
7389 * Returns true if the most recent block change is be considered ignored, or |
|
7390 * false otherwise. An ignored change is one not to be committed by |
|
7391 * BlockEditorProvider, neither via `onChange` nor `onInput`. |
|
7392 * |
|
7393 * @param {Object} state Block editor state. |
|
7394 * |
|
7395 * @return {boolean} Whether the most recent block change was ignored. |
|
7396 */ |
|
7397 |
|
7398 function __unstableIsLastBlockChangeIgnored(state) { |
|
7399 // TODO: Removal Plan: Changes incurred by RECEIVE_BLOCKS should not be |
|
7400 // ignored if in-fact they result in a change in blocks state. The current |
|
7401 // need to ignore changes not a result of user interaction should be |
|
7402 // accounted for in the refactoring of reusable blocks as occurring within |
|
7403 // their own separate block editor / state (#7119). |
|
7404 return state.blocks.isIgnoredChange; |
|
7405 } |
|
7406 /** |
|
7407 * Returns the value of a post meta from the editor settings. |
|
7408 * |
|
7409 * @param {Object} state Global application state. |
|
7410 * @param {string} key Meta Key to retrieve |
|
7411 * |
|
7412 * @return {*} Meta value |
|
7413 */ |
|
7414 |
|
7415 function getPostMeta(state, key) { |
|
7416 if (key === undefined) { |
|
7417 return Object(external_lodash_["get"])(state, ['settings', '__experimentalMetaSource', 'value'], EMPTY_OBJECT); |
|
7418 } |
|
7419 |
|
7420 return Object(external_lodash_["get"])(state, ['settings', '__experimentalMetaSource', 'value', key]); |
|
7421 } |
|
7422 /** |
|
7423 * Returns the available reusable blocks |
|
7424 * |
|
7425 * @param {Object} state Global application state. |
|
7426 * |
|
7427 * @return {Array} Reusable blocks |
|
7428 */ |
|
7429 |
|
7430 |
|
7431 function getReusableBlocks(state) { |
|
7432 return Object(external_lodash_["get"])(state, ['settings', '__experimentalReusableBlocks'], EMPTY_ARRAY); |
|
7433 } |
|
7434 |
|
7435 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/effects.js |
|
7436 |
|
7437 |
|
7438 |
|
7439 |
|
7440 /** |
|
7441 * WordPress dependencies |
|
7442 */ |
|
7443 |
|
7444 |
|
7445 |
|
7446 /** |
|
7447 * Internal dependencies |
|
7448 */ |
|
7449 |
|
7450 |
|
7451 |
|
7452 /** |
|
7453 * Block validity is a function of blocks state (at the point of a |
|
7454 * reset) and the template setting. As a compromise to its placement |
|
7455 * across distinct parts of state, it is implemented here as a side- |
|
7456 * effect of the block reset action. |
|
7457 * |
|
7458 * @param {Object} action RESET_BLOCKS action. |
|
7459 * @param {Object} store Store instance. |
|
7460 * |
|
7461 * @return {?Object} New validity set action if validity has changed. |
|
7462 */ |
|
7463 |
|
7464 function validateBlocksToTemplate(action, store) { |
|
7465 var state = store.getState(); |
|
7466 var template = getTemplate(state); |
|
7467 var templateLock = selectors_getTemplateLock(state); // Unlocked templates are considered always valid because they act |
|
7468 // as default values only. |
|
7469 |
|
7470 var isBlocksValidToTemplate = !template || templateLock !== 'all' || Object(external_this_wp_blocks_["doBlocksMatchTemplate"])(action.blocks, template); // Update if validity has changed. |
|
7471 |
|
7472 if (isBlocksValidToTemplate !== isValidTemplate(state)) { |
|
7473 return setTemplateValidity(isBlocksValidToTemplate); |
|
7474 } |
|
7475 } |
|
7476 /* harmony default export */ var effects = ({ |
|
7477 MERGE_BLOCKS: function MERGE_BLOCKS(action, store) { |
|
7478 var dispatch = store.dispatch; |
|
7479 var state = store.getState(); |
|
7480 |
|
7481 var _action$blocks = Object(slicedToArray["a" /* default */])(action.blocks, 2), |
|
7482 firstBlockClientId = _action$blocks[0], |
|
7483 secondBlockClientId = _action$blocks[1]; |
|
7484 |
|
7485 var blockA = selectors_getBlock(state, firstBlockClientId); |
|
7486 var blockType = Object(external_this_wp_blocks_["getBlockType"])(blockA.name); // Only focus the previous block if it's not mergeable |
|
7487 |
|
7488 if (!blockType.merge) { |
|
7489 dispatch(actions_selectBlock(blockA.clientId)); |
|
7490 return; |
|
7491 } // We can only merge blocks with similar types |
|
7492 // thus, we transform the block to merge first |
|
7493 |
|
7494 |
|
7495 var blockB = selectors_getBlock(state, secondBlockClientId); |
|
7496 var blocksWithTheSameType = blockA.name === blockB.name ? [blockB] : Object(external_this_wp_blocks_["switchToBlockType"])(blockB, blockA.name); // If the block types can not match, do nothing |
|
7497 |
|
7498 if (!blocksWithTheSameType || !blocksWithTheSameType.length) { |
|
7499 return; |
|
7500 } // Calling the merge to update the attributes and remove the block to be merged |
|
7501 |
|
7502 |
|
7503 var updatedAttributes = blockType.merge(blockA.attributes, blocksWithTheSameType[0].attributes); |
|
7504 dispatch(actions_selectBlock(blockA.clientId, -1)); |
|
7505 dispatch(actions_replaceBlocks([blockA.clientId, blockB.clientId], [Object(objectSpread["a" /* default */])({}, blockA, { |
|
7506 attributes: Object(objectSpread["a" /* default */])({}, blockA.attributes, updatedAttributes) |
|
7507 })].concat(Object(toConsumableArray["a" /* default */])(blocksWithTheSameType.slice(1))))); |
|
7508 }, |
|
7509 RESET_BLOCKS: [validateBlocksToTemplate], |
|
7510 MULTI_SELECT: function MULTI_SELECT(action, _ref) { |
|
7511 var getState = _ref.getState; |
|
7512 var blockCount = selectors_getSelectedBlockCount(getState()); |
|
7513 /* translators: %s: number of selected blocks */ |
|
7514 |
|
7515 Object(external_this_wp_a11y_["speak"])(Object(external_this_wp_i18n_["sprintf"])(Object(external_this_wp_i18n_["_n"])('%s block selected.', '%s blocks selected.', blockCount), blockCount), 'assertive'); |
|
7516 }, |
|
7517 SYNCHRONIZE_TEMPLATE: function SYNCHRONIZE_TEMPLATE(action, _ref2) { |
|
7518 var getState = _ref2.getState; |
|
7519 var state = getState(); |
|
7520 var blocks = getBlocks(state); |
|
7521 var template = getTemplate(state); |
|
7522 var updatedBlockList = Object(external_this_wp_blocks_["synchronizeBlocksWithTemplate"])(blocks, template); |
|
7523 return resetBlocks(updatedBlockList); |
|
7524 } |
|
7525 }); |
|
7526 |
|
7527 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/middlewares.js |
|
7528 |
|
7529 |
|
7530 /** |
|
7531 * External dependencies |
|
7532 */ |
|
7533 |
|
7534 |
|
7535 |
|
7536 /** |
|
7537 * Internal dependencies |
|
7538 */ |
|
7539 |
|
7540 |
|
7541 /** |
|
7542 * Applies the custom middlewares used specifically in the editor module. |
|
7543 * |
|
7544 * @param {Object} store Store Object. |
|
7545 * |
|
7546 * @return {Object} Update Store Object. |
|
7547 */ |
|
7548 |
|
7549 function applyMiddlewares(store) { |
|
7550 var middlewares = [refx_default()(effects), lib_default.a]; |
|
7551 |
|
7552 var enhancedDispatch = function enhancedDispatch() { |
|
7553 throw new Error('Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.'); |
|
7554 }; |
|
7555 |
|
7556 var chain = []; |
|
7557 var middlewareAPI = { |
|
7558 getState: store.getState, |
|
7559 dispatch: function dispatch() { |
|
7560 return enhancedDispatch.apply(void 0, arguments); |
|
7561 } |
|
7562 }; |
|
7563 chain = middlewares.map(function (middleware) { |
|
7564 return middleware(middlewareAPI); |
|
7565 }); |
|
7566 enhancedDispatch = external_lodash_["flowRight"].apply(void 0, Object(toConsumableArray["a" /* default */])(chain))(store.dispatch); |
|
7567 store.dispatch = enhancedDispatch; |
|
7568 return store; |
|
7569 } |
|
7570 |
|
7571 /* harmony default export */ var store_middlewares = (applyMiddlewares); |
|
7572 |
|
7573 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/index.js |
|
7574 /** |
|
7575 * WordPress dependencies |
|
7576 */ |
|
7577 |
|
7578 /** |
|
7579 * Internal dependencies |
|
7580 */ |
|
7581 |
|
7582 |
|
7583 |
|
7584 |
|
7585 |
|
7586 |
|
7587 /** |
|
7588 * Module Constants |
|
7589 */ |
|
7590 |
|
7591 var MODULE_KEY = 'core/block-editor'; |
|
7592 var store_store = Object(external_this_wp_data_["registerStore"])(MODULE_KEY, { |
|
7593 reducer: store_reducer, |
|
7594 selectors: selectors_namespaceObject, |
|
7595 actions: actions_namespaceObject, |
|
7596 controls: store_controls, |
|
7597 persist: ['preferences'] |
|
7598 }); |
|
7599 store_middlewares(store_store); |
|
7600 /* harmony default export */ var build_module_store = (store_store); |
|
7601 |
|
7602 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js |
|
7603 var esm_extends = __webpack_require__(19); |
|
7604 |
|
7605 // EXTERNAL MODULE: external {"this":["wp","element"]} |
|
7606 var external_this_wp_element_ = __webpack_require__(0); |
|
7607 |
|
7608 // EXTERNAL MODULE: ./node_modules/classnames/index.js |
|
7609 var classnames = __webpack_require__(16); |
|
7610 var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames); |
|
7611 |
|
7612 // EXTERNAL MODULE: external {"this":["wp","compose"]} |
|
7613 var external_this_wp_compose_ = __webpack_require__(6); |
|
7614 |
|
7615 // EXTERNAL MODULE: external {"this":["wp","hooks"]} |
|
7616 var external_this_wp_hooks_ = __webpack_require__(26); |
|
7617 |
|
7618 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js |
|
7619 var classCallCheck = __webpack_require__(10); |
|
7620 |
|
7621 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js |
|
7622 var createClass = __webpack_require__(9); |
|
7623 |
|
7624 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js |
|
7625 var possibleConstructorReturn = __webpack_require__(11); |
|
7626 |
|
7627 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js |
|
7628 var getPrototypeOf = __webpack_require__(12); |
|
7629 |
|
7630 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js + 1 modules |
|
7631 var inherits = __webpack_require__(13); |
|
7632 |
|
7633 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js |
|
7634 var assertThisInitialized = __webpack_require__(3); |
|
7635 |
|
7636 // EXTERNAL MODULE: external {"this":["wp","components"]} |
|
7637 var external_this_wp_components_ = __webpack_require__(4); |
|
7638 |
|
7639 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-edit/context.js |
|
7640 |
|
7641 |
|
7642 |
|
7643 /** |
|
7644 * External dependencies |
|
7645 */ |
|
7646 |
|
7647 /** |
|
7648 * WordPress dependencies |
|
7649 */ |
|
7650 |
|
7651 |
|
7652 |
|
7653 |
|
7654 var _createContext = Object(external_this_wp_element_["createContext"])({ |
|
7655 name: '', |
|
7656 isSelected: false, |
|
7657 focusedElement: null, |
|
7658 setFocusedElement: external_lodash_["noop"], |
|
7659 clientId: null |
|
7660 }), |
|
7661 Consumer = _createContext.Consumer, |
|
7662 Provider = _createContext.Provider; |
|
7663 |
|
7664 |
|
7665 /** |
|
7666 * A Higher Order Component used to inject BlockEdit context to the |
|
7667 * wrapped component. |
|
7668 * |
|
7669 * @param {Function} mapContextToProps Function called on every context change, |
|
7670 * expected to return object of props to |
|
7671 * merge with the component's own props. |
|
7672 * |
|
7673 * @return {Component} Enhanced component with injected context as props. |
|
7674 */ |
|
7675 |
|
7676 var context_withBlockEditContext = function withBlockEditContext(mapContextToProps) { |
|
7677 return Object(external_this_wp_compose_["createHigherOrderComponent"])(function (OriginalComponent) { |
|
7678 return function (props) { |
|
7679 return Object(external_this_wp_element_["createElement"])(Consumer, null, function (context) { |
|
7680 return Object(external_this_wp_element_["createElement"])(OriginalComponent, Object(esm_extends["a" /* default */])({}, props, mapContextToProps(context, props))); |
|
7681 }); |
|
7682 }; |
|
7683 }, 'withBlockEditContext'); |
|
7684 }; |
|
7685 /** |
|
7686 * A Higher Order Component used to render conditionally the wrapped |
|
7687 * component only when the BlockEdit has selected state set. |
|
7688 * |
|
7689 * @param {Component} OriginalComponent Component to wrap. |
|
7690 * |
|
7691 * @return {Component} Component which renders only when the BlockEdit is selected. |
|
7692 */ |
|
7693 |
|
7694 var ifBlockEditSelected = Object(external_this_wp_compose_["createHigherOrderComponent"])(function (OriginalComponent) { |
|
7695 return function (props) { |
|
7696 return Object(external_this_wp_element_["createElement"])(Consumer, null, function (_ref) { |
|
7697 var isSelected = _ref.isSelected; |
|
7698 return isSelected && Object(external_this_wp_element_["createElement"])(OriginalComponent, props); |
|
7699 }); |
|
7700 }; |
|
7701 }, 'ifBlockEditSelected'); |
|
7702 |
|
7703 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/autocomplete/index.js |
|
7704 |
|
7705 |
|
7706 |
|
7707 |
|
7708 |
|
7709 |
|
7710 |
|
7711 |
|
7712 |
|
7713 |
|
7714 /** |
|
7715 * External dependencies |
|
7716 */ |
|
7717 |
|
7718 /** |
|
7719 * WordPress dependencies |
|
7720 */ |
|
7721 |
|
7722 |
|
7723 |
|
7724 |
|
7725 |
|
7726 /** |
|
7727 * Internal dependencies |
|
7728 */ |
|
7729 |
|
7730 |
|
7731 /* |
|
7732 * Use one array instance for fallback rather than inline array literals |
|
7733 * because the latter may cause rerender due to failed prop equality checks. |
|
7734 */ |
|
7735 |
|
7736 var completersFallback = []; |
|
7737 /** |
|
7738 * Wrap the default Autocomplete component with one that |
|
7739 * supports a filter hook for customizing its list of autocompleters. |
|
7740 * |
|
7741 * Since there may be many Autocomplete instances at one time, this component |
|
7742 * applies the filter on demand, when the component is first focused after |
|
7743 * receiving a new list of completers. |
|
7744 * |
|
7745 * This function is exported for unit test. |
|
7746 * |
|
7747 * @param {Function} Autocomplete Original component. |
|
7748 * @return {Function} Wrapped component |
|
7749 */ |
|
7750 |
|
7751 function withFilteredAutocompleters(Autocomplete) { |
|
7752 return ( |
|
7753 /*#__PURE__*/ |
|
7754 function (_Component) { |
|
7755 Object(inherits["a" /* default */])(FilteredAutocomplete, _Component); |
|
7756 |
|
7757 function FilteredAutocomplete() { |
|
7758 var _this; |
|
7759 |
|
7760 Object(classCallCheck["a" /* default */])(this, FilteredAutocomplete); |
|
7761 |
|
7762 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(FilteredAutocomplete).call(this)); |
|
7763 _this.state = { |
|
7764 completers: completersFallback |
|
7765 }; |
|
7766 _this.saveParentRef = _this.saveParentRef.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
7767 _this.onFocus = _this.onFocus.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
7768 return _this; |
|
7769 } |
|
7770 |
|
7771 Object(createClass["a" /* default */])(FilteredAutocomplete, [{ |
|
7772 key: "componentDidUpdate", |
|
7773 value: function componentDidUpdate() { |
|
7774 var hasFocus = this.parentNode.contains(document.activeElement); |
|
7775 /* |
|
7776 * It's possible for props to be updated when the component has focus, |
|
7777 * so here, we ensure new completers are immediately applied while we |
|
7778 * have the focus. |
|
7779 * |
|
7780 * NOTE: This may trigger another render but only when the component has focus. |
|
7781 */ |
|
7782 |
|
7783 if (hasFocus && this.hasStaleCompleters()) { |
|
7784 this.updateCompletersState(); |
|
7785 } |
|
7786 } |
|
7787 }, { |
|
7788 key: "onFocus", |
|
7789 value: function onFocus() { |
|
7790 if (this.hasStaleCompleters()) { |
|
7791 this.updateCompletersState(); |
|
7792 } |
|
7793 } |
|
7794 }, { |
|
7795 key: "hasStaleCompleters", |
|
7796 value: function hasStaleCompleters() { |
|
7797 return !('lastFilteredCompletersProp' in this.state) || this.state.lastFilteredCompletersProp !== this.props.completers; |
|
7798 } |
|
7799 }, { |
|
7800 key: "updateCompletersState", |
|
7801 value: function updateCompletersState() { |
|
7802 var _this$props = this.props, |
|
7803 blockName = _this$props.blockName, |
|
7804 completers = _this$props.completers; |
|
7805 var nextCompleters = completers; |
|
7806 var lastFilteredCompletersProp = nextCompleters; |
|
7807 |
|
7808 if (Object(external_this_wp_hooks_["hasFilter"])('editor.Autocomplete.completers')) { |
|
7809 nextCompleters = Object(external_this_wp_hooks_["applyFilters"])('editor.Autocomplete.completers', // Provide copies so filters may directly modify them. |
|
7810 nextCompleters && nextCompleters.map(external_lodash_["clone"]), blockName); |
|
7811 } |
|
7812 |
|
7813 this.setState({ |
|
7814 lastFilteredCompletersProp: lastFilteredCompletersProp, |
|
7815 completers: nextCompleters || completersFallback |
|
7816 }); |
|
7817 } |
|
7818 }, { |
|
7819 key: "saveParentRef", |
|
7820 value: function saveParentRef(parentNode) { |
|
7821 this.parentNode = parentNode; |
|
7822 } |
|
7823 }, { |
|
7824 key: "render", |
|
7825 value: function render() { |
|
7826 var completers = this.state.completers; |
|
7827 |
|
7828 var autocompleteProps = Object(objectSpread["a" /* default */])({}, this.props, { |
|
7829 completers: completers |
|
7830 }); |
|
7831 |
|
7832 return Object(external_this_wp_element_["createElement"])("div", { |
|
7833 onFocus: this.onFocus, |
|
7834 ref: this.saveParentRef |
|
7835 }, Object(external_this_wp_element_["createElement"])(Autocomplete, Object(esm_extends["a" /* default */])({ |
|
7836 onFocus: this.onFocus |
|
7837 }, autocompleteProps))); |
|
7838 } |
|
7839 }]); |
|
7840 |
|
7841 return FilteredAutocomplete; |
|
7842 }(external_this_wp_element_["Component"]) |
|
7843 ); |
|
7844 } |
|
7845 /* harmony default export */ var autocomplete = (Object(external_this_wp_compose_["compose"])([context_withBlockEditContext(function (_ref) { |
|
7846 var name = _ref.name; |
|
7847 return { |
|
7848 blockName: name |
|
7849 }; |
|
7850 }), withFilteredAutocompleters])(external_this_wp_components_["Autocomplete"])); |
|
7851 |
|
7852 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/alignment-toolbar/index.js |
|
7853 |
|
7854 |
|
7855 |
|
7856 /** |
|
7857 * External dependencies |
|
7858 */ |
|
7859 |
|
7860 /** |
|
7861 * WordPress dependencies |
|
7862 */ |
|
7863 |
|
7864 |
|
7865 |
|
7866 |
|
7867 |
|
7868 |
|
7869 /** |
|
7870 * Internal dependencies |
|
7871 */ |
|
7872 |
|
7873 |
|
7874 var DEFAULT_ALIGNMENT_CONTROLS = [{ |
|
7875 icon: 'editor-alignleft', |
|
7876 title: Object(external_this_wp_i18n_["__"])('Align text left'), |
|
7877 align: 'left' |
|
7878 }, { |
|
7879 icon: 'editor-aligncenter', |
|
7880 title: Object(external_this_wp_i18n_["__"])('Align text center'), |
|
7881 align: 'center' |
|
7882 }, { |
|
7883 icon: 'editor-alignright', |
|
7884 title: Object(external_this_wp_i18n_["__"])('Align text right'), |
|
7885 align: 'right' |
|
7886 }]; |
|
7887 function AlignmentToolbar(_ref) { |
|
7888 var isCollapsed = _ref.isCollapsed, |
|
7889 value = _ref.value, |
|
7890 onChange = _ref.onChange, |
|
7891 _ref$alignmentControl = _ref.alignmentControls, |
|
7892 alignmentControls = _ref$alignmentControl === void 0 ? DEFAULT_ALIGNMENT_CONTROLS : _ref$alignmentControl; |
|
7893 |
|
7894 function applyOrUnset(align) { |
|
7895 return function () { |
|
7896 return onChange(value === align ? undefined : align); |
|
7897 }; |
|
7898 } |
|
7899 |
|
7900 var activeAlignment = Object(external_lodash_["find"])(alignmentControls, function (control) { |
|
7901 return control.align === value; |
|
7902 }); |
|
7903 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Toolbar"], { |
|
7904 isCollapsed: isCollapsed, |
|
7905 icon: activeAlignment ? activeAlignment.icon : 'editor-alignleft', |
|
7906 label: Object(external_this_wp_i18n_["__"])('Change Text Alignment'), |
|
7907 controls: alignmentControls.map(function (control) { |
|
7908 var align = control.align; |
|
7909 var isActive = value === align; |
|
7910 return Object(objectSpread["a" /* default */])({}, control, { |
|
7911 isActive: isActive, |
|
7912 onClick: applyOrUnset(align) |
|
7913 }); |
|
7914 }) |
|
7915 }); |
|
7916 } |
|
7917 /* harmony default export */ var alignment_toolbar = (Object(external_this_wp_compose_["compose"])(context_withBlockEditContext(function (_ref2) { |
|
7918 var clientId = _ref2.clientId; |
|
7919 return { |
|
7920 clientId: clientId |
|
7921 }; |
|
7922 }), Object(external_this_wp_viewport_["withViewportMatch"])({ |
|
7923 isLargeViewport: 'medium' |
|
7924 }), Object(external_this_wp_data_["withSelect"])(function (select, _ref3) { |
|
7925 var clientId = _ref3.clientId, |
|
7926 isLargeViewport = _ref3.isLargeViewport, |
|
7927 isCollapsed = _ref3.isCollapsed; |
|
7928 |
|
7929 var _select = select('core/block-editor'), |
|
7930 getBlockRootClientId = _select.getBlockRootClientId, |
|
7931 getSettings = _select.getSettings; |
|
7932 |
|
7933 return { |
|
7934 isCollapsed: isCollapsed || !isLargeViewport || !getSettings().hasFixedToolbar && getBlockRootClientId(clientId) |
|
7935 }; |
|
7936 }))(AlignmentToolbar)); |
|
7937 |
|
7938 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-alignment-toolbar/index.js |
|
7939 |
|
7940 |
|
7941 |
|
7942 /** |
|
7943 * WordPress dependencies |
|
7944 */ |
|
7945 |
|
7946 |
|
7947 |
|
7948 |
|
7949 |
|
7950 /** |
|
7951 * Internal dependencies |
|
7952 */ |
|
7953 |
|
7954 |
|
7955 var BLOCK_ALIGNMENTS_CONTROLS = { |
|
7956 left: { |
|
7957 icon: 'align-left', |
|
7958 title: Object(external_this_wp_i18n_["__"])('Align left') |
|
7959 }, |
|
7960 center: { |
|
7961 icon: 'align-center', |
|
7962 title: Object(external_this_wp_i18n_["__"])('Align center') |
|
7963 }, |
|
7964 right: { |
|
7965 icon: 'align-right', |
|
7966 title: Object(external_this_wp_i18n_["__"])('Align right') |
|
7967 }, |
|
7968 wide: { |
|
7969 icon: 'align-wide', |
|
7970 title: Object(external_this_wp_i18n_["__"])('Wide width') |
|
7971 }, |
|
7972 full: { |
|
7973 icon: 'align-full-width', |
|
7974 title: Object(external_this_wp_i18n_["__"])('Full width') |
|
7975 } |
|
7976 }; |
|
7977 var DEFAULT_CONTROLS = ['left', 'center', 'right', 'wide', 'full']; |
|
7978 var WIDE_CONTROLS = ['wide', 'full']; |
|
7979 function BlockAlignmentToolbar(_ref) { |
|
7980 var isCollapsed = _ref.isCollapsed, |
|
7981 value = _ref.value, |
|
7982 onChange = _ref.onChange, |
|
7983 _ref$controls = _ref.controls, |
|
7984 controls = _ref$controls === void 0 ? DEFAULT_CONTROLS : _ref$controls, |
|
7985 _ref$wideControlsEnab = _ref.wideControlsEnabled, |
|
7986 wideControlsEnabled = _ref$wideControlsEnab === void 0 ? false : _ref$wideControlsEnab; |
|
7987 |
|
7988 function applyOrUnset(align) { |
|
7989 return function () { |
|
7990 return onChange(value === align ? undefined : align); |
|
7991 }; |
|
7992 } |
|
7993 |
|
7994 var enabledControls = wideControlsEnabled ? controls : controls.filter(function (control) { |
|
7995 return WIDE_CONTROLS.indexOf(control) === -1; |
|
7996 }); |
|
7997 var activeAlignment = BLOCK_ALIGNMENTS_CONTROLS[value]; |
|
7998 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Toolbar"], { |
|
7999 isCollapsed: isCollapsed, |
|
8000 icon: activeAlignment ? activeAlignment.icon : 'align-left', |
|
8001 label: Object(external_this_wp_i18n_["__"])('Change Alignment'), |
|
8002 controls: enabledControls.map(function (control) { |
|
8003 return Object(objectSpread["a" /* default */])({}, BLOCK_ALIGNMENTS_CONTROLS[control], { |
|
8004 isActive: value === control, |
|
8005 onClick: applyOrUnset(control) |
|
8006 }); |
|
8007 }) |
|
8008 }); |
|
8009 } |
|
8010 /* harmony default export */ var block_alignment_toolbar = (Object(external_this_wp_compose_["compose"])(context_withBlockEditContext(function (_ref2) { |
|
8011 var clientId = _ref2.clientId; |
|
8012 return { |
|
8013 clientId: clientId |
|
8014 }; |
|
8015 }), Object(external_this_wp_viewport_["withViewportMatch"])({ |
|
8016 isLargeViewport: 'medium' |
|
8017 }), Object(external_this_wp_data_["withSelect"])(function (select, _ref3) { |
|
8018 var clientId = _ref3.clientId, |
|
8019 isLargeViewport = _ref3.isLargeViewport, |
|
8020 isCollapsed = _ref3.isCollapsed; |
|
8021 |
|
8022 var _select = select('core/block-editor'), |
|
8023 getBlockRootClientId = _select.getBlockRootClientId, |
|
8024 getSettings = _select.getSettings; |
|
8025 |
|
8026 var settings = getSettings(); |
|
8027 return { |
|
8028 wideControlsEnabled: settings.alignWide, |
|
8029 isCollapsed: isCollapsed || !isLargeViewport || !settings.hasFixedToolbar && getBlockRootClientId(clientId) |
|
8030 }; |
|
8031 }))(BlockAlignmentToolbar)); |
|
8032 |
|
8033 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-controls/index.js |
|
8034 |
|
8035 |
|
8036 /** |
|
8037 * WordPress dependencies |
|
8038 */ |
|
8039 |
|
8040 /** |
|
8041 * Internal dependencies |
|
8042 */ |
|
8043 |
|
8044 |
|
8045 |
|
8046 var _createSlotFill = Object(external_this_wp_components_["createSlotFill"])('BlockControls'), |
|
8047 Fill = _createSlotFill.Fill, |
|
8048 Slot = _createSlotFill.Slot; |
|
8049 |
|
8050 var block_controls_BlockControlsFill = function BlockControlsFill(_ref) { |
|
8051 var controls = _ref.controls, |
|
8052 children = _ref.children; |
|
8053 return Object(external_this_wp_element_["createElement"])(Fill, null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Toolbar"], { |
|
8054 controls: controls |
|
8055 }), children); |
|
8056 }; |
|
8057 |
|
8058 var BlockControls = ifBlockEditSelected(block_controls_BlockControlsFill); |
|
8059 BlockControls.Slot = Slot; |
|
8060 /* harmony default export */ var block_controls = (BlockControls); |
|
8061 |
|
8062 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-edit/edit.js |
|
8063 |
|
8064 |
|
8065 |
|
8066 /** |
|
8067 * External dependencies |
|
8068 */ |
|
8069 |
|
8070 /** |
|
8071 * WordPress dependencies |
|
8072 */ |
|
8073 |
|
8074 |
|
8075 |
|
8076 var edit_Edit = function Edit(props) { |
|
8077 var _props$attributes = props.attributes, |
|
8078 attributes = _props$attributes === void 0 ? {} : _props$attributes, |
|
8079 name = props.name; |
|
8080 var blockType = Object(external_this_wp_blocks_["getBlockType"])(name); |
|
8081 |
|
8082 if (!blockType) { |
|
8083 return null; |
|
8084 } // Generate a class name for the block's editable form |
|
8085 |
|
8086 |
|
8087 var generatedClassName = Object(external_this_wp_blocks_["hasBlockSupport"])(blockType, 'className', true) ? Object(external_this_wp_blocks_["getBlockDefaultClassName"])(name) : null; |
|
8088 var className = classnames_default()(generatedClassName, attributes.className); // `edit` and `save` are functions or components describing the markup |
|
8089 // with which a block is displayed. If `blockType` is valid, assign |
|
8090 // them preferentially as the render value for the block. |
|
8091 |
|
8092 var Component = blockType.edit || blockType.save; |
|
8093 return Object(external_this_wp_element_["createElement"])(Component, Object(esm_extends["a" /* default */])({}, props, { |
|
8094 className: className |
|
8095 })); |
|
8096 }; |
|
8097 /* harmony default export */ var edit = (Object(external_this_wp_components_["withFilters"])('editor.BlockEdit')(edit_Edit)); |
|
8098 |
|
8099 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-edit/index.js |
|
8100 |
|
8101 |
|
8102 |
|
8103 |
|
8104 |
|
8105 |
|
8106 |
|
8107 |
|
8108 /** |
|
8109 * WordPress dependencies |
|
8110 */ |
|
8111 |
|
8112 /** |
|
8113 * Internal dependencies |
|
8114 */ |
|
8115 |
|
8116 |
|
8117 |
|
8118 |
|
8119 var block_edit_BlockEdit = |
|
8120 /*#__PURE__*/ |
|
8121 function (_Component) { |
|
8122 Object(inherits["a" /* default */])(BlockEdit, _Component); |
|
8123 |
|
8124 function BlockEdit(props) { |
|
8125 var _this; |
|
8126 |
|
8127 Object(classCallCheck["a" /* default */])(this, BlockEdit); |
|
8128 |
|
8129 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(BlockEdit).call(this, props)); |
|
8130 _this.setFocusedElement = _this.setFocusedElement.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
8131 _this.state = { |
|
8132 focusedElement: null, |
|
8133 setFocusedElement: _this.setFocusedElement |
|
8134 }; |
|
8135 return _this; |
|
8136 } |
|
8137 |
|
8138 Object(createClass["a" /* default */])(BlockEdit, [{ |
|
8139 key: "setFocusedElement", |
|
8140 value: function setFocusedElement(focusedElement) { |
|
8141 this.setState(function (prevState) { |
|
8142 if (prevState.focusedElement === focusedElement) { |
|
8143 return null; |
|
8144 } |
|
8145 |
|
8146 return { |
|
8147 focusedElement: focusedElement |
|
8148 }; |
|
8149 }); |
|
8150 } |
|
8151 }, { |
|
8152 key: "render", |
|
8153 value: function render() { |
|
8154 return Object(external_this_wp_element_["createElement"])(Provider, { |
|
8155 value: this.state |
|
8156 }, Object(external_this_wp_element_["createElement"])(edit, this.props)); |
|
8157 } |
|
8158 }], [{ |
|
8159 key: "getDerivedStateFromProps", |
|
8160 value: function getDerivedStateFromProps(props) { |
|
8161 var clientId = props.clientId, |
|
8162 name = props.name, |
|
8163 isSelected = props.isSelected; |
|
8164 return { |
|
8165 name: name, |
|
8166 isSelected: isSelected, |
|
8167 clientId: clientId |
|
8168 }; |
|
8169 } |
|
8170 }]); |
|
8171 |
|
8172 return BlockEdit; |
|
8173 }(external_this_wp_element_["Component"]); |
|
8174 |
|
8175 /* harmony default export */ var block_edit = (block_edit_BlockEdit); |
|
8176 |
|
8177 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-format-controls/index.js |
|
8178 /** |
|
8179 * WordPress dependencies |
|
8180 */ |
|
8181 |
|
8182 /** |
|
8183 * Internal dependencies |
|
8184 */ |
|
8185 |
|
8186 |
|
8187 |
|
8188 var block_format_controls_createSlotFill = Object(external_this_wp_components_["createSlotFill"])('BlockFormatControls'), |
|
8189 block_format_controls_Fill = block_format_controls_createSlotFill.Fill, |
|
8190 block_format_controls_Slot = block_format_controls_createSlotFill.Slot; |
|
8191 |
|
8192 var BlockFormatControls = ifBlockEditSelected(block_format_controls_Fill); |
|
8193 BlockFormatControls.Slot = block_format_controls_Slot; |
|
8194 /* harmony default export */ var block_format_controls = (BlockFormatControls); |
|
8195 |
|
8196 // EXTERNAL MODULE: external {"this":["wp","keycodes"]} |
|
8197 var external_this_wp_keycodes_ = __webpack_require__(18); |
|
8198 |
|
8199 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-icon/index.js |
|
8200 |
|
8201 |
|
8202 /** |
|
8203 * External dependencies |
|
8204 */ |
|
8205 |
|
8206 |
|
8207 /** |
|
8208 * WordPress dependencies |
|
8209 */ |
|
8210 |
|
8211 |
|
8212 function BlockIcon(_ref) { |
|
8213 var icon = _ref.icon, |
|
8214 _ref$showColors = _ref.showColors, |
|
8215 showColors = _ref$showColors === void 0 ? false : _ref$showColors, |
|
8216 className = _ref.className; |
|
8217 |
|
8218 if (Object(external_lodash_["get"])(icon, ['src']) === 'block-default') { |
|
8219 icon = { |
|
8220 src: Object(external_this_wp_element_["createElement"])(external_this_wp_components_["SVG"], { |
|
8221 xmlns: "http://www.w3.org/2000/svg", |
|
8222 viewBox: "0 0 24 24" |
|
8223 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Path"], { |
|
8224 d: "M19 7h-1V5h-4v2h-4V5H6v2H5c-1.1 0-2 .9-2 2v10h18V9c0-1.1-.9-2-2-2zm0 10H5V9h14v8z" |
|
8225 })) |
|
8226 }; |
|
8227 } |
|
8228 |
|
8229 var renderedIcon = Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Icon"], { |
|
8230 icon: icon && icon.src ? icon.src : icon |
|
8231 }); |
|
8232 var style = showColors ? { |
|
8233 backgroundColor: icon && icon.background, |
|
8234 color: icon && icon.foreground |
|
8235 } : {}; |
|
8236 return Object(external_this_wp_element_["createElement"])("span", { |
|
8237 style: style, |
|
8238 className: classnames_default()('editor-block-icon block-editor-block-icon', className, { |
|
8239 'has-colors': showColors |
|
8240 }) |
|
8241 }, renderedIcon); |
|
8242 } |
|
8243 |
|
8244 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/index.js |
|
8245 |
|
8246 |
|
8247 /** |
|
8248 * External dependencies |
|
8249 */ |
|
8250 |
|
8251 |
|
8252 /** |
|
8253 * WordPress dependencies |
|
8254 */ |
|
8255 |
|
8256 |
|
8257 |
|
8258 |
|
8259 |
|
8260 |
|
8261 /** |
|
8262 * Internal dependencies |
|
8263 */ |
|
8264 |
|
8265 |
|
8266 |
|
8267 function BlockNavigationList(_ref) { |
|
8268 var blocks = _ref.blocks, |
|
8269 selectedBlockClientId = _ref.selectedBlockClientId, |
|
8270 selectBlock = _ref.selectBlock, |
|
8271 showNestedBlocks = _ref.showNestedBlocks; |
|
8272 return ( |
|
8273 /* |
|
8274 * Disable reason: The `list` ARIA role is redundant but |
|
8275 * Safari+VoiceOver won't announce the list otherwise. |
|
8276 */ |
|
8277 |
|
8278 /* eslint-disable jsx-a11y/no-redundant-roles */ |
|
8279 Object(external_this_wp_element_["createElement"])("ul", { |
|
8280 className: "editor-block-navigation__list block-editor-block-navigation__list", |
|
8281 role: "list" |
|
8282 }, Object(external_lodash_["map"])(blocks, function (block) { |
|
8283 var blockType = Object(external_this_wp_blocks_["getBlockType"])(block.name); |
|
8284 var isSelected = block.clientId === selectedBlockClientId; |
|
8285 return Object(external_this_wp_element_["createElement"])("li", { |
|
8286 key: block.clientId |
|
8287 }, Object(external_this_wp_element_["createElement"])("div", { |
|
8288 className: "editor-block-navigation__item block-editor-block-navigation__item" |
|
8289 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
8290 className: classnames_default()('editor-block-navigation__item-button block-editor-block-navigation__item-button', { |
|
8291 'is-selected': isSelected |
|
8292 }), |
|
8293 onClick: function onClick() { |
|
8294 return selectBlock(block.clientId); |
|
8295 } |
|
8296 }, Object(external_this_wp_element_["createElement"])(BlockIcon, { |
|
8297 icon: blockType.icon, |
|
8298 showColors: true |
|
8299 }), blockType.title, isSelected && Object(external_this_wp_element_["createElement"])("span", { |
|
8300 className: "screen-reader-text" |
|
8301 }, Object(external_this_wp_i18n_["__"])('(selected block)')))), showNestedBlocks && !!block.innerBlocks && !!block.innerBlocks.length && Object(external_this_wp_element_["createElement"])(BlockNavigationList, { |
|
8302 blocks: block.innerBlocks, |
|
8303 selectedBlockClientId: selectedBlockClientId, |
|
8304 selectBlock: selectBlock, |
|
8305 showNestedBlocks: true |
|
8306 })); |
|
8307 })) |
|
8308 /* eslint-enable jsx-a11y/no-redundant-roles */ |
|
8309 |
|
8310 ); |
|
8311 } |
|
8312 |
|
8313 function BlockNavigation(_ref2) { |
|
8314 var rootBlock = _ref2.rootBlock, |
|
8315 rootBlocks = _ref2.rootBlocks, |
|
8316 selectedBlockClientId = _ref2.selectedBlockClientId, |
|
8317 selectBlock = _ref2.selectBlock; |
|
8318 |
|
8319 if (!rootBlocks || rootBlocks.length === 0) { |
|
8320 return null; |
|
8321 } |
|
8322 |
|
8323 var hasHierarchy = rootBlock && (rootBlock.clientId !== selectedBlockClientId || rootBlock.innerBlocks && rootBlock.innerBlocks.length !== 0); |
|
8324 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["NavigableMenu"], { |
|
8325 role: "presentation", |
|
8326 className: "editor-block-navigation__container block-editor-block-navigation__container" |
|
8327 }, Object(external_this_wp_element_["createElement"])("p", { |
|
8328 className: "editor-block-navigation__label block-editor-block-navigation__label" |
|
8329 }, Object(external_this_wp_i18n_["__"])('Block Navigation')), hasHierarchy && Object(external_this_wp_element_["createElement"])(BlockNavigationList, { |
|
8330 blocks: [rootBlock], |
|
8331 selectedBlockClientId: selectedBlockClientId, |
|
8332 selectBlock: selectBlock, |
|
8333 showNestedBlocks: true |
|
8334 }), !hasHierarchy && Object(external_this_wp_element_["createElement"])(BlockNavigationList, { |
|
8335 blocks: rootBlocks, |
|
8336 selectedBlockClientId: selectedBlockClientId, |
|
8337 selectBlock: selectBlock |
|
8338 })); |
|
8339 } |
|
8340 |
|
8341 /* harmony default export */ var block_navigation = (Object(external_this_wp_compose_["compose"])(Object(external_this_wp_data_["withSelect"])(function (select) { |
|
8342 var _select = select('core/block-editor'), |
|
8343 getSelectedBlockClientId = _select.getSelectedBlockClientId, |
|
8344 getBlockHierarchyRootClientId = _select.getBlockHierarchyRootClientId, |
|
8345 getBlock = _select.getBlock, |
|
8346 getBlocks = _select.getBlocks; |
|
8347 |
|
8348 var selectedBlockClientId = getSelectedBlockClientId(); |
|
8349 return { |
|
8350 rootBlocks: getBlocks(), |
|
8351 rootBlock: selectedBlockClientId ? getBlock(getBlockHierarchyRootClientId(selectedBlockClientId)) : null, |
|
8352 selectedBlockClientId: selectedBlockClientId |
|
8353 }; |
|
8354 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, _ref3) { |
|
8355 var _ref3$onSelect = _ref3.onSelect, |
|
8356 onSelect = _ref3$onSelect === void 0 ? external_lodash_["noop"] : _ref3$onSelect; |
|
8357 return { |
|
8358 selectBlock: function selectBlock(clientId) { |
|
8359 dispatch('core/block-editor').selectBlock(clientId); |
|
8360 onSelect(clientId); |
|
8361 } |
|
8362 }; |
|
8363 }))(BlockNavigation)); |
|
8364 |
|
8365 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/dropdown.js |
|
8366 |
|
8367 |
|
8368 |
|
8369 /** |
|
8370 * WordPress dependencies |
|
8371 */ |
|
8372 |
|
8373 |
|
8374 |
|
8375 |
|
8376 |
|
8377 /** |
|
8378 * Internal dependencies |
|
8379 */ |
|
8380 |
|
8381 |
|
8382 var MenuIcon = Object(external_this_wp_element_["createElement"])(external_this_wp_components_["SVG"], { |
|
8383 xmlns: "http://www.w3.org/2000/svg", |
|
8384 viewBox: "0 0 24 24", |
|
8385 width: "20", |
|
8386 height: "20" |
|
8387 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Path"], { |
|
8388 d: "M5 5H3v2h2V5zm3 8h11v-2H8v2zm9-8H6v2h11V5zM7 11H5v2h2v-2zm0 8h2v-2H7v2zm3-2v2h11v-2H10z" |
|
8389 })); |
|
8390 |
|
8391 function BlockNavigationDropdown(_ref) { |
|
8392 var hasBlocks = _ref.hasBlocks, |
|
8393 isDisabled = _ref.isDisabled; |
|
8394 var isEnabled = hasBlocks && !isDisabled; |
|
8395 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Dropdown"], { |
|
8396 renderToggle: function renderToggle(_ref2) { |
|
8397 var isOpen = _ref2.isOpen, |
|
8398 onToggle = _ref2.onToggle; |
|
8399 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, isEnabled && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["KeyboardShortcuts"], { |
|
8400 bindGlobal: true, |
|
8401 shortcuts: Object(defineProperty["a" /* default */])({}, external_this_wp_keycodes_["rawShortcut"].access('o'), onToggle) |
|
8402 }), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], { |
|
8403 icon: MenuIcon, |
|
8404 "aria-expanded": isOpen, |
|
8405 onClick: isEnabled ? onToggle : undefined, |
|
8406 label: Object(external_this_wp_i18n_["__"])('Block Navigation'), |
|
8407 className: "editor-block-navigation block-editor-block-navigation", |
|
8408 shortcut: external_this_wp_keycodes_["displayShortcut"].access('o'), |
|
8409 "aria-disabled": !isEnabled |
|
8410 })); |
|
8411 }, |
|
8412 renderContent: function renderContent(_ref4) { |
|
8413 var onClose = _ref4.onClose; |
|
8414 return Object(external_this_wp_element_["createElement"])(block_navigation, { |
|
8415 onSelect: onClose |
|
8416 }); |
|
8417 } |
|
8418 }); |
|
8419 } |
|
8420 |
|
8421 /* harmony default export */ var dropdown = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
8422 return { |
|
8423 hasBlocks: !!select('core/block-editor').getBlockCount() |
|
8424 }; |
|
8425 })(BlockNavigationDropdown)); |
|
8426 |
|
8427 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-palette/with-color-context.js |
|
8428 /** |
|
8429 * External dependencies |
|
8430 */ |
|
8431 |
|
8432 /** |
|
8433 * WordPress dependencies |
|
8434 */ |
|
8435 |
|
8436 |
|
8437 |
|
8438 /* harmony default export */ var with_color_context = (Object(external_this_wp_compose_["createHigherOrderComponent"])(Object(external_this_wp_data_["withSelect"])(function (select, ownProps) { |
|
8439 var settings = select('core/block-editor').getSettings(); |
|
8440 var colors = ownProps.colors === undefined ? settings.colors : ownProps.colors; |
|
8441 var disableCustomColors = ownProps.disableCustomColors === undefined ? settings.disableCustomColors : ownProps.disableCustomColors; |
|
8442 return { |
|
8443 colors: colors, |
|
8444 disableCustomColors: disableCustomColors, |
|
8445 hasColorsToChoose: !Object(external_lodash_["isEmpty"])(colors) || !disableCustomColors |
|
8446 }; |
|
8447 }), 'withColorContext')); |
|
8448 |
|
8449 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-palette/index.js |
|
8450 /** |
|
8451 * WordPress dependencies |
|
8452 */ |
|
8453 |
|
8454 /** |
|
8455 * Internal dependencies |
|
8456 */ |
|
8457 |
|
8458 |
|
8459 /* harmony default export */ var color_palette = (with_color_context(external_this_wp_components_["ColorPalette"])); |
|
8460 |
|
8461 // EXTERNAL MODULE: ./node_modules/tinycolor2/tinycolor.js |
|
8462 var tinycolor = __webpack_require__(45); |
|
8463 var tinycolor_default = /*#__PURE__*/__webpack_require__.n(tinycolor); |
|
8464 |
|
8465 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/utils.js |
|
8466 /** |
|
8467 * External dependencies |
|
8468 */ |
|
8469 |
|
8470 |
|
8471 /** |
|
8472 * Provided an array of color objects as set by the theme or by the editor defaults, |
|
8473 * and the values of the defined color or custom color returns a color object describing the color. |
|
8474 * |
|
8475 * @param {Array} colors Array of color objects as set by the theme or by the editor defaults. |
|
8476 * @param {?string} definedColor A string containing the color slug. |
|
8477 * @param {?string} customColor A string containing the customColor value. |
|
8478 * |
|
8479 * @return {?string} If definedColor is passed and the name is found in colors, |
|
8480 * the color object exactly as set by the theme or editor defaults is returned. |
|
8481 * Otherwise, an object that just sets the color is defined. |
|
8482 */ |
|
8483 |
|
8484 var utils_getColorObjectByAttributeValues = function getColorObjectByAttributeValues(colors, definedColor, customColor) { |
|
8485 if (definedColor) { |
|
8486 var colorObj = Object(external_lodash_["find"])(colors, { |
|
8487 slug: definedColor |
|
8488 }); |
|
8489 |
|
8490 if (colorObj) { |
|
8491 return colorObj; |
|
8492 } |
|
8493 } |
|
8494 |
|
8495 return { |
|
8496 color: customColor |
|
8497 }; |
|
8498 }; |
|
8499 /** |
|
8500 * Provided an array of color objects as set by the theme or by the editor defaults, and a color value returns the color object matching that value or undefined. |
|
8501 * |
|
8502 * @param {Array} colors Array of color objects as set by the theme or by the editor defaults. |
|
8503 * @param {?string} colorValue A string containing the color value. |
|
8504 * |
|
8505 * @return {?string} Returns the color object included in the colors array whose color property equals colorValue. |
|
8506 * Returns undefined if no color object matches this requirement. |
|
8507 */ |
|
8508 |
|
8509 var utils_getColorObjectByColorValue = function getColorObjectByColorValue(colors, colorValue) { |
|
8510 return Object(external_lodash_["find"])(colors, { |
|
8511 color: colorValue |
|
8512 }); |
|
8513 }; |
|
8514 /** |
|
8515 * Returns a class based on the context a color is being used and its slug. |
|
8516 * |
|
8517 * @param {string} colorContextName Context/place where color is being used e.g: background, text etc... |
|
8518 * @param {string} colorSlug Slug of the color. |
|
8519 * |
|
8520 * @return {string} String with the class corresponding to the color in the provided context. |
|
8521 */ |
|
8522 |
|
8523 function getColorClassName(colorContextName, colorSlug) { |
|
8524 if (!colorContextName || !colorSlug) { |
|
8525 return; |
|
8526 } |
|
8527 |
|
8528 return "has-".concat(Object(external_lodash_["kebabCase"])(colorSlug), "-").concat(colorContextName); |
|
8529 } |
|
8530 /** |
|
8531 * Given an array of color objects and a color value returns the color value of the most readable color in the array. |
|
8532 * |
|
8533 * @param {Array} colors Array of color objects as set by the theme or by the editor defaults. |
|
8534 * @param {?string} colorValue A string containing the color value. |
|
8535 * |
|
8536 * @return {string} String with the color value of the most readable color. |
|
8537 */ |
|
8538 |
|
8539 function utils_getMostReadableColor(colors, colorValue) { |
|
8540 return tinycolor_default.a.mostReadable(colorValue, Object(external_lodash_["map"])(colors, 'color')).toHexString(); |
|
8541 } |
|
8542 |
|
8543 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/with-colors.js |
|
8544 |
|
8545 |
|
8546 |
|
8547 |
|
8548 |
|
8549 |
|
8550 |
|
8551 |
|
8552 |
|
8553 |
|
8554 |
|
8555 /** |
|
8556 * External dependencies |
|
8557 */ |
|
8558 |
|
8559 /** |
|
8560 * WordPress dependencies |
|
8561 */ |
|
8562 |
|
8563 |
|
8564 |
|
8565 |
|
8566 /** |
|
8567 * Internal dependencies |
|
8568 */ |
|
8569 |
|
8570 |
|
8571 var DEFAULT_COLORS = []; |
|
8572 /** |
|
8573 * Higher order component factory for injecting the `colorsArray` argument as |
|
8574 * the colors prop in the `withCustomColors` HOC. |
|
8575 * |
|
8576 * @param {Array} colorsArray An array of color objects. |
|
8577 * |
|
8578 * @return {function} The higher order component. |
|
8579 */ |
|
8580 |
|
8581 var with_colors_withCustomColorPalette = function withCustomColorPalette(colorsArray) { |
|
8582 return Object(external_this_wp_compose_["createHigherOrderComponent"])(function (WrappedComponent) { |
|
8583 return function (props) { |
|
8584 return Object(external_this_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, props, { |
|
8585 colors: colorsArray |
|
8586 })); |
|
8587 }; |
|
8588 }, 'withCustomColorPalette'); |
|
8589 }; |
|
8590 /** |
|
8591 * Higher order component factory for injecting the editor colors as the |
|
8592 * `colors` prop in the `withColors` HOC. |
|
8593 * |
|
8594 * @return {function} The higher order component. |
|
8595 */ |
|
8596 |
|
8597 |
|
8598 var with_colors_withEditorColorPalette = function withEditorColorPalette() { |
|
8599 return Object(external_this_wp_data_["withSelect"])(function (select) { |
|
8600 var settings = select('core/block-editor').getSettings(); |
|
8601 return { |
|
8602 colors: Object(external_lodash_["get"])(settings, ['colors'], DEFAULT_COLORS) |
|
8603 }; |
|
8604 }); |
|
8605 }; |
|
8606 /** |
|
8607 * Helper function used with `createHigherOrderComponent` to create |
|
8608 * higher order components for managing color logic. |
|
8609 * |
|
8610 * @param {Array} colorTypes An array of color types (e.g. 'backgroundColor, borderColor). |
|
8611 * @param {Function} withColorPalette A HOC for injecting the 'colors' prop into the WrappedComponent. |
|
8612 * |
|
8613 * @return {Component} The component that can be used as a HOC. |
|
8614 */ |
|
8615 |
|
8616 |
|
8617 function createColorHOC(colorTypes, withColorPalette) { |
|
8618 var colorMap = Object(external_lodash_["reduce"])(colorTypes, function (colorObject, colorType) { |
|
8619 return Object(objectSpread["a" /* default */])({}, colorObject, Object(external_lodash_["isString"])(colorType) ? Object(defineProperty["a" /* default */])({}, colorType, Object(external_lodash_["kebabCase"])(colorType)) : colorType); |
|
8620 }, {}); |
|
8621 return Object(external_this_wp_compose_["compose"])([withColorPalette, function (WrappedComponent) { |
|
8622 return ( |
|
8623 /*#__PURE__*/ |
|
8624 function (_Component) { |
|
8625 Object(inherits["a" /* default */])(_class, _Component); |
|
8626 |
|
8627 function _class(props) { |
|
8628 var _this; |
|
8629 |
|
8630 Object(classCallCheck["a" /* default */])(this, _class); |
|
8631 |
|
8632 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(_class).call(this, props)); |
|
8633 _this.setters = _this.createSetters(); |
|
8634 _this.colorUtils = { |
|
8635 getMostReadableColor: _this.getMostReadableColor.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))) |
|
8636 }; |
|
8637 _this.state = {}; |
|
8638 return _this; |
|
8639 } |
|
8640 |
|
8641 Object(createClass["a" /* default */])(_class, [{ |
|
8642 key: "getMostReadableColor", |
|
8643 value: function getMostReadableColor(colorValue) { |
|
8644 var colors = this.props.colors; |
|
8645 return utils_getMostReadableColor(colors, colorValue); |
|
8646 } |
|
8647 }, { |
|
8648 key: "createSetters", |
|
8649 value: function createSetters() { |
|
8650 var _this2 = this; |
|
8651 |
|
8652 return Object(external_lodash_["reduce"])(colorMap, function (settersAccumulator, colorContext, colorAttributeName) { |
|
8653 var upperFirstColorAttributeName = Object(external_lodash_["upperFirst"])(colorAttributeName); |
|
8654 var customColorAttributeName = "custom".concat(upperFirstColorAttributeName); |
|
8655 settersAccumulator["set".concat(upperFirstColorAttributeName)] = _this2.createSetColor(colorAttributeName, customColorAttributeName); |
|
8656 return settersAccumulator; |
|
8657 }, {}); |
|
8658 } |
|
8659 }, { |
|
8660 key: "createSetColor", |
|
8661 value: function createSetColor(colorAttributeName, customColorAttributeName) { |
|
8662 var _this3 = this; |
|
8663 |
|
8664 return function (colorValue) { |
|
8665 var _this3$props$setAttri; |
|
8666 |
|
8667 var colorObject = utils_getColorObjectByColorValue(_this3.props.colors, colorValue); |
|
8668 |
|
8669 _this3.props.setAttributes((_this3$props$setAttri = {}, Object(defineProperty["a" /* default */])(_this3$props$setAttri, colorAttributeName, colorObject && colorObject.slug ? colorObject.slug : undefined), Object(defineProperty["a" /* default */])(_this3$props$setAttri, customColorAttributeName, colorObject && colorObject.slug ? undefined : colorValue), _this3$props$setAttri)); |
|
8670 }; |
|
8671 } |
|
8672 }, { |
|
8673 key: "render", |
|
8674 value: function render() { |
|
8675 return Object(external_this_wp_element_["createElement"])(WrappedComponent, Object(objectSpread["a" /* default */])({}, this.props, { |
|
8676 colors: undefined |
|
8677 }, this.state, this.setters, { |
|
8678 colorUtils: this.colorUtils |
|
8679 })); |
|
8680 } |
|
8681 }], [{ |
|
8682 key: "getDerivedStateFromProps", |
|
8683 value: function getDerivedStateFromProps(_ref2, previousState) { |
|
8684 var attributes = _ref2.attributes, |
|
8685 colors = _ref2.colors; |
|
8686 return Object(external_lodash_["reduce"])(colorMap, function (newState, colorContext, colorAttributeName) { |
|
8687 var colorObject = utils_getColorObjectByAttributeValues(colors, attributes[colorAttributeName], attributes["custom".concat(Object(external_lodash_["upperFirst"])(colorAttributeName))]); |
|
8688 var previousColorObject = previousState[colorAttributeName]; |
|
8689 var previousColor = Object(external_lodash_["get"])(previousColorObject, ['color']); |
|
8690 /** |
|
8691 * The "and previousColorObject" condition checks that a previous color object was already computed. |
|
8692 * At the start previousColorObject and colorValue are both equal to undefined |
|
8693 * bus as previousColorObject does not exist we should compute the object. |
|
8694 */ |
|
8695 |
|
8696 if (previousColor === colorObject.color && previousColorObject) { |
|
8697 newState[colorAttributeName] = previousColorObject; |
|
8698 } else { |
|
8699 newState[colorAttributeName] = Object(objectSpread["a" /* default */])({}, colorObject, { |
|
8700 class: getColorClassName(colorContext, colorObject.slug) |
|
8701 }); |
|
8702 } |
|
8703 |
|
8704 return newState; |
|
8705 }, {}); |
|
8706 } |
|
8707 }]); |
|
8708 |
|
8709 return _class; |
|
8710 }(external_this_wp_element_["Component"]) |
|
8711 ); |
|
8712 }]); |
|
8713 } |
|
8714 /** |
|
8715 * A higher-order component factory for creating a 'withCustomColors' HOC, which handles color logic |
|
8716 * for class generation color value, retrieval and color attribute setting. |
|
8717 * |
|
8718 * Use this higher-order component to work with a custom set of colors. |
|
8719 * |
|
8720 * @example |
|
8721 * |
|
8722 * ```jsx |
|
8723 * const CUSTOM_COLORS = [ { name: 'Red', slug: 'red', color: '#ff0000' }, { name: 'Blue', slug: 'blue', color: '#0000ff' } ]; |
|
8724 * const withCustomColors = createCustomColorsHOC( CUSTOM_COLORS ); |
|
8725 * // ... |
|
8726 * export default compose( |
|
8727 * withCustomColors( 'backgroundColor', 'borderColor' ), |
|
8728 * MyColorfulComponent, |
|
8729 * ); |
|
8730 * ``` |
|
8731 * |
|
8732 * @param {Array} colorsArray The array of color objects (name, slug, color, etc... ). |
|
8733 * |
|
8734 * @return {Function} Higher-order component. |
|
8735 */ |
|
8736 |
|
8737 |
|
8738 function createCustomColorsHOC(colorsArray) { |
|
8739 return function () { |
|
8740 var withColorPalette = with_colors_withCustomColorPalette(colorsArray); |
|
8741 |
|
8742 for (var _len = arguments.length, colorTypes = new Array(_len), _key = 0; _key < _len; _key++) { |
|
8743 colorTypes[_key] = arguments[_key]; |
|
8744 } |
|
8745 |
|
8746 return Object(external_this_wp_compose_["createHigherOrderComponent"])(createColorHOC(colorTypes, withColorPalette), 'withCustomColors'); |
|
8747 }; |
|
8748 } |
|
8749 /** |
|
8750 * A higher-order component, which handles color logic for class generation color value, retrieval and color attribute setting. |
|
8751 * |
|
8752 * For use with the default editor/theme color palette. |
|
8753 * |
|
8754 * @example |
|
8755 * |
|
8756 * ```jsx |
|
8757 * export default compose( |
|
8758 * withColors( 'backgroundColor', { textColor: 'color' } ), |
|
8759 * MyColorfulComponent, |
|
8760 * ); |
|
8761 * ``` |
|
8762 * |
|
8763 * @param {...(object|string)} colorTypes The arguments can be strings or objects. If the argument is an object, |
|
8764 * it should contain the color attribute name as key and the color context as value. |
|
8765 * If the argument is a string the value should be the color attribute name, |
|
8766 * the color context is computed by applying a kebab case transform to the value. |
|
8767 * Color context represents the context/place where the color is going to be used. |
|
8768 * The class name of the color is generated using 'has' followed by the color name |
|
8769 * and ending with the color context all in kebab case e.g: has-green-background-color. |
|
8770 * |
|
8771 * @return {Function} Higher-order component. |
|
8772 */ |
|
8773 |
|
8774 function withColors() { |
|
8775 var withColorPalette = with_colors_withEditorColorPalette(); |
|
8776 |
|
8777 for (var _len2 = arguments.length, colorTypes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { |
|
8778 colorTypes[_key2] = arguments[_key2]; |
|
8779 } |
|
8780 |
|
8781 return Object(external_this_wp_compose_["createHigherOrderComponent"])(createColorHOC(colorTypes, withColorPalette), 'withColors'); |
|
8782 } |
|
8783 |
|
8784 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/index.js |
|
8785 |
|
8786 |
|
8787 |
|
8788 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/contrast-checker/index.js |
|
8789 |
|
8790 |
|
8791 /** |
|
8792 * External dependencies |
|
8793 */ |
|
8794 |
|
8795 /** |
|
8796 * WordPress dependencies |
|
8797 */ |
|
8798 |
|
8799 |
|
8800 |
|
8801 |
|
8802 function ContrastChecker(_ref) { |
|
8803 var backgroundColor = _ref.backgroundColor, |
|
8804 fallbackBackgroundColor = _ref.fallbackBackgroundColor, |
|
8805 fallbackTextColor = _ref.fallbackTextColor, |
|
8806 fontSize = _ref.fontSize, |
|
8807 isLargeText = _ref.isLargeText, |
|
8808 textColor = _ref.textColor; |
|
8809 |
|
8810 if (!(backgroundColor || fallbackBackgroundColor) || !(textColor || fallbackTextColor)) { |
|
8811 return null; |
|
8812 } |
|
8813 |
|
8814 var tinyBackgroundColor = tinycolor_default()(backgroundColor || fallbackBackgroundColor); |
|
8815 var tinyTextColor = tinycolor_default()(textColor || fallbackTextColor); |
|
8816 var hasTransparency = tinyBackgroundColor.getAlpha() !== 1 || tinyTextColor.getAlpha() !== 1; |
|
8817 |
|
8818 if (hasTransparency || tinycolor_default.a.isReadable(tinyBackgroundColor, tinyTextColor, { |
|
8819 level: 'AA', |
|
8820 size: isLargeText || isLargeText !== false && fontSize >= 24 ? 'large' : 'small' |
|
8821 })) { |
|
8822 return null; |
|
8823 } |
|
8824 |
|
8825 var msg = tinyBackgroundColor.getBrightness() < tinyTextColor.getBrightness() ? Object(external_this_wp_i18n_["__"])('This color combination may be hard for people to read. Try using a darker background color and/or a brighter text color.') : Object(external_this_wp_i18n_["__"])('This color combination may be hard for people to read. Try using a brighter background color and/or a darker text color.'); |
|
8826 return Object(external_this_wp_element_["createElement"])("div", { |
|
8827 className: "editor-contrast-checker block-editor-contrast-checker" |
|
8828 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Notice"], { |
|
8829 status: "warning", |
|
8830 isDismissible: false |
|
8831 }, msg)); |
|
8832 } |
|
8833 |
|
8834 /* harmony default export */ var contrast_checker = (ContrastChecker); |
|
8835 |
|
8836 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/utils.js |
|
8837 /** |
|
8838 * External dependencies |
|
8839 */ |
|
8840 |
|
8841 /** |
|
8842 * Returns the font size object based on an array of named font sizes and the namedFontSize and customFontSize values. |
|
8843 * If namedFontSize is undefined or not found in fontSizes an object with just the size value based on customFontSize is returned. |
|
8844 * |
|
8845 * @param {Array} fontSizes Array of font size objects containing at least the "name" and "size" values as properties. |
|
8846 * @param {?string} fontSizeAttribute Content of the font size attribute (slug). |
|
8847 * @param {?number} customFontSizeAttribute Contents of the custom font size attribute (value). |
|
8848 * |
|
8849 * @return {?string} If fontSizeAttribute is set and an equal slug is found in fontSizes it returns the font size object for that slug. |
|
8850 * Otherwise, an object with just the size value based on customFontSize is returned. |
|
8851 */ |
|
8852 |
|
8853 var utils_getFontSize = function getFontSize(fontSizes, fontSizeAttribute, customFontSizeAttribute) { |
|
8854 if (fontSizeAttribute) { |
|
8855 var fontSizeObject = Object(external_lodash_["find"])(fontSizes, { |
|
8856 slug: fontSizeAttribute |
|
8857 }); |
|
8858 |
|
8859 if (fontSizeObject) { |
|
8860 return fontSizeObject; |
|
8861 } |
|
8862 } |
|
8863 |
|
8864 return { |
|
8865 size: customFontSizeAttribute |
|
8866 }; |
|
8867 }; |
|
8868 /** |
|
8869 * Returns a class based on fontSizeName. |
|
8870 * |
|
8871 * @param {string} fontSizeSlug Slug of the fontSize. |
|
8872 * |
|
8873 * @return {string} String with the class corresponding to the fontSize passed. |
|
8874 * The class is generated by appending 'has-' followed by fontSizeSlug in kebabCase and ending with '-font-size'. |
|
8875 */ |
|
8876 |
|
8877 function getFontSizeClass(fontSizeSlug) { |
|
8878 if (!fontSizeSlug) { |
|
8879 return; |
|
8880 } |
|
8881 |
|
8882 return "has-".concat(Object(external_lodash_["kebabCase"])(fontSizeSlug), "-font-size"); |
|
8883 } |
|
8884 |
|
8885 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/font-size-picker.js |
|
8886 /** |
|
8887 * WordPress dependencies |
|
8888 */ |
|
8889 |
|
8890 |
|
8891 /* harmony default export */ var font_size_picker = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
8892 var _select$getSettings = select('core/block-editor').getSettings(), |
|
8893 disableCustomFontSizes = _select$getSettings.disableCustomFontSizes, |
|
8894 fontSizes = _select$getSettings.fontSizes; |
|
8895 |
|
8896 return { |
|
8897 disableCustomFontSizes: disableCustomFontSizes, |
|
8898 fontSizes: fontSizes |
|
8899 }; |
|
8900 })(external_this_wp_components_["FontSizePicker"])); |
|
8901 |
|
8902 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/with-font-sizes.js |
|
8903 |
|
8904 |
|
8905 |
|
8906 |
|
8907 |
|
8908 |
|
8909 |
|
8910 |
|
8911 |
|
8912 /** |
|
8913 * External dependencies |
|
8914 */ |
|
8915 |
|
8916 /** |
|
8917 * WordPress dependencies |
|
8918 */ |
|
8919 |
|
8920 |
|
8921 |
|
8922 |
|
8923 /** |
|
8924 * Internal dependencies |
|
8925 */ |
|
8926 |
|
8927 |
|
8928 /** |
|
8929 * Higher-order component, which handles font size logic for class generation, |
|
8930 * font size value retrieval, and font size change handling. |
|
8931 * |
|
8932 * @param {...(object|string)} args The arguments should all be strings |
|
8933 * Each string contains the font size attribute name e.g: 'fontSize'. |
|
8934 * |
|
8935 * @return {Function} Higher-order component. |
|
8936 */ |
|
8937 |
|
8938 /* harmony default export */ var with_font_sizes = (function () { |
|
8939 for (var _len = arguments.length, fontSizeNames = new Array(_len), _key = 0; _key < _len; _key++) { |
|
8940 fontSizeNames[_key] = arguments[_key]; |
|
8941 } |
|
8942 |
|
8943 /* |
|
8944 * Computes an object whose key is the font size attribute name as passed in the array, |
|
8945 * and the value is the custom font size attribute name. |
|
8946 * Custom font size is automatically compted by appending custom followed by the font size attribute name in with the first letter capitalized. |
|
8947 */ |
|
8948 var fontSizeAttributeNames = Object(external_lodash_["reduce"])(fontSizeNames, function (fontSizeAttributeNamesAccumulator, fontSizeAttributeName) { |
|
8949 fontSizeAttributeNamesAccumulator[fontSizeAttributeName] = "custom".concat(Object(external_lodash_["upperFirst"])(fontSizeAttributeName)); |
|
8950 return fontSizeAttributeNamesAccumulator; |
|
8951 }, {}); |
|
8952 return Object(external_this_wp_compose_["createHigherOrderComponent"])(Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
8953 var _select$getSettings = select('core/block-editor').getSettings(), |
|
8954 fontSizes = _select$getSettings.fontSizes; |
|
8955 |
|
8956 return { |
|
8957 fontSizes: fontSizes |
|
8958 }; |
|
8959 }), function (WrappedComponent) { |
|
8960 return ( |
|
8961 /*#__PURE__*/ |
|
8962 function (_Component) { |
|
8963 Object(inherits["a" /* default */])(_class, _Component); |
|
8964 |
|
8965 function _class(props) { |
|
8966 var _this; |
|
8967 |
|
8968 Object(classCallCheck["a" /* default */])(this, _class); |
|
8969 |
|
8970 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(_class).call(this, props)); |
|
8971 _this.setters = _this.createSetters(); |
|
8972 _this.state = {}; |
|
8973 return _this; |
|
8974 } |
|
8975 |
|
8976 Object(createClass["a" /* default */])(_class, [{ |
|
8977 key: "createSetters", |
|
8978 value: function createSetters() { |
|
8979 var _this2 = this; |
|
8980 |
|
8981 return Object(external_lodash_["reduce"])(fontSizeAttributeNames, function (settersAccumulator, customFontSizeAttributeName, fontSizeAttributeName) { |
|
8982 var upperFirstFontSizeAttributeName = Object(external_lodash_["upperFirst"])(fontSizeAttributeName); |
|
8983 settersAccumulator["set".concat(upperFirstFontSizeAttributeName)] = _this2.createSetFontSize(fontSizeAttributeName, customFontSizeAttributeName); |
|
8984 return settersAccumulator; |
|
8985 }, {}); |
|
8986 } |
|
8987 }, { |
|
8988 key: "createSetFontSize", |
|
8989 value: function createSetFontSize(fontSizeAttributeName, customFontSizeAttributeName) { |
|
8990 var _this3 = this; |
|
8991 |
|
8992 return function (fontSizeValue) { |
|
8993 var _this3$props$setAttri; |
|
8994 |
|
8995 var fontSizeObject = Object(external_lodash_["find"])(_this3.props.fontSizes, { |
|
8996 size: fontSizeValue |
|
8997 }); |
|
8998 |
|
8999 _this3.props.setAttributes((_this3$props$setAttri = {}, Object(defineProperty["a" /* default */])(_this3$props$setAttri, fontSizeAttributeName, fontSizeObject && fontSizeObject.slug ? fontSizeObject.slug : undefined), Object(defineProperty["a" /* default */])(_this3$props$setAttri, customFontSizeAttributeName, fontSizeObject && fontSizeObject.slug ? undefined : fontSizeValue), _this3$props$setAttri)); |
|
9000 }; |
|
9001 } |
|
9002 }, { |
|
9003 key: "render", |
|
9004 value: function render() { |
|
9005 return Object(external_this_wp_element_["createElement"])(WrappedComponent, Object(objectSpread["a" /* default */])({}, this.props, { |
|
9006 fontSizes: undefined |
|
9007 }, this.state, this.setters)); |
|
9008 } |
|
9009 }], [{ |
|
9010 key: "getDerivedStateFromProps", |
|
9011 value: function getDerivedStateFromProps(_ref, previousState) { |
|
9012 var attributes = _ref.attributes, |
|
9013 fontSizes = _ref.fontSizes; |
|
9014 |
|
9015 var didAttributesChange = function didAttributesChange(customFontSizeAttributeName, fontSizeAttributeName) { |
|
9016 if (previousState[fontSizeAttributeName]) { |
|
9017 // if new font size is name compare with the previous slug |
|
9018 if (attributes[fontSizeAttributeName]) { |
|
9019 return attributes[fontSizeAttributeName] !== previousState[fontSizeAttributeName].slug; |
|
9020 } // if font size is not named, update when the font size value changes. |
|
9021 |
|
9022 |
|
9023 return previousState[fontSizeAttributeName].size !== attributes[customFontSizeAttributeName]; |
|
9024 } // in this case we need to build the font size object |
|
9025 |
|
9026 |
|
9027 return true; |
|
9028 }; |
|
9029 |
|
9030 if (!Object(external_lodash_["some"])(fontSizeAttributeNames, didAttributesChange)) { |
|
9031 return null; |
|
9032 } |
|
9033 |
|
9034 var newState = Object(external_lodash_["reduce"])(Object(external_lodash_["pickBy"])(fontSizeAttributeNames, didAttributesChange), function (newStateAccumulator, customFontSizeAttributeName, fontSizeAttributeName) { |
|
9035 var fontSizeAttributeValue = attributes[fontSizeAttributeName]; |
|
9036 var fontSizeObject = utils_getFontSize(fontSizes, fontSizeAttributeValue, attributes[customFontSizeAttributeName]); |
|
9037 newStateAccumulator[fontSizeAttributeName] = Object(objectSpread["a" /* default */])({}, fontSizeObject, { |
|
9038 class: getFontSizeClass(fontSizeAttributeValue) |
|
9039 }); |
|
9040 return newStateAccumulator; |
|
9041 }, {}); |
|
9042 return Object(objectSpread["a" /* default */])({}, previousState, newState); |
|
9043 } |
|
9044 }]); |
|
9045 |
|
9046 return _class; |
|
9047 }(external_this_wp_element_["Component"]) |
|
9048 ); |
|
9049 }]), 'withFontSizes'); |
|
9050 }); |
|
9051 |
|
9052 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/index.js |
|
9053 |
|
9054 |
|
9055 |
|
9056 |
|
9057 // EXTERNAL MODULE: external {"this":["wp","isShallowEqual"]} |
|
9058 var external_this_wp_isShallowEqual_ = __webpack_require__(42); |
|
9059 var external_this_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_isShallowEqual_); |
|
9060 |
|
9061 // EXTERNAL MODULE: external {"this":["wp","dom"]} |
|
9062 var external_this_wp_dom_ = __webpack_require__(24); |
|
9063 |
|
9064 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-mover/mover-description.js |
|
9065 /** |
|
9066 * WordPress dependencies |
|
9067 */ |
|
9068 |
|
9069 /** |
|
9070 * Return a label for the block movement controls depending on block position. |
|
9071 * |
|
9072 * @param {number} selectedCount Number of blocks selected. |
|
9073 * @param {string} type Block type - in the case of a single block, should |
|
9074 * define its 'type'. I.e. 'Text', 'Heading', 'Image' etc. |
|
9075 * @param {number} firstIndex The index (position - 1) of the first block selected. |
|
9076 * @param {boolean} isFirst This is the first block. |
|
9077 * @param {boolean} isLast This is the last block. |
|
9078 * @param {number} dir Direction of movement (> 0 is considered to be going |
|
9079 * down, < 0 is up). |
|
9080 * |
|
9081 * @return {string} Label for the block movement controls. |
|
9082 */ |
|
9083 |
|
9084 function getBlockMoverDescription(selectedCount, type, firstIndex, isFirst, isLast, dir) { |
|
9085 var position = firstIndex + 1; |
|
9086 |
|
9087 if (selectedCount > 1) { |
|
9088 return getMultiBlockMoverDescription(selectedCount, firstIndex, isFirst, isLast, dir); |
|
9089 } |
|
9090 |
|
9091 if (isFirst && isLast) { |
|
9092 // translators: %s: Type of block (i.e. Text, Image etc) |
|
9093 return Object(external_this_wp_i18n_["sprintf"])(Object(external_this_wp_i18n_["__"])('Block %s is the only block, and cannot be moved'), type); |
|
9094 } |
|
9095 |
|
9096 if (dir > 0 && !isLast) { |
|
9097 // moving down |
|
9098 return Object(external_this_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position |
|
9099 Object(external_this_wp_i18n_["__"])('Move %1$s block from position %2$d down to position %3$d'), type, position, position + 1); |
|
9100 } |
|
9101 |
|
9102 if (dir > 0 && isLast) { |
|
9103 // moving down, and is the last item |
|
9104 // translators: %s: Type of block (i.e. Text, Image etc) |
|
9105 return Object(external_this_wp_i18n_["sprintf"])(Object(external_this_wp_i18n_["__"])('Block %s is at the end of the content and can’t be moved down'), type); |
|
9106 } |
|
9107 |
|
9108 if (dir < 0 && !isFirst) { |
|
9109 // moving up |
|
9110 return Object(external_this_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position |
|
9111 Object(external_this_wp_i18n_["__"])('Move %1$s block from position %2$d up to position %3$d'), type, position, position - 1); |
|
9112 } |
|
9113 |
|
9114 if (dir < 0 && isFirst) { |
|
9115 // moving up, and is the first item |
|
9116 // translators: %s: Type of block (i.e. Text, Image etc) |
|
9117 return Object(external_this_wp_i18n_["sprintf"])(Object(external_this_wp_i18n_["__"])('Block %s is at the beginning of the content and can’t be moved up'), type); |
|
9118 } |
|
9119 } |
|
9120 /** |
|
9121 * Return a label for the block movement controls depending on block position. |
|
9122 * |
|
9123 * @param {number} selectedCount Number of blocks selected. |
|
9124 * @param {number} firstIndex The index (position - 1) of the first block selected. |
|
9125 * @param {boolean} isFirst This is the first block. |
|
9126 * @param {boolean} isLast This is the last block. |
|
9127 * @param {number} dir Direction of movement (> 0 is considered to be going |
|
9128 * down, < 0 is up). |
|
9129 * |
|
9130 * @return {string} Label for the block movement controls. |
|
9131 */ |
|
9132 |
|
9133 function getMultiBlockMoverDescription(selectedCount, firstIndex, isFirst, isLast, dir) { |
|
9134 var position = firstIndex + 1; |
|
9135 |
|
9136 if (dir < 0 && isFirst) { |
|
9137 return Object(external_this_wp_i18n_["__"])('Blocks cannot be moved up as they are already at the top'); |
|
9138 } |
|
9139 |
|
9140 if (dir > 0 && isLast) { |
|
9141 return Object(external_this_wp_i18n_["__"])('Blocks cannot be moved down as they are already at the bottom'); |
|
9142 } |
|
9143 |
|
9144 if (dir < 0 && !isFirst) { |
|
9145 return Object(external_this_wp_i18n_["sprintf"])( // translators: 1: Number of selected blocks, 2: Position of selected blocks |
|
9146 Object(external_this_wp_i18n_["_n"])('Move %1$d block from position %2$d up by one place', 'Move %1$d blocks from position %2$d up by one place', selectedCount), selectedCount, position); |
|
9147 } |
|
9148 |
|
9149 if (dir > 0 && !isLast) { |
|
9150 return Object(external_this_wp_i18n_["sprintf"])( // translators: 1: Number of selected blocks, 2: Position of selected blocks |
|
9151 Object(external_this_wp_i18n_["_n"])('Move %1$d block from position %2$d down by one place', 'Move %1$d blocks from position %2$d down by one place', selectedCount), selectedCount, position); |
|
9152 } |
|
9153 } |
|
9154 |
|
9155 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-mover/icons.js |
|
9156 |
|
9157 |
|
9158 /** |
|
9159 * WordPress dependencies |
|
9160 */ |
|
9161 |
|
9162 var upArrow = Object(external_this_wp_element_["createElement"])(external_this_wp_components_["SVG"], { |
|
9163 width: "18", |
|
9164 height: "18", |
|
9165 xmlns: "http://www.w3.org/2000/svg", |
|
9166 viewBox: "0 0 18 18" |
|
9167 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Polygon"], { |
|
9168 points: "9,4.5 3.3,10.1 4.8,11.5 9,7.3 13.2,11.5 14.7,10.1 " |
|
9169 })); |
|
9170 var downArrow = Object(external_this_wp_element_["createElement"])(external_this_wp_components_["SVG"], { |
|
9171 width: "18", |
|
9172 height: "18", |
|
9173 xmlns: "http://www.w3.org/2000/svg", |
|
9174 viewBox: "0 0 18 18" |
|
9175 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Polygon"], { |
|
9176 points: "9,13.5 14.7,7.9 13.2,6.5 9,10.7 4.8,6.5 3.3,7.9 " |
|
9177 })); |
|
9178 var dragHandle = Object(external_this_wp_element_["createElement"])(external_this_wp_components_["SVG"], { |
|
9179 width: "18", |
|
9180 height: "18", |
|
9181 xmlns: "http://www.w3.org/2000/svg", |
|
9182 viewBox: "0 0 18 18" |
|
9183 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Path"], { |
|
9184 d: "M13,8c0.6,0,1-0.4,1-1s-0.4-1-1-1s-1,0.4-1,1S12.4,8,13,8z M5,6C4.4,6,4,6.4,4,7s0.4,1,1,1s1-0.4,1-1S5.6,6,5,6z M5,10 c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S5.6,10,5,10z M13,10c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S13.6,10,13,10z M9,6 C8.4,6,8,6.4,8,7s0.4,1,1,1s1-0.4,1-1S9.6,6,9,6z M9,10c-0.6,0-1,0.4-1,1s0.4,1,1,1s1-0.4,1-1S9.6,10,9,10z" |
|
9185 })); |
|
9186 |
|
9187 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-draggable/index.js |
|
9188 |
|
9189 |
|
9190 /** |
|
9191 * WordPress dependencies |
|
9192 */ |
|
9193 |
|
9194 |
|
9195 |
|
9196 var block_draggable_BlockDraggable = function BlockDraggable(_ref) { |
|
9197 var children = _ref.children, |
|
9198 clientId = _ref.clientId, |
|
9199 rootClientId = _ref.rootClientId, |
|
9200 blockElementId = _ref.blockElementId, |
|
9201 index = _ref.index, |
|
9202 onDragStart = _ref.onDragStart, |
|
9203 onDragEnd = _ref.onDragEnd; |
|
9204 var transferData = { |
|
9205 type: 'block', |
|
9206 srcIndex: index, |
|
9207 srcRootClientId: rootClientId, |
|
9208 srcClientId: clientId |
|
9209 }; |
|
9210 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Draggable"], { |
|
9211 elementId: blockElementId, |
|
9212 transferData: transferData, |
|
9213 onDragStart: onDragStart, |
|
9214 onDragEnd: onDragEnd |
|
9215 }, function (_ref2) { |
|
9216 var onDraggableStart = _ref2.onDraggableStart, |
|
9217 onDraggableEnd = _ref2.onDraggableEnd; |
|
9218 return children({ |
|
9219 onDraggableStart: onDraggableStart, |
|
9220 onDraggableEnd: onDraggableEnd |
|
9221 }); |
|
9222 }); |
|
9223 }; |
|
9224 |
|
9225 /* harmony default export */ var block_draggable = (Object(external_this_wp_data_["withSelect"])(function (select, _ref3) { |
|
9226 var clientId = _ref3.clientId; |
|
9227 |
|
9228 var _select = select('core/block-editor'), |
|
9229 getBlockIndex = _select.getBlockIndex, |
|
9230 getBlockRootClientId = _select.getBlockRootClientId; |
|
9231 |
|
9232 var rootClientId = getBlockRootClientId(clientId); |
|
9233 return { |
|
9234 index: getBlockIndex(clientId, rootClientId), |
|
9235 rootClientId: rootClientId |
|
9236 }; |
|
9237 })(block_draggable_BlockDraggable)); |
|
9238 |
|
9239 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-mover/drag-handle.js |
|
9240 |
|
9241 |
|
9242 /** |
|
9243 * External dependencies |
|
9244 */ |
|
9245 |
|
9246 /** |
|
9247 * Internal dependencies |
|
9248 */ |
|
9249 |
|
9250 |
|
9251 var drag_handle_IconDragHandle = function IconDragHandle(_ref) { |
|
9252 var isVisible = _ref.isVisible, |
|
9253 className = _ref.className, |
|
9254 icon = _ref.icon, |
|
9255 onDragStart = _ref.onDragStart, |
|
9256 onDragEnd = _ref.onDragEnd, |
|
9257 blockElementId = _ref.blockElementId, |
|
9258 clientId = _ref.clientId; |
|
9259 |
|
9260 if (!isVisible) { |
|
9261 return null; |
|
9262 } |
|
9263 |
|
9264 var dragHandleClassNames = classnames_default()('editor-block-mover__control-drag-handle block-editor-block-mover__control-drag-handle', className); |
|
9265 return Object(external_this_wp_element_["createElement"])(block_draggable, { |
|
9266 clientId: clientId, |
|
9267 blockElementId: blockElementId, |
|
9268 onDragStart: onDragStart, |
|
9269 onDragEnd: onDragEnd |
|
9270 }, function (_ref2) { |
|
9271 var onDraggableStart = _ref2.onDraggableStart, |
|
9272 onDraggableEnd = _ref2.onDraggableEnd; |
|
9273 return Object(external_this_wp_element_["createElement"])("div", { |
|
9274 className: dragHandleClassNames, |
|
9275 "aria-hidden": "true", |
|
9276 onDragStart: onDraggableStart, |
|
9277 onDragEnd: onDraggableEnd, |
|
9278 draggable: true |
|
9279 }, icon); |
|
9280 }); |
|
9281 }; |
|
9282 |
|
9283 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-mover/index.js |
|
9284 |
|
9285 |
|
9286 |
|
9287 |
|
9288 |
|
9289 |
|
9290 |
|
9291 |
|
9292 /** |
|
9293 * External dependencies |
|
9294 */ |
|
9295 |
|
9296 |
|
9297 /** |
|
9298 * WordPress dependencies |
|
9299 */ |
|
9300 |
|
9301 |
|
9302 |
|
9303 |
|
9304 |
|
9305 |
|
9306 |
|
9307 /** |
|
9308 * Internal dependencies |
|
9309 */ |
|
9310 |
|
9311 |
|
9312 |
|
9313 |
|
9314 var block_mover_BlockMover = |
|
9315 /*#__PURE__*/ |
|
9316 function (_Component) { |
|
9317 Object(inherits["a" /* default */])(BlockMover, _Component); |
|
9318 |
|
9319 function BlockMover() { |
|
9320 var _this; |
|
9321 |
|
9322 Object(classCallCheck["a" /* default */])(this, BlockMover); |
|
9323 |
|
9324 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(BlockMover).apply(this, arguments)); |
|
9325 _this.state = { |
|
9326 isFocused: false |
|
9327 }; |
|
9328 _this.onFocus = _this.onFocus.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
9329 _this.onBlur = _this.onBlur.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
9330 return _this; |
|
9331 } |
|
9332 |
|
9333 Object(createClass["a" /* default */])(BlockMover, [{ |
|
9334 key: "onFocus", |
|
9335 value: function onFocus() { |
|
9336 this.setState({ |
|
9337 isFocused: true |
|
9338 }); |
|
9339 } |
|
9340 }, { |
|
9341 key: "onBlur", |
|
9342 value: function onBlur() { |
|
9343 this.setState({ |
|
9344 isFocused: false |
|
9345 }); |
|
9346 } |
|
9347 }, { |
|
9348 key: "render", |
|
9349 value: function render() { |
|
9350 var _this$props = this.props, |
|
9351 onMoveUp = _this$props.onMoveUp, |
|
9352 onMoveDown = _this$props.onMoveDown, |
|
9353 isFirst = _this$props.isFirst, |
|
9354 isLast = _this$props.isLast, |
|
9355 isDraggable = _this$props.isDraggable, |
|
9356 onDragStart = _this$props.onDragStart, |
|
9357 onDragEnd = _this$props.onDragEnd, |
|
9358 clientIds = _this$props.clientIds, |
|
9359 blockElementId = _this$props.blockElementId, |
|
9360 blockType = _this$props.blockType, |
|
9361 firstIndex = _this$props.firstIndex, |
|
9362 isLocked = _this$props.isLocked, |
|
9363 instanceId = _this$props.instanceId, |
|
9364 isHidden = _this$props.isHidden; |
|
9365 var isFocused = this.state.isFocused; |
|
9366 var blocksCount = Object(external_lodash_["castArray"])(clientIds).length; |
|
9367 |
|
9368 if (isLocked || isFirst && isLast) { |
|
9369 return null; |
|
9370 } // We emulate a disabled state because forcefully applying the `disabled` |
|
9371 // attribute on the button while it has focus causes the screen to change |
|
9372 // to an unfocused state (body as active element) without firing blur on, |
|
9373 // the rendering parent, leaving it unable to react to focus out. |
|
9374 |
|
9375 |
|
9376 return Object(external_this_wp_element_["createElement"])("div", { |
|
9377 className: classnames_default()('editor-block-mover block-editor-block-mover', { |
|
9378 'is-visible': isFocused || !isHidden |
|
9379 }) |
|
9380 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], { |
|
9381 className: "editor-block-mover__control block-editor-block-mover__control", |
|
9382 onClick: isFirst ? null : onMoveUp, |
|
9383 icon: upArrow, |
|
9384 label: Object(external_this_wp_i18n_["__"])('Move up'), |
|
9385 "aria-describedby": "block-editor-block-mover__up-description-".concat(instanceId), |
|
9386 "aria-disabled": isFirst, |
|
9387 onFocus: this.onFocus, |
|
9388 onBlur: this.onBlur |
|
9389 }), Object(external_this_wp_element_["createElement"])(drag_handle_IconDragHandle, { |
|
9390 className: "editor-block-mover__control block-editor-block-mover__control", |
|
9391 icon: dragHandle, |
|
9392 clientId: clientIds, |
|
9393 blockElementId: blockElementId, |
|
9394 isVisible: isDraggable, |
|
9395 onDragStart: onDragStart, |
|
9396 onDragEnd: onDragEnd |
|
9397 }), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], { |
|
9398 className: "editor-block-mover__control block-editor-block-mover__control", |
|
9399 onClick: isLast ? null : onMoveDown, |
|
9400 icon: downArrow, |
|
9401 label: Object(external_this_wp_i18n_["__"])('Move down'), |
|
9402 "aria-describedby": "block-editor-block-mover__down-description-".concat(instanceId), |
|
9403 "aria-disabled": isLast, |
|
9404 onFocus: this.onFocus, |
|
9405 onBlur: this.onBlur |
|
9406 }), Object(external_this_wp_element_["createElement"])("span", { |
|
9407 id: "block-editor-block-mover__up-description-".concat(instanceId), |
|
9408 className: "editor-block-mover__description block-editor-block-mover__description" |
|
9409 }, getBlockMoverDescription(blocksCount, blockType && blockType.title, firstIndex, isFirst, isLast, -1)), Object(external_this_wp_element_["createElement"])("span", { |
|
9410 id: "block-editor-block-mover__down-description-".concat(instanceId), |
|
9411 className: "editor-block-mover__description block-editor-block-mover__description" |
|
9412 }, getBlockMoverDescription(blocksCount, blockType && blockType.title, firstIndex, isFirst, isLast, 1))); |
|
9413 } |
|
9414 }]); |
|
9415 |
|
9416 return BlockMover; |
|
9417 }(external_this_wp_element_["Component"]); |
|
9418 /* harmony default export */ var block_mover = (Object(external_this_wp_compose_["compose"])(Object(external_this_wp_data_["withSelect"])(function (select, _ref) { |
|
9419 var clientIds = _ref.clientIds; |
|
9420 |
|
9421 var _select = select('core/block-editor'), |
|
9422 getBlock = _select.getBlock, |
|
9423 getBlockIndex = _select.getBlockIndex, |
|
9424 getTemplateLock = _select.getTemplateLock, |
|
9425 getBlockRootClientId = _select.getBlockRootClientId; |
|
9426 |
|
9427 var firstClientId = Object(external_lodash_["first"])(Object(external_lodash_["castArray"])(clientIds)); |
|
9428 var block = getBlock(firstClientId); |
|
9429 var rootClientId = getBlockRootClientId(Object(external_lodash_["first"])(Object(external_lodash_["castArray"])(clientIds))); |
|
9430 return { |
|
9431 firstIndex: getBlockIndex(firstClientId, rootClientId), |
|
9432 blockType: block ? Object(external_this_wp_blocks_["getBlockType"])(block.name) : null, |
|
9433 isLocked: getTemplateLock(rootClientId) === 'all', |
|
9434 rootClientId: rootClientId |
|
9435 }; |
|
9436 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, _ref2) { |
|
9437 var clientIds = _ref2.clientIds, |
|
9438 rootClientId = _ref2.rootClientId; |
|
9439 |
|
9440 var _dispatch = dispatch('core/block-editor'), |
|
9441 moveBlocksDown = _dispatch.moveBlocksDown, |
|
9442 moveBlocksUp = _dispatch.moveBlocksUp; |
|
9443 |
|
9444 return { |
|
9445 onMoveDown: Object(external_lodash_["partial"])(moveBlocksDown, clientIds, rootClientId), |
|
9446 onMoveUp: Object(external_lodash_["partial"])(moveBlocksUp, clientIds, rootClientId) |
|
9447 }; |
|
9448 }), external_this_wp_compose_["withInstanceId"])(block_mover_BlockMover)); |
|
9449 |
|
9450 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-upload/check.js |
|
9451 /** |
|
9452 * External dependencies |
|
9453 */ |
|
9454 |
|
9455 /** |
|
9456 * WordPress dependencies |
|
9457 */ |
|
9458 |
|
9459 |
|
9460 function MediaUploadCheck(_ref) { |
|
9461 var hasUploadPermissions = _ref.hasUploadPermissions, |
|
9462 _ref$fallback = _ref.fallback, |
|
9463 fallback = _ref$fallback === void 0 ? null : _ref$fallback, |
|
9464 children = _ref.children; |
|
9465 return hasUploadPermissions ? children : fallback; |
|
9466 } |
|
9467 /* harmony default export */ var check = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
9468 var _select = select('core'), |
|
9469 canUser = _select.canUser; |
|
9470 |
|
9471 return { |
|
9472 hasUploadPermissions: Object(external_lodash_["defaultTo"])(canUser('create', 'media'), true) |
|
9473 }; |
|
9474 })(MediaUploadCheck)); |
|
9475 |
|
9476 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-drop-zone/index.js |
|
9477 |
|
9478 |
|
9479 |
|
9480 |
|
9481 |
|
9482 |
|
9483 |
|
9484 |
|
9485 /** |
|
9486 * External dependencies |
|
9487 */ |
|
9488 |
|
9489 /** |
|
9490 * WordPress dependencies |
|
9491 */ |
|
9492 |
|
9493 |
|
9494 |
|
9495 |
|
9496 |
|
9497 |
|
9498 /** |
|
9499 * Internal dependencies |
|
9500 */ |
|
9501 |
|
9502 |
|
9503 |
|
9504 var parseDropEvent = function parseDropEvent(event) { |
|
9505 var result = { |
|
9506 srcRootClientId: null, |
|
9507 srcClientId: null, |
|
9508 srcIndex: null, |
|
9509 type: null |
|
9510 }; |
|
9511 |
|
9512 if (!event.dataTransfer) { |
|
9513 return result; |
|
9514 } |
|
9515 |
|
9516 try { |
|
9517 result = Object.assign(result, JSON.parse(event.dataTransfer.getData('text'))); |
|
9518 } catch (err) { |
|
9519 return result; |
|
9520 } |
|
9521 |
|
9522 return result; |
|
9523 }; |
|
9524 |
|
9525 var block_drop_zone_BlockDropZone = |
|
9526 /*#__PURE__*/ |
|
9527 function (_Component) { |
|
9528 Object(inherits["a" /* default */])(BlockDropZone, _Component); |
|
9529 |
|
9530 function BlockDropZone() { |
|
9531 var _this; |
|
9532 |
|
9533 Object(classCallCheck["a" /* default */])(this, BlockDropZone); |
|
9534 |
|
9535 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(BlockDropZone).apply(this, arguments)); |
|
9536 _this.onFilesDrop = _this.onFilesDrop.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
9537 _this.onHTMLDrop = _this.onHTMLDrop.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
9538 _this.onDrop = _this.onDrop.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
9539 return _this; |
|
9540 } |
|
9541 |
|
9542 Object(createClass["a" /* default */])(BlockDropZone, [{ |
|
9543 key: "getInsertIndex", |
|
9544 value: function getInsertIndex(position) { |
|
9545 var _this$props = this.props, |
|
9546 clientId = _this$props.clientId, |
|
9547 rootClientId = _this$props.rootClientId, |
|
9548 getBlockIndex = _this$props.getBlockIndex; |
|
9549 |
|
9550 if (clientId !== undefined) { |
|
9551 var index = getBlockIndex(clientId, rootClientId); |
|
9552 return position.y === 'top' ? index : index + 1; |
|
9553 } |
|
9554 } |
|
9555 }, { |
|
9556 key: "onFilesDrop", |
|
9557 value: function onFilesDrop(files, position) { |
|
9558 var transformation = Object(external_this_wp_blocks_["findTransform"])(Object(external_this_wp_blocks_["getBlockTransforms"])('from'), function (transform) { |
|
9559 return transform.type === 'files' && transform.isMatch(files); |
|
9560 }); |
|
9561 |
|
9562 if (transformation) { |
|
9563 var insertIndex = this.getInsertIndex(position); |
|
9564 var blocks = transformation.transform(files, this.props.updateBlockAttributes); |
|
9565 this.props.insertBlocks(blocks, insertIndex); |
|
9566 } |
|
9567 } |
|
9568 }, { |
|
9569 key: "onHTMLDrop", |
|
9570 value: function onHTMLDrop(HTML, position) { |
|
9571 var blocks = Object(external_this_wp_blocks_["pasteHandler"])({ |
|
9572 HTML: HTML, |
|
9573 mode: 'BLOCKS' |
|
9574 }); |
|
9575 |
|
9576 if (blocks.length) { |
|
9577 this.props.insertBlocks(blocks, this.getInsertIndex(position)); |
|
9578 } |
|
9579 } |
|
9580 }, { |
|
9581 key: "onDrop", |
|
9582 value: function onDrop(event, position) { |
|
9583 var _this$props2 = this.props, |
|
9584 dstRootClientId = _this$props2.rootClientId, |
|
9585 dstClientId = _this$props2.clientId, |
|
9586 getClientIdsOfDescendants = _this$props2.getClientIdsOfDescendants, |
|
9587 getBlockIndex = _this$props2.getBlockIndex; |
|
9588 |
|
9589 var _parseDropEvent = parseDropEvent(event), |
|
9590 srcRootClientId = _parseDropEvent.srcRootClientId, |
|
9591 srcClientId = _parseDropEvent.srcClientId, |
|
9592 srcIndex = _parseDropEvent.srcIndex, |
|
9593 type = _parseDropEvent.type; |
|
9594 |
|
9595 var isBlockDropType = function isBlockDropType(dropType) { |
|
9596 return dropType === 'block'; |
|
9597 }; |
|
9598 |
|
9599 var isSameLevel = function isSameLevel(srcRoot, dstRoot) { |
|
9600 // Note that rootClientId of top-level blocks will be undefined OR a void string, |
|
9601 // so we also need to account for that case separately. |
|
9602 return srcRoot === dstRoot || !srcRoot === true && !dstRoot === true; |
|
9603 }; |
|
9604 |
|
9605 var isSameBlock = function isSameBlock(src, dst) { |
|
9606 return src === dst; |
|
9607 }; |
|
9608 |
|
9609 var isSrcBlockAnAncestorOfDstBlock = function isSrcBlockAnAncestorOfDstBlock(src, dst) { |
|
9610 return getClientIdsOfDescendants([src]).some(function (id) { |
|
9611 return id === dst; |
|
9612 }); |
|
9613 }; |
|
9614 |
|
9615 if (!isBlockDropType(type) || isSameBlock(srcClientId, dstClientId) || isSrcBlockAnAncestorOfDstBlock(srcClientId, dstClientId || dstRootClientId)) { |
|
9616 return; |
|
9617 } |
|
9618 |
|
9619 var dstIndex = dstClientId ? getBlockIndex(dstClientId, dstRootClientId) : undefined; |
|
9620 var positionIndex = this.getInsertIndex(position); // If the block is kept at the same level and moved downwards, |
|
9621 // subtract to account for blocks shifting upward to occupy its old position. |
|
9622 |
|
9623 var insertIndex = dstIndex && srcIndex < dstIndex && isSameLevel(srcRootClientId, dstRootClientId) ? positionIndex - 1 : positionIndex; |
|
9624 this.props.moveBlockToPosition(srcClientId, srcRootClientId, insertIndex); |
|
9625 } |
|
9626 }, { |
|
9627 key: "render", |
|
9628 value: function render() { |
|
9629 var _this$props3 = this.props, |
|
9630 isLocked = _this$props3.isLocked, |
|
9631 index = _this$props3.index; |
|
9632 |
|
9633 if (isLocked) { |
|
9634 return null; |
|
9635 } |
|
9636 |
|
9637 var isAppender = index === undefined; |
|
9638 return Object(external_this_wp_element_["createElement"])(check, null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["DropZone"], { |
|
9639 className: classnames_default()('editor-block-drop-zone block-editor-block-drop-zone', { |
|
9640 'is-appender': isAppender |
|
9641 }), |
|
9642 onFilesDrop: this.onFilesDrop, |
|
9643 onHTMLDrop: this.onHTMLDrop, |
|
9644 onDrop: this.onDrop |
|
9645 })); |
|
9646 } |
|
9647 }]); |
|
9648 |
|
9649 return BlockDropZone; |
|
9650 }(external_this_wp_element_["Component"]); |
|
9651 |
|
9652 /* harmony default export */ var block_drop_zone = (Object(external_this_wp_compose_["compose"])(Object(external_this_wp_data_["withDispatch"])(function (dispatch, ownProps) { |
|
9653 var _dispatch = dispatch('core/block-editor'), |
|
9654 _insertBlocks = _dispatch.insertBlocks, |
|
9655 _updateBlockAttributes = _dispatch.updateBlockAttributes, |
|
9656 _moveBlockToPosition = _dispatch.moveBlockToPosition; |
|
9657 |
|
9658 return { |
|
9659 insertBlocks: function insertBlocks(blocks, index) { |
|
9660 var rootClientId = ownProps.rootClientId; |
|
9661 |
|
9662 _insertBlocks(blocks, index, rootClientId); |
|
9663 }, |
|
9664 updateBlockAttributes: function updateBlockAttributes() { |
|
9665 _updateBlockAttributes.apply(void 0, arguments); |
|
9666 }, |
|
9667 moveBlockToPosition: function moveBlockToPosition(srcClientId, srcRootClientId, dstIndex) { |
|
9668 var dstRootClientId = ownProps.rootClientId; |
|
9669 |
|
9670 _moveBlockToPosition(srcClientId, srcRootClientId, dstRootClientId, dstIndex); |
|
9671 } |
|
9672 }; |
|
9673 }), Object(external_this_wp_data_["withSelect"])(function (select, _ref) { |
|
9674 var rootClientId = _ref.rootClientId; |
|
9675 |
|
9676 var _select = select('core/block-editor'), |
|
9677 getClientIdsOfDescendants = _select.getClientIdsOfDescendants, |
|
9678 getTemplateLock = _select.getTemplateLock, |
|
9679 getBlockIndex = _select.getBlockIndex; |
|
9680 |
|
9681 return { |
|
9682 isLocked: !!getTemplateLock(rootClientId), |
|
9683 getClientIdsOfDescendants: getClientIdsOfDescendants, |
|
9684 getBlockIndex: getBlockIndex |
|
9685 }; |
|
9686 }), Object(external_this_wp_components_["withFilters"])('editor.BlockDropZone'))(block_drop_zone_BlockDropZone)); |
|
9687 |
|
9688 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/warning/index.js |
|
9689 |
|
9690 |
|
9691 /** |
|
9692 * External dependencies |
|
9693 */ |
|
9694 |
|
9695 /** |
|
9696 * WordPress dependencies |
|
9697 */ |
|
9698 |
|
9699 |
|
9700 |
|
9701 |
|
9702 |
|
9703 function Warning(_ref) { |
|
9704 var className = _ref.className, |
|
9705 actions = _ref.actions, |
|
9706 children = _ref.children, |
|
9707 secondaryActions = _ref.secondaryActions; |
|
9708 return Object(external_this_wp_element_["createElement"])("div", { |
|
9709 className: classnames_default()(className, 'editor-warning block-editor-warning') |
|
9710 }, Object(external_this_wp_element_["createElement"])("div", { |
|
9711 className: "editor-warning__contents block-editor-warning__contents" |
|
9712 }, Object(external_this_wp_element_["createElement"])("p", { |
|
9713 className: "editor-warning__message block-editor-warning__message" |
|
9714 }, children), external_this_wp_element_["Children"].count(actions) > 0 && Object(external_this_wp_element_["createElement"])("div", { |
|
9715 className: "editor-warning__actions block-editor-warning__actions" |
|
9716 }, external_this_wp_element_["Children"].map(actions, function (action, i) { |
|
9717 return Object(external_this_wp_element_["createElement"])("span", { |
|
9718 key: i, |
|
9719 className: "editor-warning__action block-editor-warning__action" |
|
9720 }, action); |
|
9721 }))), secondaryActions && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Dropdown"], { |
|
9722 className: "editor-warning__secondary block-editor-warning__secondary", |
|
9723 position: "bottom left", |
|
9724 renderToggle: function renderToggle(_ref2) { |
|
9725 var isOpen = _ref2.isOpen, |
|
9726 onToggle = _ref2.onToggle; |
|
9727 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], { |
|
9728 icon: "ellipsis", |
|
9729 label: Object(external_this_wp_i18n_["__"])('More options'), |
|
9730 onClick: onToggle, |
|
9731 "aria-expanded": isOpen |
|
9732 }); |
|
9733 }, |
|
9734 renderContent: function renderContent() { |
|
9735 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["MenuGroup"], null, secondaryActions.map(function (item, pos) { |
|
9736 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["MenuItem"], { |
|
9737 onClick: item.onClick, |
|
9738 key: pos |
|
9739 }, item.title); |
|
9740 })); |
|
9741 } |
|
9742 })); |
|
9743 } |
|
9744 |
|
9745 /* harmony default export */ var warning = (Warning); |
|
9746 |
|
9747 // EXTERNAL MODULE: ./node_modules/diff/dist/diff.js |
|
9748 var diff = __webpack_require__(207); |
|
9749 |
|
9750 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-compare/block-view.js |
|
9751 |
|
9752 |
|
9753 /** |
|
9754 * WordPress dependencies |
|
9755 */ |
|
9756 |
|
9757 |
|
9758 var block_view_BlockView = function BlockView(_ref) { |
|
9759 var title = _ref.title, |
|
9760 rawContent = _ref.rawContent, |
|
9761 renderedContent = _ref.renderedContent, |
|
9762 action = _ref.action, |
|
9763 actionText = _ref.actionText, |
|
9764 className = _ref.className; |
|
9765 return Object(external_this_wp_element_["createElement"])("div", { |
|
9766 className: className |
|
9767 }, Object(external_this_wp_element_["createElement"])("div", { |
|
9768 className: "editor-block-compare__content block-editor-block-compare__content" |
|
9769 }, Object(external_this_wp_element_["createElement"])("h2", { |
|
9770 className: "editor-block-compare__heading block-editor-block-compare__heading" |
|
9771 }, title), Object(external_this_wp_element_["createElement"])("div", { |
|
9772 className: "editor-block-compare__html block-editor-block-compare__html" |
|
9773 }, rawContent), Object(external_this_wp_element_["createElement"])("div", { |
|
9774 className: "editor-block-compare__preview block-editor-block-compare__preview edit-post-visual-editor" |
|
9775 }, renderedContent)), Object(external_this_wp_element_["createElement"])("div", { |
|
9776 className: "editor-block-compare__action block-editor-block-compare__action" |
|
9777 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
9778 isLarge: true, |
|
9779 tabIndex: "0", |
|
9780 onClick: action |
|
9781 }, actionText))); |
|
9782 }; |
|
9783 |
|
9784 /* harmony default export */ var block_view = (block_view_BlockView); |
|
9785 |
|
9786 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-compare/index.js |
|
9787 |
|
9788 |
|
9789 |
|
9790 |
|
9791 |
|
9792 |
|
9793 |
|
9794 /** |
|
9795 * External dependencies |
|
9796 */ |
|
9797 |
|
9798 |
|
9799 |
|
9800 /** |
|
9801 * WordPress dependencies |
|
9802 */ |
|
9803 |
|
9804 |
|
9805 |
|
9806 |
|
9807 /** |
|
9808 * Internal dependencies |
|
9809 */ |
|
9810 |
|
9811 |
|
9812 |
|
9813 var block_compare_BlockCompare = |
|
9814 /*#__PURE__*/ |
|
9815 function (_Component) { |
|
9816 Object(inherits["a" /* default */])(BlockCompare, _Component); |
|
9817 |
|
9818 function BlockCompare() { |
|
9819 Object(classCallCheck["a" /* default */])(this, BlockCompare); |
|
9820 |
|
9821 return Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(BlockCompare).apply(this, arguments)); |
|
9822 } |
|
9823 |
|
9824 Object(createClass["a" /* default */])(BlockCompare, [{ |
|
9825 key: "getDifference", |
|
9826 value: function getDifference(originalContent, newContent) { |
|
9827 var difference = Object(diff["diffChars"])(originalContent, newContent); |
|
9828 return difference.map(function (item, pos) { |
|
9829 var classes = classnames_default()({ |
|
9830 'editor-block-compare__added block-editor-block-compare__added': item.added, |
|
9831 'editor-block-compare__removed block-editor-block-compare__removed': item.removed |
|
9832 }); |
|
9833 return Object(external_this_wp_element_["createElement"])("span", { |
|
9834 key: pos, |
|
9835 className: classes |
|
9836 }, item.value); |
|
9837 }); |
|
9838 } |
|
9839 }, { |
|
9840 key: "getOriginalContent", |
|
9841 value: function getOriginalContent(block) { |
|
9842 return { |
|
9843 rawContent: block.originalContent, |
|
9844 renderedContent: Object(external_this_wp_blocks_["getSaveElement"])(block.name, block.attributes) |
|
9845 }; |
|
9846 } |
|
9847 }, { |
|
9848 key: "getConvertedContent", |
|
9849 value: function getConvertedContent(block) { |
|
9850 // The convertor may return an array of items or a single item |
|
9851 var newBlocks = Object(external_lodash_["castArray"])(block); // Get converted block details |
|
9852 |
|
9853 var newContent = newBlocks.map(function (item) { |
|
9854 return Object(external_this_wp_blocks_["getSaveContent"])(item.name, item.attributes, item.innerBlocks); |
|
9855 }); |
|
9856 var renderedContent = newBlocks.map(function (item) { |
|
9857 return Object(external_this_wp_blocks_["getSaveElement"])(item.name, item.attributes, item.innerBlocks); |
|
9858 }); |
|
9859 return { |
|
9860 rawContent: newContent.join(''), |
|
9861 renderedContent: renderedContent |
|
9862 }; |
|
9863 } |
|
9864 }, { |
|
9865 key: "render", |
|
9866 value: function render() { |
|
9867 var _this$props = this.props, |
|
9868 block = _this$props.block, |
|
9869 onKeep = _this$props.onKeep, |
|
9870 onConvert = _this$props.onConvert, |
|
9871 convertor = _this$props.convertor, |
|
9872 convertButtonText = _this$props.convertButtonText; |
|
9873 var original = this.getOriginalContent(block); |
|
9874 var converted = this.getConvertedContent(convertor(block)); |
|
9875 var difference = this.getDifference(original.rawContent, converted.rawContent); |
|
9876 return Object(external_this_wp_element_["createElement"])("div", { |
|
9877 className: "editor-block-compare__wrapper block-editor-block-compare__wrapper" |
|
9878 }, Object(external_this_wp_element_["createElement"])(block_view, { |
|
9879 title: Object(external_this_wp_i18n_["__"])('Current'), |
|
9880 className: "editor-block-compare__current block-editor-block-compare__current", |
|
9881 action: onKeep, |
|
9882 actionText: Object(external_this_wp_i18n_["__"])('Convert to HTML'), |
|
9883 rawContent: original.rawContent, |
|
9884 renderedContent: original.renderedContent |
|
9885 }), Object(external_this_wp_element_["createElement"])(block_view, { |
|
9886 title: Object(external_this_wp_i18n_["__"])('After Conversion'), |
|
9887 className: "editor-block-compare__converted block-editor-block-compare__converted", |
|
9888 action: onConvert, |
|
9889 actionText: convertButtonText, |
|
9890 rawContent: difference, |
|
9891 renderedContent: converted.renderedContent |
|
9892 })); |
|
9893 } |
|
9894 }]); |
|
9895 |
|
9896 return BlockCompare; |
|
9897 }(external_this_wp_element_["Component"]); |
|
9898 |
|
9899 /* harmony default export */ var block_compare = (block_compare_BlockCompare); |
|
9900 |
|
9901 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-invalid-warning.js |
|
9902 |
|
9903 |
|
9904 |
|
9905 |
|
9906 |
|
9907 |
|
9908 |
|
9909 |
|
9910 /** |
|
9911 * WordPress dependencies |
|
9912 */ |
|
9913 |
|
9914 |
|
9915 |
|
9916 |
|
9917 |
|
9918 |
|
9919 /** |
|
9920 * Internal dependencies |
|
9921 */ |
|
9922 |
|
9923 |
|
9924 |
|
9925 var block_invalid_warning_BlockInvalidWarning = |
|
9926 /*#__PURE__*/ |
|
9927 function (_Component) { |
|
9928 Object(inherits["a" /* default */])(BlockInvalidWarning, _Component); |
|
9929 |
|
9930 function BlockInvalidWarning(props) { |
|
9931 var _this; |
|
9932 |
|
9933 Object(classCallCheck["a" /* default */])(this, BlockInvalidWarning); |
|
9934 |
|
9935 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(BlockInvalidWarning).call(this, props)); |
|
9936 _this.state = { |
|
9937 compare: false |
|
9938 }; |
|
9939 _this.onCompare = _this.onCompare.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
9940 _this.onCompareClose = _this.onCompareClose.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
9941 return _this; |
|
9942 } |
|
9943 |
|
9944 Object(createClass["a" /* default */])(BlockInvalidWarning, [{ |
|
9945 key: "onCompare", |
|
9946 value: function onCompare() { |
|
9947 this.setState({ |
|
9948 compare: true |
|
9949 }); |
|
9950 } |
|
9951 }, { |
|
9952 key: "onCompareClose", |
|
9953 value: function onCompareClose() { |
|
9954 this.setState({ |
|
9955 compare: false |
|
9956 }); |
|
9957 } |
|
9958 }, { |
|
9959 key: "render", |
|
9960 value: function render() { |
|
9961 var _this$props = this.props, |
|
9962 convertToHTML = _this$props.convertToHTML, |
|
9963 convertToBlocks = _this$props.convertToBlocks, |
|
9964 convertToClassic = _this$props.convertToClassic, |
|
9965 attemptBlockRecovery = _this$props.attemptBlockRecovery, |
|
9966 block = _this$props.block; |
|
9967 var hasHTMLBlock = !!Object(external_this_wp_blocks_["getBlockType"])('core/html'); |
|
9968 var compare = this.state.compare; |
|
9969 var hiddenActions = [{ |
|
9970 title: Object(external_this_wp_i18n_["__"])('Convert to Classic Block'), |
|
9971 onClick: convertToClassic |
|
9972 }, { |
|
9973 title: Object(external_this_wp_i18n_["__"])('Attempt Block Recovery'), |
|
9974 onClick: attemptBlockRecovery |
|
9975 }]; |
|
9976 |
|
9977 if (compare) { |
|
9978 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Modal"], { |
|
9979 title: // translators: Dialog title to fix block content |
|
9980 Object(external_this_wp_i18n_["__"])('Resolve Block'), |
|
9981 onRequestClose: this.onCompareClose, |
|
9982 className: "editor-block-compare block-editor-block-compare" |
|
9983 }, Object(external_this_wp_element_["createElement"])(block_compare, { |
|
9984 block: block, |
|
9985 onKeep: convertToHTML, |
|
9986 onConvert: convertToBlocks, |
|
9987 convertor: block_invalid_warning_blockToBlocks, |
|
9988 convertButtonText: Object(external_this_wp_i18n_["__"])('Convert to Blocks') |
|
9989 })); |
|
9990 } |
|
9991 |
|
9992 return Object(external_this_wp_element_["createElement"])(warning, { |
|
9993 actions: [Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
9994 key: "convert", |
|
9995 onClick: this.onCompare, |
|
9996 isLarge: true, |
|
9997 isPrimary: !hasHTMLBlock |
|
9998 }, // translators: Button to fix block content |
|
9999 Object(external_this_wp_i18n_["_x"])('Resolve', 'imperative verb')), hasHTMLBlock && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
10000 key: "edit", |
|
10001 onClick: convertToHTML, |
|
10002 isLarge: true, |
|
10003 isPrimary: true |
|
10004 }, Object(external_this_wp_i18n_["__"])('Convert to HTML'))], |
|
10005 secondaryActions: hiddenActions |
|
10006 }, Object(external_this_wp_i18n_["__"])('This block contains unexpected or invalid content.')); |
|
10007 } |
|
10008 }]); |
|
10009 |
|
10010 return BlockInvalidWarning; |
|
10011 }(external_this_wp_element_["Component"]); |
|
10012 |
|
10013 var block_invalid_warning_blockToClassic = function blockToClassic(block) { |
|
10014 return Object(external_this_wp_blocks_["createBlock"])('core/freeform', { |
|
10015 content: block.originalContent |
|
10016 }); |
|
10017 }; |
|
10018 |
|
10019 var block_invalid_warning_blockToHTML = function blockToHTML(block) { |
|
10020 return Object(external_this_wp_blocks_["createBlock"])('core/html', { |
|
10021 content: block.originalContent |
|
10022 }); |
|
10023 }; |
|
10024 |
|
10025 var block_invalid_warning_blockToBlocks = function blockToBlocks(block) { |
|
10026 return Object(external_this_wp_blocks_["rawHandler"])({ |
|
10027 HTML: block.originalContent |
|
10028 }); |
|
10029 }; |
|
10030 |
|
10031 var block_invalid_warning_recoverBlock = function recoverBlock(_ref) { |
|
10032 var name = _ref.name, |
|
10033 attributes = _ref.attributes, |
|
10034 innerBlocks = _ref.innerBlocks; |
|
10035 return Object(external_this_wp_blocks_["createBlock"])(name, attributes, innerBlocks); |
|
10036 }; |
|
10037 |
|
10038 /* harmony default export */ var block_invalid_warning = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select, _ref2) { |
|
10039 var clientId = _ref2.clientId; |
|
10040 return { |
|
10041 block: select('core/block-editor').getBlock(clientId) |
|
10042 }; |
|
10043 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, _ref3) { |
|
10044 var block = _ref3.block; |
|
10045 |
|
10046 var _dispatch = dispatch('core/block-editor'), |
|
10047 replaceBlock = _dispatch.replaceBlock; |
|
10048 |
|
10049 return { |
|
10050 convertToClassic: function convertToClassic() { |
|
10051 replaceBlock(block.clientId, block_invalid_warning_blockToClassic(block)); |
|
10052 }, |
|
10053 convertToHTML: function convertToHTML() { |
|
10054 replaceBlock(block.clientId, block_invalid_warning_blockToHTML(block)); |
|
10055 }, |
|
10056 convertToBlocks: function convertToBlocks() { |
|
10057 replaceBlock(block.clientId, block_invalid_warning_blockToBlocks(block)); |
|
10058 }, |
|
10059 attemptBlockRecovery: function attemptBlockRecovery() { |
|
10060 replaceBlock(block.clientId, block_invalid_warning_recoverBlock(block)); |
|
10061 } |
|
10062 }; |
|
10063 })])(block_invalid_warning_BlockInvalidWarning)); |
|
10064 |
|
10065 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-crash-warning.js |
|
10066 |
|
10067 |
|
10068 /** |
|
10069 * WordPress dependencies |
|
10070 */ |
|
10071 |
|
10072 /** |
|
10073 * Internal dependencies |
|
10074 */ |
|
10075 |
|
10076 |
|
10077 var block_crash_warning_warning = Object(external_this_wp_element_["createElement"])(warning, null, Object(external_this_wp_i18n_["__"])('This block has encountered an error and cannot be previewed.')); |
|
10078 /* harmony default export */ var block_crash_warning = (function () { |
|
10079 return block_crash_warning_warning; |
|
10080 }); |
|
10081 |
|
10082 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-crash-boundary.js |
|
10083 |
|
10084 |
|
10085 |
|
10086 |
|
10087 |
|
10088 |
|
10089 /** |
|
10090 * WordPress dependencies |
|
10091 */ |
|
10092 |
|
10093 |
|
10094 var block_crash_boundary_BlockCrashBoundary = |
|
10095 /*#__PURE__*/ |
|
10096 function (_Component) { |
|
10097 Object(inherits["a" /* default */])(BlockCrashBoundary, _Component); |
|
10098 |
|
10099 function BlockCrashBoundary() { |
|
10100 var _this; |
|
10101 |
|
10102 Object(classCallCheck["a" /* default */])(this, BlockCrashBoundary); |
|
10103 |
|
10104 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(BlockCrashBoundary).apply(this, arguments)); |
|
10105 _this.state = { |
|
10106 hasError: false |
|
10107 }; |
|
10108 return _this; |
|
10109 } |
|
10110 |
|
10111 Object(createClass["a" /* default */])(BlockCrashBoundary, [{ |
|
10112 key: "componentDidCatch", |
|
10113 value: function componentDidCatch(error) { |
|
10114 this.props.onError(error); |
|
10115 this.setState({ |
|
10116 hasError: true |
|
10117 }); |
|
10118 } |
|
10119 }, { |
|
10120 key: "render", |
|
10121 value: function render() { |
|
10122 if (this.state.hasError) { |
|
10123 return null; |
|
10124 } |
|
10125 |
|
10126 return this.props.children; |
|
10127 } |
|
10128 }]); |
|
10129 |
|
10130 return BlockCrashBoundary; |
|
10131 }(external_this_wp_element_["Component"]); |
|
10132 |
|
10133 /* harmony default export */ var block_crash_boundary = (block_crash_boundary_BlockCrashBoundary); |
|
10134 |
|
10135 // EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js |
|
10136 var react_autosize_textarea_lib = __webpack_require__(61); |
|
10137 var react_autosize_textarea_lib_default = /*#__PURE__*/__webpack_require__.n(react_autosize_textarea_lib); |
|
10138 |
|
10139 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-html.js |
|
10140 |
|
10141 |
|
10142 |
|
10143 |
|
10144 |
|
10145 |
|
10146 |
|
10147 |
|
10148 /** |
|
10149 * External dependencies |
|
10150 */ |
|
10151 |
|
10152 |
|
10153 /** |
|
10154 * WordPress dependencies |
|
10155 */ |
|
10156 |
|
10157 |
|
10158 |
|
10159 |
|
10160 |
|
10161 var block_html_BlockHTML = |
|
10162 /*#__PURE__*/ |
|
10163 function (_Component) { |
|
10164 Object(inherits["a" /* default */])(BlockHTML, _Component); |
|
10165 |
|
10166 function BlockHTML(props) { |
|
10167 var _this; |
|
10168 |
|
10169 Object(classCallCheck["a" /* default */])(this, BlockHTML); |
|
10170 |
|
10171 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(BlockHTML).apply(this, arguments)); |
|
10172 _this.onChange = _this.onChange.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
10173 _this.onBlur = _this.onBlur.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
10174 _this.state = { |
|
10175 html: props.block.isValid ? Object(external_this_wp_blocks_["getBlockContent"])(props.block) : props.block.originalContent |
|
10176 }; |
|
10177 return _this; |
|
10178 } |
|
10179 |
|
10180 Object(createClass["a" /* default */])(BlockHTML, [{ |
|
10181 key: "componentDidUpdate", |
|
10182 value: function componentDidUpdate(prevProps) { |
|
10183 if (!Object(external_lodash_["isEqual"])(this.props.block.attributes, prevProps.block.attributes)) { |
|
10184 this.setState({ |
|
10185 html: Object(external_this_wp_blocks_["getBlockContent"])(this.props.block) |
|
10186 }); |
|
10187 } |
|
10188 } |
|
10189 }, { |
|
10190 key: "onBlur", |
|
10191 value: function onBlur() { |
|
10192 var html = this.state.html; |
|
10193 var blockType = Object(external_this_wp_blocks_["getBlockType"])(this.props.block.name); |
|
10194 var attributes = Object(external_this_wp_blocks_["getBlockAttributes"])(blockType, html, this.props.block.attributes); // If html is empty we reset the block to the default HTML and mark it as valid to avoid triggering an error |
|
10195 |
|
10196 var content = html ? html : Object(external_this_wp_blocks_["getSaveContent"])(blockType, attributes); |
|
10197 var isValid = html ? Object(external_this_wp_blocks_["isValidBlockContent"])(blockType, attributes, content) : true; |
|
10198 this.props.onChange(this.props.clientId, attributes, content, isValid); // Ensure the state is updated if we reset so it displays the default content |
|
10199 |
|
10200 if (!html) { |
|
10201 this.setState({ |
|
10202 html: content |
|
10203 }); |
|
10204 } |
|
10205 } |
|
10206 }, { |
|
10207 key: "onChange", |
|
10208 value: function onChange(event) { |
|
10209 this.setState({ |
|
10210 html: event.target.value |
|
10211 }); |
|
10212 } |
|
10213 }, { |
|
10214 key: "render", |
|
10215 value: function render() { |
|
10216 var html = this.state.html; |
|
10217 return Object(external_this_wp_element_["createElement"])(react_autosize_textarea_lib_default.a, { |
|
10218 className: "editor-block-list__block-html-textarea block-editor-block-list__block-html-textarea", |
|
10219 value: html, |
|
10220 onBlur: this.onBlur, |
|
10221 onChange: this.onChange |
|
10222 }); |
|
10223 } |
|
10224 }]); |
|
10225 |
|
10226 return BlockHTML; |
|
10227 }(external_this_wp_element_["Component"]); |
|
10228 /* harmony default export */ var block_html = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select, ownProps) { |
|
10229 return { |
|
10230 block: select('core/block-editor').getBlock(ownProps.clientId) |
|
10231 }; |
|
10232 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
10233 return { |
|
10234 onChange: function onChange(clientId, attributes, originalContent, isValid) { |
|
10235 dispatch('core/block-editor').updateBlock(clientId, { |
|
10236 attributes: attributes, |
|
10237 originalContent: originalContent, |
|
10238 isValid: isValid |
|
10239 }); |
|
10240 } |
|
10241 }; |
|
10242 })])(block_html_BlockHTML)); |
|
10243 |
|
10244 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-title/index.js |
|
10245 /** |
|
10246 * WordPress dependencies |
|
10247 */ |
|
10248 |
|
10249 |
|
10250 /** |
|
10251 * Renders the block's configured title as a string, or empty if the title |
|
10252 * cannot be determined. |
|
10253 * |
|
10254 * @example |
|
10255 * |
|
10256 * ```jsx |
|
10257 * <BlockTitle clientId="afd1cb17-2c08-4e7a-91be-007ba7ddc3a1" /> |
|
10258 * ``` |
|
10259 * |
|
10260 * @param {?string} props.name Block name. |
|
10261 * |
|
10262 * @return {?string} Block title. |
|
10263 */ |
|
10264 |
|
10265 function BlockTitle(_ref) { |
|
10266 var name = _ref.name; |
|
10267 |
|
10268 if (!name) { |
|
10269 return null; |
|
10270 } |
|
10271 |
|
10272 var blockType = Object(external_this_wp_blocks_["getBlockType"])(name); |
|
10273 |
|
10274 if (!blockType) { |
|
10275 return null; |
|
10276 } |
|
10277 |
|
10278 return blockType.title; |
|
10279 } |
|
10280 /* harmony default export */ var block_title = (Object(external_this_wp_data_["withSelect"])(function (select, ownProps) { |
|
10281 var _select = select('core/block-editor'), |
|
10282 getBlockName = _select.getBlockName; |
|
10283 |
|
10284 var clientId = ownProps.clientId; |
|
10285 return { |
|
10286 name: getBlockName(clientId) |
|
10287 }; |
|
10288 })(BlockTitle)); |
|
10289 |
|
10290 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/breadcrumb.js |
|
10291 |
|
10292 |
|
10293 |
|
10294 |
|
10295 |
|
10296 |
|
10297 |
|
10298 |
|
10299 /** |
|
10300 * WordPress dependencies |
|
10301 */ |
|
10302 |
|
10303 |
|
10304 |
|
10305 |
|
10306 /** |
|
10307 * Internal dependencies |
|
10308 */ |
|
10309 |
|
10310 |
|
10311 /** |
|
10312 * Block breadcrumb component, displaying the label of the block. If the block |
|
10313 * descends from a root block, a button is displayed enabling the user to select |
|
10314 * the root block. |
|
10315 * |
|
10316 * @param {string} props.clientId Client ID of block. |
|
10317 * @param {string} props.rootClientId Client ID of block's root. |
|
10318 * @param {Function} props.selectRootBlock Callback to select root block. |
|
10319 */ |
|
10320 |
|
10321 var breadcrumb_BlockBreadcrumb = |
|
10322 /*#__PURE__*/ |
|
10323 function (_Component) { |
|
10324 Object(inherits["a" /* default */])(BlockBreadcrumb, _Component); |
|
10325 |
|
10326 function BlockBreadcrumb() { |
|
10327 var _this; |
|
10328 |
|
10329 Object(classCallCheck["a" /* default */])(this, BlockBreadcrumb); |
|
10330 |
|
10331 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(BlockBreadcrumb).apply(this, arguments)); |
|
10332 _this.state = { |
|
10333 isFocused: false |
|
10334 }; |
|
10335 _this.onFocus = _this.onFocus.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
10336 _this.onBlur = _this.onBlur.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
10337 return _this; |
|
10338 } |
|
10339 |
|
10340 Object(createClass["a" /* default */])(BlockBreadcrumb, [{ |
|
10341 key: "onFocus", |
|
10342 value: function onFocus(event) { |
|
10343 this.setState({ |
|
10344 isFocused: true |
|
10345 }); // This is used for improved interoperability |
|
10346 // with the block's `onFocus` handler which selects the block, thus conflicting |
|
10347 // with the intention to select the root block. |
|
10348 |
|
10349 event.stopPropagation(); |
|
10350 } |
|
10351 }, { |
|
10352 key: "onBlur", |
|
10353 value: function onBlur() { |
|
10354 this.setState({ |
|
10355 isFocused: false |
|
10356 }); |
|
10357 } |
|
10358 }, { |
|
10359 key: "render", |
|
10360 value: function render() { |
|
10361 var _this$props = this.props, |
|
10362 clientId = _this$props.clientId, |
|
10363 rootClientId = _this$props.rootClientId; |
|
10364 return Object(external_this_wp_element_["createElement"])("div", { |
|
10365 className: 'editor-block-list__breadcrumb block-editor-block-list__breadcrumb' |
|
10366 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Toolbar"], null, rootClientId && Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])(block_title, { |
|
10367 clientId: rootClientId |
|
10368 }), Object(external_this_wp_element_["createElement"])("span", { |
|
10369 className: "editor-block-list__descendant-arrow block-editor-block-list__descendant-arrow" |
|
10370 })), Object(external_this_wp_element_["createElement"])(block_title, { |
|
10371 clientId: clientId |
|
10372 }))); |
|
10373 } |
|
10374 }]); |
|
10375 |
|
10376 return BlockBreadcrumb; |
|
10377 }(external_this_wp_element_["Component"]); |
|
10378 /* harmony default export */ var breadcrumb = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select, ownProps) { |
|
10379 var _select = select('core/block-editor'), |
|
10380 getBlockRootClientId = _select.getBlockRootClientId; |
|
10381 |
|
10382 var clientId = ownProps.clientId; |
|
10383 return { |
|
10384 rootClientId: getBlockRootClientId(clientId) |
|
10385 }; |
|
10386 })])(breadcrumb_BlockBreadcrumb)); |
|
10387 |
|
10388 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/navigable-toolbar/index.js |
|
10389 |
|
10390 |
|
10391 |
|
10392 |
|
10393 |
|
10394 |
|
10395 |
|
10396 |
|
10397 |
|
10398 |
|
10399 /** |
|
10400 * External dependencies |
|
10401 */ |
|
10402 |
|
10403 /** |
|
10404 * WordPress dependencies |
|
10405 */ |
|
10406 |
|
10407 |
|
10408 |
|
10409 |
|
10410 |
|
10411 /** |
|
10412 * Browser dependencies |
|
10413 */ |
|
10414 |
|
10415 var _window = window, |
|
10416 Node = _window.Node, |
|
10417 getSelection = _window.getSelection; |
|
10418 |
|
10419 var navigable_toolbar_NavigableToolbar = |
|
10420 /*#__PURE__*/ |
|
10421 function (_Component) { |
|
10422 Object(inherits["a" /* default */])(NavigableToolbar, _Component); |
|
10423 |
|
10424 function NavigableToolbar() { |
|
10425 var _this; |
|
10426 |
|
10427 Object(classCallCheck["a" /* default */])(this, NavigableToolbar); |
|
10428 |
|
10429 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(NavigableToolbar).apply(this, arguments)); |
|
10430 _this.focusToolbar = _this.focusToolbar.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
10431 _this.focusSelection = _this.focusSelection.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
10432 _this.switchOnKeyDown = Object(external_lodash_["cond"])([[Object(external_lodash_["matchesProperty"])(['keyCode'], external_this_wp_keycodes_["ESCAPE"]), _this.focusSelection]]); |
|
10433 _this.toolbar = Object(external_this_wp_element_["createRef"])(); |
|
10434 return _this; |
|
10435 } |
|
10436 |
|
10437 Object(createClass["a" /* default */])(NavigableToolbar, [{ |
|
10438 key: "focusToolbar", |
|
10439 value: function focusToolbar() { |
|
10440 var tabbables = external_this_wp_dom_["focus"].tabbable.find(this.toolbar.current); |
|
10441 |
|
10442 if (tabbables.length) { |
|
10443 tabbables[0].focus(); |
|
10444 } |
|
10445 } |
|
10446 /** |
|
10447 * Programmatically shifts focus to the element where the current selection |
|
10448 * exists, if there is a selection. |
|
10449 */ |
|
10450 |
|
10451 }, { |
|
10452 key: "focusSelection", |
|
10453 value: function focusSelection() { |
|
10454 // Ensure that a selection exists. |
|
10455 var selection = getSelection(); |
|
10456 |
|
10457 if (!selection) { |
|
10458 return; |
|
10459 } // Focus node may be a text node, which cannot be focused directly. |
|
10460 // Find its parent element instead. |
|
10461 |
|
10462 |
|
10463 var focusNode = selection.focusNode; |
|
10464 var focusElement = focusNode; |
|
10465 |
|
10466 if (focusElement.nodeType !== Node.ELEMENT_NODE) { |
|
10467 focusElement = focusElement.parentElement; |
|
10468 } |
|
10469 |
|
10470 if (focusElement) { |
|
10471 focusElement.focus(); |
|
10472 } |
|
10473 } |
|
10474 }, { |
|
10475 key: "componentDidMount", |
|
10476 value: function componentDidMount() { |
|
10477 if (this.props.focusOnMount) { |
|
10478 this.focusToolbar(); |
|
10479 } |
|
10480 } |
|
10481 }, { |
|
10482 key: "render", |
|
10483 value: function render() { |
|
10484 var _this$props = this.props, |
|
10485 children = _this$props.children, |
|
10486 props = Object(objectWithoutProperties["a" /* default */])(_this$props, ["children"]); |
|
10487 |
|
10488 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["NavigableMenu"], Object(esm_extends["a" /* default */])({ |
|
10489 orientation: "horizontal", |
|
10490 role: "toolbar", |
|
10491 ref: this.toolbar, |
|
10492 onKeyDown: this.switchOnKeyDown |
|
10493 }, Object(external_lodash_["omit"])(props, ['focusOnMount'])), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["KeyboardShortcuts"], { |
|
10494 bindGlobal: true // Use the same event that TinyMCE uses in the Classic block for its own `alt+f10` shortcut. |
|
10495 , |
|
10496 eventName: "keydown", |
|
10497 shortcuts: { |
|
10498 'alt+f10': this.focusToolbar |
|
10499 } |
|
10500 }), children); |
|
10501 } |
|
10502 }]); |
|
10503 |
|
10504 return NavigableToolbar; |
|
10505 }(external_this_wp_element_["Component"]); |
|
10506 |
|
10507 /* harmony default export */ var navigable_toolbar = (navigable_toolbar_NavigableToolbar); |
|
10508 |
|
10509 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-contextual-toolbar.js |
|
10510 |
|
10511 |
|
10512 /** |
|
10513 * WordPress dependencies |
|
10514 */ |
|
10515 |
|
10516 /** |
|
10517 * Internal dependencies |
|
10518 */ |
|
10519 |
|
10520 |
|
10521 |
|
10522 |
|
10523 function BlockContextualToolbar(_ref) { |
|
10524 var focusOnMount = _ref.focusOnMount; |
|
10525 return Object(external_this_wp_element_["createElement"])(navigable_toolbar, { |
|
10526 focusOnMount: focusOnMount, |
|
10527 className: "editor-block-contextual-toolbar block-editor-block-contextual-toolbar" |
|
10528 /* translators: accessibility text for the block toolbar */ |
|
10529 , |
|
10530 "aria-label": Object(external_this_wp_i18n_["__"])('Block tools') |
|
10531 }, Object(external_this_wp_element_["createElement"])(block_toolbar, null)); |
|
10532 } |
|
10533 |
|
10534 /* harmony default export */ var block_contextual_toolbar = (BlockContextualToolbar); |
|
10535 |
|
10536 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/multi-controls.js |
|
10537 |
|
10538 |
|
10539 /** |
|
10540 * External dependencies |
|
10541 */ |
|
10542 |
|
10543 /** |
|
10544 * WordPress dependencies |
|
10545 */ |
|
10546 |
|
10547 |
|
10548 /** |
|
10549 * Internal dependencies |
|
10550 */ |
|
10551 |
|
10552 |
|
10553 |
|
10554 function BlockListMultiControls(_ref) { |
|
10555 var multiSelectedBlockClientIds = _ref.multiSelectedBlockClientIds, |
|
10556 clientId = _ref.clientId, |
|
10557 isSelecting = _ref.isSelecting, |
|
10558 isFirst = _ref.isFirst, |
|
10559 isLast = _ref.isLast; |
|
10560 |
|
10561 if (isSelecting) { |
|
10562 return null; |
|
10563 } |
|
10564 |
|
10565 return Object(external_this_wp_element_["createElement"])(block_mover, { |
|
10566 key: "mover", |
|
10567 clientId: clientId, |
|
10568 clientIds: multiSelectedBlockClientIds, |
|
10569 isFirst: isFirst, |
|
10570 isLast: isLast |
|
10571 }); |
|
10572 } |
|
10573 |
|
10574 /* harmony default export */ var multi_controls = (Object(external_this_wp_data_["withSelect"])(function (select, _ref2) { |
|
10575 var clientId = _ref2.clientId; |
|
10576 |
|
10577 var _select = select('core/block-editor'), |
|
10578 getMultiSelectedBlockClientIds = _select.getMultiSelectedBlockClientIds, |
|
10579 isMultiSelecting = _select.isMultiSelecting, |
|
10580 getBlockIndex = _select.getBlockIndex, |
|
10581 getBlockCount = _select.getBlockCount; |
|
10582 |
|
10583 var clientIds = getMultiSelectedBlockClientIds(); |
|
10584 var firstIndex = getBlockIndex(Object(external_lodash_["first"])(clientIds), clientId); |
|
10585 var lastIndex = getBlockIndex(Object(external_lodash_["last"])(clientIds), clientId); |
|
10586 return { |
|
10587 multiSelectedBlockClientIds: clientIds, |
|
10588 isSelecting: isMultiSelecting(), |
|
10589 isFirst: firstIndex === 0, |
|
10590 isLast: lastIndex + 1 === getBlockCount() |
|
10591 }; |
|
10592 })(BlockListMultiControls)); |
|
10593 |
|
10594 // EXTERNAL MODULE: ./node_modules/dom-scroll-into-view/lib/index.js |
|
10595 var dom_scroll_into_view_lib = __webpack_require__(67); |
|
10596 var dom_scroll_into_view_lib_default = /*#__PURE__*/__webpack_require__.n(dom_scroll_into_view_lib); |
|
10597 |
|
10598 // EXTERNAL MODULE: external {"this":["wp","url"]} |
|
10599 var external_this_wp_url_ = __webpack_require__(25); |
|
10600 |
|
10601 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-preview/index.js |
|
10602 |
|
10603 |
|
10604 /** |
|
10605 * External dependencies |
|
10606 */ |
|
10607 |
|
10608 /** |
|
10609 * WordPress dependencies |
|
10610 */ |
|
10611 |
|
10612 |
|
10613 |
|
10614 |
|
10615 /** |
|
10616 * Internal dependencies |
|
10617 */ |
|
10618 |
|
10619 |
|
10620 /** |
|
10621 * Block Preview Component: It renders a preview given a block name and attributes. |
|
10622 * |
|
10623 * @param {Object} props Component props. |
|
10624 * |
|
10625 * @return {WPElement} Rendered element. |
|
10626 */ |
|
10627 |
|
10628 function BlockPreview(props) { |
|
10629 return Object(external_this_wp_element_["createElement"])("div", { |
|
10630 className: "editor-block-preview block-editor-block-preview" |
|
10631 }, Object(external_this_wp_element_["createElement"])("div", { |
|
10632 className: "editor-block-preview__title block-editor-block-preview__title" |
|
10633 }, Object(external_this_wp_i18n_["__"])('Preview')), Object(external_this_wp_element_["createElement"])(BlockPreviewContent, props)); |
|
10634 } |
|
10635 |
|
10636 function BlockPreviewContent(_ref) { |
|
10637 var name = _ref.name, |
|
10638 attributes = _ref.attributes; |
|
10639 var block = Object(external_this_wp_blocks_["createBlock"])(name, attributes); |
|
10640 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Disabled"], { |
|
10641 className: "editor-block-preview__content block-editor-block-preview__content editor-styles-wrapper", |
|
10642 "aria-hidden": true |
|
10643 }, Object(external_this_wp_element_["createElement"])(block_edit, { |
|
10644 name: name, |
|
10645 focus: false, |
|
10646 attributes: block.attributes, |
|
10647 setAttributes: external_lodash_["noop"] |
|
10648 })); |
|
10649 } |
|
10650 /* harmony default export */ var block_preview = (BlockPreview); |
|
10651 |
|
10652 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-list-item/index.js |
|
10653 |
|
10654 |
|
10655 |
|
10656 |
|
10657 /** |
|
10658 * External dependencies |
|
10659 */ |
|
10660 |
|
10661 /** |
|
10662 * Internal dependencies |
|
10663 */ |
|
10664 |
|
10665 |
|
10666 |
|
10667 function InserterListItem(_ref) { |
|
10668 var icon = _ref.icon, |
|
10669 hasChildBlocksWithInserterSupport = _ref.hasChildBlocksWithInserterSupport, |
|
10670 _onClick = _ref.onClick, |
|
10671 isDisabled = _ref.isDisabled, |
|
10672 title = _ref.title, |
|
10673 className = _ref.className, |
|
10674 props = Object(objectWithoutProperties["a" /* default */])(_ref, ["icon", "hasChildBlocksWithInserterSupport", "onClick", "isDisabled", "title", "className"]); |
|
10675 |
|
10676 var itemIconStyle = icon ? { |
|
10677 backgroundColor: icon.background, |
|
10678 color: icon.foreground |
|
10679 } : {}; |
|
10680 var itemIconStackStyle = icon && icon.shadowColor ? { |
|
10681 backgroundColor: icon.shadowColor |
|
10682 } : {}; |
|
10683 return Object(external_this_wp_element_["createElement"])("li", { |
|
10684 className: "editor-block-types-list__list-item block-editor-block-types-list__list-item" |
|
10685 }, Object(external_this_wp_element_["createElement"])("button", Object(esm_extends["a" /* default */])({ |
|
10686 className: classnames_default()('editor-block-types-list__item block-editor-block-types-list__item', className, { |
|
10687 'editor-block-types-list__item-has-children block-editor-block-types-list__item-has-children': hasChildBlocksWithInserterSupport |
|
10688 }), |
|
10689 onClick: function onClick(event) { |
|
10690 event.preventDefault(); |
|
10691 |
|
10692 _onClick(); |
|
10693 }, |
|
10694 disabled: isDisabled, |
|
10695 "aria-label": title // Fix for IE11 and JAWS 2018. |
|
10696 |
|
10697 }, props), Object(external_this_wp_element_["createElement"])("span", { |
|
10698 className: "editor-block-types-list__item-icon block-editor-block-types-list__item-icon", |
|
10699 style: itemIconStyle |
|
10700 }, Object(external_this_wp_element_["createElement"])(BlockIcon, { |
|
10701 icon: icon, |
|
10702 showColors: true |
|
10703 }), hasChildBlocksWithInserterSupport && Object(external_this_wp_element_["createElement"])("span", { |
|
10704 className: "editor-block-types-list__item-icon-stack block-editor-block-types-list__item-icon-stack", |
|
10705 style: itemIconStackStyle |
|
10706 })), Object(external_this_wp_element_["createElement"])("span", { |
|
10707 className: "editor-block-types-list__item-title block-editor-block-types-list__item-title" |
|
10708 }, title))); |
|
10709 } |
|
10710 |
|
10711 /* harmony default export */ var inserter_list_item = (InserterListItem); |
|
10712 |
|
10713 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-types-list/index.js |
|
10714 |
|
10715 |
|
10716 /** |
|
10717 * WordPress dependencies |
|
10718 */ |
|
10719 |
|
10720 /** |
|
10721 * Internal dependencies |
|
10722 */ |
|
10723 |
|
10724 |
|
10725 |
|
10726 function BlockTypesList(_ref) { |
|
10727 var items = _ref.items, |
|
10728 onSelect = _ref.onSelect, |
|
10729 _ref$onHover = _ref.onHover, |
|
10730 onHover = _ref$onHover === void 0 ? function () {} : _ref$onHover, |
|
10731 children = _ref.children; |
|
10732 return ( |
|
10733 /* |
|
10734 * Disable reason: The `list` ARIA role is redundant but |
|
10735 * Safari+VoiceOver won't announce the list otherwise. |
|
10736 */ |
|
10737 |
|
10738 /* eslint-disable jsx-a11y/no-redundant-roles */ |
|
10739 Object(external_this_wp_element_["createElement"])("ul", { |
|
10740 role: "list", |
|
10741 className: "editor-block-types-list block-editor-block-types-list" |
|
10742 }, items && items.map(function (item) { |
|
10743 return Object(external_this_wp_element_["createElement"])(inserter_list_item, { |
|
10744 key: item.id, |
|
10745 className: Object(external_this_wp_blocks_["getBlockMenuDefaultClassName"])(item.id), |
|
10746 icon: item.icon, |
|
10747 hasChildBlocksWithInserterSupport: item.hasChildBlocksWithInserterSupport, |
|
10748 onClick: function onClick() { |
|
10749 onSelect(item); |
|
10750 onHover(null); |
|
10751 }, |
|
10752 onFocus: function onFocus() { |
|
10753 return onHover(item); |
|
10754 }, |
|
10755 onMouseEnter: function onMouseEnter() { |
|
10756 return onHover(item); |
|
10757 }, |
|
10758 onMouseLeave: function onMouseLeave() { |
|
10759 return onHover(null); |
|
10760 }, |
|
10761 onBlur: function onBlur() { |
|
10762 return onHover(null); |
|
10763 }, |
|
10764 isDisabled: item.isDisabled, |
|
10765 title: item.title |
|
10766 }); |
|
10767 }), children) |
|
10768 /* eslint-enable jsx-a11y/no-redundant-roles */ |
|
10769 |
|
10770 ); |
|
10771 } |
|
10772 |
|
10773 /* harmony default export */ var block_types_list = (BlockTypesList); |
|
10774 |
|
10775 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/child-blocks.js |
|
10776 |
|
10777 |
|
10778 |
|
10779 |
|
10780 /** |
|
10781 * WordPress dependencies |
|
10782 */ |
|
10783 |
|
10784 |
|
10785 /** |
|
10786 * Internal dependencies |
|
10787 */ |
|
10788 |
|
10789 |
|
10790 |
|
10791 |
|
10792 function ChildBlocks(_ref) { |
|
10793 var rootBlockIcon = _ref.rootBlockIcon, |
|
10794 rootBlockTitle = _ref.rootBlockTitle, |
|
10795 items = _ref.items, |
|
10796 props = Object(objectWithoutProperties["a" /* default */])(_ref, ["rootBlockIcon", "rootBlockTitle", "items"]); |
|
10797 |
|
10798 return Object(external_this_wp_element_["createElement"])("div", { |
|
10799 className: "editor-inserter__child-blocks block-editor-inserter__child-blocks" |
|
10800 }, (rootBlockIcon || rootBlockTitle) && Object(external_this_wp_element_["createElement"])("div", { |
|
10801 className: "editor-inserter__parent-block-header block-editor-inserter__parent-block-header" |
|
10802 }, Object(external_this_wp_element_["createElement"])(BlockIcon, { |
|
10803 icon: rootBlockIcon, |
|
10804 showColors: true |
|
10805 }), rootBlockTitle && Object(external_this_wp_element_["createElement"])("h2", null, rootBlockTitle)), Object(external_this_wp_element_["createElement"])(block_types_list, Object(esm_extends["a" /* default */])({ |
|
10806 items: items |
|
10807 }, props))); |
|
10808 } |
|
10809 |
|
10810 /* harmony default export */ var child_blocks = (Object(external_this_wp_compose_["compose"])(Object(external_this_wp_compose_["ifCondition"])(function (_ref2) { |
|
10811 var items = _ref2.items; |
|
10812 return items && items.length > 0; |
|
10813 }), Object(external_this_wp_data_["withSelect"])(function (select, _ref3) { |
|
10814 var rootClientId = _ref3.rootClientId; |
|
10815 |
|
10816 var _select = select('core/blocks'), |
|
10817 getBlockType = _select.getBlockType; |
|
10818 |
|
10819 var _select2 = select('core/block-editor'), |
|
10820 getBlockName = _select2.getBlockName; |
|
10821 |
|
10822 var rootBlockName = getBlockName(rootClientId); |
|
10823 var rootBlockType = getBlockType(rootBlockName); |
|
10824 return { |
|
10825 rootBlockTitle: rootBlockType && rootBlockType.title, |
|
10826 rootBlockIcon: rootBlockType && rootBlockType.icon |
|
10827 }; |
|
10828 }))(ChildBlocks)); |
|
10829 |
|
10830 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/menu.js |
|
10831 |
|
10832 |
|
10833 |
|
10834 |
|
10835 |
|
10836 |
|
10837 |
|
10838 |
|
10839 |
|
10840 /** |
|
10841 * External dependencies |
|
10842 */ |
|
10843 |
|
10844 |
|
10845 /** |
|
10846 * WordPress dependencies |
|
10847 */ |
|
10848 |
|
10849 |
|
10850 |
|
10851 |
|
10852 |
|
10853 |
|
10854 |
|
10855 |
|
10856 |
|
10857 /** |
|
10858 * Internal dependencies |
|
10859 */ |
|
10860 |
|
10861 |
|
10862 |
|
10863 |
|
10864 var MAX_SUGGESTED_ITEMS = 9; |
|
10865 |
|
10866 var stopKeyPropagation = function stopKeyPropagation(event) { |
|
10867 return event.stopPropagation(); |
|
10868 }; |
|
10869 /** |
|
10870 * Filters an item list given a search term. |
|
10871 * |
|
10872 * @param {Array} items Item list |
|
10873 * @param {string} searchTerm Search term. |
|
10874 * |
|
10875 * @return {Array} Filtered item list. |
|
10876 */ |
|
10877 |
|
10878 |
|
10879 var menu_searchItems = function searchItems(items, searchTerm) { |
|
10880 var normalizedSearchTerm = menu_normalizeTerm(searchTerm); |
|
10881 |
|
10882 var matchSearch = function matchSearch(string) { |
|
10883 return menu_normalizeTerm(string).indexOf(normalizedSearchTerm) !== -1; |
|
10884 }; |
|
10885 |
|
10886 var categories = Object(external_this_wp_blocks_["getCategories"])(); |
|
10887 return items.filter(function (item) { |
|
10888 var itemCategory = Object(external_lodash_["find"])(categories, { |
|
10889 slug: item.category |
|
10890 }); |
|
10891 return matchSearch(item.title) || Object(external_lodash_["some"])(item.keywords, matchSearch) || itemCategory && matchSearch(itemCategory.title); |
|
10892 }); |
|
10893 }; |
|
10894 /** |
|
10895 * Converts the search term into a normalized term. |
|
10896 * |
|
10897 * @param {string} term The search term to normalize. |
|
10898 * |
|
10899 * @return {string} The normalized search term. |
|
10900 */ |
|
10901 |
|
10902 var menu_normalizeTerm = function normalizeTerm(term) { |
|
10903 // Disregard diacritics. |
|
10904 // Input: "média" |
|
10905 term = Object(external_lodash_["deburr"])(term); // Accommodate leading slash, matching autocomplete expectations. |
|
10906 // Input: "/media" |
|
10907 |
|
10908 term = term.replace(/^\//, ''); // Lowercase. |
|
10909 // Input: "MEDIA" |
|
10910 |
|
10911 term = term.toLowerCase(); // Strip leading and trailing whitespace. |
|
10912 // Input: " media " |
|
10913 |
|
10914 term = term.trim(); |
|
10915 return term; |
|
10916 }; |
|
10917 var menu_InserterMenu = |
|
10918 /*#__PURE__*/ |
|
10919 function (_Component) { |
|
10920 Object(inherits["a" /* default */])(InserterMenu, _Component); |
|
10921 |
|
10922 function InserterMenu() { |
|
10923 var _this; |
|
10924 |
|
10925 Object(classCallCheck["a" /* default */])(this, InserterMenu); |
|
10926 |
|
10927 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(InserterMenu).apply(this, arguments)); |
|
10928 _this.state = { |
|
10929 childItems: [], |
|
10930 filterValue: '', |
|
10931 hoveredItem: null, |
|
10932 suggestedItems: [], |
|
10933 reusableItems: [], |
|
10934 itemsPerCategory: {}, |
|
10935 openPanels: ['suggested'] |
|
10936 }; |
|
10937 _this.onChangeSearchInput = _this.onChangeSearchInput.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
10938 _this.onHover = _this.onHover.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
10939 _this.panels = {}; |
|
10940 _this.inserterResults = Object(external_this_wp_element_["createRef"])(); |
|
10941 return _this; |
|
10942 } |
|
10943 |
|
10944 Object(createClass["a" /* default */])(InserterMenu, [{ |
|
10945 key: "componentDidMount", |
|
10946 value: function componentDidMount() { |
|
10947 // This could be replaced by a resolver. |
|
10948 this.props.fetchReusableBlocks(); |
|
10949 this.filter(); |
|
10950 } |
|
10951 }, { |
|
10952 key: "componentDidUpdate", |
|
10953 value: function componentDidUpdate(prevProps) { |
|
10954 if (prevProps.items !== this.props.items) { |
|
10955 this.filter(this.state.filterValue); |
|
10956 } |
|
10957 } |
|
10958 }, { |
|
10959 key: "onChangeSearchInput", |
|
10960 value: function onChangeSearchInput(event) { |
|
10961 this.filter(event.target.value); |
|
10962 } |
|
10963 }, { |
|
10964 key: "onHover", |
|
10965 value: function onHover(item) { |
|
10966 this.setState({ |
|
10967 hoveredItem: item |
|
10968 }); |
|
10969 var _this$props = this.props, |
|
10970 showInsertionPoint = _this$props.showInsertionPoint, |
|
10971 hideInsertionPoint = _this$props.hideInsertionPoint; |
|
10972 |
|
10973 if (item) { |
|
10974 showInsertionPoint(); |
|
10975 } else { |
|
10976 hideInsertionPoint(); |
|
10977 } |
|
10978 } |
|
10979 }, { |
|
10980 key: "bindPanel", |
|
10981 value: function bindPanel(name) { |
|
10982 var _this2 = this; |
|
10983 |
|
10984 return function (ref) { |
|
10985 _this2.panels[name] = ref; |
|
10986 }; |
|
10987 } |
|
10988 }, { |
|
10989 key: "onTogglePanel", |
|
10990 value: function onTogglePanel(panel) { |
|
10991 var _this3 = this; |
|
10992 |
|
10993 return function () { |
|
10994 var isOpened = _this3.state.openPanels.indexOf(panel) !== -1; |
|
10995 |
|
10996 if (isOpened) { |
|
10997 _this3.setState({ |
|
10998 openPanels: Object(external_lodash_["without"])(_this3.state.openPanels, panel) |
|
10999 }); |
|
11000 } else { |
|
11001 _this3.setState({ |
|
11002 openPanels: [].concat(Object(toConsumableArray["a" /* default */])(_this3.state.openPanels), [panel]) |
|
11003 }); |
|
11004 |
|
11005 _this3.props.setTimeout(function () { |
|
11006 // We need a generic way to access the panel's container |
|
11007 // eslint-disable-next-line react/no-find-dom-node |
|
11008 dom_scroll_into_view_lib_default()(_this3.panels[panel], _this3.inserterResults.current, { |
|
11009 alignWithTop: true |
|
11010 }); |
|
11011 }); |
|
11012 } |
|
11013 }; |
|
11014 } |
|
11015 }, { |
|
11016 key: "filterOpenPanels", |
|
11017 value: function filterOpenPanels(filterValue, itemsPerCategory, filteredItems, reusableItems) { |
|
11018 if (filterValue === this.state.filterValue) { |
|
11019 return this.state.openPanels; |
|
11020 } |
|
11021 |
|
11022 if (!filterValue) { |
|
11023 return ['suggested']; |
|
11024 } |
|
11025 |
|
11026 var openPanels = []; |
|
11027 |
|
11028 if (reusableItems.length > 0) { |
|
11029 openPanels.push('reusable'); |
|
11030 } |
|
11031 |
|
11032 if (filteredItems.length > 0) { |
|
11033 openPanels = openPanels.concat(Object.keys(itemsPerCategory)); |
|
11034 } |
|
11035 |
|
11036 return openPanels; |
|
11037 } |
|
11038 }, { |
|
11039 key: "filter", |
|
11040 value: function filter() { |
|
11041 var filterValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; |
|
11042 var _this$props2 = this.props, |
|
11043 debouncedSpeak = _this$props2.debouncedSpeak, |
|
11044 items = _this$props2.items, |
|
11045 rootChildBlocks = _this$props2.rootChildBlocks; |
|
11046 var filteredItems = menu_searchItems(items, filterValue); |
|
11047 |
|
11048 var childItems = Object(external_lodash_["filter"])(filteredItems, function (_ref) { |
|
11049 var name = _ref.name; |
|
11050 return Object(external_lodash_["includes"])(rootChildBlocks, name); |
|
11051 }); |
|
11052 |
|
11053 var suggestedItems = []; |
|
11054 |
|
11055 if (!filterValue) { |
|
11056 var maxSuggestedItems = this.props.maxSuggestedItems || MAX_SUGGESTED_ITEMS; |
|
11057 suggestedItems = Object(external_lodash_["filter"])(items, function (item) { |
|
11058 return item.utility > 0; |
|
11059 }).slice(0, maxSuggestedItems); |
|
11060 } |
|
11061 |
|
11062 var reusableItems = Object(external_lodash_["filter"])(filteredItems, { |
|
11063 category: 'reusable' |
|
11064 }); |
|
11065 |
|
11066 var getCategoryIndex = function getCategoryIndex(item) { |
|
11067 return Object(external_lodash_["findIndex"])(Object(external_this_wp_blocks_["getCategories"])(), function (category) { |
|
11068 return category.slug === item.category; |
|
11069 }); |
|
11070 }; |
|
11071 |
|
11072 var itemsPerCategory = Object(external_lodash_["flow"])(function (itemList) { |
|
11073 return Object(external_lodash_["filter"])(itemList, function (item) { |
|
11074 return item.category !== 'reusable'; |
|
11075 }); |
|
11076 }, function (itemList) { |
|
11077 return Object(external_lodash_["sortBy"])(itemList, getCategoryIndex); |
|
11078 }, function (itemList) { |
|
11079 return Object(external_lodash_["groupBy"])(itemList, 'category'); |
|
11080 })(filteredItems); |
|
11081 this.setState({ |
|
11082 hoveredItem: null, |
|
11083 childItems: childItems, |
|
11084 filterValue: filterValue, |
|
11085 suggestedItems: suggestedItems, |
|
11086 reusableItems: reusableItems, |
|
11087 itemsPerCategory: itemsPerCategory, |
|
11088 openPanels: this.filterOpenPanels(filterValue, itemsPerCategory, filteredItems, reusableItems) |
|
11089 }); |
|
11090 var resultCount = Object.keys(itemsPerCategory).reduce(function (accumulator, currentCategorySlug) { |
|
11091 return accumulator + itemsPerCategory[currentCategorySlug].length; |
|
11092 }, 0); |
|
11093 var resultsFoundMessage = Object(external_this_wp_i18n_["sprintf"])(Object(external_this_wp_i18n_["_n"])('%d result found.', '%d results found.', resultCount), resultCount); |
|
11094 debouncedSpeak(resultsFoundMessage); |
|
11095 } |
|
11096 }, { |
|
11097 key: "onKeyDown", |
|
11098 value: function onKeyDown(event) { |
|
11099 if (Object(external_lodash_["includes"])([external_this_wp_keycodes_["LEFT"], external_this_wp_keycodes_["DOWN"], external_this_wp_keycodes_["RIGHT"], external_this_wp_keycodes_["UP"], external_this_wp_keycodes_["BACKSPACE"], external_this_wp_keycodes_["ENTER"]], event.keyCode)) { |
|
11100 // Stop the key event from propagating up to ObserveTyping.startTypingInTextField. |
|
11101 event.stopPropagation(); |
|
11102 } |
|
11103 } |
|
11104 }, { |
|
11105 key: "render", |
|
11106 value: function render() { |
|
11107 var _this4 = this; |
|
11108 |
|
11109 var _this$props3 = this.props, |
|
11110 instanceId = _this$props3.instanceId, |
|
11111 onSelect = _this$props3.onSelect, |
|
11112 rootClientId = _this$props3.rootClientId; |
|
11113 var _this$state = this.state, |
|
11114 childItems = _this$state.childItems, |
|
11115 hoveredItem = _this$state.hoveredItem, |
|
11116 itemsPerCategory = _this$state.itemsPerCategory, |
|
11117 openPanels = _this$state.openPanels, |
|
11118 reusableItems = _this$state.reusableItems, |
|
11119 suggestedItems = _this$state.suggestedItems; |
|
11120 |
|
11121 var isPanelOpen = function isPanelOpen(panel) { |
|
11122 return openPanels.indexOf(panel) !== -1; |
|
11123 }; // Disable reason (no-autofocus): The inserter menu is a modal display, not one which |
|
11124 // is always visible, and one which already incurs this behavior of autoFocus via |
|
11125 // Popover's focusOnMount. |
|
11126 // Disable reason (no-static-element-interactions): Navigational key-presses within |
|
11127 // the menu are prevented from triggering WritingFlow and ObserveTyping interactions. |
|
11128 |
|
11129 /* eslint-disable jsx-a11y/no-autofocus, jsx-a11y/no-static-element-interactions */ |
|
11130 |
|
11131 |
|
11132 return Object(external_this_wp_element_["createElement"])("div", { |
|
11133 className: "editor-inserter__menu block-editor-inserter__menu", |
|
11134 onKeyPress: stopKeyPropagation, |
|
11135 onKeyDown: this.onKeyDown |
|
11136 }, Object(external_this_wp_element_["createElement"])("label", { |
|
11137 htmlFor: "block-editor-inserter__search-".concat(instanceId), |
|
11138 className: "screen-reader-text" |
|
11139 }, Object(external_this_wp_i18n_["__"])('Search for a block')), Object(external_this_wp_element_["createElement"])("input", { |
|
11140 id: "block-editor-inserter__search-".concat(instanceId), |
|
11141 type: "search", |
|
11142 placeholder: Object(external_this_wp_i18n_["__"])('Search for a block'), |
|
11143 className: "editor-inserter__search block-editor-inserter__search", |
|
11144 autoFocus: true, |
|
11145 onChange: this.onChangeSearchInput |
|
11146 }), Object(external_this_wp_element_["createElement"])("div", { |
|
11147 className: "editor-inserter__results block-editor-inserter__results", |
|
11148 ref: this.inserterResults, |
|
11149 tabIndex: "0", |
|
11150 role: "region", |
|
11151 "aria-label": Object(external_this_wp_i18n_["__"])('Available block types') |
|
11152 }, Object(external_this_wp_element_["createElement"])(child_blocks, { |
|
11153 rootClientId: rootClientId, |
|
11154 items: childItems, |
|
11155 onSelect: onSelect, |
|
11156 onHover: this.onHover |
|
11157 }), !!suggestedItems.length && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["PanelBody"], { |
|
11158 title: Object(external_this_wp_i18n_["_x"])('Most Used', 'blocks'), |
|
11159 opened: isPanelOpen('suggested'), |
|
11160 onToggle: this.onTogglePanel('suggested'), |
|
11161 ref: this.bindPanel('suggested') |
|
11162 }, Object(external_this_wp_element_["createElement"])(block_types_list, { |
|
11163 items: suggestedItems, |
|
11164 onSelect: onSelect, |
|
11165 onHover: this.onHover |
|
11166 })), Object(external_lodash_["map"])(Object(external_this_wp_blocks_["getCategories"])(), function (category) { |
|
11167 var categoryItems = itemsPerCategory[category.slug]; |
|
11168 |
|
11169 if (!categoryItems || !categoryItems.length) { |
|
11170 return null; |
|
11171 } |
|
11172 |
|
11173 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["PanelBody"], { |
|
11174 key: category.slug, |
|
11175 title: category.title, |
|
11176 icon: category.icon, |
|
11177 opened: isPanelOpen(category.slug), |
|
11178 onToggle: _this4.onTogglePanel(category.slug), |
|
11179 ref: _this4.bindPanel(category.slug) |
|
11180 }, Object(external_this_wp_element_["createElement"])(block_types_list, { |
|
11181 items: categoryItems, |
|
11182 onSelect: onSelect, |
|
11183 onHover: _this4.onHover |
|
11184 })); |
|
11185 }), !!reusableItems.length && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["PanelBody"], { |
|
11186 className: "editor-inserter__reusable-blocks-panel block-editor-inserter__reusable-blocks-panel", |
|
11187 title: Object(external_this_wp_i18n_["__"])('Reusable'), |
|
11188 opened: isPanelOpen('reusable'), |
|
11189 onToggle: this.onTogglePanel('reusable'), |
|
11190 icon: "controls-repeat", |
|
11191 ref: this.bindPanel('reusable') |
|
11192 }, Object(external_this_wp_element_["createElement"])(block_types_list, { |
|
11193 items: reusableItems, |
|
11194 onSelect: onSelect, |
|
11195 onHover: this.onHover |
|
11196 }), Object(external_this_wp_element_["createElement"])("a", { |
|
11197 className: "editor-inserter__manage-reusable-blocks block-editor-inserter__manage-reusable-blocks", |
|
11198 href: Object(external_this_wp_url_["addQueryArgs"])('edit.php', { |
|
11199 post_type: 'wp_block' |
|
11200 }) |
|
11201 }, Object(external_this_wp_i18n_["__"])('Manage All Reusable Blocks'))), Object(external_lodash_["isEmpty"])(suggestedItems) && Object(external_lodash_["isEmpty"])(reusableItems) && Object(external_lodash_["isEmpty"])(itemsPerCategory) && Object(external_this_wp_element_["createElement"])("p", { |
|
11202 className: "editor-inserter__no-results block-editor-inserter__no-results" |
|
11203 }, Object(external_this_wp_i18n_["__"])('No blocks found.'))), hoveredItem && Object(external_this_wp_blocks_["isReusableBlock"])(hoveredItem) && Object(external_this_wp_element_["createElement"])(block_preview, { |
|
11204 name: hoveredItem.name, |
|
11205 attributes: hoveredItem.initialAttributes |
|
11206 })); |
|
11207 /* eslint-enable jsx-a11y/no-autofocus, jsx-a11y/no-noninteractive-element-interactions */ |
|
11208 } |
|
11209 }]); |
|
11210 |
|
11211 return InserterMenu; |
|
11212 }(external_this_wp_element_["Component"]); |
|
11213 /* harmony default export */ var menu = (Object(external_this_wp_compose_["compose"])(Object(external_this_wp_data_["withSelect"])(function (select, _ref2) { |
|
11214 var clientId = _ref2.clientId, |
|
11215 isAppender = _ref2.isAppender, |
|
11216 rootClientId = _ref2.rootClientId; |
|
11217 |
|
11218 var _select = select('core/block-editor'), |
|
11219 getInserterItems = _select.getInserterItems, |
|
11220 getBlockName = _select.getBlockName, |
|
11221 getBlockRootClientId = _select.getBlockRootClientId, |
|
11222 getBlockSelectionEnd = _select.getBlockSelectionEnd; |
|
11223 |
|
11224 var _select2 = select('core/blocks'), |
|
11225 getChildBlockNames = _select2.getChildBlockNames; |
|
11226 |
|
11227 var destinationRootClientId = rootClientId; |
|
11228 |
|
11229 if (!destinationRootClientId && !clientId && !isAppender) { |
|
11230 var end = getBlockSelectionEnd(); |
|
11231 |
|
11232 if (end) { |
|
11233 destinationRootClientId = getBlockRootClientId(end) || undefined; |
|
11234 } |
|
11235 } |
|
11236 |
|
11237 var destinationRootBlockName = getBlockName(destinationRootClientId); |
|
11238 return { |
|
11239 rootChildBlocks: getChildBlockNames(destinationRootBlockName), |
|
11240 items: getInserterItems(destinationRootClientId), |
|
11241 destinationRootClientId: destinationRootClientId |
|
11242 }; |
|
11243 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, ownProps, _ref3) { |
|
11244 var select = _ref3.select; |
|
11245 |
|
11246 var _dispatch = dispatch('core/block-editor'), |
|
11247 _showInsertionPoint = _dispatch.showInsertionPoint, |
|
11248 hideInsertionPoint = _dispatch.hideInsertionPoint; // This should be an external action provided in the editor settings. |
|
11249 |
|
11250 |
|
11251 var _dispatch2 = dispatch('core/editor'), |
|
11252 fetchReusableBlocks = _dispatch2.__experimentalFetchReusableBlocks; // To avoid duplication, getInsertionIndex is extracted and used in two event handlers |
|
11253 // This breaks the withDispatch not containing any logic rule. |
|
11254 // Since it's a function only called when the event handlers are called, |
|
11255 // it's fine to extract it. |
|
11256 // eslint-disable-next-line no-restricted-syntax |
|
11257 |
|
11258 |
|
11259 function getInsertionIndex() { |
|
11260 var _select3 = select('core/block-editor'), |
|
11261 getBlockIndex = _select3.getBlockIndex, |
|
11262 getBlockSelectionEnd = _select3.getBlockSelectionEnd, |
|
11263 getBlockOrder = _select3.getBlockOrder; |
|
11264 |
|
11265 var clientId = ownProps.clientId, |
|
11266 destinationRootClientId = ownProps.destinationRootClientId, |
|
11267 isAppender = ownProps.isAppender; // If the clientId is defined, we insert at the position of the block. |
|
11268 |
|
11269 if (clientId) { |
|
11270 return getBlockIndex(clientId, destinationRootClientId); |
|
11271 } // If there a selected block, we insert after the selected block. |
|
11272 |
|
11273 |
|
11274 var end = getBlockSelectionEnd(); |
|
11275 |
|
11276 if (!isAppender && end) { |
|
11277 return getBlockIndex(end, destinationRootClientId) + 1; |
|
11278 } // Otherwise, we insert at the end of the current rootClientId |
|
11279 |
|
11280 |
|
11281 return getBlockOrder(destinationRootClientId).length; |
|
11282 } |
|
11283 |
|
11284 return { |
|
11285 fetchReusableBlocks: fetchReusableBlocks, |
|
11286 showInsertionPoint: function showInsertionPoint() { |
|
11287 var index = getInsertionIndex(); |
|
11288 |
|
11289 _showInsertionPoint(ownProps.destinationRootClientId, index); |
|
11290 }, |
|
11291 hideInsertionPoint: hideInsertionPoint, |
|
11292 onSelect: function onSelect(item) { |
|
11293 var _dispatch3 = dispatch('core/block-editor'), |
|
11294 replaceBlocks = _dispatch3.replaceBlocks, |
|
11295 insertBlock = _dispatch3.insertBlock; |
|
11296 |
|
11297 var _select4 = select('core/block-editor'), |
|
11298 getSelectedBlock = _select4.getSelectedBlock; |
|
11299 |
|
11300 var isAppender = ownProps.isAppender; |
|
11301 var name = item.name, |
|
11302 initialAttributes = item.initialAttributes; |
|
11303 var selectedBlock = getSelectedBlock(); |
|
11304 var insertedBlock = Object(external_this_wp_blocks_["createBlock"])(name, initialAttributes); |
|
11305 |
|
11306 if (!isAppender && selectedBlock && Object(external_this_wp_blocks_["isUnmodifiedDefaultBlock"])(selectedBlock)) { |
|
11307 replaceBlocks(selectedBlock.clientId, insertedBlock); |
|
11308 } else { |
|
11309 insertBlock(insertedBlock, getInsertionIndex(), ownProps.destinationRootClientId); |
|
11310 } |
|
11311 |
|
11312 ownProps.onSelect(); |
|
11313 } |
|
11314 }; |
|
11315 }), external_this_wp_components_["withSpokenMessages"], external_this_wp_compose_["withInstanceId"], external_this_wp_compose_["withSafeTimeout"])(menu_InserterMenu)); |
|
11316 |
|
11317 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/index.js |
|
11318 |
|
11319 |
|
11320 |
|
11321 |
|
11322 |
|
11323 |
|
11324 |
|
11325 |
|
11326 /** |
|
11327 * WordPress dependencies |
|
11328 */ |
|
11329 |
|
11330 |
|
11331 |
|
11332 |
|
11333 |
|
11334 /** |
|
11335 * Internal dependencies |
|
11336 */ |
|
11337 |
|
11338 |
|
11339 |
|
11340 var inserter_defaultRenderToggle = function defaultRenderToggle(_ref) { |
|
11341 var onToggle = _ref.onToggle, |
|
11342 disabled = _ref.disabled, |
|
11343 isOpen = _ref.isOpen; |
|
11344 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], { |
|
11345 icon: "insert", |
|
11346 label: Object(external_this_wp_i18n_["__"])('Add block'), |
|
11347 labelPosition: "bottom", |
|
11348 onClick: onToggle, |
|
11349 className: "editor-inserter__toggle block-editor-inserter__toggle", |
|
11350 "aria-haspopup": "true", |
|
11351 "aria-expanded": isOpen, |
|
11352 disabled: disabled |
|
11353 }); |
|
11354 }; |
|
11355 |
|
11356 var inserter_Inserter = |
|
11357 /*#__PURE__*/ |
|
11358 function (_Component) { |
|
11359 Object(inherits["a" /* default */])(Inserter, _Component); |
|
11360 |
|
11361 function Inserter() { |
|
11362 var _this; |
|
11363 |
|
11364 Object(classCallCheck["a" /* default */])(this, Inserter); |
|
11365 |
|
11366 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(Inserter).apply(this, arguments)); |
|
11367 _this.onToggle = _this.onToggle.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
11368 _this.renderToggle = _this.renderToggle.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
11369 _this.renderContent = _this.renderContent.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
11370 return _this; |
|
11371 } |
|
11372 |
|
11373 Object(createClass["a" /* default */])(Inserter, [{ |
|
11374 key: "onToggle", |
|
11375 value: function onToggle(isOpen) { |
|
11376 var onToggle = this.props.onToggle; // Surface toggle callback to parent component |
|
11377 |
|
11378 if (onToggle) { |
|
11379 onToggle(isOpen); |
|
11380 } |
|
11381 } |
|
11382 /** |
|
11383 * Render callback to display Dropdown toggle element. |
|
11384 * |
|
11385 * @param {Function} options.onToggle Callback to invoke when toggle is |
|
11386 * pressed. |
|
11387 * @param {boolean} options.isOpen Whether dropdown is currently open. |
|
11388 * |
|
11389 * @return {WPElement} Dropdown toggle element. |
|
11390 */ |
|
11391 |
|
11392 }, { |
|
11393 key: "renderToggle", |
|
11394 value: function renderToggle(_ref2) { |
|
11395 var onToggle = _ref2.onToggle, |
|
11396 isOpen = _ref2.isOpen; |
|
11397 var _this$props = this.props, |
|
11398 disabled = _this$props.disabled, |
|
11399 _this$props$renderTog = _this$props.renderToggle, |
|
11400 renderToggle = _this$props$renderTog === void 0 ? inserter_defaultRenderToggle : _this$props$renderTog; |
|
11401 return renderToggle({ |
|
11402 onToggle: onToggle, |
|
11403 isOpen: isOpen, |
|
11404 disabled: disabled |
|
11405 }); |
|
11406 } |
|
11407 /** |
|
11408 * Render callback to display Dropdown content element. |
|
11409 * |
|
11410 * @param {Function} options.onClose Callback to invoke when dropdown is |
|
11411 * closed. |
|
11412 * |
|
11413 * @return {WPElement} Dropdown content element. |
|
11414 */ |
|
11415 |
|
11416 }, { |
|
11417 key: "renderContent", |
|
11418 value: function renderContent(_ref3) { |
|
11419 var onClose = _ref3.onClose; |
|
11420 var _this$props2 = this.props, |
|
11421 rootClientId = _this$props2.rootClientId, |
|
11422 clientId = _this$props2.clientId, |
|
11423 isAppender = _this$props2.isAppender; |
|
11424 return Object(external_this_wp_element_["createElement"])(menu, { |
|
11425 onSelect: onClose, |
|
11426 rootClientId: rootClientId, |
|
11427 clientId: clientId, |
|
11428 isAppender: isAppender |
|
11429 }); |
|
11430 } |
|
11431 }, { |
|
11432 key: "render", |
|
11433 value: function render() { |
|
11434 var _this$props3 = this.props, |
|
11435 position = _this$props3.position, |
|
11436 title = _this$props3.title; |
|
11437 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Dropdown"], { |
|
11438 className: "editor-inserter block-editor-inserter", |
|
11439 contentClassName: "editor-inserter__popover block-editor-inserter__popover", |
|
11440 position: position, |
|
11441 onToggle: this.onToggle, |
|
11442 expandOnMobile: true, |
|
11443 headerTitle: title, |
|
11444 renderToggle: this.renderToggle, |
|
11445 renderContent: this.renderContent |
|
11446 }); |
|
11447 } |
|
11448 }]); |
|
11449 |
|
11450 return Inserter; |
|
11451 }(external_this_wp_element_["Component"]); |
|
11452 |
|
11453 /* harmony default export */ var inserter = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select, _ref4) { |
|
11454 var rootClientId = _ref4.rootClientId; |
|
11455 |
|
11456 var _select = select('core/block-editor'), |
|
11457 hasInserterItems = _select.hasInserterItems; // The title should be removed from the inserter |
|
11458 // or replaced by a prop passed to the inserter. |
|
11459 |
|
11460 |
|
11461 var _select2 = select('core/editor'), |
|
11462 getEditedPostAttribute = _select2.getEditedPostAttribute; |
|
11463 |
|
11464 return { |
|
11465 title: getEditedPostAttribute('title'), |
|
11466 hasItems: hasInserterItems(rootClientId) |
|
11467 }; |
|
11468 }), Object(external_this_wp_compose_["ifCondition"])(function (_ref5) { |
|
11469 var hasItems = _ref5.hasItems; |
|
11470 return hasItems; |
|
11471 })])(inserter_Inserter)); |
|
11472 |
|
11473 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-mobile-toolbar.js |
|
11474 |
|
11475 |
|
11476 /** |
|
11477 * WordPress dependencies |
|
11478 */ |
|
11479 |
|
11480 /** |
|
11481 * Internal dependencies |
|
11482 */ |
|
11483 |
|
11484 |
|
11485 |
|
11486 |
|
11487 function BlockMobileToolbar(_ref) { |
|
11488 var clientId = _ref.clientId; |
|
11489 return Object(external_this_wp_element_["createElement"])("div", { |
|
11490 className: "editor-block-list__block-mobile-toolbar block-editor-block-list__block-mobile-toolbar" |
|
11491 }, Object(external_this_wp_element_["createElement"])(inserter, null), Object(external_this_wp_element_["createElement"])(block_mover, { |
|
11492 clientIds: [clientId] |
|
11493 })); |
|
11494 } |
|
11495 |
|
11496 /* harmony default export */ var block_mobile_toolbar = (Object(external_this_wp_viewport_["ifViewportMatches"])('< small')(BlockMobileToolbar)); |
|
11497 |
|
11498 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/insertion-point.js |
|
11499 |
|
11500 |
|
11501 |
|
11502 |
|
11503 |
|
11504 |
|
11505 |
|
11506 |
|
11507 /** |
|
11508 * External dependencies |
|
11509 */ |
|
11510 |
|
11511 /** |
|
11512 * WordPress dependencies |
|
11513 */ |
|
11514 |
|
11515 |
|
11516 |
|
11517 /** |
|
11518 * Internal dependencies |
|
11519 */ |
|
11520 |
|
11521 |
|
11522 |
|
11523 var insertion_point_BlockInsertionPoint = |
|
11524 /*#__PURE__*/ |
|
11525 function (_Component) { |
|
11526 Object(inherits["a" /* default */])(BlockInsertionPoint, _Component); |
|
11527 |
|
11528 function BlockInsertionPoint() { |
|
11529 var _this; |
|
11530 |
|
11531 Object(classCallCheck["a" /* default */])(this, BlockInsertionPoint); |
|
11532 |
|
11533 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(BlockInsertionPoint).apply(this, arguments)); |
|
11534 _this.state = { |
|
11535 isInserterFocused: false |
|
11536 }; |
|
11537 _this.onBlurInserter = _this.onBlurInserter.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
11538 _this.onFocusInserter = _this.onFocusInserter.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
11539 return _this; |
|
11540 } |
|
11541 |
|
11542 Object(createClass["a" /* default */])(BlockInsertionPoint, [{ |
|
11543 key: "onFocusInserter", |
|
11544 value: function onFocusInserter(event) { |
|
11545 // Stop propagation of the focus event to avoid selecting the current |
|
11546 // block while inserting a new block, as it is not relevant to sibling |
|
11547 // insertion and conflicts with contextual toolbar placement. |
|
11548 event.stopPropagation(); |
|
11549 this.setState({ |
|
11550 isInserterFocused: true |
|
11551 }); |
|
11552 } |
|
11553 }, { |
|
11554 key: "onBlurInserter", |
|
11555 value: function onBlurInserter() { |
|
11556 this.setState({ |
|
11557 isInserterFocused: false |
|
11558 }); |
|
11559 } |
|
11560 }, { |
|
11561 key: "render", |
|
11562 value: function render() { |
|
11563 var isInserterFocused = this.state.isInserterFocused; |
|
11564 var _this$props = this.props, |
|
11565 showInsertionPoint = _this$props.showInsertionPoint, |
|
11566 rootClientId = _this$props.rootClientId, |
|
11567 clientId = _this$props.clientId; |
|
11568 return Object(external_this_wp_element_["createElement"])("div", { |
|
11569 className: "editor-block-list__insertion-point block-editor-block-list__insertion-point" |
|
11570 }, showInsertionPoint && Object(external_this_wp_element_["createElement"])("div", { |
|
11571 className: "editor-block-list__insertion-point-indicator block-editor-block-list__insertion-point-indicator" |
|
11572 }), Object(external_this_wp_element_["createElement"])("div", { |
|
11573 onFocus: this.onFocusInserter, |
|
11574 onBlur: this.onBlurInserter // While ideally it would be enough to capture the |
|
11575 // bubbling focus event from the Inserter, due to the |
|
11576 // characteristics of click focusing of `button`s in |
|
11577 // Firefox and Safari, it is not reliable. |
|
11578 // |
|
11579 // See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus |
|
11580 , |
|
11581 tabIndex: -1, |
|
11582 className: classnames_default()('editor-block-list__insertion-point-inserter block-editor-block-list__insertion-point-inserter', { |
|
11583 'is-visible': isInserterFocused |
|
11584 }) |
|
11585 }, Object(external_this_wp_element_["createElement"])(inserter, { |
|
11586 rootClientId: rootClientId, |
|
11587 clientId: clientId |
|
11588 }))); |
|
11589 } |
|
11590 }]); |
|
11591 |
|
11592 return BlockInsertionPoint; |
|
11593 }(external_this_wp_element_["Component"]); |
|
11594 |
|
11595 /* harmony default export */ var insertion_point = (Object(external_this_wp_data_["withSelect"])(function (select, _ref) { |
|
11596 var clientId = _ref.clientId, |
|
11597 rootClientId = _ref.rootClientId; |
|
11598 |
|
11599 var _select = select('core/block-editor'), |
|
11600 getBlockIndex = _select.getBlockIndex, |
|
11601 getBlockInsertionPoint = _select.getBlockInsertionPoint, |
|
11602 isBlockInsertionPointVisible = _select.isBlockInsertionPointVisible; |
|
11603 |
|
11604 var blockIndex = getBlockIndex(clientId, rootClientId); |
|
11605 var insertionPoint = getBlockInsertionPoint(); |
|
11606 var showInsertionPoint = isBlockInsertionPointVisible() && insertionPoint.index === blockIndex && insertionPoint.rootClientId === rootClientId; |
|
11607 return { |
|
11608 showInsertionPoint: showInsertionPoint |
|
11609 }; |
|
11610 })(insertion_point_BlockInsertionPoint)); |
|
11611 |
|
11612 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/ignore-nested-events/index.js |
|
11613 |
|
11614 |
|
11615 |
|
11616 |
|
11617 |
|
11618 |
|
11619 |
|
11620 |
|
11621 |
|
11622 |
|
11623 |
|
11624 /** |
|
11625 * External dependencies |
|
11626 */ |
|
11627 |
|
11628 /** |
|
11629 * WordPress dependencies |
|
11630 */ |
|
11631 |
|
11632 |
|
11633 /** |
|
11634 * Component which renders a div with passed props applied except the optional |
|
11635 * `childHandledEvents` prop. Event prop handlers are replaced with a proxying |
|
11636 * event handler to capture and prevent events from being handled by ancestor |
|
11637 * `IgnoreNestedEvents` elements by testing the presence of a private property |
|
11638 * assigned on the event object. |
|
11639 * |
|
11640 * Optionally accepts an `childHandledEvents` prop array, which can be used in |
|
11641 * instances where an inner `IgnoreNestedEvents` element exists and the outer |
|
11642 * element should stop propagation but not invoke a callback handler, since it |
|
11643 * would be assumed these are invoked by the child element. |
|
11644 * |
|
11645 * @type {Component} |
|
11646 */ |
|
11647 |
|
11648 var ignore_nested_events_IgnoreNestedEvents = |
|
11649 /*#__PURE__*/ |
|
11650 function (_Component) { |
|
11651 Object(inherits["a" /* default */])(IgnoreNestedEvents, _Component); |
|
11652 |
|
11653 function IgnoreNestedEvents() { |
|
11654 var _this; |
|
11655 |
|
11656 Object(classCallCheck["a" /* default */])(this, IgnoreNestedEvents); |
|
11657 |
|
11658 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(IgnoreNestedEvents).apply(this, arguments)); |
|
11659 _this.proxyEvent = _this.proxyEvent.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); // The event map is responsible for tracking an event type to a React |
|
11660 // component prop name, since it is easy to determine event type from |
|
11661 // a React prop name, but not the other way around. |
|
11662 |
|
11663 _this.eventMap = {}; |
|
11664 return _this; |
|
11665 } |
|
11666 /** |
|
11667 * General event handler which only calls to its original props callback if |
|
11668 * it has not already been handled by a descendant IgnoreNestedEvents. |
|
11669 * |
|
11670 * @param {Event} event Event object. |
|
11671 * |
|
11672 * @return {void} |
|
11673 */ |
|
11674 |
|
11675 |
|
11676 Object(createClass["a" /* default */])(IgnoreNestedEvents, [{ |
|
11677 key: "proxyEvent", |
|
11678 value: function proxyEvent(event) { |
|
11679 var isHandled = !!event.nativeEvent._blockHandled; // Assign into the native event, since React will reuse their synthetic |
|
11680 // event objects and this property assignment could otherwise leak. |
|
11681 // |
|
11682 // See: https://reactjs.org/docs/events.html#event-pooling |
|
11683 |
|
11684 event.nativeEvent._blockHandled = true; // Invoke original prop handler |
|
11685 |
|
11686 var propKey = this.eventMap[event.type]; // If already handled (i.e. assume nested block), only invoke a |
|
11687 // corresponding "Handled"-suffixed prop callback. |
|
11688 |
|
11689 if (isHandled) { |
|
11690 propKey += 'Handled'; |
|
11691 } |
|
11692 |
|
11693 if (this.props[propKey]) { |
|
11694 this.props[propKey](event); |
|
11695 } |
|
11696 } |
|
11697 }, { |
|
11698 key: "render", |
|
11699 value: function render() { |
|
11700 var _this2 = this; |
|
11701 |
|
11702 var _this$props = this.props, |
|
11703 _this$props$childHand = _this$props.childHandledEvents, |
|
11704 childHandledEvents = _this$props$childHand === void 0 ? [] : _this$props$childHand, |
|
11705 forwardedRef = _this$props.forwardedRef, |
|
11706 props = Object(objectWithoutProperties["a" /* default */])(_this$props, ["childHandledEvents", "forwardedRef"]); |
|
11707 |
|
11708 var eventHandlers = Object(external_lodash_["reduce"])([].concat(Object(toConsumableArray["a" /* default */])(childHandledEvents), Object(toConsumableArray["a" /* default */])(Object.keys(props))), function (result, key) { |
|
11709 // Try to match prop key as event handler |
|
11710 var match = key.match(/^on([A-Z][a-zA-Z]+?)(Handled)?$/); |
|
11711 |
|
11712 if (match) { |
|
11713 var isHandledProp = !!match[2]; |
|
11714 |
|
11715 if (isHandledProp) { |
|
11716 // Avoid assigning through the invalid prop key. This |
|
11717 // assumes mutation of shallow clone by above spread. |
|
11718 delete props[key]; |
|
11719 } // Re-map the prop to the local proxy handler to check whether |
|
11720 // the event has already been handled. |
|
11721 |
|
11722 |
|
11723 var proxiedPropName = 'on' + match[1]; |
|
11724 result[proxiedPropName] = _this2.proxyEvent; // Assign event -> propName into an instance variable, so as to |
|
11725 // avoid re-renders which could be incurred either by setState |
|
11726 // or in mapping values to a newly created function. |
|
11727 |
|
11728 _this2.eventMap[match[1].toLowerCase()] = proxiedPropName; |
|
11729 } |
|
11730 |
|
11731 return result; |
|
11732 }, {}); |
|
11733 return Object(external_this_wp_element_["createElement"])("div", Object(esm_extends["a" /* default */])({ |
|
11734 ref: forwardedRef |
|
11735 }, props, eventHandlers)); |
|
11736 } |
|
11737 }]); |
|
11738 |
|
11739 return IgnoreNestedEvents; |
|
11740 }(external_this_wp_element_["Component"]); |
|
11741 |
|
11742 var ignore_nested_events_forwardedIgnoreNestedEvents = function forwardedIgnoreNestedEvents(props, ref) { |
|
11743 return Object(external_this_wp_element_["createElement"])(ignore_nested_events_IgnoreNestedEvents, Object(esm_extends["a" /* default */])({}, props, { |
|
11744 forwardedRef: ref |
|
11745 })); |
|
11746 }; |
|
11747 |
|
11748 ignore_nested_events_forwardedIgnoreNestedEvents.displayName = 'IgnoreNestedEvents'; |
|
11749 /* harmony default export */ var ignore_nested_events = (Object(external_this_wp_element_["forwardRef"])(ignore_nested_events_forwardedIgnoreNestedEvents)); |
|
11750 |
|
11751 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-with-shortcuts/index.js |
|
11752 |
|
11753 |
|
11754 /** |
|
11755 * External dependencies |
|
11756 */ |
|
11757 |
|
11758 /** |
|
11759 * WordPress dependencies |
|
11760 */ |
|
11761 |
|
11762 |
|
11763 |
|
11764 |
|
11765 |
|
11766 |
|
11767 /** |
|
11768 * Internal dependencies |
|
11769 */ |
|
11770 |
|
11771 |
|
11772 |
|
11773 function InserterWithShortcuts(_ref) { |
|
11774 var items = _ref.items, |
|
11775 isLocked = _ref.isLocked, |
|
11776 onInsert = _ref.onInsert; |
|
11777 |
|
11778 if (isLocked) { |
|
11779 return null; |
|
11780 } |
|
11781 |
|
11782 var itemsWithoutDefaultBlock = Object(external_lodash_["filter"])(items, function (item) { |
|
11783 return !item.isDisabled && (item.name !== Object(external_this_wp_blocks_["getDefaultBlockName"])() || !Object(external_lodash_["isEmpty"])(item.initialAttributes)); |
|
11784 }).slice(0, 3); |
|
11785 return Object(external_this_wp_element_["createElement"])("div", { |
|
11786 className: "editor-inserter-with-shortcuts block-editor-inserter-with-shortcuts" |
|
11787 }, itemsWithoutDefaultBlock.map(function (item) { |
|
11788 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], { |
|
11789 key: item.id, |
|
11790 className: "editor-inserter-with-shortcuts__block block-editor-inserter-with-shortcuts__block", |
|
11791 onClick: function onClick() { |
|
11792 return onInsert(item); |
|
11793 } // translators: %s: block title/name to be added |
|
11794 , |
|
11795 label: Object(external_this_wp_i18n_["sprintf"])(Object(external_this_wp_i18n_["__"])('Add %s'), item.title), |
|
11796 icon: Object(external_this_wp_element_["createElement"])(BlockIcon, { |
|
11797 icon: item.icon |
|
11798 }) |
|
11799 }); |
|
11800 })); |
|
11801 } |
|
11802 |
|
11803 /* harmony default export */ var inserter_with_shortcuts = (Object(external_this_wp_compose_["compose"])(Object(external_this_wp_data_["withSelect"])(function (select, _ref2) { |
|
11804 var rootClientId = _ref2.rootClientId; |
|
11805 |
|
11806 var _select = select('core/block-editor'), |
|
11807 getInserterItems = _select.getInserterItems, |
|
11808 getTemplateLock = _select.getTemplateLock; |
|
11809 |
|
11810 return { |
|
11811 items: getInserterItems(rootClientId), |
|
11812 isLocked: !!getTemplateLock(rootClientId) |
|
11813 }; |
|
11814 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, ownProps) { |
|
11815 var clientId = ownProps.clientId, |
|
11816 rootClientId = ownProps.rootClientId; |
|
11817 return { |
|
11818 onInsert: function onInsert(_ref3) { |
|
11819 var name = _ref3.name, |
|
11820 initialAttributes = _ref3.initialAttributes; |
|
11821 var block = Object(external_this_wp_blocks_["createBlock"])(name, initialAttributes); |
|
11822 |
|
11823 if (clientId) { |
|
11824 dispatch('core/block-editor').replaceBlocks(clientId, block); |
|
11825 } else { |
|
11826 dispatch('core/block-editor').insertBlock(block, undefined, rootClientId); |
|
11827 } |
|
11828 } |
|
11829 }; |
|
11830 }))(InserterWithShortcuts)); |
|
11831 |
|
11832 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/hover-area.js |
|
11833 |
|
11834 |
|
11835 |
|
11836 |
|
11837 |
|
11838 |
|
11839 |
|
11840 /** |
|
11841 * WordPress dependencies |
|
11842 */ |
|
11843 |
|
11844 |
|
11845 |
|
11846 var hover_area_HoverArea = |
|
11847 /*#__PURE__*/ |
|
11848 function (_Component) { |
|
11849 Object(inherits["a" /* default */])(HoverArea, _Component); |
|
11850 |
|
11851 function HoverArea() { |
|
11852 var _this; |
|
11853 |
|
11854 Object(classCallCheck["a" /* default */])(this, HoverArea); |
|
11855 |
|
11856 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(HoverArea).apply(this, arguments)); |
|
11857 _this.state = { |
|
11858 hoverArea: null |
|
11859 }; |
|
11860 _this.onMouseLeave = _this.onMouseLeave.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
11861 _this.onMouseMove = _this.onMouseMove.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
11862 return _this; |
|
11863 } |
|
11864 |
|
11865 Object(createClass["a" /* default */])(HoverArea, [{ |
|
11866 key: "componentWillUnmount", |
|
11867 value: function componentWillUnmount() { |
|
11868 if (this.props.container) { |
|
11869 this.toggleListeners(this.props.container, false); |
|
11870 } |
|
11871 } |
|
11872 }, { |
|
11873 key: "componentDidMount", |
|
11874 value: function componentDidMount() { |
|
11875 if (this.props.container) { |
|
11876 this.toggleListeners(this.props.container); |
|
11877 } |
|
11878 } |
|
11879 }, { |
|
11880 key: "componentDidUpdate", |
|
11881 value: function componentDidUpdate(prevProps) { |
|
11882 if (prevProps.container === this.props.container) { |
|
11883 return; |
|
11884 } |
|
11885 |
|
11886 if (prevProps.container) { |
|
11887 this.toggleListeners(prevProps.container, false); |
|
11888 } |
|
11889 |
|
11890 if (this.props.container) { |
|
11891 this.toggleListeners(this.props.container, true); |
|
11892 } |
|
11893 } |
|
11894 }, { |
|
11895 key: "toggleListeners", |
|
11896 value: function toggleListeners(container) { |
|
11897 var shouldListnerToEvents = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; |
|
11898 var method = shouldListnerToEvents ? 'addEventListener' : 'removeEventListener'; |
|
11899 container[method]('mousemove', this.onMouseMove); |
|
11900 container[method]('mouseleave', this.onMouseLeave); |
|
11901 } |
|
11902 }, { |
|
11903 key: "onMouseLeave", |
|
11904 value: function onMouseLeave() { |
|
11905 if (this.state.hoverArea) { |
|
11906 this.setState({ |
|
11907 hoverArea: null |
|
11908 }); |
|
11909 } |
|
11910 } |
|
11911 }, { |
|
11912 key: "onMouseMove", |
|
11913 value: function onMouseMove(event) { |
|
11914 var _this$props = this.props, |
|
11915 isRTL = _this$props.isRTL, |
|
11916 container = _this$props.container; |
|
11917 |
|
11918 var _container$getBoundin = container.getBoundingClientRect(), |
|
11919 width = _container$getBoundin.width, |
|
11920 left = _container$getBoundin.left, |
|
11921 right = _container$getBoundin.right; |
|
11922 |
|
11923 var hoverArea = null; |
|
11924 |
|
11925 if (event.clientX - left < width / 3) { |
|
11926 hoverArea = isRTL ? 'right' : 'left'; |
|
11927 } else if (right - event.clientX < width / 3) { |
|
11928 hoverArea = isRTL ? 'left' : 'right'; |
|
11929 } |
|
11930 |
|
11931 if (hoverArea !== this.state.hoverArea) { |
|
11932 this.setState({ |
|
11933 hoverArea: hoverArea |
|
11934 }); |
|
11935 } |
|
11936 } |
|
11937 }, { |
|
11938 key: "render", |
|
11939 value: function render() { |
|
11940 var hoverArea = this.state.hoverArea; |
|
11941 var children = this.props.children; |
|
11942 return children({ |
|
11943 hoverArea: hoverArea |
|
11944 }); |
|
11945 } |
|
11946 }]); |
|
11947 |
|
11948 return HoverArea; |
|
11949 }(external_this_wp_element_["Component"]); |
|
11950 |
|
11951 /* harmony default export */ var hover_area = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
11952 return { |
|
11953 isRTL: select('core/block-editor').getSettings().isRTL |
|
11954 }; |
|
11955 })(hover_area_HoverArea)); |
|
11956 |
|
11957 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/dom.js |
|
11958 /** |
|
11959 * Given a block client ID, returns the corresponding DOM node for the block, |
|
11960 * if exists. As much as possible, this helper should be avoided, and used only |
|
11961 * in cases where isolated behaviors need remote access to a block node. |
|
11962 * |
|
11963 * @param {string} clientId Block client ID. |
|
11964 * |
|
11965 * @return {Element} Block DOM node. |
|
11966 */ |
|
11967 function getBlockDOMNode(clientId) { |
|
11968 return document.querySelector('[data-block="' + clientId + '"]'); |
|
11969 } |
|
11970 /** |
|
11971 * Given a block client ID, returns the corresponding DOM node for the block |
|
11972 * focusable wrapper, if exists. As much as possible, this helper should be |
|
11973 * avoided, and used only in cases where isolated behaviors need remote access |
|
11974 * to a block node. |
|
11975 * |
|
11976 * @param {string} clientId Block client ID. |
|
11977 * |
|
11978 * @return {Element} Block DOM node. |
|
11979 */ |
|
11980 |
|
11981 function getBlockFocusableWrapper(clientId) { |
|
11982 return getBlockDOMNode(clientId).closest('.block-editor-block-list__block'); |
|
11983 } |
|
11984 /** |
|
11985 * Returns true if the given HTMLElement is a block focus stop. Blocks without |
|
11986 * their own text fields rely on the focus stop to be keyboard navigable. |
|
11987 * |
|
11988 * @param {HTMLElement} element Element to test. |
|
11989 * |
|
11990 * @return {boolean} Whether element is a block focus stop. |
|
11991 */ |
|
11992 |
|
11993 function isBlockFocusStop(element) { |
|
11994 return element.classList.contains('block-editor-block-list__block'); |
|
11995 } |
|
11996 /** |
|
11997 * Returns true if two elements are contained within the same block. |
|
11998 * |
|
11999 * @param {HTMLElement} a First element. |
|
12000 * @param {HTMLElement} b Second element. |
|
12001 * |
|
12002 * @return {boolean} Whether elements are in the same block. |
|
12003 */ |
|
12004 |
|
12005 function isInSameBlock(a, b) { |
|
12006 return a.closest('[data-block]') === b.closest('[data-block]'); |
|
12007 } |
|
12008 /** |
|
12009 * Returns true if an elements is considered part of the block and not its children. |
|
12010 * |
|
12011 * @param {HTMLElement} blockElement Block container element. |
|
12012 * @param {HTMLElement} element Element. |
|
12013 * |
|
12014 * @return {boolean} Whether element is in the block Element but not its children. |
|
12015 */ |
|
12016 |
|
12017 function isInsideRootBlock(blockElement, element) { |
|
12018 var innerBlocksContainer = blockElement.querySelector('.block-editor-block-list__layout'); |
|
12019 return blockElement.contains(element) && (!innerBlocksContainer || !innerBlocksContainer.contains(element)); |
|
12020 } |
|
12021 /** |
|
12022 * Returns true if the given HTMLElement contains inner blocks (an InnerBlocks |
|
12023 * element). |
|
12024 * |
|
12025 * @param {HTMLElement} element Element to test. |
|
12026 * |
|
12027 * @return {boolean} Whether element contains inner blocks. |
|
12028 */ |
|
12029 |
|
12030 function hasInnerBlocksContext(element) { |
|
12031 return !!element.querySelector('.block-editor-block-list__layout'); |
|
12032 } |
|
12033 |
|
12034 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block.js |
|
12035 |
|
12036 |
|
12037 |
|
12038 |
|
12039 |
|
12040 |
|
12041 |
|
12042 |
|
12043 |
|
12044 |
|
12045 /** |
|
12046 * External dependencies |
|
12047 */ |
|
12048 |
|
12049 |
|
12050 /** |
|
12051 * WordPress dependencies |
|
12052 */ |
|
12053 |
|
12054 |
|
12055 |
|
12056 |
|
12057 |
|
12058 |
|
12059 |
|
12060 |
|
12061 |
|
12062 |
|
12063 /** |
|
12064 * Internal dependencies |
|
12065 */ |
|
12066 |
|
12067 |
|
12068 |
|
12069 |
|
12070 |
|
12071 |
|
12072 |
|
12073 |
|
12074 |
|
12075 |
|
12076 |
|
12077 |
|
12078 |
|
12079 |
|
12080 |
|
12081 |
|
12082 |
|
12083 |
|
12084 var block_BlockListBlock = |
|
12085 /*#__PURE__*/ |
|
12086 function (_Component) { |
|
12087 Object(inherits["a" /* default */])(BlockListBlock, _Component); |
|
12088 |
|
12089 function BlockListBlock() { |
|
12090 var _this; |
|
12091 |
|
12092 Object(classCallCheck["a" /* default */])(this, BlockListBlock); |
|
12093 |
|
12094 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(BlockListBlock).apply(this, arguments)); |
|
12095 _this.setBlockListRef = _this.setBlockListRef.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12096 _this.bindBlockNode = _this.bindBlockNode.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12097 _this.setAttributes = _this.setAttributes.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12098 _this.maybeHover = _this.maybeHover.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12099 _this.forceFocusedContextualToolbar = _this.forceFocusedContextualToolbar.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12100 _this.hideHoverEffects = _this.hideHoverEffects.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12101 _this.onFocus = _this.onFocus.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12102 _this.preventDrag = _this.preventDrag.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12103 _this.onPointerDown = _this.onPointerDown.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12104 _this.deleteOrInsertAfterWrapper = _this.deleteOrInsertAfterWrapper.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12105 _this.onBlockError = _this.onBlockError.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12106 _this.onTouchStart = _this.onTouchStart.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12107 _this.onClick = _this.onClick.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12108 _this.onDragStart = _this.onDragStart.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12109 _this.onDragEnd = _this.onDragEnd.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12110 _this.selectOnOpen = _this.selectOnOpen.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12111 _this.hadTouchStart = false; |
|
12112 _this.state = { |
|
12113 error: null, |
|
12114 dragging: false, |
|
12115 isHovered: false |
|
12116 }; |
|
12117 _this.isForcingContextualToolbar = false; |
|
12118 return _this; |
|
12119 } |
|
12120 |
|
12121 Object(createClass["a" /* default */])(BlockListBlock, [{ |
|
12122 key: "componentDidMount", |
|
12123 value: function componentDidMount() { |
|
12124 if (this.props.isSelected) { |
|
12125 this.focusTabbable(); |
|
12126 } |
|
12127 } |
|
12128 }, { |
|
12129 key: "componentDidUpdate", |
|
12130 value: function componentDidUpdate(prevProps) { |
|
12131 if (this.isForcingContextualToolbar) { |
|
12132 // The forcing of contextual toolbar should only be true during one update, |
|
12133 // after the first update normal conditions should apply. |
|
12134 this.isForcingContextualToolbar = false; |
|
12135 } |
|
12136 |
|
12137 if (this.props.isTypingWithinBlock || this.props.isSelected) { |
|
12138 this.hideHoverEffects(); |
|
12139 } |
|
12140 |
|
12141 if (this.props.isSelected && !prevProps.isSelected) { |
|
12142 this.focusTabbable(true); |
|
12143 } // When triggering a multi-selection, move the focus to the wrapper of the first selected block. |
|
12144 // This ensures that it is not possible to continue editing the initially selected block |
|
12145 // when a multi-selection is triggered. |
|
12146 |
|
12147 |
|
12148 if (this.props.isFirstMultiSelected && !prevProps.isFirstMultiSelected) { |
|
12149 this.wrapperNode.focus(); |
|
12150 } |
|
12151 } |
|
12152 }, { |
|
12153 key: "setBlockListRef", |
|
12154 value: function setBlockListRef(node) { |
|
12155 this.wrapperNode = node; |
|
12156 this.props.blockRef(node, this.props.clientId); // We need to rerender to trigger a rerendering of HoverArea |
|
12157 // it depents on this.wrapperNode but we can't keep this.wrapperNode in state |
|
12158 // Because we need it to be immediately availeble for `focusableTabbable` to work. |
|
12159 |
|
12160 this.forceUpdate(); |
|
12161 } |
|
12162 }, { |
|
12163 key: "bindBlockNode", |
|
12164 value: function bindBlockNode(node) { |
|
12165 this.node = node; |
|
12166 } |
|
12167 /** |
|
12168 * When a block becomes selected, transition focus to an inner tabbable. |
|
12169 * |
|
12170 * @param {boolean} ignoreInnerBlocks Should not focus inner blocks. |
|
12171 */ |
|
12172 |
|
12173 }, { |
|
12174 key: "focusTabbable", |
|
12175 value: function focusTabbable(ignoreInnerBlocks) { |
|
12176 var _this2 = this; |
|
12177 |
|
12178 var initialPosition = this.props.initialPosition; // Focus is captured by the wrapper node, so while focus transition |
|
12179 // should only consider tabbables within editable display, since it |
|
12180 // may be the wrapper itself or a side control which triggered the |
|
12181 // focus event, don't unnecessary transition to an inner tabbable. |
|
12182 |
|
12183 if (this.wrapperNode.contains(document.activeElement)) { |
|
12184 return; |
|
12185 } // Find all tabbables within node. |
|
12186 |
|
12187 |
|
12188 var textInputs = external_this_wp_dom_["focus"].tabbable.find(this.node).filter(external_this_wp_dom_["isTextField"]) // Exclude inner blocks |
|
12189 .filter(function (node) { |
|
12190 return !ignoreInnerBlocks || isInsideRootBlock(_this2.node, node); |
|
12191 }); // If reversed (e.g. merge via backspace), use the last in the set of |
|
12192 // tabbables. |
|
12193 |
|
12194 var isReverse = -1 === initialPosition; |
|
12195 var target = (isReverse ? external_lodash_["last"] : external_lodash_["first"])(textInputs); |
|
12196 |
|
12197 if (!target) { |
|
12198 this.wrapperNode.focus(); |
|
12199 return; |
|
12200 } |
|
12201 |
|
12202 target.focus(); // In reverse case, need to explicitly place caret position. |
|
12203 |
|
12204 if (isReverse) { |
|
12205 Object(external_this_wp_dom_["placeCaretAtHorizontalEdge"])(target, true); |
|
12206 Object(external_this_wp_dom_["placeCaretAtVerticalEdge"])(target, true); |
|
12207 } |
|
12208 } |
|
12209 }, { |
|
12210 key: "setAttributes", |
|
12211 value: function setAttributes(newAttributes) { |
|
12212 var _this$props = this.props, |
|
12213 clientId = _this$props.clientId, |
|
12214 name = _this$props.name, |
|
12215 onChange = _this$props.onChange; |
|
12216 var type = Object(external_this_wp_blocks_["getBlockType"])(name); |
|
12217 |
|
12218 function isMetaAttribute(key) { |
|
12219 return Object(external_lodash_["get"])(type, ['attributes', key, 'source']) === 'meta'; |
|
12220 } // Partition new attributes to delegate update behavior by source. |
|
12221 // |
|
12222 // TODO: A consolidated approach to external attributes sourcing |
|
12223 // should be devised to avoid specific handling for meta, enable |
|
12224 // additional attributes sources. |
|
12225 // |
|
12226 // See: https://github.com/WordPress/gutenberg/issues/2759 |
|
12227 |
|
12228 |
|
12229 var _reduce = Object(external_lodash_["reduce"])(newAttributes, function (result, value, key) { |
|
12230 if (isMetaAttribute(key)) { |
|
12231 result.metaAttributes[type.attributes[key].meta] = value; |
|
12232 } else { |
|
12233 result.blockAttributes[key] = value; |
|
12234 } |
|
12235 |
|
12236 return result; |
|
12237 }, { |
|
12238 blockAttributes: {}, |
|
12239 metaAttributes: {} |
|
12240 }), |
|
12241 blockAttributes = _reduce.blockAttributes, |
|
12242 metaAttributes = _reduce.metaAttributes; |
|
12243 |
|
12244 if (Object(external_lodash_["size"])(blockAttributes)) { |
|
12245 onChange(clientId, blockAttributes); |
|
12246 } |
|
12247 |
|
12248 if (Object(external_lodash_["size"])(metaAttributes)) { |
|
12249 this.props.onMetaChange(metaAttributes); |
|
12250 } |
|
12251 } |
|
12252 }, { |
|
12253 key: "onTouchStart", |
|
12254 value: function onTouchStart() { |
|
12255 // Detect touchstart to disable hover on iOS |
|
12256 this.hadTouchStart = true; |
|
12257 } |
|
12258 }, { |
|
12259 key: "onClick", |
|
12260 value: function onClick() { |
|
12261 // Clear touchstart detection |
|
12262 // Browser will try to emulate mouse events also see https://www.html5rocks.com/en/mobile/touchandmouse/ |
|
12263 this.hadTouchStart = false; |
|
12264 } |
|
12265 /** |
|
12266 * A mouseover event handler to apply hover effect when a pointer device is |
|
12267 * placed within the bounds of the block. The mouseover event is preferred |
|
12268 * over mouseenter because it may be the case that a previous mouseenter |
|
12269 * event was blocked from being handled by a IgnoreNestedEvents component, |
|
12270 * therefore transitioning out of a nested block to the bounds of the block |
|
12271 * would otherwise not trigger a hover effect. |
|
12272 * |
|
12273 * @see https://developer.mozilla.org/en-US/docs/Web/Events/mouseenter |
|
12274 */ |
|
12275 |
|
12276 }, { |
|
12277 key: "maybeHover", |
|
12278 value: function maybeHover() { |
|
12279 var _this$props2 = this.props, |
|
12280 isPartOfMultiSelection = _this$props2.isPartOfMultiSelection, |
|
12281 isSelected = _this$props2.isSelected; |
|
12282 var isHovered = this.state.isHovered; |
|
12283 |
|
12284 if (isHovered || isPartOfMultiSelection || isSelected || this.hadTouchStart) { |
|
12285 return; |
|
12286 } |
|
12287 |
|
12288 this.setState({ |
|
12289 isHovered: true |
|
12290 }); |
|
12291 } |
|
12292 /** |
|
12293 * Sets the block state as unhovered if currently hovering. There are cases |
|
12294 * where mouseleave may occur but the block is not hovered (multi-select), |
|
12295 * so to avoid unnecesary renders, the state is only set if hovered. |
|
12296 */ |
|
12297 |
|
12298 }, { |
|
12299 key: "hideHoverEffects", |
|
12300 value: function hideHoverEffects() { |
|
12301 if (this.state.isHovered) { |
|
12302 this.setState({ |
|
12303 isHovered: false |
|
12304 }); |
|
12305 } |
|
12306 } |
|
12307 /** |
|
12308 * Marks the block as selected when focused and not already selected. This |
|
12309 * specifically handles the case where block does not set focus on its own |
|
12310 * (via `setFocus`), typically if there is no focusable input in the block. |
|
12311 * |
|
12312 * @return {void} |
|
12313 */ |
|
12314 |
|
12315 }, { |
|
12316 key: "onFocus", |
|
12317 value: function onFocus() { |
|
12318 if (!this.props.isSelected && !this.props.isPartOfMultiSelection) { |
|
12319 this.props.onSelect(); |
|
12320 } |
|
12321 } |
|
12322 /** |
|
12323 * Prevents default dragging behavior within a block to allow for multi- |
|
12324 * selection to take effect unhampered. |
|
12325 * |
|
12326 * @param {DragEvent} event Drag event. |
|
12327 * |
|
12328 * @return {void} |
|
12329 */ |
|
12330 |
|
12331 }, { |
|
12332 key: "preventDrag", |
|
12333 value: function preventDrag(event) { |
|
12334 event.preventDefault(); |
|
12335 } |
|
12336 /** |
|
12337 * Begins tracking cursor multi-selection when clicking down within block. |
|
12338 * |
|
12339 * @param {MouseEvent} event A mousedown event. |
|
12340 * |
|
12341 * @return {void} |
|
12342 */ |
|
12343 |
|
12344 }, { |
|
12345 key: "onPointerDown", |
|
12346 value: function onPointerDown(event) { |
|
12347 // Not the main button. |
|
12348 // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button |
|
12349 if (event.button !== 0) { |
|
12350 return; |
|
12351 } |
|
12352 |
|
12353 if (event.shiftKey) { |
|
12354 if (!this.props.isSelected) { |
|
12355 this.props.onShiftSelection(); |
|
12356 event.preventDefault(); |
|
12357 } |
|
12358 } else { |
|
12359 this.props.onSelectionStart(this.props.clientId); // Allow user to escape out of a multi-selection to a singular |
|
12360 // selection of a block via click. This is handled here since |
|
12361 // onFocus excludes blocks involved in a multiselection, as |
|
12362 // focus can be incurred by starting a multiselection (focus |
|
12363 // moved to first block's multi-controls). |
|
12364 |
|
12365 if (this.props.isPartOfMultiSelection) { |
|
12366 this.props.onSelect(); |
|
12367 } |
|
12368 } |
|
12369 } |
|
12370 /** |
|
12371 * Interprets keydown event intent to remove or insert after block if key |
|
12372 * event occurs on wrapper node. This can occur when the block has no text |
|
12373 * fields of its own, particularly after initial insertion, to allow for |
|
12374 * easy deletion and continuous writing flow to add additional content. |
|
12375 * |
|
12376 * @param {KeyboardEvent} event Keydown event. |
|
12377 */ |
|
12378 |
|
12379 }, { |
|
12380 key: "deleteOrInsertAfterWrapper", |
|
12381 value: function deleteOrInsertAfterWrapper(event) { |
|
12382 var keyCode = event.keyCode, |
|
12383 target = event.target; // These block shortcuts should only trigger if the wrapper of the block is selected |
|
12384 // And when it's not a multi-selection to avoid conflicting with RichText/Inputs and multiselection. |
|
12385 |
|
12386 if (!this.props.isSelected || target !== this.wrapperNode || this.props.isLocked) { |
|
12387 return; |
|
12388 } |
|
12389 |
|
12390 switch (keyCode) { |
|
12391 case external_this_wp_keycodes_["ENTER"]: |
|
12392 // Insert default block after current block if enter and event |
|
12393 // not already handled by descendant. |
|
12394 this.props.onInsertDefaultBlockAfter(); |
|
12395 event.preventDefault(); |
|
12396 break; |
|
12397 |
|
12398 case external_this_wp_keycodes_["BACKSPACE"]: |
|
12399 case external_this_wp_keycodes_["DELETE"]: |
|
12400 // Remove block on backspace. |
|
12401 var _this$props3 = this.props, |
|
12402 clientId = _this$props3.clientId, |
|
12403 onRemove = _this$props3.onRemove; |
|
12404 onRemove(clientId); |
|
12405 event.preventDefault(); |
|
12406 break; |
|
12407 } |
|
12408 } |
|
12409 }, { |
|
12410 key: "onBlockError", |
|
12411 value: function onBlockError(error) { |
|
12412 this.setState({ |
|
12413 error: error |
|
12414 }); |
|
12415 } |
|
12416 }, { |
|
12417 key: "onDragStart", |
|
12418 value: function onDragStart() { |
|
12419 this.setState({ |
|
12420 dragging: true |
|
12421 }); |
|
12422 } |
|
12423 }, { |
|
12424 key: "onDragEnd", |
|
12425 value: function onDragEnd() { |
|
12426 this.setState({ |
|
12427 dragging: false |
|
12428 }); |
|
12429 } |
|
12430 }, { |
|
12431 key: "selectOnOpen", |
|
12432 value: function selectOnOpen(open) { |
|
12433 if (open && !this.props.isSelected) { |
|
12434 this.props.onSelect(); |
|
12435 } |
|
12436 } |
|
12437 }, { |
|
12438 key: "forceFocusedContextualToolbar", |
|
12439 value: function forceFocusedContextualToolbar() { |
|
12440 this.isForcingContextualToolbar = true; // trigger a re-render |
|
12441 |
|
12442 this.setState(function () { |
|
12443 return {}; |
|
12444 }); |
|
12445 } |
|
12446 }, { |
|
12447 key: "render", |
|
12448 value: function render() { |
|
12449 var _this3 = this; |
|
12450 |
|
12451 return Object(external_this_wp_element_["createElement"])(hover_area, { |
|
12452 container: this.wrapperNode |
|
12453 }, function (_ref) { |
|
12454 var hoverArea = _ref.hoverArea; |
|
12455 var _this3$props = _this3.props, |
|
12456 mode = _this3$props.mode, |
|
12457 isFocusMode = _this3$props.isFocusMode, |
|
12458 hasFixedToolbar = _this3$props.hasFixedToolbar, |
|
12459 isLocked = _this3$props.isLocked, |
|
12460 isFirst = _this3$props.isFirst, |
|
12461 isLast = _this3$props.isLast, |
|
12462 clientId = _this3$props.clientId, |
|
12463 rootClientId = _this3$props.rootClientId, |
|
12464 isSelected = _this3$props.isSelected, |
|
12465 isPartOfMultiSelection = _this3$props.isPartOfMultiSelection, |
|
12466 isFirstMultiSelected = _this3$props.isFirstMultiSelected, |
|
12467 isTypingWithinBlock = _this3$props.isTypingWithinBlock, |
|
12468 isCaretWithinFormattedText = _this3$props.isCaretWithinFormattedText, |
|
12469 isEmptyDefaultBlock = _this3$props.isEmptyDefaultBlock, |
|
12470 isMovable = _this3$props.isMovable, |
|
12471 isParentOfSelectedBlock = _this3$props.isParentOfSelectedBlock, |
|
12472 isDraggable = _this3$props.isDraggable, |
|
12473 className = _this3$props.className, |
|
12474 name = _this3$props.name, |
|
12475 isValid = _this3$props.isValid, |
|
12476 attributes = _this3$props.attributes; |
|
12477 var isHovered = _this3.state.isHovered && !isPartOfMultiSelection; |
|
12478 var blockType = Object(external_this_wp_blocks_["getBlockType"])(name); // translators: %s: Type of block (i.e. Text, Image etc) |
|
12479 |
|
12480 var blockLabel = Object(external_this_wp_i18n_["sprintf"])(Object(external_this_wp_i18n_["__"])('Block: %s'), blockType.title); // The block as rendered in the editor is composed of general block UI |
|
12481 // (mover, toolbar, wrapper) and the display of the block content. |
|
12482 |
|
12483 var isUnregisteredBlock = name === Object(external_this_wp_blocks_["getUnregisteredTypeHandlerName"])(); // If the block is selected and we're typing the block should not appear. |
|
12484 // Empty paragraph blocks should always show up as unselected. |
|
12485 |
|
12486 var showEmptyBlockSideInserter = (isSelected || isHovered) && isEmptyDefaultBlock && isValid; |
|
12487 var shouldAppearSelected = !isFocusMode && !showEmptyBlockSideInserter && isSelected && !isTypingWithinBlock; |
|
12488 var shouldAppearHovered = !isFocusMode && !hasFixedToolbar && isHovered && !isEmptyDefaultBlock; // We render block movers and block settings to keep them tabbale even if hidden |
|
12489 |
|
12490 var shouldRenderMovers = !isFocusMode && (isSelected || hoverArea === 'left') && !showEmptyBlockSideInserter && !isPartOfMultiSelection && !isTypingWithinBlock; |
|
12491 var shouldShowBreadcrumb = !isFocusMode && isHovered && !isEmptyDefaultBlock; |
|
12492 var shouldShowContextualToolbar = !hasFixedToolbar && !showEmptyBlockSideInserter && (isSelected && (!isTypingWithinBlock || isCaretWithinFormattedText) || isFirstMultiSelected); |
|
12493 var shouldShowMobileToolbar = shouldAppearSelected; |
|
12494 var _this3$state = _this3.state, |
|
12495 error = _this3$state.error, |
|
12496 dragging = _this3$state.dragging; // Insertion point can only be made visible if the block is at the |
|
12497 // the extent of a multi-selection, or not in a multi-selection. |
|
12498 |
|
12499 var shouldShowInsertionPoint = isPartOfMultiSelection && isFirstMultiSelected || !isPartOfMultiSelection; // The wp-block className is important for editor styles. |
|
12500 // Generate the wrapper class names handling the different states of the block. |
|
12501 |
|
12502 var wrapperClassName = classnames_default()('wp-block editor-block-list__block block-editor-block-list__block', { |
|
12503 'has-warning': !isValid || !!error || isUnregisteredBlock, |
|
12504 'is-selected': shouldAppearSelected, |
|
12505 'is-multi-selected': isPartOfMultiSelection, |
|
12506 'is-hovered': shouldAppearHovered, |
|
12507 'is-reusable': Object(external_this_wp_blocks_["isReusableBlock"])(blockType), |
|
12508 'is-dragging': dragging, |
|
12509 'is-typing': isTypingWithinBlock, |
|
12510 'is-focused': isFocusMode && (isSelected || isParentOfSelectedBlock), |
|
12511 'is-focus-mode': isFocusMode |
|
12512 }, className); |
|
12513 var onReplace = _this3.props.onReplace; // Determine whether the block has props to apply to the wrapper. |
|
12514 |
|
12515 var wrapperProps = _this3.props.wrapperProps; |
|
12516 |
|
12517 if (blockType.getEditWrapperProps) { |
|
12518 wrapperProps = Object(objectSpread["a" /* default */])({}, wrapperProps, blockType.getEditWrapperProps(attributes)); |
|
12519 } |
|
12520 |
|
12521 var blockElementId = "block-".concat(clientId); // We wrap the BlockEdit component in a div that hides it when editing in |
|
12522 // HTML mode. This allows us to render all of the ancillary pieces |
|
12523 // (InspectorControls, etc.) which are inside `BlockEdit` but not |
|
12524 // `BlockHTML`, even in HTML mode. |
|
12525 |
|
12526 var blockEdit = Object(external_this_wp_element_["createElement"])(block_edit, { |
|
12527 name: name, |
|
12528 isSelected: isSelected, |
|
12529 attributes: attributes, |
|
12530 setAttributes: _this3.setAttributes, |
|
12531 insertBlocksAfter: isLocked ? undefined : _this3.props.onInsertBlocksAfter, |
|
12532 onReplace: isLocked ? undefined : onReplace, |
|
12533 mergeBlocks: isLocked ? undefined : _this3.props.onMerge, |
|
12534 clientId: clientId, |
|
12535 isSelectionEnabled: _this3.props.isSelectionEnabled, |
|
12536 toggleSelection: _this3.props.toggleSelection |
|
12537 }); |
|
12538 |
|
12539 if (mode !== 'visual') { |
|
12540 blockEdit = Object(external_this_wp_element_["createElement"])("div", { |
|
12541 style: { |
|
12542 display: 'none' |
|
12543 } |
|
12544 }, blockEdit); |
|
12545 } // Disable reasons: |
|
12546 // |
|
12547 // jsx-a11y/mouse-events-have-key-events: |
|
12548 // - onMouseOver is explicitly handling hover effects |
|
12549 // |
|
12550 // jsx-a11y/no-static-element-interactions: |
|
12551 // - Each block can be selected by clicking on it |
|
12552 |
|
12553 /* eslint-disable jsx-a11y/mouse-events-have-key-events, jsx-a11y/no-static-element-interactions, jsx-a11y/onclick-has-role, jsx-a11y/click-events-have-key-events */ |
|
12554 |
|
12555 |
|
12556 return Object(external_this_wp_element_["createElement"])(ignore_nested_events, Object(esm_extends["a" /* default */])({ |
|
12557 id: blockElementId, |
|
12558 ref: _this3.setBlockListRef, |
|
12559 onMouseOver: _this3.maybeHover, |
|
12560 onMouseOverHandled: _this3.hideHoverEffects, |
|
12561 onMouseLeave: _this3.hideHoverEffects, |
|
12562 className: wrapperClassName, |
|
12563 "data-type": name, |
|
12564 onTouchStart: _this3.onTouchStart, |
|
12565 onFocus: _this3.onFocus, |
|
12566 onClick: _this3.onClick, |
|
12567 onKeyDown: _this3.deleteOrInsertAfterWrapper, |
|
12568 tabIndex: "0", |
|
12569 "aria-label": blockLabel, |
|
12570 childHandledEvents: ['onDragStart', 'onMouseDown'] |
|
12571 }, wrapperProps), shouldShowInsertionPoint && Object(external_this_wp_element_["createElement"])(insertion_point, { |
|
12572 clientId: clientId, |
|
12573 rootClientId: rootClientId |
|
12574 }), Object(external_this_wp_element_["createElement"])(block_drop_zone, { |
|
12575 clientId: clientId, |
|
12576 rootClientId: rootClientId |
|
12577 }), isFirstMultiSelected && Object(external_this_wp_element_["createElement"])(multi_controls, { |
|
12578 rootClientId: rootClientId |
|
12579 }), Object(external_this_wp_element_["createElement"])("div", { |
|
12580 className: "editor-block-list__block-edit block-editor-block-list__block-edit" |
|
12581 }, shouldRenderMovers && Object(external_this_wp_element_["createElement"])(block_mover, { |
|
12582 clientIds: clientId, |
|
12583 blockElementId: blockElementId, |
|
12584 isFirst: isFirst, |
|
12585 isLast: isLast, |
|
12586 isHidden: !(isHovered || isSelected) || hoverArea !== 'left', |
|
12587 isDraggable: isDraggable !== false && !isPartOfMultiSelection && isMovable, |
|
12588 onDragStart: _this3.onDragStart, |
|
12589 onDragEnd: _this3.onDragEnd |
|
12590 }), shouldShowBreadcrumb && Object(external_this_wp_element_["createElement"])(breadcrumb, { |
|
12591 clientId: clientId, |
|
12592 isHidden: !(isHovered || isSelected) || hoverArea !== 'left' |
|
12593 }), (shouldShowContextualToolbar || _this3.isForcingContextualToolbar) && Object(external_this_wp_element_["createElement"])(block_contextual_toolbar // If the toolbar is being shown because of being forced |
|
12594 // it should focus the toolbar right after the mount. |
|
12595 , { |
|
12596 focusOnMount: _this3.isForcingContextualToolbar |
|
12597 }), !shouldShowContextualToolbar && isSelected && !hasFixedToolbar && !isEmptyDefaultBlock && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["KeyboardShortcuts"], { |
|
12598 bindGlobal: true, |
|
12599 eventName: "keydown", |
|
12600 shortcuts: { |
|
12601 'alt+f10': _this3.forceFocusedContextualToolbar |
|
12602 } |
|
12603 }), Object(external_this_wp_element_["createElement"])(ignore_nested_events, { |
|
12604 ref: _this3.bindBlockNode, |
|
12605 onDragStart: _this3.preventDrag, |
|
12606 onMouseDown: _this3.onPointerDown, |
|
12607 "data-block": clientId |
|
12608 }, Object(external_this_wp_element_["createElement"])(block_crash_boundary, { |
|
12609 onError: _this3.onBlockError |
|
12610 }, isValid && blockEdit, isValid && mode === 'html' && Object(external_this_wp_element_["createElement"])(block_html, { |
|
12611 clientId: clientId |
|
12612 }), !isValid && [Object(external_this_wp_element_["createElement"])(block_invalid_warning, { |
|
12613 key: "invalid-warning", |
|
12614 clientId: clientId |
|
12615 }), Object(external_this_wp_element_["createElement"])("div", { |
|
12616 key: "invalid-preview" |
|
12617 }, Object(external_this_wp_blocks_["getSaveElement"])(blockType, attributes))]), shouldShowMobileToolbar && Object(external_this_wp_element_["createElement"])(block_mobile_toolbar, { |
|
12618 clientId: clientId |
|
12619 }), !!error && Object(external_this_wp_element_["createElement"])(block_crash_warning, null))), showEmptyBlockSideInserter && Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])("div", { |
|
12620 className: "editor-block-list__side-inserter block-editor-block-list__side-inserter" |
|
12621 }, Object(external_this_wp_element_["createElement"])(inserter_with_shortcuts, { |
|
12622 clientId: clientId, |
|
12623 rootClientId: rootClientId, |
|
12624 onToggle: _this3.selectOnOpen |
|
12625 })), Object(external_this_wp_element_["createElement"])("div", { |
|
12626 className: "editor-block-list__empty-block-inserter block-editor-block-list__empty-block-inserter" |
|
12627 }, Object(external_this_wp_element_["createElement"])(inserter, { |
|
12628 position: "top right", |
|
12629 onToggle: _this3.selectOnOpen, |
|
12630 rootClientId: rootClientId, |
|
12631 clientId: clientId |
|
12632 })))); |
|
12633 /* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/onclick-has-role, jsx-a11y/click-events-have-key-events */ |
|
12634 }); |
|
12635 } |
|
12636 }]); |
|
12637 |
|
12638 return BlockListBlock; |
|
12639 }(external_this_wp_element_["Component"]); |
|
12640 var applyWithSelect = Object(external_this_wp_data_["withSelect"])(function (select, _ref2) { |
|
12641 var clientId = _ref2.clientId, |
|
12642 rootClientId = _ref2.rootClientId, |
|
12643 isLargeViewport = _ref2.isLargeViewport; |
|
12644 |
|
12645 var _select = select('core/block-editor'), |
|
12646 isBlockSelected = _select.isBlockSelected, |
|
12647 isAncestorMultiSelected = _select.isAncestorMultiSelected, |
|
12648 isBlockMultiSelected = _select.isBlockMultiSelected, |
|
12649 isFirstMultiSelectedBlock = _select.isFirstMultiSelectedBlock, |
|
12650 isTyping = _select.isTyping, |
|
12651 isCaretWithinFormattedText = _select.isCaretWithinFormattedText, |
|
12652 getBlockMode = _select.getBlockMode, |
|
12653 isSelectionEnabled = _select.isSelectionEnabled, |
|
12654 getSelectedBlocksInitialCaretPosition = _select.getSelectedBlocksInitialCaretPosition, |
|
12655 getSettings = _select.getSettings, |
|
12656 hasSelectedInnerBlock = _select.hasSelectedInnerBlock, |
|
12657 getTemplateLock = _select.getTemplateLock, |
|
12658 __unstableGetBlockWithoutInnerBlocks = _select.__unstableGetBlockWithoutInnerBlocks; |
|
12659 |
|
12660 var block = __unstableGetBlockWithoutInnerBlocks(clientId); |
|
12661 |
|
12662 var isSelected = isBlockSelected(clientId); |
|
12663 |
|
12664 var _getSettings = getSettings(), |
|
12665 hasFixedToolbar = _getSettings.hasFixedToolbar, |
|
12666 focusMode = _getSettings.focusMode; |
|
12667 |
|
12668 var templateLock = getTemplateLock(rootClientId); |
|
12669 var isParentOfSelectedBlock = hasSelectedInnerBlock(clientId, true); // The fallback to `{}` is a temporary fix. |
|
12670 // This function should never be called when a block is not present in the state. |
|
12671 // It happens now because the order in withSelect rendering is not correct. |
|
12672 |
|
12673 var _ref3 = block || {}, |
|
12674 name = _ref3.name, |
|
12675 attributes = _ref3.attributes, |
|
12676 isValid = _ref3.isValid; |
|
12677 |
|
12678 return { |
|
12679 isPartOfMultiSelection: isBlockMultiSelected(clientId) || isAncestorMultiSelected(clientId), |
|
12680 isFirstMultiSelected: isFirstMultiSelectedBlock(clientId), |
|
12681 // We only care about this prop when the block is selected |
|
12682 // Thus to avoid unnecessary rerenders we avoid updating the prop if the block is not selected. |
|
12683 isTypingWithinBlock: (isSelected || isParentOfSelectedBlock) && isTyping(), |
|
12684 isCaretWithinFormattedText: isCaretWithinFormattedText(), |
|
12685 mode: getBlockMode(clientId), |
|
12686 isSelectionEnabled: isSelectionEnabled(), |
|
12687 initialPosition: isSelected ? getSelectedBlocksInitialCaretPosition() : null, |
|
12688 isEmptyDefaultBlock: name && Object(external_this_wp_blocks_["isUnmodifiedDefaultBlock"])({ |
|
12689 name: name, |
|
12690 attributes: attributes |
|
12691 }), |
|
12692 isMovable: 'all' !== templateLock, |
|
12693 isLocked: !!templateLock, |
|
12694 isFocusMode: focusMode && isLargeViewport, |
|
12695 hasFixedToolbar: hasFixedToolbar && isLargeViewport, |
|
12696 // Users of the editor.BlockListBlock filter used to be able to access the block prop |
|
12697 // Ideally these blocks would rely on the clientId prop only. |
|
12698 // This is kept for backward compatibility reasons. |
|
12699 block: block, |
|
12700 name: name, |
|
12701 attributes: attributes, |
|
12702 isValid: isValid, |
|
12703 isSelected: isSelected, |
|
12704 isParentOfSelectedBlock: isParentOfSelectedBlock |
|
12705 }; |
|
12706 }); |
|
12707 var applyWithDispatch = Object(external_this_wp_data_["withDispatch"])(function (dispatch, ownProps, _ref4) { |
|
12708 var select = _ref4.select; |
|
12709 |
|
12710 var _dispatch = dispatch('core/block-editor'), |
|
12711 updateBlockAttributes = _dispatch.updateBlockAttributes, |
|
12712 selectBlock = _dispatch.selectBlock, |
|
12713 multiSelect = _dispatch.multiSelect, |
|
12714 insertBlocks = _dispatch.insertBlocks, |
|
12715 insertDefaultBlock = _dispatch.insertDefaultBlock, |
|
12716 removeBlock = _dispatch.removeBlock, |
|
12717 mergeBlocks = _dispatch.mergeBlocks, |
|
12718 replaceBlocks = _dispatch.replaceBlocks, |
|
12719 _toggleSelection = _dispatch.toggleSelection; |
|
12720 |
|
12721 return { |
|
12722 onChange: function onChange(clientId, attributes) { |
|
12723 updateBlockAttributes(clientId, attributes); |
|
12724 }, |
|
12725 onSelect: function onSelect() { |
|
12726 var clientId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ownProps.clientId; |
|
12727 var initialPosition = arguments.length > 1 ? arguments[1] : undefined; |
|
12728 selectBlock(clientId, initialPosition); |
|
12729 }, |
|
12730 onInsertBlocks: function onInsertBlocks(blocks, index) { |
|
12731 var rootClientId = ownProps.rootClientId; |
|
12732 insertBlocks(blocks, index, rootClientId); |
|
12733 }, |
|
12734 onInsertDefaultBlockAfter: function onInsertDefaultBlockAfter() { |
|
12735 var clientId = ownProps.clientId, |
|
12736 rootClientId = ownProps.rootClientId; |
|
12737 |
|
12738 var _select2 = select('core/block-editor'), |
|
12739 getBlockIndex = _select2.getBlockIndex; |
|
12740 |
|
12741 var index = getBlockIndex(clientId, rootClientId); |
|
12742 insertDefaultBlock({}, rootClientId, index + 1); |
|
12743 }, |
|
12744 onInsertBlocksAfter: function onInsertBlocksAfter(blocks) { |
|
12745 var clientId = ownProps.clientId, |
|
12746 rootClientId = ownProps.rootClientId; |
|
12747 |
|
12748 var _select3 = select('core/block-editor'), |
|
12749 getBlockIndex = _select3.getBlockIndex; |
|
12750 |
|
12751 var index = getBlockIndex(clientId, rootClientId); |
|
12752 insertBlocks(blocks, index + 1, rootClientId); |
|
12753 }, |
|
12754 onRemove: function onRemove(clientId) { |
|
12755 removeBlock(clientId); |
|
12756 }, |
|
12757 onMerge: function onMerge(forward) { |
|
12758 var clientId = ownProps.clientId; |
|
12759 |
|
12760 var _select4 = select('core/block-editor'), |
|
12761 getPreviousBlockClientId = _select4.getPreviousBlockClientId, |
|
12762 getNextBlockClientId = _select4.getNextBlockClientId; |
|
12763 |
|
12764 if (forward) { |
|
12765 var nextBlockClientId = getNextBlockClientId(clientId); |
|
12766 |
|
12767 if (nextBlockClientId) { |
|
12768 mergeBlocks(clientId, nextBlockClientId); |
|
12769 } |
|
12770 } else { |
|
12771 var previousBlockClientId = getPreviousBlockClientId(clientId); |
|
12772 |
|
12773 if (previousBlockClientId) { |
|
12774 mergeBlocks(previousBlockClientId, clientId); |
|
12775 } |
|
12776 } |
|
12777 }, |
|
12778 onReplace: function onReplace(blocks) { |
|
12779 replaceBlocks([ownProps.clientId], blocks); |
|
12780 }, |
|
12781 onMetaChange: function onMetaChange(updatedMeta) { |
|
12782 var _select5 = select('core/block-editor'), |
|
12783 getSettings = _select5.getSettings; |
|
12784 |
|
12785 var onChangeMeta = getSettings().__experimentalMetaSource.onChange; |
|
12786 |
|
12787 onChangeMeta(updatedMeta); |
|
12788 }, |
|
12789 onShiftSelection: function onShiftSelection() { |
|
12790 if (!ownProps.isSelectionEnabled) { |
|
12791 return; |
|
12792 } |
|
12793 |
|
12794 var _select6 = select('core/block-editor'), |
|
12795 getBlockSelectionStart = _select6.getBlockSelectionStart; |
|
12796 |
|
12797 if (getBlockSelectionStart()) { |
|
12798 multiSelect(getBlockSelectionStart(), ownProps.clientId); |
|
12799 } else { |
|
12800 selectBlock(ownProps.clientId); |
|
12801 } |
|
12802 }, |
|
12803 toggleSelection: function toggleSelection(selectionEnabled) { |
|
12804 _toggleSelection(selectionEnabled); |
|
12805 } |
|
12806 }; |
|
12807 }); |
|
12808 /* harmony default export */ var block_list_block = (Object(external_this_wp_compose_["compose"])(external_this_wp_compose_["pure"], Object(external_this_wp_viewport_["withViewportMatch"])({ |
|
12809 isLargeViewport: 'medium' |
|
12810 }), applyWithSelect, applyWithDispatch, Object(external_this_wp_components_["withFilters"])('editor.BlockListBlock'))(block_BlockListBlock)); |
|
12811 |
|
12812 // EXTERNAL MODULE: external {"this":["wp","htmlEntities"]} |
|
12813 var external_this_wp_htmlEntities_ = __webpack_require__(57); |
|
12814 |
|
12815 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/default-block-appender/index.js |
|
12816 |
|
12817 |
|
12818 /** |
|
12819 * External dependencies |
|
12820 */ |
|
12821 |
|
12822 /** |
|
12823 * WordPress dependencies |
|
12824 */ |
|
12825 |
|
12826 |
|
12827 |
|
12828 |
|
12829 |
|
12830 |
|
12831 /** |
|
12832 * Internal dependencies |
|
12833 */ |
|
12834 |
|
12835 |
|
12836 |
|
12837 |
|
12838 function DefaultBlockAppender(_ref) { |
|
12839 var isLocked = _ref.isLocked, |
|
12840 isVisible = _ref.isVisible, |
|
12841 onAppend = _ref.onAppend, |
|
12842 showPrompt = _ref.showPrompt, |
|
12843 placeholder = _ref.placeholder, |
|
12844 rootClientId = _ref.rootClientId, |
|
12845 hovered = _ref.hovered, |
|
12846 setState = _ref.setState; |
|
12847 |
|
12848 if (isLocked || !isVisible) { |
|
12849 return null; |
|
12850 } |
|
12851 |
|
12852 var value = Object(external_this_wp_htmlEntities_["decodeEntities"])(placeholder) || Object(external_this_wp_i18n_["__"])('Start writing or type / to choose a block'); // The appender "button" is in-fact a text field so as to support |
|
12853 // transitions by WritingFlow occurring by arrow key press. WritingFlow |
|
12854 // only supports tab transitions into text fields and to the block focus |
|
12855 // boundary. |
|
12856 // |
|
12857 // See: https://github.com/WordPress/gutenberg/issues/4829#issuecomment-374213658 |
|
12858 // |
|
12859 // If it were ever to be made to be a proper `button` element, it is |
|
12860 // important to note that `onFocus` alone would not be sufficient to |
|
12861 // capture click events, notably in Firefox. |
|
12862 // |
|
12863 // See: https://gist.github.com/cvrebert/68659d0333a578d75372 |
|
12864 // The wp-block className is important for editor styles. |
|
12865 |
|
12866 |
|
12867 return Object(external_this_wp_element_["createElement"])("div", { |
|
12868 "data-root-client-id": rootClientId || '', |
|
12869 className: "wp-block editor-default-block-appender block-editor-default-block-appender", |
|
12870 onMouseEnter: function onMouseEnter() { |
|
12871 return setState({ |
|
12872 hovered: true |
|
12873 }); |
|
12874 }, |
|
12875 onMouseLeave: function onMouseLeave() { |
|
12876 return setState({ |
|
12877 hovered: false |
|
12878 }); |
|
12879 } |
|
12880 }, Object(external_this_wp_element_["createElement"])(block_drop_zone, { |
|
12881 rootClientId: rootClientId |
|
12882 }), Object(external_this_wp_element_["createElement"])(react_autosize_textarea_lib_default.a, { |
|
12883 role: "button", |
|
12884 "aria-label": Object(external_this_wp_i18n_["__"])('Add block'), |
|
12885 className: "editor-default-block-appender__content block-editor-default-block-appender__content", |
|
12886 readOnly: true, |
|
12887 onFocus: onAppend, |
|
12888 value: showPrompt ? value : '' |
|
12889 }), hovered && Object(external_this_wp_element_["createElement"])(inserter_with_shortcuts, { |
|
12890 rootClientId: rootClientId |
|
12891 }), Object(external_this_wp_element_["createElement"])(inserter, { |
|
12892 rootClientId: rootClientId, |
|
12893 position: "top right", |
|
12894 isAppender: true |
|
12895 })); |
|
12896 } |
|
12897 /* harmony default export */ var default_block_appender = (Object(external_this_wp_compose_["compose"])(Object(external_this_wp_compose_["withState"])({ |
|
12898 hovered: false |
|
12899 }), Object(external_this_wp_data_["withSelect"])(function (select, ownProps) { |
|
12900 var _select = select('core/block-editor'), |
|
12901 getBlockCount = _select.getBlockCount, |
|
12902 getBlockName = _select.getBlockName, |
|
12903 isBlockValid = _select.isBlockValid, |
|
12904 getSettings = _select.getSettings, |
|
12905 getTemplateLock = _select.getTemplateLock; |
|
12906 |
|
12907 var isEmpty = !getBlockCount(ownProps.rootClientId); |
|
12908 var isLastBlockDefault = getBlockName(ownProps.lastBlockClientId) === Object(external_this_wp_blocks_["getDefaultBlockName"])(); |
|
12909 var isLastBlockValid = isBlockValid(ownProps.lastBlockClientId); |
|
12910 |
|
12911 var _getSettings = getSettings(), |
|
12912 bodyPlaceholder = _getSettings.bodyPlaceholder; |
|
12913 |
|
12914 return { |
|
12915 isVisible: isEmpty || !isLastBlockDefault || !isLastBlockValid, |
|
12916 showPrompt: isEmpty, |
|
12917 isLocked: !!getTemplateLock(ownProps.rootClientId), |
|
12918 placeholder: bodyPlaceholder |
|
12919 }; |
|
12920 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, ownProps) { |
|
12921 var _dispatch = dispatch('core/block-editor'), |
|
12922 insertDefaultBlock = _dispatch.insertDefaultBlock, |
|
12923 startTyping = _dispatch.startTyping; |
|
12924 |
|
12925 return { |
|
12926 onAppend: function onAppend() { |
|
12927 var rootClientId = ownProps.rootClientId; |
|
12928 insertDefaultBlock(undefined, rootClientId); |
|
12929 startTyping(); |
|
12930 } |
|
12931 }; |
|
12932 }))(DefaultBlockAppender)); |
|
12933 |
|
12934 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list-appender/index.js |
|
12935 |
|
12936 |
|
12937 /** |
|
12938 * External dependencies |
|
12939 */ |
|
12940 |
|
12941 /** |
|
12942 * WordPress dependencies |
|
12943 */ |
|
12944 |
|
12945 |
|
12946 |
|
12947 |
|
12948 |
|
12949 /** |
|
12950 * Internal dependencies |
|
12951 */ |
|
12952 |
|
12953 |
|
12954 |
|
12955 |
|
12956 |
|
12957 function BlockListAppender(_ref) { |
|
12958 var blockClientIds = _ref.blockClientIds, |
|
12959 rootClientId = _ref.rootClientId, |
|
12960 canInsertDefaultBlock = _ref.canInsertDefaultBlock, |
|
12961 isLocked = _ref.isLocked; |
|
12962 |
|
12963 if (isLocked) { |
|
12964 return null; |
|
12965 } |
|
12966 |
|
12967 if (canInsertDefaultBlock) { |
|
12968 return Object(external_this_wp_element_["createElement"])(ignore_nested_events, { |
|
12969 childHandledEvents: ['onFocus', 'onClick', 'onKeyDown'] |
|
12970 }, Object(external_this_wp_element_["createElement"])(default_block_appender, { |
|
12971 rootClientId: rootClientId, |
|
12972 lastBlockClientId: Object(external_lodash_["last"])(blockClientIds) |
|
12973 })); |
|
12974 } |
|
12975 |
|
12976 return Object(external_this_wp_element_["createElement"])("div", { |
|
12977 className: "block-list-appender" |
|
12978 }, Object(external_this_wp_element_["createElement"])(inserter, { |
|
12979 rootClientId: rootClientId, |
|
12980 renderToggle: function renderToggle(_ref2) { |
|
12981 var onToggle = _ref2.onToggle, |
|
12982 disabled = _ref2.disabled, |
|
12983 isOpen = _ref2.isOpen; |
|
12984 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], { |
|
12985 label: Object(external_this_wp_i18n_["__"])('Add block'), |
|
12986 icon: "insert", |
|
12987 onClick: onToggle, |
|
12988 className: "block-list-appender__toggle", |
|
12989 "aria-haspopup": "true", |
|
12990 "aria-expanded": isOpen, |
|
12991 disabled: disabled |
|
12992 }); |
|
12993 }, |
|
12994 isAppender: true |
|
12995 })); |
|
12996 } |
|
12997 |
|
12998 /* harmony default export */ var block_list_appender = (Object(external_this_wp_data_["withSelect"])(function (select, _ref3) { |
|
12999 var rootClientId = _ref3.rootClientId; |
|
13000 |
|
13001 var _select = select('core/block-editor'), |
|
13002 getBlockOrder = _select.getBlockOrder, |
|
13003 canInsertBlockType = _select.canInsertBlockType, |
|
13004 getTemplateLock = _select.getTemplateLock; |
|
13005 |
|
13006 return { |
|
13007 isLocked: !!getTemplateLock(rootClientId), |
|
13008 blockClientIds: getBlockOrder(rootClientId), |
|
13009 canInsertDefaultBlock: canInsertBlockType(Object(external_this_wp_blocks_["getDefaultBlockName"])(), rootClientId) |
|
13010 }; |
|
13011 })(BlockListAppender)); |
|
13012 |
|
13013 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/index.js |
|
13014 |
|
13015 |
|
13016 |
|
13017 |
|
13018 |
|
13019 |
|
13020 |
|
13021 |
|
13022 |
|
13023 |
|
13024 /** |
|
13025 * External dependencies |
|
13026 */ |
|
13027 |
|
13028 /** |
|
13029 * WordPress dependencies |
|
13030 */ |
|
13031 |
|
13032 |
|
13033 |
|
13034 |
|
13035 /** |
|
13036 * Internal dependencies |
|
13037 */ |
|
13038 |
|
13039 |
|
13040 |
|
13041 |
|
13042 |
|
13043 var block_list_forceSyncUpdates = function forceSyncUpdates(WrappedComponent) { |
|
13044 return function (props) { |
|
13045 return Object(external_this_wp_element_["createElement"])(external_this_wp_data_["__experimentalAsyncModeProvider"], { |
|
13046 value: false |
|
13047 }, Object(external_this_wp_element_["createElement"])(WrappedComponent, props)); |
|
13048 }; |
|
13049 }; |
|
13050 |
|
13051 var block_list_BlockList = |
|
13052 /*#__PURE__*/ |
|
13053 function (_Component) { |
|
13054 Object(inherits["a" /* default */])(BlockList, _Component); |
|
13055 |
|
13056 function BlockList(props) { |
|
13057 var _this; |
|
13058 |
|
13059 Object(classCallCheck["a" /* default */])(this, BlockList); |
|
13060 |
|
13061 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(BlockList).call(this, props)); |
|
13062 _this.onSelectionStart = _this.onSelectionStart.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
13063 _this.onSelectionEnd = _this.onSelectionEnd.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
13064 _this.setBlockRef = _this.setBlockRef.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
13065 _this.setLastClientY = _this.setLastClientY.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
13066 _this.onPointerMove = Object(external_lodash_["throttle"])(_this.onPointerMove.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))), 100); // Browser does not fire `*move` event when the pointer position changes |
|
13067 // relative to the document, so fire it with the last known position. |
|
13068 |
|
13069 _this.onScroll = function () { |
|
13070 return _this.onPointerMove({ |
|
13071 clientY: _this.lastClientY |
|
13072 }); |
|
13073 }; |
|
13074 |
|
13075 _this.lastClientY = 0; |
|
13076 _this.nodes = {}; |
|
13077 return _this; |
|
13078 } |
|
13079 |
|
13080 Object(createClass["a" /* default */])(BlockList, [{ |
|
13081 key: "componentDidMount", |
|
13082 value: function componentDidMount() { |
|
13083 window.addEventListener('mousemove', this.setLastClientY); |
|
13084 } |
|
13085 }, { |
|
13086 key: "componentWillUnmount", |
|
13087 value: function componentWillUnmount() { |
|
13088 window.removeEventListener('mousemove', this.setLastClientY); |
|
13089 } |
|
13090 }, { |
|
13091 key: "setLastClientY", |
|
13092 value: function setLastClientY(_ref) { |
|
13093 var clientY = _ref.clientY; |
|
13094 this.lastClientY = clientY; |
|
13095 } |
|
13096 }, { |
|
13097 key: "setBlockRef", |
|
13098 value: function setBlockRef(node, clientId) { |
|
13099 if (node === null) { |
|
13100 delete this.nodes[clientId]; |
|
13101 } else { |
|
13102 this.nodes = Object(objectSpread["a" /* default */])({}, this.nodes, Object(defineProperty["a" /* default */])({}, clientId, node)); |
|
13103 } |
|
13104 } |
|
13105 /** |
|
13106 * Handles a pointer move event to update the extent of the current cursor |
|
13107 * multi-selection. |
|
13108 * |
|
13109 * @param {MouseEvent} event A mousemove event object. |
|
13110 * |
|
13111 * @return {void} |
|
13112 */ |
|
13113 |
|
13114 }, { |
|
13115 key: "onPointerMove", |
|
13116 value: function onPointerMove(_ref2) { |
|
13117 var clientY = _ref2.clientY; |
|
13118 |
|
13119 // We don't start multi-selection until the mouse starts moving, so as |
|
13120 // to avoid dispatching multi-selection actions on an in-place click. |
|
13121 if (!this.props.isMultiSelecting) { |
|
13122 this.props.onStartMultiSelect(); |
|
13123 } |
|
13124 |
|
13125 var blockContentBoundaries = getBlockDOMNode(this.selectionAtStart).getBoundingClientRect(); // prevent multi-selection from triggering when the selected block is a float |
|
13126 // and the cursor is still between the top and the bottom of the block. |
|
13127 |
|
13128 if (clientY >= blockContentBoundaries.top && clientY <= blockContentBoundaries.bottom) { |
|
13129 return; |
|
13130 } |
|
13131 |
|
13132 var y = clientY - blockContentBoundaries.top; |
|
13133 var key = Object(external_lodash_["findLast"])(this.coordMapKeys, function (coordY) { |
|
13134 return coordY < y; |
|
13135 }); |
|
13136 this.onSelectionChange(this.coordMap[key]); |
|
13137 } |
|
13138 /** |
|
13139 * Binds event handlers to the document for tracking a pending multi-select |
|
13140 * in response to a mousedown event occurring in a rendered block. |
|
13141 * |
|
13142 * @param {string} clientId Client ID of block where mousedown occurred. |
|
13143 * |
|
13144 * @return {void} |
|
13145 */ |
|
13146 |
|
13147 }, { |
|
13148 key: "onSelectionStart", |
|
13149 value: function onSelectionStart(clientId) { |
|
13150 if (!this.props.isSelectionEnabled) { |
|
13151 return; |
|
13152 } |
|
13153 |
|
13154 var boundaries = this.nodes[clientId].getBoundingClientRect(); // Create a clientId to Y coördinate map. |
|
13155 |
|
13156 var clientIdToCoordMap = Object(external_lodash_["mapValues"])(this.nodes, function (node) { |
|
13157 return node.getBoundingClientRect().top - boundaries.top; |
|
13158 }); // Cache a Y coördinate to clientId map for use in `onPointerMove`. |
|
13159 |
|
13160 this.coordMap = Object(external_lodash_["invert"])(clientIdToCoordMap); // Cache an array of the Y coördinates for use in `onPointerMove`. |
|
13161 // Sort the coördinates, as `this.nodes` will not necessarily reflect |
|
13162 // the current block sequence. |
|
13163 |
|
13164 this.coordMapKeys = Object(external_lodash_["sortBy"])(Object.values(clientIdToCoordMap)); |
|
13165 this.selectionAtStart = clientId; |
|
13166 window.addEventListener('mousemove', this.onPointerMove); // Capture scroll on all elements. |
|
13167 |
|
13168 window.addEventListener('scroll', this.onScroll, true); |
|
13169 window.addEventListener('mouseup', this.onSelectionEnd); |
|
13170 } |
|
13171 /** |
|
13172 * Handles multi-selection changes in response to pointer move. |
|
13173 * |
|
13174 * @param {string} clientId Client ID of block under cursor in multi-select |
|
13175 * drag. |
|
13176 */ |
|
13177 |
|
13178 }, { |
|
13179 key: "onSelectionChange", |
|
13180 value: function onSelectionChange(clientId) { |
|
13181 var _this$props = this.props, |
|
13182 onMultiSelect = _this$props.onMultiSelect, |
|
13183 selectionStart = _this$props.selectionStart, |
|
13184 selectionEnd = _this$props.selectionEnd; |
|
13185 var selectionAtStart = this.selectionAtStart; |
|
13186 var isAtStart = selectionAtStart === clientId; |
|
13187 |
|
13188 if (!selectionAtStart || !this.props.isSelectionEnabled) { |
|
13189 return; |
|
13190 } // If multi-selecting and cursor extent returns to the start of |
|
13191 // selection, cancel multi-select. |
|
13192 |
|
13193 |
|
13194 if (isAtStart && selectionStart) { |
|
13195 onMultiSelect(null, null); |
|
13196 } // Expand multi-selection to block under cursor. |
|
13197 |
|
13198 |
|
13199 if (!isAtStart && selectionEnd !== clientId) { |
|
13200 onMultiSelect(selectionAtStart, clientId); |
|
13201 } |
|
13202 } |
|
13203 /** |
|
13204 * Handles a mouseup event to end the current cursor multi-selection. |
|
13205 * |
|
13206 * @return {void} |
|
13207 */ |
|
13208 |
|
13209 }, { |
|
13210 key: "onSelectionEnd", |
|
13211 value: function onSelectionEnd() { |
|
13212 // Cancel throttled calls. |
|
13213 this.onPointerMove.cancel(); |
|
13214 delete this.coordMap; |
|
13215 delete this.coordMapKeys; |
|
13216 delete this.selectionAtStart; |
|
13217 window.removeEventListener('mousemove', this.onPointerMove); |
|
13218 window.removeEventListener('scroll', this.onScroll, true); |
|
13219 window.removeEventListener('mouseup', this.onSelectionEnd); // We may or may not be in a multi-selection when mouseup occurs (e.g. |
|
13220 // an in-place mouse click), so only trigger stop if multi-selecting. |
|
13221 |
|
13222 if (this.props.isMultiSelecting) { |
|
13223 this.props.onStopMultiSelect(); |
|
13224 } |
|
13225 } |
|
13226 }, { |
|
13227 key: "render", |
|
13228 value: function render() { |
|
13229 var _this2 = this; |
|
13230 |
|
13231 var _this$props2 = this.props, |
|
13232 blockClientIds = _this$props2.blockClientIds, |
|
13233 rootClientId = _this$props2.rootClientId, |
|
13234 isDraggable = _this$props2.isDraggable, |
|
13235 selectedBlockClientId = _this$props2.selectedBlockClientId, |
|
13236 multiSelectedBlockClientIds = _this$props2.multiSelectedBlockClientIds, |
|
13237 hasMultiSelection = _this$props2.hasMultiSelection; |
|
13238 return Object(external_this_wp_element_["createElement"])("div", { |
|
13239 className: "editor-block-list__layout block-editor-block-list__layout" |
|
13240 }, Object(external_lodash_["map"])(blockClientIds, function (clientId, blockIndex) { |
|
13241 var isBlockInSelection = hasMultiSelection ? multiSelectedBlockClientIds.includes(clientId) : selectedBlockClientId === clientId; |
|
13242 return Object(external_this_wp_element_["createElement"])(external_this_wp_data_["__experimentalAsyncModeProvider"], { |
|
13243 key: 'block-' + clientId, |
|
13244 value: !isBlockInSelection |
|
13245 }, Object(external_this_wp_element_["createElement"])(block_list_block, { |
|
13246 clientId: clientId, |
|
13247 blockRef: _this2.setBlockRef, |
|
13248 onSelectionStart: _this2.onSelectionStart, |
|
13249 rootClientId: rootClientId, |
|
13250 isFirst: blockIndex === 0, |
|
13251 isLast: blockIndex === blockClientIds.length - 1, |
|
13252 isDraggable: isDraggable |
|
13253 })); |
|
13254 }), Object(external_this_wp_element_["createElement"])(block_list_appender, { |
|
13255 rootClientId: rootClientId |
|
13256 })); |
|
13257 } |
|
13258 }]); |
|
13259 |
|
13260 return BlockList; |
|
13261 }(external_this_wp_element_["Component"]); |
|
13262 |
|
13263 /* harmony default export */ var block_list = (Object(external_this_wp_compose_["compose"])([// This component needs to always be synchronous |
|
13264 // as it's the one changing the async mode |
|
13265 // depending on the block selection. |
|
13266 block_list_forceSyncUpdates, Object(external_this_wp_data_["withSelect"])(function (select, ownProps) { |
|
13267 var _select = select('core/block-editor'), |
|
13268 getBlockOrder = _select.getBlockOrder, |
|
13269 isSelectionEnabled = _select.isSelectionEnabled, |
|
13270 isMultiSelecting = _select.isMultiSelecting, |
|
13271 getMultiSelectedBlocksStartClientId = _select.getMultiSelectedBlocksStartClientId, |
|
13272 getMultiSelectedBlocksEndClientId = _select.getMultiSelectedBlocksEndClientId, |
|
13273 getSelectedBlockClientId = _select.getSelectedBlockClientId, |
|
13274 getMultiSelectedBlockClientIds = _select.getMultiSelectedBlockClientIds, |
|
13275 hasMultiSelection = _select.hasMultiSelection; |
|
13276 |
|
13277 var rootClientId = ownProps.rootClientId; |
|
13278 return { |
|
13279 blockClientIds: getBlockOrder(rootClientId), |
|
13280 selectionStart: getMultiSelectedBlocksStartClientId(), |
|
13281 selectionEnd: getMultiSelectedBlocksEndClientId(), |
|
13282 isSelectionEnabled: isSelectionEnabled(), |
|
13283 isMultiSelecting: isMultiSelecting(), |
|
13284 selectedBlockClientId: getSelectedBlockClientId(), |
|
13285 multiSelectedBlockClientIds: getMultiSelectedBlockClientIds(), |
|
13286 hasMultiSelection: hasMultiSelection() |
|
13287 }; |
|
13288 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
13289 var _dispatch = dispatch('core/block-editor'), |
|
13290 startMultiSelect = _dispatch.startMultiSelect, |
|
13291 stopMultiSelect = _dispatch.stopMultiSelect, |
|
13292 multiSelect = _dispatch.multiSelect; |
|
13293 |
|
13294 return { |
|
13295 onStartMultiSelect: startMultiSelect, |
|
13296 onStopMultiSelect: stopMultiSelect, |
|
13297 onMultiSelect: multiSelect |
|
13298 }; |
|
13299 })])(block_list_BlockList)); |
|
13300 |
|
13301 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/index.js |
|
13302 |
|
13303 |
|
13304 |
|
13305 |
|
13306 |
|
13307 |
|
13308 |
|
13309 /** |
|
13310 * External dependencies |
|
13311 */ |
|
13312 |
|
13313 |
|
13314 /** |
|
13315 * WordPress dependencies |
|
13316 */ |
|
13317 |
|
13318 |
|
13319 |
|
13320 |
|
13321 |
|
13322 |
|
13323 |
|
13324 /** |
|
13325 * Internal dependencies |
|
13326 */ |
|
13327 |
|
13328 |
|
13329 |
|
13330 |
|
13331 var inner_blocks_InnerBlocks = |
|
13332 /*#__PURE__*/ |
|
13333 function (_Component) { |
|
13334 Object(inherits["a" /* default */])(InnerBlocks, _Component); |
|
13335 |
|
13336 function InnerBlocks() { |
|
13337 var _this; |
|
13338 |
|
13339 Object(classCallCheck["a" /* default */])(this, InnerBlocks); |
|
13340 |
|
13341 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(InnerBlocks).apply(this, arguments)); |
|
13342 _this.state = { |
|
13343 templateInProcess: !!_this.props.template |
|
13344 }; |
|
13345 |
|
13346 _this.updateNestedSettings(); |
|
13347 |
|
13348 return _this; |
|
13349 } |
|
13350 |
|
13351 Object(createClass["a" /* default */])(InnerBlocks, [{ |
|
13352 key: "getTemplateLock", |
|
13353 value: function getTemplateLock() { |
|
13354 var _this$props = this.props, |
|
13355 templateLock = _this$props.templateLock, |
|
13356 parentLock = _this$props.parentLock; |
|
13357 return templateLock === undefined ? parentLock : templateLock; |
|
13358 } |
|
13359 }, { |
|
13360 key: "componentDidMount", |
|
13361 value: function componentDidMount() { |
|
13362 var innerBlocks = this.props.block.innerBlocks; // only synchronize innerBlocks with template if innerBlocks are empty or a locking all exists |
|
13363 |
|
13364 if (innerBlocks.length === 0 || this.getTemplateLock() === 'all') { |
|
13365 this.synchronizeBlocksWithTemplate(); |
|
13366 } |
|
13367 |
|
13368 if (this.state.templateInProcess) { |
|
13369 this.setState({ |
|
13370 templateInProcess: false |
|
13371 }); |
|
13372 } |
|
13373 } |
|
13374 }, { |
|
13375 key: "componentDidUpdate", |
|
13376 value: function componentDidUpdate(prevProps) { |
|
13377 var _this$props2 = this.props, |
|
13378 template = _this$props2.template, |
|
13379 block = _this$props2.block; |
|
13380 var innerBlocks = block.innerBlocks; |
|
13381 this.updateNestedSettings(); // only synchronize innerBlocks with template if innerBlocks are empty or a locking all exists |
|
13382 |
|
13383 if (innerBlocks.length === 0 || this.getTemplateLock() === 'all') { |
|
13384 var hasTemplateChanged = !Object(external_lodash_["isEqual"])(template, prevProps.template); |
|
13385 |
|
13386 if (hasTemplateChanged) { |
|
13387 this.synchronizeBlocksWithTemplate(); |
|
13388 } |
|
13389 } |
|
13390 } |
|
13391 /** |
|
13392 * Called on mount or when a mismatch exists between the templates and |
|
13393 * inner blocks, synchronizes inner blocks with the template, replacing |
|
13394 * current blocks. |
|
13395 */ |
|
13396 |
|
13397 }, { |
|
13398 key: "synchronizeBlocksWithTemplate", |
|
13399 value: function synchronizeBlocksWithTemplate() { |
|
13400 var _this$props3 = this.props, |
|
13401 template = _this$props3.template, |
|
13402 block = _this$props3.block, |
|
13403 replaceInnerBlocks = _this$props3.replaceInnerBlocks; |
|
13404 var innerBlocks = block.innerBlocks; // Synchronize with templates. If the next set differs, replace. |
|
13405 |
|
13406 var nextBlocks = Object(external_this_wp_blocks_["synchronizeBlocksWithTemplate"])(innerBlocks, template); |
|
13407 |
|
13408 if (!Object(external_lodash_["isEqual"])(nextBlocks, innerBlocks)) { |
|
13409 replaceInnerBlocks(nextBlocks); |
|
13410 } |
|
13411 } |
|
13412 }, { |
|
13413 key: "updateNestedSettings", |
|
13414 value: function updateNestedSettings() { |
|
13415 var _this$props4 = this.props, |
|
13416 blockListSettings = _this$props4.blockListSettings, |
|
13417 allowedBlocks = _this$props4.allowedBlocks, |
|
13418 updateNestedSettings = _this$props4.updateNestedSettings; |
|
13419 var newSettings = { |
|
13420 allowedBlocks: allowedBlocks, |
|
13421 templateLock: this.getTemplateLock() |
|
13422 }; |
|
13423 |
|
13424 if (!external_this_wp_isShallowEqual_default()(blockListSettings, newSettings)) { |
|
13425 updateNestedSettings(newSettings); |
|
13426 } |
|
13427 } |
|
13428 }, { |
|
13429 key: "render", |
|
13430 value: function render() { |
|
13431 var _this$props5 = this.props, |
|
13432 clientId = _this$props5.clientId, |
|
13433 isSmallScreen = _this$props5.isSmallScreen, |
|
13434 isSelectedBlockInRoot = _this$props5.isSelectedBlockInRoot; |
|
13435 var templateInProcess = this.state.templateInProcess; |
|
13436 var classes = classnames_default()('editor-inner-blocks block-editor-inner-blocks', { |
|
13437 'has-overlay': isSmallScreen && !isSelectedBlockInRoot |
|
13438 }); |
|
13439 return Object(external_this_wp_element_["createElement"])("div", { |
|
13440 className: classes |
|
13441 }, !templateInProcess && Object(external_this_wp_element_["createElement"])(block_list, { |
|
13442 rootClientId: clientId |
|
13443 })); |
|
13444 } |
|
13445 }]); |
|
13446 |
|
13447 return InnerBlocks; |
|
13448 }(external_this_wp_element_["Component"]); |
|
13449 |
|
13450 inner_blocks_InnerBlocks = Object(external_this_wp_compose_["compose"])([context_withBlockEditContext(function (context) { |
|
13451 return Object(external_lodash_["pick"])(context, ['clientId']); |
|
13452 }), Object(external_this_wp_viewport_["withViewportMatch"])({ |
|
13453 isSmallScreen: '< medium' |
|
13454 }), Object(external_this_wp_data_["withSelect"])(function (select, ownProps) { |
|
13455 var _select = select('core/block-editor'), |
|
13456 isBlockSelected = _select.isBlockSelected, |
|
13457 hasSelectedInnerBlock = _select.hasSelectedInnerBlock, |
|
13458 getBlock = _select.getBlock, |
|
13459 getBlockListSettings = _select.getBlockListSettings, |
|
13460 getBlockRootClientId = _select.getBlockRootClientId, |
|
13461 getTemplateLock = _select.getTemplateLock; |
|
13462 |
|
13463 var clientId = ownProps.clientId; |
|
13464 var rootClientId = getBlockRootClientId(clientId); |
|
13465 return { |
|
13466 isSelectedBlockInRoot: isBlockSelected(clientId) || hasSelectedInnerBlock(clientId), |
|
13467 block: getBlock(clientId), |
|
13468 blockListSettings: getBlockListSettings(clientId), |
|
13469 parentLock: getTemplateLock(rootClientId) |
|
13470 }; |
|
13471 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, ownProps) { |
|
13472 var _dispatch = dispatch('core/block-editor'), |
|
13473 _replaceInnerBlocks = _dispatch.replaceInnerBlocks, |
|
13474 updateBlockListSettings = _dispatch.updateBlockListSettings; |
|
13475 |
|
13476 var block = ownProps.block, |
|
13477 clientId = ownProps.clientId, |
|
13478 _ownProps$templateIns = ownProps.templateInsertUpdatesSelection, |
|
13479 templateInsertUpdatesSelection = _ownProps$templateIns === void 0 ? true : _ownProps$templateIns; |
|
13480 return { |
|
13481 replaceInnerBlocks: function replaceInnerBlocks(blocks) { |
|
13482 _replaceInnerBlocks(clientId, blocks, block.innerBlocks.length === 0 && templateInsertUpdatesSelection); |
|
13483 }, |
|
13484 updateNestedSettings: function updateNestedSettings(settings) { |
|
13485 dispatch(updateBlockListSettings(clientId, settings)); |
|
13486 } |
|
13487 }; |
|
13488 })])(inner_blocks_InnerBlocks); |
|
13489 inner_blocks_InnerBlocks.Content = Object(external_this_wp_blocks_["withBlockContentContext"])(function (_ref) { |
|
13490 var BlockContent = _ref.BlockContent; |
|
13491 return Object(external_this_wp_element_["createElement"])(BlockContent, null); |
|
13492 }); |
|
13493 /* harmony default export */ var inner_blocks = (inner_blocks_InnerBlocks); |
|
13494 |
|
13495 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-advanced-controls/index.js |
|
13496 /** |
|
13497 * WordPress dependencies |
|
13498 */ |
|
13499 |
|
13500 /** |
|
13501 * Internal dependencies |
|
13502 */ |
|
13503 |
|
13504 |
|
13505 |
|
13506 var inspector_advanced_controls_createSlotFill = Object(external_this_wp_components_["createSlotFill"])('InspectorAdvancedControls'), |
|
13507 inspector_advanced_controls_Fill = inspector_advanced_controls_createSlotFill.Fill, |
|
13508 inspector_advanced_controls_Slot = inspector_advanced_controls_createSlotFill.Slot; |
|
13509 |
|
13510 var InspectorAdvancedControls = ifBlockEditSelected(inspector_advanced_controls_Fill); |
|
13511 InspectorAdvancedControls.Slot = inspector_advanced_controls_Slot; |
|
13512 /* harmony default export */ var inspector_advanced_controls = (InspectorAdvancedControls); |
|
13513 |
|
13514 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-controls/index.js |
|
13515 /** |
|
13516 * WordPress dependencies |
|
13517 */ |
|
13518 |
|
13519 /** |
|
13520 * Internal dependencies |
|
13521 */ |
|
13522 |
|
13523 |
|
13524 |
|
13525 var inspector_controls_createSlotFill = Object(external_this_wp_components_["createSlotFill"])('InspectorControls'), |
|
13526 inspector_controls_Fill = inspector_controls_createSlotFill.Fill, |
|
13527 inspector_controls_Slot = inspector_controls_createSlotFill.Slot; |
|
13528 |
|
13529 var InspectorControls = ifBlockEditSelected(inspector_controls_Fill); |
|
13530 InspectorControls.Slot = inspector_controls_Slot; |
|
13531 /* harmony default export */ var inspector_controls = (InspectorControls); |
|
13532 |
|
13533 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-palette/control.js |
|
13534 |
|
13535 |
|
13536 |
|
13537 /** |
|
13538 * WordPress dependencies |
|
13539 */ |
|
13540 |
|
13541 |
|
13542 |
|
13543 |
|
13544 /** |
|
13545 * Internal dependencies |
|
13546 */ |
|
13547 |
|
13548 |
|
13549 |
|
13550 // translators: first %s: The type of color (e.g. background color), second %s: the color name or value (e.g. red or #ff0000) |
|
13551 |
|
13552 var colorIndicatorAriaLabel = Object(external_this_wp_i18n_["__"])('(current %s: %s)'); |
|
13553 |
|
13554 function ColorPaletteControl(_ref) { |
|
13555 var colors = _ref.colors, |
|
13556 disableCustomColors = _ref.disableCustomColors, |
|
13557 label = _ref.label, |
|
13558 onChange = _ref.onChange, |
|
13559 value = _ref.value; |
|
13560 var colorObject = utils_getColorObjectByColorValue(colors, value); |
|
13561 var colorName = colorObject && colorObject.name; |
|
13562 var ariaLabel = Object(external_this_wp_i18n_["sprintf"])(colorIndicatorAriaLabel, label.toLowerCase(), colorName || value); |
|
13563 var labelElement = Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, label, value && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["ColorIndicator"], { |
|
13564 colorValue: value, |
|
13565 "aria-label": ariaLabel |
|
13566 })); |
|
13567 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["BaseControl"], { |
|
13568 className: "editor-color-palette-control block-editor-color-palette-control", |
|
13569 label: labelElement |
|
13570 }, Object(external_this_wp_element_["createElement"])(color_palette, Object(esm_extends["a" /* default */])({ |
|
13571 className: "editor-color-palette-control__color-palette block-editor-color-palette-control__color-palette", |
|
13572 value: value, |
|
13573 onChange: onChange |
|
13574 }, { |
|
13575 colors: colors, |
|
13576 disableCustomColors: disableCustomColors |
|
13577 }))); |
|
13578 } |
|
13579 /* harmony default export */ var color_palette_control = (Object(external_this_wp_compose_["compose"])([with_color_context, Object(external_this_wp_compose_["ifCondition"])(function (_ref2) { |
|
13580 var hasColorsToChoose = _ref2.hasColorsToChoose; |
|
13581 return hasColorsToChoose; |
|
13582 })])(ColorPaletteControl)); |
|
13583 |
|
13584 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/panel-color-settings/index.js |
|
13585 |
|
13586 |
|
13587 |
|
13588 |
|
13589 |
|
13590 /** |
|
13591 * External dependencies |
|
13592 */ |
|
13593 |
|
13594 /** |
|
13595 * WordPress dependencies |
|
13596 */ |
|
13597 |
|
13598 |
|
13599 |
|
13600 |
|
13601 /** |
|
13602 * Internal dependencies |
|
13603 */ |
|
13604 |
|
13605 |
|
13606 |
|
13607 |
|
13608 |
|
13609 var hasCustomColorsDisabledForSetting = function hasCustomColorsDisabledForSetting(disableCustomColors, colorSetting) { |
|
13610 if (colorSetting.disableCustomColors !== undefined) { |
|
13611 return colorSetting.disableCustomColors; |
|
13612 } |
|
13613 |
|
13614 return disableCustomColors; |
|
13615 }; |
|
13616 |
|
13617 var hasColorsToChooseInSetting = function hasColorsToChooseInSetting() { |
|
13618 var colors = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
|
13619 var disableCustomColors = arguments.length > 1 ? arguments[1] : undefined; |
|
13620 var colorSetting = arguments.length > 2 ? arguments[2] : undefined; |
|
13621 |
|
13622 if (!hasCustomColorsDisabledForSetting(disableCustomColors, colorSetting)) { |
|
13623 return true; |
|
13624 } |
|
13625 |
|
13626 return (colorSetting.colors || colors).length > 0; |
|
13627 }; |
|
13628 |
|
13629 var panel_color_settings_hasColorsToChoose = function hasColorsToChoose(_ref) { |
|
13630 var colors = _ref.colors, |
|
13631 disableCustomColors = _ref.disableCustomColors, |
|
13632 colorSettings = _ref.colorSettings; |
|
13633 return Object(external_lodash_["some"])(colorSettings, function (colorSetting) { |
|
13634 return hasColorsToChooseInSetting(colors, disableCustomColors, colorSetting); |
|
13635 }); |
|
13636 }; // translators: first %s: The type of color (e.g. background color), second %s: the color name or value (e.g. red or #ff0000) |
|
13637 |
|
13638 |
|
13639 var panel_color_settings_colorIndicatorAriaLabel = Object(external_this_wp_i18n_["__"])('(%s: %s)'); |
|
13640 |
|
13641 var panel_color_settings_renderColorIndicators = function renderColorIndicators(colorSettings, colors) { |
|
13642 return colorSettings.map(function (_ref2, index) { |
|
13643 var value = _ref2.value, |
|
13644 label = _ref2.label, |
|
13645 availableColors = _ref2.colors; |
|
13646 |
|
13647 if (!value) { |
|
13648 return null; |
|
13649 } |
|
13650 |
|
13651 var colorObject = utils_getColorObjectByColorValue(availableColors || colors, value); |
|
13652 var colorName = colorObject && colorObject.name; |
|
13653 var ariaLabel = Object(external_this_wp_i18n_["sprintf"])(panel_color_settings_colorIndicatorAriaLabel, label.toLowerCase(), colorName || value); |
|
13654 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["ColorIndicator"], { |
|
13655 key: index, |
|
13656 colorValue: value, |
|
13657 "aria-label": ariaLabel |
|
13658 }); |
|
13659 }); |
|
13660 }; // colorSettings is passed as an array of props so that it can be used for |
|
13661 // mapping both ColorIndicator and ColorPaletteControl components. Passing |
|
13662 // an array of components/nodes here wouldn't be feasible. |
|
13663 |
|
13664 |
|
13665 var PanelColorSettings = Object(external_this_wp_compose_["ifCondition"])(panel_color_settings_hasColorsToChoose)(function (_ref3) { |
|
13666 var children = _ref3.children, |
|
13667 colors = _ref3.colors, |
|
13668 colorSettings = _ref3.colorSettings, |
|
13669 disableCustomColors = _ref3.disableCustomColors, |
|
13670 title = _ref3.title, |
|
13671 props = Object(objectWithoutProperties["a" /* default */])(_ref3, ["children", "colors", "colorSettings", "disableCustomColors", "title"]); |
|
13672 |
|
13673 var titleElement = Object(external_this_wp_element_["createElement"])("span", { |
|
13674 className: "editor-panel-color-settings__panel-title block-editor-panel-color-settings__panel-title" |
|
13675 }, title, panel_color_settings_renderColorIndicators(colorSettings, colors)); |
|
13676 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["PanelBody"], Object(esm_extends["a" /* default */])({ |
|
13677 className: "editor-panel-color-settings block-editor-panel-color-settings", |
|
13678 title: titleElement |
|
13679 }, props), colorSettings.map(function (settings, index) { |
|
13680 return Object(external_this_wp_element_["createElement"])(color_palette_control, Object(esm_extends["a" /* default */])({ |
|
13681 key: index |
|
13682 }, Object(objectSpread["a" /* default */])({ |
|
13683 colors: colors, |
|
13684 disableCustomColors: disableCustomColors |
|
13685 }, settings))); |
|
13686 }), children); |
|
13687 }); |
|
13688 /* harmony default export */ var panel_color_settings = (with_color_context(PanelColorSettings)); |
|
13689 |
|
13690 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/plain-text/index.js |
|
13691 |
|
13692 |
|
13693 |
|
13694 |
|
13695 /** |
|
13696 * External dependencies |
|
13697 */ |
|
13698 |
|
13699 |
|
13700 |
|
13701 function PlainText(_ref) { |
|
13702 var _onChange = _ref.onChange, |
|
13703 className = _ref.className, |
|
13704 props = Object(objectWithoutProperties["a" /* default */])(_ref, ["onChange", "className"]); |
|
13705 |
|
13706 return Object(external_this_wp_element_["createElement"])(react_autosize_textarea_lib_default.a, Object(esm_extends["a" /* default */])({ |
|
13707 className: classnames_default()('editor-plain-text block-editor-plain-text', className), |
|
13708 onChange: function onChange(event) { |
|
13709 return _onChange(event.target.value); |
|
13710 } |
|
13711 }, props)); |
|
13712 } |
|
13713 |
|
13714 /* harmony default export */ var plain_text = (PlainText); |
|
13715 |
|
13716 // EXTERNAL MODULE: ./node_modules/memize/index.js |
|
13717 var memize = __webpack_require__(41); |
|
13718 var memize_default = /*#__PURE__*/__webpack_require__.n(memize); |
|
13719 |
|
13720 // EXTERNAL MODULE: external {"this":["wp","blob"]} |
|
13721 var external_this_wp_blob_ = __webpack_require__(35); |
|
13722 |
|
13723 // EXTERNAL MODULE: external {"this":["wp","deprecated"]} |
|
13724 var external_this_wp_deprecated_ = __webpack_require__(49); |
|
13725 var external_this_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_deprecated_); |
|
13726 |
|
13727 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/format-edit.js |
|
13728 |
|
13729 |
|
13730 /** |
|
13731 * WordPress dependencies |
|
13732 */ |
|
13733 |
|
13734 |
|
13735 |
|
13736 |
|
13737 var format_edit_FormatEdit = function FormatEdit(_ref) { |
|
13738 var formatTypes = _ref.formatTypes, |
|
13739 onChange = _ref.onChange, |
|
13740 value = _ref.value; |
|
13741 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, formatTypes.map(function (_ref2) { |
|
13742 var name = _ref2.name, |
|
13743 Edit = _ref2.edit; |
|
13744 |
|
13745 if (!Edit) { |
|
13746 return null; |
|
13747 } |
|
13748 |
|
13749 var activeFormat = Object(external_this_wp_richText_["getActiveFormat"])(value, name); |
|
13750 var isActive = activeFormat !== undefined; |
|
13751 var activeObject = Object(external_this_wp_richText_["getActiveObject"])(value); |
|
13752 var isObjectActive = activeObject !== undefined; |
|
13753 return Object(external_this_wp_element_["createElement"])(Edit, { |
|
13754 key: name, |
|
13755 isActive: isActive, |
|
13756 activeAttributes: isActive ? activeFormat.attributes || {} : {}, |
|
13757 isObjectActive: isObjectActive, |
|
13758 activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {}, |
|
13759 value: value, |
|
13760 onChange: onChange |
|
13761 }); |
|
13762 })); |
|
13763 }; |
|
13764 |
|
13765 /* harmony default export */ var format_edit = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
13766 var _select = select('core/rich-text'), |
|
13767 getFormatTypes = _select.getFormatTypes; |
|
13768 |
|
13769 return { |
|
13770 formatTypes: getFormatTypes() |
|
13771 }; |
|
13772 })(format_edit_FormatEdit)); |
|
13773 |
|
13774 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/format-toolbar/index.js |
|
13775 |
|
13776 |
|
13777 |
|
13778 /** |
|
13779 * External dependencies |
|
13780 */ |
|
13781 |
|
13782 /** |
|
13783 * WordPress dependencies |
|
13784 */ |
|
13785 |
|
13786 |
|
13787 |
|
13788 |
|
13789 var format_toolbar_FormatToolbar = function FormatToolbar(_ref) { |
|
13790 var controls = _ref.controls; |
|
13791 return Object(external_this_wp_element_["createElement"])("div", { |
|
13792 className: "editor-format-toolbar block-editor-format-toolbar" |
|
13793 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Toolbar"], null, controls.map(function (format) { |
|
13794 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Slot"], { |
|
13795 name: "RichText.ToolbarControls.".concat(format), |
|
13796 key: format |
|
13797 }); |
|
13798 }), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Slot"], { |
|
13799 name: "RichText.ToolbarControls" |
|
13800 }, function (fills) { |
|
13801 return fills.length && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["DropdownMenu"], { |
|
13802 icon: false, |
|
13803 position: "bottom left", |
|
13804 label: Object(external_this_wp_i18n_["__"])('More Rich Text Controls'), |
|
13805 controls: Object(external_lodash_["orderBy"])(fills.map(function (_ref2) { |
|
13806 var _ref3 = Object(slicedToArray["a" /* default */])(_ref2, 1), |
|
13807 props = _ref3[0].props; |
|
13808 |
|
13809 return props; |
|
13810 }), 'title') |
|
13811 }); |
|
13812 }))); |
|
13813 }; |
|
13814 |
|
13815 /* harmony default export */ var format_toolbar = (format_toolbar_FormatToolbar); |
|
13816 |
|
13817 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/aria.js |
|
13818 /** |
|
13819 * External dependencies |
|
13820 */ |
|
13821 |
|
13822 |
|
13823 var aria_isAriaPropName = function isAriaPropName(name) { |
|
13824 return Object(external_lodash_["startsWith"])(name, 'aria-'); |
|
13825 }; |
|
13826 |
|
13827 var aria_pickAriaProps = function pickAriaProps(props) { |
|
13828 return Object(external_lodash_["pickBy"])(props, function (value, key) { |
|
13829 return aria_isAriaPropName(key) && !Object(external_lodash_["isNil"])(value); |
|
13830 }); |
|
13831 }; |
|
13832 var aria_diffAriaProps = function diffAriaProps(props, nextProps) { |
|
13833 var prevAriaKeys = Object(external_lodash_["keys"])(aria_pickAriaProps(props)); |
|
13834 var nextAriaKeys = Object(external_lodash_["keys"])(aria_pickAriaProps(nextProps)); |
|
13835 var removedKeys = Object(external_lodash_["difference"])(prevAriaKeys, nextAriaKeys); |
|
13836 var updatedKeys = nextAriaKeys.filter(function (key) { |
|
13837 return !Object(external_lodash_["isEqual"])(props[key], nextProps[key]); |
|
13838 }); |
|
13839 return { |
|
13840 removedKeys: removedKeys, |
|
13841 updatedKeys: updatedKeys |
|
13842 }; |
|
13843 }; |
|
13844 |
|
13845 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/editable.js |
|
13846 |
|
13847 |
|
13848 |
|
13849 |
|
13850 |
|
13851 |
|
13852 |
|
13853 |
|
13854 |
|
13855 |
|
13856 /** |
|
13857 * External dependencies |
|
13858 */ |
|
13859 |
|
13860 |
|
13861 /** |
|
13862 * WordPress dependencies |
|
13863 */ |
|
13864 |
|
13865 |
|
13866 |
|
13867 /** |
|
13868 * Internal dependencies |
|
13869 */ |
|
13870 |
|
13871 |
|
13872 /** |
|
13873 * Browser dependencies |
|
13874 */ |
|
13875 |
|
13876 var userAgent = window.navigator.userAgent; |
|
13877 /** |
|
13878 * Applies a fix that provides `input` events for contenteditable in Internet Explorer. |
|
13879 * |
|
13880 * @param {Element} editorNode The root editor node. |
|
13881 * |
|
13882 * @return {Function} A function to remove the fix (for cleanup). |
|
13883 */ |
|
13884 |
|
13885 function applyInternetExplorerInputFix(editorNode) { |
|
13886 /** |
|
13887 * Dispatches `input` events in response to `textinput` events. |
|
13888 * |
|
13889 * IE provides a `textinput` event that is similar to an `input` event, |
|
13890 * and we use it to manually dispatch an `input` event. |
|
13891 * `textinput` is dispatched for text entry but for not deletions. |
|
13892 * |
|
13893 * @param {Event} textInputEvent An Internet Explorer `textinput` event. |
|
13894 */ |
|
13895 function mapTextInputEvent(textInputEvent) { |
|
13896 textInputEvent.stopImmediatePropagation(); |
|
13897 var inputEvent = document.createEvent('Event'); |
|
13898 inputEvent.initEvent('input', true, false); |
|
13899 inputEvent.data = textInputEvent.data; |
|
13900 textInputEvent.target.dispatchEvent(inputEvent); |
|
13901 } |
|
13902 /** |
|
13903 * Dispatches `input` events in response to Delete and Backspace keyup. |
|
13904 * |
|
13905 * It would be better dispatch an `input` event after each deleting |
|
13906 * `keydown` because the DOM is updated after each, but it is challenging |
|
13907 * to determine the right time to dispatch `input` since propagation of |
|
13908 * `keydown` can be stopped at any point. |
|
13909 * |
|
13910 * It's easier to listen for `keyup` in the capture phase and dispatch |
|
13911 * `input` before `keyup` propagates further. It's not perfect, but should |
|
13912 * be good enough. |
|
13913 * |
|
13914 * @param {KeyboardEvent} keyUp |
|
13915 * @param {Node} keyUp.target The event target. |
|
13916 * @param {number} keyUp.keyCode The key code. |
|
13917 */ |
|
13918 |
|
13919 |
|
13920 function mapDeletionKeyUpEvents(_ref) { |
|
13921 var target = _ref.target, |
|
13922 keyCode = _ref.keyCode; |
|
13923 var isDeletion = external_this_wp_keycodes_["BACKSPACE"] === keyCode || external_this_wp_keycodes_["DELETE"] === keyCode; |
|
13924 |
|
13925 if (isDeletion && editorNode.contains(target)) { |
|
13926 var inputEvent = document.createEvent('Event'); |
|
13927 inputEvent.initEvent('input', true, false); |
|
13928 inputEvent.data = null; |
|
13929 target.dispatchEvent(inputEvent); |
|
13930 } |
|
13931 } |
|
13932 |
|
13933 editorNode.addEventListener('textinput', mapTextInputEvent); |
|
13934 document.addEventListener('keyup', mapDeletionKeyUpEvents, true); |
|
13935 return function removeInternetExplorerInputFix() { |
|
13936 editorNode.removeEventListener('textinput', mapTextInputEvent); |
|
13937 document.removeEventListener('keyup', mapDeletionKeyUpEvents, true); |
|
13938 }; |
|
13939 } |
|
13940 |
|
13941 var IS_PLACEHOLDER_VISIBLE_ATTR_NAME = 'data-is-placeholder-visible'; |
|
13942 var oldClassName = 'editor-rich-text__editable'; |
|
13943 var editable_className = 'block-editor-rich-text__editable'; |
|
13944 /** |
|
13945 * Whether or not the user agent is Internet Explorer. |
|
13946 * |
|
13947 * @type {boolean} |
|
13948 */ |
|
13949 |
|
13950 var IS_IE = userAgent.indexOf('Trident') >= 0; |
|
13951 |
|
13952 var editable_Editable = |
|
13953 /*#__PURE__*/ |
|
13954 function (_Component) { |
|
13955 Object(inherits["a" /* default */])(Editable, _Component); |
|
13956 |
|
13957 function Editable() { |
|
13958 var _this; |
|
13959 |
|
13960 Object(classCallCheck["a" /* default */])(this, Editable); |
|
13961 |
|
13962 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(Editable).call(this)); |
|
13963 _this.bindEditorNode = _this.bindEditorNode.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
13964 return _this; |
|
13965 } // We must prevent rerenders because the browser will modify the DOM. React |
|
13966 // will rerender the DOM fine, but we're losing selection and it would be |
|
13967 // more expensive to do so as it would just set the inner HTML through |
|
13968 // `dangerouslySetInnerHTML`. Instead RichText does it's own diffing and |
|
13969 // selection setting. |
|
13970 // |
|
13971 // Because we never update the component, we have to look through props and |
|
13972 // update the attributes on the wrapper nodes here. `componentDidUpdate` |
|
13973 // will never be called. |
|
13974 |
|
13975 |
|
13976 Object(createClass["a" /* default */])(Editable, [{ |
|
13977 key: "shouldComponentUpdate", |
|
13978 value: function shouldComponentUpdate(nextProps) { |
|
13979 var _this2 = this; |
|
13980 |
|
13981 this.configureIsPlaceholderVisible(nextProps.isPlaceholderVisible); |
|
13982 |
|
13983 if (!Object(external_lodash_["isEqual"])(this.props.style, nextProps.style)) { |
|
13984 this.editorNode.setAttribute('style', ''); |
|
13985 Object.assign(this.editorNode.style, nextProps.style); |
|
13986 } |
|
13987 |
|
13988 if (!Object(external_lodash_["isEqual"])(this.props.className, nextProps.className)) { |
|
13989 this.editorNode.className = classnames_default()(editable_className, oldClassName, nextProps.className); |
|
13990 } |
|
13991 |
|
13992 var _diffAriaProps = aria_diffAriaProps(this.props, nextProps), |
|
13993 removedKeys = _diffAriaProps.removedKeys, |
|
13994 updatedKeys = _diffAriaProps.updatedKeys; |
|
13995 |
|
13996 removedKeys.forEach(function (key) { |
|
13997 return _this2.editorNode.removeAttribute(key); |
|
13998 }); |
|
13999 updatedKeys.forEach(function (key) { |
|
14000 return _this2.editorNode.setAttribute(key, nextProps[key]); |
|
14001 }); |
|
14002 return false; |
|
14003 } |
|
14004 }, { |
|
14005 key: "configureIsPlaceholderVisible", |
|
14006 value: function configureIsPlaceholderVisible(isPlaceholderVisible) { |
|
14007 var isPlaceholderVisibleString = String(!!isPlaceholderVisible); |
|
14008 |
|
14009 if (this.editorNode.getAttribute(IS_PLACEHOLDER_VISIBLE_ATTR_NAME) !== isPlaceholderVisibleString) { |
|
14010 this.editorNode.setAttribute(IS_PLACEHOLDER_VISIBLE_ATTR_NAME, isPlaceholderVisibleString); |
|
14011 } |
|
14012 } |
|
14013 }, { |
|
14014 key: "bindEditorNode", |
|
14015 value: function bindEditorNode(editorNode) { |
|
14016 this.editorNode = editorNode; |
|
14017 this.props.setRef(editorNode); |
|
14018 |
|
14019 if (IS_IE) { |
|
14020 if (editorNode) { |
|
14021 // Mounting: |
|
14022 this.removeInternetExplorerInputFix = applyInternetExplorerInputFix(editorNode); |
|
14023 } else { |
|
14024 // Unmounting: |
|
14025 this.removeInternetExplorerInputFix(); |
|
14026 } |
|
14027 } |
|
14028 } |
|
14029 }, { |
|
14030 key: "render", |
|
14031 value: function render() { |
|
14032 var _objectSpread2; |
|
14033 |
|
14034 var _this$props = this.props, |
|
14035 _this$props$tagName = _this$props.tagName, |
|
14036 tagName = _this$props$tagName === void 0 ? 'div' : _this$props$tagName, |
|
14037 style = _this$props.style, |
|
14038 record = _this$props.record, |
|
14039 valueToEditableHTML = _this$props.valueToEditableHTML, |
|
14040 additionalClassName = _this$props.className, |
|
14041 isPlaceholderVisible = _this$props.isPlaceholderVisible, |
|
14042 remainingProps = Object(objectWithoutProperties["a" /* default */])(_this$props, ["tagName", "style", "record", "valueToEditableHTML", "className", "isPlaceholderVisible"]); |
|
14043 |
|
14044 delete remainingProps.setRef; |
|
14045 return Object(external_this_wp_element_["createElement"])(tagName, Object(objectSpread["a" /* default */])((_objectSpread2 = { |
|
14046 role: 'textbox', |
|
14047 'aria-multiline': true, |
|
14048 className: classnames_default()(editable_className, oldClassName, additionalClassName), |
|
14049 contentEditable: true |
|
14050 }, Object(defineProperty["a" /* default */])(_objectSpread2, IS_PLACEHOLDER_VISIBLE_ATTR_NAME, isPlaceholderVisible), Object(defineProperty["a" /* default */])(_objectSpread2, "ref", this.bindEditorNode), Object(defineProperty["a" /* default */])(_objectSpread2, "style", style), Object(defineProperty["a" /* default */])(_objectSpread2, "suppressContentEditableWarning", true), Object(defineProperty["a" /* default */])(_objectSpread2, "dangerouslySetInnerHTML", { |
|
14051 __html: valueToEditableHTML(record) |
|
14052 }), _objectSpread2), remainingProps)); |
|
14053 } |
|
14054 }]); |
|
14055 |
|
14056 return Editable; |
|
14057 }(external_this_wp_element_["Component"]); |
|
14058 |
|
14059 |
|
14060 |
|
14061 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/patterns.js |
|
14062 /** |
|
14063 * WordPress dependencies |
|
14064 */ |
|
14065 |
|
14066 |
|
14067 function getPatterns(_ref) { |
|
14068 var onReplace = _ref.onReplace, |
|
14069 valueToFormat = _ref.valueToFormat; |
|
14070 var prefixTransforms = Object(external_this_wp_blocks_["getBlockTransforms"])('from').filter(function (_ref2) { |
|
14071 var type = _ref2.type; |
|
14072 return type === 'prefix'; |
|
14073 }); |
|
14074 return [function (record) { |
|
14075 if (!onReplace) { |
|
14076 return record; |
|
14077 } |
|
14078 |
|
14079 var start = Object(external_this_wp_richText_["getSelectionStart"])(record); |
|
14080 var text = Object(external_this_wp_richText_["getTextContent"])(record); |
|
14081 var characterBefore = text.slice(start - 1, start); |
|
14082 |
|
14083 if (!/\s/.test(characterBefore)) { |
|
14084 return record; |
|
14085 } |
|
14086 |
|
14087 var trimmedTextBefore = text.slice(0, start).trim(); |
|
14088 var transformation = Object(external_this_wp_blocks_["findTransform"])(prefixTransforms, function (_ref3) { |
|
14089 var prefix = _ref3.prefix; |
|
14090 return trimmedTextBefore === prefix; |
|
14091 }); |
|
14092 |
|
14093 if (!transformation) { |
|
14094 return record; |
|
14095 } |
|
14096 |
|
14097 var content = valueToFormat(Object(external_this_wp_richText_["slice"])(record, start, text.length)); |
|
14098 var block = transformation.transform(content); |
|
14099 onReplace([block]); |
|
14100 return record; |
|
14101 }, function (record) { |
|
14102 var BACKTICK = '`'; |
|
14103 var start = Object(external_this_wp_richText_["getSelectionStart"])(record); |
|
14104 var text = Object(external_this_wp_richText_["getTextContent"])(record); |
|
14105 var characterBefore = text.slice(start - 1, start); // Quick check the text for the necessary character. |
|
14106 |
|
14107 if (characterBefore !== BACKTICK) { |
|
14108 return record; |
|
14109 } |
|
14110 |
|
14111 var textBefore = text.slice(0, start - 1); |
|
14112 var indexBefore = textBefore.lastIndexOf(BACKTICK); |
|
14113 |
|
14114 if (indexBefore === -1) { |
|
14115 return record; |
|
14116 } |
|
14117 |
|
14118 var startIndex = indexBefore; |
|
14119 var endIndex = start - 2; |
|
14120 |
|
14121 if (startIndex === endIndex) { |
|
14122 return record; |
|
14123 } |
|
14124 |
|
14125 record = Object(external_this_wp_richText_["remove"])(record, startIndex, startIndex + 1); |
|
14126 record = Object(external_this_wp_richText_["remove"])(record, endIndex, endIndex + 1); |
|
14127 record = Object(external_this_wp_richText_["applyFormat"])(record, { |
|
14128 type: 'code' |
|
14129 }, startIndex, endIndex); |
|
14130 return record; |
|
14131 }]; |
|
14132 } |
|
14133 |
|
14134 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/shortcut.js |
|
14135 |
|
14136 |
|
14137 |
|
14138 |
|
14139 |
|
14140 |
|
14141 |
|
14142 |
|
14143 |
|
14144 /** |
|
14145 * WordPress dependencies |
|
14146 */ |
|
14147 |
|
14148 |
|
14149 |
|
14150 var shortcut_RichTextShortcut = |
|
14151 /*#__PURE__*/ |
|
14152 function (_Component) { |
|
14153 Object(inherits["a" /* default */])(RichTextShortcut, _Component); |
|
14154 |
|
14155 function RichTextShortcut() { |
|
14156 var _this; |
|
14157 |
|
14158 Object(classCallCheck["a" /* default */])(this, RichTextShortcut); |
|
14159 |
|
14160 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(RichTextShortcut).apply(this, arguments)); |
|
14161 _this.onUse = _this.onUse.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14162 return _this; |
|
14163 } |
|
14164 |
|
14165 Object(createClass["a" /* default */])(RichTextShortcut, [{ |
|
14166 key: "onUse", |
|
14167 value: function onUse() { |
|
14168 this.props.onUse(); |
|
14169 return false; |
|
14170 } |
|
14171 }, { |
|
14172 key: "render", |
|
14173 value: function render() { |
|
14174 var _this$props = this.props, |
|
14175 character = _this$props.character, |
|
14176 type = _this$props.type; |
|
14177 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["KeyboardShortcuts"], { |
|
14178 bindGlobal: true, |
|
14179 shortcuts: Object(defineProperty["a" /* default */])({}, external_this_wp_keycodes_["rawShortcut"][type](character), this.onUse) |
|
14180 }); |
|
14181 } |
|
14182 }]); |
|
14183 |
|
14184 return RichTextShortcut; |
|
14185 }(external_this_wp_element_["Component"]); |
|
14186 |
|
14187 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/list-edit.js |
|
14188 |
|
14189 |
|
14190 /** |
|
14191 * WordPress dependencies |
|
14192 */ |
|
14193 |
|
14194 |
|
14195 |
|
14196 |
|
14197 /** |
|
14198 * Internal dependencies |
|
14199 */ |
|
14200 |
|
14201 |
|
14202 |
|
14203 var _window$Node = window.Node, |
|
14204 TEXT_NODE = _window$Node.TEXT_NODE, |
|
14205 ELEMENT_NODE = _window$Node.ELEMENT_NODE; |
|
14206 /** |
|
14207 * Gets the selected list node, which is the closest list node to the start of |
|
14208 * the selection. |
|
14209 * |
|
14210 * @return {?Element} The selected list node, or undefined if none is selected. |
|
14211 */ |
|
14212 |
|
14213 function getSelectedListNode() { |
|
14214 var selection = window.getSelection(); |
|
14215 |
|
14216 if (selection.rangeCount === 0) { |
|
14217 return; |
|
14218 } |
|
14219 |
|
14220 var _selection$getRangeAt = selection.getRangeAt(0), |
|
14221 startContainer = _selection$getRangeAt.startContainer; |
|
14222 |
|
14223 if (startContainer.nodeType === TEXT_NODE) { |
|
14224 startContainer = startContainer.parentNode; |
|
14225 } |
|
14226 |
|
14227 if (startContainer.nodeType !== ELEMENT_NODE) { |
|
14228 return; |
|
14229 } |
|
14230 |
|
14231 var rootNode = startContainer.closest('*[contenteditable]'); |
|
14232 |
|
14233 if (!rootNode || !rootNode.contains(startContainer)) { |
|
14234 return; |
|
14235 } |
|
14236 |
|
14237 return startContainer.closest('ol,ul'); |
|
14238 } |
|
14239 /** |
|
14240 * Whether or not the root list is selected. |
|
14241 * |
|
14242 * @return {boolean} True if the root list or nothing is selected, false if an |
|
14243 * inner list is selected. |
|
14244 */ |
|
14245 |
|
14246 |
|
14247 function isListRootSelected() { |
|
14248 var listNode = getSelectedListNode(); // Consider the root list selected if nothing is selected. |
|
14249 |
|
14250 return !listNode || listNode.contentEditable === 'true'; |
|
14251 } |
|
14252 /** |
|
14253 * Wether or not the selected list has the given tag name. |
|
14254 * |
|
14255 * @param {string} tagName The tag name the list should have. |
|
14256 * @param {string} rootTagName The current root tag name, to compare with in |
|
14257 * case nothing is selected. |
|
14258 * |
|
14259 * @return {boolean} [description] |
|
14260 */ |
|
14261 |
|
14262 |
|
14263 function isActiveListType(tagName, rootTagName) { |
|
14264 var listNode = getSelectedListNode(); |
|
14265 |
|
14266 if (!listNode) { |
|
14267 return tagName === rootTagName; |
|
14268 } |
|
14269 |
|
14270 return listNode.nodeName.toLowerCase() === tagName; |
|
14271 } |
|
14272 |
|
14273 var list_edit_ListEdit = function ListEdit(_ref) { |
|
14274 var onTagNameChange = _ref.onTagNameChange, |
|
14275 tagName = _ref.tagName, |
|
14276 value = _ref.value, |
|
14277 onChange = _ref.onChange; |
|
14278 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])(shortcut_RichTextShortcut, { |
|
14279 type: "primary", |
|
14280 character: "[", |
|
14281 onUse: function onUse() { |
|
14282 onChange(Object(external_this_wp_richText_["outdentListItems"])(value)); |
|
14283 } |
|
14284 }), Object(external_this_wp_element_["createElement"])(shortcut_RichTextShortcut, { |
|
14285 type: "primary", |
|
14286 character: "]", |
|
14287 onUse: function onUse() { |
|
14288 onChange(Object(external_this_wp_richText_["indentListItems"])(value, { |
|
14289 type: tagName |
|
14290 })); |
|
14291 } |
|
14292 }), Object(external_this_wp_element_["createElement"])(shortcut_RichTextShortcut, { |
|
14293 type: "primary", |
|
14294 character: "m", |
|
14295 onUse: function onUse() { |
|
14296 onChange(Object(external_this_wp_richText_["indentListItems"])(value, { |
|
14297 type: tagName |
|
14298 })); |
|
14299 } |
|
14300 }), Object(external_this_wp_element_["createElement"])(shortcut_RichTextShortcut, { |
|
14301 type: "primaryShift", |
|
14302 character: "m", |
|
14303 onUse: function onUse() { |
|
14304 onChange(Object(external_this_wp_richText_["outdentListItems"])(value)); |
|
14305 } |
|
14306 }), Object(external_this_wp_element_["createElement"])(block_format_controls, null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Toolbar"], { |
|
14307 controls: [onTagNameChange && { |
|
14308 icon: 'editor-ul', |
|
14309 title: Object(external_this_wp_i18n_["__"])('Convert to unordered list'), |
|
14310 isActive: isActiveListType('ul', tagName), |
|
14311 onClick: function onClick() { |
|
14312 onChange(Object(external_this_wp_richText_["changeListType"])(value, { |
|
14313 type: 'ul' |
|
14314 })); |
|
14315 |
|
14316 if (isListRootSelected()) { |
|
14317 onTagNameChange('ul'); |
|
14318 } |
|
14319 } |
|
14320 }, onTagNameChange && { |
|
14321 icon: 'editor-ol', |
|
14322 title: Object(external_this_wp_i18n_["__"])('Convert to ordered list'), |
|
14323 isActive: isActiveListType('ol', tagName), |
|
14324 onClick: function onClick() { |
|
14325 onChange(Object(external_this_wp_richText_["changeListType"])(value, { |
|
14326 type: 'ol' |
|
14327 })); |
|
14328 |
|
14329 if (isListRootSelected()) { |
|
14330 onTagNameChange('ol'); |
|
14331 } |
|
14332 } |
|
14333 }, { |
|
14334 icon: 'editor-outdent', |
|
14335 title: Object(external_this_wp_i18n_["__"])('Outdent list item'), |
|
14336 shortcut: Object(external_this_wp_i18n_["_x"])('Backspace', 'keyboard key'), |
|
14337 onClick: function onClick() { |
|
14338 onChange(Object(external_this_wp_richText_["outdentListItems"])(value)); |
|
14339 } |
|
14340 }, { |
|
14341 icon: 'editor-indent', |
|
14342 title: Object(external_this_wp_i18n_["__"])('Indent list item'), |
|
14343 shortcut: Object(external_this_wp_i18n_["_x"])('Space', 'keyboard key'), |
|
14344 onClick: function onClick() { |
|
14345 onChange(Object(external_this_wp_richText_["indentListItems"])(value, { |
|
14346 type: tagName |
|
14347 })); |
|
14348 } |
|
14349 }].filter(Boolean) |
|
14350 }))); |
|
14351 }; |
|
14352 |
|
14353 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/remove-browser-shortcuts.js |
|
14354 |
|
14355 |
|
14356 /** |
|
14357 * External dependencies |
|
14358 */ |
|
14359 |
|
14360 /** |
|
14361 * WordPress dependencies |
|
14362 */ |
|
14363 |
|
14364 |
|
14365 |
|
14366 /** |
|
14367 * Set of keyboard shortcuts handled internally by RichText. |
|
14368 * |
|
14369 * @type {Array} |
|
14370 */ |
|
14371 |
|
14372 var HANDLED_SHORTCUTS = [external_this_wp_keycodes_["rawShortcut"].primary('z'), external_this_wp_keycodes_["rawShortcut"].primaryShift('z'), external_this_wp_keycodes_["rawShortcut"].primary('y')]; |
|
14373 /** |
|
14374 * An instance of a KeyboardShortcuts element pre-bound for the handled |
|
14375 * shortcuts. Since shortcuts never change, the element can be considered |
|
14376 * static, and can be skipped in reconciliation. |
|
14377 * |
|
14378 * @type {WPElement} |
|
14379 */ |
|
14380 |
|
14381 var SHORTCUTS_ELEMENT = Object(external_this_wp_element_["createElement"])(external_this_wp_components_["KeyboardShortcuts"], { |
|
14382 bindGlobal: true, |
|
14383 shortcuts: Object(external_lodash_["fromPairs"])(HANDLED_SHORTCUTS.map(function (shortcut) { |
|
14384 return [shortcut, function (event) { |
|
14385 return event.preventDefault(); |
|
14386 }]; |
|
14387 })) |
|
14388 }); |
|
14389 /** |
|
14390 * Component which registered keyboard event handlers to prevent default |
|
14391 * behaviors for key combinations otherwise handled internally by RichText. |
|
14392 * |
|
14393 * @return {WPElement} WordPress element. |
|
14394 */ |
|
14395 |
|
14396 var RemoveBrowserShortcuts = function RemoveBrowserShortcuts() { |
|
14397 return SHORTCUTS_ELEMENT; |
|
14398 }; |
|
14399 |
|
14400 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/toolbar-button.js |
|
14401 |
|
14402 |
|
14403 |
|
14404 |
|
14405 /** |
|
14406 * WordPress dependencies |
|
14407 */ |
|
14408 |
|
14409 |
|
14410 function RichTextToolbarButton(_ref) { |
|
14411 var name = _ref.name, |
|
14412 shortcutType = _ref.shortcutType, |
|
14413 shortcutCharacter = _ref.shortcutCharacter, |
|
14414 props = Object(objectWithoutProperties["a" /* default */])(_ref, ["name", "shortcutType", "shortcutCharacter"]); |
|
14415 |
|
14416 var shortcut; |
|
14417 var fillName = 'RichText.ToolbarControls'; |
|
14418 |
|
14419 if (name) { |
|
14420 fillName += ".".concat(name); |
|
14421 } |
|
14422 |
|
14423 if (shortcutType && shortcutCharacter) { |
|
14424 shortcut = external_this_wp_keycodes_["displayShortcut"][shortcutType](shortcutCharacter); |
|
14425 } |
|
14426 |
|
14427 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Fill"], { |
|
14428 name: fillName |
|
14429 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["ToolbarButton"], Object(esm_extends["a" /* default */])({}, props, { |
|
14430 shortcut: shortcut |
|
14431 }))); |
|
14432 } |
|
14433 |
|
14434 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/input-event.js |
|
14435 |
|
14436 |
|
14437 |
|
14438 |
|
14439 |
|
14440 |
|
14441 |
|
14442 /** |
|
14443 * WordPress dependencies |
|
14444 */ |
|
14445 |
|
14446 var input_event_UnstableRichTextInputEvent = |
|
14447 /*#__PURE__*/ |
|
14448 function (_Component) { |
|
14449 Object(inherits["a" /* default */])(UnstableRichTextInputEvent, _Component); |
|
14450 |
|
14451 function UnstableRichTextInputEvent() { |
|
14452 var _this; |
|
14453 |
|
14454 Object(classCallCheck["a" /* default */])(this, UnstableRichTextInputEvent); |
|
14455 |
|
14456 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(UnstableRichTextInputEvent).apply(this, arguments)); |
|
14457 _this.onInput = _this.onInput.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14458 return _this; |
|
14459 } |
|
14460 |
|
14461 Object(createClass["a" /* default */])(UnstableRichTextInputEvent, [{ |
|
14462 key: "onInput", |
|
14463 value: function onInput(event) { |
|
14464 if (event.inputType === this.props.inputType) { |
|
14465 this.props.onInput(); |
|
14466 } |
|
14467 } |
|
14468 }, { |
|
14469 key: "componentDidMount", |
|
14470 value: function componentDidMount() { |
|
14471 document.addEventListener('input', this.onInput, true); |
|
14472 } |
|
14473 }, { |
|
14474 key: "componentWillUnmount", |
|
14475 value: function componentWillUnmount() { |
|
14476 document.removeEventListener('input', this.onInput, true); |
|
14477 } |
|
14478 }, { |
|
14479 key: "render", |
|
14480 value: function render() { |
|
14481 return null; |
|
14482 } |
|
14483 }]); |
|
14484 |
|
14485 return UnstableRichTextInputEvent; |
|
14486 }(external_this_wp_element_["Component"]); |
|
14487 |
|
14488 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/index.js |
|
14489 |
|
14490 |
|
14491 |
|
14492 |
|
14493 |
|
14494 |
|
14495 |
|
14496 |
|
14497 |
|
14498 |
|
14499 |
|
14500 |
|
14501 |
|
14502 /** |
|
14503 * External dependencies |
|
14504 */ |
|
14505 |
|
14506 |
|
14507 |
|
14508 /** |
|
14509 * WordPress dependencies |
|
14510 */ |
|
14511 |
|
14512 |
|
14513 |
|
14514 |
|
14515 |
|
14516 |
|
14517 |
|
14518 |
|
14519 |
|
14520 |
|
14521 |
|
14522 |
|
14523 |
|
14524 /** |
|
14525 * Internal dependencies |
|
14526 */ |
|
14527 |
|
14528 |
|
14529 |
|
14530 |
|
14531 |
|
14532 |
|
14533 |
|
14534 |
|
14535 |
|
14536 |
|
14537 |
|
14538 /** |
|
14539 * Browser dependencies |
|
14540 */ |
|
14541 |
|
14542 var rich_text_window = window, |
|
14543 rich_text_getSelection = rich_text_window.getSelection, |
|
14544 getComputedStyle = rich_text_window.getComputedStyle; |
|
14545 /** |
|
14546 * All inserting input types that would insert HTML into the DOM. |
|
14547 * |
|
14548 * @see https://www.w3.org/TR/input-events-2/#interface-InputEvent-Attributes |
|
14549 * |
|
14550 * @type {Set} |
|
14551 */ |
|
14552 |
|
14553 var INSERTION_INPUT_TYPES_TO_IGNORE = new Set(['insertParagraph', 'insertOrderedList', 'insertUnorderedList', 'insertHorizontalRule', 'insertLink']); |
|
14554 /** |
|
14555 * Global stylesheet. |
|
14556 */ |
|
14557 |
|
14558 var globalStyle = document.createElement('style'); |
|
14559 document.head.appendChild(globalStyle); |
|
14560 var rich_text_RichText = |
|
14561 /*#__PURE__*/ |
|
14562 function (_Component) { |
|
14563 Object(inherits["a" /* default */])(RichText, _Component); |
|
14564 |
|
14565 function RichText(_ref) { |
|
14566 var _this; |
|
14567 |
|
14568 var value = _ref.value, |
|
14569 onReplace = _ref.onReplace, |
|
14570 multiline = _ref.multiline; |
|
14571 |
|
14572 Object(classCallCheck["a" /* default */])(this, RichText); |
|
14573 |
|
14574 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(RichText).apply(this, arguments)); |
|
14575 |
|
14576 if (multiline === true || multiline === 'p' || multiline === 'li') { |
|
14577 _this.multilineTag = multiline === true ? 'p' : multiline; |
|
14578 } |
|
14579 |
|
14580 if (_this.multilineTag === 'li') { |
|
14581 _this.multilineWrapperTags = ['ul', 'ol']; |
|
14582 } |
|
14583 |
|
14584 if (_this.props.onSplit) { |
|
14585 _this.onSplit = _this.props.onSplit; |
|
14586 external_this_wp_deprecated_default()('wp.editor.RichText onSplit prop', { |
|
14587 plugin: 'Gutenberg', |
|
14588 alternative: 'wp.editor.RichText unstableOnSplit prop' |
|
14589 }); |
|
14590 } else if (_this.props.unstableOnSplit) { |
|
14591 _this.onSplit = _this.props.unstableOnSplit; |
|
14592 } |
|
14593 |
|
14594 _this.onFocus = _this.onFocus.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14595 _this.onBlur = _this.onBlur.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14596 _this.onChange = _this.onChange.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14597 _this.onDeleteKeyDown = _this.onDeleteKeyDown.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14598 _this.onKeyDown = _this.onKeyDown.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14599 _this.onPaste = _this.onPaste.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14600 _this.onCreateUndoLevel = _this.onCreateUndoLevel.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14601 _this.setFocusedElement = _this.setFocusedElement.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14602 _this.onInput = _this.onInput.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14603 _this.onCompositionEnd = _this.onCompositionEnd.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14604 _this.onSelectionChange = _this.onSelectionChange.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14605 _this.getRecord = _this.getRecord.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14606 _this.createRecord = _this.createRecord.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14607 _this.applyRecord = _this.applyRecord.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14608 _this.isEmpty = _this.isEmpty.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14609 _this.valueToFormat = _this.valueToFormat.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14610 _this.setRef = _this.setRef.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14611 _this.valueToEditableHTML = _this.valueToEditableHTML.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14612 _this.handleHorizontalNavigation = _this.handleHorizontalNavigation.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14613 _this.onPointerDown = _this.onPointerDown.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
14614 _this.formatToValue = memize_default()(_this.formatToValue.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))), { |
|
14615 maxSize: 1 |
|
14616 }); |
|
14617 _this.savedContent = value; |
|
14618 _this.patterns = getPatterns({ |
|
14619 onReplace: onReplace, |
|
14620 valueToFormat: _this.valueToFormat |
|
14621 }); |
|
14622 _this.enterPatterns = Object(external_this_wp_blocks_["getBlockTransforms"])('from').filter(function (_ref2) { |
|
14623 var type = _ref2.type; |
|
14624 return type === 'enter'; |
|
14625 }); |
|
14626 _this.state = {}; |
|
14627 _this.usedDeprecatedChildrenSource = Array.isArray(value); |
|
14628 _this.lastHistoryValue = value; |
|
14629 return _this; |
|
14630 } |
|
14631 |
|
14632 Object(createClass["a" /* default */])(RichText, [{ |
|
14633 key: "componentWillUnmount", |
|
14634 value: function componentWillUnmount() { |
|
14635 document.removeEventListener('selectionchange', this.onSelectionChange); |
|
14636 } |
|
14637 }, { |
|
14638 key: "setRef", |
|
14639 value: function setRef(node) { |
|
14640 if (node) { |
|
14641 if (false) { var computedStyle; } |
|
14642 |
|
14643 this.editableRef = node; |
|
14644 } else { |
|
14645 delete this.editableRef; |
|
14646 } |
|
14647 } |
|
14648 }, { |
|
14649 key: "setFocusedElement", |
|
14650 value: function setFocusedElement() { |
|
14651 if (this.props.setFocusedElement) { |
|
14652 this.props.setFocusedElement(this.props.instanceId); |
|
14653 } |
|
14654 } |
|
14655 /** |
|
14656 * Get the current record (value and selection) from props and state. |
|
14657 * |
|
14658 * @return {Object} The current record (value and selection). |
|
14659 */ |
|
14660 |
|
14661 }, { |
|
14662 key: "getRecord", |
|
14663 value: function getRecord() { |
|
14664 var _this$formatToValue = this.formatToValue(this.props.value), |
|
14665 formats = _this$formatToValue.formats, |
|
14666 replacements = _this$formatToValue.replacements, |
|
14667 text = _this$formatToValue.text; |
|
14668 |
|
14669 var _this$state = this.state, |
|
14670 start = _this$state.start, |
|
14671 end = _this$state.end, |
|
14672 activeFormats = _this$state.activeFormats; |
|
14673 return { |
|
14674 formats: formats, |
|
14675 replacements: replacements, |
|
14676 text: text, |
|
14677 start: start, |
|
14678 end: end, |
|
14679 activeFormats: activeFormats |
|
14680 }; |
|
14681 } |
|
14682 }, { |
|
14683 key: "createRecord", |
|
14684 value: function createRecord() { |
|
14685 var selection = rich_text_getSelection(); |
|
14686 var range = selection.rangeCount > 0 ? selection.getRangeAt(0) : null; |
|
14687 return Object(external_this_wp_richText_["create"])({ |
|
14688 element: this.editableRef, |
|
14689 range: range, |
|
14690 multilineTag: this.multilineTag, |
|
14691 multilineWrapperTags: this.multilineWrapperTags, |
|
14692 __unstableIsEditableTree: true |
|
14693 }); |
|
14694 } |
|
14695 }, { |
|
14696 key: "applyRecord", |
|
14697 value: function applyRecord(record) { |
|
14698 var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, |
|
14699 domOnly = _ref3.domOnly; |
|
14700 |
|
14701 Object(external_this_wp_richText_["apply"])({ |
|
14702 value: record, |
|
14703 current: this.editableRef, |
|
14704 multilineTag: this.multilineTag, |
|
14705 multilineWrapperTags: this.multilineWrapperTags, |
|
14706 prepareEditableTree: this.props.prepareEditableTree, |
|
14707 __unstableDomOnly: domOnly |
|
14708 }); |
|
14709 } |
|
14710 }, { |
|
14711 key: "isEmpty", |
|
14712 value: function isEmpty() { |
|
14713 return Object(external_this_wp_richText_["isEmpty"])(this.formatToValue(this.props.value)); |
|
14714 } |
|
14715 /** |
|
14716 * Handles a paste event. |
|
14717 * |
|
14718 * Saves the pasted data as plain text in `pastedPlainText`. |
|
14719 * |
|
14720 * @param {PasteEvent} event The paste event. |
|
14721 */ |
|
14722 |
|
14723 }, { |
|
14724 key: "onPaste", |
|
14725 value: function onPaste(event) { |
|
14726 var clipboardData = event.clipboardData; |
|
14727 var items = clipboardData.items, |
|
14728 files = clipboardData.files; // In Edge these properties can be null instead of undefined, so a more |
|
14729 // rigorous test is required over using default values. |
|
14730 |
|
14731 items = Object(external_lodash_["isNil"])(items) ? [] : items; |
|
14732 files = Object(external_lodash_["isNil"])(files) ? [] : files; |
|
14733 var plainText = ''; |
|
14734 var html = ''; // IE11 only supports `Text` as an argument for `getData` and will |
|
14735 // otherwise throw an invalid argument error, so we try the standard |
|
14736 // arguments first, then fallback to `Text` if they fail. |
|
14737 |
|
14738 try { |
|
14739 plainText = clipboardData.getData('text/plain'); |
|
14740 html = clipboardData.getData('text/html'); |
|
14741 } catch (error1) { |
|
14742 try { |
|
14743 html = clipboardData.getData('Text'); |
|
14744 } catch (error2) { |
|
14745 // Some browsers like UC Browser paste plain text by default and |
|
14746 // don't support clipboardData at all, so allow default |
|
14747 // behaviour. |
|
14748 return; |
|
14749 } |
|
14750 } |
|
14751 |
|
14752 event.preventDefault(); // Allows us to ask for this information when we get a report. |
|
14753 |
|
14754 window.console.log('Received HTML:\n\n', html); |
|
14755 window.console.log('Received plain text:\n\n', plainText); // Only process file if no HTML is present. |
|
14756 // Note: a pasted file may have the URL as plain text. |
|
14757 |
|
14758 var item = Object(external_lodash_["find"])([].concat(Object(toConsumableArray["a" /* default */])(items), Object(toConsumableArray["a" /* default */])(files)), function (_ref4) { |
|
14759 var type = _ref4.type; |
|
14760 return /^image\/(?:jpe?g|png|gif)$/.test(type); |
|
14761 }); |
|
14762 |
|
14763 if (item && !html) { |
|
14764 var file = item.getAsFile ? item.getAsFile() : item; |
|
14765 |
|
14766 var _content = Object(external_this_wp_blocks_["pasteHandler"])({ |
|
14767 HTML: "<img src=\"".concat(Object(external_this_wp_blob_["createBlobURL"])(file), "\">"), |
|
14768 mode: 'BLOCKS', |
|
14769 tagName: this.props.tagName |
|
14770 }); |
|
14771 |
|
14772 var _shouldReplace = this.props.onReplace && this.isEmpty(); // Allows us to ask for this information when we get a report. |
|
14773 |
|
14774 |
|
14775 window.console.log('Received item:\n\n', file); |
|
14776 |
|
14777 if (_shouldReplace) { |
|
14778 this.props.onReplace(_content); |
|
14779 } else if (this.onSplit) { |
|
14780 this.splitContent(_content); |
|
14781 } |
|
14782 |
|
14783 return; |
|
14784 } |
|
14785 |
|
14786 var record = this.getRecord(); // There is a selection, check if a URL is pasted. |
|
14787 |
|
14788 if (!Object(external_this_wp_richText_["isCollapsed"])(record)) { |
|
14789 var pastedText = (html || plainText).replace(/<[^>]+>/g, '').trim(); // A URL was pasted, turn the selection into a link |
|
14790 |
|
14791 if (Object(external_this_wp_url_["isURL"])(pastedText)) { |
|
14792 this.onChange(Object(external_this_wp_richText_["applyFormat"])(record, { |
|
14793 type: 'a', |
|
14794 attributes: { |
|
14795 href: Object(external_this_wp_htmlEntities_["decodeEntities"])(pastedText) |
|
14796 } |
|
14797 })); // Allows us to ask for this information when we get a report. |
|
14798 |
|
14799 window.console.log('Created link:\n\n', pastedText); |
|
14800 return; |
|
14801 } |
|
14802 } |
|
14803 |
|
14804 var shouldReplace = this.props.onReplace && this.isEmpty(); |
|
14805 var mode = 'INLINE'; |
|
14806 |
|
14807 if (shouldReplace) { |
|
14808 mode = 'BLOCKS'; |
|
14809 } else if (this.onSplit) { |
|
14810 mode = 'AUTO'; |
|
14811 } |
|
14812 |
|
14813 var content = Object(external_this_wp_blocks_["pasteHandler"])({ |
|
14814 HTML: html, |
|
14815 plainText: plainText, |
|
14816 mode: mode, |
|
14817 tagName: this.props.tagName, |
|
14818 canUserUseUnfilteredHTML: this.props.canUserUseUnfilteredHTML |
|
14819 }); |
|
14820 |
|
14821 if (typeof content === 'string') { |
|
14822 var recordToInsert = Object(external_this_wp_richText_["create"])({ |
|
14823 html: content |
|
14824 }); |
|
14825 this.onChange(Object(external_this_wp_richText_["insert"])(record, recordToInsert)); |
|
14826 } else if (this.onSplit) { |
|
14827 if (!content.length) { |
|
14828 return; |
|
14829 } |
|
14830 |
|
14831 if (shouldReplace) { |
|
14832 this.props.onReplace(content); |
|
14833 } else { |
|
14834 this.splitContent(content, { |
|
14835 paste: true |
|
14836 }); |
|
14837 } |
|
14838 } |
|
14839 } |
|
14840 /** |
|
14841 * Handles a focus event on the contenteditable field, calling the |
|
14842 * `unstableOnFocus` prop callback if one is defined. The callback does not |
|
14843 * receive any arguments. |
|
14844 * |
|
14845 * This is marked as a private API and the `unstableOnFocus` prop is not |
|
14846 * documented, as the current requirements where it is used are subject to |
|
14847 * future refactoring following `isSelected` handling. |
|
14848 * |
|
14849 * In contrast with `setFocusedElement`, this is only triggered in response |
|
14850 * to focus within the contenteditable field, whereas `setFocusedElement` |
|
14851 * is triggered on focus within any `RichText` descendent element. |
|
14852 * |
|
14853 * @see setFocusedElement |
|
14854 * |
|
14855 * @private |
|
14856 */ |
|
14857 |
|
14858 }, { |
|
14859 key: "onFocus", |
|
14860 value: function onFocus() { |
|
14861 var unstableOnFocus = this.props.unstableOnFocus; |
|
14862 |
|
14863 if (unstableOnFocus) { |
|
14864 unstableOnFocus(); |
|
14865 } |
|
14866 |
|
14867 this.recalculateBoundaryStyle(); |
|
14868 document.addEventListener('selectionchange', this.onSelectionChange); |
|
14869 } |
|
14870 }, { |
|
14871 key: "onBlur", |
|
14872 value: function onBlur() { |
|
14873 document.removeEventListener('selectionchange', this.onSelectionChange); |
|
14874 } |
|
14875 /** |
|
14876 * Handle input on the next selection change event. |
|
14877 * |
|
14878 * @param {SyntheticEvent} event Synthetic input event. |
|
14879 */ |
|
14880 |
|
14881 }, { |
|
14882 key: "onInput", |
|
14883 value: function onInput(event) { |
|
14884 // For Input Method Editor (IME), used in Chinese, Japanese, and Korean |
|
14885 // (CJK), do not trigger a change if characters are being composed. |
|
14886 // Browsers setting `isComposing` to `true` will usually emit a final |
|
14887 // `input` event when the characters are composed. |
|
14888 if (event && event.nativeEvent.isComposing) { |
|
14889 // Also don't update any selection. |
|
14890 document.removeEventListener('selectionchange', this.onSelectionChange); |
|
14891 return; |
|
14892 } |
|
14893 |
|
14894 if (event && event.nativeEvent.inputType) { |
|
14895 var inputType = event.nativeEvent.inputType; // The browser formatted something or tried to insert HTML. |
|
14896 // Overwrite it. It will be handled later by the format library if |
|
14897 // needed. |
|
14898 |
|
14899 if (inputType.indexOf('format') === 0 || INSERTION_INPUT_TYPES_TO_IGNORE.has(inputType)) { |
|
14900 this.applyRecord(this.getRecord()); |
|
14901 return; |
|
14902 } |
|
14903 } |
|
14904 |
|
14905 var value = this.createRecord(); |
|
14906 var _this$state2 = this.state, |
|
14907 _this$state2$activeFo = _this$state2.activeFormats, |
|
14908 activeFormats = _this$state2$activeFo === void 0 ? [] : _this$state2$activeFo, |
|
14909 start = _this$state2.start; // Update the formats between the last and new caret position. |
|
14910 |
|
14911 var change = Object(external_this_wp_richText_["__unstableUpdateFormats"])({ |
|
14912 value: value, |
|
14913 start: start, |
|
14914 end: value.start, |
|
14915 formats: activeFormats |
|
14916 }); |
|
14917 |
|
14918 this.onChange(change, { |
|
14919 withoutHistory: true |
|
14920 }); |
|
14921 var transformed = this.patterns.reduce(function (accumlator, transform) { |
|
14922 return transform(accumlator); |
|
14923 }, change); |
|
14924 |
|
14925 if (transformed !== change) { |
|
14926 this.onCreateUndoLevel(); |
|
14927 this.onChange(Object(objectSpread["a" /* default */])({}, transformed, { |
|
14928 activeFormats: activeFormats |
|
14929 })); |
|
14930 } // Create an undo level when input stops for over a second. |
|
14931 |
|
14932 |
|
14933 this.props.clearTimeout(this.onInput.timeout); |
|
14934 this.onInput.timeout = this.props.setTimeout(this.onCreateUndoLevel, 1000); |
|
14935 } |
|
14936 }, { |
|
14937 key: "onCompositionEnd", |
|
14938 value: function onCompositionEnd() { |
|
14939 // Ensure the value is up-to-date for browsers that don't emit a final |
|
14940 // input event after composition. |
|
14941 this.onInput(); // Tracking selection changes can be resumed. |
|
14942 |
|
14943 document.addEventListener('selectionchange', this.onSelectionChange); |
|
14944 } |
|
14945 /** |
|
14946 * Handles the `selectionchange` event: sync the selection to local state. |
|
14947 */ |
|
14948 |
|
14949 }, { |
|
14950 key: "onSelectionChange", |
|
14951 value: function onSelectionChange() { |
|
14952 var value = this.createRecord(); |
|
14953 var start = value.start, |
|
14954 end = value.end; |
|
14955 |
|
14956 if (start !== this.state.start || end !== this.state.end) { |
|
14957 var isCaretWithinFormattedText = this.props.isCaretWithinFormattedText; |
|
14958 |
|
14959 var activeFormats = Object(external_this_wp_richText_["__unstableGetActiveFormats"])(value); |
|
14960 |
|
14961 if (!isCaretWithinFormattedText && activeFormats.length) { |
|
14962 this.props.onEnterFormattedText(); |
|
14963 } else if (isCaretWithinFormattedText && !activeFormats.length) { |
|
14964 this.props.onExitFormattedText(); |
|
14965 } |
|
14966 |
|
14967 this.setState({ |
|
14968 start: start, |
|
14969 end: end, |
|
14970 activeFormats: activeFormats |
|
14971 }); |
|
14972 this.applyRecord(Object(objectSpread["a" /* default */])({}, value, { |
|
14973 activeFormats: activeFormats |
|
14974 }), { |
|
14975 domOnly: true |
|
14976 }); |
|
14977 |
|
14978 if (activeFormats.length > 0) { |
|
14979 this.recalculateBoundaryStyle(); |
|
14980 } |
|
14981 } |
|
14982 } |
|
14983 }, { |
|
14984 key: "recalculateBoundaryStyle", |
|
14985 value: function recalculateBoundaryStyle() { |
|
14986 var boundarySelector = '*[data-rich-text-format-boundary]'; |
|
14987 var element = this.editableRef.querySelector(boundarySelector); |
|
14988 |
|
14989 if (!element) { |
|
14990 return; |
|
14991 } |
|
14992 |
|
14993 var computedStyle = getComputedStyle(element); |
|
14994 var newColor = computedStyle.color.replace(')', ', 0.2)').replace('rgb', 'rgba'); |
|
14995 var selector = ".".concat(editable_className, ":focus ").concat(boundarySelector); |
|
14996 var rule = "background-color: ".concat(newColor); |
|
14997 globalStyle.innerHTML = "".concat(selector, " {").concat(rule, "}"); |
|
14998 } |
|
14999 /** |
|
15000 * Calls all registered onChangeEditableValue handlers. |
|
15001 * |
|
15002 * @param {Array} formats The formats of the latest rich-text value. |
|
15003 * @param {string} text The text of the latest rich-text value. |
|
15004 */ |
|
15005 |
|
15006 }, { |
|
15007 key: "onChangeEditableValue", |
|
15008 value: function onChangeEditableValue(_ref5) { |
|
15009 var formats = _ref5.formats, |
|
15010 text = _ref5.text; |
|
15011 Object(external_lodash_["get"])(this.props, ['onChangeEditableValue'], []).forEach(function (eventHandler) { |
|
15012 eventHandler(formats, text); |
|
15013 }); |
|
15014 } |
|
15015 /** |
|
15016 * Sync the value to global state. The node tree and selection will also be |
|
15017 * updated if differences are found. |
|
15018 * |
|
15019 * @param {Object} record The record to sync and apply. |
|
15020 * @param {Object} $2 Named options. |
|
15021 * @param {boolean} $2.withoutHistory If true, no undo level will be |
|
15022 * created. |
|
15023 */ |
|
15024 |
|
15025 }, { |
|
15026 key: "onChange", |
|
15027 value: function onChange(record) { |
|
15028 var _ref6 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, |
|
15029 withoutHistory = _ref6.withoutHistory; |
|
15030 |
|
15031 this.applyRecord(record); |
|
15032 var start = record.start, |
|
15033 end = record.end, |
|
15034 _record$activeFormats = record.activeFormats, |
|
15035 activeFormats = _record$activeFormats === void 0 ? [] : _record$activeFormats; |
|
15036 this.onChangeEditableValue(record); |
|
15037 this.savedContent = this.valueToFormat(record); |
|
15038 this.props.onChange(this.savedContent); |
|
15039 this.setState({ |
|
15040 start: start, |
|
15041 end: end, |
|
15042 activeFormats: activeFormats |
|
15043 }); |
|
15044 |
|
15045 if (!withoutHistory) { |
|
15046 this.onCreateUndoLevel(); |
|
15047 } |
|
15048 } |
|
15049 }, { |
|
15050 key: "onCreateUndoLevel", |
|
15051 value: function onCreateUndoLevel() { |
|
15052 // If the content is the same, no level needs to be created. |
|
15053 if (this.lastHistoryValue === this.savedContent) { |
|
15054 return; |
|
15055 } |
|
15056 |
|
15057 this.props.onCreateUndoLevel(); |
|
15058 this.lastHistoryValue = this.savedContent; |
|
15059 } |
|
15060 /** |
|
15061 * Handles a delete keyDown event to handle merge or removal for collapsed |
|
15062 * selection where caret is at directional edge: forward for a delete key, |
|
15063 * reverse for a backspace key. |
|
15064 * |
|
15065 * @link https://en.wikipedia.org/wiki/Caret_navigation |
|
15066 * |
|
15067 * @param {KeyboardEvent} event Keydown event. |
|
15068 */ |
|
15069 |
|
15070 }, { |
|
15071 key: "onDeleteKeyDown", |
|
15072 value: function onDeleteKeyDown(event) { |
|
15073 var _this$props = this.props, |
|
15074 onMerge = _this$props.onMerge, |
|
15075 onRemove = _this$props.onRemove; |
|
15076 |
|
15077 if (!onMerge && !onRemove) { |
|
15078 return; |
|
15079 } |
|
15080 |
|
15081 var keyCode = event.keyCode; |
|
15082 var isReverse = keyCode === external_this_wp_keycodes_["BACKSPACE"]; // Only process delete if the key press occurs at uncollapsed edge. |
|
15083 |
|
15084 if (!Object(external_this_wp_richText_["isCollapsed"])(this.createRecord())) { |
|
15085 return; |
|
15086 } |
|
15087 |
|
15088 var empty = this.isEmpty(); // It is important to consider emptiness because an empty container |
|
15089 // will include a padding BR node _after_ the caret, so in a forward |
|
15090 // deletion the isHorizontalEdge function will incorrectly interpret the |
|
15091 // presence of the BR node as not being at the edge. |
|
15092 |
|
15093 var isEdge = empty || Object(external_this_wp_dom_["isHorizontalEdge"])(this.editableRef, isReverse); |
|
15094 |
|
15095 if (!isEdge) { |
|
15096 return; |
|
15097 } |
|
15098 |
|
15099 if (onMerge) { |
|
15100 onMerge(!isReverse); |
|
15101 } // Only handle remove on Backspace. This serves dual-purpose of being |
|
15102 // an intentional user interaction distinguishing between Backspace and |
|
15103 // Delete to remove the empty field, but also to avoid merge & remove |
|
15104 // causing destruction of two fields (merge, then removed merged). |
|
15105 |
|
15106 |
|
15107 if (onRemove && empty && isReverse) { |
|
15108 onRemove(!isReverse); |
|
15109 } |
|
15110 |
|
15111 event.preventDefault(); |
|
15112 } |
|
15113 /** |
|
15114 * Handles a keydown event. |
|
15115 * |
|
15116 * @param {SyntheticEvent} event A synthetic keyboard event. |
|
15117 */ |
|
15118 |
|
15119 }, { |
|
15120 key: "onKeyDown", |
|
15121 value: function onKeyDown(event) { |
|
15122 var keyCode = event.keyCode, |
|
15123 shiftKey = event.shiftKey, |
|
15124 altKey = event.altKey, |
|
15125 metaKey = event.metaKey, |
|
15126 ctrlKey = event.ctrlKey; |
|
15127 |
|
15128 if ( // Only override left and right keys without modifiers pressed. |
|
15129 !shiftKey && !altKey && !metaKey && !ctrlKey && (keyCode === external_this_wp_keycodes_["LEFT"] || keyCode === external_this_wp_keycodes_["RIGHT"])) { |
|
15130 this.handleHorizontalNavigation(event); |
|
15131 } // Use the space key in list items (at the start of an item) to indent |
|
15132 // the list item. |
|
15133 |
|
15134 |
|
15135 if (keyCode === external_this_wp_keycodes_["SPACE"] && this.multilineTag === 'li') { |
|
15136 var value = this.createRecord(); |
|
15137 |
|
15138 if (Object(external_this_wp_richText_["isCollapsed"])(value)) { |
|
15139 var text = value.text, |
|
15140 start = value.start; |
|
15141 var characterBefore = text[start - 1]; // The caret must be at the start of a line. |
|
15142 |
|
15143 if (!characterBefore || characterBefore === external_this_wp_richText_["LINE_SEPARATOR"]) { |
|
15144 this.onChange(Object(external_this_wp_richText_["indentListItems"])(value, { |
|
15145 type: this.props.tagName |
|
15146 })); |
|
15147 event.preventDefault(); |
|
15148 } |
|
15149 } |
|
15150 } |
|
15151 |
|
15152 if (keyCode === external_this_wp_keycodes_["DELETE"] || keyCode === external_this_wp_keycodes_["BACKSPACE"]) { |
|
15153 var _value = this.createRecord(); |
|
15154 |
|
15155 var replacements = _value.replacements, |
|
15156 _text = _value.text, |
|
15157 _start = _value.start, |
|
15158 end = _value.end; // Always handle full content deletion ourselves. |
|
15159 |
|
15160 if (_start === 0 && end !== 0 && end === _value.text.length) { |
|
15161 this.onChange(Object(external_this_wp_richText_["remove"])(_value)); |
|
15162 event.preventDefault(); |
|
15163 return; |
|
15164 } |
|
15165 |
|
15166 if (this.multilineTag) { |
|
15167 var newValue; |
|
15168 |
|
15169 if (keyCode === external_this_wp_keycodes_["BACKSPACE"]) { |
|
15170 var index = _start - 1; |
|
15171 |
|
15172 if (_text[index] === external_this_wp_richText_["LINE_SEPARATOR"]) { |
|
15173 var collapsed = Object(external_this_wp_richText_["isCollapsed"])(_value); // If the line separator that is about te be removed |
|
15174 // contains wrappers, remove the wrappers first. |
|
15175 |
|
15176 if (collapsed && replacements[index] && replacements[index].length) { |
|
15177 var newReplacements = replacements.slice(); |
|
15178 newReplacements[index] = replacements[index].slice(0, -1); |
|
15179 newValue = Object(objectSpread["a" /* default */])({}, _value, { |
|
15180 replacements: newReplacements |
|
15181 }); |
|
15182 } else { |
|
15183 newValue = Object(external_this_wp_richText_["remove"])(_value, // Only remove the line if the selection is |
|
15184 // collapsed, otherwise remove the selection. |
|
15185 collapsed ? _start - 1 : _start, end); |
|
15186 } |
|
15187 } |
|
15188 } else if (_text[end] === external_this_wp_richText_["LINE_SEPARATOR"]) { |
|
15189 var _collapsed = Object(external_this_wp_richText_["isCollapsed"])(_value); // If the line separator that is about te be removed |
|
15190 // contains wrappers, remove the wrappers first. |
|
15191 |
|
15192 |
|
15193 if (_collapsed && replacements[end] && replacements[end].length) { |
|
15194 var _newReplacements = replacements.slice(); |
|
15195 |
|
15196 _newReplacements[end] = replacements[end].slice(0, -1); |
|
15197 newValue = Object(objectSpread["a" /* default */])({}, _value, { |
|
15198 replacements: _newReplacements |
|
15199 }); |
|
15200 } else { |
|
15201 newValue = Object(external_this_wp_richText_["remove"])(_value, _start, // Only remove the line if the selection is |
|
15202 // collapsed, otherwise remove the selection. |
|
15203 _collapsed ? end + 1 : end); |
|
15204 } |
|
15205 } |
|
15206 |
|
15207 if (newValue) { |
|
15208 this.onChange(newValue); |
|
15209 event.preventDefault(); |
|
15210 } |
|
15211 } |
|
15212 |
|
15213 this.onDeleteKeyDown(event); |
|
15214 } else if (keyCode === external_this_wp_keycodes_["ENTER"]) { |
|
15215 event.preventDefault(); |
|
15216 var record = this.createRecord(); |
|
15217 |
|
15218 if (this.props.onReplace) { |
|
15219 var _text2 = Object(external_this_wp_richText_["getTextContent"])(record); |
|
15220 |
|
15221 var transformation = Object(external_this_wp_blocks_["findTransform"])(this.enterPatterns, function (item) { |
|
15222 return item.regExp.test(_text2); |
|
15223 }); |
|
15224 |
|
15225 if (transformation) { |
|
15226 this.props.onReplace([transformation.transform({ |
|
15227 content: _text2 |
|
15228 })]); |
|
15229 return; |
|
15230 } |
|
15231 } |
|
15232 |
|
15233 if (this.multilineTag) { |
|
15234 if (event.shiftKey) { |
|
15235 this.onChange(Object(external_this_wp_richText_["insertLineBreak"])(record)); |
|
15236 } else if (this.onSplit && Object(external_this_wp_richText_["isEmptyLine"])(record)) { |
|
15237 this.onSplit.apply(this, Object(toConsumableArray["a" /* default */])(Object(external_this_wp_richText_["split"])(record).map(this.valueToFormat))); |
|
15238 } else { |
|
15239 this.onChange(Object(external_this_wp_richText_["insertLineSeparator"])(record)); |
|
15240 } |
|
15241 } else if (event.shiftKey || !this.onSplit) { |
|
15242 this.onChange(Object(external_this_wp_richText_["insertLineBreak"])(record)); |
|
15243 } else { |
|
15244 this.splitContent(); |
|
15245 } |
|
15246 } |
|
15247 } |
|
15248 /** |
|
15249 * Handles horizontal keyboard navigation when no modifiers are pressed. The |
|
15250 * navigation is handled separately to move correctly around format |
|
15251 * boundaries. |
|
15252 * |
|
15253 * @param {SyntheticEvent} event A synthetic keyboard event. |
|
15254 */ |
|
15255 |
|
15256 }, { |
|
15257 key: "handleHorizontalNavigation", |
|
15258 value: function handleHorizontalNavigation(event) { |
|
15259 var _this2 = this; |
|
15260 |
|
15261 var value = this.createRecord(); |
|
15262 var formats = value.formats, |
|
15263 text = value.text, |
|
15264 start = value.start, |
|
15265 end = value.end; |
|
15266 var _this$state$activeFor = this.state.activeFormats, |
|
15267 activeFormats = _this$state$activeFor === void 0 ? [] : _this$state$activeFor; |
|
15268 var collapsed = Object(external_this_wp_richText_["isCollapsed"])(value); // To do: ideally, we should look at visual position instead. |
|
15269 |
|
15270 var _getComputedStyle = getComputedStyle(this.editableRef), |
|
15271 direction = _getComputedStyle.direction; |
|
15272 |
|
15273 var reverseKey = direction === 'rtl' ? external_this_wp_keycodes_["RIGHT"] : external_this_wp_keycodes_["LEFT"]; |
|
15274 var isReverse = event.keyCode === reverseKey; // If the selection is collapsed and at the very start, do nothing if |
|
15275 // navigating backward. |
|
15276 // If the selection is collapsed and at the very end, do nothing if |
|
15277 // navigating forward. |
|
15278 |
|
15279 if (collapsed && activeFormats.length === 0) { |
|
15280 if (start === 0 && isReverse) { |
|
15281 return; |
|
15282 } |
|
15283 |
|
15284 if (end === text.length && !isReverse) { |
|
15285 return; |
|
15286 } |
|
15287 } // If the selection is not collapsed, let the browser handle collapsing |
|
15288 // the selection for now. Later we could expand this logic to set |
|
15289 // boundary positions if needed. |
|
15290 |
|
15291 |
|
15292 if (!collapsed) { |
|
15293 return; |
|
15294 } // In all other cases, prevent default behaviour. |
|
15295 |
|
15296 |
|
15297 event.preventDefault(); |
|
15298 var formatsBefore = formats[start - 1] || []; |
|
15299 var formatsAfter = formats[start] || []; |
|
15300 var newActiveFormatsLength = activeFormats.length; |
|
15301 var source = formatsAfter; |
|
15302 |
|
15303 if (formatsBefore.length > formatsAfter.length) { |
|
15304 source = formatsBefore; |
|
15305 } // If the amount of formats before the caret and after the caret is |
|
15306 // different, the caret is at a format boundary. |
|
15307 |
|
15308 |
|
15309 if (formatsBefore.length < formatsAfter.length) { |
|
15310 if (!isReverse && activeFormats.length < formatsAfter.length) { |
|
15311 newActiveFormatsLength++; |
|
15312 } |
|
15313 |
|
15314 if (isReverse && activeFormats.length > formatsBefore.length) { |
|
15315 newActiveFormatsLength--; |
|
15316 } |
|
15317 } else if (formatsBefore.length > formatsAfter.length) { |
|
15318 if (!isReverse && activeFormats.length > formatsAfter.length) { |
|
15319 newActiveFormatsLength--; |
|
15320 } |
|
15321 |
|
15322 if (isReverse && activeFormats.length < formatsBefore.length) { |
|
15323 newActiveFormatsLength++; |
|
15324 } |
|
15325 } // Wait for boundary class to be added. |
|
15326 |
|
15327 |
|
15328 setTimeout(function () { |
|
15329 return _this2.recalculateBoundaryStyle(); |
|
15330 }); |
|
15331 |
|
15332 if (newActiveFormatsLength !== activeFormats.length) { |
|
15333 var newActiveFormats = source.slice(0, newActiveFormatsLength); |
|
15334 this.applyRecord(Object(objectSpread["a" /* default */])({}, value, { |
|
15335 activeFormats: newActiveFormats |
|
15336 })); |
|
15337 this.setState({ |
|
15338 activeFormats: newActiveFormats |
|
15339 }); |
|
15340 return; |
|
15341 } |
|
15342 |
|
15343 var newPos = value.start + (isReverse ? -1 : 1); |
|
15344 this.setState({ |
|
15345 start: newPos, |
|
15346 end: newPos |
|
15347 }); |
|
15348 this.applyRecord(Object(objectSpread["a" /* default */])({}, value, { |
|
15349 start: newPos, |
|
15350 end: newPos, |
|
15351 activeFormats: isReverse ? formatsBefore : formatsAfter |
|
15352 })); |
|
15353 } |
|
15354 /** |
|
15355 * Splits the content at the location of the selection. |
|
15356 * |
|
15357 * Replaces the content of the editor inside this element with the contents |
|
15358 * before the selection. Sends the elements after the selection to the `onSplit` |
|
15359 * handler. |
|
15360 * |
|
15361 * @param {Array} blocks The blocks to add after the split point. |
|
15362 * @param {Object} context The context for splitting. |
|
15363 */ |
|
15364 |
|
15365 }, { |
|
15366 key: "splitContent", |
|
15367 value: function splitContent() { |
|
15368 var blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
|
15369 var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
15370 |
|
15371 if (!this.onSplit) { |
|
15372 return; |
|
15373 } |
|
15374 |
|
15375 var record = this.createRecord(); |
|
15376 |
|
15377 var _split = Object(external_this_wp_richText_["split"])(record), |
|
15378 _split2 = Object(slicedToArray["a" /* default */])(_split, 2), |
|
15379 before = _split2[0], |
|
15380 after = _split2[1]; // In case split occurs at the trailing or leading edge of the field, |
|
15381 // assume that the before/after values respectively reflect the current |
|
15382 // value. This also provides an opportunity for the parent component to |
|
15383 // determine whether the before/after value has changed using a trivial |
|
15384 // strict equality operation. |
|
15385 |
|
15386 |
|
15387 if (Object(external_this_wp_richText_["isEmpty"])(after)) { |
|
15388 before = record; |
|
15389 } else if (Object(external_this_wp_richText_["isEmpty"])(before)) { |
|
15390 after = record; |
|
15391 } // If pasting and the split would result in no content other than the |
|
15392 // pasted blocks, remove the before and after blocks. |
|
15393 |
|
15394 |
|
15395 if (context.paste) { |
|
15396 before = Object(external_this_wp_richText_["isEmpty"])(before) ? null : before; |
|
15397 after = Object(external_this_wp_richText_["isEmpty"])(after) ? null : after; |
|
15398 } |
|
15399 |
|
15400 if (before) { |
|
15401 before = this.valueToFormat(before); |
|
15402 } |
|
15403 |
|
15404 if (after) { |
|
15405 after = this.valueToFormat(after); |
|
15406 } |
|
15407 |
|
15408 this.onSplit.apply(this, [before, after].concat(Object(toConsumableArray["a" /* default */])(blocks))); |
|
15409 } |
|
15410 /** |
|
15411 * Select object when they are clicked. The browser will not set any |
|
15412 * selection when clicking e.g. an image. |
|
15413 * |
|
15414 * @param {SyntheticEvent} event Synthetic mousedown or touchstart event. |
|
15415 */ |
|
15416 |
|
15417 }, { |
|
15418 key: "onPointerDown", |
|
15419 value: function onPointerDown(event) { |
|
15420 var target = event.target; // If the child element has no text content, it must be an object. |
|
15421 |
|
15422 if (target === this.editableRef || target.textContent) { |
|
15423 return; |
|
15424 } |
|
15425 |
|
15426 var parentNode = target.parentNode; |
|
15427 var index = Array.from(parentNode.childNodes).indexOf(target); |
|
15428 var range = target.ownerDocument.createRange(); |
|
15429 var selection = rich_text_getSelection(); |
|
15430 range.setStart(target.parentNode, index); |
|
15431 range.setEnd(target.parentNode, index + 1); |
|
15432 selection.removeAllRanges(); |
|
15433 selection.addRange(range); |
|
15434 } |
|
15435 }, { |
|
15436 key: "componentDidUpdate", |
|
15437 value: function componentDidUpdate(prevProps) { |
|
15438 var _this3 = this; |
|
15439 |
|
15440 var _this$props2 = this.props, |
|
15441 tagName = _this$props2.tagName, |
|
15442 value = _this$props2.value, |
|
15443 isSelected = _this$props2.isSelected; |
|
15444 |
|
15445 if (tagName === prevProps.tagName && value !== prevProps.value && value !== this.savedContent) { |
|
15446 // Handle deprecated `children` and `node` sources. |
|
15447 // The old way of passing a value with the `node` matcher required |
|
15448 // the value to be mapped first, creating a new array each time, so |
|
15449 // a shallow check wouldn't work. We need to check deep equality. |
|
15450 // This is only executed for a deprecated API and will eventually be |
|
15451 // removed. |
|
15452 if (Array.isArray(value) && Object(external_lodash_["isEqual"])(value, this.savedContent)) { |
|
15453 return; |
|
15454 } |
|
15455 |
|
15456 var record = this.formatToValue(value); |
|
15457 |
|
15458 if (isSelected) { |
|
15459 var prevRecord = this.formatToValue(prevProps.value); |
|
15460 var length = Object(external_this_wp_richText_["getTextContent"])(prevRecord).length; |
|
15461 record.start = length; |
|
15462 record.end = length; |
|
15463 } |
|
15464 |
|
15465 this.applyRecord(record); |
|
15466 this.savedContent = value; |
|
15467 } // If any format props update, reapply value. |
|
15468 |
|
15469 |
|
15470 var shouldReapply = Object.keys(this.props).some(function (name) { |
|
15471 if (name.indexOf('format_') !== 0) { |
|
15472 return false; |
|
15473 } // Allow primitives and arrays: |
|
15474 |
|
15475 |
|
15476 if (!Object(external_lodash_["isPlainObject"])(_this3.props[name])) { |
|
15477 return _this3.props[name] !== prevProps[name]; |
|
15478 } |
|
15479 |
|
15480 return Object.keys(_this3.props[name]).some(function (subName) { |
|
15481 return _this3.props[name][subName] !== prevProps[name][subName]; |
|
15482 }); |
|
15483 }); |
|
15484 |
|
15485 if (shouldReapply) { |
|
15486 var _record = this.formatToValue(value); // Maintain the previous selection if the instance is currently |
|
15487 // selected. |
|
15488 |
|
15489 |
|
15490 if (isSelected) { |
|
15491 _record.start = this.state.start; |
|
15492 _record.end = this.state.end; |
|
15493 } |
|
15494 |
|
15495 this.applyRecord(_record); |
|
15496 } |
|
15497 } |
|
15498 /** |
|
15499 * Get props that are provided by formats to modify RichText. |
|
15500 * |
|
15501 * @return {Object} Props that start with 'format_'. |
|
15502 */ |
|
15503 |
|
15504 }, { |
|
15505 key: "getFormatProps", |
|
15506 value: function getFormatProps() { |
|
15507 return Object(external_lodash_["pickBy"])(this.props, function (propValue, name) { |
|
15508 return name.startsWith('format_'); |
|
15509 }); |
|
15510 } |
|
15511 /** |
|
15512 * Converts the outside data structure to our internal representation. |
|
15513 * |
|
15514 * @param {*} value The outside value, data type depends on props. |
|
15515 * @return {Object} An internal rich-text value. |
|
15516 */ |
|
15517 |
|
15518 }, { |
|
15519 key: "formatToValue", |
|
15520 value: function formatToValue(value) { |
|
15521 // Handle deprecated `children` and `node` sources. |
|
15522 if (Array.isArray(value)) { |
|
15523 return Object(external_this_wp_richText_["create"])({ |
|
15524 html: external_this_wp_blocks_["children"].toHTML(value), |
|
15525 multilineTag: this.multilineTag, |
|
15526 multilineWrapperTags: this.multilineWrapperTags |
|
15527 }); |
|
15528 } |
|
15529 |
|
15530 if (this.props.format === 'string') { |
|
15531 return Object(external_this_wp_richText_["create"])({ |
|
15532 html: value, |
|
15533 multilineTag: this.multilineTag, |
|
15534 multilineWrapperTags: this.multilineWrapperTags |
|
15535 }); |
|
15536 } // Guard for blocks passing `null` in onSplit callbacks. May be removed |
|
15537 // if onSplit is revised to not pass a `null` value. |
|
15538 |
|
15539 |
|
15540 if (value === null) { |
|
15541 return Object(external_this_wp_richText_["create"])(); |
|
15542 } |
|
15543 |
|
15544 return value; |
|
15545 } |
|
15546 }, { |
|
15547 key: "valueToEditableHTML", |
|
15548 value: function valueToEditableHTML(value) { |
|
15549 return Object(external_this_wp_richText_["unstableToDom"])({ |
|
15550 value: value, |
|
15551 multilineTag: this.multilineTag, |
|
15552 prepareEditableTree: this.props.prepareEditableTree |
|
15553 }).body.innerHTML; |
|
15554 } |
|
15555 /** |
|
15556 * Removes editor only formats from the value. |
|
15557 * |
|
15558 * Editor only formats are applied using `prepareEditableTree`, so we need to |
|
15559 * remove them before converting the internal state |
|
15560 * |
|
15561 * @param {Object} value The internal rich-text value. |
|
15562 * @return {Object} A new rich-text value. |
|
15563 */ |
|
15564 |
|
15565 }, { |
|
15566 key: "removeEditorOnlyFormats", |
|
15567 value: function removeEditorOnlyFormats(value) { |
|
15568 this.props.formatTypes.forEach(function (formatType) { |
|
15569 // Remove formats created by prepareEditableTree, because they are editor only. |
|
15570 if (formatType.__experimentalCreatePrepareEditableTree) { |
|
15571 value = Object(external_this_wp_richText_["removeFormat"])(value, formatType.name, 0, value.text.length); |
|
15572 } |
|
15573 }); |
|
15574 return value; |
|
15575 } |
|
15576 /** |
|
15577 * Converts the internal value to the external data format. |
|
15578 * |
|
15579 * @param {Object} value The internal rich-text value. |
|
15580 * @return {*} The external data format, data type depends on props. |
|
15581 */ |
|
15582 |
|
15583 }, { |
|
15584 key: "valueToFormat", |
|
15585 value: function valueToFormat(value) { |
|
15586 value = this.removeEditorOnlyFormats(value); // Handle deprecated `children` and `node` sources. |
|
15587 |
|
15588 if (this.usedDeprecatedChildrenSource) { |
|
15589 return external_this_wp_blocks_["children"].fromDOM(Object(external_this_wp_richText_["unstableToDom"])({ |
|
15590 value: value, |
|
15591 multilineTag: this.multilineTag, |
|
15592 isEditableTree: false |
|
15593 }).body.childNodes); |
|
15594 } |
|
15595 |
|
15596 if (this.props.format === 'string') { |
|
15597 return Object(external_this_wp_richText_["toHTMLString"])({ |
|
15598 value: value, |
|
15599 multilineTag: this.multilineTag |
|
15600 }); |
|
15601 } |
|
15602 |
|
15603 return value; |
|
15604 } |
|
15605 }, { |
|
15606 key: "render", |
|
15607 value: function render() { |
|
15608 var _this4 = this; |
|
15609 |
|
15610 var _this$props3 = this.props, |
|
15611 _this$props3$tagName = _this$props3.tagName, |
|
15612 Tagname = _this$props3$tagName === void 0 ? 'div' : _this$props3$tagName, |
|
15613 style = _this$props3.style, |
|
15614 wrapperClassName = _this$props3.wrapperClassName, |
|
15615 className = _this$props3.className, |
|
15616 _this$props3$inlineTo = _this$props3.inlineToolbar, |
|
15617 inlineToolbar = _this$props3$inlineTo === void 0 ? false : _this$props3$inlineTo, |
|
15618 formattingControls = _this$props3.formattingControls, |
|
15619 placeholder = _this$props3.placeholder, |
|
15620 _this$props3$keepPlac = _this$props3.keepPlaceholderOnFocus, |
|
15621 keepPlaceholderOnFocus = _this$props3$keepPlac === void 0 ? false : _this$props3$keepPlac, |
|
15622 isSelected = _this$props3.isSelected, |
|
15623 autocompleters = _this$props3.autocompleters, |
|
15624 onTagNameChange = _this$props3.onTagNameChange; // Generating a key that includes `tagName` ensures that if the tag |
|
15625 // changes, we replace the relevant element. This is needed because we |
|
15626 // prevent Editable component updates. |
|
15627 |
|
15628 var key = Tagname; |
|
15629 var MultilineTag = this.multilineTag; |
|
15630 var ariaProps = aria_pickAriaProps(this.props); |
|
15631 var isPlaceholderVisible = placeholder && (!isSelected || keepPlaceholderOnFocus) && this.isEmpty(); |
|
15632 var classes = classnames_default()(wrapperClassName, 'editor-rich-text block-editor-rich-text'); |
|
15633 var record = this.getRecord(); |
|
15634 return Object(external_this_wp_element_["createElement"])("div", { |
|
15635 className: classes, |
|
15636 onFocus: this.setFocusedElement |
|
15637 }, isSelected && this.multilineTag === 'li' && Object(external_this_wp_element_["createElement"])(list_edit_ListEdit, { |
|
15638 onTagNameChange: onTagNameChange, |
|
15639 tagName: Tagname, |
|
15640 value: record, |
|
15641 onChange: this.onChange |
|
15642 }), isSelected && !inlineToolbar && Object(external_this_wp_element_["createElement"])(block_format_controls, null, Object(external_this_wp_element_["createElement"])(format_toolbar, { |
|
15643 controls: formattingControls |
|
15644 })), isSelected && inlineToolbar && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IsolatedEventContainer"], { |
|
15645 className: "editor-rich-text__inline-toolbar block-editor-rich-text__inline-toolbar" |
|
15646 }, Object(external_this_wp_element_["createElement"])(format_toolbar, { |
|
15647 controls: formattingControls |
|
15648 })), Object(external_this_wp_element_["createElement"])(autocomplete, { |
|
15649 onReplace: this.props.onReplace, |
|
15650 completers: autocompleters, |
|
15651 record: record, |
|
15652 onChange: this.onChange |
|
15653 }, function (_ref7) { |
|
15654 var listBoxId = _ref7.listBoxId, |
|
15655 activeId = _ref7.activeId; |
|
15656 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])(editable_Editable, Object(esm_extends["a" /* default */])({ |
|
15657 tagName: Tagname, |
|
15658 style: style, |
|
15659 record: record, |
|
15660 valueToEditableHTML: _this4.valueToEditableHTML, |
|
15661 isPlaceholderVisible: isPlaceholderVisible, |
|
15662 "aria-label": placeholder, |
|
15663 "aria-autocomplete": "list", |
|
15664 "aria-owns": listBoxId, |
|
15665 "aria-activedescendant": activeId |
|
15666 }, ariaProps, { |
|
15667 className: className, |
|
15668 key: key, |
|
15669 onPaste: _this4.onPaste, |
|
15670 onInput: _this4.onInput, |
|
15671 onCompositionEnd: _this4.onCompositionEnd, |
|
15672 onKeyDown: _this4.onKeyDown, |
|
15673 onFocus: _this4.onFocus, |
|
15674 onBlur: _this4.onBlur, |
|
15675 onMouseDown: _this4.onPointerDown, |
|
15676 onTouchStart: _this4.onPointerDown, |
|
15677 setRef: _this4.setRef |
|
15678 })), isPlaceholderVisible && Object(external_this_wp_element_["createElement"])(Tagname, { |
|
15679 className: classnames_default()('editor-rich-text__editable block-editor-rich-text__editable', className), |
|
15680 style: style |
|
15681 }, MultilineTag ? Object(external_this_wp_element_["createElement"])(MultilineTag, null, placeholder) : placeholder), isSelected && Object(external_this_wp_element_["createElement"])(format_edit, { |
|
15682 value: record, |
|
15683 onChange: _this4.onChange |
|
15684 })); |
|
15685 }), isSelected && Object(external_this_wp_element_["createElement"])(RemoveBrowserShortcuts, null)); |
|
15686 } |
|
15687 }]); |
|
15688 |
|
15689 return RichText; |
|
15690 }(external_this_wp_element_["Component"]); |
|
15691 rich_text_RichText.defaultProps = { |
|
15692 formattingControls: ['bold', 'italic', 'link', 'strikethrough'], |
|
15693 format: 'string', |
|
15694 value: '' |
|
15695 }; |
|
15696 var RichTextContainer = Object(external_this_wp_compose_["compose"])([external_this_wp_compose_["withInstanceId"], context_withBlockEditContext(function (context, ownProps) { |
|
15697 // When explicitly set as not selected, do nothing. |
|
15698 if (ownProps.isSelected === false) { |
|
15699 return { |
|
15700 clientId: context.clientId |
|
15701 }; |
|
15702 } // When explicitly set as selected, use the value stored in the context instead. |
|
15703 |
|
15704 |
|
15705 if (ownProps.isSelected === true) { |
|
15706 return { |
|
15707 isSelected: context.isSelected, |
|
15708 clientId: context.clientId |
|
15709 }; |
|
15710 } // Ensures that only one RichText component can be focused. |
|
15711 |
|
15712 |
|
15713 return { |
|
15714 isSelected: context.isSelected && context.focusedElement === ownProps.instanceId, |
|
15715 setFocusedElement: context.setFocusedElement, |
|
15716 clientId: context.clientId |
|
15717 }; |
|
15718 }), Object(external_this_wp_data_["withSelect"])(function (select) { |
|
15719 // This should probably be moved to the block editor settings. |
|
15720 var _select = select('core/editor'), |
|
15721 canUserUseUnfilteredHTML = _select.canUserUseUnfilteredHTML; |
|
15722 |
|
15723 var _select2 = select('core/block-editor'), |
|
15724 isCaretWithinFormattedText = _select2.isCaretWithinFormattedText; |
|
15725 |
|
15726 var _select3 = select('core/rich-text'), |
|
15727 getFormatTypes = _select3.getFormatTypes; |
|
15728 |
|
15729 return { |
|
15730 canUserUseUnfilteredHTML: canUserUseUnfilteredHTML(), |
|
15731 isCaretWithinFormattedText: isCaretWithinFormattedText(), |
|
15732 formatTypes: getFormatTypes() |
|
15733 }; |
|
15734 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
15735 var _dispatch = dispatch('core/block-editor'), |
|
15736 __unstableMarkLastChangeAsPersistent = _dispatch.__unstableMarkLastChangeAsPersistent, |
|
15737 enterFormattedText = _dispatch.enterFormattedText, |
|
15738 exitFormattedText = _dispatch.exitFormattedText; |
|
15739 |
|
15740 return { |
|
15741 onCreateUndoLevel: __unstableMarkLastChangeAsPersistent, |
|
15742 onEnterFormattedText: enterFormattedText, |
|
15743 onExitFormattedText: exitFormattedText |
|
15744 }; |
|
15745 }), external_this_wp_compose_["withSafeTimeout"], Object(external_this_wp_components_["withFilters"])('experimentalRichText')])(rich_text_RichText); |
|
15746 |
|
15747 RichTextContainer.Content = function (_ref8) { |
|
15748 var value = _ref8.value, |
|
15749 Tag = _ref8.tagName, |
|
15750 multiline = _ref8.multiline, |
|
15751 props = Object(objectWithoutProperties["a" /* default */])(_ref8, ["value", "tagName", "multiline"]); |
|
15752 |
|
15753 var html = value; |
|
15754 var MultilineTag; |
|
15755 |
|
15756 if (multiline === true || multiline === 'p' || multiline === 'li') { |
|
15757 MultilineTag = multiline === true ? 'p' : multiline; |
|
15758 } // Handle deprecated `children` and `node` sources. |
|
15759 |
|
15760 |
|
15761 if (Array.isArray(value)) { |
|
15762 html = external_this_wp_blocks_["children"].toHTML(value); |
|
15763 } |
|
15764 |
|
15765 if (!html && MultilineTag) { |
|
15766 html = "<".concat(MultilineTag, "></").concat(MultilineTag, ">"); |
|
15767 } |
|
15768 |
|
15769 var content = Object(external_this_wp_element_["createElement"])(external_this_wp_element_["RawHTML"], null, html); |
|
15770 |
|
15771 if (Tag) { |
|
15772 return Object(external_this_wp_element_["createElement"])(Tag, Object(external_lodash_["omit"])(props, ['format']), content); |
|
15773 } |
|
15774 |
|
15775 return content; |
|
15776 }; |
|
15777 |
|
15778 RichTextContainer.isEmpty = function () { |
|
15779 var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; |
|
15780 |
|
15781 // Handle deprecated `children` and `node` sources. |
|
15782 if (Array.isArray(value)) { |
|
15783 return !value || value.length === 0; |
|
15784 } |
|
15785 |
|
15786 return value.length === 0; |
|
15787 }; |
|
15788 |
|
15789 RichTextContainer.Content.defaultProps = { |
|
15790 format: 'string', |
|
15791 value: '' |
|
15792 }; |
|
15793 /* harmony default export */ var rich_text = (RichTextContainer); |
|
15794 |
|
15795 |
|
15796 |
|
15797 |
|
15798 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-upload/index.js |
|
15799 /** |
|
15800 * WordPress dependencies |
|
15801 */ |
|
15802 |
|
15803 /** |
|
15804 * This is a placeholder for the media upload component necessary to make it possible to provide |
|
15805 * an integration with the core blocks that handle media files. By default it renders nothing but |
|
15806 * it provides a way to have it overridden with the `editor.MediaUpload` filter. |
|
15807 * |
|
15808 * @return {WPElement} Media upload element. |
|
15809 */ |
|
15810 |
|
15811 var MediaUpload = function MediaUpload() { |
|
15812 return null; |
|
15813 }; // Todo: rename the filter |
|
15814 |
|
15815 |
|
15816 /* harmony default export */ var media_upload = (Object(external_this_wp_components_["withFilters"])('editor.MediaUpload')(MediaUpload)); |
|
15817 |
|
15818 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/index.js |
|
15819 |
|
15820 |
|
15821 |
|
15822 |
|
15823 |
|
15824 |
|
15825 |
|
15826 |
|
15827 |
|
15828 |
|
15829 /** |
|
15830 * WordPress dependencies |
|
15831 */ |
|
15832 |
|
15833 |
|
15834 |
|
15835 |
|
15836 var url_popover_URLPopover = |
|
15837 /*#__PURE__*/ |
|
15838 function (_Component) { |
|
15839 Object(inherits["a" /* default */])(URLPopover, _Component); |
|
15840 |
|
15841 function URLPopover() { |
|
15842 var _this; |
|
15843 |
|
15844 Object(classCallCheck["a" /* default */])(this, URLPopover); |
|
15845 |
|
15846 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(URLPopover).apply(this, arguments)); |
|
15847 _this.toggleSettingsVisibility = _this.toggleSettingsVisibility.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
15848 _this.state = { |
|
15849 isSettingsExpanded: false |
|
15850 }; |
|
15851 return _this; |
|
15852 } |
|
15853 |
|
15854 Object(createClass["a" /* default */])(URLPopover, [{ |
|
15855 key: "toggleSettingsVisibility", |
|
15856 value: function toggleSettingsVisibility() { |
|
15857 this.setState({ |
|
15858 isSettingsExpanded: !this.state.isSettingsExpanded |
|
15859 }); |
|
15860 } |
|
15861 }, { |
|
15862 key: "render", |
|
15863 value: function render() { |
|
15864 var _this$props = this.props, |
|
15865 children = _this$props.children, |
|
15866 renderSettings = _this$props.renderSettings, |
|
15867 _this$props$position = _this$props.position, |
|
15868 position = _this$props$position === void 0 ? 'bottom center' : _this$props$position, |
|
15869 _this$props$focusOnMo = _this$props.focusOnMount, |
|
15870 focusOnMount = _this$props$focusOnMo === void 0 ? 'firstElement' : _this$props$focusOnMo, |
|
15871 popoverProps = Object(objectWithoutProperties["a" /* default */])(_this$props, ["children", "renderSettings", "position", "focusOnMount"]); |
|
15872 |
|
15873 var isSettingsExpanded = this.state.isSettingsExpanded; |
|
15874 var showSettings = !!renderSettings && isSettingsExpanded; |
|
15875 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Popover"], Object(esm_extends["a" /* default */])({ |
|
15876 className: "editor-url-popover block-editor-url-popover", |
|
15877 focusOnMount: focusOnMount, |
|
15878 position: position |
|
15879 }, popoverProps), Object(external_this_wp_element_["createElement"])("div", { |
|
15880 className: "editor-url-popover__row block-editor-url-popover__row" |
|
15881 }, children, !!renderSettings && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], { |
|
15882 className: "editor-url-popover__settings-toggle block-editor-url-popover__settings-toggle", |
|
15883 icon: "arrow-down-alt2", |
|
15884 label: Object(external_this_wp_i18n_["__"])('Link Settings'), |
|
15885 onClick: this.toggleSettingsVisibility, |
|
15886 "aria-expanded": isSettingsExpanded |
|
15887 })), showSettings && Object(external_this_wp_element_["createElement"])("div", { |
|
15888 className: "editor-url-popover__row block-editor-url-popover__row editor-url-popover__settings block-editor-url-popover__settings" |
|
15889 }, renderSettings())); |
|
15890 } |
|
15891 }]); |
|
15892 |
|
15893 return URLPopover; |
|
15894 }(external_this_wp_element_["Component"]); |
|
15895 |
|
15896 /* harmony default export */ var url_popover = (url_popover_URLPopover); |
|
15897 |
|
15898 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-placeholder/index.js |
|
15899 |
|
15900 |
|
15901 |
|
15902 |
|
15903 |
|
15904 |
|
15905 |
|
15906 |
|
15907 |
|
15908 /** |
|
15909 * External dependencies |
|
15910 */ |
|
15911 |
|
15912 |
|
15913 /** |
|
15914 * WordPress dependencies |
|
15915 */ |
|
15916 |
|
15917 |
|
15918 |
|
15919 |
|
15920 |
|
15921 |
|
15922 /** |
|
15923 * Internal dependencies |
|
15924 */ |
|
15925 |
|
15926 |
|
15927 |
|
15928 |
|
15929 |
|
15930 var media_placeholder_InsertFromURLPopover = function InsertFromURLPopover(_ref) { |
|
15931 var src = _ref.src, |
|
15932 onChange = _ref.onChange, |
|
15933 onSubmit = _ref.onSubmit, |
|
15934 onClose = _ref.onClose; |
|
15935 return Object(external_this_wp_element_["createElement"])(url_popover, { |
|
15936 onClose: onClose |
|
15937 }, Object(external_this_wp_element_["createElement"])("form", { |
|
15938 className: "editor-media-placeholder__url-input-form block-editor-media-placeholder__url-input-form", |
|
15939 onSubmit: onSubmit |
|
15940 }, Object(external_this_wp_element_["createElement"])("input", { |
|
15941 className: "editor-media-placeholder__url-input-field block-editor-media-placeholder__url-input-field", |
|
15942 type: "url", |
|
15943 "aria-label": Object(external_this_wp_i18n_["__"])('URL'), |
|
15944 placeholder: Object(external_this_wp_i18n_["__"])('Paste or type URL'), |
|
15945 onChange: onChange, |
|
15946 value: src |
|
15947 }), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], { |
|
15948 className: "editor-media-placeholder__url-input-submit-button block-editor-media-placeholder__url-input-submit-button", |
|
15949 icon: "editor-break", |
|
15950 label: Object(external_this_wp_i18n_["__"])('Apply'), |
|
15951 type: "submit" |
|
15952 }))); |
|
15953 }; |
|
15954 |
|
15955 var media_placeholder_MediaPlaceholder = |
|
15956 /*#__PURE__*/ |
|
15957 function (_Component) { |
|
15958 Object(inherits["a" /* default */])(MediaPlaceholder, _Component); |
|
15959 |
|
15960 function MediaPlaceholder() { |
|
15961 var _this; |
|
15962 |
|
15963 Object(classCallCheck["a" /* default */])(this, MediaPlaceholder); |
|
15964 |
|
15965 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(MediaPlaceholder).apply(this, arguments)); |
|
15966 _this.state = { |
|
15967 src: '', |
|
15968 isURLInputVisible: false |
|
15969 }; |
|
15970 _this.onChangeSrc = _this.onChangeSrc.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
15971 _this.onSubmitSrc = _this.onSubmitSrc.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
15972 _this.onUpload = _this.onUpload.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
15973 _this.onFilesUpload = _this.onFilesUpload.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
15974 _this.openURLInput = _this.openURLInput.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
15975 _this.closeURLInput = _this.closeURLInput.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
15976 return _this; |
|
15977 } |
|
15978 |
|
15979 Object(createClass["a" /* default */])(MediaPlaceholder, [{ |
|
15980 key: "onlyAllowsImages", |
|
15981 value: function onlyAllowsImages() { |
|
15982 var allowedTypes = this.props.allowedTypes; |
|
15983 |
|
15984 if (!allowedTypes) { |
|
15985 return false; |
|
15986 } |
|
15987 |
|
15988 return Object(external_lodash_["every"])(allowedTypes, function (allowedType) { |
|
15989 return allowedType === 'image' || Object(external_lodash_["startsWith"])(allowedType, 'image/'); |
|
15990 }); |
|
15991 } |
|
15992 }, { |
|
15993 key: "componentDidMount", |
|
15994 value: function componentDidMount() { |
|
15995 this.setState({ |
|
15996 src: Object(external_lodash_["get"])(this.props.value, ['src'], '') |
|
15997 }); |
|
15998 } |
|
15999 }, { |
|
16000 key: "componentDidUpdate", |
|
16001 value: function componentDidUpdate(prevProps) { |
|
16002 if (Object(external_lodash_["get"])(prevProps.value, ['src'], '') !== Object(external_lodash_["get"])(this.props.value, ['src'], '')) { |
|
16003 this.setState({ |
|
16004 src: Object(external_lodash_["get"])(this.props.value, ['src'], '') |
|
16005 }); |
|
16006 } |
|
16007 } |
|
16008 }, { |
|
16009 key: "onChangeSrc", |
|
16010 value: function onChangeSrc(event) { |
|
16011 this.setState({ |
|
16012 src: event.target.value |
|
16013 }); |
|
16014 } |
|
16015 }, { |
|
16016 key: "onSubmitSrc", |
|
16017 value: function onSubmitSrc(event) { |
|
16018 event.preventDefault(); |
|
16019 |
|
16020 if (this.state.src && this.props.onSelectURL) { |
|
16021 this.props.onSelectURL(this.state.src); |
|
16022 this.closeURLInput(); |
|
16023 } |
|
16024 } |
|
16025 }, { |
|
16026 key: "onUpload", |
|
16027 value: function onUpload(event) { |
|
16028 this.onFilesUpload(event.target.files); |
|
16029 } |
|
16030 }, { |
|
16031 key: "onFilesUpload", |
|
16032 value: function onFilesUpload(files) { |
|
16033 var _this$props = this.props, |
|
16034 onSelect = _this$props.onSelect, |
|
16035 multiple = _this$props.multiple, |
|
16036 onError = _this$props.onError, |
|
16037 allowedTypes = _this$props.allowedTypes, |
|
16038 mediaUpload = _this$props.mediaUpload; |
|
16039 var setMedia = multiple ? onSelect : function (_ref2) { |
|
16040 var _ref3 = Object(slicedToArray["a" /* default */])(_ref2, 1), |
|
16041 media = _ref3[0]; |
|
16042 |
|
16043 return onSelect(media); |
|
16044 }; |
|
16045 mediaUpload({ |
|
16046 allowedTypes: allowedTypes, |
|
16047 filesList: files, |
|
16048 onFileChange: setMedia, |
|
16049 onError: onError |
|
16050 }); |
|
16051 } |
|
16052 }, { |
|
16053 key: "openURLInput", |
|
16054 value: function openURLInput() { |
|
16055 this.setState({ |
|
16056 isURLInputVisible: true |
|
16057 }); |
|
16058 } |
|
16059 }, { |
|
16060 key: "closeURLInput", |
|
16061 value: function closeURLInput() { |
|
16062 this.setState({ |
|
16063 isURLInputVisible: false |
|
16064 }); |
|
16065 } |
|
16066 }, { |
|
16067 key: "render", |
|
16068 value: function render() { |
|
16069 var _this$props2 = this.props, |
|
16070 accept = _this$props2.accept, |
|
16071 icon = _this$props2.icon, |
|
16072 className = _this$props2.className, |
|
16073 _this$props2$labels = _this$props2.labels, |
|
16074 labels = _this$props2$labels === void 0 ? {} : _this$props2$labels, |
|
16075 onSelect = _this$props2.onSelect, |
|
16076 _this$props2$value = _this$props2.value, |
|
16077 value = _this$props2$value === void 0 ? {} : _this$props2$value, |
|
16078 onSelectURL = _this$props2.onSelectURL, |
|
16079 _this$props2$onHTMLDr = _this$props2.onHTMLDrop, |
|
16080 onHTMLDrop = _this$props2$onHTMLDr === void 0 ? external_lodash_["noop"] : _this$props2$onHTMLDr, |
|
16081 _this$props2$multiple = _this$props2.multiple, |
|
16082 multiple = _this$props2$multiple === void 0 ? false : _this$props2$multiple, |
|
16083 notices = _this$props2.notices, |
|
16084 _this$props2$allowedT = _this$props2.allowedTypes, |
|
16085 allowedTypes = _this$props2$allowedT === void 0 ? [] : _this$props2$allowedT, |
|
16086 hasUploadPermissions = _this$props2.hasUploadPermissions, |
|
16087 mediaUpload = _this$props2.mediaUpload; |
|
16088 var _this$state = this.state, |
|
16089 isURLInputVisible = _this$state.isURLInputVisible, |
|
16090 src = _this$state.src; |
|
16091 var instructions = labels.instructions || ''; |
|
16092 var title = labels.title || ''; |
|
16093 |
|
16094 if (!hasUploadPermissions && !onSelectURL) { |
|
16095 instructions = Object(external_this_wp_i18n_["__"])('To edit this block, you need permission to upload media.'); |
|
16096 } |
|
16097 |
|
16098 if (!instructions || !title) { |
|
16099 var isOneType = 1 === allowedTypes.length; |
|
16100 var isAudio = isOneType && 'audio' === allowedTypes[0]; |
|
16101 var isImage = isOneType && 'image' === allowedTypes[0]; |
|
16102 var isVideo = isOneType && 'video' === allowedTypes[0]; |
|
16103 |
|
16104 if (!instructions) { |
|
16105 if (hasUploadPermissions) { |
|
16106 instructions = Object(external_this_wp_i18n_["__"])('Drag a media file, upload a new one or select a file from your library.'); |
|
16107 |
|
16108 if (isAudio) { |
|
16109 instructions = Object(external_this_wp_i18n_["__"])('Drag an audio, upload a new one or select a file from your library.'); |
|
16110 } else if (isImage) { |
|
16111 instructions = Object(external_this_wp_i18n_["__"])('Drag an image, upload a new one or select a file from your library.'); |
|
16112 } else if (isVideo) { |
|
16113 instructions = Object(external_this_wp_i18n_["__"])('Drag a video, upload a new one or select a file from your library.'); |
|
16114 } |
|
16115 } else if (!hasUploadPermissions && onSelectURL) { |
|
16116 instructions = Object(external_this_wp_i18n_["__"])('Given your current role, you can only link a media file, you cannot upload.'); |
|
16117 |
|
16118 if (isAudio) { |
|
16119 instructions = Object(external_this_wp_i18n_["__"])('Given your current role, you can only link an audio, you cannot upload.'); |
|
16120 } else if (isImage) { |
|
16121 instructions = Object(external_this_wp_i18n_["__"])('Given your current role, you can only link an image, you cannot upload.'); |
|
16122 } else if (isVideo) { |
|
16123 instructions = Object(external_this_wp_i18n_["__"])('Given your current role, you can only link a video, you cannot upload.'); |
|
16124 } |
|
16125 } |
|
16126 } |
|
16127 |
|
16128 if (!title) { |
|
16129 title = Object(external_this_wp_i18n_["__"])('Media'); |
|
16130 |
|
16131 if (isAudio) { |
|
16132 title = Object(external_this_wp_i18n_["__"])('Audio'); |
|
16133 } else if (isImage) { |
|
16134 title = Object(external_this_wp_i18n_["__"])('Image'); |
|
16135 } else if (isVideo) { |
|
16136 title = Object(external_this_wp_i18n_["__"])('Video'); |
|
16137 } |
|
16138 } |
|
16139 } |
|
16140 |
|
16141 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Placeholder"], { |
|
16142 icon: icon, |
|
16143 label: title, |
|
16144 instructions: instructions, |
|
16145 className: classnames_default()('editor-media-placeholder block-editor-media-placeholder', className), |
|
16146 notices: notices |
|
16147 }, Object(external_this_wp_element_["createElement"])(check, null, !!mediaUpload && Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["DropZone"], { |
|
16148 onFilesDrop: this.onFilesUpload, |
|
16149 onHTMLDrop: onHTMLDrop |
|
16150 }), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["FormFileUpload"], { |
|
16151 isLarge: true, |
|
16152 className: "editor-media-placeholder__button block-editor-media-placeholder__button", |
|
16153 onChange: this.onUpload, |
|
16154 accept: accept, |
|
16155 multiple: multiple |
|
16156 }, Object(external_this_wp_i18n_["__"])('Upload'))), Object(external_this_wp_element_["createElement"])(media_upload, { |
|
16157 gallery: multiple && this.onlyAllowsImages(), |
|
16158 multiple: multiple, |
|
16159 onSelect: onSelect, |
|
16160 allowedTypes: allowedTypes, |
|
16161 value: value.id, |
|
16162 render: function render(_ref4) { |
|
16163 var open = _ref4.open; |
|
16164 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
16165 isLarge: true, |
|
16166 className: "editor-media-placeholder__button block-editor-media-placeholder__button", |
|
16167 onClick: open |
|
16168 }, Object(external_this_wp_i18n_["__"])('Media Library')); |
|
16169 } |
|
16170 })), onSelectURL && Object(external_this_wp_element_["createElement"])("div", { |
|
16171 className: "editor-media-placeholder__url-input-container block-editor-media-placeholder__url-input-container" |
|
16172 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
16173 className: "editor-media-placeholder__button block-editor-media-placeholder__button", |
|
16174 onClick: this.openURLInput, |
|
16175 isToggled: isURLInputVisible, |
|
16176 isLarge: true |
|
16177 }, Object(external_this_wp_i18n_["__"])('Insert from URL')), isURLInputVisible && Object(external_this_wp_element_["createElement"])(media_placeholder_InsertFromURLPopover, { |
|
16178 src: src, |
|
16179 onChange: this.onChangeSrc, |
|
16180 onSubmit: this.onSubmitSrc, |
|
16181 onClose: this.closeURLInput |
|
16182 }))); |
|
16183 } |
|
16184 }]); |
|
16185 |
|
16186 return MediaPlaceholder; |
|
16187 }(external_this_wp_element_["Component"]); |
|
16188 var media_placeholder_applyWithSelect = Object(external_this_wp_data_["withSelect"])(function (select) { |
|
16189 var _select = select('core'), |
|
16190 canUser = _select.canUser; |
|
16191 |
|
16192 var _select2 = select('core/block-editor'), |
|
16193 getSettings = _select2.getSettings; |
|
16194 |
|
16195 return { |
|
16196 hasUploadPermissions: Object(external_lodash_["defaultTo"])(canUser('create', 'media'), true), |
|
16197 mediaUpload: getSettings().__experimentalMediaUpload |
|
16198 }; |
|
16199 }); |
|
16200 /* harmony default export */ var media_placeholder = (Object(external_this_wp_compose_["compose"])(media_placeholder_applyWithSelect, Object(external_this_wp_components_["withFilters"])('editor.MediaPlaceholder'))(media_placeholder_MediaPlaceholder)); |
|
16201 |
|
16202 // EXTERNAL MODULE: external {"this":["wp","apiFetch"]} |
|
16203 var external_this_wp_apiFetch_ = __webpack_require__(33); |
|
16204 var external_this_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_apiFetch_); |
|
16205 |
|
16206 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-input/index.js |
|
16207 |
|
16208 |
|
16209 |
|
16210 |
|
16211 |
|
16212 |
|
16213 |
|
16214 |
|
16215 /** |
|
16216 * External dependencies |
|
16217 */ |
|
16218 |
|
16219 |
|
16220 |
|
16221 /** |
|
16222 * WordPress dependencies |
|
16223 */ |
|
16224 |
|
16225 |
|
16226 |
|
16227 |
|
16228 |
|
16229 |
|
16230 |
|
16231 |
|
16232 // Since URLInput is rendered in the context of other inputs, but should be |
|
16233 // considered a separate modal node, prevent keyboard events from propagating |
|
16234 // as being considered from the input. |
|
16235 |
|
16236 var stopEventPropagation = function stopEventPropagation(event) { |
|
16237 return event.stopPropagation(); |
|
16238 }; |
|
16239 |
|
16240 var url_input_URLInput = |
|
16241 /*#__PURE__*/ |
|
16242 function (_Component) { |
|
16243 Object(inherits["a" /* default */])(URLInput, _Component); |
|
16244 |
|
16245 function URLInput(_ref) { |
|
16246 var _this; |
|
16247 |
|
16248 var autocompleteRef = _ref.autocompleteRef; |
|
16249 |
|
16250 Object(classCallCheck["a" /* default */])(this, URLInput); |
|
16251 |
|
16252 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(URLInput).apply(this, arguments)); |
|
16253 _this.onChange = _this.onChange.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
16254 _this.onKeyDown = _this.onKeyDown.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
16255 _this.autocompleteRef = autocompleteRef || Object(external_this_wp_element_["createRef"])(); |
|
16256 _this.inputRef = Object(external_this_wp_element_["createRef"])(); |
|
16257 _this.updateSuggestions = Object(external_lodash_["throttle"])(_this.updateSuggestions.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))), 200); |
|
16258 _this.suggestionNodes = []; |
|
16259 _this.state = { |
|
16260 posts: [], |
|
16261 showSuggestions: false, |
|
16262 selectedSuggestion: null |
|
16263 }; |
|
16264 return _this; |
|
16265 } |
|
16266 |
|
16267 Object(createClass["a" /* default */])(URLInput, [{ |
|
16268 key: "componentDidUpdate", |
|
16269 value: function componentDidUpdate() { |
|
16270 var _this2 = this; |
|
16271 |
|
16272 var _this$state = this.state, |
|
16273 showSuggestions = _this$state.showSuggestions, |
|
16274 selectedSuggestion = _this$state.selectedSuggestion; // only have to worry about scrolling selected suggestion into view |
|
16275 // when already expanded |
|
16276 |
|
16277 if (showSuggestions && selectedSuggestion !== null && !this.scrollingIntoView) { |
|
16278 this.scrollingIntoView = true; |
|
16279 dom_scroll_into_view_lib_default()(this.suggestionNodes[selectedSuggestion], this.autocompleteRef.current, { |
|
16280 onlyScrollIfNeeded: true |
|
16281 }); |
|
16282 setTimeout(function () { |
|
16283 _this2.scrollingIntoView = false; |
|
16284 }, 100); |
|
16285 } |
|
16286 } |
|
16287 }, { |
|
16288 key: "componentWillUnmount", |
|
16289 value: function componentWillUnmount() { |
|
16290 delete this.suggestionsRequest; |
|
16291 } |
|
16292 }, { |
|
16293 key: "bindSuggestionNode", |
|
16294 value: function bindSuggestionNode(index) { |
|
16295 var _this3 = this; |
|
16296 |
|
16297 return function (ref) { |
|
16298 _this3.suggestionNodes[index] = ref; |
|
16299 }; |
|
16300 } |
|
16301 }, { |
|
16302 key: "updateSuggestions", |
|
16303 value: function updateSuggestions(value) { |
|
16304 var _this4 = this; |
|
16305 |
|
16306 // Show the suggestions after typing at least 2 characters |
|
16307 // and also for URLs |
|
16308 if (value.length < 2 || /^https?:/.test(value)) { |
|
16309 this.setState({ |
|
16310 showSuggestions: false, |
|
16311 selectedSuggestion: null, |
|
16312 loading: false |
|
16313 }); |
|
16314 return; |
|
16315 } |
|
16316 |
|
16317 this.setState({ |
|
16318 showSuggestions: true, |
|
16319 selectedSuggestion: null, |
|
16320 loading: true |
|
16321 }); |
|
16322 var request = external_this_wp_apiFetch_default()({ |
|
16323 path: Object(external_this_wp_url_["addQueryArgs"])('/wp/v2/search', { |
|
16324 search: value, |
|
16325 per_page: 20, |
|
16326 type: 'post' |
|
16327 }) |
|
16328 }); |
|
16329 request.then(function (posts) { |
|
16330 // A fetch Promise doesn't have an abort option. It's mimicked by |
|
16331 // comparing the request reference in on the instance, which is |
|
16332 // reset or deleted on subsequent requests or unmounting. |
|
16333 if (_this4.suggestionsRequest !== request) { |
|
16334 return; |
|
16335 } |
|
16336 |
|
16337 _this4.setState({ |
|
16338 posts: posts, |
|
16339 loading: false |
|
16340 }); |
|
16341 |
|
16342 if (!!posts.length) { |
|
16343 _this4.props.debouncedSpeak(Object(external_this_wp_i18n_["sprintf"])(Object(external_this_wp_i18n_["_n"])('%d result found, use up and down arrow keys to navigate.', '%d results found, use up and down arrow keys to navigate.', posts.length), posts.length), 'assertive'); |
|
16344 } else { |
|
16345 _this4.props.debouncedSpeak(Object(external_this_wp_i18n_["__"])('No results.'), 'assertive'); |
|
16346 } |
|
16347 }).catch(function () { |
|
16348 if (_this4.suggestionsRequest === request) { |
|
16349 _this4.setState({ |
|
16350 loading: false |
|
16351 }); |
|
16352 } |
|
16353 }); |
|
16354 this.suggestionsRequest = request; |
|
16355 } |
|
16356 }, { |
|
16357 key: "onChange", |
|
16358 value: function onChange(event) { |
|
16359 var inputValue = event.target.value; |
|
16360 this.props.onChange(inputValue); |
|
16361 this.updateSuggestions(inputValue); |
|
16362 } |
|
16363 }, { |
|
16364 key: "onKeyDown", |
|
16365 value: function onKeyDown(event) { |
|
16366 var _this$state2 = this.state, |
|
16367 showSuggestions = _this$state2.showSuggestions, |
|
16368 selectedSuggestion = _this$state2.selectedSuggestion, |
|
16369 posts = _this$state2.posts, |
|
16370 loading = _this$state2.loading; // If the suggestions are not shown or loading, we shouldn't handle the arrow keys |
|
16371 // We shouldn't preventDefault to allow block arrow keys navigation |
|
16372 |
|
16373 if (!showSuggestions || !posts.length || loading) { |
|
16374 // In the Windows version of Firefox the up and down arrows don't move the caret |
|
16375 // within an input field like they do for Mac Firefox/Chrome/Safari. This causes |
|
16376 // a form of focus trapping that is disruptive to the user experience. This disruption |
|
16377 // only happens if the caret is not in the first or last position in the text input. |
|
16378 // See: https://github.com/WordPress/gutenberg/issues/5693#issuecomment-436684747 |
|
16379 switch (event.keyCode) { |
|
16380 // When UP is pressed, if the caret is at the start of the text, move it to the 0 |
|
16381 // position. |
|
16382 case external_this_wp_keycodes_["UP"]: |
|
16383 { |
|
16384 if (0 !== event.target.selectionStart) { |
|
16385 event.stopPropagation(); |
|
16386 event.preventDefault(); // Set the input caret to position 0 |
|
16387 |
|
16388 event.target.setSelectionRange(0, 0); |
|
16389 } |
|
16390 |
|
16391 break; |
|
16392 } |
|
16393 // When DOWN is pressed, if the caret is not at the end of the text, move it to the |
|
16394 // last position. |
|
16395 |
|
16396 case external_this_wp_keycodes_["DOWN"]: |
|
16397 { |
|
16398 if (this.props.value.length !== event.target.selectionStart) { |
|
16399 event.stopPropagation(); |
|
16400 event.preventDefault(); // Set the input caret to the last position |
|
16401 |
|
16402 event.target.setSelectionRange(this.props.value.length, this.props.value.length); |
|
16403 } |
|
16404 |
|
16405 break; |
|
16406 } |
|
16407 } |
|
16408 |
|
16409 return; |
|
16410 } |
|
16411 |
|
16412 var post = this.state.posts[this.state.selectedSuggestion]; |
|
16413 |
|
16414 switch (event.keyCode) { |
|
16415 case external_this_wp_keycodes_["UP"]: |
|
16416 { |
|
16417 event.stopPropagation(); |
|
16418 event.preventDefault(); |
|
16419 var previousIndex = !selectedSuggestion ? posts.length - 1 : selectedSuggestion - 1; |
|
16420 this.setState({ |
|
16421 selectedSuggestion: previousIndex |
|
16422 }); |
|
16423 break; |
|
16424 } |
|
16425 |
|
16426 case external_this_wp_keycodes_["DOWN"]: |
|
16427 { |
|
16428 event.stopPropagation(); |
|
16429 event.preventDefault(); |
|
16430 var nextIndex = selectedSuggestion === null || selectedSuggestion === posts.length - 1 ? 0 : selectedSuggestion + 1; |
|
16431 this.setState({ |
|
16432 selectedSuggestion: nextIndex |
|
16433 }); |
|
16434 break; |
|
16435 } |
|
16436 |
|
16437 case external_this_wp_keycodes_["TAB"]: |
|
16438 { |
|
16439 if (this.state.selectedSuggestion !== null) { |
|
16440 this.selectLink(post); // Announce a link has been selected when tabbing away from the input field. |
|
16441 |
|
16442 this.props.speak(Object(external_this_wp_i18n_["__"])('Link selected.')); |
|
16443 } |
|
16444 |
|
16445 break; |
|
16446 } |
|
16447 |
|
16448 case external_this_wp_keycodes_["ENTER"]: |
|
16449 { |
|
16450 if (this.state.selectedSuggestion !== null) { |
|
16451 event.stopPropagation(); |
|
16452 this.selectLink(post); |
|
16453 } |
|
16454 |
|
16455 break; |
|
16456 } |
|
16457 } |
|
16458 } |
|
16459 }, { |
|
16460 key: "selectLink", |
|
16461 value: function selectLink(post) { |
|
16462 this.props.onChange(post.url, post); |
|
16463 this.setState({ |
|
16464 selectedSuggestion: null, |
|
16465 showSuggestions: false |
|
16466 }); |
|
16467 } |
|
16468 }, { |
|
16469 key: "handleOnClick", |
|
16470 value: function handleOnClick(post) { |
|
16471 this.selectLink(post); // Move focus to the input field when a link suggestion is clicked. |
|
16472 |
|
16473 this.inputRef.current.focus(); |
|
16474 } |
|
16475 }, { |
|
16476 key: "render", |
|
16477 value: function render() { |
|
16478 var _this5 = this; |
|
16479 |
|
16480 var _this$props = this.props, |
|
16481 _this$props$value = _this$props.value, |
|
16482 value = _this$props$value === void 0 ? '' : _this$props$value, |
|
16483 _this$props$autoFocus = _this$props.autoFocus, |
|
16484 autoFocus = _this$props$autoFocus === void 0 ? true : _this$props$autoFocus, |
|
16485 instanceId = _this$props.instanceId, |
|
16486 className = _this$props.className; |
|
16487 var _this$state3 = this.state, |
|
16488 showSuggestions = _this$state3.showSuggestions, |
|
16489 posts = _this$state3.posts, |
|
16490 selectedSuggestion = _this$state3.selectedSuggestion, |
|
16491 loading = _this$state3.loading; |
|
16492 /* eslint-disable jsx-a11y/no-autofocus */ |
|
16493 |
|
16494 return Object(external_this_wp_element_["createElement"])("div", { |
|
16495 className: classnames_default()('editor-url-input block-editor-url-input', className) |
|
16496 }, Object(external_this_wp_element_["createElement"])("input", { |
|
16497 autoFocus: autoFocus, |
|
16498 type: "text", |
|
16499 "aria-label": Object(external_this_wp_i18n_["__"])('URL'), |
|
16500 required: true, |
|
16501 value: value, |
|
16502 onChange: this.onChange, |
|
16503 onInput: stopEventPropagation, |
|
16504 placeholder: Object(external_this_wp_i18n_["__"])('Paste URL or type to search'), |
|
16505 onKeyDown: this.onKeyDown, |
|
16506 role: "combobox", |
|
16507 "aria-expanded": showSuggestions, |
|
16508 "aria-autocomplete": "list", |
|
16509 "aria-owns": "block-editor-url-input-suggestions-".concat(instanceId), |
|
16510 "aria-activedescendant": selectedSuggestion !== null ? "block-editor-url-input-suggestion-".concat(instanceId, "-").concat(selectedSuggestion) : undefined, |
|
16511 ref: this.inputRef |
|
16512 }), loading && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Spinner"], null), showSuggestions && !!posts.length && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Popover"], { |
|
16513 position: "bottom", |
|
16514 noArrow: true, |
|
16515 focusOnMount: false |
|
16516 }, Object(external_this_wp_element_["createElement"])("div", { |
|
16517 className: "editor-url-input__suggestions block-editor-url-input__suggestions", |
|
16518 id: "editor-url-input-suggestions-".concat(instanceId), |
|
16519 ref: this.autocompleteRef, |
|
16520 role: "listbox" |
|
16521 }, posts.map(function (post, index) { |
|
16522 return Object(external_this_wp_element_["createElement"])("button", { |
|
16523 key: post.id, |
|
16524 role: "option", |
|
16525 tabIndex: "-1", |
|
16526 id: "block-editor-url-input-suggestion-".concat(instanceId, "-").concat(index), |
|
16527 ref: _this5.bindSuggestionNode(index), |
|
16528 className: classnames_default()('editor-url-input__suggestion block-editor-url-input__suggestion', { |
|
16529 'is-selected': index === selectedSuggestion |
|
16530 }), |
|
16531 onClick: function onClick() { |
|
16532 return _this5.handleOnClick(post); |
|
16533 }, |
|
16534 "aria-selected": index === selectedSuggestion |
|
16535 }, Object(external_this_wp_htmlEntities_["decodeEntities"])(post.title) || Object(external_this_wp_i18n_["__"])('(no title)')); |
|
16536 })))); |
|
16537 /* eslint-enable jsx-a11y/no-autofocus */ |
|
16538 } |
|
16539 }]); |
|
16540 |
|
16541 return URLInput; |
|
16542 }(external_this_wp_element_["Component"]); |
|
16543 |
|
16544 /* harmony default export */ var url_input = (Object(external_this_wp_components_["withSpokenMessages"])(Object(external_this_wp_compose_["withInstanceId"])(url_input_URLInput))); |
|
16545 |
|
16546 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-input/button.js |
|
16547 |
|
16548 |
|
16549 |
|
16550 |
|
16551 |
|
16552 |
|
16553 |
|
16554 |
|
16555 /** |
|
16556 * External dependencies |
|
16557 */ |
|
16558 |
|
16559 /** |
|
16560 * WordPress dependencies |
|
16561 */ |
|
16562 |
|
16563 |
|
16564 |
|
16565 |
|
16566 /** |
|
16567 * Internal dependencies |
|
16568 */ |
|
16569 |
|
16570 |
|
16571 |
|
16572 var button_URLInputButton = |
|
16573 /*#__PURE__*/ |
|
16574 function (_Component) { |
|
16575 Object(inherits["a" /* default */])(URLInputButton, _Component); |
|
16576 |
|
16577 function URLInputButton() { |
|
16578 var _this; |
|
16579 |
|
16580 Object(classCallCheck["a" /* default */])(this, URLInputButton); |
|
16581 |
|
16582 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(URLInputButton).apply(this, arguments)); |
|
16583 _this.toggle = _this.toggle.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
16584 _this.submitLink = _this.submitLink.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
16585 _this.state = { |
|
16586 expanded: false |
|
16587 }; |
|
16588 return _this; |
|
16589 } |
|
16590 |
|
16591 Object(createClass["a" /* default */])(URLInputButton, [{ |
|
16592 key: "toggle", |
|
16593 value: function toggle() { |
|
16594 this.setState({ |
|
16595 expanded: !this.state.expanded |
|
16596 }); |
|
16597 } |
|
16598 }, { |
|
16599 key: "submitLink", |
|
16600 value: function submitLink(event) { |
|
16601 event.preventDefault(); |
|
16602 this.toggle(); |
|
16603 } |
|
16604 }, { |
|
16605 key: "render", |
|
16606 value: function render() { |
|
16607 var _this$props = this.props, |
|
16608 url = _this$props.url, |
|
16609 onChange = _this$props.onChange; |
|
16610 var expanded = this.state.expanded; |
|
16611 var buttonLabel = url ? Object(external_this_wp_i18n_["__"])('Edit Link') : Object(external_this_wp_i18n_["__"])('Insert Link'); |
|
16612 return Object(external_this_wp_element_["createElement"])("div", { |
|
16613 className: "editor-url-input__button block-editor-url-input__button" |
|
16614 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], { |
|
16615 icon: "admin-links", |
|
16616 label: buttonLabel, |
|
16617 onClick: this.toggle, |
|
16618 className: classnames_default()('components-toolbar__control', { |
|
16619 'is-active': url |
|
16620 }) |
|
16621 }), expanded && Object(external_this_wp_element_["createElement"])("form", { |
|
16622 className: "editor-url-input__button-modal block-editor-url-input__button-modal", |
|
16623 onSubmit: this.submitLink |
|
16624 }, Object(external_this_wp_element_["createElement"])("div", { |
|
16625 className: "editor-url-input__button-modal-line block-editor-url-input__button-modal-line" |
|
16626 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], { |
|
16627 className: "editor-url-input__back block-editor-url-input__back", |
|
16628 icon: "arrow-left-alt", |
|
16629 label: Object(external_this_wp_i18n_["__"])('Close'), |
|
16630 onClick: this.toggle |
|
16631 }), Object(external_this_wp_element_["createElement"])(url_input, { |
|
16632 value: url || '', |
|
16633 onChange: onChange |
|
16634 }), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], { |
|
16635 icon: "editor-break", |
|
16636 label: Object(external_this_wp_i18n_["__"])('Submit'), |
|
16637 type: "submit" |
|
16638 })))); |
|
16639 } |
|
16640 }]); |
|
16641 |
|
16642 return URLInputButton; |
|
16643 }(external_this_wp_element_["Component"]); |
|
16644 |
|
16645 /* harmony default export */ var url_input_button = (button_URLInputButton); |
|
16646 |
|
16647 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-actions/index.js |
|
16648 /** |
|
16649 * External dependencies |
|
16650 */ |
|
16651 |
|
16652 /** |
|
16653 * WordPress dependencies |
|
16654 */ |
|
16655 |
|
16656 |
|
16657 |
|
16658 |
|
16659 |
|
16660 function BlockActions(_ref) { |
|
16661 var onDuplicate = _ref.onDuplicate, |
|
16662 onRemove = _ref.onRemove, |
|
16663 onInsertBefore = _ref.onInsertBefore, |
|
16664 onInsertAfter = _ref.onInsertAfter, |
|
16665 isLocked = _ref.isLocked, |
|
16666 canDuplicate = _ref.canDuplicate, |
|
16667 children = _ref.children; |
|
16668 return children({ |
|
16669 onDuplicate: onDuplicate, |
|
16670 onRemove: onRemove, |
|
16671 onInsertAfter: onInsertAfter, |
|
16672 onInsertBefore: onInsertBefore, |
|
16673 isLocked: isLocked, |
|
16674 canDuplicate: canDuplicate |
|
16675 }); |
|
16676 } |
|
16677 |
|
16678 /* harmony default export */ var block_actions = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select, props) { |
|
16679 var _select = select('core/block-editor'), |
|
16680 getBlocksByClientId = _select.getBlocksByClientId, |
|
16681 getTemplateLock = _select.getTemplateLock, |
|
16682 getBlockRootClientId = _select.getBlockRootClientId; |
|
16683 |
|
16684 var blocks = getBlocksByClientId(props.clientIds); |
|
16685 var canDuplicate = Object(external_lodash_["every"])(blocks, function (block) { |
|
16686 return !!block && Object(external_this_wp_blocks_["hasBlockSupport"])(block.name, 'multiple', true); |
|
16687 }); |
|
16688 var rootClientId = getBlockRootClientId(props.clientIds[0]); |
|
16689 return { |
|
16690 isLocked: !!getTemplateLock(rootClientId), |
|
16691 blocks: blocks, |
|
16692 canDuplicate: canDuplicate, |
|
16693 rootClientId: rootClientId, |
|
16694 extraProps: props |
|
16695 }; |
|
16696 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, props, _ref2) { |
|
16697 var select = _ref2.select; |
|
16698 var clientIds = props.clientIds, |
|
16699 rootClientId = props.rootClientId, |
|
16700 blocks = props.blocks, |
|
16701 isLocked = props.isLocked, |
|
16702 canDuplicate = props.canDuplicate; |
|
16703 |
|
16704 var _dispatch = dispatch('core/block-editor'), |
|
16705 insertBlocks = _dispatch.insertBlocks, |
|
16706 multiSelect = _dispatch.multiSelect, |
|
16707 removeBlocks = _dispatch.removeBlocks, |
|
16708 insertDefaultBlock = _dispatch.insertDefaultBlock; |
|
16709 |
|
16710 return { |
|
16711 onDuplicate: function onDuplicate() { |
|
16712 if (isLocked || !canDuplicate) { |
|
16713 return; |
|
16714 } |
|
16715 |
|
16716 var _select2 = select('core/block-editor'), |
|
16717 getBlockIndex = _select2.getBlockIndex; |
|
16718 |
|
16719 var lastSelectedIndex = getBlockIndex(Object(external_lodash_["last"])(Object(external_lodash_["castArray"])(clientIds)), rootClientId); |
|
16720 var clonedBlocks = blocks.map(function (block) { |
|
16721 return Object(external_this_wp_blocks_["cloneBlock"])(block); |
|
16722 }); |
|
16723 insertBlocks(clonedBlocks, lastSelectedIndex + 1, rootClientId); |
|
16724 |
|
16725 if (clonedBlocks.length > 1) { |
|
16726 multiSelect(Object(external_lodash_["first"])(clonedBlocks).clientId, Object(external_lodash_["last"])(clonedBlocks).clientId); |
|
16727 } |
|
16728 }, |
|
16729 onRemove: function onRemove() { |
|
16730 if (!isLocked) { |
|
16731 removeBlocks(clientIds); |
|
16732 } |
|
16733 }, |
|
16734 onInsertBefore: function onInsertBefore() { |
|
16735 if (!isLocked) { |
|
16736 var _select3 = select('core/block-editor'), |
|
16737 getBlockIndex = _select3.getBlockIndex; |
|
16738 |
|
16739 var firstSelectedIndex = getBlockIndex(Object(external_lodash_["first"])(Object(external_lodash_["castArray"])(clientIds)), rootClientId); |
|
16740 insertDefaultBlock({}, rootClientId, firstSelectedIndex); |
|
16741 } |
|
16742 }, |
|
16743 onInsertAfter: function onInsertAfter() { |
|
16744 if (!isLocked) { |
|
16745 var _select4 = select('core/block-editor'), |
|
16746 getBlockIndex = _select4.getBlockIndex; |
|
16747 |
|
16748 var lastSelectedIndex = getBlockIndex(Object(external_lodash_["last"])(Object(external_lodash_["castArray"])(clientIds)), rootClientId); |
|
16749 insertDefaultBlock({}, rootClientId, lastSelectedIndex + 1); |
|
16750 } |
|
16751 } |
|
16752 }; |
|
16753 })])(BlockActions)); |
|
16754 |
|
16755 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-editor-keyboard-shortcuts/index.js |
|
16756 |
|
16757 |
|
16758 |
|
16759 |
|
16760 |
|
16761 |
|
16762 |
|
16763 |
|
16764 |
|
16765 /** |
|
16766 * External dependencies |
|
16767 */ |
|
16768 |
|
16769 /** |
|
16770 * WordPress dependencies |
|
16771 */ |
|
16772 |
|
16773 |
|
16774 |
|
16775 |
|
16776 |
|
16777 |
|
16778 /** |
|
16779 * Internal dependencies |
|
16780 */ |
|
16781 |
|
16782 |
|
16783 |
|
16784 var preventDefault = function preventDefault(event) { |
|
16785 event.preventDefault(); |
|
16786 return event; |
|
16787 }; |
|
16788 |
|
16789 var shortcuts = { |
|
16790 duplicate: { |
|
16791 raw: external_this_wp_keycodes_["rawShortcut"].primaryShift('d'), |
|
16792 display: external_this_wp_keycodes_["displayShortcut"].primaryShift('d') |
|
16793 }, |
|
16794 removeBlock: { |
|
16795 raw: external_this_wp_keycodes_["rawShortcut"].access('z'), |
|
16796 display: external_this_wp_keycodes_["displayShortcut"].access('z') |
|
16797 }, |
|
16798 insertBefore: { |
|
16799 raw: external_this_wp_keycodes_["rawShortcut"].primaryAlt('t'), |
|
16800 display: external_this_wp_keycodes_["displayShortcut"].primaryAlt('t') |
|
16801 }, |
|
16802 insertAfter: { |
|
16803 raw: external_this_wp_keycodes_["rawShortcut"].primaryAlt('y'), |
|
16804 display: external_this_wp_keycodes_["displayShortcut"].primaryAlt('y') |
|
16805 } |
|
16806 }; |
|
16807 |
|
16808 var block_editor_keyboard_shortcuts_BlockEditorKeyboardShortcuts = |
|
16809 /*#__PURE__*/ |
|
16810 function (_Component) { |
|
16811 Object(inherits["a" /* default */])(BlockEditorKeyboardShortcuts, _Component); |
|
16812 |
|
16813 function BlockEditorKeyboardShortcuts() { |
|
16814 var _this; |
|
16815 |
|
16816 Object(classCallCheck["a" /* default */])(this, BlockEditorKeyboardShortcuts); |
|
16817 |
|
16818 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(BlockEditorKeyboardShortcuts).apply(this, arguments)); |
|
16819 _this.selectAll = _this.selectAll.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
16820 _this.deleteSelectedBlocks = _this.deleteSelectedBlocks.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
16821 _this.clearMultiSelection = _this.clearMultiSelection.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
16822 return _this; |
|
16823 } |
|
16824 |
|
16825 Object(createClass["a" /* default */])(BlockEditorKeyboardShortcuts, [{ |
|
16826 key: "selectAll", |
|
16827 value: function selectAll(event) { |
|
16828 var _this$props = this.props, |
|
16829 rootBlocksClientIds = _this$props.rootBlocksClientIds, |
|
16830 onMultiSelect = _this$props.onMultiSelect; |
|
16831 event.preventDefault(); |
|
16832 onMultiSelect(Object(external_lodash_["first"])(rootBlocksClientIds), Object(external_lodash_["last"])(rootBlocksClientIds)); |
|
16833 } |
|
16834 }, { |
|
16835 key: "deleteSelectedBlocks", |
|
16836 value: function deleteSelectedBlocks(event) { |
|
16837 var _this$props2 = this.props, |
|
16838 selectedBlockClientIds = _this$props2.selectedBlockClientIds, |
|
16839 hasMultiSelection = _this$props2.hasMultiSelection, |
|
16840 onRemove = _this$props2.onRemove, |
|
16841 isLocked = _this$props2.isLocked; |
|
16842 |
|
16843 if (hasMultiSelection) { |
|
16844 event.preventDefault(); |
|
16845 |
|
16846 if (!isLocked) { |
|
16847 onRemove(selectedBlockClientIds); |
|
16848 } |
|
16849 } |
|
16850 } |
|
16851 /** |
|
16852 * Clears current multi-selection, if one exists. |
|
16853 */ |
|
16854 |
|
16855 }, { |
|
16856 key: "clearMultiSelection", |
|
16857 value: function clearMultiSelection() { |
|
16858 var _this$props3 = this.props, |
|
16859 hasMultiSelection = _this$props3.hasMultiSelection, |
|
16860 clearSelectedBlock = _this$props3.clearSelectedBlock; |
|
16861 |
|
16862 if (hasMultiSelection) { |
|
16863 clearSelectedBlock(); |
|
16864 window.getSelection().removeAllRanges(); |
|
16865 } |
|
16866 } |
|
16867 }, { |
|
16868 key: "render", |
|
16869 value: function render() { |
|
16870 var _ref; |
|
16871 |
|
16872 var selectedBlockClientIds = this.props.selectedBlockClientIds; |
|
16873 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["KeyboardShortcuts"], { |
|
16874 shortcuts: (_ref = {}, Object(defineProperty["a" /* default */])(_ref, external_this_wp_keycodes_["rawShortcut"].primary('a'), this.selectAll), Object(defineProperty["a" /* default */])(_ref, "backspace", this.deleteSelectedBlocks), Object(defineProperty["a" /* default */])(_ref, "del", this.deleteSelectedBlocks), Object(defineProperty["a" /* default */])(_ref, "escape", this.clearMultiSelection), _ref) |
|
16875 }), selectedBlockClientIds.length > 0 && Object(external_this_wp_element_["createElement"])(block_actions, { |
|
16876 clientIds: selectedBlockClientIds |
|
16877 }, function (_ref2) { |
|
16878 var _ref3; |
|
16879 |
|
16880 var onDuplicate = _ref2.onDuplicate, |
|
16881 onRemove = _ref2.onRemove, |
|
16882 onInsertAfter = _ref2.onInsertAfter, |
|
16883 onInsertBefore = _ref2.onInsertBefore; |
|
16884 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["KeyboardShortcuts"], { |
|
16885 bindGlobal: true, |
|
16886 shortcuts: (_ref3 = {}, Object(defineProperty["a" /* default */])(_ref3, shortcuts.duplicate.raw, Object(external_lodash_["flow"])(preventDefault, onDuplicate)), Object(defineProperty["a" /* default */])(_ref3, shortcuts.removeBlock.raw, Object(external_lodash_["flow"])(preventDefault, onRemove)), Object(defineProperty["a" /* default */])(_ref3, shortcuts.insertBefore.raw, Object(external_lodash_["flow"])(preventDefault, onInsertBefore)), Object(defineProperty["a" /* default */])(_ref3, shortcuts.insertAfter.raw, Object(external_lodash_["flow"])(preventDefault, onInsertAfter)), _ref3) |
|
16887 }); |
|
16888 })); |
|
16889 } |
|
16890 }]); |
|
16891 |
|
16892 return BlockEditorKeyboardShortcuts; |
|
16893 }(external_this_wp_element_["Component"]); |
|
16894 |
|
16895 /* harmony default export */ var block_editor_keyboard_shortcuts = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
16896 var _select = select('core/block-editor'), |
|
16897 getBlockOrder = _select.getBlockOrder, |
|
16898 getMultiSelectedBlockClientIds = _select.getMultiSelectedBlockClientIds, |
|
16899 hasMultiSelection = _select.hasMultiSelection, |
|
16900 getBlockRootClientId = _select.getBlockRootClientId, |
|
16901 getTemplateLock = _select.getTemplateLock, |
|
16902 getSelectedBlockClientId = _select.getSelectedBlockClientId; |
|
16903 |
|
16904 var selectedBlockClientId = getSelectedBlockClientId(); |
|
16905 var selectedBlockClientIds = selectedBlockClientId ? [selectedBlockClientId] : getMultiSelectedBlockClientIds(); |
|
16906 return { |
|
16907 rootBlocksClientIds: getBlockOrder(), |
|
16908 hasMultiSelection: hasMultiSelection(), |
|
16909 isLocked: Object(external_lodash_["some"])(selectedBlockClientIds, function (clientId) { |
|
16910 return !!getTemplateLock(getBlockRootClientId(clientId)); |
|
16911 }), |
|
16912 selectedBlockClientIds: selectedBlockClientIds |
|
16913 }; |
|
16914 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
16915 var _dispatch = dispatch('core/block-editor'), |
|
16916 clearSelectedBlock = _dispatch.clearSelectedBlock, |
|
16917 multiSelect = _dispatch.multiSelect, |
|
16918 removeBlocks = _dispatch.removeBlocks; |
|
16919 |
|
16920 return { |
|
16921 clearSelectedBlock: clearSelectedBlock, |
|
16922 onMultiSelect: multiSelect, |
|
16923 onRemove: removeBlocks |
|
16924 }; |
|
16925 })])(block_editor_keyboard_shortcuts_BlockEditorKeyboardShortcuts)); |
|
16926 |
|
16927 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/skip-to-selected-block/index.js |
|
16928 |
|
16929 |
|
16930 /** |
|
16931 * WordPress dependencies |
|
16932 */ |
|
16933 |
|
16934 |
|
16935 |
|
16936 /** |
|
16937 * Internal dependencies |
|
16938 */ |
|
16939 |
|
16940 |
|
16941 |
|
16942 var skip_to_selected_block_SkipToSelectedBlock = function SkipToSelectedBlock(_ref) { |
|
16943 var selectedBlockClientId = _ref.selectedBlockClientId; |
|
16944 |
|
16945 var onClick = function onClick() { |
|
16946 var selectedBlockElement = getBlockFocusableWrapper(selectedBlockClientId); |
|
16947 selectedBlockElement.focus(); |
|
16948 }; |
|
16949 |
|
16950 return selectedBlockClientId && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
16951 isDefault: true, |
|
16952 type: "button", |
|
16953 className: "editor-skip-to-selected-block block-editor-skip-to-selected-block", |
|
16954 onClick: onClick |
|
16955 }, Object(external_this_wp_i18n_["__"])('Skip to the selected block')); |
|
16956 }; |
|
16957 |
|
16958 /* harmony default export */ var skip_to_selected_block = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
16959 return { |
|
16960 selectedBlockClientId: select('core/block-editor').getBlockSelectionStart() |
|
16961 }; |
|
16962 })(skip_to_selected_block_SkipToSelectedBlock)); |
|
16963 |
|
16964 // EXTERNAL MODULE: external {"this":["wp","tokenList"]} |
|
16965 var external_this_wp_tokenList_ = __webpack_require__(135); |
|
16966 var external_this_wp_tokenList_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_tokenList_); |
|
16967 |
|
16968 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/index.js |
|
16969 |
|
16970 |
|
16971 |
|
16972 |
|
16973 /** |
|
16974 * External dependencies |
|
16975 */ |
|
16976 |
|
16977 |
|
16978 /** |
|
16979 * WordPress dependencies |
|
16980 */ |
|
16981 |
|
16982 |
|
16983 |
|
16984 |
|
16985 |
|
16986 |
|
16987 |
|
16988 /** |
|
16989 * Internal dependencies |
|
16990 */ |
|
16991 |
|
16992 |
|
16993 /** |
|
16994 * Returns the active style from the given className. |
|
16995 * |
|
16996 * @param {Array} styles Block style variations. |
|
16997 * @param {string} className Class name |
|
16998 * |
|
16999 * @return {Object?} The active style. |
|
17000 */ |
|
17001 |
|
17002 function getActiveStyle(styles, className) { |
|
17003 var _iteratorNormalCompletion = true; |
|
17004 var _didIteratorError = false; |
|
17005 var _iteratorError = undefined; |
|
17006 |
|
17007 try { |
|
17008 for (var _iterator = new external_this_wp_tokenList_default.a(className).values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
|
17009 var style = _step.value; |
|
17010 |
|
17011 if (style.indexOf('is-style-') === -1) { |
|
17012 continue; |
|
17013 } |
|
17014 |
|
17015 var potentialStyleName = style.substring(9); |
|
17016 var activeStyle = Object(external_lodash_["find"])(styles, { |
|
17017 name: potentialStyleName |
|
17018 }); |
|
17019 |
|
17020 if (activeStyle) { |
|
17021 return activeStyle; |
|
17022 } |
|
17023 } |
|
17024 } catch (err) { |
|
17025 _didIteratorError = true; |
|
17026 _iteratorError = err; |
|
17027 } finally { |
|
17028 try { |
|
17029 if (!_iteratorNormalCompletion && _iterator.return != null) { |
|
17030 _iterator.return(); |
|
17031 } |
|
17032 } finally { |
|
17033 if (_didIteratorError) { |
|
17034 throw _iteratorError; |
|
17035 } |
|
17036 } |
|
17037 } |
|
17038 |
|
17039 return Object(external_lodash_["find"])(styles, 'isDefault'); |
|
17040 } |
|
17041 /** |
|
17042 * Replaces the active style in the block's className. |
|
17043 * |
|
17044 * @param {string} className Class name. |
|
17045 * @param {Object?} activeStyle The replaced style. |
|
17046 * @param {Object} newStyle The replacing style. |
|
17047 * |
|
17048 * @return {string} The updated className. |
|
17049 */ |
|
17050 |
|
17051 function replaceActiveStyle(className, activeStyle, newStyle) { |
|
17052 var list = new external_this_wp_tokenList_default.a(className); |
|
17053 |
|
17054 if (activeStyle) { |
|
17055 list.remove('is-style-' + activeStyle.name); |
|
17056 } |
|
17057 |
|
17058 list.add('is-style-' + newStyle.name); |
|
17059 return list.value; |
|
17060 } |
|
17061 |
|
17062 function BlockStyles(_ref) { |
|
17063 var styles = _ref.styles, |
|
17064 className = _ref.className, |
|
17065 onChangeClassName = _ref.onChangeClassName, |
|
17066 name = _ref.name, |
|
17067 attributes = _ref.attributes, |
|
17068 type = _ref.type, |
|
17069 _ref$onSwitch = _ref.onSwitch, |
|
17070 onSwitch = _ref$onSwitch === void 0 ? external_lodash_["noop"] : _ref$onSwitch, |
|
17071 _ref$onHoverClassName = _ref.onHoverClassName, |
|
17072 onHoverClassName = _ref$onHoverClassName === void 0 ? external_lodash_["noop"] : _ref$onHoverClassName; |
|
17073 |
|
17074 if (!styles || styles.length === 0) { |
|
17075 return null; |
|
17076 } |
|
17077 |
|
17078 if (!type.styles && !Object(external_lodash_["find"])(styles, 'isDefault')) { |
|
17079 styles = [{ |
|
17080 name: 'default', |
|
17081 label: Object(external_this_wp_i18n_["_x"])('Default', 'block style'), |
|
17082 isDefault: true |
|
17083 }].concat(Object(toConsumableArray["a" /* default */])(styles)); |
|
17084 } |
|
17085 |
|
17086 var activeStyle = getActiveStyle(styles, className); |
|
17087 |
|
17088 function updateClassName(style) { |
|
17089 var updatedClassName = replaceActiveStyle(className, activeStyle, style); |
|
17090 onChangeClassName(updatedClassName); |
|
17091 onHoverClassName(null); |
|
17092 onSwitch(); |
|
17093 } |
|
17094 |
|
17095 return Object(external_this_wp_element_["createElement"])("div", { |
|
17096 className: "editor-block-styles block-editor-block-styles" |
|
17097 }, styles.map(function (style) { |
|
17098 var styleClassName = replaceActiveStyle(className, activeStyle, style); |
|
17099 return Object(external_this_wp_element_["createElement"])("div", { |
|
17100 key: style.name, |
|
17101 className: classnames_default()('editor-block-styles__item block-editor-block-styles__item', { |
|
17102 'is-active': activeStyle === style |
|
17103 }), |
|
17104 onClick: function onClick() { |
|
17105 return updateClassName(style); |
|
17106 }, |
|
17107 onKeyDown: function onKeyDown(event) { |
|
17108 if (external_this_wp_keycodes_["ENTER"] === event.keyCode || external_this_wp_keycodes_["SPACE"] === event.keyCode) { |
|
17109 event.preventDefault(); |
|
17110 updateClassName(style); |
|
17111 } |
|
17112 }, |
|
17113 onMouseEnter: function onMouseEnter() { |
|
17114 return onHoverClassName(styleClassName); |
|
17115 }, |
|
17116 onMouseLeave: function onMouseLeave() { |
|
17117 return onHoverClassName(null); |
|
17118 }, |
|
17119 role: "button", |
|
17120 tabIndex: "0", |
|
17121 "aria-label": style.label || style.name |
|
17122 }, Object(external_this_wp_element_["createElement"])("div", { |
|
17123 className: "editor-block-styles__item-preview block-editor-block-styles__item-preview" |
|
17124 }, Object(external_this_wp_element_["createElement"])(BlockPreviewContent, { |
|
17125 name: name, |
|
17126 attributes: Object(objectSpread["a" /* default */])({}, attributes, { |
|
17127 className: styleClassName |
|
17128 }) |
|
17129 })), Object(external_this_wp_element_["createElement"])("div", { |
|
17130 className: "editor-block-styles__item-label block-editor-block-styles__item-label" |
|
17131 }, style.label || style.name)); |
|
17132 })); |
|
17133 } |
|
17134 |
|
17135 /* harmony default export */ var block_styles = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select, _ref2) { |
|
17136 var clientId = _ref2.clientId; |
|
17137 |
|
17138 var _select = select('core/block-editor'), |
|
17139 getBlock = _select.getBlock; |
|
17140 |
|
17141 var _select2 = select('core/blocks'), |
|
17142 getBlockStyles = _select2.getBlockStyles; |
|
17143 |
|
17144 var block = getBlock(clientId); |
|
17145 var blockType = Object(external_this_wp_blocks_["getBlockType"])(block.name); |
|
17146 return { |
|
17147 name: block.name, |
|
17148 attributes: block.attributes, |
|
17149 className: block.attributes.className || '', |
|
17150 styles: getBlockStyles(block.name), |
|
17151 type: blockType |
|
17152 }; |
|
17153 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, _ref3) { |
|
17154 var clientId = _ref3.clientId; |
|
17155 return { |
|
17156 onChangeClassName: function onChangeClassName(newClassName) { |
|
17157 dispatch('core/block-editor').updateBlockAttributes(clientId, { |
|
17158 className: newClassName |
|
17159 }); |
|
17160 } |
|
17161 }; |
|
17162 })])(BlockStyles)); |
|
17163 |
|
17164 // EXTERNAL MODULE: external {"this":["wp","wordcount"]} |
|
17165 var external_this_wp_wordcount_ = __webpack_require__(98); |
|
17166 |
|
17167 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/multi-selection-inspector/index.js |
|
17168 |
|
17169 |
|
17170 /** |
|
17171 * WordPress dependencies |
|
17172 */ |
|
17173 |
|
17174 |
|
17175 |
|
17176 |
|
17177 |
|
17178 /** |
|
17179 * Internal dependencies |
|
17180 */ |
|
17181 |
|
17182 |
|
17183 |
|
17184 function MultiSelectionInspector(_ref) { |
|
17185 var blocks = _ref.blocks; |
|
17186 var words = Object(external_this_wp_wordcount_["count"])(Object(external_this_wp_blocks_["serialize"])(blocks), 'words'); |
|
17187 return Object(external_this_wp_element_["createElement"])("div", { |
|
17188 className: "editor-multi-selection-inspector__card block-editor-multi-selection-inspector__card" |
|
17189 }, Object(external_this_wp_element_["createElement"])(BlockIcon, { |
|
17190 icon: Object(external_this_wp_element_["createElement"])(external_this_wp_components_["SVG"], { |
|
17191 xmlns: "http://www.w3.org/2000/svg", |
|
17192 viewBox: "0 0 24 24" |
|
17193 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Path"], { |
|
17194 d: "M3 5H1v16c0 1.1.9 2 2 2h16v-2H3V5zm18-4H7c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V3c0-1.1-.9-2-2-2zm0 16H7V3h14v14z" |
|
17195 })), |
|
17196 showColors: true |
|
17197 }), Object(external_this_wp_element_["createElement"])("div", { |
|
17198 className: "editor-multi-selection-inspector__card-content block-editor-multi-selection-inspector__card-content" |
|
17199 }, Object(external_this_wp_element_["createElement"])("div", { |
|
17200 className: "editor-multi-selection-inspector__card-title block-editor-multi-selection-inspector__card-title" |
|
17201 }, |
|
17202 /* translators: %d: number of blocks */ |
|
17203 Object(external_this_wp_i18n_["sprintf"])(Object(external_this_wp_i18n_["_n"])('%d block', '%d blocks', blocks.length), blocks.length)), Object(external_this_wp_element_["createElement"])("div", { |
|
17204 className: "editor-multi-selection-inspector__card-description block-editor-multi-selection-inspector__card-description" |
|
17205 }, |
|
17206 /* translators: %d: number of words */ |
|
17207 Object(external_this_wp_i18n_["sprintf"])(Object(external_this_wp_i18n_["_n"])('%d word', '%d words', words), words)))); |
|
17208 } |
|
17209 |
|
17210 /* harmony default export */ var multi_selection_inspector = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
17211 var _select = select('core/block-editor'), |
|
17212 getMultiSelectedBlocks = _select.getMultiSelectedBlocks; |
|
17213 |
|
17214 return { |
|
17215 blocks: getMultiSelectedBlocks() |
|
17216 }; |
|
17217 })(MultiSelectionInspector)); |
|
17218 |
|
17219 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-inspector/index.js |
|
17220 |
|
17221 |
|
17222 /** |
|
17223 * External dependencies |
|
17224 */ |
|
17225 |
|
17226 /** |
|
17227 * WordPress dependencies |
|
17228 */ |
|
17229 |
|
17230 |
|
17231 |
|
17232 |
|
17233 |
|
17234 |
|
17235 /** |
|
17236 * Internal dependencies |
|
17237 */ |
|
17238 |
|
17239 |
|
17240 |
|
17241 |
|
17242 |
|
17243 |
|
17244 |
|
17245 |
|
17246 var block_inspector_BlockInspector = function BlockInspector(_ref) { |
|
17247 var selectedBlockClientId = _ref.selectedBlockClientId, |
|
17248 selectedBlockName = _ref.selectedBlockName, |
|
17249 blockType = _ref.blockType, |
|
17250 count = _ref.count, |
|
17251 hasBlockStyles = _ref.hasBlockStyles; |
|
17252 |
|
17253 if (count > 1) { |
|
17254 return Object(external_this_wp_element_["createElement"])(multi_selection_inspector, null); |
|
17255 } |
|
17256 |
|
17257 var isSelectedBlockUnregistered = selectedBlockName === Object(external_this_wp_blocks_["getUnregisteredTypeHandlerName"])(); |
|
17258 /* |
|
17259 * If the selected block is of an unregistered type, avoid showing it as an actual selection |
|
17260 * because we want the user to focus on the unregistered block warning, not block settings. |
|
17261 */ |
|
17262 |
|
17263 if (!blockType || !selectedBlockClientId || isSelectedBlockUnregistered) { |
|
17264 return Object(external_this_wp_element_["createElement"])("span", { |
|
17265 className: "editor-block-inspector__no-blocks block-editor-block-inspector__no-blocks" |
|
17266 }, Object(external_this_wp_i18n_["__"])('No block selected.')); |
|
17267 } |
|
17268 |
|
17269 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])("div", { |
|
17270 className: "editor-block-inspector__card block-editor-block-inspector__card" |
|
17271 }, Object(external_this_wp_element_["createElement"])(BlockIcon, { |
|
17272 icon: blockType.icon, |
|
17273 showColors: true |
|
17274 }), Object(external_this_wp_element_["createElement"])("div", { |
|
17275 className: "editor-block-inspector__card-content block-editor-block-inspector__card-content" |
|
17276 }, Object(external_this_wp_element_["createElement"])("div", { |
|
17277 className: "editor-block-inspector__card-title block-editor-block-inspector__card-title" |
|
17278 }, blockType.title), Object(external_this_wp_element_["createElement"])("div", { |
|
17279 className: "editor-block-inspector__card-description block-editor-block-inspector__card-description" |
|
17280 }, blockType.description))), hasBlockStyles && Object(external_this_wp_element_["createElement"])("div", null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["PanelBody"], { |
|
17281 title: Object(external_this_wp_i18n_["__"])('Styles'), |
|
17282 initialOpen: false |
|
17283 }, Object(external_this_wp_element_["createElement"])(block_styles, { |
|
17284 clientId: selectedBlockClientId |
|
17285 }))), Object(external_this_wp_element_["createElement"])("div", null, Object(external_this_wp_element_["createElement"])(inspector_controls.Slot, null)), Object(external_this_wp_element_["createElement"])("div", null, Object(external_this_wp_element_["createElement"])(inspector_advanced_controls.Slot, null, function (fills) { |
|
17286 return !Object(external_lodash_["isEmpty"])(fills) && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["PanelBody"], { |
|
17287 className: "editor-block-inspector__advanced block-editor-block-inspector__advanced", |
|
17288 title: Object(external_this_wp_i18n_["__"])('Advanced'), |
|
17289 initialOpen: false |
|
17290 }, fills); |
|
17291 })), Object(external_this_wp_element_["createElement"])(skip_to_selected_block, { |
|
17292 key: "back" |
|
17293 })); |
|
17294 }; |
|
17295 |
|
17296 /* harmony default export */ var block_inspector = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
17297 var _select = select('core/block-editor'), |
|
17298 getSelectedBlockClientId = _select.getSelectedBlockClientId, |
|
17299 getSelectedBlockCount = _select.getSelectedBlockCount, |
|
17300 getBlockName = _select.getBlockName; |
|
17301 |
|
17302 var _select2 = select('core/blocks'), |
|
17303 getBlockStyles = _select2.getBlockStyles; |
|
17304 |
|
17305 var selectedBlockClientId = getSelectedBlockClientId(); |
|
17306 var selectedBlockName = selectedBlockClientId && getBlockName(selectedBlockClientId); |
|
17307 var blockType = selectedBlockClientId && Object(external_this_wp_blocks_["getBlockType"])(selectedBlockName); |
|
17308 var blockStyles = selectedBlockClientId && getBlockStyles(selectedBlockName); |
|
17309 return { |
|
17310 count: getSelectedBlockCount(), |
|
17311 hasBlockStyles: blockStyles && blockStyles.length > 0, |
|
17312 selectedBlockName: selectedBlockName, |
|
17313 selectedBlockClientId: selectedBlockClientId, |
|
17314 blockType: blockType |
|
17315 }; |
|
17316 })(block_inspector_BlockInspector)); |
|
17317 |
|
17318 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-selection-clearer/index.js |
|
17319 |
|
17320 |
|
17321 |
|
17322 |
|
17323 |
|
17324 |
|
17325 |
|
17326 |
|
17327 |
|
17328 /** |
|
17329 * External dependencies |
|
17330 */ |
|
17331 |
|
17332 /** |
|
17333 * WordPress dependencies |
|
17334 */ |
|
17335 |
|
17336 |
|
17337 |
|
17338 |
|
17339 |
|
17340 var block_selection_clearer_BlockSelectionClearer = |
|
17341 /*#__PURE__*/ |
|
17342 function (_Component) { |
|
17343 Object(inherits["a" /* default */])(BlockSelectionClearer, _Component); |
|
17344 |
|
17345 function BlockSelectionClearer() { |
|
17346 var _this; |
|
17347 |
|
17348 Object(classCallCheck["a" /* default */])(this, BlockSelectionClearer); |
|
17349 |
|
17350 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(BlockSelectionClearer).apply(this, arguments)); |
|
17351 _this.bindContainer = _this.bindContainer.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
17352 _this.clearSelectionIfFocusTarget = _this.clearSelectionIfFocusTarget.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
17353 return _this; |
|
17354 } |
|
17355 |
|
17356 Object(createClass["a" /* default */])(BlockSelectionClearer, [{ |
|
17357 key: "bindContainer", |
|
17358 value: function bindContainer(ref) { |
|
17359 this.container = ref; |
|
17360 } |
|
17361 /** |
|
17362 * Clears the selected block on focus if the container is the target of the |
|
17363 * focus. This assumes no other descendents have received focus until event |
|
17364 * has bubbled to the container. |
|
17365 * |
|
17366 * @param {FocusEvent} event Focus event. |
|
17367 */ |
|
17368 |
|
17369 }, { |
|
17370 key: "clearSelectionIfFocusTarget", |
|
17371 value: function clearSelectionIfFocusTarget(event) { |
|
17372 var _this$props = this.props, |
|
17373 hasSelectedBlock = _this$props.hasSelectedBlock, |
|
17374 hasMultiSelection = _this$props.hasMultiSelection, |
|
17375 clearSelectedBlock = _this$props.clearSelectedBlock; |
|
17376 var hasSelection = hasSelectedBlock || hasMultiSelection; |
|
17377 |
|
17378 if (event.target === this.container && hasSelection) { |
|
17379 clearSelectedBlock(); |
|
17380 } |
|
17381 } |
|
17382 }, { |
|
17383 key: "render", |
|
17384 value: function render() { |
|
17385 return Object(external_this_wp_element_["createElement"])("div", Object(esm_extends["a" /* default */])({ |
|
17386 tabIndex: -1, |
|
17387 onFocus: this.clearSelectionIfFocusTarget, |
|
17388 ref: this.bindContainer |
|
17389 }, Object(external_lodash_["omit"])(this.props, ['clearSelectedBlock', 'hasSelectedBlock', 'hasMultiSelection']))); |
|
17390 } |
|
17391 }]); |
|
17392 |
|
17393 return BlockSelectionClearer; |
|
17394 }(external_this_wp_element_["Component"]); |
|
17395 |
|
17396 /* harmony default export */ var block_selection_clearer = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
17397 var _select = select('core/block-editor'), |
|
17398 hasSelectedBlock = _select.hasSelectedBlock, |
|
17399 hasMultiSelection = _select.hasMultiSelection; |
|
17400 |
|
17401 return { |
|
17402 hasSelectedBlock: hasSelectedBlock(), |
|
17403 hasMultiSelection: hasMultiSelection() |
|
17404 }; |
|
17405 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
17406 var _dispatch = dispatch('core/block-editor'), |
|
17407 clearSelectedBlock = _dispatch.clearSelectedBlock; |
|
17408 |
|
17409 return { |
|
17410 clearSelectedBlock: clearSelectedBlock |
|
17411 }; |
|
17412 })])(block_selection_clearer_BlockSelectionClearer)); |
|
17413 |
|
17414 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-mode-toggle.js |
|
17415 |
|
17416 |
|
17417 /** |
|
17418 * External dependencies |
|
17419 */ |
|
17420 |
|
17421 /** |
|
17422 * WordPress dependencies |
|
17423 */ |
|
17424 |
|
17425 |
|
17426 |
|
17427 |
|
17428 |
|
17429 |
|
17430 function BlockModeToggle(_ref) { |
|
17431 var blockType = _ref.blockType, |
|
17432 mode = _ref.mode, |
|
17433 onToggleMode = _ref.onToggleMode, |
|
17434 _ref$small = _ref.small, |
|
17435 small = _ref$small === void 0 ? false : _ref$small; |
|
17436 |
|
17437 if (!Object(external_this_wp_blocks_["hasBlockSupport"])(blockType, 'html', true)) { |
|
17438 return null; |
|
17439 } |
|
17440 |
|
17441 var label = mode === 'visual' ? Object(external_this_wp_i18n_["__"])('Edit as HTML') : Object(external_this_wp_i18n_["__"])('Edit visually'); |
|
17442 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["MenuItem"], { |
|
17443 className: "editor-block-settings-menu__control block-editor-block-settings-menu__control", |
|
17444 onClick: onToggleMode, |
|
17445 icon: "html" |
|
17446 }, !small && label); |
|
17447 } |
|
17448 /* harmony default export */ var block_mode_toggle = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select, _ref2) { |
|
17449 var clientId = _ref2.clientId; |
|
17450 |
|
17451 var _select = select('core/block-editor'), |
|
17452 getBlock = _select.getBlock, |
|
17453 getBlockMode = _select.getBlockMode; |
|
17454 |
|
17455 var block = getBlock(clientId); |
|
17456 return { |
|
17457 mode: getBlockMode(clientId), |
|
17458 blockType: block ? Object(external_this_wp_blocks_["getBlockType"])(block.name) : null |
|
17459 }; |
|
17460 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, _ref3) { |
|
17461 var _ref3$onToggle = _ref3.onToggle, |
|
17462 onToggle = _ref3$onToggle === void 0 ? external_lodash_["noop"] : _ref3$onToggle, |
|
17463 clientId = _ref3.clientId; |
|
17464 return { |
|
17465 onToggleMode: function onToggleMode() { |
|
17466 dispatch('core/block-editor').toggleBlockMode(clientId); |
|
17467 onToggle(); |
|
17468 } |
|
17469 }; |
|
17470 })])(BlockModeToggle)); |
|
17471 |
|
17472 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/reusable-block-convert-button.js |
|
17473 |
|
17474 |
|
17475 /** |
|
17476 * External dependencies |
|
17477 */ |
|
17478 |
|
17479 /** |
|
17480 * WordPress dependencies |
|
17481 */ |
|
17482 |
|
17483 |
|
17484 |
|
17485 |
|
17486 |
|
17487 |
|
17488 |
|
17489 function ReusableBlockConvertButton(_ref) { |
|
17490 var isVisible = _ref.isVisible, |
|
17491 isReusable = _ref.isReusable, |
|
17492 onConvertToStatic = _ref.onConvertToStatic, |
|
17493 onConvertToReusable = _ref.onConvertToReusable; |
|
17494 |
|
17495 if (!isVisible) { |
|
17496 return null; |
|
17497 } |
|
17498 |
|
17499 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, !isReusable && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["MenuItem"], { |
|
17500 className: "editor-block-settings-menu__control block-editor-block-settings-menu__control", |
|
17501 icon: "controls-repeat", |
|
17502 onClick: onConvertToReusable |
|
17503 }, Object(external_this_wp_i18n_["__"])('Add to Reusable Blocks')), isReusable && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["MenuItem"], { |
|
17504 className: "editor-block-settings-menu__control block-editor-block-settings-menu__control", |
|
17505 icon: "controls-repeat", |
|
17506 onClick: onConvertToStatic |
|
17507 }, Object(external_this_wp_i18n_["__"])('Convert to Regular Block'))); |
|
17508 } |
|
17509 /* harmony default export */ var reusable_block_convert_button = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select, _ref2) { |
|
17510 var clientIds = _ref2.clientIds; |
|
17511 |
|
17512 var _select = select('core/block-editor'), |
|
17513 getBlocksByClientId = _select.getBlocksByClientId, |
|
17514 canInsertBlockType = _select.canInsertBlockType; |
|
17515 |
|
17516 var _select2 = select('core/editor'), |
|
17517 getReusableBlock = _select2.__experimentalGetReusableBlock; |
|
17518 |
|
17519 var _select3 = select('core'), |
|
17520 canUser = _select3.canUser; |
|
17521 |
|
17522 var blocks = getBlocksByClientId(clientIds); |
|
17523 var isReusable = blocks.length === 1 && blocks[0] && Object(external_this_wp_blocks_["isReusableBlock"])(blocks[0]) && !!getReusableBlock(blocks[0].attributes.ref); // Show 'Convert to Regular Block' when selected block is a reusable block |
|
17524 |
|
17525 var isVisible = isReusable || // Hide 'Add to Reusable Blocks' when reusable blocks are disabled |
|
17526 canInsertBlockType('core/block') && Object(external_lodash_["every"])(blocks, function (block) { |
|
17527 return (// Guard against the case where a regular block has *just* been converted |
|
17528 !!block && // Hide 'Add to Reusable Blocks' on invalid blocks |
|
17529 block.isValid && // Hide 'Add to Reusable Blocks' when block doesn't support being made reusable |
|
17530 Object(external_this_wp_blocks_["hasBlockSupport"])(block.name, 'reusable', true) |
|
17531 ); |
|
17532 }) && // Hide 'Add to Reusable Blocks' when current doesn't have permission to do that |
|
17533 !!canUser('create', 'blocks'); |
|
17534 return { |
|
17535 isReusable: isReusable, |
|
17536 isVisible: isVisible |
|
17537 }; |
|
17538 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, _ref3) { |
|
17539 var clientIds = _ref3.clientIds, |
|
17540 _ref3$onToggle = _ref3.onToggle, |
|
17541 onToggle = _ref3$onToggle === void 0 ? external_lodash_["noop"] : _ref3$onToggle; |
|
17542 |
|
17543 var _dispatch = dispatch('core/editor'), |
|
17544 convertBlockToReusable = _dispatch.__experimentalConvertBlockToReusable, |
|
17545 convertBlockToStatic = _dispatch.__experimentalConvertBlockToStatic; |
|
17546 |
|
17547 return { |
|
17548 onConvertToStatic: function onConvertToStatic() { |
|
17549 if (clientIds.length !== 1) { |
|
17550 return; |
|
17551 } |
|
17552 |
|
17553 convertBlockToStatic(clientIds[0]); |
|
17554 onToggle(); |
|
17555 }, |
|
17556 onConvertToReusable: function onConvertToReusable() { |
|
17557 convertBlockToReusable(clientIds); |
|
17558 onToggle(); |
|
17559 } |
|
17560 }; |
|
17561 })])(ReusableBlockConvertButton)); |
|
17562 |
|
17563 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/reusable-block-delete-button.js |
|
17564 |
|
17565 |
|
17566 /** |
|
17567 * External dependencies |
|
17568 */ |
|
17569 |
|
17570 /** |
|
17571 * WordPress dependencies |
|
17572 */ |
|
17573 |
|
17574 |
|
17575 |
|
17576 |
|
17577 |
|
17578 |
|
17579 function ReusableBlockDeleteButton(_ref) { |
|
17580 var isVisible = _ref.isVisible, |
|
17581 isDisabled = _ref.isDisabled, |
|
17582 onDelete = _ref.onDelete; |
|
17583 |
|
17584 if (!isVisible) { |
|
17585 return null; |
|
17586 } |
|
17587 |
|
17588 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["MenuItem"], { |
|
17589 className: "editor-block-settings-menu__control block-editor-block-settings-menu__control", |
|
17590 icon: "no", |
|
17591 disabled: isDisabled, |
|
17592 onClick: function onClick() { |
|
17593 return onDelete(); |
|
17594 } |
|
17595 }, Object(external_this_wp_i18n_["__"])('Remove from Reusable Blocks')); |
|
17596 } |
|
17597 /* harmony default export */ var reusable_block_delete_button = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select, _ref2) { |
|
17598 var clientId = _ref2.clientId; |
|
17599 |
|
17600 var _select = select('core/block-editor'), |
|
17601 getBlock = _select.getBlock; |
|
17602 |
|
17603 var _select2 = select('core'), |
|
17604 canUser = _select2.canUser; |
|
17605 |
|
17606 var _select3 = select('core/editor'), |
|
17607 getReusableBlock = _select3.__experimentalGetReusableBlock; |
|
17608 |
|
17609 var block = getBlock(clientId); |
|
17610 var reusableBlock = block && Object(external_this_wp_blocks_["isReusableBlock"])(block) ? getReusableBlock(block.attributes.ref) : null; |
|
17611 return { |
|
17612 isVisible: !!reusableBlock && !!canUser('delete', 'blocks', reusableBlock.id), |
|
17613 isDisabled: reusableBlock && reusableBlock.isTemporary |
|
17614 }; |
|
17615 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, _ref3, _ref4) { |
|
17616 var clientId = _ref3.clientId, |
|
17617 _ref3$onToggle = _ref3.onToggle, |
|
17618 onToggle = _ref3$onToggle === void 0 ? external_lodash_["noop"] : _ref3$onToggle; |
|
17619 var select = _ref4.select; |
|
17620 |
|
17621 var _dispatch = dispatch('core/editor'), |
|
17622 deleteReusableBlock = _dispatch.__experimentalDeleteReusableBlock; |
|
17623 |
|
17624 var _select4 = select('core/block-editor'), |
|
17625 getBlock = _select4.getBlock; |
|
17626 |
|
17627 return { |
|
17628 onDelete: function onDelete() { |
|
17629 // TODO: Make this a <Confirm /> component or similar |
|
17630 // eslint-disable-next-line no-alert |
|
17631 var hasConfirmed = window.confirm(Object(external_this_wp_i18n_["__"])('Are you sure you want to delete this Reusable Block?\n\n' + 'It will be permanently removed from all posts and pages that use it.')); |
|
17632 |
|
17633 if (hasConfirmed) { |
|
17634 var block = getBlock(clientId); |
|
17635 deleteReusableBlock(block.attributes.ref); |
|
17636 onToggle(); |
|
17637 } |
|
17638 } |
|
17639 }; |
|
17640 })])(ReusableBlockDeleteButton)); |
|
17641 |
|
17642 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-convert-button.js |
|
17643 |
|
17644 |
|
17645 /** |
|
17646 * WordPress dependencies |
|
17647 */ |
|
17648 |
|
17649 |
|
17650 function BlockConvertButton(_ref) { |
|
17651 var shouldRender = _ref.shouldRender, |
|
17652 onClick = _ref.onClick, |
|
17653 small = _ref.small; |
|
17654 |
|
17655 if (!shouldRender) { |
|
17656 return null; |
|
17657 } |
|
17658 |
|
17659 var label = Object(external_this_wp_i18n_["__"])('Convert to Blocks'); |
|
17660 |
|
17661 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["MenuItem"], { |
|
17662 className: "editor-block-settings-menu__control block-editor-block-settings-menu__control", |
|
17663 onClick: onClick, |
|
17664 icon: "screenoptions" |
|
17665 }, !small && label); |
|
17666 } |
|
17667 |
|
17668 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-html-convert-button.js |
|
17669 /** |
|
17670 * WordPress dependencies |
|
17671 */ |
|
17672 |
|
17673 |
|
17674 |
|
17675 /** |
|
17676 * Internal dependencies |
|
17677 */ |
|
17678 |
|
17679 |
|
17680 /* harmony default export */ var block_html_convert_button = (Object(external_this_wp_compose_["compose"])(Object(external_this_wp_data_["withSelect"])(function (select, _ref) { |
|
17681 var clientId = _ref.clientId; |
|
17682 var block = select('core/block-editor').getBlock(clientId); |
|
17683 return { |
|
17684 block: block, |
|
17685 shouldRender: block && block.name === 'core/html' |
|
17686 }; |
|
17687 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, _ref2) { |
|
17688 var block = _ref2.block; |
|
17689 return { |
|
17690 onClick: function onClick() { |
|
17691 return dispatch('core/block-editor').replaceBlocks(block.clientId, Object(external_this_wp_blocks_["rawHandler"])({ |
|
17692 HTML: Object(external_this_wp_blocks_["getBlockContent"])(block) |
|
17693 })); |
|
17694 } |
|
17695 }; |
|
17696 }))(BlockConvertButton)); |
|
17697 |
|
17698 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-unknown-convert-button.js |
|
17699 /** |
|
17700 * WordPress dependencies |
|
17701 */ |
|
17702 |
|
17703 |
|
17704 |
|
17705 /** |
|
17706 * Internal dependencies |
|
17707 */ |
|
17708 |
|
17709 |
|
17710 /* harmony default export */ var block_unknown_convert_button = (Object(external_this_wp_compose_["compose"])(Object(external_this_wp_data_["withSelect"])(function (select, _ref) { |
|
17711 var clientId = _ref.clientId; |
|
17712 var block = select('core/block-editor').getBlock(clientId); |
|
17713 return { |
|
17714 block: block, |
|
17715 shouldRender: block && block.name === Object(external_this_wp_blocks_["getFreeformContentHandlerName"])() |
|
17716 }; |
|
17717 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, _ref2) { |
|
17718 var block = _ref2.block; |
|
17719 return { |
|
17720 onClick: function onClick() { |
|
17721 return dispatch('core/block-editor').replaceBlocks(block.clientId, Object(external_this_wp_blocks_["rawHandler"])({ |
|
17722 HTML: Object(external_this_wp_blocks_["serialize"])(block) |
|
17723 })); |
|
17724 } |
|
17725 }; |
|
17726 }))(BlockConvertButton)); |
|
17727 |
|
17728 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-settings-menu-first-item.js |
|
17729 /** |
|
17730 * WordPress dependencies |
|
17731 */ |
|
17732 |
|
17733 |
|
17734 var block_settings_menu_first_item_createSlotFill = Object(external_this_wp_components_["createSlotFill"])('_BlockSettingsMenuFirstItem'), |
|
17735 _BlockSettingsMenuFirstItem = block_settings_menu_first_item_createSlotFill.Fill, |
|
17736 block_settings_menu_first_item_Slot = block_settings_menu_first_item_createSlotFill.Slot; |
|
17737 |
|
17738 _BlockSettingsMenuFirstItem.Slot = block_settings_menu_first_item_Slot; |
|
17739 /* harmony default export */ var block_settings_menu_first_item = (_BlockSettingsMenuFirstItem); |
|
17740 |
|
17741 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-settings-menu-plugins-extension.js |
|
17742 /** |
|
17743 * WordPress dependencies |
|
17744 */ |
|
17745 |
|
17746 |
|
17747 var block_settings_menu_plugins_extension_createSlotFill = Object(external_this_wp_components_["createSlotFill"])('_BlockSettingsMenuPluginsExtension'), |
|
17748 _BlockSettingsMenuPluginsExtension = block_settings_menu_plugins_extension_createSlotFill.Fill, |
|
17749 block_settings_menu_plugins_extension_Slot = block_settings_menu_plugins_extension_createSlotFill.Slot; |
|
17750 |
|
17751 _BlockSettingsMenuPluginsExtension.Slot = block_settings_menu_plugins_extension_Slot; |
|
17752 /* harmony default export */ var block_settings_menu_plugins_extension = (_BlockSettingsMenuPluginsExtension); |
|
17753 |
|
17754 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/index.js |
|
17755 |
|
17756 |
|
17757 /** |
|
17758 * External dependencies |
|
17759 */ |
|
17760 |
|
17761 |
|
17762 /** |
|
17763 * WordPress dependencies |
|
17764 */ |
|
17765 |
|
17766 |
|
17767 |
|
17768 |
|
17769 |
|
17770 /** |
|
17771 * Internal dependencies |
|
17772 */ |
|
17773 |
|
17774 |
|
17775 |
|
17776 |
|
17777 |
|
17778 |
|
17779 |
|
17780 |
|
17781 |
|
17782 |
|
17783 function BlockSettingsMenu(_ref) { |
|
17784 var clientIds = _ref.clientIds, |
|
17785 onSelect = _ref.onSelect; |
|
17786 var blockClientIds = Object(external_lodash_["castArray"])(clientIds); |
|
17787 var count = blockClientIds.length; |
|
17788 var firstBlockClientId = blockClientIds[0]; |
|
17789 return Object(external_this_wp_element_["createElement"])(block_actions, { |
|
17790 clientIds: clientIds |
|
17791 }, function (_ref2) { |
|
17792 var onDuplicate = _ref2.onDuplicate, |
|
17793 onRemove = _ref2.onRemove, |
|
17794 onInsertAfter = _ref2.onInsertAfter, |
|
17795 onInsertBefore = _ref2.onInsertBefore, |
|
17796 canDuplicate = _ref2.canDuplicate, |
|
17797 isLocked = _ref2.isLocked; |
|
17798 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Dropdown"], { |
|
17799 contentClassName: "editor-block-settings-menu__popover block-editor-block-settings-menu__popover", |
|
17800 position: "bottom right", |
|
17801 renderToggle: function renderToggle(_ref3) { |
|
17802 var onToggle = _ref3.onToggle, |
|
17803 isOpen = _ref3.isOpen; |
|
17804 var toggleClassname = classnames_default()('editor-block-settings-menu__toggle block-editor-block-settings-menu__toggle', { |
|
17805 'is-opened': isOpen |
|
17806 }); |
|
17807 var label = isOpen ? Object(external_this_wp_i18n_["__"])('Hide options') : Object(external_this_wp_i18n_["__"])('More options'); |
|
17808 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Toolbar"], { |
|
17809 controls: [{ |
|
17810 icon: 'ellipsis', |
|
17811 title: label, |
|
17812 onClick: function onClick() { |
|
17813 if (count === 1) { |
|
17814 onSelect(firstBlockClientId); |
|
17815 } |
|
17816 |
|
17817 onToggle(); |
|
17818 }, |
|
17819 className: toggleClassname, |
|
17820 extraProps: { |
|
17821 'aria-expanded': isOpen |
|
17822 } |
|
17823 }] |
|
17824 }); |
|
17825 }, |
|
17826 renderContent: function renderContent(_ref4) { |
|
17827 var onClose = _ref4.onClose; |
|
17828 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["NavigableMenu"], { |
|
17829 className: "editor-block-settings-menu__content block-editor-block-settings-menu__content" |
|
17830 }, Object(external_this_wp_element_["createElement"])(block_settings_menu_first_item.Slot, { |
|
17831 fillProps: { |
|
17832 onClose: onClose |
|
17833 } |
|
17834 }), count === 1 && Object(external_this_wp_element_["createElement"])(block_unknown_convert_button, { |
|
17835 clientId: firstBlockClientId |
|
17836 }), count === 1 && Object(external_this_wp_element_["createElement"])(block_html_convert_button, { |
|
17837 clientId: firstBlockClientId |
|
17838 }), !isLocked && canDuplicate && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["MenuItem"], { |
|
17839 className: "editor-block-settings-menu__control block-editor-block-settings-menu__control", |
|
17840 onClick: onDuplicate, |
|
17841 icon: "admin-page", |
|
17842 shortcut: shortcuts.duplicate.display |
|
17843 }, Object(external_this_wp_i18n_["__"])('Duplicate')), !isLocked && Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["MenuItem"], { |
|
17844 className: "editor-block-settings-menu__control block-editor-block-settings-menu__control", |
|
17845 onClick: onInsertBefore, |
|
17846 icon: "insert-before", |
|
17847 shortcut: shortcuts.insertBefore.display |
|
17848 }, Object(external_this_wp_i18n_["__"])('Insert Before')), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["MenuItem"], { |
|
17849 className: "editor-block-settings-menu__control block-editor-block-settings-menu__control", |
|
17850 onClick: onInsertAfter, |
|
17851 icon: "insert-after", |
|
17852 shortcut: shortcuts.insertAfter.display |
|
17853 }, Object(external_this_wp_i18n_["__"])('Insert After'))), count === 1 && Object(external_this_wp_element_["createElement"])(block_mode_toggle, { |
|
17854 clientId: firstBlockClientId, |
|
17855 onToggle: onClose |
|
17856 }), Object(external_this_wp_element_["createElement"])(reusable_block_convert_button, { |
|
17857 clientIds: clientIds, |
|
17858 onToggle: onClose |
|
17859 }), Object(external_this_wp_element_["createElement"])(block_settings_menu_plugins_extension.Slot, { |
|
17860 fillProps: { |
|
17861 clientIds: clientIds, |
|
17862 onClose: onClose |
|
17863 } |
|
17864 }), Object(external_this_wp_element_["createElement"])("div", { |
|
17865 className: "editor-block-settings-menu__separator block-editor-block-settings-menu__separator" |
|
17866 }), count === 1 && Object(external_this_wp_element_["createElement"])(reusable_block_delete_button, { |
|
17867 clientId: firstBlockClientId, |
|
17868 onToggle: onClose |
|
17869 }), !isLocked && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["MenuItem"], { |
|
17870 className: "editor-block-settings-menu__control block-editor-block-settings-menu__control", |
|
17871 onClick: onRemove, |
|
17872 icon: "trash", |
|
17873 shortcut: shortcuts.removeBlock.display |
|
17874 }, Object(external_this_wp_i18n_["__"])('Remove Block'))); |
|
17875 } |
|
17876 }); |
|
17877 }); |
|
17878 } |
|
17879 /* harmony default export */ var block_settings_menu = (Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
17880 var _dispatch = dispatch('core/block-editor'), |
|
17881 selectBlock = _dispatch.selectBlock; |
|
17882 |
|
17883 return { |
|
17884 onSelect: function onSelect(clientId) { |
|
17885 selectBlock(clientId); |
|
17886 } |
|
17887 }; |
|
17888 })(BlockSettingsMenu)); |
|
17889 |
|
17890 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/index.js |
|
17891 |
|
17892 |
|
17893 |
|
17894 |
|
17895 |
|
17896 |
|
17897 |
|
17898 |
|
17899 |
|
17900 /** |
|
17901 * External dependencies |
|
17902 */ |
|
17903 |
|
17904 /** |
|
17905 * WordPress dependencies |
|
17906 */ |
|
17907 |
|
17908 |
|
17909 |
|
17910 |
|
17911 |
|
17912 |
|
17913 |
|
17914 |
|
17915 /** |
|
17916 * Internal dependencies |
|
17917 */ |
|
17918 |
|
17919 |
|
17920 |
|
17921 |
|
17922 |
|
17923 var block_switcher_BlockSwitcher = |
|
17924 /*#__PURE__*/ |
|
17925 function (_Component) { |
|
17926 Object(inherits["a" /* default */])(BlockSwitcher, _Component); |
|
17927 |
|
17928 function BlockSwitcher() { |
|
17929 var _this; |
|
17930 |
|
17931 Object(classCallCheck["a" /* default */])(this, BlockSwitcher); |
|
17932 |
|
17933 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(BlockSwitcher).apply(this, arguments)); |
|
17934 _this.state = { |
|
17935 hoveredClassName: null |
|
17936 }; |
|
17937 _this.onHoverClassName = _this.onHoverClassName.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
17938 return _this; |
|
17939 } |
|
17940 |
|
17941 Object(createClass["a" /* default */])(BlockSwitcher, [{ |
|
17942 key: "onHoverClassName", |
|
17943 value: function onHoverClassName(className) { |
|
17944 this.setState({ |
|
17945 hoveredClassName: className |
|
17946 }); |
|
17947 } |
|
17948 }, { |
|
17949 key: "render", |
|
17950 value: function render() { |
|
17951 var _this2 = this; |
|
17952 |
|
17953 var _this$props = this.props, |
|
17954 blocks = _this$props.blocks, |
|
17955 onTransform = _this$props.onTransform, |
|
17956 inserterItems = _this$props.inserterItems, |
|
17957 hasBlockStyles = _this$props.hasBlockStyles; |
|
17958 var hoveredClassName = this.state.hoveredClassName; |
|
17959 |
|
17960 if (!blocks || !blocks.length) { |
|
17961 return null; |
|
17962 } |
|
17963 |
|
17964 var itemsByName = Object(external_lodash_["mapKeys"])(inserterItems, function (_ref) { |
|
17965 var name = _ref.name; |
|
17966 return name; |
|
17967 }); |
|
17968 var possibleBlockTransformations = Object(external_lodash_["orderBy"])(Object(external_lodash_["filter"])(Object(external_this_wp_blocks_["getPossibleBlockTransformations"])(blocks), function (block) { |
|
17969 return block && !!itemsByName[block.name]; |
|
17970 }), function (block) { |
|
17971 return itemsByName[block.name].frecency; |
|
17972 }, 'desc'); // When selection consists of blocks of multiple types, display an |
|
17973 // appropriate icon to communicate the non-uniformity. |
|
17974 |
|
17975 var isSelectionOfSameType = Object(external_lodash_["uniq"])(Object(external_lodash_["map"])(blocks, 'name')).length === 1; |
|
17976 var icon; |
|
17977 |
|
17978 if (isSelectionOfSameType) { |
|
17979 var sourceBlockName = blocks[0].name; |
|
17980 var blockType = Object(external_this_wp_blocks_["getBlockType"])(sourceBlockName); |
|
17981 icon = blockType.icon; |
|
17982 } else { |
|
17983 icon = 'layout'; |
|
17984 } |
|
17985 |
|
17986 if (!hasBlockStyles && !possibleBlockTransformations.length) { |
|
17987 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Toolbar"], null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], { |
|
17988 disabled: true, |
|
17989 className: "editor-block-switcher__no-switcher-icon block-editor-block-switcher__no-switcher-icon", |
|
17990 label: Object(external_this_wp_i18n_["__"])('Block icon') |
|
17991 }, Object(external_this_wp_element_["createElement"])(BlockIcon, { |
|
17992 icon: icon, |
|
17993 showColors: true |
|
17994 }))); |
|
17995 } |
|
17996 |
|
17997 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Dropdown"], { |
|
17998 position: "bottom right", |
|
17999 className: "editor-block-switcher block-editor-block-switcher", |
|
18000 contentClassName: "editor-block-switcher__popover block-editor-block-switcher__popover", |
|
18001 renderToggle: function renderToggle(_ref2) { |
|
18002 var onToggle = _ref2.onToggle, |
|
18003 isOpen = _ref2.isOpen; |
|
18004 |
|
18005 var openOnArrowDown = function openOnArrowDown(event) { |
|
18006 if (!isOpen && event.keyCode === external_this_wp_keycodes_["DOWN"]) { |
|
18007 event.preventDefault(); |
|
18008 event.stopPropagation(); |
|
18009 onToggle(); |
|
18010 } |
|
18011 }; |
|
18012 |
|
18013 var label = 1 === blocks.length ? Object(external_this_wp_i18n_["__"])('Change block type or style') : Object(external_this_wp_i18n_["sprintf"])(Object(external_this_wp_i18n_["_n"])('Change type of %d block', 'Change type of %d blocks', blocks.length), blocks.length); |
|
18014 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Toolbar"], null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], { |
|
18015 className: "editor-block-switcher__toggle block-editor-block-switcher__toggle", |
|
18016 onClick: onToggle, |
|
18017 "aria-haspopup": "true", |
|
18018 "aria-expanded": isOpen, |
|
18019 label: label, |
|
18020 tooltip: label, |
|
18021 onKeyDown: openOnArrowDown, |
|
18022 icon: Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])(BlockIcon, { |
|
18023 icon: icon, |
|
18024 showColors: true |
|
18025 }), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["SVG"], { |
|
18026 className: "editor-block-switcher__transform block-editor-block-switcher__transform", |
|
18027 xmlns: "http://www.w3.org/2000/svg", |
|
18028 viewBox: "0 0 24 24" |
|
18029 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Path"], { |
|
18030 d: "M6.5 8.9c.6-.6 1.4-.9 2.2-.9h6.9l-1.3 1.3 1.4 1.4L19.4 7l-3.7-3.7-1.4 1.4L15.6 6H8.7c-1.4 0-2.6.5-3.6 1.5l-2.8 2.8 1.4 1.4 2.8-2.8zm13.8 2.4l-2.8 2.8c-.6.6-1.3.9-2.1.9h-7l1.3-1.3-1.4-1.4L4.6 16l3.7 3.7 1.4-1.4L8.4 17h6.9c1.3 0 2.6-.5 3.5-1.5l2.8-2.8-1.3-1.4z" |
|
18031 }))) |
|
18032 })); |
|
18033 }, |
|
18034 renderContent: function renderContent(_ref3) { |
|
18035 var onClose = _ref3.onClose; |
|
18036 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, hasBlockStyles && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["PanelBody"], { |
|
18037 title: Object(external_this_wp_i18n_["__"])('Block Styles'), |
|
18038 initialOpen: true |
|
18039 }, Object(external_this_wp_element_["createElement"])(block_styles, { |
|
18040 clientId: blocks[0].clientId, |
|
18041 onSwitch: onClose, |
|
18042 onHoverClassName: _this2.onHoverClassName |
|
18043 })), possibleBlockTransformations.length !== 0 && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["PanelBody"], { |
|
18044 title: Object(external_this_wp_i18n_["__"])('Transform To:'), |
|
18045 initialOpen: true |
|
18046 }, Object(external_this_wp_element_["createElement"])(block_types_list, { |
|
18047 items: possibleBlockTransformations.map(function (destinationBlockType) { |
|
18048 return { |
|
18049 id: destinationBlockType.name, |
|
18050 icon: destinationBlockType.icon, |
|
18051 title: destinationBlockType.title, |
|
18052 hasChildBlocksWithInserterSupport: Object(external_this_wp_blocks_["hasChildBlocksWithInserterSupport"])(destinationBlockType.name) |
|
18053 }; |
|
18054 }), |
|
18055 onSelect: function onSelect(item) { |
|
18056 onTransform(blocks, item.id); |
|
18057 onClose(); |
|
18058 } |
|
18059 })), hoveredClassName !== null && Object(external_this_wp_element_["createElement"])(block_preview, { |
|
18060 name: blocks[0].name, |
|
18061 attributes: Object(objectSpread["a" /* default */])({}, blocks[0].attributes, { |
|
18062 className: hoveredClassName |
|
18063 }) |
|
18064 })); |
|
18065 } |
|
18066 }); |
|
18067 } |
|
18068 }]); |
|
18069 |
|
18070 return BlockSwitcher; |
|
18071 }(external_this_wp_element_["Component"]); |
|
18072 /* harmony default export */ var block_switcher = (Object(external_this_wp_compose_["compose"])(Object(external_this_wp_data_["withSelect"])(function (select, _ref4) { |
|
18073 var clientIds = _ref4.clientIds; |
|
18074 |
|
18075 var _select = select('core/block-editor'), |
|
18076 getBlocksByClientId = _select.getBlocksByClientId, |
|
18077 getBlockRootClientId = _select.getBlockRootClientId, |
|
18078 getInserterItems = _select.getInserterItems; |
|
18079 |
|
18080 var _select2 = select('core/blocks'), |
|
18081 getBlockStyles = _select2.getBlockStyles; |
|
18082 |
|
18083 var rootClientId = getBlockRootClientId(Object(external_lodash_["first"])(Object(external_lodash_["castArray"])(clientIds))); |
|
18084 var blocks = getBlocksByClientId(clientIds); |
|
18085 var firstBlock = blocks && blocks.length === 1 ? blocks[0] : null; |
|
18086 var styles = firstBlock && getBlockStyles(firstBlock.name); |
|
18087 return { |
|
18088 blocks: blocks, |
|
18089 inserterItems: getInserterItems(rootClientId), |
|
18090 hasBlockStyles: styles && styles.length > 0 |
|
18091 }; |
|
18092 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, ownProps) { |
|
18093 return { |
|
18094 onTransform: function onTransform(blocks, name) { |
|
18095 dispatch('core/block-editor').replaceBlocks(ownProps.clientIds, Object(external_this_wp_blocks_["switchToBlockType"])(blocks, name)); |
|
18096 } |
|
18097 }; |
|
18098 }))(block_switcher_BlockSwitcher)); |
|
18099 |
|
18100 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/multi-blocks-switcher.js |
|
18101 |
|
18102 |
|
18103 /** |
|
18104 * WordPress dependencies |
|
18105 */ |
|
18106 |
|
18107 /** |
|
18108 * Internal dependencies |
|
18109 */ |
|
18110 |
|
18111 |
|
18112 function MultiBlocksSwitcher(_ref) { |
|
18113 var isMultiBlockSelection = _ref.isMultiBlockSelection, |
|
18114 selectedBlockClientIds = _ref.selectedBlockClientIds; |
|
18115 |
|
18116 if (!isMultiBlockSelection) { |
|
18117 return null; |
|
18118 } |
|
18119 |
|
18120 return Object(external_this_wp_element_["createElement"])(block_switcher, { |
|
18121 key: "switcher", |
|
18122 clientIds: selectedBlockClientIds |
|
18123 }); |
|
18124 } |
|
18125 /* harmony default export */ var multi_blocks_switcher = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
18126 var selectedBlockClientIds = select('core/block-editor').getMultiSelectedBlockClientIds(); |
|
18127 return { |
|
18128 isMultiBlockSelection: selectedBlockClientIds.length > 1, |
|
18129 selectedBlockClientIds: selectedBlockClientIds |
|
18130 }; |
|
18131 })(MultiBlocksSwitcher)); |
|
18132 |
|
18133 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-toolbar/index.js |
|
18134 |
|
18135 |
|
18136 /** |
|
18137 * WordPress dependencies |
|
18138 */ |
|
18139 |
|
18140 |
|
18141 /** |
|
18142 * Internal dependencies |
|
18143 */ |
|
18144 |
|
18145 |
|
18146 |
|
18147 |
|
18148 |
|
18149 |
|
18150 |
|
18151 function BlockToolbar(_ref) { |
|
18152 var blockClientIds = _ref.blockClientIds, |
|
18153 isValid = _ref.isValid, |
|
18154 mode = _ref.mode; |
|
18155 |
|
18156 if (blockClientIds.length === 0) { |
|
18157 return null; |
|
18158 } |
|
18159 |
|
18160 if (blockClientIds.length > 1) { |
|
18161 return Object(external_this_wp_element_["createElement"])("div", { |
|
18162 className: "editor-block-toolbar block-editor-block-toolbar" |
|
18163 }, Object(external_this_wp_element_["createElement"])(multi_blocks_switcher, null), Object(external_this_wp_element_["createElement"])(block_settings_menu, { |
|
18164 clientIds: blockClientIds |
|
18165 })); |
|
18166 } |
|
18167 |
|
18168 return Object(external_this_wp_element_["createElement"])("div", { |
|
18169 className: "editor-block-toolbar block-editor-block-toolbar" |
|
18170 }, mode === 'visual' && isValid && Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])(block_switcher, { |
|
18171 clientIds: blockClientIds |
|
18172 }), Object(external_this_wp_element_["createElement"])(block_controls.Slot, null), Object(external_this_wp_element_["createElement"])(block_format_controls.Slot, null)), Object(external_this_wp_element_["createElement"])(block_settings_menu, { |
|
18173 clientIds: blockClientIds |
|
18174 })); |
|
18175 } |
|
18176 |
|
18177 /* harmony default export */ var block_toolbar = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
18178 var _select = select('core/block-editor'), |
|
18179 getSelectedBlockClientId = _select.getSelectedBlockClientId, |
|
18180 getBlockMode = _select.getBlockMode, |
|
18181 getMultiSelectedBlockClientIds = _select.getMultiSelectedBlockClientIds, |
|
18182 isBlockValid = _select.isBlockValid; |
|
18183 |
|
18184 var selectedBlockClientId = getSelectedBlockClientId(); |
|
18185 var blockClientIds = selectedBlockClientId ? [selectedBlockClientId] : getMultiSelectedBlockClientIds(); |
|
18186 return { |
|
18187 blockClientIds: blockClientIds, |
|
18188 isValid: selectedBlockClientId ? isBlockValid(selectedBlockClientId) : null, |
|
18189 mode: selectedBlockClientId ? getBlockMode(selectedBlockClientId) : null |
|
18190 }; |
|
18191 })(BlockToolbar)); |
|
18192 |
|
18193 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/copy-handler/index.js |
|
18194 |
|
18195 |
|
18196 /** |
|
18197 * WordPress dependencies |
|
18198 */ |
|
18199 |
|
18200 |
|
18201 |
|
18202 |
|
18203 |
|
18204 function CopyHandler(_ref) { |
|
18205 var children = _ref.children, |
|
18206 onCopy = _ref.onCopy, |
|
18207 onCut = _ref.onCut; |
|
18208 return Object(external_this_wp_element_["createElement"])("div", { |
|
18209 onCopy: onCopy, |
|
18210 onCut: onCut |
|
18211 }, children); |
|
18212 } |
|
18213 |
|
18214 /* harmony default export */ var copy_handler = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withDispatch"])(function (dispatch, ownProps, _ref2) { |
|
18215 var select = _ref2.select; |
|
18216 |
|
18217 var _select = select('core/block-editor'), |
|
18218 getBlocksByClientId = _select.getBlocksByClientId, |
|
18219 getMultiSelectedBlockClientIds = _select.getMultiSelectedBlockClientIds, |
|
18220 getSelectedBlockClientId = _select.getSelectedBlockClientId, |
|
18221 hasMultiSelection = _select.hasMultiSelection; |
|
18222 |
|
18223 var _dispatch = dispatch('core/block-editor'), |
|
18224 removeBlocks = _dispatch.removeBlocks; |
|
18225 |
|
18226 var onCopy = function onCopy(event) { |
|
18227 var selectedBlockClientIds = getSelectedBlockClientId() ? [getSelectedBlockClientId()] : getMultiSelectedBlockClientIds(); |
|
18228 |
|
18229 if (selectedBlockClientIds.length === 0) { |
|
18230 return; |
|
18231 } // Let native copy behaviour take over in input fields. |
|
18232 |
|
18233 |
|
18234 if (!hasMultiSelection() && Object(external_this_wp_dom_["documentHasSelection"])()) { |
|
18235 return; |
|
18236 } |
|
18237 |
|
18238 var serialized = Object(external_this_wp_blocks_["serialize"])(getBlocksByClientId(selectedBlockClientIds)); |
|
18239 event.clipboardData.setData('text/plain', serialized); |
|
18240 event.clipboardData.setData('text/html', serialized); |
|
18241 event.preventDefault(); |
|
18242 }; |
|
18243 |
|
18244 return { |
|
18245 onCopy: onCopy, |
|
18246 onCut: function onCut(event) { |
|
18247 onCopy(event); |
|
18248 |
|
18249 if (hasMultiSelection()) { |
|
18250 var selectedBlockClientIds = getSelectedBlockClientId() ? [getSelectedBlockClientId()] : getMultiSelectedBlockClientIds(); |
|
18251 removeBlocks(selectedBlockClientIds); |
|
18252 } |
|
18253 } |
|
18254 }; |
|
18255 })])(CopyHandler)); |
|
18256 |
|
18257 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/multi-select-scroll-into-view/index.js |
|
18258 |
|
18259 |
|
18260 |
|
18261 |
|
18262 |
|
18263 |
|
18264 /** |
|
18265 * External dependencies |
|
18266 */ |
|
18267 |
|
18268 /** |
|
18269 * WordPress dependencies |
|
18270 */ |
|
18271 |
|
18272 |
|
18273 |
|
18274 |
|
18275 /** |
|
18276 * Internal dependencies |
|
18277 */ |
|
18278 |
|
18279 |
|
18280 |
|
18281 var multi_select_scroll_into_view_MultiSelectScrollIntoView = |
|
18282 /*#__PURE__*/ |
|
18283 function (_Component) { |
|
18284 Object(inherits["a" /* default */])(MultiSelectScrollIntoView, _Component); |
|
18285 |
|
18286 function MultiSelectScrollIntoView() { |
|
18287 Object(classCallCheck["a" /* default */])(this, MultiSelectScrollIntoView); |
|
18288 |
|
18289 return Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(MultiSelectScrollIntoView).apply(this, arguments)); |
|
18290 } |
|
18291 |
|
18292 Object(createClass["a" /* default */])(MultiSelectScrollIntoView, [{ |
|
18293 key: "componentDidUpdate", |
|
18294 value: function componentDidUpdate() { |
|
18295 // Relies on expectation that `componentDidUpdate` will only be called |
|
18296 // if value of `extentClientId` changes. |
|
18297 this.scrollIntoView(); |
|
18298 } |
|
18299 /** |
|
18300 * Ensures that if a multi-selection exists, the extent of the selection is |
|
18301 * visible within the nearest scrollable container. |
|
18302 * |
|
18303 * @return {void} |
|
18304 */ |
|
18305 |
|
18306 }, { |
|
18307 key: "scrollIntoView", |
|
18308 value: function scrollIntoView() { |
|
18309 var extentClientId = this.props.extentClientId; |
|
18310 |
|
18311 if (!extentClientId) { |
|
18312 return; |
|
18313 } |
|
18314 |
|
18315 var extentNode = getBlockDOMNode(extentClientId); |
|
18316 |
|
18317 if (!extentNode) { |
|
18318 return; |
|
18319 } |
|
18320 |
|
18321 var scrollContainer = Object(external_this_wp_dom_["getScrollContainer"])(extentNode); // If there's no scroll container, it follows that there's no scrollbar |
|
18322 // and thus there's no need to try to scroll into view. |
|
18323 |
|
18324 if (!scrollContainer) { |
|
18325 return; |
|
18326 } |
|
18327 |
|
18328 dom_scroll_into_view_lib_default()(extentNode, scrollContainer, { |
|
18329 onlyScrollIfNeeded: true |
|
18330 }); |
|
18331 } |
|
18332 }, { |
|
18333 key: "render", |
|
18334 value: function render() { |
|
18335 return null; |
|
18336 } |
|
18337 }]); |
|
18338 |
|
18339 return MultiSelectScrollIntoView; |
|
18340 }(external_this_wp_element_["Component"]); |
|
18341 |
|
18342 /* harmony default export */ var multi_select_scroll_into_view = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
18343 var _select = select('core/block-editor'), |
|
18344 getLastMultiSelectedBlockClientId = _select.getLastMultiSelectedBlockClientId; |
|
18345 |
|
18346 return { |
|
18347 extentClientId: getLastMultiSelectedBlockClientId() |
|
18348 }; |
|
18349 })(multi_select_scroll_into_view_MultiSelectScrollIntoView)); |
|
18350 |
|
18351 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/observe-typing/index.js |
|
18352 |
|
18353 |
|
18354 |
|
18355 |
|
18356 |
|
18357 |
|
18358 |
|
18359 |
|
18360 /** |
|
18361 * External dependencies |
|
18362 */ |
|
18363 |
|
18364 /** |
|
18365 * WordPress dependencies |
|
18366 */ |
|
18367 |
|
18368 |
|
18369 |
|
18370 |
|
18371 |
|
18372 |
|
18373 /** |
|
18374 * Set of key codes upon which typing is to be initiated on a keydown event. |
|
18375 * |
|
18376 * @type {number[]} |
|
18377 */ |
|
18378 |
|
18379 var KEY_DOWN_ELIGIBLE_KEY_CODES = [external_this_wp_keycodes_["UP"], external_this_wp_keycodes_["RIGHT"], external_this_wp_keycodes_["DOWN"], external_this_wp_keycodes_["LEFT"], external_this_wp_keycodes_["ENTER"], external_this_wp_keycodes_["BACKSPACE"]]; |
|
18380 /** |
|
18381 * Returns true if a given keydown event can be inferred as intent to start |
|
18382 * typing, or false otherwise. A keydown is considered eligible if it is a |
|
18383 * text navigation without shift active. |
|
18384 * |
|
18385 * @param {KeyboardEvent} event Keydown event to test. |
|
18386 * |
|
18387 * @return {boolean} Whether event is eligible to start typing. |
|
18388 */ |
|
18389 |
|
18390 function isKeyDownEligibleForStartTyping(event) { |
|
18391 var keyCode = event.keyCode, |
|
18392 shiftKey = event.shiftKey; |
|
18393 return !shiftKey && Object(external_lodash_["includes"])(KEY_DOWN_ELIGIBLE_KEY_CODES, keyCode); |
|
18394 } |
|
18395 |
|
18396 var observe_typing_ObserveTyping = |
|
18397 /*#__PURE__*/ |
|
18398 function (_Component) { |
|
18399 Object(inherits["a" /* default */])(ObserveTyping, _Component); |
|
18400 |
|
18401 function ObserveTyping() { |
|
18402 var _this; |
|
18403 |
|
18404 Object(classCallCheck["a" /* default */])(this, ObserveTyping); |
|
18405 |
|
18406 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(ObserveTyping).apply(this, arguments)); |
|
18407 _this.stopTypingOnSelectionUncollapse = _this.stopTypingOnSelectionUncollapse.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
18408 _this.stopTypingOnMouseMove = _this.stopTypingOnMouseMove.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
18409 _this.startTypingInTextField = _this.startTypingInTextField.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
18410 _this.stopTypingOnNonTextField = _this.stopTypingOnNonTextField.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
18411 _this.stopTypingOnEscapeKey = _this.stopTypingOnEscapeKey.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
18412 _this.onKeyDown = Object(external_lodash_["over"])([_this.startTypingInTextField, _this.stopTypingOnEscapeKey]); |
|
18413 _this.lastMouseMove = null; |
|
18414 return _this; |
|
18415 } |
|
18416 |
|
18417 Object(createClass["a" /* default */])(ObserveTyping, [{ |
|
18418 key: "componentDidMount", |
|
18419 value: function componentDidMount() { |
|
18420 this.toggleEventBindings(this.props.isTyping); |
|
18421 } |
|
18422 }, { |
|
18423 key: "componentDidUpdate", |
|
18424 value: function componentDidUpdate(prevProps) { |
|
18425 if (this.props.isTyping !== prevProps.isTyping) { |
|
18426 this.toggleEventBindings(this.props.isTyping); |
|
18427 } |
|
18428 } |
|
18429 }, { |
|
18430 key: "componentWillUnmount", |
|
18431 value: function componentWillUnmount() { |
|
18432 this.toggleEventBindings(false); |
|
18433 } |
|
18434 /** |
|
18435 * Bind or unbind events to the document when typing has started or stopped |
|
18436 * respectively, or when component has become unmounted. |
|
18437 * |
|
18438 * @param {boolean} isBound Whether event bindings should be applied. |
|
18439 */ |
|
18440 |
|
18441 }, { |
|
18442 key: "toggleEventBindings", |
|
18443 value: function toggleEventBindings(isBound) { |
|
18444 var bindFn = isBound ? 'addEventListener' : 'removeEventListener'; |
|
18445 document[bindFn]('selectionchange', this.stopTypingOnSelectionUncollapse); |
|
18446 document[bindFn]('mousemove', this.stopTypingOnMouseMove); |
|
18447 } |
|
18448 /** |
|
18449 * On mouse move, unset typing flag if user has moved cursor. |
|
18450 * |
|
18451 * @param {MouseEvent} event Mousemove event. |
|
18452 */ |
|
18453 |
|
18454 }, { |
|
18455 key: "stopTypingOnMouseMove", |
|
18456 value: function stopTypingOnMouseMove(event) { |
|
18457 var clientX = event.clientX, |
|
18458 clientY = event.clientY; // We need to check that the mouse really moved because Safari triggers |
|
18459 // mousemove events when shift or ctrl are pressed. |
|
18460 |
|
18461 if (this.lastMouseMove) { |
|
18462 var _this$lastMouseMove = this.lastMouseMove, |
|
18463 lastClientX = _this$lastMouseMove.clientX, |
|
18464 lastClientY = _this$lastMouseMove.clientY; |
|
18465 |
|
18466 if (lastClientX !== clientX || lastClientY !== clientY) { |
|
18467 this.props.onStopTyping(); |
|
18468 } |
|
18469 } |
|
18470 |
|
18471 this.lastMouseMove = { |
|
18472 clientX: clientX, |
|
18473 clientY: clientY |
|
18474 }; |
|
18475 } |
|
18476 /** |
|
18477 * On selection change, unset typing flag if user has made an uncollapsed |
|
18478 * (shift) selection. |
|
18479 */ |
|
18480 |
|
18481 }, { |
|
18482 key: "stopTypingOnSelectionUncollapse", |
|
18483 value: function stopTypingOnSelectionUncollapse() { |
|
18484 var selection = window.getSelection(); |
|
18485 var isCollapsed = selection.rangeCount > 0 && selection.getRangeAt(0).collapsed; |
|
18486 |
|
18487 if (!isCollapsed) { |
|
18488 this.props.onStopTyping(); |
|
18489 } |
|
18490 } |
|
18491 /** |
|
18492 * Unsets typing flag if user presses Escape while typing flag is active. |
|
18493 * |
|
18494 * @param {KeyboardEvent} event Keypress or keydown event to interpret. |
|
18495 */ |
|
18496 |
|
18497 }, { |
|
18498 key: "stopTypingOnEscapeKey", |
|
18499 value: function stopTypingOnEscapeKey(event) { |
|
18500 if (this.props.isTyping && event.keyCode === external_this_wp_keycodes_["ESCAPE"]) { |
|
18501 this.props.onStopTyping(); |
|
18502 } |
|
18503 } |
|
18504 /** |
|
18505 * Handles a keypress or keydown event to infer intention to start typing. |
|
18506 * |
|
18507 * @param {KeyboardEvent} event Keypress or keydown event to interpret. |
|
18508 */ |
|
18509 |
|
18510 }, { |
|
18511 key: "startTypingInTextField", |
|
18512 value: function startTypingInTextField(event) { |
|
18513 var _this$props = this.props, |
|
18514 isTyping = _this$props.isTyping, |
|
18515 onStartTyping = _this$props.onStartTyping; |
|
18516 var type = event.type, |
|
18517 target = event.target; // Abort early if already typing, or key press is incurred outside a |
|
18518 // text field (e.g. arrow-ing through toolbar buttons). |
|
18519 // Ignore typing in a block toolbar |
|
18520 |
|
18521 if (isTyping || !Object(external_this_wp_dom_["isTextField"])(target) || target.closest('.block-editor-block-toolbar')) { |
|
18522 return; |
|
18523 } // Special-case keydown because certain keys do not emit a keypress |
|
18524 // event. Conversely avoid keydown as the canonical event since there |
|
18525 // are many keydown which are explicitly not targeted for typing. |
|
18526 |
|
18527 |
|
18528 if (type === 'keydown' && !isKeyDownEligibleForStartTyping(event)) { |
|
18529 return; |
|
18530 } |
|
18531 |
|
18532 onStartTyping(); |
|
18533 } |
|
18534 /** |
|
18535 * Stops typing when focus transitions to a non-text field element. |
|
18536 * |
|
18537 * @param {FocusEvent} event Focus event. |
|
18538 */ |
|
18539 |
|
18540 }, { |
|
18541 key: "stopTypingOnNonTextField", |
|
18542 value: function stopTypingOnNonTextField(event) { |
|
18543 var _this2 = this; |
|
18544 |
|
18545 event.persist(); // Since focus to a non-text field via arrow key will trigger before |
|
18546 // the keydown event, wait until after current stack before evaluating |
|
18547 // whether typing is to be stopped. Otherwise, typing will re-start. |
|
18548 |
|
18549 this.props.setTimeout(function () { |
|
18550 var _this2$props = _this2.props, |
|
18551 isTyping = _this2$props.isTyping, |
|
18552 onStopTyping = _this2$props.onStopTyping; |
|
18553 var target = event.target; |
|
18554 |
|
18555 if (isTyping && !Object(external_this_wp_dom_["isTextField"])(target)) { |
|
18556 onStopTyping(); |
|
18557 } |
|
18558 }); |
|
18559 } |
|
18560 }, { |
|
18561 key: "render", |
|
18562 value: function render() { |
|
18563 var children = this.props.children; // Disable reason: This component is responsible for capturing bubbled |
|
18564 // keyboard events which are interpreted as typing intent. |
|
18565 |
|
18566 /* eslint-disable jsx-a11y/no-static-element-interactions */ |
|
18567 |
|
18568 return Object(external_this_wp_element_["createElement"])("div", { |
|
18569 onFocus: this.stopTypingOnNonTextField, |
|
18570 onKeyPress: this.startTypingInTextField, |
|
18571 onKeyDown: this.onKeyDown |
|
18572 }, children); |
|
18573 /* eslint-enable jsx-a11y/no-static-element-interactions */ |
|
18574 } |
|
18575 }]); |
|
18576 |
|
18577 return ObserveTyping; |
|
18578 }(external_this_wp_element_["Component"]); |
|
18579 |
|
18580 /* harmony default export */ var observe_typing = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
18581 var _select = select('core/block-editor'), |
|
18582 isTyping = _select.isTyping; |
|
18583 |
|
18584 return { |
|
18585 isTyping: isTyping() |
|
18586 }; |
|
18587 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
18588 var _dispatch = dispatch('core/block-editor'), |
|
18589 startTyping = _dispatch.startTyping, |
|
18590 stopTyping = _dispatch.stopTyping; |
|
18591 |
|
18592 return { |
|
18593 onStartTyping: startTyping, |
|
18594 onStopTyping: stopTyping |
|
18595 }; |
|
18596 }), external_this_wp_compose_["withSafeTimeout"]])(observe_typing_ObserveTyping)); |
|
18597 |
|
18598 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/preserve-scroll-in-reorder/index.js |
|
18599 |
|
18600 |
|
18601 |
|
18602 |
|
18603 |
|
18604 |
|
18605 /** |
|
18606 * WordPress dependencies |
|
18607 */ |
|
18608 |
|
18609 |
|
18610 |
|
18611 /** |
|
18612 * Internal dependencies |
|
18613 */ |
|
18614 |
|
18615 |
|
18616 /** |
|
18617 * Non-visual component which preserves offset of selected block within nearest |
|
18618 * scrollable container while reordering. |
|
18619 * |
|
18620 * @example |
|
18621 * |
|
18622 * ```jsx |
|
18623 * <PreserveScrollInReorder /> |
|
18624 * ``` |
|
18625 */ |
|
18626 |
|
18627 var preserve_scroll_in_reorder_PreserveScrollInReorder = |
|
18628 /*#__PURE__*/ |
|
18629 function (_Component) { |
|
18630 Object(inherits["a" /* default */])(PreserveScrollInReorder, _Component); |
|
18631 |
|
18632 function PreserveScrollInReorder() { |
|
18633 Object(classCallCheck["a" /* default */])(this, PreserveScrollInReorder); |
|
18634 |
|
18635 return Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(PreserveScrollInReorder).apply(this, arguments)); |
|
18636 } |
|
18637 |
|
18638 Object(createClass["a" /* default */])(PreserveScrollInReorder, [{ |
|
18639 key: "getSnapshotBeforeUpdate", |
|
18640 value: function getSnapshotBeforeUpdate(prevProps) { |
|
18641 var _this$props = this.props, |
|
18642 blockOrder = _this$props.blockOrder, |
|
18643 selectionStart = _this$props.selectionStart; |
|
18644 |
|
18645 if (blockOrder !== prevProps.blockOrder && selectionStart) { |
|
18646 return this.getOffset(selectionStart); |
|
18647 } |
|
18648 |
|
18649 return null; |
|
18650 } |
|
18651 }, { |
|
18652 key: "componentDidUpdate", |
|
18653 value: function componentDidUpdate(prevProps, prevState, snapshot) { |
|
18654 if (snapshot) { |
|
18655 this.restorePreviousOffset(snapshot); |
|
18656 } |
|
18657 } |
|
18658 /** |
|
18659 * Given the block client ID of the start of the selection, saves the |
|
18660 * block's top offset as an instance property before a reorder is to occur. |
|
18661 * |
|
18662 * @param {string} selectionStart Client ID of selected block. |
|
18663 * |
|
18664 * @return {number?} The scroll offset. |
|
18665 */ |
|
18666 |
|
18667 }, { |
|
18668 key: "getOffset", |
|
18669 value: function getOffset(selectionStart) { |
|
18670 var blockNode = getBlockDOMNode(selectionStart); |
|
18671 |
|
18672 if (!blockNode) { |
|
18673 return null; |
|
18674 } |
|
18675 |
|
18676 return blockNode.getBoundingClientRect().top; |
|
18677 } |
|
18678 /** |
|
18679 * After a block reordering, restores the previous viewport top offset. |
|
18680 * |
|
18681 * @param {number} offset The scroll offset. |
|
18682 */ |
|
18683 |
|
18684 }, { |
|
18685 key: "restorePreviousOffset", |
|
18686 value: function restorePreviousOffset(offset) { |
|
18687 var selectionStart = this.props.selectionStart; |
|
18688 var blockNode = getBlockDOMNode(selectionStart); |
|
18689 |
|
18690 if (blockNode) { |
|
18691 var scrollContainer = Object(external_this_wp_dom_["getScrollContainer"])(blockNode); |
|
18692 |
|
18693 if (scrollContainer) { |
|
18694 scrollContainer.scrollTop = scrollContainer.scrollTop + blockNode.getBoundingClientRect().top - offset; |
|
18695 } |
|
18696 } |
|
18697 } |
|
18698 }, { |
|
18699 key: "render", |
|
18700 value: function render() { |
|
18701 return null; |
|
18702 } |
|
18703 }]); |
|
18704 |
|
18705 return PreserveScrollInReorder; |
|
18706 }(external_this_wp_element_["Component"]); |
|
18707 |
|
18708 /* harmony default export */ var preserve_scroll_in_reorder = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
18709 return { |
|
18710 blockOrder: select('core/block-editor').getBlockOrder(), |
|
18711 selectionStart: select('core/block-editor').getBlockSelectionStart() |
|
18712 }; |
|
18713 })(preserve_scroll_in_reorder_PreserveScrollInReorder)); |
|
18714 |
|
18715 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/index.js |
|
18716 |
|
18717 |
|
18718 |
|
18719 |
|
18720 |
|
18721 |
|
18722 |
|
18723 |
|
18724 /** |
|
18725 * External dependencies |
|
18726 */ |
|
18727 |
|
18728 /** |
|
18729 * WordPress dependencies |
|
18730 */ |
|
18731 |
|
18732 |
|
18733 |
|
18734 |
|
18735 |
|
18736 |
|
18737 /** |
|
18738 * Internal dependencies |
|
18739 */ |
|
18740 |
|
18741 |
|
18742 /** |
|
18743 * Browser constants |
|
18744 */ |
|
18745 |
|
18746 var writing_flow_window = window, |
|
18747 writing_flow_getSelection = writing_flow_window.getSelection, |
|
18748 writing_flow_getComputedStyle = writing_flow_window.getComputedStyle; |
|
18749 /** |
|
18750 * Given an element, returns true if the element is a tabbable text field, or |
|
18751 * false otherwise. |
|
18752 * |
|
18753 * @param {Element} element Element to test. |
|
18754 * |
|
18755 * @return {boolean} Whether element is a tabbable text field. |
|
18756 */ |
|
18757 |
|
18758 var isTabbableTextField = Object(external_lodash_["overEvery"])([external_this_wp_dom_["isTextField"], external_this_wp_dom_["focus"].tabbable.isTabbableIndex]); |
|
18759 /** |
|
18760 * Returns true if the element should consider edge navigation upon a keyboard |
|
18761 * event of the given directional key code, or false otherwise. |
|
18762 * |
|
18763 * @param {Element} element HTML element to test. |
|
18764 * @param {number} keyCode KeyboardEvent keyCode to test. |
|
18765 * @param {boolean} hasModifier Whether a modifier is pressed. |
|
18766 * |
|
18767 * @return {boolean} Whether element should consider edge navigation. |
|
18768 */ |
|
18769 |
|
18770 function isNavigationCandidate(element, keyCode, hasModifier) { |
|
18771 var isVertical = keyCode === external_this_wp_keycodes_["UP"] || keyCode === external_this_wp_keycodes_["DOWN"]; // Currently, all elements support unmodified vertical navigation. |
|
18772 |
|
18773 if (isVertical && !hasModifier) { |
|
18774 return true; |
|
18775 } // Native inputs should not navigate horizontally. |
|
18776 |
|
18777 |
|
18778 var tagName = element.tagName; |
|
18779 return tagName !== 'INPUT' && tagName !== 'TEXTAREA'; |
|
18780 } |
|
18781 |
|
18782 var writing_flow_WritingFlow = |
|
18783 /*#__PURE__*/ |
|
18784 function (_Component) { |
|
18785 Object(inherits["a" /* default */])(WritingFlow, _Component); |
|
18786 |
|
18787 function WritingFlow() { |
|
18788 var _this; |
|
18789 |
|
18790 Object(classCallCheck["a" /* default */])(this, WritingFlow); |
|
18791 |
|
18792 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(WritingFlow).apply(this, arguments)); |
|
18793 _this.onKeyDown = _this.onKeyDown.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
18794 _this.bindContainer = _this.bindContainer.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
18795 _this.clearVerticalRect = _this.clearVerticalRect.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
18796 _this.focusLastTextField = _this.focusLastTextField.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
18797 /** |
|
18798 * Here a rectangle is stored while moving the caret vertically so |
|
18799 * vertical position of the start position can be restored. |
|
18800 * This is to recreate browser behaviour across blocks. |
|
18801 * |
|
18802 * @type {?DOMRect} |
|
18803 */ |
|
18804 |
|
18805 _this.verticalRect = null; |
|
18806 return _this; |
|
18807 } |
|
18808 |
|
18809 Object(createClass["a" /* default */])(WritingFlow, [{ |
|
18810 key: "bindContainer", |
|
18811 value: function bindContainer(ref) { |
|
18812 this.container = ref; |
|
18813 } |
|
18814 }, { |
|
18815 key: "clearVerticalRect", |
|
18816 value: function clearVerticalRect() { |
|
18817 this.verticalRect = null; |
|
18818 } |
|
18819 /** |
|
18820 * Returns the optimal tab target from the given focused element in the |
|
18821 * desired direction. A preference is made toward text fields, falling back |
|
18822 * to the block focus stop if no other candidates exist for the block. |
|
18823 * |
|
18824 * @param {Element} target Currently focused text field. |
|
18825 * @param {boolean} isReverse True if considering as the first field. |
|
18826 * |
|
18827 * @return {?Element} Optimal tab target, if one exists. |
|
18828 */ |
|
18829 |
|
18830 }, { |
|
18831 key: "getClosestTabbable", |
|
18832 value: function getClosestTabbable(target, isReverse) { |
|
18833 // Since the current focus target is not guaranteed to be a text field, |
|
18834 // find all focusables. Tabbability is considered later. |
|
18835 var focusableNodes = external_this_wp_dom_["focus"].focusable.find(this.container); |
|
18836 |
|
18837 if (isReverse) { |
|
18838 focusableNodes = Object(external_lodash_["reverse"])(focusableNodes); |
|
18839 } // Consider as candidates those focusables after the current target. |
|
18840 // It's assumed this can only be reached if the target is focusable |
|
18841 // (on its keydown event), so no need to verify it exists in the set. |
|
18842 |
|
18843 |
|
18844 focusableNodes = focusableNodes.slice(focusableNodes.indexOf(target) + 1); |
|
18845 |
|
18846 function isTabCandidate(node, i, array) { |
|
18847 // Not a candidate if the node is not tabbable. |
|
18848 if (!external_this_wp_dom_["focus"].tabbable.isTabbableIndex(node)) { |
|
18849 return false; |
|
18850 } // Prefer text fields... |
|
18851 |
|
18852 |
|
18853 if (Object(external_this_wp_dom_["isTextField"])(node)) { |
|
18854 return true; |
|
18855 } // ...but settle for block focus stop. |
|
18856 |
|
18857 |
|
18858 if (!isBlockFocusStop(node)) { |
|
18859 return false; |
|
18860 } // If element contains inner blocks, stop immediately at its focus |
|
18861 // wrapper. |
|
18862 |
|
18863 |
|
18864 if (hasInnerBlocksContext(node)) { |
|
18865 return true; |
|
18866 } // If navigating out of a block (in reverse), don't consider its |
|
18867 // block focus stop. |
|
18868 |
|
18869 |
|
18870 if (node.contains(target)) { |
|
18871 return false; |
|
18872 } // In case of block focus stop, check to see if there's a better |
|
18873 // text field candidate within. |
|
18874 |
|
18875 |
|
18876 for (var offset = 1, nextNode; nextNode = array[i + offset]; offset++) { |
|
18877 // Abort if no longer testing descendents of focus stop. |
|
18878 if (!node.contains(nextNode)) { |
|
18879 break; |
|
18880 } // Apply same tests by recursion. This is important to consider |
|
18881 // nestable blocks where we don't want to settle for the inner |
|
18882 // block focus stop. |
|
18883 |
|
18884 |
|
18885 if (isTabCandidate(nextNode, i + offset, array)) { |
|
18886 return false; |
|
18887 } |
|
18888 } |
|
18889 |
|
18890 return true; |
|
18891 } |
|
18892 |
|
18893 return Object(external_lodash_["find"])(focusableNodes, isTabCandidate); |
|
18894 } |
|
18895 }, { |
|
18896 key: "expandSelection", |
|
18897 value: function expandSelection(isReverse) { |
|
18898 var _this$props = this.props, |
|
18899 selectedBlockClientId = _this$props.selectedBlockClientId, |
|
18900 selectionStartClientId = _this$props.selectionStartClientId, |
|
18901 selectionBeforeEndClientId = _this$props.selectionBeforeEndClientId, |
|
18902 selectionAfterEndClientId = _this$props.selectionAfterEndClientId; |
|
18903 var nextSelectionEndClientId = isReverse ? selectionBeforeEndClientId : selectionAfterEndClientId; |
|
18904 |
|
18905 if (nextSelectionEndClientId) { |
|
18906 this.props.onMultiSelect(selectionStartClientId || selectedBlockClientId, nextSelectionEndClientId); |
|
18907 } |
|
18908 } |
|
18909 }, { |
|
18910 key: "moveSelection", |
|
18911 value: function moveSelection(isReverse) { |
|
18912 var _this$props2 = this.props, |
|
18913 selectedFirstClientId = _this$props2.selectedFirstClientId, |
|
18914 selectedLastClientId = _this$props2.selectedLastClientId; |
|
18915 var focusedBlockClientId = isReverse ? selectedFirstClientId : selectedLastClientId; |
|
18916 |
|
18917 if (focusedBlockClientId) { |
|
18918 this.props.onSelectBlock(focusedBlockClientId); |
|
18919 } |
|
18920 } |
|
18921 /** |
|
18922 * Returns true if the given target field is the last in its block which |
|
18923 * can be considered for tab transition. For example, in a block with two |
|
18924 * text fields, this would return true when reversing from the first of the |
|
18925 * two fields, but false when reversing from the second. |
|
18926 * |
|
18927 * @param {Element} target Currently focused text field. |
|
18928 * @param {boolean} isReverse True if considering as the first field. |
|
18929 * |
|
18930 * @return {boolean} Whether field is at edge for tab transition. |
|
18931 */ |
|
18932 |
|
18933 }, { |
|
18934 key: "isTabbableEdge", |
|
18935 value: function isTabbableEdge(target, isReverse) { |
|
18936 var closestTabbable = this.getClosestTabbable(target, isReverse); |
|
18937 return !closestTabbable || !isInSameBlock(target, closestTabbable); |
|
18938 } |
|
18939 }, { |
|
18940 key: "onKeyDown", |
|
18941 value: function onKeyDown(event) { |
|
18942 var _this$props3 = this.props, |
|
18943 hasMultiSelection = _this$props3.hasMultiSelection, |
|
18944 onMultiSelect = _this$props3.onMultiSelect, |
|
18945 blocks = _this$props3.blocks, |
|
18946 selectionBeforeEndClientId = _this$props3.selectionBeforeEndClientId, |
|
18947 selectionAfterEndClientId = _this$props3.selectionAfterEndClientId; |
|
18948 var keyCode = event.keyCode, |
|
18949 target = event.target; |
|
18950 var isUp = keyCode === external_this_wp_keycodes_["UP"]; |
|
18951 var isDown = keyCode === external_this_wp_keycodes_["DOWN"]; |
|
18952 var isLeft = keyCode === external_this_wp_keycodes_["LEFT"]; |
|
18953 var isRight = keyCode === external_this_wp_keycodes_["RIGHT"]; |
|
18954 var isReverse = isUp || isLeft; |
|
18955 var isHorizontal = isLeft || isRight; |
|
18956 var isVertical = isUp || isDown; |
|
18957 var isNav = isHorizontal || isVertical; |
|
18958 var isShift = event.shiftKey; |
|
18959 var hasModifier = isShift || event.ctrlKey || event.altKey || event.metaKey; |
|
18960 var isNavEdge = isVertical ? external_this_wp_dom_["isVerticalEdge"] : external_this_wp_dom_["isHorizontalEdge"]; // When presing any key other than up or down, the initial vertical |
|
18961 // position must ALWAYS be reset. The vertical position is saved so it |
|
18962 // can be restored as well as possible on sebsequent vertical arrow key |
|
18963 // presses. It may not always be possible to restore the exact same |
|
18964 // position (such as at an empty line), so it wouldn't be good to |
|
18965 // compute the position right before any vertical arrow key press. |
|
18966 |
|
18967 if (!isVertical) { |
|
18968 this.verticalRect = null; |
|
18969 } else if (!this.verticalRect) { |
|
18970 this.verticalRect = Object(external_this_wp_dom_["computeCaretRect"])(target); |
|
18971 } // This logic inside this condition needs to be checked before |
|
18972 // the check for event.nativeEvent.defaultPrevented. |
|
18973 // The logic handles meta+a keypress and this event is default prevented |
|
18974 // by RichText. |
|
18975 |
|
18976 |
|
18977 if (!isNav) { |
|
18978 // Set immediately before the meta+a combination can be pressed. |
|
18979 if (external_this_wp_keycodes_["isKeyboardEvent"].primary(event)) { |
|
18980 this.isEntirelySelected = Object(external_this_wp_dom_["isEntirelySelected"])(target); |
|
18981 } |
|
18982 |
|
18983 if (external_this_wp_keycodes_["isKeyboardEvent"].primary(event, 'a')) { |
|
18984 // When the target is contentEditable, selection will already |
|
18985 // have been set by the browser earlier in this call stack. We |
|
18986 // need check the previous result, otherwise all blocks will be |
|
18987 // selected right away. |
|
18988 if (target.isContentEditable ? this.isEntirelySelected : Object(external_this_wp_dom_["isEntirelySelected"])(target)) { |
|
18989 onMultiSelect(Object(external_lodash_["first"])(blocks), Object(external_lodash_["last"])(blocks)); |
|
18990 event.preventDefault(); |
|
18991 } // After pressing primary + A we can assume isEntirelySelected is true. |
|
18992 // Calling right away isEntirelySelected after primary + A may still return false on some browsers. |
|
18993 |
|
18994 |
|
18995 this.isEntirelySelected = true; |
|
18996 } |
|
18997 |
|
18998 return; |
|
18999 } // Abort if navigation has already been handled (e.g. RichText inline |
|
19000 // boundaries). |
|
19001 |
|
19002 |
|
19003 if (event.nativeEvent.defaultPrevented) { |
|
19004 return; |
|
19005 } // Abort if our current target is not a candidate for navigation (e.g. |
|
19006 // preserve native input behaviors). |
|
19007 |
|
19008 |
|
19009 if (!isNavigationCandidate(target, keyCode, hasModifier)) { |
|
19010 return; |
|
19011 } // In the case of RTL scripts, right means previous and left means next, |
|
19012 // which is the exact reverse of LTR. |
|
19013 |
|
19014 |
|
19015 var _getComputedStyle = writing_flow_getComputedStyle(target), |
|
19016 direction = _getComputedStyle.direction; |
|
19017 |
|
19018 var isReverseDir = direction === 'rtl' ? !isReverse : isReverse; |
|
19019 |
|
19020 if (isShift) { |
|
19021 if (( // Ensure that there is a target block. |
|
19022 isReverse && selectionBeforeEndClientId || !isReverse && selectionAfterEndClientId) && (hasMultiSelection || this.isTabbableEdge(target, isReverse) && isNavEdge(target, isReverse))) { |
|
19023 // Shift key is down, and there is multi selection or we're at |
|
19024 // the end of the current block. |
|
19025 this.expandSelection(isReverse); |
|
19026 event.preventDefault(); |
|
19027 } |
|
19028 } else if (hasMultiSelection) { |
|
19029 // Moving from block multi-selection to single block selection |
|
19030 this.moveSelection(isReverse); |
|
19031 event.preventDefault(); |
|
19032 } else if (isVertical && Object(external_this_wp_dom_["isVerticalEdge"])(target, isReverse)) { |
|
19033 var closestTabbable = this.getClosestTabbable(target, isReverse); |
|
19034 |
|
19035 if (closestTabbable) { |
|
19036 Object(external_this_wp_dom_["placeCaretAtVerticalEdge"])(closestTabbable, isReverse, this.verticalRect); |
|
19037 event.preventDefault(); |
|
19038 } |
|
19039 } else if (isHorizontal && writing_flow_getSelection().isCollapsed && Object(external_this_wp_dom_["isHorizontalEdge"])(target, isReverseDir)) { |
|
19040 var _closestTabbable = this.getClosestTabbable(target, isReverseDir); |
|
19041 |
|
19042 Object(external_this_wp_dom_["placeCaretAtHorizontalEdge"])(_closestTabbable, isReverseDir); |
|
19043 event.preventDefault(); |
|
19044 } |
|
19045 } |
|
19046 /** |
|
19047 * Sets focus to the end of the last tabbable text field, if one exists. |
|
19048 */ |
|
19049 |
|
19050 }, { |
|
19051 key: "focusLastTextField", |
|
19052 value: function focusLastTextField() { |
|
19053 var focusableNodes = external_this_wp_dom_["focus"].focusable.find(this.container); |
|
19054 var target = Object(external_lodash_["findLast"])(focusableNodes, isTabbableTextField); |
|
19055 |
|
19056 if (target) { |
|
19057 Object(external_this_wp_dom_["placeCaretAtHorizontalEdge"])(target, true); |
|
19058 } |
|
19059 } |
|
19060 }, { |
|
19061 key: "render", |
|
19062 value: function render() { |
|
19063 var children = this.props.children; // Disable reason: Wrapper itself is non-interactive, but must capture |
|
19064 // bubbling events from children to determine focus transition intents. |
|
19065 |
|
19066 /* eslint-disable jsx-a11y/no-static-element-interactions */ |
|
19067 |
|
19068 return Object(external_this_wp_element_["createElement"])("div", { |
|
19069 className: "editor-writing-flow block-editor-writing-flow" |
|
19070 }, Object(external_this_wp_element_["createElement"])("div", { |
|
19071 ref: this.bindContainer, |
|
19072 onKeyDown: this.onKeyDown, |
|
19073 onMouseDown: this.clearVerticalRect |
|
19074 }, children), Object(external_this_wp_element_["createElement"])("div", { |
|
19075 "aria-hidden": true, |
|
19076 tabIndex: -1, |
|
19077 onClick: this.focusLastTextField, |
|
19078 className: "wp-block editor-writing-flow__click-redirect block-editor-writing-flow__click-redirect" |
|
19079 })); |
|
19080 /* eslint-disable jsx-a11y/no-static-element-interactions */ |
|
19081 } |
|
19082 }]); |
|
19083 |
|
19084 return WritingFlow; |
|
19085 }(external_this_wp_element_["Component"]); |
|
19086 |
|
19087 /* harmony default export */ var writing_flow = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
19088 var _select = select('core/block-editor'), |
|
19089 getSelectedBlockClientId = _select.getSelectedBlockClientId, |
|
19090 getMultiSelectedBlocksStartClientId = _select.getMultiSelectedBlocksStartClientId, |
|
19091 getMultiSelectedBlocksEndClientId = _select.getMultiSelectedBlocksEndClientId, |
|
19092 getPreviousBlockClientId = _select.getPreviousBlockClientId, |
|
19093 getNextBlockClientId = _select.getNextBlockClientId, |
|
19094 getFirstMultiSelectedBlockClientId = _select.getFirstMultiSelectedBlockClientId, |
|
19095 getLastMultiSelectedBlockClientId = _select.getLastMultiSelectedBlockClientId, |
|
19096 hasMultiSelection = _select.hasMultiSelection, |
|
19097 getBlockOrder = _select.getBlockOrder; |
|
19098 |
|
19099 var selectedBlockClientId = getSelectedBlockClientId(); |
|
19100 var selectionStartClientId = getMultiSelectedBlocksStartClientId(); |
|
19101 var selectionEndClientId = getMultiSelectedBlocksEndClientId(); |
|
19102 return { |
|
19103 selectedBlockClientId: selectedBlockClientId, |
|
19104 selectionStartClientId: selectionStartClientId, |
|
19105 selectionBeforeEndClientId: getPreviousBlockClientId(selectionEndClientId || selectedBlockClientId), |
|
19106 selectionAfterEndClientId: getNextBlockClientId(selectionEndClientId || selectedBlockClientId), |
|
19107 selectedFirstClientId: getFirstMultiSelectedBlockClientId(), |
|
19108 selectedLastClientId: getLastMultiSelectedBlockClientId(), |
|
19109 hasMultiSelection: hasMultiSelection(), |
|
19110 blocks: getBlockOrder() |
|
19111 }; |
|
19112 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
19113 var _dispatch = dispatch('core/block-editor'), |
|
19114 multiSelect = _dispatch.multiSelect, |
|
19115 selectBlock = _dispatch.selectBlock; |
|
19116 |
|
19117 return { |
|
19118 onMultiSelect: multiSelect, |
|
19119 onSelectBlock: selectBlock |
|
19120 }; |
|
19121 })])(writing_flow_WritingFlow)); |
|
19122 |
|
19123 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/provider/index.js |
|
19124 |
|
19125 |
|
19126 |
|
19127 |
|
19128 |
|
19129 |
|
19130 |
|
19131 /** |
|
19132 * WordPress dependencies |
|
19133 */ |
|
19134 |
|
19135 |
|
19136 |
|
19137 |
|
19138 |
|
19139 var provider_BlockEditorProvider = |
|
19140 /*#__PURE__*/ |
|
19141 function (_Component) { |
|
19142 Object(inherits["a" /* default */])(BlockEditorProvider, _Component); |
|
19143 |
|
19144 function BlockEditorProvider() { |
|
19145 Object(classCallCheck["a" /* default */])(this, BlockEditorProvider); |
|
19146 |
|
19147 return Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(BlockEditorProvider).apply(this, arguments)); |
|
19148 } |
|
19149 |
|
19150 Object(createClass["a" /* default */])(BlockEditorProvider, [{ |
|
19151 key: "componentDidMount", |
|
19152 value: function componentDidMount() { |
|
19153 this.props.updateSettings(this.props.settings); |
|
19154 this.props.resetBlocks(this.props.value); |
|
19155 this.attachChangeObserver(this.props.registry); |
|
19156 } |
|
19157 }, { |
|
19158 key: "componentDidUpdate", |
|
19159 value: function componentDidUpdate(prevProps) { |
|
19160 var _this$props = this.props, |
|
19161 settings = _this$props.settings, |
|
19162 updateSettings = _this$props.updateSettings, |
|
19163 value = _this$props.value, |
|
19164 resetBlocks = _this$props.resetBlocks, |
|
19165 registry = _this$props.registry; |
|
19166 |
|
19167 if (settings !== prevProps.settings) { |
|
19168 updateSettings(settings); |
|
19169 } |
|
19170 |
|
19171 if (registry !== prevProps.registry) { |
|
19172 this.attachChangeObserver(registry); |
|
19173 } |
|
19174 |
|
19175 if (this.isSyncingOutcomingValue) { |
|
19176 this.isSyncingOutcomingValue = false; |
|
19177 } else if (value !== prevProps.value) { |
|
19178 this.isSyncingIncomingValue = true; |
|
19179 resetBlocks(value); |
|
19180 } |
|
19181 } |
|
19182 }, { |
|
19183 key: "componentWillUnmount", |
|
19184 value: function componentWillUnmount() { |
|
19185 if (this.unsubscribe) { |
|
19186 this.unsubscribe(); |
|
19187 } |
|
19188 } |
|
19189 /** |
|
19190 * Given a registry object, overrides the default dispatch behavior for the |
|
19191 * `core/block-editor` store to interpret a state change and decide whether |
|
19192 * we should call `onChange` or `onInput` depending on whether the change |
|
19193 * is persistent or not. |
|
19194 * |
|
19195 * This needs to be done synchronously after state changes (instead of using |
|
19196 * `componentDidUpdate`) in order to avoid batching these changes. |
|
19197 * |
|
19198 * @param {WPDataRegistry} registry Registry from which block editor |
|
19199 * dispatch is to be overriden. |
|
19200 */ |
|
19201 |
|
19202 }, { |
|
19203 key: "attachChangeObserver", |
|
19204 value: function attachChangeObserver(registry) { |
|
19205 var _this = this; |
|
19206 |
|
19207 if (this.unsubscribe) { |
|
19208 this.unsubscribe(); |
|
19209 } |
|
19210 |
|
19211 var _registry$select = registry.select('core/block-editor'), |
|
19212 getBlocks = _registry$select.getBlocks, |
|
19213 isLastBlockChangePersistent = _registry$select.isLastBlockChangePersistent, |
|
19214 __unstableIsLastBlockChangeIgnored = _registry$select.__unstableIsLastBlockChangeIgnored; |
|
19215 |
|
19216 var blocks = getBlocks(); |
|
19217 var isPersistent = isLastBlockChangePersistent(); |
|
19218 this.unsubscribe = registry.subscribe(function () { |
|
19219 var _this$props2 = _this.props, |
|
19220 onChange = _this$props2.onChange, |
|
19221 onInput = _this$props2.onInput; |
|
19222 var newBlocks = getBlocks(); |
|
19223 var newIsPersistent = isLastBlockChangePersistent(); |
|
19224 |
|
19225 if (newBlocks !== blocks && (_this.isSyncingIncomingValue || __unstableIsLastBlockChangeIgnored())) { |
|
19226 _this.isSyncingIncomingValue = false; |
|
19227 blocks = newBlocks; |
|
19228 isPersistent = newIsPersistent; |
|
19229 return; |
|
19230 } |
|
19231 |
|
19232 if (newBlocks !== blocks || // This happens when a previous input is explicitely marked as persistent. |
|
19233 newIsPersistent && !isPersistent) { |
|
19234 // When knowing the blocks value is changing, assign instance |
|
19235 // value to skip reset in subsequent `componentDidUpdate`. |
|
19236 if (newBlocks !== blocks) { |
|
19237 _this.isSyncingOutcomingValue = true; |
|
19238 } |
|
19239 |
|
19240 blocks = newBlocks; |
|
19241 isPersistent = newIsPersistent; |
|
19242 |
|
19243 if (isPersistent) { |
|
19244 onChange(blocks); |
|
19245 } else { |
|
19246 onInput(blocks); |
|
19247 } |
|
19248 } |
|
19249 }); |
|
19250 } |
|
19251 }, { |
|
19252 key: "render", |
|
19253 value: function render() { |
|
19254 var children = this.props.children; |
|
19255 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["SlotFillProvider"], null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["DropZoneProvider"], null, children)); |
|
19256 } |
|
19257 }]); |
|
19258 |
|
19259 return BlockEditorProvider; |
|
19260 }(external_this_wp_element_["Component"]); |
|
19261 |
|
19262 /* harmony default export */ var provider = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
19263 var _dispatch = dispatch('core/block-editor'), |
|
19264 updateSettings = _dispatch.updateSettings, |
|
19265 resetBlocks = _dispatch.resetBlocks; |
|
19266 |
|
19267 return { |
|
19268 updateSettings: updateSettings, |
|
19269 resetBlocks: resetBlocks |
|
19270 }; |
|
19271 }), external_this_wp_data_["withRegistry"]])(provider_BlockEditorProvider)); |
|
19272 |
|
19273 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/index.js |
|
19274 // Block Creation Components |
|
19275 |
|
19276 |
|
19277 |
|
19278 |
|
19279 |
|
19280 |
|
19281 |
|
19282 |
|
19283 |
|
19284 |
|
19285 |
|
19286 |
|
19287 |
|
19288 |
|
19289 |
|
19290 |
|
19291 |
|
19292 |
|
19293 |
|
19294 |
|
19295 |
|
19296 |
|
19297 |
|
19298 |
|
19299 // Content Related Components |
|
19300 |
|
19301 |
|
19302 |
|
19303 |
|
19304 |
|
19305 |
|
19306 |
|
19307 |
|
19308 |
|
19309 |
|
19310 |
|
19311 |
|
19312 |
|
19313 |
|
19314 |
|
19315 |
|
19316 |
|
19317 |
|
19318 |
|
19319 |
|
19320 |
|
19321 // State Related Components |
|
19322 |
|
19323 |
|
19324 |
|
19325 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/align.js |
|
19326 |
|
19327 |
|
19328 |
|
19329 |
|
19330 /** |
|
19331 * External dependencies |
|
19332 */ |
|
19333 |
|
19334 |
|
19335 /** |
|
19336 * WordPress dependencies |
|
19337 */ |
|
19338 |
|
19339 |
|
19340 |
|
19341 |
|
19342 |
|
19343 /** |
|
19344 * Internal dependencies |
|
19345 */ |
|
19346 |
|
19347 |
|
19348 /** |
|
19349 * An array which includes all possible valid alignments, |
|
19350 * used to validate if an alignment is valid or not. |
|
19351 * |
|
19352 * @constant |
|
19353 * @type {string[]} |
|
19354 */ |
|
19355 |
|
19356 var ALL_ALIGNMENTS = ['left', 'center', 'right', 'wide', 'full']; |
|
19357 /** |
|
19358 * An array which includes all wide alignments. |
|
19359 * In order for this alignments to be valid they need to be supported by the block, |
|
19360 * and by the theme. |
|
19361 * |
|
19362 * @constant |
|
19363 * @type {string[]} |
|
19364 */ |
|
19365 |
|
19366 var WIDE_ALIGNMENTS = ['wide', 'full']; |
|
19367 /** |
|
19368 * Returns the valid alignments. |
|
19369 * Takes into consideration the aligns supported by a block, if the block supports wide controls or not and if theme supports wide controls or not. |
|
19370 * Exported just for testing purposes, not exported outside the module. |
|
19371 * |
|
19372 * @param {?boolean|string[]} blockAlign Aligns supported by the block. |
|
19373 * @param {?boolean} hasWideBlockSupport True if block supports wide alignments. And False otherwise. |
|
19374 * @param {?boolean} hasWideEnabled True if theme supports wide alignments. And False otherwise. |
|
19375 * |
|
19376 * @return {string[]} Valid alignments. |
|
19377 */ |
|
19378 |
|
19379 function getValidAlignments(blockAlign) { |
|
19380 var hasWideBlockSupport = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; |
|
19381 var hasWideEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; |
|
19382 var validAlignments; |
|
19383 |
|
19384 if (Array.isArray(blockAlign)) { |
|
19385 validAlignments = blockAlign; |
|
19386 } else if (blockAlign === true) { |
|
19387 // `true` includes all alignments... |
|
19388 validAlignments = ALL_ALIGNMENTS; |
|
19389 } else { |
|
19390 validAlignments = []; |
|
19391 } |
|
19392 |
|
19393 if (!hasWideEnabled || blockAlign === true && !hasWideBlockSupport) { |
|
19394 return external_lodash_["without"].apply(void 0, [validAlignments].concat(WIDE_ALIGNMENTS)); |
|
19395 } |
|
19396 |
|
19397 return validAlignments; |
|
19398 } |
|
19399 /** |
|
19400 * Filters registered block settings, extending attributes to include `align`. |
|
19401 * |
|
19402 * @param {Object} settings Original block settings |
|
19403 * @return {Object} Filtered block settings |
|
19404 */ |
|
19405 |
|
19406 function addAttribute(settings) { |
|
19407 // allow blocks to specify their own attribute definition with default values if needed. |
|
19408 if (Object(external_lodash_["has"])(settings.attributes, ['align', 'type'])) { |
|
19409 return settings; |
|
19410 } |
|
19411 |
|
19412 if (Object(external_this_wp_blocks_["hasBlockSupport"])(settings, 'align')) { |
|
19413 // Use Lodash's assign to gracefully handle if attributes are undefined |
|
19414 settings.attributes = Object(external_lodash_["assign"])(settings.attributes, { |
|
19415 align: { |
|
19416 type: 'string' |
|
19417 } |
|
19418 }); |
|
19419 } |
|
19420 |
|
19421 return settings; |
|
19422 } |
|
19423 /** |
|
19424 * Override the default edit UI to include new toolbar controls for block |
|
19425 * alignment, if block defines support. |
|
19426 * |
|
19427 * @param {Function} BlockEdit Original component |
|
19428 * @return {Function} Wrapped component |
|
19429 */ |
|
19430 |
|
19431 var withToolbarControls = Object(external_this_wp_compose_["createHigherOrderComponent"])(function (BlockEdit) { |
|
19432 return function (props) { |
|
19433 var blockName = props.name; // Compute valid alignments without taking into account, |
|
19434 // if the theme supports wide alignments or not. |
|
19435 // BlockAlignmentToolbar takes into account the theme support. |
|
19436 |
|
19437 var validAlignments = getValidAlignments(Object(external_this_wp_blocks_["getBlockSupport"])(blockName, 'align'), Object(external_this_wp_blocks_["hasBlockSupport"])(blockName, 'alignWide', true)); |
|
19438 |
|
19439 var updateAlignment = function updateAlignment(nextAlign) { |
|
19440 if (!nextAlign) { |
|
19441 var blockType = Object(external_this_wp_blocks_["getBlockType"])(props.name); |
|
19442 var blockDefaultAlign = Object(external_lodash_["get"])(blockType, ['attributes', 'align', 'default']); |
|
19443 |
|
19444 if (blockDefaultAlign) { |
|
19445 nextAlign = ''; |
|
19446 } |
|
19447 } |
|
19448 |
|
19449 props.setAttributes({ |
|
19450 align: nextAlign |
|
19451 }); |
|
19452 }; |
|
19453 |
|
19454 return [validAlignments.length > 0 && props.isSelected && Object(external_this_wp_element_["createElement"])(block_controls, { |
|
19455 key: "align-controls" |
|
19456 }, Object(external_this_wp_element_["createElement"])(block_alignment_toolbar, { |
|
19457 value: props.attributes.align, |
|
19458 onChange: updateAlignment, |
|
19459 controls: validAlignments |
|
19460 })), Object(external_this_wp_element_["createElement"])(BlockEdit, Object(esm_extends["a" /* default */])({ |
|
19461 key: "edit" |
|
19462 }, props))]; |
|
19463 }; |
|
19464 }, 'withToolbarControls'); // Exported just for testing purposes, not exported outside the module. |
|
19465 |
|
19466 var align_insideSelectWithDataAlign = function insideSelectWithDataAlign(BlockListBlock) { |
|
19467 return function (props) { |
|
19468 var name = props.name, |
|
19469 attributes = props.attributes, |
|
19470 hasWideEnabled = props.hasWideEnabled; |
|
19471 var align = attributes.align; |
|
19472 var validAlignments = getValidAlignments(Object(external_this_wp_blocks_["getBlockSupport"])(name, 'align'), Object(external_this_wp_blocks_["hasBlockSupport"])(name, 'alignWide', true), hasWideEnabled); |
|
19473 var wrapperProps = props.wrapperProps; |
|
19474 |
|
19475 if (Object(external_lodash_["includes"])(validAlignments, align)) { |
|
19476 wrapperProps = Object(objectSpread["a" /* default */])({}, wrapperProps, { |
|
19477 'data-align': align |
|
19478 }); |
|
19479 } |
|
19480 |
|
19481 return Object(external_this_wp_element_["createElement"])(BlockListBlock, Object(esm_extends["a" /* default */])({}, props, { |
|
19482 wrapperProps: wrapperProps |
|
19483 })); |
|
19484 }; |
|
19485 }; |
|
19486 /** |
|
19487 * Override the default block element to add alignment wrapper props. |
|
19488 * |
|
19489 * @param {Function} BlockListBlock Original component |
|
19490 * @return {Function} Wrapped component |
|
19491 */ |
|
19492 |
|
19493 var withDataAlign = Object(external_this_wp_compose_["createHigherOrderComponent"])(Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
19494 var _select = select('core/block-editor'), |
|
19495 getSettings = _select.getSettings; |
|
19496 |
|
19497 return { |
|
19498 hasWideEnabled: !!getSettings().alignWide |
|
19499 }; |
|
19500 }), align_insideSelectWithDataAlign])); |
|
19501 /** |
|
19502 * Override props assigned to save component to inject alignment class name if |
|
19503 * block supports it. |
|
19504 * |
|
19505 * @param {Object} props Additional props applied to save element |
|
19506 * @param {Object} blockType Block type |
|
19507 * @param {Object} attributes Block attributes |
|
19508 * @return {Object} Filtered props applied to save element |
|
19509 */ |
|
19510 |
|
19511 function addAssignedAlign(props, blockType, attributes) { |
|
19512 var align = attributes.align; |
|
19513 var blockAlign = Object(external_this_wp_blocks_["getBlockSupport"])(blockType, 'align'); |
|
19514 var hasWideBlockSupport = Object(external_this_wp_blocks_["hasBlockSupport"])(blockType, 'alignWide', true); |
|
19515 var isAlignValid = Object(external_lodash_["includes"])( // Compute valid alignments without taking into account, |
|
19516 // if the theme supports wide alignments or not. |
|
19517 // This way changing themes does not impacts the block save. |
|
19518 getValidAlignments(blockAlign, hasWideBlockSupport), align); |
|
19519 |
|
19520 if (isAlignValid) { |
|
19521 props.className = classnames_default()("align".concat(align), props.className); |
|
19522 } |
|
19523 |
|
19524 return props; |
|
19525 } |
|
19526 Object(external_this_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/align/addAttribute', addAttribute); |
|
19527 Object(external_this_wp_hooks_["addFilter"])('editor.BlockListBlock', 'core/editor/align/with-data-align', withDataAlign); |
|
19528 Object(external_this_wp_hooks_["addFilter"])('editor.BlockEdit', 'core/editor/align/with-toolbar-controls', withToolbarControls); |
|
19529 Object(external_this_wp_hooks_["addFilter"])('blocks.getSaveContent.extraProps', 'core/align/addAssignedAlign', addAssignedAlign); |
|
19530 |
|
19531 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/anchor.js |
|
19532 |
|
19533 |
|
19534 /** |
|
19535 * External dependencies |
|
19536 */ |
|
19537 |
|
19538 /** |
|
19539 * WordPress dependencies |
|
19540 */ |
|
19541 |
|
19542 |
|
19543 |
|
19544 |
|
19545 |
|
19546 |
|
19547 |
|
19548 /** |
|
19549 * Internal dependencies |
|
19550 */ |
|
19551 |
|
19552 |
|
19553 /** |
|
19554 * Regular expression matching invalid anchor characters for replacement. |
|
19555 * |
|
19556 * @type {RegExp} |
|
19557 */ |
|
19558 |
|
19559 var ANCHOR_REGEX = /[\s#]/g; |
|
19560 /** |
|
19561 * Filters registered block settings, extending attributes with anchor using ID |
|
19562 * of the first node. |
|
19563 * |
|
19564 * @param {Object} settings Original block settings. |
|
19565 * |
|
19566 * @return {Object} Filtered block settings. |
|
19567 */ |
|
19568 |
|
19569 function anchor_addAttribute(settings) { |
|
19570 if (Object(external_this_wp_blocks_["hasBlockSupport"])(settings, 'anchor')) { |
|
19571 // Use Lodash's assign to gracefully handle if attributes are undefined |
|
19572 settings.attributes = Object(external_lodash_["assign"])(settings.attributes, { |
|
19573 anchor: { |
|
19574 type: 'string', |
|
19575 source: 'attribute', |
|
19576 attribute: 'id', |
|
19577 selector: '*' |
|
19578 } |
|
19579 }); |
|
19580 } |
|
19581 |
|
19582 return settings; |
|
19583 } |
|
19584 /** |
|
19585 * Override the default edit UI to include a new block inspector control for |
|
19586 * assigning the anchor ID, if block supports anchor. |
|
19587 * |
|
19588 * @param {function|Component} BlockEdit Original component. |
|
19589 * |
|
19590 * @return {string} Wrapped component. |
|
19591 */ |
|
19592 |
|
19593 var withInspectorControl = Object(external_this_wp_compose_["createHigherOrderComponent"])(function (BlockEdit) { |
|
19594 return function (props) { |
|
19595 var hasAnchor = Object(external_this_wp_blocks_["hasBlockSupport"])(props.name, 'anchor'); |
|
19596 |
|
19597 if (hasAnchor && props.isSelected) { |
|
19598 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])(BlockEdit, props), Object(external_this_wp_element_["createElement"])(inspector_advanced_controls, null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["TextControl"], { |
|
19599 label: Object(external_this_wp_i18n_["__"])('HTML Anchor'), |
|
19600 help: Object(external_this_wp_i18n_["__"])('Anchors lets you link directly to a section on a page.'), |
|
19601 value: props.attributes.anchor || '', |
|
19602 onChange: function onChange(nextValue) { |
|
19603 nextValue = nextValue.replace(ANCHOR_REGEX, '-'); |
|
19604 props.setAttributes({ |
|
19605 anchor: nextValue |
|
19606 }); |
|
19607 } |
|
19608 }))); |
|
19609 } |
|
19610 |
|
19611 return Object(external_this_wp_element_["createElement"])(BlockEdit, props); |
|
19612 }; |
|
19613 }, 'withInspectorControl'); |
|
19614 /** |
|
19615 * Override props assigned to save component to inject anchor ID, if block |
|
19616 * supports anchor. This is only applied if the block's save result is an |
|
19617 * element and not a markup string. |
|
19618 * |
|
19619 * @param {Object} extraProps Additional props applied to save element. |
|
19620 * @param {Object} blockType Block type. |
|
19621 * @param {Object} attributes Current block attributes. |
|
19622 * |
|
19623 * @return {Object} Filtered props applied to save element. |
|
19624 */ |
|
19625 |
|
19626 function addSaveProps(extraProps, blockType, attributes) { |
|
19627 if (Object(external_this_wp_blocks_["hasBlockSupport"])(blockType, 'anchor')) { |
|
19628 extraProps.id = attributes.anchor === '' ? null : attributes.anchor; |
|
19629 } |
|
19630 |
|
19631 return extraProps; |
|
19632 } |
|
19633 Object(external_this_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/anchor/attribute', anchor_addAttribute); |
|
19634 Object(external_this_wp_hooks_["addFilter"])('editor.BlockEdit', 'core/editor/anchor/with-inspector-control', withInspectorControl); |
|
19635 Object(external_this_wp_hooks_["addFilter"])('blocks.getSaveContent.extraProps', 'core/anchor/save-props', addSaveProps); |
|
19636 |
|
19637 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/custom-class-name.js |
|
19638 |
|
19639 |
|
19640 /** |
|
19641 * External dependencies |
|
19642 */ |
|
19643 |
|
19644 |
|
19645 /** |
|
19646 * WordPress dependencies |
|
19647 */ |
|
19648 |
|
19649 |
|
19650 |
|
19651 |
|
19652 |
|
19653 |
|
19654 |
|
19655 /** |
|
19656 * Internal dependencies |
|
19657 */ |
|
19658 |
|
19659 |
|
19660 /** |
|
19661 * Filters registered block settings, extending attributes with anchor using ID |
|
19662 * of the first node. |
|
19663 * |
|
19664 * @param {Object} settings Original block settings. |
|
19665 * |
|
19666 * @return {Object} Filtered block settings. |
|
19667 */ |
|
19668 |
|
19669 function custom_class_name_addAttribute(settings) { |
|
19670 if (Object(external_this_wp_blocks_["hasBlockSupport"])(settings, 'customClassName', true)) { |
|
19671 // Use Lodash's assign to gracefully handle if attributes are undefined |
|
19672 settings.attributes = Object(external_lodash_["assign"])(settings.attributes, { |
|
19673 className: { |
|
19674 type: 'string' |
|
19675 } |
|
19676 }); |
|
19677 } |
|
19678 |
|
19679 return settings; |
|
19680 } |
|
19681 /** |
|
19682 * Override the default edit UI to include a new block inspector control for |
|
19683 * assigning the custom class name, if block supports custom class name. |
|
19684 * |
|
19685 * @param {function|Component} BlockEdit Original component. |
|
19686 * |
|
19687 * @return {string} Wrapped component. |
|
19688 */ |
|
19689 |
|
19690 var custom_class_name_withInspectorControl = Object(external_this_wp_compose_["createHigherOrderComponent"])(function (BlockEdit) { |
|
19691 return function (props) { |
|
19692 var hasCustomClassName = Object(external_this_wp_blocks_["hasBlockSupport"])(props.name, 'customClassName', true); |
|
19693 |
|
19694 if (hasCustomClassName && props.isSelected) { |
|
19695 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])(BlockEdit, props), Object(external_this_wp_element_["createElement"])(inspector_advanced_controls, null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["TextControl"], { |
|
19696 label: Object(external_this_wp_i18n_["__"])('Additional CSS Class'), |
|
19697 value: props.attributes.className || '', |
|
19698 onChange: function onChange(nextValue) { |
|
19699 props.setAttributes({ |
|
19700 className: nextValue !== '' ? nextValue : undefined |
|
19701 }); |
|
19702 } |
|
19703 }))); |
|
19704 } |
|
19705 |
|
19706 return Object(external_this_wp_element_["createElement"])(BlockEdit, props); |
|
19707 }; |
|
19708 }, 'withInspectorControl'); |
|
19709 /** |
|
19710 * Override props assigned to save component to inject anchor ID, if block |
|
19711 * supports anchor. This is only applied if the block's save result is an |
|
19712 * element and not a markup string. |
|
19713 * |
|
19714 * @param {Object} extraProps Additional props applied to save element. |
|
19715 * @param {Object} blockType Block type. |
|
19716 * @param {Object} attributes Current block attributes. |
|
19717 * |
|
19718 * @return {Object} Filtered props applied to save element. |
|
19719 */ |
|
19720 |
|
19721 function custom_class_name_addSaveProps(extraProps, blockType, attributes) { |
|
19722 if (Object(external_this_wp_blocks_["hasBlockSupport"])(blockType, 'customClassName', true) && attributes.className) { |
|
19723 extraProps.className = classnames_default()(extraProps.className, attributes.className); |
|
19724 } |
|
19725 |
|
19726 return extraProps; |
|
19727 } |
|
19728 /** |
|
19729 * Given an HTML string, returns an array of class names assigned to the root |
|
19730 * element in the markup. |
|
19731 * |
|
19732 * @param {string} innerHTML Markup string from which to extract classes. |
|
19733 * |
|
19734 * @return {string[]} Array of class names assigned to the root element. |
|
19735 */ |
|
19736 |
|
19737 function getHTMLRootElementClasses(innerHTML) { |
|
19738 innerHTML = "<div data-custom-class-name>".concat(innerHTML, "</div>"); |
|
19739 var parsed = Object(external_this_wp_blocks_["parseWithAttributeSchema"])(innerHTML, { |
|
19740 type: 'string', |
|
19741 source: 'attribute', |
|
19742 selector: '[data-custom-class-name] > *', |
|
19743 attribute: 'class' |
|
19744 }); |
|
19745 return parsed ? parsed.trim().split(/\s+/) : []; |
|
19746 } |
|
19747 /** |
|
19748 * Given a parsed set of block attributes, if the block supports custom class |
|
19749 * names and an unknown class (per the block's serialization behavior) is |
|
19750 * found, the unknown classes are treated as custom classes. This prevents the |
|
19751 * block from being considered as invalid. |
|
19752 * |
|
19753 * @param {Object} blockAttributes Original block attributes. |
|
19754 * @param {Object} blockType Block type settings. |
|
19755 * @param {string} innerHTML Original block markup. |
|
19756 * |
|
19757 * @return {Object} Filtered block attributes. |
|
19758 */ |
|
19759 |
|
19760 function addParsedDifference(blockAttributes, blockType, innerHTML) { |
|
19761 if (Object(external_this_wp_blocks_["hasBlockSupport"])(blockType, 'customClassName', true)) { |
|
19762 // To determine difference, serialize block given the known set of |
|
19763 // attributes, with the exception of `className`. This will determine |
|
19764 // the default set of classes. From there, any difference in innerHTML |
|
19765 // can be considered as custom classes. |
|
19766 var attributesSansClassName = Object(external_lodash_["omit"])(blockAttributes, ['className']); |
|
19767 var serialized = Object(external_this_wp_blocks_["getSaveContent"])(blockType, attributesSansClassName); |
|
19768 var defaultClasses = getHTMLRootElementClasses(serialized); |
|
19769 var actualClasses = getHTMLRootElementClasses(innerHTML); |
|
19770 var customClasses = Object(external_lodash_["difference"])(actualClasses, defaultClasses); |
|
19771 |
|
19772 if (customClasses.length) { |
|
19773 blockAttributes.className = customClasses.join(' '); |
|
19774 } else if (serialized) { |
|
19775 delete blockAttributes.className; |
|
19776 } |
|
19777 } |
|
19778 |
|
19779 return blockAttributes; |
|
19780 } |
|
19781 Object(external_this_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/custom-class-name/attribute', custom_class_name_addAttribute); |
|
19782 Object(external_this_wp_hooks_["addFilter"])('editor.BlockEdit', 'core/editor/custom-class-name/with-inspector-control', custom_class_name_withInspectorControl); |
|
19783 Object(external_this_wp_hooks_["addFilter"])('blocks.getSaveContent.extraProps', 'core/custom-class-name/save-props', custom_class_name_addSaveProps); |
|
19784 Object(external_this_wp_hooks_["addFilter"])('blocks.getBlockAttributes', 'core/custom-class-name/addParsedDifference', addParsedDifference); |
|
19785 |
|
19786 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/generated-class-name.js |
|
19787 |
|
19788 |
|
19789 /** |
|
19790 * External dependencies |
|
19791 */ |
|
19792 |
|
19793 /** |
|
19794 * WordPress dependencies |
|
19795 */ |
|
19796 |
|
19797 |
|
19798 |
|
19799 /** |
|
19800 * Override props assigned to save component to inject generated className if |
|
19801 * block supports it. This is only applied if the block's save result is an |
|
19802 * element and not a markup string. |
|
19803 * |
|
19804 * @param {Object} extraProps Additional props applied to save element. |
|
19805 * @param {Object} blockType Block type. |
|
19806 * |
|
19807 * @return {Object} Filtered props applied to save element. |
|
19808 */ |
|
19809 |
|
19810 function addGeneratedClassName(extraProps, blockType) { |
|
19811 // Adding the generated className |
|
19812 if (Object(external_this_wp_blocks_["hasBlockSupport"])(blockType, 'className', true)) { |
|
19813 if (typeof extraProps.className === 'string') { |
|
19814 // We have some extra classes and want to add the default classname |
|
19815 // We use uniq to prevent duplicate classnames |
|
19816 extraProps.className = Object(external_lodash_["uniq"])([Object(external_this_wp_blocks_["getBlockDefaultClassName"])(blockType.name)].concat(Object(toConsumableArray["a" /* default */])(extraProps.className.split(' ')))).join(' ').trim(); |
|
19817 } else { |
|
19818 // There is no string in the className variable, |
|
19819 // so we just dump the default name in there |
|
19820 extraProps.className = Object(external_this_wp_blocks_["getBlockDefaultClassName"])(blockType.name); |
|
19821 } |
|
19822 } |
|
19823 |
|
19824 return extraProps; |
|
19825 } |
|
19826 Object(external_this_wp_hooks_["addFilter"])('blocks.getSaveContent.extraProps', 'core/generated-class-name/save-props', addGeneratedClassName); |
|
19827 |
|
19828 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/index.js |
|
19829 /** |
|
19830 * Internal dependencies |
|
19831 */ |
|
19832 |
|
19833 |
|
19834 |
|
19835 |
|
19836 |
|
19837 // CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/index.js |
|
19838 /* concated harmony reexport Autocomplete */__webpack_require__.d(__webpack_exports__, "Autocomplete", function() { return autocomplete; }); |
|
19839 /* concated harmony reexport AlignmentToolbar */__webpack_require__.d(__webpack_exports__, "AlignmentToolbar", function() { return alignment_toolbar; }); |
|
19840 /* concated harmony reexport BlockAlignmentToolbar */__webpack_require__.d(__webpack_exports__, "BlockAlignmentToolbar", function() { return block_alignment_toolbar; }); |
|
19841 /* concated harmony reexport BlockControls */__webpack_require__.d(__webpack_exports__, "BlockControls", function() { return block_controls; }); |
|
19842 /* concated harmony reexport BlockEdit */__webpack_require__.d(__webpack_exports__, "BlockEdit", function() { return block_edit; }); |
|
19843 /* concated harmony reexport BlockFormatControls */__webpack_require__.d(__webpack_exports__, "BlockFormatControls", function() { return block_format_controls; }); |
|
19844 /* concated harmony reexport BlockNavigationDropdown */__webpack_require__.d(__webpack_exports__, "BlockNavigationDropdown", function() { return dropdown; }); |
|
19845 /* concated harmony reexport BlockIcon */__webpack_require__.d(__webpack_exports__, "BlockIcon", function() { return BlockIcon; }); |
|
19846 /* concated harmony reexport ColorPalette */__webpack_require__.d(__webpack_exports__, "ColorPalette", function() { return color_palette; }); |
|
19847 /* concated harmony reexport withColorContext */__webpack_require__.d(__webpack_exports__, "withColorContext", function() { return with_color_context; }); |
|
19848 /* concated harmony reexport ContrastChecker */__webpack_require__.d(__webpack_exports__, "ContrastChecker", function() { return contrast_checker; }); |
|
19849 /* concated harmony reexport InnerBlocks */__webpack_require__.d(__webpack_exports__, "InnerBlocks", function() { return inner_blocks; }); |
|
19850 /* concated harmony reexport InspectorAdvancedControls */__webpack_require__.d(__webpack_exports__, "InspectorAdvancedControls", function() { return inspector_advanced_controls; }); |
|
19851 /* concated harmony reexport InspectorControls */__webpack_require__.d(__webpack_exports__, "InspectorControls", function() { return inspector_controls; }); |
|
19852 /* concated harmony reexport PanelColorSettings */__webpack_require__.d(__webpack_exports__, "PanelColorSettings", function() { return panel_color_settings; }); |
|
19853 /* concated harmony reexport PlainText */__webpack_require__.d(__webpack_exports__, "PlainText", function() { return plain_text; }); |
|
19854 /* concated harmony reexport RichText */__webpack_require__.d(__webpack_exports__, "RichText", function() { return rich_text; }); |
|
19855 /* concated harmony reexport RichTextShortcut */__webpack_require__.d(__webpack_exports__, "RichTextShortcut", function() { return shortcut_RichTextShortcut; }); |
|
19856 /* concated harmony reexport RichTextToolbarButton */__webpack_require__.d(__webpack_exports__, "RichTextToolbarButton", function() { return RichTextToolbarButton; }); |
|
19857 /* concated harmony reexport UnstableRichTextInputEvent */__webpack_require__.d(__webpack_exports__, "UnstableRichTextInputEvent", function() { return input_event_UnstableRichTextInputEvent; }); |
|
19858 /* concated harmony reexport MediaPlaceholder */__webpack_require__.d(__webpack_exports__, "MediaPlaceholder", function() { return media_placeholder; }); |
|
19859 /* concated harmony reexport MediaUpload */__webpack_require__.d(__webpack_exports__, "MediaUpload", function() { return media_upload; }); |
|
19860 /* concated harmony reexport MediaUploadCheck */__webpack_require__.d(__webpack_exports__, "MediaUploadCheck", function() { return check; }); |
|
19861 /* concated harmony reexport URLInput */__webpack_require__.d(__webpack_exports__, "URLInput", function() { return url_input; }); |
|
19862 /* concated harmony reexport URLInputButton */__webpack_require__.d(__webpack_exports__, "URLInputButton", function() { return url_input_button; }); |
|
19863 /* concated harmony reexport URLPopover */__webpack_require__.d(__webpack_exports__, "URLPopover", function() { return url_popover; }); |
|
19864 /* concated harmony reexport BlockEditorKeyboardShortcuts */__webpack_require__.d(__webpack_exports__, "BlockEditorKeyboardShortcuts", function() { return block_editor_keyboard_shortcuts; }); |
|
19865 /* concated harmony reexport BlockInspector */__webpack_require__.d(__webpack_exports__, "BlockInspector", function() { return block_inspector; }); |
|
19866 /* concated harmony reexport BlockList */__webpack_require__.d(__webpack_exports__, "BlockList", function() { return block_list; }); |
|
19867 /* concated harmony reexport BlockMover */__webpack_require__.d(__webpack_exports__, "BlockMover", function() { return block_mover; }); |
|
19868 /* concated harmony reexport BlockSelectionClearer */__webpack_require__.d(__webpack_exports__, "BlockSelectionClearer", function() { return block_selection_clearer; }); |
|
19869 /* concated harmony reexport BlockSettingsMenu */__webpack_require__.d(__webpack_exports__, "BlockSettingsMenu", function() { return block_settings_menu; }); |
|
19870 /* concated harmony reexport _BlockSettingsMenuFirstItem */__webpack_require__.d(__webpack_exports__, "_BlockSettingsMenuFirstItem", function() { return block_settings_menu_first_item; }); |
|
19871 /* concated harmony reexport _BlockSettingsMenuPluginsExtension */__webpack_require__.d(__webpack_exports__, "_BlockSettingsMenuPluginsExtension", function() { return block_settings_menu_plugins_extension; }); |
|
19872 /* concated harmony reexport BlockTitle */__webpack_require__.d(__webpack_exports__, "BlockTitle", function() { return block_title; }); |
|
19873 /* concated harmony reexport BlockToolbar */__webpack_require__.d(__webpack_exports__, "BlockToolbar", function() { return block_toolbar; }); |
|
19874 /* concated harmony reexport CopyHandler */__webpack_require__.d(__webpack_exports__, "CopyHandler", function() { return copy_handler; }); |
|
19875 /* concated harmony reexport DefaultBlockAppender */__webpack_require__.d(__webpack_exports__, "DefaultBlockAppender", function() { return default_block_appender; }); |
|
19876 /* concated harmony reexport Inserter */__webpack_require__.d(__webpack_exports__, "Inserter", function() { return inserter; }); |
|
19877 /* concated harmony reexport MultiBlocksSwitcher */__webpack_require__.d(__webpack_exports__, "MultiBlocksSwitcher", function() { return multi_blocks_switcher; }); |
|
19878 /* concated harmony reexport MultiSelectScrollIntoView */__webpack_require__.d(__webpack_exports__, "MultiSelectScrollIntoView", function() { return multi_select_scroll_into_view; }); |
|
19879 /* concated harmony reexport NavigableToolbar */__webpack_require__.d(__webpack_exports__, "NavigableToolbar", function() { return navigable_toolbar; }); |
|
19880 /* concated harmony reexport ObserveTyping */__webpack_require__.d(__webpack_exports__, "ObserveTyping", function() { return observe_typing; }); |
|
19881 /* concated harmony reexport PreserveScrollInReorder */__webpack_require__.d(__webpack_exports__, "PreserveScrollInReorder", function() { return preserve_scroll_in_reorder; }); |
|
19882 /* concated harmony reexport SkipToSelectedBlock */__webpack_require__.d(__webpack_exports__, "SkipToSelectedBlock", function() { return skip_to_selected_block; }); |
|
19883 /* concated harmony reexport Warning */__webpack_require__.d(__webpack_exports__, "Warning", function() { return warning; }); |
|
19884 /* concated harmony reexport WritingFlow */__webpack_require__.d(__webpack_exports__, "WritingFlow", function() { return writing_flow; }); |
|
19885 /* concated harmony reexport BlockEditorProvider */__webpack_require__.d(__webpack_exports__, "BlockEditorProvider", function() { return provider; }); |
|
19886 /* concated harmony reexport getColorClassName */__webpack_require__.d(__webpack_exports__, "getColorClassName", function() { return getColorClassName; }); |
|
19887 /* concated harmony reexport getColorObjectByAttributeValues */__webpack_require__.d(__webpack_exports__, "getColorObjectByAttributeValues", function() { return utils_getColorObjectByAttributeValues; }); |
|
19888 /* concated harmony reexport getColorObjectByColorValue */__webpack_require__.d(__webpack_exports__, "getColorObjectByColorValue", function() { return utils_getColorObjectByColorValue; }); |
|
19889 /* concated harmony reexport createCustomColorsHOC */__webpack_require__.d(__webpack_exports__, "createCustomColorsHOC", function() { return createCustomColorsHOC; }); |
|
19890 /* concated harmony reexport withColors */__webpack_require__.d(__webpack_exports__, "withColors", function() { return withColors; }); |
|
19891 /* concated harmony reexport getFontSize */__webpack_require__.d(__webpack_exports__, "getFontSize", function() { return utils_getFontSize; }); |
|
19892 /* concated harmony reexport getFontSizeClass */__webpack_require__.d(__webpack_exports__, "getFontSizeClass", function() { return getFontSizeClass; }); |
|
19893 /* concated harmony reexport FontSizePicker */__webpack_require__.d(__webpack_exports__, "FontSizePicker", function() { return font_size_picker; }); |
|
19894 /* concated harmony reexport withFontSizes */__webpack_require__.d(__webpack_exports__, "withFontSizes", function() { return with_font_sizes; }); |
|
19895 /* concated harmony reexport SETTINGS_DEFAULTS */__webpack_require__.d(__webpack_exports__, "SETTINGS_DEFAULTS", function() { return SETTINGS_DEFAULTS; }); |
|
19896 /** |
|
19897 * WordPress dependencies |
|
19898 */ |
|
19899 |
|
19900 |
|
19901 |
|
19902 |
|
19903 /** |
|
19904 * Internal dependencies |
|
19905 */ |
|
19906 |
|
19907 |
|
19908 |
|
19909 |
|
19910 |
|
19911 |
|
19912 |
|
19913 /***/ }), |
|
19914 |
|
19915 /***/ 37: |
|
19916 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
19917 |
|
19918 "use strict"; |
|
19919 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; }); |
|
19920 function _arrayWithHoles(arr) { |
|
19921 if (Array.isArray(arr)) return arr; |
|
19922 } |
|
19923 |
|
19924 /***/ }), |
|
19925 |
|
19926 /***/ 38: |
|
19927 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
19928 |
|
19929 "use strict"; |
|
19930 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; }); |
|
19931 function _nonIterableRest() { |
|
19932 throw new TypeError("Invalid attempt to destructure non-iterable instance"); |
|
19933 } |
|
19934 |
|
19935 /***/ }), |
|
19936 |
|
19937 /***/ 4: |
|
19938 /***/ (function(module, exports) { |
|
19939 |
|
19940 (function() { module.exports = this["wp"]["components"]; }()); |
|
19941 |
|
19942 /***/ }), |
|
19943 |
|
19944 /***/ 40: |
|
19945 /***/ (function(module, exports) { |
|
19946 |
|
19947 (function() { module.exports = this["wp"]["viewport"]; }()); |
|
19948 |
|
19949 /***/ }), |
|
19950 |
|
19951 /***/ 41: |
|
19952 /***/ (function(module, exports, __webpack_require__) { |
|
19953 |
|
19954 module.exports = function memize( fn, options ) { |
|
19955 var size = 0, |
|
19956 maxSize, head, tail; |
|
19957 |
|
19958 if ( options && options.maxSize ) { |
|
19959 maxSize = options.maxSize; |
|
19960 } |
|
19961 |
|
19962 function memoized( /* ...args */ ) { |
|
19963 var node = head, |
|
19964 len = arguments.length, |
|
19965 args, i; |
|
19966 |
|
19967 searchCache: while ( node ) { |
|
19968 // Perform a shallow equality test to confirm that whether the node |
|
19969 // under test is a candidate for the arguments passed. Two arrays |
|
19970 // are shallowly equal if their length matches and each entry is |
|
19971 // strictly equal between the two sets. Avoid abstracting to a |
|
19972 // function which could incur an arguments leaking deoptimization. |
|
19973 |
|
19974 // Check whether node arguments match arguments length |
|
19975 if ( node.args.length !== arguments.length ) { |
|
19976 node = node.next; |
|
19977 continue; |
|
19978 } |
|
19979 |
|
19980 // Check whether node arguments match arguments values |
|
19981 for ( i = 0; i < len; i++ ) { |
|
19982 if ( node.args[ i ] !== arguments[ i ] ) { |
|
19983 node = node.next; |
|
19984 continue searchCache; |
|
19985 } |
|
19986 } |
|
19987 |
|
19988 // At this point we can assume we've found a match |
|
19989 |
|
19990 // Surface matched node to head if not already |
|
19991 if ( node !== head ) { |
|
19992 // As tail, shift to previous. Must only shift if not also |
|
19993 // head, since if both head and tail, there is no previous. |
|
19994 if ( node === tail ) { |
|
19995 tail = node.prev; |
|
19996 } |
|
19997 |
|
19998 // Adjust siblings to point to each other. If node was tail, |
|
19999 // this also handles new tail's empty `next` assignment. |
|
20000 node.prev.next = node.next; |
|
20001 if ( node.next ) { |
|
20002 node.next.prev = node.prev; |
|
20003 } |
|
20004 |
|
20005 node.next = head; |
|
20006 node.prev = null; |
|
20007 head.prev = node; |
|
20008 head = node; |
|
20009 } |
|
20010 |
|
20011 // Return immediately |
|
20012 return node.val; |
|
20013 } |
|
20014 |
|
20015 // No cached value found. Continue to insertion phase: |
|
20016 |
|
20017 // Create a copy of arguments (avoid leaking deoptimization) |
|
20018 args = new Array( len ); |
|
20019 for ( i = 0; i < len; i++ ) { |
|
20020 args[ i ] = arguments[ i ]; |
|
20021 } |
|
20022 |
|
20023 node = { |
|
20024 args: args, |
|
20025 |
|
20026 // Generate the result from original function |
|
20027 val: fn.apply( null, args ) |
|
20028 }; |
|
20029 |
|
20030 // Don't need to check whether node is already head, since it would |
|
20031 // have been returned above already if it was |
|
20032 |
|
20033 // Shift existing head down list |
|
20034 if ( head ) { |
|
20035 head.prev = node; |
|
20036 node.next = head; |
|
20037 } else { |
|
20038 // If no head, follows that there's no tail (at initial or reset) |
|
20039 tail = node; |
|
20040 } |
|
20041 |
|
20042 // Trim tail if we're reached max size and are pending cache insertion |
|
20043 if ( size === maxSize ) { |
|
20044 tail = tail.prev; |
|
20045 tail.next = null; |
|
20046 } else { |
|
20047 size++; |
|
20048 } |
|
20049 |
|
20050 head = node; |
|
20051 |
|
20052 return node.val; |
|
20053 } |
|
20054 |
|
20055 memoized.clear = function() { |
|
20056 head = null; |
|
20057 tail = null; |
|
20058 size = 0; |
|
20059 }; |
|
20060 |
|
20061 if ( false ) {} |
|
20062 |
|
20063 return memoized; |
|
20064 }; |
|
20065 |
|
20066 |
|
20067 /***/ }), |
|
20068 |
|
20069 /***/ 42: |
|
20070 /***/ (function(module, exports) { |
|
20071 |
|
20072 (function() { module.exports = this["wp"]["isShallowEqual"]; }()); |
|
20073 |
|
20074 /***/ }), |
|
20075 |
|
20076 /***/ 45: |
|
20077 /***/ (function(module, exports, __webpack_require__) { |
|
20078 |
|
20079 var __WEBPACK_AMD_DEFINE_RESULT__;// TinyColor v1.4.1 |
|
20080 // https://github.com/bgrins/TinyColor |
|
20081 // Brian Grinstead, MIT License |
|
20082 |
|
20083 (function(Math) { |
|
20084 |
|
20085 var trimLeft = /^\s+/, |
|
20086 trimRight = /\s+$/, |
|
20087 tinyCounter = 0, |
|
20088 mathRound = Math.round, |
|
20089 mathMin = Math.min, |
|
20090 mathMax = Math.max, |
|
20091 mathRandom = Math.random; |
|
20092 |
|
20093 function tinycolor (color, opts) { |
|
20094 |
|
20095 color = (color) ? color : ''; |
|
20096 opts = opts || { }; |
|
20097 |
|
20098 // If input is already a tinycolor, return itself |
|
20099 if (color instanceof tinycolor) { |
|
20100 return color; |
|
20101 } |
|
20102 // If we are called as a function, call using new instead |
|
20103 if (!(this instanceof tinycolor)) { |
|
20104 return new tinycolor(color, opts); |
|
20105 } |
|
20106 |
|
20107 var rgb = inputToRGB(color); |
|
20108 this._originalInput = color, |
|
20109 this._r = rgb.r, |
|
20110 this._g = rgb.g, |
|
20111 this._b = rgb.b, |
|
20112 this._a = rgb.a, |
|
20113 this._roundA = mathRound(100*this._a) / 100, |
|
20114 this._format = opts.format || rgb.format; |
|
20115 this._gradientType = opts.gradientType; |
|
20116 |
|
20117 // Don't let the range of [0,255] come back in [0,1]. |
|
20118 // Potentially lose a little bit of precision here, but will fix issues where |
|
20119 // .5 gets interpreted as half of the total, instead of half of 1 |
|
20120 // If it was supposed to be 128, this was already taken care of by `inputToRgb` |
|
20121 if (this._r < 1) { this._r = mathRound(this._r); } |
|
20122 if (this._g < 1) { this._g = mathRound(this._g); } |
|
20123 if (this._b < 1) { this._b = mathRound(this._b); } |
|
20124 |
|
20125 this._ok = rgb.ok; |
|
20126 this._tc_id = tinyCounter++; |
|
20127 } |
|
20128 |
|
20129 tinycolor.prototype = { |
|
20130 isDark: function() { |
|
20131 return this.getBrightness() < 128; |
|
20132 }, |
|
20133 isLight: function() { |
|
20134 return !this.isDark(); |
|
20135 }, |
|
20136 isValid: function() { |
|
20137 return this._ok; |
|
20138 }, |
|
20139 getOriginalInput: function() { |
|
20140 return this._originalInput; |
|
20141 }, |
|
20142 getFormat: function() { |
|
20143 return this._format; |
|
20144 }, |
|
20145 getAlpha: function() { |
|
20146 return this._a; |
|
20147 }, |
|
20148 getBrightness: function() { |
|
20149 //http://www.w3.org/TR/AERT#color-contrast |
|
20150 var rgb = this.toRgb(); |
|
20151 return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000; |
|
20152 }, |
|
20153 getLuminance: function() { |
|
20154 //http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef |
|
20155 var rgb = this.toRgb(); |
|
20156 var RsRGB, GsRGB, BsRGB, R, G, B; |
|
20157 RsRGB = rgb.r/255; |
|
20158 GsRGB = rgb.g/255; |
|
20159 BsRGB = rgb.b/255; |
|
20160 |
|
20161 if (RsRGB <= 0.03928) {R = RsRGB / 12.92;} else {R = Math.pow(((RsRGB + 0.055) / 1.055), 2.4);} |
|
20162 if (GsRGB <= 0.03928) {G = GsRGB / 12.92;} else {G = Math.pow(((GsRGB + 0.055) / 1.055), 2.4);} |
|
20163 if (BsRGB <= 0.03928) {B = BsRGB / 12.92;} else {B = Math.pow(((BsRGB + 0.055) / 1.055), 2.4);} |
|
20164 return (0.2126 * R) + (0.7152 * G) + (0.0722 * B); |
|
20165 }, |
|
20166 setAlpha: function(value) { |
|
20167 this._a = boundAlpha(value); |
|
20168 this._roundA = mathRound(100*this._a) / 100; |
|
20169 return this; |
|
20170 }, |
|
20171 toHsv: function() { |
|
20172 var hsv = rgbToHsv(this._r, this._g, this._b); |
|
20173 return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a }; |
|
20174 }, |
|
20175 toHsvString: function() { |
|
20176 var hsv = rgbToHsv(this._r, this._g, this._b); |
|
20177 var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100); |
|
20178 return (this._a == 1) ? |
|
20179 "hsv(" + h + ", " + s + "%, " + v + "%)" : |
|
20180 "hsva(" + h + ", " + s + "%, " + v + "%, "+ this._roundA + ")"; |
|
20181 }, |
|
20182 toHsl: function() { |
|
20183 var hsl = rgbToHsl(this._r, this._g, this._b); |
|
20184 return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a }; |
|
20185 }, |
|
20186 toHslString: function() { |
|
20187 var hsl = rgbToHsl(this._r, this._g, this._b); |
|
20188 var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100); |
|
20189 return (this._a == 1) ? |
|
20190 "hsl(" + h + ", " + s + "%, " + l + "%)" : |
|
20191 "hsla(" + h + ", " + s + "%, " + l + "%, "+ this._roundA + ")"; |
|
20192 }, |
|
20193 toHex: function(allow3Char) { |
|
20194 return rgbToHex(this._r, this._g, this._b, allow3Char); |
|
20195 }, |
|
20196 toHexString: function(allow3Char) { |
|
20197 return '#' + this.toHex(allow3Char); |
|
20198 }, |
|
20199 toHex8: function(allow4Char) { |
|
20200 return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char); |
|
20201 }, |
|
20202 toHex8String: function(allow4Char) { |
|
20203 return '#' + this.toHex8(allow4Char); |
|
20204 }, |
|
20205 toRgb: function() { |
|
20206 return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a }; |
|
20207 }, |
|
20208 toRgbString: function() { |
|
20209 return (this._a == 1) ? |
|
20210 "rgb(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ")" : |
|
20211 "rgba(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ", " + this._roundA + ")"; |
|
20212 }, |
|
20213 toPercentageRgb: function() { |
|
20214 return { r: mathRound(bound01(this._r, 255) * 100) + "%", g: mathRound(bound01(this._g, 255) * 100) + "%", b: mathRound(bound01(this._b, 255) * 100) + "%", a: this._a }; |
|
20215 }, |
|
20216 toPercentageRgbString: function() { |
|
20217 return (this._a == 1) ? |
|
20218 "rgb(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%)" : |
|
20219 "rgba(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")"; |
|
20220 }, |
|
20221 toName: function() { |
|
20222 if (this._a === 0) { |
|
20223 return "transparent"; |
|
20224 } |
|
20225 |
|
20226 if (this._a < 1) { |
|
20227 return false; |
|
20228 } |
|
20229 |
|
20230 return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false; |
|
20231 }, |
|
20232 toFilter: function(secondColor) { |
|
20233 var hex8String = '#' + rgbaToArgbHex(this._r, this._g, this._b, this._a); |
|
20234 var secondHex8String = hex8String; |
|
20235 var gradientType = this._gradientType ? "GradientType = 1, " : ""; |
|
20236 |
|
20237 if (secondColor) { |
|
20238 var s = tinycolor(secondColor); |
|
20239 secondHex8String = '#' + rgbaToArgbHex(s._r, s._g, s._b, s._a); |
|
20240 } |
|
20241 |
|
20242 return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")"; |
|
20243 }, |
|
20244 toString: function(format) { |
|
20245 var formatSet = !!format; |
|
20246 format = format || this._format; |
|
20247 |
|
20248 var formattedString = false; |
|
20249 var hasAlpha = this._a < 1 && this._a >= 0; |
|
20250 var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name"); |
|
20251 |
|
20252 if (needsAlphaFormat) { |
|
20253 // Special case for "transparent", all other non-alpha formats |
|
20254 // will return rgba when there is transparency. |
|
20255 if (format === "name" && this._a === 0) { |
|
20256 return this.toName(); |
|
20257 } |
|
20258 return this.toRgbString(); |
|
20259 } |
|
20260 if (format === "rgb") { |
|
20261 formattedString = this.toRgbString(); |
|
20262 } |
|
20263 if (format === "prgb") { |
|
20264 formattedString = this.toPercentageRgbString(); |
|
20265 } |
|
20266 if (format === "hex" || format === "hex6") { |
|
20267 formattedString = this.toHexString(); |
|
20268 } |
|
20269 if (format === "hex3") { |
|
20270 formattedString = this.toHexString(true); |
|
20271 } |
|
20272 if (format === "hex4") { |
|
20273 formattedString = this.toHex8String(true); |
|
20274 } |
|
20275 if (format === "hex8") { |
|
20276 formattedString = this.toHex8String(); |
|
20277 } |
|
20278 if (format === "name") { |
|
20279 formattedString = this.toName(); |
|
20280 } |
|
20281 if (format === "hsl") { |
|
20282 formattedString = this.toHslString(); |
|
20283 } |
|
20284 if (format === "hsv") { |
|
20285 formattedString = this.toHsvString(); |
|
20286 } |
|
20287 |
|
20288 return formattedString || this.toHexString(); |
|
20289 }, |
|
20290 clone: function() { |
|
20291 return tinycolor(this.toString()); |
|
20292 }, |
|
20293 |
|
20294 _applyModification: function(fn, args) { |
|
20295 var color = fn.apply(null, [this].concat([].slice.call(args))); |
|
20296 this._r = color._r; |
|
20297 this._g = color._g; |
|
20298 this._b = color._b; |
|
20299 this.setAlpha(color._a); |
|
20300 return this; |
|
20301 }, |
|
20302 lighten: function() { |
|
20303 return this._applyModification(lighten, arguments); |
|
20304 }, |
|
20305 brighten: function() { |
|
20306 return this._applyModification(brighten, arguments); |
|
20307 }, |
|
20308 darken: function() { |
|
20309 return this._applyModification(darken, arguments); |
|
20310 }, |
|
20311 desaturate: function() { |
|
20312 return this._applyModification(desaturate, arguments); |
|
20313 }, |
|
20314 saturate: function() { |
|
20315 return this._applyModification(saturate, arguments); |
|
20316 }, |
|
20317 greyscale: function() { |
|
20318 return this._applyModification(greyscale, arguments); |
|
20319 }, |
|
20320 spin: function() { |
|
20321 return this._applyModification(spin, arguments); |
|
20322 }, |
|
20323 |
|
20324 _applyCombination: function(fn, args) { |
|
20325 return fn.apply(null, [this].concat([].slice.call(args))); |
|
20326 }, |
|
20327 analogous: function() { |
|
20328 return this._applyCombination(analogous, arguments); |
|
20329 }, |
|
20330 complement: function() { |
|
20331 return this._applyCombination(complement, arguments); |
|
20332 }, |
|
20333 monochromatic: function() { |
|
20334 return this._applyCombination(monochromatic, arguments); |
|
20335 }, |
|
20336 splitcomplement: function() { |
|
20337 return this._applyCombination(splitcomplement, arguments); |
|
20338 }, |
|
20339 triad: function() { |
|
20340 return this._applyCombination(triad, arguments); |
|
20341 }, |
|
20342 tetrad: function() { |
|
20343 return this._applyCombination(tetrad, arguments); |
|
20344 } |
|
20345 }; |
|
20346 |
|
20347 // If input is an object, force 1 into "1.0" to handle ratios properly |
|
20348 // String input requires "1.0" as input, so 1 will be treated as 1 |
|
20349 tinycolor.fromRatio = function(color, opts) { |
|
20350 if (typeof color == "object") { |
|
20351 var newColor = {}; |
|
20352 for (var i in color) { |
|
20353 if (color.hasOwnProperty(i)) { |
|
20354 if (i === "a") { |
|
20355 newColor[i] = color[i]; |
|
20356 } |
|
20357 else { |
|
20358 newColor[i] = convertToPercentage(color[i]); |
|
20359 } |
|
20360 } |
|
20361 } |
|
20362 color = newColor; |
|
20363 } |
|
20364 |
|
20365 return tinycolor(color, opts); |
|
20366 }; |
|
20367 |
|
20368 // Given a string or object, convert that input to RGB |
|
20369 // Possible string inputs: |
|
20370 // |
|
20371 // "red" |
|
20372 // "#f00" or "f00" |
|
20373 // "#ff0000" or "ff0000" |
|
20374 // "#ff000000" or "ff000000" |
|
20375 // "rgb 255 0 0" or "rgb (255, 0, 0)" |
|
20376 // "rgb 1.0 0 0" or "rgb (1, 0, 0)" |
|
20377 // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1" |
|
20378 // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1" |
|
20379 // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%" |
|
20380 // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1" |
|
20381 // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%" |
|
20382 // |
|
20383 function inputToRGB(color) { |
|
20384 |
|
20385 var rgb = { r: 0, g: 0, b: 0 }; |
|
20386 var a = 1; |
|
20387 var s = null; |
|
20388 var v = null; |
|
20389 var l = null; |
|
20390 var ok = false; |
|
20391 var format = false; |
|
20392 |
|
20393 if (typeof color == "string") { |
|
20394 color = stringInputToObject(color); |
|
20395 } |
|
20396 |
|
20397 if (typeof color == "object") { |
|
20398 if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) { |
|
20399 rgb = rgbToRgb(color.r, color.g, color.b); |
|
20400 ok = true; |
|
20401 format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb"; |
|
20402 } |
|
20403 else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) { |
|
20404 s = convertToPercentage(color.s); |
|
20405 v = convertToPercentage(color.v); |
|
20406 rgb = hsvToRgb(color.h, s, v); |
|
20407 ok = true; |
|
20408 format = "hsv"; |
|
20409 } |
|
20410 else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) { |
|
20411 s = convertToPercentage(color.s); |
|
20412 l = convertToPercentage(color.l); |
|
20413 rgb = hslToRgb(color.h, s, l); |
|
20414 ok = true; |
|
20415 format = "hsl"; |
|
20416 } |
|
20417 |
|
20418 if (color.hasOwnProperty("a")) { |
|
20419 a = color.a; |
|
20420 } |
|
20421 } |
|
20422 |
|
20423 a = boundAlpha(a); |
|
20424 |
|
20425 return { |
|
20426 ok: ok, |
|
20427 format: color.format || format, |
|
20428 r: mathMin(255, mathMax(rgb.r, 0)), |
|
20429 g: mathMin(255, mathMax(rgb.g, 0)), |
|
20430 b: mathMin(255, mathMax(rgb.b, 0)), |
|
20431 a: a |
|
20432 }; |
|
20433 } |
|
20434 |
|
20435 |
|
20436 // Conversion Functions |
|
20437 // -------------------- |
|
20438 |
|
20439 // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from: |
|
20440 // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript> |
|
20441 |
|
20442 // `rgbToRgb` |
|
20443 // Handle bounds / percentage checking to conform to CSS color spec |
|
20444 // <http://www.w3.org/TR/css3-color/> |
|
20445 // *Assumes:* r, g, b in [0, 255] or [0, 1] |
|
20446 // *Returns:* { r, g, b } in [0, 255] |
|
20447 function rgbToRgb(r, g, b){ |
|
20448 return { |
|
20449 r: bound01(r, 255) * 255, |
|
20450 g: bound01(g, 255) * 255, |
|
20451 b: bound01(b, 255) * 255 |
|
20452 }; |
|
20453 } |
|
20454 |
|
20455 // `rgbToHsl` |
|
20456 // Converts an RGB color value to HSL. |
|
20457 // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1] |
|
20458 // *Returns:* { h, s, l } in [0,1] |
|
20459 function rgbToHsl(r, g, b) { |
|
20460 |
|
20461 r = bound01(r, 255); |
|
20462 g = bound01(g, 255); |
|
20463 b = bound01(b, 255); |
|
20464 |
|
20465 var max = mathMax(r, g, b), min = mathMin(r, g, b); |
|
20466 var h, s, l = (max + min) / 2; |
|
20467 |
|
20468 if(max == min) { |
|
20469 h = s = 0; // achromatic |
|
20470 } |
|
20471 else { |
|
20472 var d = max - min; |
|
20473 s = l > 0.5 ? d / (2 - max - min) : d / (max + min); |
|
20474 switch(max) { |
|
20475 case r: h = (g - b) / d + (g < b ? 6 : 0); break; |
|
20476 case g: h = (b - r) / d + 2; break; |
|
20477 case b: h = (r - g) / d + 4; break; |
|
20478 } |
|
20479 |
|
20480 h /= 6; |
|
20481 } |
|
20482 |
|
20483 return { h: h, s: s, l: l }; |
|
20484 } |
|
20485 |
|
20486 // `hslToRgb` |
|
20487 // Converts an HSL color value to RGB. |
|
20488 // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100] |
|
20489 // *Returns:* { r, g, b } in the set [0, 255] |
|
20490 function hslToRgb(h, s, l) { |
|
20491 var r, g, b; |
|
20492 |
|
20493 h = bound01(h, 360); |
|
20494 s = bound01(s, 100); |
|
20495 l = bound01(l, 100); |
|
20496 |
|
20497 function hue2rgb(p, q, t) { |
|
20498 if(t < 0) t += 1; |
|
20499 if(t > 1) t -= 1; |
|
20500 if(t < 1/6) return p + (q - p) * 6 * t; |
|
20501 if(t < 1/2) return q; |
|
20502 if(t < 2/3) return p + (q - p) * (2/3 - t) * 6; |
|
20503 return p; |
|
20504 } |
|
20505 |
|
20506 if(s === 0) { |
|
20507 r = g = b = l; // achromatic |
|
20508 } |
|
20509 else { |
|
20510 var q = l < 0.5 ? l * (1 + s) : l + s - l * s; |
|
20511 var p = 2 * l - q; |
|
20512 r = hue2rgb(p, q, h + 1/3); |
|
20513 g = hue2rgb(p, q, h); |
|
20514 b = hue2rgb(p, q, h - 1/3); |
|
20515 } |
|
20516 |
|
20517 return { r: r * 255, g: g * 255, b: b * 255 }; |
|
20518 } |
|
20519 |
|
20520 // `rgbToHsv` |
|
20521 // Converts an RGB color value to HSV |
|
20522 // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1] |
|
20523 // *Returns:* { h, s, v } in [0,1] |
|
20524 function rgbToHsv(r, g, b) { |
|
20525 |
|
20526 r = bound01(r, 255); |
|
20527 g = bound01(g, 255); |
|
20528 b = bound01(b, 255); |
|
20529 |
|
20530 var max = mathMax(r, g, b), min = mathMin(r, g, b); |
|
20531 var h, s, v = max; |
|
20532 |
|
20533 var d = max - min; |
|
20534 s = max === 0 ? 0 : d / max; |
|
20535 |
|
20536 if(max == min) { |
|
20537 h = 0; // achromatic |
|
20538 } |
|
20539 else { |
|
20540 switch(max) { |
|
20541 case r: h = (g - b) / d + (g < b ? 6 : 0); break; |
|
20542 case g: h = (b - r) / d + 2; break; |
|
20543 case b: h = (r - g) / d + 4; break; |
|
20544 } |
|
20545 h /= 6; |
|
20546 } |
|
20547 return { h: h, s: s, v: v }; |
|
20548 } |
|
20549 |
|
20550 // `hsvToRgb` |
|
20551 // Converts an HSV color value to RGB. |
|
20552 // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100] |
|
20553 // *Returns:* { r, g, b } in the set [0, 255] |
|
20554 function hsvToRgb(h, s, v) { |
|
20555 |
|
20556 h = bound01(h, 360) * 6; |
|
20557 s = bound01(s, 100); |
|
20558 v = bound01(v, 100); |
|
20559 |
|
20560 var i = Math.floor(h), |
|
20561 f = h - i, |
|
20562 p = v * (1 - s), |
|
20563 q = v * (1 - f * s), |
|
20564 t = v * (1 - (1 - f) * s), |
|
20565 mod = i % 6, |
|
20566 r = [v, q, p, p, t, v][mod], |
|
20567 g = [t, v, v, q, p, p][mod], |
|
20568 b = [p, p, t, v, v, q][mod]; |
|
20569 |
|
20570 return { r: r * 255, g: g * 255, b: b * 255 }; |
|
20571 } |
|
20572 |
|
20573 // `rgbToHex` |
|
20574 // Converts an RGB color to hex |
|
20575 // Assumes r, g, and b are contained in the set [0, 255] |
|
20576 // Returns a 3 or 6 character hex |
|
20577 function rgbToHex(r, g, b, allow3Char) { |
|
20578 |
|
20579 var hex = [ |
|
20580 pad2(mathRound(r).toString(16)), |
|
20581 pad2(mathRound(g).toString(16)), |
|
20582 pad2(mathRound(b).toString(16)) |
|
20583 ]; |
|
20584 |
|
20585 // Return a 3 character hex if possible |
|
20586 if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) { |
|
20587 return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0); |
|
20588 } |
|
20589 |
|
20590 return hex.join(""); |
|
20591 } |
|
20592 |
|
20593 // `rgbaToHex` |
|
20594 // Converts an RGBA color plus alpha transparency to hex |
|
20595 // Assumes r, g, b are contained in the set [0, 255] and |
|
20596 // a in [0, 1]. Returns a 4 or 8 character rgba hex |
|
20597 function rgbaToHex(r, g, b, a, allow4Char) { |
|
20598 |
|
20599 var hex = [ |
|
20600 pad2(mathRound(r).toString(16)), |
|
20601 pad2(mathRound(g).toString(16)), |
|
20602 pad2(mathRound(b).toString(16)), |
|
20603 pad2(convertDecimalToHex(a)) |
|
20604 ]; |
|
20605 |
|
20606 // Return a 4 character hex if possible |
|
20607 if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) { |
|
20608 return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0); |
|
20609 } |
|
20610 |
|
20611 return hex.join(""); |
|
20612 } |
|
20613 |
|
20614 // `rgbaToArgbHex` |
|
20615 // Converts an RGBA color to an ARGB Hex8 string |
|
20616 // Rarely used, but required for "toFilter()" |
|
20617 function rgbaToArgbHex(r, g, b, a) { |
|
20618 |
|
20619 var hex = [ |
|
20620 pad2(convertDecimalToHex(a)), |
|
20621 pad2(mathRound(r).toString(16)), |
|
20622 pad2(mathRound(g).toString(16)), |
|
20623 pad2(mathRound(b).toString(16)) |
|
20624 ]; |
|
20625 |
|
20626 return hex.join(""); |
|
20627 } |
|
20628 |
|
20629 // `equals` |
|
20630 // Can be called with any tinycolor input |
|
20631 tinycolor.equals = function (color1, color2) { |
|
20632 if (!color1 || !color2) { return false; } |
|
20633 return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString(); |
|
20634 }; |
|
20635 |
|
20636 tinycolor.random = function() { |
|
20637 return tinycolor.fromRatio({ |
|
20638 r: mathRandom(), |
|
20639 g: mathRandom(), |
|
20640 b: mathRandom() |
|
20641 }); |
|
20642 }; |
|
20643 |
|
20644 |
|
20645 // Modification Functions |
|
20646 // ---------------------- |
|
20647 // Thanks to less.js for some of the basics here |
|
20648 // <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js> |
|
20649 |
|
20650 function desaturate(color, amount) { |
|
20651 amount = (amount === 0) ? 0 : (amount || 10); |
|
20652 var hsl = tinycolor(color).toHsl(); |
|
20653 hsl.s -= amount / 100; |
|
20654 hsl.s = clamp01(hsl.s); |
|
20655 return tinycolor(hsl); |
|
20656 } |
|
20657 |
|
20658 function saturate(color, amount) { |
|
20659 amount = (amount === 0) ? 0 : (amount || 10); |
|
20660 var hsl = tinycolor(color).toHsl(); |
|
20661 hsl.s += amount / 100; |
|
20662 hsl.s = clamp01(hsl.s); |
|
20663 return tinycolor(hsl); |
|
20664 } |
|
20665 |
|
20666 function greyscale(color) { |
|
20667 return tinycolor(color).desaturate(100); |
|
20668 } |
|
20669 |
|
20670 function lighten (color, amount) { |
|
20671 amount = (amount === 0) ? 0 : (amount || 10); |
|
20672 var hsl = tinycolor(color).toHsl(); |
|
20673 hsl.l += amount / 100; |
|
20674 hsl.l = clamp01(hsl.l); |
|
20675 return tinycolor(hsl); |
|
20676 } |
|
20677 |
|
20678 function brighten(color, amount) { |
|
20679 amount = (amount === 0) ? 0 : (amount || 10); |
|
20680 var rgb = tinycolor(color).toRgb(); |
|
20681 rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100)))); |
|
20682 rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100)))); |
|
20683 rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100)))); |
|
20684 return tinycolor(rgb); |
|
20685 } |
|
20686 |
|
20687 function darken (color, amount) { |
|
20688 amount = (amount === 0) ? 0 : (amount || 10); |
|
20689 var hsl = tinycolor(color).toHsl(); |
|
20690 hsl.l -= amount / 100; |
|
20691 hsl.l = clamp01(hsl.l); |
|
20692 return tinycolor(hsl); |
|
20693 } |
|
20694 |
|
20695 // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue. |
|
20696 // Values outside of this range will be wrapped into this range. |
|
20697 function spin(color, amount) { |
|
20698 var hsl = tinycolor(color).toHsl(); |
|
20699 var hue = (hsl.h + amount) % 360; |
|
20700 hsl.h = hue < 0 ? 360 + hue : hue; |
|
20701 return tinycolor(hsl); |
|
20702 } |
|
20703 |
|
20704 // Combination Functions |
|
20705 // --------------------- |
|
20706 // Thanks to jQuery xColor for some of the ideas behind these |
|
20707 // <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js> |
|
20708 |
|
20709 function complement(color) { |
|
20710 var hsl = tinycolor(color).toHsl(); |
|
20711 hsl.h = (hsl.h + 180) % 360; |
|
20712 return tinycolor(hsl); |
|
20713 } |
|
20714 |
|
20715 function triad(color) { |
|
20716 var hsl = tinycolor(color).toHsl(); |
|
20717 var h = hsl.h; |
|
20718 return [ |
|
20719 tinycolor(color), |
|
20720 tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }), |
|
20721 tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l }) |
|
20722 ]; |
|
20723 } |
|
20724 |
|
20725 function tetrad(color) { |
|
20726 var hsl = tinycolor(color).toHsl(); |
|
20727 var h = hsl.h; |
|
20728 return [ |
|
20729 tinycolor(color), |
|
20730 tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }), |
|
20731 tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }), |
|
20732 tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l }) |
|
20733 ]; |
|
20734 } |
|
20735 |
|
20736 function splitcomplement(color) { |
|
20737 var hsl = tinycolor(color).toHsl(); |
|
20738 var h = hsl.h; |
|
20739 return [ |
|
20740 tinycolor(color), |
|
20741 tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}), |
|
20742 tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l}) |
|
20743 ]; |
|
20744 } |
|
20745 |
|
20746 function analogous(color, results, slices) { |
|
20747 results = results || 6; |
|
20748 slices = slices || 30; |
|
20749 |
|
20750 var hsl = tinycolor(color).toHsl(); |
|
20751 var part = 360 / slices; |
|
20752 var ret = [tinycolor(color)]; |
|
20753 |
|
20754 for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) { |
|
20755 hsl.h = (hsl.h + part) % 360; |
|
20756 ret.push(tinycolor(hsl)); |
|
20757 } |
|
20758 return ret; |
|
20759 } |
|
20760 |
|
20761 function monochromatic(color, results) { |
|
20762 results = results || 6; |
|
20763 var hsv = tinycolor(color).toHsv(); |
|
20764 var h = hsv.h, s = hsv.s, v = hsv.v; |
|
20765 var ret = []; |
|
20766 var modification = 1 / results; |
|
20767 |
|
20768 while (results--) { |
|
20769 ret.push(tinycolor({ h: h, s: s, v: v})); |
|
20770 v = (v + modification) % 1; |
|
20771 } |
|
20772 |
|
20773 return ret; |
|
20774 } |
|
20775 |
|
20776 // Utility Functions |
|
20777 // --------------------- |
|
20778 |
|
20779 tinycolor.mix = function(color1, color2, amount) { |
|
20780 amount = (amount === 0) ? 0 : (amount || 50); |
|
20781 |
|
20782 var rgb1 = tinycolor(color1).toRgb(); |
|
20783 var rgb2 = tinycolor(color2).toRgb(); |
|
20784 |
|
20785 var p = amount / 100; |
|
20786 |
|
20787 var rgba = { |
|
20788 r: ((rgb2.r - rgb1.r) * p) + rgb1.r, |
|
20789 g: ((rgb2.g - rgb1.g) * p) + rgb1.g, |
|
20790 b: ((rgb2.b - rgb1.b) * p) + rgb1.b, |
|
20791 a: ((rgb2.a - rgb1.a) * p) + rgb1.a |
|
20792 }; |
|
20793 |
|
20794 return tinycolor(rgba); |
|
20795 }; |
|
20796 |
|
20797 |
|
20798 // Readability Functions |
|
20799 // --------------------- |
|
20800 // <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2) |
|
20801 |
|
20802 // `contrast` |
|
20803 // Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2) |
|
20804 tinycolor.readability = function(color1, color2) { |
|
20805 var c1 = tinycolor(color1); |
|
20806 var c2 = tinycolor(color2); |
|
20807 return (Math.max(c1.getLuminance(),c2.getLuminance())+0.05) / (Math.min(c1.getLuminance(),c2.getLuminance())+0.05); |
|
20808 }; |
|
20809 |
|
20810 // `isReadable` |
|
20811 // Ensure that foreground and background color combinations meet WCAG2 guidelines. |
|
20812 // The third argument is an optional Object. |
|
20813 // the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA'; |
|
20814 // the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'. |
|
20815 // If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}. |
|
20816 |
|
20817 // *Example* |
|
20818 // tinycolor.isReadable("#000", "#111") => false |
|
20819 // tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false |
|
20820 tinycolor.isReadable = function(color1, color2, wcag2) { |
|
20821 var readability = tinycolor.readability(color1, color2); |
|
20822 var wcag2Parms, out; |
|
20823 |
|
20824 out = false; |
|
20825 |
|
20826 wcag2Parms = validateWCAG2Parms(wcag2); |
|
20827 switch (wcag2Parms.level + wcag2Parms.size) { |
|
20828 case "AAsmall": |
|
20829 case "AAAlarge": |
|
20830 out = readability >= 4.5; |
|
20831 break; |
|
20832 case "AAlarge": |
|
20833 out = readability >= 3; |
|
20834 break; |
|
20835 case "AAAsmall": |
|
20836 out = readability >= 7; |
|
20837 break; |
|
20838 } |
|
20839 return out; |
|
20840 |
|
20841 }; |
|
20842 |
|
20843 // `mostReadable` |
|
20844 // Given a base color and a list of possible foreground or background |
|
20845 // colors for that base, returns the most readable color. |
|
20846 // Optionally returns Black or White if the most readable color is unreadable. |
|
20847 // *Example* |
|
20848 // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255" |
|
20849 // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff" |
|
20850 // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3" |
|
20851 // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff" |
|
20852 tinycolor.mostReadable = function(baseColor, colorList, args) { |
|
20853 var bestColor = null; |
|
20854 var bestScore = 0; |
|
20855 var readability; |
|
20856 var includeFallbackColors, level, size ; |
|
20857 args = args || {}; |
|
20858 includeFallbackColors = args.includeFallbackColors ; |
|
20859 level = args.level; |
|
20860 size = args.size; |
|
20861 |
|
20862 for (var i= 0; i < colorList.length ; i++) { |
|
20863 readability = tinycolor.readability(baseColor, colorList[i]); |
|
20864 if (readability > bestScore) { |
|
20865 bestScore = readability; |
|
20866 bestColor = tinycolor(colorList[i]); |
|
20867 } |
|
20868 } |
|
20869 |
|
20870 if (tinycolor.isReadable(baseColor, bestColor, {"level":level,"size":size}) || !includeFallbackColors) { |
|
20871 return bestColor; |
|
20872 } |
|
20873 else { |
|
20874 args.includeFallbackColors=false; |
|
20875 return tinycolor.mostReadable(baseColor,["#fff", "#000"],args); |
|
20876 } |
|
20877 }; |
|
20878 |
|
20879 |
|
20880 // Big List of Colors |
|
20881 // ------------------ |
|
20882 // <http://www.w3.org/TR/css3-color/#svg-color> |
|
20883 var names = tinycolor.names = { |
|
20884 aliceblue: "f0f8ff", |
|
20885 antiquewhite: "faebd7", |
|
20886 aqua: "0ff", |
|
20887 aquamarine: "7fffd4", |
|
20888 azure: "f0ffff", |
|
20889 beige: "f5f5dc", |
|
20890 bisque: "ffe4c4", |
|
20891 black: "000", |
|
20892 blanchedalmond: "ffebcd", |
|
20893 blue: "00f", |
|
20894 blueviolet: "8a2be2", |
|
20895 brown: "a52a2a", |
|
20896 burlywood: "deb887", |
|
20897 burntsienna: "ea7e5d", |
|
20898 cadetblue: "5f9ea0", |
|
20899 chartreuse: "7fff00", |
|
20900 chocolate: "d2691e", |
|
20901 coral: "ff7f50", |
|
20902 cornflowerblue: "6495ed", |
|
20903 cornsilk: "fff8dc", |
|
20904 crimson: "dc143c", |
|
20905 cyan: "0ff", |
|
20906 darkblue: "00008b", |
|
20907 darkcyan: "008b8b", |
|
20908 darkgoldenrod: "b8860b", |
|
20909 darkgray: "a9a9a9", |
|
20910 darkgreen: "006400", |
|
20911 darkgrey: "a9a9a9", |
|
20912 darkkhaki: "bdb76b", |
|
20913 darkmagenta: "8b008b", |
|
20914 darkolivegreen: "556b2f", |
|
20915 darkorange: "ff8c00", |
|
20916 darkorchid: "9932cc", |
|
20917 darkred: "8b0000", |
|
20918 darksalmon: "e9967a", |
|
20919 darkseagreen: "8fbc8f", |
|
20920 darkslateblue: "483d8b", |
|
20921 darkslategray: "2f4f4f", |
|
20922 darkslategrey: "2f4f4f", |
|
20923 darkturquoise: "00ced1", |
|
20924 darkviolet: "9400d3", |
|
20925 deeppink: "ff1493", |
|
20926 deepskyblue: "00bfff", |
|
20927 dimgray: "696969", |
|
20928 dimgrey: "696969", |
|
20929 dodgerblue: "1e90ff", |
|
20930 firebrick: "b22222", |
|
20931 floralwhite: "fffaf0", |
|
20932 forestgreen: "228b22", |
|
20933 fuchsia: "f0f", |
|
20934 gainsboro: "dcdcdc", |
|
20935 ghostwhite: "f8f8ff", |
|
20936 gold: "ffd700", |
|
20937 goldenrod: "daa520", |
|
20938 gray: "808080", |
|
20939 green: "008000", |
|
20940 greenyellow: "adff2f", |
|
20941 grey: "808080", |
|
20942 honeydew: "f0fff0", |
|
20943 hotpink: "ff69b4", |
|
20944 indianred: "cd5c5c", |
|
20945 indigo: "4b0082", |
|
20946 ivory: "fffff0", |
|
20947 khaki: "f0e68c", |
|
20948 lavender: "e6e6fa", |
|
20949 lavenderblush: "fff0f5", |
|
20950 lawngreen: "7cfc00", |
|
20951 lemonchiffon: "fffacd", |
|
20952 lightblue: "add8e6", |
|
20953 lightcoral: "f08080", |
|
20954 lightcyan: "e0ffff", |
|
20955 lightgoldenrodyellow: "fafad2", |
|
20956 lightgray: "d3d3d3", |
|
20957 lightgreen: "90ee90", |
|
20958 lightgrey: "d3d3d3", |
|
20959 lightpink: "ffb6c1", |
|
20960 lightsalmon: "ffa07a", |
|
20961 lightseagreen: "20b2aa", |
|
20962 lightskyblue: "87cefa", |
|
20963 lightslategray: "789", |
|
20964 lightslategrey: "789", |
|
20965 lightsteelblue: "b0c4de", |
|
20966 lightyellow: "ffffe0", |
|
20967 lime: "0f0", |
|
20968 limegreen: "32cd32", |
|
20969 linen: "faf0e6", |
|
20970 magenta: "f0f", |
|
20971 maroon: "800000", |
|
20972 mediumaquamarine: "66cdaa", |
|
20973 mediumblue: "0000cd", |
|
20974 mediumorchid: "ba55d3", |
|
20975 mediumpurple: "9370db", |
|
20976 mediumseagreen: "3cb371", |
|
20977 mediumslateblue: "7b68ee", |
|
20978 mediumspringgreen: "00fa9a", |
|
20979 mediumturquoise: "48d1cc", |
|
20980 mediumvioletred: "c71585", |
|
20981 midnightblue: "191970", |
|
20982 mintcream: "f5fffa", |
|
20983 mistyrose: "ffe4e1", |
|
20984 moccasin: "ffe4b5", |
|
20985 navajowhite: "ffdead", |
|
20986 navy: "000080", |
|
20987 oldlace: "fdf5e6", |
|
20988 olive: "808000", |
|
20989 olivedrab: "6b8e23", |
|
20990 orange: "ffa500", |
|
20991 orangered: "ff4500", |
|
20992 orchid: "da70d6", |
|
20993 palegoldenrod: "eee8aa", |
|
20994 palegreen: "98fb98", |
|
20995 paleturquoise: "afeeee", |
|
20996 palevioletred: "db7093", |
|
20997 papayawhip: "ffefd5", |
|
20998 peachpuff: "ffdab9", |
|
20999 peru: "cd853f", |
|
21000 pink: "ffc0cb", |
|
21001 plum: "dda0dd", |
|
21002 powderblue: "b0e0e6", |
|
21003 purple: "800080", |
|
21004 rebeccapurple: "663399", |
|
21005 red: "f00", |
|
21006 rosybrown: "bc8f8f", |
|
21007 royalblue: "4169e1", |
|
21008 saddlebrown: "8b4513", |
|
21009 salmon: "fa8072", |
|
21010 sandybrown: "f4a460", |
|
21011 seagreen: "2e8b57", |
|
21012 seashell: "fff5ee", |
|
21013 sienna: "a0522d", |
|
21014 silver: "c0c0c0", |
|
21015 skyblue: "87ceeb", |
|
21016 slateblue: "6a5acd", |
|
21017 slategray: "708090", |
|
21018 slategrey: "708090", |
|
21019 snow: "fffafa", |
|
21020 springgreen: "00ff7f", |
|
21021 steelblue: "4682b4", |
|
21022 tan: "d2b48c", |
|
21023 teal: "008080", |
|
21024 thistle: "d8bfd8", |
|
21025 tomato: "ff6347", |
|
21026 turquoise: "40e0d0", |
|
21027 violet: "ee82ee", |
|
21028 wheat: "f5deb3", |
|
21029 white: "fff", |
|
21030 whitesmoke: "f5f5f5", |
|
21031 yellow: "ff0", |
|
21032 yellowgreen: "9acd32" |
|
21033 }; |
|
21034 |
|
21035 // Make it easy to access colors via `hexNames[hex]` |
|
21036 var hexNames = tinycolor.hexNames = flip(names); |
|
21037 |
|
21038 |
|
21039 // Utilities |
|
21040 // --------- |
|
21041 |
|
21042 // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }` |
|
21043 function flip(o) { |
|
21044 var flipped = { }; |
|
21045 for (var i in o) { |
|
21046 if (o.hasOwnProperty(i)) { |
|
21047 flipped[o[i]] = i; |
|
21048 } |
|
21049 } |
|
21050 return flipped; |
|
21051 } |
|
21052 |
|
21053 // Return a valid alpha value [0,1] with all invalid values being set to 1 |
|
21054 function boundAlpha(a) { |
|
21055 a = parseFloat(a); |
|
21056 |
|
21057 if (isNaN(a) || a < 0 || a > 1) { |
|
21058 a = 1; |
|
21059 } |
|
21060 |
|
21061 return a; |
|
21062 } |
|
21063 |
|
21064 // Take input from [0, n] and return it as [0, 1] |
|
21065 function bound01(n, max) { |
|
21066 if (isOnePointZero(n)) { n = "100%"; } |
|
21067 |
|
21068 var processPercent = isPercentage(n); |
|
21069 n = mathMin(max, mathMax(0, parseFloat(n))); |
|
21070 |
|
21071 // Automatically convert percentage into number |
|
21072 if (processPercent) { |
|
21073 n = parseInt(n * max, 10) / 100; |
|
21074 } |
|
21075 |
|
21076 // Handle floating point rounding errors |
|
21077 if ((Math.abs(n - max) < 0.000001)) { |
|
21078 return 1; |
|
21079 } |
|
21080 |
|
21081 // Convert into [0, 1] range if it isn't already |
|
21082 return (n % max) / parseFloat(max); |
|
21083 } |
|
21084 |
|
21085 // Force a number between 0 and 1 |
|
21086 function clamp01(val) { |
|
21087 return mathMin(1, mathMax(0, val)); |
|
21088 } |
|
21089 |
|
21090 // Parse a base-16 hex value into a base-10 integer |
|
21091 function parseIntFromHex(val) { |
|
21092 return parseInt(val, 16); |
|
21093 } |
|
21094 |
|
21095 // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1 |
|
21096 // <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0> |
|
21097 function isOnePointZero(n) { |
|
21098 return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1; |
|
21099 } |
|
21100 |
|
21101 // Check to see if string passed in is a percentage |
|
21102 function isPercentage(n) { |
|
21103 return typeof n === "string" && n.indexOf('%') != -1; |
|
21104 } |
|
21105 |
|
21106 // Force a hex value to have 2 characters |
|
21107 function pad2(c) { |
|
21108 return c.length == 1 ? '0' + c : '' + c; |
|
21109 } |
|
21110 |
|
21111 // Replace a decimal with it's percentage value |
|
21112 function convertToPercentage(n) { |
|
21113 if (n <= 1) { |
|
21114 n = (n * 100) + "%"; |
|
21115 } |
|
21116 |
|
21117 return n; |
|
21118 } |
|
21119 |
|
21120 // Converts a decimal to a hex value |
|
21121 function convertDecimalToHex(d) { |
|
21122 return Math.round(parseFloat(d) * 255).toString(16); |
|
21123 } |
|
21124 // Converts a hex value to a decimal |
|
21125 function convertHexToDecimal(h) { |
|
21126 return (parseIntFromHex(h) / 255); |
|
21127 } |
|
21128 |
|
21129 var matchers = (function() { |
|
21130 |
|
21131 // <http://www.w3.org/TR/css3-values/#integers> |
|
21132 var CSS_INTEGER = "[-\\+]?\\d+%?"; |
|
21133 |
|
21134 // <http://www.w3.org/TR/css3-values/#number-value> |
|
21135 var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?"; |
|
21136 |
|
21137 // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome. |
|
21138 var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")"; |
|
21139 |
|
21140 // Actual matching. |
|
21141 // Parentheses and commas are optional, but not required. |
|
21142 // Whitespace can take the place of commas or opening paren |
|
21143 var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; |
|
21144 var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?"; |
|
21145 |
|
21146 return { |
|
21147 CSS_UNIT: new RegExp(CSS_UNIT), |
|
21148 rgb: new RegExp("rgb" + PERMISSIVE_MATCH3), |
|
21149 rgba: new RegExp("rgba" + PERMISSIVE_MATCH4), |
|
21150 hsl: new RegExp("hsl" + PERMISSIVE_MATCH3), |
|
21151 hsla: new RegExp("hsla" + PERMISSIVE_MATCH4), |
|
21152 hsv: new RegExp("hsv" + PERMISSIVE_MATCH3), |
|
21153 hsva: new RegExp("hsva" + PERMISSIVE_MATCH4), |
|
21154 hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, |
|
21155 hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/, |
|
21156 hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/, |
|
21157 hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/ |
|
21158 }; |
|
21159 })(); |
|
21160 |
|
21161 // `isValidCSSUnit` |
|
21162 // Take in a single string / number and check to see if it looks like a CSS unit |
|
21163 // (see `matchers` above for definition). |
|
21164 function isValidCSSUnit(color) { |
|
21165 return !!matchers.CSS_UNIT.exec(color); |
|
21166 } |
|
21167 |
|
21168 // `stringInputToObject` |
|
21169 // Permissive string parsing. Take in a number of formats, and output an object |
|
21170 // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}` |
|
21171 function stringInputToObject(color) { |
|
21172 |
|
21173 color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase(); |
|
21174 var named = false; |
|
21175 if (names[color]) { |
|
21176 color = names[color]; |
|
21177 named = true; |
|
21178 } |
|
21179 else if (color == 'transparent') { |
|
21180 return { r: 0, g: 0, b: 0, a: 0, format: "name" }; |
|
21181 } |
|
21182 |
|
21183 // Try to match string input using regular expressions. |
|
21184 // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360] |
|
21185 // Just return an object and let the conversion functions handle that. |
|
21186 // This way the result will be the same whether the tinycolor is initialized with string or object. |
|
21187 var match; |
|
21188 if ((match = matchers.rgb.exec(color))) { |
|
21189 return { r: match[1], g: match[2], b: match[3] }; |
|
21190 } |
|
21191 if ((match = matchers.rgba.exec(color))) { |
|
21192 return { r: match[1], g: match[2], b: match[3], a: match[4] }; |
|
21193 } |
|
21194 if ((match = matchers.hsl.exec(color))) { |
|
21195 return { h: match[1], s: match[2], l: match[3] }; |
|
21196 } |
|
21197 if ((match = matchers.hsla.exec(color))) { |
|
21198 return { h: match[1], s: match[2], l: match[3], a: match[4] }; |
|
21199 } |
|
21200 if ((match = matchers.hsv.exec(color))) { |
|
21201 return { h: match[1], s: match[2], v: match[3] }; |
|
21202 } |
|
21203 if ((match = matchers.hsva.exec(color))) { |
|
21204 return { h: match[1], s: match[2], v: match[3], a: match[4] }; |
|
21205 } |
|
21206 if ((match = matchers.hex8.exec(color))) { |
|
21207 return { |
|
21208 r: parseIntFromHex(match[1]), |
|
21209 g: parseIntFromHex(match[2]), |
|
21210 b: parseIntFromHex(match[3]), |
|
21211 a: convertHexToDecimal(match[4]), |
|
21212 format: named ? "name" : "hex8" |
|
21213 }; |
|
21214 } |
|
21215 if ((match = matchers.hex6.exec(color))) { |
|
21216 return { |
|
21217 r: parseIntFromHex(match[1]), |
|
21218 g: parseIntFromHex(match[2]), |
|
21219 b: parseIntFromHex(match[3]), |
|
21220 format: named ? "name" : "hex" |
|
21221 }; |
|
21222 } |
|
21223 if ((match = matchers.hex4.exec(color))) { |
|
21224 return { |
|
21225 r: parseIntFromHex(match[1] + '' + match[1]), |
|
21226 g: parseIntFromHex(match[2] + '' + match[2]), |
|
21227 b: parseIntFromHex(match[3] + '' + match[3]), |
|
21228 a: convertHexToDecimal(match[4] + '' + match[4]), |
|
21229 format: named ? "name" : "hex8" |
|
21230 }; |
|
21231 } |
|
21232 if ((match = matchers.hex3.exec(color))) { |
|
21233 return { |
|
21234 r: parseIntFromHex(match[1] + '' + match[1]), |
|
21235 g: parseIntFromHex(match[2] + '' + match[2]), |
|
21236 b: parseIntFromHex(match[3] + '' + match[3]), |
|
21237 format: named ? "name" : "hex" |
|
21238 }; |
|
21239 } |
|
21240 |
|
21241 return false; |
|
21242 } |
|
21243 |
|
21244 function validateWCAG2Parms(parms) { |
|
21245 // return valid WCAG2 parms for isReadable. |
|
21246 // If input parms are invalid, return {"level":"AA", "size":"small"} |
|
21247 var level, size; |
|
21248 parms = parms || {"level":"AA", "size":"small"}; |
|
21249 level = (parms.level || "AA").toUpperCase(); |
|
21250 size = (parms.size || "small").toLowerCase(); |
|
21251 if (level !== "AA" && level !== "AAA") { |
|
21252 level = "AA"; |
|
21253 } |
|
21254 if (size !== "small" && size !== "large") { |
|
21255 size = "small"; |
|
21256 } |
|
21257 return {"level":level, "size":size}; |
|
21258 } |
|
21259 |
|
21260 // Node: Export function |
|
21261 if ( true && module.exports) { |
|
21262 module.exports = tinycolor; |
|
21263 } |
|
21264 // AMD/requirejs: Define the module |
|
21265 else if (true) { |
|
21266 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {return tinycolor;}).call(exports, __webpack_require__, exports, module), |
|
21267 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); |
|
21268 } |
|
21269 // Browser: Expose to window |
|
21270 else {} |
|
21271 |
|
21272 })(Math); |
|
21273 |
|
21274 |
|
21275 /***/ }), |
|
21276 |
|
21277 /***/ 48: |
|
21278 /***/ (function(module, exports) { |
|
21279 |
|
21280 (function() { module.exports = this["wp"]["a11y"]; }()); |
|
21281 |
|
21282 /***/ }), |
|
21283 |
|
21284 /***/ 49: |
|
21285 /***/ (function(module, exports) { |
|
21286 |
|
21287 (function() { module.exports = this["wp"]["deprecated"]; }()); |
|
21288 |
|
21289 /***/ }), |
|
21290 |
|
21291 /***/ 5: |
|
21292 /***/ (function(module, exports) { |
|
21293 |
|
21294 (function() { module.exports = this["wp"]["data"]; }()); |
|
21295 |
|
21296 /***/ }), |
|
21297 |
|
21298 /***/ 54: |
|
21299 /***/ (function(module, exports, __webpack_require__) { |
|
21300 |
|
21301 /** |
|
21302 * Copyright (c) 2014-present, Facebook, Inc. |
|
21303 * |
|
21304 * This source code is licensed under the MIT license found in the |
|
21305 * LICENSE file in the root directory of this source tree. |
|
21306 */ |
|
21307 |
|
21308 // This method of obtaining a reference to the global object needs to be |
|
21309 // kept identical to the way it is obtained in runtime.js |
|
21310 var g = (function() { |
|
21311 return this || (typeof self === "object" && self); |
|
21312 })() || Function("return this")(); |
|
21313 |
|
21314 // Use `getOwnPropertyNames` because not all browsers support calling |
|
21315 // `hasOwnProperty` on the global `self` object in a worker. See #183. |
|
21316 var hadRuntime = g.regeneratorRuntime && |
|
21317 Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0; |
|
21318 |
|
21319 // Save the old regeneratorRuntime in case it needs to be restored later. |
|
21320 var oldRuntime = hadRuntime && g.regeneratorRuntime; |
|
21321 |
|
21322 // Force reevalutation of runtime.js. |
|
21323 g.regeneratorRuntime = undefined; |
|
21324 |
|
21325 module.exports = __webpack_require__(55); |
|
21326 |
|
21327 if (hadRuntime) { |
|
21328 // Restore the original runtime. |
|
21329 g.regeneratorRuntime = oldRuntime; |
|
21330 } else { |
|
21331 // Remove the global property added by runtime.js. |
|
21332 try { |
|
21333 delete g.regeneratorRuntime; |
|
21334 } catch(e) { |
|
21335 g.regeneratorRuntime = undefined; |
|
21336 } |
|
21337 } |
|
21338 |
|
21339 |
|
21340 /***/ }), |
|
21341 |
|
21342 /***/ 55: |
|
21343 /***/ (function(module, exports) { |
|
21344 |
|
21345 /** |
|
21346 * Copyright (c) 2014-present, Facebook, Inc. |
|
21347 * |
|
21348 * This source code is licensed under the MIT license found in the |
|
21349 * LICENSE file in the root directory of this source tree. |
|
21350 */ |
|
21351 |
|
21352 !(function(global) { |
|
21353 "use strict"; |
|
21354 |
|
21355 var Op = Object.prototype; |
|
21356 var hasOwn = Op.hasOwnProperty; |
|
21357 var undefined; // More compressible than void 0. |
|
21358 var $Symbol = typeof Symbol === "function" ? Symbol : {}; |
|
21359 var iteratorSymbol = $Symbol.iterator || "@@iterator"; |
|
21360 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; |
|
21361 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; |
|
21362 |
|
21363 var inModule = typeof module === "object"; |
|
21364 var runtime = global.regeneratorRuntime; |
|
21365 if (runtime) { |
|
21366 if (inModule) { |
|
21367 // If regeneratorRuntime is defined globally and we're in a module, |
|
21368 // make the exports object identical to regeneratorRuntime. |
|
21369 module.exports = runtime; |
|
21370 } |
|
21371 // Don't bother evaluating the rest of this file if the runtime was |
|
21372 // already defined globally. |
|
21373 return; |
|
21374 } |
|
21375 |
|
21376 // Define the runtime globally (as expected by generated code) as either |
|
21377 // module.exports (if we're in a module) or a new, empty object. |
|
21378 runtime = global.regeneratorRuntime = inModule ? module.exports : {}; |
|
21379 |
|
21380 function wrap(innerFn, outerFn, self, tryLocsList) { |
|
21381 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. |
|
21382 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; |
|
21383 var generator = Object.create(protoGenerator.prototype); |
|
21384 var context = new Context(tryLocsList || []); |
|
21385 |
|
21386 // The ._invoke method unifies the implementations of the .next, |
|
21387 // .throw, and .return methods. |
|
21388 generator._invoke = makeInvokeMethod(innerFn, self, context); |
|
21389 |
|
21390 return generator; |
|
21391 } |
|
21392 runtime.wrap = wrap; |
|
21393 |
|
21394 // Try/catch helper to minimize deoptimizations. Returns a completion |
|
21395 // record like context.tryEntries[i].completion. This interface could |
|
21396 // have been (and was previously) designed to take a closure to be |
|
21397 // invoked without arguments, but in all the cases we care about we |
|
21398 // already have an existing method we want to call, so there's no need |
|
21399 // to create a new function object. We can even get away with assuming |
|
21400 // the method takes exactly one argument, since that happens to be true |
|
21401 // in every case, so we don't have to touch the arguments object. The |
|
21402 // only additional allocation required is the completion record, which |
|
21403 // has a stable shape and so hopefully should be cheap to allocate. |
|
21404 function tryCatch(fn, obj, arg) { |
|
21405 try { |
|
21406 return { type: "normal", arg: fn.call(obj, arg) }; |
|
21407 } catch (err) { |
|
21408 return { type: "throw", arg: err }; |
|
21409 } |
|
21410 } |
|
21411 |
|
21412 var GenStateSuspendedStart = "suspendedStart"; |
|
21413 var GenStateSuspendedYield = "suspendedYield"; |
|
21414 var GenStateExecuting = "executing"; |
|
21415 var GenStateCompleted = "completed"; |
|
21416 |
|
21417 // Returning this object from the innerFn has the same effect as |
|
21418 // breaking out of the dispatch switch statement. |
|
21419 var ContinueSentinel = {}; |
|
21420 |
|
21421 // Dummy constructor functions that we use as the .constructor and |
|
21422 // .constructor.prototype properties for functions that return Generator |
|
21423 // objects. For full spec compliance, you may wish to configure your |
|
21424 // minifier not to mangle the names of these two functions. |
|
21425 function Generator() {} |
|
21426 function GeneratorFunction() {} |
|
21427 function GeneratorFunctionPrototype() {} |
|
21428 |
|
21429 // This is a polyfill for %IteratorPrototype% for environments that |
|
21430 // don't natively support it. |
|
21431 var IteratorPrototype = {}; |
|
21432 IteratorPrototype[iteratorSymbol] = function () { |
|
21433 return this; |
|
21434 }; |
|
21435 |
|
21436 var getProto = Object.getPrototypeOf; |
|
21437 var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); |
|
21438 if (NativeIteratorPrototype && |
|
21439 NativeIteratorPrototype !== Op && |
|
21440 hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { |
|
21441 // This environment has a native %IteratorPrototype%; use it instead |
|
21442 // of the polyfill. |
|
21443 IteratorPrototype = NativeIteratorPrototype; |
|
21444 } |
|
21445 |
|
21446 var Gp = GeneratorFunctionPrototype.prototype = |
|
21447 Generator.prototype = Object.create(IteratorPrototype); |
|
21448 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; |
|
21449 GeneratorFunctionPrototype.constructor = GeneratorFunction; |
|
21450 GeneratorFunctionPrototype[toStringTagSymbol] = |
|
21451 GeneratorFunction.displayName = "GeneratorFunction"; |
|
21452 |
|
21453 // Helper for defining the .next, .throw, and .return methods of the |
|
21454 // Iterator interface in terms of a single ._invoke method. |
|
21455 function defineIteratorMethods(prototype) { |
|
21456 ["next", "throw", "return"].forEach(function(method) { |
|
21457 prototype[method] = function(arg) { |
|
21458 return this._invoke(method, arg); |
|
21459 }; |
|
21460 }); |
|
21461 } |
|
21462 |
|
21463 runtime.isGeneratorFunction = function(genFun) { |
|
21464 var ctor = typeof genFun === "function" && genFun.constructor; |
|
21465 return ctor |
|
21466 ? ctor === GeneratorFunction || |
|
21467 // For the native GeneratorFunction constructor, the best we can |
|
21468 // do is to check its .name property. |
|
21469 (ctor.displayName || ctor.name) === "GeneratorFunction" |
|
21470 : false; |
|
21471 }; |
|
21472 |
|
21473 runtime.mark = function(genFun) { |
|
21474 if (Object.setPrototypeOf) { |
|
21475 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); |
|
21476 } else { |
|
21477 genFun.__proto__ = GeneratorFunctionPrototype; |
|
21478 if (!(toStringTagSymbol in genFun)) { |
|
21479 genFun[toStringTagSymbol] = "GeneratorFunction"; |
|
21480 } |
|
21481 } |
|
21482 genFun.prototype = Object.create(Gp); |
|
21483 return genFun; |
|
21484 }; |
|
21485 |
|
21486 // Within the body of any async function, `await x` is transformed to |
|
21487 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test |
|
21488 // `hasOwn.call(value, "__await")` to determine if the yielded value is |
|
21489 // meant to be awaited. |
|
21490 runtime.awrap = function(arg) { |
|
21491 return { __await: arg }; |
|
21492 }; |
|
21493 |
|
21494 function AsyncIterator(generator) { |
|
21495 function invoke(method, arg, resolve, reject) { |
|
21496 var record = tryCatch(generator[method], generator, arg); |
|
21497 if (record.type === "throw") { |
|
21498 reject(record.arg); |
|
21499 } else { |
|
21500 var result = record.arg; |
|
21501 var value = result.value; |
|
21502 if (value && |
|
21503 typeof value === "object" && |
|
21504 hasOwn.call(value, "__await")) { |
|
21505 return Promise.resolve(value.__await).then(function(value) { |
|
21506 invoke("next", value, resolve, reject); |
|
21507 }, function(err) { |
|
21508 invoke("throw", err, resolve, reject); |
|
21509 }); |
|
21510 } |
|
21511 |
|
21512 return Promise.resolve(value).then(function(unwrapped) { |
|
21513 // When a yielded Promise is resolved, its final value becomes |
|
21514 // the .value of the Promise<{value,done}> result for the |
|
21515 // current iteration. |
|
21516 result.value = unwrapped; |
|
21517 resolve(result); |
|
21518 }, function(error) { |
|
21519 // If a rejected Promise was yielded, throw the rejection back |
|
21520 // into the async generator function so it can be handled there. |
|
21521 return invoke("throw", error, resolve, reject); |
|
21522 }); |
|
21523 } |
|
21524 } |
|
21525 |
|
21526 var previousPromise; |
|
21527 |
|
21528 function enqueue(method, arg) { |
|
21529 function callInvokeWithMethodAndArg() { |
|
21530 return new Promise(function(resolve, reject) { |
|
21531 invoke(method, arg, resolve, reject); |
|
21532 }); |
|
21533 } |
|
21534 |
|
21535 return previousPromise = |
|
21536 // If enqueue has been called before, then we want to wait until |
|
21537 // all previous Promises have been resolved before calling invoke, |
|
21538 // so that results are always delivered in the correct order. If |
|
21539 // enqueue has not been called before, then it is important to |
|
21540 // call invoke immediately, without waiting on a callback to fire, |
|
21541 // so that the async generator function has the opportunity to do |
|
21542 // any necessary setup in a predictable way. This predictability |
|
21543 // is why the Promise constructor synchronously invokes its |
|
21544 // executor callback, and why async functions synchronously |
|
21545 // execute code before the first await. Since we implement simple |
|
21546 // async functions in terms of async generators, it is especially |
|
21547 // important to get this right, even though it requires care. |
|
21548 previousPromise ? previousPromise.then( |
|
21549 callInvokeWithMethodAndArg, |
|
21550 // Avoid propagating failures to Promises returned by later |
|
21551 // invocations of the iterator. |
|
21552 callInvokeWithMethodAndArg |
|
21553 ) : callInvokeWithMethodAndArg(); |
|
21554 } |
|
21555 |
|
21556 // Define the unified helper method that is used to implement .next, |
|
21557 // .throw, and .return (see defineIteratorMethods). |
|
21558 this._invoke = enqueue; |
|
21559 } |
|
21560 |
|
21561 defineIteratorMethods(AsyncIterator.prototype); |
|
21562 AsyncIterator.prototype[asyncIteratorSymbol] = function () { |
|
21563 return this; |
|
21564 }; |
|
21565 runtime.AsyncIterator = AsyncIterator; |
|
21566 |
|
21567 // Note that simple async functions are implemented on top of |
|
21568 // AsyncIterator objects; they just return a Promise for the value of |
|
21569 // the final result produced by the iterator. |
|
21570 runtime.async = function(innerFn, outerFn, self, tryLocsList) { |
|
21571 var iter = new AsyncIterator( |
|
21572 wrap(innerFn, outerFn, self, tryLocsList) |
|
21573 ); |
|
21574 |
|
21575 return runtime.isGeneratorFunction(outerFn) |
|
21576 ? iter // If outerFn is a generator, return the full iterator. |
|
21577 : iter.next().then(function(result) { |
|
21578 return result.done ? result.value : iter.next(); |
|
21579 }); |
|
21580 }; |
|
21581 |
|
21582 function makeInvokeMethod(innerFn, self, context) { |
|
21583 var state = GenStateSuspendedStart; |
|
21584 |
|
21585 return function invoke(method, arg) { |
|
21586 if (state === GenStateExecuting) { |
|
21587 throw new Error("Generator is already running"); |
|
21588 } |
|
21589 |
|
21590 if (state === GenStateCompleted) { |
|
21591 if (method === "throw") { |
|
21592 throw arg; |
|
21593 } |
|
21594 |
|
21595 // Be forgiving, per 25.3.3.3.3 of the spec: |
|
21596 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume |
|
21597 return doneResult(); |
|
21598 } |
|
21599 |
|
21600 context.method = method; |
|
21601 context.arg = arg; |
|
21602 |
|
21603 while (true) { |
|
21604 var delegate = context.delegate; |
|
21605 if (delegate) { |
|
21606 var delegateResult = maybeInvokeDelegate(delegate, context); |
|
21607 if (delegateResult) { |
|
21608 if (delegateResult === ContinueSentinel) continue; |
|
21609 return delegateResult; |
|
21610 } |
|
21611 } |
|
21612 |
|
21613 if (context.method === "next") { |
|
21614 // Setting context._sent for legacy support of Babel's |
|
21615 // function.sent implementation. |
|
21616 context.sent = context._sent = context.arg; |
|
21617 |
|
21618 } else if (context.method === "throw") { |
|
21619 if (state === GenStateSuspendedStart) { |
|
21620 state = GenStateCompleted; |
|
21621 throw context.arg; |
|
21622 } |
|
21623 |
|
21624 context.dispatchException(context.arg); |
|
21625 |
|
21626 } else if (context.method === "return") { |
|
21627 context.abrupt("return", context.arg); |
|
21628 } |
|
21629 |
|
21630 state = GenStateExecuting; |
|
21631 |
|
21632 var record = tryCatch(innerFn, self, context); |
|
21633 if (record.type === "normal") { |
|
21634 // If an exception is thrown from innerFn, we leave state === |
|
21635 // GenStateExecuting and loop back for another invocation. |
|
21636 state = context.done |
|
21637 ? GenStateCompleted |
|
21638 : GenStateSuspendedYield; |
|
21639 |
|
21640 if (record.arg === ContinueSentinel) { |
|
21641 continue; |
|
21642 } |
|
21643 |
|
21644 return { |
|
21645 value: record.arg, |
|
21646 done: context.done |
|
21647 }; |
|
21648 |
|
21649 } else if (record.type === "throw") { |
|
21650 state = GenStateCompleted; |
|
21651 // Dispatch the exception by looping back around to the |
|
21652 // context.dispatchException(context.arg) call above. |
|
21653 context.method = "throw"; |
|
21654 context.arg = record.arg; |
|
21655 } |
|
21656 } |
|
21657 }; |
|
21658 } |
|
21659 |
|
21660 // Call delegate.iterator[context.method](context.arg) and handle the |
|
21661 // result, either by returning a { value, done } result from the |
|
21662 // delegate iterator, or by modifying context.method and context.arg, |
|
21663 // setting context.delegate to null, and returning the ContinueSentinel. |
|
21664 function maybeInvokeDelegate(delegate, context) { |
|
21665 var method = delegate.iterator[context.method]; |
|
21666 if (method === undefined) { |
|
21667 // A .throw or .return when the delegate iterator has no .throw |
|
21668 // method always terminates the yield* loop. |
|
21669 context.delegate = null; |
|
21670 |
|
21671 if (context.method === "throw") { |
|
21672 if (delegate.iterator.return) { |
|
21673 // If the delegate iterator has a return method, give it a |
|
21674 // chance to clean up. |
|
21675 context.method = "return"; |
|
21676 context.arg = undefined; |
|
21677 maybeInvokeDelegate(delegate, context); |
|
21678 |
|
21679 if (context.method === "throw") { |
|
21680 // If maybeInvokeDelegate(context) changed context.method from |
|
21681 // "return" to "throw", let that override the TypeError below. |
|
21682 return ContinueSentinel; |
|
21683 } |
|
21684 } |
|
21685 |
|
21686 context.method = "throw"; |
|
21687 context.arg = new TypeError( |
|
21688 "The iterator does not provide a 'throw' method"); |
|
21689 } |
|
21690 |
|
21691 return ContinueSentinel; |
|
21692 } |
|
21693 |
|
21694 var record = tryCatch(method, delegate.iterator, context.arg); |
|
21695 |
|
21696 if (record.type === "throw") { |
|
21697 context.method = "throw"; |
|
21698 context.arg = record.arg; |
|
21699 context.delegate = null; |
|
21700 return ContinueSentinel; |
|
21701 } |
|
21702 |
|
21703 var info = record.arg; |
|
21704 |
|
21705 if (! info) { |
|
21706 context.method = "throw"; |
|
21707 context.arg = new TypeError("iterator result is not an object"); |
|
21708 context.delegate = null; |
|
21709 return ContinueSentinel; |
|
21710 } |
|
21711 |
|
21712 if (info.done) { |
|
21713 // Assign the result of the finished delegate to the temporary |
|
21714 // variable specified by delegate.resultName (see delegateYield). |
|
21715 context[delegate.resultName] = info.value; |
|
21716 |
|
21717 // Resume execution at the desired location (see delegateYield). |
|
21718 context.next = delegate.nextLoc; |
|
21719 |
|
21720 // If context.method was "throw" but the delegate handled the |
|
21721 // exception, let the outer generator proceed normally. If |
|
21722 // context.method was "next", forget context.arg since it has been |
|
21723 // "consumed" by the delegate iterator. If context.method was |
|
21724 // "return", allow the original .return call to continue in the |
|
21725 // outer generator. |
|
21726 if (context.method !== "return") { |
|
21727 context.method = "next"; |
|
21728 context.arg = undefined; |
|
21729 } |
|
21730 |
|
21731 } else { |
|
21732 // Re-yield the result returned by the delegate method. |
|
21733 return info; |
|
21734 } |
|
21735 |
|
21736 // The delegate iterator is finished, so forget it and continue with |
|
21737 // the outer generator. |
|
21738 context.delegate = null; |
|
21739 return ContinueSentinel; |
|
21740 } |
|
21741 |
|
21742 // Define Generator.prototype.{next,throw,return} in terms of the |
|
21743 // unified ._invoke helper method. |
|
21744 defineIteratorMethods(Gp); |
|
21745 |
|
21746 Gp[toStringTagSymbol] = "Generator"; |
|
21747 |
|
21748 // A Generator should always return itself as the iterator object when the |
|
21749 // @@iterator function is called on it. Some browsers' implementations of the |
|
21750 // iterator prototype chain incorrectly implement this, causing the Generator |
|
21751 // object to not be returned from this call. This ensures that doesn't happen. |
|
21752 // See https://github.com/facebook/regenerator/issues/274 for more details. |
|
21753 Gp[iteratorSymbol] = function() { |
|
21754 return this; |
|
21755 }; |
|
21756 |
|
21757 Gp.toString = function() { |
|
21758 return "[object Generator]"; |
|
21759 }; |
|
21760 |
|
21761 function pushTryEntry(locs) { |
|
21762 var entry = { tryLoc: locs[0] }; |
|
21763 |
|
21764 if (1 in locs) { |
|
21765 entry.catchLoc = locs[1]; |
|
21766 } |
|
21767 |
|
21768 if (2 in locs) { |
|
21769 entry.finallyLoc = locs[2]; |
|
21770 entry.afterLoc = locs[3]; |
|
21771 } |
|
21772 |
|
21773 this.tryEntries.push(entry); |
|
21774 } |
|
21775 |
|
21776 function resetTryEntry(entry) { |
|
21777 var record = entry.completion || {}; |
|
21778 record.type = "normal"; |
|
21779 delete record.arg; |
|
21780 entry.completion = record; |
|
21781 } |
|
21782 |
|
21783 function Context(tryLocsList) { |
|
21784 // The root entry object (effectively a try statement without a catch |
|
21785 // or a finally block) gives us a place to store values thrown from |
|
21786 // locations where there is no enclosing try statement. |
|
21787 this.tryEntries = [{ tryLoc: "root" }]; |
|
21788 tryLocsList.forEach(pushTryEntry, this); |
|
21789 this.reset(true); |
|
21790 } |
|
21791 |
|
21792 runtime.keys = function(object) { |
|
21793 var keys = []; |
|
21794 for (var key in object) { |
|
21795 keys.push(key); |
|
21796 } |
|
21797 keys.reverse(); |
|
21798 |
|
21799 // Rather than returning an object with a next method, we keep |
|
21800 // things simple and return the next function itself. |
|
21801 return function next() { |
|
21802 while (keys.length) { |
|
21803 var key = keys.pop(); |
|
21804 if (key in object) { |
|
21805 next.value = key; |
|
21806 next.done = false; |
|
21807 return next; |
|
21808 } |
|
21809 } |
|
21810 |
|
21811 // To avoid creating an additional object, we just hang the .value |
|
21812 // and .done properties off the next function object itself. This |
|
21813 // also ensures that the minifier will not anonymize the function. |
|
21814 next.done = true; |
|
21815 return next; |
|
21816 }; |
|
21817 }; |
|
21818 |
|
21819 function values(iterable) { |
|
21820 if (iterable) { |
|
21821 var iteratorMethod = iterable[iteratorSymbol]; |
|
21822 if (iteratorMethod) { |
|
21823 return iteratorMethod.call(iterable); |
|
21824 } |
|
21825 |
|
21826 if (typeof iterable.next === "function") { |
|
21827 return iterable; |
|
21828 } |
|
21829 |
|
21830 if (!isNaN(iterable.length)) { |
|
21831 var i = -1, next = function next() { |
|
21832 while (++i < iterable.length) { |
|
21833 if (hasOwn.call(iterable, i)) { |
|
21834 next.value = iterable[i]; |
|
21835 next.done = false; |
|
21836 return next; |
|
21837 } |
|
21838 } |
|
21839 |
|
21840 next.value = undefined; |
|
21841 next.done = true; |
|
21842 |
|
21843 return next; |
|
21844 }; |
|
21845 |
|
21846 return next.next = next; |
|
21847 } |
|
21848 } |
|
21849 |
|
21850 // Return an iterator with no values. |
|
21851 return { next: doneResult }; |
|
21852 } |
|
21853 runtime.values = values; |
|
21854 |
|
21855 function doneResult() { |
|
21856 return { value: undefined, done: true }; |
|
21857 } |
|
21858 |
|
21859 Context.prototype = { |
|
21860 constructor: Context, |
|
21861 |
|
21862 reset: function(skipTempReset) { |
|
21863 this.prev = 0; |
|
21864 this.next = 0; |
|
21865 // Resetting context._sent for legacy support of Babel's |
|
21866 // function.sent implementation. |
|
21867 this.sent = this._sent = undefined; |
|
21868 this.done = false; |
|
21869 this.delegate = null; |
|
21870 |
|
21871 this.method = "next"; |
|
21872 this.arg = undefined; |
|
21873 |
|
21874 this.tryEntries.forEach(resetTryEntry); |
|
21875 |
|
21876 if (!skipTempReset) { |
|
21877 for (var name in this) { |
|
21878 // Not sure about the optimal order of these conditions: |
|
21879 if (name.charAt(0) === "t" && |
|
21880 hasOwn.call(this, name) && |
|
21881 !isNaN(+name.slice(1))) { |
|
21882 this[name] = undefined; |
|
21883 } |
|
21884 } |
|
21885 } |
|
21886 }, |
|
21887 |
|
21888 stop: function() { |
|
21889 this.done = true; |
|
21890 |
|
21891 var rootEntry = this.tryEntries[0]; |
|
21892 var rootRecord = rootEntry.completion; |
|
21893 if (rootRecord.type === "throw") { |
|
21894 throw rootRecord.arg; |
|
21895 } |
|
21896 |
|
21897 return this.rval; |
|
21898 }, |
|
21899 |
|
21900 dispatchException: function(exception) { |
|
21901 if (this.done) { |
|
21902 throw exception; |
|
21903 } |
|
21904 |
|
21905 var context = this; |
|
21906 function handle(loc, caught) { |
|
21907 record.type = "throw"; |
|
21908 record.arg = exception; |
|
21909 context.next = loc; |
|
21910 |
|
21911 if (caught) { |
|
21912 // If the dispatched exception was caught by a catch block, |
|
21913 // then let that catch block handle the exception normally. |
|
21914 context.method = "next"; |
|
21915 context.arg = undefined; |
|
21916 } |
|
21917 |
|
21918 return !! caught; |
|
21919 } |
|
21920 |
|
21921 for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
21922 var entry = this.tryEntries[i]; |
|
21923 var record = entry.completion; |
|
21924 |
|
21925 if (entry.tryLoc === "root") { |
|
21926 // Exception thrown outside of any try block that could handle |
|
21927 // it, so set the completion value of the entire function to |
|
21928 // throw the exception. |
|
21929 return handle("end"); |
|
21930 } |
|
21931 |
|
21932 if (entry.tryLoc <= this.prev) { |
|
21933 var hasCatch = hasOwn.call(entry, "catchLoc"); |
|
21934 var hasFinally = hasOwn.call(entry, "finallyLoc"); |
|
21935 |
|
21936 if (hasCatch && hasFinally) { |
|
21937 if (this.prev < entry.catchLoc) { |
|
21938 return handle(entry.catchLoc, true); |
|
21939 } else if (this.prev < entry.finallyLoc) { |
|
21940 return handle(entry.finallyLoc); |
|
21941 } |
|
21942 |
|
21943 } else if (hasCatch) { |
|
21944 if (this.prev < entry.catchLoc) { |
|
21945 return handle(entry.catchLoc, true); |
|
21946 } |
|
21947 |
|
21948 } else if (hasFinally) { |
|
21949 if (this.prev < entry.finallyLoc) { |
|
21950 return handle(entry.finallyLoc); |
|
21951 } |
|
21952 |
|
21953 } else { |
|
21954 throw new Error("try statement without catch or finally"); |
|
21955 } |
|
21956 } |
|
21957 } |
|
21958 }, |
|
21959 |
|
21960 abrupt: function(type, arg) { |
|
21961 for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
21962 var entry = this.tryEntries[i]; |
|
21963 if (entry.tryLoc <= this.prev && |
|
21964 hasOwn.call(entry, "finallyLoc") && |
|
21965 this.prev < entry.finallyLoc) { |
|
21966 var finallyEntry = entry; |
|
21967 break; |
|
21968 } |
|
21969 } |
|
21970 |
|
21971 if (finallyEntry && |
|
21972 (type === "break" || |
|
21973 type === "continue") && |
|
21974 finallyEntry.tryLoc <= arg && |
|
21975 arg <= finallyEntry.finallyLoc) { |
|
21976 // Ignore the finally entry if control is not jumping to a |
|
21977 // location outside the try/catch block. |
|
21978 finallyEntry = null; |
|
21979 } |
|
21980 |
|
21981 var record = finallyEntry ? finallyEntry.completion : {}; |
|
21982 record.type = type; |
|
21983 record.arg = arg; |
|
21984 |
|
21985 if (finallyEntry) { |
|
21986 this.method = "next"; |
|
21987 this.next = finallyEntry.finallyLoc; |
|
21988 return ContinueSentinel; |
|
21989 } |
|
21990 |
|
21991 return this.complete(record); |
|
21992 }, |
|
21993 |
|
21994 complete: function(record, afterLoc) { |
|
21995 if (record.type === "throw") { |
|
21996 throw record.arg; |
|
21997 } |
|
21998 |
|
21999 if (record.type === "break" || |
|
22000 record.type === "continue") { |
|
22001 this.next = record.arg; |
|
22002 } else if (record.type === "return") { |
|
22003 this.rval = this.arg = record.arg; |
|
22004 this.method = "return"; |
|
22005 this.next = "end"; |
|
22006 } else if (record.type === "normal" && afterLoc) { |
|
22007 this.next = afterLoc; |
|
22008 } |
|
22009 |
|
22010 return ContinueSentinel; |
|
22011 }, |
|
22012 |
|
22013 finish: function(finallyLoc) { |
|
22014 for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
22015 var entry = this.tryEntries[i]; |
|
22016 if (entry.finallyLoc === finallyLoc) { |
|
22017 this.complete(entry.completion, entry.afterLoc); |
|
22018 resetTryEntry(entry); |
|
22019 return ContinueSentinel; |
|
22020 } |
|
22021 } |
|
22022 }, |
|
22023 |
|
22024 "catch": function(tryLoc) { |
|
22025 for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
22026 var entry = this.tryEntries[i]; |
|
22027 if (entry.tryLoc === tryLoc) { |
|
22028 var record = entry.completion; |
|
22029 if (record.type === "throw") { |
|
22030 var thrown = record.arg; |
|
22031 resetTryEntry(entry); |
|
22032 } |
|
22033 return thrown; |
|
22034 } |
|
22035 } |
|
22036 |
|
22037 // The context.catch method must only be called with a location |
|
22038 // argument that corresponds to a known catch block. |
|
22039 throw new Error("illegal catch attempt"); |
|
22040 }, |
|
22041 |
|
22042 delegateYield: function(iterable, resultName, nextLoc) { |
|
22043 this.delegate = { |
|
22044 iterator: values(iterable), |
|
22045 resultName: resultName, |
|
22046 nextLoc: nextLoc |
|
22047 }; |
|
22048 |
|
22049 if (this.method === "next") { |
|
22050 // Deliberately forget the last sent value so that we don't |
|
22051 // accidentally pass it on to the delegate. |
|
22052 this.arg = undefined; |
|
22053 } |
|
22054 |
|
22055 return ContinueSentinel; |
|
22056 } |
|
22057 }; |
|
22058 })( |
|
22059 // In sloppy mode, unbound `this` refers to the global object, fallback to |
|
22060 // Function constructor if we're in global strict mode. That is sadly a form |
|
22061 // of indirect eval which violates Content Security Policy. |
|
22062 (function() { |
|
22063 return this || (typeof self === "object" && self); |
|
22064 })() || Function("return this")() |
|
22065 ); |
|
22066 |
|
22067 |
|
22068 /***/ }), |
|
22069 |
|
22070 /***/ 57: |
|
22071 /***/ (function(module, exports) { |
|
22072 |
|
22073 (function() { module.exports = this["wp"]["htmlEntities"]; }()); |
|
22074 |
|
22075 /***/ }), |
|
22076 |
|
22077 /***/ 6: |
|
22078 /***/ (function(module, exports) { |
|
22079 |
|
22080 (function() { module.exports = this["wp"]["compose"]; }()); |
|
22081 |
|
22082 /***/ }), |
|
22083 |
|
22084 /***/ 61: |
|
22085 /***/ (function(module, exports, __webpack_require__) { |
|
22086 |
|
22087 "use strict"; |
|
22088 |
|
22089 exports.__esModule = true; |
|
22090 var TextareaAutosize_1 = __webpack_require__(111); |
|
22091 exports["default"] = TextareaAutosize_1["default"]; |
|
22092 |
|
22093 |
|
22094 /***/ }), |
|
22095 |
|
22096 /***/ 67: |
|
22097 /***/ (function(module, exports, __webpack_require__) { |
|
22098 |
|
22099 "use strict"; |
|
22100 |
|
22101 |
|
22102 module.exports = __webpack_require__(115); |
|
22103 |
|
22104 /***/ }), |
|
22105 |
|
22106 /***/ 7: |
|
22107 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
22108 |
|
22109 "use strict"; |
|
22110 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectSpread; }); |
|
22111 /* harmony import */ var _defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15); |
|
22112 |
|
22113 function _objectSpread(target) { |
|
22114 for (var i = 1; i < arguments.length; i++) { |
|
22115 var source = arguments[i] != null ? arguments[i] : {}; |
|
22116 var ownKeys = Object.keys(source); |
|
22117 |
|
22118 if (typeof Object.getOwnPropertySymbols === 'function') { |
|
22119 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { |
|
22120 return Object.getOwnPropertyDescriptor(source, sym).enumerable; |
|
22121 })); |
|
22122 } |
|
22123 |
|
22124 ownKeys.forEach(function (key) { |
|
22125 Object(_defineProperty__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(target, key, source[key]); |
|
22126 }); |
|
22127 } |
|
22128 |
|
22129 return target; |
|
22130 } |
|
22131 |
|
22132 /***/ }), |
|
22133 |
|
22134 /***/ 70: |
|
22135 /***/ (function(module, exports, __webpack_require__) { |
|
22136 |
|
22137 "use strict"; |
|
22138 |
|
22139 |
|
22140 function flattenIntoMap( map, effects ) { |
|
22141 var i; |
|
22142 if ( Array.isArray( effects ) ) { |
|
22143 for ( i = 0; i < effects.length; i++ ) { |
|
22144 flattenIntoMap( map, effects[ i ] ); |
|
22145 } |
|
22146 } else { |
|
22147 for ( i in effects ) { |
|
22148 map[ i ] = ( map[ i ] || [] ).concat( effects[ i ] ); |
|
22149 } |
|
22150 } |
|
22151 } |
|
22152 |
|
22153 function refx( effects ) { |
|
22154 var map = {}, |
|
22155 middleware; |
|
22156 |
|
22157 flattenIntoMap( map, effects ); |
|
22158 |
|
22159 middleware = function( store ) { |
|
22160 return function( next ) { |
|
22161 return function( action ) { |
|
22162 var handlers = map[ action.type ], |
|
22163 result = next( action ), |
|
22164 i, handlerAction; |
|
22165 |
|
22166 if ( handlers ) { |
|
22167 for ( i = 0; i < handlers.length; i++ ) { |
|
22168 handlerAction = handlers[ i ]( action, store ); |
|
22169 if ( handlerAction ) { |
|
22170 store.dispatch( handlerAction ); |
|
22171 } |
|
22172 } |
|
22173 } |
|
22174 |
|
22175 return result; |
|
22176 }; |
|
22177 }; |
|
22178 }; |
|
22179 |
|
22180 middleware.effects = map; |
|
22181 |
|
22182 return middleware; |
|
22183 } |
|
22184 |
|
22185 module.exports = refx; |
|
22186 |
|
22187 |
|
22188 /***/ }), |
|
22189 |
|
22190 /***/ 72: |
|
22191 /***/ (function(module, exports) { |
|
22192 |
|
22193 (function() { module.exports = this["wp"]["coreData"]; }()); |
|
22194 |
|
22195 /***/ }), |
|
22196 |
|
22197 /***/ 89: |
|
22198 /***/ (function(module, exports, __webpack_require__) { |
|
22199 |
|
22200 "use strict"; |
|
22201 /** |
|
22202 * Copyright (c) 2013-present, Facebook, Inc. |
|
22203 * |
|
22204 * This source code is licensed under the MIT license found in the |
|
22205 * LICENSE file in the root directory of this source tree. |
|
22206 */ |
|
22207 |
|
22208 |
|
22209 |
|
22210 var ReactPropTypesSecret = __webpack_require__(90); |
|
22211 |
|
22212 function emptyFunction() {} |
|
22213 |
|
22214 module.exports = function() { |
|
22215 function shim(props, propName, componentName, location, propFullName, secret) { |
|
22216 if (secret === ReactPropTypesSecret) { |
|
22217 // It is still safe when called from React. |
|
22218 return; |
|
22219 } |
|
22220 var err = new Error( |
|
22221 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + |
|
22222 'Use PropTypes.checkPropTypes() to call them. ' + |
|
22223 'Read more at http://fb.me/use-check-prop-types' |
|
22224 ); |
|
22225 err.name = 'Invariant Violation'; |
|
22226 throw err; |
|
22227 }; |
|
22228 shim.isRequired = shim; |
|
22229 function getShim() { |
|
22230 return shim; |
|
22231 }; |
|
22232 // Important! |
|
22233 // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. |
|
22234 var ReactPropTypes = { |
|
22235 array: shim, |
|
22236 bool: shim, |
|
22237 func: shim, |
|
22238 number: shim, |
|
22239 object: shim, |
|
22240 string: shim, |
|
22241 symbol: shim, |
|
22242 |
|
22243 any: shim, |
|
22244 arrayOf: getShim, |
|
22245 element: shim, |
|
22246 instanceOf: getShim, |
|
22247 node: shim, |
|
22248 objectOf: getShim, |
|
22249 oneOf: getShim, |
|
22250 oneOfType: getShim, |
|
22251 shape: getShim, |
|
22252 exact: getShim |
|
22253 }; |
|
22254 |
|
22255 ReactPropTypes.checkPropTypes = emptyFunction; |
|
22256 ReactPropTypes.PropTypes = ReactPropTypes; |
|
22257 |
|
22258 return ReactPropTypes; |
|
22259 }; |
|
22260 |
|
22261 |
|
22262 /***/ }), |
|
22263 |
|
22264 /***/ 9: |
|
22265 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
22266 |
|
22267 "use strict"; |
|
22268 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; }); |
|
22269 function _defineProperties(target, props) { |
|
22270 for (var i = 0; i < props.length; i++) { |
|
22271 var descriptor = props[i]; |
|
22272 descriptor.enumerable = descriptor.enumerable || false; |
|
22273 descriptor.configurable = true; |
|
22274 if ("value" in descriptor) descriptor.writable = true; |
|
22275 Object.defineProperty(target, descriptor.key, descriptor); |
|
22276 } |
|
22277 } |
|
22278 |
|
22279 function _createClass(Constructor, protoProps, staticProps) { |
|
22280 if (protoProps) _defineProperties(Constructor.prototype, protoProps); |
|
22281 if (staticProps) _defineProperties(Constructor, staticProps); |
|
22282 return Constructor; |
|
22283 } |
|
22284 |
|
22285 /***/ }), |
|
22286 |
|
22287 /***/ 90: |
|
22288 /***/ (function(module, exports, __webpack_require__) { |
|
22289 |
|
22290 "use strict"; |
|
22291 /** |
|
22292 * Copyright (c) 2013-present, Facebook, Inc. |
|
22293 * |
|
22294 * This source code is licensed under the MIT license found in the |
|
22295 * LICENSE file in the root directory of this source tree. |
|
22296 */ |
|
22297 |
|
22298 |
|
22299 |
|
22300 var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; |
|
22301 |
|
22302 module.exports = ReactPropTypesSecret; |
|
22303 |
|
22304 |
|
22305 /***/ }), |
|
22306 |
|
22307 /***/ 97: |
|
22308 /***/ (function(module, exports, __webpack_require__) { |
|
22309 |
|
22310 "use strict"; |
|
22311 |
|
22312 |
|
22313 Object.defineProperty(exports, "__esModule", { |
|
22314 value: true |
|
22315 }); |
|
22316 /** |
|
22317 * Redux dispatch multiple actions |
|
22318 */ |
|
22319 |
|
22320 function multi(_ref) { |
|
22321 var dispatch = _ref.dispatch; |
|
22322 |
|
22323 return function (next) { |
|
22324 return function (action) { |
|
22325 return Array.isArray(action) ? action.filter(Boolean).map(dispatch) : next(action); |
|
22326 }; |
|
22327 }; |
|
22328 } |
|
22329 |
|
22330 /** |
|
22331 * Exports |
|
22332 */ |
|
22333 |
|
22334 exports.default = multi; |
|
22335 |
|
22336 /***/ }), |
|
22337 |
|
22338 /***/ 98: |
|
22339 /***/ (function(module, exports) { |
|
22340 |
|
22341 (function() { module.exports = this["wp"]["wordcount"]; }()); |
|
22342 |
|
22343 /***/ }) |
|
22344 |
|
22345 /******/ }); |