@ckeditor/ckeditor5-utils 34.2.0 → 35.0.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 (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 +0 -92
  5. package/src/ckeditorerror.js +0 -217
  6. package/src/collection.js +0 -785
  7. package/src/comparearrays.js +0 -51
  8. package/src/config.js +0 -246
  9. package/src/count.js +0 -26
  10. package/src/diff.js +0 -138
  11. package/src/difftochanges.js +0 -86
  12. package/src/dom/createelement.js +0 -49
  13. package/src/dom/emittermixin.js +0 -341
  14. package/src/dom/getancestors.js +0 -31
  15. package/src/dom/getborderwidths.js +0 -27
  16. package/src/dom/getcommonancestor.js +0 -31
  17. package/src/dom/getdatafromelement.js +0 -24
  18. package/src/dom/getpositionedancestor.js +0 -28
  19. package/src/dom/global.js +0 -26
  20. package/src/dom/indexof.js +0 -25
  21. package/src/dom/insertat.js +0 -19
  22. package/src/dom/iscomment.js +0 -20
  23. package/src/dom/isnode.js +0 -26
  24. package/src/dom/isrange.js +0 -18
  25. package/src/dom/istext.js +0 -18
  26. package/src/dom/isvisible.js +0 -25
  27. package/src/dom/iswindow.js +0 -30
  28. package/src/dom/position.js +0 -518
  29. package/src/dom/rect.js +0 -443
  30. package/src/dom/remove.js +0 -21
  31. package/src/dom/resizeobserver.js +0 -378
  32. package/src/dom/scroll.js +0 -302
  33. package/src/dom/setdatainelement.js +0 -24
  34. package/src/dom/tounit.js +0 -27
  35. package/src/elementreplacer.js +0 -57
  36. package/src/emittermixin.js +0 -719
  37. package/src/env.js +0 -190
  38. package/src/eventinfo.js +0 -79
  39. package/src/fastdiff.js +0 -261
  40. package/src/first.js +0 -24
  41. package/src/focustracker.js +0 -157
  42. package/src/index.js +0 -45
  43. package/src/inserttopriorityarray.js +0 -42
  44. package/src/isiterable.js +0 -18
  45. package/src/keyboard.js +0 -301
  46. package/src/keystrokehandler.js +0 -130
  47. package/src/language.js +0 -26
  48. package/src/locale.js +0 -176
  49. package/src/mapsequal.js +0 -32
  50. package/src/mix.js +0 -47
  51. package/src/nth.js +0 -31
  52. package/src/objecttomap.js +0 -29
  53. package/src/observablemixin.js +0 -908
  54. package/src/priorities.js +0 -44
  55. package/src/spy.js +0 -25
  56. package/src/toarray.js +0 -18
  57. package/src/tomap.js +0 -29
  58. package/src/translation-service.js +0 -216
  59. package/src/uid.js +0 -59
  60. package/src/unicode.js +0 -106
  61. package/src/version.js +0 -157
@@ -1,341 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2022, 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
- /**
7
- * @module utils/dom/emittermixin
8
- */
9
-
10
- import { default as EmitterMixin, _getEmitterListenedTo, _setEmitterId } from '../emittermixin';
11
- import uid from '../uid';
12
- import isNode from './isnode';
13
- import isWindow from './iswindow';
14
- import { extend } from 'lodash-es';
15
-
16
- /**
17
- * Mixin that injects the DOM events API into its host. It provides the API
18
- * compatible with {@link module:utils/emittermixin~EmitterMixin}.
19
- *
20
- * DOM emitter mixin is by default available in the {@link module:ui/view~View} class,
21
- * but it can also be mixed into any other class:
22
- *
23
- * import mix from '../utils/mix.js';
24
- * import DomEmitterMixin from '../utils/dom/emittermixin.js';
25
- *
26
- * class SomeView {}
27
- * mix( SomeView, DomEmitterMixin );
28
- *
29
- * const view = new SomeView();
30
- * view.listenTo( domElement, ( evt, domEvt ) => {
31
- * console.log( evt, domEvt );
32
- * } );
33
- *
34
- * @mixin EmitterMixin
35
- * @mixes module:utils/emittermixin~EmitterMixin
36
- * @implements module:utils/dom/emittermixin~Emitter
37
- */
38
- const DomEmitterMixin = extend( {}, EmitterMixin, {
39
- /**
40
- * Registers a callback function to be executed when an event is fired in a specific Emitter or DOM Node.
41
- * It is backwards compatible with {@link module:utils/emittermixin~EmitterMixin#listenTo}.
42
- *
43
- * @param {module:utils/emittermixin~Emitter|Node} emitter The object that fires the event.
44
- * @param {String} event The name of the event.
45
- * @param {Function} callback The function to be called on event.
46
- * @param {Object} [options={}] Additional options.
47
- * @param {module:utils/priorities~PriorityString|Number} [options.priority='normal'] The priority of this event callback. The higher
48
- * the priority value the sooner the callback will be fired. Events having the same priority are called in the
49
- * order they were added.
50
- * @param {Boolean} [options.useCapture=false] Indicates that events of this type will be dispatched to the registered
51
- * listener before being dispatched to any EventTarget beneath it in the DOM tree.
52
- * @param {Boolean} [options.usePassive=false] Indicates that the function specified by listener will never call preventDefault()
53
- * and prevents blocking browser's main thread by this event handler.
54
- */
55
- listenTo( emitter, event, callback, options = {} ) {
56
- // Check if emitter is an instance of DOM Node. If so, use corresponding ProxyEmitter (or create one if not existing).
57
- if ( isNode( emitter ) || isWindow( emitter ) ) {
58
- const proxyOptions = {
59
- capture: !!options.useCapture,
60
- passive: !!options.usePassive
61
- };
62
-
63
- const proxyEmitter = this._getProxyEmitter( emitter, proxyOptions ) || new ProxyEmitter( emitter, proxyOptions );
64
-
65
- this.listenTo( proxyEmitter, event, callback, options );
66
- } else {
67
- // Execute parent class method with Emitter (or ProxyEmitter) instance.
68
- EmitterMixin.listenTo.call( this, emitter, event, callback, options );
69
- }
70
- },
71
-
72
- /**
73
- * Stops listening for events. It can be used at different levels:
74
- * It is backwards compatible with {@link module:utils/emittermixin~EmitterMixin#listenTo}.
75
- *
76
- * * To stop listening to a specific callback.
77
- * * To stop listening to a specific event.
78
- * * To stop listening to all events fired by a specific object.
79
- * * To stop listening to all events fired by all object.
80
- *
81
- * @param {module:utils/emittermixin~Emitter|Node} [emitter] The object to stop listening to. If omitted, stops it for all objects.
82
- * @param {String} [event] (Requires the `emitter`) The name of the event to stop listening to. If omitted, stops it
83
- * for all events from `emitter`.
84
- * @param {Function} [callback] (Requires the `event`) The function to be removed from the call list for the given
85
- * `event`.
86
- */
87
- stopListening( emitter, event, callback ) {
88
- // Check if the emitter is an instance of DOM Node. If so, forward the call to the corresponding ProxyEmitters.
89
- if ( isNode( emitter ) || isWindow( emitter ) ) {
90
- const proxyEmitters = this._getAllProxyEmitters( emitter );
91
-
92
- for ( const proxy of proxyEmitters ) {
93
- this.stopListening( proxy, event, callback );
94
- }
95
- } else {
96
- // Execute parent class method with Emitter (or ProxyEmitter) instance.
97
- EmitterMixin.stopListening.call( this, emitter, event, callback );
98
- }
99
- },
100
-
101
- /**
102
- * Retrieves ProxyEmitter instance for given DOM Node residing in this Host and given options.
103
- *
104
- * @private
105
- * @param {Node} node DOM Node of the ProxyEmitter.
106
- * @param {Object} [options] Additional options.
107
- * @param {Boolean} [options.useCapture=false] Indicates that events of this type will be dispatched to the registered
108
- * listener before being dispatched to any EventTarget beneath it in the DOM tree.
109
- * @param {Boolean} [options.usePassive=false] Indicates that the function specified by listener will never call preventDefault()
110
- * and prevents blocking browser's main thread by this event handler.
111
- * @returns {module:utils/dom/emittermixin~ProxyEmitter|null} ProxyEmitter instance bound to the DOM Node.
112
- */
113
- _getProxyEmitter( node, options ) {
114
- return _getEmitterListenedTo( this, getProxyEmitterId( node, options ) );
115
- },
116
-
117
- /**
118
- * Retrieves all the ProxyEmitter instances for given DOM Node residing in this Host.
119
- *
120
- * @private
121
- * @param {Node} node DOM Node of the ProxyEmitter.
122
- * @returns {Array.<module:utils/dom/emittermixin~ProxyEmitter>}
123
- */
124
- _getAllProxyEmitters( node ) {
125
- return [
126
- { capture: false, passive: false },
127
- { capture: false, passive: true },
128
- { capture: true, passive: false },
129
- { capture: true, passive: true }
130
- ].map( options => this._getProxyEmitter( node, options ) ).filter( proxy => !!proxy );
131
- }
132
- } );
133
-
134
- export default DomEmitterMixin;
135
-
136
- /**
137
- * Creates a ProxyEmitter instance. Such an instance is a bridge between a DOM Node firing events
138
- * and any Host listening to them. It is backwards compatible with {@link module:utils/emittermixin~EmitterMixin#on}.
139
- * There is a separate instance for each combination of modes (useCapture & usePassive). The mode is concatenated with
140
- * UID stored in HTMLElement to give each instance unique identifier.
141
- *
142
- * listenTo( click, ... )
143
- * +-----------------------------------------+
144
- * | stopListening( ... ) |
145
- * +----------------------------+ | addEventListener( click, ... )
146
- * | Host | | +---------------------------------------------+
147
- * +----------------------------+ | | removeEventListener( click, ... ) |
148
- * | _listeningTo: { | +----------v-------------+ |
149
- * | UID+mode: { | | ProxyEmitter | |
150
- * | emitter: ProxyEmitter, | +------------------------+ +------------v----------+
151
- * | callbacks: { | | events: { | | Node (HTMLElement) |
152
- * | click: [ callbacks ] | | click: [ callbacks ] | +-----------------------+
153
- * | } | | }, | | data-ck-expando: UID |
154
- * | } | | _domNode: Node, | +-----------------------+
155
- * | } | | _domListeners: {}, | |
156
- * | +------------------------+ | | _emitterId: UID+mode | |
157
- * | | DomEmitterMixin | | +--------------^---------+ |
158
- * | +------------------------+ | | | |
159
- * +--------------^-------------+ | +---------------------------------------------+
160
- * | | click (DOM Event)
161
- * +-----------------------------------------+
162
- * fire( click, DOM Event )
163
- *
164
- * @mixes module:utils/emittermixin~EmitterMixin
165
- * @implements module:utils/dom/emittermixin~Emitter
166
- * @private
167
- */
168
- class ProxyEmitter {
169
- /**
170
- * @param {Node} node DOM Node that fires events.
171
- * @param {Object} [options] Additional options.
172
- * @param {Boolean} [options.useCapture=false] Indicates that events of this type will be dispatched to the registered
173
- * listener before being dispatched to any EventTarget beneath it in the DOM tree.
174
- * @param {Boolean} [options.usePassive=false] Indicates that the function specified by listener will never call preventDefault()
175
- * and prevents blocking browser's main thread by this event handler.
176
- */
177
- constructor( node, options ) {
178
- // Set emitter ID to match DOM Node "expando" property.
179
- _setEmitterId( this, getProxyEmitterId( node, options ) );
180
-
181
- // Remember the DOM Node this ProxyEmitter is bound to.
182
- this._domNode = node;
183
-
184
- // And given options.
185
- this._options = options;
186
- }
187
- }
188
-
189
- extend( ProxyEmitter.prototype, EmitterMixin, {
190
- /**
191
- * Collection of native DOM listeners.
192
- *
193
- * @private
194
- * @member {Object} module:utils/dom/emittermixin~ProxyEmitter#_domListeners
195
- */
196
-
197
- /**
198
- * Registers a callback function to be executed when an event is fired.
199
- *
200
- * It attaches a native DOM listener to the DOM Node. When fired,
201
- * a corresponding Emitter event will also fire with DOM Event object as an argument.
202
- *
203
- * **Note**: This is automatically called by the
204
- * {@link module:utils/emittermixin~EmitterMixin#listenTo `EmitterMixin#listenTo()`}.
205
- *
206
- * @method module:utils/dom/emittermixin~ProxyEmitter#attach
207
- * @param {String} event The name of the event.
208
- */
209
- attach( event ) {
210
- // If the DOM Listener for given event already exist it is pointless
211
- // to attach another one.
212
- if ( this._domListeners && this._domListeners[ event ] ) {
213
- return;
214
- }
215
-
216
- const domListener = this._createDomListener( event );
217
-
218
- // Attach the native DOM listener to DOM Node.
219
- this._domNode.addEventListener( event, domListener, this._options );
220
-
221
- if ( !this._domListeners ) {
222
- this._domListeners = {};
223
- }
224
-
225
- // Store the native DOM listener in this ProxyEmitter. It will be helpful
226
- // when stopping listening to the event.
227
- this._domListeners[ event ] = domListener;
228
- },
229
-
230
- /**
231
- * Stops executing the callback on the given event.
232
- *
233
- * **Note**: This is automatically called by the
234
- * {@link module:utils/emittermixin~EmitterMixin#stopListening `EmitterMixin#stopListening()`}.
235
- *
236
- * @method module:utils/dom/emittermixin~ProxyEmitter#detach
237
- * @param {String} event The name of the event.
238
- */
239
- detach( event ) {
240
- let events;
241
-
242
- // Remove native DOM listeners which are orphans. If no callbacks
243
- // are awaiting given event, detach native DOM listener from DOM Node.
244
- // See: {@link attach}.
245
-
246
- if ( this._domListeners[ event ] && ( !( events = this._events[ event ] ) || !events.callbacks.length ) ) {
247
- this._domListeners[ event ].removeListener();
248
- }
249
- },
250
-
251
- /**
252
- * Adds callback to emitter for given event.
253
- *
254
- * @protected
255
- * @method module:utils/dom/emittermixin~ProxyEmitter#_addEventListener
256
- * @param {String} event The name of the event.
257
- * @param {Function} callback The function to be called on event.
258
- * @param {Object} [options={}] Additional options.
259
- * @param {module:utils/priorities~PriorityString|Number} [options.priority='normal'] The priority of this event callback. The higher
260
- * the priority value the sooner the callback will be fired. Events having the same priority are called in the
261
- * order they were added.
262
- */
263
- _addEventListener( event, callback, options ) {
264
- this.attach( event );
265
- EmitterMixin._addEventListener.call( this, event, callback, options );
266
- },
267
-
268
- /**
269
- * Removes callback from emitter for given event.
270
- *
271
- * @protected
272
- * @method module:utils/dom/emittermixin~ProxyEmitter#_removeEventListener
273
- * @param {String} event The name of the event.
274
- * @param {Function} callback The function to stop being called.
275
- */
276
- _removeEventListener( event, callback ) {
277
- EmitterMixin._removeEventListener.call( this, event, callback );
278
- this.detach( event );
279
- },
280
-
281
- /**
282
- * Creates a native DOM listener callback. When the native DOM event
283
- * is fired it will fire corresponding event on this ProxyEmitter.
284
- * Note: A native DOM Event is passed as an argument.
285
- *
286
- * @private
287
- * @method module:utils/dom/emittermixin~ProxyEmitter#_createDomListener
288
- * @param {String} event The name of the event.
289
- * @returns {Function} The DOM listener callback.
290
- */
291
- _createDomListener( event ) {
292
- const domListener = domEvt => {
293
- this.fire( event, domEvt );
294
- };
295
-
296
- // Supply the DOM listener callback with a function that will help
297
- // detach it from the DOM Node, when it is no longer necessary.
298
- // See: {@link detach}.
299
- domListener.removeListener = () => {
300
- this._domNode.removeEventListener( event, domListener, this._options );
301
- delete this._domListeners[ event ];
302
- };
303
-
304
- return domListener;
305
- }
306
- } );
307
-
308
- // Gets an unique DOM Node identifier. The identifier will be set if not defined.
309
- //
310
- // @private
311
- // @param {Node} node
312
- // @returns {String} UID for given DOM Node.
313
- function getNodeUID( node ) {
314
- return node[ 'data-ck-expando' ] || ( node[ 'data-ck-expando' ] = uid() );
315
- }
316
-
317
- // Gets id of the ProxyEmitter for the given node.
318
- //
319
- // Combines DOM Node identifier and additional options.
320
- //
321
- // @private
322
- // @param {Node} node
323
- // @param {Object} options Additional options.
324
- // @returns {String} ProxyEmitter id.
325
- function getProxyEmitterId( node, options ) {
326
- let id = getNodeUID( node );
327
-
328
- for ( const option of Object.keys( options ).sort() ) {
329
- if ( options[ option ] ) {
330
- id += '-' + option;
331
- }
332
- }
333
-
334
- return id;
335
- }
336
-
337
- /**
338
- * Interface representing classes which mix in {@link module:utils/dom/emittermixin~EmitterMixin}.
339
- *
340
- * @interface Emitter
341
- */
@@ -1,31 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2022, 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
- /* globals Node */
7
-
8
- /**
9
- * @module utils/dom/getancestors
10
- */
11
-
12
- /**
13
- * Returns all ancestors of given DOM node, starting from the top-most (root). Includes the given node itself. If the
14
- * node is a part of `DocumentFragment` that `DocumentFragment` will be returned. In contrary, if the node is
15
- * appended to a `Document`, that `Document` will not be returned (algorithms operating on DOM tree care for `Document#documentElement`
16
- * at most, which will be returned).
17
- *
18
- * @param {Node} node DOM node.
19
- * @returns {Array.<Node|DocumentFragment>} Array of given `node` parents.
20
- */
21
- export default function getAncestors( node ) {
22
- const nodes = [];
23
-
24
- // We are interested in `Node`s `DocumentFragment`s only.
25
- while ( node && node.nodeType != Node.DOCUMENT_NODE ) {
26
- nodes.unshift( node );
27
- node = node.parentNode;
28
- }
29
-
30
- return nodes;
31
- }
@@ -1,27 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2022, 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
- /**
7
- * @module utils/dom/getborderwidths
8
- */
9
-
10
- /**
11
- * Returns an object containing CSS border widths of a specified HTML element.
12
- *
13
- * @param {HTMLElement} element An element which has CSS borders.
14
- * @returns {Object} An object containing `top`, `left`, `right` and `bottom` properties
15
- * with numerical values of the `border-[top,left,right,bottom]-width` CSS styles.
16
- */
17
- export default function getBorderWidths( element ) {
18
- // Call getComputedStyle on the window the element document belongs to.
19
- const style = element.ownerDocument.defaultView.getComputedStyle( element );
20
-
21
- return {
22
- top: parseInt( style.borderTopWidth, 10 ),
23
- right: parseInt( style.borderRightWidth, 10 ),
24
- bottom: parseInt( style.borderBottomWidth, 10 ),
25
- left: parseInt( style.borderLeftWidth, 10 )
26
- };
27
- }
@@ -1,31 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2022, 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
- /**
7
- * @module utils/dom/getcommonancestor
8
- */
9
-
10
- import getAncestors from './getancestors';
11
-
12
- /**
13
- * Searches and returns the lowest common ancestor of two given nodes.
14
- *
15
- * @param {Node} nodeA First node.
16
- * @param {Node} nodeB Second node.
17
- * @returns {Node|DocumentFragment|Document|null} Lowest common ancestor of both nodes or `null` if nodes do not have a common ancestor.
18
- */
19
- export default function getCommonAncestor( nodeA, nodeB ) {
20
- const ancestorsA = getAncestors( nodeA );
21
- const ancestorsB = getAncestors( nodeB );
22
-
23
- let i = 0;
24
-
25
- // It does not matter which array is shorter.
26
- while ( ancestorsA[ i ] == ancestorsB[ i ] && ancestorsA[ i ] ) {
27
- i++;
28
- }
29
-
30
- return i === 0 ? null : ancestorsA[ i - 1 ];
31
- }
@@ -1,24 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2022, 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
- /* globals HTMLTextAreaElement */
7
-
8
- /**
9
- * @module utils/dom/getdatafromelement
10
- */
11
-
12
- /**
13
- * Gets data from a given source element.
14
- *
15
- * @param {HTMLElement} el The element from which the data will be retrieved.
16
- * @returns {String} The data string.
17
- */
18
- export default function getDataFromElement( el ) {
19
- if ( el instanceof HTMLTextAreaElement ) {
20
- return el.value;
21
- }
22
-
23
- return el.innerHTML;
24
- }
@@ -1,28 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2022, 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
- /**
7
- * @module utils/dom/getpositionedancestor
8
- */
9
-
10
- import global from './global';
11
-
12
- /**
13
- * For a given element, returns the nearest ancestor element which CSS position is not "static".
14
- *
15
- * @param {HTMLElement} element The native DOM element to be checked.
16
- * @returns {HTMLElement|null}
17
- */
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;
28
- }
package/src/dom/global.js DELETED
@@ -1,26 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2022, 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
- /* globals window, document */
7
-
8
- /**
9
- * @module utils/dom/global
10
- */
11
-
12
- /**
13
- * A helper (module) giving an access to the global DOM objects such as `window` and
14
- * `document`. Accessing these objects using this helper allows easy and bulletproof
15
- * testing, i.e. stubbing native properties:
16
- *
17
- * import global from 'ckeditor5/utils/dom/global.js';
18
- *
19
- * // This stub will work for any code using global module.
20
- * testUtils.sinon.stub( global, 'window', {
21
- * innerWidth: 10000
22
- * } );
23
- *
24
- * console.log( global.window.innerWidth );
25
- */
26
- export default { window, document };
@@ -1,25 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2022, 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
- /**
7
- * @module utils/dom/indexof
8
- */
9
-
10
- /**
11
- * Returns index of the node in the parent element.
12
- *
13
- * @param {Node} node Node which index is tested.
14
- * @returns {Number} Index of the node in the parent element. Returns 0 if node has no parent.
15
- */
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;
25
- }
@@ -1,19 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2022, 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
- /**
7
- * @module utils/dom/insertat
8
- */
9
-
10
- /**
11
- * Inserts node to the parent at given index.
12
- *
13
- * @param {Element} parentElement Parent element.
14
- * @param {Number} index Insertions index.
15
- * @param {Node} nodeToInsert Node to insert.
16
- */
17
- export default function insertAt( parentElement, index, nodeToInsert ) {
18
- parentElement.insertBefore( nodeToInsert, parentElement.childNodes[ index ] || null );
19
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2022, 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
- /* globals Node */
7
-
8
- /**
9
- * @module utils/dom/iscomment
10
- */
11
-
12
- /**
13
- * Checks whether the object is a native DOM Comment node.
14
- *
15
- * @param {*} obj
16
- * @returns {Boolean}
17
- */
18
- export default function isComment( obj ) {
19
- return obj && obj.nodeType === Node.COMMENT_NODE;
20
- }
package/src/dom/isnode.js DELETED
@@ -1,26 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2022, 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
- /**
7
- * @module utils/dom/isnode
8
- */
9
-
10
- /**
11
- * Checks if the object is a native DOM Node.
12
- *
13
- * @param {*} obj
14
- * @returns {Boolean}
15
- */
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;
26
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2022, 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
- /**
7
- * @module utils/dom/isrange
8
- */
9
-
10
- /**
11
- * Checks if the object is a native DOM Range.
12
- *
13
- * @param {*} obj
14
- * @returns {Boolean}
15
- */
16
- export default function isRange( obj ) {
17
- return Object.prototype.toString.apply( obj ) == '[object Range]';
18
- }
package/src/dom/istext.js DELETED
@@ -1,18 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2022, 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
- /**
7
- * @module utils/dom/istext
8
- */
9
-
10
- /**
11
- * Checks if the object is a native DOM Text node.
12
- *
13
- * @param {*} obj
14
- * @returns {Boolean}
15
- */
16
- export default function isText( obj ) {
17
- return Object.prototype.toString.call( obj ) == '[object Text]';
18
- }
@@ -1,25 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2022, 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
- /**
7
- * @module utils/dom/isvisible
8
- */
9
-
10
- /**
11
- * Checks whether the element is visible to the user in DOM:
12
- *
13
- * * connected to the root of the document,
14
- * * has no `display: none`,
15
- * * has no ancestors with `display: none`.
16
- *
17
- * **Note**: This helper does not check whether the element is hidden by cropping, overflow, etc..
18
- * To check that, use {@link module:utils/dom/rect~Rect} instead.
19
- *
20
- * @param {HTMLElement|null|undefined} element
21
- * @returns {Boolean}
22
- */
23
- export default function isVisible( element ) {
24
- return !!( element && element.getClientRects && element.getClientRects().length );
25
- }