PluginProbe
Gutenberg / 17.6.2
Gutenberg v17.6.2
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
gutenberg / build / format-library / index.js

index.js in Gutenberg 17.6.2, at build/format-library/index.js

1,840 lines 62.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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: ./packages/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: ./packages/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: ./packages/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: ./packages/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: ./packages/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: ./packages/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: ./packages/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: ./packages/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: ./packages/icons/build-module/library/link-off.js
419
420 /**
421 * WordPress dependencies
422 */
423
424 const linkOff = (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: "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"
429 }));
430 /* harmony default export */ const link_off = (linkOff);
431
432 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/link.js
433
434 /**
435 * WordPress dependencies
436 */
437
438 const link_link = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
439 xmlns: "http://www.w3.org/2000/svg",
440 viewBox: "0 0 24 24"
441 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
442 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"
443 }));
444 /* harmony default export */ const library_link = (link_link);
445
446 ;// CONCATENATED MODULE: external ["wp","a11y"]
447 const external_wp_a11y_namespaceObject = window["wp"]["a11y"];
448 ;// CONCATENATED MODULE: external ["wp","data"]
449 const external_wp_data_namespaceObject = window["wp"]["data"];
450 ;// CONCATENATED MODULE: ./packages/format-library/build-module/link/utils.js
451 /**
452 * WordPress dependencies
453 */
454
455
456 /**
457 * Check for issues with the provided href.
458 *
459 * @param {string} href The href.
460 *
461 * @return {boolean} Is the href invalid?
462 */
463 function isValidHref(href) {
464 if (!href) {
465 return false;
466 }
467 const trimmedHref = href.trim();
468 if (!trimmedHref) {
469 return false;
470 }
471
472 // Does the href start with something that looks like a URL protocol?
473 if (/^\S+:/.test(trimmedHref)) {
474 const protocol = (0,external_wp_url_namespaceObject.getProtocol)(trimmedHref);
475 if (!(0,external_wp_url_namespaceObject.isValidProtocol)(protocol)) {
476 return false;
477 }
478
479 // Add some extra checks for http(s) URIs, since these are the most common use-case.
480 // This ensures URIs with an http protocol have exactly two forward slashes following the protocol.
481 if (protocol.startsWith('http') && !/^https?:\/\/[^\/\s]/i.test(trimmedHref)) {
482 return false;
483 }
484 const authority = (0,external_wp_url_namespaceObject.getAuthority)(trimmedHref);
485 if (!(0,external_wp_url_namespaceObject.isValidAuthority)(authority)) {
486 return false;
487 }
488 const path = (0,external_wp_url_namespaceObject.getPath)(trimmedHref);
489 if (path && !(0,external_wp_url_namespaceObject.isValidPath)(path)) {
490 return false;
491 }
492 const queryString = (0,external_wp_url_namespaceObject.getQueryString)(trimmedHref);
493 if (queryString && !(0,external_wp_url_namespaceObject.isValidQueryString)(queryString)) {
494 return false;
495 }
496 const fragment = (0,external_wp_url_namespaceObject.getFragment)(trimmedHref);
497 if (fragment && !(0,external_wp_url_namespaceObject.isValidFragment)(fragment)) {
498 return false;
499 }
500 }
501
502 // Validate anchor links.
503 if (trimmedHref.startsWith('#') && !(0,external_wp_url_namespaceObject.isValidFragment)(trimmedHref)) {
504 return false;
505 }
506 return true;
507 }
508
509 /**
510 * Generates the format object that will be applied to the link text.
511 *
512 * @param {Object} options
513 * @param {string} options.url The href of the link.
514 * @param {string} options.type The type of the link.
515 * @param {string} options.id The ID of the link.
516 * @param {boolean} options.opensInNewWindow Whether this link will open in a new window.
517 * @param {boolean} options.nofollow Whether this link is marked as no follow relationship.
518 * @return {Object} The final format object.
519 */
520 function createLinkFormat({
521 url,
522 type,
523 id,
524 opensInNewWindow,
525 nofollow
526 }) {
527 const format = {
528 type: 'core/link',
529 attributes: {
530 url
531 }
532 };
533 if (type) format.attributes.type = type;
534 if (id) format.attributes.id = id;
535 if (opensInNewWindow) {
536 format.attributes.target = '_blank';
537 format.attributes.rel = format.attributes.rel ? format.attributes.rel + ' noreferrer noopener' : 'noreferrer noopener';
538 }
539 if (nofollow) {
540 format.attributes.rel = format.attributes.rel ? format.attributes.rel + ' nofollow' : 'nofollow';
541 }
542 return format;
543 }
544
545 /* eslint-disable jsdoc/no-undefined-types */
546 /**
547 * Get the start and end boundaries of a given format from a rich text value.
548 *
549 *
550 * @param {RichTextValue} value the rich text value to interrogate.
551 * @param {string} format the identifier for the target format (e.g. `core/link`, `core/bold`).
552 * @param {number?} startIndex optional startIndex to seek from.
553 * @param {number?} endIndex optional endIndex to seek from.
554 * @return {Object} object containing start and end values for the given format.
555 */
556 /* eslint-enable jsdoc/no-undefined-types */
557 function getFormatBoundary(value, format, startIndex = value.start, endIndex = value.end) {
558 const EMPTY_BOUNDARIES = {
559 start: null,
560 end: null
561 };
562 const {
563 formats
564 } = value;
565 let targetFormat;
566 let initialIndex;
567 if (!formats?.length) {
568 return EMPTY_BOUNDARIES;
569 }
570
571 // Clone formats to avoid modifying source formats.
572 const newFormats = formats.slice();
573 const formatAtStart = newFormats[startIndex]?.find(({
574 type
575 }) => type === format.type);
576 const formatAtEnd = newFormats[endIndex]?.find(({
577 type
578 }) => type === format.type);
579 const formatAtEndMinusOne = newFormats[endIndex - 1]?.find(({
580 type
581 }) => type === format.type);
582 if (!!formatAtStart) {
583 // Set values to conform to "start"
584 targetFormat = formatAtStart;
585 initialIndex = startIndex;
586 } else if (!!formatAtEnd) {
587 // Set values to conform to "end"
588 targetFormat = formatAtEnd;
589 initialIndex = endIndex;
590 } else if (!!formatAtEndMinusOne) {
591 // This is an edge case which will occur if you create a format, then place
592 // the caret just before the format and hit the back ARROW key. The resulting
593 // value object will have start and end +1 beyond the edge of the format boundary.
594 targetFormat = formatAtEndMinusOne;
595 initialIndex = endIndex - 1;
596 } else {
597 return EMPTY_BOUNDARIES;
598 }
599 const index = newFormats[initialIndex].indexOf(targetFormat);
600 const walkingArgs = [newFormats, initialIndex, targetFormat, index];
601
602 // Walk the startIndex "backwards" to the leading "edge" of the matching format.
603 startIndex = walkToStart(...walkingArgs);
604
605 // Walk the endIndex "forwards" until the trailing "edge" of the matching format.
606 endIndex = walkToEnd(...walkingArgs);
607
608 // Safe guard: start index cannot be less than 0.
609 startIndex = startIndex < 0 ? 0 : startIndex;
610
611 // // Return the indicies of the "edges" as the boundaries.
612 return {
613 start: startIndex,
614 end: endIndex
615 };
616 }
617
618 /**
619 * Walks forwards/backwards towards the boundary of a given format within an
620 * array of format objects. Returns the index of the boundary.
621 *
622 * @param {Array} formats the formats to search for the given format type.
623 * @param {number} initialIndex the starting index from which to walk.
624 * @param {Object} targetFormatRef a reference to the format type object being sought.
625 * @param {number} formatIndex the index at which we expect the target format object to be.
626 * @param {string} direction either 'forwards' or 'backwards' to indicate the direction.
627 * @return {number} the index of the boundary of the given format.
628 */
629 function walkToBoundary(formats, initialIndex, targetFormatRef, formatIndex, direction) {
630 let index = initialIndex;
631 const directions = {
632 forwards: 1,
633 backwards: -1
634 };
635 const directionIncrement = directions[direction] || 1; // invalid direction arg default to forwards
636 const inverseDirectionIncrement = directionIncrement * -1;
637 while (formats[index] && formats[index][formatIndex] === targetFormatRef) {
638 // Increment/decrement in the direction of operation.
639 index = index + directionIncrement;
640 }
641
642 // Restore by one in inverse direction of operation
643 // to avoid out of bounds.
644 index = index + inverseDirectionIncrement;
645 return index;
646 }
647 const partialRight = (fn, ...partialArgs) => (...args) => fn(...args, ...partialArgs);
648 const walkToStart = partialRight(walkToBoundary, 'backwards');
649 const walkToEnd = partialRight(walkToBoundary, 'forwards');
650
651 ;// CONCATENATED MODULE: ./packages/format-library/build-module/link/inline.js
652
653 /**
654 * WordPress dependencies
655 */
656
657
658
659
660
661
662
663
664
665 /**
666 * Internal dependencies
667 */
668
669
670 const LINK_SETTINGS = [...external_wp_blockEditor_namespaceObject.__experimentalLinkControl.DEFAULT_LINK_SETTINGS, {
671 id: 'nofollow',
672 title: (0,external_wp_i18n_namespaceObject.__)('Mark as nofollow')
673 }];
674 function InlineLinkUI({
675 isActive,
676 activeAttributes,
677 addingLink,
678 value,
679 onChange,
680 stopAddingLink,
681 contentRef
682 }) {
683 const richLinkTextValue = getRichTextValueFromSelection(value, isActive);
684
685 // Get the text content minus any HTML tags.
686 const richTextText = richLinkTextValue.text;
687 const {
688 createPageEntity,
689 userCanCreatePages
690 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
691 const {
692 getSettings
693 } = select(external_wp_blockEditor_namespaceObject.store);
694 const _settings = getSettings();
695 return {
696 createPageEntity: _settings.__experimentalCreatePageEntity,
697 userCanCreatePages: _settings.__experimentalUserCanCreatePages
698 };
699 }, []);
700 const linkValue = (0,external_wp_element_namespaceObject.useMemo)(() => ({
701 url: activeAttributes.url,
702 type: activeAttributes.type,
703 id: activeAttributes.id,
704 opensInNewTab: activeAttributes.target === '_blank',
705 nofollow: activeAttributes.rel?.includes('nofollow'),
706 title: richTextText
707 }), [activeAttributes.id, activeAttributes.rel, activeAttributes.target, activeAttributes.type, activeAttributes.url, richTextText]);
708 function removeLink() {
709 const newValue = (0,external_wp_richText_namespaceObject.removeFormat)(value, 'core/link');
710 onChange(newValue);
711 stopAddingLink();
712 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Link removed.'), 'assertive');
713 }
714 function onChangeLink(nextValue) {
715 const hasLink = linkValue?.url;
716 const isNewLink = !hasLink;
717
718 // Merge the next value with the current link value.
719 nextValue = {
720 ...linkValue,
721 ...nextValue
722 };
723 const newUrl = (0,external_wp_url_namespaceObject.prependHTTP)(nextValue.url);
724 const linkFormat = createLinkFormat({
725 url: newUrl,
726 type: nextValue.type,
727 id: nextValue.id !== undefined && nextValue.id !== null ? String(nextValue.id) : undefined,
728 opensInNewWindow: nextValue.opensInNewTab,
729 nofollow: nextValue.nofollow
730 });
731 const newText = nextValue.title || newUrl;
732 if ((0,external_wp_richText_namespaceObject.isCollapsed)(value) && !isActive) {
733 // Scenario: we don't have any actively selected text or formats.
734 const toInsert = (0,external_wp_richText_namespaceObject.applyFormat)((0,external_wp_richText_namespaceObject.create)({
735 text: newText
736 }), linkFormat, 0, newText.length);
737 onChange((0,external_wp_richText_namespaceObject.insert)(value, toInsert));
738 } else {
739 // Scenario: we have any active text selection or an active format.
740 let newValue;
741 if (newText === richTextText) {
742 // If we're not updating the text then ignore.
743 newValue = (0,external_wp_richText_namespaceObject.applyFormat)(value, linkFormat);
744 } else {
745 // Create new RichText value for the new text in order that we
746 // can apply formats to it.
747 newValue = (0,external_wp_richText_namespaceObject.create)({
748 text: newText
749 });
750
751 // Apply the new Link format to this new text value.
752 newValue = (0,external_wp_richText_namespaceObject.applyFormat)(newValue, linkFormat, 0, newText.length);
753
754 // Get the boundaries of the active link format.
755 const boundary = getFormatBoundary(value, {
756 type: 'core/link'
757 });
758
759 // Split the value at the start of the active link format.
760 // Passing "start" as the 3rd parameter is required to ensure
761 // the second half of the split value is split at the format's
762 // start boundary and avoids relying on the value's "end" property
763 // which may not correspond correctly.
764 const [valBefore, valAfter] = (0,external_wp_richText_namespaceObject.split)(value, boundary.start, boundary.start);
765
766 // Update the original (full) RichTextValue replacing the
767 // target text with the *new* RichTextValue containing:
768 // 1. The new text content.
769 // 2. The new link format.
770 // As "replace" will operate on the first match only, it is
771 // run only against the second half of the value which was
772 // split at the active format's boundary. This avoids a bug
773 // with incorrectly targetted replacements.
774 // See: https://github.com/WordPress/gutenberg/issues/41771.
775 // Note original formats will be lost when applying this change.
776 // That is expected behaviour.
777 // See: https://github.com/WordPress/gutenberg/pull/33849#issuecomment-936134179.
778 const newValAfter = (0,external_wp_richText_namespaceObject.replace)(valAfter, richTextText, newValue);
779 newValue = (0,external_wp_richText_namespaceObject.concat)(valBefore, newValAfter);
780 }
781 onChange(newValue);
782 }
783
784 // Focus should only be returned to the rich text on submit if this link is not
785 // being created for the first time. If it is then focus should remain within the
786 // Link UI because it should remain open for the user to modify the link they have
787 // just created.
788 if (!isNewLink) {
789 const returnFocusToRichText = true;
790 stopAddingLink(returnFocusToRichText);
791 }
792 if (!isValidHref(newUrl)) {
793 (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');
794 } else if (isActive) {
795 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Link edited.'), 'assertive');
796 } else {
797 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Link inserted.'), 'assertive');
798 }
799 }
800 const popoverAnchor = (0,external_wp_richText_namespaceObject.useAnchor)({
801 editableContentElement: contentRef.current,
802 settings: build_module_link_link
803 });
804
805 // As you change the link by interacting with the Link UI
806 // the return value of document.getSelection jumps to the field you're editing,
807 // not the highlighted text. Given that useAnchor uses document.getSelection,
808 // it will return null, since it can't find the <mark> element within the Link UI.
809 // This caches the last truthy value of the selection anchor reference.
810 // This ensures the Popover is positioned correctly on initial submission of the link.
811 const cachedRect = (0,external_wp_blockEditor_namespaceObject.useCachedTruthy)(popoverAnchor.getBoundingClientRect());
812 popoverAnchor.getBoundingClientRect = () => cachedRect;
813
814 // Focus should only be moved into the Popover when the Link is being created or edited.
815 // When the Link is in "preview" mode focus should remain on the rich text because at
816 // this point the Link dialog is informational only and thus the user should be able to
817 // continue editing the rich text.
818 // Ref used because the focusOnMount prop shouldn't evolve during render of a Popover
819 // otherwise it causes a render of the content.
820 const focusOnMount = (0,external_wp_element_namespaceObject.useRef)(addingLink ? 'firstElement' : false);
821 async function handleCreate(pageTitle) {
822 const page = await createPageEntity({
823 title: pageTitle,
824 status: 'draft'
825 });
826 return {
827 id: page.id,
828 type: page.type,
829 title: page.title.rendered,
830 url: page.link,
831 kind: 'post-type'
832 };
833 }
834 function createButtonText(searchTerm) {
835 return (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: search term. */
836 (0,external_wp_i18n_namespaceObject.__)('Create page: <mark>%s</mark>'), searchTerm), {
837 mark: (0,external_React_namespaceObject.createElement)("mark", null)
838 });
839 }
840 return (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
841 anchor: popoverAnchor,
842 focusOnMount: focusOnMount.current,
843 onClose: stopAddingLink,
844 onFocusOutside: () => stopAddingLink(false),
845 placement: "bottom",
846 offset: 10,
847 shift: true
848 }, (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalLinkControl, {
849 value: linkValue,
850 onChange: onChangeLink,
851 onRemove: removeLink,
852 forceIsEditingLink: addingLink,
853 hasRichPreviews: true,
854 createSuggestion: createPageEntity && handleCreate,
855 withCreateSuggestion: userCanCreatePages,
856 createSuggestionButtonText: createButtonText,
857 hasTextControl: true,
858 settings: LINK_SETTINGS,
859 showInitialSuggestions: true,
860 suggestionsQuery: {
861 // always show Pages as initial suggestions
862 initialSuggestionsSearchOptions: {
863 type: 'post',
864 subtype: 'page',
865 perPage: 20
866 }
867 }
868 }));
869 }
870 function getRichTextValueFromSelection(value, isActive) {
871 // Default to the selection ranges on the RichTextValue object.
872 let textStart = value.start;
873 let textEnd = value.end;
874
875 // If the format is currently active then the rich text value
876 // should always be taken from the bounds of the active format
877 // and not the selected text.
878 if (isActive) {
879 const boundary = getFormatBoundary(value, {
880 type: 'core/link'
881 });
882 textStart = boundary.start;
883
884 // Text *selection* always extends +1 beyond the edge of the format.
885 // We account for that here.
886 textEnd = boundary.end + 1;
887 }
888
889 // Get a RichTextValue containing the selected text content.
890 return (0,external_wp_richText_namespaceObject.slice)(value, textStart, textEnd);
891 }
892 /* harmony default export */ const inline = (InlineLinkUI);
893
894 ;// CONCATENATED MODULE: ./packages/format-library/build-module/link/index.js
895
896 /**
897 * WordPress dependencies
898 */
899
900
901
902
903
904
905
906
907
908 /**
909 * Internal dependencies
910 */
911
912
913 const link_name = 'core/link';
914 const link_title = (0,external_wp_i18n_namespaceObject.__)('Link');
915 function link_Edit({
916 isActive,
917 activeAttributes,
918 value,
919 onChange,
920 onFocus,
921 contentRef
922 }) {
923 const [addingLink, setAddingLink] = (0,external_wp_element_namespaceObject.useState)(false);
924 function addLink() {
925 const text = (0,external_wp_richText_namespaceObject.getTextContent)((0,external_wp_richText_namespaceObject.slice)(value));
926 if (text && (0,external_wp_url_namespaceObject.isURL)(text) && isValidHref(text)) {
927 onChange((0,external_wp_richText_namespaceObject.applyFormat)(value, {
928 type: link_name,
929 attributes: {
930 url: text
931 }
932 }));
933 } else if (text && (0,external_wp_url_namespaceObject.isEmail)(text)) {
934 onChange((0,external_wp_richText_namespaceObject.applyFormat)(value, {
935 type: link_name,
936 attributes: {
937 url: `mailto:${text}`
938 }
939 }));
940 } else {
941 setAddingLink(true);
942 }
943 }
944 function stopAddingLink(returnFocus = true) {
945 setAddingLink(false);
946 if (returnFocus) {
947 onFocus();
948 }
949 }
950 function onRemoveFormat() {
951 onChange((0,external_wp_richText_namespaceObject.removeFormat)(value, link_name));
952 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Link removed.'), 'assertive');
953 }
954 return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, {
955 type: "primary",
956 character: "k",
957 onUse: addLink
958 }), (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, {
959 type: "primaryShift",
960 character: "k",
961 onUse: onRemoveFormat
962 }), isActive && (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
963 name: "link",
964 icon: link_off,
965 title: (0,external_wp_i18n_namespaceObject.__)('Unlink'),
966 onClick: onRemoveFormat,
967 isActive: isActive,
968 shortcutType: "primaryShift",
969 shortcutCharacter: "k",
970 "aria-haspopup": "true",
971 "aria-expanded": addingLink || isActive
972 }), !isActive && (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
973 name: "link",
974 icon: library_link,
975 title: link_title,
976 onClick: addLink,
977 isActive: isActive,
978 shortcutType: "primary",
979 shortcutCharacter: "k",
980 "aria-haspopup": "true",
981 "aria-expanded": addingLink || isActive
982 }), (addingLink || isActive) && (0,external_React_namespaceObject.createElement)(inline, {
983 addingLink: addingLink,
984 stopAddingLink: stopAddingLink,
985 isActive: isActive,
986 activeAttributes: activeAttributes,
987 value: value,
988 onChange: onChange,
989 contentRef: contentRef
990 }));
991 }
992 const build_module_link_link = {
993 name: link_name,
994 title: link_title,
995 tagName: 'a',
996 className: null,
997 attributes: {
998 url: 'href',
999 type: 'data-type',
1000 id: 'data-id',
1001 _id: 'id',
1002 target: 'target',
1003 rel: 'rel'
1004 },
1005 __unstablePasteRule(value, {
1006 html,
1007 plainText
1008 }) {
1009 const pastedText = (html || plainText).replace(/<[^>]+>/g, '').trim();
1010
1011 // A URL was pasted, turn the selection into a link.
1012 // For the link pasting feature, allow only http(s) protocols.
1013 if (!(0,external_wp_url_namespaceObject.isURL)(pastedText) || !/^https?:/.test(pastedText)) {
1014 return value;
1015 }
1016
1017 // Allows us to ask for this information when we get a report.
1018 window.console.log('Created link:\n\n', pastedText);
1019 const format = {
1020 type: link_name,
1021 attributes: {
1022 url: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(pastedText)
1023 }
1024 };
1025 if ((0,external_wp_richText_namespaceObject.isCollapsed)(value)) {
1026 return (0,external_wp_richText_namespaceObject.insert)(value, (0,external_wp_richText_namespaceObject.applyFormat)((0,external_wp_richText_namespaceObject.create)({
1027 text: plainText
1028 }), format, 0, plainText.length));
1029 }
1030 return (0,external_wp_richText_namespaceObject.applyFormat)(value, format);
1031 },
1032 edit: link_Edit
1033 };
1034
1035 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/format-strikethrough.js
1036
1037 /**
1038 * WordPress dependencies
1039 */
1040
1041 const formatStrikethrough = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1042 xmlns: "http://www.w3.org/2000/svg",
1043 viewBox: "0 0 24 24"
1044 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1045 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"
1046 }));
1047 /* harmony default export */ const format_strikethrough = (formatStrikethrough);
1048
1049 ;// CONCATENATED MODULE: ./packages/format-library/build-module/strikethrough/index.js
1050
1051 /**
1052 * WordPress dependencies
1053 */
1054
1055
1056
1057
1058 const strikethrough_name = 'core/strikethrough';
1059 const strikethrough_title = (0,external_wp_i18n_namespaceObject.__)('Strikethrough');
1060 const strikethrough = {
1061 name: strikethrough_name,
1062 title: strikethrough_title,
1063 tagName: 's',
1064 className: null,
1065 edit({
1066 isActive,
1067 value,
1068 onChange,
1069 onFocus
1070 }) {
1071 function onClick() {
1072 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, {
1073 type: strikethrough_name,
1074 title: strikethrough_title
1075 }));
1076 onFocus();
1077 }
1078 return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, {
1079 type: "access",
1080 character: "d",
1081 onUse: onClick
1082 }), (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
1083 icon: format_strikethrough,
1084 title: strikethrough_title,
1085 onClick: onClick,
1086 isActive: isActive,
1087 role: "menuitemcheckbox"
1088 }));
1089 }
1090 };
1091
1092 ;// CONCATENATED MODULE: ./packages/format-library/build-module/underline/index.js
1093
1094 /**
1095 * WordPress dependencies
1096 */
1097
1098
1099
1100 const underline_name = 'core/underline';
1101 const underline_title = (0,external_wp_i18n_namespaceObject.__)('Underline');
1102 const underline = {
1103 name: underline_name,
1104 title: underline_title,
1105 tagName: 'span',
1106 className: null,
1107 attributes: {
1108 style: 'style'
1109 },
1110 edit({
1111 value,
1112 onChange
1113 }) {
1114 const onToggle = () => {
1115 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, {
1116 type: underline_name,
1117 attributes: {
1118 style: 'text-decoration: underline;'
1119 },
1120 title: underline_title
1121 }));
1122 };
1123 return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextShortcut, {
1124 type: "primary",
1125 character: "u",
1126 onUse: onToggle
1127 }), (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent, {
1128 inputType: "formatUnderline",
1129 onInput: onToggle
1130 }));
1131 }
1132 };
1133
1134 ;// CONCATENATED MODULE: ./packages/icons/build-module/icon/index.js
1135 /**
1136 * WordPress dependencies
1137 */
1138
1139
1140 /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */
1141
1142 /**
1143 * Return an SVG icon.
1144 *
1145 * @param {IconProps} props icon is the SVG component to render
1146 * size is a number specifiying the icon size in pixels
1147 * Other props will be passed to wrapped SVG component
1148 * @param {import('react').ForwardedRef<HTMLElement>} ref The forwarded ref to the SVG element.
1149 *
1150 * @return {JSX.Element} Icon component
1151 */
1152 function Icon({
1153 icon,
1154 size = 24,
1155 ...props
1156 }, ref) {
1157 return (0,external_wp_element_namespaceObject.cloneElement)(icon, {
1158 width: size,
1159 height: size,
1160 ...props,
1161 ref
1162 });
1163 }
1164 /* harmony default export */ const icon = ((0,external_wp_element_namespaceObject.forwardRef)(Icon));
1165
1166 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/text-color.js
1167
1168 /**
1169 * WordPress dependencies
1170 */
1171
1172 const textColor = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1173 xmlns: "http://www.w3.org/2000/svg",
1174 viewBox: "0 0 24 24"
1175 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1176 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"
1177 }));
1178 /* harmony default export */ const text_color = (textColor);
1179
1180 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/color.js
1181
1182 /**
1183 * WordPress dependencies
1184 */
1185
1186 const color = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1187 viewBox: "0 0 24 24",
1188 xmlns: "http://www.w3.org/2000/svg"
1189 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1190 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"
1191 }));
1192 /* harmony default export */ const library_color = (color);
1193
1194 ;// CONCATENATED MODULE: external ["wp","privateApis"]
1195 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
1196 ;// CONCATENATED MODULE: ./packages/format-library/build-module/lock-unlock.js
1197 /**
1198 * WordPress dependencies
1199 */
1200
1201 const {
1202 lock,
1203 unlock
1204 } = (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');
1205
1206 ;// CONCATENATED MODULE: ./packages/format-library/build-module/text-color/inline.js
1207
1208 /**
1209 * WordPress dependencies
1210 */
1211
1212
1213
1214
1215
1216
1217
1218 /**
1219 * Internal dependencies
1220 */
1221
1222
1223 const {
1224 Tabs
1225 } = unlock(external_wp_components_namespaceObject.privateApis);
1226 const TABS = [{
1227 name: 'color',
1228 title: (0,external_wp_i18n_namespaceObject.__)('Text')
1229 }, {
1230 name: 'backgroundColor',
1231 title: (0,external_wp_i18n_namespaceObject.__)('Background')
1232 }];
1233 function parseCSS(css = '') {
1234 return css.split(';').reduce((accumulator, rule) => {
1235 if (rule) {
1236 const [property, value] = rule.split(':');
1237 if (property === 'color') accumulator.color = value;
1238 if (property === 'background-color' && value !== transparentValue) accumulator.backgroundColor = value;
1239 }
1240 return accumulator;
1241 }, {});
1242 }
1243 function parseClassName(className = '', colorSettings) {
1244 return className.split(' ').reduce((accumulator, name) => {
1245 // `colorSlug` could contain dashes, so simply match the start and end.
1246 if (name.startsWith('has-') && name.endsWith('-color')) {
1247 const colorSlug = name.replace(/^has-/, '').replace(/-color$/, '');
1248 const colorObject = (0,external_wp_blockEditor_namespaceObject.getColorObjectByAttributeValues)(colorSettings, colorSlug);
1249 accumulator.color = colorObject.color;
1250 }
1251 return accumulator;
1252 }, {});
1253 }
1254 function getActiveColors(value, name, colorSettings) {
1255 const activeColorFormat = (0,external_wp_richText_namespaceObject.getActiveFormat)(value, name);
1256 if (!activeColorFormat) {
1257 return {};
1258 }
1259 return {
1260 ...parseCSS(activeColorFormat.attributes.style),
1261 ...parseClassName(activeColorFormat.attributes.class, colorSettings)
1262 };
1263 }
1264 function setColors(value, name, colorSettings, colors) {
1265 const {
1266 color,
1267 backgroundColor
1268 } = {
1269 ...getActiveColors(value, name, colorSettings),
1270 ...colors
1271 };
1272 if (!color && !backgroundColor) {
1273 return (0,external_wp_richText_namespaceObject.removeFormat)(value, name);
1274 }
1275 const styles = [];
1276 const classNames = [];
1277 const attributes = {};
1278 if (backgroundColor) {
1279 styles.push(['background-color', backgroundColor].join(':'));
1280 } else {
1281 // Override default browser color for mark element.
1282 styles.push(['background-color', transparentValue].join(':'));
1283 }
1284 if (color) {
1285 const colorObject = (0,external_wp_blockEditor_namespaceObject.getColorObjectByColorValue)(colorSettings, color);
1286 if (colorObject) {
1287 classNames.push((0,external_wp_blockEditor_namespaceObject.getColorClassName)('color', colorObject.slug));
1288 } else {
1289 styles.push(['color', color].join(':'));
1290 }
1291 }
1292 if (styles.length) attributes.style = styles.join(';');
1293 if (classNames.length) attributes.class = classNames.join(' ');
1294 return (0,external_wp_richText_namespaceObject.applyFormat)(value, {
1295 type: name,
1296 attributes
1297 });
1298 }
1299 function ColorPicker({
1300 name,
1301 property,
1302 value,
1303 onChange
1304 }) {
1305 const colors = (0,external_wp_data_namespaceObject.useSelect)(select => {
1306 var _getSettings$colors;
1307 const {
1308 getSettings
1309 } = select(external_wp_blockEditor_namespaceObject.store);
1310 return (_getSettings$colors = getSettings().colors) !== null && _getSettings$colors !== void 0 ? _getSettings$colors : [];
1311 }, []);
1312 const onColorChange = (0,external_wp_element_namespaceObject.useCallback)(color => {
1313 onChange(setColors(value, name, colors, {
1314 [property]: color
1315 }));
1316 }, [colors, onChange, property]);
1317 const activeColors = (0,external_wp_element_namespaceObject.useMemo)(() => getActiveColors(value, name, colors), [name, value, colors]);
1318 return (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.ColorPalette, {
1319 value: activeColors[property],
1320 onChange: onColorChange
1321 });
1322 }
1323 function InlineColorUI({
1324 name,
1325 value,
1326 onChange,
1327 onClose,
1328 contentRef
1329 }) {
1330 const popoverAnchor = (0,external_wp_richText_namespaceObject.useAnchor)({
1331 editableContentElement: contentRef.current,
1332 settings: text_color_textColor
1333 });
1334
1335 /*
1336 As you change the text color by typing a HEX value into a field,
1337 the return value of document.getSelection jumps to the field you're editing,
1338 not the highlighted text. Given that useAnchor uses document.getSelection,
1339 it will return null, since it can't find the <mark> element within the HEX input.
1340 This caches the last truthy value of the selection anchor reference.
1341 */
1342 const cachedRect = (0,external_wp_blockEditor_namespaceObject.useCachedTruthy)(popoverAnchor.getBoundingClientRect());
1343 popoverAnchor.getBoundingClientRect = () => cachedRect;
1344 return (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
1345 onClose: onClose,
1346 className: "format-library__inline-color-popover",
1347 anchor: popoverAnchor
1348 }, (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, {
1349 tabId: tab.name,
1350 key: tab.name
1351 }, tab.title))), TABS.map(tab => (0,external_React_namespaceObject.createElement)(Tabs.TabPanel, {
1352 tabId: tab.name,
1353 focusable: false,
1354 key: tab.name
1355 }, (0,external_React_namespaceObject.createElement)(ColorPicker, {
1356 name: name,
1357 property: tab.name,
1358 value: value,
1359 onChange: onChange
1360 })))));
1361 }
1362
1363 ;// CONCATENATED MODULE: ./packages/format-library/build-module/text-color/index.js
1364
1365 /**
1366 * WordPress dependencies
1367 */
1368
1369
1370
1371
1372
1373
1374 /**
1375 * Internal dependencies
1376 */
1377
1378 const transparentValue = 'rgba(0, 0, 0, 0)';
1379 const text_color_name = 'core/text-color';
1380 const text_color_title = (0,external_wp_i18n_namespaceObject.__)('Highlight');
1381 const EMPTY_ARRAY = [];
1382 function getComputedStyleProperty(element, property) {
1383 const {
1384 ownerDocument
1385 } = element;
1386 const {
1387 defaultView
1388 } = ownerDocument;
1389 const style = defaultView.getComputedStyle(element);
1390 const value = style.getPropertyValue(property);
1391 if (property === 'background-color' && value === transparentValue && element.parentElement) {
1392 return getComputedStyleProperty(element.parentElement, property);
1393 }
1394 return value;
1395 }
1396 function fillComputedColors(element, {
1397 color,
1398 backgroundColor
1399 }) {
1400 if (!color && !backgroundColor) {
1401 return;
1402 }
1403 return {
1404 color: color || getComputedStyleProperty(element, 'color'),
1405 backgroundColor: backgroundColor === transparentValue ? getComputedStyleProperty(element, 'background-color') : backgroundColor
1406 };
1407 }
1408 function TextColorEdit({
1409 value,
1410 onChange,
1411 isActive,
1412 activeAttributes,
1413 contentRef
1414 }) {
1415 const [allowCustomControl, colors = EMPTY_ARRAY] = (0,external_wp_blockEditor_namespaceObject.useSettings)('color.custom', 'color.palette');
1416 const [isAddingColor, setIsAddingColor] = (0,external_wp_element_namespaceObject.useState)(false);
1417 const enableIsAddingColor = (0,external_wp_element_namespaceObject.useCallback)(() => setIsAddingColor(true), [setIsAddingColor]);
1418 const disableIsAddingColor = (0,external_wp_element_namespaceObject.useCallback)(() => setIsAddingColor(false), [setIsAddingColor]);
1419 const colorIndicatorStyle = (0,external_wp_element_namespaceObject.useMemo)(() => fillComputedColors(contentRef.current, getActiveColors(value, text_color_name, colors)), [value, colors]);
1420 const hasColorsToChoose = colors.length || !allowCustomControl;
1421 if (!hasColorsToChoose && !isActive) {
1422 return null;
1423 }
1424 return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
1425 className: "format-library-text-color-button",
1426 isActive: isActive,
1427 icon: (0,external_React_namespaceObject.createElement)(icon, {
1428 icon: Object.keys(activeAttributes).length ? text_color : library_color,
1429 style: colorIndicatorStyle
1430 }),
1431 title: text_color_title
1432 // If has no colors to choose but a color is active remove the color onClick.
1433 ,
1434 onClick: hasColorsToChoose ? enableIsAddingColor : () => onChange((0,external_wp_richText_namespaceObject.removeFormat)(value, text_color_name)),
1435 role: "menuitemcheckbox"
1436 }), isAddingColor && (0,external_React_namespaceObject.createElement)(InlineColorUI, {
1437 name: text_color_name,
1438 onClose: disableIsAddingColor,
1439 activeAttributes: activeAttributes,
1440 value: value,
1441 onChange: onChange,
1442 contentRef: contentRef
1443 }));
1444 }
1445 const text_color_textColor = {
1446 name: text_color_name,
1447 title: text_color_title,
1448 tagName: 'mark',
1449 className: 'has-inline-color',
1450 attributes: {
1451 style: 'style',
1452 class: 'class'
1453 },
1454 edit: TextColorEdit
1455 };
1456
1457 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/subscript.js
1458
1459 /**
1460 * WordPress dependencies
1461 */
1462
1463 const subscript = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1464 xmlns: "http://www.w3.org/2000/svg",
1465 viewBox: "0 0 24 24"
1466 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1467 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"
1468 }));
1469 /* harmony default export */ const library_subscript = (subscript);
1470
1471 ;// CONCATENATED MODULE: ./packages/format-library/build-module/subscript/index.js
1472
1473 /**
1474 * WordPress dependencies
1475 */
1476
1477
1478
1479
1480 const subscript_name = 'core/subscript';
1481 const subscript_title = (0,external_wp_i18n_namespaceObject.__)('Subscript');
1482 const subscript_subscript = {
1483 name: subscript_name,
1484 title: subscript_title,
1485 tagName: 'sub',
1486 className: null,
1487 edit({
1488 isActive,
1489 value,
1490 onChange,
1491 onFocus
1492 }) {
1493 function onToggle() {
1494 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, {
1495 type: subscript_name,
1496 title: subscript_title
1497 }));
1498 }
1499 function onClick() {
1500 onToggle();
1501 onFocus();
1502 }
1503 return (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
1504 icon: library_subscript,
1505 title: subscript_title,
1506 onClick: onClick,
1507 isActive: isActive,
1508 role: "menuitemcheckbox"
1509 });
1510 }
1511 };
1512
1513 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/superscript.js
1514
1515 /**
1516 * WordPress dependencies
1517 */
1518
1519 const superscript = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1520 xmlns: "http://www.w3.org/2000/svg",
1521 viewBox: "0 0 24 24"
1522 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1523 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"
1524 }));
1525 /* harmony default export */ const library_superscript = (superscript);
1526
1527 ;// CONCATENATED MODULE: ./packages/format-library/build-module/superscript/index.js
1528
1529 /**
1530 * WordPress dependencies
1531 */
1532
1533
1534
1535
1536 const superscript_name = 'core/superscript';
1537 const superscript_title = (0,external_wp_i18n_namespaceObject.__)('Superscript');
1538 const superscript_superscript = {
1539 name: superscript_name,
1540 title: superscript_title,
1541 tagName: 'sup',
1542 className: null,
1543 edit({
1544 isActive,
1545 value,
1546 onChange,
1547 onFocus
1548 }) {
1549 function onToggle() {
1550 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, {
1551 type: superscript_name,
1552 title: superscript_title
1553 }));
1554 }
1555 function onClick() {
1556 onToggle();
1557 onFocus();
1558 }
1559 return (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
1560 icon: library_superscript,
1561 title: superscript_title,
1562 onClick: onClick,
1563 isActive: isActive,
1564 role: "menuitemcheckbox"
1565 });
1566 }
1567 };
1568
1569 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/button.js
1570
1571 /**
1572 * WordPress dependencies
1573 */
1574
1575 const button_button = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1576 viewBox: "0 0 24 24",
1577 xmlns: "http://www.w3.org/2000/svg"
1578 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1579 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"
1580 }));
1581 /* harmony default export */ const library_button = (button_button);
1582
1583 ;// CONCATENATED MODULE: ./packages/format-library/build-module/keyboard/index.js
1584
1585 /**
1586 * WordPress dependencies
1587 */
1588
1589
1590
1591
1592 const keyboard_name = 'core/keyboard';
1593 const keyboard_title = (0,external_wp_i18n_namespaceObject.__)('Keyboard input');
1594 const keyboard = {
1595 name: keyboard_name,
1596 title: keyboard_title,
1597 tagName: 'kbd',
1598 className: null,
1599 edit({
1600 isActive,
1601 value,
1602 onChange,
1603 onFocus
1604 }) {
1605 function onToggle() {
1606 onChange((0,external_wp_richText_namespaceObject.toggleFormat)(value, {
1607 type: keyboard_name,
1608 title: keyboard_title
1609 }));
1610 }
1611 function onClick() {
1612 onToggle();
1613 onFocus();
1614 }
1615 return (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
1616 icon: library_button,
1617 title: keyboard_title,
1618 onClick: onClick,
1619 isActive: isActive,
1620 role: "menuitemcheckbox"
1621 });
1622 }
1623 };
1624
1625 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/help.js
1626
1627 /**
1628 * WordPress dependencies
1629 */
1630
1631 const help = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1632 xmlns: "http://www.w3.org/2000/svg",
1633 viewBox: "0 0 24 24"
1634 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1635 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"
1636 }));
1637 /* harmony default export */ const library_help = (help);
1638
1639 ;// CONCATENATED MODULE: ./packages/format-library/build-module/unknown/index.js
1640
1641 /**
1642 * WordPress dependencies
1643 */
1644
1645
1646
1647
1648 const unknown_name = 'core/unknown';
1649 const unknown_title = (0,external_wp_i18n_namespaceObject.__)('Clear Unknown Formatting');
1650 const unknown = {
1651 name: unknown_name,
1652 title: unknown_title,
1653 tagName: '*',
1654 className: null,
1655 edit({
1656 isActive,
1657 value,
1658 onChange,
1659 onFocus
1660 }) {
1661 function onClick() {
1662 onChange((0,external_wp_richText_namespaceObject.removeFormat)(value, unknown_name));
1663 onFocus();
1664 }
1665 const selectedValue = (0,external_wp_richText_namespaceObject.slice)(value);
1666 const hasUnknownFormats = selectedValue.formats.some(formats => {
1667 return formats.some(format => format.type === unknown_name);
1668 });
1669 if (!isActive && !hasUnknownFormats) {
1670 return null;
1671 }
1672 return (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
1673 name: "unknown",
1674 icon: library_help,
1675 title: unknown_title,
1676 onClick: onClick,
1677 isActive: true
1678 });
1679 }
1680 };
1681
1682 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/language.js
1683
1684 /**
1685 * WordPress dependencies
1686 */
1687
1688 const language = (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1689 xmlns: "http://www.w3.org/2000/svg",
1690 viewBox: "0 0 24 24"
1691 }, (0,external_React_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1692 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"
1693 }));
1694 /* harmony default export */ const library_language = (language);
1695
1696 ;// CONCATENATED MODULE: ./packages/format-library/build-module/language/index.js
1697
1698 /**
1699 * WordPress dependencies
1700 */
1701
1702
1703 /**
1704 * WordPress dependencies
1705 */
1706
1707
1708
1709
1710
1711 const language_name = 'core/language';
1712 const language_title = (0,external_wp_i18n_namespaceObject.__)('Language');
1713 const language_language = {
1714 name: language_name,
1715 tagName: 'bdo',
1716 className: null,
1717 edit: language_Edit,
1718 title: language_title
1719 };
1720 function language_Edit({
1721 isActive,
1722 value,
1723 onChange,
1724 contentRef
1725 }) {
1726 const [isPopoverVisible, setIsPopoverVisible] = (0,external_wp_element_namespaceObject.useState)(false);
1727 const togglePopover = () => {
1728 setIsPopoverVisible(state => !state);
1729 };
1730 return (0,external_React_namespaceObject.createElement)(external_React_namespaceObject.Fragment, null, (0,external_React_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.RichTextToolbarButton, {
1731 icon: library_language,
1732 label: language_title,
1733 title: language_title,
1734 onClick: () => {
1735 if (isActive) {
1736 onChange((0,external_wp_richText_namespaceObject.removeFormat)(value, language_name));
1737 } else {
1738 togglePopover();
1739 }
1740 },
1741 isActive: isActive,
1742 role: "menuitemcheckbox"
1743 }), isPopoverVisible && (0,external_React_namespaceObject.createElement)(InlineLanguageUI, {
1744 value: value,
1745 onChange: onChange,
1746 onClose: togglePopover,
1747 contentRef: contentRef
1748 }));
1749 }
1750 function InlineLanguageUI({
1751 value,
1752 contentRef,
1753 onChange,
1754 onClose
1755 }) {
1756 const popoverAnchor = (0,external_wp_richText_namespaceObject.useAnchor)({
1757 editableContentElement: contentRef.current,
1758 settings: language_language
1759 });
1760 const [lang, setLang] = (0,external_wp_element_namespaceObject.useState)('');
1761 const [dir, setDir] = (0,external_wp_element_namespaceObject.useState)('ltr');
1762 return (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.Popover, {
1763 className: "block-editor-format-toolbar__language-popover",
1764 anchor: popoverAnchor,
1765 onClose: onClose
1766 }, (0,external_React_namespaceObject.createElement)("form", {
1767 className: "block-editor-format-toolbar__language-container-content",
1768 onSubmit: event => {
1769 event.preventDefault();
1770 onChange((0,external_wp_richText_namespaceObject.applyFormat)(value, {
1771 type: language_name,
1772 attributes: {
1773 lang,
1774 dir
1775 }
1776 }));
1777 onClose();
1778 }
1779 }, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
1780 label: language_title,
1781 value: lang,
1782 onChange: val => setLang(val),
1783 help: (0,external_wp_i18n_namespaceObject.__)('A valid language attribute, like "en" or "fr".')
1784 }), (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
1785 label: (0,external_wp_i18n_namespaceObject.__)('Text direction'),
1786 value: dir,
1787 options: [{
1788 label: (0,external_wp_i18n_namespaceObject.__)('Left to right'),
1789 value: 'ltr'
1790 }, {
1791 label: (0,external_wp_i18n_namespaceObject.__)('Right to left'),
1792 value: 'rtl'
1793 }],
1794 onChange: val => setDir(val)
1795 }), (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalHStack, {
1796 alignment: "right"
1797 }, (0,external_React_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
1798 variant: "primary",
1799 type: "submit",
1800 text: (0,external_wp_i18n_namespaceObject.__)('Apply')
1801 }))));
1802 }
1803
1804 ;// CONCATENATED MODULE: ./packages/format-library/build-module/default-formats.js
1805 /**
1806 * Internal dependencies
1807 */
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821 /* 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]);
1822
1823 ;// CONCATENATED MODULE: ./packages/format-library/build-module/index.js
1824 /**
1825 * WordPress dependencies
1826 */
1827
1828
1829 /**
1830 * Internal dependencies
1831 */
1832
1833 default_formats.forEach(({
1834 name,
1835 ...settings
1836 }) => (0,external_wp_richText_namespaceObject.registerFormatType)(name, settings));
1837
1838 (window.wp = window.wp || {}).formatLibrary = __webpack_exports__;
1839 /******/ })()
1840 ;