[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/dist/ -> dom.js (source)

   1  /******/ (() => { // webpackBootstrap
   2  /******/     "use strict";
   3  /******/     // The require scope
   4  /******/     var __webpack_require__ = {};
   5  /******/     
   6  /************************************************************************/
   7  /******/     /* webpack/runtime/compat get default export */
   8  /******/     (() => {
   9  /******/         // getDefaultExport function for compatibility with non-harmony modules
  10  /******/         __webpack_require__.n = (module) => {
  11  /******/             var getter = module && module.__esModule ?
  12  /******/                 () => (module['default']) :
  13  /******/                 () => (module);
  14  /******/             __webpack_require__.d(getter, { a: getter });
  15  /******/             return getter;
  16  /******/         };
  17  /******/     })();
  18  /******/     
  19  /******/     /* webpack/runtime/define property getters */
  20  /******/     (() => {
  21  /******/         // define getter functions for harmony exports
  22  /******/         __webpack_require__.d = (exports, definition) => {
  23  /******/             for(var key in definition) {
  24  /******/                 if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  25  /******/                     Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  26  /******/                 }
  27  /******/             }
  28  /******/         };
  29  /******/     })();
  30  /******/     
  31  /******/     /* webpack/runtime/hasOwnProperty shorthand */
  32  /******/     (() => {
  33  /******/         __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  34  /******/     })();
  35  /******/     
  36  /******/     /* webpack/runtime/make namespace object */
  37  /******/     (() => {
  38  /******/         // define __esModule on exports
  39  /******/         __webpack_require__.r = (exports) => {
  40  /******/             if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  41  /******/                 Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  42  /******/             }
  43  /******/             Object.defineProperty(exports, '__esModule', { value: true });
  44  /******/         };
  45  /******/     })();
  46  /******/     
  47  /************************************************************************/
  48  var __webpack_exports__ = {};
  49  // ESM COMPAT FLAG
  50  __webpack_require__.r(__webpack_exports__);
  51  
  52  // EXPORTS
  53  __webpack_require__.d(__webpack_exports__, {
  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    isSelectionForward: () => (/* reexport */ isSelectionForward),
  74    isTextContent: () => (/* reexport */ isTextContent),
  75    isTextField: () => (/* reexport */ isTextField),
  76    isVerticalEdge: () => (/* reexport */ isVerticalEdge),
  77    placeCaretAtHorizontalEdge: () => (/* reexport */ placeCaretAtHorizontalEdge),
  78    placeCaretAtVerticalEdge: () => (/* reexport */ placeCaretAtVerticalEdge),
  79    remove: () => (/* reexport */ remove),
  80    removeInvalidHTML: () => (/* reexport */ removeInvalidHTML),
  81    replace: () => (/* reexport */ replace),
  82    replaceTag: () => (/* reexport */ replaceTag),
  83    safeHTML: () => (/* reexport */ safeHTML),
  84    unwrap: () => (/* reexport */ unwrap),
  85    wrap: () => (/* reexport */ wrap)
  86  });
  87  
  88  // NAMESPACE OBJECT: ./node_modules/@wordpress/dom/build-module/focusable.js
  89  var focusable_namespaceObject = {};
  90  __webpack_require__.r(focusable_namespaceObject);
  91  __webpack_require__.d(focusable_namespaceObject, {
  92    find: () => (find)
  93  });
  94  
  95  // NAMESPACE OBJECT: ./node_modules/@wordpress/dom/build-module/tabbable.js
  96  var tabbable_namespaceObject = {};
  97  __webpack_require__.r(tabbable_namespaceObject);
  98  __webpack_require__.d(tabbable_namespaceObject, {
  99    find: () => (tabbable_find),
 100    findNext: () => (findNext),
 101    findPrevious: () => (findPrevious),
 102    isTabbableIndex: () => (isTabbableIndex)
 103  });
 104  
 105  ;// ./node_modules/@wordpress/dom/build-module/focusable.js
 106  function buildSelector(sequential) {
 107    return [
 108      sequential ? '[tabindex]:not([tabindex^="-"])' : "[tabindex]",
 109      "a[href]",
 110      "button:not([disabled])",
 111      'input:not([type="hidden"]):not([disabled])',
 112      "select:not([disabled])",
 113      "textarea:not([disabled])",
 114      'iframe:not([tabindex^="-"])',
 115      "object",
 116      "embed",
 117      "summary",
 118      "area[href]",
 119      "[contenteditable]:not([contenteditable=false])"
 120    ].join(",");
 121  }
 122  function isVisible(element) {
 123    return element.offsetWidth > 0 || element.offsetHeight > 0 || element.getClientRects().length > 0;
 124  }
 125  function isValidFocusableArea(element) {
 126    const map = element.closest("map[name]");
 127    if (!map) {
 128      return false;
 129    }
 130    const img = element.ownerDocument.querySelector(
 131      'img[usemap="#' + map.name + '"]'
 132    );
 133    return !!img && isVisible(img);
 134  }
 135  function find(context, { sequential = false } = {}) {
 136    const elements = context.querySelectorAll(buildSelector(sequential));
 137    return Array.from(elements).filter((element) => {
 138      if (!isVisible(element)) {
 139        return false;
 140      }
 141      const { nodeName } = element;
 142      if ("AREA" === nodeName) {
 143        return isValidFocusableArea(
 144          /** @type {HTMLAreaElement} */
 145          element
 146        );
 147      }
 148      return true;
 149    });
 150  }
 151  
 152  
 153  ;// ./node_modules/@wordpress/dom/build-module/tabbable.js
 154  
 155  function getTabIndex(element) {
 156    const tabIndex = element.getAttribute("tabindex");
 157    return tabIndex === null ? 0 : parseInt(tabIndex, 10);
 158  }
 159  function isTabbableIndex(element) {
 160    return getTabIndex(element) !== -1;
 161  }
 162  function createStatefulCollapseRadioGroup() {
 163    const CHOSEN_RADIO_BY_NAME = {};
 164    return function collapseRadioGroup(result, element) {
 165      const { nodeName, type, checked, name } = element;
 166      if (nodeName !== "INPUT" || type !== "radio" || !name) {
 167        return result.concat(element);
 168      }
 169      const hasChosen = CHOSEN_RADIO_BY_NAME.hasOwnProperty(name);
 170      const isChosen = checked || !hasChosen;
 171      if (!isChosen) {
 172        return result;
 173      }
 174      if (hasChosen) {
 175        const hadChosenElement = CHOSEN_RADIO_BY_NAME[name];
 176        result = result.filter((e) => e !== hadChosenElement);
 177      }
 178      CHOSEN_RADIO_BY_NAME[name] = element;
 179      return result.concat(element);
 180    };
 181  }
 182  function mapElementToObjectTabbable(element, index) {
 183    return { element, index };
 184  }
 185  function mapObjectTabbableToElement(object) {
 186    return object.element;
 187  }
 188  function compareObjectTabbables(a, b) {
 189    const aTabIndex = getTabIndex(a.element);
 190    const bTabIndex = getTabIndex(b.element);
 191    if (aTabIndex === bTabIndex) {
 192      return a.index - b.index;
 193    }
 194    return aTabIndex - bTabIndex;
 195  }
 196  function filterTabbable(focusables) {
 197    return focusables.filter(isTabbableIndex).map(mapElementToObjectTabbable).sort(compareObjectTabbables).map(mapObjectTabbableToElement).reduce(createStatefulCollapseRadioGroup(), []);
 198  }
 199  function tabbable_find(context) {
 200    return filterTabbable(find(context));
 201  }
 202  function findPrevious(element) {
 203    return filterTabbable(find(element.ownerDocument.body)).reverse().find(
 204      (focusable) => (
 205        // eslint-disable-next-line no-bitwise
 206        element.compareDocumentPosition(focusable) & element.DOCUMENT_POSITION_PRECEDING
 207      )
 208    );
 209  }
 210  function findNext(element) {
 211    return filterTabbable(find(element.ownerDocument.body)).find(
 212      (focusable) => (
 213        // eslint-disable-next-line no-bitwise
 214        element.compareDocumentPosition(focusable) & element.DOCUMENT_POSITION_FOLLOWING
 215      )
 216    );
 217  }
 218  
 219  
 220  ;// ./node_modules/@wordpress/dom/build-module/utils/assert-is-defined.js
 221  function assertIsDefined(val, name) {
 222    if (false) {}
 223  }
 224  
 225  
 226  ;// ./node_modules/@wordpress/dom/build-module/dom/get-rectangle-from-range.js
 227  
 228  function getRectangleFromRange(range) {
 229    if (!range.collapsed) {
 230      const rects2 = Array.from(range.getClientRects());
 231      if (rects2.length === 1) {
 232        return rects2[0];
 233      }
 234      const filteredRects = rects2.filter(({ width }) => width > 1);
 235      if (filteredRects.length === 0) {
 236        return range.getBoundingClientRect();
 237      }
 238      if (filteredRects.length === 1) {
 239        return filteredRects[0];
 240      }
 241      let {
 242        top: furthestTop,
 243        bottom: furthestBottom,
 244        left: furthestLeft,
 245        right: furthestRight
 246      } = filteredRects[0];
 247      for (const { top, bottom, left, right } of filteredRects) {
 248        if (top < furthestTop) {
 249          furthestTop = top;
 250        }
 251        if (bottom > furthestBottom) {
 252          furthestBottom = bottom;
 253        }
 254        if (left < furthestLeft) {
 255          furthestLeft = left;
 256        }
 257        if (right > furthestRight) {
 258          furthestRight = right;
 259        }
 260      }
 261      return new window.DOMRect(
 262        furthestLeft,
 263        furthestTop,
 264        furthestRight - furthestLeft,
 265        furthestBottom - furthestTop
 266      );
 267    }
 268    const { startContainer } = range;
 269    const { ownerDocument } = startContainer;
 270    if (startContainer.nodeName === "BR") {
 271      const { parentNode } = startContainer;
 272      assertIsDefined(parentNode, "parentNode");
 273      const index = (
 274        /** @type {Node[]} */
 275        Array.from(parentNode.childNodes).indexOf(startContainer)
 276      );
 277      assertIsDefined(ownerDocument, "ownerDocument");
 278      range = ownerDocument.createRange();
 279      range.setStart(parentNode, index);
 280      range.setEnd(parentNode, index);
 281    }
 282    const rects = range.getClientRects();
 283    if (rects.length > 1) {
 284      return null;
 285    }
 286    let rect = rects[0];
 287    if (!rect || rect.height === 0) {
 288      assertIsDefined(ownerDocument, "ownerDocument");
 289      const padNode = ownerDocument.createTextNode("\u200B");
 290      range = range.cloneRange();
 291      range.insertNode(padNode);
 292      rect = range.getClientRects()[0];
 293      assertIsDefined(padNode.parentNode, "padNode.parentNode");
 294      padNode.parentNode.removeChild(padNode);
 295    }
 296    return rect;
 297  }
 298  
 299  
 300  ;// ./node_modules/@wordpress/dom/build-module/dom/compute-caret-rect.js
 301  
 302  
 303  function computeCaretRect(win) {
 304    const selection = win.getSelection();
 305    assertIsDefined(selection, "selection");
 306    const range = selection.rangeCount ? selection.getRangeAt(0) : null;
 307    if (!range) {
 308      return null;
 309    }
 310    return getRectangleFromRange(range);
 311  }
 312  
 313  
 314  ;// ./node_modules/@wordpress/dom/build-module/dom/document-has-text-selection.js
 315  
 316  function documentHasTextSelection(doc) {
 317    assertIsDefined(doc.defaultView, "doc.defaultView");
 318    const selection = doc.defaultView.getSelection();
 319    assertIsDefined(selection, "selection");
 320    const range = selection.rangeCount ? selection.getRangeAt(0) : null;
 321    return !!range && !range.collapsed;
 322  }
 323  
 324  
 325  ;// ./node_modules/@wordpress/dom/build-module/dom/is-html-input-element.js
 326  function isHTMLInputElement(node) {
 327    return node?.nodeName === "INPUT";
 328  }
 329  
 330  
 331  ;// ./node_modules/@wordpress/dom/build-module/dom/is-text-field.js
 332  
 333  function isTextField(node) {
 334    const nonTextInputs = [
 335      "button",
 336      "checkbox",
 337      "hidden",
 338      "file",
 339      "radio",
 340      "image",
 341      "range",
 342      "reset",
 343      "submit",
 344      "number",
 345      "email",
 346      "time"
 347    ];
 348    return isHTMLInputElement(node) && node.type && !nonTextInputs.includes(node.type) || node.nodeName === "TEXTAREA" || /** @type {HTMLElement} */
 349    node.contentEditable === "true";
 350  }
 351  
 352  
 353  ;// ./node_modules/@wordpress/dom/build-module/dom/input-field-has-uncollapsed-selection.js
 354  
 355  
 356  function inputFieldHasUncollapsedSelection(element) {
 357    if (!isHTMLInputElement(element) && !isTextField(element)) {
 358      return false;
 359    }
 360    try {
 361      const { selectionStart, selectionEnd } = (
 362        /** @type {HTMLInputElement | HTMLTextAreaElement} */
 363        element
 364      );
 365      return (
 366        // `null` means the input type doesn't implement selection, thus we
 367        // cannot determine whether the selection is collapsed, so we
 368        // default to true.
 369        selectionStart === null || // when not null, compare the two points
 370        selectionStart !== selectionEnd
 371      );
 372    } catch (error) {
 373      return true;
 374    }
 375  }
 376  
 377  
 378  ;// ./node_modules/@wordpress/dom/build-module/dom/document-has-uncollapsed-selection.js
 379  
 380  
 381  function documentHasUncollapsedSelection(doc) {
 382    return documentHasTextSelection(doc) || !!doc.activeElement && inputFieldHasUncollapsedSelection(doc.activeElement);
 383  }
 384  
 385  
 386  ;// ./node_modules/@wordpress/dom/build-module/dom/document-has-selection.js
 387  
 388  
 389  
 390  function documentHasSelection(doc) {
 391    return !!doc.activeElement && (isHTMLInputElement(doc.activeElement) || isTextField(doc.activeElement) || documentHasTextSelection(doc));
 392  }
 393  
 394  
 395  ;// ./node_modules/@wordpress/dom/build-module/dom/get-computed-style.js
 396  
 397  function getComputedStyle(element) {
 398    assertIsDefined(
 399      element.ownerDocument.defaultView,
 400      "element.ownerDocument.defaultView"
 401    );
 402    return element.ownerDocument.defaultView.getComputedStyle(element);
 403  }
 404  
 405  
 406  ;// ./node_modules/@wordpress/dom/build-module/dom/get-scroll-container.js
 407  
 408  function getScrollContainer(node, direction = "vertical") {
 409    if (!node) {
 410      return void 0;
 411    }
 412    if (direction === "vertical" || direction === "all") {
 413      if (node.scrollHeight > node.clientHeight) {
 414        const { overflowY } = getComputedStyle(node);
 415        if (/(auto|scroll)/.test(overflowY)) {
 416          return node;
 417        }
 418      }
 419    }
 420    if (direction === "horizontal" || direction === "all") {
 421      if (node.scrollWidth > node.clientWidth) {
 422        const { overflowX } = getComputedStyle(node);
 423        if (/(auto|scroll)/.test(overflowX)) {
 424          return node;
 425        }
 426      }
 427    }
 428    if (node.ownerDocument === node.parentNode) {
 429      return node;
 430    }
 431    return getScrollContainer(
 432      /** @type {Element} */
 433      node.parentNode,
 434      direction
 435    );
 436  }
 437  
 438  
 439  ;// ./node_modules/@wordpress/dom/build-module/dom/get-offset-parent.js
 440  
 441  function getOffsetParent(node) {
 442    let closestElement;
 443    while (closestElement = /** @type {Node} */
 444    node.parentNode) {
 445      if (closestElement.nodeType === closestElement.ELEMENT_NODE) {
 446        break;
 447      }
 448    }
 449    if (!closestElement) {
 450      return null;
 451    }
 452    if (getComputedStyle(
 453      /** @type {Element} */
 454      closestElement
 455    ).position !== "static") {
 456      return closestElement;
 457    }
 458    return (
 459      /** @type {Node & { offsetParent: Node }} */
 460      closestElement.offsetParent
 461    );
 462  }
 463  
 464  
 465  ;// ./node_modules/@wordpress/dom/build-module/dom/is-input-or-text-area.js
 466  function isInputOrTextArea(element) {
 467    return element.tagName === "INPUT" || element.tagName === "TEXTAREA";
 468  }
 469  
 470  
 471  ;// ./node_modules/@wordpress/dom/build-module/dom/is-entirely-selected.js
 472  
 473  
 474  function isEntirelySelected(element) {
 475    if (isInputOrTextArea(element)) {
 476      return element.selectionStart === 0 && element.value.length === element.selectionEnd;
 477    }
 478    if (!element.isContentEditable) {
 479      return true;
 480    }
 481    const { ownerDocument } = element;
 482    const { defaultView } = ownerDocument;
 483    assertIsDefined(defaultView, "defaultView");
 484    const selection = defaultView.getSelection();
 485    assertIsDefined(selection, "selection");
 486    const range = selection.rangeCount ? selection.getRangeAt(0) : null;
 487    if (!range) {
 488      return true;
 489    }
 490    const { startContainer, endContainer, startOffset, endOffset } = range;
 491    if (startContainer === element && endContainer === element && startOffset === 0 && endOffset === element.childNodes.length) {
 492      return true;
 493    }
 494    const lastChild = element.lastChild;
 495    assertIsDefined(lastChild, "lastChild");
 496    const endContainerContentLength = endContainer.nodeType === endContainer.TEXT_NODE ? (
 497      /** @type {Text} */
 498      endContainer.data.length
 499    ) : endContainer.childNodes.length;
 500    return isDeepChild(startContainer, element, "firstChild") && isDeepChild(endContainer, element, "lastChild") && startOffset === 0 && endOffset === endContainerContentLength;
 501  }
 502  function isDeepChild(query, container, propName) {
 503    let candidate = container;
 504    do {
 505      if (query === candidate) {
 506        return true;
 507      }
 508      candidate = candidate[propName];
 509    } while (candidate);
 510    return false;
 511  }
 512  
 513  
 514  ;// ./node_modules/@wordpress/dom/build-module/dom/is-form-element.js
 515  
 516  function isFormElement(element) {
 517    if (!element) {
 518      return false;
 519    }
 520    const { tagName } = element;
 521    const checkForInputTextarea = isInputOrTextArea(element);
 522    return checkForInputTextarea || tagName === "BUTTON" || tagName === "SELECT";
 523  }
 524  
 525  
 526  ;// ./node_modules/@wordpress/dom/build-module/dom/is-rtl.js
 527  
 528  function isRTL(element) {
 529    return getComputedStyle(element).direction === "rtl";
 530  }
 531  
 532  
 533  ;// ./node_modules/@wordpress/dom/build-module/dom/get-range-height.js
 534  function getRangeHeight(range) {
 535    const rects = Array.from(range.getClientRects());
 536    if (!rects.length) {
 537      return;
 538    }
 539    const highestTop = Math.min(...rects.map(({ top }) => top));
 540    const lowestBottom = Math.max(...rects.map(({ bottom }) => bottom));
 541    return lowestBottom - highestTop;
 542  }
 543  
 544  
 545  ;// ./node_modules/@wordpress/dom/build-module/dom/is-selection-forward.js
 546  
 547  function isSelectionForward(selection) {
 548    const { anchorNode, focusNode, anchorOffset, focusOffset } = selection;
 549    assertIsDefined(anchorNode, "anchorNode");
 550    assertIsDefined(focusNode, "focusNode");
 551    const position = anchorNode.compareDocumentPosition(focusNode);
 552    if (position & anchorNode.DOCUMENT_POSITION_PRECEDING) {
 553      return false;
 554    }
 555    if (position & anchorNode.DOCUMENT_POSITION_FOLLOWING) {
 556      return true;
 557    }
 558    if (position === 0) {
 559      return anchorOffset <= focusOffset;
 560    }
 561    return true;
 562  }
 563  
 564  
 565  ;// ./node_modules/@wordpress/dom/build-module/dom/caret-range-from-point.js
 566  function caretRangeFromPoint(doc, x, y) {
 567    if (doc.caretRangeFromPoint) {
 568      return doc.caretRangeFromPoint(x, y);
 569    }
 570    if (!doc.caretPositionFromPoint) {
 571      return null;
 572    }
 573    const point = doc.caretPositionFromPoint(x, y);
 574    if (!point) {
 575      return null;
 576    }
 577    const range = doc.createRange();
 578    range.setStart(point.offsetNode, point.offset);
 579    range.collapse(true);
 580    return range;
 581  }
 582  
 583  
 584  ;// ./node_modules/@wordpress/dom/build-module/dom/hidden-caret-range-from-point.js
 585  
 586  
 587  function hiddenCaretRangeFromPoint(doc, x, y, container) {
 588    const originalZIndex = container.style.zIndex;
 589    const originalPosition = container.style.position;
 590    const { position = "static" } = getComputedStyle(container);
 591    if (position === "static") {
 592      container.style.position = "relative";
 593    }
 594    container.style.zIndex = "10000";
 595    const range = caretRangeFromPoint(doc, x, y);
 596    container.style.zIndex = originalZIndex;
 597    container.style.position = originalPosition;
 598    return range;
 599  }
 600  
 601  
 602  ;// ./node_modules/@wordpress/dom/build-module/dom/scroll-if-no-range.js
 603  function scrollIfNoRange(container, alignToTop, callback) {
 604    let range = callback();
 605    if (!range || !range.startContainer || !container.contains(range.startContainer)) {
 606      container.scrollIntoView(alignToTop);
 607      range = callback();
 608      if (!range || !range.startContainer || !container.contains(range.startContainer)) {
 609        return null;
 610      }
 611    }
 612    return range;
 613  }
 614  
 615  
 616  ;// ./node_modules/@wordpress/dom/build-module/dom/is-edge.js
 617  
 618  
 619  
 620  
 621  
 622  
 623  
 624  
 625  function isEdge(container, isReverse, onlyVertical = false) {
 626    if (isInputOrTextArea(container) && typeof container.selectionStart === "number") {
 627      if (container.selectionStart !== container.selectionEnd) {
 628        return false;
 629      }
 630      if (isReverse) {
 631        return container.selectionStart === 0;
 632      }
 633      return container.value.length === container.selectionStart;
 634    }
 635    if (!container.isContentEditable) {
 636      return true;
 637    }
 638    const { ownerDocument } = container;
 639    const { defaultView } = ownerDocument;
 640    assertIsDefined(defaultView, "defaultView");
 641    const selection = defaultView.getSelection();
 642    if (!selection || !selection.rangeCount) {
 643      return false;
 644    }
 645    const range = selection.getRangeAt(0);
 646    const collapsedRange = range.cloneRange();
 647    const isForward = isSelectionForward(selection);
 648    const isCollapsed = selection.isCollapsed;
 649    if (!isCollapsed) {
 650      collapsedRange.collapse(!isForward);
 651    }
 652    const collapsedRangeRect = getRectangleFromRange(collapsedRange);
 653    const rangeRect = getRectangleFromRange(range);
 654    if (!collapsedRangeRect || !rangeRect) {
 655      return false;
 656    }
 657    const rangeHeight = getRangeHeight(range);
 658    if (!isCollapsed && rangeHeight && rangeHeight > collapsedRangeRect.height && isForward === isReverse) {
 659      return false;
 660    }
 661    const isReverseDir = isRTL(container) ? !isReverse : isReverse;
 662    const containerRect = container.getBoundingClientRect();
 663    const x = isReverseDir ? containerRect.left + 1 : containerRect.right - 1;
 664    const y = isReverse ? containerRect.top + 1 : containerRect.bottom - 1;
 665    const testRange = scrollIfNoRange(
 666      container,
 667      isReverse,
 668      () => hiddenCaretRangeFromPoint(ownerDocument, x, y, container)
 669    );
 670    if (!testRange) {
 671      return false;
 672    }
 673    const testRect = getRectangleFromRange(testRange);
 674    if (!testRect) {
 675      return false;
 676    }
 677    const verticalSide = isReverse ? "top" : "bottom";
 678    const horizontalSide = isReverseDir ? "left" : "right";
 679    const verticalDiff = testRect[verticalSide] - rangeRect[verticalSide];
 680    const horizontalDiff = testRect[horizontalSide] - collapsedRangeRect[horizontalSide];
 681    const hasVerticalDiff = Math.abs(verticalDiff) <= 1;
 682    const hasHorizontalDiff = Math.abs(horizontalDiff) <= 1;
 683    return onlyVertical ? hasVerticalDiff : hasVerticalDiff && hasHorizontalDiff;
 684  }
 685  
 686  
 687  ;// ./node_modules/@wordpress/dom/build-module/dom/is-horizontal-edge.js
 688  
 689  function isHorizontalEdge(container, isReverse) {
 690    return isEdge(container, isReverse);
 691  }
 692  
 693  
 694  ;// external ["wp","deprecated"]
 695  const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
 696  var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
 697  ;// ./node_modules/@wordpress/dom/build-module/dom/is-number-input.js
 698  
 699  
 700  function isNumberInput(node) {
 701    external_wp_deprecated_default()("wp.dom.isNumberInput", {
 702      since: "6.1",
 703      version: "6.5"
 704    });
 705    return isHTMLInputElement(node) && node.type === "number" && !isNaN(node.valueAsNumber);
 706  }
 707  
 708  
 709  ;// ./node_modules/@wordpress/dom/build-module/dom/is-vertical-edge.js
 710  
 711  function isVerticalEdge(container, isReverse) {
 712    return isEdge(container, isReverse, true);
 713  }
 714  
 715  
 716  ;// ./node_modules/@wordpress/dom/build-module/dom/place-caret-at-edge.js
 717  
 718  
 719  
 720  
 721  
 722  function getRange(container, isReverse, x) {
 723    const { ownerDocument } = container;
 724    const isReverseDir = isRTL(container) ? !isReverse : isReverse;
 725    const containerRect = container.getBoundingClientRect();
 726    if (x === void 0) {
 727      x = isReverse ? containerRect.right - 1 : containerRect.left + 1;
 728    } else if (x <= containerRect.left) {
 729      x = containerRect.left + 1;
 730    } else if (x >= containerRect.right) {
 731      x = containerRect.right - 1;
 732    }
 733    const y = isReverseDir ? containerRect.bottom - 1 : containerRect.top + 1;
 734    return hiddenCaretRangeFromPoint(ownerDocument, x, y, container);
 735  }
 736  function placeCaretAtEdge(container, isReverse, x) {
 737    if (!container) {
 738      return;
 739    }
 740    container.focus();
 741    if (isInputOrTextArea(container)) {
 742      if (typeof container.selectionStart !== "number") {
 743        return;
 744      }
 745      if (isReverse) {
 746        container.selectionStart = container.value.length;
 747        container.selectionEnd = container.value.length;
 748      } else {
 749        container.selectionStart = 0;
 750        container.selectionEnd = 0;
 751      }
 752      return;
 753    }
 754    if (!container.isContentEditable) {
 755      return;
 756    }
 757    const range = scrollIfNoRange(
 758      container,
 759      isReverse,
 760      () => getRange(container, isReverse, x)
 761    );
 762    if (!range) {
 763      return;
 764    }
 765    const { ownerDocument } = container;
 766    const { defaultView } = ownerDocument;
 767    assertIsDefined(defaultView, "defaultView");
 768    const selection = defaultView.getSelection();
 769    assertIsDefined(selection, "selection");
 770    selection.removeAllRanges();
 771    selection.addRange(range);
 772  }
 773  
 774  
 775  ;// ./node_modules/@wordpress/dom/build-module/dom/place-caret-at-horizontal-edge.js
 776  
 777  function placeCaretAtHorizontalEdge(container, isReverse) {
 778    return placeCaretAtEdge(container, isReverse, void 0);
 779  }
 780  
 781  
 782  ;// ./node_modules/@wordpress/dom/build-module/dom/place-caret-at-vertical-edge.js
 783  
 784  function placeCaretAtVerticalEdge(container, isReverse, rect) {
 785    return placeCaretAtEdge(container, isReverse, rect?.left);
 786  }
 787  
 788  
 789  ;// ./node_modules/@wordpress/dom/build-module/dom/insert-after.js
 790  
 791  function insertAfter(newNode, referenceNode) {
 792    assertIsDefined(referenceNode.parentNode, "referenceNode.parentNode");
 793    referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
 794  }
 795  
 796  
 797  ;// ./node_modules/@wordpress/dom/build-module/dom/remove.js
 798  
 799  function remove(node) {
 800    assertIsDefined(node.parentNode, "node.parentNode");
 801    node.parentNode.removeChild(node);
 802  }
 803  
 804  
 805  ;// ./node_modules/@wordpress/dom/build-module/dom/replace.js
 806  
 807  
 808  
 809  function replace(processedNode, newNode) {
 810    assertIsDefined(processedNode.parentNode, "processedNode.parentNode");
 811    insertAfter(newNode, processedNode.parentNode);
 812    remove(processedNode);
 813  }
 814  
 815  
 816  ;// ./node_modules/@wordpress/dom/build-module/dom/unwrap.js
 817  
 818  function unwrap(node) {
 819    const parent = node.parentNode;
 820    assertIsDefined(parent, "node.parentNode");
 821    while (node.firstChild) {
 822      parent.insertBefore(node.firstChild, node);
 823    }
 824    parent.removeChild(node);
 825  }
 826  
 827  
 828  ;// ./node_modules/@wordpress/dom/build-module/dom/replace-tag.js
 829  
 830  function replaceTag(node, tagName) {
 831    const newNode = node.ownerDocument.createElement(tagName);
 832    while (node.firstChild) {
 833      newNode.appendChild(node.firstChild);
 834    }
 835    assertIsDefined(node.parentNode, "node.parentNode");
 836    node.parentNode.replaceChild(newNode, node);
 837    return newNode;
 838  }
 839  
 840  
 841  ;// ./node_modules/@wordpress/dom/build-module/dom/wrap.js
 842  
 843  function wrap(newNode, referenceNode) {
 844    assertIsDefined(referenceNode.parentNode, "referenceNode.parentNode");
 845    referenceNode.parentNode.insertBefore(newNode, referenceNode);
 846    newNode.appendChild(referenceNode);
 847  }
 848  
 849  
 850  ;// ./node_modules/@wordpress/dom/build-module/dom/safe-html.js
 851  
 852  function safeHTML(html) {
 853    const { body } = document.implementation.createHTMLDocument("");
 854    body.innerHTML = html;
 855    const elements = body.getElementsByTagName("*");
 856    let elementIndex = elements.length;
 857    while (elementIndex--) {
 858      const element = elements[elementIndex];
 859      if (element.tagName === "SCRIPT") {
 860        remove(element);
 861      } else {
 862        let attributeIndex = element.attributes.length;
 863        while (attributeIndex--) {
 864          const { name: key } = element.attributes[attributeIndex];
 865          if (key.startsWith("on")) {
 866            element.removeAttribute(key);
 867          }
 868        }
 869      }
 870    }
 871    return body.innerHTML;
 872  }
 873  
 874  
 875  ;// ./node_modules/@wordpress/dom/build-module/dom/strip-html.js
 876  
 877  function stripHTML(html) {
 878    html = safeHTML(html);
 879    const doc = document.implementation.createHTMLDocument("");
 880    doc.body.innerHTML = html;
 881    return doc.body.textContent || "";
 882  }
 883  
 884  
 885  ;// ./node_modules/@wordpress/dom/build-module/dom/is-empty.js
 886  function isEmpty(element) {
 887    switch (element.nodeType) {
 888      case element.TEXT_NODE:
 889        return /^[ \f\n\r\t\v\u00a0]*$/.test(element.nodeValue || "");
 890      case element.ELEMENT_NODE:
 891        if (element.hasAttributes()) {
 892          return false;
 893        } else if (!element.hasChildNodes()) {
 894          return true;
 895        }
 896        return (
 897          /** @type {Element[]} */
 898          Array.from(element.childNodes).every(isEmpty)
 899        );
 900      default:
 901        return true;
 902    }
 903  }
 904  
 905  
 906  ;// ./node_modules/@wordpress/dom/build-module/phrasing-content.js
 907  const textContentSchema = {
 908    strong: {},
 909    em: {},
 910    s: {},
 911    del: {},
 912    ins: {},
 913    a: { attributes: ["href", "target", "rel", "id"] },
 914    code: {},
 915    abbr: { attributes: ["title"] },
 916    sub: {},
 917    sup: {},
 918    br: {},
 919    small: {},
 920    // To do: fix blockquote.
 921    // cite: {},
 922    q: { attributes: ["cite"] },
 923    dfn: { attributes: ["title"] },
 924    data: { attributes: ["value"] },
 925    time: { attributes: ["datetime"] },
 926    var: {},
 927    samp: {},
 928    kbd: {},
 929    i: {},
 930    b: {},
 931    u: {},
 932    mark: {},
 933    ruby: {},
 934    rt: {},
 935    rp: {},
 936    bdi: { attributes: ["dir"] },
 937    bdo: { attributes: ["dir"] },
 938    wbr: {},
 939    "#text": {}
 940  };
 941  const excludedElements = ["#text", "br"];
 942  Object.keys(textContentSchema).filter((element) => !excludedElements.includes(element)).forEach((tag) => {
 943    const { [tag]: removedTag, ...restSchema } = textContentSchema;
 944    textContentSchema[tag].children = restSchema;
 945  });
 946  const embeddedContentSchema = {
 947    audio: {
 948      attributes: [
 949        "src",
 950        "preload",
 951        "autoplay",
 952        "mediagroup",
 953        "loop",
 954        "muted"
 955      ]
 956    },
 957    canvas: { attributes: ["width", "height"] },
 958    embed: { attributes: ["src", "type", "width", "height"] },
 959    img: {
 960      attributes: [
 961        "alt",
 962        "src",
 963        "srcset",
 964        "usemap",
 965        "ismap",
 966        "width",
 967        "height"
 968      ]
 969    },
 970    object: {
 971      attributes: [
 972        "data",
 973        "type",
 974        "name",
 975        "usemap",
 976        "form",
 977        "width",
 978        "height"
 979      ]
 980    },
 981    video: {
 982      attributes: [
 983        "src",
 984        "poster",
 985        "preload",
 986        "playsinline",
 987        "autoplay",
 988        "mediagroup",
 989        "loop",
 990        "muted",
 991        "controls",
 992        "width",
 993        "height"
 994      ]
 995    },
 996    math: {
 997      attributes: ["display", "xmlns"],
 998      children: "*"
 999    }
1000  };
1001  const phrasingContentSchema = {
1002    ...textContentSchema,
1003    ...embeddedContentSchema
1004  };
1005  function getPhrasingContentSchema(context) {
1006    if (context !== "paste") {
1007      return phrasingContentSchema;
1008    }
1009    const {
1010      u,
1011      // Used to mark misspelling. Shouldn't be pasted.
1012      abbr,
1013      // Invisible.
1014      data,
1015      // Invisible.
1016      time,
1017      // Invisible.
1018      wbr,
1019      // Invisible.
1020      bdi,
1021      // Invisible.
1022      bdo,
1023      // Invisible.
1024      ...remainingContentSchema
1025    } = {
1026      ...phrasingContentSchema,
1027      // We shouldn't paste potentially sensitive information which is not
1028      // visible to the user when pasted, so strip the attributes.
1029      ins: { children: phrasingContentSchema.ins.children },
1030      del: { children: phrasingContentSchema.del.children }
1031    };
1032    return remainingContentSchema;
1033  }
1034  function isPhrasingContent(node) {
1035    const tag = node.nodeName.toLowerCase();
1036    return getPhrasingContentSchema().hasOwnProperty(tag) || tag === "span";
1037  }
1038  function isTextContent(node) {
1039    const tag = node.nodeName.toLowerCase();
1040    return textContentSchema.hasOwnProperty(tag) || tag === "span";
1041  }
1042  
1043  
1044  ;// ./node_modules/@wordpress/dom/build-module/dom/is-element.js
1045  function isElement(node) {
1046    return !!node && node.nodeType === node.ELEMENT_NODE;
1047  }
1048  
1049  
1050  ;// ./node_modules/@wordpress/dom/build-module/dom/clean-node-list.js
1051  
1052  
1053  
1054  
1055  
1056  
1057  const noop = () => {
1058  };
1059  function cleanNodeList(nodeList, doc, schema, inline) {
1060    Array.from(nodeList).forEach(
1061      (node) => {
1062        const tag = node.nodeName.toLowerCase();
1063        if (schema.hasOwnProperty(tag) && (!schema[tag].isMatch || schema[tag].isMatch?.(node))) {
1064          if (isElement(node)) {
1065            const {
1066              attributes = [],
1067              classes = [],
1068              children,
1069              require: require2 = [],
1070              allowEmpty
1071            } = schema[tag];
1072            if (children && !allowEmpty && isEmpty(node)) {
1073              remove(node);
1074              return;
1075            }
1076            if (node.hasAttributes()) {
1077              Array.from(node.attributes).forEach(({ name }) => {
1078                if (name !== "class" && !attributes.includes(name)) {
1079                  node.removeAttribute(name);
1080                }
1081              });
1082              if (node.classList && node.classList.length) {
1083                const mattchers = classes.map((item) => {
1084                  if (item === "*") {
1085                    return () => true;
1086                  } else if (typeof item === "string") {
1087                    return (className) => className === item;
1088                  } else if (item instanceof RegExp) {
1089                    return (className) => item.test(className);
1090                  }
1091                  return noop;
1092                });
1093                Array.from(node.classList).forEach((name) => {
1094                  if (!mattchers.some(
1095                    (isMatch) => isMatch(name)
1096                  )) {
1097                    node.classList.remove(name);
1098                  }
1099                });
1100                if (!node.classList.length) {
1101                  node.removeAttribute("class");
1102                }
1103              }
1104            }
1105            if (node.hasChildNodes()) {
1106              if (children === "*") {
1107                return;
1108              }
1109              if (children) {
1110                if (require2.length && !node.querySelector(require2.join(","))) {
1111                  cleanNodeList(
1112                    node.childNodes,
1113                    doc,
1114                    schema,
1115                    inline
1116                  );
1117                  unwrap(node);
1118                } else if (node.parentNode && node.parentNode.nodeName === "BODY" && isPhrasingContent(node)) {
1119                  cleanNodeList(
1120                    node.childNodes,
1121                    doc,
1122                    schema,
1123                    inline
1124                  );
1125                  if (Array.from(node.childNodes).some(
1126                    (child) => !isPhrasingContent(child)
1127                  )) {
1128                    unwrap(node);
1129                  }
1130                } else {
1131                  cleanNodeList(
1132                    node.childNodes,
1133                    doc,
1134                    children,
1135                    inline
1136                  );
1137                }
1138              } else {
1139                while (node.firstChild) {
1140                  remove(node.firstChild);
1141                }
1142              }
1143            }
1144          }
1145        } else {
1146          cleanNodeList(node.childNodes, doc, schema, inline);
1147          if (inline && !isPhrasingContent(node) && node.nextElementSibling) {
1148            insertAfter(doc.createElement("br"), node);
1149          }
1150          unwrap(node);
1151        }
1152      }
1153    );
1154  }
1155  
1156  
1157  ;// ./node_modules/@wordpress/dom/build-module/dom/remove-invalid-html.js
1158  
1159  function removeInvalidHTML(HTML, schema, inline) {
1160    const doc = document.implementation.createHTMLDocument("");
1161    doc.body.innerHTML = HTML;
1162    cleanNodeList(doc.body.childNodes, doc, schema, inline);
1163    return doc.body.innerHTML;
1164  }
1165  
1166  
1167  ;// ./node_modules/@wordpress/dom/build-module/dom/index.js
1168  
1169  
1170  
1171  
1172  
1173  
1174  
1175  
1176  
1177  
1178  
1179  
1180  
1181  
1182  
1183  
1184  
1185  
1186  
1187  
1188  
1189  
1190  
1191  
1192  
1193  
1194  
1195  
1196  
1197  ;// ./node_modules/@wordpress/dom/build-module/data-transfer.js
1198  function getFilesFromDataTransfer(dataTransfer) {
1199    const files = Array.from(dataTransfer.files);
1200    Array.from(dataTransfer.items).forEach((item) => {
1201      const file = item.getAsFile();
1202      if (file && !files.find(
1203        ({ name, type, size }) => name === file.name && type === file.type && size === file.size
1204      )) {
1205        files.push(file);
1206      }
1207    });
1208    return files;
1209  }
1210  
1211  
1212  ;// ./node_modules/@wordpress/dom/build-module/index.js
1213  
1214  
1215  const build_module_focus = { focusable: focusable_namespaceObject, tabbable: tabbable_namespaceObject };
1216  
1217  
1218  
1219  
1220  
1221  (window.wp = window.wp || {}).dom = __webpack_exports__;
1222  /******/ })()
1223  ;


Generated : Fri Dec 12 08:20:05 2025 Cross-referenced by PHPXref