@ckeditor/ckeditor5-utils 34.1.0 → 35.0.1

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.
Files changed (61) hide show
  1. package/CHANGELOG.md +324 -0
  2. package/LICENSE.md +1 -1
  3. package/package.json +19 -8
  4. package/src/areconnectedthroughproperties.js +54 -71
  5. package/src/ckeditorerror.js +92 -114
  6. package/src/collection.js +594 -760
  7. package/src/comparearrays.js +22 -28
  8. package/src/config.js +193 -223
  9. package/src/count.js +8 -12
  10. package/src/diff.js +85 -110
  11. package/src/difftochanges.js +47 -57
  12. package/src/dom/createelement.js +17 -25
  13. package/src/dom/emittermixin.js +217 -257
  14. package/src/dom/getancestors.js +9 -13
  15. package/src/dom/getborderwidths.js +10 -13
  16. package/src/dom/getcommonancestor.js +9 -15
  17. package/src/dom/getdatafromelement.js +5 -9
  18. package/src/dom/getpositionedancestor.js +9 -14
  19. package/src/dom/global.js +0 -3
  20. package/src/dom/indexof.js +7 -11
  21. package/src/dom/insertat.js +2 -4
  22. package/src/dom/iscomment.js +2 -5
  23. package/src/dom/isnode.js +10 -12
  24. package/src/dom/isrange.js +2 -4
  25. package/src/dom/istext.js +2 -4
  26. package/src/dom/isvisible.js +2 -4
  27. package/src/dom/iswindow.js +11 -16
  28. package/src/dom/position.js +220 -410
  29. package/src/dom/rect.js +335 -414
  30. package/src/dom/remove.js +5 -8
  31. package/src/dom/resizeobserver.js +109 -342
  32. package/src/dom/scroll.js +151 -183
  33. package/src/dom/setdatainelement.js +5 -9
  34. package/src/dom/tounit.js +10 -12
  35. package/src/elementreplacer.js +30 -44
  36. package/src/emittermixin.js +383 -631
  37. package/src/env.js +93 -115
  38. package/src/eventinfo.js +12 -65
  39. package/src/fastdiff.js +96 -128
  40. package/src/first.js +8 -12
  41. package/src/focustracker.js +77 -131
  42. package/src/index.js +0 -9
  43. package/src/inserttopriorityarray.js +9 -30
  44. package/src/isiterable.js +2 -4
  45. package/src/keyboard.js +117 -196
  46. package/src/keystrokehandler.js +72 -88
  47. package/src/language.js +9 -15
  48. package/src/locale.js +61 -158
  49. package/src/mapsequal.js +12 -17
  50. package/src/mix.js +13 -16
  51. package/src/nth.js +8 -11
  52. package/src/objecttomap.js +7 -11
  53. package/src/observablemixin.js +465 -768
  54. package/src/priorities.js +20 -32
  55. package/src/spy.js +3 -6
  56. package/src/toarray.js +2 -13
  57. package/src/tomap.js +8 -10
  58. package/src/translation-service.js +51 -87
  59. package/src/uid.js +34 -38
  60. package/src/unicode.js +28 -43
  61. package/src/version.js +134 -143
@@ -2,27 +2,22 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module utils/dom/getpositionedancestor
8
7
  */
9
-
10
8
  import global from './global';
11
-
12
9
  /**
13
10
  * For a given element, returns the nearest ancestor element which CSS position is not "static".
14
11
  *
15
- * @param {HTMLElement} element The native DOM element to be checked.
12
+ * @param {HTMLElement} [element] The native DOM element to be checked.
16
13
  * @returns {HTMLElement|null}
17
14
  */
