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


Generated : Sat Dec 21 08:20:01 2024 Cross-referenced by PHPXref