[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/js/dist/ -> annotations.js (source)

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


Generated: Sun Sep 22 01:00:03 2019 Cross-referenced by PHPXref 0.7.1