[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

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

   1  /******/ (() => { // webpackBootstrap
   2  /******/     "use strict";
   3  /******/     // The require scope
   4  /******/     var __webpack_require__ = {};
   5  /******/     
   6  /************************************************************************/
   7  /******/     /* webpack/runtime/define property getters */
   8  /******/     (() => {
   9  /******/         // define getter functions for harmony exports
  10  /******/         __webpack_require__.d = (exports, definition) => {
  11  /******/             for(var key in definition) {
  12  /******/                 if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  13  /******/                     Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  14  /******/                 }
  15  /******/             }
  16  /******/         };
  17  /******/     })();
  18  /******/     
  19  /******/     /* webpack/runtime/hasOwnProperty shorthand */
  20  /******/     (() => {
  21  /******/         __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  22  /******/     })();
  23  /******/     
  24  /******/     /* webpack/runtime/make namespace object */
  25  /******/     (() => {
  26  /******/         // define __esModule on exports
  27  /******/         __webpack_require__.r = (exports) => {
  28  /******/             if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  29  /******/                 Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  30  /******/             }
  31  /******/             Object.defineProperty(exports, '__esModule', { value: true });
  32  /******/         };
  33  /******/     })();
  34  /******/     
  35  /************************************************************************/
  36  var __webpack_exports__ = {};
  37  // ESM COMPAT FLAG
  38  __webpack_require__.r(__webpack_exports__);
  39  
  40  // EXPORTS
  41  __webpack_require__.d(__webpack_exports__, {
  42    store: () => (/* reexport */ store)
  43  });
  44  
  45  // NAMESPACE OBJECT: ./node_modules/@wordpress/annotations/build-module/store/selectors.js
  46  var selectors_namespaceObject = {};
  47  __webpack_require__.r(selectors_namespaceObject);
  48  __webpack_require__.d(selectors_namespaceObject, {
  49    __experimentalGetAllAnnotationsForBlock: () => (__experimentalGetAllAnnotationsForBlock),
  50    __experimentalGetAnnotations: () => (__experimentalGetAnnotations),
  51    __experimentalGetAnnotationsForBlock: () => (__experimentalGetAnnotationsForBlock),
  52    __experimentalGetAnnotationsForRichText: () => (__experimentalGetAnnotationsForRichText)
  53  });
  54  
  55  // NAMESPACE OBJECT: ./node_modules/@wordpress/annotations/build-module/store/actions.js
  56  var actions_namespaceObject = {};
  57  __webpack_require__.r(actions_namespaceObject);
  58  __webpack_require__.d(actions_namespaceObject, {
  59    __experimentalAddAnnotation: () => (__experimentalAddAnnotation),
  60    __experimentalRemoveAnnotation: () => (__experimentalRemoveAnnotation),
  61    __experimentalRemoveAnnotationsBySource: () => (__experimentalRemoveAnnotationsBySource),
  62    __experimentalUpdateAnnotationRange: () => (__experimentalUpdateAnnotationRange)
  63  });
  64  
  65  ;// external ["wp","richText"]
  66  const external_wp_richText_namespaceObject = window["wp"]["richText"];
  67  ;// external ["wp","i18n"]
  68  const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
  69  ;// ./node_modules/@wordpress/annotations/build-module/store/constants.js
  70  /**
  71   * The identifier for the data store.
  72   *
  73   * @type {string}
  74   */
  75  const STORE_NAME = 'core/annotations';
  76  
  77  ;// ./node_modules/@wordpress/annotations/build-module/format/annotation.js
  78  /* wp:polyfill */
  79  /**
  80   * WordPress dependencies
  81   */
  82  
  83  
  84  const FORMAT_NAME = 'core/annotation';
  85  const ANNOTATION_ATTRIBUTE_PREFIX = 'annotation-text-';
  86  /**
  87   * Internal dependencies
  88   */
  89  
  90  
  91  /**
  92   * Applies given annotations to the given record.
  93   *
  94   * @param {Object} record      The record to apply annotations to.
  95   * @param {Array}  annotations The annotation to apply.
  96   * @return {Object} A record with the annotations applied.
  97   */
  98  function applyAnnotations(record, annotations = []) {
  99    annotations.forEach(annotation => {
 100      let {
 101        start,
 102        end
 103      } = annotation;
 104      if (start > record.text.length) {
 105        start = record.text.length;
 106      }
 107      if (end > record.text.length) {
 108        end = record.text.length;
 109      }
 110      const className = ANNOTATION_ATTRIBUTE_PREFIX + annotation.source;
 111      const id = ANNOTATION_ATTRIBUTE_PREFIX + annotation.id;
 112      record = (0,external_wp_richText_namespaceObject.applyFormat)(record, {
 113        type: FORMAT_NAME,
 114        attributes: {
 115          className,
 116          id
 117        }
 118      }, start, end);
 119    });
 120    return record;
 121  }
 122  
 123  /**
 124   * Removes annotations from the given record.
 125   *
 126   * @param {Object} record Record to remove annotations from.
 127   * @return {Object} The cleaned record.
 128   */
 129  function removeAnnotations(record) {
 130    return removeFormat(record, 'core/annotation', 0, record.text.length);
 131  }
 132  
 133  /**
 134   * Retrieves the positions of annotations inside an array of formats.
 135   *
 136   * @param {Array} formats Formats with annotations in there.
 137   * @return {Object} ID keyed positions of annotations.
 138   */
 139  function retrieveAnnotationPositions(formats) {
 140    const positions = {};
 141    formats.forEach((characterFormats, i) => {
 142      characterFormats = characterFormats || [];
 143      characterFormats = characterFormats.filter(format => format.type === FORMAT_NAME);
 144      characterFormats.forEach(format => {
 145        let {
 146          id
 147        } = format.attributes;
 148        id = id.replace(ANNOTATION_ATTRIBUTE_PREFIX, '');
 149        if (!positions.hasOwnProperty(id)) {
 150          positions[id] = {
 151            start: i
 152          };
 153        }
 154  
 155        // Annotations refer to positions between characters.
 156        // Formats refer to the character themselves.
 157        // So we need to adjust for that here.
 158        positions[id].end = i + 1;
 159      });
 160    });
 161    return positions;
 162  }
 163  
 164  /**
 165   * Updates annotations in the state based on positions retrieved from RichText.
 166   *
 167   * @param {Array}    annotations                   The annotations that are currently applied.
 168   * @param {Array}    positions                     The current positions of the given annotations.
 169   * @param {Object}   actions
 170   * @param {Function} actions.removeAnnotation      Function to remove an annotation from the state.
 171   * @param {Function} actions.updateAnnotationRange Function to update an annotation range in the state.
 172   */
 173  function updateAnnotationsWithPositions(annotations, positions, {
 174    removeAnnotation,
 175    updateAnnotationRange
 176  }) {
 177    annotations.forEach(currentAnnotation => {
 178      const position = positions[currentAnnotation.id];
 179      // If we cannot find an annotation, delete it.
 180      if (!position) {
 181        // Apparently the annotation has been removed, so remove it from the state:
 182        // Remove...
 183        removeAnnotation(currentAnnotation.id);
 184        return;
 185      }
 186      const {
 187        start,
 188        end
 189      } = currentAnnotation;
 190      if (start !== position.start || end !== position.end) {
 191        updateAnnotationRange(currentAnnotation.id, position.start, position.end);
 192      }
 193    });
 194  }
 195  const annotation = {
 196    name: FORMAT_NAME,
 197    title: (0,external_wp_i18n_namespaceObject.__)('Annotation'),
 198    tagName: 'mark',
 199    className: 'annotation-text',
 200    attributes: {
 201      className: 'class',
 202      id: 'id'
 203    },
 204    edit() {
 205      return null;
 206    },
 207    __experimentalGetPropsForEditableTreePreparation(select, {
 208      richTextIdentifier,
 209      blockClientId
 210    }) {
 211      return {
 212        annotations: select(STORE_NAME).__experimentalGetAnnotationsForRichText(blockClientId, richTextIdentifier)
 213      };
 214    },
 215    __experimentalCreatePrepareEditableTree({
 216      annotations
 217    }) {
 218      return (formats, text) => {
 219        if (annotations.length === 0) {
 220          return formats;
 221        }
 222        let record = {
 223          formats,
 224          text
 225        };
 226        record = applyAnnotations(record, annotations);
 227        return record.formats;
 228      };
 229    },
 230    __experimentalGetPropsForEditableTreeChangeHandler(dispatch) {
 231      return {
 232        removeAnnotation: dispatch(STORE_NAME).__experimentalRemoveAnnotation,
 233        updateAnnotationRange: dispatch(STORE_NAME).__experimentalUpdateAnnotationRange
 234      };
 235    },
 236    __experimentalCreateOnChangeEditableValue(props) {
 237      return formats => {
 238        const positions = retrieveAnnotationPositions(formats);
 239        const {
 240          removeAnnotation,
 241          updateAnnotationRange,
 242          annotations
 243        } = props;
 244        updateAnnotationsWithPositions(annotations, positions, {
 245          removeAnnotation,
 246          updateAnnotationRange
 247        });
 248      };
 249    }
 250  };
 251  
 252  ;// ./node_modules/@wordpress/annotations/build-module/format/index.js
 253  /**
 254   * WordPress dependencies
 255   */
 256  
 257  
 258  /**
 259   * Internal dependencies
 260   */
 261  
 262  const {
 263    name: format_name,
 264    ...settings
 265  } = annotation;
 266  (0,external_wp_richText_namespaceObject.registerFormatType)(format_name, settings);
 267  
 268  ;// external ["wp","hooks"]
 269  const external_wp_hooks_namespaceObject = window["wp"]["hooks"];
 270  ;// external ["wp","data"]
 271  const external_wp_data_namespaceObject = window["wp"]["data"];
 272  ;// ./node_modules/@wordpress/annotations/build-module/block/index.js
 273  /* wp:polyfill */
 274  /**
 275   * WordPress dependencies
 276   */
 277  
 278  
 279  
 280  /**
 281   * Internal dependencies
 282   */
 283  
 284  /**
 285   * Adds annotation className to the block-list-block component.
 286   *
 287   * @param {Object} OriginalComponent The original BlockListBlock component.
 288   * @return {Object} The enhanced component.
 289   */
 290  const addAnnotationClassName = OriginalComponent => {
 291    return (0,external_wp_data_namespaceObject.withSelect)((select, {
 292      clientId,
 293      className
 294    }) => {
 295      const annotations = select(STORE_NAME).__experimentalGetAnnotationsForBlock(clientId);
 296      return {
 297        className: annotations.map(annotation => {
 298          return 'is-annotated-by-' + annotation.source;
 299        }).concat(className).filter(Boolean).join(' ')
 300      };
 301    })(OriginalComponent);
 302  };
 303  (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/annotations', addAnnotationClassName);
 304  
 305  ;// ./node_modules/@wordpress/annotations/build-module/store/reducer.js
 306  /* wp:polyfill */
 307  /**
 308   * Filters an array based on the predicate, but keeps the reference the same if
 309   * the array hasn't changed.
 310   *
 311   * @param {Array}    collection The collection to filter.
 312   * @param {Function} predicate  Function that determines if the item should stay
 313   *                              in the array.
 314   * @return {Array} Filtered array.
 315   */
 316  function filterWithReference(collection, predicate) {
 317    const filteredCollection = collection.filter(predicate);
 318    return collection.length === filteredCollection.length ? collection : filteredCollection;
 319  }
 320  
 321  /**
 322   * Creates a new object with the same keys, but with `callback()` called as
 323   * a transformer function on each of the values.
 324   *
 325   * @param {Object}   obj      The object to transform.
 326   * @param {Function} callback The function to transform each object value.
 327   * @return {Array} Transformed object.
 328   */
 329  const mapValues = (obj, callback) => Object.entries(obj).reduce((acc, [key, value]) => ({
 330    ...acc,
 331    [key]: callback(value)
 332  }), {});
 333  
 334  /**
 335   * Verifies whether the given annotations is a valid annotation.
 336   *
 337   * @param {Object} annotation The annotation to verify.
 338   * @return {boolean} Whether the given annotation is valid.
 339   */
 340  function isValidAnnotationRange(annotation) {
 341    return typeof annotation.start === 'number' && typeof annotation.end === 'number' && annotation.start <= annotation.end;
 342  }
 343  
 344  /**
 345   * Reducer managing annotations.
 346   *
 347   * @param {Object} state  The annotations currently shown in the editor.
 348   * @param {Object} action Dispatched action.
 349   *
 350   * @return {Array} Updated state.
 351   */
 352  function annotations(state = {}, action) {
 353    var _state$blockClientId;
 354    switch (action.type) {
 355      case 'ANNOTATION_ADD':
 356        const blockClientId = action.blockClientId;
 357        const newAnnotation = {
 358          id: action.id,
 359          blockClientId,
 360          richTextIdentifier: action.richTextIdentifier,
 361          source: action.source,
 362          selector: action.selector,
 363          range: action.range
 364        };
 365        if (newAnnotation.selector === 'range' && !isValidAnnotationRange(newAnnotation.range)) {
 366          return state;
 367        }
 368        const previousAnnotationsForBlock = (_state$blockClientId = state?.[blockClientId]) !== null && _state$blockClientId !== void 0 ? _state$blockClientId : [];
 369        return {
 370          ...state,
 371          [blockClientId]: [...previousAnnotationsForBlock, newAnnotation]
 372        };
 373      case 'ANNOTATION_REMOVE':
 374        return mapValues(state, annotationsForBlock => {
 375          return filterWithReference(annotationsForBlock, annotation => {
 376            return annotation.id !== action.annotationId;
 377          });
 378        });
 379      case 'ANNOTATION_UPDATE_RANGE':
 380        return mapValues(state, annotationsForBlock => {
 381          let hasChangedRange = false;
 382          const newAnnotations = annotationsForBlock.map(annotation => {
 383            if (annotation.id === action.annotationId) {
 384              hasChangedRange = true;
 385              return {
 386                ...annotation,
 387                range: {
 388                  start: action.start,
 389                  end: action.end
 390                }
 391              };
 392            }
 393            return annotation;
 394          });
 395          return hasChangedRange ? newAnnotations : annotationsForBlock;
 396        });
 397      case 'ANNOTATION_REMOVE_SOURCE':
 398        return mapValues(state, annotationsForBlock => {
 399          return filterWithReference(annotationsForBlock, annotation => {
 400            return annotation.source !== action.source;
 401          });
 402        });
 403    }
 404    return state;
 405  }
 406  /* harmony default export */ const reducer = (annotations);
 407  
 408  ;// ./node_modules/@wordpress/annotations/build-module/store/selectors.js
 409  /* wp:polyfill */
 410  /**
 411   * WordPress dependencies
 412   */
 413  
 414  
 415  /**
 416   * Shared reference to an empty array for cases where it is important to avoid
 417   * returning a new array reference on every invocation, as in a connected or
 418   * other pure component which performs `shouldComponentUpdate` check on props.
 419   * This should be used as a last resort, since the normalized data should be
 420   * maintained by the reducer result in state.
 421   *
 422   * @type {Array}
 423   */
 424  const EMPTY_ARRAY = [];
 425  
 426  /**
 427   * Returns the annotations for a specific client ID.
 428   *
 429   * @param {Object} state    Editor state.
 430   * @param {string} clientId The ID of the block to get the annotations for.
 431   *
 432   * @return {Array} The annotations applicable to this block.
 433   */
 434  const __experimentalGetAnnotationsForBlock = (0,external_wp_data_namespaceObject.createSelector)((state, blockClientId) => {
 435    var _state$blockClientId;
 436    return ((_state$blockClientId = state?.[blockClientId]) !== null && _state$blockClientId !== void 0 ? _state$blockClientId : []).filter(annotation => {
 437      return annotation.selector === 'block';
 438    });
 439  }, (state, blockClientId) => {
 440    var _state$blockClientId2;
 441    return [(_state$blockClientId2 = state?.[blockClientId]) !== null && _state$blockClientId2 !== void 0 ? _state$blockClientId2 : EMPTY_ARRAY];
 442  });
 443  function __experimentalGetAllAnnotationsForBlock(state, blockClientId) {
 444    var _state$blockClientId3;
 445    return (_state$blockClientId3 = state?.[blockClientId]) !== null && _state$blockClientId3 !== void 0 ? _state$blockClientId3 : EMPTY_ARRAY;
 446  }
 447  
 448  /**
 449   * Returns the annotations that apply to the given RichText instance.
 450   *
 451   * Both a blockClientId and a richTextIdentifier are required. This is because
 452   * a block might have multiple `RichText` components. This does mean that every
 453   * block needs to implement annotations itself.
 454   *
 455   * @param {Object} state              Editor state.
 456   * @param {string} blockClientId      The client ID for the block.
 457   * @param {string} richTextIdentifier Unique identifier that identifies the given RichText.
 458   * @return {Array} All the annotations relevant for the `RichText`.
 459   */
 460  const __experimentalGetAnnotationsForRichText = (0,external_wp_data_namespaceObject.createSelector)((state, blockClientId, richTextIdentifier) => {
 461    var _state$blockClientId4;
 462    return ((_state$blockClientId4 = state?.[blockClientId]) !== null && _state$blockClientId4 !== void 0 ? _state$blockClientId4 : []).filter(annotation => {
 463      return annotation.selector === 'range' && richTextIdentifier === annotation.richTextIdentifier;
 464    }).map(annotation => {
 465      const {
 466        range,
 467        ...other
 468      } = annotation;
 469      return {
 470        ...range,
 471        ...other
 472      };
 473    });
 474  }, (state, blockClientId) => {
 475    var _state$blockClientId5;
 476    return [(_state$blockClientId5 = state?.[blockClientId]) !== null && _state$blockClientId5 !== void 0 ? _state$blockClientId5 : EMPTY_ARRAY];
 477  });
 478  
 479  /**
 480   * Returns all annotations in the editor state.
 481   *
 482   * @param {Object} state Editor state.
 483   * @return {Array} All annotations currently applied.
 484   */
 485  function __experimentalGetAnnotations(state) {
 486    return Object.values(state).flat();
 487  }
 488  
 489  ;// ./node_modules/@wordpress/annotations/node_modules/uuid/dist/esm-browser/native.js
 490  const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
 491  /* harmony default export */ const esm_browser_native = ({
 492    randomUUID
 493  });
 494  ;// ./node_modules/@wordpress/annotations/node_modules/uuid/dist/esm-browser/rng.js
 495  // Unique ID creation requires a high quality random # generator. In the browser we therefore
 496  // require the crypto API and do not support built-in fallback to lower quality random number
 497  // generators (like Math.random()).
 498  let getRandomValues;
 499  const rnds8 = new Uint8Array(16);
 500  function rng() {
 501    // lazy load so that environments that need to polyfill have a chance to do so
 502    if (!getRandomValues) {
 503      // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
 504      getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
 505  
 506      if (!getRandomValues) {
 507        throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
 508      }
 509    }
 510  
 511    return getRandomValues(rnds8);
 512  }
 513  ;// ./node_modules/@wordpress/annotations/node_modules/uuid/dist/esm-browser/stringify.js
 514  
 515  /**
 516   * Convert array of 16 byte values to UUID string format of the form:
 517   * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
 518   */
 519  
 520  const byteToHex = [];
 521  
 522  for (let i = 0; i < 256; ++i) {
 523    byteToHex.push((i + 0x100).toString(16).slice(1));
 524  }
 525  
 526  function unsafeStringify(arr, offset = 0) {
 527    // Note: Be careful editing this code!  It's been tuned for performance
 528    // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
 529    return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
 530  }
 531  
 532  function stringify(arr, offset = 0) {
 533    const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID.  If this throws, it's likely due to one
 534    // of the following:
 535    // - One or more input array values don't map to a hex octet (leading to
 536    // "undefined" in the uuid)
 537    // - Invalid input values for the RFC `version` or `variant` fields
 538  
 539    if (!validate(uuid)) {
 540      throw TypeError('Stringified UUID is invalid');
 541    }
 542  
 543    return uuid;
 544  }
 545  
 546  /* harmony default export */ const esm_browser_stringify = ((/* unused pure expression or super */ null && (stringify)));
 547  ;// ./node_modules/@wordpress/annotations/node_modules/uuid/dist/esm-browser/v4.js
 548  
 549  
 550  
 551  
 552  function v4(options, buf, offset) {
 553    if (esm_browser_native.randomUUID && !buf && !options) {
 554      return esm_browser_native.randomUUID();
 555    }
 556  
 557    options = options || {};
 558    const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
 559  
 560    rnds[6] = rnds[6] & 0x0f | 0x40;
 561    rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
 562  
 563    if (buf) {
 564      offset = offset || 0;
 565  
 566      for (let i = 0; i < 16; ++i) {
 567        buf[offset + i] = rnds[i];
 568      }
 569  
 570      return buf;
 571    }
 572  
 573    return unsafeStringify(rnds);
 574  }
 575  
 576  /* harmony default export */ const esm_browser_v4 = (v4);
 577  ;// ./node_modules/@wordpress/annotations/build-module/store/actions.js
 578  /**
 579   * External dependencies
 580   */
 581  
 582  
 583  /**
 584   * @typedef WPAnnotationRange
 585   *
 586   * @property {number} start The offset where the annotation should start.
 587   * @property {number} end   The offset where the annotation should end.
 588   */
 589  
 590  /**
 591   * Adds an annotation to a block.
 592   *
 593   * The `block` attribute refers to a block ID that needs to be annotated.
 594   * `isBlockAnnotation` controls whether or not the annotation is a block
 595   * annotation. The `source` is the source of the annotation, this will be used
 596   * to identity groups of annotations.
 597   *
 598   * The `range` property is only relevant if the selector is 'range'.
 599   *
 600   * @param {Object}            annotation                    The annotation to add.
 601   * @param {string}            annotation.blockClientId      The blockClientId to add the annotation to.
 602   * @param {string}            annotation.richTextIdentifier Identifier for the RichText instance the annotation applies to.
 603   * @param {WPAnnotationRange} annotation.range              The range at which to apply this annotation.
 604   * @param {string}            [annotation.selector="range"] The way to apply this annotation.
 605   * @param {string}            [annotation.source="default"] The source that added the annotation.
 606   * @param {string}            [annotation.id]               The ID the annotation should have. Generates a UUID by default.
 607   *
 608   * @return {Object} Action object.
 609   */
 610  function __experimentalAddAnnotation({
 611    blockClientId,
 612    richTextIdentifier = null,
 613    range = null,
 614    selector = 'range',
 615    source = 'default',
 616    id = esm_browser_v4()
 617  }) {
 618    const action = {
 619      type: 'ANNOTATION_ADD',
 620      id,
 621      blockClientId,
 622      richTextIdentifier,
 623      source,
 624      selector
 625    };
 626    if (selector === 'range') {
 627      action.range = range;
 628    }
 629    return action;
 630  }
 631  
 632  /**
 633   * Removes an annotation with a specific ID.
 634   *
 635   * @param {string} annotationId The annotation to remove.
 636   *
 637   * @return {Object} Action object.
 638   */
 639  function __experimentalRemoveAnnotation(annotationId) {
 640    return {
 641      type: 'ANNOTATION_REMOVE',
 642      annotationId
 643    };
 644  }
 645  
 646  /**
 647   * Updates the range of an annotation.
 648   *
 649   * @param {string} annotationId ID of the annotation to update.
 650   * @param {number} start        The start of the new range.
 651   * @param {number} end          The end of the new range.
 652   *
 653   * @return {Object} Action object.
 654   */
 655  function __experimentalUpdateAnnotationRange(annotationId, start, end) {
 656    return {
 657      type: 'ANNOTATION_UPDATE_RANGE',
 658      annotationId,
 659      start,
 660      end
 661    };
 662  }
 663  
 664  /**
 665   * Removes all annotations of a specific source.
 666   *
 667   * @param {string} source The source to remove.
 668   *
 669   * @return {Object} Action object.
 670   */
 671  function __experimentalRemoveAnnotationsBySource(source) {
 672    return {
 673      type: 'ANNOTATION_REMOVE_SOURCE',
 674      source
 675    };
 676  }
 677  
 678  ;// ./node_modules/@wordpress/annotations/build-module/store/index.js
 679  /**
 680   * WordPress dependencies
 681   */
 682  
 683  
 684  /**
 685   * Internal dependencies
 686   */
 687  
 688  
 689  
 690  
 691  /**
 692   * Module Constants
 693   */
 694  
 695  
 696  /**
 697   * Store definition for the annotations namespace.
 698   *
 699   * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
 700   *
 701   * @type {Object}
 702   */
 703  const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
 704    reducer: reducer,
 705    selectors: selectors_namespaceObject,
 706    actions: actions_namespaceObject
 707  });
 708  (0,external_wp_data_namespaceObject.register)(store);
 709  
 710  ;// ./node_modules/@wordpress/annotations/build-module/index.js
 711  /**
 712   * Internal dependencies
 713   */
 714  
 715  
 716  
 717  
 718  (window.wp = window.wp || {}).annotations = __webpack_exports__;
 719  /******/ })()
 720  ;


Generated : Sat Feb 22 08:20:01 2025 Cross-referenced by PHPXref