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