annotations.js (34983B)
1 this["wp"] = this["wp"] || {}; this["wp"]["annotations"] = 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 = "23Y4"); 86 /******/ }) 87 /************************************************************************/ 88 /******/ ({ 89 90 /***/ "1ZqX": 91 /***/ (function(module, exports) { 92 93 (function() { module.exports = window["wp"]["data"]; }()); 94 95 /***/ }), 96 97 /***/ "23Y4": 98 /***/ (function(module, __webpack_exports__, __webpack_require__) { 99 100 "use strict"; 101 // ESM COMPAT FLAG 102 __webpack_require__.r(__webpack_exports__); 103 104 // EXPORTS 105 __webpack_require__.d(__webpack_exports__, "store", function() { return /* reexport */ store; }); 106 107 // NAMESPACE OBJECT: ./node_modules/@wordpress/annotations/build-module/store/selectors.js 108 var selectors_namespaceObject = {}; 109 __webpack_require__.r(selectors_namespaceObject); 110 __webpack_require__.d(selectors_namespaceObject, "__experimentalGetAnnotationsForBlock", function() { return __experimentalGetAnnotationsForBlock; }); 111 __webpack_require__.d(selectors_namespaceObject, "__experimentalGetAllAnnotationsForBlock", function() { return __experimentalGetAllAnnotationsForBlock; }); 112 __webpack_require__.d(selectors_namespaceObject, "__experimentalGetAnnotationsForRichText", function() { return __experimentalGetAnnotationsForRichText; }); 113 __webpack_require__.d(selectors_namespaceObject, "__experimentalGetAnnotations", function() { return __experimentalGetAnnotations; }); 114 115 // NAMESPACE OBJECT: ./node_modules/@wordpress/annotations/build-module/store/actions.js 116 var actions_namespaceObject = {}; 117 __webpack_require__.r(actions_namespaceObject); 118 __webpack_require__.d(actions_namespaceObject, "__experimentalAddAnnotation", function() { return __experimentalAddAnnotation; }); 119 __webpack_require__.d(actions_namespaceObject, "__experimentalRemoveAnnotation", function() { return __experimentalRemoveAnnotation; }); 120 __webpack_require__.d(actions_namespaceObject, "__experimentalUpdateAnnotationRange", function() { return __experimentalUpdateAnnotationRange; }); 121 __webpack_require__.d(actions_namespaceObject, "__experimentalRemoveAnnotationsBySource", function() { return __experimentalRemoveAnnotationsBySource; }); 122 123 // EXTERNAL MODULE: external ["wp","richText"] 124 var external_wp_richText_ = __webpack_require__("qRz9"); 125 126 // EXTERNAL MODULE: external ["wp","i18n"] 127 var external_wp_i18n_ = __webpack_require__("l3Sj"); 128 129 // CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/store/constants.js 130 /** 131 * The identifier for the data store. 132 * 133 * @type {string} 134 */ 135 const STORE_NAME = 'core/annotations'; 136 137 // CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/format/annotation.js 138 /** 139 * WordPress dependencies 140 */ 141 142 143 const FORMAT_NAME = 'core/annotation'; 144 const ANNOTATION_ATTRIBUTE_PREFIX = 'annotation-text-'; 145 /** 146 * Internal dependencies 147 */ 148 149 150 /** 151 * Applies given annotations to the given record. 152 * 153 * @param {Object} record The record to apply annotations to. 154 * @param {Array} annotations The annotation to apply. 155 * @return {Object} A record with the annotations applied. 156 */ 157 158 function applyAnnotations(record, annotations = []) { 159 annotations.forEach(annotation => { 160 let { 161 start, 162 end 163 } = annotation; 164 165 if (start > record.text.length) { 166 start = record.text.length; 167 } 168 169 if (end > record.text.length) { 170 end = record.text.length; 171 } 172 173 const className = ANNOTATION_ATTRIBUTE_PREFIX + annotation.source; 174 const id = ANNOTATION_ATTRIBUTE_PREFIX + annotation.id; 175 record = Object(external_wp_richText_["applyFormat"])(record, { 176 type: FORMAT_NAME, 177 attributes: { 178 className, 179 id 180 } 181 }, start, end); 182 }); 183 return record; 184 } 185 /** 186 * Removes annotations from the given record. 187 * 188 * @param {Object} record Record to remove annotations from. 189 * @return {Object} The cleaned record. 190 */ 191 192 function removeAnnotations(record) { 193 return Object(external_wp_richText_["removeFormat"])(record, 'core/annotation', 0, record.text.length); 194 } 195 /** 196 * Retrieves the positions of annotations inside an array of formats. 197 * 198 * @param {Array} formats Formats with annotations in there. 199 * @return {Object} ID keyed positions of annotations. 200 */ 201 202 function retrieveAnnotationPositions(formats) { 203 const positions = {}; 204 formats.forEach((characterFormats, i) => { 205 characterFormats = characterFormats || []; 206 characterFormats = characterFormats.filter(format => format.type === FORMAT_NAME); 207 characterFormats.forEach(format => { 208 let { 209 id 210 } = format.attributes; 211 id = id.replace(ANNOTATION_ATTRIBUTE_PREFIX, ''); 212 213 if (!positions.hasOwnProperty(id)) { 214 positions[id] = { 215 start: i 216 }; 217 } // Annotations refer to positions between characters. 218 // Formats refer to the character themselves. 219 // So we need to adjust for that here. 220 221 222 positions[id].end = i + 1; 223 }); 224 }); 225 return positions; 226 } 227 /** 228 * Updates annotations in the state based on positions retrieved from RichText. 229 * 230 * @param {Array} annotations The annotations that are currently applied. 231 * @param {Array} positions The current positions of the given annotations. 232 * @param {Object} actions 233 * @param {Function} actions.removeAnnotation Function to remove an annotation from the state. 234 * @param {Function} actions.updateAnnotationRange Function to update an annotation range in the state. 235 */ 236 237 238 function updateAnnotationsWithPositions(annotations, positions, { 239 removeAnnotation, 240 updateAnnotationRange 241 }) { 242 annotations.forEach(currentAnnotation => { 243 const position = positions[currentAnnotation.id]; // If we cannot find an annotation, delete it. 244 245 if (!position) { 246 // Apparently the annotation has been removed, so remove it from the state: 247 // Remove... 248 removeAnnotation(currentAnnotation.id); 249 return; 250 } 251 252 const { 253 start, 254 end 255 } = currentAnnotation; 256 257 if (start !== position.start || end !== position.end) { 258 updateAnnotationRange(currentAnnotation.id, position.start, position.end); 259 } 260 }); 261 } 262 263 const annotation_annotation = { 264 name: FORMAT_NAME, 265 title: Object(external_wp_i18n_["__"])('Annotation'), 266 tagName: 'mark', 267 className: 'annotation-text', 268 attributes: { 269 className: 'class', 270 id: 'id' 271 }, 272 273 edit() { 274 return null; 275 }, 276 277 __experimentalGetPropsForEditableTreePreparation(select, { 278 richTextIdentifier, 279 blockClientId 280 }) { 281 return { 282 annotations: select(STORE_NAME).__experimentalGetAnnotationsForRichText(blockClientId, richTextIdentifier) 283 }; 284 }, 285 286 __experimentalCreatePrepareEditableTree({ 287 annotations 288 }) { 289 return (formats, text) => { 290 if (annotations.length === 0) { 291 return formats; 292 } 293 294 let record = { 295 formats, 296 text 297 }; 298 record = applyAnnotations(record, annotations); 299 return record.formats; 300 }; 301 }, 302 303 __experimentalGetPropsForEditableTreeChangeHandler(dispatch) { 304 return { 305 removeAnnotation: dispatch(STORE_NAME).__experimentalRemoveAnnotation, 306 updateAnnotationRange: dispatch(STORE_NAME).__experimentalUpdateAnnotationRange 307 }; 308 }, 309 310 __experimentalCreateOnChangeEditableValue(props) { 311 return formats => { 312 const positions = retrieveAnnotationPositions(formats); 313 const { 314 removeAnnotation, 315 updateAnnotationRange, 316 annotations 317 } = props; 318 updateAnnotationsWithPositions(annotations, positions, { 319 removeAnnotation, 320 updateAnnotationRange 321 }); 322 }; 323 } 324 325 }; 326 327 // CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/format/index.js 328 /** 329 * WordPress dependencies 330 */ 331 332 /** 333 * Internal dependencies 334 */ 335 336 337 const { 338 name: format_name, 339 ...settings 340 } = annotation_annotation; 341 Object(external_wp_richText_["registerFormatType"])(format_name, settings); 342 343 // EXTERNAL MODULE: external ["wp","hooks"] 344 var external_wp_hooks_ = __webpack_require__("g56x"); 345 346 // EXTERNAL MODULE: external ["wp","data"] 347 var external_wp_data_ = __webpack_require__("1ZqX"); 348 349 // CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/block/index.js 350 /** 351 * WordPress dependencies 352 */ 353 354 355 /** 356 * Internal dependencies 357 */ 358 359 360 /** 361 * Adds annotation className to the block-list-block component. 362 * 363 * @param {Object} OriginalComponent The original BlockListBlock component. 364 * @return {Object} The enhanced component. 365 */ 366 367 const addAnnotationClassName = OriginalComponent => { 368 return Object(external_wp_data_["withSelect"])((select, { 369 clientId, 370 className 371 }) => { 372 const annotations = select(STORE_NAME).__experimentalGetAnnotationsForBlock(clientId); 373 374 return { 375 className: annotations.map(annotation => { 376 return 'is-annotated-by-' + annotation.source; 377 }).concat(className).filter(Boolean).join(' ') 378 }; 379 })(OriginalComponent); 380 }; 381 382 Object(external_wp_hooks_["addFilter"])('editor.BlockListBlock', 'core/annotations', addAnnotationClassName); 383 384 // EXTERNAL MODULE: external "lodash" 385 var external_lodash_ = __webpack_require__("YLtl"); 386 387 // CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/store/reducer.js 388 /** 389 * External dependencies 390 */ 391 392 /** 393 * Filters an array based on the predicate, but keeps the reference the same if 394 * the array hasn't changed. 395 * 396 * @param {Array} collection The collection to filter. 397 * @param {Function} predicate Function that determines if the item should stay 398 * in the array. 399 * @return {Array} Filtered array. 400 */ 401 402 function filterWithReference(collection, predicate) { 403 const filteredCollection = collection.filter(predicate); 404 return collection.length === filteredCollection.length ? collection : filteredCollection; 405 } 406 /** 407 * Verifies whether the given annotations is a valid annotation. 408 * 409 * @param {Object} annotation The annotation to verify. 410 * @return {boolean} Whether the given annotation is valid. 411 */ 412 413 414 function isValidAnnotationRange(annotation) { 415 return Object(external_lodash_["isNumber"])(annotation.start) && Object(external_lodash_["isNumber"])(annotation.end) && annotation.start <= annotation.end; 416 } 417 /** 418 * Reducer managing annotations. 419 * 420 * @param {Object} state The annotations currently shown in the editor. 421 * @param {Object} action Dispatched action. 422 * 423 * @return {Array} Updated state. 424 */ 425 426 427 function reducer_annotations(state = {}, action) { 428 var _state$blockClientId; 429 430 switch (action.type) { 431 case 'ANNOTATION_ADD': 432 const blockClientId = action.blockClientId; 433 const newAnnotation = { 434 id: action.id, 435 blockClientId, 436 richTextIdentifier: action.richTextIdentifier, 437 source: action.source, 438 selector: action.selector, 439 range: action.range 440 }; 441 442 if (newAnnotation.selector === 'range' && !isValidAnnotationRange(newAnnotation.range)) { 443 return state; 444 } 445 446 const previousAnnotationsForBlock = (_state$blockClientId = state === null || state === void 0 ? void 0 : state[blockClientId]) !== null && _state$blockClientId !== void 0 ? _state$blockClientId : []; 447 return { ...state, 448 [blockClientId]: [...previousAnnotationsForBlock, newAnnotation] 449 }; 450 451 case 'ANNOTATION_REMOVE': 452 return Object(external_lodash_["mapValues"])(state, annotationsForBlock => { 453 return filterWithReference(annotationsForBlock, annotation => { 454 return annotation.id !== action.annotationId; 455 }); 456 }); 457 458 case 'ANNOTATION_UPDATE_RANGE': 459 return Object(external_lodash_["mapValues"])(state, annotationsForBlock => { 460 let hasChangedRange = false; 461 const newAnnotations = annotationsForBlock.map(annotation => { 462 if (annotation.id === action.annotationId) { 463 hasChangedRange = true; 464 return { ...annotation, 465 range: { 466 start: action.start, 467 end: action.end 468 } 469 }; 470 } 471 472 return annotation; 473 }); 474 return hasChangedRange ? newAnnotations : annotationsForBlock; 475 }); 476 477 case 'ANNOTATION_REMOVE_SOURCE': 478 return Object(external_lodash_["mapValues"])(state, annotationsForBlock => { 479 return filterWithReference(annotationsForBlock, annotation => { 480 return annotation.source !== action.source; 481 }); 482 }); 483 } 484 485 return state; 486 } 487 /* harmony default export */ var reducer = (reducer_annotations); 488 489 // EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js 490 var rememo = __webpack_require__("pPDe"); 491 492 // CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/store/selectors.js 493 /** 494 * External dependencies 495 */ 496 497 498 /** 499 * Shared reference to an empty array for cases where it is important to avoid 500 * returning a new array reference on every invocation, as in a connected or 501 * other pure component which performs `shouldComponentUpdate` check on props. 502 * This should be used as a last resort, since the normalized data should be 503 * maintained by the reducer result in state. 504 * 505 * @type {Array} 506 */ 507 508 const EMPTY_ARRAY = []; 509 /** 510 * Returns the annotations for a specific client ID. 511 * 512 * @param {Object} state Editor state. 513 * @param {string} clientId The ID of the block to get the annotations for. 514 * 515 * @return {Array} The annotations applicable to this block. 516 */ 517 518 const __experimentalGetAnnotationsForBlock = Object(rememo["a" /* default */])((state, blockClientId) => { 519 var _state$blockClientId; 520 521 return ((_state$blockClientId = state === null || state === void 0 ? void 0 : state[blockClientId]) !== null && _state$blockClientId !== void 0 ? _state$blockClientId : []).filter(annotation => { 522 return annotation.selector === 'block'; 523 }); 524 }, (state, blockClientId) => { 525 var _state$blockClientId2; 526 527 return [(_state$blockClientId2 = state === null || state === void 0 ? void 0 : state[blockClientId]) !== null && _state$blockClientId2 !== void 0 ? _state$blockClientId2 : EMPTY_ARRAY]; 528 }); 529 function __experimentalGetAllAnnotationsForBlock(state, blockClientId) { 530 var _state$blockClientId3; 531 532 return (_state$blockClientId3 = state === null || state === void 0 ? void 0 : state[blockClientId]) !== null && _state$blockClientId3 !== void 0 ? _state$blockClientId3 : EMPTY_ARRAY; 533 } 534 /** 535 * Returns the annotations that apply to the given RichText instance. 536 * 537 * Both a blockClientId and a richTextIdentifier are required. This is because 538 * a block might have multiple `RichText` components. This does mean that every 539 * block needs to implement annotations itself. 540 * 541 * @param {Object} state Editor state. 542 * @param {string} blockClientId The client ID for the block. 543 * @param {string} richTextIdentifier Unique identifier that identifies the given RichText. 544 * @return {Array} All the annotations relevant for the `RichText`. 545 */ 546 547 const __experimentalGetAnnotationsForRichText = Object(rememo["a" /* default */])((state, blockClientId, richTextIdentifier) => { 548 var _state$blockClientId4; 549 550 return ((_state$blockClientId4 = state === null || state === void 0 ? void 0 : state[blockClientId]) !== null && _state$blockClientId4 !== void 0 ? _state$blockClientId4 : []).filter(annotation => { 551 return annotation.selector === 'range' && richTextIdentifier === annotation.richTextIdentifier; 552 }).map(annotation => { 553 const { 554 range, 555 ...other 556 } = annotation; 557 return { ...range, 558 ...other 559 }; 560 }); 561 }, (state, blockClientId) => { 562 var _state$blockClientId5; 563 564 return [(_state$blockClientId5 = state === null || state === void 0 ? void 0 : state[blockClientId]) !== null && _state$blockClientId5 !== void 0 ? _state$blockClientId5 : EMPTY_ARRAY]; 565 }); 566 /** 567 * Returns all annotations in the editor state. 568 * 569 * @param {Object} state Editor state. 570 * @return {Array} All annotations currently applied. 571 */ 572 573 function __experimentalGetAnnotations(state) { 574 return Object(external_lodash_["flatMap"])(state, annotations => { 575 return annotations; 576 }); 577 } 578 579 // EXTERNAL MODULE: ./node_modules/uuid/dist/esm-browser/v4.js + 4 modules 580 var v4 = __webpack_require__("7Cbv"); 581 582 // CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/store/actions.js 583 /** 584 * External dependencies 585 */ 586 587 /** 588 * @typedef WPAnnotationRange 589 * 590 * @property {number} start The offset where the annotation should start. 591 * @property {number} end The offset where the annotation should end. 592 */ 593 594 /** 595 * Adds an annotation to a block. 596 * 597 * The `block` attribute refers to a block ID that needs to be annotated. 598 * `isBlockAnnotation` controls whether or not the annotation is a block 599 * annotation. The `source` is the source of the annotation, this will be used 600 * to identity groups of annotations. 601 * 602 * The `range` property is only relevant if the selector is 'range'. 603 * 604 * @param {Object} annotation The annotation to add. 605 * @param {string} annotation.blockClientId The blockClientId to add the annotation to. 606 * @param {string} annotation.richTextIdentifier Identifier for the RichText instance the annotation applies to. 607 * @param {WPAnnotationRange} annotation.range The range at which to apply this annotation. 608 * @param {string} [annotation.selector="range"] The way to apply this annotation. 609 * @param {string} [annotation.source="default"] The source that added the annotation. 610 * @param {string} [annotation.id] The ID the annotation should have. Generates a UUID by default. 611 * 612 * @return {Object} Action object. 613 */ 614 615 function __experimentalAddAnnotation({ 616 blockClientId, 617 richTextIdentifier = null, 618 range = null, 619 selector = 'range', 620 source = 'default', 621 id = Object(v4["a" /* default */])() 622 }) { 623 const action = { 624 type: 'ANNOTATION_ADD', 625 id, 626 blockClientId, 627 richTextIdentifier, 628 source, 629 selector 630 }; 631 632 if (selector === 'range') { 633 action.range = range; 634 } 635 636 return action; 637 } 638 /** 639 * Removes an annotation with a specific ID. 640 * 641 * @param {string} annotationId The annotation to remove. 642 * 643 * @return {Object} Action object. 644 */ 645 646 function __experimentalRemoveAnnotation(annotationId) { 647 return { 648 type: 'ANNOTATION_REMOVE', 649 annotationId 650 }; 651 } 652 /** 653 * Updates the range of an annotation. 654 * 655 * @param {string} annotationId ID of the annotation to update. 656 * @param {number} start The start of the new range. 657 * @param {number} end The end of the new range. 658 * 659 * @return {Object} Action object. 660 */ 661 662 function __experimentalUpdateAnnotationRange(annotationId, start, end) { 663 return { 664 type: 'ANNOTATION_UPDATE_RANGE', 665 annotationId, 666 start, 667 end 668 }; 669 } 670 /** 671 * Removes all annotations of a specific source. 672 * 673 * @param {string} source The source to remove. 674 * 675 * @return {Object} Action object. 676 */ 677 678 function __experimentalRemoveAnnotationsBySource(source) { 679 return { 680 type: 'ANNOTATION_REMOVE_SOURCE', 681 source 682 }; 683 } 684 685 // CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/store/index.js 686 /** 687 * WordPress dependencies 688 */ 689 690 /** 691 * Internal dependencies 692 */ 693 694 695 696 697 /** 698 * Module Constants 699 */ 700 701 702 /** 703 * Store definition for the annotations namespace. 704 * 705 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore 706 * 707 * @type {Object} 708 */ 709 710 const store = Object(external_wp_data_["createReduxStore"])(STORE_NAME, { 711 reducer: reducer, 712 selectors: selectors_namespaceObject, 713 actions: actions_namespaceObject 714 }); 715 Object(external_wp_data_["register"])(store); 716 717 // CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/index.js 718 /** 719 * Internal dependencies 720 */ 721 722 723 724 725 726 /***/ }), 727 728 /***/ "7Cbv": 729 /***/ (function(module, __webpack_exports__, __webpack_require__) { 730 731 "use strict"; 732 733 // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js 734 // Unique ID creation requires a high quality random # generator. In the browser we therefore 735 // require the crypto API and do not support built-in fallback to lower quality random number 736 // generators (like Math.random()). 737 var getRandomValues; 738 var rnds8 = new Uint8Array(16); 739 function rng() { 740 // lazy load so that environments that need to polyfill have a chance to do so 741 if (!getRandomValues) { 742 // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also, 743 // find the complete implementation of crypto (msCrypto) on IE11. 744 getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto); 745 746 if (!getRandomValues) { 747 throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported'); 748 } 749 } 750 751 return getRandomValues(rnds8); 752 } 753 // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/regex.js 754 /* harmony default export */ var regex = (/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i); 755 // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/validate.js 756 757 758 function validate(uuid) { 759 return typeof uuid === 'string' && regex.test(uuid); 760 } 761 762 /* harmony default export */ var esm_browser_validate = (validate); 763 // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js 764 765 /** 766 * Convert array of 16 byte values to UUID string format of the form: 767 * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX 768 */ 769 770 var byteToHex = []; 771 772 for (var stringify_i = 0; stringify_i < 256; ++stringify_i) { 773 byteToHex.push((stringify_i + 0x100).toString(16).substr(1)); 774 } 775 776 function stringify(arr) { 777 var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; 778 // Note: Be careful editing this code! It's been tuned for performance 779 // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 780 var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one 781 // of the following: 782 // - One or more input array values don't map to a hex octet (leading to 783 // "undefined" in the uuid) 784 // - Invalid input values for the RFC `version` or `variant` fields 785 786 if (!esm_browser_validate(uuid)) { 787 throw TypeError('Stringified UUID is invalid'); 788 } 789 790 return uuid; 791 } 792 793 /* harmony default export */ var esm_browser_stringify = (stringify); 794 // CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js 795 796 797 798 function v4(options, buf, offset) { 799 options = options || {}; 800 var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` 801 802 rnds[6] = rnds[6] & 0x0f | 0x40; 803 rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided 804 805 if (buf) { 806 offset = offset || 0; 807 808 for (var i = 0; i < 16; ++i) { 809 buf[offset + i] = rnds[i]; 810 } 811 812 return buf; 813 } 814 815 return esm_browser_stringify(rnds); 816 } 817 818 /* harmony default export */ var esm_browser_v4 = __webpack_exports__["a"] = (v4); 819 820 /***/ }), 821 822 /***/ "YLtl": 823 /***/ (function(module, exports) { 824 825 (function() { module.exports = window["lodash"]; }()); 826 827 /***/ }), 828 829 /***/ "g56x": 830 /***/ (function(module, exports) { 831 832 (function() { module.exports = window["wp"]["hooks"]; }()); 833 834 /***/ }), 835 836 /***/ "l3Sj": 837 /***/ (function(module, exports) { 838 839 (function() { module.exports = window["wp"]["i18n"]; }()); 840 841 /***/ }), 842 843 /***/ "pPDe": 844 /***/ (function(module, __webpack_exports__, __webpack_require__) { 845 846 "use strict"; 847 848 849 var LEAF_KEY, hasWeakMap; 850 851 /** 852 * Arbitrary value used as key for referencing cache object in WeakMap tree. 853 * 854 * @type {Object} 855 */ 856 LEAF_KEY = {}; 857 858 /** 859 * Whether environment supports WeakMap. 860 * 861 * @type {boolean} 862 */ 863 hasWeakMap = typeof WeakMap !== 'undefined'; 864 865 /** 866 * Returns the first argument as the sole entry in an array. 867 * 868 * @param {*} value Value to return. 869 * 870 * @return {Array} Value returned as entry in array. 871 */ 872 function arrayOf( value ) { 873 return [ value ]; 874 } 875 876 /** 877 * Returns true if the value passed is object-like, or false otherwise. A value 878 * is object-like if it can support property assignment, e.g. object or array. 879 * 880 * @param {*} value Value to test. 881 * 882 * @return {boolean} Whether value is object-like. 883 */ 884 function isObjectLike( value ) { 885 return !! value && 'object' === typeof value; 886 } 887 888 /** 889 * Creates and returns a new cache object. 890 * 891 * @return {Object} Cache object. 892 */ 893 function createCache() { 894 var cache = { 895 clear: function() { 896 cache.head = null; 897 }, 898 }; 899 900 return cache; 901 } 902 903 /** 904 * Returns true if entries within the two arrays are strictly equal by 905 * reference from a starting index. 906 * 907 * @param {Array} a First array. 908 * @param {Array} b Second array. 909 * @param {number} fromIndex Index from which to start comparison. 910 * 911 * @return {boolean} Whether arrays are shallowly equal. 912 */ 913 function isShallowEqual( a, b, fromIndex ) { 914 var i; 915 916 if ( a.length !== b.length ) { 917 return false; 918 } 919 920 for ( i = fromIndex; i < a.length; i++ ) { 921 if ( a[ i ] !== b[ i ] ) { 922 return false; 923 } 924 } 925 926 return true; 927 } 928 929 /** 930 * Returns a memoized selector function. The getDependants function argument is 931 * called before the memoized selector and is expected to return an immutable 932 * reference or array of references on which the selector depends for computing 933 * its own return value. The memoize cache is preserved only as long as those 934 * dependant references remain the same. If getDependants returns a different 935 * reference(s), the cache is cleared and the selector value regenerated. 936 * 937 * @param {Function} selector Selector function. 938 * @param {Function} getDependants Dependant getter returning an immutable 939 * reference or array of reference used in 940 * cache bust consideration. 941 * 942 * @return {Function} Memoized selector. 943 */ 944 /* harmony default export */ __webpack_exports__["a"] = (function( selector, getDependants ) { 945 var rootCache, getCache; 946 947 // Use object source as dependant if getter not provided 948 if ( ! getDependants ) { 949 getDependants = arrayOf; 950 } 951 952 /** 953 * Returns the root cache. If WeakMap is supported, this is assigned to the 954 * root WeakMap cache set, otherwise it is a shared instance of the default 955 * cache object. 956 * 957 * @return {(WeakMap|Object)} Root cache object. 958 */ 959 function getRootCache() { 960 return rootCache; 961 } 962 963 /** 964 * Returns the cache for a given dependants array. When possible, a WeakMap 965 * will be used to create a unique cache for each set of dependants. This 966 * is feasible due to the nature of WeakMap in allowing garbage collection 967 * to occur on entries where the key object is no longer referenced. Since 968 * WeakMap requires the key to be an object, this is only possible when the 969 * dependant is object-like. The root cache is created as a hierarchy where 970 * each top-level key is the first entry in a dependants set, the value a 971 * WeakMap where each key is the next dependant, and so on. This continues 972 * so long as the dependants are object-like. If no dependants are object- 973 * like, then the cache is shared across all invocations. 974 * 975 * @see isObjectLike 976 * 977 * @param {Array} dependants Selector dependants. 978 * 979 * @return {Object} Cache object. 980 */ 981 function getWeakMapCache( dependants ) { 982 var caches = rootCache, 983 isUniqueByDependants = true, 984 i, dependant, map, cache; 985 986 for ( i = 0; i < dependants.length; i++ ) { 987 dependant = dependants[ i ]; 988 989 // Can only compose WeakMap from object-like key. 990 if ( ! isObjectLike( dependant ) ) { 991 isUniqueByDependants = false; 992 break; 993 } 994 995 // Does current segment of cache already have a WeakMap? 996 if ( caches.has( dependant ) ) { 997 // Traverse into nested WeakMap. 998 caches = caches.get( dependant ); 999 } else { 1000 // Create, set, and traverse into a new one. 1001 map = new WeakMap(); 1002 caches.set( dependant, map ); 1003 caches = map; 1004 } 1005 } 1006 1007 // We use an arbitrary (but consistent) object as key for the last item 1008 // in the WeakMap to serve as our running cache. 1009 if ( ! caches.has( LEAF_KEY ) ) { 1010 cache = createCache(); 1011 cache.isUniqueByDependants = isUniqueByDependants; 1012 caches.set( LEAF_KEY, cache ); 1013 } 1014 1015 return caches.get( LEAF_KEY ); 1016 } 1017 1018 // Assign cache handler by availability of WeakMap 1019 getCache = hasWeakMap ? getWeakMapCache : getRootCache; 1020 1021 /** 1022 * Resets root memoization cache. 1023 */ 1024 function clear() { 1025 rootCache = hasWeakMap ? new WeakMap() : createCache(); 1026 } 1027 1028 // eslint-disable-next-line jsdoc/check-param-names 1029 /** 1030 * The augmented selector call, considering first whether dependants have 1031 * changed before passing it to underlying memoize function. 1032 * 1033 * @param {Object} source Source object for derivation. 1034 * @param {...*} extraArgs Additional arguments to pass to selector. 1035 * 1036 * @return {*} Selector result. 1037 */ 1038 function callSelector( /* source, ...extraArgs */ ) { 1039 var len = arguments.length, 1040 cache, node, i, args, dependants; 1041 1042 // Create copy of arguments (avoid leaking deoptimization). 1043 args = new Array( len ); 1044 for ( i = 0; i < len; i++ ) { 1045 args[ i ] = arguments[ i ]; 1046 } 1047 1048 dependants = getDependants.apply( null, args ); 1049 cache = getCache( dependants ); 1050 1051 // If not guaranteed uniqueness by dependants (primitive type or lack 1052 // of WeakMap support), shallow compare against last dependants and, if 1053 // references have changed, destroy cache to recalculate result. 1054 if ( ! cache.isUniqueByDependants ) { 1055 if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) { 1056 cache.clear(); 1057 } 1058 1059 cache.lastDependants = dependants; 1060 } 1061 1062 node = cache.head; 1063 while ( node ) { 1064 // Check whether node arguments match arguments 1065 if ( ! isShallowEqual( node.args, args, 1 ) ) { 1066 node = node.next; 1067 continue; 1068 } 1069 1070 // At this point we can assume we've found a match 1071 1072 // Surface matched node to head if not already 1073 if ( node !== cache.head ) { 1074 // Adjust siblings to point to each other. 1075 node.prev.next = node.next; 1076 if ( node.next ) { 1077 node.next.prev = node.prev; 1078 } 1079 1080 node.next = cache.head; 1081 node.prev = null; 1082 cache.head.prev = node; 1083 cache.head = node; 1084 } 1085 1086 // Return immediately 1087 return node.val; 1088 } 1089 1090 // No cached value found. Continue to insertion phase: 1091 1092 node = { 1093 // Generate the result from original function 1094 val: selector.apply( null, args ), 1095 }; 1096 1097 // Avoid including the source object in the cache. 1098 args[ 0 ] = null; 1099 node.args = args; 1100 1101 // Don't need to check whether node is already head, since it would 1102 // have been returned above already if it was 1103 1104 // Shift existing head down list 1105 if ( cache.head ) { 1106 cache.head.prev = node; 1107 node.next = cache.head; 1108 } 1109 1110 cache.head = node; 1111 1112 return node.val; 1113 } 1114 1115 callSelector.getDependants = getDependants; 1116 callSelector.clear = clear; 1117 clear(); 1118 1119 return callSelector; 1120 }); 1121 1122 1123 /***/ }), 1124 1125 /***/ "qRz9": 1126 /***/ (function(module, exports) { 1127 1128 (function() { module.exports = window["wp"]["richText"]; }()); 1129 1130 /***/ }) 1131 1132 /******/ });