changeset 19 | 3d72ae0968f4 |
parent 18 | be944660c56a |
child 21 | 48c4eec2b7e6 |
18:be944660c56a | 19:3d72ae0968f4 |
---|---|
1 this["wp"] = this["wp"] || {}; this["wp"]["dom"] = |
1 /******/ (function() { // webpackBootstrap |
2 /******/ (function(modules) { // webpackBootstrap |
2 /******/ "use strict"; |
3 /******/ // The module cache |
3 /******/ // The require scope |
4 /******/ var installedModules = {}; |
4 /******/ var __webpack_require__ = {}; |
5 /******/ |
5 /******/ |
6 /******/ // The require function |
6 /************************************************************************/ |
7 /******/ function __webpack_require__(moduleId) { |
7 /******/ /* webpack/runtime/define property getters */ |
8 /******/ |
8 /******/ !function() { |
9 /******/ // Check if module is in cache |
9 /******/ // define getter functions for harmony exports |
10 /******/ if(installedModules[moduleId]) { |
10 /******/ __webpack_require__.d = function(exports, definition) { |
11 /******/ return installedModules[moduleId].exports; |
11 /******/ for(var key in definition) { |
12 /******/ } |
12 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
13 /******/ // Create a new module (and put it into the cache) |
13 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
14 /******/ var module = installedModules[moduleId] = { |
14 /******/ } |
15 /******/ i: moduleId, |
15 /******/ } |
16 /******/ l: false, |
|
17 /******/ exports: {} |
|
18 /******/ }; |
16 /******/ }; |
19 /******/ |
17 /******/ }(); |
20 /******/ // Execute the module function |
18 /******/ |
21 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
19 /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
22 /******/ |
20 /******/ !function() { |
23 /******/ // Flag the module as loaded |
21 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
24 /******/ module.l = true; |
22 /******/ }(); |
25 /******/ |
23 /******/ |
26 /******/ // Return the exports of the module |
24 /******/ /* webpack/runtime/make namespace object */ |
27 /******/ return module.exports; |
25 /******/ !function() { |
28 /******/ } |
26 /******/ // define __esModule on exports |
29 /******/ |
27 /******/ __webpack_require__.r = function(exports) { |
30 /******/ |
28 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
31 /******/ // expose the modules object (__webpack_modules__) |
29 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
32 /******/ __webpack_require__.m = modules; |
30 /******/ } |
33 /******/ |
31 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
34 /******/ // expose the module cache |
32 /******/ }; |
35 /******/ __webpack_require__.c = installedModules; |
33 /******/ }(); |
36 /******/ |
34 /******/ |
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 = "2sUP"); |
|
86 /******/ }) |
|
87 /************************************************************************/ |
35 /************************************************************************/ |
88 /******/ ({ |
36 var __webpack_exports__ = {}; |
89 |
|
90 /***/ "2sUP": |
|
91 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
92 |
|
93 "use strict"; |
|
94 // ESM COMPAT FLAG |
37 // ESM COMPAT FLAG |
95 __webpack_require__.r(__webpack_exports__); |
38 __webpack_require__.r(__webpack_exports__); |
96 |
39 |
97 // EXPORTS |
40 // EXPORTS |
98 __webpack_require__.d(__webpack_exports__, "focus", function() { return /* binding */ build_module_focus; }); |
41 __webpack_require__.d(__webpack_exports__, { |
99 __webpack_require__.d(__webpack_exports__, "computeCaretRect", function() { return /* reexport */ computeCaretRect; }); |
42 "__unstableStripHTML": function() { return /* reexport */ stripHTML; }, |
100 __webpack_require__.d(__webpack_exports__, "documentHasTextSelection", function() { return /* reexport */ documentHasTextSelection; }); |
43 "computeCaretRect": function() { return /* reexport */ computeCaretRect; }, |
101 __webpack_require__.d(__webpack_exports__, "documentHasUncollapsedSelection", function() { return /* reexport */ documentHasUncollapsedSelection; }); |
44 "documentHasSelection": function() { return /* reexport */ documentHasSelection; }, |
102 __webpack_require__.d(__webpack_exports__, "documentHasSelection", function() { return /* reexport */ documentHasSelection; }); |
45 "documentHasTextSelection": function() { return /* reexport */ documentHasTextSelection; }, |
103 __webpack_require__.d(__webpack_exports__, "getRectangleFromRange", function() { return /* reexport */ getRectangleFromRange; }); |
46 "documentHasUncollapsedSelection": function() { return /* reexport */ documentHasUncollapsedSelection; }, |
104 __webpack_require__.d(__webpack_exports__, "getScrollContainer", function() { return /* reexport */ getScrollContainer; }); |
47 "focus": function() { return /* binding */ build_module_focus; }, |
105 __webpack_require__.d(__webpack_exports__, "getOffsetParent", function() { return /* reexport */ getOffsetParent; }); |
48 "getFilesFromDataTransfer": function() { return /* reexport */ getFilesFromDataTransfer; }, |
106 __webpack_require__.d(__webpack_exports__, "isEntirelySelected", function() { return /* reexport */ isEntirelySelected; }); |
49 "getOffsetParent": function() { return /* reexport */ getOffsetParent; }, |
107 __webpack_require__.d(__webpack_exports__, "isHorizontalEdge", function() { return /* reexport */ isHorizontalEdge; }); |
50 "getPhrasingContentSchema": function() { return /* reexport */ getPhrasingContentSchema; }, |
108 __webpack_require__.d(__webpack_exports__, "isNumberInput", function() { return /* reexport */ isNumberInput; }); |
51 "getRectangleFromRange": function() { return /* reexport */ getRectangleFromRange; }, |
109 __webpack_require__.d(__webpack_exports__, "isTextField", function() { return /* reexport */ isTextField; }); |
52 "getScrollContainer": function() { return /* reexport */ getScrollContainer; }, |
110 __webpack_require__.d(__webpack_exports__, "isVerticalEdge", function() { return /* reexport */ isVerticalEdge; }); |
53 "insertAfter": function() { return /* reexport */ insertAfter; }, |
111 __webpack_require__.d(__webpack_exports__, "placeCaretAtHorizontalEdge", function() { return /* reexport */ placeCaretAtHorizontalEdge; }); |
54 "isEmpty": function() { return /* reexport */ isEmpty; }, |
112 __webpack_require__.d(__webpack_exports__, "placeCaretAtVerticalEdge", function() { return /* reexport */ placeCaretAtVerticalEdge; }); |
55 "isEntirelySelected": function() { return /* reexport */ isEntirelySelected; }, |
113 __webpack_require__.d(__webpack_exports__, "replace", function() { return /* reexport */ replace; }); |
56 "isFormElement": function() { return /* reexport */ isFormElement; }, |
114 __webpack_require__.d(__webpack_exports__, "remove", function() { return /* reexport */ remove; }); |
57 "isHorizontalEdge": function() { return /* reexport */ isHorizontalEdge; }, |
115 __webpack_require__.d(__webpack_exports__, "insertAfter", function() { return /* reexport */ insertAfter; }); |
58 "isNumberInput": function() { return /* reexport */ isNumberInput; }, |
116 __webpack_require__.d(__webpack_exports__, "unwrap", function() { return /* reexport */ unwrap; }); |
59 "isPhrasingContent": function() { return /* reexport */ isPhrasingContent; }, |
117 __webpack_require__.d(__webpack_exports__, "replaceTag", function() { return /* reexport */ replaceTag; }); |
60 "isRTL": function() { return /* reexport */ isRTL; }, |
118 __webpack_require__.d(__webpack_exports__, "wrap", function() { return /* reexport */ wrap; }); |
61 "isTextContent": function() { return /* reexport */ isTextContent; }, |
119 __webpack_require__.d(__webpack_exports__, "__unstableStripHTML", function() { return /* reexport */ stripHTML; }); |
62 "isTextField": function() { return /* reexport */ isTextField; }, |
120 __webpack_require__.d(__webpack_exports__, "isEmpty", function() { return /* reexport */ isEmpty; }); |
63 "isVerticalEdge": function() { return /* reexport */ isVerticalEdge; }, |
121 __webpack_require__.d(__webpack_exports__, "removeInvalidHTML", function() { return /* reexport */ removeInvalidHTML; }); |
64 "placeCaretAtHorizontalEdge": function() { return /* reexport */ placeCaretAtHorizontalEdge; }, |
122 __webpack_require__.d(__webpack_exports__, "isRTL", function() { return /* reexport */ isRTL; }); |
65 "placeCaretAtVerticalEdge": function() { return /* reexport */ placeCaretAtVerticalEdge; }, |
123 __webpack_require__.d(__webpack_exports__, "safeHTML", function() { return /* reexport */ safeHTML; }); |
66 "remove": function() { return /* reexport */ remove; }, |
124 __webpack_require__.d(__webpack_exports__, "getPhrasingContentSchema", function() { return /* reexport */ getPhrasingContentSchema; }); |
67 "removeInvalidHTML": function() { return /* reexport */ removeInvalidHTML; }, |
125 __webpack_require__.d(__webpack_exports__, "isPhrasingContent", function() { return /* reexport */ isPhrasingContent; }); |
68 "replace": function() { return /* reexport */ replace; }, |
126 __webpack_require__.d(__webpack_exports__, "isTextContent", function() { return /* reexport */ isTextContent; }); |
69 "replaceTag": function() { return /* reexport */ replaceTag; }, |
127 __webpack_require__.d(__webpack_exports__, "getFilesFromDataTransfer", function() { return /* reexport */ getFilesFromDataTransfer; }); |
70 "safeHTML": function() { return /* reexport */ safeHTML; }, |
71 "unwrap": function() { return /* reexport */ unwrap; }, |
|
72 "wrap": function() { return /* reexport */ wrap; } |
|
73 }); |
|
128 |
74 |
129 // NAMESPACE OBJECT: ./node_modules/@wordpress/dom/build-module/focusable.js |
75 // NAMESPACE OBJECT: ./node_modules/@wordpress/dom/build-module/focusable.js |
130 var focusable_namespaceObject = {}; |
76 var focusable_namespaceObject = {}; |
131 __webpack_require__.r(focusable_namespaceObject); |
77 __webpack_require__.r(focusable_namespaceObject); |
132 __webpack_require__.d(focusable_namespaceObject, "find", function() { return find; }); |
78 __webpack_require__.d(focusable_namespaceObject, { |
79 "find": function() { return find; } |
|
80 }); |
|
133 |
81 |
134 // NAMESPACE OBJECT: ./node_modules/@wordpress/dom/build-module/tabbable.js |
82 // NAMESPACE OBJECT: ./node_modules/@wordpress/dom/build-module/tabbable.js |
135 var tabbable_namespaceObject = {}; |
83 var tabbable_namespaceObject = {}; |
136 __webpack_require__.r(tabbable_namespaceObject); |
84 __webpack_require__.r(tabbable_namespaceObject); |
137 __webpack_require__.d(tabbable_namespaceObject, "isTabbableIndex", function() { return isTabbableIndex; }); |
85 __webpack_require__.d(tabbable_namespaceObject, { |
138 __webpack_require__.d(tabbable_namespaceObject, "find", function() { return tabbable_find; }); |
86 "find": function() { return tabbable_find; }, |
139 __webpack_require__.d(tabbable_namespaceObject, "findPrevious", function() { return findPrevious; }); |
87 "findNext": function() { return findNext; }, |
140 __webpack_require__.d(tabbable_namespaceObject, "findNext", function() { return findNext; }); |
88 "findPrevious": function() { return findPrevious; }, |
141 |
89 "isTabbableIndex": function() { return isTabbableIndex; } |
142 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/focusable.js |
90 }); |
91 |
|
92 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/focusable.js |
|
143 /** |
93 /** |
144 * References: |
94 * References: |
145 * |
95 * |
146 * Focusable: |
96 * Focusable: |
147 * - https://www.w3.org/TR/html5/editing.html#focus-management |
97 * - https://www.w3.org/TR/html5/editing.html#focus-management |
156 * - https://www.w3.org/TR/cssom-view-1/#extension-to-the-element-interface |
106 * - https://www.w3.org/TR/cssom-view-1/#extension-to-the-element-interface |
157 * |
107 * |
158 * AREA elements associated with an IMG: |
108 * AREA elements associated with an IMG: |
159 * - https://w3c.github.io/html/editing.html#data-model |
109 * - https://w3c.github.io/html/editing.html#data-model |
160 */ |
110 */ |
161 const 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(','); |
111 |
112 /** |
|
113 * Returns a CSS selector used to query for focusable elements. |
|
114 * |
|
115 * @param {boolean} sequential If set, only query elements that are sequentially |
|
116 * focusable. Non-interactive elements with a |
|
117 * negative `tabindex` are focusable but not |
|
118 * sequentially focusable. |
|
119 * https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute |
|
120 * |
|
121 * @return {string} CSS selector. |
|
122 */ |
|
123 function buildSelector(sequential) { |
|
124 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(','); |
|
125 } |
|
162 /** |
126 /** |
163 * Returns true if the specified element is visible (i.e. neither display: none |
127 * Returns true if the specified element is visible (i.e. neither display: none |
164 * nor visibility: hidden). |
128 * nor visibility: hidden). |
165 * |
129 * |
166 * @param {HTMLElement} element DOM element to test. |
130 * @param {HTMLElement} element DOM element to test. |
167 * |
131 * |
168 * @return {boolean} Whether element is visible. |
132 * @return {boolean} Whether element is visible. |
169 */ |
133 */ |
170 |
134 |
135 |
|
171 function isVisible(element) { |
136 function isVisible(element) { |
172 return element.offsetWidth > 0 || element.offsetHeight > 0 || element.getClientRects().length > 0; |
137 return element.offsetWidth > 0 || element.offsetHeight > 0 || element.getClientRects().length > 0; |
173 } |
|
174 /** |
|
175 * Returns true if the specified element should be skipped from focusable elements. |
|
176 * For now it rather specific for `iframes` and if tabindex attribute is set to -1. |
|
177 * |
|
178 * @param {Element} element DOM element to test. |
|
179 * |
|
180 * @return {boolean} Whether element should be skipped from focusable elements. |
|
181 */ |
|
182 |
|
183 |
|
184 function skipFocus(element) { |
|
185 return element.nodeName.toLowerCase() === 'iframe' && element.getAttribute('tabindex') === '-1'; |
|
186 } |
138 } |
187 /** |
139 /** |
188 * Returns true if the specified area element is a valid focusable element, or |
140 * Returns true if the specified area element is a valid focusable element, or |
189 * false otherwise. Area is only focusable if within a map where a named map |
141 * false otherwise. Area is only focusable if within a map where a named map |
190 * referenced by an image somewhere in the document. |
142 * referenced by an image somewhere in the document. |
209 return !!img && isVisible(img); |
161 return !!img && isVisible(img); |
210 } |
162 } |
211 /** |
163 /** |
212 * Returns all focusable elements within a given context. |
164 * Returns all focusable elements within a given context. |
213 * |
165 * |
214 * @param {Element} context Element in which to search. |
166 * @param {Element} context Element in which to search. |
167 * @param {Object} [options] |
|
168 * @param {boolean} [options.sequential] If set, only return elements that are |
|
169 * sequentially focusable. |
|
170 * Non-interactive elements with a |
|
171 * negative `tabindex` are focusable but |
|
172 * not sequentially focusable. |
|
173 * https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute |
|
215 * |
174 * |
216 * @return {Element[]} Focusable elements. |
175 * @return {Element[]} Focusable elements. |
217 */ |
176 */ |
218 |
177 |
219 |
178 |
220 function find(context) { |
179 function find(context) { |
180 let { |
|
181 sequential = false |
|
182 } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
183 |
|
221 /* eslint-disable jsdoc/no-undefined-types */ |
184 /* eslint-disable jsdoc/no-undefined-types */ |
222 |
185 |
223 /** @type {NodeListOf<HTMLElement>} */ |
186 /** @type {NodeListOf<HTMLElement>} */ |
224 |
187 |
225 /* eslint-enable jsdoc/no-undefined-types */ |
188 /* eslint-enable jsdoc/no-undefined-types */ |
226 const elements = context.querySelectorAll(SELECTOR); |
189 const elements = context.querySelectorAll(buildSelector(sequential)); |
227 return Array.from(elements).filter(element => { |
190 return Array.from(elements).filter(element => { |
228 if (!isVisible(element) || skipFocus(element)) { |
191 if (!isVisible(element)) { |
229 return false; |
192 return false; |
230 } |
193 } |
231 |
194 |
232 const { |
195 const { |
233 nodeName |
196 nodeName |
241 |
204 |
242 return true; |
205 return true; |
243 }); |
206 }); |
244 } |
207 } |
245 |
208 |
246 // EXTERNAL MODULE: external "lodash" |
209 ;// CONCATENATED MODULE: external "lodash" |
247 var external_lodash_ = __webpack_require__("YLtl"); |
210 var external_lodash_namespaceObject = window["lodash"]; |
248 |
211 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/tabbable.js |
249 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/tabbable.js |
|
250 /** |
212 /** |
251 * External dependencies |
213 * External dependencies |
252 */ |
214 */ |
253 |
215 |
254 /** |
216 /** |
326 // the element which had previously been considered the chosen one. |
288 // the element which had previously been considered the chosen one. |
327 |
289 |
328 |
290 |
329 if (hasChosen) { |
291 if (hasChosen) { |
330 const hadChosenElement = CHOSEN_RADIO_BY_NAME[name]; |
292 const hadChosenElement = CHOSEN_RADIO_BY_NAME[name]; |
331 result = Object(external_lodash_["without"])(result, hadChosenElement); |
293 result = (0,external_lodash_namespaceObject.without)(result, hadChosenElement); |
332 } |
294 } |
333 |
295 |
334 CHOSEN_RADIO_BY_NAME[name] = element; |
296 CHOSEN_RADIO_BY_NAME[name] = element; |
335 return result.concat(element); |
297 return result.concat(element); |
336 }; |
298 }; |
413 /** |
375 /** |
414 * Given a focusable element, find the preceding tabbable element. |
376 * Given a focusable element, find the preceding tabbable element. |
415 * |
377 * |
416 * @param {Element} element The focusable element before which to look. Defaults |
378 * @param {Element} element The focusable element before which to look. Defaults |
417 * to the active element. |
379 * to the active element. |
380 * |
|
381 * @return {Element|undefined} Preceding tabbable element. |
|
418 */ |
382 */ |
419 |
383 |
420 function findPrevious(element) { |
384 function findPrevious(element) { |
421 const focusables = find(element.ownerDocument.body); |
385 const focusables = find(element.ownerDocument.body); |
422 const index = focusables.indexOf(element); // Remove all focusables after and including `element`. |
386 const index = focusables.indexOf(element); |
387 |
|
388 if (index === -1) { |
|
389 return undefined; |
|
390 } // Remove all focusables after and including `element`. |
|
391 |
|
423 |
392 |
424 focusables.length = index; |
393 focusables.length = index; |
425 return Object(external_lodash_["last"])(filterTabbable(focusables)); |
394 return (0,external_lodash_namespaceObject.last)(filterTabbable(focusables)); |
426 } |
395 } |
427 /** |
396 /** |
428 * Given a focusable element, find the next tabbable element. |
397 * Given a focusable element, find the next tabbable element. |
429 * |
398 * |
430 * @param {Element} element The focusable element after which to look. Defaults |
399 * @param {Element} element The focusable element after which to look. Defaults |
431 * to the active element. |
400 * to the active element. |
432 */ |
401 */ |
433 |
402 |
434 function findNext(element) { |
403 function findNext(element) { |
435 const focusables = find(element.ownerDocument.body); |
404 const focusables = find(element.ownerDocument.body); |
436 const index = focusables.indexOf(element); // Remove all focusables before and inside `element`. |
405 const index = focusables.indexOf(element); // Remove all focusables before and including `element`. |
437 |
406 |
438 const remaining = focusables.slice(index + 1).filter(node => !element.contains(node)); |
407 const remaining = focusables.slice(index + 1); |
439 return Object(external_lodash_["first"])(filterTabbable(remaining)); |
408 return (0,external_lodash_namespaceObject.first)(filterTabbable(remaining)); |
440 } |
409 } |
441 |
410 |
442 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/utils/assert-is-defined.js |
411 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/utils/assert-is-defined.js |
443 function assertIsDefined(val, name) { |
412 function assertIsDefined(val, name) { |
444 if (false) {} |
413 if (false) {} |
445 } |
414 } |
446 |
415 |
447 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/get-rectangle-from-range.js |
416 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/get-rectangle-from-range.js |
448 /** |
417 /** |
449 * Internal dependencies |
418 * Internal dependencies |
450 */ |
419 */ |
451 |
420 |
452 /** |
421 /** |
467 if (rects.length === 1) { |
436 if (rects.length === 1) { |
468 return rects[0]; |
437 return rects[0]; |
469 } // Ignore tiny selection at the edge of a range. |
438 } // Ignore tiny selection at the edge of a range. |
470 |
439 |
471 |
440 |
472 const filteredRects = rects.filter(({ |
441 const filteredRects = rects.filter(_ref => { |
473 width |
442 let { |
474 }) => width > 1); // If it's full of tiny selections, return browser default. |
443 width |
444 } = _ref; |
|
445 return width > 1; |
|
446 }); // If it's full of tiny selections, return browser default. |
|
475 |
447 |
476 if (filteredRects.length === 0) { |
448 if (filteredRects.length === 0) { |
477 return range.getBoundingClientRect(); |
449 return range.getBoundingClientRect(); |
478 } |
450 } |
479 |
451 |
542 } |
514 } |
543 |
515 |
544 return rect; |
516 return rect; |
545 } |
517 } |
546 |
518 |
547 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/compute-caret-rect.js |
519 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/compute-caret-rect.js |
548 /** |
520 /** |
549 * Internal dependencies |
521 * Internal dependencies |
550 */ |
522 */ |
551 |
523 |
552 |
524 |
568 } |
540 } |
569 |
541 |
570 return getRectangleFromRange(range); |
542 return getRectangleFromRange(range); |
571 } |
543 } |
572 |
544 |
573 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/document-has-text-selection.js |
545 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/document-has-text-selection.js |
574 /** |
546 /** |
575 * Internal dependencies |
547 * Internal dependencies |
576 */ |
548 */ |
577 |
549 |
578 /** |
550 /** |
579 * Check whether the current document has selected text. This applies to ranges |
551 * Check whether the current document has selected text. This applies to ranges |
580 * of text in the document, and not selection inside <input> and <textarea> |
552 * of text in the document, and not selection inside `<input>` and `<textarea>` |
581 * elements. |
553 * elements. |
582 * |
554 * |
583 * See: https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection#Related_objects. |
555 * See: https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection#Related_objects. |
584 * |
556 * |
585 * @param {Document} doc The document to check. |
557 * @param {Document} doc The document to check. |
593 assertIsDefined(selection, 'selection'); |
565 assertIsDefined(selection, 'selection'); |
594 const range = selection.rangeCount ? selection.getRangeAt(0) : null; |
566 const range = selection.rangeCount ? selection.getRangeAt(0) : null; |
595 return !!range && !range.collapsed; |
567 return !!range && !range.collapsed; |
596 } |
568 } |
597 |
569 |
598 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-html-input-element.js |
570 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-html-input-element.js |
599 /* eslint-disable jsdoc/valid-types */ |
571 /* eslint-disable jsdoc/valid-types */ |
600 |
572 |
601 /** |
573 /** |
602 * @param {Node} node |
574 * @param {Node} node |
603 * @return {node is HTMLInputElement} Whether the node is an HTMLInputElement. |
575 * @return {node is HTMLInputElement} Whether the node is an HTMLInputElement. |
605 function isHTMLInputElement(node) { |
577 function isHTMLInputElement(node) { |
606 /* eslint-enable jsdoc/valid-types */ |
578 /* eslint-enable jsdoc/valid-types */ |
607 return !!node && node.nodeName === 'INPUT'; |
579 return !!node && node.nodeName === 'INPUT'; |
608 } |
580 } |
609 |
581 |
610 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-text-field.js |
582 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-text-field.js |
611 /** |
583 /** |
612 * Internal dependencies |
584 * Internal dependencies |
613 */ |
585 */ |
614 |
586 |
615 /* eslint-disable jsdoc/valid-types */ |
587 /* eslint-disable jsdoc/valid-types */ |
630 return isHTMLInputElement(node) && node.type && !nonTextInputs.includes(node.type) || node.nodeName === 'TEXTAREA' || |
602 return isHTMLInputElement(node) && node.type && !nonTextInputs.includes(node.type) || node.nodeName === 'TEXTAREA' || |
631 /** @type {HTMLElement} */ |
603 /** @type {HTMLElement} */ |
632 node.contentEditable === 'true'; |
604 node.contentEditable === 'true'; |
633 } |
605 } |
634 |
606 |
635 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-number-input.js |
607 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-number-input.js |
636 /** |
608 /** |
637 * Internal dependencies |
609 * Internal dependencies |
638 */ |
610 */ |
639 |
611 |
640 /* eslint-disable jsdoc/valid-types */ |
612 /* eslint-disable jsdoc/valid-types */ |
651 function isNumberInput(node) { |
623 function isNumberInput(node) { |
652 /* eslint-enable jsdoc/valid-types */ |
624 /* eslint-enable jsdoc/valid-types */ |
653 return isHTMLInputElement(node) && node.type === 'number' && !!node.valueAsNumber; |
625 return isHTMLInputElement(node) && node.type === 'number' && !!node.valueAsNumber; |
654 } |
626 } |
655 |
627 |
656 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/input-field-has-uncollapsed-selection.js |
628 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/input-field-has-uncollapsed-selection.js |
657 /** |
629 /** |
658 * Internal dependencies |
630 * Internal dependencies |
659 */ |
631 */ |
660 |
632 |
661 |
633 |
697 // evolves over time. |
669 // evolves over time. |
698 return false; |
670 return false; |
699 } |
671 } |
700 } |
672 } |
701 |
673 |
702 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/document-has-uncollapsed-selection.js |
674 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/document-has-uncollapsed-selection.js |
703 /** |
675 /** |
704 * Internal dependencies |
676 * Internal dependencies |
705 */ |
677 */ |
706 |
678 |
707 |
679 |
708 /** |
680 /** |
709 * Check whether the current document has any sort of selection. This includes |
681 * Check whether the current document has any sort of selection. This includes |
710 * ranges of text across elements and any selection inside <input> and |
682 * ranges of text across elements and any selection inside `<input>` and |
711 * <textarea> elements. |
683 * `<textarea>` elements. |
712 * |
684 * |
713 * @param {Document} doc The document to check. |
685 * @param {Document} doc The document to check. |
714 * |
686 * |
715 * @return {boolean} Whether there is any sort of "selection" in the document. |
687 * @return {boolean} Whether there is any sort of "selection" in the document. |
716 */ |
688 */ |
717 |
689 |
718 function documentHasUncollapsedSelection(doc) { |
690 function documentHasUncollapsedSelection(doc) { |
719 return documentHasTextSelection(doc) || !!doc.activeElement && inputFieldHasUncollapsedSelection(doc.activeElement); |
691 return documentHasTextSelection(doc) || !!doc.activeElement && inputFieldHasUncollapsedSelection(doc.activeElement); |
720 } |
692 } |
721 |
693 |
722 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/document-has-selection.js |
694 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/document-has-selection.js |
723 /** |
695 /** |
724 * Internal dependencies |
696 * Internal dependencies |
725 */ |
697 */ |
726 |
698 |
727 |
699 |
737 |
709 |
738 function documentHasSelection(doc) { |
710 function documentHasSelection(doc) { |
739 return !!doc.activeElement && (isTextField(doc.activeElement) || isNumberInput(doc.activeElement) || documentHasTextSelection(doc)); |
711 return !!doc.activeElement && (isTextField(doc.activeElement) || isNumberInput(doc.activeElement) || documentHasTextSelection(doc)); |
740 } |
712 } |
741 |
713 |
742 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/get-computed-style.js |
714 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/get-computed-style.js |
743 /** |
715 /** |
744 * Internal dependencies |
716 * Internal dependencies |
745 */ |
717 */ |
746 |
718 |
747 /* eslint-disable jsdoc/valid-types */ |
719 /* eslint-disable jsdoc/valid-types */ |
755 /* eslint-enable jsdoc/valid-types */ |
727 /* eslint-enable jsdoc/valid-types */ |
756 assertIsDefined(element.ownerDocument.defaultView, 'element.ownerDocument.defaultView'); |
728 assertIsDefined(element.ownerDocument.defaultView, 'element.ownerDocument.defaultView'); |
757 return element.ownerDocument.defaultView.getComputedStyle(element); |
729 return element.ownerDocument.defaultView.getComputedStyle(element); |
758 } |
730 } |
759 |
731 |
760 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/get-scroll-container.js |
732 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/get-scroll-container.js |
761 /** |
733 /** |
762 * Internal dependencies |
734 * Internal dependencies |
763 */ |
735 */ |
764 |
736 |
765 /** |
737 /** |
783 } = getComputedStyle(node); |
755 } = getComputedStyle(node); |
784 |
756 |
785 if (/(auto|scroll)/.test(overflowY)) { |
757 if (/(auto|scroll)/.test(overflowY)) { |
786 return node; |
758 return node; |
787 } |
759 } |
788 } // Continue traversing |
760 } // Continue traversing. |
789 |
761 |
790 |
762 |
791 return getScrollContainer( |
763 return getScrollContainer( |
792 /** @type {Element} */ |
764 /** @type {Element} */ |
793 node.parentNode); |
765 node.parentNode); |
794 } |
766 } |
795 |
767 |
796 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/get-offset-parent.js |
768 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/get-offset-parent.js |
797 /** |
769 /** |
798 * Internal dependencies |
770 * Internal dependencies |
799 */ |
771 */ |
800 |
772 |
801 /** |
773 /** |
831 |
803 |
832 if (getComputedStyle( |
804 if (getComputedStyle( |
833 /** @type {Element} */ |
805 /** @type {Element} */ |
834 closestElement).position !== 'static') { |
806 closestElement).position !== 'static') { |
835 return closestElement; |
807 return closestElement; |
836 } // offsetParent is undocumented/draft |
808 } // offsetParent is undocumented/draft. |
837 |
809 |
838 |
810 |
839 return ( |
811 return ( |
840 /** @type {Node & { offsetParent: Node }} */ |
812 /** @type {Node & { offsetParent: Node }} */ |
841 closestElement.offsetParent |
813 closestElement.offsetParent |
842 ); |
814 ); |
843 } |
815 } |
844 |
816 |
845 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-input-or-text-area.js |
817 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-input-or-text-area.js |
846 /* eslint-disable jsdoc/valid-types */ |
818 /* eslint-disable jsdoc/valid-types */ |
847 |
819 |
848 /** |
820 /** |
849 * @param {Element} element |
821 * @param {Element} element |
850 * @return {element is HTMLInputElement | HTMLTextAreaElement} Whether the element is an input or textarea |
822 * @return {element is HTMLInputElement | HTMLTextAreaElement} Whether the element is an input or textarea |
852 function isInputOrTextArea(element) { |
824 function isInputOrTextArea(element) { |
853 /* eslint-enable jsdoc/valid-types */ |
825 /* eslint-enable jsdoc/valid-types */ |
854 return element.tagName === 'INPUT' || element.tagName === 'TEXTAREA'; |
826 return element.tagName === 'INPUT' || element.tagName === 'TEXTAREA'; |
855 } |
827 } |
856 |
828 |
857 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-entirely-selected.js |
829 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-entirely-selected.js |
858 /** |
830 /** |
859 * Internal dependencies |
831 * Internal dependencies |
860 */ |
832 */ |
861 |
833 |
862 |
834 |
913 } |
885 } |
914 /** |
886 /** |
915 * Check whether the contents of the element have been entirely selected. |
887 * Check whether the contents of the element have been entirely selected. |
916 * Returns true if there is no possibility of selection. |
888 * Returns true if there is no possibility of selection. |
917 * |
889 * |
918 * @param {HTMLElement|Node} query The element to check. |
890 * @param {HTMLElement|Node} query The element to check. |
919 * @param {HTMLElement} container The container that we suspect "query" may be a first or last child of. |
891 * @param {HTMLElement} container The container that we suspect "query" may be a first or last child of. |
920 * @param {"firstChild"|"lastChild"} propName "firstChild" or "lastChild" |
892 * @param {"firstChild"|"lastChild"} propName "firstChild" or "lastChild" |
921 * |
893 * |
922 * @return {boolean} True if query is a deep first/last child of container, false otherwise. |
894 * @return {boolean} True if query is a deep first/last child of container, false otherwise. |
923 */ |
895 */ |
924 |
896 |
925 function isDeepChild(query, container, propName) { |
897 function isDeepChild(query, container, propName) { |
935 } while (candidate); |
907 } while (candidate); |
936 |
908 |
937 return false; |
909 return false; |
938 } |
910 } |
939 |
911 |
940 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-rtl.js |
912 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-form-element.js |
913 /** |
|
914 * Internal dependencies |
|
915 */ |
|
916 |
|
917 /** |
|
918 * |
|
919 * Detects if element is a form element. |
|
920 * |
|
921 * @param {Element} element The element to check. |
|
922 * |
|
923 * @return {boolean} True if form element and false otherwise. |
|
924 */ |
|
925 |
|
926 function isFormElement(element) { |
|
927 const { |
|
928 tagName |
|
929 } = element; |
|
930 const checkForInputTextarea = isInputOrTextArea(element); |
|
931 return checkForInputTextarea || tagName === 'BUTTON' || tagName === 'SELECT'; |
|
932 } |
|
933 |
|
934 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-rtl.js |
|
941 /** |
935 /** |
942 * Internal dependencies |
936 * Internal dependencies |
943 */ |
937 */ |
944 |
938 |
945 /** |
939 /** |
952 |
946 |
953 function isRTL(element) { |
947 function isRTL(element) { |
954 return getComputedStyle(element).direction === 'rtl'; |
948 return getComputedStyle(element).direction === 'rtl'; |
955 } |
949 } |
956 |
950 |
957 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/get-range-height.js |
951 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/get-range-height.js |
958 /** |
952 /** |
959 * Gets the height of the range without ignoring zero width rectangles, which |
953 * Gets the height of the range without ignoring zero width rectangles, which |
960 * some browsers ignore when creating a union. |
954 * some browsers ignore when creating a union. |
961 * |
955 * |
962 * @param {Range} range The range to check. |
956 * @param {Range} range The range to check. |
967 |
961 |
968 if (!rects.length) { |
962 if (!rects.length) { |
969 return; |
963 return; |
970 } |
964 } |
971 |
965 |
972 const highestTop = Math.min(...rects.map(({ |
966 const highestTop = Math.min(...rects.map(_ref => { |
973 top |
967 let { |
974 }) => top)); |
968 top |
975 const lowestBottom = Math.max(...rects.map(({ |
969 } = _ref; |
976 bottom |
970 return top; |
977 }) => bottom)); |
971 })); |
972 const lowestBottom = Math.max(...rects.map(_ref2 => { |
|
973 let { |
|
974 bottom |
|
975 } = _ref2; |
|
976 return bottom; |
|
977 })); |
|
978 return lowestBottom - highestTop; |
978 return lowestBottom - highestTop; |
979 } |
979 } |
980 |
980 |
981 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-selection-forward.js |
981 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-selection-forward.js |
982 /** |
982 /** |
983 * Internal dependencies |
983 * Internal dependencies |
984 */ |
984 */ |
985 |
985 |
986 /** |
986 /** |
1028 |
1028 |
1029 |
1029 |
1030 return true; |
1030 return true; |
1031 } |
1031 } |
1032 |
1032 |
1033 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/caret-range-from-point.js |
1033 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/caret-range-from-point.js |
1034 /** |
1034 /** |
1035 * Polyfill. |
1035 * Polyfill. |
1036 * Get a collapsed range for a given point. |
1036 * Get a collapsed range for a given point. |
1037 * |
1037 * |
1038 * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint |
1038 * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint |
1039 * |
1039 * |
1040 * @param {Document} doc The document of the range. |
1040 * @param {DocumentMaybeWithCaretPositionFromPoint} doc The document of the range. |
1041 * @param {number} x Horizontal position within the current viewport. |
1041 * @param {number} x Horizontal position within the current viewport. |
1042 * @param {number} y Vertical position within the current viewport. |
1042 * @param {number} y Vertical position within the current viewport. |
1043 * |
1043 * |
1044 * @return {Range | null} The best range for the given point. |
1044 * @return {Range | null} The best range for the given point. |
1045 */ |
1045 */ |
1046 function caretRangeFromPoint(doc, x, y) { |
1046 function caretRangeFromPoint(doc, x, y) { |
1047 if (doc.caretRangeFromPoint) { |
1047 if (doc.caretRangeFromPoint) { |
1062 const range = doc.createRange(); |
1062 const range = doc.createRange(); |
1063 range.setStart(point.offsetNode, point.offset); |
1063 range.setStart(point.offsetNode, point.offset); |
1064 range.collapse(true); |
1064 range.collapse(true); |
1065 return range; |
1065 return range; |
1066 } |
1066 } |
1067 |
1067 /** |
1068 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/hidden-caret-range-from-point.js |
1068 * @typedef {{caretPositionFromPoint?: (x: number, y: number)=> CaretPosition | null} & Document } DocumentMaybeWithCaretPositionFromPoint |
1069 * @typedef {{ readonly offset: number; readonly offsetNode: Node; getClientRect(): DOMRect | null; }} CaretPosition |
|
1070 */ |
|
1071 |
|
1072 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/hidden-caret-range-from-point.js |
|
1069 /** |
1073 /** |
1070 * Internal dependencies |
1074 * Internal dependencies |
1071 */ |
1075 */ |
1072 |
1076 |
1073 |
1077 |
1074 /** |
1078 /** |
1075 * Get a collapsed range for a given point. |
1079 * Get a collapsed range for a given point. |
1076 * Gives the container a temporary high z-index (above any UI). |
1080 * Gives the container a temporary high z-index (above any UI). |
1077 * This is preferred over getting the UI nodes and set styles there. |
1081 * This is preferred over getting the UI nodes and set styles there. |
1078 * |
1082 * |
1079 * @param {Document} doc The document of the range. |
1083 * @param {Document} doc The document of the range. |
1080 * @param {number} x Horizontal position within the current viewport. |
1084 * @param {number} x Horizontal position within the current viewport. |
1081 * @param {number} y Vertical position within the current viewport. |
1085 * @param {number} y Vertical position within the current viewport. |
1082 * @param {HTMLElement} container Container in which the range is expected to be found. |
1086 * @param {HTMLElement} container Container in which the range is expected to be found. |
1083 * |
1087 * |
1084 * @return {?Range} The best range for the given point. |
1088 * @return {?Range} The best range for the given point. |
1085 */ |
1089 */ |
1086 |
1090 |
1087 function hiddenCaretRangeFromPoint(doc, x, y, container) { |
1091 function hiddenCaretRangeFromPoint(doc, x, y, container) { |
1100 container.style.zIndex = originalZIndex; |
1104 container.style.zIndex = originalZIndex; |
1101 container.style.position = originalPosition; |
1105 container.style.position = originalPosition; |
1102 return range; |
1106 return range; |
1103 } |
1107 } |
1104 |
1108 |
1105 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-edge.js |
1109 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-edge.js |
1106 /** |
1110 /** |
1107 * Internal dependencies |
1111 * Internal dependencies |
1108 */ |
1112 */ |
1109 |
1113 |
1110 |
1114 |
1116 /** |
1120 /** |
1117 * Check whether the selection is at the edge of the container. Checks for |
1121 * Check whether the selection is at the edge of the container. Checks for |
1118 * horizontal position by default. Set `onlyVertical` to true to check only |
1122 * horizontal position by default. Set `onlyVertical` to true to check only |
1119 * vertically. |
1123 * vertically. |
1120 * |
1124 * |
1121 * @param {Element} container Focusable element. |
1125 * @param {Element} container Focusable element. |
1122 * @param {boolean} isReverse Set to true to check left, false to check right. |
1126 * @param {boolean} isReverse Set to true to check left, false to check right. |
1123 * @param {boolean} [onlyVertical=false] Set to true to check only vertical position. |
1127 * @param {boolean} [onlyVertical=false] Set to true to check only vertical position. |
1124 * |
1128 * |
1125 * @return {boolean} True if at the edge, false if not. |
1129 * @return {boolean} True if at the edge, false if not. |
1126 */ |
1130 */ |
1127 |
1131 |
1128 function isEdge(container, isReverse, onlyVertical = false) { |
1132 function isEdge(container, isReverse) { |
1129 if (isInputOrTextArea(container)) { |
1133 let onlyVertical = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; |
1134 |
|
1135 if (isInputOrTextArea(container) && typeof container.selectionStart === 'number') { |
|
1130 if (container.selectionStart !== container.selectionEnd) { |
1136 if (container.selectionStart !== container.selectionEnd) { |
1131 return false; |
1137 return false; |
1132 } |
1138 } |
1133 |
1139 |
1134 if (isReverse) { |
1140 if (isReverse) { |
1219 const hasVerticalDiff = Math.abs(verticalDiff) <= 1; |
1225 const hasVerticalDiff = Math.abs(verticalDiff) <= 1; |
1220 const hasHorizontalDiff = Math.abs(horizontalDiff) <= 1; |
1226 const hasHorizontalDiff = Math.abs(horizontalDiff) <= 1; |
1221 return onlyVertical ? hasVerticalDiff : hasVerticalDiff && hasHorizontalDiff; |
1227 return onlyVertical ? hasVerticalDiff : hasVerticalDiff && hasHorizontalDiff; |
1222 } |
1228 } |
1223 |
1229 |
1224 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-horizontal-edge.js |
1230 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-horizontal-edge.js |
1225 /** |
1231 /** |
1226 * Internal dependencies |
1232 * Internal dependencies |
1227 */ |
1233 */ |
1228 |
1234 |
1229 /** |
1235 /** |
1237 |
1243 |
1238 function isHorizontalEdge(container, isReverse) { |
1244 function isHorizontalEdge(container, isReverse) { |
1239 return isEdge(container, isReverse); |
1245 return isEdge(container, isReverse); |
1240 } |
1246 } |
1241 |
1247 |
1242 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-vertical-edge.js |
1248 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-vertical-edge.js |
1243 /** |
1249 /** |
1244 * Internal dependencies |
1250 * Internal dependencies |
1245 */ |
1251 */ |
1246 |
1252 |
1247 /** |
1253 /** |
1255 |
1261 |
1256 function isVerticalEdge(container, isReverse) { |
1262 function isVerticalEdge(container, isReverse) { |
1257 return isEdge(container, isReverse, true); |
1263 return isEdge(container, isReverse, true); |
1258 } |
1264 } |
1259 |
1265 |
1260 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/place-caret-at-horizontal-edge.js |
1266 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/place-caret-at-edge.js |
1261 /** |
|
1262 * Internal dependencies |
|
1263 */ |
|
1264 |
|
1265 /** |
1267 /** |
1266 * Internal dependencies |
1268 * Internal dependencies |
1267 */ |
1269 */ |
1268 |
1270 |
1269 |
1271 |
1270 |
1272 |
1271 |
1273 |
1272 /** |
1274 /** |
1273 * Gets the range to place. |
1275 * Gets the range to place. |
1274 * |
1276 * |
1275 * @param {HTMLElement} container Focusable element. |
1277 * @param {HTMLElement} container Focusable element. |
1276 * @param {boolean} isReverse True for end, false for start. |
1278 * @param {boolean} isReverse True for end, false for start. |
1279 * @param {number|undefined} x X coordinate to vertically position. |
|
1277 * |
1280 * |
1278 * @return {Range|null} The range to place. |
1281 * @return {Range|null} The range to place. |
1279 */ |
1282 */ |
1280 |
1283 |
1281 function getRange(container, isReverse) { |
1284 function getRange(container, isReverse, x) { |
1282 const { |
1285 const { |
1283 ownerDocument |
1286 ownerDocument |
1284 } = container; // In the case of RTL scripts, the horizontal edge is at the opposite side. |
1287 } = container; // In the case of RTL scripts, the horizontal edge is at the opposite side. |
1285 |
1288 |
1286 const isReverseDir = isRTL(container) ? !isReverse : isReverse; |
1289 const isReverseDir = isRTL(container) ? !isReverse : isReverse; |
1287 const containerRect = container.getBoundingClientRect(); // When placing at the end (isReverse), find the closest range to the bottom |
1290 const containerRect = container.getBoundingClientRect(); // When placing at the end (isReverse), find the closest range to the bottom |
1288 // right corner. When placing at the start, to the top left corner. |
1291 // right corner. When placing at the start, to the top left corner. |
1289 |
1292 |
1290 const x = isReverse ? containerRect.right - 1 : containerRect.left + 1; |
1293 if (x === undefined) { |
1294 x = isReverse ? containerRect.right - 1 : containerRect.left + 1; |
|
1295 } |
|
1296 |
|
1291 const y = isReverseDir ? containerRect.bottom - 1 : containerRect.top + 1; |
1297 const y = isReverseDir ? containerRect.bottom - 1 : containerRect.top + 1; |
1292 return hiddenCaretRangeFromPoint(ownerDocument, x, y, container); |
1298 return hiddenCaretRangeFromPoint(ownerDocument, x, y, container); |
1293 } |
1299 } |
1294 /** |
1300 /** |
1295 * Places the caret at start or end of a given element. |
1301 * Places the caret at start or end of a given element. |
1296 * |
1302 * |
1297 * @param {HTMLElement} container Focusable element. |
1303 * @param {HTMLElement} container Focusable element. |
1298 * @param {boolean} isReverse True for end, false for start. |
1304 * @param {boolean} isReverse True for end, false for start. |
1299 */ |
1305 * @param {number|undefined} x X coordinate to vertically position. |
1300 |
1306 */ |
1301 |
1307 |
1302 function placeCaretAtHorizontalEdge(container, isReverse) { |
1308 |
1309 function placeCaretAtEdge(container, isReverse, x) { |
|
1303 if (!container) { |
1310 if (!container) { |
1304 return; |
1311 return; |
1305 } |
1312 } |
1306 |
1313 |
1307 container.focus(); |
1314 container.focus(); |
1325 |
1332 |
1326 if (!container.isContentEditable) { |
1333 if (!container.isContentEditable) { |
1327 return; |
1334 return; |
1328 } |
1335 } |
1329 |
1336 |
1330 let range = getRange(container, isReverse); // If no range range can be created or it is outside the container, the |
1337 let range = getRange(container, isReverse, x); // If no range range can be created or it is outside the container, the |
1331 // element may be out of view. |
1338 // element may be out of view. |
1332 |
1339 |
1333 if (!range || !range.startContainer || !container.contains(range.startContainer)) { |
1340 if (!range || !range.startContainer || !container.contains(range.startContainer)) { |
1334 container.scrollIntoView(isReverse); |
1341 container.scrollIntoView(isReverse); |
1335 range = getRange(container, isReverse); |
1342 range = range = getRange(container, isReverse, x); |
1336 |
1343 |
1337 if (!range || !range.startContainer || !container.contains(range.startContainer)) { |
1344 if (!range || !range.startContainer || !container.contains(range.startContainer)) { |
1338 return; |
1345 return; |
1339 } |
1346 } |
1340 } |
1347 } |
1350 assertIsDefined(selection, 'selection'); |
1357 assertIsDefined(selection, 'selection'); |
1351 selection.removeAllRanges(); |
1358 selection.removeAllRanges(); |
1352 selection.addRange(range); |
1359 selection.addRange(range); |
1353 } |
1360 } |
1354 |
1361 |
1355 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/place-caret-at-vertical-edge.js |
1362 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/place-caret-at-horizontal-edge.js |
1356 /** |
1363 /** |
1357 * Internal dependencies |
1364 * Internal dependencies |
1358 */ |
1365 */ |
1359 |
1366 |
1360 |
1367 /** |
1368 * Places the caret at start or end of a given element. |
|
1369 * |
|
1370 * @param {HTMLElement} container Focusable element. |
|
1371 * @param {boolean} isReverse True for end, false for start. |
|
1372 */ |
|
1373 |
|
1374 function placeCaretAtHorizontalEdge(container, isReverse) { |
|
1375 return placeCaretAtEdge(container, isReverse, undefined); |
|
1376 } |
|
1377 |
|
1378 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/place-caret-at-vertical-edge.js |
|
1379 /** |
|
1380 * Internal dependencies |
|
1381 */ |
|
1361 |
1382 |
1362 /** |
1383 /** |
1363 * Places the caret at the top or bottom of a given element. |
1384 * Places the caret at the top or bottom of a given element. |
1364 * |
1385 * |
1365 * @param {HTMLElement} container Focusable element. |
1386 * @param {HTMLElement} container Focusable element. |
1366 * @param {boolean} isReverse True for bottom, false for top. |
1387 * @param {boolean} isReverse True for bottom, false for top. |
1367 * @param {DOMRect} [rect] The rectangle to position the caret with. |
1388 * @param {DOMRect} [rect] The rectangle to position the caret with. |
1368 * @param {boolean} [mayUseScroll=true] True to allow scrolling, false to disallow. |
1389 */ |
1369 */ |
1390 |
1370 |
1391 function placeCaretAtVerticalEdge(container, isReverse, rect) { |
1371 function placeCaretAtVerticalEdge(container, isReverse, rect, mayUseScroll = true) { |
1392 return placeCaretAtEdge(container, isReverse, rect === null || rect === void 0 ? void 0 : rect.left); |
1372 if (!container) { |
1393 } |
1373 return; |
1394 |
1374 } |
1395 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/insert-after.js |
1375 |
|
1376 if (!rect || !container.isContentEditable) { |
|
1377 placeCaretAtHorizontalEdge(container, isReverse); |
|
1378 return; |
|
1379 } |
|
1380 |
|
1381 container.focus(); // Offset by a buffer half the height of the caret rect. This is needed |
|
1382 // because caretRangeFromPoint may default to the end of the selection if |
|
1383 // offset is too close to the edge. It's unclear how to precisely calculate |
|
1384 // this threshold; it may be the padded area of some combination of line |
|
1385 // height, caret height, and font size. The buffer offset is effectively |
|
1386 // equivalent to a point at half the height of a line of text. |
|
1387 |
|
1388 const buffer = rect.height / 2; |
|
1389 const editableRect = container.getBoundingClientRect(); |
|
1390 const x = rect.left; |
|
1391 const y = isReverse ? editableRect.bottom - buffer : editableRect.top + buffer; |
|
1392 const { |
|
1393 ownerDocument |
|
1394 } = container; |
|
1395 const { |
|
1396 defaultView |
|
1397 } = ownerDocument; |
|
1398 const range = hiddenCaretRangeFromPoint(ownerDocument, x, y, container); |
|
1399 |
|
1400 if (!range || !container.contains(range.startContainer)) { |
|
1401 if (mayUseScroll && (!range || !range.startContainer || !range.startContainer.contains(container))) { |
|
1402 // Might be out of view. |
|
1403 // Easier than attempting to calculate manually. |
|
1404 container.scrollIntoView(isReverse); |
|
1405 placeCaretAtVerticalEdge(container, isReverse, rect, false); |
|
1406 return; |
|
1407 } |
|
1408 |
|
1409 placeCaretAtHorizontalEdge(container, isReverse); |
|
1410 return; |
|
1411 } |
|
1412 |
|
1413 assertIsDefined(defaultView, 'defaultView'); |
|
1414 const selection = defaultView.getSelection(); |
|
1415 assertIsDefined(selection, 'selection'); |
|
1416 selection.removeAllRanges(); |
|
1417 selection.addRange(range); |
|
1418 } |
|
1419 |
|
1420 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/insert-after.js |
|
1421 /** |
1396 /** |
1422 * Internal dependencies |
1397 * Internal dependencies |
1423 */ |
1398 */ |
1424 |
1399 |
1425 /** |
1400 /** |
1434 function insertAfter(newNode, referenceNode) { |
1409 function insertAfter(newNode, referenceNode) { |
1435 assertIsDefined(referenceNode.parentNode, 'referenceNode.parentNode'); |
1410 assertIsDefined(referenceNode.parentNode, 'referenceNode.parentNode'); |
1436 referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); |
1411 referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); |
1437 } |
1412 } |
1438 |
1413 |
1439 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/remove.js |
1414 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/remove.js |
1440 /** |
1415 /** |
1441 * Internal dependencies |
1416 * Internal dependencies |
1442 */ |
1417 */ |
1443 |
1418 |
1444 /** |
1419 /** |
1451 function remove(node) { |
1426 function remove(node) { |
1452 assertIsDefined(node.parentNode, 'node.parentNode'); |
1427 assertIsDefined(node.parentNode, 'node.parentNode'); |
1453 node.parentNode.removeChild(node); |
1428 node.parentNode.removeChild(node); |
1454 } |
1429 } |
1455 |
1430 |
1456 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/replace.js |
1431 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/replace.js |
1457 /** |
1432 /** |
1458 * Internal dependencies |
1433 * Internal dependencies |
1459 */ |
1434 */ |
1460 |
1435 |
1461 |
1436 |
1472 assertIsDefined(processedNode.parentNode, 'processedNode.parentNode'); |
1447 assertIsDefined(processedNode.parentNode, 'processedNode.parentNode'); |
1473 insertAfter(newNode, processedNode.parentNode); |
1448 insertAfter(newNode, processedNode.parentNode); |
1474 remove(processedNode); |
1449 remove(processedNode); |
1475 } |
1450 } |
1476 |
1451 |
1477 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/unwrap.js |
1452 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/unwrap.js |
1478 /** |
1453 /** |
1479 * Internal dependencies |
1454 * Internal dependencies |
1480 */ |
1455 */ |
1481 |
1456 |
1482 /** |
1457 /** |
1496 } |
1471 } |
1497 |
1472 |
1498 parent.removeChild(node); |
1473 parent.removeChild(node); |
1499 } |
1474 } |
1500 |
1475 |
1501 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/replace-tag.js |
1476 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/replace-tag.js |
1502 /** |
1477 /** |
1503 * Internal dependencies |
1478 * Internal dependencies |
1504 */ |
1479 */ |
1505 |
1480 |
1506 /** |
1481 /** |
1507 * Replaces the given node with a new node with the given tag name. |
1482 * Replaces the given node with a new node with the given tag name. |
1508 * |
1483 * |
1509 * @param {Element} node The node to replace |
1484 * @param {Element} node The node to replace |
1510 * @param {string} tagName The new tag name. |
1485 * @param {string} tagName The new tag name. |
1511 * |
1486 * |
1512 * @return {Element} The new node. |
1487 * @return {Element} The new node. |
1513 */ |
1488 */ |
1514 |
1489 |
1515 function replaceTag(node, tagName) { |
1490 function replaceTag(node, tagName) { |
1522 assertIsDefined(node.parentNode, 'node.parentNode'); |
1497 assertIsDefined(node.parentNode, 'node.parentNode'); |
1523 node.parentNode.replaceChild(newNode, node); |
1498 node.parentNode.replaceChild(newNode, node); |
1524 return newNode; |
1499 return newNode; |
1525 } |
1500 } |
1526 |
1501 |
1527 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/wrap.js |
1502 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/wrap.js |
1528 /** |
1503 /** |
1529 * Internal dependencies |
1504 * Internal dependencies |
1530 */ |
1505 */ |
1531 |
1506 |
1532 /** |
1507 /** |
1540 assertIsDefined(referenceNode.parentNode, 'referenceNode.parentNode'); |
1515 assertIsDefined(referenceNode.parentNode, 'referenceNode.parentNode'); |
1541 referenceNode.parentNode.insertBefore(newNode, referenceNode); |
1516 referenceNode.parentNode.insertBefore(newNode, referenceNode); |
1542 newNode.appendChild(referenceNode); |
1517 newNode.appendChild(referenceNode); |
1543 } |
1518 } |
1544 |
1519 |
1545 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/strip-html.js |
1520 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/safe-html.js |
1521 /** |
|
1522 * Internal dependencies |
|
1523 */ |
|
1524 |
|
1525 /** |
|
1526 * Strips scripts and on* attributes from HTML. |
|
1527 * |
|
1528 * @param {string} html HTML to sanitize. |
|
1529 * |
|
1530 * @return {string} The sanitized HTML. |
|
1531 */ |
|
1532 |
|
1533 function safeHTML(html) { |
|
1534 const { |
|
1535 body |
|
1536 } = document.implementation.createHTMLDocument(''); |
|
1537 body.innerHTML = html; |
|
1538 const elements = body.getElementsByTagName('*'); |
|
1539 let elementIndex = elements.length; |
|
1540 |
|
1541 while (elementIndex--) { |
|
1542 const element = elements[elementIndex]; |
|
1543 |
|
1544 if (element.tagName === 'SCRIPT') { |
|
1545 remove(element); |
|
1546 } else { |
|
1547 let attributeIndex = element.attributes.length; |
|
1548 |
|
1549 while (attributeIndex--) { |
|
1550 const { |
|
1551 name: key |
|
1552 } = element.attributes[attributeIndex]; |
|
1553 |
|
1554 if (key.startsWith('on')) { |
|
1555 element.removeAttribute(key); |
|
1556 } |
|
1557 } |
|
1558 } |
|
1559 } |
|
1560 |
|
1561 return body.innerHTML; |
|
1562 } |
|
1563 |
|
1564 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/strip-html.js |
|
1565 /** |
|
1566 * Internal dependencies |
|
1567 */ |
|
1568 |
|
1546 /** |
1569 /** |
1547 * Removes any HTML tags from the provided string. |
1570 * Removes any HTML tags from the provided string. |
1548 * |
1571 * |
1549 * @param {string} html The string containing html. |
1572 * @param {string} html The string containing html. |
1550 * |
1573 * |
1551 * @return {string} The text content with any html removed. |
1574 * @return {string} The text content with any html removed. |
1552 */ |
1575 */ |
1576 |
|
1553 function stripHTML(html) { |
1577 function stripHTML(html) { |
1554 const document = new window.DOMParser().parseFromString(html, 'text/html'); |
1578 // Remove any script tags or on* attributes otherwise their *contents* will be left |
1555 return document.body.textContent || ''; |
1579 // in place following removal of HTML tags. |
1556 } |
1580 html = safeHTML(html); |
1557 |
1581 const doc = document.implementation.createHTMLDocument(''); |
1558 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-empty.js |
1582 doc.body.innerHTML = html; |
1583 return doc.body.textContent || ''; |
|
1584 } |
|
1585 |
|
1586 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-empty.js |
|
1559 /** |
1587 /** |
1560 * Recursively checks if an element is empty. An element is not empty if it |
1588 * Recursively checks if an element is empty. An element is not empty if it |
1561 * contains text or contains elements with attributes such as images. |
1589 * contains text or contains elements with attributes such as images. |
1562 * |
1590 * |
1563 * @param {Element} element The element to check. |
1591 * @param {Element} element The element to check. |
1586 default: |
1614 default: |
1587 return true; |
1615 return true; |
1588 } |
1616 } |
1589 } |
1617 } |
1590 |
1618 |
1591 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/phrasing-content.js |
1619 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/phrasing-content.js |
1592 /** |
1620 /** |
1593 * External dependencies |
1621 * External dependencies |
1594 */ |
1622 */ |
1595 |
1623 |
1596 /** |
1624 /** |
1603 * @typedef {Record<string,SemanticElementDefinition>} ContentSchema |
1631 * @typedef {Record<string,SemanticElementDefinition>} ContentSchema |
1604 */ |
1632 */ |
1605 |
1633 |
1606 /** |
1634 /** |
1607 * @typedef SemanticElementDefinition |
1635 * @typedef SemanticElementDefinition |
1608 * @property {string[]} [attributes] Content attributes |
1636 * @property {string[]} [attributes] Content attributes |
1609 * @property {ContentSchema} [children] Content attributes |
1637 * @property {ContentSchema} [children] Content attributes |
1610 */ |
1638 */ |
1611 |
1639 |
1612 /** |
1640 /** |
1613 * All text-level semantic elements. |
1641 * All text-level semantic elements. |
1614 * |
1642 * |
1622 em: {}, |
1650 em: {}, |
1623 s: {}, |
1651 s: {}, |
1624 del: {}, |
1652 del: {}, |
1625 ins: {}, |
1653 ins: {}, |
1626 a: { |
1654 a: { |
1627 attributes: ['href', 'target', 'rel'] |
1655 attributes: ['href', 'target', 'rel', 'id'] |
1628 }, |
1656 }, |
1629 code: {}, |
1657 code: {}, |
1630 abbr: { |
1658 abbr: { |
1631 attributes: ['title'] |
1659 attributes: ['title'] |
1632 }, |
1660 }, |
1668 '#text': {} |
1696 '#text': {} |
1669 }; // Recursion is needed. |
1697 }; // Recursion is needed. |
1670 // Possible: strong > em > strong. |
1698 // Possible: strong > em > strong. |
1671 // Impossible: strong > strong. |
1699 // Impossible: strong > strong. |
1672 |
1700 |
1673 Object(external_lodash_["without"])(Object.keys(textContentSchema), '#text', 'br').forEach(tag => { |
1701 (0,external_lodash_namespaceObject.without)(Object.keys(textContentSchema), '#text', 'br').forEach(tag => { |
1674 textContentSchema[tag].children = Object(external_lodash_["omit"])(textContentSchema, tag); |
1702 textContentSchema[tag].children = (0,external_lodash_namespaceObject.omit)(textContentSchema, tag); |
1675 }); |
1703 }); |
1676 /** |
1704 /** |
1677 * Embedded content elements. |
1705 * Embedded content elements. |
1678 * |
1706 * |
1679 * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#embedded-content-0 |
1707 * @see https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#embedded-content-0 |
1714 * Get schema of possible paths for phrasing content. |
1742 * Get schema of possible paths for phrasing content. |
1715 * |
1743 * |
1716 * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content |
1744 * @see https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content |
1717 * |
1745 * |
1718 * @param {string} [context] Set to "paste" to exclude invisible elements and |
1746 * @param {string} [context] Set to "paste" to exclude invisible elements and |
1719 * sensitive data. |
1747 * sensitive data. |
1720 * |
1748 * |
1721 * @return {Partial<ContentSchema>} Schema. |
1749 * @return {Partial<ContentSchema>} Schema. |
1722 */ |
1750 */ |
1723 |
1751 |
1724 function getPhrasingContentSchema(context) { |
1752 function getPhrasingContentSchema(context) { |
1725 if (context !== 'paste') { |
1753 if (context !== 'paste') { |
1726 return phrasingContentSchema; |
1754 return phrasingContentSchema; |
1727 } |
1755 } |
1728 |
1756 |
1729 return Object(external_lodash_["omit"])({ ...phrasingContentSchema, |
1757 return (0,external_lodash_namespaceObject.omit)({ ...phrasingContentSchema, |
1730 // We shouldn't paste potentially sensitive information which is not |
1758 // We shouldn't paste potentially sensitive information which is not |
1731 // visible to the user when pasted, so strip the attributes. |
1759 // visible to the user when pasted, so strip the attributes. |
1732 ins: { |
1760 ins: { |
1733 children: phrasingContentSchema.ins.children |
1761 children: phrasingContentSchema.ins.children |
1734 }, |
1762 }, |
1766 function isTextContent(node) { |
1794 function isTextContent(node) { |
1767 const tag = node.nodeName.toLowerCase(); |
1795 const tag = node.nodeName.toLowerCase(); |
1768 return textContentSchema.hasOwnProperty(tag) || tag === 'span'; |
1796 return textContentSchema.hasOwnProperty(tag) || tag === 'span'; |
1769 } |
1797 } |
1770 |
1798 |
1771 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-element.js |
1799 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/is-element.js |
1772 /* eslint-disable jsdoc/valid-types */ |
1800 /* eslint-disable jsdoc/valid-types */ |
1773 |
1801 |
1774 /** |
1802 /** |
1775 * @param {Node | null | undefined} node |
1803 * @param {Node | null | undefined} node |
1776 * @return {node is Element} True if node is an Element node |
1804 * @return {node is Element} True if node is an Element node |
1778 function isElement(node) { |
1806 function isElement(node) { |
1779 /* eslint-enable jsdoc/valid-types */ |
1807 /* eslint-enable jsdoc/valid-types */ |
1780 return !!node && node.nodeType === node.ELEMENT_NODE; |
1808 return !!node && node.nodeType === node.ELEMENT_NODE; |
1781 } |
1809 } |
1782 |
1810 |
1783 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/clean-node-list.js |
1811 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/clean-node-list.js |
1784 /** |
1812 /** |
1785 * External dependencies |
1813 * External dependencies |
1786 */ |
1814 */ |
1787 |
1815 |
1788 /** |
1816 /** |
1797 |
1825 |
1798 /* eslint-disable jsdoc/valid-types */ |
1826 /* eslint-disable jsdoc/valid-types */ |
1799 |
1827 |
1800 /** |
1828 /** |
1801 * @typedef SchemaItem |
1829 * @typedef SchemaItem |
1802 * @property {string[]} [attributes] Attributes. |
1830 * @property {string[]} [attributes] Attributes. |
1803 * @property {(string | RegExp)[]} [classes] Classnames or RegExp to test against. |
1831 * @property {(string | RegExp)[]} [classes] Classnames or RegExp to test against. |
1804 * @property {'*' | { [tag: string]: SchemaItem }} [children] Child schemas. |
1832 * @property {'*' | { [tag: string]: SchemaItem }} [children] Child schemas. |
1805 * @property {string[]} [require] Selectors to test required children against. Leave empty or undefined if there are no requirements. |
1833 * @property {string[]} [require] Selectors to test required children against. Leave empty or undefined if there are no requirements. |
1806 * @property {boolean} allowEmpty Whether to allow nodes without children. |
1834 * @property {boolean} allowEmpty Whether to allow nodes without children. |
1807 * @property {(node: Node) => boolean} [isMatch] Function to test whether a node is a match. If left undefined any node will be assumed to match. |
1835 * @property {(node: Node) => boolean} [isMatch] Function to test whether a node is a match. If left undefined any node will be assumed to match. |
1808 */ |
1836 */ |
1809 |
1837 |
1810 /** @typedef {{ [tag: string]: SchemaItem }} Schema */ |
1838 /** @typedef {{ [tag: string]: SchemaItem }} Schema */ |
1811 |
1839 |
1812 /* eslint-enable jsdoc/valid-types */ |
1840 /* eslint-enable jsdoc/valid-types */ |
1820 * @param {Schema} schema An array of functions that can mutate with the provided node. |
1848 * @param {Schema} schema An array of functions that can mutate with the provided node. |
1821 * @param {boolean} inline Whether to clean for inline mode. |
1849 * @param {boolean} inline Whether to clean for inline mode. |
1822 */ |
1850 */ |
1823 |
1851 |
1824 function cleanNodeList(nodeList, doc, schema, inline) { |
1852 function cleanNodeList(nodeList, doc, schema, inline) { |
1825 Array.from(nodeList).forEach( |
1853 Array.from(nodeList).forEach(( |
1826 /** @type {Node & { nextElementSibling?: unknown }} */ |
1854 /** @type {Node & { nextElementSibling?: unknown }} */ |
1827 node => { |
1855 node) => { |
1828 var _schema$tag$isMatch, _schema$tag; |
1856 var _schema$tag$isMatch, _schema$tag; |
1829 |
1857 |
1830 const tag = node.nodeName.toLowerCase(); // It's a valid child, if the tag exists in the schema without an isMatch |
1858 const tag = node.nodeName.toLowerCase(); // It's a valid child, if the tag exists in the schema without an isMatch |
1831 // function, or with an isMatch function that matches the node. |
1859 // function, or with an isMatch function that matches the node. |
1832 |
1860 |
1846 return; |
1874 return; |
1847 } |
1875 } |
1848 |
1876 |
1849 if (node.hasAttributes()) { |
1877 if (node.hasAttributes()) { |
1850 // Strip invalid attributes. |
1878 // Strip invalid attributes. |
1851 Array.from(node.attributes).forEach(({ |
1879 Array.from(node.attributes).forEach(_ref => { |
1852 name |
1880 let { |
1853 }) => { |
1881 name |
1854 if (name !== 'class' && !Object(external_lodash_["includes"])(attributes, name)) { |
1882 } = _ref; |
1883 |
|
1884 if (name !== 'class' && !(0,external_lodash_namespaceObject.includes)(attributes, name)) { |
|
1855 node.removeAttribute(name); |
1885 node.removeAttribute(name); |
1856 } |
1886 } |
1857 }); // Strip invalid classes. |
1887 }); // Strip invalid classes. |
1858 // In jsdom-jscore, 'node.classList' can be undefined. |
1888 // In jsdom-jscore, 'node.classList' can be undefined. |
1859 // TODO: Explore patching this in jsdom-jscore. |
1889 // TODO: Explore patching this in jsdom-jscore. |
1860 |
1890 |
1861 if (node.classList && node.classList.length) { |
1891 if (node.classList && node.classList.length) { |
1862 const mattchers = classes.map(item => { |
1892 const mattchers = classes.map(item => { |
1863 if (typeof item === 'string') { |
1893 if (typeof item === 'string') { |
1864 return ( |
1894 return ( |
1865 /** @type {string} */ |
1895 /** @type {string} */ |
1866 className => className === item |
1896 className) => className === item; |
1867 ); |
|
1868 } else if (item instanceof RegExp) { |
1897 } else if (item instanceof RegExp) { |
1869 return ( |
1898 return ( |
1870 /** @type {string} */ |
1899 /** @type {string} */ |
1871 className => item.test(className) |
1900 className) => item.test(className); |
1872 ); |
|
1873 } |
1901 } |
1874 |
1902 |
1875 return external_lodash_["noop"]; |
1903 return external_lodash_namespaceObject.noop; |
1876 }); |
1904 }); |
1877 Array.from(node.classList).forEach(name => { |
1905 Array.from(node.classList).forEach(name => { |
1878 if (!mattchers.some(isMatch => isMatch(name))) { |
1906 if (!mattchers.some(isMatch => isMatch(name))) { |
1879 node.classList.remove(name); |
1907 node.classList.remove(name); |
1880 } |
1908 } |
1930 unwrap(node); |
1958 unwrap(node); |
1931 } |
1959 } |
1932 }); |
1960 }); |
1933 } |
1961 } |
1934 |
1962 |
1935 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/remove-invalid-html.js |
1963 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/remove-invalid-html.js |
1936 /** |
1964 /** |
1937 * Internal dependencies |
1965 * Internal dependencies |
1938 */ |
1966 */ |
1939 |
1967 |
1940 /** |
1968 /** |
1941 * Given a schema, unwraps or removes nodes, attributes and classes on HTML. |
1969 * Given a schema, unwraps or removes nodes, attributes and classes on HTML. |
1942 * |
1970 * |
1943 * @param {string} HTML The HTML to clean up. |
1971 * @param {string} HTML The HTML to clean up. |
1944 * @param {import('./clean-node-list').Schema} schema Schema for the HTML. |
1972 * @param {import('./clean-node-list').Schema} schema Schema for the HTML. |
1945 * @param {boolean} inline Whether to clean for inline mode. |
1973 * @param {boolean} inline Whether to clean for inline mode. |
1946 * |
1974 * |
1947 * @return {string} The cleaned up HTML. |
1975 * @return {string} The cleaned up HTML. |
1948 */ |
1976 */ |
1949 |
1977 |
1950 function removeInvalidHTML(HTML, schema, inline) { |
1978 function removeInvalidHTML(HTML, schema, inline) { |
1952 doc.body.innerHTML = HTML; |
1980 doc.body.innerHTML = HTML; |
1953 cleanNodeList(doc.body.childNodes, doc, schema, inline); |
1981 cleanNodeList(doc.body.childNodes, doc, schema, inline); |
1954 return doc.body.innerHTML; |
1982 return doc.body.innerHTML; |
1955 } |
1983 } |
1956 |
1984 |
1957 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/safe-html.js |
1985 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/index.js |
1958 /** |
1986 |
1959 * Internal dependencies |
1987 |
1960 */ |
1988 |
1961 |
1989 |
1962 /** |
1990 |
1963 * Strips scripts and on* attributes from HTML. |
1991 |
1964 * |
1992 |
1965 * @param {string} html HTML to sanitize. |
1993 |
1966 * |
1994 |
1967 * @return {string} The sanitized HTML. |
1995 |
1968 */ |
1996 |
1969 |
1997 |
1970 function safeHTML(html) { |
1998 |
1971 const { |
1999 |
1972 body |
2000 |
1973 } = document.implementation.createHTMLDocument(''); |
2001 |
1974 body.innerHTML = html; |
2002 |
1975 const elements = body.getElementsByTagName('*'); |
2003 |
1976 let elementIndex = elements.length; |
2004 |
1977 |
2005 |
1978 while (elementIndex--) { |
2006 |
1979 const element = elements[elementIndex]; |
2007 |
1980 |
2008 |
1981 if (element.tagName === 'SCRIPT') { |
2009 |
1982 remove(element); |
2010 |
1983 } else { |
2011 |
1984 let attributeIndex = element.attributes.length; |
2012 |
1985 |
2013 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/data-transfer.js |
1986 while (attributeIndex--) { |
|
1987 const { |
|
1988 name: key |
|
1989 } = element.attributes[attributeIndex]; |
|
1990 |
|
1991 if (key.startsWith('on')) { |
|
1992 element.removeAttribute(key); |
|
1993 } |
|
1994 } |
|
1995 } |
|
1996 } |
|
1997 |
|
1998 return body.innerHTML; |
|
1999 } |
|
2000 |
|
2001 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/dom/index.js |
|
2002 |
|
2003 |
|
2004 |
|
2005 |
|
2006 |
|
2007 |
|
2008 |
|
2009 |
|
2010 |
|
2011 |
|
2012 |
|
2013 |
|
2014 |
|
2015 |
|
2016 |
|
2017 |
|
2018 |
|
2019 |
|
2020 |
|
2021 |
|
2022 |
|
2023 |
|
2024 |
|
2025 |
|
2026 |
|
2027 |
|
2028 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/data-transfer.js |
|
2029 /** |
2014 /** |
2030 * Gets all files from a DataTransfer object. |
2015 * Gets all files from a DataTransfer object. |
2031 * |
2016 * |
2032 * @param {DataTransfer} dataTransfer DataTransfer object to inspect. |
2017 * @param {DataTransfer} dataTransfer DataTransfer object to inspect. |
2033 * |
2018 * |
2036 function getFilesFromDataTransfer(dataTransfer) { |
2021 function getFilesFromDataTransfer(dataTransfer) { |
2037 const files = Array.from(dataTransfer.files); |
2022 const files = Array.from(dataTransfer.files); |
2038 Array.from(dataTransfer.items).forEach(item => { |
2023 Array.from(dataTransfer.items).forEach(item => { |
2039 const file = item.getAsFile(); |
2024 const file = item.getAsFile(); |
2040 |
2025 |
2041 if (file && !files.find(({ |
2026 if (file && !files.find(_ref => { |
2042 name, |
2027 let { |
2043 type, |
2028 name, |
2044 size |
2029 type, |
2045 }) => name === file.name && type === file.type && size === file.size)) { |
2030 size |
2031 } = _ref; |
|
2032 return name === file.name && type === file.type && size === file.size; |
|
2033 })) { |
|
2046 files.push(file); |
2034 files.push(file); |
2047 } |
2035 } |
2048 }); |
2036 }); |
2049 return files; |
2037 return files; |
2050 } |
2038 } |
2051 |
2039 |
2052 // CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/index.js |
2040 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dom/build-module/index.js |
2053 /** |
2041 /** |
2054 * Internal dependencies |
2042 * Internal dependencies |
2055 */ |
2043 */ |
2056 |
2044 |
2057 |
2045 |
2066 }; |
2054 }; |
2067 |
2055 |
2068 |
2056 |
2069 |
2057 |
2070 |
2058 |
2071 |
2059 (window.wp = window.wp || {}).dom = __webpack_exports__; |
2072 /***/ }), |
2060 /******/ })() |
2073 |
2061 ; |
2074 /***/ "YLtl": |
|
2075 /***/ (function(module, exports) { |
|
2076 |
|
2077 (function() { module.exports = window["lodash"]; }()); |
|
2078 |
|
2079 /***/ }) |
|
2080 |
|
2081 /******/ }); |