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


Generated: Thu Jan 23 01:00:04 2020 Cross-referenced by PHPXref 0.7.1