[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

   1  this["wp"] = this["wp"] || {}; this["wp"]["dom"] =
   2  /******/ (function(modules) { // webpackBootstrap
   3  /******/     // The module cache
   4  /******/     var installedModules = {};
   5  /******/
   6  /******/     // The require function
   7  /******/ 	function __webpack_require__(moduleId) {
   8  /******/
   9  /******/         // Check if module is in cache
  10  /******/         if(installedModules[moduleId]) {
  11  /******/             return installedModules[moduleId].exports;
  12  /******/         }
  13  /******/         // Create a new module (and put it into the cache)
  14  /******/         var module = installedModules[moduleId] = {
  15  /******/             i: moduleId,
  16  /******/             l: false,
  17  /******/             exports: {}
  18  /******/         };
  19  /******/
  20  /******/         // Execute the module function
  21  /******/         modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22  /******/
  23  /******/         // Flag the module as loaded
  24  /******/         module.l = true;
  25  /******/
  26  /******/         // Return the exports of the module
  27  /******/         return module.exports;
  28  /******/     }
  29  /******/
  30  /******/
  31  /******/     // expose the modules object (__webpack_modules__)
  32  /******/     __webpack_require__.m = modules;
  33  /******/
  34  /******/     // expose the module cache
  35  /******/     __webpack_require__.c = installedModules;
  36  /******/
  37  /******/     // define getter function for harmony exports
  38  /******/     __webpack_require__.d = function(exports, name, getter) {
  39  /******/         if(!__webpack_require__.o(exports, name)) {
  40  /******/             Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41  /******/         }
  42  /******/     };
  43  /******/
  44  /******/     // define __esModule on exports
  45  /******/     __webpack_require__.r = function(exports) {
  46  /******/         if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47  /******/             Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48  /******/         }
  49  /******/         Object.defineProperty(exports, '__esModule', { value: true });
  50  /******/     };
  51  /******/
  52  /******/     // create a fake namespace object
  53  /******/     // mode & 1: value is a module id, require it
  54  /******/     // mode & 2: merge all properties of value into the ns
  55  /******/     // mode & 4: return value when already ns object
  56  /******/     // mode & 8|1: behave like require
  57  /******/     __webpack_require__.t = function(value, mode) {
  58  /******/         if(mode & 1) value = __webpack_require__(value);
  59  /******/         if(mode & 8) return value;
  60  /******/         if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61  /******/         var ns = Object.create(null);
  62  /******/         __webpack_require__.r(ns);
  63  /******/         Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64  /******/         if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65  /******/         return ns;
  66  /******/     };
  67  /******/
  68  /******/     // getDefaultExport function for compatibility with non-harmony modules
  69  /******/     __webpack_require__.n = function(module) {
  70  /******/         var getter = module && module.__esModule ?
  71  /******/ 			function getDefault() { return module['default']; } :
  72  /******/ 			function getModuleExports() { return module; };
  73  /******/         __webpack_require__.d(getter, 'a', getter);
  74  /******/         return getter;
  75  /******/     };
  76  /******/
  77  /******/     // Object.prototype.hasOwnProperty.call
  78  /******/     __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79  /******/
  80  /******/     // __webpack_public_path__
  81  /******/     __webpack_require__.p = "";
  82  /******/
  83  /******/
  84  /******/     // Load entry module and return exports
  85  /******/     return __webpack_require__(__webpack_require__.s = 476);
  86  /******/ })
  87  /************************************************************************/
  88  /******/ ({
  89  
  90  /***/ 15:
  91  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92  
  93  "use strict";
  94  
  95  // EXPORTS
  96  __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _toConsumableArray; });
  97  
  98  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
  99  var arrayLikeToArray = __webpack_require__(24);
 100  
 101  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
 102  
 103  function _arrayWithoutHoles(arr) {
 104    if (Array.isArray(arr)) return Object(arrayLikeToArray["a" /* default */])(arr);
 105  }
 106  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js
 107  var iterableToArray = __webpack_require__(37);
 108  
 109  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
 110  var unsupportedIterableToArray = __webpack_require__(31);
 111  
 112  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
 113  function _nonIterableSpread() {
 114    throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
 115  }
 116  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
 117  
 118  
 119  
 120  
 121  function _toConsumableArray(arr) {
 122    return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || Object(unsupportedIterableToArray["a" /* default */])(arr) || _nonIterableSpread();
 123  }
 124  
 125  /***/ }),
 126  
 127  /***/ 2:
 128  /***/ (function(module, exports) {
 129  
 130  (function() { module.exports = window["lodash"]; }());
 131  
 132  /***/ }),
 133  
 134  /***/ 24:
 135  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 136  
 137  "use strict";
 138  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayLikeToArray; });
 139  function _arrayLikeToArray(arr, len) {
 140    if (len == null || len > arr.length) len = arr.length;
 141  
 142    for (var i = 0, arr2 = new Array(len); i < len; i++) {
 143      arr2[i] = arr[i];
 144    }
 145  
 146    return arr2;
 147  }
 148  
 149  /***/ }),
 150  
 151  /***/ 31:
 152  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 153  
 154  "use strict";
 155  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; });
 156  /* harmony import */ var _babel_runtime_helpers_esm_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(24);
 157  
 158  function _unsupportedIterableToArray(o, minLen) {
 159    if (!o) return;
 160    if (typeof o === "string") return Object(_babel_runtime_helpers_esm_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
 161    var n = Object.prototype.toString.call(o).slice(8, -1);
 162    if (n === "Object" && o.constructor) n = o.constructor.name;
 163    if (n === "Map" || n === "Set") return Array.from(o);
 164    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_babel_runtime_helpers_esm_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
 165  }
 166  
 167  /***/ }),
 168  
 169  /***/ 37:
 170  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 171  
 172  "use strict";
 173  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; });
 174  function _iterableToArray(iter) {
 175    if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
 176  }
 177  
 178  /***/ }),
 179  
 180  /***/ 476:
 181  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 182  
 183  "use strict";
 184  // ESM COMPAT FLAG
 185  __webpack_require__.r(__webpack_exports__);
 186  
 187  // EXPORTS
 188  __webpack_require__.d(__webpack_exports__, "focus", function() { return /* binding */ build_module_focus; });
 189  __webpack_require__.d(__webpack_exports__, "isHorizontalEdge", function() { return /* reexport */ isHorizontalEdge; });
 190  __webpack_require__.d(__webpack_exports__, "isVerticalEdge", function() { return /* reexport */ isVerticalEdge; });
 191  __webpack_require__.d(__webpack_exports__, "getRectangleFromRange", function() { return /* reexport */ getRectangleFromRange; });
 192  __webpack_require__.d(__webpack_exports__, "computeCaretRect", function() { return /* reexport */ computeCaretRect; });
 193  __webpack_require__.d(__webpack_exports__, "placeCaretAtHorizontalEdge", function() { return /* reexport */ placeCaretAtHorizontalEdge; });
 194  __webpack_require__.d(__webpack_exports__, "placeCaretAtVerticalEdge", function() { return /* reexport */ placeCaretAtVerticalEdge; });
 195  __webpack_require__.d(__webpack_exports__, "isTextField", function() { return /* reexport */ isTextField; });
 196  __webpack_require__.d(__webpack_exports__, "isNumberInput", function() { return /* reexport */ isNumberInput; });
 197  __webpack_require__.d(__webpack_exports__, "documentHasTextSelection", function() { return /* reexport */ documentHasTextSelection; });
 198  __webpack_require__.d(__webpack_exports__, "documentHasUncollapsedSelection", function() { return /* reexport */ documentHasUncollapsedSelection; });
 199  __webpack_require__.d(__webpack_exports__, "documentHasSelection", function() { return /* reexport */ documentHasSelection; });
 200  __webpack_require__.d(__webpack_exports__, "isEntirelySelected", function() { return /* reexport */ isEntirelySelected; });
 201  __webpack_require__.d(__webpack_exports__, "getScrollContainer", function() { return /* reexport */ getScrollContainer; });
 202  __webpack_require__.d(__webpack_exports__, "getOffsetParent", function() { return /* reexport */ getOffsetParent; });
 203  __webpack_require__.d(__webpack_exports__, "replace", function() { return /* reexport */ replace; });
 204  __webpack_require__.d(__webpack_exports__, "remove", function() { return /* reexport */ remove; });
 205  __webpack_require__.d(__webpack_exports__, "insertAfter", function() { return /* reexport */ insertAfter; });
 206  __webpack_require__.d(__webpack_exports__, "unwrap", function() { return /* reexport */ unwrap; });
 207  __webpack_require__.d(__webpack_exports__, "replaceTag", function() { return /* reexport */ replaceTag; });
 208  __webpack_require__.d(__webpack_exports__, "wrap", function() { return /* reexport */ wrap; });
 209  __webpack_require__.d(__webpack_exports__, "__unstableStripHTML", function() { return /* reexport */ __unstableStripHTML; });
 210  __webpack_require__.d(__webpack_exports__, "isEmpty", function() { return /* reexport */ isEmpty; });
 211  __webpack_require__.d(__webpack_exports__, "removeInvalidHTML", function() { return /* reexport */ removeInvalidHTML; });
 212  __webpack_require__.d(__webpack_exports__, "getPhrasingContentSchema", function() { return /* reexport */ getPhrasingContentSchema; });
 213  __webpack_require__.d(__webpack_exports__, "isPhrasingContent", function() { return /* reexport */ isPhrasingContent; });
 214  __webpack_require__.d(__webpack_exports__, "isTextContent", function() { return /* reexport */ isTextContent; });
 215  __webpack_require__.d(__webpack_exports__, "getFilesFromDataTransfer", function() { return /* reexport */ getFilesFromDataTransfer; });
 216  
 217  // NAMESPACE OBJECT: ./node_modules/@wordpress/dom/build-module/focusable.js
 218  var focusable_namespaceObject = {};
 219  __webpack_require__.r(focusable_namespaceObject);
 220  __webpack_require__.d(focusable_namespaceObject, "find", function() { return find; });
 221  
 222  // NAMESPACE OBJECT: ./node_modules/@wordpress/dom/build-module/tabbable.js
 223  var tabbable_namespaceObject = {};
 224  __webpack_require__.r(tabbable_namespaceObject);
 225  __webpack_require__.d(tabbable_namespaceObject, "isTabbableIndex", function() { return isTabbableIndex; });
 226  __webpack_require__.d(tabbable_namespaceObject, "find", function() { return tabbable_find; });
 227  __webpack_require__.d(tabbable_namespaceObject, "findPrevious", function() { return findPrevious; });
 228  __webpack_require__.d(tabbable_namespaceObject, "findNext", function() { return findNext; });
 229  
 230  // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/focusable.js
 231  /**
 232   * References:
 233   *
 234   * Focusable:
 235   *  - https://www.w3.org/TR/html5/editing.html#focus-management
 236   *
 237   * Sequential focus navigation:
 238   *  - https://www.w3.org/TR/html5/editing.html#sequential-focus-navigation-and-the-tabindex-attribute
 239   *
 240   * Disabled elements:
 241   *  - https://www.w3.org/TR/html5/disabled-elements.html#disabled-elements
 242   *
 243   * getClientRects algorithm (requiring layout box):
 244   *  - https://www.w3.org/TR/cssom-view-1/#extension-to-the-element-interface
 245   *
 246   * AREA elements associated with an IMG:
 247   *  - https://w3c.github.io/html/editing.html#data-model
 248   */
 249  var SELECTOR = ['[tabindex]', 'a[href]', 'button:not([disabled])', 'input:not([type="hidden"]):not([disabled])', 'select:not([disabled])', 'textarea:not([disabled])', 'iframe', 'object', 'embed', 'area[href]', '[contenteditable]:not([contenteditable=false])'].join(',');
 250  /**
 251   * Returns true if the specified element is visible (i.e. neither display: none
 252   * nor visibility: hidden).
 253   *
 254   * @param {Element} element DOM element to test.
 255   *
 256   * @return {boolean} Whether element is visible.
 257   */
 258  
 259  function isVisible(element) {
 260    return element.offsetWidth > 0 || element.offsetHeight > 0 || element.getClientRects().length > 0;
 261  }
 262  /**
 263   * Returns true if the specified element should be skipped from focusable elements.
 264   * For now it rather specific for `iframes` and  if tabindex attribute is set to -1.
 265   *
 266   * @param {Element} element DOM element to test.
 267   *
 268   * @return {boolean} Whether element should be skipped from focusable elements.
 269   */
 270  
 271  
 272  function skipFocus(element) {
 273    return element.nodeName.toLowerCase() === 'iframe' && element.getAttribute('tabindex') === '-1';
 274  }
 275  /**
 276   * Returns true if the specified area element is a valid focusable element, or
 277   * false otherwise. Area is only focusable if within a map where a named map
 278   * referenced by an image somewhere in the document.
 279   *
 280   * @param {Element} element DOM area element to test.
 281   *
 282   * @return {boolean} Whether area element is valid for focus.
 283   */
 284  
 285  
 286  function isValidFocusableArea(element) {
 287    var map = element.closest('map[name]');
 288  
 289    if (!map) {
 290      return false;
 291    }
 292  
 293    var img = element.ownerDocument.querySelector('img[usemap="#' + map.name + '"]');
 294    return !!img && isVisible(img);
 295  }
 296  /**
 297   * Returns all focusable elements within a given context.
 298   *
 299   * @param {Element} context Element in which to search.
 300   *
 301   * @return {Element[]} Focusable elements.
 302   */
 303  
 304  
 305  function find(context) {
 306    var elements = context.querySelectorAll(SELECTOR);
 307    return Array.from(elements).filter(function (element) {
 308      if (!isVisible(element) || skipFocus(element)) {
 309        return false;
 310      }
 311  
 312      var nodeName = element.nodeName;
 313  
 314      if ('AREA' === nodeName) {
 315        return isValidFocusableArea(element);
 316      }
 317  
 318      return true;
 319    });
 320  }
 321  
 322  // EXTERNAL MODULE: external "lodash"
 323  var external_lodash_ = __webpack_require__(2);
 324  
 325  // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/tabbable.js
 326  /**
 327   * External dependencies
 328   */
 329  
 330  /**
 331   * Internal dependencies
 332   */
 333  
 334  
 335  /**
 336   * Returns the tab index of the given element. In contrast with the tabIndex
 337   * property, this normalizes the default (0) to avoid browser inconsistencies,
 338   * operating under the assumption that this function is only ever called with a
 339   * focusable node.
 340   *
 341   * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1190261
 342   *
 343   * @param {Element} element Element from which to retrieve.
 344   *
 345   * @return {?number} Tab index of element (default 0).
 346   */
 347  
 348  function getTabIndex(element) {
 349    var tabIndex = element.getAttribute('tabindex');
 350    return tabIndex === null ? 0 : parseInt(tabIndex, 10);
 351  }
 352  /**
 353   * Returns true if the specified element is tabbable, or false otherwise.
 354   *
 355   * @param {Element} element Element to test.
 356   *
 357   * @return {boolean} Whether element is tabbable.
 358   */
 359  
 360  
 361  function isTabbableIndex(element) {
 362    return getTabIndex(element) !== -1;
 363  }
 364  /**
 365   * Returns a stateful reducer function which constructs a filtered array of
 366   * tabbable elements, where at most one radio input is selected for a given
 367   * name, giving priority to checked input, falling back to the first
 368   * encountered.
 369   *
 370   * @return {Function} Radio group collapse reducer.
 371   */
 372  
 373  function createStatefulCollapseRadioGroup() {
 374    var CHOSEN_RADIO_BY_NAME = {};
 375    return function collapseRadioGroup(result, element) {
 376      var nodeName = element.nodeName,
 377          type = element.type,
 378          checked = element.checked,
 379          name = element.name; // For all non-radio tabbables, construct to array by concatenating.
 380  
 381      if (nodeName !== 'INPUT' || type !== 'radio' || !name) {
 382        return result.concat(element);
 383      }
 384  
 385      var hasChosen = CHOSEN_RADIO_BY_NAME.hasOwnProperty(name); // Omit by skipping concatenation if the radio element is not chosen.
 386  
 387      var isChosen = checked || !hasChosen;
 388  
 389      if (!isChosen) {
 390        return result;
 391      } // At this point, if there had been a chosen element, the current
 392      // element is checked and should take priority. Retroactively remove
 393      // the element which had previously been considered the chosen one.
 394  
 395  
 396      if (hasChosen) {
 397        var hadChosenElement = CHOSEN_RADIO_BY_NAME[name];
 398        result = Object(external_lodash_["without"])(result, hadChosenElement);
 399      }
 400  
 401      CHOSEN_RADIO_BY_NAME[name] = element;
 402      return result.concat(element);
 403    };
 404  }
 405  /**
 406   * An array map callback, returning an object with the element value and its
 407   * array index location as properties. This is used to emulate a proper stable
 408   * sort where equal tabIndex should be left in order of their occurrence in the
 409   * document.
 410   *
 411   * @param {Element} element Element.
 412   * @param {number}  index   Array index of element.
 413   *
 414   * @return {Object} Mapped object with element, index.
 415   */
 416  
 417  
 418  function mapElementToObjectTabbable(element, index) {
 419    return {
 420      element: element,
 421      index: index
 422    };
 423  }
 424  /**
 425   * An array map callback, returning an element of the given mapped object's
 426   * element value.
 427   *
 428   * @param {Object} object Mapped object with index.
 429   *
 430   * @return {Element} Mapped object element.
 431   */
 432  
 433  
 434  function mapObjectTabbableToElement(object) {
 435    return object.element;
 436  }
 437  /**
 438   * A sort comparator function used in comparing two objects of mapped elements.
 439   *
 440   * @see mapElementToObjectTabbable
 441   *
 442   * @param {Object} a First object to compare.
 443   * @param {Object} b Second object to compare.
 444   *
 445   * @return {number} Comparator result.
 446   */
 447  
 448  
 449  function compareObjectTabbables(a, b) {
 450    var aTabIndex = getTabIndex(a.element);
 451    var bTabIndex = getTabIndex(b.element);
 452  
 453    if (aTabIndex === bTabIndex) {
 454      return a.index - b.index;
 455    }
 456  
 457    return aTabIndex - bTabIndex;
 458  }
 459  /**
 460   * Givin focusable elements, filters out tabbable element.
 461   *
 462   * @param {Array} focusables Focusable elements to filter.
 463   *
 464   * @return {Array} Tabbable elements.
 465   */
 466  
 467  
 468  function filterTabbable(focusables) {
 469    return focusables.filter(isTabbableIndex).map(mapElementToObjectTabbable).sort(compareObjectTabbables).map(mapObjectTabbableToElement).reduce(createStatefulCollapseRadioGroup(), []);
 470  }
 471  
 472  function tabbable_find(context) {
 473    return filterTabbable(find(context));
 474  }
 475  /**
 476   * Given a focusable element, find the preceding tabbable element.
 477   *
 478   * @param {Element} element The focusable element before which to look. Defaults
 479   *                          to the active element.
 480   */
 481  
 482  function findPrevious(element) {
 483    var focusables = find(element.ownerDocument.body);
 484    var index = focusables.indexOf(element); // Remove all focusables after and including `element`.
 485  
 486    focusables.length = index;
 487    return Object(external_lodash_["last"])(filterTabbable(focusables));
 488  }
 489  /**
 490   * Given a focusable element, find the next tabbable element.
 491   *
 492   * @param {Element} element The focusable element after which to look. Defaults
 493   *                          to the active element.
 494   */
 495  
 496  function findNext(element) {
 497    var focusables = find(element.ownerDocument.body);
 498    var index = focusables.indexOf(element); // Remove all focusables before and inside `element`.
 499  
 500    var remaining = focusables.slice(index + 1).filter(function (node) {
 501      return !element.contains(node);
 502    });
 503    return Object(external_lodash_["first"])(filterTabbable(remaining));
 504  }
 505  
 506  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules
 507  var toConsumableArray = __webpack_require__(15);
 508  
 509  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
 510  var defineProperty = __webpack_require__(5);
 511  
 512  // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/phrasing-content.js
 513  
 514  
 515  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
 516  
 517  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
 518  
 519  /**
 520   * External dependencies
 521   */
 522  
 523  /**
 524   * All phrasing content elements.
 525   *
 526   * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0
 527   */
 528  
 529  /**
 530   * All text-level semantic elements.
 531   *
 532   * @see https://html.spec.whatwg.org/multipage/text-level-semantics.html
 533   */
 534  
 535  var textContentSchema = {
 536    strong: {},
 537    em: {},
 538    s: {},
 539    del: {},
 540    ins: {},
 541    a: {
 542      attributes: ['href', 'target', 'rel']
 543    },
 544    code: {},
 545    abbr: {
 546      attributes: ['title']
 547    },
 548    sub: {},
 549    sup: {},
 550    br: {},
 551    small: {},
 552    // To do: fix blockquote.
 553    // cite: {},
 554    q: {
 555      attributes: ['cite']
 556    },
 557    dfn: {
 558      attributes: ['title']
 559    },
 560    data: {
 561      attributes: ['value']
 562    },
 563    time: {
 564      attributes: ['datetime']
 565    },
 566    var: {},
 567    samp: {},
 568    kbd: {},
 569    i: {},
 570    b: {},
 571    u: {},
 572    mark: {},
 573    ruby: {},
 574    rt: {},
 575    rp: {},
 576    bdi: {
 577      attributes: ['dir']
 578    },
 579    bdo: {
 580      attributes: ['dir']
 581    },
 582    wbr: {},
 583    '#text': {}
 584  }; // Recursion is needed.
 585  // Possible: strong > em > strong.
 586  // Impossible: strong > strong.
 587  
 588  Object(external_lodash_["without"])(Object.keys(textContentSchema), '#text', 'br').forEach(function (tag) {
 589    textContentSchema[tag].children = Object(external_lodash_["omit"])(textContentSchema, tag);
 590  });
 591  /**
 592   * Embedded content elements.
 593   *
 594   * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#embedded-content-0
 595   */
 596  
 597  var embeddedContentSchema = {
 598    audio: {
 599      attributes: ['src', 'preload', 'autoplay', 'mediagroup', 'loop', 'muted']
 600    },
 601    canvas: {
 602      attributes: ['width', 'height']
 603    },
 604    embed: {
 605      attributes: ['src', 'type', 'width', 'height']
 606    },
 607    img: {
 608      attributes: ['alt', 'src', 'srcset', 'usemap', 'ismap', 'width', 'height']
 609    },
 610    object: {
 611      attributes: ['data', 'type', 'name', 'usemap', 'form', 'width', 'height']
 612    },
 613    video: {
 614      attributes: ['src', 'poster', 'preload', 'autoplay', 'mediagroup', 'loop', 'muted', 'controls', 'width', 'height']
 615    }
 616  };
 617  /**
 618   * Phrasing content elements.
 619   *
 620   * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#phrasing-content-0
 621   */
 622  
 623  var phrasingContentSchema = _objectSpread(_objectSpread({}, textContentSchema), embeddedContentSchema);
 624  /**
 625   * Get schema of possible paths for phrasing content.
 626   *
 627   * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content
 628   *
 629   * @param {string} context Set to "paste" to exclude invisible elements and
 630   *                         sensitive data.
 631   *
 632   * @return {Object} Schema.
 633   */
 634  
 635  
 636  function getPhrasingContentSchema(context) {
 637    if (context !== 'paste') {
 638      return phrasingContentSchema;
 639    }
 640  
 641    return Object(external_lodash_["omit"])(_objectSpread(_objectSpread({}, phrasingContentSchema), {}, {
 642      // We shouldn't paste potentially sensitive information which is not
 643      // visible to the user when pasted, so strip the attributes.
 644      ins: {
 645        children: phrasingContentSchema.ins.children
 646      },
 647      del: {
 648        children: phrasingContentSchema.del.children
 649      }
 650    }), ['u', // Used to mark misspelling. Shouldn't be pasted.
 651    'abbr', // Invisible.
 652    'data', // Invisible.
 653    'time', // Invisible.
 654    'wbr', // Invisible.
 655    'bdi', // Invisible.
 656    'bdo' // Invisible.
 657    ]);
 658  }
 659  /**
 660   * Find out whether or not the given node is phrasing content.
 661   *
 662   * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content
 663   *
 664   * @param {Element} node The node to test.
 665   *
 666   * @return {boolean} True if phrasing content, false if not.
 667   */
 668  
 669  function isPhrasingContent(node) {
 670    var tag = node.nodeName.toLowerCase();
 671    return getPhrasingContentSchema().hasOwnProperty(tag) || tag === 'span';
 672  }
 673  function isTextContent(node) {
 674    var tag = node.nodeName.toLowerCase();
 675    return textContentSchema.hasOwnProperty(tag) || tag === 'span';
 676  }
 677  
 678  // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom.js
 679  
 680  
 681  /**
 682   * External dependencies
 683   */
 684  
 685  /**
 686   * Internal dependencies
 687   */
 688  
 689  
 690  
 691  function getComputedStyle(node) {
 692    return node.ownerDocument.defaultView.getComputedStyle(node);
 693  }
 694  /**
 695   * Gets the height of the range without ignoring zero width rectangles, which
 696   * some browsers ignore when creating a union.
 697   *
 698   * @param {Range} range The range to check.
 699   */
 700  
 701  
 702  function getRangeHeight(range) {
 703    var rects = Array.from(range.getClientRects());
 704  
 705    if (!rects.length) {
 706      return;
 707    }
 708  
 709    var highestTop = Math.min.apply(Math, Object(toConsumableArray["a" /* default */])(rects.map(function (_ref) {
 710      var top = _ref.top;
 711      return top;
 712    })));
 713    var lowestBottom = Math.max.apply(Math, Object(toConsumableArray["a" /* default */])(rects.map(function (_ref2) {
 714      var bottom = _ref2.bottom;
 715      return bottom;
 716    })));
 717    return lowestBottom - highestTop;
 718  }
 719  /**
 720   * Returns true if the given selection object is in the forward direction, or
 721   * false otherwise.
 722   *
 723   * @see https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
 724   *
 725   * @param {Selection} selection Selection object to check.
 726   *
 727   * @return {boolean} Whether the selection is forward.
 728   */
 729  
 730  
 731  function isSelectionForward(selection) {
 732    var anchorNode = selection.anchorNode,
 733        focusNode = selection.focusNode,
 734        anchorOffset = selection.anchorOffset,
 735        focusOffset = selection.focusOffset;
 736    var position = anchorNode.compareDocumentPosition(focusNode); // Disable reason: `Node#compareDocumentPosition` returns a bitmask value,
 737    // so bitwise operators are intended.
 738  
 739    /* eslint-disable no-bitwise */
 740    // Compare whether anchor node precedes focus node. If focus node (where
 741    // end of selection occurs) is after the anchor node, it is forward.
 742  
 743    if (position & anchorNode.DOCUMENT_POSITION_PRECEDING) {
 744      return false;
 745    }
 746  
 747    if (position & anchorNode.DOCUMENT_POSITION_FOLLOWING) {
 748      return true;
 749    }
 750    /* eslint-enable no-bitwise */
 751    // `compareDocumentPosition` returns 0 when passed the same node, in which
 752    // case compare offsets.
 753  
 754  
 755    if (position === 0) {
 756      return anchorOffset <= focusOffset;
 757    } // This should never be reached, but return true as default case.
 758  
 759  
 760    return true;
 761  }
 762  /**
 763   * Check whether the selection is at the edge of the container. Checks for
 764   * horizontal position by default. Set `onlyVertical` to true to check only
 765   * vertically.
 766   *
 767   * @param {Element} container    Focusable element.
 768   * @param {boolean} isReverse    Set to true to check left, false to check right.
 769   * @param {boolean} onlyVertical Set to true to check only vertical position.
 770   *
 771   * @return {boolean} True if at the edge, false if not.
 772   */
 773  
 774  
 775  function isEdge(container, isReverse, onlyVertical) {
 776    if (Object(external_lodash_["includes"])(['INPUT', 'TEXTAREA'], container.tagName)) {
 777      if (container.selectionStart !== container.selectionEnd) {
 778        return false;
 779      }
 780  
 781      if (isReverse) {
 782        return container.selectionStart === 0;
 783      }
 784  
 785      return container.value.length === container.selectionStart;
 786    }
 787  
 788    if (!container.isContentEditable) {
 789      return true;
 790    }
 791  
 792    var ownerDocument = container.ownerDocument;
 793    var defaultView = ownerDocument.defaultView;
 794    var selection = defaultView.getSelection();
 795  
 796    if (!selection.rangeCount) {
 797      return false;
 798    }
 799  
 800    var range = selection.getRangeAt(0);
 801    var collapsedRange = range.cloneRange();
 802    var isForward = isSelectionForward(selection);
 803    var isCollapsed = selection.isCollapsed; // Collapse in direction of selection.
 804  
 805    if (!isCollapsed) {
 806      collapsedRange.collapse(!isForward);
 807    }
 808  
 809    var collapsedRangeRect = getRectangleFromRange(collapsedRange);
 810    var rangeRect = getRectangleFromRange(range);
 811  
 812    if (!collapsedRangeRect || !rangeRect) {
 813      return false;
 814    } // Only consider the multiline selection at the edge if the direction is
 815    // towards the edge. The selection is multiline if it is taller than the
 816    // collapsed  selection.
 817  
 818  
 819    if (!isCollapsed && getRangeHeight(range) > collapsedRangeRect.height && isForward === isReverse) {
 820      return false;
 821    } // In the case of RTL scripts, the horizontal edge is at the opposite side.
 822  
 823  
 824    var _getComputedStyle = getComputedStyle(container),
 825        direction = _getComputedStyle.direction;
 826  
 827    var isReverseDir = direction === 'rtl' ? !isReverse : isReverse;
 828    var containerRect = container.getBoundingClientRect(); // To check if a selection is at the edge, we insert a test selection at the
 829    // edge of the container and check if the selections have the same vertical
 830    // or horizontal position. If they do, the selection is at the edge.
 831    // This method proves to be better than a DOM-based calculation for the
 832    // horizontal edge, since it ignores empty textnodes and a trailing line
 833    // break element. In other words, we need to check visual positioning, not
 834    // DOM positioning.
 835    // It also proves better than using the computed style for the vertical
 836    // edge, because we cannot know the padding and line height reliably in
 837    // pixels. `getComputedStyle` may return a value with different units.
 838  
 839    var x = isReverseDir ? containerRect.left + 1 : containerRect.right - 1;
 840    var y = isReverse ? containerRect.top + 1 : containerRect.bottom - 1;
 841    var testRange = hiddenCaretRangeFromPoint(ownerDocument, x, y, container);
 842  
 843    if (!testRange) {
 844      return false;
 845    }
 846  
 847    var testRect = getRectangleFromRange(testRange);
 848  
 849    if (!testRect) {
 850      return false;
 851    }
 852  
 853    var verticalSide = isReverse ? 'top' : 'bottom';
 854    var horizontalSide = isReverseDir ? 'left' : 'right';
 855    var verticalDiff = testRect[verticalSide] - rangeRect[verticalSide];
 856    var horizontalDiff = testRect[horizontalSide] - collapsedRangeRect[horizontalSide]; // Allow the position to be 1px off.
 857  
 858    var hasVerticalDiff = Math.abs(verticalDiff) <= 1;
 859    var hasHorizontalDiff = Math.abs(horizontalDiff) <= 1;
 860    return onlyVertical ? hasVerticalDiff : hasVerticalDiff && hasHorizontalDiff;
 861  }
 862  /**
 863   * Check whether the selection is horizontally at the edge of the container.
 864   *
 865   * @param {Element} container Focusable element.
 866   * @param {boolean} isReverse Set to true to check left, false for right.
 867   *
 868   * @return {boolean} True if at the horizontal edge, false if not.
 869   */
 870  
 871  
 872  function isHorizontalEdge(container, isReverse) {
 873    return isEdge(container, isReverse);
 874  }
 875  /**
 876   * Check whether the selection is vertically at the edge of the container.
 877   *
 878   * @param {Element} container Focusable element.
 879   * @param {boolean} isReverse Set to true to check top, false for bottom.
 880   *
 881   * @return {boolean} True if at the vertical edge, false if not.
 882   */
 883  
 884  function isVerticalEdge(container, isReverse) {
 885    return isEdge(container, isReverse, true);
 886  }
 887  /**
 888   * Get the rectangle of a given Range.
 889   *
 890   * @param {Range} range The range.
 891   *
 892   * @return {DOMRect} The rectangle.
 893   */
 894  
 895  function getRectangleFromRange(range) {
 896    // For uncollapsed ranges, get the rectangle that bounds the contents of the
 897    // range; this a rectangle enclosing the union of the bounding rectangles
 898    // for all the elements in the range.
 899    if (!range.collapsed) {
 900      return range.getBoundingClientRect();
 901    }
 902  
 903    var _range = range,
 904        startContainer = _range.startContainer;
 905    var ownerDocument = startContainer.ownerDocument; // Correct invalid "BR" ranges. The cannot contain any children.
 906  
 907    if (startContainer.nodeName === 'BR') {
 908      var parentNode = startContainer.parentNode;
 909      var index = Array.from(parentNode.childNodes).indexOf(startContainer);
 910      range = ownerDocument.createRange();
 911      range.setStart(parentNode, index);
 912      range.setEnd(parentNode, index);
 913    }
 914  
 915    var rect = range.getClientRects()[0]; // If the collapsed range starts (and therefore ends) at an element node,
 916    // `getClientRects` can be empty in some browsers. This can be resolved
 917    // by adding a temporary text node with zero-width space to the range.
 918    //
 919    // See: https://stackoverflow.com/a/6847328/995445
 920  
 921    if (!rect) {
 922      var padNode = ownerDocument.createTextNode("\u200B"); // Do not modify the live range.
 923  
 924      range = range.cloneRange();
 925      range.insertNode(padNode);
 926      rect = range.getClientRects()[0];
 927      padNode.parentNode.removeChild(padNode);
 928    }
 929  
 930    return rect;
 931  }
 932  /**
 933   * Get the rectangle for the selection in a container.
 934   *
 935   * @param {Window} win The window of the selection.
 936   *
 937   * @return {?DOMRect} The rectangle.
 938   */
 939  
 940  function computeCaretRect(win) {
 941    var selection = win.getSelection();
 942    var range = selection.rangeCount ? selection.getRangeAt(0) : null;
 943  
 944    if (!range) {
 945      return;
 946    }
 947  
 948    return getRectangleFromRange(range);
 949  }
 950  /**
 951   * Places the caret at start or end of a given element.
 952   *
 953   * @param {Element} container Focusable element.
 954   * @param {boolean} isReverse True for end, false for start.
 955   */
 956  
 957  function placeCaretAtHorizontalEdge(container, isReverse) {
 958    if (!container) {
 959      return;
 960    }
 961  
 962    if (Object(external_lodash_["includes"])(['INPUT', 'TEXTAREA'], container.tagName)) {
 963      container.focus();
 964  
 965      if (isReverse) {
 966        container.selectionStart = container.value.length;
 967        container.selectionEnd = container.value.length;
 968      } else {
 969        container.selectionStart = 0;
 970        container.selectionEnd = 0;
 971      }
 972  
 973      return;
 974    }
 975  
 976    container.focus();
 977  
 978    if (!container.isContentEditable) {
 979      return;
 980    } // Select on extent child of the container, not the container itself. This
 981    // avoids the selection always being `endOffset` of 1 when placed at end,
 982    // where `startContainer`, `endContainer` would always be container itself.
 983  
 984  
 985    var rangeTarget = container[isReverse ? 'lastChild' : 'firstChild']; // If no range target, it implies that the container is empty. Focusing is
 986    // sufficient for caret to be placed correctly.
 987  
 988    if (!rangeTarget) {
 989      return;
 990    }
 991  
 992    var ownerDocument = container.ownerDocument;
 993    var defaultView = ownerDocument.defaultView;
 994    var selection = defaultView.getSelection();
 995    var range = ownerDocument.createRange();
 996    range.selectNodeContents(rangeTarget);
 997    range.collapse(!isReverse);
 998    selection.removeAllRanges();
 999    selection.addRange(range);
1000  }
1001  /**
1002   * Polyfill.
1003   * Get a collapsed range for a given point.
1004   *
1005   * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint
1006   *
1007   * @param {Document} doc  The document of the range.
1008   * @param {number}   x    Horizontal position within the current viewport.
1009   * @param {number}   y    Vertical position within the current viewport.
1010   *
1011   * @return {?Range} The best range for the given point.
1012   */
1013  
1014  function caretRangeFromPoint(doc, x, y) {
1015    if (doc.caretRangeFromPoint) {
1016      return doc.caretRangeFromPoint(x, y);
1017    }
1018  
1019    if (!doc.caretPositionFromPoint) {
1020      return null;
1021    }
1022  
1023    var point = doc.caretPositionFromPoint(x, y); // If x or y are negative, outside viewport, or there is no text entry node.
1024    // https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint
1025  
1026    if (!point) {
1027      return null;
1028    }
1029  
1030    var range = doc.createRange();
1031    range.setStart(point.offsetNode, point.offset);
1032    range.collapse(true);
1033    return range;
1034  }
1035  /**
1036   * Get a collapsed range for a given point.
1037   * Gives the container a temporary high z-index (above any UI).
1038   * This is preferred over getting the UI nodes and set styles there.
1039   *
1040   * @param {Document} doc       The document of the range.
1041   * @param {number}    x         Horizontal position within the current viewport.
1042   * @param {number}    y         Vertical position within the current viewport.
1043   * @param {Element}  container Container in which the range is expected to be found.
1044   *
1045   * @return {?Range} The best range for the given point.
1046   */
1047  
1048  
1049  function hiddenCaretRangeFromPoint(doc, x, y, container) {
1050    var originalZIndex = container.style.zIndex;
1051    var originalPosition = container.style.position; // A z-index only works if the element position is not static.
1052  
1053    container.style.zIndex = '10000';
1054    container.style.position = 'relative';
1055    var range = caretRangeFromPoint(doc, x, y);
1056    container.style.zIndex = originalZIndex;
1057    container.style.position = originalPosition;
1058    return range;
1059  }
1060  /**
1061   * Places the caret at the top or bottom of a given element.
1062   *
1063   * @param {Element} container           Focusable element.
1064   * @param {boolean} isReverse           True for bottom, false for top.
1065   * @param {DOMRect} [rect]              The rectangle to position the caret with.
1066   * @param {boolean} [mayUseScroll=true] True to allow scrolling, false to disallow.
1067   */
1068  
1069  
1070  function placeCaretAtVerticalEdge(container, isReverse, rect) {
1071    var mayUseScroll = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
1072  
1073    if (!container) {
1074      return;
1075    }
1076  
1077    if (!rect || !container.isContentEditable) {
1078      placeCaretAtHorizontalEdge(container, isReverse);
1079      return;
1080    } // Offset by a buffer half the height of the caret rect. This is needed
1081    // because caretRangeFromPoint may default to the end of the selection if
1082    // offset is too close to the edge. It's unclear how to precisely calculate
1083    // this threshold; it may be the padded area of some combination of line
1084    // height, caret height, and font size. The buffer offset is effectively
1085    // equivalent to a point at half the height of a line of text.
1086  
1087  
1088    var buffer = rect.height / 2;
1089    var editableRect = container.getBoundingClientRect();
1090    var x = rect.left;
1091    var y = isReverse ? editableRect.bottom - buffer : editableRect.top + buffer;
1092    var ownerDocument = container.ownerDocument;
1093    var defaultView = ownerDocument.defaultView;
1094    var range = hiddenCaretRangeFromPoint(ownerDocument, x, y, container);
1095  
1096    if (!range || !container.contains(range.startContainer)) {
1097      if (mayUseScroll && (!range || !range.startContainer || !range.startContainer.contains(container))) {
1098        // Might be out of view.
1099        // Easier than attempting to calculate manually.
1100        container.scrollIntoView(isReverse);
1101        placeCaretAtVerticalEdge(container, isReverse, rect, false);
1102        return;
1103      }
1104  
1105      placeCaretAtHorizontalEdge(container, isReverse);
1106      return;
1107    }
1108  
1109    var selection = defaultView.getSelection();
1110    selection.removeAllRanges();
1111    selection.addRange(range);
1112    container.focus(); // Editable was already focussed, it goes back to old range...
1113    // This fixes it.
1114  
1115    selection.removeAllRanges();
1116    selection.addRange(range);
1117  }
1118  /**
1119   * Check whether the given element is a text field, where text field is defined
1120   * by the ability to select within the input, or that it is contenteditable.
1121   *
1122   * See: https://html.spec.whatwg.org/#textFieldSelection
1123   *
1124   * @param {HTMLElement} element The HTML element.
1125   *
1126   * @return {boolean} True if the element is an text field, false if not.
1127   */
1128  
1129  function isTextField(element) {
1130    var nodeName = element.nodeName,
1131        contentEditable = element.contentEditable;
1132    var nonTextInputs = ['button', 'checkbox', 'hidden', 'file', 'radio', 'image', 'range', 'reset', 'submit', 'number'];
1133    return nodeName === 'INPUT' && !nonTextInputs.includes(element.type) || nodeName === 'TEXTAREA' || contentEditable === 'true';
1134  }
1135  /**
1136   * Check whether the given element is an input field of type number
1137   * and has a valueAsNumber
1138   *
1139   * @param {HTMLElement} element The HTML element.
1140   *
1141   * @return {boolean} True if the element is input and holds a number.
1142   */
1143  
1144  function isNumberInput(element) {
1145    var nodeName = element.nodeName,
1146        type = element.type,
1147        valueAsNumber = element.valueAsNumber;
1148    return nodeName === 'INPUT' && type === 'number' && !!valueAsNumber;
1149  }
1150  /**
1151   * Check whether the current document has selected text. This applies to ranges
1152   * of text in the document, and not selection inside <input> and <textarea>
1153   * elements.
1154   *
1155   * See: https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection#Related_objects.
1156   *
1157   * @param {Document} doc The document to check.
1158   *
1159   * @return {boolean} True if there is selection, false if not.
1160   */
1161  
1162  function documentHasTextSelection(doc) {
1163    var selection = doc.defaultView.getSelection();
1164    var range = selection.rangeCount ? selection.getRangeAt(0) : null;
1165    return range && !range.collapsed;
1166  }
1167  /**
1168   * Check whether the given element, assumed an input field or textarea,
1169   * contains a (uncollapsed) selection of text.
1170   *
1171   * Note: this is perhaps an abuse of the term "selection", since these elements
1172   * manage selection differently and aren't covered by Selection#collapsed.
1173   *
1174   * See: https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection#Related_objects.
1175   *
1176   * @param {HTMLElement} element The HTML element.
1177   *
1178   * @return {boolean} Whether the input/textareaa element has some "selection".
1179   */
1180  
1181  function inputFieldHasUncollapsedSelection(element) {
1182    if (!isTextField(element) && !isNumberInput(element)) {
1183      return false;
1184    }
1185  
1186    try {
1187      var selectionStart = element.selectionStart,
1188          selectionEnd = element.selectionEnd;
1189      return selectionStart !== null && selectionStart !== selectionEnd;
1190    } catch (error) {
1191      // Safari throws an exception when trying to get `selectionStart`
1192      // on non-text <input> elements (which, understandably, don't
1193      // have the text selection API). We catch this via a try/catch
1194      // block, as opposed to a more explicit check of the element's
1195      // input types, because of Safari's non-standard behavior. This
1196      // also means we don't have to worry about the list of input
1197      // types that support `selectionStart` changing as the HTML spec
1198      // evolves over time.
1199      return false;
1200    }
1201  }
1202  /**
1203   * Check whether the current document has any sort of selection. This includes
1204   * ranges of text across elements and any selection inside <input> and
1205   * <textarea> elements.
1206   *
1207   * @param {Document} doc The document to check.
1208   *
1209   * @return {boolean} Whether there is any sort of "selection" in the document.
1210   */
1211  
1212  
1213  function documentHasUncollapsedSelection(doc) {
1214    return documentHasTextSelection(doc) || inputFieldHasUncollapsedSelection(doc.activeElement);
1215  }
1216  /**
1217   * Check whether the current document has a selection. This checks for both
1218   * focus in an input field and general text selection.
1219   *
1220   * @param {Document} doc The document to check.
1221   *
1222   * @return {boolean} True if there is selection, false if not.
1223   */
1224  
1225  function documentHasSelection(doc) {
1226    return isTextField(doc.activeElement) || isNumberInput(doc.activeElement) || documentHasTextSelection(doc);
1227  }
1228  /**
1229   * Check whether the contents of the element have been entirely selected.
1230   * Returns true if there is no possibility of selection.
1231   *
1232   * @param {Element} element The element to check.
1233   *
1234   * @return {boolean} True if entirely selected, false if not.
1235   */
1236  
1237  function isEntirelySelected(element) {
1238    if (Object(external_lodash_["includes"])(['INPUT', 'TEXTAREA'], element.nodeName)) {
1239      return element.selectionStart === 0 && element.value.length === element.selectionEnd;
1240    }
1241  
1242    if (!element.isContentEditable) {
1243      return true;
1244    }
1245  
1246    var ownerDocument = element.ownerDocument;
1247    var defaultView = ownerDocument.defaultView;
1248    var selection = defaultView.getSelection();
1249    var range = selection.rangeCount ? selection.getRangeAt(0) : null;
1250  
1251    if (!range) {
1252      return true;
1253    }
1254  
1255    var startContainer = range.startContainer,
1256        endContainer = range.endContainer,
1257        startOffset = range.startOffset,
1258        endOffset = range.endOffset;
1259  
1260    if (startContainer === element && endContainer === element && startOffset === 0 && endOffset === element.childNodes.length) {
1261      return true;
1262    }
1263  
1264    var lastChild = element.lastChild;
1265    var lastChildContentLength = lastChild.nodeType === lastChild.TEXT_NODE ? lastChild.data.length : lastChild.childNodes.length;
1266    return startContainer === element.firstChild && endContainer === element.lastChild && startOffset === 0 && endOffset === lastChildContentLength;
1267  }
1268  /**
1269   * Given a DOM node, finds the closest scrollable container node.
1270   *
1271   * @param {Element} node Node from which to start.
1272   *
1273   * @return {?Element} Scrollable container node, if found.
1274   */
1275  
1276  function getScrollContainer(node) {
1277    if (!node) {
1278      return;
1279    } // Scrollable if scrollable height exceeds displayed...
1280  
1281  
1282    if (node.scrollHeight > node.clientHeight) {
1283      // ...except when overflow is defined to be hidden or visible
1284      var _getComputedStyle2 = getComputedStyle(node),
1285          overflowY = _getComputedStyle2.overflowY;
1286  
1287      if (/(auto|scroll)/.test(overflowY)) {
1288        return node;
1289      }
1290    } // Continue traversing
1291  
1292  
1293    return getScrollContainer(node.parentNode);
1294  }
1295  /**
1296   * Returns the closest positioned element, or null under any of the conditions
1297   * of the offsetParent specification. Unlike offsetParent, this function is not
1298   * limited to HTMLElement and accepts any Node (e.g. Node.TEXT_NODE).
1299   *
1300   * @see https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetparent
1301   *
1302   * @param {Node} node Node from which to find offset parent.
1303   *
1304   * @return {?Node} Offset parent.
1305   */
1306  
1307  function getOffsetParent(node) {
1308    // Cannot retrieve computed style or offset parent only anything other than
1309    // an element node, so find the closest element node.
1310    var closestElement;
1311  
1312    while (closestElement = node.parentNode) {
1313      if (closestElement.nodeType === closestElement.ELEMENT_NODE) {
1314        break;
1315      }
1316    }
1317  
1318    if (!closestElement) {
1319      return null;
1320    } // If the closest element is already positioned, return it, as offsetParent
1321    // does not otherwise consider the node itself.
1322  
1323  
1324    if (getComputedStyle(closestElement).position !== 'static') {
1325      return closestElement;
1326    }
1327  
1328    return closestElement.offsetParent;
1329  }
1330  /**
1331   * Given two DOM nodes, replaces the former with the latter in the DOM.
1332   *
1333   * @param {Element} processedNode Node to be removed.
1334   * @param {Element} newNode       Node to be inserted in its place.
1335   * @return {void}
1336   */
1337  
1338  function replace(processedNode, newNode) {
1339    insertAfter(newNode, processedNode.parentNode);
1340    remove(processedNode);
1341  }
1342  /**
1343   * Given a DOM node, removes it from the DOM.
1344   *
1345   * @param {Element} node Node to be removed.
1346   * @return {void}
1347   */
1348  
1349  function remove(node) {
1350    node.parentNode.removeChild(node);
1351  }
1352  /**
1353   * Given two DOM nodes, inserts the former in the DOM as the next sibling of
1354   * the latter.
1355   *
1356   * @param {Element} newNode       Node to be inserted.
1357   * @param {Element} referenceNode Node after which to perform the insertion.
1358   * @return {void}
1359   */
1360  
1361  function insertAfter(newNode, referenceNode) {
1362    referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
1363  }
1364  /**
1365   * Unwrap the given node. This means any child nodes are moved to the parent.
1366   *
1367   * @param {Node} node The node to unwrap.
1368   *
1369   * @return {void}
1370   */
1371  
1372  function unwrap(node) {
1373    var parent = node.parentNode;
1374  
1375    while (node.firstChild) {
1376      parent.insertBefore(node.firstChild, node);
1377    }
1378  
1379    parent.removeChild(node);
1380  }
1381  /**
1382   * Replaces the given node with a new node with the given tag name.
1383   *
1384   * @param {Element}  node    The node to replace
1385   * @param {string}   tagName The new tag name.
1386   *
1387   * @return {Element} The new node.
1388   */
1389  
1390  function replaceTag(node, tagName) {
1391    var newNode = node.ownerDocument.createElement(tagName);
1392  
1393    while (node.firstChild) {
1394      newNode.appendChild(node.firstChild);
1395    }
1396  
1397    node.parentNode.replaceChild(newNode, node);
1398    return newNode;
1399  }
1400  /**
1401   * Wraps the given node with a new node with the given tag name.
1402   *
1403   * @param {Element} newNode       The node to insert.
1404   * @param {Element} referenceNode The node to wrap.
1405   */
1406  
1407  function wrap(newNode, referenceNode) {
1408    referenceNode.parentNode.insertBefore(newNode, referenceNode);
1409    newNode.appendChild(referenceNode);
1410  }
1411  /**
1412   * Removes any HTML tags from the provided string.
1413   *
1414   * @param {string} html The string containing html.
1415   *
1416   * @return {string} The text content with any html removed.
1417   */
1418  
1419  function __unstableStripHTML(html) {
1420    var document = new window.DOMParser().parseFromString(html, 'text/html');
1421    return document.body.textContent || '';
1422  }
1423  /**
1424   * Given a schema, unwraps or removes nodes, attributes and classes on a node
1425   * list.
1426   *
1427   * @param {NodeList} nodeList The nodeList to filter.
1428   * @param {Document} doc      The document of the nodeList.
1429   * @param {Object}   schema   An array of functions that can mutate with the provided node.
1430   * @param {Object}   inline   Whether to clean for inline mode.
1431   */
1432  
1433  function cleanNodeList(nodeList, doc, schema, inline) {
1434    Array.from(nodeList).forEach(function (node) {
1435      var tag = node.nodeName.toLowerCase(); // It's a valid child, if the tag exists in the schema without an isMatch
1436      // function, or with an isMatch function that matches the node.
1437  
1438      if (schema.hasOwnProperty(tag) && (!schema[tag].isMatch || schema[tag].isMatch(node))) {
1439        if (node.nodeType === node.ELEMENT_NODE) {
1440          var _schema$tag = schema[tag],
1441              _schema$tag$attribute = _schema$tag.attributes,
1442              attributes = _schema$tag$attribute === void 0 ? [] : _schema$tag$attribute,
1443              _schema$tag$classes = _schema$tag.classes,
1444              classes = _schema$tag$classes === void 0 ? [] : _schema$tag$classes,
1445              children = _schema$tag.children,
1446              _schema$tag$require = _schema$tag.require,
1447              require = _schema$tag$require === void 0 ? [] : _schema$tag$require,
1448              allowEmpty = _schema$tag.allowEmpty; // If the node is empty and it's supposed to have children,
1449          // remove the node.
1450  
1451  
1452          if (children && !allowEmpty && isEmpty(node)) {
1453            remove(node);
1454            return;
1455          }
1456  
1457          if (node.hasAttributes()) {
1458            // Strip invalid attributes.
1459            Array.from(node.attributes).forEach(function (_ref3) {
1460              var name = _ref3.name;
1461  
1462              if (name !== 'class' && !Object(external_lodash_["includes"])(attributes, name)) {
1463                node.removeAttribute(name);
1464              }
1465            }); // Strip invalid classes.
1466            // In jsdom-jscore, 'node.classList' can be undefined.
1467            // TODO: Explore patching this in jsdom-jscore.
1468  
1469            if (node.classList && node.classList.length) {
1470              var mattchers = classes.map(function (item) {
1471                if (typeof item === 'string') {
1472                  return function (className) {
1473                    return className === item;
1474                  };
1475                } else if (item instanceof RegExp) {
1476                  return function (className) {
1477                    return item.test(className);
1478                  };
1479                }
1480  
1481                return external_lodash_["noop"];
1482              });
1483              Array.from(node.classList).forEach(function (name) {
1484                if (!mattchers.some(function (isMatch) {
1485                  return isMatch(name);
1486                })) {
1487                  node.classList.remove(name);
1488                }
1489              });
1490  
1491              if (!node.classList.length) {
1492                node.removeAttribute('class');
1493              }
1494            }
1495          }
1496  
1497          if (node.hasChildNodes()) {
1498            // Do not filter any content.
1499            if (children === '*') {
1500              return;
1501            } // Continue if the node is supposed to have children.
1502  
1503  
1504            if (children) {
1505              // If a parent requires certain children, but it does
1506              // not have them, drop the parent and continue.
1507              if (require.length && !node.querySelector(require.join(','))) {
1508                cleanNodeList(node.childNodes, doc, schema, inline);
1509                unwrap(node); // If the node is at the top, phrasing content, and
1510                // contains children that are block content, unwrap
1511                // the node because it is invalid.
1512              } else if (node.parentNode.nodeName === 'BODY' && isPhrasingContent(node)) {
1513                cleanNodeList(node.childNodes, doc, schema, inline);
1514  
1515                if (Array.from(node.childNodes).some(function (child) {
1516                  return !isPhrasingContent(child);
1517                })) {
1518                  unwrap(node);
1519                }
1520              } else {
1521                cleanNodeList(node.childNodes, doc, children, inline);
1522              } // Remove children if the node is not supposed to have any.
1523  
1524            } else {
1525              while (node.firstChild) {
1526                remove(node.firstChild);
1527              }
1528            }
1529          }
1530        } // Invalid child. Continue with schema at the same place and unwrap.
1531  
1532      } else {
1533        cleanNodeList(node.childNodes, doc, schema, inline); // For inline mode, insert a line break when unwrapping nodes that
1534        // are not phrasing content.
1535  
1536        if (inline && !isPhrasingContent(node) && node.nextElementSibling) {
1537          insertAfter(doc.createElement('br'), node);
1538        }
1539  
1540        unwrap(node);
1541      }
1542    });
1543  }
1544  /**
1545   * Recursively checks if an element is empty. An element is not empty if it
1546   * contains text or contains elements with attributes such as images.
1547   *
1548   * @param {Element} element The element to check.
1549   *
1550   * @return {boolean} Whether or not the element is empty.
1551   */
1552  
1553  
1554  function isEmpty(element) {
1555    if (!element.hasChildNodes()) {
1556      return true;
1557    }
1558  
1559    return Array.from(element.childNodes).every(function (node) {
1560      if (node.nodeType === node.TEXT_NODE) {
1561        return !node.nodeValue.trim();
1562      }
1563  
1564      if (node.nodeType === node.ELEMENT_NODE) {
1565        if (node.nodeName === 'BR') {
1566          return true;
1567        } else if (node.hasAttributes()) {
1568          return false;
1569        }
1570  
1571        return isEmpty(node);
1572      }
1573  
1574      return true;
1575    });
1576  }
1577  /**
1578   * Given a schema, unwraps or removes nodes, attributes and classes on HTML.
1579   *
1580   * @param {string} HTML   The HTML to clean up.
1581   * @param {Object} schema Schema for the HTML.
1582   * @param {Object} inline Whether to clean for inline mode.
1583   *
1584   * @return {string} The cleaned up HTML.
1585   */
1586  
1587  function removeInvalidHTML(HTML, schema, inline) {
1588    var doc = document.implementation.createHTMLDocument('');
1589    doc.body.innerHTML = HTML;
1590    cleanNodeList(doc.body.childNodes, doc, schema, inline);
1591    return doc.body.innerHTML;
1592  }
1593  
1594  // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/data-transfer.js
1595  
1596  
1597  /**
1598   * Gets all files from a DataTransfer object.
1599   *
1600   * @param {DataTransfer} dataTransfer DataTransfer object to inspect.
1601   *
1602   * @return {Object[]} An array containing all files.
1603   */
1604  function getFilesFromDataTransfer(dataTransfer) {
1605    var files = Object(toConsumableArray["a" /* default */])(dataTransfer.files);
1606  
1607    Array.from(dataTransfer.items).forEach(function (item) {
1608      var file = item.getAsFile();
1609  
1610      if (file && !files.find(function (_ref) {
1611        var name = _ref.name,
1612            type = _ref.type,
1613            size = _ref.size;
1614        return name === file.name && type === file.type && size === file.size;
1615      })) {
1616        files.push(file);
1617      }
1618    });
1619    return files;
1620  }
1621  
1622  // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/index.js
1623  /**
1624   * Internal dependencies
1625   */
1626  
1627  
1628  /**
1629   * Object grouping `focusable` and `tabbable` utils
1630   * under the keys with the same name.
1631   */
1632  
1633  var build_module_focus = {
1634    focusable: focusable_namespaceObject,
1635    tabbable: tabbable_namespaceObject
1636  };
1637  
1638  
1639  
1640  
1641  
1642  /***/ }),
1643  
1644  /***/ 5:
1645  /***/ (function(module, __webpack_exports__, __webpack_require__) {
1646  
1647  "use strict";
1648  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
1649  function _defineProperty(obj, key, value) {
1650    if (key in obj) {
1651      Object.defineProperty(obj, key, {
1652        value: value,
1653        enumerable: true,
1654        configurable: true,
1655        writable: true
1656      });
1657    } else {
1658      obj[key] = value;
1659    }
1660  
1661    return obj;
1662  }
1663  
1664  /***/ })
1665  
1666  /******/ });


Generated: Thu Mar 4 01:00:04 2021 Cross-referenced by PHPXref 0.7.1