@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
@@ -11,15 +11,17 @@
11
11
  * a flag specifying the relation is returned. Flags are negative numbers, so whenever a number >= 0 is returned
12
12
  * it means that arrays differ.
13
13
  *
14
- * compareArrays( [ 0, 2 ], [ 0, 2 ] ); // 'same'
15
- * compareArrays( [ 0, 2 ], [ 0, 2, 1 ] ); // 'prefix'
16
- * compareArrays( [ 0, 2 ], [ 0 ] ); // 'extension'
17
- * compareArrays( [ 0, 2 ], [ 1, 2 ] ); // 0
18
- * compareArrays( [ 0, 2 ], [ 0, 1 ] ); // 1
14
+ * ```ts
15
+ * compareArrays( [ 0, 2 ], [ 0, 2 ] ); // 'same'
16
+ * compareArrays( [ 0, 2 ], [ 0, 2, 1 ] ); // 'prefix'
17
+ * compareArrays( [ 0, 2 ], [ 0 ] ); // 'extension'
18
+ * compareArrays( [ 0, 2 ], [ 1, 2 ] ); // 0
19
+ * compareArrays( [ 0, 2 ], [ 0, 1 ] ); // 1
20
+ * ```
19
21
  *
20
- * @param {Array} a Array that is compared.
21
- * @param {Array} b Array to compare with.
22
- * @returns {module:utils/comparearrays~ArrayRelation|Number} How array `a` is related to `b`.
22
+ * @param a Array that is compared.
23
+ * @param b Array to compare with.
24
+ * @returns How array `a` is related to `b`.
23
25
  */