18
- export default function getPositionedAncestor( element ) {
19
- if ( !element || !element.parentNode ) {
20
- return null;
21
- }
22
-
23
- if ( element.offsetParent === global.document.body ) {
24
- return null;
25
- }
26
-
27
- return element.offsetParent;
15
+ export default function getPositionedAncestor(element) {
16
+ if (!element || !element.parentNode) {
17
+ return null;
18
+ }
19
+ if (element.offsetParent === global.document.body) {
20
+ return null;
21
+ }
22
+ return element.offsetParent;
28
23
  }
package/src/dom/global.js CHANGED
@@ -2,13 +2,10 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /* globals window, document */
7
-
8
6
  /**
9
7
  * @module utils/dom/global
10
8
  */
11
-
12
9
  /**
13
10
  * A helper (module) giving an access to the global DOM objects such as `window` and
14
11
  * `document`. Accessing these objects using this helper allows easy and bulletproof
@@ -2,24 +2,20 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module utils/dom/indexof
8
7
  */
9
-
10
8
  /**
11
9
  * Returns index of the node in the parent element.
12
10
  *
13
11
  * @param {Node} node Node which index is tested.
14
12
  * @returns {Number} Index of the node in the parent element. Returns 0 if node has no parent.
15
13
  */
16
- export default function indexOf( node ) {
17
- let index = 0;
18
-
19
- while ( node.previousSibling ) {
20
- node = node.previousSibling;
21
- index++;
22
- }
23
-
24
- return index;
14
+ export default function indexOf(node) {
15
+ let index = 0;
16
+ while (node.previousSibling) {
17
+ node = node.previousSibling;
18
+ index++;
19
+ }
20
+ return index;
25
21
  }
@@ -2,11 +2,9 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module utils/dom/insertat
8
7
  */
9
-
10
8
  /**
11
9
  * Inserts node to the parent at given index.
12
10
  *
@@ -14,6 +12,6 @@
14
12
  * @param {Number} index Insertions index.
15
13
  * @param {Node} nodeToInsert Node to insert.
16
14
  */
17
- export default function insertAt( parentElement, index, nodeToInsert ) {
18
- parentElement.insertBefore( nodeToInsert, parentElement.childNodes[ index ] || null );
15
+ export default function insertAt(parentElement, index, nodeToInsert) {
16
+ parentElement.insertBefore(nodeToInsert, parentElement.childNodes[index] || null);
19
17
  }
@@ -2,19 +2,16 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /* globals Node */
7
-
8
6
  /**
9
7
  * @module utils/dom/iscomment
10
8
  */
11
-
12
9
  /**
13
10
  * Checks whether the object is a native DOM Comment node.
14
11
  *
15
12
  * @param {*} obj
16
13
  * @returns {Boolean}
17
14
  */
18
- export default function isComment( obj ) {
19
- return obj && obj.nodeType === Node.COMMENT_NODE;
15
+ export default function isComment(obj) {
16
+ return obj && obj.nodeType === Node.COMMENT_NODE;
20
17
  }
package/src/dom/isnode.js CHANGED
@@ -2,25 +2,23 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module utils/dom/isnode
8
7
  */
9
-
10
8
  /**
11
9
  * Checks if the object is a native DOM Node.
12
10
  *
13
11
  * @param {*} obj
14
12
  * @returns {Boolean}
15
13
  */
16
- export default function isNode( obj ) {
17
- if ( obj ) {
18
- if ( obj.defaultView ) {
19
- return obj instanceof obj.defaultView.Document;
20
- } else if ( obj.ownerDocument && obj.ownerDocument.defaultView ) {
21
- return obj instanceof obj.ownerDocument.defaultView.Node;
22
- }
23
- }
24
-
25
- return false;
14
+ export default function isNode(obj) {
15
+ if (obj) {
16
+ if (obj.defaultView) {
17
+ return obj instanceof obj.defaultView.Document;
18
+ }
19
+ else if (obj.ownerDocument && obj.ownerDocument.defaultView) {
20
+ return obj instanceof obj.ownerDocument.defaultView.Node;
21
+ }
22
+ }
23
+ return false;
26
24
  }
@@ -2,17 +2,15 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module utils/dom/isrange
8
7
  */
9
-
10
8
  /**
11
9
  * Checks if the object is a native DOM Range.
12
10
  *
13
11
  * @param {*} obj
14
12
  * @returns {Boolean}
15
13
  */
16
- export default function isRange( obj ) {
17
- return Object.prototype.toString.apply( obj ) == '[object Range]';
14
+ export default function isRange(obj) {
15
+ return Object.prototype.toString.apply(obj) == '[object Range]';
18
16
  }
package/src/dom/istext.js CHANGED
@@ -2,17 +2,15 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module utils/dom/istext
8
7
  */
9
-
10
8
  /**
11
9
  * Checks if the object is a native DOM Text node.
12
10
  *
13
11
  * @param {*} obj
14
12
  * @returns {Boolean}
15
13
  */
16
- export default function isText( obj ) {
17
- return Object.prototype.toString.call( obj ) == '[object Text]';
14
+ export default function isText(obj) {
15
+ return Object.prototype.toString.call(obj) == '[object Text]';
18
16
  }
@@ -2,11 +2,9 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module utils/dom/isvisible
8
7
  */
9
-
10
8
  /**
11
9
  * Checks whether the element is visible to the user in DOM:
12
10
  *
@@ -20,6 +18,6 @@
20
18
  * @param {HTMLElement|null|undefined} element
21
19
  * @returns {Boolean}
22
20
  */
23
- export default function isVisible( element ) {
24
- return !!( element && element.getClientRects && element.getClientRects().length );
21
+ export default function isVisible(element) {
22
+ return !!(element && element.getClientRects && element.getClientRects().length);
25
23
  }
@@ -2,29 +2,24 @@
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
-
6
5
  /**
7
6
  * @module utils/dom/iswindow
8
7
  */
9
-
10
8
  /**
11
9
  * Checks if the object is a native DOM Window.
12
10
  *
13
11
  * @param {*} obj
14
12
  * @returns {Boolean}
15
13
  */
16
- export default function isWindow( obj ) {
17
- const stringifiedObject = Object.prototype.toString.apply( obj );
18
-
19
- // Returns `true` for the `window` object in browser environments.
20
- if ( stringifiedObject == '[object Window]' ) {
21
- return true;
22
- }
23
-
24
- // Returns `true` for the `window` object in the Electron environment.
25
- if ( stringifiedObject == '[object global]' ) {
26
- return true;
27
- }
28
-
29
- return false;
14
+ export default function isWindow(obj) {
15
+ const stringifiedObject = Object.prototype.toString.apply(obj);
16
+ // Returns `true` for the `window` object in browser environments.
17
+ if (stringifiedObject == '[object Window]') {
18
+ return true;
19
+ }
20
+ // Returns `true` for the `window` object in the Electron environment.
21
+ if (stringifiedObject == '[object global]') {
22
+ return true;
23
+ }
24
+ return false;
30
25
  }