@ckeditor/ckeditor5-utils 35.3.2 → 35.4.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.
Files changed (59) hide show
  1. package/package.json +5 -5
  2. package/src/areconnectedthroughproperties.js +5 -7
  3. package/src/ckeditorerror.js +51 -70
  4. package/src/collection.js +106 -148
  5. package/src/comparearrays.js +10 -8
  6. package/src/config.js +29 -83
  7. package/src/count.js +5 -3
  8. package/src/diff.js +7 -5
  9. package/src/difftochanges.js +17 -14
  10. package/src/dom/createelement.js +11 -9
  11. package/src/dom/emittermixin.js +43 -84
  12. package/src/dom/getancestors.js +2 -2
  13. package/src/dom/getborderwidths.js +2 -2
  14. package/src/dom/getcommonancestor.js +3 -3
  15. package/src/dom/getdatafromelement.js +2 -2
  16. package/src/dom/getpositionedancestor.js +1 -2
  17. package/src/dom/global.js +8 -10
  18. package/src/dom/indexof.js +2 -2
  19. package/src/dom/insertat.js +3 -3
  20. package/src/dom/iscomment.js +0 -3
  21. package/src/dom/isnode.js +0 -3
  22. package/src/dom/isrange.js +0 -3
  23. package/src/dom/istext.js +0 -3
  24. package/src/dom/isvisible.js +0 -3
  25. package/src/dom/iswindow.js +0 -3
  26. package/src/dom/position.js +110 -133
  27. package/src/dom/rect.js +42 -52
  28. package/src/dom/remove.js +1 -1
  29. package/src/dom/resizeobserver.js +10 -35
  30. package/src/dom/scroll.js +85 -91
  31. package/src/dom/setdatainelement.js +2 -2
  32. package/src/dom/tounit.js +1 -10
  33. package/src/elementreplacer.js +2 -2
  34. package/src/emittermixin.js +48 -48
  35. package/src/env.js +14 -75
  36. package/src/eventinfo.js +2 -2
  37. package/src/fastdiff.js +115 -96
  38. package/src/first.js +0 -3
  39. package/src/focustracker.js +10 -18
  40. package/src/index.js +17 -0
  41. package/src/inserttopriorityarray.js +2 -2
  42. package/src/isiterable.js +2 -2
  43. package/src/keyboard.js +20 -21
  44. package/src/keystrokehandler.js +26 -24
  45. package/src/language.js +1 -2
  46. package/src/locale.js +11 -14
  47. package/src/mapsequal.js +3 -3
  48. package/src/mix.js +15 -13
  49. package/src/nth.js +0 -4
  50. package/src/objecttomap.js +6 -4
  51. package/src/observablemixin.js +126 -150
  52. package/src/priorities.js +0 -9
  53. package/src/splicearray.js +12 -11
  54. package/src/spy.js +1 -1
  55. package/src/tomap.js +7 -5
  56. package/src/translation-service.js +70 -52
  57. package/src/uid.js +5 -3
  58. package/src/unicode.js +9 -15
  59. package/src/version.js +32 -26
