vendor: 4,323 bytes, lines 1-103
1/******/ (() => { // webpackBootstrap 2/******/ "use strict"; 3/******/ // The require scope 4/******/ var __webpack_require__ = {}; 5/******/ 6/************************************************************************/ 7/******/ /* webpack/runtime/compat get default export */ 8/******/ (() => { 9/******/ // getDefaultExport function for compatibility with non-harmony modules 10/******/ __webpack_require__.n = (module) => { 11/******/ var getter = module && module.__esModule ? 12/******/ () => (module['default']) : 13/******/ () => (module); 14/******/ __webpack_require__.d(getter, { a: getter }); 15/******/ return getter; 16/******/ }; 17/******/ })(); 18/******/ 19/******/ /* webpack/runtime/define property getters */ 20/******/ (() => { 21/******/ // define getter functions for harmony exports 22/******/ __webpack_require__.d = (exports, definition) => { 23/******/ for(var key in definition) { 24/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 25/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 26/******/ } 27/******/ } 28/******/ }; 29/******/ })(); 30/******/ 31/******/ /* webpack/runtime/hasOwnProperty shorthand */ 32/******/ (() => { 33/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 34/******/ })(); 35/******/ 36/******/ /* webpack/runtime/make namespace object */ 37/******/ (() => { 38/******/ // define __esModule on exports 39/******/ __webpack_require__.r = (exports) => { 40/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 41/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 42/******/ } 43/******/ Object.defineProperty(exports, '__esModule', { value: true }); 44/******/ }; 45/******/ })(); 46/******/ 47/************************************************************************/ 48var __webpack_exports__ = {}; 49// ESM COMPAT FLAG 50__webpack_require__.r(__webpack_exports__); 51 52// EXPORTS 53__webpack_require__.d(__webpack_exports__, { 54 RichTextData: () => (/* reexport */ RichTextData), 55 __experimentalRichText: () => (/* reexport */ __experimentalRichText), 56 __unstableCreateElement: () => (/* reexport */ createElement), 57 __unstableToDom: () => (/* reexport */ toDom), 58 __unstableUseRichText: () => (/* reexport */ useRichText), 59 applyFormat: () => (/* reexport */ applyFormat), 60 concat: () => (/* reexport */ concat), 61 create: () => (/* reexport */ create), 62 getActiveFormat: () => (/* reexport */ getActiveFormat), 63 getActiveFormats: () => (/* reexport */ getActiveFormats), 64 getActiveObject: () => (/* reexport */ getActiveObject), 65 getTextContent: () => (/* reexport */ getTextContent), 66 insert: () => (/* reexport */ insert), 67 insertObject: () => (/* reexport */ insertObject), 68 isCollapsed: () => (/* reexport */ isCollapsed), 69 isEmpty: () => (/* reexport */ isEmpty), 70 join: () => (/* reexport */ join), 71 registerFormatType: () => (/* reexport */ registerFormatType), 72 remove: () => (/* reexport */ remove_remove), 73 removeFormat: () => (/* reexport */ removeFormat), 74 replace: () => (/* reexport */ replace_replace), 75 slice: () => (/* reexport */ slice), 76 split: () => (/* reexport */ split), 77 store: () => (/* reexport */ store), 78 toHTMLString: () => (/* reexport */ toHTMLString), 79 toggleFormat: () => (/* reexport */ toggleFormat), 80 unregisterFormatType: () => (/* reexport */ unregisterFormatType), 81 useAnchor: () => (/* reexport */ useAnchor), 82 useAnchorRef: () => (/* reexport */ useAnchorRef) 83}); 84 85// NAMESPACE OBJECT: ./node_modules/@wordpress/rich-text/build-module/store/selectors.js 86var selectors_namespaceObject = {}; 87__webpack_require__.r(selectors_namespaceObject); 88__webpack_require__.d(selectors_namespaceObject, { 89 getFormatType: () => (getFormatType), 90 getFormatTypeForBareElement: () => (getFormatTypeForBareElement), 91 getFormatTypeForClassName: () => (getFormatTypeForClassName), 92 getFormatTypes: () => (getFormatTypes) 93}); 94 95// NAMESPACE OBJECT: ./node_modules/@wordpress/rich-text/build-module/store/actions.js 96var actions_namespaceObject = {}; 97__webpack_require__.r(actions_namespaceObject); 98__webpack_require__.d(actions_namespaceObject, { 99 addFormatTypes: () => (addFormatTypes), 100 removeFormatTypes: () => (removeFormatTypes) 101}); 102 103;
103// external ["wp","data"] 104const external_wp_data_namespaceObject = window["wp"]["data"]; 105;// ./node_modules/@wordpress/rich-text/build-module/store/reducer.js 106 107function formatTypes(state = {}, action) { 108 switch (action.type) { 109 case "ADD_FORMAT_TYPES": 110 return { 111 ...state, 112 // Key format types by their name. 113 ...action.formatTypes.reduce( 114 (newFormatTypes, type) => ({ 115 ...newFormatTypes, 116 [type.name]: type 117 }), 118 {} 119 ) 120 }; 121 case "REMOVE_FORMAT_TYPES": 122 return Object.fromEntries( 123 Object.entries(state).filter( 124 ([key]) => !action.names.includes(key) 125 ) 126 ); 127 } 128 return state; 129} 130var reducer_default = (0,external_wp_data_namespaceObject.combineReducers)({ formatTypes }); 131 132 133;// ./node_modules/@wordpress/rich-text/build-module/store/selectors.js 134 135const getFormatTypes = (0,external_wp_data_namespaceObject.createSelector)( 136 (state) => Object.values(state.formatTypes), 137 (state) => [state.formatTypes] 138); 139function getFormatType(state, name) { 140 return state.formatTypes[name]; 141} 142function getFormatTypeForBareElement(state, bareElementTagName) { 143 const formatTypes = getFormatTypes(state); 144 return formatTypes.find(({ className, tagName }) => { 145 return className === null && bareElementTagName === tagName; 146 }) || formatTypes.find(({ className, tagName }) => { 147 return className === null && "*" === tagName; 148 }); 149} 150function getFormatTypeForClassName(state, elementClassName) { 151 return getFormatTypes(state).find(({ className }) => { 152 if (className === null) { 153 return false; 154 } 155 return ` ${elementClassName} `.indexOf(` ${className} `) >= 0; 156 }); 157} 158 159 160;// ./node_modules/@wordpress/rich-text/build-module/store/actions.js 161function addFormatTypes(formatTypes) { 162 return { 163 type: "ADD_FORMAT_TYPES", 164 formatTypes: Array.isArray(formatTypes) ? formatTypes : [formatTypes] 165 }; 166} 167function removeFormatTypes(names) { 168 return { 169 type: "REMOVE_FORMAT_TYPES", 170 names: Array.isArray(names) ? names : [names] 171 }; 172} 173 174 175;// ./node_modules/@wordpress/rich-text/build-module/store/index.js 176 177 178 179 180const STORE_NAME = "core/rich-text"; 181const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { 182 reducer: reducer_default, 183 selectors: selectors_namespaceObject, 184 actions: actions_namespaceObject 185}); 186(0,external_wp_data_namespaceObject.register)(store); 187 188 189;// ./node_modules/@wordpress/rich-text/build-module/is-format-equal.js 190function isFormatEqual(format1, format2) { 191 if (format1 === format2) { 192 return true; 193 } 194 if (!format1 || !format2) { 195 return false; 196 } 197 if (format1.type !== format2.type) { 198 return false; 199 } 200 const attributes1 = format1.attributes; 201 const attributes2 = format2.attributes; 202 if (attributes1 === attributes2) { 203 return true; 204 } 205 if (!attributes1 || !attributes2) { 206 return false; 207 } 208 const keys1 = Object.keys(attributes1); 209 const keys2 = Object.keys(attributes2); 210 if (keys1.length !== keys2.length) { 211 return false; 212 } 213 const length = keys1.length; 214 for (let i = 0; i < length; i++) { 215 const name = keys1[i]; 216 if (attributes1[name] !== attributes2[name]) { 217 return false; 218 } 219 } 220 return true; 221} 222 223 224;// ./node_modules/@wordpress/rich-text/build-module/normalise-formats.js 225 226function normaliseFormats(value) { 227 const newFormats = value.formats.slice(); 228 newFormats.forEach((formatsAtIndex, index) => { 229 const formatsAtPreviousIndex = newFormats[index - 1]; 230 if (formatsAtPreviousIndex) { 231 const newFormatsAtIndex = formatsAtIndex.slice(); 232 newFormatsAtIndex.forEach((format, formatIndex) => { 233 const previousFormat = formatsAtPreviousIndex[formatIndex]; 234 if (isFormatEqual(format, previousFormat)) { 235 newFormatsAtIndex[formatIndex] = previousFormat; 236 } 237 }); 238 newFormats[index] = newFormatsAtIndex; 239 } 240 }); 241 return { 242 ...value, 243 formats: newFormats 244 }; 245} 246 247 248;// ./node_modules/@wordpress/rich-text/build-module/apply-format.js 249 250function replace(array, index, value) { 251 array = array.slice(); 252 array[index] = value; 253 return array; 254} 255function applyFormat(value, format, startIndex = value.start, endIndex = value.end) { 256 const { formats, activeFormats } = value; 257 const newFormats = formats.slice(); 258 if (startIndex === endIndex) { 259 const startFormat = newFormats[startIndex]?.find( 260 ({ type }) => type === format.type 261 ); 262 if (startFormat) { 263 const index = newFormats[startIndex].indexOf(startFormat); 264 while (newFormats[startIndex] && newFormats[startIndex][index] === startFormat) { 265 newFormats[startIndex] = replace( 266 newFormats[startIndex], 267 index, 268 format 269 ); 270 startIndex--; 271 } 272 endIndex++; 273 while (newFormats[endIndex] && newFormats[endIndex][index] === startFormat) { 274 newFormats[endIndex] = replace( 275 newFormats[endIndex], 276 index, 277 format 278 ); 279 endIndex++; 280 } 281 } 282 } else { 283 let position = Infinity; 284 for (let index = startIndex; index < endIndex; index++) { 285 if (newFormats[index]) { 286 newFormats[index] = newFormats[index].filter( 287 ({ type }) => type !== format.type 288 ); 289 const length = newFormats[index].length; 290 if (length < position) { 291 position = length; 292 } 293 } else { 294 newFormats[index] = []; 295 position = 0; 296 } 297 } 298 for (let index = startIndex; index < endIndex; index++) { 299 newFormats[index].splice(position, 0, format); 300 } 301 } 302 return normaliseFormats({ 303 ...value, 304 formats: newFormats, 305 // Always revise active formats. This serves as a placeholder for new 306 // inputs with the format so new input appears with the format applied, 307 // and ensures a format of the same type uses the latest values. 308 activeFormats: [ 309 ...activeFormats?.filter( 310 ({ type }) => type !== format.type 311 ) || [], 312 format 313 ] 314 }); 315} 316 317 318;// ./node_modules/@wordpress/rich-text/build-module/create-element.js 319function createElement({ implementation }, html) { 320 if (!createElement.body) { 321 createElement.body = implementation.createHTMLDocument("").body; 322 } 323 createElement.body.innerHTML = html; 324 return createElement.body; 325} 326 327 328;// ./node_modules/@wordpress/rich-text/build-module/special-characters.js 329const OBJECT_REPLACEMENT_CHARACTER = "\uFFFC"; 330const ZWNBSP = "\uFEFF"; 331 332 333;
333// external ["wp","escapeHtml"] 334const external_wp_escapeHtml_namespaceObject = window["wp"]["escapeHtml"]; 335;// ./node_modules/@wordpress/rich-text/build-module/get-active-formats.js 336 337function getActiveFormats(value, EMPTY_ACTIVE_FORMATS = []) { 338 const { formats, start, end, activeFormats } = value; 339 if (start === void 0) { 340 return EMPTY_ACTIVE_FORMATS; 341 } 342 if (start === end) { 343 if (activeFormats) { 344 return activeFormats; 345 } 346 const formatsBefore = formats[start - 1] || EMPTY_ACTIVE_FORMATS; 347 const formatsAfter = formats[start] || EMPTY_ACTIVE_FORMATS; 348 if (formatsBefore.length < formatsAfter.length) { 349 return formatsBefore; 350 } 351 return formatsAfter; 352 } 353 if (!formats[start]) { 354 return EMPTY_ACTIVE_FORMATS; 355 } 356 const selectedFormats = formats.slice(start, end); 357 const _activeFormats = [...selectedFormats[0]]; 358 let i = selectedFormats.length; 359 while (i--) { 360 const formatsAtIndex = selectedFormats[i]; 361 if (!formatsAtIndex) { 362 return EMPTY_ACTIVE_FORMATS; 363 } 364 let ii = _activeFormats.length; 365 while (ii--) { 366 const format = _activeFormats[ii]; 367 if (!formatsAtIndex.find( 368 (_format) => isFormatEqual(format, _format) 369 )) { 370 _activeFormats.splice(ii, 1); 371 } 372 } 373 if (_activeFormats.length === 0) { 374 return EMPTY_ACTIVE_FORMATS; 375 } 376 } 377 return _activeFormats || EMPTY_ACTIVE_FORMATS; 378} 379 380 381;// ./node_modules/@wordpress/rich-text/build-module/get-format-type.js 382 383 384function get_format_type_getFormatType(name) { 385 return (0,external_wp_data_namespaceObject.select)(store).getFormatType(name); 386} 387 388 389;// ./node_modules/@wordpress/rich-text/build-module/to-tree.js 390 391 392 393function restoreOnAttributes(attributes, isEditableTree) { 394 if (isEditableTree) { 395 return attributes; 396 } 397 const newAttributes = {}; 398 for (const key in attributes) { 399 let newKey = key; 400 if (key.startsWith("data-disable-rich-text-")) { 401 newKey = key.slice("data-disable-rich-text-".length); 402 } 403 newAttributes[newKey] = attributes[key]; 404 } 405 return newAttributes; 406} 407function fromFormat({ 408 type, 409 tagName, 410 attributes, 411 unregisteredAttributes, 412 object, 413 boundaryClass, 414 isEditableTree 415}) { 416 const formatType = get_format_type_getFormatType(type); 417 let elementAttributes = {}; 418 if (boundaryClass && isEditableTree) { 419 elementAttributes["data-rich-text-format-boundary"] = "true"; 420 } 421 if (!formatType) { 422 if (attributes) { 423 elementAttributes = { ...attributes, ...elementAttributes }; 424 } 425 return { 426 type, 427 attributes: restoreOnAttributes( 428 elementAttributes, 429 isEditableTree 430 ), 431 object 432 }; 433 } 434 elementAttributes = { ...unregisteredAttributes, ...elementAttributes }; 435 for (const name in attributes) { 436 const key = formatType.attributes ? formatType.attributes[name] : false; 437 if (key) { 438 elementAttributes[key] = attributes[name]; 439 } else { 440 elementAttributes[name] = attributes[name]; 441 } 442 } 443 if (formatType.className) { 444 if (elementAttributes.class) { 445 elementAttributes.class = `${formatType.className} ${elementAttributes.class}`; 446 } else { 447 elementAttributes.class = formatType.className; 448 } 449 } 450 return { 451 type: tagName || formatType.tagName, 452 object: formatType.object, 453 attributes: restoreOnAttributes(elementAttributes, isEditableTree) 454 }; 455} 456function isEqualUntil(a, b, index) { 457 do { 458 if (a[index] !== b[index]) { 459 return false; 460 } 461 } while (index--); 462 return true; 463} 464function toTree({ 465 value, 466 preserveWhiteSpace, 467 createEmpty, 468 append, 469 getLastChild, 470 getParent, 471 isText, 472 getText, 473 remove, 474 appendText, 475 onStartIndex, 476 onEndIndex, 477 isEditableTree, 478 placeholder 479}) { 480 const { formats, replacements, text, start, end } = value; 481 const formatsLength = formats.length + 1; 482 const tree = createEmpty(); 483 const activeFormats = getActiveFormats(value); 484 const deepestActiveFormat = activeFormats[activeFormats.length - 1]; 485 let lastCharacterFormats; 486 let lastCharacter; 487 append(tree, ""); 488 for (let i = 0; i < formatsLength; i++) { 489 const character = text.charAt(i); 490 const shouldInsertPadding = isEditableTree && // Pad the line if the line is empty. 491 (!lastCharacter || // Pad the line if the previous character is a line break, otherwise 492 // the line break won't be visible. 493 lastCharacter === "\n"); 494 const characterFormats = formats[i]; 495 let pointer = getLastChild(tree); 496 if (characterFormats) {
497 characterFormats.forEach((format, formatIndex) => { 498 if (pointer && lastCharacterFormats && // Reuse the last element if all formats remain the same. 499 isEqualUntil( 500 characterFormats, 501 lastCharacterFormats, 502 formatIndex 503 )) { 504 pointer = getLastChild(pointer); 505 return; 506 } 507 const { type, tagName, attributes, unregisteredAttributes } = format; 508 const boundaryClass = isEditableTree && format === deepestActiveFormat; 509 const parent = getParent(pointer); 510 const newNode = append( 511 parent, 512 fromFormat({ 513 type, 514 tagName, 515 attributes, 516 unregisteredAttributes, 517 boundaryClass, 518 isEditableTree 519 }) 520 ); 521 if (isText(pointer) && getText(pointer).length === 0) { 522 remove(pointer); 523 } 524 pointer = append(newNode, ""); 525 }); 526 } 527 if (i === 0) { 528 if (onStartIndex && start === 0) { 529 onStartIndex(tree, pointer); 530 } 531 if (onEndIndex && end === 0) { 532 onEndIndex(tree, pointer); 533 } 534 } 535 if (character === OBJECT_REPLACEMENT_CHARACTER) { 536 const replacement = replacements[i]; 537 if (!replacement) { 538 continue; 539 } 540 const { type, attributes, innerHTML } = replacement; 541 const formatType = get_format_type_getFormatType(type); 542 if (isEditableTree && type === "#comment") { 543 pointer = append(getParent(pointer), { 544 type: "span", 545 attributes: { 546 contenteditable: "false", 547 "data-rich-text-comment": attributes["data-rich-text-comment"] 548 } 549 }); 550 append( 551 append(pointer, { type: "span" }), 552 attributes["data-rich-text-comment"].trim() 553 ); 554 } else if (!isEditableTree && type === "script") { 555 pointer = append( 556 getParent(pointer), 557 fromFormat({ 558 type: "script", 559 isEditableTree 560 }) 561 ); 562 append(pointer, { 563 html: decodeURIComponent( 564 attributes["data-rich-text-script"] 565 ) 566 }); 567 } else if (formatType?.contentEditable === false) { 568 if (innerHTML || isEditableTree) { 569 pointer = getParent(pointer); 570 if (isEditableTree) { 571 const attrs = { 572 contenteditable: "false", 573 "data-rich-text-bogus": true 574 }; 575 if (start === i && end === i + 1) { 576 attrs["data-rich-text-format-boundary"] = true; 577 } 578 pointer = append(pointer, { 579 type: "span", 580 attributes: attrs 581 }); 582 if (isEditableTree && i + 1 === text.length) { 583 append(getParent(pointer), ZWNBSP); 584 } 585 } 586 pointer = append( 587 pointer, 588 fromFormat({ 589 ...replacement, 590 isEditableTree 591 }) 592 ); 593 if (innerHTML) { 594 append(pointer, { 595 html: innerHTML 596 }); 597 } 598 } 599 } else { 600 pointer = append( 601 getParent(pointer), 602 fromFormat({ 603 ...replacement, 604 object: true, 605 isEditableTree 606 }) 607 ); 608 } 609 pointer = append(getParent(pointer), ""); 610 } else if (!preserveWhiteSpace && character === "\n") { 611 pointer = append(getParent(pointer), { 612 type: "br", 613 attributes: isEditableTree ? { 614 "data-rich-text-line-break": "true" 615 } : void 0, 616 object: true 617 }); 618 pointer = append(getParent(pointer), ""); 619 } else if (!isText(pointer)) { 620 pointer = append(getParent(pointer), character); 621 } else { 622 appendText(pointer, character); 623 } 624 if (onStartIndex && start === i + 1) { 625 onStartIndex(tree, pointer); 626 } 627 if (onEndIndex && end === i + 1) { 628 onEndIndex(tree, pointer); 629 } 630 if (shouldInsertPadding && i === text.length) { 631 append(getParent(pointer), ZWNBSP); 632 if (placeholder && text.length === 0) { 633 append(getParent(pointer), { 634 type: "span", 635 attributes: { 636 "data-rich-text-placeholder": placeholder, 637 // Necessary to prevent the placeholder from catching 638 // selection and being editable. 639 style: "pointer-events:none;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;" 640 } 641 }); 642 } 643 } 644 lastCharacterFormats = characterFormats; 645 lastCharacter = character; 646 } 647 return tree; 648} 649 650 651;// ./node_modules/@wordpress/rich-text/build-module/to-html-string.js 652 653 654function toHTMLString({ value, preserveWhiteSpace }) { 655 const tree = toTree({ 656 value, 657 preserveWhiteSpace, 658 createEmpty, 659 append, 660 getLastChild, 661 getParent, 662 isText, 663 getText, 664 remove, 665 appendText 666 }); 667 return createChildrenHTML(tree.children); 668} 669function createEmpty() { 670 return {}; 671} 672function getLastChild({ children }) { 673 return children && children[children.length - 1]; 674} 675function append(parent, object) { 676 if (typeof object === "string") { 677 object = { text: object }; 678 } 679 object.parent = parent; 680 parent.children = parent.children || []; 681 parent.children.push(object); 682 return object; 683} 684function appendText(object, text) { 685 object.text += text; 686} 687function getParent({ parent }) { 688 return parent; 689} 690function isText({ text }) { 691 return typeof text === "string"; 692} 693function getText({ text }) { 694 return text; 695} 696function remove(object) { 697 const index = object.parent.children.indexOf(object); 698 if (index !== -1) { 699 object.parent.children.splice(index, 1); 700 } 701 return object; 702} 703function createElementHTML({ type, attributes, object, children }) { 704 if (type === "#comment") { 705 return `<!--${attributes["data-rich-text-comment"]}-->`; 706 } 707 let attributeString = ""; 708 for (const key in attributes) { 709 if (!(0,external_wp_escapeHtml_namespaceObject.isValidAttributeName)(key)) { 710 continue; 711 } 712 attributeString += ` ${key}="${(0,external_wp_escapeHtml_namespaceObject.escapeAttribute)( 713 attributes[key] 714 )}"`; 715 } 716 if (object) { 717 return `<${type}${attributeString}>`; 718 } 719 return `<${type}${attributeString}>${createChildrenHTML( 720 children 721 )}</${type}>`; 722} 723function createChildrenHTML(children = []) { 724 return children.map((child) => { 725 if (child.html !== void 0) { 726 return child.html; 727 } 728 return child.text === void 0 ? createElementHTML(child) : (0,external_wp_escapeHtml_namespaceObject.escapeEditableHTML)(child.text); 729 }).join(""); 730} 731 732 733;// ./node_modules/@wordpress/rich-text/build-module/get-text-content.js 734 735function getTextContent({ text }) { 736 return text.replace(OBJECT_REPLACEMENT_CHARACTER, ""); 737} 738 739 740;// ./node_modules/@wordpress/rich-text/build-module/create.js 741 742 743 744 745 746 747 748function createEmptyValue() { 749 return { 750 formats: [], 751 replacements: [], 752 text: "" 753 }; 754} 755function toFormat({ tagName, attributes }) { 756 let formatType; 757 if (attributes && attributes.class) { 758 formatType = (0,external_wp_data_namespaceObject.select)(store).getFormatTypeForClassName( 759 attributes.class 760 ); 761 if (formatType) { 762 attributes.class = ` ${attributes.class} `.replace(` ${formatType.className} `, " ").trim(); 763 if (!attributes.class) { 764 delete attributes.class; 765 } 766 } 767 } 768 if (!formatType) { 769 formatType = (0,external_wp_data_namespaceObject.select)(store).getFormatTypeForBareElement(tagName); 770 } 771 if (!formatType) { 772 return attributes ? { type: tagName, attributes } : { type: tagName }; 773 } 774 if (formatType.__experimentalCreatePrepareEditableTree && !formatType.__experimentalCreateOnChangeEditableValue) { 775 return null; 776 } 777 if (!attributes) { 778 return { formatType, type: formatType.name, tagName }; 779 } 780 const registeredAttributes = {}; 781 const unregisteredAttributes = {}; 782 const _attributes = { ...attributes }; 783 for (const key in formatType.attributes) { 784 const name = formatType.attributes[key]; 785 registeredAttributes[key] = _attributes[name]; 786 delete _attributes[name]; 787 if (typeof registeredAttributes[key] === "undefined") { 788 delete registeredAttributes[key]; 789 } 790 } 791 for (const name in _attributes) { 792 unregisteredAttributes[name] = attributes[name]; 793 } 794 if (formatType.contentEditable === false) { 795 delete unregisteredAttributes.contenteditable; 796 } 797 return { 798 formatType, 799 type: formatType.name, 800 tagName, 801 attributes: registeredAttributes, 802 unregisteredAttributes 803 }; 804} 805class RichTextData { 806 #value; 807 static empty() { 808 return new RichTextData(); 809 } 810 static fromPlainText(text) { 811 return new RichTextData(create({ text })); 812 } 813 static fromHTMLString(html) { 814 return new RichTextData(create({ html })); 815 } 816 /** 817 * Create a RichTextData instance from an HTML element. 818 * 819 * @param {HTMLElement} htmlElement The HTML element to create the instance from. 820 * @param {{preserveWhiteSpace?: boolean}} options Options. 821 * @return {RichTextData} The RichTextData instance. 822 */ 823 static fromHTMLElement(htmlElement, options = {}) { 824 const { preserveWhiteSpace = false } = options; 825 const element = preserveWhiteSpace ? htmlElement : collapseWhiteSpace(htmlElement); 826 const richTextData = new RichTextData(create({ element }));
827 Object.defineProperty(richTextData, "originalHTML", { 828 value: htmlElement.innerHTML 829 }); 830 return richTextData; 831 } 832 constructor(init = createEmptyValue()) { 833 this.#value = init; 834 } 835 toPlainText() { 836 return getTextContent(this.#value); 837 } 838 // We could expose `toHTMLElement` at some point as well, but we'd only use 839 // it internally. 840 /** 841 * Convert the rich text value to an HTML string. 842 * 843 * @param {{preserveWhiteSpace?: boolean}} options Options. 844 * @return {string} The HTML string. 845 */ 846 toHTMLString({ preserveWhiteSpace } = {}) { 847 return this.originalHTML || toHTMLString({ value: this.#value, preserveWhiteSpace }); 848 } 849 valueOf() { 850 return this.toHTMLString(); 851 } 852 toString() { 853 return this.toHTMLString(); 854 } 855 toJSON() { 856 return this.toHTMLString(); 857 } 858 get length() { 859 return this.text.length; 860 } 861 get formats() { 862 return this.#value.formats; 863 } 864 get replacements() { 865 return this.#value.replacements; 866 } 867 get text() { 868 return this.#value.text; 869 } 870} 871for (const name of Object.getOwnPropertyNames(String.prototype)) { 872 if (RichTextData.prototype.hasOwnProperty(name)) { 873 continue; 874 } 875 Object.defineProperty(RichTextData.prototype, name, { 876 value(...args) { 877 return this.toHTMLString()[name](...args); 878 } 879 }); 880} 881function create({ 882 element, 883 text, 884 html, 885 range, 886 __unstableIsEditableTree: isEditableTree 887} = {}) { 888 if (html instanceof RichTextData) { 889 return { 890 text: html.text, 891 formats: html.formats, 892 replacements: html.replacements 893 }; 894 } 895 if (typeof text === "string" && text.length > 0) { 896 return { 897 formats: Array(text.length), 898 replacements: Array(text.length), 899 text 900 }; 901 } 902 if (typeof html === "string" && html.length > 0) { 903 element = createElement(document, html); 904 } 905 if (typeof element !== "object") { 906 return createEmptyValue(); 907 } 908 return createFromElement({ 909 element, 910 range, 911 isEditableTree 912 }); 913} 914function accumulateSelection(accumulator, node, range, value) { 915 if (!range) { 916 return; 917 } 918 const { parentNode } = node; 919 const { startContainer, startOffset, endContainer, endOffset } = range; 920 const currentLength = accumulator.text.length; 921 if (value.start !== void 0) { 922 accumulator.start = currentLength + value.start; 923 } else if (node === startContainer && node.nodeType === node.TEXT_NODE) { 924 accumulator.start = currentLength + startOffset; 925 } else if (parentNode === startContainer && node === startContainer.childNodes[startOffset]) { 926 accumulator.start = currentLength; 927 } else if (parentNode === startContainer && node === startContainer.childNodes[startOffset - 1]) { 928 accumulator.start = currentLength + value.text.length; 929 } else if (node === startContainer) { 930 accumulator.start = currentLength; 931 } 932 if (value.end !== void 0) { 933 accumulator.end = currentLength + value.end; 934 } else if (node === endContainer && node.nodeType === node.TEXT_NODE) { 935 accumulator.end = currentLength + endOffset; 936 } else if (parentNode === endContainer && node === endContainer.childNodes[endOffset - 1]) { 937 accumulator.end = currentLength + value.text.length; 938 } else if (parentNode === endContainer && node === endContainer.childNodes[endOffset]) { 939 accumulator.end = currentLength; 940 } else if (node === endContainer) { 941 accumulator.end = currentLength + endOffset; 942 } 943} 944function filterRange(node, range, filter) { 945 if (!range) { 946 return; 947 } 948 const { startContainer, endContainer } = range; 949 let { startOffset, endOffset } = range; 950 if (node === startContainer) { 951 startOffset = filter(node.nodeValue.slice(0, startOffset)).length; 952 } 953 if (node === endContainer) { 954 endOffset = filter(node.nodeValue.slice(0, endOffset)).length; 955 } 956 return { startContainer, startOffset, endContainer, endOffset }; 957} 958function collapseWhiteSpace(element, isRoot = true) { 959 const clone = element.cloneNode(true); 960 clone.normalize(); 961 Array.from(clone.childNodes).forEach((node, i, nodes) => { 962 if (node.nodeType === node.TEXT_NODE) { 963 let newNodeValue = node.nodeValue; 964 if (/[\n\t\r\f]/.test(newNodeValue)) { 965 newNodeValue = newNodeValue.replace(/[\n\t\r\f]+/g, " "); 966 } 967 if (newNodeValue.indexOf(" ") !== -1) { 968 newNodeValue = newNodeValue.replace(/ {2,}/g, " "); 969 } 970 if (i === 0 && newNodeValue.startsWith(" ")) { 971 newNodeValue = newNodeValue.slice(1); 972 } else if (isRoot && i === nodes.length - 1 && newNodeValue.endsWith(" ")) { 973 newNodeValue = newNodeValue.slice(0, -1); 974 } 975 node.nodeValue = newNodeValue; 976 } else if (node.nodeType === node.ELEMENT_NODE) { 977 node.replaceWith(collapseWhiteSpace(node, false)); 978 } 979 }); 980 return clone; 981} 982const CARRIAGE_RETURN = "\r"; 983function removeReservedCharacters(string) { 984 return string.replace( 985 new RegExp( 986 `[${ZWNBSP}${OBJECT_REPLACEMENT_CHARACTER}${CARRIAGE_RETURN}]`, 987 "gu" 988 ), 989 "" 990 ); 991} 992function createFromElement({ element, range, isEditableTree }) { 993 const accumulator = createEmptyValue(); 994 if (!element) { 995 return accumulator; 996 } 997 if (!element.hasChildNodes()) { 998 accumulateSelection(accumulator, element, range, createEmptyValue()); 999 return accumulator; 1000 } 1001 const length = element.childNodes.length; 1002 for (let index = 0; index < length; index++) { 1003 const node = element.childNodes[index]; 1004 const tagName = node.nodeName.toLowerCase(); 1005 if (node.nodeType === node.TEXT_NODE) { 1006 const text = removeReservedCharacters(node.nodeValue); 1007 range = filterRange(node, range, removeReservedCharacters); 1008 accumulateSelection(accumulator, node, range, { text }); 1009 accumulator.formats.length += text.length; 1010 accumulator.replacements.length += text.length; 1011 accumulator.text += text; 1012 continue; 1013 } 1014 if (node.nodeType === node.COMMENT_NODE || node.nodeType === node.ELEMENT_NODE && node.tagName === "SPAN" && node.hasAttribute("data-rich-text-comment")) { 1015 const value2 = { 1016 formats: [,], 1017 replacements: [ 1018 { 1019 type: "#comment", 1020 attributes: { 1021 "data-rich-text-comment": node.nodeType === node.COMMENT_NODE ? node.nodeValue : node.getAttribute( 1022 "data-rich-text-comment" 1023 ) 1024 } 1025 } 1026 ], 1027 text: OBJECT_REPLACEMENT_CHARACTER 1028 }; 1029 accumulateSelection(accumulator, node, range, value2); 1030 mergePair(accumulator, value2); 1031 continue; 1032 }
1033 if (node.nodeType !== node.ELEMENT_NODE) { 1034 continue; 1035 } 1036 if (isEditableTree && // Ignore any line breaks that are not inserted by us. 1037 tagName === "br" && !node.getAttribute("data-rich-text-line-break")) { 1038 accumulateSelection(accumulator, node, range, createEmptyValue()); 1039 continue; 1040 } 1041 if (tagName === "script") { 1042 const value2 = { 1043 formats: [,], 1044 replacements: [ 1045 { 1046 type: tagName, 1047 attributes: { 1048 "data-rich-text-script": node.getAttribute("data-rich-text-script") || encodeURIComponent(node.innerHTML) 1049 } 1050 } 1051 ], 1052 text: OBJECT_REPLACEMENT_CHARACTER 1053 }; 1054 accumulateSelection(accumulator, node, range, value2); 1055 mergePair(accumulator, value2); 1056 continue; 1057 } 1058 if (tagName === "br") { 1059 accumulateSelection(accumulator, node, range, createEmptyValue()); 1060 mergePair(accumulator, create({ text: "\n" })); 1061 continue; 1062 } 1063 const format = toFormat({ 1064 tagName, 1065 attributes: getAttributes({ element: node }) 1066 }); 1067 if (format?.formatType?.contentEditable === false) { 1068 delete format.formatType; 1069 accumulateSelection(accumulator, node, range, createEmptyValue()); 1070 mergePair(accumulator, { 1071 formats: [,], 1072 replacements: [ 1073 { 1074 ...format, 1075 innerHTML: node.innerHTML 1076 } 1077 ], 1078 text: OBJECT_REPLACEMENT_CHARACTER 1079 }); 1080 continue; 1081 } 1082 if (format) { 1083 delete format.formatType; 1084 } 1085 const value = createFromElement({ 1086 element: node, 1087 range, 1088 isEditableTree 1089 }); 1090 accumulateSelection(accumulator, node, range, value); 1091 if (!format || node.getAttribute("data-rich-text-placeholder") || node.getAttribute("data-rich-text-bogus")) { 1092 mergePair(accumulator, value); 1093 } else if (value.text.length === 0) { 1094 if (format.attributes) { 1095 mergePair(accumulator, { 1096 formats: [,], 1097 replacements: [format], 1098 text: OBJECT_REPLACEMENT_CHARACTER 1099 }); 1100 } 1101 } else { 1102 let mergeFormats2 = function(formats) { 1103 if (mergeFormats2.formats === formats) { 1104 return mergeFormats2.newFormats; 1105 } 1106 const newFormats = formats ? [format, ...formats] : [format]; 1107 mergeFormats2.formats = formats; 1108 mergeFormats2.newFormats = newFormats; 1109 return newFormats; 1110 }; 1111 var mergeFormats = mergeFormats2; 1112 mergeFormats2.newFormats = [format]; 1113 mergePair(accumulator, { 1114 ...value, 1115 formats: Array.from(value.formats, mergeFormats2) 1116 }); 1117 } 1118 } 1119 return accumulator; 1120} 1121function getAttributes({ element }) { 1122 if (!element.hasAttributes()) { 1123 return; 1124 } 1125 const length = element.attributes.length; 1126 let accumulator; 1127 for (let i = 0; i < length; i++) { 1128 const { name, value } = element.attributes[i]; 1129 if (name.indexOf("data-rich-text-") === 0) { 1130 continue; 1131 } 1132 const safeName = /^on/i.test(name) ? "data-disable-rich-text-" + name : name; 1133 accumulator = accumulator || {}; 1134 accumulator[safeName] = value; 1135 } 1136 return accumulator; 1137} 1138 1139 1140;// ./node_modules/@wordpress/rich-text/build-module/concat.js 1141 1142 1143function mergePair(a, b) { 1144 a.formats = a.formats.concat(b.formats); 1145 a.replacements = a.replacements.concat(b.replacements); 1146 a.text += b.text; 1147 return a; 1148} 1149function concat(...values) { 1150 return normaliseFormats(values.reduce(mergePair, create())); 1151} 1152 1153 1154;// ./node_modules/@wordpress/rich-text/build-module/get-active-format.js 1155 1156function getActiveFormat(value, formatType) { 1157 return getActiveFormats(value).find( 1158 ({ type }) => type === formatType 1159 ); 1160} 1161 1162 1163;// ./node_modules/@wordpress/rich-text/build-module/get-active-object.js 1164 1165function getActiveObject({ start, end, replacements, text }) { 1166 if (start + 1 !== end || text[start] !== OBJECT_REPLACEMENT_CHARACTER) { 1167 return; 1168 } 1169 return replacements[start]; 1170} 1171 1172 1173;// ./node_modules/@wordpress/rich-text/build-module/is-collapsed.js 1174function isCollapsed({ 1175 start, 1176 end 1177}) { 1178 if (start === void 0 || end === void 0) { 1179 return; 1180 } 1181 return start === end; 1182} 1183 1184 1185;// ./node_modules/@wordpress/rich-text/build-module/is-empty.js 1186function isEmpty({ text }) { 1187 return text.length === 0; 1188} 1189 1190 1191;// ./node_modules/@wordpress/rich-text/build-module/join.js 1192 1193 1194function join(values, separator = "") { 1195 if (typeof separator === "string") { 1196 separator = create({ text: separator }); 1197 } 1198 return normaliseFormats( 1199 values.reduce((accumulator, { formats, replacements, text }) => ({ 1200 formats: accumulator.formats.concat(separator.formats, formats), 1201 replacements: accumulator.replacements.concat( 1202 separator.replacements, 1203 replacements 1204 ), 1205 text: accumulator.text + separator.text + text 1206 })) 1207 ); 1208} 1209 1210 1211;// ./node_modules/@wordpress/rich-text/build-module/register-format-type.js 1212 1213 1214function registerFormatType(name, settings) { 1215 settings = { 1216 name, 1217 ...settings 1218 }; 1219 if (typeof settings.name !== "string") { 1220 window.console.error("Format names must be strings."); 1221 return; 1222 } 1223 if (!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(settings.name)) { 1224 window.console.error( 1225 "Format names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-format" 1226 ); 1227 return; 1228 } 1229 if ((0,external_wp_data_namespaceObject.select)(store).getFormatType(settings.name)) { 1230 window.console.error( 1231 'Format "' + settings.name + '" is already registered.' 1232 ); 1233 return; 1234 } 1235 if (typeof settings.tagName !== "string" || settings.tagName === "") { 1236 window.console.error("Format tag names must be a string."); 1237 return; 1238 } 1239 if ((typeof settings.className !== "string" || settings.className === "") && settings.className !== null) { 1240 window.console.error( 1241 "Format class names must be a string, or null to handle bare elements." 1242 ); 1243 return; 1244 } 1245 if (!/^[_a-zA-Z]+[a-zA-Z0-9_-]*$/.test(settings.className)) { 1246 window.console.error( 1247 "A class name must begin with a letter, followed by any number of hyphens, underscores, letters, or numbers." 1248 ); 1249 return; 1250 } 1251 if (settings.className === null) { 1252 const formatTypeForBareElement = (0,external_wp_data_namespaceObject.select)( 1253 store 1254 ).getFormatTypeForBareElement(settings.tagName); 1255 if (formatTypeForBareElement && formatTypeForBareElement.name !== "core/unknown") { 1256 window.console.error( 1257 `Format "${formatTypeForBareElement.name}" is already registered to handle bare tag name "${settings.tagName}".` 1258 ); 1259 return; 1260 } 1261 } else { 1262 const formatTypeForClassName = (0,external_wp_data_namespaceObject.select)( 1263 store 1264 ).getFormatTypeForClassName(settings.className); 1265 if (formatTypeForClassName) { 1266 window.console.error( 1267 `Format "${formatTypeForClassName.name}" is already registered to handle class name "${settings.className}".` 1268 ); 1269 return; 1270 } 1271 } 1272 if (!("title" in settings) || settings.title === "") { 1273 window.console.error( 1274 'The format "' + settings.name + '" must have a title.' 1275 ); 1276 return; 1277 } 1278 if ("keywords" in settings && settings.keywords.length > 3) { 1279 window.console.error( 1280 'The format "' + settings.name + '" can have a maximum of 3 keywords.' 1281 ); 1282 return; 1283 } 1284 if (typeof settings.title !== "string") { 1285 window.console.error("Format titles must be strings."); 1286 return; 1287 } 1288 (0,external_wp_data_namespaceObject.dispatch)(store).addFormatTypes(settings); 1289 return settings; 1290} 1291 1292 1293;// ./node_modules/@wordpress/rich-text/build-module/remove-format.js 1294 1295function removeFormat(value, formatType, startIndex = value.start, endIndex = value.end) { 1296 const { formats, activeFormats } = value; 1297 const newFormats = formats.slice(); 1298 if (startIndex === endIndex) { 1299 const format = newFormats[startIndex]?.find( 1300 ({ type }) => type === formatType 1301 ); 1302 if (format) { 1303 while (newFormats[startIndex]?.find( 1304 (newFormat) => newFormat === format 1305 )) { 1306 filterFormats(newFormats, startIndex, formatType); 1307 startIndex--; 1308 } 1309 endIndex++; 1310 while (newFormats[endIndex]?.find( 1311 (newFormat) => newFormat === format 1312 )) { 1313 filterFormats(newFormats, endIndex, formatType); 1314 endIndex++; 1315 } 1316 } 1317 } else { 1318 for (let i = startIndex; i < endIndex; i++) { 1319 if (newFormats[i]) { 1320 filterFormats(newFormats, i, formatType); 1321 } 1322 } 1323 } 1324 return normaliseFormats({ 1325 ...value, 1326 formats: newFormats, 1327 activeFormats: activeFormats?.filter(({ type }) => type !== formatType) || [] 1328 }); 1329} 1330function filterFormats(formats, index, formatType) { 1331 const newFormats = formats[index].filter( 1332 ({ type }) => type !== formatType 1333 ); 1334 if (newFormats.length) { 1335 formats[index] = newFormats; 1336 } else { 1337 delete formats[index]; 1338 } 1339} 1340 1341 1342;// ./node_modules/@wordpress/rich-text/build-module/insert.js 1343 1344 1345function insert(value, valueToInsert, startIndex = value.start, endIndex = value.end) { 1346 const { formats, replacements, text } = value; 1347 if (typeof valueToInsert === "string") { 1348 valueToInsert = create({ text: valueToInsert }); 1349 } 1350 const index = startIndex + valueToInsert.text.length; 1351 return normaliseFormats({ 1352 formats: formats.slice(0, startIndex).concat(valueToInsert.formats, formats.slice(endIndex)), 1353 replacements: replacements.slice(0, startIndex).concat( 1354 valueToInsert.replacements, 1355 replacements.slice(endIndex) 1356 ), 1357 text: text.slice(0, startIndex) + valueToInsert.text + text.slice(endIndex), 1358 start: index, 1359 end: index 1360 }); 1361} 1362 1363 1364;// ./node_modules/@wordpress/rich-text/build-module/remove.js 1365 1366 1367function remove_remove(value, startIndex, endIndex) { 1368 return insert(value, create(), startIndex, endIndex); 1369} 1370 1371 1372;// ./node_modules/@wordpress/rich-text/build-module/replace.js 1373 1374function replace_replace({ formats, replacements, text, start, end }, pattern, replacement) { 1375 text = text.replace(pattern, (match, ...rest) => { 1376 const offset = rest[rest.length - 2]; 1377 let newText = replacement; 1378 let newFormats; 1379 let newReplacements; 1380 if (typeof newText === "function") { 1381 newText = replacement(match, ...rest); 1382 } 1383 if (typeof newText === "object") { 1384 newFormats = newText.formats; 1385 newReplacements = newText.replacements; 1386 newText = newText.text; 1387 } else { 1388 newFormats = Array(newText.length); 1389 newReplacements = Array(newText.length); 1390 if (formats[offset]) { 1391 newFormats = newFormats.fill(formats[offset]); 1392 } 1393 } 1394 formats = formats.slice(0, offset).concat(newFormats, formats.slice(offset + match.length)); 1395 replacements = replacements.slice(0, offset).concat( 1396 newReplacements, 1397 replacements.slice(offset + match.length) 1398 ); 1399 if (start) { 1400 start = end = offset + newText.length; 1401 } 1402 return newText; 1403 }); 1404 return normaliseFormats({ formats, replacements, text, start, end }); 1405} 1406 1407 1408;// ./node_modules/@wordpress/rich-text/build-module/insert-object.js 1409 1410 1411function insertObject(value, formatToInsert, startIndex, endIndex) { 1412 const valueToInsert = { 1413 formats: [,], 1414 replacements: [formatToInsert], 1415 text: OBJECT_REPLACEMENT_CHARACTER 1416 }; 1417 return insert(value, valueToInsert, startIndex, endIndex); 1418} 1419 1420 1421;// ./node_modules/@wordpress/rich-text/build-module/slice.js 1422function slice(value, startIndex = value.start, endIndex = value.end) { 1423 const { formats, replacements, text } = value; 1424 if (startIndex === void 0 || endIndex === void 0) { 1425 return { ...value }; 1426 } 1427 return { 1428 formats: formats.slice(startIndex, endIndex), 1429 replacements: replacements.slice(startIndex, endIndex), 1430 text: text.slice(startIndex, endIndex) 1431 }; 1432} 1433 1434 1435;// ./node_modules/@wordpress/rich-text/build-module/split.js 1436function split({ formats, replacements, text, start, end }, string) { 1437 if (typeof string !== "string") { 1438 return splitAtSelection(...arguments); 1439 } 1440 let nextStart = 0; 1441 return text.split(string).map((substring) => { 1442 const startIndex = nextStart; 1443 const value = { 1444 formats: formats.slice(startIndex, startIndex + substring.length), 1445 replacements: replacements.slice( 1446 startIndex, 1447 startIndex + substring.length 1448 ), 1449 text: substring 1450 }; 1451 nextStart += string.length + substring.length; 1452 if (start !== void 0 && end !== void 0) { 1453 if (start >= startIndex && start < nextStart) { 1454 value.start = start - startIndex; 1455 } else if (start < startIndex && end > startIndex) { 1456 value.start = 0; 1457 } 1458 if (end >= startIndex && end < nextStart) { 1459 value.end = end - startIndex; 1460 } else if (start < nextStart && end > nextStart) { 1461 value.end = substring.length; 1462 } 1463 } 1464 return value; 1465 }); 1466} 1467function splitAtSelection({ formats, replacements, text, start, end }, startIndex = start, endIndex = end) { 1468 if (start === void 0 || end === void 0) { 1469 return; 1470 } 1471 const before = { 1472 formats: formats.slice(0, startIndex), 1473 replacements: replacements.slice(0, startIndex), 1474 text: text.slice(0, startIndex) 1475 }; 1476 const after = { 1477 formats: formats.slice(endIndex), 1478 replacements: replacements.slice(endIndex), 1479 text: text.slice(endIndex), 1480 start: 0, 1481 end: 0 1482 }; 1483 return [before, after]; 1484} 1485 1486 1487;// ./node_modules/@wordpress/rich-text/build-module/is-range-equal.js 1488function isRangeEqual(a, b) { 1489 return a === b || a && b && a.startContainer === b.startContainer && a.startOffset === b.startOffset && a.endContainer === b.endContainer && a.endOffset === b.endOffset; 1490} 1491 1492 1493;// ./node_modules/@wordpress/rich-text/build-module/to-dom.js 1494 1495 1496 1497const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML"; 1498function createPathToNode(node, rootNode, path) { 1499 const parentNode = node.parentNode; 1500 let i = 0; 1501 while (node = node.previousSibling) { 1502 i++; 1503 } 1504 path = [i, ...path]; 1505 if (parentNode !== rootNode) { 1506 path = createPathToNode(parentNode, rootNode, path); 1507 } 1508 return path; 1509} 1510function getNodeByPath(node, path) { 1511 path = [...path]; 1512 while (node && path.length > 1) { 1513 node = node.childNodes[path.shift()]; 1514 } 1515 return { 1516 node, 1517 offset: path[0] 1518 }; 1519} 1520function to_dom_append(element, child) { 1521 if (child.html !== void 0) { 1522 return element.innerHTML += child.html; 1523 } 1524 if (typeof child === "string") { 1525 child = element.ownerDocument.createTextNode(child); 1526 } 1527 const { type, attributes } = child; 1528 if (type) { 1529 if (type === "#comment") { 1530 child = element.ownerDocument.createComment( 1531 attributes["data-rich-text-comment"] 1532 ); 1533 } else { 1534 const parentNamespace = element.namespaceURI; 1535 if (type === "math") { 1536 child = element.ownerDocument.createElementNS( 1537 MATHML_NAMESPACE, 1538 type 1539 ); 1540 } else if (parentNamespace === MATHML_NAMESPACE) { 1541 if (element.tagName === "MTEXT") { 1542 child = element.ownerDocument.createElement(type); 1543 } else { 1544 child = element.ownerDocument.createElementNS( 1545 MATHML_NAMESPACE, 1546 type 1547 ); 1548 } 1549 } else { 1550 child = element.ownerDocument.createElement(type); 1551 } 1552 for (const key in attributes) { 1553 child.setAttribute(key, attributes[key]); 1554 } 1555 } 1556 } 1557 return element.appendChild(child); 1558} 1559function to_dom_appendText(node, text) { 1560 node.appendData(text); 1561} 1562function to_dom_getLastChild({ lastChild }) { 1563 return lastChild; 1564} 1565function to_dom_getParent({ parentNode }) { 1566 return parentNode; 1567} 1568function to_dom_isText(node) { 1569 return node.nodeType === node.TEXT_NODE; 1570} 1571function to_dom_getText({ nodeValue }) { 1572 return nodeValue; 1573} 1574function to_dom_remove(node) { 1575 return node.parentNode.removeChild(node); 1576} 1577function toDom({ 1578 value, 1579 prepareEditableTree, 1580 isEditableTree = true, 1581 placeholder, 1582 doc = document 1583}) { 1584 let startPath = []; 1585 let endPath = []; 1586 if (prepareEditableTree) { 1587 value = { 1588 ...value, 1589 formats: prepareEditableTree(value) 1590 }; 1591 } 1592 const createEmpty = () => createElement(doc, ""); 1593 const tree = toTree({ 1594 value, 1595 createEmpty, 1596 append: to_dom_append, 1597 getLastChild: to_dom_getLastChild, 1598 getParent: to_dom_getParent, 1599 isText: to_dom_isText, 1600 getText: to_
1600dom_getText, 1601 remove: to_dom_remove, 1602 appendText: to_dom_appendText, 1603 onStartIndex(body, pointer) { 1604 startPath = createPathToNode(pointer, body, [ 1605 pointer.nodeValue.length 1606 ]); 1607 }, 1608 onEndIndex(body, pointer) { 1609 endPath = createPathToNode(pointer, body, [ 1610 pointer.nodeValue.length 1611 ]); 1612 }, 1613 isEditableTree, 1614 placeholder 1615 }); 1616 return { 1617 body: tree, 1618 selection: { startPath, endPath } 1619 }; 1620} 1621function apply({ 1622 value, 1623 current, 1624 prepareEditableTree, 1625 __unstableDomOnly, 1626 placeholder 1627}) { 1628 const { body, selection } = toDom({ 1629 value, 1630 prepareEditableTree, 1631 placeholder, 1632 doc: current.ownerDocument 1633 }); 1634 applyValue(body, current); 1635 if (value.start !== void 0 && !__unstableDomOnly) { 1636 applySelection(selection, current); 1637 } 1638} 1639function applyValue(future, current) { 1640 let i = 0; 1641 let futureChild; 1642 while (futureChild = future.firstChild) { 1643 const currentChild = current.childNodes[i]; 1644 if (!currentChild) { 1645 current.appendChild(futureChild); 1646 } else if (!currentChild.isEqualNode(futureChild)) { 1647 if (currentChild.nodeName !== futureChild.nodeName || currentChild.nodeType === currentChild.TEXT_NODE && currentChild.data !== futureChild.data) { 1648 current.replaceChild(futureChild, currentChild); 1649 } else { 1650 const currentAttributes = currentChild.attributes; 1651 const futureAttributes = futureChild.attributes; 1652 if (currentAttributes) { 1653 let ii = currentAttributes.length; 1654 while (ii--) { 1655 const { name } = currentAttributes[ii]; 1656 if (!futureChild.getAttribute(name)) { 1657 currentChild.removeAttribute(name); 1658 } 1659 } 1660 } 1661 if (futureAttributes) { 1662 for (let ii = 0; ii < futureAttributes.length; ii++) { 1663 const { name, value } = futureAttributes[ii]; 1664 if (currentChild.getAttribute(name) !== value) { 1665 currentChild.setAttribute(name, value); 1666 } 1667 } 1668 } 1669 applyValue(futureChild, currentChild); 1670 future.removeChild(futureChild); 1671 } 1672 } else { 1673 future.removeChild(futureChild); 1674 } 1675 i++; 1676 } 1677 while (current.childNodes[i]) { 1678 current.removeChild(current.childNodes[i]); 1679 } 1680} 1681function applySelection({ startPath, endPath }, current) { 1682 const { node: startContainer, offset: startOffset } = getNodeByPath( 1683 current, 1684 startPath 1685 ); 1686 const { node: endContainer, offset: endOffset } = getNodeByPath( 1687 current, 1688 endPath 1689 ); 1690 const { ownerDocument } = current; 1691 const { defaultView } = ownerDocument; 1692 const selection = defaultView.getSelection(); 1693 const range = ownerDocument.createRange(); 1694 range.setStart(startContainer, startOffset); 1695 range.setEnd(endContainer, endOffset); 1696 const { activeElement } = ownerDocument; 1697 if (selection.rangeCount > 0) { 1698 if (isRangeEqual(range, selection.getRangeAt(0))) { 1699 return; 1700 } 1701 selection.removeAllRanges(); 1702 } 1703 selection.addRange(range); 1704 if (activeElement !== ownerDocument.activeElement) { 1705 if (activeElement instanceof defaultView.HTMLElement) { 1706 activeElement.focus(); 1707 } 1708 } 1709} 1710 1711 1712;// external ["wp","a11y"] 1713const external_wp_a11y_namespaceObject = window["wp"]["a11y"]; 1714;// external ["wp","i18n"] 1715const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; 1716;// ./node_modules/@wordpress/rich-text/build-module/toggle-format.js 1717 1718 1719 1720 1721 1722function toggleFormat(value, format) { 1723 if (getActiveFormat(value, format.type)) { 1724 if (format.title) { 1725 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)("%s removed."), format.title), "assertive"); 1726 } 1727 return removeFormat(value, format.type); 1728 } 1729 if (format.title) { 1730 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)("%s applied."), format.title), "assertive"); 1731 } 1732 return applyFormat(value, format); 1733} 1734 1735 1736;// ./node_modules/@wordpress/rich-text/build-module/unregister-format-type.js 1737 1738 1739function unregisterFormatType(name) { 1740 const oldFormat = (0,external_wp_data_namespaceObject.select)(store).getFormatType(name); 1741 if (!oldFormat) { 1742 window.console.error(`Format ${name} is not registered.`); 1743 return; 1744 } 1745 (0,external_wp_data_namespaceObject.dispatch)(store).removeFormatTypes(name); 1746 return oldFormat; 1747} 1748 1749 1750;
1750// external ["wp","element"] 1751const external_wp_element_namespaceObject = window["wp"]["element"]; 1752;// external ["wp","deprecated"] 1753const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"]; 1754var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject); 1755;// ./node_modules/@wordpress/rich-text/build-module/component/use-anchor-ref.js 1756 1757 1758 1759function useAnchorRef({ ref, value, settings = {} }) { 1760 external_wp_deprecated_default()("`useAnchorRef` hook", { 1761 since: "6.1", 1762 alternative: "`useAnchor` hook" 1763 }); 1764 const { tagName, className, name } = settings; 1765 const activeFormat = name ? getActiveFormat(value, name) : void 0; 1766 return (0,external_wp_element_namespaceObject.useMemo)(() => { 1767 if (!ref.current) { 1768 return; 1769 } 1770 const { 1771 ownerDocument: { defaultView } 1772 } = ref.current; 1773 const selection = defaultView.getSelection(); 1774 if (!selection.rangeCount) { 1775 return; 1776 } 1777 const range = selection.getRangeAt(0); 1778 if (!activeFormat) { 1779 return range; 1780 } 1781 let element = range.startContainer; 1782 element = element.nextElementSibling || element; 1783 while (element.nodeType !== element.ELEMENT_NODE) { 1784 element = element.parentNode; 1785 } 1786 return element.closest( 1787 tagName + (className ? "." + className : "") 1788 ); 1789 }, [activeFormat, value.start, value.end, tagName, className]); 1790} 1791 1792 1793;// external ["wp","compose"] 1794const external_wp_compose_namespaceObject = window["wp"]["compose"]; 1795;// ./node_modules/@wordpress/rich-text/build-module/component/use-anchor.js 1796 1797 1798function getFormatElement(range, editableContentElement, tagName, className) { 1799 let element = range.startContainer; 1800 if (element.nodeType === element.TEXT_NODE && range.startOffset === element.length && element.nextSibling) { 1801 element = element.nextSibling; 1802 while (element.firstChild) { 1803 element = element.firstChild; 1804 } 1805 } 1806 if (element.nodeType !== element.ELEMENT_NODE) { 1807 element = element.parentElement; 1808 } 1809 if (!element) { 1810 return; 1811 } 1812 if (element === editableContentElement) { 1813 return; 1814 } 1815 if (!editableContentElement.contains(element)) { 1816 return; 1817 } 1818 const selector = tagName + (className ? "." + className : ""); 1819 while (element !== editableContentElement) { 1820 if (element.matches(selector)) { 1821 return element; 1822 } 1823 element = element.parentElement; 1824 } 1825} 1826function createVirtualAnchorElement(range, editableContentElement) { 1827 return { 1828 contextElement: editableContentElement, 1829 getBoundingClientRect() { 1830 return editableContentElement.contains(range.startContainer) ? range.getBoundingClientRect() : editableContentElement.getBoundingClientRect(); 1831 } 1832 }; 1833} 1834function getAnchor(editableContentElement, tagName, className) { 1835 if (!editableContentElement) { 1836 return; 1837 } 1838 const { ownerDocument } = editableContentElement; 1839 const { defaultView } = ownerDocument; 1840 const selection = defaultView.getSelection(); 1841 if (!selection) { 1842 return; 1843 } 1844 if (!selection.rangeCount) { 1845 return; 1846 } 1847 const range = selection.getRangeAt(0); 1848 if (!range || !range.startContainer) { 1849 return; 1850 } 1851 const formatElement = getFormatElement( 1852 range, 1853 editableContentElement, 1854 tagName, 1855 className 1856 ); 1857 if (formatElement) { 1858 return formatElement; 1859 } 1860 return createVirtualAnchorElement(range, editableContentElement); 1861} 1862function useAnchor({ editableContentElement, settings = {} }) { 1863 const { tagName, className, isActive } = settings; 1864 const [anchor, setAnchor] = (0,external_wp_element_namespaceObject.useState)( 1865 () => getAnchor(editableContentElement, tagName, className) 1866 ); 1867 const wasActive = (0,external_wp_compose_namespaceObject.usePrevious)(isActive); 1868 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 1869 if (!editableContentElement) { 1870 return; 1871 } 1872 function callback() { 1873 setAnchor( 1874 getAnchor(editableContentElement, tagName, className) 1875 ); 1876 } 1877 function attach() { 1878 ownerDocument.addEventListener("selectionchange", callback); 1879 } 1880 function detach() { 1881 ownerDocument.removeEventListener("selectionchange", callback); 1882 } 1883 const { ownerDocument } = editableContentElement; 1884 if (editableContentElement === ownerDocument.activeElement || // When a link is created, we need to attach the popover to the newly created anchor. 1885 !wasActive && isActive || // Sometimes we're _removing_ an active anchor, such as the inline color popover.
vendor: 4,879 bytes, lines 1886-1922
1886 // When we add the color, it switches from a virtual anchor to a `<mark>` element. 1887 // When we _remove_ the color, it switches from a `<mark>` element to a virtual anchor. 1888 wasActive && !isActive) { 1889 setAnchor( 1890 getAnchor(editableContentElement, tagName, className) 1891 ); 1892 attach(); 1893 } 1894 editableContentElement.addEventListener("focusin", attach); 1895 editableContentElement.addEventListener("focusout", detach); 1896 return () => { 1897 detach(); 1898 editableContentElement.removeEventListener("focusin", attach); 1899 editableContentElement.removeEventListener("focusout", detach); 1900 }; 1901 }, [editableContentElement, tagName, className, isActive, wasActive]); 1902 return anchor; 1903} 1904 1905 1906;// ./node_modules/@wordpress/rich-text/build-module/component/use-default-style.js 1907 1908const whiteSpace = "pre-wrap"; 1909const minWidth = "1px"; 1910function useDefaultStyle() { 1911 return (0,external_wp_element_namespaceObject.useCallback)((element) => { 1912 if (!element) { 1913 return; 1914 } 1915 element.style.whiteSpace = whiteSpace; 1916 element.style.minWidth = minWidth; 1917 }, []); 1918} 1919 1920 1921;// ./node_modules/colord/index.mjs 1922var r={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n+0},e=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},u=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},a=function(r){return{r:e(r.r,0,255),g:e(r.g,0,255),b:e(r.b,0,255),a:e(r.a)}},o=function(r){return{r:n(r.r),g:n(r.g),b:n(r.b),a:n(r.a,3)}},i=/^#([0-9a-f]{3,8})$/i,s=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},h=function(r){var t=r.r,n=r.g,e=r.b,u=r.a,a=Math.max(t,n,e),o=a-Math.min(t,n,e),i=o?a===t?(n-e)/o:a===n?2+(e-t)/o:4+(t-n)/o:0;return{h:60*(i<0?i+6:i),s:a?o/a*100:0,v:a/255*100,a:u}},b=function(r){var t=r.h,n=r.s,e=r.v,u=r.a;t=t/360*6,n/=100,e/=100;var a=Math.floor(t),o=e*(1-n),i=e*(1-(t-a)*n),s=e*(1-(1-t+a)*n),h=a%6;return{r:255*[e,i,o,o,s,e][h],g:255*[s,e,e,i,o,o][h],b:255*[o,o,s,e,e,i][h],a:u}},g=function(r){return{h:u(r.h),s:e(r.s,0,100),l:e(r.l,0,100),a:e(r.a)}},d=function(r){return{h:n(r.h),s:n(r.s),l:n(r.l),a:n(r.a,3)}},f=function(r){return b((n=(t=r).s,{h:t.h,s:(n*=((e=t.l)<50?e:100-e)/100)>0?2*n/(e+n)*100:0,v:e+n,a:t.a}));var t,n,e},c=function(r){return{h:(t=h(r)).h,s:(u=(200-(n=t.s))*(e=t.v)/100)>0&&u<200?n*e/100/(u<=100?u:200-u)*100:0,l:u/2,a:t.a};var t,n,e,u},l=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,p=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,v=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,m=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y={string:[[function(r){var t=i.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:4===r.length?n(parseInt(r[3]+r[3],16)/255,2):1}:6===r.length||8===r.length?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:8===r.length?n(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=v.exec(r)||m.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:a({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:void 0===t[7]?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(t){var n=l.exec(t)||p.exec(t);if(!n)return null;var e,u,a=g({h:(e=n[1],u=n[2],void 0===u&&(u="deg"),Number(e)*(r[u]||1)),s:Number(n[3]),l:Number(n[4]),a:void 0===n[5]?1:Number(n[5])/(n[6]?100:1)});return f(a)},"hsl"]],object:[[function(r){var n=r.r,e=r.g,u=r.b,o=r.a,i=void 0===o?1:o;return t(n)&&t(e)&&t(u)?a({r:Number(n),g:Number(e),b:Number(u),a:Number(i)}):null},"rgb"],[function(r){var n=r.h,e=r.s,u=r.l,a=r.a,o=void 0===a?1:a;if(!t(n)||!t(e)||!t(u))return null;var i=g({h:Number(n),s:Number(e),l:Number(u),a:Number(o)});return f(i)},"hsl"],[function(r){var n=r.h,a=r.s,o=r.v,i=r.a,s=void 0===i?1:i;if(!t(n)||!t(a)||!t(o))return null;var h=function(r){return{h:u(r.h),s:e(r.s,0,100),v:e(r.v,0,100),a:e(r.a)}}({h:Number(n),s:Number(a),v:Number(o),a:Number(s)});return b(h)},"hsv"]]},N=function(r,t){for(var n=0;n<t.length;n++){var e=t[n][0](r);if(e)return[e,t[n][1]]}return[null,void 0]},x=function(r){return"string"==typeof r?N(r.trim(),y.string):"object"==typeof r&&null!==r?N(r,y.object):[null,void 0]},I=function(r){return x(r)[1]},M=function(r,t){var n=c(r);return{h:n.h,s:e(n.s+100*t,0,100),l:n.l,a:n.a}},H=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},$=function(r,t){var n=c(r);return{h:n.h,s:n.s,l:e(n.l+100*t,0,100),a:n.a}
1922},j=function(){function r(r){this.parsed=x(r)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return null!==this.parsed},r.prototype.brightness=function(){return n(H(this.rgba),2)},r.prototype.isDark=function(){return H(this.rgba)<.5},r.prototype.isLight=function(){return H(this.rgba)>=.5},r.prototype.toHex=function(){return r=o(this.rgba),t=r.r,e=r.g,u=r.b,i=(a=r.a)<1?s(n(255*a)):"","#"+s(t)+s(e)+s(u)+i;var r,t,e,u,a,i},r.prototype.toRgb=function(){return o(this.rgba)},r.prototype.toRgbString=function(){return r=o(this.rgba),t=r.r,n=r.g,e=r.b,(u=r.a)<1?"rgba("+t+", "+n+", "+e+", "+u+")":"rgb("+t+", "+n+", "+e+")";var r,t,n,e,u},r.prototype.toHsl=function(){return d(c(this.rgba))},r.prototype.toHslString=function(){return r=d(c(this.rgba)),t=r.h,n=r.s,e=r.l,(u=r.a)<1?"hsla("+t+", "+n+"%, "+e+"%, "+u+")":"hsl("+t+", "+n+"%, "+e+"%)";var r,t,n,e,u},r.prototype.toHsv=function(){return r=h(this.rgba),{h:n(r.h),s:n(r.s),v:n(r.v),a:n(r.a,3)};var r},r.prototype.invert=function(){return w({r:255-(r=this.rgba).r,g:255-r.g,b:255-r.b,a:r.a});var r},r.prototype.saturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,r))},r.prototype.desaturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,-r))},r.prototype.grayscale=function(){return w(M(this.rgba,-1))},r.prototype.lighten=function(r){return void 0===r&&(r=.1),w($(this.rgba,r))},r.prototype.darken=function(r){return void 0===r&&(r=.1),w($(this.rgba,-r))},r.prototype.rotate=function(r){return void 0===r&&(r=15),this.hue(this.hue()+r)},r.prototype.alpha=function(r){return"number"==typeof r?w({r:(t=this.rgba).r,g:t.g,b:t.b,a:r}):n(this.rgba.a,3);var t},r.prototype.hue=function(r){var t=c(this.rgba);return"number"==typeof r?w({h:r,s:t.s,l:t.l,a:t.a}):n(t.h)},r.prototype.isEqual=function(r){return this.toHex()===w(r).toHex()},r}(),w=function(r){return r instanceof j?r:new j(r)},S=(/* unused pure expression or super */ null && ([])),k=function(r){r.forEach(function(r){S.indexOf(r)<0&&(r(j,y),S.push(r))})},E=function(){return new j({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})}; 1923 1924;// ./node_modules/@wordpress/rich-text/build-module/component/use-boundary-style.js 1925 1926 1927function useBoundaryStyle({ record }) { 1928 const ref = (0,external_wp_element_namespaceObject.useRef)(); 1929 const { activeFormats = [], replacements, start } = record.current; 1930 const activeReplacement = replacements[start]; 1931 (0,external_wp_element_namespaceObject.useEffect)(() => { 1932 if ((!activeFormats || !activeFormats.length) && !activeReplacement) { 1933 return; 1934 } 1935 const boundarySelector = "*[data-rich-text-format-boundary]"; 1936 const element = ref.current.querySelector(boundarySelector); 1937 if (!element) { 1938 return; 1939 } 1940 const { ownerDocument } = element; 1941 const { defaultView } = ownerDocument; 1942 const computedStyle = defaultView.getComputedStyle(element); 1943 const newColor = w(computedStyle.color).alpha(0.2).toRgbString(); 1944 const selector = `.rich-text:focus ${boundarySelector}`; 1945 const rule = `background-color: ${newColor}`; 1946 const style = `${selector} {${rule}}`; 1947 const globalStyleId = "rich-text-boundary-style"; 1948 let globalStyle = ownerDocument.getElementById(globalStyleId); 1949 if (!globalStyle) { 1950 globalStyle = ownerDocument.createElement("style"); 1951 globalStyle.id = globalStyleId; 1952 ownerDocument.head.appendChild(globalStyle); 1953 } 1954 if (globalStyle.innerHTML !== style) { 1955 globalStyle.innerHTML = style; 1956 } 1957 }, [activeFormats, activeReplacement]); 1958 return ref; 1959} 1960 1961 1962;// ./node_modules/@wordpress/rich-text/build-module/component/event-listeners/copy-handler.js 1963 1964 1965 1966 1967var copy_handler_default = (props) => (element) => { 1968 function onCopy(event) { 1969 const { record } = props.current; 1970 const { ownerDocument } = element; 1971 if (isCollapsed(record.current) || !element.contains(ownerDocument.activeElement)) { 1972 return; 1973 } 1974 const selectedRecord = slice(record.current); 1975 const plainText = getTextContent(selectedRecord); 1976 const html = toHTMLString({ value: selectedRecord }); 1977 event.clipboardData.setData("text/plain", plainText); 1978 event.clipboardData.setData("text/html", html); 1979 event.clipboardData.setData("rich-text", "true"); 1980 event.preventDefault(); 1981 if (event.type === "cut") { 1982 ownerDocument.execCommand("delete"); 1983 } 1984 } 1985 const { defaultView } = element.ownerDocument; 1986 defaultView.addEventListener("copy", onCopy); 1987 defaultView.addEventListener("cut", onCopy); 1988 return () => { 1989 defaultView.removeEventListener("copy", onCopy); 1990 defaultView.removeEventListener("cut", onCopy); 1991 }; 1992}; 1993 1994 1995;// ./node_modules/@wordpress/rich-text/build-module/component/event-listeners/select-object.js 1996var select_object_default = () => (element) => { 1997 function onClick(event) { 1998 const { target } = event; 1999 if (target === element || target.textContent && target.isContentEditable) { 2000 return; 2001 } 2002 const { ownerDocument } = target; 2003 const { defaultView } = ownerDocument; 2004 const selection = defaultView.getSelection(); 2005 if (selection.containsNode(target)) { 2006 return; 2007 } 2008 const range = ownerDocument.createRange(); 2009 const nodeToSelect = target.isContentEditable ? target : target.closest("[contenteditable]"); 2010 range.selectNode(nodeToSelect); 2011 selection.removeAllRanges(); 2012 selection.addRange(range); 2013 event.preventDefault(); 2014 } 2015 function onFocusIn(event) { 2016 if (event.relatedTarget && !element.contains(event.relatedTarget) && event.relatedTarget.tagName === "A") { 2017 onClick(event); 2018 } 2019 } 2020 element.addEventListener("click", onClick); 2021 element.addEventListener("focusin", onFocusIn); 2022 return () => { 2023 element.removeEventListener("click", onClick); 2024 element.removeEventListener("focusin", onFocusIn); 2025 }; 2026}; 2027 2028 2029;
2029// external ["wp","keycodes"] 2030const external_wp_keycodes_namespaceObject = window["wp"]["keycodes"]; 2031;// ./node_modules/@wordpress/rich-text/build-module/component/event-listeners/format-boundaries.js 2032 2033 2034const EMPTY_ACTIVE_FORMATS = []; 2035var format_boundaries_default = (props) => (element) => { 2036 function onKeyDown(event) { 2037 const { keyCode, shiftKey, altKey, metaKey, ctrlKey } = event; 2038 if ( 2039 // Only override left and right keys without modifiers pressed. 2040 shiftKey || altKey || metaKey || ctrlKey || keyCode !== external_wp_keycodes_namespaceObject.LEFT && keyCode !== external_wp_keycodes_namespaceObject.RIGHT 2041 ) { 2042 return; 2043 } 2044 const { record, applyRecord, forceRender } = props.current; 2045 const { 2046 text, 2047 formats, 2048 start, 2049 end, 2050 activeFormats: currentActiveFormats = [] 2051 } = record.current; 2052 const collapsed = isCollapsed(record.current); 2053 const { ownerDocument } = element; 2054 const { defaultView } = ownerDocument; 2055 const { direction } = defaultView.getComputedStyle(element); 2056 const reverseKey = direction === "rtl" ? external_wp_keycodes_namespaceObject.RIGHT : external_wp_keycodes_namespaceObject.LEFT; 2057 const isReverse = event.keyCode === reverseKey; 2058 if (collapsed && currentActiveFormats.length === 0) { 2059 if (start === 0 && isReverse) { 2060 return; 2061 } 2062 if (end === text.length && !isReverse) { 2063 return; 2064 } 2065 } 2066 if (!collapsed) { 2067 return; 2068 } 2069 const formatsBefore = formats[start - 1] || EMPTY_ACTIVE_FORMATS; 2070 const formatsAfter = formats[start] || EMPTY_ACTIVE_FORMATS; 2071 const destination = isReverse ? formatsBefore : formatsAfter; 2072 const isIncreasing = currentActiveFormats.every( 2073 (format, index) => format === destination[index] 2074 ); 2075 let newActiveFormatsLength = currentActiveFormats.length; 2076 if (!isIncreasing) { 2077 newActiveFormatsLength--; 2078 } else if (newActiveFormatsLength < destination.length) { 2079 newActiveFormatsLength++; 2080 } 2081 if (newActiveFormatsLength === currentActiveFormats.length) { 2082 record.current._newActiveFormats = destination; 2083 return; 2084 } 2085 event.preventDefault(); 2086 const origin = isReverse ? formatsAfter : formatsBefore; 2087 const source = isIncreasing ? destination : origin; 2088 const newActiveFormats = source.slice(0, newActiveFormatsLength); 2089 const newValue = { 2090 ...record.current, 2091 activeFormats: newActiveFormats 2092 }; 2093 record.current = newValue; 2094 applyRecord(newValue); 2095 forceRender(); 2096 } 2097 element.addEventListener("keydown", onKeyDown); 2098 return () => { 2099 element.removeEventListener("keydown", onKeyDown); 2100 }; 2101}; 2102 2103 2104;// ./node_modules/@wordpress/rich-text/build-module/component/event-listeners/delete.js 2105 2106 2107var delete_default = (props) => (element) => { 2108 function onKeyDown(event) { 2109 const { keyCode } = event; 2110 const { createRecord, handleChange } = props.current; 2111 if (event.defaultPrevented) { 2112 return; 2113 } 2114 if (keyCode !== external_wp_keycodes_namespaceObject.DELETE && keyCode !== external_wp_keycodes_namespaceObject.BACKSPACE) { 2115 return; 2116 } 2117 const currentValue = createRecord(); 2118 const { start, end, text } = currentValue; 2119 if (start === 0 && end !== 0 && end === text.length) { 2120 handleChange(remove_remove(currentValue)); 2121 event.preventDefault(); 2122 } 2123 } 2124 element.addEventListener("keydown", onKeyDown); 2125 return () => { 2126 element.removeEventListener("keydown", onKeyDown); 2127 }; 2128}; 2129 2130 2131;// ./node_modules/@wordpress/rich-text/build-module/update-formats.js 2132 2133function updateFormats({ value, start, end, formats }) { 2134 const min = Math.min(start, end); 2135 const max = Math.max(start, end); 2136 const formatsBefore = value.formats[min - 1] || []; 2137 const formatsAfter = value.formats[max] || []; 2138 value.activeFormats = formats.map((format, index) => { 2139 if (formatsBefore[index]) { 2140 if (isFormatEqual(format, formatsBefore[index])) { 2141 return formatsBefore[index]; 2142 } 2143 } else if (formatsAfter[index]) { 2144 if (isFormatEqual(format, formatsAfter[index])) { 2145 return formatsAfter[index]; 2146 } 2147 } 2148 return format; 2149 }); 2150 while (--end >= start) { 2151 if (value.activeFormats.length > 0) { 2152 value.formats[end] = value.activeFormats; 2153 } else { 2154 delete value.formats[end]; 2155 } 2156 } 2157 return value; 2158} 2159 2160 2161;// ./node_modules/@wordpress/rich-text/build-module/component/event-listeners/input-and-selection.js 2162 2163 2164const INSERTION_INPUT_TYPES_TO_IGNORE = /* @__PURE__ */ new Set([ 2165 "insertParagraph", 2166 "insertOrderedList", 2167 "insertUnorderedList", 2168 "insertHorizontalRule", 2169 "insertLink" 2170]); 2171const input_and_selection_EMPTY_ACTIVE_FORMATS = []; 2172const PLACEHOLDER_ATTR_NAME = "data-rich-text-placeholder"; 2173function fixPlaceholderSelection(defaultView) { 2174 const selection = defaultView.getSelection(); 2175 const { anchorNode, anchorOffset } = selection; 2176 if (anchorNode.nodeType !== anchorNode.ELEMENT_NODE) { 2177 return; 2178 } 2179 const targetNode = anchorNode.childNodes[anchorOffset]; 2180 if (!targetNode || targetNode.nodeType !== targetNode.ELEMENT_NODE || !targetNode.hasAttribute(PLACEHOLDER_ATTR_NAME)) { 2181 return; 2182 } 2183 selection.collapseToStart(); 2184} 2185var input_and_selection_default = (props) => (element) => { 2186 const { ownerDocument } = element; 2187 const { defaultView } = ownerDocument; 2188 let isComposing = false;
2189 function onInput(event) { 2190 if (isComposing) { 2191 return; 2192 } 2193 let inputType; 2194 if (event) { 2195 inputType = event.inputType; 2196 } 2197 const { record, applyRecord, createRecord, handleChange } = props.current; 2198 if (inputType && (inputType.indexOf("format") === 0 || INSERTION_INPUT_TYPES_TO_IGNORE.has(inputType))) { 2199 applyRecord(record.current); 2200 return; 2201 } 2202 const currentValue = createRecord(); 2203 const { start, activeFormats: oldActiveFormats = [] } = record.current; 2204 const change = updateFormats({ 2205 value: currentValue, 2206 start, 2207 end: currentValue.start, 2208 formats: oldActiveFormats 2209 }); 2210 handleChange(change); 2211 } 2212 function handleSelectionChange() { 2213 const { record, applyRecord, createRecord, onSelectionChange } = props.current; 2214 if (element.contentEditable !== "true") { 2215 return; 2216 } 2217 if (ownerDocument.activeElement !== element) { 2218 ownerDocument.removeEventListener( 2219 "selectionchange", 2220 handleSelectionChange 2221 ); 2222 return; 2223 } 2224 if (isComposing) { 2225 return; 2226 } 2227 const { start, end, text } = createRecord(); 2228 const oldRecord = record.current; 2229 if (text !== oldRecord.text) { 2230 onInput(); 2231 return; 2232 } 2233 if (start === oldRecord.start && end === oldRecord.end) { 2234 if (oldRecord.text.length === 0 && start === 0) { 2235 fixPlaceholderSelection(defaultView); 2236 } 2237 return; 2238 } 2239 const newValue = { 2240 ...oldRecord, 2241 start, 2242 end, 2243 // _newActiveFormats may be set on arrow key navigation to control 2244 // the right boundary position. If undefined, getActiveFormats will 2245 // give the active formats according to the browser. 2246 activeFormats: oldRecord._newActiveFormats, 2247 _newActiveFormats: void 0 2248 }; 2249 const newActiveFormats = getActiveFormats( 2250 newValue, 2251 input_and_selection_EMPTY_ACTIVE_FORMATS 2252 ); 2253 newValue.activeFormats = newActiveFormats; 2254 record.current = newValue; 2255 applyRecord(newValue, { domOnly: true }); 2256 onSelectionChange(start, end); 2257 } 2258 function onCompositionStart() { 2259 isComposing = true; 2260 ownerDocument.removeEventListener( 2261 "selectionchange", 2262 handleSelectionChange 2263 ); 2264 element.querySelector(`[${PLACEHOLDER_ATTR_NAME}]`)?.remove(); 2265 } 2266 function onCompositionEnd() { 2267 isComposing = false; 2268 onInput({ inputType: "insertText" }); 2269 ownerDocument.addEventListener( 2270 "selectionchange", 2271 handleSelectionChange 2272 ); 2273 } 2274 function onFocus() { 2275 const { record, isSelected, onSelectionChange, applyRecord } = props.current; 2276 if (element.parentElement.closest('[contenteditable="true"]')) { 2277 return; 2278 } 2279 if (!isSelected) { 2280 const index = void 0; 2281 record.current = { 2282 ...record.current, 2283 start: index, 2284 end: index, 2285 activeFormats: input_and_selection_EMPTY_ACTIVE_FORMATS 2286 }; 2287 } else { 2288 applyRecord(record.current, { domOnly: true }); 2289 } 2290 onSelectionChange(record.current.start, record.current.end); 2291 window.queueMicrotask(handleSelectionChange); 2292 ownerDocument.addEventListener( 2293 "selectionchange", 2294 handleSelectionChange 2295 ); 2296 } 2297 element.addEventListener("input", onInput); 2298 element.addEventListener("compositionstart", onCompositionStart); 2299 element.addEventListener("compositionend", onCompositionEnd); 2300 element.addEventListener("focus", onFocus); 2301 return () => { 2302 element.removeEventListener("input", onInput); 2303 element.removeEventListener("compositionstart", onCompositionStart); 2304 element.removeEventListener("compositionend", onCompositionEnd); 2305 element.removeEventListener("focus", onFocus); 2306 }; 2307}; 2308 2309 2310;// ./node_modules/@wordpress/rich-text/build-module/component/event-listeners/selection-change-compat.js 2311 2312var selection_change_compat_default = () => (element) => { 2313 const { ownerDocument } = element; 2314 const { defaultView } = ownerDocument; 2315 const selection = defaultView?.getSelection(); 2316 let range; 2317 function getRange() { 2318 return selection.rangeCount ? selection.getRangeAt(0) : null; 2319 } 2320 function onDown(event) { 2321 const type = event.type === "keydown" ? "keyup" : "pointerup"; 2322 function onCancel() { 2323 ownerDocument.removeEventListener(type, onUp); 2324 ownerDocument.removeEventListener("selectionchange", onCancel); 2325 ownerDocument.removeEventListener("input", onCancel); 2326 } 2327 function onUp() { 2328 onCancel(); 2329 if (isRangeEqual(range, getRange())) { 2330 return; 2331 } 2332 ownerDocument.dispatchEvent(new Event("selectionchange")); 2333 } 2334 ownerDocument.addEventListener(type, onUp); 2335 ownerDocument.addEventListener("selectionchange", onCancel); 2336 ownerDocument.addEventListener("input", onCancel); 2337 range = getRange(); 2338 } 2339 element.addEventListener("pointerdown", onDown); 2340 element.addEventListener("keydown", onDown); 2341 return () => { 2342 element.removeEventListener("pointerdown", onDown); 2343 element.removeEventListener("keydown", onDown); 2344 }; 2345}; 2346 2347 2348;// ./node_modules/@wordpress/rich-text/build-module/component/event-listeners/prevent-focus-capture.
2348js 2349function preventFocusCapture() { 2350 return (element) => { 2351 const { ownerDocument } = element; 2352 const { defaultView } = ownerDocument; 2353 let value = null; 2354 function onPointerDown(event) { 2355 if (event.defaultPrevented) { 2356 return; 2357 } 2358 if (event.target === element) { 2359 return; 2360 } 2361 if (!event.target.contains(element)) { 2362 return; 2363 } 2364 value = element.getAttribute("contenteditable"); 2365 element.setAttribute("contenteditable", "false"); 2366 defaultView.getSelection().removeAllRanges(); 2367 } 2368 function onPointerUp() { 2369 if (value !== null) { 2370 element.setAttribute("contenteditable", value); 2371 value = null; 2372 } 2373 } 2374 defaultView.addEventListener("pointerdown", onPointerDown); 2375 defaultView.addEventListener("pointerup", onPointerUp); 2376 return () => { 2377 defaultView.removeEventListener("pointerdown", onPointerDown); 2378 defaultView.removeEventListener("pointerup", onPointerUp); 2379 }; 2380 }; 2381} 2382 2383 2384;// ./node_modules/@wordpress/rich-text/build-module/component/event-listeners/index.js 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394const allEventListeners = [ 2395 copy_handler_default, 2396 select_object_default, 2397 format_boundaries_default, 2398 delete_default, 2399 input_and_selection_default, 2400 selection_change_compat_default, 2401 preventFocusCapture 2402]; 2403function useEventListeners(props) { 2404 const propsRef = (0,external_wp_element_namespaceObject.useRef)(props); 2405 (0,external_wp_element_namespaceObject.useInsertionEffect)(() => { 2406 propsRef.current = props; 2407 }); 2408 const refEffects = (0,external_wp_element_namespaceObject.useMemo)( 2409 () => allEventListeners.map((refEffect) => refEffect(propsRef)), 2410 [propsRef] 2411 ); 2412 return (0,external_wp_compose_namespaceObject.useRefEffect)( 2413 (element) => { 2414 const cleanups = refEffects.map((effect) => effect(element)); 2415 return () => { 2416 cleanups.forEach((cleanup) => cleanup()); 2417 }; 2418 }, 2419 [refEffects] 2420 ); 2421} 2422 2423 2424;// ./node_modules/@wordpress/rich-text/build-module/component/index.js 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434function useRichText({ 2435 value = "", 2436 selectionStart, 2437 selectionEnd, 2438 placeholder, 2439 onSelectionChange, 2440 preserveWhiteSpace, 2441 onChange, 2442 __unstableDisableFormats: disableFormats, 2443 __unstableIsSelected: isSelected, 2444 __unstableDependencies = [], 2445 __unstableAfterParse, 2446 __unstableBeforeSerialize, 2447 __unstableAddInvisibleFormats 2448}) { 2449 const registry = (0,external_wp_data_namespaceObject.useRegistry)(); 2450 const [, forceRender] = (0,external_wp_element_namespaceObject.useReducer)(() => ({})); 2451 const ref = (0,external_wp_element_namespaceObject.useRef)(); 2452 function createRecord() { 2453 const { 2454 ownerDocument: { defaultView } 2455 } = ref.current; 2456 const selection = defaultView.getSelection(); 2457 const range = selection.rangeCount > 0 ? selection.getRangeAt(0) : null; 2458 return create({ 2459 element: ref.current, 2460 range, 2461 __unstableIsEditableTree: true 2462 }); 2463 } 2464 function applyRecord(newRecord, { domOnly } = {}) { 2465 apply({ 2466 value: newRecord, 2467 current: ref.current, 2468 prepareEditableTree: __unstableAddInvisibleFormats, 2469 __unstableDomOnly: domOnly, 2470 placeholder 2471 }); 2472 } 2473 const _valueRef = (0,external_wp_element_namespaceObject.useRef)(value); 2474 const recordRef = (0,external_wp_element_namespaceObject.useRef)(); 2475 function setRecordFromProps() { 2476 _valueRef.current = value; 2477 recordRef.current = value; 2478 if (!(value instanceof RichTextData)) { 2479 recordRef.current = value ? RichTextData.fromHTMLString(value, { preserveWhiteSpace }) : RichTextData.empty(); 2480 } 2481 recordRef.current = { 2482 text: recordRef.current.text, 2483 formats: recordRef.current.formats, 2484 replacements: recordRef.current.replacements 2485 }; 2486 if (disableFormats) { 2487 recordRef.current.formats = Array(value.length); 2488 recordRef.current.replacements = Array(value.length); 2489 } 2490 if (__unstableAfterParse) { 2491 recordRef.current.formats = __unstableAfterParse( 2492 recordRef.current 2493 ); 2494 } 2495 recordRef.current.start = selectionStart; 2496 recordRef.current.end = selectionEnd; 2497 } 2498 const hadSelectionUpdateRef = (0,external_wp_element_namespaceObject.useRef)(false); 2499 if (!recordRef.current) { 2500 hadSelectionUpdateRef.current = isSelected; 2501 setRecordFromProps(); 2502 } else if (selectionStart !== recordRef.current.start || selectionEnd !== re
2502cordRef.current.end) { 2503 hadSelectionUpdateRef.current = isSelected; 2504 recordRef.current = { 2505 ...recordRef.current, 2506 start: selectionStart, 2507 end: selectionEnd, 2508 activeFormats: void 0 2509 }; 2510 } 2511 function handleChange(newRecord) { 2512 recordRef.current = newRecord; 2513 applyRecord(newRecord); 2514 if (disableFormats) { 2515 _valueRef.current = newRecord.text; 2516 } else { 2517 const newFormats = __unstableBeforeSerialize ? __unstableBeforeSerialize(newRecord) : newRecord.formats; 2518 newRecord = { ...newRecord, formats: newFormats }; 2519 if (typeof value === "string") { 2520 _valueRef.current = toHTMLString({ 2521 value: newRecord, 2522 preserveWhiteSpace 2523 }); 2524 } else { 2525 _valueRef.current = new RichTextData(newRecord); 2526 } 2527 } 2528 const { start, end, formats, text } = recordRef.current; 2529 registry.batch(() => { 2530 onSelectionChange(start, end); 2531 onChange(_valueRef.current, { 2532 __unstableFormats: formats, 2533 __unstableText: text 2534 }); 2535 }); 2536 forceRender(); 2537 } 2538 function applyFromProps() { 2539 const previousValue = _valueRef.current; 2540 setRecordFromProps(); 2541 const contentLengthChanged = previousValue && typeof previousValue === "string" && typeof value === "string" && previousValue.length !== value.length; 2542 const hasFocus = ref.current?.contains( 2543 ref.current.ownerDocument.activeElement 2544 ); 2545 const skipSelection = contentLengthChanged && !hasFocus; 2546 applyRecord(recordRef.current, { domOnly: skipSelection }); 2547 } 2548 const didMountRef = (0,external_wp_element_namespaceObject.useRef)(false); 2549 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 2550 if (didMountRef.current && value !== _valueRef.current) { 2551 applyFromProps(); 2552 forceRender(); 2553 } 2554 }, [value]); 2555 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 2556 if (!hadSelectionUpdateRef.current) { 2557 return; 2558 } 2559 if (ref.current.ownerDocument.activeElement !== ref.current) { 2560 ref.current.focus(); 2561 } 2562 applyRecord(recordRef.current); 2563 hadSelectionUpdateRef.current = false; 2564 }, [hadSelectionUpdateRef.current]); 2565 const mergedRefs = (0,external_wp_compose_namespaceObject.useMergeRefs)([ 2566 ref, 2567 useDefaultStyle(), 2568 useBoundaryStyle({ record: recordRef }), 2569 useEventListeners({ 2570 record: recordRef, 2571 handleChange, 2572 applyRecord, 2573 createRecord, 2574 isSelected, 2575 onSelectionChange, 2576 forceRender 2577 }), 2578 (0,external_wp_compose_namespaceObject.useRefEffect)(() => { 2579 applyFromProps(); 2580 didMountRef.current = true; 2581 }, [placeholder, ...__unstableDependencies]) 2582 ]); 2583 return { 2584 value: recordRef.current, 2585 // A function to get the most recent value so event handlers in 2586 // useRichText implementations have access to it. For example when 2587 // listening to input events, we internally update the state, but this 2588 // state is not yet available to the input event handler because React 2589 // may re-render asynchronously. 2590 getValue: () => recordRef.current, 2591 onChange: handleChange, 2592 ref: mergedRefs 2593 }; 2594} 2595function __experimentalRichText() { 2596} 2597 2598 2599;// ./node_modules/@wordpress/rich-text/build-module/index.js 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629(window.wp = window.wp || {}).richText = __webpack_exports__; 2630/******/ })() 2631;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.