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