24
26
  export default function compareArrays(a, b) {
25
27
  const minLen = Math.min(a.length, b.length);
package/src/config.js CHANGED
@@ -8,21 +8,17 @@
8
8
  import { isPlainObject, isElement, cloneDeepWith } from 'lodash-es';
9
9
  /**
10
10
  * Handles a configuration dictionary.
11
+ *
12
+ * @typeParam Cfg A type of the configuration dictionary.
11
13
  */
12
14
  export default class Config {
13
15
  /**
14
16
  * Creates an instance of the {@link ~Config} class.
15
17
  *
16
- * @param {Object} [configurations] The initial configurations to be set. Usually, provided by the user.
17
- * @param {Object} [defaultConfigurations] The default configurations. Usually, provided by the system.
18
+ * @param configurations The initial configurations to be set. Usually, provided by the user.
19
+ * @param defaultConfigurations The default configurations. Usually, provided by the system.
18
20
  */
19
21
  constructor(configurations, defaultConfigurations) {
20
- /**
21
- * Store for the whole configuration.
22
- *
23
- * @private
24
- * @member {Object}
25
- */
26
22
  this._config = {};
27
23
  // Set default configuration.
28
24
  if (defaultConfigurations) {
@@ -35,57 +31,9 @@ export default class Config {
35
31
  this._setObjectToTarget(this._config, configurations);
36
32
  }
37
33
  }
38
- /**
39
- * Set configuration values.
40
- *
41
- * It accepts both a name/value pair or an object, which properties and values will be used to set
42
- * configurations.
43
- *
44
- * It also accepts setting a "deep configuration" by using dots in the name. For example, `'resize.width'` sets
45
- * the value for the `width` configuration in the `resize` subset.
46
- *
47
- * config.set( 'width', 500 );
48
- * config.set( 'toolbar.collapsed', true );
49
- *
50
- * // Equivalent to:
51
- * config.set( {
52
- * width: 500
53
- * toolbar: {
54
- * collapsed: true
55
- * }
56
- * } );
57
- *
58
- * Passing an object as the value will amend the configuration, not replace it.
59
- *
60
- * config.set( 'toolbar', {
61
- * collapsed: true,
62
- * } );
63
- *
64
- * config.set( 'toolbar', {
65
- * color: 'red',
66
- * } );
67
- *
68
- * config.get( 'toolbar.collapsed' ); // true
69
- * config.get( 'toolbar.color' ); // 'red'
70
- *
71
- * @param {String|Object} name The configuration name or an object from which take properties as
72
- * configuration entries. Configuration names are case-sensitive.
73
- * @param {*} value The configuration value. Used if a name is passed.
74
- */
75
34
  set(name, value) {
76
35
  this._setToTarget(this._config, name, value);
77
36
  }
78
- /**
79
- * Does exactly the same as {@link #set} with one exception – passed configuration extends
80
- * existing one, but does not overwrite already defined values.
81
- *
82
- * This method is supposed to be called by plugin developers to setup plugin's configurations. It would be
83
- * rarely used for other needs.
84
- *
85
- * @param {String|Object} name The configuration name or an object from which take properties as
86
- * configuration entries. Configuration names are case-sensitive.
87
- * @param {*} value The configuration value. Used if a name is passed.
88
- */
89
37
  define(name, value) {
90
38
  const isDefine = true;
91
39
  this._setToTarget(this._config, name, value, isDefine);
@@ -93,22 +41,24 @@ export default class Config {
93
41
  /**
94
42
  * Gets the value for a configuration entry.
95
43
  *
96
- * config.get( 'name' );
44
+ * ```ts
45
+ * config.get( 'name' );
46
+ * ```
97
47
  *
98
48
  * Deep configurations can be retrieved by separating each part with a dot.
99
49
  *
100
- * config.get( 'toolbar.collapsed' );
50
+ * ```ts
51
+ * config.get( 'toolbar.collapsed' );
52
+ * ```
101
53
  *
102
- * @param {String} name The configuration name. Configuration names are case-sensitive.
103
- * @returns {*} The configuration value or `undefined` if the configuration entry was not found.
54
+ * @param name The configuration name. Configuration names are case-sensitive.
55
+ * @returns The configuration value or `undefined` if the configuration entry was not found.
104
56
  */
105
57
  get(name) {
106
58
  return this._getFromSource(this._config, name);
107
59
  }
108
60
  /**
109
61
  * Iterates over all top level configuration names.
110
- *
111
- * @returns {Iterable.<String>}
112
62
  */
113
63
  *names() {
114
64
  for (const name of Object.keys(this._config)) {
@@ -118,12 +68,11 @@ export default class Config {
118
68
  /**
119
69
  * Saves passed configuration to the specified target (nested object).
120
70
  *
121
- * @private
122
- * @param {Object} target Nested config object.
123
- * @param {String|Object} name The configuration name or an object from which take properties as
71
+ * @param target Nested config object.
72
+ * @param name The configuration name or an object from which take properties as
124
73
  * configuration entries. Configuration names are case-sensitive.
125
- * @param {*} value The configuration value. Used if a name is passed.
126
- * @param {Boolean} [isDefine=false] Define if passed configuration should overwrite existing one.
74
+ * @param value The configuration value. Used if a name is passed.
75
+ * @param isDefine Define if passed configuration should overwrite existing one.
127
76
  */
128
77
  _setToTarget(target, name, value, isDefine = false) {
129
78
  // In case of an object, iterate through it and call `_setToTarget` again for each property.
@@ -164,10 +113,9 @@ export default class Config {
164
113
  /**
165
114
  * Get specified configuration from specified source (nested object).
166
115
  *
167
- * @private
168
- * @param {Object} source level of nested object.
169
- * @param {String} name The configuration name. Configuration names are case-sensitive.
170
- * @returns {*} The configuration value or `undefined` if the configuration entry was not found.
116
+ * @param source level of nested object.
117
+ * @param name The configuration name. Configuration names are case-sensitive.
118
+ * @returns The configuration value or `undefined` if the configuration entry was not found.
171
119
  */
172
120
  _getFromSource(source, name) {
173
121
  // The configuration name should be split into parts if it has dots. E.g. `resize.width` -> [`resize`, `width`].
@@ -189,10 +137,9 @@ export default class Config {
189
137
  /**
190
138
  * Iterates through passed object and calls {@link #_setToTarget} method with object key and value for each property.
191
139
  *
192
- * @private
193
- * @param {Object} target Nested config object.
194
- * @param {Object} configuration Configuration data set
195
- * @param {Boolean} [isDefine] Defines if passed configuration is default configuration or not.
140
+ * @param target Nested config object.
141
+ * @param configuration Configuration data set
142
+ * @param isDefine Defines if passed configuration is default configuration or not.
196
143
  */
197
144
  _setObjectToTarget(target, configuration, isDefine) {
198
145
  Object.keys(configuration).forEach(key => {
@@ -200,17 +147,16 @@ export default class Config {
200
147
  });
201
148
  }
202
149
  }
203
- // Clones configuration object or value.
204
- // @param {*} source Source configuration
205
- // @returns {*} Cloned configuration value.
150
+ /**
151
+ * Clones configuration object or value.
152
+ */
206
153
  function cloneConfig(source) {
207
154
  return cloneDeepWith(source, leaveDOMReferences);
208
155
  }
209
- // A customized function for cloneDeepWith.
210
- // It will leave references to DOM Elements instead of cloning them.
211
- //
212
- // @param {*} value
213
- // @returns {Element|undefined}
156
+ /**
157
+ * A customized function for cloneDeepWith.
158
+ * It will leave references to DOM Elements instead of cloning them.
159
+ */
214
160
  function leaveDOMReferences(value) {
215
161
  return isElement(value) ? value : undefined;
216
162
  }
package/src/count.js CHANGED
@@ -8,10 +8,12 @@
8
8
  /**
9
9
  * Returns the number of items return by the iterator.
10
10
  *
11
- * count( [ 1, 2, 3, 4, 5 ] ); // 5;
11
+ * ```ts
12
+ * count( [ 1, 2, 3, 4, 5 ] ); // 5;
13
+ * ```
12
14
  *
13
- * @param {Iterable.<*>} iterable Any iterable.
14
- * @returns {Number} Number of items returned by that iterable.
15
+ * @param iterable Any iterable.
16
+ * @returns Number of items returned by that iterable.
15
17
  */
16
18
  export default function count(iterable) {
17
19
  let count = 0;
package/src/diff.js CHANGED
@@ -12,17 +12,19 @@ import fastDiff from './fastdiff';
12
12
  * Calculates the difference between two arrays or strings producing an array containing a list of changes
13
13
  * necessary to transform input into output.
14
14
  *
15
- * diff( 'aba', 'acca' ); // [ 'equal', 'insert', 'insert', 'delete', 'equal' ]
15
+ * ```ts
16
+ * diff( 'aba', 'acca' ); // [ 'equal', 'insert', 'insert', 'delete', 'equal' ]
17
+ * ```
16
18
  *
17
19
  * This function is based on the "O(NP) Sequence Comparison Algorithm" by Sun Wu, Udi Manber, Gene Myers, Webb Miller.
18
20
  * Unfortunately, while it gives the most precise results, its to complex for longer strings/arrow (above 200 items).
19
21
  * Therefore, `diff()` automatically switches to {@link module:utils/fastdiff~fastDiff `fastDiff()`} when detecting
20
22
  * such a scenario. The return formats of both functions are identical.
21
23
  *
22
- * @param {Array|String} a Input array or string.
23
- * @param {Array|String} b Output array or string.
24
- * @param {Function} [cmp] Optional function used to compare array values, by default === is used.
25
- * @returns {Array.<module:utils/diff~DiffResult>} Array of changes.
24
+ * @param a Input array or string.
25
+ * @param b Output array or string.
26
+ * @param cmp Optional function used to compare array values, by default === is used.
27
+ * @returns Array of changes.
26
28
  */
27
29
  export default function diff(a, b, cmp) {
28
30
  // Set the comparator function.
@@ -9,23 +9,26 @@
9
9
  * Creates a set of changes which need to be applied to the input in order to transform
10
10
  * it into the output. This function can be used with strings or arrays.
11
11
  *
12
- * const input = Array.from( 'abc' );
13
- * const output = Array.from( 'xaby' );
14
- * const changes = diffToChanges( diff( input, output ), output );
12
+ * ```ts
13
+ * const input = Array.from( 'abc' );
14
+ * const output = Array.from( 'xaby' );
15
+ * const changes = diffToChanges( diff( input, output ), output );
15
16
  *
16
- * changes.forEach( change => {
17
- * if ( change.type == 'insert' ) {
18
- * input.splice( change.index, 0, ...change.values );
19
- * } else if ( change.type == 'delete' ) {
20
- * input.splice( change.index, change.howMany );
21
- * }
22
- * } );
17
+ * changes.forEach( change => {
18
+ * if ( change.type == 'insert' ) {
19
+ * input.splice( change.index, 0, ...change.values );
20
+ * } else if ( change.type == 'delete' ) {
21
+ * input.splice( change.index, change.howMany );
22
+ * }
23
+ * } );
23
24
  *
24
- * input.join( '' ) == output.join( '' ); // -> true
25
+ * input.join( '' ) == output.join( '' ); // -> true
26
+ * ```
25
27
  *
26
- * @param {Array.<module:utils/diff~DiffResult>} diff Result of {@link module:utils/diff~diff}.
27
- * @param {String|Array} output The string or array which was passed as diff's output.
28
- * @returns {Array.<module:utils/difftochanges~Change>} Set of changes (insert or delete) which need to be applied to the input
28
+ * @typeParam T The type of output array element.
29
+ * @param diff Result of {@link module:utils/diff~diff}.
30
+ * @param output The string or array which was passed as diff's output.
31
+ * @returns Set of changes (insert or delete) which need to be applied to the input
29
32
  * in order to transform it into the output.
30
33
  */
31
34
  export default function diffToChanges(diff, output) {
@@ -10,17 +10,19 @@ import { isString } from 'lodash-es';
10
10
  /**
11
11
  * Creates element with attributes and children.
12
12
  *
13
- * createElement( document, 'p' ); // <p>
14
- * createElement( document, 'p', { class: 'foo' } ); // <p class="foo">
15
- * createElement( document, 'p', null, 'foo' ); // <p>foo</p>
16
- * createElement( document, 'p', null, [ 'foo', createElement( document, 'img' ) ] ); // <p>foo<img></p>
13
+ * ```ts
14
+ * createElement( document, 'p' ); // <p>
15
+ * createElement( document, 'p', { class: 'foo' } ); // <p class="foo">
16
+ * createElement( document, 'p', null, 'foo' ); // <p>foo</p>
17
+ * createElement( document, 'p', null, [ 'foo', createElement( document, 'img' ) ] ); // <p>foo<img></p>
18
+ * ```
17
19
  *
18
- * @param {Document} doc Document used to create element.
19
- * @param {String} name Name of the element.
20
- * @param {Object} [attributes] Object keys will become attributes keys and object values will became attributes values.
21
- * @param {Node|String|Iterable.<Node|String>} [children] Child or any iterable of children. Strings will be automatically turned
20
+ * @param doc Document used to create element.
21
+ * @param name Name of the element.
22
+ * @param attributes Object keys will become attributes keys and object values will became attributes values.
23
+ * @param children Child or any iterable of children. Strings will be automatically turned
22
24
  * into Text nodes.
23
- * @returns {Element} Created element.
25
+ * @returns Created element.
24
26
  */
25
27
  export default function createElement(doc, name, attributes = {}, children = []) {
26
28
  const namespace = attributes && attributes.xmlns;
@@ -2,37 +2,18 @@
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
- /* eslint-disable new-cap */
6
5
  /**
7
6
  * @module utils/dom/emittermixin
8
7
  */
9
- import { _getEmitterListenedTo, _setEmitterId, Emitter as BaseEmitter } from '../emittermixin';
8
+ import EmitterMixin, { _getEmitterListenedTo, _setEmitterId } from '../emittermixin';
10
9
  import uid from '../uid';
11
10
  import isNode from './isnode';
12
11
  import isWindow from './iswindow';
13
- /**
14
- * Mixin that injects the DOM events API into its host. It provides the API
15
- * compatible with {@link module:utils/emittermixin~EmitterMixin}.
16
- *
17
- * DOM emitter mixin is by default available in the {@link module:ui/view~View} class,
18
- * but it can also be mixed into any other class:
19
- *
20
- * import mix from '../utils/mix.js';
21
- * import DomEmitterMixin from '../utils/dom/emittermixin.js';
22
- * import { Emitter } from '../utils/emittermixin.js';
23
- *
24
- * class SomeView extends DomEmitterMixin( Emitter ) {}
25
- *
26
- * const view = new SomeView();
27
- * view.listenTo( domElement, ( evt, domEvt ) => {
28
- * console.log( evt, domEvt );
29
- * } );
30
- *
31
- * @mixin EmitterMixin
32
- * @mixes module:utils/emittermixin~EmitterMixin
33
- * @implements module:utils/dom/emittermixin~Emitter
34
- */
12
+ const defaultEmitterClass = DomEmitterMixin(EmitterMixin());
35
13
  export default function DomEmitterMixin(base) {
14
+ if (!base) {
15
+ return defaultEmitterClass;
16
+ }
36
17
  class Mixin extends base {
37
18
  listenTo(emitter, event, callback, options = {}) {
38
19
  // Check if emitter is an instance of DOM Node. If so, use corresponding ProxyEmitter (or create one if not existing).
@@ -46,7 +27,7 @@ export default function DomEmitterMixin(base) {
46
27
  }
47
28
  else {
48
29
  // Execute parent class method with Emitter (or ProxyEmitter) instance.
49
- BaseEmitter.prototype.listenTo.call(this, emitter, event, callback, options);
30
+ super.listenTo(emitter, event, callback, options);
50
31
  }
51
32
  }
52
33
  stopListening(emitter, event, callback) {
@@ -59,20 +40,19 @@ export default function DomEmitterMixin(base) {
59
40
  }
60
41
  else {
61
42
  // Execute parent class method with Emitter (or ProxyEmitter) instance.
62
- BaseEmitter.prototype.stopListening.call(this, emitter, event, callback);
43
+ super.stopListening(emitter, event, callback);
63
44
  }
64
45
  }
65
46
  /**
66
47
  * Retrieves ProxyEmitter instance for given DOM Node residing in this Host and given options.
67
48
  *
68
- * @private
69
- * @param {Node|Window} node DOM Node of the ProxyEmitter.
70
- * @param {Object} [options] Additional options.
71
- * @param {Boolean} [options.useCapture=false] Indicates that events of this type will be dispatched to the registered
49
+ * @param node DOM Node of the ProxyEmitter.
50
+ * @param options Additional options.
51
+ * @param options.useCapture Indicates that events of this type will be dispatched to the registered
72
52
  * listener before being dispatched to any EventTarget beneath it in the DOM tree.
73
- * @param {Boolean} [options.usePassive=false] Indicates that the function specified by listener will never call preventDefault()
53
+ * @param options.usePassive Indicates that the function specified by listener will never call preventDefault()
74
54
  * and prevents blocking browser's main thread by this event handler.
75
- * @returns {module:utils/dom/emittermixin~ProxyEmitter|null} ProxyEmitter instance bound to the DOM Node.
55
+ * @returns ProxyEmitter instance bound to the DOM Node.
76
56
  */
77
57
  _getProxyEmitter(node, options) {
78
58
  return _getEmitterListenedTo(this, getProxyEmitterId(node, options));
@@ -80,9 +60,7 @@ export default function DomEmitterMixin(base) {
80
60
  /**
81
61
  * Retrieves all the ProxyEmitter instances for given DOM Node residing in this Host.
82
62
  *
83
- * @private
84
- * @param {Node|Window} node DOM Node of the ProxyEmitter.
85
- * @returns {Array.<module:utils/dom/emittermixin~ProxyEmitter>}
63
+ * @param node DOM Node of the ProxyEmitter.
86
64
  */
87
65
  _getAllProxyEmitters(node) {
88
66
  return [
@@ -95,7 +73,6 @@ export default function DomEmitterMixin(base) {
95
73
  }
96
74
  return Mixin;
97
75
  }
98
- export const Emitter = DomEmitterMixin(BaseEmitter);
99
76
  // Backward compatibility with `mix`
100
77
  ([
101
78
  '_getProxyEmitter', '_getAllProxyEmitters',
@@ -103,11 +80,11 @@ export const Emitter = DomEmitterMixin(BaseEmitter);
103
80
  'stopListening', 'fire', 'delegate', 'stopDelegating',
104
81
  '_addEventListener', '_removeEventListener'
105
82
  ]).forEach(key => {
106
- DomEmitterMixin[key] = Emitter.prototype[key];
83
+ DomEmitterMixin[key] = defaultEmitterClass.prototype[key];
107
84
  });
108
85
  /**
109
86
  * Creates a ProxyEmitter instance. Such an instance is a bridge between a DOM Node firing events
110
- * and any Host listening to them. It is backwards compatible with {@link module:utils/emittermixin~EmitterMixin#on}.
87
+ * and any Host listening to them. It is backwards compatible with {@link module:utils/emittermixin~Emitter#on}.
111
88
  * There is a separate instance for each combination of modes (useCapture & usePassive). The mode is concatenated with
112
89
  * UID stored in HTMLElement to give each instance unique identifier.
113
90
  *
@@ -132,18 +109,14 @@ export const Emitter = DomEmitterMixin(BaseEmitter);
132
109
  * | | click (DOM Event)
133
110
  * +-----------------------------------------+
134
111
  * fire( click, DOM Event )
135
- *
136
- * @mixes module:utils/emittermixin~EmitterMixin
137
- * @implements module:utils/dom/emittermixin~Emitter
138
- * @private
139
112
  */
140
- class ProxyEmitter extends BaseEmitter {
113
+ class ProxyEmitter extends EmitterMixin() {
141
114
  /**
142
- * @param {Node|Window} node DOM Node that fires events.
143
- * @param {Object} [options] Additional options.
144
- * @param {Boolean} [options.useCapture=false] Indicates that events of this type will be dispatched to the registered
115
+ * @param node DOM Node that fires events.
116
+ * @param options Additional options.
117
+ * @param options.useCapture Indicates that events of this type will be dispatched to the registered
145
118
  * listener before being dispatched to any EventTarget beneath it in the DOM tree.
146
- * @param {Boolean} [options.usePassive=false] Indicates that the function specified by listener will never call preventDefault()
119
+ * @param options.usePassive Indicates that the function specified by listener will never call preventDefault()
147
120
  * and prevents blocking browser's main thread by this event handler.
148
121
  */
149
122
  constructor(node, options) {
@@ -162,10 +135,9 @@ class ProxyEmitter extends BaseEmitter {
162
135
  * a corresponding Emitter event will also fire with DOM Event object as an argument.
163
136
  *
164
137
  * **Note**: This is automatically called by the
165
- * {@link module:utils/emittermixin~EmitterMixin#listenTo `EmitterMixin#listenTo()`}.
138
+ * {@link module:utils/emittermixin~Emitter#listenTo `Emitter#listenTo()`}.
166
139
  *
167
- * @method module:utils/dom/emittermixin~ProxyEmitter#attach
168
- * @param {String} event The name of the event.
140
+ * @param event The name of the event.
169
141
  */
170
142
  attach(event) {
171
143
  // If the DOM Listener for given event already exist it is pointless
@@ -187,10 +159,9 @@ class ProxyEmitter extends BaseEmitter {
187
159
  * Stops executing the callback on the given event.
188
160
  *
189
161
  * **Note**: This is automatically called by the
190
- * {@link module:utils/emittermixin~EmitterMixin#stopListening `EmitterMixin#stopListening()`}.
162
+ * {@link module:utils/emittermixin~Emitter#stopListening `Emitter#stopListening()`}.
191
163
  *
192
- * @method module:utils/dom/emittermixin~ProxyEmitter#detach
193
- * @param {String} event The name of the event.
164
+ * @param event The name of the event.
194
165
  */
195
166
  detach(event) {
196
167
  let events;
@@ -204,29 +175,24 @@ class ProxyEmitter extends BaseEmitter {
204
175
  /**
205
176
  * Adds callback to emitter for given event.
206
177
  *
207
- * @protected
208
- * @method module:utils/dom/emittermixin~ProxyEmitter#_addEventListener
209
- * @param {String} event The name of the event.
210
- * @param {Function} callback The function to be called on event.
211
- * @param {Object} [options={}] Additional options.
212
- * @param {module:utils/priorities~PriorityString} [options.priority='normal'] The priority of this event callback. The higher
213
- * the priority value the sooner the callback will be fired. Events having the same priority are called in the
214
- * order they were added.
178
+ * @internal
179
+ * @param event The name of the event.
180
+ * @param callback The function to be called on event.
181
+ * @param options Additional options.
215
182
  */
216
183
  _addEventListener(event, callback, options) {
217
184
  this.attach(event);
218
- BaseEmitter.prototype._addEventListener.call(this, event, callback, options);
185
+ EmitterMixin().prototype._addEventListener.call(this, event, callback, options);
219
186
  }
220
187
  /**
221
188
  * Removes callback from emitter for given event.
222
189
  *
223
- * @protected
224
- * @method module:utils/dom/emittermixin~ProxyEmitter#_removeEventListener
225
- * @param {String} event The name of the event.
226
- * @param {Function} callback The function to stop being called.
190
+ * @internal
191
+ * @param event The name of the event.
192
+ * @param callback The function to stop being called.
227
193
  */
228
194
  _removeEventListener(event, callback) {
229
- BaseEmitter.prototype._removeEventListener.call(this, event, callback);
195
+ EmitterMixin().prototype._removeEventListener.call(this, event, callback);
230
196
  this.detach(event);
231
197
  }
232
198
  /**
@@ -234,10 +200,8 @@ class ProxyEmitter extends BaseEmitter {
234
200
  * is fired it will fire corresponding event on this ProxyEmitter.
235
201
  * Note: A native DOM Event is passed as an argument.
236
202
  *
237
- * @private
238
- * @method module:utils/dom/emittermixin~ProxyEmitter#_createDomListener
239
- * @param {String} event The name of the event.
240
- * @returns {Function} The DOM listener callback.
203
+ * @param event The name of the event.
204
+ * @returns The DOM listener callback.
241
205
  */
242
206
  _createDomListener(event) {
243
207
  const domListener = (domEvt) => {
@@ -253,22 +217,17 @@ class ProxyEmitter extends BaseEmitter {
253
217
  return domListener;
254
218
  }
255
219
  }
256
- // Gets an unique DOM Node identifier. The identifier will be set if not defined.
257
- //
258
- // @private
259
- // @param {Node} node
260
- // @returns {String} UID for given DOM Node.
220
+ /**
221
+ * Gets an unique DOM Node identifier. The identifier will be set if not defined.
222
+ *
223
+ * @returns UID for given DOM Node.
224
+ */
261
225
  function getNodeUID(node) {
262
226
  return node['data-ck-expando'] || (node['data-ck-expando'] = uid());
263
227
  }
264
- // Gets id of the ProxyEmitter for the given node.
265
- //
266
- // Combines DOM Node identifier and additional options.
267
- //
268
- // @private
269
- // @param {Node} node
270
- // @param {Object} options Additional options.
271
- // @returns {String} ProxyEmitter id.
228
+ /**
229
+ * Gets id of the ProxyEmitter for the given node.
230
+ */
272
231
  function getProxyEmitterId(node, options) {
273
232
  let id = getNodeUID(node);
274
233
  for (const option of Object.keys(options).sort()) {
@@ -12,8 +12,8 @@
12
12
  * appended to a `Document`, that `Document` will not be returned (algorithms operating on DOM tree care for `Document#documentElement`
13
13
  * at most, which will be returned).
14
14
  *
15
- * @param {Node} node DOM node.
16
- * @returns {Array.<Node|DocumentFragment>} Array of given `node` parents.
15
+ * @param node DOM node.
16
+ * @returns Array of given `node` parents.
17
17
  */
18
18
  export default function getAncestors(node) {
19
19
  const nodes = [];
@@ -8,8 +8,8 @@
8
8
  /**
9
9
  * Returns an object containing CSS border widths of a specified HTML element.
10
10
  *
11
- * @param {HTMLElement} element An element which has CSS borders.
12
- * @returns {module:utils/dom/getborderwidths~BorderWidths} An object containing `top`, `left`, `right` and `bottom` properties
11
+ * @param element An element which has CSS borders.
12
+ * @returns An object containing `top`, `left`, `right` and `bottom` properties
13
13
  * with numerical values of the `border-[top,left,right,bottom]-width` CSS styles.
14
14
  */
15
15
  export default function getBorderWidths(element) {
@@ -9,9 +9,9 @@ import getAncestors from './getancestors';
9
9
  /**
10
10
  * Searches and returns the lowest common ancestor of two given nodes.
11
11
  *
12
- * @param {Node} nodeA First node.
13
- * @param {Node} nodeB Second node.
14
- * @returns {Node|DocumentFragment|Document|null} Lowest common ancestor of both nodes or `null` if nodes do not have a common ancestor.
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
15
  */
16
16
  export default function getCommonAncestor(nodeA, nodeB) {
17
17
  const ancestorsA = getAncestors(nodeA);
@@ -9,8 +9,8 @@
9
9
  /**
10
10
  * Gets data from a given source element.
11
11
  *
12
- * @param {HTMLElement} el The element from which the data will be retrieved.
13
- * @returns {String} The data string.
12
+ * @param el The element from which the data will be retrieved.
13
+ * @returns The data string.
14
14
  */
15
15
  export default function getDataFromElement(el) {
16
16
  if (el instanceof HTMLTextAreaElement) {
@@ -9,8 +9,7 @@ import global from './global';
9
9
  /**
10
10
  * For a given element, returns the nearest ancestor element which CSS position is not "static".
11
11
  *
12
- * @param {HTMLElement} [element] The native DOM element to be checked.
13
- * @returns {HTMLElement|null}
12
+ * @param element The native DOM element to be checked.
14
13
  */
15
14
  export default function getPositionedAncestor(element) {
16
15
  if (!element || !element.parentNode) {