PluginProbe
Gutenberg / 14.5.2
Gutenberg v14.5.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
← All changes | build/dom/index.js +263 -172 12.6.0 → 14.5.2 View file →
@@ -1,14 +1,26 @@
1 -/******/ (function() { // webpackBootstrap
1 +/******/ (() => { // webpackBootstrap
2 2 /******/ "use strict";
3 3 /******/ // The require scope
4 4 /******/ var __webpack_require__ = {};
5 5 /******/
6 6 /************************************************************************/
7 +/******/ /* webpack/runtime/compat get default export */
8 +/******/ (() => {
9 +/******/ // getDefaultExport function for compatibility with non-harmony modules
10 +/******/ __webpack_require__.n = (module) => {
11 +/******/ var getter = module && module.__esModule ?
12 +/******/ () => (module['default']) :
13 +/******/ () => (module);
14 +/******/ __webpack_require__.d(getter, { a: getter });
15 +/******/ return getter;
16 +/******/ };
17 +/******/ })();
18 +/******/
7 19 /******/ /* webpack/runtime/define property getters */
8 -/******/ !function() {
20 +/******/ (() => {
9 21 /******/ // define getter functions for harmony exports
10 -/******/ __webpack_require__.d = function(exports, definition) {
22 +/******/ __webpack_require__.d = (exports, definition) => {
11 23 /******/ for(var key in definition) {
12 24 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
13 25 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
14 26 /******/ }
@@ -13,25 +25,25 @@
13 25 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
14 26 /******/ }
15 27 /******/ }
16 28 /******/ };
17 -/******/ }();
29 +/******/ })();
18 30 /******/
19 31 /******/ /* webpack/runtime/hasOwnProperty shorthand */
20 -/******/ !function() {
21 -/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
22 -/******/ }();
32 +/******/ (() => {
33 +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
34 +/******/ })();
23 35 /******/
24 36 /******/ /* webpack/runtime/make namespace object */
25 -/******/ !function() {
37 +/******/ (() => {
26 38 /******/ // define __esModule on exports
27 -/******/ __webpack_require__.r = function(exports) {
39 +/******/ __webpack_require__.r = (exports) => {
28 40 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
29 41 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
30 42 /******/ }
31 43 /******/ Object.defineProperty(exports, '__esModule', { value: true });
32 44 /******/ };
33 -/******/ }();
45 +/******/ })();
34 46 /******/
35 47 /************************************************************************/
36 48 var __webpack_exports__ = {};
37 49 // ESM COMPAT FLAG
@@ -38,38 +50,39 @@
38 50 __webpack_require__.r(__webpack_exports__);
39 51
40 52 // EXPORTS
41 53 __webpack_require__.d(__webpack_exports__, {
42 - "__unstableStripHTML": function() { return /* reexport */ stripHTML; },
43 - "computeCaretRect": function() { return /* reexport */ computeCaretRect; },
44 - "documentHasSelection": function() { return /* reexport */ documentHasSelection; },
45 - "documentHasTextSelection": function() { return /* reexport */ documentHasTextSelection; },
46 - "documentHasUncollapsedSelection": function() { return /* reexport */ documentHasUncollapsedSelection; },
47 - "focus": function() { return /* binding */ build_module_focus; },
48 - "getFilesFromDataTransfer": function() { return /* reexport */ getFilesFromDataTransfer; },
49 - "getOffsetParent": function() { return /* reexport */ getOffsetParent; },
50 - "getPhrasingContentSchema": function() { return /* reexport */ getPhrasingContentSchema; },
51 - "getRectangleFromRange": function() { return /* reexport */ getRectangleFromRange; },
52 - "getScrollContainer": function() { return /* reexport */ getScrollContainer; },
53 - "insertAfter": function() { return /* reexport */ insertAfter; },
54 - "isEmpty": function() { return /* reexport */ isEmpty; },
55 - "isEntirelySelected": function() { return /* reexport */ isEntirelySelected; },
56 - "isHorizontalEdge": function() { return /* reexport */ isHorizontalEdge; },
57 - "isNumberInput": function() { return /* reexport */ isNumberInput; },
58 - "isPhrasingContent": function() { return /* reexport */ isPhrasingContent; },
59 - "isRTL": function() { return /* reexport */ isRTL; },
60 - "isTextContent": function() { return /* reexport */ isTextContent; },
61 - "isTextField": function() { return /* reexport */ isTextField; },
62 - "isVerticalEdge": function() { return /* reexport */ isVerticalEdge; },
63 - "placeCaretAtHorizontalEdge": function() { return /* reexport */ placeCaretAtHorizontalEdge; },
64 - "placeCaretAtVerticalEdge": function() { return /* reexport */ placeCaretAtVerticalEdge; },
65 - "remove": function() { return /* reexport */ remove; },
66 - "removeInvalidHTML": function() { return /* reexport */ removeInvalidHTML; },
67 - "replace": function() { return /* reexport */ replace; },
68 - "replaceTag": function() { return /* reexport */ replaceTag; },
69 - "safeHTML": function() { return /* reexport */ safeHTML; },
70 - "unwrap": function() { return /* reexport */ unwrap; },
71 - "wrap": function() { return /* reexport */ wrap; }
54 + "__unstableStripHTML": () => (/* reexport */ stripHTML),
55 + "computeCaretRect": () => (/* reexport */ computeCaretRect),
56 + "documentHasSelection": () => (/* reexport */ documentHasSelection),
57 + "documentHasTextSelection": () => (/* reexport */ documentHasTextSelection),
58 + "documentHasUncollapsedSelection": () => (/* reexport */ documentHasUncollapsedSelection),
59 + "focus": () => (/* binding */ build_module_focus),
60 + "getFilesFromDataTransfer": () => (/* reexport */ getFilesFromDataTransfer),
61 + "getOffsetParent": () => (/* reexport */ getOffsetParent),
62 + "getPhrasingContentSchema": () => (/* reexport */ getPhrasingContentSchema),
63 + "getRectangleFromRange": () => (/* reexport */ getRectangleFromRange),
64 + "getScrollContainer": () => (/* reexport */ getScrollContainer),
65 + "insertAfter": () => (/* reexport */ insertAfter),
66 + "isEmpty": () => (/* reexport */ isEmpty),
67 + "isEntirelySelected": () => (/* reexport */ isEntirelySelected),
68 + "isFormElement": () => (/* reexport */ isFormElement),
69 + "isHorizontalEdge": () => (/* reexport */ isHorizontalEdge),
70 + "isNumberInput": () => (/* reexport */ isNumberInput),
71 + "isPhrasingContent": () => (/* reexport */ isPhrasingContent),
72 + "isRTL": () => (/* reexport */ isRTL),
73 + "isTextContent": () => (/* reexport */ isTextContent),
74 + "isTextField": () => (/* reexport */ isTextField),
75 + "isVerticalEdge": () => (/* reexport */ isVerticalEdge),
76 + "placeCaretAtHorizontalEdge": () => (/* reexport */ placeCaretAtHorizontalEdge),
77 + "placeCaretAtVerticalEdge": () => (/* reexport */ placeCaretAtVerticalEdge),
78 + "remove": () => (/* reexport */ remove),
79 + "removeInvalidHTML": () => (/* reexport */ removeInvalidHTML),
80 + "replace": () => (/* reexport */ replace),
81 + "replaceTag": () => (/* reexport */ replaceTag),
82 + "safeHTML": () => (/* reexport */ safeHTML),
83 + "unwrap": () => (/* reexport */ unwrap),
84 + "wrap": () => (/* reexport */ wrap)
72 85 });
73 86
74 87 // NAMESPACE OBJECT: ./packages/dom/build-module/focusable.js
75 88 var focusable_namespaceObject = {};
@@ -74,9 +87,9 @@
74 87 // NAMESPACE OBJECT: ./packages/dom/build-module/focusable.js
75 88 var focusable_namespaceObject = {};
76 89 __webpack_require__.r(focusable_namespaceObject);
77 90 __webpack_require__.d(focusable_namespaceObject, {
78 - "find": function() { return find; }
91 + "find": () => (find)
79 92 });
80 93
81 94 // NAMESPACE OBJECT: ./packages/dom/build-module/tabbable.js
82 95 var tabbable_namespaceObject = {};
@@ -81,12 +94,12 @@
81 94 // NAMESPACE OBJECT: ./packages/dom/build-module/tabbable.js
82 95 var tabbable_namespaceObject = {};
83 96 __webpack_require__.r(tabbable_namespaceObject);
84 97 __webpack_require__.d(tabbable_namespaceObject, {
85 - "find": function() { return tabbable_find; },
86 - "findNext": function() { return findNext; },
87 - "findPrevious": function() { return findPrevious; },
88 - "isTabbableIndex": function() { return isTabbableIndex; }
98 + "find": () => (tabbable_find),
99 + "findNext": () => (findNext),
100 + "findPrevious": () => (findPrevious),
101 + "isTabbableIndex": () => (isTabbableIndex)
89 102 });
90 103
91 104 ;// CONCATENATED MODULE: ./packages/dom/build-module/focusable.js
92 105 /**
@@ -203,21 +216,14 @@
203 216
204 217 return true;
205 218 });
206 219 }
207 -//# sourceMappingURL=focusable.js.map
208 -;// CONCATENATED MODULE: external "lodash"
209 -var external_lodash_namespaceObject = window["lodash"];
220 +
210 221 ;// CONCATENATED MODULE: ./packages/dom/build-module/tabbable.js
211 222 /**
212 - * External dependencies
213 - */
214 -
215 -/**
216 223 * Internal dependencies
217 224 */
218 225
219 -
220 226 /**
221 227 * Returns the tab index of the given element. In contrast with the tabIndex
222 228 * property, this normalizes the default (0) to avoid browser inconsistencies,
223 229 * operating under the assumption that this function is only ever called with a
@@ -288,9 +294,9 @@
288 294
289 295
290 296 if (hasChosen) {
291 297 const hadChosenElement = CHOSEN_RADIO_BY_NAME[name];
292 - result = (0,external_lodash_namespaceObject.without)(result, hadChosenElement);
298 + result = result.filter(e => e !== hadChosenElement);
293 299 }
294 300
295 301 CHOSEN_RADIO_BY_NAME[name] = element;
296 302 return result.concat(element);
@@ -375,16 +381,24 @@
375 381 * Given a focusable element, find the preceding tabbable element.
376 382 *
377 383 * @param {Element} element The focusable element before which to look. Defaults
378 384 * to the active element.
385 + *
386 + * @return {Element|undefined} Preceding tabbable element.
379 387 */
380 388
381 389 function findPrevious(element) {
382 390 const focusables = find(element.ownerDocument.body);
383 - const index = focusables.indexOf(element); // Remove all focusables after and including `element`.
391 + const index = focusables.indexOf(element);
384 392
393 + if (index === -1) {
394 + return undefined;
395 + } // Remove all focusables after and including `element`.
396 +
397 +
385 398 focusables.length = index;
386 - return (0,external_lodash_namespaceObject.last)(filterTabbable(focusables));
399 + const tabbable = filterTabbable(focusables);
400 + return tabbable[tabbable.length - 1];
387 401 }
388 402 /**
389 403 * Given a focusable element, find the next tabbable element.
390 404 *
@@ -389,8 +403,10 @@
389 403 * Given a focusable element, find the next tabbable element.
390 404 *
391 405 * @param {Element} element The focusable element after which to look. Defaults
392 406 * to the active element.
407 + *
408 + * @return {Element|undefined} Next tabbable element.
393 409 */
394 410
395 411 function findNext(element) {
396 412 const focusables = find(element.ownerDocument.body);
@@ -396,16 +412,16 @@
396 412 const focusables = find(element.ownerDocument.body);
397 413 const index = focusables.indexOf(element); // Remove all focusables before and including `element`.
398 414
399 415 const remaining = focusables.slice(index + 1);
400 - return (0,external_lodash_namespaceObject.first)(filterTabbable(remaining));
416 + return filterTabbable(remaining)[0];
401 417 }
402 -//# sourceMappingURL=tabbable.js.map
418 +
403 419 ;// CONCATENATED MODULE: ./packages/dom/build-module/utils/assert-is-defined.js
404 420 function assertIsDefined(val, name) {
405 421 if (false) {}
406 422 }
407 -//# sourceMappingURL=assert-is-defined.js.map
423 +
408 424 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/get-rectangle-from-range.js
409 425 /**
410 426 * Internal dependencies
411 427 */
@@ -410,13 +426,14 @@
410 426 * Internal dependencies
411 427 */
412 428
413 429 /**
414 - * Get the rectangle of a given Range.
430 + * Get the rectangle of a given Range. Returns `null` if no suitable rectangle
431 + * can be found.
415 432 *
416 433 * @param {Range} range The range.
417 434 *
418 - * @return {DOMRect} The rectangle.
435 + * @return {DOMRect?} The rectangle.
419 436 */
420 437
421 438 function getRectangleFromRange(range) {
422 439 // For uncollapsed ranges, get the rectangle that bounds the contents of the
@@ -487,9 +504,16 @@
487 504 range.setStart(parentNode, index);
488 505 range.setEnd(parentNode, index);
489 506 }
490 507
491 - let rect = range.getClientRects()[0]; // If the collapsed range starts (and therefore ends) at an element node,
508 + const rects = range.getClientRects(); // If we have multiple rectangles for a collapsed range, there's no way to
509 + // know which it is, so don't return anything.
510 +
511 + if (rects.length > 1) {
512 + return null;
513 + }
514 +
515 + let rect = rects[0]; // If the collapsed range starts (and therefore ends) at an element node,
492 516 // `getClientRects` can be empty in some browsers. This can be resolved
493 517 // by adding a temporary text node with zero-width space to the range.
494 518 //
495 519 // See: https://stackoverflow.com/a/6847328/995445
@@ -506,9 +530,9 @@
506 530 }
507 531
508 532 return rect;
509 533 }
510 -//# sourceMappingURL=get-rectangle-from-range.js.map
534 +
511 535 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/compute-caret-rect.js
512 536 /**
513 537 * Internal dependencies
514 538 */
@@ -532,9 +556,9 @@
532 556 }
533 557
534 558 return getRectangleFromRange(range);
535 559 }
536 -//# sourceMappingURL=compute-caret-rect.js.map
560 +
537 561 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/document-has-text-selection.js
538 562 /**
539 563 * Internal dependencies
540 564 */
@@ -557,9 +581,9 @@
557 581 assertIsDefined(selection, 'selection');
558 582 const range = selection.rangeCount ? selection.getRangeAt(0) : null;
559 583 return !!range && !range.collapsed;
560 584 }
561 -//# sourceMappingURL=document-has-text-selection.js.map
585 +
562 586 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/is-html-input-element.js
563 587 /* eslint-disable jsdoc/valid-types */
564 588
565 589 /**
@@ -567,11 +591,11 @@
567 591 * @return {node is HTMLInputElement} Whether the node is an HTMLInputElement.
568 592 */
569 593 function isHTMLInputElement(node) {
570 594 /* eslint-enable jsdoc/valid-types */
571 - return !!node && node.nodeName === 'INPUT';
595 + return (node === null || node === void 0 ? void 0 : node.nodeName) === 'INPUT';
572 596 }
573 -//# sourceMappingURL=is-html-input-element.js.map
597 +
574 598 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/is-text-field.js
575 599 /**
576 600 * Internal dependencies
577 601 */
@@ -589,35 +613,14 @@
589 613 */
590 614
591 615 function isTextField(node) {
592 616 /* eslint-enable jsdoc/valid-types */
593 - const nonTextInputs = ['button', 'checkbox', 'hidden', 'file', 'radio', 'image', 'range', 'reset', 'submit', 'number'];
617 + const nonTextInputs = ['button', 'checkbox', 'hidden', 'file', 'radio', 'image', 'range', 'reset', 'submit', 'number', 'email', 'time'];
594 618 return isHTMLInputElement(node) && node.type && !nonTextInputs.includes(node.type) || node.nodeName === 'TEXTAREA' ||
595 619 /** @type {HTMLElement} */
596 620 node.contentEditable === 'true';
597 621 }
598 -//# sourceMappingURL=is-text-field.js.map
599 -;// CONCATENATED MODULE: ./packages/dom/build-module/dom/is-number-input.js
600 -/**
601 - * Internal dependencies
602 - */
603 622
604 -/* eslint-disable jsdoc/valid-types */
605 -
606 -/**
607 - * Check whether the given element is an input field of type number
608 - * and has a valueAsNumber
609 - *
610 - * @param {Node} node The HTML node.
611 - *
612 - * @return {node is HTMLInputElement} True if the node is input and holds a number.
613 - */
614 -
615 -function isNumberInput(node) {
616 - /* eslint-enable jsdoc/valid-types */
617 - return isHTMLInputElement(node) && node.type === 'number' && !!node.valueAsNumber;
618 -}
619 -//# sourceMappingURL=is-number-input.js.map
620 623 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/input-field-has-uncollapsed-selection.js
621 624 /**
622 625 * Internal dependencies
623 626 */
@@ -623,15 +626,19 @@
623 626 */
624 627
625 628
626 629 /**
627 - * Check whether the given element, assumed an input field or textarea,
628 - * contains a (uncollapsed) selection of text.
630 + * Check whether the given input field or textarea contains a (uncollapsed)
631 + * selection of text.
629 632 *
630 - * Note: this is perhaps an abuse of the term "selection", since these elements
631 - * manage selection differently and aren't covered by Selection#collapsed.
633 + * CAVEAT: Only specific text-based HTML inputs support the selection APIs
634 + * needed to determine whether they have a collapsed or uncollapsed selection.
635 + * This function defaults to returning `true` when the selection cannot be
636 + * inspected, such as with `<input type="time">`. The rationale is that this
637 + * should cause the block editor to defer to the browser's native selection
638 + * handling (e.g. copying and pasting), thereby reducing friction for the user.
632 639 *
633 - * See: https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection#Related_objects.
640 + * See: https://html.spec.whatwg.org/multipage/input.html#do-not-apply
634 641 *
635 642 * @param {Element} element The HTML element.
636 643 *
637 644 * @return {boolean} Whether the input/textareaa element has some "selection".
@@ -637,12 +644,15 @@
637 644 * @return {boolean} Whether the input/textareaa element has some "selection".
638 645 */
639 646
640 647 function inputFieldHasUncollapsedSelection(element) {
641 - if (!isTextField(element) && !isNumberInput(element)) {
648 + if (!isHTMLInputElement(element) && !isTextField(element)) {
642 649 return false;
643 - }
650 + } // Safari throws a type error when trying to get `selectionStart` and
651 + // `selectionEnd` on non-text <input> elements, so a try/catch construct is
652 + // necessary.
644 653
654 +
645 655 try {
646 656 const {
647 657 selectionStart,
648 658 selectionEnd
@@ -648,22 +658,21 @@
648 658 selectionEnd
649 659 } =
650 660 /** @type {HTMLInputElement | HTMLTextAreaElement} */
651 661 element;
652 - return selectionStart !== null && selectionStart !== selectionEnd;
662 + return (// `null` means the input type doesn't implement selection, thus we
663 + // cannot determine whether the selection is collapsed, so we
664 + // default to true.
665 + selectionStart === null || // when not null, compare the two points
666 + selectionStart !== selectionEnd
667 + );
653 668 } catch (error) {
654 - // Safari throws an exception when trying to get `selectionStart`
655 - // on non-text <input> elements (which, understandably, don't
656 - // have the text selection API). We catch this via a try/catch
657 - // block, as opposed to a more explicit check of the element's
658 - // input types, because of Safari's non-standard behavior. This
659 - // also means we don't have to worry about the list of input
660 - // types that support `selectionStart` changing as the HTML spec
661 - // evolves over time.
662 - return false;
669 + // This is Safari's way of saying that the input type doesn't implement
670 + // selection, so we default to true.
671 + return true;
663 672 }
664 673 }
665 -//# sourceMappingURL=input-field-has-uncollapsed-selection.js.map
674 +
666 675 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/document-has-uncollapsed-selection.js
667 676 /**
668 677 * Internal dependencies
669 678 */
@@ -669,21 +678,21 @@
669 678 */
670 679
671 680
672 681 /**
673 - * Check whether the current document has any sort of selection. This includes
674 - * ranges of text across elements and any selection inside `<input>` and
675 - * `<textarea>` elements.
682 + * Check whether the current document has any sort of (uncollapsed) selection.
683 + * This includes ranges of text across elements and any selection inside
684 + * textual `<input>` and `<textarea>` elements.
676 685 *
677 686 * @param {Document} doc The document to check.
678 687 *
679 - * @return {boolean} Whether there is any sort of "selection" in the document.
688 + * @return {boolean} Whether there is any recognizable text selection in the document.
680 689 */
681 690
682 691 function documentHasUncollapsedSelection(doc) {
683 692 return documentHasTextSelection(doc) || !!doc.activeElement && inputFieldHasUncollapsedSelection(doc.activeElement);
684 693 }
685 -//# sourceMappingURL=document-has-uncollapsed-selection.js.map
694 +
686 695 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/document-has-selection.js
687 696 /**
688 697 * Internal dependencies
689 698 */
@@ -690,10 +699,10 @@
690 699
691 700
692 701
693 702 /**
694 - * Check whether the current document has a selection. This checks for both
695 - * focus in an input field and general text selection.
703 + * Check whether the current document has a selection. This includes focus in
704 + * input fields, textareas, and general rich-text selection.
696 705 *
697 706 * @param {Document} doc The document to check.
698 707 *
699 708 * @return {boolean} True if there is selection, false if not.
@@ -699,11 +708,11 @@
699 708 * @return {boolean} True if there is selection, false if not.
700 709 */
701 710
702 711 function documentHasSelection(doc) {
703 - return !!doc.activeElement && (isTextField(doc.activeElement) || isNumberInput(doc.activeElement) || documentHasTextSelection(doc));
712 + return !!doc.activeElement && (isHTMLInputElement(doc.activeElement) || isTextField(doc.activeElement) || documentHasTextSelection(doc));
704 713 }
705 -//# sourceMappingURL=document-has-selection.js.map
714 +
706 715 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/get-computed-style.js
707 716 /**
708 717 * Internal dependencies
709 718 */
@@ -719,9 +728,9 @@
719 728 /* eslint-enable jsdoc/valid-types */
720 729 assertIsDefined(element.ownerDocument.defaultView, 'element.ownerDocument.defaultView');
721 730 return element.ownerDocument.defaultView.getComputedStyle(element);
722 731 }
723 -//# sourceMappingURL=get-computed-style.js.map
732 +
724 733 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/get-scroll-container.js
725 734 /**
726 735 * Internal dependencies
727 736 */
@@ -748,16 +757,20 @@
748 757
749 758 if (/(auto|scroll)/.test(overflowY)) {
750 759 return node;
751 760 }
752 - } // Continue traversing
761 + }
753 762
763 + if (node.ownerDocument === node.parentNode) {
764 + return node;
765 + } // Continue traversing.
754 766
767 +
755 768 return getScrollContainer(
756 769 /** @type {Element} */
757 770 node.parentNode);
758 771 }
759 -//# sourceMappingURL=get-scroll-container.js.map
772 +
760 773 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/get-offset-parent.js
761 774 /**
762 775 * Internal dependencies
763 776 */
@@ -796,9 +809,9 @@
796 809 if (getComputedStyle(
797 810 /** @type {Element} */
798 811 closestElement).position !== 'static') {
799 812 return closestElement;
800 - } // offsetParent is undocumented/draft
813 + } // offsetParent is undocumented/draft.
801 814
802 815
803 816 return (
804 817 /** @type {Node & { offsetParent: Node }} */
@@ -804,9 +817,9 @@
804 817 /** @type {Node & { offsetParent: Node }} */
805 818 closestElement.offsetParent
806 819 );
807 820 }
808 -//# sourceMappingURL=get-offset-parent.js.map
821 +
809 822 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/is-input-or-text-area.js
810 823 /* eslint-disable jsdoc/valid-types */
811 824
812 825 /**
@@ -816,9 +829,9 @@
816 829 function isInputOrTextArea(element) {
817 830 /* eslint-enable jsdoc/valid-types */
818 831 return element.tagName === 'INPUT' || element.tagName === 'TEXTAREA';
819 832 }
820 -//# sourceMappingURL=is-input-or-text-area.js.map
833 +
821 834 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/is-entirely-selected.js
822 835 /**
823 836 * Internal dependencies
824 837 */
@@ -899,9 +912,35 @@
899 912 } while (candidate);
900 913
901 914 return false;
902 915 }
903 -//# sourceMappingURL=is-entirely-selected.js.map
916 +
917 +;// CONCATENATED MODULE: ./packages/dom/build-module/dom/is-form-element.js
918 +/**
919 + * Internal dependencies
920 + */
921 +
922 +/**
923 + *
924 + * Detects if element is a form element.
925 + *
926 + * @param {Element} element The element to check.
927 + *
928 + * @return {boolean} True if form element and false otherwise.
929 + */
930 +
931 +function isFormElement(element) {
932 + if (!element) {
933 + return false;
934 + }
935 +
936 + const {
937 + tagName
938 + } = element;
939 + const checkForInputTextarea = isInputOrTextArea(element);
940 + return checkForInputTextarea || tagName === 'BUTTON' || tagName === 'SELECT';
941 +}
942 +
904 943 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/is-rtl.js
905 944 /**
906 945 * Internal dependencies
907 946 */
@@ -916,9 +955,9 @@
916 955
917 956 function isRTL(element) {
918 957 return getComputedStyle(element).direction === 'rtl';
919 958 }
920 -//# sourceMappingURL=is-rtl.js.map
959 +
921 960 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/get-range-height.js
922 961 /**
923 962 * Gets the height of the range without ignoring zero width rectangles, which
924 963 * some browsers ignore when creating a union.
@@ -946,9 +985,9 @@
946 985 return bottom;
947 986 }));
948 987 return lowestBottom - highestTop;
949 988 }
950 -//# sourceMappingURL=get-range-height.js.map
989 +
951 990 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/is-selection-forward.js
952 991 /**
953 992 * Internal dependencies
954 993 */
@@ -998,9 +1037,9 @@
998 1037
999 1038
1000 1039 return true;
1001 1040 }
1002 -//# sourceMappingURL=is-selection-forward.js.map
1041 +
1003 1042 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/caret-range-from-point.js
1004 1043 /**
1005 1044 * Polyfill.
1006 1045 * Get a collapsed range for a given point.
@@ -1037,9 +1076,9 @@
1037 1076 /**
1038 1077 * @typedef {{caretPositionFromPoint?: (x: number, y: number)=> CaretPosition | null} & Document } DocumentMaybeWithCaretPositionFromPoint
1039 1078 * @typedef {{ readonly offset: number; readonly offsetNode: Node; getClientRect(): DOMRect | null; }} CaretPosition
1040 1079 */
1041 -//# sourceMappingURL=caret-range-from-point.js.map
1080 +
1042 1081 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/hidden-caret-range-from-point.js
1043 1082 /**
1044 1083 * Internal dependencies
1045 1084 */
@@ -1074,9 +1113,9 @@
1074 1113 container.style.zIndex = originalZIndex;
1075 1114 container.style.position = originalPosition;
1076 1115 return range;
1077 1116 }
1078 -//# sourceMappingURL=hidden-caret-range-from-point.js.map
1117 +
1079 1118 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/is-edge.js
1080 1119 /**
1081 1120 * Internal dependencies
1082 1121 */
@@ -1195,9 +1234,9 @@
1195 1234 const hasVerticalDiff = Math.abs(verticalDiff) <= 1;
1196 1235 const hasHorizontalDiff = Math.abs(horizontalDiff) <= 1;
1197 1236 return onlyVertical ? hasVerticalDiff : hasVerticalDiff && hasHorizontalDiff;
1198 1237 }
1199 -//# sourceMappingURL=is-edge.js.map
1238 +
1200 1239 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/is-horizontal-edge.js
1201 1240 /**
1202 1241 * Internal dependencies
1203 1242 */
@@ -1213,9 +1252,42 @@
1213 1252
1214 1253 function isHorizontalEdge(container, isReverse) {
1215 1254 return isEdge(container, isReverse);
1216 1255 }
1217 -//# sourceMappingURL=is-horizontal-edge.js.map
1256 +
1257 +;// CONCATENATED MODULE: external ["wp","deprecated"]
1258 +const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
1259 +var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
1260 +;// CONCATENATED MODULE: ./packages/dom/build-module/dom/is-number-input.js
1261 +/**
1262 + * WordPress dependencies
1263 + */
1264 +
1265 +/**
1266 + * Internal dependencies
1267 + */
1268 +
1269 +
1270 +/* eslint-disable jsdoc/valid-types */
1271 +
1272 +/**
1273 + * Check whether the given element is an input field of type number.
1274 + *
1275 + * @param {Node} node The HTML node.
1276 + *
1277 + * @return {node is HTMLInputElement} True if the node is number input.
1278 + */
1279 +
1280 +function isNumberInput(node) {
1281 + external_wp_deprecated_default()('wp.dom.isNumberInput', {
1282 + since: '6.1',
1283 + version: '6.5'
1284 + });
1285 + /* eslint-enable jsdoc/valid-types */
1286 +
1287 + return isHTMLInputElement(node) && node.type === 'number' && !isNaN(node.valueAsNumber);
1288 +}
1289 +
1218 1290 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/is-vertical-edge.js
1219 1291 /**
1220 1292 * Internal dependencies
1221 1293 */
@@ -1231,9 +1303,9 @@
1231 1303
1232 1304 function isVerticalEdge(container, isReverse) {
1233 1305 return isEdge(container, isReverse, true);
1234 1306 }
1235 -//# sourceMappingURL=is-vertical-edge.js.map
1307 +
1236 1308 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/place-caret-at-edge.js
1237 1309 /**
1238 1310 * Internal dependencies
1239 1311 */
@@ -1258,11 +1330,17 @@
1258 1330
1259 1331 const isReverseDir = isRTL(container) ? !isReverse : isReverse;
1260 1332 const containerRect = container.getBoundingClientRect(); // When placing at the end (isReverse), find the closest range to the bottom
1261 1333 // right corner. When placing at the start, to the top left corner.
1334 + // Ensure x is defined and within the container's boundaries. When it's
1335 + // exactly at the boundary, it's not considered within the boundaries.
1262 1336
1263 1337 if (x === undefined) {
1264 1338 x = isReverse ? containerRect.right - 1 : containerRect.left + 1;
1339 + } else if (x <= containerRect.left) {
1340 + x = containerRect.left + 1;
1341 + } else if (x >= containerRect.right) {
1342 + x = containerRect.right - 1;
1265 1343 }
1266 1344
1267 1345 const y = isReverseDir ? containerRect.bottom - 1 : containerRect.top + 1;
1268 1346 return hiddenCaretRangeFromPoint(ownerDocument, x, y, container);
@@ -1327,9 +1405,9 @@
1327 1405 assertIsDefined(selection, 'selection');
1328 1406 selection.removeAllRanges();
1329 1407 selection.addRange(range);
1330 1408 }
1331 -//# sourceMappingURL=place-caret-at-edge.js.map
1409 +
1332 1410 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/place-caret-at-horizontal-edge.js
1333 1411 /**
1334 1412 * Internal dependencies
1335 1413 */
@@ -1343,9 +1421,9 @@
1343 1421
1344 1422 function placeCaretAtHorizontalEdge(container, isReverse) {
1345 1423 return placeCaretAtEdge(container, isReverse, undefined);
1346 1424 }
1347 -//# sourceMappingURL=place-caret-at-horizontal-edge.js.map
1425 +
1348 1426 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/place-caret-at-vertical-edge.js
1349 1427 /**
1350 1428 * Internal dependencies
1351 1429 */
@@ -1360,9 +1438,9 @@
1360 1438
1361 1439 function placeCaretAtVerticalEdge(container, isReverse, rect) {
1362 1440 return placeCaretAtEdge(container, isReverse, rect === null || rect === void 0 ? void 0 : rect.left);
1363 1441 }
1364 -//# sourceMappingURL=place-caret-at-vertical-edge.js.map
1442 +
1365 1443 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/insert-after.js
1366 1444 /**
1367 1445 * Internal dependencies
1368 1446 */
@@ -1379,9 +1457,9 @@
1379 1457 function insertAfter(newNode, referenceNode) {
1380 1458 assertIsDefined(referenceNode.parentNode, 'referenceNode.parentNode');
1381 1459 referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
1382 1460 }
1383 -//# sourceMappingURL=insert-after.js.map
1461 +
1384 1462 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/remove.js
1385 1463 /**
1386 1464 * Internal dependencies
1387 1465 */
@@ -1396,9 +1474,9 @@
1396 1474 function remove(node) {
1397 1475 assertIsDefined(node.parentNode, 'node.parentNode');
1398 1476 node.parentNode.removeChild(node);
1399 1477 }
1400 -//# sourceMappingURL=remove.js.map
1478 +
1401 1479 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/replace.js
1402 1480 /**
1403 1481 * Internal dependencies
1404 1482 */
@@ -1417,9 +1495,9 @@
1417 1495 assertIsDefined(processedNode.parentNode, 'processedNode.parentNode');
1418 1496 insertAfter(newNode, processedNode.parentNode);
1419 1497 remove(processedNode);
1420 1498 }
1421 -//# sourceMappingURL=replace.js.map
1499 +
1422 1500 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/unwrap.js
1423 1501 /**
1424 1502 * Internal dependencies
1425 1503 */
@@ -1441,9 +1519,9 @@
1441 1519 }
1442 1520
1443 1521 parent.removeChild(node);
1444 1522 }
1445 -//# sourceMappingURL=unwrap.js.map
1523 +
1446 1524 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/replace-tag.js
1447 1525 /**
1448 1526 * Internal dependencies
1449 1527 */
@@ -1467,9 +1545,9 @@
1467 1545 assertIsDefined(node.parentNode, 'node.parentNode');
1468 1546 node.parentNode.replaceChild(newNode, node);
1469 1547 return newNode;
1470 1548 }
1471 -//# sourceMappingURL=replace-tag.js.map
1549 +
1472 1550 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/wrap.js
1473 1551 /**
1474 1552 * Internal dependencies
1475 1553 */
@@ -1485,9 +1563,9 @@
1485 1563 assertIsDefined(referenceNode.parentNode, 'referenceNode.parentNode');
1486 1564 referenceNode.parentNode.insertBefore(newNode, referenceNode);
1487 1565 newNode.appendChild(referenceNode);
1488 1566 }
1489 -//# sourceMappingURL=wrap.js.map
1567 +
1490 1568 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/safe-html.js
1491 1569 /**
1492 1570 * Internal dependencies
1493 1571 */
@@ -1529,9 +1607,9 @@
1529 1607 }
1530 1608
1531 1609 return body.innerHTML;
1532 1610 }
1533 -//# sourceMappingURL=safe-html.js.map
1611 +
1534 1612 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/strip-html.js
1535 1613 /**
1536 1614 * Internal dependencies
1537 1615 */
@@ -1551,9 +1629,9 @@
1551 1629 const doc = document.implementation.createHTMLDocument('');
1552 1630 doc.body.innerHTML = html;
1553 1631 return doc.body.textContent || '';
1554 1632 }
1555 -//# sourceMappingURL=strip-html.js.map
1633 +
1556 1634 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/is-empty.js
1557 1635 /**
1558 1636 * Recursively checks if an element is empty. An element is not empty if it
1559 1637 * contains text or contains elements with attributes such as images.
@@ -1584,15 +1662,11 @@
1584 1662 default:
1585 1663 return true;
1586 1664 }
1587 1665 }
1588 -//# sourceMappingURL=is-empty.js.map
1666 +
1589 1667 ;// CONCATENATED MODULE: ./packages/dom/build-module/phrasing-content.js
1590 1668 /**
1591 - * External dependencies
1592 - */
1593 -
1594 -/**
1595 1669 * All phrasing content elements.
1596 1670 *
1597 1671 * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0
1598 1672 */
@@ -1613,9 +1687,8 @@
1613 1687 * @see https://html.spec.whatwg.org/multipage/text-level-semantics.html
1614 1688 *
1615 1689 * @type {ContentSchema}
1616 1690 */
1617 -
1618 1691 const textContentSchema = {
1619 1692 strong: {},
1620 1693 em: {},
1621 1694 s: {},
@@ -1667,10 +1740,15 @@
1667 1740 }; // Recursion is needed.
1668 1741 // Possible: strong > em > strong.
1669 1742 // Impossible: strong > strong.
1670 1743
1671 -(0,external_lodash_namespaceObject.without)(Object.keys(textContentSchema), '#text', 'br').forEach(tag => {
1672 - textContentSchema[tag].children = (0,external_lodash_namespaceObject.omit)(textContentSchema, tag);
1744 +const excludedElements = ['#text', 'br'];
1745 +Object.keys(textContentSchema).filter(element => !excludedElements.includes(element)).forEach(tag => {
1746 + const {
1747 + [tag]: removedTag,
1748 + ...restSchema
1749 + } = textContentSchema;
1750 + textContentSchema[tag].children = restSchema;
1673 1751 });
1674 1752 /**
1675 1753 * Embedded content elements.
1676 1754 *
@@ -1722,10 +1800,30 @@
1722 1800 function getPhrasingContentSchema(context) {
1723 1801 if (context !== 'paste') {
1724 1802 return phrasingContentSchema;
1725 1803 }
1804 + /**
1805 + * @type {Partial<ContentSchema>}
1806 + */
1726 1807
1727 - return (0,external_lodash_namespaceObject.omit)({ ...phrasingContentSchema,
1808 +
1809 + const {
1810 + u,
1811 + // Used to mark misspelling. Shouldn't be pasted.
1812 + abbr,
1813 + // Invisible.
1814 + data,
1815 + // Invisible.
1816 + time,
1817 + // Invisible.
1818 + wbr,
1819 + // Invisible.
1820 + bdi,
1821 + // Invisible.
1822 + bdo,
1823 + // Invisible.
1824 + ...remainingContentSchema
1825 + } = { ...phrasingContentSchema,
1728 1826 // We shouldn't paste potentially sensitive information which is not
1729 1827 // visible to the user when pasted, so strip the attributes.
1730 1828 ins: {
1731 1829 children: phrasingContentSchema.ins.children
@@ -1732,16 +1830,10 @@
1732 1830 },
1733 1831 del: {
1734 1832 children: phrasingContentSchema.del.children
1735 1833 }
1736 - }, ['u', // Used to mark misspelling. Shouldn't be pasted.
1737 - 'abbr', // Invisible.
1738 - 'data', // Invisible.
1739 - 'time', // Invisible.
1740 - 'wbr', // Invisible.
1741 - 'bdi', // Invisible.
1742 - 'bdo' // Invisible.
1743 - ]);
1834 + };
1835 + return remainingContentSchema;
1744 1836 }
1745 1837 /**
1746 1838 * Find out whether or not the given node is phrasing content.
1747 1839 *
@@ -1764,9 +1856,9 @@
1764 1856 function isTextContent(node) {
1765 1857 const tag = node.nodeName.toLowerCase();
1766 1858 return textContentSchema.hasOwnProperty(tag) || tag === 'span';
1767 1859 }
1768 -//# sourceMappingURL=phrasing-content.js.map
1860 +
1769 1861 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/is-element.js
1770 1862 /* eslint-disable jsdoc/valid-types */
1771 1863
1772 1864 /**
@@ -1776,15 +1868,11 @@
1776 1868 function isElement(node) {
1777 1869 /* eslint-enable jsdoc/valid-types */
1778 1870 return !!node && node.nodeType === node.ELEMENT_NODE;
1779 1871 }
1780 -//# sourceMappingURL=is-element.js.map
1872 +
1781 1873 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/clean-node-list.js
1782 1874 /**
1783 - * External dependencies
1784 - */
1785 -
1786 -/**
1787 1875 * Internal dependencies
1788 1876 */
1789 1877
1790 1878
@@ -1792,8 +1880,9 @@
1792 1880
1793 1881
1794 1882
1795 1883
1884 +const noop = () => {};
1796 1885 /* eslint-disable jsdoc/valid-types */
1797 1886
1798 1887 /**
1799 1888 * @typedef SchemaItem
@@ -1818,8 +1907,9 @@
1818 1907 * @param {Schema} schema An array of functions that can mutate with the provided node.
1819 1908 * @param {boolean} inline Whether to clean for inline mode.
1820 1909 */
1821 1910
1911 +
1822 1912 function cleanNodeList(nodeList, doc, schema, inline) {
1823 1913 Array.from(nodeList).forEach((
1824 1914 /** @type {Node & { nextElementSibling?: unknown }} */
1825 1915 node) => {
@@ -1850,9 +1940,9 @@
1850 1940 let {
1851 1941 name
1852 1942 } = _ref;
1853 1943
1854 - if (name !== 'class' && !(0,external_lodash_namespaceObject.includes)(attributes, name)) {
1944 + if (name !== 'class' && !attributes.includes(name)) {
1855 1945 node.removeAttribute(name);
1856 1946 }
1857 1947 }); // Strip invalid classes.
1858 1948 // In jsdom-jscore, 'node.classList' can be undefined.
@@ -1869,9 +1959,9 @@
1869 1959 /** @type {string} */
1870 1960 className) => item.test(className);
1871 1961 }
1872 1962
1873 - return external_lodash_namespaceObject.noop;
1963 + return noop;
1874 1964 });
1875 1965 Array.from(node.classList).forEach(name => {
1876 1966 if (!mattchers.some(isMatch => isMatch(name))) {
1877 1967 node.classList.remove(name);
@@ -1928,9 +2018,9 @@
1928 2018 unwrap(node);
1929 2019 }
1930 2020 });
1931 2021 }
1932 -//# sourceMappingURL=clean-node-list.js.map
2022 +
1933 2023 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/remove-invalid-html.js
1934 2024 /**
1935 2025 * Internal dependencies
1936 2026 */
@@ -1950,9 +2040,9 @@
1950 2040 doc.body.innerHTML = HTML;
1951 2041 cleanNodeList(doc.body.childNodes, doc, schema, inline);
1952 2042 return doc.body.innerHTML;
1953 2043 }
1954 -//# sourceMappingURL=remove-invalid-html.js.map
2044 +
1955 2045 ;// CONCATENATED MODULE: ./packages/dom/build-module/dom/index.js
1956 2046
1957 2047
1958 2048
@@ -1977,9 +2067,10 @@
1977 2067
1978 2068
1979 2069
1980 2070
1981 -//# sourceMappingURL=index.js.map
2071 +
2072 +
1982 2073 ;// CONCATENATED MODULE: ./packages/dom/build-module/data-transfer.js
1983 2074 /**
1984 2075 * Gets all files from a DataTransfer object.
1985 2076 *
@@ -2004,9 +2095,9 @@
2004 2095 }
2005 2096 });
2006 2097 return files;
2007 2098 }
2008 -//# sourceMappingURL=data-transfer.js.map
2099 +
2009 2100 ;// CONCATENATED MODULE: ./packages/dom/build-module/index.js
2010 2101 /**
2011 2102 * Internal dependencies
2012 2103 */
@@ -2023,8 +2114,8 @@
2023 2114 };
2024 2115
2025 2116
2026 2117
2027 -//# sourceMappingURL=index.js.map
2118 +
2028 2119 (window.wp = window.wp || {}).dom = __webpack_exports__;
2029 2120 /******/ })()
2030 2121 ;