@ckeditor/ckeditor5-engine 30.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.
- package/LICENSE.md +17 -0
- package/README.md +30 -0
- package/package.json +70 -0
- package/src/controller/datacontroller.js +563 -0
- package/src/controller/editingcontroller.js +149 -0
- package/src/conversion/conversion.js +644 -0
- package/src/conversion/conversionhelpers.js +40 -0
- package/src/conversion/downcastdispatcher.js +914 -0
- package/src/conversion/downcasthelpers.js +1706 -0
- package/src/conversion/mapper.js +696 -0
- package/src/conversion/modelconsumable.js +329 -0
- package/src/conversion/upcastdispatcher.js +807 -0
- package/src/conversion/upcasthelpers.js +997 -0
- package/src/conversion/viewconsumable.js +623 -0
- package/src/dataprocessor/basichtmlwriter.js +32 -0
- package/src/dataprocessor/dataprocessor.jsdoc +64 -0
- package/src/dataprocessor/htmldataprocessor.js +159 -0
- package/src/dataprocessor/htmlwriter.js +22 -0
- package/src/dataprocessor/xmldataprocessor.js +161 -0
- package/src/dev-utils/model.js +482 -0
- package/src/dev-utils/operationreplayer.js +140 -0
- package/src/dev-utils/utils.js +103 -0
- package/src/dev-utils/view.js +1091 -0
- package/src/index.js +52 -0
- package/src/model/batch.js +82 -0
- package/src/model/differ.js +1282 -0
- package/src/model/document.js +483 -0
- package/src/model/documentfragment.js +390 -0
- package/src/model/documentselection.js +1261 -0
- package/src/model/element.js +438 -0
- package/src/model/history.js +138 -0
- package/src/model/item.jsdoc +14 -0
- package/src/model/liveposition.js +182 -0
- package/src/model/liverange.js +221 -0
- package/src/model/markercollection.js +553 -0
- package/src/model/model.js +934 -0
- package/src/model/node.js +507 -0
- package/src/model/nodelist.js +217 -0
- package/src/model/operation/attributeoperation.js +202 -0
- package/src/model/operation/detachoperation.js +103 -0
- package/src/model/operation/insertoperation.js +188 -0
- package/src/model/operation/markeroperation.js +154 -0
- package/src/model/operation/mergeoperation.js +216 -0
- package/src/model/operation/moveoperation.js +209 -0
- package/src/model/operation/nooperation.js +58 -0
- package/src/model/operation/operation.js +139 -0
- package/src/model/operation/operationfactory.js +49 -0
- package/src/model/operation/renameoperation.js +155 -0
- package/src/model/operation/rootattributeoperation.js +211 -0
- package/src/model/operation/splitoperation.js +254 -0
- package/src/model/operation/transform.js +2389 -0
- package/src/model/operation/utils.js +292 -0
- package/src/model/position.js +1164 -0
- package/src/model/range.js +1049 -0
- package/src/model/rootelement.js +111 -0
- package/src/model/schema.js +1851 -0
- package/src/model/selection.js +902 -0
- package/src/model/text.js +138 -0
- package/src/model/textproxy.js +279 -0
- package/src/model/treewalker.js +414 -0
- package/src/model/utils/autoparagraphing.js +77 -0
- package/src/model/utils/deletecontent.js +528 -0
- package/src/model/utils/getselectedcontent.js +150 -0
- package/src/model/utils/insertcontent.js +824 -0
- package/src/model/utils/modifyselection.js +229 -0
- package/src/model/utils/selection-post-fixer.js +297 -0
- package/src/model/writer.js +1574 -0
- package/src/view/attributeelement.js +274 -0
- package/src/view/containerelement.js +123 -0
- package/src/view/document.js +221 -0
- package/src/view/documentfragment.js +273 -0
- package/src/view/documentselection.js +387 -0
- package/src/view/domconverter.js +1437 -0
- package/src/view/downcastwriter.js +2121 -0
- package/src/view/editableelement.js +118 -0
- package/src/view/element.js +945 -0
- package/src/view/elementdefinition.jsdoc +59 -0
- package/src/view/emptyelement.js +119 -0
- package/src/view/filler.js +161 -0
- package/src/view/item.jsdoc +14 -0
- package/src/view/matcher.js +776 -0
- package/src/view/node.js +391 -0
- package/src/view/observer/arrowkeysobserver.js +58 -0
- package/src/view/observer/bubblingemittermixin.js +307 -0
- package/src/view/observer/bubblingeventinfo.js +71 -0
- package/src/view/observer/clickobserver.js +46 -0
- package/src/view/observer/compositionobserver.js +79 -0
- package/src/view/observer/domeventdata.js +82 -0
- package/src/view/observer/domeventobserver.js +99 -0
- package/src/view/observer/fakeselectionobserver.js +118 -0
- package/src/view/observer/focusobserver.js +106 -0
- package/src/view/observer/inputobserver.js +44 -0
- package/src/view/observer/keyobserver.js +83 -0
- package/src/view/observer/mouseobserver.js +56 -0
- package/src/view/observer/mutationobserver.js +345 -0
- package/src/view/observer/observer.js +118 -0
- package/src/view/observer/selectionobserver.js +242 -0
- package/src/view/placeholder.js +285 -0
- package/src/view/position.js +426 -0
- package/src/view/range.js +533 -0
- package/src/view/rawelement.js +148 -0
- package/src/view/renderer.js +1037 -0
- package/src/view/rooteditableelement.js +107 -0
- package/src/view/selection.js +718 -0
- package/src/view/styles/background.js +73 -0
- package/src/view/styles/border.js +362 -0
- package/src/view/styles/margin.js +41 -0
- package/src/view/styles/padding.js +40 -0
- package/src/view/styles/utils.js +277 -0
- package/src/view/stylesmap.js +938 -0
- package/src/view/text.js +147 -0
- package/src/view/textproxy.js +199 -0
- package/src/view/treewalker.js +496 -0
- package/src/view/uielement.js +238 -0
- package/src/view/upcastwriter.js +484 -0
- package/src/view/view.js +721 -0
- package/theme/placeholder.css +27 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @module engine/conversion/modelconsumable
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import TextProxy from '../model/textproxy';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Manages a list of consumable values for {@link module:engine/model/item~Item model items}.
|
|
14
|
+
*
|
|
15
|
+
* Consumables are various aspects of the model. A model item can be broken down into singular properties that might be
|
|
16
|
+
* taken into consideration when converting that item.
|
|
17
|
+
*
|
|
18
|
+
* `ModelConsumable` is used by {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher} while analyzing changed
|
|
19
|
+
* parts of {@link module:engine/model/document~Document the document}. The added / changed / removed model items are broken down
|
|
20
|
+
* into singular properties (the item itself and it's attributes). All those parts are saved in `ModelConsumable`. Then,
|
|
21
|
+
* during conversion, when given part of model item is converted (i.e. the view element has been inserted into the view,
|
|
22
|
+
* but without attributes), consumable value is removed from `ModelConsumable`.
|
|
23
|
+
*
|
|
24
|
+
* For model items, `ModelConsumable` stores consumable values of one of following types: `insert`, `addattribute:<attributeKey>`,
|
|
25
|
+
* `changeattributes:<attributeKey>`, `removeattributes:<attributeKey>`.
|
|
26
|
+
*
|
|
27
|
+
* In most cases, it is enough to let {@link module:engine/conversion/downcastdispatcher~DowncastDispatcher}
|
|
28
|
+
* gather consumable values, so there is no need to use
|
|
29
|
+
* {@link module:engine/conversion/modelconsumable~ModelConsumable#add add method} directly.
|
|
30
|
+
* However, it is important to understand how consumable values can be
|
|
31
|
+
* {@link module:engine/conversion/modelconsumable~ModelConsumable#consume consumed}.
|
|
32
|
+
* See {@link module:engine/conversion/downcasthelpers default downcast converters} for more information.
|
|
33
|
+
*
|
|
34
|
+
* Keep in mind, that one conversion event may have multiple callbacks (converters) attached to it. Each of those is
|
|
35
|
+
* able to convert one or more parts of the model. However, when one of those callbacks actually converts
|
|
36
|
+
* something, other should not, because they would duplicate the results. Using `ModelConsumable` helps avoiding
|
|
37
|
+
* this situation, because callbacks should only convert those values, which were not yet consumed from `ModelConsumable`.
|
|
38
|
+
*
|
|
39
|
+
* Consuming multiple values in a single callback:
|
|
40
|
+
*
|
|
41
|
+
* // Converter for custom `imageBlock` element that might have a `caption` element inside which changes
|
|
42
|
+
* // how the image is displayed in the view:
|
|
43
|
+
* //
|
|
44
|
+
* // Model:
|
|
45
|
+
* //
|
|
46
|
+
* // [imageBlock]
|
|
47
|
+
* // └─ [caption]
|
|
48
|
+
* // └─ foo
|
|
49
|
+
* //
|
|
50
|
+
* // View:
|
|
51
|
+
* //
|
|
52
|
+
* // <figure>
|
|
53
|
+
* // ├─ <img />
|
|
54
|
+
* // └─ <caption>
|
|
55
|
+
* // └─ foo
|
|
56
|
+
* modelConversionDispatcher.on( 'insert:imageBlock', ( evt, data, conversionApi ) => {
|
|
57
|
+
* // First, consume the `imageBlock` element.
|
|
58
|
+
* conversionApi.consumable.consume( data.item, 'insert' );
|
|
59
|
+
*
|
|
60
|
+
* // Just create normal image element for the view.
|
|
61
|
+
* // Maybe it will be "decorated" later.
|
|
62
|
+
* const viewImage = new ViewElement( 'img' );
|
|
63
|
+
* const insertPosition = conversionApi.mapper.toViewPosition( data.range.start );
|
|
64
|
+
* const viewWriter = conversionApi.writer;
|
|
65
|
+
*
|
|
66
|
+
* // Check if the `imageBlock` element has children.
|
|
67
|
+
* if ( data.item.childCount > 0 ) {
|
|
68
|
+
* const modelCaption = data.item.getChild( 0 );
|
|
69
|
+
*
|
|
70
|
+
* // `modelCaption` insertion change is consumed from consumable values.
|
|
71
|
+
* // It will not be converted by other converters, but it's children (probably some text) will be.
|
|
72
|
+
* // Through mapping, converters for text will know where to insert contents of `modelCaption`.
|
|
73
|
+
* if ( conversionApi.consumable.consume( modelCaption, 'insert' ) ) {
|
|
74
|
+
* const viewCaption = new ViewElement( 'figcaption' );
|
|
75
|
+
*
|
|
76
|
+
* const viewImageHolder = new ViewElement( 'figure', null, [ viewImage, viewCaption ] );
|
|
77
|
+
*
|
|
78
|
+
* conversionApi.mapper.bindElements( modelCaption, viewCaption );
|
|
79
|
+
* conversionApi.mapper.bindElements( data.item, viewImageHolder );
|
|
80
|
+
* viewWriter.insert( insertPosition, viewImageHolder );
|
|
81
|
+
* }
|
|
82
|
+
* } else {
|
|
83
|
+
* conversionApi.mapper.bindElements( data.item, viewImage );
|
|
84
|
+
* viewWriter.insert( insertPosition, viewImage );
|
|
85
|
+
* }
|
|
86
|
+
*
|
|
87
|
+
* evt.stop();
|
|
88
|
+
* } );
|
|
89
|
+
*/
|
|
90
|
+
export default class ModelConsumable {
|
|
91
|
+
/**
|
|
92
|
+
* Creates an empty consumables list.
|
|
93
|
+
*/
|
|
94
|
+
constructor() {
|
|
95
|
+
/**
|
|
96
|
+
* Contains list of consumable values.
|
|
97
|
+
*
|
|
98
|
+
* @private
|
|
99
|
+
* @member {Map} module:engine/conversion/modelconsumable~ModelConsumable#_consumable
|
|
100
|
+
*/
|
|
101
|
+
this._consumable = new Map();
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* For each {@link module:engine/model/textproxy~TextProxy} added to `ModelConsumable`, this registry holds parent
|
|
105
|
+
* of that `TextProxy` and start and end indices of that `TextProxy`. This allows identification of `TextProxy`
|
|
106
|
+
* instances that points to the same part of the model but are different instances. Each distinct `TextProxy`
|
|
107
|
+
* is given unique `Symbol` which is then registered as consumable. This process is transparent for `ModelConsumable`
|
|
108
|
+
* API user because whenever `TextProxy` is added, tested, consumed or reverted, internal mechanisms of
|
|
109
|
+
* `ModelConsumable` translates `TextProxy` to that unique `Symbol`.
|
|
110
|
+
*
|
|
111
|
+
* @private
|
|
112
|
+
* @member {Map} module:engine/conversion/modelconsumable~ModelConsumable#_textProxyRegistry
|
|
113
|
+
*/
|
|
114
|
+
this._textProxyRegistry = new Map();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Adds a consumable value to the consumables list and links it with given model item.
|
|
119
|
+
*
|
|
120
|
+
* modelConsumable.add( modelElement, 'insert' ); // Add `modelElement` insertion change to consumable values.
|
|
121
|
+
* modelConsumable.add( modelElement, 'addAttribute:bold' ); // Add `bold` attribute insertion on `modelElement` change.
|
|
122
|
+
* modelConsumable.add( modelElement, 'removeAttribute:bold' ); // Add `bold` attribute removal on `modelElement` change.
|
|
123
|
+
* modelConsumable.add( modelSelection, 'selection' ); // Add `modelSelection` to consumable values.
|
|
124
|
+
* modelConsumable.add( modelRange, 'range' ); // Add `modelRange` to consumable values.
|
|
125
|
+
*
|
|
126
|
+
* @param {module:engine/model/item~Item|module:engine/model/selection~Selection|module:engine/model/range~Range} item
|
|
127
|
+
* Model item, range or selection that has the consumable.
|
|
128
|
+
* @param {String} type Consumable type. Will be normalized to a proper form, that is either `<word>` or `<part>:<part>`.
|
|
129
|
+
* Second colon and everything after will be cut. Passing event name is a safe and good practice.
|
|
130
|
+
*/
|
|
131
|
+
add( item, type ) {
|
|
132
|
+
type = _normalizeConsumableType( type );
|
|
133
|
+
|
|
134
|
+
if ( item instanceof TextProxy ) {
|
|
135
|
+
item = this._getSymbolForTextProxy( item );
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if ( !this._consumable.has( item ) ) {
|
|
139
|
+
this._consumable.set( item, new Map() );
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
this._consumable.get( item ).set( type, true );
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Removes given consumable value from given model item.
|
|
147
|
+
*
|
|
148
|
+
* modelConsumable.consume( modelElement, 'insert' ); // Remove `modelElement` insertion change from consumable values.
|
|
149
|
+
* modelConsumable.consume( modelElement, 'addAttribute:bold' ); // Remove `bold` attribute insertion on `modelElement` change.
|
|
150
|
+
* modelConsumable.consume( modelElement, 'removeAttribute:bold' ); // Remove `bold` attribute removal on `modelElement` change.
|
|
151
|
+
* modelConsumable.consume( modelSelection, 'selection' ); // Remove `modelSelection` from consumable values.
|
|
152
|
+
* modelConsumable.consume( modelRange, 'range' ); // Remove 'modelRange' from consumable values.
|
|
153
|
+
*
|
|
154
|
+
* @param {module:engine/model/item~Item|module:engine/model/selection~Selection|module:engine/model/range~Range} item
|
|
155
|
+
* Model item, range or selection from which consumable will be consumed.
|
|
156
|
+
* @param {String} type Consumable type. Will be normalized to a proper form, that is either `<word>` or `<part>:<part>`.
|
|
157
|
+
* Second colon and everything after will be cut. Passing event name is a safe and good practice.
|
|
158
|
+
* @returns {Boolean} `true` if consumable value was available and was consumed, `false` otherwise.
|
|
159
|
+
*/
|
|
160
|
+
consume( item, type ) {
|
|
161
|
+
type = _normalizeConsumableType( type );
|
|
162
|
+
|
|
163
|
+
if ( item instanceof TextProxy ) {
|
|
164
|
+
item = this._getSymbolForTextProxy( item );
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if ( this.test( item, type ) ) {
|
|
168
|
+
this._consumable.get( item ).set( type, false );
|
|
169
|
+
|
|
170
|
+
return true;
|
|
171
|
+
} else {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Tests whether there is a consumable value of given type connected with given model item.
|
|
178
|
+
*
|
|
179
|
+
* modelConsumable.test( modelElement, 'insert' ); // Check for `modelElement` insertion change.
|
|
180
|
+
* modelConsumable.test( modelElement, 'addAttribute:bold' ); // Check for `bold` attribute insertion on `modelElement` change.
|
|
181
|
+
* modelConsumable.test( modelElement, 'removeAttribute:bold' ); // Check for `bold` attribute removal on `modelElement` change.
|
|
182
|
+
* modelConsumable.test( modelSelection, 'selection' ); // Check if `modelSelection` is consumable.
|
|
183
|
+
* modelConsumable.test( modelRange, 'range' ); // Check if `modelRange` is consumable.
|
|
184
|
+
*
|
|
185
|
+
* @param {module:engine/model/item~Item|module:engine/model/selection~Selection|module:engine/model/range~Range} item
|
|
186
|
+
* Model item, range or selection to be tested.
|
|
187
|
+
* @param {String} type Consumable type. Will be normalized to a proper form, that is either `<word>` or `<part>:<part>`.
|
|
188
|
+
* Second colon and everything after will be cut. Passing event name is a safe and good practice.
|
|
189
|
+
* @returns {null|Boolean} `null` if such consumable was never added, `false` if the consumable values was
|
|
190
|
+
* already consumed or `true` if it was added and not consumed yet.
|
|
191
|
+
*/
|
|
192
|
+
test( item, type ) {
|
|
193
|
+
type = _normalizeConsumableType( type );
|
|
194
|
+
|
|
195
|
+
if ( item instanceof TextProxy ) {
|
|
196
|
+
item = this._getSymbolForTextProxy( item );
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
const itemConsumables = this._consumable.get( item );
|
|
200
|
+
|
|
201
|
+
if ( itemConsumables === undefined ) {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const value = itemConsumables.get( type );
|
|
206
|
+
|
|
207
|
+
if ( value === undefined ) {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return value;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Reverts consuming of consumable value.
|
|
216
|
+
*
|
|
217
|
+
* modelConsumable.revert( modelElement, 'insert' ); // Revert consuming `modelElement` insertion change.
|
|
218
|
+
* modelConsumable.revert( modelElement, 'addAttribute:bold' ); // Revert consuming `bold` attribute insert from `modelElement`.
|
|
219
|
+
* modelConsumable.revert( modelElement, 'removeAttribute:bold' ); // Revert consuming `bold` attribute remove from `modelElement`.
|
|
220
|
+
* modelConsumable.revert( modelSelection, 'selection' ); // Revert consuming `modelSelection`.
|
|
221
|
+
* modelConsumable.revert( modelRange, 'range' ); // Revert consuming `modelRange`.
|
|
222
|
+
*
|
|
223
|
+
* @param {module:engine/model/item~Item|module:engine/model/selection~Selection|module:engine/model/range~Range} item
|
|
224
|
+
* Model item, range or selection to be reverted.
|
|
225
|
+
* @param {String} type Consumable type.
|
|
226
|
+
* @returns {null|Boolean} `true` if consumable has been reversed, `false` otherwise. `null` if the consumable has
|
|
227
|
+
* never been added.
|
|
228
|
+
*/
|
|
229
|
+
revert( item, type ) {
|
|
230
|
+
type = _normalizeConsumableType( type );
|
|
231
|
+
|
|
232
|
+
if ( item instanceof TextProxy ) {
|
|
233
|
+
item = this._getSymbolForTextProxy( item );
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const test = this.test( item, type );
|
|
237
|
+
|
|
238
|
+
if ( test === false ) {
|
|
239
|
+
this._consumable.get( item ).set( type, true );
|
|
240
|
+
|
|
241
|
+
return true;
|
|
242
|
+
} else if ( test === true ) {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Gets a unique symbol for passed {@link module:engine/model/textproxy~TextProxy} instance. All `TextProxy` instances that
|
|
251
|
+
* have same parent, same start index and same end index will get the same symbol.
|
|
252
|
+
*
|
|
253
|
+
* Used internally to correctly consume `TextProxy` instances.
|
|
254
|
+
*
|
|
255
|
+
* @private
|
|
256
|
+
* @param {module:engine/model/textproxy~TextProxy} textProxy `TextProxy` instance to get a symbol for.
|
|
257
|
+
* @returns {Symbol} Symbol representing all equal instances of `TextProxy`.
|
|
258
|
+
*/
|
|
259
|
+
_getSymbolForTextProxy( textProxy ) {
|
|
260
|
+
let symbol = null;
|
|
261
|
+
|
|
262
|
+
const startMap = this._textProxyRegistry.get( textProxy.startOffset );
|
|
263
|
+
|
|
264
|
+
if ( startMap ) {
|
|
265
|
+
const endMap = startMap.get( textProxy.endOffset );
|
|
266
|
+
|
|
267
|
+
if ( endMap ) {
|
|
268
|
+
symbol = endMap.get( textProxy.parent );
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if ( !symbol ) {
|
|
273
|
+
symbol = this._addSymbolForTextProxy( textProxy.startOffset, textProxy.endOffset, textProxy.parent );
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return symbol;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Adds a symbol for given properties that characterizes a {@link module:engine/model/textproxy~TextProxy} instance.
|
|
281
|
+
*
|
|
282
|
+
* Used internally to correctly consume `TextProxy` instances.
|
|
283
|
+
*
|
|
284
|
+
* @private
|
|
285
|
+
* @param {Number} startIndex Text proxy start index in it's parent.
|
|
286
|
+
* @param {Number} endIndex Text proxy end index in it's parent.
|
|
287
|
+
* @param {module:engine/model/element~Element} parent Text proxy parent.
|
|
288
|
+
* @returns {Symbol} Symbol generated for given properties.
|
|
289
|
+
*/
|
|
290
|
+
_addSymbolForTextProxy( start, end, parent ) {
|
|
291
|
+
const symbol = Symbol( 'textProxySymbol' );
|
|
292
|
+
let startMap, endMap;
|
|
293
|
+
|
|
294
|
+
startMap = this._textProxyRegistry.get( start );
|
|
295
|
+
|
|
296
|
+
if ( !startMap ) {
|
|
297
|
+
startMap = new Map();
|
|
298
|
+
this._textProxyRegistry.set( start, startMap );
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
endMap = startMap.get( end );
|
|
302
|
+
|
|
303
|
+
if ( !endMap ) {
|
|
304
|
+
endMap = new Map();
|
|
305
|
+
startMap.set( end, endMap );
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
endMap.set( parent, symbol );
|
|
309
|
+
|
|
310
|
+
return symbol;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// Returns a normalized consumable type name from given string. A normalized consumable type name is a string that has
|
|
315
|
+
// at most one colon, for example: `insert` or `addMarker:highlight`. If string to normalize has more "parts" (more colons),
|
|
316
|
+
// the other parts are dropped, for example: `addattribute:bold:$text` -> `addattributes:bold`.
|
|
317
|
+
//
|
|
318
|
+
// @param {String} type Consumable type.
|
|
319
|
+
// @returns {String} Normalized consumable type.
|
|
320
|
+
function _normalizeConsumableType( type ) {
|
|
321
|
+
const parts = type.split( ':' );
|
|
322
|
+
|
|
323
|
+
// Markers are identified by the whole name (otherwise we would consume the whole markers group).
|
|
324
|
+
if ( parts[ 0 ] == 'addMarker' || parts[ 0 ] == 'removeMarker' ) {
|
|
325
|
+
return type;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return parts.length > 1 ? parts[ 0 ] + ':' + parts[ 1 ] : parts[ 0 ];
|
|
329
|
+
}
|