@ckeditor/ckeditor5-engine 37.0.0-alpha.0 → 37.0.0-alpha.2
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/package.json +23 -23
- package/src/controller/datacontroller.d.ts +24 -24
- package/src/controller/datacontroller.js +10 -7
- package/src/conversion/downcastdispatcher.d.ts +8 -8
- package/src/conversion/mapper.d.ts +6 -2
- package/src/conversion/upcastdispatcher.d.ts +8 -8
- package/src/conversion/viewconsumable.d.ts +193 -1
- package/src/conversion/viewconsumable.js +1 -30
- package/src/index.d.ts +6 -3
- package/src/index.js +3 -0
- package/src/model/document.d.ts +2 -1
- package/src/model/documentselection.d.ts +4 -4
- package/src/model/liveposition.d.ts +1 -1
- package/src/model/liverange.d.ts +2 -2
- package/src/model/markercollection.d.ts +5 -5
- package/src/model/model.d.ts +97 -24
- package/src/model/model.js +0 -51
- package/src/model/operation/mergeoperation.d.ts +2 -2
- package/src/model/operation/mergeoperation.js +1 -1
- package/src/model/operation/splitoperation.d.ts +1 -1
- package/src/model/operation/splitoperation.js +1 -1
- package/src/model/operation/utils.d.ts +1 -1
- package/src/model/operation/utils.js +1 -1
- package/src/model/schema.d.ts +10 -10
- package/src/model/schema.js +4 -4
- package/src/model/selection.d.ts +2 -2
- package/src/model/typecheckable.d.ts +31 -1
- package/src/model/writer.d.ts +100 -3
- package/src/model/writer.js +0 -57
- package/src/view/document.d.ts +1 -1
- package/src/view/documentfragment.d.ts +0 -1
- package/src/view/documentfragment.js +0 -1
- package/src/view/documentselection.d.ts +88 -1
- package/src/view/documentselection.js +0 -55
- package/src/view/domconverter.d.ts +30 -0
- package/src/view/domconverter.js +0 -9
- package/src/view/downcastwriter.d.ts +192 -0
- package/src/view/downcastwriter.js +0 -123
- package/src/view/element.d.ts +2 -0
- package/src/view/node.d.ts +4 -1
- package/src/view/observer/arrowkeysobserver.d.ts +1 -1
- package/src/view/observer/clickobserver.d.ts +1 -1
- package/src/view/observer/compositionobserver.d.ts +3 -3
- package/src/view/observer/fakeselectionobserver.d.ts +0 -3
- package/src/view/observer/fakeselectionobserver.js +0 -3
- package/src/view/observer/focusobserver.d.ts +2 -2
- package/src/view/observer/inputobserver.d.ts +2 -2
- package/src/view/observer/keyobserver.d.ts +3 -4
- package/src/view/observer/mouseobserver.d.ts +4 -4
- package/src/view/observer/selectionobserver.d.ts +3 -2
- package/src/view/observer/selectionobserver.js +8 -8
- package/src/view/observer/tabobserver.d.ts +1 -1
- package/src/view/position.d.ts +1 -1
- package/src/view/position.js +1 -1
- package/src/view/selection.d.ts +1 -1
- package/src/view/stylesmap.d.ts +3 -3
- package/src/view/typecheckable.d.ts +49 -2
- package/src/view/uielement.d.ts +1 -1
- package/src/view/uielement.js +1 -1
- package/src/view/upcastwriter.d.ts +92 -3
- package/src/view/upcastwriter.js +0 -61
- package/src/view/view.d.ts +91 -1
- package/src/view/view.js +3 -60
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-engine",
|
|
3
|
-
"version": "37.0.0-alpha.
|
|
3
|
+
"version": "37.0.0-alpha.2",
|
|
4
4
|
"description": "The editing engine of CKEditor 5 – the best browser-based rich text editor.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wysiwyg",
|
|
@@ -23,30 +23,30 @@
|
|
|
23
23
|
],
|
|
24
24
|
"main": "src/index.js",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@ckeditor/ckeditor5-utils": "^37.0.0-alpha.
|
|
26
|
+
"@ckeditor/ckeditor5-utils": "^37.0.0-alpha.2",
|
|
27
27
|
"lodash-es": "^4.17.15"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@ckeditor/ckeditor5-basic-styles": "^37.0.0-alpha.
|
|
31
|
-
"@ckeditor/ckeditor5-block-quote": "^37.0.0-alpha.
|
|
32
|
-
"@ckeditor/ckeditor5-clipboard": "^37.0.0-alpha.
|
|
33
|
-
"@ckeditor/ckeditor5-cloud-services": "^37.0.0-alpha.
|
|
34
|
-
"@ckeditor/ckeditor5-core": "^37.0.0-alpha.
|
|
35
|
-
"@ckeditor/ckeditor5-editor-classic": "^37.0.0-alpha.
|
|
36
|
-
"@ckeditor/ckeditor5-enter": "^37.0.0-alpha.
|
|
37
|
-
"@ckeditor/ckeditor5-essentials": "^37.0.0-alpha.
|
|
38
|
-
"@ckeditor/ckeditor5-heading": "^37.0.0-alpha.
|
|
39
|
-
"@ckeditor/ckeditor5-image": "^37.0.0-alpha.
|
|
40
|
-
"@ckeditor/ckeditor5-link": "^37.0.0-alpha.
|
|
41
|
-
"@ckeditor/ckeditor5-list": "^37.0.0-alpha.
|
|
42
|
-
"@ckeditor/ckeditor5-mention": "^37.0.0-alpha.
|
|
43
|
-
"@ckeditor/ckeditor5-paragraph": "^37.0.0-alpha.
|
|
44
|
-
"@ckeditor/ckeditor5-table": "^37.0.0-alpha.
|
|
45
|
-
"@ckeditor/ckeditor5-theme-lark": "^37.0.0-alpha.
|
|
46
|
-
"@ckeditor/ckeditor5-typing": "^37.0.0-alpha.
|
|
47
|
-
"@ckeditor/ckeditor5-ui": "^37.0.0-alpha.
|
|
48
|
-
"@ckeditor/ckeditor5-undo": "^37.0.0-alpha.
|
|
49
|
-
"@ckeditor/ckeditor5-widget": "^37.0.0-alpha.
|
|
30
|
+
"@ckeditor/ckeditor5-basic-styles": "^37.0.0-alpha.2",
|
|
31
|
+
"@ckeditor/ckeditor5-block-quote": "^37.0.0-alpha.2",
|
|
32
|
+
"@ckeditor/ckeditor5-clipboard": "^37.0.0-alpha.2",
|
|
33
|
+
"@ckeditor/ckeditor5-cloud-services": "^37.0.0-alpha.2",
|
|
34
|
+
"@ckeditor/ckeditor5-core": "^37.0.0-alpha.2",
|
|
35
|
+
"@ckeditor/ckeditor5-editor-classic": "^37.0.0-alpha.2",
|
|
36
|
+
"@ckeditor/ckeditor5-enter": "^37.0.0-alpha.2",
|
|
37
|
+
"@ckeditor/ckeditor5-essentials": "^37.0.0-alpha.2",
|
|
38
|
+
"@ckeditor/ckeditor5-heading": "^37.0.0-alpha.2",
|
|
39
|
+
"@ckeditor/ckeditor5-image": "^37.0.0-alpha.2",
|
|
40
|
+
"@ckeditor/ckeditor5-link": "^37.0.0-alpha.2",
|
|
41
|
+
"@ckeditor/ckeditor5-list": "^37.0.0-alpha.2",
|
|
42
|
+
"@ckeditor/ckeditor5-mention": "^37.0.0-alpha.2",
|
|
43
|
+
"@ckeditor/ckeditor5-paragraph": "^37.0.0-alpha.2",
|
|
44
|
+
"@ckeditor/ckeditor5-table": "^37.0.0-alpha.2",
|
|
45
|
+
"@ckeditor/ckeditor5-theme-lark": "^37.0.0-alpha.2",
|
|
46
|
+
"@ckeditor/ckeditor5-typing": "^37.0.0-alpha.2",
|
|
47
|
+
"@ckeditor/ckeditor5-ui": "^37.0.0-alpha.2",
|
|
48
|
+
"@ckeditor/ckeditor5-undo": "^37.0.0-alpha.2",
|
|
49
|
+
"@ckeditor/ckeditor5-widget": "^37.0.0-alpha.2",
|
|
50
50
|
"typescript": "^4.8.4",
|
|
51
51
|
"webpack": "^5.58.1",
|
|
52
52
|
"webpack-cli": "^4.9.0"
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"CHANGELOG.md"
|
|
74
74
|
],
|
|
75
75
|
"scripts": {
|
|
76
|
-
"build": "tsc -p ./tsconfig.
|
|
76
|
+
"build": "tsc -p ./tsconfig.json",
|
|
77
77
|
"postversion": "npm run build"
|
|
78
78
|
},
|
|
79
79
|
"types": "src/index.d.ts"
|
|
@@ -132,7 +132,7 @@ export default class DataController extends DataController_base {
|
|
|
132
132
|
* converted by the {@link #upcastDispatcher view-to-model converters}.
|
|
133
133
|
* Initial data can be only set to a document whose {@link module:engine/model/document~Document#version} is equal 0.
|
|
134
134
|
*
|
|
135
|
-
* **Note** This method is {@link module:utils/observablemixin~
|
|
135
|
+
* **Note** This method is {@link module:utils/observablemixin~Observable#decorate decorated} which is
|
|
136
136
|
* used by e.g. collaborative editing plugin that syncs remote data on init.
|
|
137
137
|
*
|
|
138
138
|
* When data is passed as a string, it is initialized on the default `main` root:
|
|
@@ -255,21 +255,21 @@ export default class DataController extends DataController_base {
|
|
|
255
255
|
/**
|
|
256
256
|
* Event fired once the data initialization has finished.
|
|
257
257
|
*
|
|
258
|
-
* @eventName ready
|
|
258
|
+
* @eventName ~DataController#ready
|
|
259
259
|
*/
|
|
260
260
|
export type DataControllerReadyEvent = {
|
|
261
261
|
name: 'ready';
|
|
262
262
|
args: [];
|
|
263
263
|
};
|
|
264
264
|
/**
|
|
265
|
-
* An event fired after the {@link #init `init()` method} was run. It can be {@link #listenTo listened to} in
|
|
266
|
-
* the initialization flow. However, if the `init` event is stopped or prevented,
|
|
267
|
-
* should be fired manually.
|
|
265
|
+
* An event fired after the {@link ~DataController#init `init()` method} was run. It can be {@link ~DataController#listenTo listened to} in
|
|
266
|
+
* order to adjust or modify the initialization flow. However, if the `init` event is stopped or prevented,
|
|
267
|
+
* the {@link ~DataController#event:ready `ready` event} should be fired manually.
|
|
268
268
|
*
|
|
269
|
-
* The `init` event is fired by the decorated {@link #init} method.
|
|
270
|
-
* See {@link module:utils/observablemixin~
|
|
269
|
+
* The `init` event is fired by the decorated {@link ~DataController#init} method.
|
|
270
|
+
* See {@link module:utils/observablemixin~Observable#decorate} for more information and samples.
|
|
271
271
|
*
|
|
272
|
-
* @eventName init
|
|
272
|
+
* @eventName ~DataController#init
|
|
273
273
|
*/
|
|
274
274
|
export type DataControllerInitEvent = {
|
|
275
275
|
name: 'init';
|
|
@@ -277,12 +277,12 @@ export type DataControllerInitEvent = {
|
|
|
277
277
|
return: ReturnType<DataController['init']>;
|
|
278
278
|
};
|
|
279
279
|
/**
|
|
280
|
-
* An event fired after {@link #set set() method} has been run.
|
|
280
|
+
* An event fired after {@link ~DataController#set set() method} has been run.
|
|
281
281
|
*
|
|
282
|
-
* The `set` event is fired by the decorated {@link #set} method.
|
|
283
|
-
* See {@link module:utils/observablemixin~
|
|
282
|
+
* The `set` event is fired by the decorated {@link ~DataController#set} method.
|
|
283
|
+
* See {@link module:utils/observablemixin~Observable#decorate} for more information and samples.
|
|
284
284
|
*
|
|
285
|
-
* @eventName set
|
|
285
|
+
* @eventName ~DataController#set
|
|
286
286
|
*/
|
|
287
287
|
export type DataControllerSetEvent = {
|
|
288
288
|
name: 'set';
|
|
@@ -290,12 +290,12 @@ export type DataControllerSetEvent = {
|
|
|
290
290
|
return: ReturnType<DataController['set']>;
|
|
291
291
|
};
|
|
292
292
|
/**
|
|
293
|
-
* Event fired after the {@link #get get() method} has been run.
|
|
293
|
+
* Event fired after the {@link ~DataController#get get() method} has been run.
|
|
294
294
|
*
|
|
295
|
-
* The `get` event is fired by the decorated {@link #get} method.
|
|
296
|
-
* See {@link module:utils/observablemixin~
|
|
295
|
+
* The `get` event is fired by the decorated {@link ~DataController#get} method.
|
|
296
|
+
* See {@link module:utils/observablemixin~Observable#decorate} for more information and samples.
|
|
297
297
|
*
|
|
298
|
-
* @eventName get
|
|
298
|
+
* @eventName ~DataController#get
|
|
299
299
|
*/
|
|
300
300
|
export type DataControllerGetEvent = {
|
|
301
301
|
name: 'get';
|
|
@@ -303,12 +303,12 @@ export type DataControllerGetEvent = {
|
|
|
303
303
|
return: ReturnType<DataController['get']>;
|
|
304
304
|
};
|
|
305
305
|
/**
|
|
306
|
-
* Event fired after the {@link #toView toView() method} has been run.
|
|
306
|
+
* Event fired after the {@link ~DataController#toView toView() method} has been run.
|
|
307
307
|
*
|
|
308
|
-
* The `toView` event is fired by the decorated {@link #toView} method.
|
|
309
|
-
* See {@link module:utils/observablemixin~
|
|
308
|
+
* The `toView` event is fired by the decorated {@link ~DataController#toView} method.
|
|
309
|
+
* See {@link module:utils/observablemixin~Observable#decorate} for more information and samples.
|
|
310
310
|
*
|
|
311
|
-
* @eventName toView
|
|
311
|
+
* @eventName ~DataController#toView
|
|
312
312
|
*/
|
|
313
313
|
export type DataControllerToViewEvent = {
|
|
314
314
|
name: 'toView';
|
|
@@ -316,12 +316,12 @@ export type DataControllerToViewEvent = {
|
|
|
316
316
|
return: ReturnType<DataController['toView']>;
|
|
317
317
|
};
|
|
318
318
|
/**
|
|
319
|
-
* Event fired after the {@link #toModel toModel() method} has been run.
|
|
319
|
+
* Event fired after the {@link ~DataController#toModel toModel() method} has been run.
|
|
320
320
|
*
|
|
321
|
-
* The `toModel` event is fired by the decorated {@link #toModel} method.
|
|
322
|
-
* See {@link module:utils/observablemixin~
|
|
321
|
+
* The `toModel` event is fired by the decorated {@link ~DataController#toModel} method.
|
|
322
|
+
* See {@link module:utils/observablemixin~Observable#decorate} for more information and samples.
|
|
323
323
|
*
|
|
324
|
-
* @eventName toModel
|
|
324
|
+
* @eventName ~DataController#toModel
|
|
325
325
|
*/
|
|
326
326
|
export type DataControllerToModelEvent = {
|
|
327
327
|
name: 'toModel';
|
|
@@ -100,9 +100,10 @@ export default class DataController extends EmitterMixin() {
|
|
|
100
100
|
const { rootName = 'main', trim = 'empty' } = options;
|
|
101
101
|
if (!this._checkIfRootsExists([rootName])) {
|
|
102
102
|
/**
|
|
103
|
-
* Cannot get data from a non-existing root. This error is thrown when
|
|
103
|
+
* Cannot get data from a non-existing root. This error is thrown when
|
|
104
|
+
* {@link module:engine/controller/datacontroller~DataController#get `DataController#get()` method}
|
|
104
105
|
* is called with a non-existent root name. For example, if there is an editor instance with only `main` root,
|
|
105
|
-
* calling {@link #get} like:
|
|
106
|
+
* calling {@link module:engine/controller/datacontroller~DataController#get} like:
|
|
106
107
|
*
|
|
107
108
|
* ```ts
|
|
108
109
|
* data.get( { rootName: 'root2' } );
|
|
@@ -172,7 +173,7 @@ export default class DataController extends EmitterMixin() {
|
|
|
172
173
|
* converted by the {@link #upcastDispatcher view-to-model converters}.
|
|
173
174
|
* Initial data can be only set to a document whose {@link module:engine/model/document~Document#version} is equal 0.
|
|
174
175
|
*
|
|
175
|
-
* **Note** This method is {@link module:utils/observablemixin~
|
|
176
|
+
* **Note** This method is {@link module:utils/observablemixin~Observable#decorate decorated} which is
|
|
176
177
|
* used by e.g. collaborative editing plugin that syncs remote data on init.
|
|
177
178
|
*
|
|
178
179
|
* When data is passed as a string, it is initialized on the default `main` root:
|
|
@@ -212,9 +213,10 @@ export default class DataController extends EmitterMixin() {
|
|
|
212
213
|
}
|
|
213
214
|
if (!this._checkIfRootsExists(Object.keys(initialData))) {
|
|
214
215
|
/**
|
|
215
|
-
* Cannot init data on a non-existent root. This error is thrown when
|
|
216
|
+
* Cannot init data on a non-existent root. This error is thrown when
|
|
217
|
+
* {@link module:engine/controller/datacontroller~DataController#init DataController#init() method}
|
|
216
218
|
* is called with non-existent root name. For example, if there is an editor instance with only `main` root,
|
|
217
|
-
* calling {@link #init} like:
|
|
219
|
+
* calling {@link module:engine/controller/datacontroller~DataController#init} like:
|
|
218
220
|
*
|
|
219
221
|
* ```ts
|
|
220
222
|
* data.init( { main: '<p>Foo</p>', root2: '<p>Bar</p>' } );
|
|
@@ -280,9 +282,10 @@ export default class DataController extends EmitterMixin() {
|
|
|
280
282
|
}
|
|
281
283
|
if (!this._checkIfRootsExists(Object.keys(newData))) {
|
|
282
284
|
/**
|
|
283
|
-
* Cannot set data on a non-existent root. This error is thrown when the
|
|
285
|
+
* Cannot set data on a non-existent root. This error is thrown when the
|
|
286
|
+
* {@link module:engine/controller/datacontroller~DataController#set DataController#set() method}
|
|
284
287
|
* is called with non-existent root name. For example, if there is an editor instance with only the default `main` root,
|
|
285
|
-
* calling {@link #set} like:
|
|
288
|
+
* calling {@link module:engine/controller/datacontroller~DataController#set} like:
|
|
286
289
|
*
|
|
287
290
|
* ```ts
|
|
288
291
|
* data.set( { main: '<p>Foo</p>', root2: '<p>Bar</p>' } );
|
|
@@ -309,7 +309,7 @@ export default class DowncastDispatcher extends DowncastDispatcher_base {
|
|
|
309
309
|
}
|
|
310
310
|
/**
|
|
311
311
|
* Fired to enable reducing (transforming) changes buffered in the {@link module:engine/model/differ~Differ `Differ`} before
|
|
312
|
-
* {@link #convertChanges `convertChanges()`} will fire any conversion events.
|
|
312
|
+
* {@link ~DowncastDispatcher#convertChanges `convertChanges()`} will fire any conversion events.
|
|
313
313
|
*
|
|
314
314
|
* For instance, a feature can replace selected {@link module:engine/model/differ~DiffItem `DiffItem`}s with a `reinsert` entry
|
|
315
315
|
* to trigger reconversion of an element when e.g. its attribute has changes.
|
|
@@ -317,7 +317,7 @@ export default class DowncastDispatcher extends DowncastDispatcher_base {
|
|
|
317
317
|
* `DowncastHelpers.elementToStructure()`} helper is using this event to trigger reconversion of an element when the element,
|
|
318
318
|
* its attributes or direct children changed.
|
|
319
319
|
*
|
|
320
|
-
* @eventName reduceChanges
|
|
320
|
+
* @eventName ~DowncastDispatcher#reduceChanges
|
|
321
321
|
*/
|
|
322
322
|
export type DowncastReduceChangesEvent = {
|
|
323
323
|
name: 'reduceChanges';
|
|
@@ -373,7 +373,7 @@ export type DowncastEvent<TName extends keyof EventMap<TItem>, TItem = Item> = {
|
|
|
373
373
|
*
|
|
374
374
|
* This way, the listeners can either listen to a general `insert` event or specific event (for example `insert:paragraph`).
|
|
375
375
|
*
|
|
376
|
-
* @eventName insert
|
|
376
|
+
* @eventName ~DowncastDispatcher#insert
|
|
377
377
|
* @param {Object} data Additional information about the change.
|
|
378
378
|
* @param {module:engine/model/item~Item} data.item The inserted item.
|
|
379
379
|
* @param {module:engine/model/range~Range} data.range Range spanning over inserted item.
|
|
@@ -390,7 +390,7 @@ export type DowncastInsertEvent<TItem extends Item = Item> = DowncastEvent<'inse
|
|
|
390
390
|
*
|
|
391
391
|
* This way, listeners can either listen to a general `remove` event or specific event (for example `remove:paragraph`).
|
|
392
392
|
*
|
|
393
|
-
* @eventName remove
|
|
393
|
+
* @eventName ~DowncastDispatcher#remove
|
|
394
394
|
* @param {Object} data Additional information about the change.
|
|
395
395
|
* @param {module:engine/model/position~Position} data.position Position from which the node has been removed.
|
|
396
396
|
* @param {Number} data.length Offset size of the removed node.
|
|
@@ -412,7 +412,7 @@ export type DowncastRemoveEvent = DowncastEvent<'remove'>;
|
|
|
412
412
|
*
|
|
413
413
|
* This way listeners can either listen to a general `attribute:bold` event or specific event (for example `attribute:src:imageBlock`).
|
|
414
414
|
*
|
|
415
|
-
* @eventName attribute
|
|
415
|
+
* @eventName ~DowncastDispatcher#attribute
|
|
416
416
|
* @param {Object} data Additional information about the change.
|
|
417
417
|
* @param {module:engine/model/item~Item|module:engine/model/documentselection~DocumentSelection} data.item Changed item
|
|
418
418
|
* or converted selection.
|
|
@@ -427,7 +427,7 @@ export type DowncastAttributeEvent<TItem = Item | Selection | DocumentSelection>
|
|
|
427
427
|
/**
|
|
428
428
|
* Fired for {@link module:engine/model/selection~Selection selection} changes.
|
|
429
429
|
*
|
|
430
|
-
* @eventName selection
|
|
430
|
+
* @eventName ~DowncastDispatcher#selection
|
|
431
431
|
* @param {module:engine/model/selection~Selection} selection Selection that is converted.
|
|
432
432
|
* @param {module:engine/conversion/downcastdispatcher~DowncastConversionApi} conversionApi Conversion interface
|
|
433
433
|
* to be used by callback, passed in `DowncastDispatcher` constructor.
|
|
@@ -456,7 +456,7 @@ export type DowncastSelectionEvent = DowncastEvent<'selection'>;
|
|
|
456
456
|
* * there is only one event,
|
|
457
457
|
* * `conversionApi.consumable` includes the selection instance with the event name.
|
|
458
458
|
*
|
|
459
|
-
* @eventName addMarker
|
|
459
|
+
* @eventName ~DowncastDispatcher#addMarker
|
|
460
460
|
* @param {Object} data Additional information about the change.
|
|
461
461
|
* @param {module:engine/model/item~Item|module:engine/model/selection~Selection} data.item Item inside the new marker or
|
|
462
462
|
* the selection that is being converted.
|
|
@@ -476,7 +476,7 @@ export type DowncastAddMarkerEvent = DowncastEvent<'addMarker'>;
|
|
|
476
476
|
* if markers are named `foo:abc`, `foo:bar`, then it is possible to listen to `removeMarker:foo` or `removeMarker:foo:abc` and
|
|
477
477
|
* `removeMarker:foo:bar` events.
|
|
478
478
|
*
|
|
479
|
-
* @eventName removeMarker
|
|
479
|
+
* @eventName ~DowncastDispatcher#removeMarker
|
|
480
480
|
* @param {Object} data Additional information about the change.
|
|
481
481
|
* @param {module:engine/model/range~Range} data.markerRange Marker range.
|
|
482
482
|
* @param {String} data.markerName Marker name.
|
|
@@ -151,6 +151,7 @@ export default class Mapper extends Mapper_base {
|
|
|
151
151
|
*
|
|
152
152
|
* **Note:** {@link module:engine/view/uielement~UIElement} does not have corresponding element in model.
|
|
153
153
|
*
|
|
154
|
+
* @label ELEMENT
|
|
154
155
|
* @param viewElement View element.
|
|
155
156
|
* @returns Corresponding model element or `undefined` if not found.
|
|
156
157
|
*/
|
|
@@ -158,6 +159,7 @@ export default class Mapper extends Mapper_base {
|
|
|
158
159
|
/**
|
|
159
160
|
* Gets the corresponding model document fragment.
|
|
160
161
|
*
|
|
162
|
+
* @label DOCUMENT_FRAGMENT
|
|
161
163
|
* @param viewDocumentFragment View document fragment.
|
|
162
164
|
* @returns Corresponding model document fragment or `undefined` if not found.
|
|
163
165
|
*/
|
|
@@ -165,6 +167,7 @@ export default class Mapper extends Mapper_base {
|
|
|
165
167
|
/**
|
|
166
168
|
* Gets the corresponding view element.
|
|
167
169
|
*
|
|
170
|
+
* @label ELEMENT
|
|
168
171
|
* @param modelElement Model element.
|
|
169
172
|
* @returns Corresponding view element or `undefined` if not found.
|
|
170
173
|
*/
|
|
@@ -172,6 +175,7 @@ export default class Mapper extends Mapper_base {
|
|
|
172
175
|
/**
|
|
173
176
|
* Gets the corresponding view document fragment.
|
|
174
177
|
*
|
|
178
|
+
* @label DOCUMENT_FRAGMENT
|
|
175
179
|
* @param modelDocumentFragment Model document fragment.
|
|
176
180
|
* @returns Corresponding view document fragment or `undefined` if not found.
|
|
177
181
|
*/
|
|
@@ -412,7 +416,7 @@ export default class Mapper extends Mapper_base {
|
|
|
412
416
|
* mapping between the given model and view elements is unsolvable by using just elements mapping and default algorithm.
|
|
413
417
|
* Also, the condition that checks if a special case scenario happened should be as simple as possible.
|
|
414
418
|
*
|
|
415
|
-
* @eventName modelToViewPosition
|
|
419
|
+
* @eventName ~Mapper#modelToViewPosition
|
|
416
420
|
*/
|
|
417
421
|
export type MapperModelToViewPositionEvent = {
|
|
418
422
|
name: 'modelToViewPosition';
|
|
@@ -471,7 +475,7 @@ export type MapperModelToViewPositionEventData = {
|
|
|
471
475
|
* mapping between the given model and view elements is unsolvable by using just elements mapping and default algorithm.
|
|
472
476
|
* Also, the condition that checks if special case scenario happened should be as simple as possible.
|
|
473
477
|
*
|
|
474
|
-
* @eventName viewToModelPosition
|
|
478
|
+
* @eventName ~Mapper#viewToModelPosition
|
|
475
479
|
*/
|
|
476
480
|
export type MapperViewToModelPositionEvent = {
|
|
477
481
|
name: 'viewToModelPosition';
|
|
@@ -213,7 +213,7 @@ export default class UpcastDispatcher extends UpcastDispatcher_base {
|
|
|
213
213
|
/**
|
|
214
214
|
* Fired before the first conversion event, at the beginning of the upcast (view-to-model conversion) process.
|
|
215
215
|
*
|
|
216
|
-
* @eventName viewCleanup
|
|
216
|
+
* @eventName ~UpcastDispatcher#viewCleanup
|
|
217
217
|
* @param viewItem A part of the view to be converted.
|
|
218
218
|
*/
|
|
219
219
|
export type UpcastViewCleanupEvent = {
|
|
@@ -230,7 +230,7 @@ type UpcastEvent<TName extends string, TItem extends ViewItem | ViewDocumentFrag
|
|
|
230
230
|
* **Note:** Keep in mind that this object is shared by reference between all conversion callbacks that will be called.
|
|
231
231
|
* This means that callbacks can override values if needed, and these values will be available in other callbacks.
|
|
232
232
|
*/
|
|
233
|
-
export
|
|
233
|
+
export interface UpcastConversionData<TItem extends ViewItem | ViewDocumentFragment = ViewItem | ViewDocumentFragment> {
|
|
234
234
|
/**
|
|
235
235
|
* The converted item.
|
|
236
236
|
*/
|
|
@@ -245,7 +245,7 @@ export type UpcastConversionData<TItem extends ViewItem | ViewDocumentFragment =
|
|
|
245
245
|
* the converted element should be reflected by setting or modifying this property.
|
|
246
246
|
*/
|
|
247
247
|
modelRange: ModelRange | null;
|
|
248
|
-
}
|
|
248
|
+
}
|
|
249
249
|
/**
|
|
250
250
|
* Fired when an {@link module:engine/view/element~Element} is converted.
|
|
251
251
|
*
|
|
@@ -253,7 +253,7 @@ export type UpcastConversionData<TItem extends ViewItem | ViewDocumentFragment =
|
|
|
253
253
|
* `element:<elementName>` where `elementName` is the name of the converted element. This way listeners may listen to
|
|
254
254
|
* a conversion of all or just specific elements.
|
|
255
255
|
*
|
|
256
|
-
* @eventName element
|
|
256
|
+
* @eventName ~UpcastDispatcher#element
|
|
257
257
|
* @param data The conversion data. Keep in mind that this object is shared by reference between all callbacks
|
|
258
258
|
* that will be called. This means that callbacks can override values if needed, and these values
|
|
259
259
|
* will be available in other callbacks.
|
|
@@ -263,15 +263,15 @@ export type UpcastElementEvent = UpcastEvent<'element', ViewElement>;
|
|
|
263
263
|
/**
|
|
264
264
|
* Fired when a {@link module:engine/view/text~Text} is converted.
|
|
265
265
|
*
|
|
266
|
-
* @eventName text
|
|
267
|
-
* @see #event:element
|
|
266
|
+
* @eventName ~UpcastDispatcher#text
|
|
267
|
+
* @see ~UpcastDispatcher#event:element
|
|
268
268
|
*/
|
|
269
269
|
export type UpcastTextEvent = UpcastEvent<'text', ViewText>;
|
|
270
270
|
/**
|
|
271
271
|
* Fired when a {@link module:engine/view/documentfragment~DocumentFragment} is converted.
|
|
272
272
|
*
|
|
273
|
-
* @eventName documentFragment
|
|
274
|
-
* @see #event:element
|
|
273
|
+
* @eventName ~UpcastDispatcher#documentFragment
|
|
274
|
+
* @see ~UpcastDispatcher#event:element
|
|
275
275
|
*/
|
|
276
276
|
export type UpcastDocumentFragmentEvent = UpcastEvent<'documentFragment', ViewDocumentFragment>;
|
|
277
277
|
/**
|
|
@@ -40,7 +40,49 @@ export default class ViewConsumable {
|
|
|
40
40
|
* {@link module:engine/view/documentfragment~DocumentFragment document fragments} boolean value is stored as value.
|
|
41
41
|
*/
|
|
42
42
|
private _consumables;
|
|
43
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Adds {@link module:engine/view/text~Text text node} or
|
|
45
|
+
* {@link module:engine/view/documentfragment~DocumentFragment document fragment} as ready to be consumed.
|
|
46
|
+
*
|
|
47
|
+
* ```ts
|
|
48
|
+
* viewConsumable.add( textNode ); // Adds text node to consume.
|
|
49
|
+
* viewConsumable.add( docFragment ); // Adds document fragment to consume.
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* See also: {@link #add:ELEMENT `add( element, consumables )`}.
|
|
53
|
+
*
|
|
54
|
+
* @label TEXT_OR_FRAGMENT
|
|
55
|
+
*/
|
|
56
|
+
add(textOrDocumentFragment: Text | DocumentFragment): void;
|
|
57
|
+
/**
|
|
58
|
+
* Adds {@link module:engine/view/element~Element view element} as ready to be consumed.
|
|
59
|
+
*
|
|
60
|
+
* ```ts
|
|
61
|
+
* viewConsumable.add( p, { name: true } ); // Adds element's name to consume.
|
|
62
|
+
* viewConsumable.add( p, { attributes: 'name' } ); // Adds element's attribute.
|
|
63
|
+
* viewConsumable.add( p, { classes: 'foobar' } ); // Adds element's class.
|
|
64
|
+
* viewConsumable.add( p, { styles: 'color' } ); // Adds element's style
|
|
65
|
+
* viewConsumable.add( p, { attributes: 'name', styles: 'color' } ); // Adds attribute and style.
|
|
66
|
+
* viewConsumable.add( p, { classes: [ 'baz', 'bar' ] } ); // Multiple consumables can be provided.
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `viewconsumable-invalid-attribute` when `class` or `style`
|
|
70
|
+
* attribute is provided - it should be handled separately by providing actual style/class.
|
|
71
|
+
*
|
|
72
|
+
* ```ts
|
|
73
|
+
* viewConsumable.add( p, { attributes: 'style' } ); // This call will throw an exception.
|
|
74
|
+
* viewConsumable.add( p, { styles: 'color' } ); // This is properly handled style.
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* See also: {@link #add:TEXT_OR_FRAGMENT `add( textOrDocumentFragment )`}.
|
|
78
|
+
*
|
|
79
|
+
* @label ELEMENT
|
|
80
|
+
* @param consumables Used only if first parameter is {@link module:engine/view/element~Element view element} instance.
|
|
81
|
+
* @param consumables.name If set to true element's name will be included.
|
|
82
|
+
* @param consumables.attributes Attribute name or array of attribute names.
|
|
83
|
+
* @param consumables.classes Class name or array of class names.
|
|
84
|
+
* @param consumables.styles Style name or array of style names.
|
|
85
|
+
*/
|
|
44
86
|
add(element: Element, consumables: Consumables): void;
|
|
45
87
|
/**
|
|
46
88
|
* Tests if {@link module:engine/view/element~Element view element}, {@link module:engine/view/text~Text text node} or
|
|
@@ -175,3 +217,153 @@ export interface Consumables {
|
|
|
175
217
|
*/
|
|
176
218
|
styles?: string | Array<string>;
|
|
177
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* This is a private helper-class for {@link module:engine/conversion/viewconsumable~ViewConsumable}.
|
|
222
|
+
* It represents and manipulates consumable parts of a single {@link module:engine/view/element~Element}.
|
|
223
|
+
*/
|
|
224
|
+
export declare class ViewElementConsumables {
|
|
225
|
+
readonly element: Node | DocumentFragment;
|
|
226
|
+
/**
|
|
227
|
+
* Flag indicating if name of the element can be consumed.
|
|
228
|
+
*/
|
|
229
|
+
private _canConsumeName;
|
|
230
|
+
/**
|
|
231
|
+
* Contains maps of element's consumables: attributes, classes and styles.
|
|
232
|
+
*/
|
|
233
|
+
private readonly _consumables;
|
|
234
|
+
/**
|
|
235
|
+
* Creates ViewElementConsumables instance.
|
|
236
|
+
*
|
|
237
|
+
* @param from View node or document fragment from which `ViewElementConsumables` is being created.
|
|
238
|
+
*/
|
|
239
|
+
constructor(from: Node | DocumentFragment);
|
|
240
|
+
/**
|
|
241
|
+
* Adds consumable parts of the {@link module:engine/view/element~Element view element}.
|
|
242
|
+
* Element's name itself can be marked to be consumed (when element's name is consumed its attributes, classes and
|
|
243
|
+
* styles still could be consumed):
|
|
244
|
+
*
|
|
245
|
+
* ```ts
|
|
246
|
+
* consumables.add( { name: true } );
|
|
247
|
+
* ```
|
|
248
|
+
*
|
|
249
|
+
* Attributes classes and styles:
|
|
250
|
+
*
|
|
251
|
+
* ```ts
|
|
252
|
+
* consumables.add( { attributes: 'title', classes: 'foo', styles: 'color' } );
|
|
253
|
+
* consumables.add( { attributes: [ 'title', 'name' ], classes: [ 'foo', 'bar' ] );
|
|
254
|
+
* ```
|
|
255
|
+
*
|
|
256
|
+
* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `viewconsumable-invalid-attribute` when `class` or `style`
|
|
257
|
+
* attribute is provided - it should be handled separately by providing `style` and `class` in consumables object.
|
|
258
|
+
*
|
|
259
|
+
* @param consumables Object describing which parts of the element can be consumed.
|
|
260
|
+
* @param consumables.name If set to `true` element's name will be added as consumable.
|
|
261
|
+
* @param consumables.attributes Attribute name or array of attribute names to add as consumable.
|
|
262
|
+
* @param consumables.classes Class name or array of class names to add as consumable.
|
|
263
|
+
* @param consumables.styles Style name or array of style names to add as consumable.
|
|
264
|
+
*/
|
|
265
|
+
add(consumables: Consumables): void;
|
|
266
|
+
/**
|
|
267
|
+
* Tests if parts of the {@link module:engine/view/node~Node view node} can be consumed.
|
|
268
|
+
*
|
|
269
|
+
* Element's name can be tested:
|
|
270
|
+
*
|
|
271
|
+
* ```ts
|
|
272
|
+
* consumables.test( { name: true } );
|
|
273
|
+
* ```
|
|
274
|
+
*
|
|
275
|
+
* Attributes classes and styles:
|
|
276
|
+
*
|
|
277
|
+
* ```ts
|
|
278
|
+
* consumables.test( { attributes: 'title', classes: 'foo', styles: 'color' } );
|
|
279
|
+
* consumables.test( { attributes: [ 'title', 'name' ], classes: [ 'foo', 'bar' ] );
|
|
280
|
+
* ```
|
|
281
|
+
*
|
|
282
|
+
* @param consumables Object describing which parts of the element should be tested.
|
|
283
|
+
* @param consumables.name If set to `true` element's name will be tested.
|
|
284
|
+
* @param consumables.attributes Attribute name or array of attribute names to test.
|
|
285
|
+
* @param consumables.classes Class name or array of class names to test.
|
|
286
|
+
* @param consumables.styles Style name or array of style names to test.
|
|
287
|
+
* @returns `true` when all tested items can be consumed, `null` when even one of the items
|
|
288
|
+
* was never marked for consumption and `false` when even one of the items was already consumed.
|
|
289
|
+
*/
|
|
290
|
+
test(consumables: Consumables | Match): boolean | null;
|
|
291
|
+
/**
|
|
292
|
+
* Consumes parts of {@link module:engine/view/element~Element view element}. This function does not check if consumable item
|
|
293
|
+
* is already consumed - it consumes all consumable items provided.
|
|
294
|
+
* Element's name can be consumed:
|
|
295
|
+
*
|
|
296
|
+
* ```ts
|
|
297
|
+
* consumables.consume( { name: true } );
|
|
298
|
+
* ```
|
|
299
|
+
*
|
|
300
|
+
* Attributes classes and styles:
|
|
301
|
+
*
|
|
302
|
+
* ```ts
|
|
303
|
+
* consumables.consume( { attributes: 'title', classes: 'foo', styles: 'color' } );
|
|
304
|
+
* consumables.consume( { attributes: [ 'title', 'name' ], classes: [ 'foo', 'bar' ] );
|
|
305
|
+
* ```
|
|
306
|
+
*
|
|
307
|
+
* @param consumables Object describing which parts of the element should be consumed.
|
|
308
|
+
* @param consumables.name If set to `true` element's name will be consumed.
|
|
309
|
+
* @param consumables.attributes Attribute name or array of attribute names to consume.
|
|
310
|
+
* @param consumables.classes Class name or array of class names to consume.
|
|
311
|
+
* @param consumables.styles Style name or array of style names to consume.
|
|
312
|
+
*/
|
|
313
|
+
consume(consumables: Consumables | Match): void;
|
|
314
|
+
/**
|
|
315
|
+
* Revert already consumed parts of {@link module:engine/view/element~Element view Element}, so they can be consumed once again.
|
|
316
|
+
* Element's name can be reverted:
|
|
317
|
+
*
|
|
318
|
+
* ```ts
|
|
319
|
+
* consumables.revert( { name: true } );
|
|
320
|
+
* ```
|
|
321
|
+
*
|
|
322
|
+
* Attributes classes and styles:
|
|
323
|
+
*
|
|
324
|
+
* ```ts
|
|
325
|
+
* consumables.revert( { attributes: 'title', classes: 'foo', styles: 'color' } );
|
|
326
|
+
* consumables.revert( { attributes: [ 'title', 'name' ], classes: [ 'foo', 'bar' ] );
|
|
327
|
+
* ```
|
|
328
|
+
*
|
|
329
|
+
* @param consumables Object describing which parts of the element should be reverted.
|
|
330
|
+
* @param consumables.name If set to `true` element's name will be reverted.
|
|
331
|
+
* @param consumables.attributes Attribute name or array of attribute names to revert.
|
|
332
|
+
* @param consumables.classes Class name or array of class names to revert.
|
|
333
|
+
* @param consumables.styles Style name or array of style names to revert.
|
|
334
|
+
*/
|
|
335
|
+
revert(consumables: Consumables): void;
|
|
336
|
+
/**
|
|
337
|
+
* Helper method that adds consumables of a given type: attribute, class or style.
|
|
338
|
+
*
|
|
339
|
+
* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `viewconsumable-invalid-attribute` when `class` or `style`
|
|
340
|
+
* type is provided - it should be handled separately by providing actual style/class type.
|
|
341
|
+
*
|
|
342
|
+
* @param type Type of the consumable item: `attributes`, `classes` or `styles`.
|
|
343
|
+
* @param item Consumable item or array of items.
|
|
344
|
+
*/
|
|
345
|
+
private _add;
|
|
346
|
+
/**
|
|
347
|
+
* Helper method that tests consumables of a given type: attribute, class or style.
|
|
348
|
+
*
|
|
349
|
+
* @param type Type of the consumable item: `attributes`, `classes` or `styles`.
|
|
350
|
+
* @param item Consumable item or array of items.
|
|
351
|
+
* @returns Returns `true` if all items can be consumed, `null` when one of the items cannot be
|
|
352
|
+
* consumed and `false` when one of the items is already consumed.
|
|
353
|
+
*/
|
|
354
|
+
private _test;
|
|
355
|
+
/**
|
|
356
|
+
* Helper method that consumes items of a given type: attribute, class or style.
|
|
357
|
+
*
|
|
358
|
+
* @param type Type of the consumable item: `attributes`, `classes` or `styles`.
|
|
359
|
+
* @param item Consumable item or array of items.
|
|
360
|
+
*/
|
|
361
|
+
private _consume;
|
|
362
|
+
/**
|
|
363
|
+
* Helper method that reverts items of a given type: attribute, class or style.
|
|
364
|
+
*
|
|
365
|
+
* @param type Type of the consumable item: `attributes`, `classes` or , `styles`.
|
|
366
|
+
* @param item Consumable item or array of items.
|
|
367
|
+
*/
|
|
368
|
+
private _revert;
|
|
369
|
+
}
|
|
@@ -42,35 +42,6 @@ export default class ViewConsumable {
|
|
|
42
42
|
*/
|
|
43
43
|
this._consumables = new Map();
|
|
44
44
|
}
|
|
45
|
-
/**
|
|
46
|
-
* Adds {@link module:engine/view/element~Element view element}, {@link module:engine/view/text~Text text node} or
|
|
47
|
-
* {@link module:engine/view/documentfragment~DocumentFragment document fragment} as ready to be consumed.
|
|
48
|
-
*
|
|
49
|
-
* ```ts
|
|
50
|
-
* viewConsumable.add( p, { name: true } ); // Adds element's name to consume.
|
|
51
|
-
* viewConsumable.add( p, { attributes: 'name' } ); // Adds element's attribute.
|
|
52
|
-
* viewConsumable.add( p, { classes: 'foobar' } ); // Adds element's class.
|
|
53
|
-
* viewConsumable.add( p, { styles: 'color' } ); // Adds element's style
|
|
54
|
-
* viewConsumable.add( p, { attributes: 'name', styles: 'color' } ); // Adds attribute and style.
|
|
55
|
-
* viewConsumable.add( p, { classes: [ 'baz', 'bar' ] } ); // Multiple consumables can be provided.
|
|
56
|
-
* viewConsumable.add( textNode ); // Adds text node to consume.
|
|
57
|
-
* viewConsumable.add( docFragment ); // Adds document fragment to consume.
|
|
58
|
-
* ```
|
|
59
|
-
*
|
|
60
|
-
* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `viewconsumable-invalid-attribute` when `class` or `style`
|
|
61
|
-
* attribute is provided - it should be handled separately by providing actual style/class.
|
|
62
|
-
*
|
|
63
|
-
* ```ts
|
|
64
|
-
* viewConsumable.add( p, { attributes: 'style' } ); // This call will throw an exception.
|
|
65
|
-
* viewConsumable.add( p, { styles: 'color' } ); // This is properly handled style.
|
|
66
|
-
* ```
|
|
67
|
-
*
|
|
68
|
-
* @param consumables Used only if first parameter is {@link module:engine/view/element~Element view element} instance.
|
|
69
|
-
* @param consumables.name If set to true element's name will be included.
|
|
70
|
-
* @param consumables.attributes Attribute name or array of attribute names.
|
|
71
|
-
* @param consumables.classes Class name or array of class names.
|
|
72
|
-
* @param consumables.styles Style name or array of style names.
|
|
73
|
-
*/
|
|
74
45
|
add(element, consumables) {
|
|
75
46
|
let elementConsumables;
|
|
76
47
|
// For text nodes and document fragments just mark them as consumable.
|
|
@@ -286,7 +257,7 @@ const CONSUMABLE_TYPES = ['attributes', 'classes', 'styles'];
|
|
|
286
257
|
* This is a private helper-class for {@link module:engine/conversion/viewconsumable~ViewConsumable}.
|
|
287
258
|
* It represents and manipulates consumable parts of a single {@link module:engine/view/element~Element}.
|
|
288
259
|
*/
|
|
289
|
-
class ViewElementConsumables {
|
|
260
|
+
export class ViewElementConsumables {
|
|
290
261
|
/**
|
|
291
262
|
* Creates ViewElementConsumables instance.
|
|
292
263
|
*
|