[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

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