@ckeditor/ckeditor5-engine 47.6.1 → 48.0.0-alpha.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 +1 -1
- package/{src → dist}/engineconfig.d.ts +6 -15
- package/dist/index-editor.css +38 -15
- package/dist/index.css +37 -37
- package/dist/index.css.map +1 -1
- package/{src → dist}/index.d.ts +0 -1
- package/dist/index.js +588 -94
- package/dist/index.js.map +1 -1
- package/{src → dist}/model/model.d.ts +10 -4
- package/{src → dist}/model/selection.d.ts +1 -1
- package/{src → dist}/view/downcastwriter.d.ts +3 -2
- package/{src → dist}/view/element.d.ts +2 -2
- package/{src → dist}/view/matcher.d.ts +4 -2
- package/dist/view/styles/background.d.ts +18 -0
- package/{src → dist}/view/styles/border.d.ts +0 -12
- package/{src → dist}/view/styles/margin.d.ts +0 -13
- package/{src → dist}/view/styles/padding.d.ts +0 -13
- package/{src → dist}/view/styles/utils.d.ts +12 -0
- package/package.json +20 -39
- package/src/controller/datacontroller.js +0 -522
- package/src/controller/editingcontroller.js +0 -181
- package/src/conversion/conversion.js +0 -606
- package/src/conversion/conversionhelpers.js +0 -33
- package/src/conversion/downcastdispatcher.js +0 -563
- package/src/conversion/downcasthelpers.js +0 -2160
- package/src/conversion/mapper.js +0 -1050
- package/src/conversion/modelconsumable.js +0 -331
- package/src/conversion/upcastdispatcher.js +0 -470
- package/src/conversion/upcasthelpers.js +0 -952
- package/src/conversion/viewconsumable.js +0 -541
- package/src/dataprocessor/basichtmlwriter.js +0 -22
- package/src/dataprocessor/dataprocessor.js +0 -5
- package/src/dataprocessor/htmldataprocessor.js +0 -107
- package/src/dataprocessor/htmlwriter.js +0 -5
- package/src/dataprocessor/xmldataprocessor.js +0 -127
- package/src/dev-utils/model.js +0 -396
- package/src/dev-utils/operationreplayer.js +0 -116
- package/src/dev-utils/utils.js +0 -122
- package/src/dev-utils/view.js +0 -990
- package/src/engineconfig.js +0 -5
- package/src/index.js +0 -134
- package/src/legacyerrors.js +0 -17
- package/src/model/batch.js +0 -98
- package/src/model/differ.js +0 -1288
- package/src/model/document.js +0 -398
- package/src/model/documentfragment.js +0 -332
- package/src/model/documentselection.js +0 -1026
- package/src/model/element.js +0 -323
- package/src/model/history.js +0 -206
- package/src/model/item.js +0 -5
- package/src/model/liveposition.js +0 -93
- package/src/model/liverange.js +0 -121
- package/src/model/markercollection.js +0 -436
- package/src/model/model.js +0 -866
- package/src/model/node.js +0 -371
- package/src/model/nodelist.js +0 -244
- package/src/model/operation/attributeoperation.js +0 -172
- package/src/model/operation/detachoperation.js +0 -87
- package/src/model/operation/insertoperation.js +0 -153
- package/src/model/operation/markeroperation.js +0 -136
- package/src/model/operation/mergeoperation.js +0 -184
- package/src/model/operation/moveoperation.js +0 -179
- package/src/model/operation/nooperation.js +0 -48
- package/src/model/operation/operation.js +0 -78
- package/src/model/operation/operationfactory.js +0 -44
- package/src/model/operation/renameoperation.js +0 -128
- package/src/model/operation/rootattributeoperation.js +0 -173
- package/src/model/operation/rootoperation.js +0 -106
- package/src/model/operation/splitoperation.js +0 -214
- package/src/model/operation/transform.js +0 -2211
- package/src/model/operation/utils.js +0 -217
- package/src/model/position.js +0 -1041
- package/src/model/range.js +0 -880
- package/src/model/rootelement.js +0 -82
- package/src/model/schema.js +0 -1542
- package/src/model/selection.js +0 -814
- package/src/model/text.js +0 -92
- package/src/model/textproxy.js +0 -202
- package/src/model/treewalker.js +0 -313
- package/src/model/typecheckable.js +0 -16
- package/src/model/utils/autoparagraphing.js +0 -63
- package/src/model/utils/deletecontent.js +0 -509
- package/src/model/utils/getselectedcontent.js +0 -126
- package/src/model/utils/insertcontent.js +0 -750
- package/src/model/utils/insertobject.js +0 -135
- package/src/model/utils/modifyselection.js +0 -187
- package/src/model/utils/selection-post-fixer.js +0 -264
- package/src/model/writer.js +0 -1318
- package/src/view/attributeelement.js +0 -220
- package/src/view/containerelement.js +0 -91
- package/src/view/datatransfer.js +0 -106
- package/src/view/document.js +0 -139
- package/src/view/documentfragment.js +0 -251
- package/src/view/documentselection.js +0 -270
- package/src/view/domconverter.js +0 -1661
- package/src/view/downcastwriter.js +0 -1589
- package/src/view/editableelement.js +0 -74
- package/src/view/element.js +0 -1053
- package/src/view/elementdefinition.js +0 -5
- package/src/view/emptyelement.js +0 -83
- package/src/view/filler.js +0 -161
- package/src/view/item.js +0 -5
- package/src/view/matcher.js +0 -437
- package/src/view/node.js +0 -238
- package/src/view/observer/arrowkeysobserver.js +0 -40
- package/src/view/observer/bubblingemittermixin.js +0 -215
- package/src/view/observer/bubblingeventinfo.js +0 -49
- package/src/view/observer/clickobserver.js +0 -26
- package/src/view/observer/compositionobserver.js +0 -64
- package/src/view/observer/domeventdata.js +0 -63
- package/src/view/observer/domeventobserver.js +0 -81
- package/src/view/observer/fakeselectionobserver.js +0 -95
- package/src/view/observer/focusobserver.js +0 -166
- package/src/view/observer/inputobserver.js +0 -236
- package/src/view/observer/keyobserver.js +0 -36
- package/src/view/observer/mouseobserver.js +0 -26
- package/src/view/observer/mutationobserver.js +0 -219
- package/src/view/observer/observer.js +0 -92
- package/src/view/observer/pointerobserver.js +0 -26
- package/src/view/observer/selectionobserver.js +0 -318
- package/src/view/observer/tabobserver.js +0 -42
- package/src/view/observer/touchobserver.js +0 -26
- package/src/view/placeholder.js +0 -285
- package/src/view/position.js +0 -341
- package/src/view/range.js +0 -451
- package/src/view/rawelement.js +0 -115
- package/src/view/renderer.js +0 -1148
- package/src/view/rooteditableelement.js +0 -78
- package/src/view/selection.js +0 -594
- package/src/view/styles/background.d.ts +0 -33
- package/src/view/styles/background.js +0 -74
- package/src/view/styles/border.js +0 -316
- package/src/view/styles/margin.js +0 -34
- package/src/view/styles/padding.js +0 -34
- package/src/view/styles/utils.js +0 -219
- package/src/view/stylesmap.js +0 -941
- package/src/view/text.js +0 -110
- package/src/view/textproxy.js +0 -136
- package/src/view/tokenlist.js +0 -194
- package/src/view/treewalker.js +0 -389
- package/src/view/typecheckable.js +0 -19
- package/src/view/uielement.js +0 -194
- package/src/view/upcastwriter.js +0 -363
- package/src/view/view.js +0 -579
- package/theme/placeholder.css +0 -36
- package/theme/renderer.css +0 -9
- /package/{src → dist}/controller/datacontroller.d.ts +0 -0
- /package/{src → dist}/controller/editingcontroller.d.ts +0 -0
- /package/{src → dist}/conversion/conversion.d.ts +0 -0
- /package/{src → dist}/conversion/conversionhelpers.d.ts +0 -0
- /package/{src → dist}/conversion/downcastdispatcher.d.ts +0 -0
- /package/{src → dist}/conversion/downcasthelpers.d.ts +0 -0
- /package/{src → dist}/conversion/mapper.d.ts +0 -0
- /package/{src → dist}/conversion/modelconsumable.d.ts +0 -0
- /package/{src → dist}/conversion/upcastdispatcher.d.ts +0 -0
- /package/{src → dist}/conversion/upcasthelpers.d.ts +0 -0
- /package/{src → dist}/conversion/viewconsumable.d.ts +0 -0
- /package/{src → dist}/dataprocessor/basichtmlwriter.d.ts +0 -0
- /package/{src → dist}/dataprocessor/dataprocessor.d.ts +0 -0
- /package/{src → dist}/dataprocessor/htmldataprocessor.d.ts +0 -0
- /package/{src → dist}/dataprocessor/htmlwriter.d.ts +0 -0
- /package/{src → dist}/dataprocessor/xmldataprocessor.d.ts +0 -0
- /package/{src → dist}/dev-utils/model.d.ts +0 -0
- /package/{src → dist}/dev-utils/operationreplayer.d.ts +0 -0
- /package/{src → dist}/dev-utils/utils.d.ts +0 -0
- /package/{src → dist}/dev-utils/view.d.ts +0 -0
- /package/{src → dist}/legacyerrors.d.ts +0 -0
- /package/{src → dist}/model/batch.d.ts +0 -0
- /package/{src → dist}/model/differ.d.ts +0 -0
- /package/{src → dist}/model/document.d.ts +0 -0
- /package/{src → dist}/model/documentfragment.d.ts +0 -0
- /package/{src → dist}/model/documentselection.d.ts +0 -0
- /package/{src → dist}/model/element.d.ts +0 -0
- /package/{src → dist}/model/history.d.ts +0 -0
- /package/{src → dist}/model/item.d.ts +0 -0
- /package/{src → dist}/model/liveposition.d.ts +0 -0
- /package/{src → dist}/model/liverange.d.ts +0 -0
- /package/{src → dist}/model/markercollection.d.ts +0 -0
- /package/{src → dist}/model/node.d.ts +0 -0
- /package/{src → dist}/model/nodelist.d.ts +0 -0
- /package/{src → dist}/model/operation/attributeoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/detachoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/insertoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/markeroperation.d.ts +0 -0
- /package/{src → dist}/model/operation/mergeoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/moveoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/nooperation.d.ts +0 -0
- /package/{src → dist}/model/operation/operation.d.ts +0 -0
- /package/{src → dist}/model/operation/operationfactory.d.ts +0 -0
- /package/{src → dist}/model/operation/renameoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/rootattributeoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/rootoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/splitoperation.d.ts +0 -0
- /package/{src → dist}/model/operation/transform.d.ts +0 -0
- /package/{src → dist}/model/operation/utils.d.ts +0 -0
- /package/{src → dist}/model/position.d.ts +0 -0
- /package/{src → dist}/model/range.d.ts +0 -0
- /package/{src → dist}/model/rootelement.d.ts +0 -0
- /package/{src → dist}/model/schema.d.ts +0 -0
- /package/{src → dist}/model/text.d.ts +0 -0
- /package/{src → dist}/model/textproxy.d.ts +0 -0
- /package/{src → dist}/model/treewalker.d.ts +0 -0
- /package/{src → dist}/model/typecheckable.d.ts +0 -0
- /package/{src → dist}/model/utils/autoparagraphing.d.ts +0 -0
- /package/{src → dist}/model/utils/deletecontent.d.ts +0 -0
- /package/{src → dist}/model/utils/getselectedcontent.d.ts +0 -0
- /package/{src → dist}/model/utils/insertcontent.d.ts +0 -0
- /package/{src → dist}/model/utils/insertobject.d.ts +0 -0
- /package/{src → dist}/model/utils/modifyselection.d.ts +0 -0
- /package/{src → dist}/model/utils/selection-post-fixer.d.ts +0 -0
- /package/{src → dist}/model/writer.d.ts +0 -0
- /package/{src → dist}/view/attributeelement.d.ts +0 -0
- /package/{src → dist}/view/containerelement.d.ts +0 -0
- /package/{src → dist}/view/datatransfer.d.ts +0 -0
- /package/{src → dist}/view/document.d.ts +0 -0
- /package/{src → dist}/view/documentfragment.d.ts +0 -0
- /package/{src → dist}/view/documentselection.d.ts +0 -0
- /package/{src → dist}/view/domconverter.d.ts +0 -0
- /package/{src → dist}/view/editableelement.d.ts +0 -0
- /package/{src → dist}/view/elementdefinition.d.ts +0 -0
- /package/{src → dist}/view/emptyelement.d.ts +0 -0
- /package/{src → dist}/view/filler.d.ts +0 -0
- /package/{src → dist}/view/item.d.ts +0 -0
- /package/{src → dist}/view/node.d.ts +0 -0
- /package/{src → dist}/view/observer/arrowkeysobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/bubblingemittermixin.d.ts +0 -0
- /package/{src → dist}/view/observer/bubblingeventinfo.d.ts +0 -0
- /package/{src → dist}/view/observer/clickobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/compositionobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/domeventdata.d.ts +0 -0
- /package/{src → dist}/view/observer/domeventobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/fakeselectionobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/focusobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/inputobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/keyobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/mouseobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/mutationobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/observer.d.ts +0 -0
- /package/{src → dist}/view/observer/pointerobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/selectionobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/tabobserver.d.ts +0 -0
- /package/{src → dist}/view/observer/touchobserver.d.ts +0 -0
- /package/{src → dist}/view/placeholder.d.ts +0 -0
- /package/{src → dist}/view/position.d.ts +0 -0
- /package/{src → dist}/view/range.d.ts +0 -0
- /package/{src → dist}/view/rawelement.d.ts +0 -0
- /package/{src → dist}/view/renderer.d.ts +0 -0
- /package/{src → dist}/view/rooteditableelement.d.ts +0 -0
- /package/{src → dist}/view/selection.d.ts +0 -0
- /package/{src → dist}/view/stylesmap.d.ts +0 -0
- /package/{src → dist}/view/text.d.ts +0 -0
- /package/{src → dist}/view/textproxy.d.ts +0 -0
- /package/{src → dist}/view/tokenlist.d.ts +0 -0
- /package/{src → dist}/view/treewalker.d.ts +0 -0
- /package/{src → dist}/view/typecheckable.d.ts +0 -0
- /package/{src → dist}/view/uielement.d.ts +0 -0
- /package/{src → dist}/view/upcastwriter.d.ts +0 -0
- /package/{src → dist}/view/view.d.ts +0 -0
package/src/view/text.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module engine/view/text
|
|
7
|
-
*/
|
|
8
|
-
import { ViewNode } from './node.js';
|
|
9
|
-
/**
|
|
10
|
-
* Tree view text node.
|
|
11
|
-
*
|
|
12
|
-
* The constructor of this class should not be used directly. To create a new text node instance
|
|
13
|
-
* use the {@link module:engine/view/downcastwriter~ViewDowncastWriter#createText `ViewDowncastWriter#createText()`}
|
|
14
|
-
* method when working on data downcasted from the model or the
|
|
15
|
-
* {@link module:engine/view/upcastwriter~ViewUpcastWriter#createText `ViewUpcastWriter#createText()`}
|
|
16
|
-
* method when working on non-semantic views.
|
|
17
|
-
*/
|
|
18
|
-
export class ViewText extends ViewNode {
|
|
19
|
-
/**
|
|
20
|
-
* The text content.
|
|
21
|
-
*
|
|
22
|
-
* Setting the data fires the {@link module:engine/view/node~ViewNode#event:change:text change event}.
|
|
23
|
-
*/
|
|
24
|
-
_textData;
|
|
25
|
-
/**
|
|
26
|
-
* Creates a tree view text node.
|
|
27
|
-
*
|
|
28
|
-
* @see module:engine/view/downcastwriter~ViewDowncastWriter#createText
|
|
29
|
-
* @internal
|
|
30
|
-
* @param document The document instance to which this text node belongs.
|
|
31
|
-
* @param data The text's data.
|
|
32
|
-
*/
|
|
33
|
-
constructor(document, data) {
|
|
34
|
-
super(document);
|
|
35
|
-
this._textData = data;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* The text content.
|
|
39
|
-
*/
|
|
40
|
-
get data() {
|
|
41
|
-
return this._textData;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* The `_data` property is controlled by a getter and a setter.
|
|
45
|
-
*
|
|
46
|
-
* The getter is required when using the addition assignment operator on protected property:
|
|
47
|
-
*
|
|
48
|
-
* ```ts
|
|
49
|
-
* const foo = downcastWriter.createText( 'foo' );
|
|
50
|
-
* const bar = downcastWriter.createText( 'bar' );
|
|
51
|
-
*
|
|
52
|
-
* foo._data += bar.data; // executes: `foo._data = foo._data + bar.data`
|
|
53
|
-
* console.log( foo.data ); // prints: 'foobar'
|
|
54
|
-
* ```
|
|
55
|
-
*
|
|
56
|
-
* If the protected getter didn't exist, `foo._data` will return `undefined` and result of the merge will be invalid.
|
|
57
|
-
*
|
|
58
|
-
* The setter sets data and fires the {@link module:engine/view/node~ViewNode#event:change:text change event}.
|
|
59
|
-
*
|
|
60
|
-
* @internal
|
|
61
|
-
*/
|
|
62
|
-
get _data() {
|
|
63
|
-
return this.data;
|
|
64
|
-
}
|
|
65
|
-
set _data(data) {
|
|
66
|
-
this._fireChange('text', this);
|
|
67
|
-
this._textData = data;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Checks if this text node is similar to other text node.
|
|
71
|
-
* Both nodes should have the same data to be considered as similar.
|
|
72
|
-
*
|
|
73
|
-
* @param otherNode Node to check if it is same as this node.
|
|
74
|
-
*/
|
|
75
|
-
isSimilar(otherNode) {
|
|
76
|
-
if (!(otherNode instanceof ViewText)) {
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
return this === otherNode || this.data === otherNode.data;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Converts `ViewText` instance to plain object and returns it.
|
|
83
|
-
*
|
|
84
|
-
* @returns `ViewText` instance converted to plain object.
|
|
85
|
-
*/
|
|
86
|
-
toJSON() {
|
|
87
|
-
const json = super.toJSON();
|
|
88
|
-
json.type = 'Text';
|
|
89
|
-
json.data = this.data;
|
|
90
|
-
return json;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Clones this node.
|
|
94
|
-
*
|
|
95
|
-
* @internal
|
|
96
|
-
* @returns Text node that is a clone of this node.
|
|
97
|
-
*/
|
|
98
|
-
_clone() {
|
|
99
|
-
return new ViewText(this.document, this.data);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
// The magic of type inference using `is` method is centralized in `TypeCheckable` class.
|
|
103
|
-
// Proper overload would interfere with that.
|
|
104
|
-
ViewText.prototype.is = function (type) {
|
|
105
|
-
return type === '$text' || type === 'view:$text' ||
|
|
106
|
-
// This are legacy values kept for backward compatibility.
|
|
107
|
-
type === 'text' || type === 'view:text' ||
|
|
108
|
-
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
|
|
109
|
-
type === 'node' || type === 'view:node';
|
|
110
|
-
};
|
package/src/view/textproxy.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module engine/view/textproxy
|
|
7
|
-
*/
|
|
8
|
-
import { ViewTypeCheckable } from './typecheckable.js';
|
|
9
|
-
import { CKEditorError } from '@ckeditor/ckeditor5-utils';
|
|
10
|
-
/**
|
|
11
|
-
* ViewTextProxy is a wrapper for substring of {@link module:engine/view/text~ViewText}. Instance of this class is created by
|
|
12
|
-
* {@link module:engine/view/treewalker~ViewTreeWalker} when only a part of {@link module:engine/view/text~ViewText} needs to be returned.
|
|
13
|
-
*
|
|
14
|
-
* `ViewTextProxy` has an API similar to {@link module:engine/view/text~ViewText Text} and allows to do most of the common tasks performed
|
|
15
|
-
* on view nodes.
|
|
16
|
-
*
|
|
17
|
-
* **Note:** Some `ViewTextProxy` instances may represent whole text node, not just a part of it.
|
|
18
|
-
* See {@link module:engine/view/textproxy~ViewTextProxy#isPartial}.
|
|
19
|
-
*
|
|
20
|
-
* **Note:** `ViewTextProxy` is a readonly interface.
|
|
21
|
-
*
|
|
22
|
-
* **Note:** `ViewTextProxy` instances are created on the fly basing
|
|
23
|
-
* on the current state of parent {@link module:engine/view/text~ViewText}.
|
|
24
|
-
* Because of this it is highly unrecommended to store references to `TextProxy instances because they might get
|
|
25
|
-
* invalidated due to operations on Document. Also ViewTextProxy is not a {@link module:engine/view/node~ViewNode} so it cannot be
|
|
26
|
-
* inserted as a child of {@link module:engine/view/element~ViewElement}.
|
|
27
|
-
*
|
|
28
|
-
* `ViewTextProxy` instances are created by {@link module:engine/view/treewalker~ViewTreeWalker view tree walker}.
|
|
29
|
-
* You should not need to create an instance of this class by your own.
|
|
30
|
-
*/
|
|
31
|
-
export class ViewTextProxy extends ViewTypeCheckable {
|
|
32
|
-
/**
|
|
33
|
-
* Reference to the {@link module:engine/view/text~ViewText} element which ViewTextProxy is a substring.
|
|
34
|
-
*/
|
|
35
|
-
textNode;
|
|
36
|
-
/**
|
|
37
|
-
* Text data represented by this text proxy.
|
|
38
|
-
*/
|
|
39
|
-
data;
|
|
40
|
-
/**
|
|
41
|
-
* Offset in the `textNode` where this `ViewTextProxy` instance starts.
|
|
42
|
-
*/
|
|
43
|
-
offsetInText;
|
|
44
|
-
/**
|
|
45
|
-
* Creates a text proxy.
|
|
46
|
-
*
|
|
47
|
-
* @internal
|
|
48
|
-
* @param textNode Text node which part is represented by this text proxy.
|
|
49
|
-
* @param offsetInText Offset in {@link module:engine/view/textproxy~ViewTextProxy#textNode text node}
|
|
50
|
-
* from which the text proxy starts.
|
|
51
|
-
* @param length Text proxy length, that is how many text node's characters, starting from `offsetInText` it represents.
|
|
52
|
-
*/
|
|
53
|
-
constructor(textNode, offsetInText, length) {
|
|
54
|
-
super();
|
|
55
|
-
this.textNode = textNode;
|
|
56
|
-
if (offsetInText < 0 || offsetInText > textNode.data.length) {
|
|
57
|
-
/**
|
|
58
|
-
* Given offsetInText value is incorrect.
|
|
59
|
-
*
|
|
60
|
-
* @error view-textproxy-wrong-offsetintext
|
|
61
|
-
*/
|
|
62
|
-
throw new CKEditorError('view-textproxy-wrong-offsetintext', this);
|
|
63
|
-
}
|
|
64
|
-
if (length < 0 || offsetInText + length > textNode.data.length) {
|
|
65
|
-
/**
|
|
66
|
-
* Given length value is incorrect.
|
|
67
|
-
*
|
|
68
|
-
* @error view-textproxy-wrong-length
|
|
69
|
-
*/
|
|
70
|
-
throw new CKEditorError('view-textproxy-wrong-length', this);
|
|
71
|
-
}
|
|
72
|
-
this.data = textNode.data.substring(offsetInText, offsetInText + length);
|
|
73
|
-
this.offsetInText = offsetInText;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Offset size of this node.
|
|
77
|
-
*/
|
|
78
|
-
get offsetSize() {
|
|
79
|
-
return this.data.length;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Flag indicating whether `ViewTextProxy` instance covers only part of the original {@link module:engine/view/text~ViewText text node}
|
|
83
|
-
* (`true`) or the whole text node (`false`).
|
|
84
|
-
*
|
|
85
|
-
* This is `false` when text proxy starts at the very beginning of {@link module:engine/view/textproxy~ViewTextProxy#textNode textNode}
|
|
86
|
-
* ({@link module:engine/view/textproxy~ViewTextProxy#offsetInText offsetInText} equals `0`) and text proxy sizes is equal to
|
|
87
|
-
* text node size.
|
|
88
|
-
*/
|
|
89
|
-
get isPartial() {
|
|
90
|
-
return this.data.length !== this.textNode.data.length;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Parent of this text proxy, which is same as parent of text node represented by this text proxy.
|
|
94
|
-
*/
|
|
95
|
-
get parent() {
|
|
96
|
-
return this.textNode.parent;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Root of this text proxy, which is same as root of text node represented by this text proxy.
|
|
100
|
-
*/
|
|
101
|
-
get root() {
|
|
102
|
-
return this.textNode.root;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* {@link module:engine/view/document~ViewDocument View document} that owns this text proxy, or `null` if the text proxy is inside
|
|
106
|
-
* {@link module:engine/view/documentfragment~ViewDocumentFragment document fragment}.
|
|
107
|
-
*/
|
|
108
|
-
get document() {
|
|
109
|
-
return this.textNode.document;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Returns ancestors array of this text proxy.
|
|
113
|
-
*
|
|
114
|
-
* @param options Options object.
|
|
115
|
-
* @param options.includeSelf When set to `true`, textNode will be also included in parent's array.
|
|
116
|
-
* @param options.parentFirst When set to `true`, array will be sorted from text proxy parent to
|
|
117
|
-
* root element, otherwise root element will be the first item in the array.
|
|
118
|
-
* @returns Array with ancestors.
|
|
119
|
-
*/
|
|
120
|
-
getAncestors(options = {}) {
|
|
121
|
-
const ancestors = [];
|
|
122
|
-
let parent = options.includeSelf ? this.textNode : this.parent;
|
|
123
|
-
while (parent !== null) {
|
|
124
|
-
ancestors[options.parentFirst ? 'push' : 'unshift'](parent);
|
|
125
|
-
parent = parent.parent;
|
|
126
|
-
}
|
|
127
|
-
return ancestors;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
// The magic of type inference using `is` method is centralized in `TypeCheckable` class.
|
|
131
|
-
// Proper overload would interfere with that.
|
|
132
|
-
ViewTextProxy.prototype.is = function (type) {
|
|
133
|
-
return type === '$textProxy' || type === 'view:$textProxy' ||
|
|
134
|
-
// This are legacy values kept for backward compatibility.
|
|
135
|
-
type === 'textProxy' || type === 'view:textProxy';
|
|
136
|
-
};
|
package/src/view/tokenlist.js
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module engine/view/tokenlist
|
|
7
|
-
*/
|
|
8
|
-
import { toArray } from '@ckeditor/ckeditor5-utils';
|
|
9
|
-
/**
|
|
10
|
-
* Token list. Allows handling (adding, removing, retrieving) a set of tokens (for example class names).
|
|
11
|
-
*/
|
|
12
|
-
export class ViewTokenList {
|
|
13
|
-
/**
|
|
14
|
-
* The set of tokens.
|
|
15
|
-
*/
|
|
16
|
-
_set = new Set();
|
|
17
|
-
/**
|
|
18
|
-
* Returns true if token list has no tokens set.
|
|
19
|
-
*/
|
|
20
|
-
get isEmpty() {
|
|
21
|
-
return this._set.size == 0;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Number of tokens.
|
|
25
|
-
*/
|
|
26
|
-
get size() {
|
|
27
|
-
return this._set.size;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Checks if a given token is set.
|
|
31
|
-
*/
|
|
32
|
-
has(name) {
|
|
33
|
-
return this._set.has(name);
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Returns all tokens.
|
|
37
|
-
*/
|
|
38
|
-
keys() {
|
|
39
|
-
return Array.from(this._set.keys());
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Resets the value to the given one.
|
|
43
|
-
*/
|
|
44
|
-
setTo(value) {
|
|
45
|
-
this.clear();
|
|
46
|
-
for (const token of value.split(/\s+/)) {
|
|
47
|
-
if (token) {
|
|
48
|
-
this._set.add(token);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return this;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Sets a given token without affecting other tokens.
|
|
55
|
-
*/
|
|
56
|
-
set(tokens) {
|
|
57
|
-
for (const token of toArray(tokens)) {
|
|
58
|
-
if (token) {
|
|
59
|
-
this._set.add(token);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Removes given token.
|
|
65
|
-
*/
|
|
66
|
-
remove(tokens) {
|
|
67
|
-
for (const token of toArray(tokens)) {
|
|
68
|
-
this._set.delete(token);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Removes all tokens.
|
|
73
|
-
*/
|
|
74
|
-
clear() {
|
|
75
|
-
this._set.clear();
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Returns a normalized tokens string.
|
|
79
|
-
*/
|
|
80
|
-
toString() {
|
|
81
|
-
return Array.from(this._set).join(' ');
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Returns `true` if both attributes have the same tokens.
|
|
85
|
-
*/
|
|
86
|
-
isSimilar(other) {
|
|
87
|
-
if (this.size !== other.size) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
for (const token of this.keys()) {
|
|
91
|
-
if (!other.has(token)) {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Clones the attribute value.
|
|
99
|
-
*
|
|
100
|
-
* @internal
|
|
101
|
-
*/
|
|
102
|
-
_clone() {
|
|
103
|
-
const clone = new this.constructor();
|
|
104
|
-
clone._set = new Set(this._set);
|
|
105
|
-
return clone;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Used by the {@link module:engine/view/matcher~Matcher Matcher} to collect matching attribute tokens.
|
|
109
|
-
*
|
|
110
|
-
* @internal
|
|
111
|
-
* @param tokenPattern The matched token name pattern.
|
|
112
|
-
* @returns An array of matching tokens.
|
|
113
|
-
*/
|
|
114
|
-
_getTokensMatch(tokenPattern) {
|
|
115
|
-
const match = [];
|
|
116
|
-
if (tokenPattern === true) {
|
|
117
|
-
for (const token of this._set.keys()) {
|
|
118
|
-
match.push(token);
|
|
119
|
-
}
|
|
120
|
-
return match;
|
|
121
|
-
}
|
|
122
|
-
if (typeof tokenPattern == 'string') {
|
|
123
|
-
for (const token of tokenPattern.split(/\s+/)) {
|
|
124
|
-
if (this._set.has(token)) {
|
|
125
|
-
match.push(token);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
return undefined;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return match;
|
|
132
|
-
}
|
|
133
|
-
for (const token of this._set.keys()) {
|
|
134
|
-
if (token.match(tokenPattern)) {
|
|
135
|
-
match.push(token);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return match.length ? match : undefined;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Returns a list of consumables for the attribute.
|
|
142
|
-
*
|
|
143
|
-
* Could be filtered by the given token name.
|
|
144
|
-
*
|
|
145
|
-
* @internal
|
|
146
|
-
*/
|
|
147
|
-
_getConsumables(name) {
|
|
148
|
-
return name ? [name] : this.keys();
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Used by {@link module:engine/view/element~ViewElement#_canMergeAttributesFrom} to verify if the given attribute
|
|
152
|
-
* can be merged without conflicts into the attribute.
|
|
153
|
-
*
|
|
154
|
-
* This method is indirectly used by the {@link module:engine/view/downcastwriter~ViewDowncastWriter} while downcasting
|
|
155
|
-
* an {@link module:engine/view/attributeelement~ViewAttributeElement} to merge it with other `AttributeElement`.
|
|
156
|
-
*
|
|
157
|
-
* @internal
|
|
158
|
-
*/
|
|
159
|
-
_canMergeFrom() {
|
|
160
|
-
return true;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Used by {@link module:engine/view/element~ViewElement#_mergeAttributesFrom} to merge a given attribute into the attribute.
|
|
164
|
-
*
|
|
165
|
-
* This method is indirectly used by the {@link module:engine/view/downcastwriter~ViewDowncastWriter} while down-casting
|
|
166
|
-
* an {@link module:engine/view/attributeelement~ViewAttributeElement} to merge it with other ViewAttributeElement.
|
|
167
|
-
*
|
|
168
|
-
* @internal
|
|
169
|
-
*/
|
|
170
|
-
_mergeFrom(other) {
|
|
171
|
-
for (const token of other._set.keys()) {
|
|
172
|
-
if (!this._set.has(token)) {
|
|
173
|
-
this._set.add(token);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Used by {@link module:engine/view/element~ViewElement#_canSubtractAttributesOf} to verify if the given attribute
|
|
179
|
-
* can be fully subtracted from the attribute.
|
|
180
|
-
*
|
|
181
|
-
* This method is indirectly used by the {@link module:engine/view/downcastwriter~ViewDowncastWriter} while down-casting
|
|
182
|
-
* an {@link module:engine/view/attributeelement~ViewAttributeElement} to unwrap the ViewAttributeElement.
|
|
183
|
-
*
|
|
184
|
-
* @internal
|
|
185
|
-
*/
|
|
186
|
-
_isMatching(other) {
|
|
187
|
-
for (const name of other._set.keys()) {
|
|
188
|
-
if (!this._set.has(name)) {
|
|
189
|
-
return false;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return true;
|
|
193
|
-
}
|
|
194
|
-
}
|