You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1850 lines
64 KiB

1 year ago
  1. /******/ (function() { // webpackBootstrap
  2. /******/ "use strict";
  3. /******/ // The require scope
  4. /******/ var __webpack_require__ = {};
  5. /******/
  6. /************************************************************************/
  7. /******/ /* webpack/runtime/make namespace object */
  8. /******/ !function() {
  9. /******/ // define __esModule on exports
  10. /******/ __webpack_require__.r = function(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. ;// CONCATENATED MODULE: external ["wp","richText"]
  23. var external_wp_richText_namespaceObject = window["wp"]["richText"];
  24. ;// CONCATENATED MODULE: external ["wp","element"]
  25. var external_wp_element_namespaceObject = window["wp"]["element"];
  26. ;// CONCATENATED MODULE: external ["wp","i18n"]
  27. var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
  28. ;// CONCATENATED MODULE: external ["wp","blockEditor"]
  29. var external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
  30. ;// CONCATENATED MODULE: external ["wp","primitives"]
  31. var external_wp_primitives_namespaceObject = window["wp"]["primitives"];
  32. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-bold.js
  33. /**
  34. * WordPress dependencies
  35. */
  36. const formatBold = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  37. xmlns: "http://www.w3.org/2000/svg",
  38. viewBox: "0 0 24 24"
  39. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  40. 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"
  41. }));
  42. /* harmony default export */ var format_bold = (formatBold);
  43. ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/bold/index.js
  44. /**
  45. * WordPress dependencies
  46. */
  47. const bold_name = 'core/bold';
  48. const title = (0,external_wp_i18n_namespaceObject.__)('Bold');
  49. const bold = {
  50. name: bold_name,
  51. title,
  52. tagName: 'strong',
  53. className: null,
  54. edit({
  55. isActive,
  56. value,
  57. onChange,
  58. onFocus
  59. }) {
  60. function onToggle() {
  61. onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, {
  62. type: bold_name,
  63. title
  64. }));
  65. }
  66. function onClick() {
  67. onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, {
  68. type: bold_name
  69. }));
  70. onFocus();
  71. }
  72. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, {
  73. type: "primary",
  74. character: "b",
  75. onUse: onToggle
  76. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
  77. name: "bold",
  78. icon: format_bold,
  79. title: title,
  80. onClick: onClick,
  81. isActive: isActive,
  82. shortcutType: "primary",
  83. shortcutCharacter: "b"
  84. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent, {
  85. inputType: "formatBold",
  86. onInput: onToggle
  87. }));
  88. }
  89. };
  90. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/code.js
  91. /**
  92. * WordPress dependencies
  93. */
  94. const code = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  95. viewBox: "0 0 24 24",
  96. xmlns: "http://www.w3.org/2000/svg"
  97. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  98. 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"
  99. }));
  100. /* harmony default export */ var library_code = (code);
  101. ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/code/index.js
  102. /**
  103. * WordPress dependencies
  104. */
  105. const code_name = 'core/code';
  106. const code_title = (0,external_wp_i18n_namespaceObject.__)('Inline code');
  107. const code_code = {
  108. name: code_name,
  109. title: code_title,
  110. tagName: 'code',
  111. className: null,
  112. __unstableInputRule(value) {
  113. const BACKTICK = '`';
  114. const {
  115. start,
  116. text
  117. } = value;
  118. const characterBefore = text[start - 1];
  119. // Quick check the text for the necessary character.
  120. if (characterBefore !== BACKTICK) {
  121. return value;
  122. }
  123. if (start - 2 < 0) {
  124. return value;
  125. }
  126. const indexBefore = text.lastIndexOf(BACKTICK, start - 2);
  127. if (indexBefore === -1) {
  128. return value;
  129. }
  130. const startIndex = indexBefore;
  131. const endIndex = start - 2;
  132. if (startIndex === endIndex) {
  133. return value;
  134. }
  135. value = (0,external_wp_richText_namespaceObject.remove)(value, startIndex, startIndex + 1);
  136. value = (0,external_wp_richText_namespaceObject.remove)(value, endIndex, endIndex + 1);
  137. value = (0,external_wp_richText_namespaceObject.applyFormat)(value, {
  138. type: code_name
  139. }, startIndex, endIndex);
  140. return value;
  141. },
  142. edit({
  143. value,
  144. onChange,
  145. onFocus,
  146. isActive
  147. }) {
  148. function onClick() {
  149. onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, {
  150. type: code_name,
  151. title: code_title
  152. }));
  153. onFocus();
  154. }
  155. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, {
  156. type: "access",
  157. character: "x",
  158. onUse: onClick
  159. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
  160. icon: library_code,
  161. title: code_title,
  162. onClick: onClick,
  163. isActive: isActive,
  164. role: "menuitemcheckbox"
  165. }));
  166. }
  167. };
  168. ;// CONCATENATED MODULE: external ["wp","components"]
  169. var external_wp_components_namespaceObject = window["wp"]["components"];
  170. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/keyboard-return.js
  171. /**
  172. * WordPress dependencies
  173. */
  174. const keyboardReturn = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  175. xmlns: "http://www.w3.org/2000/svg",
  176. viewBox: "-2 -2 24 24"
  177. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  178. 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"
  179. }));
  180. /* harmony default export */ var keyboard_return = (keyboardReturn);
  181. ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/image/index.js
  182. /**
  183. * WordPress dependencies
  184. */
  185. const ALLOWED_MEDIA_TYPES = ['image'];
  186. const image_name = 'core/image';
  187. const image_title = (0,external_wp_i18n_namespaceObject.__)('Inline image');
  188. const image_image = {
  189. name: image_name,
  190. title: image_title,
  191. keywords: [(0,external_wp_i18n_namespaceObject.__)('photo'), (0,external_wp_i18n_namespaceObject.__)('media')],
  192. object: true,
  193. tagName: 'img',
  194. className: null,
  195. attributes: {
  196. className: 'class',
  197. style: 'style',
  198. url: 'src',
  199. alt: 'alt'
  200. },
  201. edit: Edit
  202. };
  203. function InlineUI({
  204. value,
  205. onChange,
  206. activeObjectAttributes,
  207. contentRef
  208. }) {
  209. const {
  210. style
  211. } = activeObjectAttributes;
  212. const [width, setWidth] = (0,external_wp_element_namespaceObject.useState)(style?.replace(/\D/g, ''));
  213. const popoverAnchor = (0,external_wp_richText_namespaceObject.useAnchor)({
  214. editableContentElement: contentRef.current,
  215. settings: image_image
  216. });
  217. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
  218. placement: "bottom",
  219. focusOnMount: false,
  220. anchor: popoverAnchor,
  221. className: "block-editor-format-toolbar__image-popover"
  222. }, (0,external_wp_element_namespaceObject.createElement)("form", {
  223. className: "block-editor-format-toolbar__image-container-content",
  224. onSubmit: event => {
  225. const newReplacements = value.replacements.slice();
  226. newReplacements[value.start] = {
  227. type: image_name,
  228. attributes: {
  229. ...activeObjectAttributes,
  230. style: width ? `width: ${width}px;` : ''
  231. }
  232. };
  233. onChange({
  234. ...value,
  235. replacements: newReplacements
  236. });
  237. event.preventDefault();
  238. }
  239. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
  240. alignment: "bottom",
  241. spacing: "0"
  242. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalNumberControl, {
  243. className: "block-editor-format-toolbar__image-container-value",
  244. label: (0,external_wp_i18n_namespaceObject.__)('Width'),
  245. value: width,
  246. min: 1,
  247. onChange: newWidth => setWidth(newWidth)
  248. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  249. className: "block-editor-format-toolbar__image-container-button",
  250. icon: keyboard_return,
  251. label: (0,external_wp_i18n_namespaceObject.__)('Apply'),
  252. type: "submit"
  253. }))));
  254. }
  255. function Edit({
  256. value,
  257. onChange,
  258. onFocus,
  259. isObjectActive,
  260. activeObjectAttributes,
  261. contentRef
  262. }) {
  263. const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
  264. function openModal() {
  265. setIsModalOpen(true);
  266. }
  267. function closeModal() {
  268. setIsModalOpen(false);
  269. }
  270. return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.MediaUploadCheck, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
  271. icon: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
  272. xmlns: "http://www.w3.org/2000/svg",
  273. viewBox: "0 0 24 24"
  274. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
  275. 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"
  276. })),
  277. title: image_title,
  278. onClick: openModal,
  279. isActive: isObjectActive
  280. }), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.MediaUpload, {
  281. allowedTypes: ALLOWED_MEDIA_TYPES,
  282. onSelect: ({
  283. id,
  284. url,
  285. alt,
  286. width: imgWidth
  287. }) => {
  288. closeModal();
  289. onChange((0,external_wp_richText_namespaceObject.insertObject)(value, {
  290. type: image_name,
  291. attributes: {
  292. className: `wp-image-${id}`,
  293. style: `width: ${Math.min(imgWidth, 150)}px;`,
  294. url,
  295. alt
  296. }
  297. }));
  298. onFocus();
  299. },
  300. onClose: closeModal,
  301. render: ({
  302. open
  303. }) => {
  304. open();
  305. return null;
  306. }
  307. }), isObjectActive && (0,external_wp_element_namespaceObject.createElement)(InlineUI, {
  308. value: value,
  309. onChange: onChange,
  310. activeObjectAttributes: activeObjectAttributes,
  311. contentRef: contentRef
  312. }));
  313. }
  314. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-italic.js
  315. /**
  316. * WordPress dependencies
  317. */
  318. const formatItalic = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  319. xmlns: "http://www.w3.org/2000/svg",
  320. viewBox: "0 0 24 24"
  321. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  322. d: "M12.5 5L10 19h1.9l2.5-14z"
  323. }));
  324. /* harmony default export */ var format_italic = (formatItalic);
  325. ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/italic/index.js
  326. /**
  327. * WordPress dependencies
  328. */
  329. const italic_name = 'core/italic';
  330. const italic_title = (0,external_wp_i18n_namespaceObject.__)('Italic');
  331. const italic = {
  332. name: italic_name,
  333. title: italic_title,
  334. tagName: 'em',
  335. className: null,
  336. edit({
  337. isActive,
  338. value,
  339. onChange,
  340. onFocus
  341. }) {
  342. function onToggle() {
  343. onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, {
  344. type: italic_name,
  345. title: italic_title
  346. }));
  347. }
  348. function onClick() {
  349. onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, {
  350. type: italic_name
  351. }));
  352. onFocus();
  353. }
  354. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, {
  355. type: "primary",
  356. character: "i",
  357. onUse: onToggle
  358. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
  359. name: "italic",
  360. icon: format_italic,
  361. title: italic_title,
  362. onClick: onClick,
  363. isActive: isActive,
  364. shortcutType: "primary",
  365. shortcutCharacter: "i"
  366. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent, {
  367. inputType: "formatItalic",
  368. onInput: onToggle
  369. }));
  370. }
  371. };
  372. ;// CONCATENATED MODULE: external ["wp","url"]
  373. var external_wp_url_namespaceObject = window["wp"]["url"];
  374. ;// CONCATENATED MODULE: external ["wp","htmlEntities"]
  375. var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
  376. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/link-off.js
  377. /**
  378. * WordPress dependencies
  379. */
  380. const linkOff = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  381. xmlns: "http://www.w3.org/2000/svg",
  382. viewBox: "0 0 24 24"
  383. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  384. d: "M17.031 4.703 15.576 4l-1.56 3H14v.03l-2.324 4.47H9.5V13h1.396l-1.502 2.889h-.95a3.694 3.694 0 0 1 0-7.389H10V7H8.444a5.194 5.194 0 1 0 0 10.389h.17L7.5 19.53l1.416.719L15.049 8.5h.507a3.694 3.694 0 0 1 0 7.39H14v1.5h1.556a5.194 5.194 0 0 0 .273-10.383l1.202-2.304Z"
  385. }));
  386. /* harmony default export */ var link_off = (linkOff);
  387. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/link.js
  388. /**
  389. * WordPress dependencies
  390. */
  391. const link_link = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  392. xmlns: "http://www.w3.org/2000/svg",
  393. viewBox: "0 0 24 24"
  394. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  395. 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"
  396. }));
  397. /* harmony default export */ var library_link = (link_link);
  398. ;// CONCATENATED MODULE: external ["wp","a11y"]
  399. var external_wp_a11y_namespaceObject = window["wp"]["a11y"];
  400. ;// CONCATENATED MODULE: external ["wp","data"]
  401. var external_wp_data_namespaceObject = window["wp"]["data"];
  402. ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/link/utils.js
  403. /**
  404. * WordPress dependencies
  405. */
  406. /**
  407. * Check for issues with the provided href.
  408. *
  409. * @param {string} href The href.
  410. *
  411. * @return {boolean} Is the href invalid?
  412. */
  413. function isValidHref(href) {
  414. if (!href) {
  415. return false;
  416. }
  417. const trimmedHref = href.trim();
  418. if (!trimmedHref) {
  419. return false;
  420. }
  421. // Does the href start with something that looks like a URL protocol?
  422. if (/^\S+:/.test(trimmedHref)) {
  423. const protocol = (0,external_wp_url_namespaceObject.getProtocol)(trimmedHref);
  424. if (!(0,external_wp_url_namespaceObject.isValidProtocol)(protocol)) {
  425. return false;
  426. }
  427. // Add some extra checks for http(s) URIs, since these are the most common use-case.
  428. // This ensures URIs with an http protocol have exactly two forward slashes following the protocol.
  429. if (protocol.startsWith('http') && !/^https?:\/\/[^\/\s]/i.test(trimmedHref)) {
  430. return false;
  431. }
  432. const authority = (0,external_wp_url_namespaceObject.getAuthority)(trimmedHref);
  433. if (!(0,external_wp_url_namespaceObject.isValidAuthority)(authority)) {
  434. return false;
  435. }
  436. const path = (0,external_wp_url_namespaceObject.getPath)(trimmedHref);
  437. if (path && !(0,external_wp_url_namespaceObject.isValidPath)(path)) {
  438. return false;
  439. }
  440. const queryString = (0,external_wp_url_namespaceObject.getQueryString)(trimmedHref);
  441. if (queryString && !(0,external_wp_url_namespaceObject.isValidQueryString)(queryString)) {
  442. return false;
  443. }
  444. const fragment = (0,external_wp_url_namespaceObject.getFragment)(trimmedHref);
  445. if (fragment && !(0,external_wp_url_namespaceObject.isValidFragment)(fragment)) {
  446. return false;
  447. }
  448. }
  449. // Validate anchor links.
  450. if (trimmedHref.startsWith('#') && !(0,external_wp_url_namespaceObject.isValidFragment)(trimmedHref)) {
  451. return false;
  452. }
  453. return true;
  454. }
  455. /**
  456. * Generates the format object that will be applied to the link text.
  457. *
  458. * @param {Object} options
  459. * @param {string} options.url The href of the link.
  460. * @param {string} options.type The type of the link.
  461. * @param {string} options.id The ID of the link.
  462. * @param {boolean} options.opensInNewWindow Whether this link will open in a new window.
  463. * @param {boolean} options.nofollow Whether this link is marked as no follow relationship.
  464. * @return {Object} The final format object.
  465. */
  466. function createLinkFormat({
  467. url,
  468. type,
  469. id,
  470. opensInNewWindow,
  471. nofollow
  472. }) {
  473. const format = {
  474. type: 'core/link',
  475. attributes: {
  476. url
  477. }
  478. };
  479. if (type) format.attributes.type = type;
  480. if (id) format.attributes.id = id;
  481. if (opensInNewWindow) {
  482. format.attributes.target = '_blank';
  483. format.attributes.rel = format.attributes.rel ? format.attributes.rel + ' noreferrer noopener' : 'noreferrer noopener';
  484. }
  485. if (nofollow) {
  486. format.attributes.rel = format.attributes.rel ? format.attributes.rel + ' nofollow' : 'nofollow';
  487. }
  488. return format;
  489. }
  490. /* eslint-disable jsdoc/no-undefined-types */
  491. /**
  492. * Get the start and end boundaries of a given format from a rich text value.
  493. *
  494. *
  495. * @param {RichTextValue} value the rich text value to interrogate.
  496. * @param {string} format the identifier for the target format (e.g. `core/link`, `core/bold`).
  497. * @param {number?} startIndex optional startIndex to seek from.
  498. * @param {number?} endIndex optional endIndex to seek from.
  499. * @return {Object} object containing start and end values for the given format.
  500. */
  501. /* eslint-enable jsdoc/no-undefined-types */
  502. function getFormatBoundary(value, format, startIndex = value.start, endIndex = value.end) {
  503. const EMPTY_BOUNDARIES = {
  504. start: null,
  505. end: null
  506. };
  507. const {
  508. formats
  509. } = value;
  510. let targetFormat;
  511. let initialIndex;
  512. if (!formats?.length) {
  513. return EMPTY_BOUNDARIES;
  514. }
  515. // Clone formats to avoid modifying source formats.
  516. const newFormats = formats.slice();
  517. const formatAtStart = newFormats[startIndex]?.find(({
  518. type
  519. }) => type === format.type);
  520. const formatAtEnd = newFormats[endIndex]?.find(({
  521. type
  522. }) => type === format.type);
  523. const formatAtEndMinusOne = newFormats[endIndex - 1]?.find(({
  524. type
  525. }) => type === format.type);
  526. if (!!formatAtStart) {
  527. // Set values to conform to "start"
  528. targetFormat = formatAtStart;
  529. initialIndex = startIndex;
  530. } else if (!!formatAtEnd) {
  531. // Set values to conform to "end"
  532. targetFormat = formatAtEnd;
  533. initialIndex = endIndex;
  534. } else if (!!formatAtEndMinusOne) {
  535. // This is an edge case which will occur if you create a format, then place
  536. // the caret just before the format and hit the back ARROW key. The resulting
  537. // value object will have start and end +1 beyond the edge of the format boundary.
  538. targetFormat = formatAtEndMinusOne;
  539. initialIndex = endIndex - 1;
  540. } else {
  541. return EMPTY_BOUNDARIES;
  542. }
  543. const index = newFormats[initialIndex].indexOf(targetFormat);
  544. const walkingArgs = [newFormats, initialIndex, targetFormat, index];
  545. // Walk the startIndex "backwards" to the leading "edge" of the matching format.
  546. startIndex = walkToStart(...walkingArgs);
  547. // Walk the endIndex "forwards" until the trailing "edge" of the matching format.
  548. endIndex = walkToEnd(...walkingArgs);
  549. // Safe guard: start index cannot be less than 0.
  550. startIndex = startIndex < 0 ? 0 : startIndex;
  551. // // Return the indicies of the "edges" as the boundaries.
  552. return {
  553. start: startIndex,
  554. end: endIndex
  555. };
  556. }
  557. /**
  558. * Walks forwards/backwards towards the boundary of a given format within an
  559. * array of format objects. Returns the index of the boundary.
  560. *
  561. * @param {Array} formats the formats to search for the given format type.
  562. * @param {number} initialIndex the starting index from which to walk.
  563. * @param {Object} targetFormatRef a reference to the format type object being sought.
  564. * @param {number} formatIndex the index at which we expect the target format object to be.
  565. * @param {string} direction either 'forwards' or 'backwards' to indicate the direction.
  566. * @return {number} the index of the boundary of the given format.
  567. */
  568. function walkToBoundary(formats, initialIndex, targetFormatRef, formatIndex, direction) {
  569. let index = initialIndex;
  570. const directions = {
  571. forwards: 1,
  572. backwards: -1
  573. };
  574. const directionIncrement = directions[direction] || 1; // invalid direction arg default to forwards
  575. const inverseDirectionIncrement = directionIncrement * -1;
  576. while (formats[index] && formats[index][formatIndex] === targetFormatRef) {
  577. // Increment/decrement in the direction of operation.
  578. index = index + directionIncrement;
  579. }
  580. // Restore by one in inverse direction of operation
  581. // to avoid out of bounds.
  582. index = index + inverseDirectionIncrement;
  583. return index;
  584. }
  585. const partialRight = (fn, ...partialArgs) => (...args) => fn(...args, ...partialArgs);
  586. const walkToStart = partialRight(walkToBoundary, 'backwards');
  587. const walkToEnd = partialRight(walkToBoundary, 'forwards');
  588. ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/link/use-link-instance-key.js
  589. // Weakly referenced map allows unused ids to be garbage collected.
  590. const weakMap = new WeakMap();
  591. // Incrementing zero-based ID value.
  592. let id = -1;
  593. const prefix = 'link-control-instance';
  594. function getKey(_id) {
  595. return `${prefix}-${_id}`;
  596. }
  597. /**
  598. * Builds a unique link control key for the given object reference.
  599. *
  600. * @param {Object} instance an unique object reference specific to this link control instance.
  601. * @return {string | undefined} the unique key to use for this link control.
  602. */
  603. function useLinkInstanceKey(instance) {
  604. if (!instance) {
  605. return;
  606. }
  607. if (weakMap.has(instance)) {
  608. return getKey(weakMap.get(instance));
  609. }
  610. id += 1;
  611. weakMap.set(instance, id);
  612. return getKey(id);
  613. }
  614. /* harmony default export */ var use_link_instance_key = (useLinkInstanceKey);
  615. ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/link/inline.js
  616. /**
  617. * WordPress dependencies
  618. */
  619. /**
  620. * Internal dependencies
  621. */
  622. const LINK_SETTINGS = [...external_wp_blockEditor_namespaceObject.__experimentalLinkControl.DEFAULT_LINK_SETTINGS, {
  623. id: 'nofollow',
  624. title: (0,external_wp_i18n_namespaceObject.__)('Mark as nofollow')
  625. }];
  626. function InlineLinkUI({
  627. isActive,
  628. activeAttributes,
  629. addingLink,
  630. value,
  631. onChange,
  632. stopAddingLink,
  633. contentRef
  634. }) {
  635. const richLinkTextValue = getRichTextValueFromSelection(value, isActive);
  636. // Get the text content minus any HTML tags.
  637. const richTextText = richLinkTextValue.text;
  638. const {
  639. createPageEntity,
  640. userCanCreatePages
  641. } = (0,external_wp_data_namespaceObject.useSelect)(select => {
  642. const {
  643. getSettings
  644. } = select(external_wp_blockEditor_namespaceObject.store);
  645. const _settings = getSettings();
  646. return {
  647. createPageEntity: _settings.__experimentalCreatePageEntity,
  648. userCanCreatePages: _settings.__experimentalUserCanCreatePages
  649. };
  650. }, []);
  651. const linkValue = (0,external_wp_element_namespaceObject.useMemo)(() => ({
  652. url: activeAttributes.url,
  653. type: activeAttributes.type,
  654. id: activeAttributes.id,
  655. opensInNewTab: activeAttributes.target === '_blank',
  656. nofollow: activeAttributes.rel?.includes('nofollow'),
  657. title: richTextText
  658. }), [activeAttributes.id, activeAttributes.rel, activeAttributes.target, activeAttributes.type, activeAttributes.url, richTextText]);
  659. function removeLink() {
  660. const newValue = (0,external_wp_richText_namespaceObject.removeFormat)(value, 'core/link');
  661. onChange(newValue);
  662. stopAddingLink();
  663. (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Link removed.'), 'assertive');
  664. }
  665. function onChangeLink(nextValue) {
  666. // LinkControl calls `onChange` immediately upon the toggling a setting.
  667. // Before merging the next value with the current link value, check if
  668. // the setting was toggled.
  669. const didToggleSetting = linkValue.opensInNewTab !== nextValue.opensInNewTab && nextValue.url === undefined;
  670. // Merge the next value with the current link value.
  671. nextValue = {
  672. ...linkValue,
  673. ...nextValue
  674. };
  675. const newUrl = (0,external_wp_url_namespaceObject.prependHTTP)(nextValue.url);
  676. const linkFormat = createLinkFormat({
  677. url: newUrl,
  678. type: nextValue.type,
  679. id: nextValue.id !== undefined && nextValue.id !== null ? String(nextValue.id) : undefined,
  680. opensInNewWindow: nextValue.opensInNewTab,
  681. nofollow: nextValue.nofollow
  682. });
  683. const newText = nextValue.title || newUrl;
  684. if ((0,external_wp_richText_namespaceObject.isCollapsed)(value) && !isActive) {
  685. // Scenario: we don't have any actively selected text or formats.
  686. const toInsert = (0,external_wp_richText_namespaceObject.applyFormat)((0,external_wp_richText_namespaceObject.create)({
  687. text: newText
  688. }), linkFormat, 0, newText.length);
  689. onChange((0,external_wp_richText_namespaceObject.insert)(value, toInsert));
  690. } else {
  691. // Scenario: we have any active text selection or an active format.
  692. let newValue;
  693. if (newText === richTextText) {
  694. // If we're not updating the text then ignore.
  695. newValue = (0,external_wp_richText_namespaceObject.applyFormat)(value, linkFormat);
  696. } else {
  697. // Create new RichText value for the new text in order that we
  698. // can apply formats to it.
  699. newValue = (0,external_wp_richText_namespaceObject.create)({
  700. text: newText
  701. });
  702. // Apply the new Link format to this new text value.
  703. newValue = (0,external_wp_richText_namespaceObject.applyFormat)(newValue, linkFormat, 0, newText.length);
  704. // Get the boundaries of the active link format.
  705. const boundary = getFormatBoundary(value, {
  706. type: 'core/link'
  707. });
  708. // Split the value at the start of the active link format.
  709. // Passing "start" as the 3rd parameter is required to ensure
  710. // the second half of the split value is split at the format's
  711. // start boundary and avoids relying on the value's "end" property
  712. // which may not correspond correctly.
  713. const [valBefore, valAfter] = (0,external_wp_richText_namespaceObject.split)(value, boundary.start, boundary.start);
  714. // Update the original (full) RichTextValue replacing the
  715. // target text with the *new* RichTextValue containing:
  716. // 1. The new text content.
  717. // 2. The new link format.
  718. // As "replace" will operate on the first match only, it is
  719. // run only against the second half of the value which was
  720. // split at the active format's boundary. This avoids a bug
  721. // with incorrectly targetted replacements.
  722. // See: https://github.com/WordPress/gutenberg/issues/41771.
  723. // Note original formats will be lost when applying this change.
  724. // That is expected behaviour.
  725. // See: https://github.com/WordPress/gutenberg/pull/33849#issuecomment-936134179.
  726. const newValAfter = (0,external_wp_richText_namespaceObject.replace)(valAfter, richTextText, newValue);
  727. newValue = (0,external_wp_richText_namespaceObject.concat)(valBefore, newValAfter);
  728. }
  729. newValue.start = newValue.end;
  730. // Hides the Link UI.
  731. newValue.activeFormats = [];
  732. onChange(newValue);
  733. }
  734. // Focus should only be shifted back to the formatted segment when the
  735. // URL is submitted.
  736. if (!didToggleSetting) {
  737. stopAddingLink();
  738. }
  739. if (!isValidHref(newUrl)) {
  740. (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');
  741. } else if (isActive) {
  742. (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Link edited.'), 'assertive');
  743. } else {
  744. (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Link inserted.'), 'assertive');
  745. }
  746. }
  747. const popoverAnchor = (0,external_wp_richText_namespaceObject.useAnchor)({
  748. editableContentElement: contentRef.current,
  749. settings: build_module_link_link
  750. });
  751. // Generate a string based key that is unique to this anchor reference.
  752. // This is used to force re-mount the LinkControl component to avoid
  753. // potential stale state bugs caused by the component not being remounted
  754. // See https://github.com/WordPress/gutenberg/pull/34742.
  755. const forceRemountKey = use_link_instance_key(popoverAnchor);
  756. // Focus should only be moved into the Popover when the Link is being created or edited.
  757. // When the Link is in "preview" mode focus should remain on the rich text because at
  758. // this point the Link dialog is informational only and thus the user should be able to
  759. // continue editing the rich text.
  760. // Ref used because the focusOnMount prop shouldn't evolve during render of a Popover
  761. // otherwise it causes a render of the content.
  762. const focusOnMount = (0,external_wp_element_namespaceObject.useRef)(addingLink ? 'firstElement' : false);
  763. async function handleCreate(pageTitle) {
  764. const page = await createPageEntity({
  765. title: pageTitle,
  766. status: 'draft'
  767. });
  768. return {
  769. id: page.id,
  770. type: page.type,
  771. title: page.title.rendered,
  772. url: page.link,
  773. kind: 'post-type'
  774. };
  775. }
  776. function createButtonText(searchTerm) {
  777. return (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: search term. */
  778. (0,external_wp_i18n_namespaceObject.__)('Create page: <mark>%s</mark>'), searchTerm), {
  779. mark: (0,external_wp_element_namespaceObject.createElement)("mark", null)
  780. });
  781. }
  782. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
  783. anchor: popoverAnchor,
  784. focusOnMount: focusOnMount.current,
  785. onClose: stopAddingLink,
  786. onFocusOutside: () => stopAddingLink(false),
  787. placement: "bottom",
  788. shift: true
  789. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLinkControl, {
  790. key: forceRemountKey,
  791. value: linkValue,
  792. onChange: onChangeLink,
  793. onRemove: removeLink,
  794. forceIsEditingLink: addingLink,
  795. hasRichPreviews: true,
  796. createSuggestion: createPageEntity && handleCreate,
  797. withCreateSuggestion: userCanCreatePages,
  798. createSuggestionButtonText: createButtonText,
  799. hasTextControl: true,
  800. settings: LINK_SETTINGS
  801. }));
  802. }
  803. function getRichTextValueFromSelection(value, isActive) {
  804. // Default to the selection ranges on the RichTextValue object.
  805. let textStart = value.start;
  806. let textEnd = value.end;
  807. // If the format is currently active then the rich text value
  808. // should always be taken from the bounds of the active format
  809. // and not the selected text.
  810. if (isActive) {
  811. const boundary = getFormatBoundary(value, {
  812. type: 'core/link'
  813. });
  814. textStart = boundary.start;
  815. // Text *selection* always extends +1 beyond the edge of the format.
  816. // We account for that here.
  817. textEnd = boundary.end + 1;
  818. }
  819. // Get a RichTextValue containing the selected text content.
  820. return (0,external_wp_richText_namespaceObject.slice)(value, textStart, textEnd);
  821. }
  822. /* harmony default export */ var inline = (InlineLinkUI);
  823. ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/link/index.js
  824. /**
  825. * WordPress dependencies
  826. */
  827. /**
  828. * Internal dependencies
  829. */
  830. const link_name = 'core/link';
  831. const link_title = (0,external_wp_i18n_namespaceObject.__)('Link');
  832. function link_Edit({
  833. isActive,
  834. activeAttributes,
  835. value,
  836. onChange,
  837. onFocus,
  838. contentRef
  839. }) {
  840. const [addingLink, setAddingLink] = (0,external_wp_element_namespaceObject.useState)(false);
  841. function addLink() {
  842. const text = (0,external_wp_richText_namespaceObject.getTextContent)((0,external_wp_richText_namespaceObject.slice)(value));
  843. if (text && (0,external_wp_url_namespaceObject.isURL)(text) && isValidHref(text)) {
  844. onChange((0,external_wp_richText_namespaceObject.applyFormat)(value, {
  845. type: link_name,
  846. attributes: {
  847. url: text
  848. }
  849. }));
  850. } else if (text && (0,external_wp_url_namespaceObject.isEmail)(text)) {
  851. onChange((0,external_wp_richText_namespaceObject.applyFormat)(value, {
  852. type: link_name,
  853. attributes: {
  854. url: `mailto:${text}`
  855. }
  856. }));
  857. } else {
  858. setAddingLink(true);
  859. }
  860. }
  861. function stopAddingLink(returnFocus = true) {
  862. setAddingLink(false);
  863. if (returnFocus) {
  864. onFocus();
  865. }
  866. }
  867. function onRemoveFormat() {
  868. onChange((0,external_wp_richText_namespaceObject.removeFormat)(value, link_name));
  869. (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Link removed.'), 'assertive');
  870. }
  871. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, {
  872. type: "primary",
  873. character: "k",
  874. onUse: addLink
  875. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, {
  876. type: "primaryShift",
  877. character: "k",
  878. onUse: onRemoveFormat
  879. }), isActive && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
  880. name: "link",
  881. icon: link_off,
  882. title: (0,external_wp_i18n_namespaceObject.__)('Unlink'),
  883. onClick: onRemoveFormat,
  884. isActive: isActive,
  885. shortcutType: "primaryShift",
  886. shortcutCharacter: "k",
  887. "aria-haspopup": "true",
  888. "aria-expanded": addingLink || isActive
  889. }), !isActive && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
  890. name: "link",
  891. icon: library_link,
  892. title: link_title,
  893. onClick: addLink,
  894. isActive: isActive,
  895. shortcutType: "primary",
  896. shortcutCharacter: "k",
  897. "aria-haspopup": "true",
  898. "aria-expanded": addingLink || isActive
  899. }), (addingLink || isActive) && (0,external_wp_element_namespaceObject.createElement)(inline, {
  900. addingLink: addingLink,
  901. stopAddingLink: stopAddingLink,
  902. isActive: isActive,
  903. activeAttributes: activeAttributes,
  904. value: value,
  905. onChange: onChange,
  906. contentRef: contentRef
  907. }));
  908. }
  909. const build_module_link_link = {
  910. name: link_name,
  911. title: link_title,
  912. tagName: 'a',
  913. className: null,
  914. attributes: {
  915. url: 'href',
  916. type: 'data-type',
  917. id: 'data-id',
  918. target: 'target',
  919. rel: 'rel'
  920. },
  921. __unstablePasteRule(value, {
  922. html,
  923. plainText
  924. }) {
  925. if ((0,external_wp_richText_namespaceObject.isCollapsed)(value)) {
  926. return value;
  927. }
  928. const pastedText = (html || plainText).replace(/<[^>]+>/g, '').trim();
  929. // A URL was pasted, turn the selection into a link.
  930. if (!(0,external_wp_url_namespaceObject.isURL)(pastedText)) {
  931. return value;
  932. }
  933. // Allows us to ask for this information when we get a report.
  934. window.console.log('Created link:\n\n', pastedText);
  935. return (0,external_wp_richText_namespaceObject.applyFormat)(value, {
  936. type: link_name,
  937. attributes: {
  938. url: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(pastedText)
  939. }
  940. });
  941. },
  942. edit: link_Edit
  943. };
  944. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-strikethrough.js
  945. /**
  946. * WordPress dependencies
  947. */
  948. const formatStrikethrough = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  949. xmlns: "http://www.w3.org/2000/svg",
  950. viewBox: "0 0 24 24"
  951. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  952. 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"
  953. }));
  954. /* harmony default export */ var format_strikethrough = (formatStrikethrough);
  955. ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/strikethrough/index.js
  956. /**
  957. * WordPress dependencies
  958. */
  959. const strikethrough_name = 'core/strikethrough';
  960. const strikethrough_title = (0,external_wp_i18n_namespaceObject.__)('Strikethrough');
  961. const strikethrough = {
  962. name: strikethrough_name,
  963. title: strikethrough_title,
  964. tagName: 's',
  965. className: null,
  966. edit({
  967. isActive,
  968. value,
  969. onChange,
  970. onFocus
  971. }) {
  972. function onClick() {
  973. onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, {
  974. type: strikethrough_name,
  975. title: strikethrough_title
  976. }));
  977. onFocus();
  978. }
  979. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, {
  980. type: "access",
  981. character: "d",
  982. onUse: onClick
  983. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
  984. icon: format_strikethrough,
  985. title: strikethrough_title,
  986. onClick: onClick,
  987. isActive: isActive,
  988. role: "menuitemcheckbox"
  989. }));
  990. }
  991. };
  992. ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/underline/index.js
  993. /**
  994. * WordPress dependencies
  995. */
  996. const underline_name = 'core/underline';
  997. const underline_title = (0,external_wp_i18n_namespaceObject.__)('Underline');
  998. const underline = {
  999. name: underline_name,
  1000. title: underline_title,
  1001. tagName: 'span',
  1002. className: null,
  1003. attributes: {
  1004. style: 'style'
  1005. },
  1006. edit({
  1007. value,
  1008. onChange
  1009. }) {
  1010. const onToggle = () => {
  1011. onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, {
  1012. type: underline_name,
  1013. attributes: {
  1014. style: 'text-decoration: underline;'
  1015. },
  1016. title: underline_title
  1017. }));
  1018. };
  1019. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, {
  1020. type: "primary",
  1021. character: "u",
  1022. onUse: onToggle
  1023. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent, {
  1024. inputType: "formatUnderline",
  1025. onInput: onToggle
  1026. }));
  1027. }
  1028. };
  1029. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/icon/index.js
  1030. /**
  1031. * WordPress dependencies
  1032. */
  1033. /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */
  1034. /**
  1035. * Return an SVG icon.
  1036. *
  1037. * @param {IconProps} props icon is the SVG component to render
  1038. * size is a number specifiying the icon size in pixels
  1039. * Other props will be passed to wrapped SVG component
  1040. * @param {import('react').ForwardedRef<HTMLElement>} ref The forwarded ref to the SVG element.
  1041. *
  1042. * @return {JSX.Element} Icon component
  1043. */
  1044. function Icon({
  1045. icon,
  1046. size = 24,
  1047. ...props
  1048. }, ref) {
  1049. return (0,external_wp_element_namespaceObject.cloneElement)(icon, {
  1050. width: size,
  1051. height: size,
  1052. ...props,
  1053. ref
  1054. });
  1055. }
  1056. /* harmony default export */ var icon = ((0,external_wp_element_namespaceObject.forwardRef)(Icon));
  1057. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/text-color.js
  1058. /**
  1059. * WordPress dependencies
  1060. */
  1061. const textColor = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  1062. xmlns: "http://www.w3.org/2000/svg",
  1063. viewBox: "0 0 24 24"
  1064. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  1065. 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"
  1066. }));
  1067. /* harmony default export */ var text_color = (textColor);
  1068. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/color.js
  1069. /**
  1070. * WordPress dependencies
  1071. */
  1072. const color = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  1073. viewBox: "0 0 24 24",
  1074. xmlns: "http://www.w3.org/2000/svg"
  1075. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  1076. 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"
  1077. }));
  1078. /* harmony default export */ var library_color = (color);
  1079. ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/text-color/inline.js
  1080. /**
  1081. * WordPress dependencies
  1082. */
  1083. /**
  1084. * Internal dependencies
  1085. */
  1086. function parseCSS(css = '') {
  1087. return css.split(';').reduce((accumulator, rule) => {
  1088. if (rule) {
  1089. const [property, value] = rule.split(':');
  1090. if (property === 'color') accumulator.color = value;
  1091. if (property === 'background-color' && value !== transparentValue) accumulator.backgroundColor = value;
  1092. }
  1093. return accumulator;
  1094. }, {});
  1095. }
  1096. function parseClassName(className = '', colorSettings) {
  1097. return className.split(' ').reduce((accumulator, name) => {
  1098. // `colorSlug` could contain dashes, so simply match the start and end.
  1099. if (name.startsWith('has-') && name.endsWith('-color')) {
  1100. const colorSlug = name.replace(/^has-/, '').replace(/-color$/, '');
  1101. const colorObject = (0,external_wp_blockEditor_namespaceObject.getColorObjectByAttributeValues)(colorSettings, colorSlug);
  1102. accumulator.color = colorObject.color;
  1103. }
  1104. return accumulator;
  1105. }, {});
  1106. }
  1107. function getActiveColors(value, name, colorSettings) {
  1108. const activeColorFormat = (0,external_wp_richText_namespaceObject.getActiveFormat)(value, name);
  1109. if (!activeColorFormat) {
  1110. return {};
  1111. }
  1112. return {
  1113. ...parseCSS(activeColorFormat.attributes.style),
  1114. ...parseClassName(activeColorFormat.attributes.class, colorSettings)
  1115. };
  1116. }
  1117. function setColors(value, name, colorSettings, colors) {
  1118. const {
  1119. color,
  1120. backgroundColor
  1121. } = {
  1122. ...getActiveColors(value, name, colorSettings),
  1123. ...colors
  1124. };
  1125. if (!color && !backgroundColor) {
  1126. return (0,external_wp_richText_namespaceObject.removeFormat)(value, name);
  1127. }
  1128. const styles = [];
  1129. const classNames = [];
  1130. const attributes = {};
  1131. if (backgroundColor) {
  1132. styles.push(['background-color', backgroundColor].join(':'));
  1133. } else {
  1134. // Override default browser color for mark element.
  1135. styles.push(['background-color', transparentValue].join(':'));
  1136. }
  1137. if (color) {
  1138. const colorObject = (0,external_wp_blockEditor_namespaceObject.getColorObjectByColorValue)(colorSettings, color);
  1139. if (colorObject) {
  1140. classNames.push((0,external_wp_blockEditor_namespaceObject.getColorClassName)('color', colorObject.slug));
  1141. } else {
  1142. styles.push(['color', color].join(':'));
  1143. }
  1144. }
  1145. if (styles.length) attributes.style = styles.join(';');
  1146. if (classNames.length) attributes.class = classNames.join(' ');
  1147. return (0,external_wp_richText_namespaceObject.applyFormat)(value, {
  1148. type: name,
  1149. attributes
  1150. });
  1151. }
  1152. function ColorPicker({
  1153. name,
  1154. property,
  1155. value,
  1156. onChange
  1157. }) {
  1158. const colors = (0,external_wp_data_namespaceObject.useSelect)(select => {
  1159. var _getSettings$colors;
  1160. const {
  1161. getSettings
  1162. } = select(external_wp_blockEditor_namespaceObject.store);
  1163. return (_getSettings$colors = getSettings().colors) !== null && _getSettings$colors !== void 0 ? _getSettings$colors : [];
  1164. }, []);
  1165. const onColorChange = (0,external_wp_element_namespaceObject.useCallback)(color => {
  1166. onChange(setColors(value, name, colors, {
  1167. [property]: color
  1168. }));
  1169. }, [colors, onChange, property]);
  1170. const activeColors = (0,external_wp_element_namespaceObject.useMemo)(() => getActiveColors(value, name, colors), [name, value, colors]);
  1171. return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.ColorPalette, {
  1172. value: activeColors[property],
  1173. onChange: onColorChange
  1174. });
  1175. }
  1176. function InlineColorUI({
  1177. name,
  1178. value,
  1179. onChange,
  1180. onClose,
  1181. contentRef
  1182. }) {
  1183. const popoverAnchor = (0,external_wp_richText_namespaceObject.useAnchor)({
  1184. editableContentElement: contentRef.current,
  1185. settings: text_color_textColor
  1186. });
  1187. /*
  1188. As you change the text color by typing a HEX value into a field,
  1189. the return value of document.getSelection jumps to the field you're editing,
  1190. not the highlighted text. Given that useAnchor uses document.getSelection,
  1191. it will return null, since it can't find the <mark> element within the HEX input.
  1192. This caches the last truthy value of the selection anchor reference.
  1193. */
  1194. const cachedRect = (0,external_wp_blockEditor_namespaceObject.useCachedTruthy)(popoverAnchor.getBoundingClientRect());
  1195. popoverAnchor.getBoundingClientRect = () => cachedRect;
  1196. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
  1197. onClose: onClose,
  1198. className: "components-inline-color-popover",
  1199. anchor: popoverAnchor
  1200. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TabPanel, {
  1201. tabs: [{
  1202. name: 'color',
  1203. title: (0,external_wp_i18n_namespaceObject.__)('Text')
  1204. }, {
  1205. name: 'backgroundColor',
  1206. title: (0,external_wp_i18n_namespaceObject.__)('Background')
  1207. }]
  1208. }, tab => (0,external_wp_element_namespaceObject.createElement)(ColorPicker, {
  1209. name: name,
  1210. property: tab.name,
  1211. value: value,
  1212. onChange: onChange
  1213. })));
  1214. }
  1215. ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/text-color/index.js
  1216. /**
  1217. * WordPress dependencies
  1218. */
  1219. /**
  1220. * Internal dependencies
  1221. */
  1222. const transparentValue = 'rgba(0, 0, 0, 0)';
  1223. const text_color_name = 'core/text-color';
  1224. const text_color_title = (0,external_wp_i18n_namespaceObject.__)('Highlight');
  1225. const EMPTY_ARRAY = [];
  1226. function getComputedStyleProperty(element, property) {
  1227. const {
  1228. ownerDocument
  1229. } = element;
  1230. const {
  1231. defaultView
  1232. } = ownerDocument;
  1233. const style = defaultView.getComputedStyle(element);
  1234. const value = style.getPropertyValue(property);
  1235. if (property === 'background-color' && value === transparentValue && element.parentElement) {
  1236. return getComputedStyleProperty(element.parentElement, property);
  1237. }
  1238. return value;
  1239. }
  1240. function fillComputedColors(element, {
  1241. color,
  1242. backgroundColor
  1243. }) {
  1244. if (!color && !backgroundColor) {
  1245. return;
  1246. }
  1247. return {
  1248. color: color || getComputedStyleProperty(element, 'color'),
  1249. backgroundColor: backgroundColor === transparentValue ? getComputedStyleProperty(element, 'background-color') : backgroundColor
  1250. };
  1251. }
  1252. function TextColorEdit({
  1253. value,
  1254. onChange,
  1255. isActive,
  1256. activeAttributes,
  1257. contentRef
  1258. }) {
  1259. const allowCustomControl = (0,external_wp_blockEditor_namespaceObject.useSetting)('color.custom');
  1260. const colors = (0,external_wp_blockEditor_namespaceObject.useSetting)('color.palette') || EMPTY_ARRAY;
  1261. const [isAddingColor, setIsAddingColor] = (0,external_wp_element_namespaceObject.useState)(false);
  1262. const enableIsAddingColor = (0,external_wp_element_namespaceObject.useCallback)(() => setIsAddingColor(true), [setIsAddingColor]);
  1263. const disableIsAddingColor = (0,external_wp_element_namespaceObject.useCallback)(() => setIsAddingColor(false), [setIsAddingColor]);
  1264. const colorIndicatorStyle = (0,external_wp_element_namespaceObject.useMemo)(() => fillComputedColors(contentRef.current, getActiveColors(value, text_color_name, colors)), [value, colors]);
  1265. const hasColorsToChoose = colors.length || !allowCustomControl;
  1266. if (!hasColorsToChoose && !isActive) {
  1267. return null;
  1268. }
  1269. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
  1270. className: "format-library-text-color-button",
  1271. isActive: isActive,
  1272. icon: (0,external_wp_element_namespaceObject.createElement)(icon, {
  1273. icon: Object.keys(activeAttributes).length ? text_color : library_color,
  1274. style: colorIndicatorStyle
  1275. }),
  1276. title: text_color_title
  1277. // If has no colors to choose but a color is active remove the color onClick.
  1278. ,
  1279. onClick: hasColorsToChoose ? enableIsAddingColor : () => onChange((0,external_wp_richText_namespaceObject.removeFormat)(value, text_color_name)),
  1280. role: "menuitemcheckbox"
  1281. }), isAddingColor && (0,external_wp_element_namespaceObject.createElement)(InlineColorUI, {
  1282. name: text_color_name,
  1283. onClose: disableIsAddingColor,
  1284. activeAttributes: activeAttributes,
  1285. value: value,
  1286. onChange: onChange,
  1287. contentRef: contentRef
  1288. }));
  1289. }
  1290. const text_color_textColor = {
  1291. name: text_color_name,
  1292. title: text_color_title,
  1293. tagName: 'mark',
  1294. className: 'has-inline-color',
  1295. attributes: {
  1296. style: 'style',
  1297. class: 'class'
  1298. },
  1299. /*
  1300. * Since this format relies on the <mark> tag, it's important to
  1301. * prevent the default yellow background color applied by most
  1302. * browsers. The solution is to detect when this format is used with a
  1303. * text color but no background color, and in such cases to override
  1304. * the default styling with a transparent background.
  1305. *
  1306. * @see https://github.com/WordPress/gutenberg/pull/35516
  1307. */
  1308. __unstableFilterAttributeValue(key, value) {
  1309. if (key !== 'style') return value;
  1310. // We should not add a background-color if it's already set.
  1311. if (value && value.includes('background-color')) return value;
  1312. const addedCSS = ['background-color', transparentValue].join(':');
  1313. // Prepend `addedCSS` to avoid a double `;;` as any the existing CSS
  1314. // rules will already include a `;`.
  1315. return value ? [addedCSS, value].join(';') : addedCSS;
  1316. },
  1317. edit: TextColorEdit
  1318. };
  1319. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/subscript.js
  1320. /**
  1321. * WordPress dependencies
  1322. */
  1323. const subscript = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  1324. xmlns: "http://www.w3.org/2000/svg",
  1325. viewBox: "0 0 24 24"
  1326. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  1327. 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"
  1328. }));
  1329. /* harmony default export */ var library_subscript = (subscript);
  1330. ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/subscript/index.js
  1331. /**
  1332. * WordPress dependencies
  1333. */
  1334. const subscript_name = 'core/subscript';
  1335. const subscript_title = (0,external_wp_i18n_namespaceObject.__)('Subscript');
  1336. const subscript_subscript = {
  1337. name: subscript_name,
  1338. title: subscript_title,
  1339. tagName: 'sub',
  1340. className: null,
  1341. edit({
  1342. isActive,
  1343. value,
  1344. onChange,
  1345. onFocus
  1346. }) {
  1347. function onToggle() {
  1348. onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, {
  1349. type: subscript_name,
  1350. title: subscript_title
  1351. }));
  1352. }
  1353. function onClick() {
  1354. onToggle();
  1355. onFocus();
  1356. }
  1357. return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
  1358. icon: library_subscript,
  1359. title: subscript_title,
  1360. onClick: onClick,
  1361. isActive: isActive,
  1362. role: "menuitemcheckbox"
  1363. });
  1364. }
  1365. };
  1366. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/superscript.js
  1367. /**
  1368. * WordPress dependencies
  1369. */
  1370. const superscript = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  1371. xmlns: "http://www.w3.org/2000/svg",
  1372. viewBox: "0 0 24 24"
  1373. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  1374. 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"
  1375. }));
  1376. /* harmony default export */ var library_superscript = (superscript);
  1377. ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/superscript/index.js
  1378. /**
  1379. * WordPress dependencies
  1380. */
  1381. const superscript_name = 'core/superscript';
  1382. const superscript_title = (0,external_wp_i18n_namespaceObject.__)('Superscript');
  1383. const superscript_superscript = {
  1384. name: superscript_name,
  1385. title: superscript_title,
  1386. tagName: 'sup',
  1387. className: null,
  1388. edit({
  1389. isActive,
  1390. value,
  1391. onChange,
  1392. onFocus
  1393. }) {
  1394. function onToggle() {
  1395. onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, {
  1396. type: superscript_name,
  1397. title: superscript_title
  1398. }));
  1399. }
  1400. function onClick() {
  1401. onToggle();
  1402. onFocus();
  1403. }
  1404. return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
  1405. icon: library_superscript,
  1406. title: superscript_title,
  1407. onClick: onClick,
  1408. isActive: isActive,
  1409. role: "menuitemcheckbox"
  1410. });
  1411. }
  1412. };
  1413. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/button.js
  1414. /**
  1415. * WordPress dependencies
  1416. */
  1417. const button_button = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  1418. viewBox: "0 0 24 24",
  1419. xmlns: "http://www.w3.org/2000/svg"
  1420. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  1421. 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"
  1422. }));
  1423. /* harmony default export */ var library_button = (button_button);
  1424. ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/keyboard/index.js
  1425. /**
  1426. * WordPress dependencies
  1427. */
  1428. const keyboard_name = 'core/keyboard';
  1429. const keyboard_title = (0,external_wp_i18n_namespaceObject.__)('Keyboard input');
  1430. const keyboard = {
  1431. name: keyboard_name,
  1432. title: keyboard_title,
  1433. tagName: 'kbd',
  1434. className: null,
  1435. edit({
  1436. isActive,
  1437. value,
  1438. onChange,
  1439. onFocus
  1440. }) {
  1441. function onToggle() {
  1442. onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, {
  1443. type: keyboard_name,
  1444. title: keyboard_title
  1445. }));
  1446. }
  1447. function onClick() {
  1448. onToggle();
  1449. onFocus();
  1450. }
  1451. return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
  1452. icon: library_button,
  1453. title: keyboard_title,
  1454. onClick: onClick,
  1455. isActive: isActive,
  1456. role: "menuitemcheckbox"
  1457. });
  1458. }
  1459. };
  1460. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/help.js
  1461. /**
  1462. * WordPress dependencies
  1463. */
  1464. const help = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  1465. xmlns: "http://www.w3.org/2000/svg",
  1466. viewBox: "0 0 24 24"
  1467. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  1468. 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"
  1469. }));
  1470. /* harmony default export */ var library_help = (help);
  1471. ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/unknown/index.js
  1472. /**
  1473. * WordPress dependencies
  1474. */
  1475. const unknown_name = 'core/unknown';
  1476. const unknown_title = (0,external_wp_i18n_namespaceObject.__)('Clear Unknown Formatting');
  1477. const unknown = {
  1478. name: unknown_name,
  1479. title: unknown_title,
  1480. tagName: '*',
  1481. className: null,
  1482. edit({
  1483. isActive,
  1484. value,
  1485. onChange,
  1486. onFocus
  1487. }) {
  1488. function onClick() {
  1489. onChange((0,external_wp_richText_namespaceObject.removeFormat)(value, unknown_name));
  1490. onFocus();
  1491. }
  1492. const selectedValue = (0,external_wp_richText_namespaceObject.slice)(value);
  1493. const hasUnknownFormats = selectedValue.formats.some(formats => {
  1494. return formats.some(format => format.type === unknown_name);
  1495. });
  1496. if (!isActive && !hasUnknownFormats) {
  1497. return null;
  1498. }
  1499. return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
  1500. name: "unknown",
  1501. icon: library_help,
  1502. title: unknown_title,
  1503. onClick: onClick,
  1504. isActive: true
  1505. });
  1506. }
  1507. };
  1508. ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/language.js
  1509. /**
  1510. * WordPress dependencies
  1511. */
  1512. const language = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
  1513. xmlns: "http://www.w3.org/2000/svg",
  1514. viewBox: "0 0 24 24"
  1515. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
  1516. 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"
  1517. }));
  1518. /* harmony default export */ var library_language = (language);
  1519. ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/language/index.js
  1520. /**
  1521. * WordPress dependencies
  1522. */
  1523. /**
  1524. * WordPress dependencies
  1525. */
  1526. const language_name = 'core/language';
  1527. const language_title = (0,external_wp_i18n_namespaceObject.__)('Language');
  1528. const language_language = {
  1529. name: language_name,
  1530. tagName: 'bdo',
  1531. className: null,
  1532. edit: language_Edit,
  1533. title: language_title
  1534. };
  1535. function language_Edit({
  1536. isActive,
  1537. value,
  1538. onChange,
  1539. contentRef
  1540. }) {
  1541. const [isPopoverVisible, setIsPopoverVisible] = (0,external_wp_element_namespaceObject.useState)(false);
  1542. const togglePopover = () => {
  1543. setIsPopoverVisible(state => !state);
  1544. };
  1545. return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
  1546. icon: library_language,
  1547. label: language_title,
  1548. title: language_title,
  1549. onClick: () => {
  1550. if (isActive) {
  1551. onChange((0,external_wp_richText_namespaceObject.removeFormat)(value, language_name));
  1552. } else {
  1553. togglePopover();
  1554. }
  1555. },
  1556. isActive: isActive,
  1557. role: "menuitemcheckbox"
  1558. }), isPopoverVisible && (0,external_wp_element_namespaceObject.createElement)(InlineLanguageUI, {
  1559. value: value,
  1560. onChange: onChange,
  1561. onClose: togglePopover,
  1562. contentRef: contentRef
  1563. }));
  1564. }
  1565. function InlineLanguageUI({
  1566. value,
  1567. contentRef,
  1568. onChange,
  1569. onClose
  1570. }) {
  1571. const popoverAnchor = (0,external_wp_richText_namespaceObject.useAnchor)({
  1572. editableContentElement: contentRef.current,
  1573. settings: language_language
  1574. });
  1575. const [lang, setLang] = (0,external_wp_element_namespaceObject.useState)('');
  1576. const [dir, setDir] = (0,external_wp_element_namespaceObject.useState)('ltr');
  1577. return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
  1578. className: "block-editor-format-toolbar__language-popover",
  1579. anchor: popoverAnchor,
  1580. onClose: onClose
  1581. }, (0,external_wp_element_namespaceObject.createElement)("form", {
  1582. className: "block-editor-format-toolbar__language-container-content",
  1583. onSubmit: event => {
  1584. event.preventDefault();
  1585. onChange((0,external_wp_richText_namespaceObject.applyFormat)(value, {
  1586. type: language_name,
  1587. attributes: {
  1588. lang,
  1589. dir
  1590. }
  1591. }));
  1592. onClose();
  1593. }
  1594. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
  1595. label: language_title,
  1596. value: lang,
  1597. onChange: val => setLang(val),
  1598. help: (0,external_wp_i18n_namespaceObject.__)('A valid language attribute, like "en" or "fr".')
  1599. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
  1600. label: (0,external_wp_i18n_namespaceObject.__)('Text direction'),
  1601. value: dir,
  1602. options: [{
  1603. label: (0,external_wp_i18n_namespaceObject.__)('Left to right'),
  1604. value: 'ltr'
  1605. }, {
  1606. label: (0,external_wp_i18n_namespaceObject.__)('Right to left'),
  1607. value: 'rtl'
  1608. }],
  1609. onChange: val => setDir(val)
  1610. }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
  1611. alignment: "right"
  1612. }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
  1613. variant: "primary",
  1614. type: "submit",
  1615. text: (0,external_wp_i18n_namespaceObject.__)('Apply')
  1616. }))));
  1617. }
  1618. ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/default-formats.js
  1619. /**
  1620. * Internal dependencies
  1621. */
  1622. /* harmony default export */ var 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]);
  1623. ;// CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/index.js
  1624. /**
  1625. * WordPress dependencies
  1626. */
  1627. /**
  1628. * Internal dependencies
  1629. */
  1630. default_formats.forEach(({
  1631. name,
  1632. ...settings
  1633. }) => (0,external_wp_richText_namespaceObject.registerFormatType)(name, settings));
  1634. (window.wp = window.wp || {}).formatLibrary = __webpack_exports__;
  1635. /******/ })()
  1636. ;