@ckeditor/ckeditor5-engine 35.0.1 → 35.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -4
- package/package.json +30 -24
- package/src/controller/datacontroller.js +467 -561
- package/src/controller/editingcontroller.js +168 -204
- package/src/conversion/conversion.js +541 -565
- package/src/conversion/conversionhelpers.js +24 -28
- package/src/conversion/downcastdispatcher.js +457 -686
- package/src/conversion/downcasthelpers.js +1583 -1965
- package/src/conversion/mapper.js +518 -707
- package/src/conversion/modelconsumable.js +240 -283
- package/src/conversion/upcastdispatcher.js +372 -718
- package/src/conversion/upcasthelpers.js +707 -818
- package/src/conversion/viewconsumable.js +524 -581
- package/src/dataprocessor/basichtmlwriter.js +12 -16
- package/src/dataprocessor/dataprocessor.js +5 -0
- package/src/dataprocessor/htmldataprocessor.js +100 -116
- package/src/dataprocessor/htmlwriter.js +1 -18
- package/src/dataprocessor/xmldataprocessor.js +116 -137
- package/src/dev-utils/model.js +260 -352
- package/src/dev-utils/operationreplayer.js +106 -126
- package/src/dev-utils/utils.js +34 -51
- package/src/dev-utils/view.js +632 -753
- package/src/index.js +0 -11
- package/src/model/batch.js +111 -127
- package/src/model/differ.js +988 -1233
- package/src/model/document.js +340 -449
- package/src/model/documentfragment.js +327 -364
- package/src/model/documentselection.js +996 -1189
- package/src/model/element.js +306 -410
- package/src/model/history.js +224 -262
- package/src/model/item.js +5 -0
- package/src/model/liveposition.js +84 -145
- package/src/model/liverange.js +108 -185
- package/src/model/markercollection.js +379 -480
- package/src/model/model.js +883 -1034
- package/src/model/node.js +419 -463
- package/src/model/nodelist.js +176 -201
- package/src/model/operation/attributeoperation.js +153 -182
- package/src/model/operation/detachoperation.js +64 -83
- package/src/model/operation/insertoperation.js +135 -166
- package/src/model/operation/markeroperation.js +114 -140
- package/src/model/operation/mergeoperation.js +163 -191
- package/src/model/operation/moveoperation.js +157 -187
- package/src/model/operation/nooperation.js +28 -38
- package/src/model/operation/operation.js +106 -125
- package/src/model/operation/operationfactory.js +30 -34
- package/src/model/operation/renameoperation.js +109 -135
- package/src/model/operation/rootattributeoperation.js +155 -188
- package/src/model/operation/splitoperation.js +196 -232
- package/src/model/operation/transform.js +1833 -2204
- package/src/model/operation/utils.js +140 -204
- package/src/model/position.js +980 -1053
- package/src/model/range.js +910 -1028
- package/src/model/rootelement.js +77 -97
- package/src/model/schema.js +1189 -1835
- package/src/model/selection.js +745 -862
- package/src/model/text.js +90 -114
- package/src/model/textproxy.js +204 -240
- package/src/model/treewalker.js +316 -397
- package/src/model/typecheckable.js +16 -0
- package/src/model/utils/autoparagraphing.js +32 -44
- package/src/model/utils/deletecontent.js +334 -418
- package/src/model/utils/findoptimalinsertionrange.js +25 -36
- package/src/model/utils/getselectedcontent.js +96 -118
- package/src/model/utils/insertcontent.js +757 -773
- package/src/model/utils/insertobject.js +96 -119
- package/src/model/utils/modifyselection.js +120 -158
- package/src/model/utils/selection-post-fixer.js +153 -201
- package/src/model/writer.js +1305 -1474
- package/src/view/attributeelement.js +189 -225
- package/src/view/containerelement.js +75 -85
- package/src/view/document.js +172 -215
- package/src/view/documentfragment.js +200 -249
- package/src/view/documentselection.js +338 -367
- package/src/view/domconverter.js +1370 -1617
- package/src/view/downcastwriter.js +1747 -2076
- package/src/view/editableelement.js +81 -97
- package/src/view/element.js +739 -890
- package/src/view/elementdefinition.js +5 -0
- package/src/view/emptyelement.js +82 -92
- package/src/view/filler.js +35 -50
- package/src/view/item.js +5 -0
- package/src/view/matcher.js +260 -559
- package/src/view/node.js +274 -360
- package/src/view/observer/arrowkeysobserver.js +19 -28
- package/src/view/observer/bubblingemittermixin.js +120 -263
- package/src/view/observer/bubblingeventinfo.js +47 -55
- package/src/view/observer/clickobserver.js +7 -13
- package/src/view/observer/compositionobserver.js +14 -24
- package/src/view/observer/domeventdata.js +57 -67
- package/src/view/observer/domeventobserver.js +40 -64
- package/src/view/observer/fakeselectionobserver.js +81 -96
- package/src/view/observer/focusobserver.js +45 -61
- package/src/view/observer/inputobserver.js +7 -13
- package/src/view/observer/keyobserver.js +17 -27
- package/src/view/observer/mouseobserver.js +7 -14
- package/src/view/observer/mutationobserver.js +220 -315
- package/src/view/observer/observer.js +81 -102
- package/src/view/observer/selectionobserver.js +199 -246
- package/src/view/observer/tabobserver.js +23 -36
- package/src/view/placeholder.js +128 -173
- package/src/view/position.js +350 -401
- package/src/view/range.js +453 -513
- package/src/view/rawelement.js +85 -112
- package/src/view/renderer.js +874 -1018
- package/src/view/rooteditableelement.js +80 -90
- package/src/view/selection.js +608 -689
- package/src/view/styles/background.js +43 -44
- package/src/view/styles/border.js +220 -276
- package/src/view/styles/margin.js +8 -17
- package/src/view/styles/padding.js +8 -16
- package/src/view/styles/utils.js +127 -160
- package/src/view/stylesmap.js +728 -905
- package/src/view/text.js +102 -126
- package/src/view/textproxy.js +144 -170
- package/src/view/treewalker.js +383 -479
- package/src/view/typecheckable.js +19 -0
- package/src/view/uielement.js +166 -187
- package/src/view/upcastwriter.js +395 -449
- package/src/view/view.js +569 -664
- package/src/dataprocessor/dataprocessor.jsdoc +0 -64
- package/src/model/item.jsdoc +0 -14
- package/src/view/elementdefinition.jsdoc +0 -59
- package/src/view/item.jsdoc +0 -14
|
@@ -2,16 +2,12 @@
|
|
|
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 engine/view/observer/arrowkeysobserver
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import Observer from './observer';
|
|
11
9
|
import BubblingEventInfo from './bubblingeventinfo';
|
|
12
|
-
|
|
13
10
|
import { isArrowKeyCode } from '@ckeditor/ckeditor5-utils';
|
|
14
|
-
|
|
15
11
|
/**
|
|
16
12
|
* Arrow keys observer introduces the {@link module:engine/view/document~Document#event:arrowKey `Document#arrowKey`} event.
|
|
17
13
|
*
|
|
@@ -20,31 +16,26 @@ import { isArrowKeyCode } from '@ckeditor/ckeditor5-utils';
|
|
|
20
16
|
* @extends module:engine/view/observer/observer~Observer
|
|
21
17
|
*/
|
|
22
18
|
export default class ArrowKeysObserver extends Observer {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @inheritDoc
|
|
44
|
-
*/
|
|
45
|
-
observe() {}
|
|
19
|
+
/**
|
|
20
|
+
* @inheritDoc
|
|
21
|
+
*/
|
|
22
|
+
constructor(view) {
|
|
23
|
+
super(view);
|
|
24
|
+
this.document.on('keydown', (event, data) => {
|
|
25
|
+
if (this.isEnabled && isArrowKeyCode(data.keyCode)) {
|
|
26
|
+
const eventInfo = new BubblingEventInfo(this.document, 'arrowKey', this.document.selection.getFirstRange());
|
|
27
|
+
this.document.fire(eventInfo, data);
|
|
28
|
+
if (eventInfo.stop.called) {
|
|
29
|
+
event.stop();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @inheritDoc
|
|
36
|
+
*/
|
|
37
|
+
observe() { }
|
|
46
38
|
}
|
|
47
|
-
|
|
48
39
|
/**
|
|
49
40
|
* Event fired when the user presses an arrow keys.
|
|
50
41
|
*
|
|
@@ -2,21 +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 engine/view/observer/bubblingemittermixin
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import EventInfo from '@ckeditor/ckeditor5-utils/src/eventinfo';
|
|
11
9
|
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
12
|
-
|
|
13
|
-
import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';
|
|
10
|
+
import { Emitter } from '@ckeditor/ckeditor5-utils/src/emittermixin';
|
|
14
11
|
import toArray from '@ckeditor/ckeditor5-utils/src/toarray';
|
|
15
|
-
|
|
16
12
|
import BubblingEventInfo from './bubblingeventinfo';
|
|
17
|
-
|
|
18
|
-
const contextsSymbol = Symbol( 'bubbling contexts' );
|
|
19
|
-
|
|
13
|
+
const contextsSymbol = Symbol('bubbling contexts');
|
|
20
14
|
/**
|
|
21
15
|
* Bubbling emitter mixin for the view document as described in the
|
|
22
16
|
* {@link ~BubblingEmitter} interface.
|
|
@@ -24,126 +18,102 @@ const contextsSymbol = Symbol( 'bubbling contexts' );
|
|
|
24
18
|
* @mixin BubblingEmitterMixin
|
|
25
19
|
* @implements module:engine/view/observer/bubblingemittermixin~BubblingEmitter
|
|
26
20
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if ( !emitter ) {
|
|
113
|
-
emitter = Object.create( EmitterMixin );
|
|
114
|
-
eventContexts.set( context, emitter );
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
this.listenTo( emitter, event, callback, options );
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* @inheritDoc
|
|
123
|
-
*/
|
|
124
|
-
_removeEventListener( event, callback ) {
|
|
125
|
-
const eventContexts = getBubblingContexts( this );
|
|
126
|
-
|
|
127
|
-
for ( const emitter of eventContexts.values() ) {
|
|
128
|
-
this.stopListening( emitter, event, callback );
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
export default BubblingEmitterMixin;
|
|
134
|
-
|
|
21
|
+
export default function BubblingEmitterMixin(base) {
|
|
22
|
+
class Mixin extends base {
|
|
23
|
+
fire(eventOrInfo, ...eventArgs) {
|
|
24
|
+
try {
|
|
25
|
+
const eventInfo = eventOrInfo instanceof EventInfo ? eventOrInfo : new EventInfo(this, eventOrInfo);
|
|
26
|
+
const eventContexts = getBubblingContexts(this);
|
|
27
|
+
if (!eventContexts.size) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
updateEventInfo(eventInfo, 'capturing', this);
|
|
31
|
+
// The capture phase of the event.
|
|
32
|
+
if (fireListenerFor(eventContexts, '$capture', eventInfo, ...eventArgs)) {
|
|
33
|
+
return eventInfo.return;
|
|
34
|
+
}
|
|
35
|
+
const startRange = eventInfo.startRange || this.selection.getFirstRange();
|
|
36
|
+
const selectedElement = startRange ? startRange.getContainedElement() : null;
|
|
37
|
+
const isCustomContext = selectedElement ? Boolean(getCustomContext(eventContexts, selectedElement)) : false;
|
|
38
|
+
let node = selectedElement || getDeeperRangeParent(startRange);
|
|
39
|
+
updateEventInfo(eventInfo, 'atTarget', node);
|
|
40
|
+
// For the not yet bubbling event trigger for $text node if selection can be there and it's not a custom context selected.
|
|
41
|
+
if (!isCustomContext) {
|
|
42
|
+
if (fireListenerFor(eventContexts, '$text', eventInfo, ...eventArgs)) {
|
|
43
|
+
return eventInfo.return;
|
|
44
|
+
}
|
|
45
|
+
updateEventInfo(eventInfo, 'bubbling', node);
|
|
46
|
+
}
|
|
47
|
+
while (node) {
|
|
48
|
+
// Root node handling.
|
|
49
|
+
if (node.is('rootElement')) {
|
|
50
|
+
if (fireListenerFor(eventContexts, '$root', eventInfo, ...eventArgs)) {
|
|
51
|
+
return eventInfo.return;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Element node handling.
|
|
55
|
+
else if (node.is('element')) {
|
|
56
|
+
if (fireListenerFor(eventContexts, node.name, eventInfo, ...eventArgs)) {
|
|
57
|
+
return eventInfo.return;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// Check custom contexts (i.e., a widget).
|
|
61
|
+
if (fireListenerFor(eventContexts, node, eventInfo, ...eventArgs)) {
|
|
62
|
+
return eventInfo.return;
|
|
63
|
+
}
|
|
64
|
+
node = node.parent;
|
|
65
|
+
updateEventInfo(eventInfo, 'bubbling', node);
|
|
66
|
+
}
|
|
67
|
+
updateEventInfo(eventInfo, 'bubbling', this);
|
|
68
|
+
// Document context.
|
|
69
|
+
fireListenerFor(eventContexts, '$document', eventInfo, ...eventArgs);
|
|
70
|
+
return eventInfo.return;
|
|
71
|
+
}
|
|
72
|
+
catch (err) {
|
|
73
|
+
// @if CK_DEBUG // throw err;
|
|
74
|
+
/* istanbul ignore next */
|
|
75
|
+
CKEditorError.rethrowUnexpectedError(err, this);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
_addEventListener(event, callback, options) {
|
|
79
|
+
const contexts = toArray(options.context || '$document');
|
|
80
|
+
const eventContexts = getBubblingContexts(this);
|
|
81
|
+
for (const context of contexts) {
|
|
82
|
+
let emitter = eventContexts.get(context);
|
|
83
|
+
if (!emitter) {
|
|
84
|
+
emitter = new Emitter();
|
|
85
|
+
eventContexts.set(context, emitter);
|
|
86
|
+
}
|
|
87
|
+
this.listenTo(emitter, event, callback, options);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
_removeEventListener(event, callback) {
|
|
91
|
+
const eventContexts = getBubblingContexts(this);
|
|
92
|
+
for (const emitter of eventContexts.values()) {
|
|
93
|
+
this.stopListening(emitter, event, callback);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return Mixin;
|
|
98
|
+
}
|
|
99
|
+
// Backward compatibility with `mix`.
|
|
100
|
+
{
|
|
101
|
+
const mixin = BubblingEmitterMixin(Object);
|
|
102
|
+
['fire', '_addEventListener', '_removeEventListener'].forEach(key => {
|
|
103
|
+
BubblingEmitterMixin[key] = mixin.prototype[key];
|
|
104
|
+
});
|
|
105
|
+
}
|
|
135
106
|
// Update the event info bubbling fields.
|
|
136
107
|
//
|
|
137
108
|
// @param {module:utils/eventinfo~EventInfo} eventInfo The event info object to update.
|
|
138
109
|
// @param {'none'|'capturing'|'atTarget'|'bubbling'} eventPhase The current event phase.
|
|
139
110
|
// @param {module:engine/view/document~Document|module:engine/view/node~Node} currentTarget The current bubbling target.
|
|
140
|
-
function updateEventInfo(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
111
|
+
function updateEventInfo(eventInfo, eventPhase, currentTarget) {
|
|
112
|
+
if (eventInfo instanceof BubblingEventInfo) {
|
|
113
|
+
eventInfo._eventPhase = eventPhase;
|
|
114
|
+
eventInfo._currentTarget = currentTarget;
|
|
115
|
+
}
|
|
145
116
|
}
|
|
146
|
-
|
|
147
117
|
// Fires the listener for the specified context. Returns `true` if event was stopped.
|
|
148
118
|
//
|
|
149
119
|
// @private
|
|
@@ -152,156 +122,43 @@ function updateEventInfo( eventInfo, eventPhase, currentTarget ) {
|
|
|
152
122
|
// @param {module:utils/eventinfo~EventInfo} eventInfo The `EventInfo` object.
|
|
153
123
|
// @param {...*} [eventArgs] Additional arguments to be passed to the callbacks.
|
|
154
124
|
// @returns {Boolean} True if event stop was called.
|
|
155
|
-
function fireListenerFor(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
emitter.fire( eventInfo, ...eventArgs );
|
|
163
|
-
|
|
164
|
-
return eventInfo.stop.called;
|
|
125
|
+
function fireListenerFor(eventContexts, context, eventInfo, ...eventArgs) {
|
|
126
|
+
const emitter = typeof context == 'string' ? eventContexts.get(context) : getCustomContext(eventContexts, context);
|
|
127
|
+
if (!emitter) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
emitter.fire(eventInfo, ...eventArgs);
|
|
131
|
+
return eventInfo.stop.called;
|
|
165
132
|
}
|
|
166
|
-
|
|
167
133
|
// Returns an emitter for a specified view node.
|
|
168
134
|
//
|
|
169
135
|
// @private
|
|
170
136
|
// @param {Map.<String|Function, module:utils/emittermixin~Emitter>} eventContexts
|
|
171
137
|
// @param {module:engine/view/node~Node} node
|
|
172
138
|
// @returns {module:utils/emittermixin~Emitter|null}
|
|
173
|
-
function getCustomContext(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
return null;
|
|
139
|
+
function getCustomContext(eventContexts, node) {
|
|
140
|
+
for (const [context, emitter] of eventContexts) {
|
|
141
|
+
if (typeof context == 'function' && context(node)) {
|
|
142
|
+
return emitter;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return null;
|
|
181
146
|
}
|
|
182
|
-
|
|
183
147
|
// Returns bubbling contexts map for the source (emitter).
|
|
184
|
-
function getBubblingContexts(
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
return source[ contextsSymbol ];
|
|
148
|
+
function getBubblingContexts(source) {
|
|
149
|
+
if (!source[contextsSymbol]) {
|
|
150
|
+
source[contextsSymbol] = new Map();
|
|
151
|
+
}
|
|
152
|
+
return source[contextsSymbol];
|
|
190
153
|
}
|
|
191
|
-
|
|
192
154
|
// Returns the deeper parent element for the range.
|
|
193
|
-
function getDeeperRangeParent(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
const endPath = endParent.getPath();
|
|
203
|
-
|
|
204
|
-
return startPath.length > endPath.length ? startParent : endParent;
|
|
155
|
+
function getDeeperRangeParent(range) {
|
|
156
|
+
if (!range) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
const startParent = range.start.parent;
|
|
160
|
+
const endParent = range.end.parent;
|
|
161
|
+
const startPath = startParent.getPath();
|
|
162
|
+
const endPath = endParent.getPath();
|
|
163
|
+
return startPath.length > endPath.length ? startParent : endParent;
|
|
205
164
|
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Bubbling emitter for the view document.
|
|
209
|
-
*
|
|
210
|
-
* Bubbling emitter is triggering events in the context of specified {@link module:engine/view/element~Element view element} name,
|
|
211
|
-
* predefined `'$text'`, `'$root'`, `'$document'` and `'$capture'` contexts, and context matchers provided as a function.
|
|
212
|
-
*
|
|
213
|
-
* Before bubbling starts, listeners for `'$capture'` context are triggered. Then the bubbling starts from the deeper selection
|
|
214
|
-
* position (by firing event on the `'$text'` context) and propagates the view document tree up to the `'$root'` and finally
|
|
215
|
-
* the listeners at `'$document'` context are fired (this is the default context).
|
|
216
|
-
*
|
|
217
|
-
* Examples:
|
|
218
|
-
*
|
|
219
|
-
* // Listeners registered in the context of the view element names:
|
|
220
|
-
* this.listenTo( viewDocument, 'enter', ( evt, data ) => {
|
|
221
|
-
* // ...
|
|
222
|
-
* }, { context: 'blockquote' } );
|
|
223
|
-
*
|
|
224
|
-
* this.listenTo( viewDocument, 'enter', ( evt, data ) => {
|
|
225
|
-
* // ...
|
|
226
|
-
* }, { context: 'li' } );
|
|
227
|
-
*
|
|
228
|
-
* // Listeners registered in the context of the '$text' and '$root' nodes.
|
|
229
|
-
* this.listenTo( view.document, 'arrowKey', ( evt, data ) => {
|
|
230
|
-
* // ...
|
|
231
|
-
* }, { context: '$text', priority: 'high' } );
|
|
232
|
-
*
|
|
233
|
-
* this.listenTo( view.document, 'arrowKey', ( evt, data ) => {
|
|
234
|
-
* // ...
|
|
235
|
-
* }, { context: '$root' } );
|
|
236
|
-
*
|
|
237
|
-
* // Listeners registered in the context of custom callback function.
|
|
238
|
-
* this.listenTo( view.document, 'arrowKey', ( evt, data ) => {
|
|
239
|
-
* // ...
|
|
240
|
-
* }, { context: isWidget } );
|
|
241
|
-
*
|
|
242
|
-
* this.listenTo( view.document, 'arrowKey', ( evt, data ) => {
|
|
243
|
-
* // ...
|
|
244
|
-
* }, { context: isWidget, priority: 'high' } );
|
|
245
|
-
*
|
|
246
|
-
* Example flow for selection in text:
|
|
247
|
-
*
|
|
248
|
-
* <blockquote><p>Foo[]bar</p></blockquote>
|
|
249
|
-
*
|
|
250
|
-
* Fired events on contexts:
|
|
251
|
-
* 1. `'$capture'`
|
|
252
|
-
* 2. `'$text'`
|
|
253
|
-
* 3. `'p'`
|
|
254
|
-
* 4. `'blockquote'`
|
|
255
|
-
* 5. `'$root'`
|
|
256
|
-
* 6. `'$document'`
|
|
257
|
-
*
|
|
258
|
-
* Example flow for selection on element (i.e., Widget):
|
|
259
|
-
*
|
|
260
|
-
* <blockquote><p>Foo[<widget/>]bar</p></blockquote>
|
|
261
|
-
*
|
|
262
|
-
* Fired events on contexts:
|
|
263
|
-
* 1. `'$capture'`
|
|
264
|
-
* 2. *widget* (custom matcher)
|
|
265
|
-
* 3. `'p'`
|
|
266
|
-
* 4. `'blockquote'`
|
|
267
|
-
* 5. `'$root'`
|
|
268
|
-
* 6. `'$document'`
|
|
269
|
-
*
|
|
270
|
-
* There could be multiple listeners registered for the same context and at different priority levels:
|
|
271
|
-
*
|
|
272
|
-
* <p>Foo[]bar</p>
|
|
273
|
-
*
|
|
274
|
-
* 1. `'$capture'` at priorities:
|
|
275
|
-
* 1. `'highest'`
|
|
276
|
-
* 2. `'high'`
|
|
277
|
-
* 3. `'normal'`
|
|
278
|
-
* 4. `'low'`
|
|
279
|
-
* 5. `'lowest'`
|
|
280
|
-
* 2. `'$text'` at priorities:
|
|
281
|
-
* 1. `'highest'`
|
|
282
|
-
* 2. `'high'`
|
|
283
|
-
* 3. `'normal'`
|
|
284
|
-
* 4. `'low'`
|
|
285
|
-
* 5. `'lowest'`
|
|
286
|
-
* 3. `'p'` at priorities:
|
|
287
|
-
* 1. `'highest'`
|
|
288
|
-
* 2. `'high'`
|
|
289
|
-
* 3. `'normal'`
|
|
290
|
-
* 4. `'low'`
|
|
291
|
-
* 5. `'lowest'`
|
|
292
|
-
* 4. `'$root'` at priorities:
|
|
293
|
-
* 1. `'highest'`
|
|
294
|
-
* 2. `'high'`
|
|
295
|
-
* 3. `'normal'`
|
|
296
|
-
* 4. `'low'`
|
|
297
|
-
* 5. `'lowest'`
|
|
298
|
-
* 5. `'$document'` at priorities:
|
|
299
|
-
* 1. `'highest'`
|
|
300
|
-
* 2. `'high'`
|
|
301
|
-
* 3. `'normal'`
|
|
302
|
-
* 4. `'low'`
|
|
303
|
-
* 5. `'lowest'`
|
|
304
|
-
*
|
|
305
|
-
* @interface BubblingEmitter
|
|
306
|
-
* @extends module:utils/emittermixin~Emitter
|
|
307
|
-
*/
|
|
@@ -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
|
/**
|
|
7
6
|
* @module engine/view/observer/bubblingeventinfo
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import EventInfo from '@ckeditor/ckeditor5-utils/src/eventinfo';
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* The event object passed to bubbling event callbacks. It is used to provide information about the event as well as a tool to
|
|
14
11
|
* manipulate it.
|
|
@@ -16,56 +13,51 @@ import EventInfo from '@ckeditor/ckeditor5-utils/src/eventinfo';
|
|
|
16
13
|
* @extends module:utils/eventinfo~EventInfo
|
|
17
14
|
*/
|
|
18
15
|
export default class BubblingEventInfo extends EventInfo {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
* @member {module:engine/view/document~Document|module:engine/view/node~Node|null}
|
|
67
|
-
*/
|
|
68
|
-
get currentTarget() {
|
|
69
|
-
return this._currentTarget;
|
|
70
|
-
}
|
|
16
|
+
/**
|
|
17
|
+
* @param {Object} source The emitter.
|
|
18
|
+
* @param {String} name The event name.
|
|
19
|
+
* @param {module:engine/view/range~Range} startRange The view range that the bubbling should start from.
|
|
20
|
+
*/
|
|
21
|
+
constructor(source, name, startRange) {
|
|
22
|
+
super(source, name);
|
|
23
|
+
/**
|
|
24
|
+
* The view range that the bubbling should start from.
|
|
25
|
+
*
|
|
26
|
+
* @readonly
|
|
27
|
+
* @member {module:engine/view/range~Range}
|
|
28
|
+
*/
|
|
29
|
+
this.startRange = startRange;
|
|
30
|
+
/**
|
|
31
|
+
* The current event phase.
|
|
32
|
+
*
|
|
33
|
+
* @protected
|
|
34
|
+
* @member {'none'|'capturing'|'atTarget'|'bubbling'}
|
|
35
|
+
*/
|
|
36
|
+
this._eventPhase = 'none';
|
|
37
|
+
/**
|
|
38
|
+
* The current bubbling target.
|
|
39
|
+
*
|
|
40
|
+
* @protected
|
|
41
|
+
* @member {module:engine/view/document~Document|module:engine/view/node~Node|null}
|
|
42
|
+
*/
|
|
43
|
+
this._currentTarget = null;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The current event phase.
|
|
47
|
+
*
|
|
48
|
+
* @readonly
|
|
49
|
+
* @member {'none'|'capturing'|'atTarget'|'bubbling'}
|
|
50
|
+
*/
|
|
51
|
+
get eventPhase() {
|
|
52
|
+
return this._eventPhase;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The current bubbling target.
|
|
56
|
+
*
|
|
57
|
+
* @readonly
|
|
58
|
+
* @member {module:engine/view/document~Document|module:engine/view/node~Node|null}
|
|
59
|
+
*/
|
|
60
|
+
get currentTarget() {
|
|
61
|
+
return this._currentTarget;
|
|
62
|
+
}
|
|
71
63
|
}
|
|
@@ -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
|
/**
|
|
7
6
|
* @module engine/view/observer/clickobserver
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import DomEventObserver from './domeventobserver';
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* {@link module:engine/view/document~Document#event:click Click} event observer.
|
|
14
11
|
*
|
|
@@ -19,17 +16,14 @@ import DomEventObserver from './domeventobserver';
|
|
|
19
16
|
* @extends module:engine/view/observer/domeventobserver~DomEventObserver
|
|
20
17
|
*/
|
|
21
18
|
export default class ClickObserver extends DomEventObserver {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.fire( domEvent.type, domEvent );
|
|
30
|
-
}
|
|
19
|
+
constructor(view) {
|
|
20
|
+
super(view);
|
|
21
|
+
this.domEventType = 'click';
|
|
22
|
+
}
|
|
23
|
+
onDomEvent(domEvent) {
|
|
24
|
+
this.fire(domEvent.type, domEvent);
|
|
25
|
+
}
|
|
31
26
|
}
|
|
32
|
-
|
|
33
27
|
/**
|
|
34
28
|
* Fired when one of the editables has been clicked.
|
|
35
29
|
*
|