kollapsminoriteten/wp-includes/js/dist/dom.js

1223 lines
34 KiB
JavaScript
Raw Normal View History

2024-04-17 11:32:24 +02:00
/******/ (() => { // webpackBootstrap
2022-06-16 14:03:35 +02:00
/******/ "use strict";
/******/ // The require scope
/******/ var __webpack_require__ = {};
/******/
/************************************************************************/
2022-12-15 17:47:31 +01:00
/******/ /* webpack/runtime/compat get default export */
2024-04-17 11:32:24 +02:00
/******/ (() => {
2022-12-15 17:47:31 +01:00
/******/ // getDefaultExport function for compatibility with non-harmony modules
2024-04-17 11:32:24 +02:00
/******/ __webpack_require__.n = (module) => {
2022-12-15 17:47:31 +01:00
/******/ var getter = module && module.__esModule ?
2024-04-17 11:32:24 +02:00
/******/ () => (module['default']) :
/******/ () => (module);
2022-12-15 17:47:31 +01:00
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
2024-04-17 11:32:24 +02:00
/******/ })();
2022-12-15 17:47:31 +01:00
/******/
2022-06-16 14:03:35 +02:00
/******/ /* webpack/runtime/define property getters */
2024-04-17 11:32:24 +02:00
/******/ (() => {
2022-06-16 14:03:35 +02:00
/******/ // define getter functions for harmony exports
2024-04-17 11:32:24 +02:00
/******/ __webpack_require__.d = (exports, definition) => {
2022-06-16 14:03:35 +02:00
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
2024-04-17 11:32:24 +02:00
/******/ })();
2022-06-16 14:03:35 +02:00
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
2024-04-17 11:32:24 +02:00
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
2022-06-16 14:03:35 +02:00
/******/
/******/ /* webpack/runtime/make namespace object */
2024-04-17 11:32:24 +02:00
/******/ (() => {
2022-06-16 14:03:35 +02:00
/******/ // define __esModule on exports
2024-04-17 11:32:24 +02:00
/******/ __webpack_require__.r = (exports) => {
2022-06-16 14:03:35 +02:00
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
2019-11-02 10:38:58 +01:00
/******/ };
2024-04-17 11:32:24 +02:00
/******/ })();
2022-06-16 14:03:35 +02:00
/******/
2019-11-02 10:38:58 +01:00
/************************************************************************/
2022-06-16 14:03:35 +02:00
var __webpack_exports__ = {};
2020-09-15 14:29:22 +02:00
// ESM COMPAT FLAG
2019-11-02 10:38:58 +01:00
__webpack_require__.r(__webpack_exports__);
2020-09-15 14:29:22 +02:00
// EXPORTS
2022-06-16 14:03:35 +02:00
__webpack_require__.d(__webpack_exports__, {
2024-04-17 11:32:24 +02:00
__unstableStripHTML: () => (/* reexport */ stripHTML),
computeCaretRect: () => (/* reexport */ computeCaretRect),
documentHasSelection: () => (/* reexport */ documentHasSelection),
documentHasTextSelection: () => (/* reexport */ documentHasTextSelection),
documentHasUncollapsedSelection: () => (/* reexport */ documentHasUncollapsedSelection),
focus: () => (/* binding */ build_module_focus),
getFilesFromDataTransfer: () => (/* reexport */ getFilesFromDataTransfer),
getOffsetParent: () => (/* reexport */ getOffsetParent),
getPhrasingContentSchema: () => (/* reexport */ getPhrasingContentSchema),
getRectangleFromRange: () => (/* reexport */ getRectangleFromRange),
getScrollContainer: () => (/* reexport */ getScrollContainer),
insertAfter: () => (/* reexport */ insertAfter),
isEmpty: () => (/* reexport */ isEmpty),
isEntirelySelected: () => (/* reexport */ isEntirelySelected),
isFormElement: () => (/* reexport */ isFormElement),
isHorizontalEdge: () => (/* reexport */ isHorizontalEdge),
isNumberInput: () => (/* reexport */ isNumberInput),
isPhrasingContent: () => (/* reexport */ isPhrasingContent),
isRTL: () => (/* reexport */ isRTL),
2025-02-28 08:42:11 +01:00
isSelectionForward: () => (/* reexport */ isSelectionForward),
2024-04-17 11:32:24 +02:00
isTextContent: () => (/* reexport */ isTextContent),
isTextField: () => (/* reexport */ isTextField),
isVerticalEdge: () => (/* reexport */ isVerticalEdge),
placeCaretAtHorizontalEdge: () => (/* reexport */ placeCaretAtHorizontalEdge),
placeCaretAtVerticalEdge: () => (/* reexport */ placeCaretAtVerticalEdge),
remove: () => (/* reexport */ remove),
removeInvalidHTML: () => (/* reexport */ removeInvalidHTML),
replace: () => (/* reexport */ replace),
replaceTag: () => (/* reexport */ replaceTag),
safeHTML: () => (/* reexport */ safeHTML),
unwrap: () => (/* reexport */ unwrap),
wrap: () => (/* reexport */ wrap)
2022-06-16 14:03:35 +02:00
});
2020-09-15 14:29:22 +02:00
// NAMESPACE OBJECT: ./node_modules/@wordpress/dom/build-module/focusable.js
2019-11-02 10:38:58 +01:00
var focusable_namespaceObject = {};
__webpack_require__.r(focusable_namespaceObject);
2022-06-16 14:03:35 +02:00
__webpack_require__.d(focusable_namespaceObject, {
2024-04-17 11:32:24 +02:00
find: () => (find)
2022-06-16 14:03:35 +02:00
});
2020-09-15 14:29:22 +02:00
// NAMESPACE OBJECT: ./node_modules/@wordpress/dom/build-module/tabbable.js
2019-11-02 10:38:58 +01:00
var tabbable_namespaceObject = {};
__webpack_require__.r(tabbable_namespaceObject);
2022-06-16 14:03:35 +02:00
__webpack_require__.d(tabbable_namespaceObject, {
2024-04-17 11:32:24 +02:00
find: () => (tabbable_find),
findNext: () => (findNext),
findPrevious: () => (findPrevious),
isTabbableIndex: () => (isTabbableIndex)
2022-06-16 14:03:35 +02:00
});
2019-11-02 10:38:58 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/focusable.js
2022-04-02 10:26:41 +02:00
function buildSelector(sequential) {
2025-12-12 13:15:55 +01:00
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",
"summary",
"area[href]",
"[contenteditable]:not([contenteditable=false])"
].join(",");
2019-11-02 10:38:58 +01:00
}
2022-04-02 10:26:41 +02:00
function isVisible(element) {
return element.offsetWidth > 0 || element.offsetHeight > 0 || element.getClientRects().length > 0;
2020-09-15 14:29:22 +02:00
}
2019-11-02 10:38:58 +01:00
function isValidFocusableArea(element) {
2025-12-12 13:15:55 +01:00
const map = element.closest("map[name]");
2019-11-02 10:38:58 +01:00
if (!map) {
return false;
}
2025-12-12 13:15:55 +01:00
const img = element.ownerDocument.querySelector(
'img[usemap="#' + map.name + '"]'
);
2019-11-02 10:38:58 +01:00
return !!img && isVisible(img);
}
2025-12-12 13:15:55 +01:00
function find(context, { sequential = false } = {}) {
2022-04-02 10:26:41 +02:00
const elements = context.querySelectorAll(buildSelector(sequential));
2025-12-12 13:15:55 +01:00
return Array.from(elements).filter((element) => {
2022-04-02 10:26:41 +02:00
if (!isVisible(element)) {
2019-11-02 10:38:58 +01:00
return false;
}
2025-12-12 13:15:55 +01:00
const { nodeName } = element;
if ("AREA" === nodeName) {
return isValidFocusableArea(
/** @type {HTMLAreaElement} */
element
);
2019-11-02 10:38:58 +01:00
}
return true;
});
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/tabbable.js
2025-12-12 13:15:55 +01:00
2019-11-02 10:38:58 +01:00
function getTabIndex(element) {
2025-12-12 13:15:55 +01:00
const tabIndex = element.getAttribute("tabindex");
2019-11-02 10:38:58 +01:00
return tabIndex === null ? 0 : parseInt(tabIndex, 10);
}
function isTabbableIndex(element) {
return getTabIndex(element) !== -1;
}
function createStatefulCollapseRadioGroup() {
2021-07-23 11:58:50 +02:00
const CHOSEN_RADIO_BY_NAME = {};
2025-12-12 13:15:55 +01:00
return function collapseRadioGroup(result, element) {
const { nodeName, type, checked, name } = element;
if (nodeName !== "INPUT" || type !== "radio" || !name) {
2019-11-02 10:38:58 +01:00
return result.concat(element);
}
2023-12-07 09:44:11 +01:00
const hasChosen = CHOSEN_RADIO_BY_NAME.hasOwnProperty(name);
2021-07-23 11:58:50 +02:00
const isChosen = checked || !hasChosen;
2019-11-02 10:38:58 +01:00
if (!isChosen) {
return result;
2023-12-07 09:44:11 +01:00
}
2019-11-02 10:38:58 +01:00
if (hasChosen) {
2021-07-23 11:58:50 +02:00
const hadChosenElement = CHOSEN_RADIO_BY_NAME[name];
2025-12-12 13:15:55 +01:00
result = result.filter((e) => e !== hadChosenElement);
2019-11-02 10:38:58 +01:00
}
CHOSEN_RADIO_BY_NAME[name] = element;
return result.concat(element);
};
}
function mapElementToObjectTabbable(element, index) {
2025-12-12 13:15:55 +01:00
return { element, index };
2019-11-02 10:38:58 +01:00
}
function mapObjectTabbableToElement(object) {
return object.element;
}
function compareObjectTabbables(a, b) {
2021-07-23 11:58:50 +02:00
const aTabIndex = getTabIndex(a.element);
const bTabIndex = getTabIndex(b.element);
2019-11-02 10:38:58 +01:00
if (aTabIndex === bTabIndex) {
return a.index - b.index;
}
return aTabIndex - bTabIndex;
}
2020-05-06 17:23:38 +02:00
function filterTabbable(focusables) {
return focusables.filter(isTabbableIndex).map(mapElementToObjectTabbable).sort(compareObjectTabbables).map(mapObjectTabbableToElement).reduce(createStatefulCollapseRadioGroup(), []);
}
2019-11-02 10:38:58 +01:00
function tabbable_find(context) {
2020-05-06 17:23:38 +02:00
return filterTabbable(find(context));
}
2020-12-10 14:06:04 +01:00
function findPrevious(element) {
2025-12-12 13:15:55 +01:00
return filterTabbable(find(element.ownerDocument.body)).reverse().find(
(focusable) => (
// eslint-disable-next-line no-bitwise
element.compareDocumentPosition(focusable) & element.DOCUMENT_POSITION_PRECEDING
)
);
2020-05-06 17:23:38 +02:00
}
2020-12-10 14:06:04 +01:00
function findNext(element) {
2025-12-12 13:15:55 +01:00
return filterTabbable(find(element.ownerDocument.body)).find(
(focusable) => (
// eslint-disable-next-line no-bitwise
element.compareDocumentPosition(focusable) & element.DOCUMENT_POSITION_FOLLOWING
)
);
2019-11-02 10:38:58 +01:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/utils/assert-is-defined.js
2021-07-23 11:58:50 +02:00
function assertIsDefined(val, name) {
if (false) {}
}
2021-04-27 08:32:47 +02:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/get-rectangle-from-range.js
2025-12-12 13:15:55 +01:00
2021-07-23 11:58:50 +02:00
function getRectangleFromRange(range) {
if (!range.collapsed) {
2025-12-12 13:15:55 +01:00
const rects2 = Array.from(range.getClientRects());
if (rects2.length === 1) {
return rects2[0];
2023-12-07 09:44:11 +01:00
}
2025-12-12 13:15:55 +01:00
const filteredRects = rects2.filter(({ width }) => width > 1);
2021-07-23 11:58:50 +02:00
if (filteredRects.length === 0) {
return range.getBoundingClientRect();
}
if (filteredRects.length === 1) {
return filteredRects[0];
}
let {
top: furthestTop,
bottom: furthestBottom,
left: furthestLeft,
right: furthestRight
} = filteredRects[0];
2025-12-12 13:15:55 +01:00
for (const { top, bottom, left, right } of filteredRects) {
2025-02-28 08:42:11 +01:00
if (top < furthestTop) {
furthestTop = top;
}
if (bottom > furthestBottom) {
furthestBottom = bottom;
}
if (left < furthestLeft) {
furthestLeft = left;
}
if (right > furthestRight) {
furthestRight = right;
}
2021-07-23 11:58:50 +02:00
}
2025-12-12 13:15:55 +01:00
return new window.DOMRect(
furthestLeft,
furthestTop,
furthestRight - furthestLeft,
furthestBottom - furthestTop
);
2021-07-23 11:58:50 +02:00
}
2025-12-12 13:15:55 +01:00
const { startContainer } = range;
const { ownerDocument } = startContainer;
if (startContainer.nodeName === "BR") {
const { parentNode } = startContainer;
assertIsDefined(parentNode, "parentNode");
const index = (
/** @type {Node[]} */
Array.from(parentNode.childNodes).indexOf(startContainer)
);
assertIsDefined(ownerDocument, "ownerDocument");
2021-07-23 11:58:50 +02:00
range = ownerDocument.createRange();
range.setStart(parentNode, index);
range.setEnd(parentNode, index);
}
2023-12-07 09:44:11 +01:00
const rects = range.getClientRects();
2022-12-15 17:47:31 +01:00
if (rects.length > 1) {
return null;
}
2023-12-07 09:44:11 +01:00
let rect = rects[0];
2023-09-26 10:33:34 +02:00
if (!rect || rect.height === 0) {
2025-12-12 13:15:55 +01:00
assertIsDefined(ownerDocument, "ownerDocument");
const padNode = ownerDocument.createTextNode("\u200B");
2021-07-23 11:58:50 +02:00
range = range.cloneRange();
range.insertNode(padNode);
rect = range.getClientRects()[0];
2025-12-12 13:15:55 +01:00
assertIsDefined(padNode.parentNode, "padNode.parentNode");
2021-07-23 11:58:50 +02:00
padNode.parentNode.removeChild(padNode);
}
return rect;
}
2020-12-10 14:06:04 +01:00
2025-12-12 13:15:55 +01:00
;// ./node_modules/@wordpress/dom/build-module/dom/compute-caret-rect.js
2021-07-23 11:58:50 +02:00
2023-12-07 09:44:11 +01:00
2021-07-23 11:58:50 +02:00
function computeCaretRect(win) {
const selection = win.getSelection();
2025-12-12 13:15:55 +01:00
assertIsDefined(selection, "selection");
2021-07-23 11:58:50 +02:00
const range = selection.rangeCount ? selection.getRangeAt(0) : null;
if (!range) {
return null;
}
return getRectangleFromRange(range);
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/document-has-text-selection.js
2025-12-12 13:15:55 +01:00
2021-07-23 11:58:50 +02:00
function documentHasTextSelection(doc) {
2025-12-12 13:15:55 +01:00
assertIsDefined(doc.defaultView, "doc.defaultView");
2021-07-23 11:58:50 +02:00
const selection = doc.defaultView.getSelection();
2025-12-12 13:15:55 +01:00
assertIsDefined(selection, "selection");
2021-07-23 11:58:50 +02:00
const range = selection.rangeCount ? selection.getRangeAt(0) : null;
return !!range && !range.collapsed;
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/is-html-input-element.js
2021-07-23 11:58:50 +02:00
function isHTMLInputElement(node) {
2025-12-12 13:15:55 +01:00
return node?.nodeName === "INPUT";
2021-07-23 11:58:50 +02:00
}
2020-12-10 14:06:04 +01:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/is-text-field.js
2025-12-12 13:15:55 +01:00
2021-07-23 11:58:50 +02:00
function isTextField(node) {
2025-12-12 13:15:55 +01:00
const nonTextInputs = [
"button",
"checkbox",
"hidden",
"file",
"radio",
"image",
"range",
"reset",
"submit",
"number",
"email",
"time"
];
return isHTMLInputElement(node) && node.type && !nonTextInputs.includes(node.type) || node.nodeName === "TEXTAREA" || /** @type {HTMLElement} */
node.contentEditable === "true";
2021-07-23 11:58:50 +02:00
}
2020-12-10 14:06:04 +01:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/input-field-has-uncollapsed-selection.js
2025-12-12 13:15:55 +01:00
2021-07-23 11:58:50 +02:00
function inputFieldHasUncollapsedSelection(element) {
2022-12-15 17:47:31 +01:00
if (!isHTMLInputElement(element) && !isTextField(element)) {
2021-07-23 11:58:50 +02:00
return false;
2023-12-07 09:44:11 +01:00
}
2021-07-23 11:58:50 +02:00
try {
2025-12-12 13:15:55 +01:00
const { selectionStart, selectionEnd } = (
/** @type {HTMLInputElement | HTMLTextAreaElement} */
element
);
2023-12-07 09:44:11 +01:00
return (
// `null` means the input type doesn't implement selection, thus we
2022-12-15 17:47:31 +01:00
// cannot determine whether the selection is collapsed, so we
// default to true.
2025-12-12 13:15:55 +01:00
selectionStart === null || // when not null, compare the two points
2022-12-15 17:47:31 +01:00
selectionStart !== selectionEnd
);
2021-07-23 11:58:50 +02:00
} catch (error) {
2022-12-15 17:47:31 +01:00
return true;
2021-07-23 11:58:50 +02:00
}
2020-12-10 14:06:04 +01:00
}
2021-07-23 11:58:50 +02:00
2025-12-12 13:15:55 +01:00
;// ./node_modules/@wordpress/dom/build-module/dom/document-has-uncollapsed-selection.js
2021-07-23 11:58:50 +02:00
2023-12-07 09:44:11 +01:00
2021-07-23 11:58:50 +02:00
function documentHasUncollapsedSelection(doc) {
return documentHasTextSelection(doc) || !!doc.activeElement && inputFieldHasUncollapsedSelection(doc.activeElement);
2020-12-10 14:06:04 +01:00
}
2021-07-23 11:58:50 +02:00
2025-12-12 13:15:55 +01:00
;// ./node_modules/@wordpress/dom/build-module/dom/document-has-selection.js
2021-04-27 08:32:47 +02:00
2023-12-07 09:44:11 +01:00
2021-07-23 11:58:50 +02:00
function documentHasSelection(doc) {
2022-12-15 17:47:31 +01:00
return !!doc.activeElement && (isHTMLInputElement(doc.activeElement) || isTextField(doc.activeElement) || documentHasTextSelection(doc));
2021-07-23 11:58:50 +02:00
}
2025-12-12 13:15:55 +01:00
;// ./node_modules/@wordpress/dom/build-module/dom/get-computed-style.js
2021-07-23 11:58:50 +02:00
function getComputedStyle(element) {
2025-12-12 13:15:55 +01:00
assertIsDefined(
element.ownerDocument.defaultView,
"element.ownerDocument.defaultView"
);
2021-07-23 11:58:50 +02:00
return element.ownerDocument.defaultView.getComputedStyle(element);
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/get-scroll-container.js
2025-12-12 13:15:55 +01:00
function getScrollContainer(node, direction = "vertical") {
2021-07-23 11:58:50 +02:00
if (!node) {
2025-12-12 13:15:55 +01:00
return void 0;
2023-09-26 10:33:34 +02:00
}
2025-12-12 13:15:55 +01:00
if (direction === "vertical" || direction === "all") {
2023-09-26 10:33:34 +02:00
if (node.scrollHeight > node.clientHeight) {
2025-12-12 13:15:55 +01:00
const { overflowY } = getComputedStyle(node);
2023-09-26 10:33:34 +02:00
if (/(auto|scroll)/.test(overflowY)) {
return node;
}
}
}
2025-12-12 13:15:55 +01:00
if (direction === "horizontal" || direction === "all") {
2023-09-26 10:33:34 +02:00
if (node.scrollWidth > node.clientWidth) {
2025-12-12 13:15:55 +01:00
const { overflowX } = getComputedStyle(node);
2023-09-26 10:33:34 +02:00
if (/(auto|scroll)/.test(overflowX)) {
return node;
}
2021-07-23 11:58:50 +02:00
}
2022-12-15 17:47:31 +01:00
}
if (node.ownerDocument === node.parentNode) {
return node;
2023-12-07 09:44:11 +01:00
}
2025-12-12 13:15:55 +01:00
return getScrollContainer(
/** @type {Element} */
node.parentNode,
direction
);
2021-07-23 11:58:50 +02:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/get-offset-parent.js
2025-12-12 13:15:55 +01:00
2021-07-23 11:58:50 +02:00
function getOffsetParent(node) {
let closestElement;
2025-12-12 13:15:55 +01:00
while (closestElement = /** @type {Node} */
node.parentNode) {
2021-07-23 11:58:50 +02:00
if (closestElement.nodeType === closestElement.ELEMENT_NODE) {
break;
}
}
if (!closestElement) {
return null;
2023-12-07 09:44:11 +01:00
}
2025-12-12 13:15:55 +01:00
if (getComputedStyle(
/** @type {Element} */
closestElement
).position !== "static") {
2021-07-23 11:58:50 +02:00
return closestElement;
2023-12-07 09:44:11 +01:00
}
2025-12-12 13:15:55 +01:00
return (
/** @type {Node & { offsetParent: Node }} */
closestElement.offsetParent
);
2020-12-10 14:06:04 +01:00
}
2021-07-23 11:58:50 +02:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/is-input-or-text-area.js
2021-07-23 11:58:50 +02:00
function isInputOrTextArea(element) {
2025-12-12 13:15:55 +01:00
return element.tagName === "INPUT" || element.tagName === "TEXTAREA";
2021-07-23 11:58:50 +02:00
}
2025-12-12 13:15:55 +01:00
;// ./node_modules/@wordpress/dom/build-module/dom/is-entirely-selected.js
2021-07-23 11:58:50 +02:00
2023-12-07 09:44:11 +01:00
2021-07-23 11:58:50 +02:00
function isEntirelySelected(element) {
if (isInputOrTextArea(element)) {
return element.selectionStart === 0 && element.value.length === element.selectionEnd;
}
if (!element.isContentEditable) {
return true;
}
2025-12-12 13:15:55 +01:00
const { ownerDocument } = element;
const { defaultView } = ownerDocument;
assertIsDefined(defaultView, "defaultView");
2021-07-23 11:58:50 +02:00
const selection = defaultView.getSelection();
2025-12-12 13:15:55 +01:00
assertIsDefined(selection, "selection");
2021-07-23 11:58:50 +02:00
const range = selection.rangeCount ? selection.getRangeAt(0) : null;
if (!range) {
return true;
}
2025-12-12 13:15:55 +01:00
const { startContainer, endContainer, startOffset, endOffset } = range;
2021-07-23 11:58:50 +02:00
if (startContainer === element && endContainer === element && startOffset === 0 && endOffset === element.childNodes.length) {
return true;
}
const lastChild = element.lastChild;
2025-12-12 13:15:55 +01:00
assertIsDefined(lastChild, "lastChild");
const endContainerContentLength = endContainer.nodeType === endContainer.TEXT_NODE ? (
/** @type {Text} */
endContainer.data.length
) : endContainer.childNodes.length;
return isDeepChild(startContainer, element, "firstChild") && isDeepChild(endContainer, element, "lastChild") && startOffset === 0 && endOffset === endContainerContentLength;
2021-07-23 11:58:50 +02:00
}
function isDeepChild(query, container, propName) {
let candidate = container;
do {
if (query === candidate) {
return true;
}
candidate = candidate[propName];
} while (candidate);
return false;
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/is-form-element.js
2025-12-12 13:15:55 +01:00
2022-06-16 14:03:35 +02:00
function isFormElement(element) {
2022-12-15 17:47:31 +01:00
if (!element) {
return false;
}
2025-12-12 13:15:55 +01:00
const { tagName } = element;
2022-06-16 14:03:35 +02:00
const checkForInputTextarea = isInputOrTextArea(element);
2025-12-12 13:15:55 +01:00
return checkForInputTextarea || tagName === "BUTTON" || tagName === "SELECT";
2022-06-16 14:03:35 +02:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/is-rtl.js
2025-12-12 13:15:55 +01:00
2021-07-23 11:58:50 +02:00
function isRTL(element) {
2025-12-12 13:15:55 +01:00
return getComputedStyle(element).direction === "rtl";
2021-07-23 11:58:50 +02:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/get-range-height.js
2021-04-27 08:32:47 +02:00
function getRangeHeight(range) {
2021-07-23 11:58:50 +02:00
const rects = Array.from(range.getClientRects());
2021-04-27 08:32:47 +02:00
if (!rects.length) {
return;
}
2025-12-12 13:15:55 +01:00
const highestTop = Math.min(...rects.map(({ top }) => top));
const lowestBottom = Math.max(...rects.map(({ bottom }) => bottom));
2021-04-27 08:32:47 +02:00
return lowestBottom - highestTop;
}
2021-07-23 11:58:50 +02:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/is-selection-forward.js
2025-12-12 13:15:55 +01:00
2019-11-02 10:38:58 +01:00
function isSelectionForward(selection) {
2025-12-12 13:15:55 +01:00
const { anchorNode, focusNode, anchorOffset, focusOffset } = selection;
assertIsDefined(anchorNode, "anchorNode");
assertIsDefined(focusNode, "focusNode");
2023-12-07 09:44:11 +01:00
const position = anchorNode.compareDocumentPosition(focusNode);
2020-12-10 14:06:04 +01:00
if (position & anchorNode.DOCUMENT_POSITION_PRECEDING) {
2019-11-02 10:38:58 +01:00
return false;
}
2020-12-10 14:06:04 +01:00
if (position & anchorNode.DOCUMENT_POSITION_FOLLOWING) {
2019-11-02 10:38:58 +01:00
return true;
}
if (position === 0) {
return anchorOffset <= focusOffset;
2023-12-07 09:44:11 +01:00
}
2019-11-02 10:38:58 +01:00
return true;
}
2021-07-23 11:58:50 +02:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/caret-range-from-point.js
2021-07-23 11:58:50 +02:00
function caretRangeFromPoint(doc, x, y) {
if (doc.caretRangeFromPoint) {
return doc.caretRangeFromPoint(x, y);
}
if (!doc.caretPositionFromPoint) {
return null;
}
2023-12-07 09:44:11 +01:00
const point = doc.caretPositionFromPoint(x, y);
2021-07-23 11:58:50 +02:00
if (!point) {
return null;
}
const range = doc.createRange();
range.setStart(point.offsetNode, point.offset);
range.collapse(true);
return range;
}
2023-12-07 09:44:11 +01:00
2021-07-23 11:58:50 +02:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/hidden-caret-range-from-point.js
2025-12-12 13:15:55 +01:00
2021-07-23 11:58:50 +02:00
function hiddenCaretRangeFromPoint(doc, x, y, container) {
const originalZIndex = container.style.zIndex;
const originalPosition = container.style.position;
2025-12-12 13:15:55 +01:00
const { position = "static" } = getComputedStyle(container);
if (position === "static") {
container.style.position = "relative";
2021-07-23 11:58:50 +02:00
}
2025-12-12 13:15:55 +01:00
container.style.zIndex = "10000";
2021-07-23 11:58:50 +02:00
const range = caretRangeFromPoint(doc, x, y);
container.style.zIndex = originalZIndex;
container.style.position = originalPosition;
return range;
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/scroll-if-no-range.js
2023-12-07 09:44:11 +01:00
function scrollIfNoRange(container, alignToTop, callback) {
let range = callback();
if (!range || !range.startContainer || !container.contains(range.startContainer)) {
container.scrollIntoView(alignToTop);
range = callback();
if (!range || !range.startContainer || !container.contains(range.startContainer)) {
return null;
}
}
return range;
}
2021-07-23 11:58:50 +02:00
2025-12-12 13:15:55 +01:00
;// ./node_modules/@wordpress/dom/build-module/dom/is-edge.js
2021-07-23 11:58:50 +02:00
2023-12-07 09:44:11 +01:00
2023-09-26 10:33:34 +02:00
function isEdge(container, isReverse, onlyVertical = false) {
2025-12-12 13:15:55 +01:00
if (isInputOrTextArea(container) && typeof container.selectionStart === "number") {
2019-11-02 10:38:58 +01:00
if (container.selectionStart !== container.selectionEnd) {
return false;
}
if (isReverse) {
return container.selectionStart === 0;
}
return container.value.length === container.selectionStart;
}
2025-02-28 08:42:11 +01:00
if (!container.isContentEditable) {
2019-11-02 10:38:58 +01:00
return true;
}
2025-12-12 13:15:55 +01:00
const { ownerDocument } = container;
const { defaultView } = ownerDocument;
assertIsDefined(defaultView, "defaultView");
2021-07-23 11:58:50 +02:00
const selection = defaultView.getSelection();
if (!selection || !selection.rangeCount) {
2019-11-02 10:38:58 +01:00
return false;
}
2021-07-23 11:58:50 +02:00
const range = selection.getRangeAt(0);
const collapsedRange = range.cloneRange();
const isForward = isSelectionForward(selection);
2023-12-07 09:44:11 +01:00
const isCollapsed = selection.isCollapsed;
2019-11-02 10:38:58 +01:00
if (!isCollapsed) {
2021-04-27 08:32:47 +02:00
collapsedRange.collapse(!isForward);
2019-11-02 10:38:58 +01:00
}
2021-07-23 11:58:50 +02:00
const collapsedRangeRect = getRectangleFromRange(collapsedRange);
const rangeRect = getRectangleFromRange(range);
2021-04-27 08:32:47 +02:00
if (!collapsedRangeRect || !rangeRect) {
2019-11-02 10:38:58 +01:00
return false;
2023-12-07 09:44:11 +01:00
}
2021-07-23 11:58:50 +02:00
const rangeHeight = getRangeHeight(range);
if (!isCollapsed && rangeHeight && rangeHeight > collapsedRangeRect.height && isForward === isReverse) {
2019-11-02 10:38:58 +01:00
return false;
2023-12-07 09:44:11 +01:00
}
2021-07-23 11:58:50 +02:00
const isReverseDir = isRTL(container) ? !isReverse : isReverse;
2023-12-07 09:44:11 +01:00
const containerRect = container.getBoundingClientRect();
2021-07-23 11:58:50 +02:00
const x = isReverseDir ? containerRect.left + 1 : containerRect.right - 1;
const y = isReverse ? containerRect.top + 1 : containerRect.bottom - 1;
2025-12-12 13:15:55 +01:00
const testRange = scrollIfNoRange(
container,
isReverse,
() => hiddenCaretRangeFromPoint(ownerDocument, x, y, container)
);
2019-11-02 10:38:58 +01:00
if (!testRange) {
return false;
}
2021-07-23 11:58:50 +02:00
const testRect = getRectangleFromRange(testRange);
2021-04-27 08:32:47 +02:00
if (!testRect) {
return false;
}
2025-12-12 13:15:55 +01:00
const verticalSide = isReverse ? "top" : "bottom";
const horizontalSide = isReverseDir ? "left" : "right";
2021-07-23 11:58:50 +02:00
const verticalDiff = testRect[verticalSide] - rangeRect[verticalSide];
2023-12-07 09:44:11 +01:00
const horizontalDiff = testRect[horizontalSide] - collapsedRangeRect[horizontalSide];
2021-07-23 11:58:50 +02:00
const hasVerticalDiff = Math.abs(verticalDiff) <= 1;
const hasHorizontalDiff = Math.abs(horizontalDiff) <= 1;
2021-04-27 08:32:47 +02:00
return onlyVertical ? hasVerticalDiff : hasVerticalDiff && hasHorizontalDiff;
2019-11-02 10:38:58 +01:00
}
2021-07-23 11:58:50 +02:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/is-horizontal-edge.js
2025-12-12 13:15:55 +01:00
2019-11-02 10:38:58 +01:00
function isHorizontalEdge(container, isReverse) {
return isEdge(container, isReverse);
}
2021-07-23 11:58:50 +02:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// external ["wp","deprecated"]
2024-04-17 11:32:24 +02:00
const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
2022-12-15 17:47:31 +01:00
var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/is-number-input.js
2022-12-15 17:47:31 +01:00
2023-12-07 09:44:11 +01:00
2022-12-15 17:47:31 +01:00
function isNumberInput(node) {
2025-12-12 13:15:55 +01:00
external_wp_deprecated_default()("wp.dom.isNumberInput", {
since: "6.1",
version: "6.5"
2022-12-15 17:47:31 +01:00
});
2025-12-12 13:15:55 +01:00
return isHTMLInputElement(node) && node.type === "number" && !isNaN(node.valueAsNumber);
2022-12-15 17:47:31 +01:00
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/is-vertical-edge.js
2025-12-12 13:15:55 +01:00
2019-11-02 10:38:58 +01:00
function isVerticalEdge(container, isReverse) {
return isEdge(container, isReverse, true);
}
2021-07-23 11:58:50 +02:00
2019-11-02 10:38:58 +01:00
2025-12-12 13:15:55 +01:00
;// ./node_modules/@wordpress/dom/build-module/dom/place-caret-at-edge.js
2019-11-02 10:38:58 +01:00
2023-12-07 09:44:11 +01:00
2022-04-02 10:26:41 +02:00
function getRange(container, isReverse, x) {
2025-12-12 13:15:55 +01:00
const { ownerDocument } = container;
2021-07-23 11:58:50 +02:00
const isReverseDir = isRTL(container) ? !isReverse : isReverse;
2023-12-07 09:44:11 +01:00
const containerRect = container.getBoundingClientRect();
2025-12-12 13:15:55 +01:00
if (x === void 0) {
2022-04-02 10:26:41 +02:00
x = isReverse ? containerRect.right - 1 : containerRect.left + 1;
2022-12-15 17:47:31 +01:00
} else if (x <= containerRect.left) {
x = containerRect.left + 1;
} else if (x >= containerRect.right) {
x = containerRect.right - 1;
2022-04-02 10:26:41 +02:00
}
2021-07-23 11:58:50 +02:00
const y = isReverseDir ? containerRect.bottom - 1 : containerRect.top + 1;
return hiddenCaretRangeFromPoint(ownerDocument, x, y, container);
2019-11-02 10:38:58 +01:00
}
2022-04-02 10:26:41 +02:00
function placeCaretAtEdge(container, isReverse, x) {
2019-11-02 10:38:58 +01:00
if (!container) {
return;
}
2021-07-23 11:58:50 +02:00
container.focus();
if (isInputOrTextArea(container)) {
2025-12-12 13:15:55 +01:00
if (typeof container.selectionStart !== "number") {
2021-07-23 11:58:50 +02:00
return;
}
2019-11-02 10:38:58 +01:00
if (isReverse) {
container.selectionStart = container.value.length;
container.selectionEnd = container.value.length;
} else {
container.selectionStart = 0;
container.selectionEnd = 0;
}
return;
}
if (!container.isContentEditable) {
return;
}
2025-12-12 13:15:55 +01:00
const range = scrollIfNoRange(
container,
isReverse,
() => getRange(container, isReverse, x)
);
2025-02-28 08:42:11 +01:00
if (!range) {
return;
}
2025-12-12 13:15:55 +01:00
const { ownerDocument } = container;
const { defaultView } = ownerDocument;
assertIsDefined(defaultView, "defaultView");
2021-07-23 11:58:50 +02:00
const selection = defaultView.getSelection();
2025-12-12 13:15:55 +01:00
assertIsDefined(selection, "selection");
2021-07-23 11:58:50 +02:00
selection.removeAllRanges();
selection.addRange(range);
2019-11-02 10:38:58 +01:00
}
2021-07-23 11:58:50 +02:00
2019-11-02 10:38:58 +01:00
2025-12-12 13:15:55 +01:00
;// ./node_modules/@wordpress/dom/build-module/dom/place-caret-at-horizontal-edge.js
2023-12-07 09:44:11 +01:00
2022-04-02 10:26:41 +02:00
function placeCaretAtHorizontalEdge(container, isReverse) {
2025-12-12 13:15:55 +01:00
return placeCaretAtEdge(container, isReverse, void 0);
2022-04-02 10:26:41 +02:00
}
2021-07-23 11:58:50 +02:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/place-caret-at-vertical-edge.js
2025-12-12 13:15:55 +01:00
2022-04-02 10:26:41 +02:00
function placeCaretAtVerticalEdge(container, isReverse, rect) {
2023-09-26 10:33:34 +02:00
return placeCaretAtEdge(container, isReverse, rect?.left);
2019-11-02 10:38:58 +01:00
}
2021-07-23 11:58:50 +02:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/insert-after.js
2025-12-12 13:15:55 +01:00
2021-07-23 11:58:50 +02:00
function insertAfter(newNode, referenceNode) {
2025-12-12 13:15:55 +01:00
assertIsDefined(referenceNode.parentNode, "referenceNode.parentNode");
2021-07-23 11:58:50 +02:00
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
2020-09-15 14:29:22 +02:00
}
2021-07-23 11:58:50 +02:00
2025-12-12 13:15:55 +01:00
;// ./node_modules/@wordpress/dom/build-module/dom/remove.js
2023-12-07 09:44:11 +01:00
2021-07-23 11:58:50 +02:00
function remove(node) {
2025-12-12 13:15:55 +01:00
assertIsDefined(node.parentNode, "node.parentNode");
2021-07-23 11:58:50 +02:00
node.parentNode.removeChild(node);
2020-09-15 14:29:22 +02:00
}
2021-07-23 11:58:50 +02:00
2025-12-12 13:15:55 +01:00
;// ./node_modules/@wordpress/dom/build-module/dom/replace.js
2021-07-23 11:58:50 +02:00
2023-12-07 09:44:11 +01:00
2021-07-23 11:58:50 +02:00
function replace(processedNode, newNode) {
2025-12-12 13:15:55 +01:00
assertIsDefined(processedNode.parentNode, "processedNode.parentNode");
2021-07-23 11:58:50 +02:00
insertAfter(newNode, processedNode.parentNode);
remove(processedNode);
2020-09-15 14:29:22 +02:00
}
2021-07-23 11:58:50 +02:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/unwrap.js
2025-12-12 13:15:55 +01:00
2021-07-23 11:58:50 +02:00
function unwrap(node) {
const parent = node.parentNode;
2025-12-12 13:15:55 +01:00
assertIsDefined(parent, "node.parentNode");
2021-07-23 11:58:50 +02:00
while (node.firstChild) {
parent.insertBefore(node.firstChild, node);
2019-11-02 10:38:58 +01:00
}
2021-07-23 11:58:50 +02:00
parent.removeChild(node);
2019-11-02 10:38:58 +01:00
}
2021-07-23 11:58:50 +02:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/replace-tag.js
2025-12-12 13:15:55 +01:00
2021-07-23 11:58:50 +02:00
function replaceTag(node, tagName) {
const newNode = node.ownerDocument.createElement(tagName);
while (node.firstChild) {
newNode.appendChild(node.firstChild);
}
2025-12-12 13:15:55 +01:00
assertIsDefined(node.parentNode, "node.parentNode");
2021-07-23 11:58:50 +02:00
node.parentNode.replaceChild(newNode, node);
return newNode;
}
2020-09-15 14:29:22 +02:00
2025-12-12 13:15:55 +01:00
;// ./node_modules/@wordpress/dom/build-module/dom/wrap.js
2023-12-07 09:44:11 +01:00
2021-07-23 11:58:50 +02:00
function wrap(newNode, referenceNode) {
2025-12-12 13:15:55 +01:00
assertIsDefined(referenceNode.parentNode, "referenceNode.parentNode");
2021-07-23 11:58:50 +02:00
referenceNode.parentNode.insertBefore(newNode, referenceNode);
newNode.appendChild(referenceNode);
2020-09-15 14:29:22 +02:00
}
2021-07-23 11:58:50 +02:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/safe-html.js
2025-12-12 13:15:55 +01:00
2022-04-02 10:26:41 +02:00
function safeHTML(html) {
2025-12-12 13:15:55 +01:00
const { body } = document.implementation.createHTMLDocument("");
2022-04-02 10:26:41 +02:00
body.innerHTML = html;
2025-12-12 13:15:55 +01:00
const elements = body.getElementsByTagName("*");
2022-04-02 10:26:41 +02:00
let elementIndex = elements.length;
while (elementIndex--) {
const element = elements[elementIndex];
2025-12-12 13:15:55 +01:00
if (element.tagName === "SCRIPT") {
2022-04-02 10:26:41 +02:00
remove(element);
} else {
let attributeIndex = element.attributes.length;
while (attributeIndex--) {
2025-12-12 13:15:55 +01:00
const { name: key } = element.attributes[attributeIndex];
if (key.startsWith("on")) {
2022-04-02 10:26:41 +02:00
element.removeAttribute(key);
}
}
}
}
return body.innerHTML;
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/strip-html.js
2025-12-12 13:15:55 +01:00
2021-07-23 11:58:50 +02:00
function stripHTML(html) {
2022-04-02 10:26:41 +02:00
html = safeHTML(html);
2025-12-12 13:15:55 +01:00
const doc = document.implementation.createHTMLDocument("");
2022-04-02 10:26:41 +02:00
doc.body.innerHTML = html;
2025-12-12 13:15:55 +01:00
return doc.body.textContent || "";
2019-11-02 10:38:58 +01:00
}
2021-07-23 11:58:50 +02:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/is-empty.js
2021-07-23 11:58:50 +02:00
function isEmpty(element) {
switch (element.nodeType) {
case element.TEXT_NODE:
2025-12-12 13:15:55 +01:00
return /^[ \f\n\r\t\v\u00a0]*$/.test(element.nodeValue || "");
2021-07-23 11:58:50 +02:00
case element.ELEMENT_NODE:
if (element.hasAttributes()) {
return false;
} else if (!element.hasChildNodes()) {
return true;
}
2025-12-12 13:15:55 +01:00
return (
/** @type {Element[]} */
Array.from(element.childNodes).every(isEmpty)
);
2021-07-23 11:58:50 +02:00
default:
return true;
2019-11-02 10:38:58 +01:00
}
2021-07-23 11:58:50 +02:00
}
2019-11-02 10:38:58 +01:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/phrasing-content.js
2021-07-23 11:58:50 +02:00
const textContentSchema = {
strong: {},
em: {},
s: {},
del: {},
ins: {},
2025-12-12 13:15:55 +01:00
a: { attributes: ["href", "target", "rel", "id"] },
2021-07-23 11:58:50 +02:00
code: {},
2025-12-12 13:15:55 +01:00
abbr: { attributes: ["title"] },
2021-07-23 11:58:50 +02:00
sub: {},
sup: {},
br: {},
small: {},
// To do: fix blockquote.
// cite: {},
2025-12-12 13:15:55 +01:00
q: { attributes: ["cite"] },
dfn: { attributes: ["title"] },
data: { attributes: ["value"] },
time: { attributes: ["datetime"] },
2021-07-23 11:58:50 +02:00
var: {},
samp: {},
kbd: {},
i: {},
b: {},
u: {},
mark: {},
ruby: {},
rt: {},
rp: {},
2025-12-12 13:15:55 +01:00
bdi: { attributes: ["dir"] },
bdo: { attributes: ["dir"] },
2021-07-23 11:58:50 +02:00
wbr: {},
2025-12-12 13:15:55 +01:00
"#text": {}
2023-12-07 09:44:11 +01:00
};
2025-12-12 13:15:55 +01:00
const excludedElements = ["#text", "br"];
Object.keys(textContentSchema).filter((element) => !excludedElements.includes(element)).forEach((tag) => {
const { [tag]: removedTag, ...restSchema } = textContentSchema;
2022-12-15 17:47:31 +01:00
textContentSchema[tag].children = restSchema;
2021-07-23 11:58:50 +02:00
});
const embeddedContentSchema = {
audio: {
2025-12-12 13:15:55 +01:00
attributes: [
"src",
"preload",
"autoplay",
"mediagroup",
"loop",
"muted"
]
2021-07-23 11:58:50 +02:00
},
2025-12-12 13:15:55 +01:00
canvas: { attributes: ["width", "height"] },
embed: { attributes: ["src", "type", "width", "height"] },
2021-07-23 11:58:50 +02:00
img: {
2025-12-12 13:15:55 +01:00
attributes: [
"alt",
"src",
"srcset",
"usemap",
"ismap",
"width",
"height"
]
2021-07-23 11:58:50 +02:00
},
object: {
2025-12-12 13:15:55 +01:00
attributes: [
"data",
"type",
"name",
"usemap",
"form",
"width",
"height"
]
2021-07-23 11:58:50 +02:00
},
video: {
2025-12-12 13:15:55 +01:00
attributes: [
"src",
"poster",
"preload",
"playsinline",
"autoplay",
"mediagroup",
"loop",
"muted",
"controls",
"width",
"height"
]
},
math: {
attributes: ["display", "xmlns"],
children: "*"
2019-11-02 10:38:58 +01:00
}
2021-07-23 11:58:50 +02:00
};
2023-12-07 09:44:11 +01:00
const phrasingContentSchema = {
...textContentSchema,
2021-07-23 11:58:50 +02:00
...embeddedContentSchema
};
function getPhrasingContentSchema(context) {
2025-12-12 13:15:55 +01:00
if (context !== "paste") {
2021-07-23 11:58:50 +02:00
return phrasingContentSchema;
}
2022-12-15 17:47:31 +01:00
const {
u,
// Used to mark misspelling. Shouldn't be pasted.
abbr,
// Invisible.
data,
// Invisible.
time,
// Invisible.
wbr,
// Invisible.
bdi,
// Invisible.
bdo,
// Invisible.
...remainingContentSchema
2023-12-07 09:44:11 +01:00
} = {
...phrasingContentSchema,
2021-07-23 11:58:50 +02:00
// We shouldn't paste potentially sensitive information which is not
// visible to the user when pasted, so strip the attributes.
2025-12-12 13:15:55 +01:00
ins: { children: phrasingContentSchema.ins.children },
del: { children: phrasingContentSchema.del.children }
2022-12-15 17:47:31 +01:00
};
return remainingContentSchema;
2019-11-02 10:38:58 +01:00
}
2021-07-23 11:58:50 +02:00
function isPhrasingContent(node) {
const tag = node.nodeName.toLowerCase();
2025-12-12 13:15:55 +01:00
return getPhrasingContentSchema().hasOwnProperty(tag) || tag === "span";
2019-11-02 10:38:58 +01:00
}
2021-07-23 11:58:50 +02:00
function isTextContent(node) {
const tag = node.nodeName.toLowerCase();
2025-12-12 13:15:55 +01:00
return textContentSchema.hasOwnProperty(tag) || tag === "span";
2019-11-02 10:38:58 +01:00
}
2021-07-23 11:58:50 +02:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/is-element.js
2021-07-23 11:58:50 +02:00
function isElement(node) {
return !!node && node.nodeType === node.ELEMENT_NODE;
2019-11-02 10:38:58 +01:00
}
2021-07-23 11:58:50 +02:00
2019-11-02 10:38:58 +01:00
2025-12-12 13:15:55 +01:00
;// ./node_modules/@wordpress/dom/build-module/dom/clean-node-list.js
2019-11-02 10:38:58 +01:00
2021-07-23 11:58:50 +02:00
2020-05-06 17:23:38 +02:00
2021-07-23 11:58:50 +02:00
2025-12-12 13:15:55 +01:00
const noop = () => {
};
2020-12-10 14:06:04 +01:00
function cleanNodeList(nodeList, doc, schema, inline) {
2025-12-12 13:15:55 +01:00
Array.from(nodeList).forEach(
(node) => {
const tag = node.nodeName.toLowerCase();
if (schema.hasOwnProperty(tag) && (!schema[tag].isMatch || schema[tag].isMatch?.(node))) {
if (isElement(node)) {
const {
attributes = [],
classes = [],
children,
require: require2 = [],
allowEmpty
} = schema[tag];
if (children && !allowEmpty && isEmpty(node)) {
remove(node);
return;
}
if (node.hasAttributes()) {
Array.from(node.attributes).forEach(({ name }) => {
if (name !== "class" && !attributes.includes(name)) {
node.removeAttribute(name);
2020-12-10 14:06:04 +01:00
}
});
2025-12-12 13:15:55 +01:00
if (node.classList && node.classList.length) {
const mattchers = classes.map((item) => {
if (item === "*") {
return () => true;
} else if (typeof item === "string") {
return (className) => className === item;
} else if (item instanceof RegExp) {
return (className) => item.test(className);
}
return noop;
});
Array.from(node.classList).forEach((name) => {
if (!mattchers.some(
(isMatch) => isMatch(name)
)) {
node.classList.remove(name);
}
});
if (!node.classList.length) {
node.removeAttribute("class");
2020-12-10 14:06:04 +01:00
}
}
}
2025-12-12 13:15:55 +01:00
if (node.hasChildNodes()) {
if (children === "*") {
return;
}
if (children) {
if (require2.length && !node.querySelector(require2.join(","))) {
cleanNodeList(
node.childNodes,
doc,
schema,
inline
);
2020-12-10 14:06:04 +01:00
unwrap(node);
2025-12-12 13:15:55 +01:00
} else if (node.parentNode && node.parentNode.nodeName === "BODY" && isPhrasingContent(node)) {
cleanNodeList(
node.childNodes,
doc,
schema,
inline
);
if (Array.from(node.childNodes).some(
(child) => !isPhrasingContent(child)
)) {
unwrap(node);
}
} else {
cleanNodeList(
node.childNodes,
doc,
children,
inline
);
2020-12-10 14:06:04 +01:00
}
} else {
2025-12-12 13:15:55 +01:00
while (node.firstChild) {
remove(node.firstChild);
}
2020-12-10 14:06:04 +01:00
}
}
}
2025-12-12 13:15:55 +01:00
} else {
cleanNodeList(node.childNodes, doc, schema, inline);
if (inline && !isPhrasingContent(node) && node.nextElementSibling) {
insertAfter(doc.createElement("br"), node);
}
unwrap(node);
2023-12-07 09:44:11 +01:00
}
2020-12-10 14:06:04 +01:00
}
2025-12-12 13:15:55 +01:00
);
2020-12-10 14:06:04 +01:00
}
2021-07-23 11:58:50 +02:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/remove-invalid-html.js
2025-12-12 13:15:55 +01:00
2020-12-10 14:06:04 +01:00
function removeInvalidHTML(HTML, schema, inline) {
2025-12-12 13:15:55 +01:00
const doc = document.implementation.createHTMLDocument("");
2020-12-10 14:06:04 +01:00
doc.body.innerHTML = HTML;
cleanNodeList(doc.body.childNodes, doc, schema, inline);
return doc.body.innerHTML;
}
2019-11-02 10:38:58 +01:00
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/dom/index.js
2021-07-23 11:58:50 +02:00
2021-04-27 08:32:47 +02:00
2021-07-23 11:58:50 +02:00
2025-02-28 08:42:11 +01:00
2025-12-12 13:15:55 +01:00
2021-07-23 11:58:50 +02:00
2022-06-16 14:03:35 +02:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/data-transfer.js
2021-04-27 08:32:47 +02:00
function getFilesFromDataTransfer(dataTransfer) {
2021-07-23 11:58:50 +02:00
const files = Array.from(dataTransfer.files);
2025-12-12 13:15:55 +01:00
Array.from(dataTransfer.items).forEach((item) => {
2021-07-23 11:58:50 +02:00
const file = item.getAsFile();
2025-12-12 13:15:55 +01:00
if (file && !files.find(
({ name, type, size }) => name === file.name && type === file.type && size === file.size
)) {
2021-04-27 08:32:47 +02:00
files.push(file);
}
});
return files;
}
2025-12-12 13:15:55 +01:00
2025-04-25 12:30:07 +02:00
;// ./node_modules/@wordpress/dom/build-module/index.js
2019-11-02 10:38:58 +01:00
2025-12-12 13:15:55 +01:00
const build_module_focus = { focusable: focusable_namespaceObject, tabbable: tabbable_namespaceObject };
2023-12-07 09:44:11 +01:00
2019-11-02 10:38:58 +01:00
2020-12-10 14:06:04 +01:00
2022-06-16 14:03:35 +02:00
(window.wp = window.wp || {}).dom = __webpack_exports__;
/******/ })()
;