[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
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 ;// CONCATENATED MODULE: external ["wp","richText"] 66 const external_wp_richText_namespaceObject = window["wp"]["richText"]; 67 ;// CONCATENATED MODULE: external ["wp","i18n"] 68 const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; 69 ;// CONCATENATED MODULE: ./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 ;// CONCATENATED MODULE: ./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 ;// CONCATENATED MODULE: ./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 ;// CONCATENATED MODULE: external ["wp","hooks"] 268 const external_wp_hooks_namespaceObject = window["wp"]["hooks"]; 269 ;// CONCATENATED MODULE: external ["wp","data"] 270 const external_wp_data_namespaceObject = window["wp"]["data"]; 271 ;// CONCATENATED MODULE: ./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 ;// CONCATENATED MODULE: ./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 ;// CONCATENATED MODULE: ./node_modules/rememo/rememo.js 406 407 408 /** @typedef {(...args: any[]) => *[]} GetDependants */ 409 410 /** @typedef {() => void} Clear */ 411 412 /** 413 * @typedef {{ 414 * getDependants: GetDependants, 415 * clear: Clear 416 * }} EnhancedSelector 417 */ 418 419 /** 420 * Internal cache entry. 421 * 422 * @typedef CacheNode 423 * 424 * @property {?CacheNode|undefined} [prev] Previous node. 425 * @property {?CacheNode|undefined} [next] Next node. 426 * @property {*[]} args Function arguments for cache entry. 427 * @property {*} val Function result. 428 */ 429 430 /** 431 * @typedef Cache 432 * 433 * @property {Clear} clear Function to clear cache. 434 * @property {boolean} [isUniqueByDependants] Whether dependants are valid in 435 * considering cache uniqueness. A cache is unique if dependents are all arrays 436 * or objects. 437 * @property {CacheNode?} [head] Cache head. 438 * @property {*[]} [lastDependants] Dependants from previous invocation. 439 */ 440 441 /** 442 * Arbitrary value used as key for referencing cache object in WeakMap tree. 443 * 444 * @type {{}} 445 */ 446 var LEAF_KEY = {}; 447 448 /** 449 * Returns the first argument as the sole entry in an array. 450 * 451 * @template T 452 * 453 * @param {T} value Value to return. 454 * 455 * @return {[T]} Value returned as entry in array. 456 */ 457 function arrayOf(value) { 458 return [value]; 459 } 460 461 /** 462 * Returns true if the value passed is object-like, or false otherwise. A value 463 * is object-like if it can support property assignment, e.g. object or array. 464 * 465 * @param {*} value Value to test. 466 * 467 * @return {boolean} Whether value is object-like. 468 */ 469 function isObjectLike(value) { 470 return !!value && 'object' === typeof value; 471 } 472 473 /** 474 * Creates and returns a new cache object. 475 * 476 * @return {Cache} Cache object. 477 */ 478 function createCache() { 479 /** @type {Cache} */ 480 var cache = { 481 clear: function () { 482 cache.head = null; 483 }, 484 }; 485 486 return cache; 487 } 488 489 /** 490 * Returns true if entries within the two arrays are strictly equal by 491 * reference from a starting index. 492 * 493 * @param {*[]} a First array. 494 * @param {*[]} b Second array. 495 * @param {number} fromIndex Index from which to start comparison. 496 * 497 * @return {boolean} Whether arrays are shallowly equal. 498 */ 499 function isShallowEqual(a, b, fromIndex) { 500 var i; 501 502 if (a.length !== b.length) { 503 return false; 504 } 505 506 for (i = fromIndex; i < a.length; i++) { 507 if (a[i] !== b[i]) { 508 return false; 509 } 510 } 511 512 return true; 513 } 514 515 /** 516 * Returns a memoized selector function. The getDependants function argument is 517 * called before the memoized selector and is expected to return an immutable 518 * reference or array of references on which the selector depends for computing 519 * its own return value. The memoize cache is preserved only as long as those 520 * dependant references remain the same. If getDependants returns a different 521 * reference(s), the cache is cleared and the selector value regenerated. 522 * 523 * @template {(...args: *[]) => *} S 524 * 525 * @param {S} selector Selector function. 526 * @param {GetDependants=} getDependants Dependant getter returning an array of 527 * references used in cache bust consideration. 528 */ 529 /* harmony default export */ function rememo(selector, getDependants) { 530 /** @type {WeakMap<*,*>} */ 531 var rootCache; 532 533 /** @type {GetDependants} */ 534 var normalizedGetDependants = getDependants ? getDependants : arrayOf; 535 536 /** 537 * Returns the cache for a given dependants array. When possible, a WeakMap 538 * will be used to create a unique cache for each set of dependants. This 539 * is feasible due to the nature of WeakMap in allowing garbage collection 540 * to occur on entries where the key object is no longer referenced. Since 541 * WeakMap requires the key to be an object, this is only possible when the 542 * dependant is object-like. The root cache is created as a hierarchy where 543 * each top-level key is the first entry in a dependants set, the value a 544 * WeakMap where each key is the next dependant, and so on. This continues 545 * so long as the dependants are object-like. If no dependants are object- 546 * like, then the cache is shared across all invocations. 547 * 548 * @see isObjectLike 549 * 550 * @param {*[]} dependants Selector dependants. 551 * 552 * @return {Cache} Cache object. 553 */ 554 function getCache(dependants) { 555 var caches = rootCache, 556 isUniqueByDependants = true, 557 i, 558 dependant, 559 map, 560 cache; 561 562 for (i = 0; i < dependants.length; i++) { 563 dependant = dependants[i]; 564 565 // Can only compose WeakMap from object-like key. 566 if (!isObjectLike(dependant)) { 567 isUniqueByDependants = false; 568 break; 569 } 570 571 // Does current segment of cache already have a WeakMap? 572 if (caches.has(dependant)) { 573 // Traverse into nested WeakMap. 574 caches = caches.get(dependant); 575 } else { 576 // Create, set, and traverse into a new one. 577 map = new WeakMap(); 578 caches.set(dependant, map); 579 caches = map; 580 } 581 } 582 583 // We use an arbitrary (but consistent) object as key for the last item 584 // in the WeakMap to serve as our running cache. 585 if (!caches.has(LEAF_KEY)) { 586 cache = createCache(); 587 cache.isUniqueByDependants = isUniqueByDependants; 588 caches.set(LEAF_KEY, cache); 589 } 590 591 return caches.get(LEAF_KEY); 592 } 593 594 /** 595 * Resets root memoization cache. 596 */ 597 function clear() { 598 rootCache = new WeakMap(); 599 } 600 601 /* eslint-disable jsdoc/check-param-names */ 602 /** 603 * The augmented selector call, considering first whether dependants have 604 * changed before passing it to underlying memoize function. 605 * 606 * @param {*} source Source object for derivation. 607 * @param {...*} extraArgs Additional arguments to pass to selector. 608 * 609 * @return {*} Selector result. 610 */ 611 /* eslint-enable jsdoc/check-param-names */ 612 function callSelector(/* source, ...extraArgs */) { 613 var len = arguments.length, 614 cache, 615 node, 616 i, 617 args, 618 dependants; 619 620 // Create copy of arguments (avoid leaking deoptimization). 621 args = new Array(len); 622 for (i = 0; i < len; i++) { 623 args[i] = arguments[i]; 624 } 625 626 dependants = normalizedGetDependants.apply(null, args); 627 cache = getCache(dependants); 628 629 // If not guaranteed uniqueness by dependants (primitive type), shallow 630 // compare against last dependants and, if references have changed, 631 // destroy cache to recalculate result. 632 if (!cache.isUniqueByDependants) { 633 if ( 634 cache.lastDependants && 635 !isShallowEqual(dependants, cache.lastDependants, 0) 636 ) { 637 cache.clear(); 638 } 639 640 cache.lastDependants = dependants; 641 } 642 643 node = cache.head; 644 while (node) { 645 // Check whether node arguments match arguments 646 if (!isShallowEqual(node.args, args, 1)) { 647 node = node.next; 648 continue; 649 } 650 651 // At this point we can assume we've found a match 652 653 // Surface matched node to head if not already 654 if (node !== cache.head) { 655 // Adjust siblings to point to each other. 656 /** @type {CacheNode} */ (node.prev).next = node.next; 657 if (node.next) { 658 node.next.prev = node.prev; 659 } 660 661 node.next = cache.head; 662 node.prev = null; 663 /** @type {CacheNode} */ (cache.head).prev = node; 664 cache.head = node; 665 } 666 667 // Return immediately 668 return node.val; 669 } 670 671 // No cached value found. Continue to insertion phase: 672 673 node = /** @type {CacheNode} */ ({ 674 // Generate the result from original function 675 val: selector.apply(null, args), 676 }); 677 678 // Avoid including the source object in the cache. 679 args[0] = null; 680 node.args = args; 681 682 // Don't need to check whether node is already head, since it would 683 // have been returned above already if it was 684 685 // Shift existing head down list 686 if (cache.head) { 687 cache.head.prev = node; 688 node.next = cache.head; 689 } 690 691 cache.head = node; 692 693 return node.val; 694 } 695 696 callSelector.getDependants = normalizedGetDependants; 697 callSelector.clear = clear; 698 clear(); 699 700 return /** @type {S & EnhancedSelector} */ (callSelector); 701 } 702 703 ;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/store/selectors.js 704 /** 705 * External dependencies 706 */ 707 708 709 /** 710 * Shared reference to an empty array for cases where it is important to avoid 711 * returning a new array reference on every invocation, as in a connected or 712 * other pure component which performs `shouldComponentUpdate` check on props. 713 * This should be used as a last resort, since the normalized data should be 714 * maintained by the reducer result in state. 715 * 716 * @type {Array} 717 */ 718 const EMPTY_ARRAY = []; 719 720 /** 721 * Returns the annotations for a specific client ID. 722 * 723 * @param {Object} state Editor state. 724 * @param {string} clientId The ID of the block to get the annotations for. 725 * 726 * @return {Array} The annotations applicable to this block. 727 */ 728 const __experimentalGetAnnotationsForBlock = rememo((state, blockClientId) => { 729 var _state$blockClientId; 730 return ((_state$blockClientId = state?.[blockClientId]) !== null && _state$blockClientId !== void 0 ? _state$blockClientId : []).filter(annotation => { 731 return annotation.selector === 'block'; 732 }); 733 }, (state, blockClientId) => { 734 var _state$blockClientId2; 735 return [(_state$blockClientId2 = state?.[blockClientId]) !== null && _state$blockClientId2 !== void 0 ? _state$blockClientId2 : EMPTY_ARRAY]; 736 }); 737 function __experimentalGetAllAnnotationsForBlock(state, blockClientId) { 738 var _state$blockClientId3; 739 return (_state$blockClientId3 = state?.[blockClientId]) !== null && _state$blockClientId3 !== void 0 ? _state$blockClientId3 : EMPTY_ARRAY; 740 } 741 742 /** 743 * Returns the annotations that apply to the given RichText instance. 744 * 745 * Both a blockClientId and a richTextIdentifier are required. This is because 746 * a block might have multiple `RichText` components. This does mean that every 747 * block needs to implement annotations itself. 748 * 749 * @param {Object} state Editor state. 750 * @param {string} blockClientId The client ID for the block. 751 * @param {string} richTextIdentifier Unique identifier that identifies the given RichText. 752 * @return {Array} All the annotations relevant for the `RichText`. 753 */ 754 const __experimentalGetAnnotationsForRichText = rememo((state, blockClientId, richTextIdentifier) => { 755 var _state$blockClientId4; 756 return ((_state$blockClientId4 = state?.[blockClientId]) !== null && _state$blockClientId4 !== void 0 ? _state$blockClientId4 : []).filter(annotation => { 757 return annotation.selector === 'range' && richTextIdentifier === annotation.richTextIdentifier; 758 }).map(annotation => { 759 const { 760 range, 761 ...other 762 } = annotation; 763 return { 764 ...range, 765 ...other 766 }; 767 }); 768 }, (state, blockClientId) => { 769 var _state$blockClientId5; 770 return [(_state$blockClientId5 = state?.[blockClientId]) !== null && _state$blockClientId5 !== void 0 ? _state$blockClientId5 : EMPTY_ARRAY]; 771 }); 772 773 /** 774 * Returns all annotations in the editor state. 775 * 776 * @param {Object} state Editor state. 777 * @return {Array} All annotations currently applied. 778 */ 779 function __experimentalGetAnnotations(state) { 780 return Object.values(state).flat(); 781 } 782 783 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/native.js 784 const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto); 785 /* harmony default export */ const esm_browser_native = ({ 786 randomUUID 787 }); 788 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js 789 // Unique ID creation requires a high quality random # generator. In the browser we therefore 790 // require the crypto API and do not support built-in fallback to lower quality random number 791 // generators (like Math.random()). 792 let getRandomValues; 793 const rnds8 = new Uint8Array(16); 794 function rng() { 795 // lazy load so that environments that need to polyfill have a chance to do so 796 if (!getRandomValues) { 797 // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. 798 getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto); 799 800 if (!getRandomValues) { 801 throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported'); 802 } 803 } 804 805 return getRandomValues(rnds8); 806 } 807 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js 808 809 /** 810 * Convert array of 16 byte values to UUID string format of the form: 811 * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX 812 */ 813 814 const byteToHex = []; 815 816 for (let i = 0; i < 256; ++i) { 817 byteToHex.push((i + 0x100).toString(16).slice(1)); 818 } 819 820 function unsafeStringify(arr, offset = 0) { 821 // Note: Be careful editing this code! It's been tuned for performance 822 // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 823 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]]; 824 } 825 826 function stringify(arr, offset = 0) { 827 const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one 828 // of the following: 829 // - One or more input array values don't map to a hex octet (leading to 830 // "undefined" in the uuid) 831 // - Invalid input values for the RFC `version` or `variant` fields 832 833 if (!validate(uuid)) { 834 throw TypeError('Stringified UUID is invalid'); 835 } 836 837 return uuid; 838 } 839 840 /* harmony default export */ const esm_browser_stringify = ((/* unused pure expression or super */ null && (stringify))); 841 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js 842 843 844 845 846 function v4(options, buf, offset) { 847 if (esm_browser_native.randomUUID && !buf && !options) { 848 return esm_browser_native.randomUUID(); 849 } 850 851 options = options || {}; 852 const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` 853 854 rnds[6] = rnds[6] & 0x0f | 0x40; 855 rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided 856 857 if (buf) { 858 offset = offset || 0; 859 860 for (let i = 0; i < 16; ++i) { 861 buf[offset + i] = rnds[i]; 862 } 863 864 return buf; 865 } 866 867 return unsafeStringify(rnds); 868 } 869 870 /* harmony default export */ const esm_browser_v4 = (v4); 871 ;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/store/actions.js 872 /** 873 * External dependencies 874 */ 875 876 877 /** 878 * @typedef WPAnnotationRange 879 * 880 * @property {number} start The offset where the annotation should start. 881 * @property {number} end The offset where the annotation should end. 882 */ 883 884 /** 885 * Adds an annotation to a block. 886 * 887 * The `block` attribute refers to a block ID that needs to be annotated. 888 * `isBlockAnnotation` controls whether or not the annotation is a block 889 * annotation. The `source` is the source of the annotation, this will be used 890 * to identity groups of annotations. 891 * 892 * The `range` property is only relevant if the selector is 'range'. 893 * 894 * @param {Object} annotation The annotation to add. 895 * @param {string} annotation.blockClientId The blockClientId to add the annotation to. 896 * @param {string} annotation.richTextIdentifier Identifier for the RichText instance the annotation applies to. 897 * @param {WPAnnotationRange} annotation.range The range at which to apply this annotation. 898 * @param {string} [annotation.selector="range"] The way to apply this annotation. 899 * @param {string} [annotation.source="default"] The source that added the annotation. 900 * @param {string} [annotation.id] The ID the annotation should have. Generates a UUID by default. 901 * 902 * @return {Object} Action object. 903 */ 904 function __experimentalAddAnnotation({ 905 blockClientId, 906 richTextIdentifier = null, 907 range = null, 908 selector = 'range', 909 source = 'default', 910 id = esm_browser_v4() 911 }) { 912 const action = { 913 type: 'ANNOTATION_ADD', 914 id, 915 blockClientId, 916 richTextIdentifier, 917 source, 918 selector 919 }; 920 if (selector === 'range') { 921 action.range = range; 922 } 923 return action; 924 } 925 926 /** 927 * Removes an annotation with a specific ID. 928 * 929 * @param {string} annotationId The annotation to remove. 930 * 931 * @return {Object} Action object. 932 */ 933 function __experimentalRemoveAnnotation(annotationId) { 934 return { 935 type: 'ANNOTATION_REMOVE', 936 annotationId 937 }; 938 } 939 940 /** 941 * Updates the range of an annotation. 942 * 943 * @param {string} annotationId ID of the annotation to update. 944 * @param {number} start The start of the new range. 945 * @param {number} end The end of the new range. 946 * 947 * @return {Object} Action object. 948 */ 949 function __experimentalUpdateAnnotationRange(annotationId, start, end) { 950 return { 951 type: 'ANNOTATION_UPDATE_RANGE', 952 annotationId, 953 start, 954 end 955 }; 956 } 957 958 /** 959 * Removes all annotations of a specific source. 960 * 961 * @param {string} source The source to remove. 962 * 963 * @return {Object} Action object. 964 */ 965 function __experimentalRemoveAnnotationsBySource(source) { 966 return { 967 type: 'ANNOTATION_REMOVE_SOURCE', 968 source 969 }; 970 } 971 972 ;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/store/index.js 973 /** 974 * WordPress dependencies 975 */ 976 977 978 /** 979 * Internal dependencies 980 */ 981 982 983 984 985 /** 986 * Module Constants 987 */ 988 989 990 /** 991 * Store definition for the annotations namespace. 992 * 993 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore 994 * 995 * @type {Object} 996 */ 997 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { 998 reducer: reducer, 999 selectors: selectors_namespaceObject, 1000 actions: actions_namespaceObject 1001 }); 1002 (0,external_wp_data_namespaceObject.register)(store); 1003 1004 ;// CONCATENATED MODULE: ./node_modules/@wordpress/annotations/build-module/index.js 1005 /** 1006 * Internal dependencies 1007 */ 1008 1009 1010 1011 1012 (window.wp = window.wp || {}).annotations = __webpack_exports__; 1013 /******/ })() 1014 ;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Fri Apr 26 08:20:02 2024 | Cross-referenced by PHPXref |