@ckeditor/ckeditor5-utils 40.0.0 → 40.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -26
- package/LICENSE.md +3 -3
- package/package.json +1 -1
- package/src/abortabledebounce.d.ts +17 -0
- package/src/abortabledebounce.js +22 -0
- package/src/areconnectedthroughproperties.d.ts +11 -11
- package/src/areconnectedthroughproperties.js +73 -73
- package/src/ckeditorerror.d.ts +123 -123
- package/src/ckeditorerror.js +176 -176
- package/src/collection.d.ts +433 -427
- package/src/collection.js +583 -575
- package/src/comparearrays.d.ts +30 -30
- package/src/comparearrays.js +47 -47
- package/src/config.d.ts +163 -163
- package/src/config.js +163 -162
- package/src/count.d.ts +18 -18
- package/src/count.js +24 -24
- package/src/delay.d.ts +19 -19
- package/src/delay.js +26 -26
- package/src/diff.d.ts +31 -31
- package/src/diff.js +115 -115
- package/src/difftochanges.d.ts +59 -59
- package/src/difftochanges.js +79 -79
- package/src/dom/createelement.d.ts +57 -57
- package/src/dom/createelement.js +40 -40
- package/src/dom/emittermixin.d.ts +142 -142
- package/src/dom/emittermixin.js +239 -239
- package/src/dom/findclosestscrollableancestor.d.ts +11 -11
- package/src/dom/findclosestscrollableancestor.js +31 -31
- package/src/dom/getancestors.d.ts +17 -17
- package/src/dom/getancestors.js +27 -27
- package/src/dom/getborderwidths.d.ts +24 -24
- package/src/dom/getborderwidths.js +24 -24
- package/src/dom/getcommonancestor.d.ts +12 -12
- package/src/dom/getcommonancestor.js +25 -25
- package/src/dom/getdatafromelement.d.ts +14 -14
- package/src/dom/getdatafromelement.js +20 -20
- package/src/dom/getpositionedancestor.d.ts +10 -10
- package/src/dom/getpositionedancestor.js +22 -22
- package/src/dom/global.d.ts +32 -32
- package/src/dom/global.js +35 -35
- package/src/dom/indexof.d.ts +14 -14
- package/src/dom/indexof.js +21 -21
- package/src/dom/insertat.d.ts +15 -15
- package/src/dom/insertat.js +17 -17
- package/src/dom/iscomment.d.ts +11 -11
- package/src/dom/iscomment.js +14 -14
- package/src/dom/isnode.d.ts +11 -11
- package/src/dom/isnode.js +21 -21
- package/src/dom/isrange.d.ts +11 -11
- package/src/dom/isrange.js +13 -13
- package/src/dom/istext.d.ts +11 -11
- package/src/dom/istext.js +13 -13
- package/src/dom/isvalidattributename.d.ts +10 -10
- package/src/dom/isvalidattributename.js +22 -22
- package/src/dom/isvisible.d.ts +18 -18
- package/src/dom/isvisible.js +20 -20
- package/src/dom/iswindow.d.ts +11 -11
- package/src/dom/iswindow.js +22 -22
- package/src/dom/position.d.ts +211 -211
- package/src/dom/position.js +313 -313
- package/src/dom/rect.d.ts +195 -195
- package/src/dom/rect.js +474 -474
- package/src/dom/remove.d.ts +13 -13
- package/src/dom/remove.js +18 -18
- package/src/dom/resizeobserver.d.ts +74 -74
- package/src/dom/resizeobserver.js +126 -126
- package/src/dom/scroll.d.ts +73 -73
- package/src/dom/scroll.js +383 -383
- package/src/dom/setdatainelement.d.ts +14 -14
- package/src/dom/setdatainelement.js +20 -20
- package/src/dom/tounit.d.ts +22 -22
- package/src/dom/tounit.js +16 -16
- package/src/elementreplacer.d.ts +31 -31
- package/src/elementreplacer.js +43 -43
- package/src/emittermixin.d.ts +312 -312
- package/src/emittermixin.js +453 -453
- package/src/env.d.ts +117 -117
- package/src/env.js +122 -122
- package/src/eventinfo.d.ts +58 -58
- package/src/eventinfo.js +26 -26
- package/src/fastdiff.d.ts +112 -112
- package/src/fastdiff.js +248 -248
- package/src/first.d.ts +11 -11
- package/src/first.js +17 -17
- package/src/focustracker.d.ts +75 -75
- package/src/focustracker.js +95 -95
- package/src/index.d.ts +64 -61
- package/src/index.js +63 -60
- package/src/inserttopriorityarray.d.ts +30 -30
- package/src/inserttopriorityarray.js +21 -21
- package/src/isiterable.d.ts +14 -14
- package/src/isiterable.js +16 -16
- package/src/keyboard.d.ts +126 -126
- package/src/keyboard.js +221 -221
- package/src/keystrokehandler.d.ts +87 -87
- package/src/keystrokehandler.js +122 -122
- package/src/language.d.ts +17 -17
- package/src/language.js +19 -19
- package/src/locale.d.ts +120 -120
- package/src/locale.js +76 -76
- package/src/mapsequal.d.ts +15 -15
- package/src/mapsequal.js +27 -27
- package/src/mix.d.ts +85 -85
- package/src/mix.js +50 -50
- package/src/nth.d.ts +16 -16
- package/src/nth.js +24 -24
- package/src/objecttomap.d.ts +23 -23
- package/src/objecttomap.js +27 -27
- package/src/observablemixin.d.ts +560 -560
- package/src/observablemixin.js +580 -580
- package/src/priorities.d.ts +33 -33
- package/src/priorities.js +23 -23
- package/src/retry.d.ts +33 -0
- package/src/retry.js +47 -0
- package/src/splicearray.d.ts +26 -26
- package/src/splicearray.js +40 -40
- package/src/spy.d.ts +21 -21
- package/src/spy.js +22 -22
- package/src/toarray.d.ts +25 -25
- package/src/toarray.js +7 -7
- package/src/tomap.d.ts +19 -19
- package/src/tomap.js +29 -29
- package/src/translation-service.d.ts +168 -168
- package/src/translation-service.js +198 -198
- package/src/uid.d.ts +15 -15
- package/src/uid.js +57 -57
- package/src/unicode.d.ts +54 -54
- package/src/unicode.js +85 -85
- package/src/verifylicense.d.ts +15 -15
- package/src/verifylicense.js +87 -87
- package/src/version.d.ts +10 -10
- package/src/version.js +153 -153
- package/src/wait.d.ts +16 -0
- package/src/wait.js +29 -0
package/src/dom/getancestors.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/* globals Node */
|
|
6
|
-
/**
|
|
7
|
-
* @module utils/dom/getancestors
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Returns all ancestors of given DOM node, starting from the top-most (root). Includes the given node itself. If the
|
|
11
|
-
* node is a part of `DocumentFragment` that `DocumentFragment` will be returned. In contrary, if the node is
|
|
12
|
-
* appended to a `Document`, that `Document` will not be returned (algorithms operating on DOM tree care for `Document#documentElement`
|
|
13
|
-
* at most, which will be returned).
|
|
14
|
-
*
|
|
15
|
-
* @param node DOM node.
|
|
16
|
-
* @returns Array of given `node` parents.
|
|
17
|
-
*/
|
|
18
|
-
export default function getAncestors(node) {
|
|
19
|
-
const nodes = [];
|
|
20
|
-
let currentNode = node;
|
|
21
|
-
// We are interested in `Node`s `DocumentFragment`s only.
|
|
22
|
-
while (currentNode && currentNode.nodeType != Node.DOCUMENT_NODE) {
|
|
23
|
-
nodes.unshift(currentNode);
|
|
24
|
-
currentNode = currentNode.parentNode;
|
|
25
|
-
}
|
|
26
|
-
return nodes;
|
|
27
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/* globals Node */
|
|
6
|
+
/**
|
|
7
|
+
* @module utils/dom/getancestors
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Returns all ancestors of given DOM node, starting from the top-most (root). Includes the given node itself. If the
|
|
11
|
+
* node is a part of `DocumentFragment` that `DocumentFragment` will be returned. In contrary, if the node is
|
|
12
|
+
* appended to a `Document`, that `Document` will not be returned (algorithms operating on DOM tree care for `Document#documentElement`
|
|
13
|
+
* at most, which will be returned).
|
|
14
|
+
*
|
|
15
|
+
* @param node DOM node.
|
|
16
|
+
* @returns Array of given `node` parents.
|
|
17
|
+
*/
|
|
18
|
+
export default function getAncestors(node) {
|
|
19
|
+
const nodes = [];
|
|
20
|
+
let currentNode = node;
|
|
21
|
+
// We are interested in `Node`s `DocumentFragment`s only.
|
|
22
|
+
while (currentNode && currentNode.nodeType != Node.DOCUMENT_NODE) {
|
|
23
|
+
nodes.unshift(currentNode);
|
|
24
|
+
currentNode = currentNode.parentNode;
|
|
25
|
+
}
|
|
26
|
+
return nodes;
|
|
27
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module utils/dom/getborderwidths
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Returns an object containing CSS border widths of a specified HTML element.
|
|
10
|
-
*
|
|
11
|
-
* @param element An element which has CSS borders.
|
|
12
|
-
* @returns An object containing `top`, `left`, `right` and `bottom` properties
|
|
13
|
-
* with numerical values of the `border-[top,left,right,bottom]-width` CSS styles.
|
|
14
|
-
*/
|
|
15
|
-
export default function getBorderWidths(element: HTMLElement): BorderWidths;
|
|
16
|
-
/**
|
|
17
|
-
* An object describing widths of `HTMLElement` borders.
|
|
18
|
-
*/
|
|
19
|
-
export interface BorderWidths {
|
|
20
|
-
top: number;
|
|
21
|
-
right: number;
|
|
22
|
-
bottom: number;
|
|
23
|
-
left: number;
|
|
24
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module utils/dom/getborderwidths
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Returns an object containing CSS border widths of a specified HTML element.
|
|
10
|
+
*
|
|
11
|
+
* @param element An element which has CSS borders.
|
|
12
|
+
* @returns An object containing `top`, `left`, `right` and `bottom` properties
|
|
13
|
+
* with numerical values of the `border-[top,left,right,bottom]-width` CSS styles.
|
|
14
|
+
*/
|
|
15
|
+
export default function getBorderWidths(element: HTMLElement): BorderWidths;
|
|
16
|
+
/**
|
|
17
|
+
* An object describing widths of `HTMLElement` borders.
|
|
18
|
+
*/
|
|
19
|
+
export interface BorderWidths {
|
|
20
|
+
top: number;
|
|
21
|
+
right: number;
|
|
22
|
+
bottom: number;
|
|
23
|
+
left: number;
|
|
24
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module utils/dom/getborderwidths
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Returns an object containing CSS border widths of a specified HTML element.
|
|
10
|
-
*
|
|
11
|
-
* @param element An element which has CSS borders.
|
|
12
|
-
* @returns An object containing `top`, `left`, `right` and `bottom` properties
|
|
13
|
-
* with numerical values of the `border-[top,left,right,bottom]-width` CSS styles.
|
|
14
|
-
*/
|
|
15
|
-
export default function getBorderWidths(element) {
|
|
16
|
-
// Call getComputedStyle on the window the element document belongs to.
|
|
17
|
-
const style = element.ownerDocument.defaultView.getComputedStyle(element);
|
|
18
|
-
return {
|
|
19
|
-
top: parseInt(style.borderTopWidth, 10),
|
|
20
|
-
right: parseInt(style.borderRightWidth, 10),
|
|
21
|
-
bottom: parseInt(style.borderBottomWidth, 10),
|
|
22
|
-
left: parseInt(style.borderLeftWidth, 10)
|
|
23
|
-
};
|
|
24
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module utils/dom/getborderwidths
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Returns an object containing CSS border widths of a specified HTML element.
|
|
10
|
+
*
|
|
11
|
+
* @param element An element which has CSS borders.
|
|
12
|
+
* @returns An object containing `top`, `left`, `right` and `bottom` properties
|
|
13
|
+
* with numerical values of the `border-[top,left,right,bottom]-width` CSS styles.
|
|
14
|
+
*/
|
|
15
|
+
export default function getBorderWidths(element) {
|
|
16
|
+
// Call getComputedStyle on the window the element document belongs to.
|
|
17
|
+
const style = element.ownerDocument.defaultView.getComputedStyle(element);
|
|
18
|
+
return {
|
|
19
|
+
top: parseInt(style.borderTopWidth, 10),
|
|
20
|
+
right: parseInt(style.borderRightWidth, 10),
|
|
21
|
+
bottom: parseInt(style.borderBottomWidth, 10),
|
|
22
|
+
left: parseInt(style.borderLeftWidth, 10)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Searches and returns the lowest common ancestor of two given nodes.
|
|
7
|
-
*
|
|
8
|
-
* @param nodeA First node.
|
|
9
|
-
* @param nodeB Second node.
|
|
10
|
-
* @returns Lowest common ancestor of both nodes or `null` if nodes do not have a common ancestor.
|
|
11
|
-
*/
|
|
12
|
-
export default function getCommonAncestor(nodeA: Node, nodeB: Node): Node | null;
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Searches and returns the lowest common ancestor of two given nodes.
|
|
7
|
+
*
|
|
8
|
+
* @param nodeA First node.
|
|
9
|
+
* @param nodeB Second node.
|
|
10
|
+
* @returns Lowest common ancestor of both nodes or `null` if nodes do not have a common ancestor.
|
|
11
|
+
*/
|
|
12
|
+
export default function getCommonAncestor(nodeA: Node, nodeB: Node): Node | null;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module utils/dom/getcommonancestor
|
|
7
|
-
*/
|
|
8
|
-
import getAncestors from './getancestors';
|
|
9
|
-
/**
|
|
10
|
-
* Searches and returns the lowest common ancestor of two given nodes.
|
|
11
|
-
*
|
|
12
|
-
* @param nodeA First node.
|
|
13
|
-
* @param nodeB Second node.
|
|
14
|
-
* @returns Lowest common ancestor of both nodes or `null` if nodes do not have a common ancestor.
|
|
15
|
-
*/
|
|
16
|
-
export default function getCommonAncestor(nodeA, nodeB) {
|
|
17
|
-
const ancestorsA = getAncestors(nodeA);
|
|
18
|
-
const ancestorsB = getAncestors(nodeB);
|
|
19
|
-
let i = 0;
|
|
20
|
-
// It does not matter which array is shorter.
|
|
21
|
-
while (ancestorsA[i] == ancestorsB[i] && ancestorsA[i]) {
|
|
22
|
-
i++;
|
|
23
|
-
}
|
|
24
|
-
return i === 0 ? null : ancestorsA[i - 1];
|
|
25
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module utils/dom/getcommonancestor
|
|
7
|
+
*/
|
|
8
|
+
import getAncestors from './getancestors';
|
|
9
|
+
/**
|
|
10
|
+
* Searches and returns the lowest common ancestor of two given nodes.
|
|
11
|
+
*
|
|
12
|
+
* @param nodeA First node.
|
|
13
|
+
* @param nodeB Second node.
|
|
14
|
+
* @returns Lowest common ancestor of both nodes or `null` if nodes do not have a common ancestor.
|
|
15
|
+
*/
|
|
16
|
+
export default function getCommonAncestor(nodeA, nodeB) {
|
|
17
|
+
const ancestorsA = getAncestors(nodeA);
|
|
18
|
+
const ancestorsB = getAncestors(nodeB);
|
|
19
|
+
let i = 0;
|
|
20
|
+
// It does not matter which array is shorter.
|
|
21
|
+
while (ancestorsA[i] == ancestorsB[i] && ancestorsA[i]) {
|
|
22
|
+
i++;
|
|
23
|
+
}
|
|
24
|
+
return i === 0 ? null : ancestorsA[i - 1];
|
|
25
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module utils/dom/getdatafromelement
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Gets data from a given source element.
|
|
10
|
-
*
|
|
11
|
-
* @param el The element from which the data will be retrieved.
|
|
12
|
-
* @returns The data string.
|
|
13
|
-
*/
|
|
14
|
-
export default function getDataFromElement(el: HTMLElement): string;
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module utils/dom/getdatafromelement
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Gets data from a given source element.
|
|
10
|
+
*
|
|
11
|
+
* @param el The element from which the data will be retrieved.
|
|
12
|
+
* @returns The data string.
|
|
13
|
+
*/
|
|
14
|
+
export default function getDataFromElement(el: HTMLElement): string;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/* globals HTMLTextAreaElement */
|
|
6
|
-
/**
|
|
7
|
-
* @module utils/dom/getdatafromelement
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Gets data from a given source element.
|
|
11
|
-
*
|
|
12
|
-
* @param el The element from which the data will be retrieved.
|
|
13
|
-
* @returns The data string.
|
|
14
|
-
*/
|
|
15
|
-
export default function getDataFromElement(el) {
|
|
16
|
-
if (el instanceof HTMLTextAreaElement) {
|
|
17
|
-
return el.value;
|
|
18
|
-
}
|
|
19
|
-
return el.innerHTML;
|
|
20
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/* globals HTMLTextAreaElement */
|
|
6
|
+
/**
|
|
7
|
+
* @module utils/dom/getdatafromelement
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Gets data from a given source element.
|
|
11
|
+
*
|
|
12
|
+
* @param el The element from which the data will be retrieved.
|
|
13
|
+
* @returns The data string.
|
|
14
|
+
*/
|
|
15
|
+
export default function getDataFromElement(el) {
|
|
16
|
+
if (el instanceof HTMLTextAreaElement) {
|
|
17
|
+
return el.value;
|
|
18
|
+
}
|
|
19
|
+
return el.innerHTML;
|
|
20
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* For a given element, returns the nearest ancestor element which CSS position is not "static".
|
|
7
|
-
*
|
|
8
|
-
* @param element The native DOM element to be checked.
|
|
9
|
-
*/
|
|
10
|
-
export default function getPositionedAncestor(element?: HTMLElement): HTMLElement | null;
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* For a given element, returns the nearest ancestor element which CSS position is not "static".
|
|
7
|
+
*
|
|
8
|
+
* @param element The native DOM element to be checked.
|
|
9
|
+
*/
|
|
10
|
+
export default function getPositionedAncestor(element?: HTMLElement): HTMLElement | null;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module utils/dom/getpositionedancestor
|
|
7
|
-
*/
|
|
8
|
-
import global from './global';
|
|
9
|
-
/**
|
|
10
|
-
* For a given element, returns the nearest ancestor element which CSS position is not "static".
|
|
11
|
-
*
|
|
12
|
-
* @param element The native DOM element to be checked.
|
|
13
|
-
*/
|
|
14
|
-
export default function getPositionedAncestor(element) {
|
|
15
|
-
if (!element || !element.parentNode) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
if (element.offsetParent === global.document.body) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
return element.offsetParent;
|
|
22
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module utils/dom/getpositionedancestor
|
|
7
|
+
*/
|
|
8
|
+
import global from './global';
|
|
9
|
+
/**
|
|
10
|
+
* For a given element, returns the nearest ancestor element which CSS position is not "static".
|
|
11
|
+
*
|
|
12
|
+
* @param element The native DOM element to be checked.
|
|
13
|
+
*/
|
|
14
|
+
export default function getPositionedAncestor(element) {
|
|
15
|
+
if (!element || !element.parentNode) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
if (element.offsetParent === global.document.body) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return element.offsetParent;
|
|
22
|
+
}
|
package/src/dom/global.d.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module utils/dom/global
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* A helper (module) giving an access to the global DOM objects such as `window` and `document`.
|
|
10
|
-
*/
|
|
11
|
-
export interface GlobalType {
|
|
12
|
-
readonly window: Window & typeof globalThis;
|
|
13
|
-
readonly document: Document;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* A helper (module) giving an access to the global DOM objects such as `window` and
|
|
17
|
-
* `document`. Accessing these objects using this helper allows easy and bulletproof
|
|
18
|
-
* testing, i.e. stubbing native properties:
|
|
19
|
-
*
|
|
20
|
-
* ```ts
|
|
21
|
-
* import { global } from 'ckeditor5/utils';
|
|
22
|
-
*
|
|
23
|
-
* // This stub will work for any code using global module.
|
|
24
|
-
* testUtils.sinon.stub( global, 'window', {
|
|
25
|
-
* innerWidth: 10000
|
|
26
|
-
* } );
|
|
27
|
-
*
|
|
28
|
-
* console.log( global.window.innerWidth );
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
declare let globalVar: GlobalType;
|
|
32
|
-
export default globalVar;
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module utils/dom/global
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A helper (module) giving an access to the global DOM objects such as `window` and `document`.
|
|
10
|
+
*/
|
|
11
|
+
export interface GlobalType {
|
|
12
|
+
readonly window: Window & typeof globalThis;
|
|
13
|
+
readonly document: Document;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A helper (module) giving an access to the global DOM objects such as `window` and
|
|
17
|
+
* `document`. Accessing these objects using this helper allows easy and bulletproof
|
|
18
|
+
* testing, i.e. stubbing native properties:
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { global } from 'ckeditor5/utils';
|
|
22
|
+
*
|
|
23
|
+
* // This stub will work for any code using global module.
|
|
24
|
+
* testUtils.sinon.stub( global, 'window', {
|
|
25
|
+
* innerWidth: 10000
|
|
26
|
+
* } );
|
|
27
|
+
*
|
|
28
|
+
* console.log( global.window.innerWidth );
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare let globalVar: GlobalType;
|
|
32
|
+
export default globalVar;
|
package/src/dom/global.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* A helper (module) giving an access to the global DOM objects such as `window` and
|
|
7
|
-
* `document`. Accessing these objects using this helper allows easy and bulletproof
|
|
8
|
-
* testing, i.e. stubbing native properties:
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* import { global } from 'ckeditor5/utils';
|
|
12
|
-
*
|
|
13
|
-
* // This stub will work for any code using global module.
|
|
14
|
-
* testUtils.sinon.stub( global, 'window', {
|
|
15
|
-
* innerWidth: 10000
|
|
16
|
-
* } );
|
|
17
|
-
*
|
|
18
|
-
* console.log( global.window.innerWidth );
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
let globalVar; // named globalVar instead of global: https://github.com/ckeditor/ckeditor5/issues/12971
|
|
22
|
-
// In some environments window and document API might not be available.
|
|
23
|
-
try {
|
|
24
|
-
globalVar = { window, document };
|
|
25
|
-
}
|
|
26
|
-
catch (e) {
|
|
27
|
-
// It's not possible to mock a window object to simulate lack of a window object without writing extremely convoluted code.
|
|
28
|
-
/* istanbul ignore next -- @preserve */
|
|
29
|
-
// Let's cast it to not change module's API.
|
|
30
|
-
// We only handle this so loading editor in environments without window and document doesn't fail.
|
|
31
|
-
// For better DX we shouldn't introduce mixed types and require developers to check the type manually.
|
|
32
|
-
// This module should not be used on purpose in any environment outside browser.
|
|
33
|
-
globalVar = { window: {}, document: {} };
|
|
34
|
-
}
|
|
35
|
-
export default globalVar;
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* A helper (module) giving an access to the global DOM objects such as `window` and
|
|
7
|
+
* `document`. Accessing these objects using this helper allows easy and bulletproof
|
|
8
|
+
* testing, i.e. stubbing native properties:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { global } from 'ckeditor5/utils';
|
|
12
|
+
*
|
|
13
|
+
* // This stub will work for any code using global module.
|
|
14
|
+
* testUtils.sinon.stub( global, 'window', {
|
|
15
|
+
* innerWidth: 10000
|
|
16
|
+
* } );
|
|
17
|
+
*
|
|
18
|
+
* console.log( global.window.innerWidth );
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
let globalVar; // named globalVar instead of global: https://github.com/ckeditor/ckeditor5/issues/12971
|
|
22
|
+
// In some environments window and document API might not be available.
|
|
23
|
+
try {
|
|
24
|
+
globalVar = { window, document };
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
// It's not possible to mock a window object to simulate lack of a window object without writing extremely convoluted code.
|
|
28
|
+
/* istanbul ignore next -- @preserve */
|
|
29
|
+
// Let's cast it to not change module's API.
|
|
30
|
+
// We only handle this so loading editor in environments without window and document doesn't fail.
|
|
31
|
+
// For better DX we shouldn't introduce mixed types and require developers to check the type manually.
|
|
32
|
+
// This module should not be used on purpose in any environment outside browser.
|
|
33
|
+
globalVar = { window: {}, document: {} };
|
|
34
|
+
}
|
|
35
|
+
export default globalVar;
|
package/src/dom/indexof.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module utils/dom/indexof
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Returns index of the node in the parent element.
|
|
10
|
-
*
|
|
11
|
-
* @param node Node which index is tested.
|
|
12
|
-
* @returns Index of the node in the parent element. Returns 0 if node has no parent.
|
|
13
|
-
*/
|
|
14
|
-
export default function indexOf(node: Node): number;
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module utils/dom/indexof
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Returns index of the node in the parent element.
|
|
10
|
+
*
|
|
11
|
+
* @param node Node which index is tested.
|
|
12
|
+
* @returns Index of the node in the parent element. Returns 0 if node has no parent.
|
|
13
|
+
*/
|
|
14
|
+
export default function indexOf(node: Node): number;
|
package/src/dom/indexof.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module utils/dom/indexof
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Returns index of the node in the parent element.
|
|
10
|
-
*
|
|
11
|
-
* @param node Node which index is tested.
|
|
12
|
-
* @returns Index of the node in the parent element. Returns 0 if node has no parent.
|
|
13
|
-
*/
|
|
14
|
-
export default function indexOf(node) {
|
|
15
|
-
let index = 0;
|
|
16
|
-
while (node.previousSibling) {
|
|
17
|
-
node = node.previousSibling;
|
|
18
|
-
index++;
|
|
19
|
-
}
|
|
20
|
-
return index;
|
|
21
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module utils/dom/indexof
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Returns index of the node in the parent element.
|
|
10
|
+
*
|
|
11
|
+
* @param node Node which index is tested.
|
|
12
|
+
* @returns Index of the node in the parent element. Returns 0 if node has no parent.
|
|
13
|
+
*/
|
|
14
|
+
export default function indexOf(node) {
|
|
15
|
+
let index = 0;
|
|
16
|
+
while (node.previousSibling) {
|
|
17
|
+
node = node.previousSibling;
|
|
18
|
+
index++;
|
|
19
|
+
}
|
|
20
|
+
return index;
|
|
21
|
+
}
|
package/src/dom/insertat.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module utils/dom/insertat
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Inserts node to the parent at given index.
|
|
10
|
-
*
|
|
11
|
-
* @param parentElement Parent element.
|
|
12
|
-
* @param index Insertions index.
|
|
13
|
-
* @param nodeToInsert Node to insert.
|
|
14
|
-
*/
|
|
15
|
-
export default function insertAt(parentElement: Element, index: number, nodeToInsert: Node): void;
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module utils/dom/insertat
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Inserts node to the parent at given index.
|
|
10
|
+
*
|
|
11
|
+
* @param parentElement Parent element.
|
|
12
|
+
* @param index Insertions index.
|
|
13
|
+
* @param nodeToInsert Node to insert.
|
|
14
|
+
*/
|
|
15
|
+
export default function insertAt(parentElement: Element, index: number, nodeToInsert: Node): void;
|
package/src/dom/insertat.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module utils/dom/insertat
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Inserts node to the parent at given index.
|
|
10
|
-
*
|
|
11
|
-
* @param parentElement Parent element.
|
|
12
|
-
* @param index Insertions index.
|
|
13
|
-
* @param nodeToInsert Node to insert.
|
|
14
|
-
*/
|
|
15
|
-
export default function insertAt(parentElement, index, nodeToInsert) {
|
|
16
|
-
parentElement.insertBefore(nodeToInsert, parentElement.childNodes[index] || null);
|
|
17
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @module utils/dom/insertat
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Inserts node to the parent at given index.
|
|
10
|
+
*
|
|
11
|
+
* @param parentElement Parent element.
|
|
12
|
+
* @param index Insertions index.
|
|
13
|
+
* @param nodeToInsert Node to insert.
|
|
14
|
+
*/
|
|
15
|
+
export default function insertAt(parentElement, index, nodeToInsert) {
|
|
16
|
+
parentElement.insertBefore(nodeToInsert, parentElement.childNodes[index] || null);
|
|
17
|
+
}
|