dom.js 60 KB

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