package/src/dom/rect.js CHANGED
@@ -19,29 +19,31 @@ export default class Rect {
19
19
  /**
20
20
  * Creates an instance of rect.
21
21
  *
22
- * // Rect of an HTMLElement.
23
- * const rectA = new Rect( document.body );
22
+ * ```ts
23
+ * // Rect of an HTMLElement.
24
+ * const rectA = new Rect( document.body );
24
25
  *
25
- * // Rect of a DOM Range.
26
- * const rectB = new Rect( document.getSelection().getRangeAt( 0 ) );
26
+ * // Rect of a DOM Range.
27
+ * const rectB = new Rect( document.getSelection().getRangeAt( 0 ) );
27
28
  *
28
- * // Rect of a window (web browser viewport).
29
- * const rectC = new Rect( window );
29
+ * // Rect of a window (web browser viewport).
30
+ * const rectC = new Rect( window );
30
31
  *
31
- * // Rect out of an object.
32
- * const rectD = new Rect( { top: 0, right: 10, bottom: 10, left: 0, width: 10, height: 10 } );
32
+ * // Rect out of an object.
33
+ * const rectD = new Rect( { top: 0, right: 10, bottom: 10, left: 0, width: 10, height: 10 } );
33
34
  *
34
- * // Rect out of another Rect instance.
35
- * const rectE = new Rect( rectD );
35
+ * // Rect out of another Rect instance.
36
+ * const rectE = new Rect( rectD );
36
37
  *
37
- * // Rect out of a ClientRect.
38
- * const rectF = new Rect( document.body.getClientRects().item( 0 ) );
38
+ * // Rect out of a ClientRect.
39
+ * const rectF = new Rect( document.body.getClientRects().item( 0 ) );
40
+ * ```
39
41
  *
40
42
  * **Note**: By default a rect of an HTML element includes its CSS borders and scrollbars (if any)
41
43
  * ant the rect of a `window` includes scrollbars too. Use {@link #excludeScrollbarsAndBorders}
42
44
  * to get the inner part of the rect.
43
45
  *
44
- * @param {module:utils/dom/rect~RectSource} source A source object to create the rect.
46
+ * @param source A source object to create the rect.
45
47
  */
46
48
  constructor(source) {
47
49
  const isSourceRange = isRange(source);
@@ -88,7 +90,7 @@ export default class Rect {
88
90
  /**
89
91
  * Returns a clone of the rect.
90
92
  *
91
- * @returns {module:utils/dom/rect~Rect} A cloned rect.
93
+ * @returns A cloned rect.
92
94
  */
93
95
  clone() {
94
96
  return new Rect(this);
@@ -96,9 +98,9 @@ export default class Rect {
96
98
  /**
97
99
  * Moves the rect so that its upper–left corner lands in desired `[ x, y ]` location.
98
100
  *
99
- * @param {Number} x Desired horizontal location.
100
- * @param {Number} y Desired vertical location.
101
- * @returns {module:utils/dom/rect~Rect} A rect which has been moved.
101
+ * @param x Desired horizontal location.
102
+ * @param y Desired vertical location.
103
+ * @returns A rect which has been moved.
102
104
  */
103
105
  moveTo(x, y) {
104
106
  this.top = y;
@@ -110,9 +112,9 @@ export default class Rect {
110
112
  /**
111
113
  * Moves the rect in–place by a dedicated offset.
112
114
  *
113
- * @param {Number} x A horizontal offset.
114
- * @param {Number} y A vertical offset
115
- * @returns {module:utils/dom/rect~Rect} A rect which has been moved.
115
+ * @param x A horizontal offset.
116
+ * @param y A vertical offset
117
+ * @returns A rect which has been moved.
116
118
  */
117
119
  moveBy(x, y) {
118
120
  this.top += y;
@@ -123,9 +125,6 @@ export default class Rect {
123
125
  }
124
126
  /**
125
127
  * Returns a new rect a a result of intersection with another rect.
126
- *
127
- * @param {module:utils/dom/rect~Rect} anotherRect
128
- * @returns {module:utils/dom/rect~Rect|null}
129
128
  */
130
129
  getIntersection(anotherRect) {
131
130
  const rect = {
@@ -148,8 +147,7 @@ export default class Rect {
148
147
  /**
149
148
  * Returns the area of intersection with another rect.
150
149
  *
151
- * @param {module:utils/dom/rect~Rect} anotherRect
152
- * @returns {Number} Area of intersection.
150
+ * @returns Area of intersection.
153
151
  */
154
152
  getIntersectionArea(anotherRect) {
155
153
  const rect = this.getIntersection(anotherRect);
@@ -162,8 +160,6 @@ export default class Rect {
162
160
  }
163
161
  /**
164
162
  * Returns the area of the rect.
165
- *
166
- * @returns {Number}
167
163
  */
168
164
  getArea() {
169
165
  return this.width * this.height;
@@ -176,7 +172,7 @@ export default class Rect {
176
172
  * If there's no such visible rect, which is when the rect is limited by one or many of
177
173
  * the ancestors, `null` is returned.
178
174
  *
179
- * @returns {module:utils/dom/rect~Rect|null} A visible rect instance or `null`, if there's none.
175
+ * @returns A visible rect instance or `null`, if there's none.
180
176
  */
181
177
  getVisible() {
182
178
  const source = this._source;
@@ -208,8 +204,8 @@ export default class Rect {
208
204
  * {@link #bottom}, {@link #width} and {@link #height}) are the equal in both rect
209
205
  * instances.
210
206
  *
211
- * @param {module:utils/dom/rect~Rect} anotherRect A rect instance to compare with.
212
- * @returns {Boolean} `true` when Rects are equal. `false` otherwise.
207
+ * @param anotherRect A rect instance to compare with.
208
+ * @returns `true` when Rects are equal. `false` otherwise.
213
209
  */
214
210
  isEqual(anotherRect) {
215
211
  for (const prop of rectProperties) {
@@ -222,8 +218,8 @@ export default class Rect {
222
218
  /**
223
219
  * Checks whether a rect fully contains another rect instance.
224
220
  *
225
- * @param {module:utils/dom/rect~Rect} anotherRect
226
- * @returns {Boolean} `true` if contains, `false` otherwise.
221
+ * @param anotherRect
222
+ * @returns `true` if contains, `false` otherwise.
227
223
  */
228
224
  contains(anotherRect) {
229
225
  const intersectRect = this.getIntersection(anotherRect);
@@ -235,7 +231,7 @@ export default class Rect {
235
231
  * * Borders are removed when {@link #_source} is an HTML element.
236
232
  * * Scrollbars are excluded from HTML elements and the `window`.
237
233
  *
238
- * @returns {module:utils/dom/rect~Rect} A rect which has been updated.
234
+ * @returns A rect which has been updated.
239
235
  */
240
236
  excludeScrollbarsAndBorders() {
241
237
  const source = this._source;
@@ -271,8 +267,8 @@ export default class Rect {
271
267
  /**
272
268
  * Returns an array of rects of the given native DOM Range.
273
269
  *
274
- * @param {Range} range A native DOM range.
275
- * @returns {Array.<module:utils/dom/rect~Rect>} DOM Range rects.
270
+ * @param range A native DOM range.
271
+ * @returns DOM Range rects.
276
272
  */
277
273
  static getDomRangeRects(range) {
278
274
  const rects = [];
@@ -302,8 +298,8 @@ export default class Rect {
302
298
  /**
303
299
  * Returns a bounding rectangle that contains all the given `rects`.
304
300
  *
305
- * @param {Iterable.<module:utils/dom/rect~Rect>} rects A list of rectangles that should be contained in the result rectangle.
306
- * @returns {module:utils/dom/rect~Rect|null} Bounding rectangle or `null` if no `rects` were given.
301
+ * @param rects A list of rectangles that should be contained in the result rectangle.
302
+ * @returns Bounding rectangle or `null` if no `rects` were given.
307
303
  */
308
304
  static getBoundingRect(rects) {
309
305
  const boundingRectData = {
@@ -330,32 +326,26 @@ export default class Rect {
330
326
  return new Rect(boundingRectData);
331
327
  }
332
328
  }
333
- // Acquires all the rect properties from the passed source.
334
- //
335
- // @private
336
- // @param {module:utils/dom/rect~Rect} rect
337
- // @param {module:utils/dom/rect~RectLike} source
329
+ /**
330
+ * Acquires all the rect properties from the passed source.
331
+ */
338
332
  function copyRectProperties(rect, source) {
339
333
  for (const p of rectProperties) {
340
334
  rect[p] = source[p];
341
335
  }
342
336
  }
343
- // Checks if provided object is a <body> HTML element.
344
- //
345
- // @private
346
- // @param {*} value
347
- // @returns {Boolean}
337
+ /**
338
+ * Checks if provided object is a <body> HTML element.
339
+ */
348
340
  function isBody(value) {
349
341
  if (!isDomElement(value)) {
350
342
  return false;
351
343
  }
352
344
  return value === value.ownerDocument.body;
353
345
  }
354
- // Checks if provided object "looks like" a DOM Element and has API required by `Rect` class.
355
- //
356
- // @private
357
- // @param {*} value
358
- // @returns {Boolean}
346
+ /**
347
+ * Checks if provided object "looks like" a DOM Element and has API required by `Rect` class.
348
+ */
359
349
  function isDomElement(value) {
360
350
  // Note: earlier we used `isElement()` from lodash library, however that function is less performant because
361
351
  // it makes complicated checks to make sure that given value is a DOM element.
package/src/dom/remove.js CHANGED
@@ -8,7 +8,7 @@
8
8
  /**
9
9
  * Removes given node from parent.
10
10
  *
11
- * @param {Node} node Node to remove.
11
+ * @param node Node to remove.
12
12
  */
13
13
  export default function remove(node) {
14
14
  const parent = node.parentNode;
@@ -9,13 +9,15 @@ import global from './global';
9
9
  /**
10
10
  * A helper class which instances allow performing custom actions when native DOM elements are resized.
11
11
  *
12
- * const editableElement = editor.editing.view.getDomRoot();
12
+ * ```ts
13
+ * const editableElement = editor.editing.view.getDomRoot();
13
14
  *
14
- * const observer = new ResizeObserver( editableElement, entry => {
15
- * console.log( 'The editable element has been resized in DOM.' );
16
- * console.log( entry.target ); // -> editableElement
17
- * console.log( entry.contentRect.width ); // -> e.g. '423px'
18
- * } );
15
+ * const observer = new ResizeObserver( editableElement, entry => {
16
+ * console.log( 'The editable element has been resized in DOM.' );
17
+ * console.log( entry.target ); // -> editableElement
18
+ * console.log( entry.contentRect.width ); // -> e.g. '423px'
19
+ * } );
20
+ * ```
19
21
  *
20
22
  * It uses the [native DOM resize observer](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver)
21
23
  * under the hood.
@@ -24,9 +26,9 @@ export default class ResizeObserver {
24
26
  /**
25
27
  * Creates an instance of the `ResizeObserver` class.
26
28
  *
27
- * @param {Element} element A DOM element that is to be observed for resizing. Note that
29
+ * @param element A DOM element that is to be observed for resizing. Note that
28
30
  * the element must be visible (i.e. not detached from DOM) for the observer to work.
29
- * @param {Function} callback A function called when the observed element was resized. It passes
31
+ * @param callback A function called when the observed element was resized. It passes
30
32
  * the [`ResizeObserverEntry`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry)
31
33
  * object with information about the resize event.
32
34
  */
@@ -49,11 +51,6 @@ export default class ResizeObserver {
49
51
  }
50
52
  /**
51
53
  * Registers a new resize callback for the DOM element.
52
- *
53
- * @private
54
- * @static
55
- * @param {Element} element
56
- * @param {Function} callback
57
54
  */
58
55
  static _addElementCallback(element, callback) {
59
56
  if (!ResizeObserver._elementCallbacks) {
@@ -69,11 +66,6 @@ export default class ResizeObserver {
69
66
  /**
70
67
  * Removes a resize callback from the DOM element. If no callbacks are left
71
68
  * for the element, it removes the element from the native observer.
72
- *
73
- * @private
74
- * @static
75
- * @param {Element} element
76
- * @param {Function} callback
77
69
  */
78
70
  static _deleteElementCallback(element, callback) {
79
71
  const callbacks = ResizeObserver._getElementCallbacks(element);
@@ -94,11 +86,6 @@ export default class ResizeObserver {
94
86
  }
95
87
  /**
96
88
  * Returns are registered resize callbacks for the DOM element.
97
- *
98
- * @private
99
- * @static
100
- * @param {Element} element
101
- * @returns {Set.<Function>|null|undefined}
102
89
  */
103
90
  static _getElementCallbacks(element) {
104
91
  if (!ResizeObserver._elementCallbacks) {
@@ -108,9 +95,6 @@ export default class ResizeObserver {
108
95
  }
109
96
  /**
110
97
  * Creates the single native observer shared across all `ResizeObserver` instances.
111
- *
112
- * @private
113
- * @static
114
98
  */
115
99
  static _createObserver() {
116
100
  ResizeObserver._observerInstance = new global.window.ResizeObserver(entries => {
@@ -127,19 +111,10 @@ export default class ResizeObserver {
127
111
  }
128
112
  /**
129
113
  * The single native observer instance shared across all {@link module:utils/dom/resizeobserver~ResizeObserver} instances.
130
- *
131
- * @static
132
- * @private
133
- * @readonly
134
- * @property {Object|null}
135
114
  */
136
115
  ResizeObserver._observerInstance = null;
137
116
  /**
138
117
  * A mapping of native DOM elements and their callbacks shared across all
139
118
  * {@link module:utils/dom/resizeobserver~ResizeObserver} instances.
140
- *
141
- * @static
142
- * @private
143
- * @property {Map.<Element,Set>|null}
144
119
  */
145
120
  ResizeObserver._elementCallbacks = null;
package/src/dom/scroll.js CHANGED
@@ -13,9 +13,9 @@ import isText from './istext';
13
13
  * This helper will scroll all `target` ancestors and the web browser viewport to reveal the target to
14
14
  * the user. If the `target` is already visible, nothing will happen.
15
15
  *
16
- * @param {Object} options
17
- * @param {HTMLElement|Range} options.target A target, which supposed to become visible to the user.
18
- * @param {Number} [options.viewportOffset] An offset from the edge of the viewport (in pixels)
16
+ * @param options
17
+ * @param options.target A target, which supposed to become visible to the user.
18
+ * @param options.viewportOffset An offset from the edge of the viewport (in pixels)
19
19
  * the `target` will be moved by when the viewport is scrolled. It enhances the user experience
20
20
  * by keeping the `target` some distance from the edge of the viewport and thus making it easier to
21
21
  * read or edit by the user.
@@ -76,7 +76,7 @@ export function scrollViewportToShowTarget({ target, viewportOffset = 0 }) {
76
76
  * Makes any page `HTMLElement` or `Range` (target) visible within its scrollable ancestors,
77
77
  * e.g. if they have `overflow: scroll` CSS style.
78
78
  *
79
- * @param {HTMLElement|Range} target A target, which supposed to become visible to the user.
79
+ * @param target A target, which supposed to become visible to the user.
80
80
  */
81
81
  export function scrollAncestorsToShowTarget(target) {
82
82
  const targetParent = getParentElement(target);
@@ -84,47 +84,56 @@ export function scrollAncestorsToShowTarget(target) {
84
84
  return new Rect(target);
85
85
  });
86
86
  }
87
- // Makes a given rect visible within its parent window.
88
- //
89
- // Note: Avoid the situation where the caret is still in the viewport, but totally
90
- // at the edge of it. In such situation, if it moved beyond the viewport in the next
91
- // action e.g. after paste, the scrolling would move it to the viewportOffset level
92
- // and it all would look like the caret visually moved up/down:
93
- //
94
- // 1.
95
- // | foo[]
96
- // | <--- N px of space below the caret
97
- // +---------------------------------...
98
- //
99
- // 2. *paste*
100
- // 3.
101
- // |
102
- // |
103
- // +-foo-----------------------------...
104
- // bar[] <--- caret below viewport, scrolling...
105
- //
106
- // 4. *scrolling*
107
- // 5.
108
- // |
109
- // | foo
110
- // | bar[] <--- caret precisely at the edge
111
- // +---------------------------------...
112
- //
113
- // To prevent this, this method checks the rects moved by the viewportOffset to cover
114
- // the upper/lower edge of the viewport. It makes sure if the action repeats, there's
115
- // no twitching – it's a purely visual improvement:
116
- //
117
- // 5. (after fix)
118
- // |
119
- // | foo
120
- // | bar[]
121
- // | <--- N px of space below the caret
122
- // +---------------------------------...
123
- //
124
- // @private
125
- // @param {Window} window A window which is scrolled to reveal the rect.
126
- // @param {module:utils/dom/rect~Rect} rect A rect which is to be revealed.
127
- // @param {Number} viewportOffset See scrollViewportToShowTarget.
87
+ /**
88
+ * Makes a given rect visible within its parent window.
89
+ *
90
+ * Note: Avoid the situation where the caret is still in the viewport, but totally
91
+ * at the edge of it. In such situation, if it moved beyond the viewport in the next
92
+ * action e.g. after paste, the scrolling would move it to the viewportOffset level
93
+ * and it all would look like the caret visually moved up/down:
94
+ *
95
+ * 1.
96
+ * ```
97
+ * | foo[]
98
+ * | <--- N px of space below the caret
99
+ * +---------------------------------...
100
+ * ```
101
+ *
102
+ * 2. *paste*
103
+ * 3.
104
+ * ```
105
+ * |
106
+ * |
107
+ * +-foo-----------------------------...
108
+ * bar[] <--- caret below viewport, scrolling...
109
+ * ```
110
+ *
111
+ * 4. *scrolling*
112
+ * 5.
113
+ * ```
114
+ * |
115
+ * | foo
116
+ * | bar[] <--- caret precisely at the edge
117
+ * +---------------------------------...
118
+ * ```
119
+ *
120
+ * To prevent this, this method checks the rects moved by the viewportOffset to cover
121
+ * the upper/lower edge of the viewport. It makes sure if the action repeats, there's
122
+ * no twitching – it's a purely visual improvement:
123
+ *
124
+ * 5. (after fix)
125
+ * ```
126
+ * |
127
+ * | foo
128
+ * | bar[]
129
+ * | <--- N px of space below the caret
130
+ * +---------------------------------...
131
+ * ```
132
+ *
133
+ * @param window A window which is scrolled to reveal the rect.
134
+ * @param rect A rect which is to be revealed.
135
+ * @param viewportOffset See scrollViewportToShowTarget.
136
+ */
128
137
  function scrollWindowToShowRect(window, rect, viewportOffset) {
129
138
  const targetShiftedDownRect = rect.clone().moveBy(0, viewportOffset);
130
139
  const targetShiftedUpRect = rect.clone().moveBy(0, -viewportOffset);
@@ -149,11 +158,12 @@ function scrollWindowToShowRect(window, rect, viewportOffset) {
149
158
  window.scrollTo(scrollX, scrollY);
150
159
  }
151
160
  }
152
- // Recursively scrolls element ancestors to visually reveal a rect.
153
- //
154
- // @private
155
- // @param {HTMLElement} A parent The first ancestors to start scrolling.
156
- // @param {Function} getRect A function which returns the Rect, which is to be revealed.
161
+ /**
162
+ * Recursively scrolls element ancestors to visually reveal a rect.
163
+ *
164
+ * @param parent A parent The first ancestors to start scrolling.
165
+ * @param getRect A function which returns the Rect, which is to be revealed.
166
+ */
157
167
  function scrollAncestorsToShowRect(parent, getRect) {
158
168
  const parentWindow = getWindow(parent);
159
169
  let parentRect, targetRect;
@@ -177,47 +187,33 @@ function scrollAncestorsToShowRect(parent, getRect) {
177
187
  parent = parent.parentNode;
178
188
  }
179
189
  }
180
- // Determines if a given `Rect` extends beyond the bottom edge of the second `Rect`.
181
- //
182
- // @private
183
- // @param {module:utils/dom/rect~Rect} firstRect
184
- // @param {module:utils/dom/rect~Rect} secondRect
185
- // @returns {Boolean}
190
+ /**
191
+ * Determines if a given `Rect` extends beyond the bottom edge of the second `Rect`.
192
+ */
186
193
  function isBelow(firstRect, secondRect) {
187
194
  return firstRect.bottom > secondRect.bottom;
188
195
  }
189
- // Determines if a given `Rect` extends beyond the top edge of the second `Rect`.
190
- //
191
- // @private
192
- // @param {module:utils/dom/rect~Rect} firstRect
193
- // @param {module:utils/dom/rect~Rect} secondRect
194
- // @returns {Boolean}
196
+ /**
197
+ * Determines if a given `Rect` extends beyond the top edge of the second `Rect`.
198
+ */
195
199
  function isAbove(firstRect, secondRect) {
196
200
  return firstRect.top < secondRect.top;
197
201
  }
198
- // Determines if a given `Rect` extends beyond the left edge of the second `Rect`.
199
- //
200
- // @private
201
- // @param {module:utils/dom/rect~Rect} firstRect
202
- // @param {module:utils/dom/rect~Rect} secondRect
203
- // @returns {Boolean}
202
+ /**
203
+ * Determines if a given `Rect` extends beyond the left edge of the second `Rect`.
204
+ */
204
205
  function isLeftOf(firstRect, secondRect) {
205
206
  return firstRect.left < secondRect.left;
206
207
  }
207
- // Determines if a given `Rect` extends beyond the right edge of the second `Rect`.
208
- //
209
- // @private
210
- // @param {module:utils/dom/rect~Rect} firstRect
211
- // @param {module:utils/dom/rect~Rect} secondRect
212
- // @returns {Boolean}
208
+ /**
209
+ * Determines if a given `Rect` extends beyond the right edge of the second `Rect`.
210
+ */
213
211
  function isRightOf(firstRect, secondRect) {
214
212
  return firstRect.right > secondRect.right;
215
213
  }
216
- // Returns the closest window of an element or range.
217
- //
218
- // @private
219
- // @param {HTMLElement|Range} elementOrRange
220
- // @returns {Window}
214
+ /**
215
+ * Returns the closest window of an element or range.
216
+ */
221
217
  function getWindow(elementOrRange) {
222
218
  if (isRange(elementOrRange)) {
223
219
  return elementOrRange.startContainer.ownerDocument.defaultView;
@@ -226,11 +222,9 @@ function getWindow(elementOrRange) {
226
222
  return elementOrRange.ownerDocument.defaultView;
227
223
  }
228
224
  }
229
- // Returns the closest parent of an element or DOM range.
230
- //
231
- // @private
232
- // @param {HTMLElement|Range} elementOrRange
233
- // @returns {HTMLelement}
225
+ /**
226
+ * Returns the closest parent of an element or DOM range.
227
+ */
234
228
  function getParentElement(elementOrRange) {
235
229
  if (isRange(elementOrRange)) {
236
230
  let parent = elementOrRange.commonAncestorContainer;
@@ -244,13 +238,13 @@ function getParentElement(elementOrRange) {
244
238
  return elementOrRange.parentNode;
245
239
  }
246
240
  }
247
- // Returns the rect of an element or range residing in an iframe.
248
- // The result rect is relative to the geometry of the passed window instance.
249
- //
250
- // @private
251
- // @param {HTMLElement|Range} target Element or range which rect should be returned.
252
- // @param {Window} relativeWindow A window the rect should be relative to.
253
- // @returns {module:utils/dom/rect~Rect}
241
+ /**
242
+ * Returns the rect of an element or range residing in an iframe.
243
+ * The result rect is relative to the geometry of the passed window instance.
244
+ *
245
+ * @param target Element or range which rect should be returned.
246
+ * @param relativeWindow A window the rect should be relative to.
247
+ */
254
248
  function getRectRelativeToWindow(target, relativeWindow) {
255
249
  const targetWindow = getWindow(target);
256
250
  const rect = new Rect(target);
@@ -9,8 +9,8 @@
9
9
  /**
10
10
  * Sets data in a given element.
11
11
  *
12
- * @param {HTMLElement} el The element in which the data will be set.
13
- * @param {String} data The data string.
12
+ * @param el The element in which the data will be set.
13
+ * @param data The data string.
14
14
  */
15
15
  export default function setDataInElement(el, data) {
16
16
  if (el instanceof HTMLTextAreaElement) {
package/src/dom/tounit.js CHANGED
@@ -9,17 +9,8 @@
9
9
  * Returns a helper function, which adds a desired trailing
10
10
  * `unit` to the passed value.
11
11
  *
12
- * @param {String} unit An unit like "px" or "em".
13
- * @returns {module:utils/dom/tounit~helper}
12
+ * @param unit An unit like "px" or "em".
14
13
  */
15
14
  export default function toUnit(unit) {
16
- /**
17
- * A function, which adds a pre–defined trailing `unit`
18
- * to the passed `value`.
19
- *
20
- * @function helper
21
- * @param {String|Number} value A value to be given the unit.
22
- * @returns {String} A value with the trailing unit.
23
- */
24
15
  return value => value + unit;
25
16
  }
@@ -18,8 +18,8 @@ export default class ElementReplacer {
18
18
  *
19
19
  * The effect of this method can be reverted by {@link #restore}.
20
20
  *
21
- * @param {HTMLElement} element The element to replace.
22
- * @param {HTMLElement} [newElement] The replacement element. If not passed, then the `element` will just be hidden.
21
+ * @param element The element to replace.
22
+ * @param newElement The replacement element. If not passed, then the `element` will just be hidden.
23
23
  */
24
24
  replace(element, newElement) {
25
25
  this._replacedElements.push({ element, newElement });