[ 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/make namespace object */ 8 /******/ (() => { 9 /******/ // define __esModule on exports 10 /******/ __webpack_require__.r = (exports) => { 11 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 12 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 13 /******/ } 14 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 15 /******/ }; 16 /******/ })(); 17 /******/ 18 /************************************************************************/ 19 var __webpack_exports__ = {}; 20 // ESM COMPAT FLAG 21 __webpack_require__.r(__webpack_exports__); 22 23 ;// CONCATENATED MODULE: external ["wp","richText"] 24 const external_wp_richText_namespaceObject = window["wp"]["richText"]; 25 ;// CONCATENATED MODULE: external "React" 26 const external_React_namespaceObject = window["React"]; 27 ;// CONCATENATED MODULE: external ["wp","i18n"] 28 const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; 29 ;// CONCATENATED MODULE: external ["wp","blockEditor"] 30 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"]; 31 ;// CONCATENATED MODULE: external ["wp","primitives"] 32 const external_wp_primitives_namespaceObject = window["wp"]["primitives"]; 33 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-bold.js 34 35 /** 36 * WordPress dependencies 37 */ 38 39 const formatBold = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 40 xmlns: "http://www.w3.org/2000/svg", 41 viewBox: "0 0 24 24" 42 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 43 d: "M14.7 11.3c1-.6 1.5-1.6 1.5-3 0-2.3-1.3-3.4-4-3.4H7v14h5.8c1.4 0 2.5-.3 3.3-1 .8-.7 1.2-1.7 1.2-2.9.1-1.9-.8-3.1-2.6-3.7zm-5.1-4h2.3c.6 0 1.1.1 1.4.4.3.3.5.7.5 1.2s-.2 1-.5 1.2c-.3.3-.8.4-1.4.4H9.6V7.3zm4.6 9c-.4.3-1 .4-1.7.4H9.6v-3.9h2.9c.7 0 1.3.2 1.7.5.4.3.6.8.6 1.5s-.2 1.2-.6 1.5z" 44 })); 45 /* harmony default export */ const format_bold = (formatBold); 46 47 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/bold/index.js 48 49 /** 50 * WordPress dependencies 51 */ 52 53 54 55 56 const bold_name = 'core/bold'; 57 const title = (0,external_wp_i18n_namespaceObject.__)('Bold'); 58 const bold = { 59 name: bold_name, 60 title, 61 tagName: 'strong', 62 className: null, 63 edit({ 64 isActive, 65 value, 66 onChange, 67 onFocus 68 }) { 69 function onToggle() { 70 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { 71 type: bold_name, 72 title 73 })); 74 } 75 function onClick() { 76 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { 77 type: bold_name 78 })); 79 onFocus(); 80 } 81 return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, { 82 type: "primary", 83 character: "b", 84 onUse: onToggle 85 }), (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { 86 name: "bold", 87 icon: format_bold, 88 title: title, 89 onClick: onClick, 90 isActive: isActive, 91 shortcutType: "primary", 92 shortcutCharacter: "b" 93 }), (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent, { 94 inputType: "formatBold", 95 onInput: onToggle 96 })); 97 } 98 }; 99 100 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/code.js 101 102 /** 103 * WordPress dependencies 104 */ 105 106 const code = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 107 viewBox: "0 0 24 24", 108 xmlns: "http://www.w3.org/2000/svg" 109 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 110 d: "M20.8 10.7l-4.3-4.3-1.1 1.1 4.3 4.3c.1.1.1.3 0 .4l-4.3 4.3 1.1 1.1 4.3-4.3c.7-.8.7-1.9 0-2.6zM4.2 11.8l4.3-4.3-1-1-4.3 4.3c-.7.7-.7 1.8 0 2.5l4.3 4.3 1.1-1.1-4.3-4.3c-.2-.1-.2-.3-.1-.4z" 111 })); 112 /* harmony default export */ const library_code = (code); 113 114 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/code/index.js 115 116 /** 117 * WordPress dependencies 118 */ 119 120 121 122 123 const code_name = 'core/code'; 124 const code_title = (0,external_wp_i18n_namespaceObject.__)('Inline code'); 125 const code_code = { 126 name: code_name, 127 title: code_title, 128 tagName: 'code', 129 className: null, 130 __unstableInputRule(value) { 131 const BACKTICK = '`'; 132 const { 133 start, 134 text 135 } = value; 136 const characterBefore = text[start - 1]; 137 138 // Quick check the text for the necessary character. 139 if (characterBefore !== BACKTICK) { 140 return value; 141 } 142 if (start - 2 < 0) { 143 return value; 144 } 145 const indexBefore = text.lastIndexOf(BACKTICK, start - 2); 146 if (indexBefore === -1) { 147 return value; 148 } 149 const startIndex = indexBefore; 150 const endIndex = start - 2; 151 if (startIndex === endIndex) { 152 return value; 153 } 154 value = (0,external_wp_richText_namespaceObject.remove)(value, startIndex, startIndex + 1); 155 value = (0,external_wp_richText_namespaceObject.remove)(value, endIndex, endIndex + 1); 156 value = (0,external_wp_richText_namespaceObject.applyFormat)(value, { 157 type: code_name 158 }, startIndex, endIndex); 159 return value; 160 }, 161 edit({ 162 value, 163 onChange, 164 onFocus, 165 isActive 166 }) { 167 function onClick() { 168 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { 169 type: code_name, 170 title: code_title 171 })); 172 onFocus(); 173 } 174 return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, { 175 type: "access", 176 character: "x", 177 onUse: onClick 178 }), (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { 179 icon: library_code, 180 title: code_title, 181 onClick: onClick, 182 isActive: isActive, 183 role: "menuitemcheckbox" 184 })); 185 } 186 }; 187 188 ;// CONCATENATED MODULE: external ["wp","components"] 189 const external_wp_components_namespaceObject = window["wp"]["components"]; 190 ;// CONCATENATED MODULE: external ["wp","element"] 191 const external_wp_element_namespaceObject = window["wp"]["element"]; 192 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/keyboard-return.js 193 194 /** 195 * WordPress dependencies 196 */ 197 198 const keyboardReturn = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 199 xmlns: "http://www.w3.org/2000/svg", 200 viewBox: "-2 -2 24 24" 201 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 202 d: "M6.734 16.106l2.176-2.38-1.093-1.028-3.846 4.158 3.846 4.157 1.093-1.027-2.176-2.38h2.811c1.125 0 2.25.03 3.374 0 1.428-.001 3.362-.25 4.963-1.277 1.66-1.065 2.868-2.906 2.868-5.859 0-2.479-1.327-4.896-3.65-5.93-1.82-.813-3.044-.8-4.806-.788l-.567.002v1.5c.184 0 .368 0 .553-.002 1.82-.007 2.704-.014 4.21.657 1.854.827 2.76 2.657 2.76 4.561 0 2.472-.973 3.824-2.178 4.596-1.258.807-2.864 1.04-4.163 1.04h-.02c-1.115.03-2.229 0-3.344 0H6.734z" 203 })); 204 /* harmony default export */ const keyboard_return = (keyboardReturn); 205 206 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/image/index.js 207 208 /** 209 * WordPress dependencies 210 */ 211 212 213 214 215 216 217 const ALLOWED_MEDIA_TYPES = ['image']; 218 const image_name = 'core/image'; 219 const image_title = (0,external_wp_i18n_namespaceObject.__)('Inline image'); 220 const image_image = { 221 name: image_name, 222 title: image_title, 223 keywords: [(0,external_wp_i18n_namespaceObject.__)('photo'), (0,external_wp_i18n_namespaceObject.__)('media')], 224 object: true, 225 tagName: 'img', 226 className: null, 227 attributes: { 228 className: 'class', 229 style: 'style', 230 url: 'src', 231 alt: 'alt' 232 }, 233 edit: Edit 234 }; 235 function InlineUI({ 236 value, 237 onChange, 238 activeObjectAttributes, 239 contentRef 240 }) { 241 const { 242 style 243 } = activeObjectAttributes; 244 const [width, setWidth] = (0,external_wp_element_namespaceObject.useState)(style?.replace(/\D/g, '')); 245 const popoverAnchor = (0,external_wp_richText_namespaceObject.useAnchor)({ 246 editableContentElement: contentRef.current, 247 settings: image_image 248 }); 249 return (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, { 250 placement: "bottom", 251 focusOnMount: false, 252 anchor: popoverAnchor, 253 className: "block-editor-format-toolbar__image-popover" 254 }, (0,external_React_namespaceObject.createElement)("form", { 255 className: "block-editor-format-toolbar__image-container-content", 256 onSubmit: event => { 257 const newReplacements = value.replacements.slice(); 258 newReplacements[value.start] = { 259 type: image_name, 260 attributes: { 261 ...activeObjectAttributes, 262 style: width ? `width: $width}px;` : '' 263 } 264 }; 265 onChange({ 266 ...value, 267 replacements: newReplacements 268 }); 269 event.preventDefault(); 270 } 271 }, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 272 alignment: "bottom", 273 spacing: "0" 274 }, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNumberControl, { 275 className: "block-editor-format-toolbar__image-container-value", 276 label: (0,external_wp_i18n_namespaceObject.__)('Width'), 277 value: width, 278 min: 1, 279 onChange: newWidth => setWidth(newWidth) 280 }), (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 281 className: "block-editor-format-toolbar__image-container-button", 282 icon: keyboard_return, 283 label: (0,external_wp_i18n_namespaceObject.__)('Apply'), 284 type: "submit" 285 })))); 286 } 287 function Edit({ 288 value, 289 onChange, 290 onFocus, 291 isObjectActive, 292 activeObjectAttributes, 293 contentRef 294 }) { 295 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); 296 function openModal() { 297 setIsModalOpen(true); 298 } 299 function closeModal() { 300 setIsModalOpen(false); 301 } 302 return (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.MediaUploadCheck, null, (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { 303 icon: (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, { 304 xmlns: "http://www.w3.org/2000/svg", 305 viewBox: "0 0 24 24" 306 }, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, { 307 d: "M4 18.5h16V17H4v1.5zM16 13v1.5h4V13h-4zM5.1 15h7.8c.6 0 1.1-.5 1.1-1.1V6.1c0-.6-.5-1.1-1.1-1.1H5.1C4.5 5 4 5.5 4 6.1v7.8c0 .6.5 1.1 1.1 1.1zm.4-8.5h7V10l-1-1c-.3-.3-.8-.3-1 0l-1.6 1.5-1.2-.7c-.3-.2-.6-.2-.9 0l-1.3 1V6.5zm0 6.1l1.8-1.3 1.3.8c.3.2.7.2.9-.1l1.5-1.4 1.5 1.4v1.5h-7v-.9z" 308 })), 309 title: image_title, 310 onClick: openModal, 311 isActive: isObjectActive 312 }), isModalOpen && (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.MediaUpload, { 313 allowedTypes: ALLOWED_MEDIA_TYPES, 314 onSelect: ({ 315 id, 316 url, 317 alt, 318 width: imgWidth 319 }) => { 320 closeModal(); 321 onChange((0,external_wp_richText_namespaceObject.insertObject)(value, { 322 type: image_name, 323 attributes: { 324 className: `wp-image-$id}`, 325 style: `width: $Math.min(imgWidth, 150)}px;`, 326 url, 327 alt 328 } 329 })); 330 onFocus(); 331 }, 332 onClose: closeModal, 333 render: ({ 334 open 335 }) => { 336 open(); 337 return null; 338 } 339 }), isObjectActive && (0,external_React_namespaceObject.createElement)(InlineUI, { 340 value: value, 341 onChange: onChange, 342 activeObjectAttributes: activeObjectAttributes, 343 contentRef: contentRef 344 })); 345 } 346 347 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-italic.js 348 349 /** 350 * WordPress dependencies 351 */ 352 353 const formatItalic = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 354 xmlns: "http://www.w3.org/2000/svg", 355 viewBox: "0 0 24 24" 356 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 357 d: "M12.5 5L10 19h1.9l2.5-14z" 358 })); 359 /* harmony default export */ const format_italic = (formatItalic); 360 361 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/italic/index.js 362 363 /** 364 * WordPress dependencies 365 */ 366 367 368 369 370 const italic_name = 'core/italic'; 371 const italic_title = (0,external_wp_i18n_namespaceObject.__)('Italic'); 372 const italic = { 373 name: italic_name, 374 title: italic_title, 375 tagName: 'em', 376 className: null, 377 edit({ 378 isActive, 379 value, 380 onChange, 381 onFocus 382 }) { 383 function onToggle() { 384 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { 385 type: italic_name, 386 title: italic_title 387 })); 388 } 389 function onClick() { 390 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { 391 type: italic_name 392 })); 393 onFocus(); 394 } 395 return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, { 396 type: "primary", 397 character: "i", 398 onUse: onToggle 399 }), (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { 400 name: "italic", 401 icon: format_italic, 402 title: italic_title, 403 onClick: onClick, 404 isActive: isActive, 405 shortcutType: "primary", 406 shortcutCharacter: "i" 407 }), (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent, { 408 inputType: "formatItalic", 409 onInput: onToggle 410 })); 411 } 412 }; 413 414 ;// CONCATENATED MODULE: external ["wp","url"] 415 const external_wp_url_namespaceObject = window["wp"]["url"]; 416 ;// CONCATENATED MODULE: external ["wp","htmlEntities"] 417 const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"]; 418 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/link.js 419 420 /** 421 * WordPress dependencies 422 */ 423 424 const link_link = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 425 xmlns: "http://www.w3.org/2000/svg", 426 viewBox: "0 0 24 24" 427 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 428 d: "M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z" 429 })); 430 /* harmony default export */ const library_link = (link_link); 431 432 ;// CONCATENATED MODULE: external ["wp","a11y"] 433 const external_wp_a11y_namespaceObject = window["wp"]["a11y"]; 434 ;// CONCATENATED MODULE: external ["wp","data"] 435 const external_wp_data_namespaceObject = window["wp"]["data"]; 436 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/link/utils.js 437 /** 438 * WordPress dependencies 439 */ 440 441 442 /** 443 * Check for issues with the provided href. 444 * 445 * @param {string} href The href. 446 * 447 * @return {boolean} Is the href invalid? 448 */ 449 function isValidHref(href) { 450 if (!href) { 451 return false; 452 } 453 const trimmedHref = href.trim(); 454 if (!trimmedHref) { 455 return false; 456 } 457 458 // Does the href start with something that looks like a URL protocol? 459 if (/^\S+:/.test(trimmedHref)) { 460 const protocol = (0,external_wp_url_namespaceObject.getProtocol)(trimmedHref); 461 if (!(0,external_wp_url_namespaceObject.isValidProtocol)(protocol)) { 462 return false; 463 } 464 465 // Add some extra checks for http(s) URIs, since these are the most common use-case. 466 // This ensures URIs with an http protocol have exactly two forward slashes following the protocol. 467 if (protocol.startsWith('http') && !/^https?:\/\/[^\/\s]/i.test(trimmedHref)) { 468 return false; 469 } 470 const authority = (0,external_wp_url_namespaceObject.getAuthority)(trimmedHref); 471 if (!(0,external_wp_url_namespaceObject.isValidAuthority)(authority)) { 472 return false; 473 } 474 const path = (0,external_wp_url_namespaceObject.getPath)(trimmedHref); 475 if (path && !(0,external_wp_url_namespaceObject.isValidPath)(path)) { 476 return false; 477 } 478 const queryString = (0,external_wp_url_namespaceObject.getQueryString)(trimmedHref); 479 if (queryString && !(0,external_wp_url_namespaceObject.isValidQueryString)(queryString)) { 480 return false; 481 } 482 const fragment = (0,external_wp_url_namespaceObject.getFragment)(trimmedHref); 483 if (fragment && !(0,external_wp_url_namespaceObject.isValidFragment)(fragment)) { 484 return false; 485 } 486 } 487 488 // Validate anchor links. 489 if (trimmedHref.startsWith('#') && !(0,external_wp_url_namespaceObject.isValidFragment)(trimmedHref)) { 490 return false; 491 } 492 return true; 493 } 494 495 /** 496 * Generates the format object that will be applied to the link text. 497 * 498 * @param {Object} options 499 * @param {string} options.url The href of the link. 500 * @param {string} options.type The type of the link. 501 * @param {string} options.id The ID of the link. 502 * @param {boolean} options.opensInNewWindow Whether this link will open in a new window. 503 * @param {boolean} options.nofollow Whether this link is marked as no follow relationship. 504 * @return {Object} The final format object. 505 */ 506 function createLinkFormat({ 507 url, 508 type, 509 id, 510 opensInNewWindow, 511 nofollow 512 }) { 513 const format = { 514 type: 'core/link', 515 attributes: { 516 url 517 } 518 }; 519 if (type) format.attributes.type = type; 520 if (id) format.attributes.id = id; 521 if (opensInNewWindow) { 522 format.attributes.target = '_blank'; 523 format.attributes.rel = format.attributes.rel ? format.attributes.rel + ' noreferrer noopener' : 'noreferrer noopener'; 524 } 525 if (nofollow) { 526 format.attributes.rel = format.attributes.rel ? format.attributes.rel + ' nofollow' : 'nofollow'; 527 } 528 return format; 529 } 530 531 /* eslint-disable jsdoc/no-undefined-types */ 532 /** 533 * Get the start and end boundaries of a given format from a rich text value. 534 * 535 * 536 * @param {RichTextValue} value the rich text value to interrogate. 537 * @param {string} format the identifier for the target format (e.g. `core/link`, `core/bold`). 538 * @param {number?} startIndex optional startIndex to seek from. 539 * @param {number?} endIndex optional endIndex to seek from. 540 * @return {Object} object containing start and end values for the given format. 541 */ 542 /* eslint-enable jsdoc/no-undefined-types */ 543 function getFormatBoundary(value, format, startIndex = value.start, endIndex = value.end) { 544 const EMPTY_BOUNDARIES = { 545 start: null, 546 end: null 547 }; 548 const { 549 formats 550 } = value; 551 let targetFormat; 552 let initialIndex; 553 if (!formats?.length) { 554 return EMPTY_BOUNDARIES; 555 } 556 557 // Clone formats to avoid modifying source formats. 558 const newFormats = formats.slice(); 559 const formatAtStart = newFormats[startIndex]?.find(({ 560 type 561 }) => type === format.type); 562 const formatAtEnd = newFormats[endIndex]?.find(({ 563 type 564 }) => type === format.type); 565 const formatAtEndMinusOne = newFormats[endIndex - 1]?.find(({ 566 type 567 }) => type === format.type); 568 if (!!formatAtStart) { 569 // Set values to conform to "start" 570 targetFormat = formatAtStart; 571 initialIndex = startIndex; 572 } else if (!!formatAtEnd) { 573 // Set values to conform to "end" 574 targetFormat = formatAtEnd; 575 initialIndex = endIndex; 576 } else if (!!formatAtEndMinusOne) { 577 // This is an edge case which will occur if you create a format, then place 578 // the caret just before the format and hit the back ARROW key. The resulting 579 // value object will have start and end +1 beyond the edge of the format boundary. 580 targetFormat = formatAtEndMinusOne; 581 initialIndex = endIndex - 1; 582 } else { 583 return EMPTY_BOUNDARIES; 584 } 585 const index = newFormats[initialIndex].indexOf(targetFormat); 586 const walkingArgs = [newFormats, initialIndex, targetFormat, index]; 587 588 // Walk the startIndex "backwards" to the leading "edge" of the matching format. 589 startIndex = walkToStart(...walkingArgs); 590 591 // Walk the endIndex "forwards" until the trailing "edge" of the matching format. 592 endIndex = walkToEnd(...walkingArgs); 593 594 // Safe guard: start index cannot be less than 0. 595 startIndex = startIndex < 0 ? 0 : startIndex; 596 597 // // Return the indicies of the "edges" as the boundaries. 598 return { 599 start: startIndex, 600 end: endIndex 601 }; 602 } 603 604 /** 605 * Walks forwards/backwards towards the boundary of a given format within an 606 * array of format objects. Returns the index of the boundary. 607 * 608 * @param {Array} formats the formats to search for the given format type. 609 * @param {number} initialIndex the starting index from which to walk. 610 * @param {Object} targetFormatRef a reference to the format type object being sought. 611 * @param {number} formatIndex the index at which we expect the target format object to be. 612 * @param {string} direction either 'forwards' or 'backwards' to indicate the direction. 613 * @return {number} the index of the boundary of the given format. 614 */ 615 function walkToBoundary(formats, initialIndex, targetFormatRef, formatIndex, direction) { 616 let index = initialIndex; 617 const directions = { 618 forwards: 1, 619 backwards: -1 620 }; 621 const directionIncrement = directions[direction] || 1; // invalid direction arg default to forwards 622 const inverseDirectionIncrement = directionIncrement * -1; 623 while (formats[index] && formats[index][formatIndex] === targetFormatRef) { 624 // Increment/decrement in the direction of operation. 625 index = index + directionIncrement; 626 } 627 628 // Restore by one in inverse direction of operation 629 // to avoid out of bounds. 630 index = index + inverseDirectionIncrement; 631 return index; 632 } 633 const partialRight = (fn, ...partialArgs) => (...args) => fn(...args, ...partialArgs); 634 const walkToStart = partialRight(walkToBoundary, 'backwards'); 635 const walkToEnd = partialRight(walkToBoundary, 'forwards'); 636 637 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/link/inline.js 638 639 /** 640 * WordPress dependencies 641 */ 642 643 644 645 646 647 648 649 650 651 /** 652 * Internal dependencies 653 */ 654 655 656 const LINK_SETTINGS = [...external_wp_blockEditor_namespaceObject.__experimentalLinkControl.DEFAULT_LINK_SETTINGS, { 657 id: 'nofollow', 658 title: (0,external_wp_i18n_namespaceObject.__)('Mark as nofollow') 659 }]; 660 function InlineLinkUI({ 661 isActive, 662 activeAttributes, 663 value, 664 onChange, 665 onFocusOutside, 666 stopAddingLink, 667 contentRef, 668 focusOnMount 669 }) { 670 const richLinkTextValue = getRichTextValueFromSelection(value, isActive); 671 672 // Get the text content minus any HTML tags. 673 const richTextText = richLinkTextValue.text; 674 const { 675 selectionChange 676 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 677 const { 678 createPageEntity, 679 userCanCreatePages, 680 selectionStart 681 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 682 const { 683 getSettings, 684 getSelectionStart 685 } = select(external_wp_blockEditor_namespaceObject.store); 686 const _settings = getSettings(); 687 return { 688 createPageEntity: _settings.__experimentalCreatePageEntity, 689 userCanCreatePages: _settings.__experimentalUserCanCreatePages, 690 selectionStart: getSelectionStart() 691 }; 692 }, []); 693 const linkValue = (0,external_wp_element_namespaceObject.useMemo)(() => ({ 694 url: activeAttributes.url, 695 type: activeAttributes.type, 696 id: activeAttributes.id, 697 opensInNewTab: activeAttributes.target === '_blank', 698 nofollow: activeAttributes.rel?.includes('nofollow'), 699 title: richTextText 700 }), [activeAttributes.id, activeAttributes.rel, activeAttributes.target, activeAttributes.type, activeAttributes.url, richTextText]); 701 function removeLink() { 702 const newValue = (0,external_wp_richText_namespaceObject.removeFormat)(value, 'core/link'); 703 onChange(newValue); 704 stopAddingLink(); 705 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Link removed.'), 'assertive'); 706 } 707 function onChangeLink(nextValue) { 708 const hasLink = linkValue?.url; 709 const isNewLink = !hasLink; 710 711 // Merge the next value with the current link value. 712 nextValue = { 713 ...linkValue, 714 ...nextValue 715 }; 716 const newUrl = (0,external_wp_url_namespaceObject.prependHTTP)(nextValue.url); 717 const linkFormat = createLinkFormat({ 718 url: newUrl, 719 type: nextValue.type, 720 id: nextValue.id !== undefined && nextValue.id !== null ? String(nextValue.id) : undefined, 721 opensInNewWindow: nextValue.opensInNewTab, 722 nofollow: nextValue.nofollow 723 }); 724 const newText = nextValue.title || newUrl; 725 726 // Scenario: we have any active text selection or an active format. 727 let newValue; 728 if ((0,external_wp_richText_namespaceObject.isCollapsed)(value) && !isActive) { 729 // Scenario: we don't have any actively selected text or formats. 730 const inserted = (0,external_wp_richText_namespaceObject.insert)(value, newText); 731 newValue = (0,external_wp_richText_namespaceObject.applyFormat)(inserted, linkFormat, value.start, value.start + newText.length); 732 onChange(newValue); 733 734 // Close the Link UI. 735 stopAddingLink(); 736 737 // Move the selection to the end of the inserted link outside of the format boundary 738 // so the user can continue typing after the link. 739 selectionChange({ 740 clientId: selectionStart.clientId, 741 identifier: selectionStart.attributeKey, 742 start: value.start + newText.length + 1 743 }); 744 return; 745 } else if (newText === richTextText) { 746 newValue = (0,external_wp_richText_namespaceObject.applyFormat)(value, linkFormat); 747 } else { 748 // Scenario: Editing an existing link. 749 750 // Create new RichText value for the new text in order that we 751 // can apply formats to it. 752 newValue = (0,external_wp_richText_namespaceObject.create)({ 753 text: newText 754 }); 755 // Apply the new Link format to this new text value. 756 newValue = (0,external_wp_richText_namespaceObject.applyFormat)(newValue, linkFormat, 0, newText.length); 757 758 // Get the boundaries of the active link format. 759 const boundary = getFormatBoundary(value, { 760 type: 'core/link' 761 }); 762 763 // Split the value at the start of the active link format. 764 // Passing "start" as the 3rd parameter is required to ensure 765 // the second half of the split value is split at the format's 766 // start boundary and avoids relying on the value's "end" property 767 // which may not correspond correctly. 768 const [valBefore, valAfter] = (0,external_wp_richText_namespaceObject.split)(value, boundary.start, boundary.start); 769 770 // Update the original (full) RichTextValue replacing the 771 // target text with the *new* RichTextValue containing: 772 // 1. The new text content. 773 // 2. The new link format. 774 // As "replace" will operate on the first match only, it is 775 // run only against the second half of the value which was 776 // split at the active format's boundary. This avoids a bug 777 // with incorrectly targetted replacements. 778 // See: https://github.com/WordPress/gutenberg/issues/41771. 779 // Note original formats will be lost when applying this change. 780 // That is expected behaviour. 781 // See: https://github.com/WordPress/gutenberg/pull/33849#issuecomment-936134179. 782 const newValAfter = (0,external_wp_richText_namespaceObject.replace)(valAfter, richTextText, newValue); 783 newValue = (0,external_wp_richText_namespaceObject.concat)(valBefore, newValAfter); 784 } 785 onChange(newValue); 786 787 // Focus should only be returned to the rich text on submit if this link is not 788 // being created for the first time. If it is then focus should remain within the 789 // Link UI because it should remain open for the user to modify the link they have 790 // just created. 791 if (!isNewLink) { 792 stopAddingLink(); 793 } 794 if (!isValidHref(newUrl)) { 795 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Warning: the link has been inserted but may have errors. Please test it.'), 'assertive'); 796 } else if (isActive) { 797 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Link edited.'), 'assertive'); 798 } else { 799 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Link inserted.'), 'assertive'); 800 } 801 } 802 const popoverAnchor = (0,external_wp_richText_namespaceObject.useAnchor)({ 803 editableContentElement: contentRef.current, 804 settings: { 805 ...build_module_link_link, 806 isActive 807 } 808 }); 809 async function handleCreate(pageTitle) { 810 const page = await createPageEntity({ 811 title: pageTitle, 812 status: 'draft' 813 }); 814 return { 815 id: page.id, 816 type: page.type, 817 title: page.title.rendered, 818 url: page.link, 819 kind: 'post-type' 820 }; 821 } 822 function createButtonText(searchTerm) { 823 return (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: search term. */ 824 (0,external_wp_i18n_namespaceObject.__)('Create page: <mark>%s</mark>'), searchTerm), { 825 mark: (0,external_React_namespaceObject.createElement)("mark", null) 826 }); 827 } 828 return (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, { 829 anchor: popoverAnchor, 830 onClose: stopAddingLink, 831 onFocusOutside: onFocusOutside, 832 placement: "bottom", 833 offset: 10, 834 shift: true, 835 focusOnMount: focusOnMount, 836 constrainTabbing: true 837 }, (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLinkControl, { 838 value: linkValue, 839 onChange: onChangeLink, 840 onRemove: removeLink, 841 hasRichPreviews: true, 842 createSuggestion: createPageEntity && handleCreate, 843 withCreateSuggestion: userCanCreatePages, 844 createSuggestionButtonText: createButtonText, 845 hasTextControl: true, 846 settings: LINK_SETTINGS, 847 showInitialSuggestions: true, 848 suggestionsQuery: { 849 // always show Pages as initial suggestions 850 initialSuggestionsSearchOptions: { 851 type: 'post', 852 subtype: 'page', 853 perPage: 20 854 } 855 } 856 })); 857 } 858 function getRichTextValueFromSelection(value, isActive) { 859 // Default to the selection ranges on the RichTextValue object. 860 let textStart = value.start; 861 let textEnd = value.end; 862 863 // If the format is currently active then the rich text value 864 // should always be taken from the bounds of the active format 865 // and not the selected text. 866 if (isActive) { 867 const boundary = getFormatBoundary(value, { 868 type: 'core/link' 869 }); 870 textStart = boundary.start; 871 872 // Text *selection* always extends +1 beyond the edge of the format. 873 // We account for that here. 874 textEnd = boundary.end + 1; 875 } 876 877 // Get a RichTextValue containing the selected text content. 878 return (0,external_wp_richText_namespaceObject.slice)(value, textStart, textEnd); 879 } 880 /* harmony default export */ const inline = (InlineLinkUI); 881 882 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/link/index.js 883 884 /** 885 * WordPress dependencies 886 */ 887 888 889 890 891 892 893 894 895 896 /** 897 * Internal dependencies 898 */ 899 900 901 const link_name = 'core/link'; 902 const link_title = (0,external_wp_i18n_namespaceObject.__)('Link'); 903 function link_Edit({ 904 isActive, 905 activeAttributes, 906 value, 907 onChange, 908 onFocus, 909 contentRef 910 }) { 911 const [editingLink, setEditingLink] = (0,external_wp_element_namespaceObject.useState)(false); 912 const [creatingLink, setCreatingLink] = (0,external_wp_element_namespaceObject.useState)(false); 913 914 // We only need to store the button element that opened the popover. We can ignore the other states, as they will be handled by the onFocus prop to return to the rich text field. 915 const [openedBy, setOpenedBy] = (0,external_wp_element_namespaceObject.useState)(null); 916 917 // Manages whether the Link UI popover should autofocus when shown. 918 const [shouldAutoFocus, setShouldAutoFocus] = (0,external_wp_element_namespaceObject.useState)(true); 919 function setIsEditingLink(isEditing, { 920 autoFocus = true 921 } = {}) { 922 setEditingLink(isEditing); 923 setShouldAutoFocus(autoFocus); 924 } 925 function setIsCreatingLink(isCreating) { 926 // Don't add a new link if there is already an active link. 927 // The two states are mutually exclusive. 928 if (isCreating === true && isActive) { 929 return; 930 } 931 setCreatingLink(isCreating); 932 } 933 (0,external_wp_element_namespaceObject.useEffect)(() => { 934 // When the link becomes inactive (i.e. isActive is false), reset the editingLink state 935 // and the creatingLink state. This means that if the Link UI is displayed and the link 936 // becomes inactive (e.g. used arrow keys to move cursor outside of link bounds), the UI will close. 937 if (!isActive) { 938 setEditingLink(false); 939 setCreatingLink(false); 940 } 941 }, [isActive]); 942 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 943 const editableContentElement = contentRef.current; 944 if (!editableContentElement) { 945 return; 946 } 947 function handleClick(event) { 948 // There is a situation whereby there is an existing link in the rich text 949 // and the user clicks on the leftmost edge of that link and fails to activate 950 // the link format, but the click event still fires on the `<a>` element. 951 // This causes the `editingLink` state to be set to `true` and the link UI 952 // to be rendered in "creating" mode. We need to check isActive to see if 953 // we have an active link format. 954 if (!event.target.closest('[contenteditable] a') || 955 // other formats (e.g. bold) may be nested within the link. 956 !isActive) { 957 setIsEditingLink(false); 958 return; 959 } 960 setIsEditingLink(true, { 961 autoFocus: false 962 }); 963 } 964 editableContentElement.addEventListener('click', handleClick); 965 return () => { 966 editableContentElement.removeEventListener('click', handleClick); 967 }; 968 }, [contentRef, isActive]); 969 function addLink(target) { 970 setShouldAutoFocus(true); 971 const text = (0,external_wp_richText_namespaceObject.getTextContent)((0,external_wp_richText_namespaceObject.slice)(value)); 972 if (!isActive && text && (0,external_wp_url_namespaceObject.isURL)(text) && isValidHref(text)) { 973 onChange((0,external_wp_richText_namespaceObject.applyFormat)(value, { 974 type: link_name, 975 attributes: { 976 url: text 977 } 978 })); 979 } else if (!isActive && text && (0,external_wp_url_namespaceObject.isEmail)(text)) { 980 onChange((0,external_wp_richText_namespaceObject.applyFormat)(value, { 981 type: link_name, 982 attributes: { 983 url: `mailto:$text}` 984 } 985 })); 986 } else { 987 if (target) { 988 setOpenedBy(target); 989 } 990 if (!isActive) { 991 setIsCreatingLink(true); 992 } else { 993 setIsEditingLink(true); 994 } 995 } 996 } 997 998 /** 999 * Runs when the popover is closed via escape keypress, unlinking the selected text, 1000 * but _not_ on a click outside the popover. onFocusOutside handles that. 1001 */ 1002 function stopAddingLink() { 1003 // Don't let the click handler on the toolbar button trigger again. 1004 1005 // There are two places for us to return focus to on Escape keypress: 1006 // 1. The rich text field. 1007 // 2. The toolbar button. 1008 1009 // The toolbar button is the only one we need to handle returning focus to. 1010 // Otherwise, we rely on the passed in onFocus to return focus to the rich text field. 1011 1012 // Close the popover 1013 setIsEditingLink(false); 1014 setIsCreatingLink(false); 1015 1016 // Return focus to the toolbar button or the rich text field 1017 if (openedBy?.tagName === 'BUTTON') { 1018 openedBy.focus(); 1019 } else { 1020 onFocus(); 1021 } 1022 // Remove the openedBy state 1023 setOpenedBy(null); 1024 } 1025 1026 // Test for this: 1027 // 1. Click on the link button 1028 // 2. Click the Options button in the top right of header 1029 // 3. Focus should be in the dropdown of the Options button 1030 // 4. Press Escape 1031 // 5. Focus should be on the Options button 1032 function onFocusOutside() { 1033 setIsEditingLink(false); 1034 setIsCreatingLink(false); 1035 setOpenedBy(null); 1036 } 1037 function onRemoveFormat() { 1038 onChange((0,external_wp_richText_namespaceObject.removeFormat)(value, link_name)); 1039 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Link removed.'), 'assertive'); 1040 } 1041 const isEditingActiveLink = editingLink && isActive; 1042 return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, { 1043 type: "primary", 1044 character: "k", 1045 onUse: addLink 1046 }), (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, { 1047 type: "primaryShift", 1048 character: "k", 1049 onUse: onRemoveFormat 1050 }), (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { 1051 name: "link", 1052 icon: library_link, 1053 title: isActive ? (0,external_wp_i18n_namespaceObject.__)('Link') : link_title, 1054 onClick: event => { 1055 addLink(event.currentTarget); 1056 }, 1057 isActive: isActive || editingLink, 1058 shortcutType: "primary", 1059 shortcutCharacter: "k", 1060 "aria-haspopup": "true", 1061 "aria-expanded": editingLink 1062 }), (isEditingActiveLink || creatingLink) && (0,external_React_namespaceObject.createElement)(inline, { 1063 stopAddingLink: stopAddingLink, 1064 onFocusOutside: onFocusOutside, 1065 isActive: isActive, 1066 activeAttributes: activeAttributes, 1067 value: value, 1068 onChange: onChange, 1069 contentRef: contentRef, 1070 focusOnMount: shouldAutoFocus ? 'firstElement' : false 1071 })); 1072 } 1073 const build_module_link_link = { 1074 name: link_name, 1075 title: link_title, 1076 tagName: 'a', 1077 className: null, 1078 attributes: { 1079 url: 'href', 1080 type: 'data-type', 1081 id: 'data-id', 1082 _id: 'id', 1083 target: 'target', 1084 rel: 'rel' 1085 }, 1086 __unstablePasteRule(value, { 1087 html, 1088 plainText 1089 }) { 1090 const pastedText = (html || plainText).replace(/<[^>]+>/g, '').trim(); 1091 1092 // A URL was pasted, turn the selection into a link. 1093 // For the link pasting feature, allow only http(s) protocols. 1094 if (!(0,external_wp_url_namespaceObject.isURL)(pastedText) || !/^https?:/.test(pastedText)) { 1095 return value; 1096 } 1097 1098 // Allows us to ask for this information when we get a report. 1099 window.console.log('Created link:\n\n', pastedText); 1100 const format = { 1101 type: link_name, 1102 attributes: { 1103 url: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(pastedText) 1104 } 1105 }; 1106 if ((0,external_wp_richText_namespaceObject.isCollapsed)(value)) { 1107 return (0,external_wp_richText_namespaceObject.insert)(value, (0,external_wp_richText_namespaceObject.applyFormat)((0,external_wp_richText_namespaceObject.create)({ 1108 text: plainText 1109 }), format, 0, plainText.length)); 1110 } 1111 return (0,external_wp_richText_namespaceObject.applyFormat)(value, format); 1112 }, 1113 edit: link_Edit 1114 }; 1115 1116 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-strikethrough.js 1117 1118 /** 1119 * WordPress dependencies 1120 */ 1121 1122 const formatStrikethrough = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 1123 xmlns: "http://www.w3.org/2000/svg", 1124 viewBox: "0 0 24 24" 1125 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 1126 d: "M9.1 9v-.5c0-.6.2-1.1.7-1.4.5-.3 1.2-.5 2-.5.7 0 1.4.1 2.1.3.7.2 1.4.5 2.1.9l.2-1.9c-.6-.3-1.2-.5-1.9-.7-.8-.1-1.6-.2-2.4-.2-1.5 0-2.7.3-3.6 1-.8.7-1.2 1.5-1.2 2.6V9h2zM20 12H4v1h8.3c.3.1.6.2.8.3.5.2.9.5 1.1.8.3.3.4.7.4 1.2 0 .7-.2 1.1-.8 1.5-.5.3-1.2.5-2.1.5-.8 0-1.6-.1-2.4-.3-.8-.2-1.5-.5-2.2-.8L7 18.1c.5.2 1.2.4 2 .6.8.2 1.6.3 2.4.3 1.7 0 3-.3 3.9-1 .9-.7 1.3-1.6 1.3-2.8 0-.9-.2-1.7-.7-2.2H20v-1z" 1127 })); 1128 /* harmony default export */ const format_strikethrough = (formatStrikethrough); 1129 1130 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/strikethrough/index.js 1131 1132 /** 1133 * WordPress dependencies 1134 */ 1135 1136 1137 1138 1139 const strikethrough_name = 'core/strikethrough'; 1140 const strikethrough_title = (0,external_wp_i18n_namespaceObject.__)('Strikethrough'); 1141 const strikethrough = { 1142 name: strikethrough_name, 1143 title: strikethrough_title, 1144 tagName: 's', 1145 className: null, 1146 edit({ 1147 isActive, 1148 value, 1149 onChange, 1150 onFocus 1151 }) { 1152 function onClick() { 1153 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { 1154 type: strikethrough_name, 1155 title: strikethrough_title 1156 })); 1157 onFocus(); 1158 } 1159 return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, { 1160 type: "access", 1161 character: "d", 1162 onUse: onClick 1163 }), (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { 1164 icon: format_strikethrough, 1165 title: strikethrough_title, 1166 onClick: onClick, 1167 isActive: isActive, 1168 role: "menuitemcheckbox" 1169 })); 1170 } 1171 }; 1172 1173 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/underline/index.js 1174 1175 /** 1176 * WordPress dependencies 1177 */ 1178 1179 1180 1181 const underline_name = 'core/underline'; 1182 const underline_title = (0,external_wp_i18n_namespaceObject.__)('Underline'); 1183 const underline = { 1184 name: underline_name, 1185 title: underline_title, 1186 tagName: 'span', 1187 className: null, 1188 attributes: { 1189 style: 'style' 1190 }, 1191 edit({ 1192 value, 1193 onChange 1194 }) { 1195 const onToggle = () => { 1196 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { 1197 type: underline_name, 1198 attributes: { 1199 style: 'text-decoration: underline;' 1200 }, 1201 title: underline_title 1202 })); 1203 }; 1204 return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, { 1205 type: "primary", 1206 character: "u", 1207 onUse: onToggle 1208 }), (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent, { 1209 inputType: "formatUnderline", 1210 onInput: onToggle 1211 })); 1212 } 1213 }; 1214 1215 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/icon/index.js 1216 /** 1217 * WordPress dependencies 1218 */ 1219 1220 1221 /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */ 1222 1223 /** 1224 * Return an SVG icon. 1225 * 1226 * @param {IconProps} props icon is the SVG component to render 1227 * size is a number specifiying the icon size in pixels 1228 * Other props will be passed to wrapped SVG component 1229 * @param {import('react').ForwardedRef<HTMLElement>} ref The forwarded ref to the SVG element. 1230 * 1231 * @return {JSX.Element} Icon component 1232 */ 1233 function Icon({ 1234 icon, 1235 size = 24, 1236 ...props 1237 }, ref) { 1238 return (0,external_wp_element_namespaceObject.cloneElement)(icon, { 1239 width: size, 1240 height: size, 1241 ...props, 1242 ref 1243 }); 1244 } 1245 /* harmony default export */ const icon = ((0,external_wp_element_namespaceObject.forwardRef)(Icon)); 1246 1247 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/text-color.js 1248 1249 /** 1250 * WordPress dependencies 1251 */ 1252 1253 const textColor = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 1254 xmlns: "http://www.w3.org/2000/svg", 1255 viewBox: "0 0 24 24" 1256 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 1257 d: "M12.9 6h-2l-4 11h1.9l1.1-3h4.2l1.1 3h1.9L12.9 6zm-2.5 6.5l1.5-4.9 1.7 4.9h-3.2z" 1258 })); 1259 /* harmony default export */ const text_color = (textColor); 1260 1261 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/color.js 1262 1263 /** 1264 * WordPress dependencies 1265 */ 1266 1267 const color = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 1268 viewBox: "0 0 24 24", 1269 xmlns: "http://www.w3.org/2000/svg" 1270 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 1271 d: "M17.2 10.9c-.5-1-1.2-2.1-2.1-3.2-.6-.9-1.3-1.7-2.1-2.6L12 4l-1 1.1c-.6.9-1.3 1.7-2 2.6-.8 1.2-1.5 2.3-2 3.2-.6 1.2-1 2.2-1 3 0 3.4 2.7 6.1 6.1 6.1s6.1-2.7 6.1-6.1c0-.8-.3-1.8-1-3zm-5.1 7.6c-2.5 0-4.6-2.1-4.6-4.6 0-.3.1-1 .8-2.3.5-.9 1.1-1.9 2-3.1.7-.9 1.3-1.7 1.8-2.3.7.8 1.3 1.6 1.8 2.3.8 1.1 1.5 2.2 2 3.1.7 1.3.8 2 .8 2.3 0 2.5-2.1 4.6-4.6 4.6z" 1272 })); 1273 /* harmony default export */ const library_color = (color); 1274 1275 ;// CONCATENATED MODULE: external ["wp","privateApis"] 1276 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"]; 1277 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/lock-unlock.js 1278 /** 1279 * WordPress dependencies 1280 */ 1281 1282 const { 1283 lock, 1284 unlock 1285 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/format-library'); 1286 1287 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/text-color/inline.js 1288 1289 /** 1290 * WordPress dependencies 1291 */ 1292 1293 1294 1295 1296 1297 1298 1299 /** 1300 * Internal dependencies 1301 */ 1302 1303 1304 const { 1305 Tabs 1306 } = unlock(external_wp_components_namespaceObject.privateApis); 1307 const TABS = [{ 1308 name: 'color', 1309 title: (0,external_wp_i18n_namespaceObject.__)('Text') 1310 }, { 1311 name: 'backgroundColor', 1312 title: (0,external_wp_i18n_namespaceObject.__)('Background') 1313 }]; 1314 function parseCSS(css = '') { 1315 return css.split(';').reduce((accumulator, rule) => { 1316 if (rule) { 1317 const [property, value] = rule.split(':'); 1318 if (property === 'color') accumulator.color = value; 1319 if (property === 'background-color' && value !== transparentValue) accumulator.backgroundColor = value; 1320 } 1321 return accumulator; 1322 }, {}); 1323 } 1324 function parseClassName(className = '', colorSettings) { 1325 return className.split(' ').reduce((accumulator, name) => { 1326 // `colorSlug` could contain dashes, so simply match the start and end. 1327 if (name.startsWith('has-') && name.endsWith('-color')) { 1328 const colorSlug = name.replace(/^has-/, '').replace(/-color$/, ''); 1329 const colorObject = (0,external_wp_blockEditor_namespaceObject.getColorObjectByAttributeValues)(colorSettings, colorSlug); 1330 accumulator.color = colorObject.color; 1331 } 1332 return accumulator; 1333 }, {}); 1334 } 1335 function getActiveColors(value, name, colorSettings) { 1336 const activeColorFormat = (0,external_wp_richText_namespaceObject.getActiveFormat)(value, name); 1337 if (!activeColorFormat) { 1338 return {}; 1339 } 1340 return { 1341 ...parseCSS(activeColorFormat.attributes.style), 1342 ...parseClassName(activeColorFormat.attributes.class, colorSettings) 1343 }; 1344 } 1345 function setColors(value, name, colorSettings, colors) { 1346 const { 1347 color, 1348 backgroundColor 1349 } = { 1350 ...getActiveColors(value, name, colorSettings), 1351 ...colors 1352 }; 1353 if (!color && !backgroundColor) { 1354 return (0,external_wp_richText_namespaceObject.removeFormat)(value, name); 1355 } 1356 const styles = []; 1357 const classNames = []; 1358 const attributes = {}; 1359 if (backgroundColor) { 1360 styles.push(['background-color', backgroundColor].join(':')); 1361 } else { 1362 // Override default browser color for mark element. 1363 styles.push(['background-color', transparentValue].join(':')); 1364 } 1365 if (color) { 1366 const colorObject = (0,external_wp_blockEditor_namespaceObject.getColorObjectByColorValue)(colorSettings, color); 1367 if (colorObject) { 1368 classNames.push((0,external_wp_blockEditor_namespaceObject.getColorClassName)('color', colorObject.slug)); 1369 } else { 1370 styles.push(['color', color].join(':')); 1371 } 1372 } 1373 if (styles.length) attributes.style = styles.join(';'); 1374 if (classNames.length) attributes.class = classNames.join(' '); 1375 return (0,external_wp_richText_namespaceObject.applyFormat)(value, { 1376 type: name, 1377 attributes 1378 }); 1379 } 1380 function ColorPicker({ 1381 name, 1382 property, 1383 value, 1384 onChange 1385 }) { 1386 const colors = (0,external_wp_data_namespaceObject.useSelect)(select => { 1387 var _getSettings$colors; 1388 const { 1389 getSettings 1390 } = select(external_wp_blockEditor_namespaceObject.store); 1391 return (_getSettings$colors = getSettings().colors) !== null && _getSettings$colors !== void 0 ? _getSettings$colors : []; 1392 }, []); 1393 const onColorChange = (0,external_wp_element_namespaceObject.useCallback)(color => { 1394 onChange(setColors(value, name, colors, { 1395 [property]: color 1396 })); 1397 }, [colors, onChange, property]); 1398 const activeColors = (0,external_wp_element_namespaceObject.useMemo)(() => getActiveColors(value, name, colors), [name, value, colors]); 1399 return (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.ColorPalette, { 1400 value: activeColors[property], 1401 onChange: onColorChange 1402 }); 1403 } 1404 function InlineColorUI({ 1405 name, 1406 value, 1407 onChange, 1408 onClose, 1409 contentRef, 1410 isActive 1411 }) { 1412 const popoverAnchor = (0,external_wp_richText_namespaceObject.useAnchor)({ 1413 editableContentElement: contentRef.current, 1414 settings: { 1415 ...text_color_textColor, 1416 isActive 1417 } 1418 }); 1419 return (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, { 1420 onClose: onClose, 1421 className: "format-library__inline-color-popover", 1422 anchor: popoverAnchor 1423 }, (0,external_React_namespaceObject.createElement)(Tabs, null, (0,external_React_namespaceObject.createElement)(Tabs.TabList, null, TABS.map(tab => (0,external_React_namespaceObject.createElement)(Tabs.Tab, { 1424 tabId: tab.name, 1425 key: tab.name 1426 }, tab.title))), TABS.map(tab => (0,external_React_namespaceObject.createElement)(Tabs.TabPanel, { 1427 tabId: tab.name, 1428 focusable: false, 1429 key: tab.name 1430 }, (0,external_React_namespaceObject.createElement)(ColorPicker, { 1431 name: name, 1432 property: tab.name, 1433 value: value, 1434 onChange: onChange 1435 }))))); 1436 } 1437 1438 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/text-color/index.js 1439 1440 /** 1441 * WordPress dependencies 1442 */ 1443 1444 1445 1446 1447 1448 1449 /** 1450 * Internal dependencies 1451 */ 1452 1453 const transparentValue = 'rgba(0, 0, 0, 0)'; 1454 const text_color_name = 'core/text-color'; 1455 const text_color_title = (0,external_wp_i18n_namespaceObject.__)('Highlight'); 1456 const EMPTY_ARRAY = []; 1457 function getComputedStyleProperty(element, property) { 1458 const { 1459 ownerDocument 1460 } = element; 1461 const { 1462 defaultView 1463 } = ownerDocument; 1464 const style = defaultView.getComputedStyle(element); 1465 const value = style.getPropertyValue(property); 1466 if (property === 'background-color' && value === transparentValue && element.parentElement) { 1467 return getComputedStyleProperty(element.parentElement, property); 1468 } 1469 return value; 1470 } 1471 function fillComputedColors(element, { 1472 color, 1473 backgroundColor 1474 }) { 1475 if (!color && !backgroundColor) { 1476 return; 1477 } 1478 return { 1479 color: color || getComputedStyleProperty(element, 'color'), 1480 backgroundColor: backgroundColor === transparentValue ? getComputedStyleProperty(element, 'background-color') : backgroundColor 1481 }; 1482 } 1483 function TextColorEdit({ 1484 value, 1485 onChange, 1486 isActive, 1487 activeAttributes, 1488 contentRef 1489 }) { 1490 const [allowCustomControl, colors = EMPTY_ARRAY] = (0,external_wp_blockEditor_namespaceObject.useSettings)('color.custom', 'color.palette'); 1491 const [isAddingColor, setIsAddingColor] = (0,external_wp_element_namespaceObject.useState)(false); 1492 const enableIsAddingColor = (0,external_wp_element_namespaceObject.useCallback)(() => setIsAddingColor(true), [setIsAddingColor]); 1493 const disableIsAddingColor = (0,external_wp_element_namespaceObject.useCallback)(() => setIsAddingColor(false), [setIsAddingColor]); 1494 const colorIndicatorStyle = (0,external_wp_element_namespaceObject.useMemo)(() => fillComputedColors(contentRef.current, getActiveColors(value, text_color_name, colors)), [value, colors]); 1495 const hasColorsToChoose = colors.length || !allowCustomControl; 1496 if (!hasColorsToChoose && !isActive) { 1497 return null; 1498 } 1499 return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { 1500 className: "format-library-text-color-button", 1501 isActive: isActive, 1502 icon: (0,external_React_namespaceObject.createElement)(icon, { 1503 icon: Object.keys(activeAttributes).length ? text_color : library_color, 1504 style: colorIndicatorStyle 1505 }), 1506 title: text_color_title 1507 // If has no colors to choose but a color is active remove the color onClick. 1508 , 1509 onClick: hasColorsToChoose ? enableIsAddingColor : () => onChange((0,external_wp_richText_namespaceObject.removeFormat)(value, text_color_name)), 1510 role: "menuitemcheckbox" 1511 }), isAddingColor && (0,external_React_namespaceObject.createElement)(InlineColorUI, { 1512 name: text_color_name, 1513 onClose: disableIsAddingColor, 1514 activeAttributes: activeAttributes, 1515 value: value, 1516 onChange: onChange, 1517 contentRef: contentRef, 1518 isActive: isActive 1519 })); 1520 } 1521 const text_color_textColor = { 1522 name: text_color_name, 1523 title: text_color_title, 1524 tagName: 'mark', 1525 className: 'has-inline-color', 1526 attributes: { 1527 style: 'style', 1528 class: 'class' 1529 }, 1530 edit: TextColorEdit 1531 }; 1532 1533 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/subscript.js 1534 1535 /** 1536 * WordPress dependencies 1537 */ 1538 1539 const subscript = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 1540 xmlns: "http://www.w3.org/2000/svg", 1541 viewBox: "0 0 24 24" 1542 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 1543 d: "M16.9 18.3l.8-1.2c.4-.6.7-1.2.9-1.6.2-.4.3-.8.3-1.2 0-.3-.1-.7-.2-1-.1-.3-.4-.5-.6-.7-.3-.2-.6-.3-1-.3s-.8.1-1.1.2c-.3.1-.7.3-1 .6l.2 1.3c.3-.3.5-.5.8-.6s.6-.2.9-.2c.3 0 .5.1.7.2.2.2.2.4.2.7 0 .3-.1.5-.2.8-.1.3-.4.7-.8 1.3L15 19.4h4.3v-1.2h-2.4zM14.1 7.2h-2L9.5 11 6.9 7.2h-2l3.6 5.3L4.7 18h2l2.7-4 2.7 4h2l-3.8-5.5 3.8-5.3z" 1544 })); 1545 /* harmony default export */ const library_subscript = (subscript); 1546 1547 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/subscript/index.js 1548 1549 /** 1550 * WordPress dependencies 1551 */ 1552 1553 1554 1555 1556 const subscript_name = 'core/subscript'; 1557 const subscript_title = (0,external_wp_i18n_namespaceObject.__)('Subscript'); 1558 const subscript_subscript = { 1559 name: subscript_name, 1560 title: subscript_title, 1561 tagName: 'sub', 1562 className: null, 1563 edit({ 1564 isActive, 1565 value, 1566 onChange, 1567 onFocus 1568 }) { 1569 function onToggle() { 1570 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { 1571 type: subscript_name, 1572 title: subscript_title 1573 })); 1574 } 1575 function onClick() { 1576 onToggle(); 1577 onFocus(); 1578 } 1579 return (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { 1580 icon: library_subscript, 1581 title: subscript_title, 1582 onClick: onClick, 1583 isActive: isActive, 1584 role: "menuitemcheckbox" 1585 }); 1586 } 1587 }; 1588 1589 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/superscript.js 1590 1591 /** 1592 * WordPress dependencies 1593 */ 1594 1595 const superscript = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 1596 xmlns: "http://www.w3.org/2000/svg", 1597 viewBox: "0 0 24 24" 1598 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 1599 d: "M16.9 10.3l.8-1.3c.4-.6.7-1.2.9-1.6.2-.4.3-.8.3-1.2 0-.3-.1-.7-.2-1-.2-.2-.4-.4-.7-.6-.3-.2-.6-.3-1-.3s-.8.1-1.1.2c-.3.1-.7.3-1 .6l.1 1.3c.3-.3.5-.5.8-.6s.6-.2.9-.2c.3 0 .5.1.7.2.2.2.2.4.2.7 0 .3-.1.5-.2.8-.1.3-.4.7-.8 1.3l-1.8 2.8h4.3v-1.2h-2.2zm-2.8-3.1h-2L9.5 11 6.9 7.2h-2l3.6 5.3L4.7 18h2l2.7-4 2.7 4h2l-3.8-5.5 3.8-5.3z" 1600 })); 1601 /* harmony default export */ const library_superscript = (superscript); 1602 1603 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/superscript/index.js 1604 1605 /** 1606 * WordPress dependencies 1607 */ 1608 1609 1610 1611 1612 const superscript_name = 'core/superscript'; 1613 const superscript_title = (0,external_wp_i18n_namespaceObject.__)('Superscript'); 1614 const superscript_superscript = { 1615 name: superscript_name, 1616 title: superscript_title, 1617 tagName: 'sup', 1618 className: null, 1619 edit({ 1620 isActive, 1621 value, 1622 onChange, 1623 onFocus 1624 }) { 1625 function onToggle() { 1626 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { 1627 type: superscript_name, 1628 title: superscript_title 1629 })); 1630 } 1631 function onClick() { 1632 onToggle(); 1633 onFocus(); 1634 } 1635 return (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { 1636 icon: library_superscript, 1637 title: superscript_title, 1638 onClick: onClick, 1639 isActive: isActive, 1640 role: "menuitemcheckbox" 1641 }); 1642 } 1643 }; 1644 1645 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/button.js 1646 1647 /** 1648 * WordPress dependencies 1649 */ 1650 1651 const button_button = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 1652 viewBox: "0 0 24 24", 1653 xmlns: "http://www.w3.org/2000/svg" 1654 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 1655 d: "M8 12.5h8V11H8v1.5Z M19 6.5H5a2 2 0 0 0-2 2V15a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8.5a2 2 0 0 0-2-2ZM5 8h14a.5.5 0 0 1 .5.5V15a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V8.5A.5.5 0 0 1 5 8Z" 1656 })); 1657 /* harmony default export */ const library_button = (button_button); 1658 1659 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/keyboard/index.js 1660 1661 /** 1662 * WordPress dependencies 1663 */ 1664 1665 1666 1667 1668 const keyboard_name = 'core/keyboard'; 1669 const keyboard_title = (0,external_wp_i18n_namespaceObject.__)('Keyboard input'); 1670 const keyboard = { 1671 name: keyboard_name, 1672 title: keyboard_title, 1673 tagName: 'kbd', 1674 className: null, 1675 edit({ 1676 isActive, 1677 value, 1678 onChange, 1679 onFocus 1680 }) { 1681 function onToggle() { 1682 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, { 1683 type: keyboard_name, 1684 title: keyboard_title 1685 })); 1686 } 1687 function onClick() { 1688 onToggle(); 1689 onFocus(); 1690 } 1691 return (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { 1692 icon: library_button, 1693 title: keyboard_title, 1694 onClick: onClick, 1695 isActive: isActive, 1696 role: "menuitemcheckbox" 1697 }); 1698 } 1699 }; 1700 1701 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/help.js 1702 1703 /** 1704 * WordPress dependencies 1705 */ 1706 1707 const help = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 1708 xmlns: "http://www.w3.org/2000/svg", 1709 viewBox: "0 0 24 24" 1710 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 1711 d: "M12 4.75a7.25 7.25 0 100 14.5 7.25 7.25 0 000-14.5zM3.25 12a8.75 8.75 0 1117.5 0 8.75 8.75 0 01-17.5 0zM12 8.75a1.5 1.5 0 01.167 2.99c-.465.052-.917.44-.917 1.01V14h1.5v-.845A3 3 0 109 10.25h1.5a1.5 1.5 0 011.5-1.5zM11.25 15v1.5h1.5V15h-1.5z" 1712 })); 1713 /* harmony default export */ const library_help = (help); 1714 1715 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/unknown/index.js 1716 1717 /** 1718 * WordPress dependencies 1719 */ 1720 1721 1722 1723 1724 const unknown_name = 'core/unknown'; 1725 const unknown_title = (0,external_wp_i18n_namespaceObject.__)('Clear Unknown Formatting'); 1726 const unknown = { 1727 name: unknown_name, 1728 title: unknown_title, 1729 tagName: '*', 1730 className: null, 1731 edit({ 1732 isActive, 1733 value, 1734 onChange, 1735 onFocus 1736 }) { 1737 function onClick() { 1738 onChange((0,external_wp_richText_namespaceObject.removeFormat)(value, unknown_name)); 1739 onFocus(); 1740 } 1741 const selectedValue = (0,external_wp_richText_namespaceObject.slice)(value); 1742 const hasUnknownFormats = selectedValue.formats.some(formats => { 1743 return formats.some(format => format.type === unknown_name); 1744 }); 1745 if (!isActive && !hasUnknownFormats) { 1746 return null; 1747 } 1748 return (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { 1749 name: "unknown", 1750 icon: library_help, 1751 title: unknown_title, 1752 onClick: onClick, 1753 isActive: true 1754 }); 1755 } 1756 }; 1757 1758 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/language.js 1759 1760 /** 1761 * WordPress dependencies 1762 */ 1763 1764 const language = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { 1765 xmlns: "http://www.w3.org/2000/svg", 1766 viewBox: "0 0 24 24" 1767 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { 1768 d: "M17.5 10h-1.7l-3.7 10.5h1.7l.9-2.6h3.9l.9 2.6h1.7L17.5 10zm-2.2 6.3 1.4-4 1.4 4h-2.8zm-4.8-3.8c1.6-1.8 2.9-3.6 3.7-5.7H16V5.2h-5.8V3H8.8v2.2H3v1.5h9.6c-.7 1.6-1.8 3.1-3.1 4.6C8.6 10.2 7.8 9 7.2 8H5.6c.6 1.4 1.7 2.9 2.9 4.4l-2.4 2.4c-.3.4-.7.8-1.1 1.2l1 1 1.2-1.2c.8-.8 1.6-1.5 2.3-2.3.8.9 1.7 1.7 2.5 2.5l.6-1.5c-.7-.6-1.4-1.3-2.1-2z" 1769 })); 1770 /* harmony default export */ const library_language = (language); 1771 1772 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/language/index.js 1773 1774 /** 1775 * WordPress dependencies 1776 */ 1777 1778 1779 /** 1780 * WordPress dependencies 1781 */ 1782 1783 1784 1785 1786 1787 const language_name = 'core/language'; 1788 const language_title = (0,external_wp_i18n_namespaceObject.__)('Language'); 1789 const language_language = { 1790 name: language_name, 1791 tagName: 'bdo', 1792 className: null, 1793 edit: language_Edit, 1794 title: language_title 1795 }; 1796 function language_Edit({ 1797 isActive, 1798 value, 1799 onChange, 1800 contentRef 1801 }) { 1802 const [isPopoverVisible, setIsPopoverVisible] = (0,external_wp_element_namespaceObject.useState)(false); 1803 const togglePopover = () => { 1804 setIsPopoverVisible(state => !state); 1805 }; 1806 return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, { 1807 icon: library_language, 1808 label: language_title, 1809 title: language_title, 1810 onClick: () => { 1811 if (isActive) { 1812 onChange((0,external_wp_richText_namespaceObject.removeFormat)(value, language_name)); 1813 } else { 1814 togglePopover(); 1815 } 1816 }, 1817 isActive: isActive, 1818 role: "menuitemcheckbox" 1819 }), isPopoverVisible && (0,external_React_namespaceObject.createElement)(InlineLanguageUI, { 1820 value: value, 1821 onChange: onChange, 1822 onClose: togglePopover, 1823 contentRef: contentRef 1824 })); 1825 } 1826 function InlineLanguageUI({ 1827 value, 1828 contentRef, 1829 onChange, 1830 onClose 1831 }) { 1832 const popoverAnchor = (0,external_wp_richText_namespaceObject.useAnchor)({ 1833 editableContentElement: contentRef.current, 1834 settings: language_language 1835 }); 1836 const [lang, setLang] = (0,external_wp_element_namespaceObject.useState)(''); 1837 const [dir, setDir] = (0,external_wp_element_namespaceObject.useState)('ltr'); 1838 return (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, { 1839 className: "block-editor-format-toolbar__language-popover", 1840 anchor: popoverAnchor, 1841 onClose: onClose 1842 }, (0,external_React_namespaceObject.createElement)("form", { 1843 className: "block-editor-format-toolbar__language-container-content", 1844 onSubmit: event => { 1845 event.preventDefault(); 1846 onChange((0,external_wp_richText_namespaceObject.applyFormat)(value, { 1847 type: language_name, 1848 attributes: { 1849 lang, 1850 dir 1851 } 1852 })); 1853 onClose(); 1854 } 1855 }, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { 1856 label: language_title, 1857 value: lang, 1858 onChange: val => setLang(val), 1859 help: (0,external_wp_i18n_namespaceObject.__)('A valid language attribute, like "en" or "fr".') 1860 }), (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, { 1861 label: (0,external_wp_i18n_namespaceObject.__)('Text direction'), 1862 value: dir, 1863 options: [{ 1864 label: (0,external_wp_i18n_namespaceObject.__)('Left to right'), 1865 value: 'ltr' 1866 }, { 1867 label: (0,external_wp_i18n_namespaceObject.__)('Right to left'), 1868 value: 'rtl' 1869 }], 1870 onChange: val => setDir(val) 1871 }), (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 1872 alignment: "right" 1873 }, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { 1874 variant: "primary", 1875 type: "submit", 1876 text: (0,external_wp_i18n_namespaceObject.__)('Apply') 1877 })))); 1878 } 1879 1880 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/default-formats.js 1881 /** 1882 * Internal dependencies 1883 */ 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 /* harmony default export */ const default_formats = ([bold, code_code, image_image, italic, build_module_link_link, strikethrough, underline, text_color_textColor, subscript_subscript, superscript_superscript, keyboard, unknown, language_language]); 1898 1899 ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/index.js 1900 /** 1901 * WordPress dependencies 1902 */ 1903 1904 1905 /** 1906 * Internal dependencies 1907 */ 1908 1909 default_formats.forEach(({ 1910 name, 1911 ...settings 1912 }) => (0,external_wp_richText_namespaceObject.registerFormatType)(name, settings)); 1913 1914 (window.wp = window.wp || {}).formatLibrary = __webpack_exports__; 1915 /******/ })() 1916 ;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sat May 11 08:20:01 2024 | Cross-referenced by PHPXref |