@ckeditor/ckeditor5-engine 35.0.1 → 35.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -4
- package/package.json +30 -24
- package/src/controller/datacontroller.js +467 -561
- package/src/controller/editingcontroller.js +168 -204
- package/src/conversion/conversion.js +541 -565
- package/src/conversion/conversionhelpers.js +24 -28
- package/src/conversion/downcastdispatcher.js +457 -686
- package/src/conversion/downcasthelpers.js +1583 -1965
- package/src/conversion/mapper.js +518 -707
- package/src/conversion/modelconsumable.js +240 -283
- package/src/conversion/upcastdispatcher.js +372 -718
- package/src/conversion/upcasthelpers.js +707 -818
- package/src/conversion/viewconsumable.js +524 -581
- package/src/dataprocessor/basichtmlwriter.js +12 -16
- package/src/dataprocessor/dataprocessor.js +5 -0
- package/src/dataprocessor/htmldataprocessor.js +100 -116
- package/src/dataprocessor/htmlwriter.js +1 -18
- package/src/dataprocessor/xmldataprocessor.js +116 -137
- package/src/dev-utils/model.js +260 -352
- package/src/dev-utils/operationreplayer.js +106 -126
- package/src/dev-utils/utils.js +34 -51
- package/src/dev-utils/view.js +632 -753
- package/src/index.js +0 -11
- package/src/model/batch.js +111 -127
- package/src/model/differ.js +988 -1233
- package/src/model/document.js +340 -449
- package/src/model/documentfragment.js +327 -364
- package/src/model/documentselection.js +996 -1189
- package/src/model/element.js +306 -410
- package/src/model/history.js +224 -262
- package/src/model/item.js +5 -0
- package/src/model/liveposition.js +84 -145
- package/src/model/liverange.js +108 -185
- package/src/model/markercollection.js +379 -480
- package/src/model/model.js +883 -1034
- package/src/model/node.js +419 -463
- package/src/model/nodelist.js +175 -201
- package/src/model/operation/attributeoperation.js +153 -182
- package/src/model/operation/detachoperation.js +64 -83
- package/src/model/operation/insertoperation.js +135 -166
- package/src/model/operation/markeroperation.js +114 -140
- package/src/model/operation/mergeoperation.js +163 -191
- package/src/model/operation/moveoperation.js +157 -187
- package/src/model/operation/nooperation.js +28 -38
- package/src/model/operation/operation.js +106 -125
- package/src/model/operation/operationfactory.js +30 -34
- package/src/model/operation/renameoperation.js +109 -135
- package/src/model/operation/rootattributeoperation.js +155 -188
- package/src/model/operation/splitoperation.js +196 -232
- package/src/model/operation/transform.js +1833 -2204
- package/src/model/operation/utils.js +140 -204
- package/src/model/position.js +899 -1053
- package/src/model/range.js +910 -1028
- package/src/model/rootelement.js +77 -97
- package/src/model/schema.js +1189 -1835
- package/src/model/selection.js +745 -862
- package/src/model/text.js +90 -114
- package/src/model/textproxy.js +204 -240
- package/src/model/treewalker.js +316 -397
- package/src/model/typecheckable.js +16 -0
- package/src/model/utils/autoparagraphing.js +32 -44
- package/src/model/utils/deletecontent.js +334 -418
- package/src/model/utils/findoptimalinsertionrange.js +25 -36
- package/src/model/utils/getselectedcontent.js +96 -118
- package/src/model/utils/insertcontent.js +654 -773
- package/src/model/utils/insertobject.js +96 -119
- package/src/model/utils/modifyselection.js +120 -158
- package/src/model/utils/selection-post-fixer.js +153 -201
- package/src/model/writer.js +1305 -1474
- package/src/view/attributeelement.js +189 -225
- package/src/view/containerelement.js +75 -85
- package/src/view/document.js +172 -215
- package/src/view/documentfragment.js +200 -249
- package/src/view/documentselection.js +338 -367
- package/src/view/domconverter.js +1370 -1617
- package/src/view/downcastwriter.js +1747 -2076
- package/src/view/editableelement.js +81 -97
- package/src/view/element.js +739 -890
- package/src/view/elementdefinition.js +5 -0
- package/src/view/emptyelement.js +82 -92
- package/src/view/filler.js +35 -50
- package/src/view/item.js +5 -0
- package/src/view/matcher.js +260 -559
- package/src/view/node.js +274 -360
- package/src/view/observer/arrowkeysobserver.js +19 -28
- package/src/view/observer/bubblingemittermixin.js +120 -263
- package/src/view/observer/bubblingeventinfo.js +47 -55
- package/src/view/observer/clickobserver.js +7 -13
- package/src/view/observer/compositionobserver.js +14 -24
- package/src/view/observer/domeventdata.js +57 -67
- package/src/view/observer/domeventobserver.js +40 -64
- package/src/view/observer/fakeselectionobserver.js +81 -96
- package/src/view/observer/focusobserver.js +45 -61
- package/src/view/observer/inputobserver.js +7 -13
- package/src/view/observer/keyobserver.js +17 -27
- package/src/view/observer/mouseobserver.js +7 -14
- package/src/view/observer/mutationobserver.js +220 -315
- package/src/view/observer/observer.js +81 -102
- package/src/view/observer/selectionobserver.js +191 -246
- package/src/view/observer/tabobserver.js +23 -36
- package/src/view/placeholder.js +128 -173
- package/src/view/position.js +350 -401
- package/src/view/range.js +453 -513
- package/src/view/rawelement.js +85 -112
- package/src/view/renderer.js +874 -1018
- package/src/view/rooteditableelement.js +80 -90
- package/src/view/selection.js +608 -689
- package/src/view/styles/background.js +43 -44
- package/src/view/styles/border.js +220 -276
- package/src/view/styles/margin.js +8 -17
- package/src/view/styles/padding.js +8 -16
- package/src/view/styles/utils.js +127 -160
- package/src/view/stylesmap.js +728 -905
- package/src/view/text.js +102 -126
- package/src/view/textproxy.js +144 -170
- package/src/view/treewalker.js +383 -479
- package/src/view/typecheckable.js +19 -0
- package/src/view/uielement.js +166 -187
- package/src/view/upcastwriter.js +395 -449
- package/src/view/view.js +569 -664
- package/src/dataprocessor/dataprocessor.jsdoc +0 -64
- package/src/model/item.jsdoc +0 -14
- package/src/view/elementdefinition.jsdoc +0 -59
- package/src/view/item.jsdoc +0 -14
package/src/view/rawelement.js
CHANGED
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
/**
|
|
7
6
|
* @module engine/view/rawelement
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
8
|
import Element from './element';
|
|
11
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
12
9
|
import Node from './node';
|
|
13
|
-
|
|
10
|
+
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
14
11
|
/**
|
|
15
12
|
* The raw element class.
|
|
16
13
|
*
|
|
@@ -30,117 +27,93 @@ import Node from './node';
|
|
|
30
27
|
* @extends module:engine/view/element~Element
|
|
31
28
|
*/
|
|
32
29
|
export default class RawElement extends Element {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
* rawElement.is( 'rawElement', 'img' ); // -> same as above
|
|
77
|
-
* text.is( 'img' ); -> false
|
|
78
|
-
*
|
|
79
|
-
* {@link module:engine/view/node~Node#is Check the entire list of view objects} which implement the `is()` method.
|
|
80
|
-
*
|
|
81
|
-
* @param {String} type The type to check when the `name` parameter is present.
|
|
82
|
-
* Otherwise, it acts like the `name` parameter.
|
|
83
|
-
* @param {String} [name] The element name.
|
|
84
|
-
* @returns {Boolean}
|
|
85
|
-
*/
|
|
86
|
-
is( type, name = null ) {
|
|
87
|
-
if ( !name ) {
|
|
88
|
-
return type === 'rawElement' || type === 'view:rawElement' ||
|
|
89
|
-
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
|
|
90
|
-
type === this.name || type === 'view:' + this.name ||
|
|
91
|
-
type === 'element' || type === 'view:element' ||
|
|
92
|
-
type === 'node' || type === 'view:node';
|
|
93
|
-
} else {
|
|
94
|
-
return name === this.name && (
|
|
95
|
-
type === 'rawElement' || type === 'view:rawElement' ||
|
|
96
|
-
type === 'element' || type === 'view:element'
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Overrides the {@link module:engine/view/element~Element#_insertChild} method.
|
|
103
|
-
* Throws the `view-rawelement-cannot-add` {@link module:utils/ckeditorerror~CKEditorError CKEditorError} to prevent
|
|
104
|
-
* adding any child nodes to a raw element.
|
|
105
|
-
*
|
|
106
|
-
* @protected
|
|
107
|
-
*/
|
|
108
|
-
_insertChild( index, nodes ) {
|
|
109
|
-
if ( nodes && ( nodes instanceof Node || Array.from( nodes ).length > 0 ) ) {
|
|
110
|
-
/**
|
|
111
|
-
* Cannot add children to a {@link module:engine/view/rawelement~RawElement} instance.
|
|
112
|
-
*
|
|
113
|
-
* @error view-rawelement-cannot-add
|
|
114
|
-
*/
|
|
115
|
-
throw new CKEditorError(
|
|
116
|
-
'view-rawelement-cannot-add',
|
|
117
|
-
[ this, nodes ]
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* This allows rendering the children of a {@link module:engine/view/rawelement~RawElement} on the DOM level.
|
|
124
|
-
* This method is called by the {@link module:engine/view/domconverter~DomConverter} with the raw DOM element
|
|
125
|
-
* passed as an argument, leaving the number and shape of the children up to the integrator.
|
|
126
|
-
*
|
|
127
|
-
* This method **must be defined** for the raw element to work:
|
|
128
|
-
*
|
|
129
|
-
* const myRawElement = downcastWriter.createRawElement( 'div' );
|
|
130
|
-
*
|
|
131
|
-
* myRawElement.render = function( domElement, domConverter ) {
|
|
132
|
-
* domConverter.setContentOf( domElement, '<b>This is the raw content of myRawElement.</b>' );
|
|
133
|
-
* };
|
|
134
|
-
*
|
|
135
|
-
* @method #render
|
|
136
|
-
* @param {HTMLElement} domElement The native DOM element representing the raw view element.
|
|
137
|
-
* @param {module:engine/view/domconverter~DomConverter} domConverter Instance of the DomConverter used to optimize the output.
|
|
138
|
-
*/
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new instance of a raw element.
|
|
32
|
+
*
|
|
33
|
+
* Throws the `view-rawelement-cannot-add` {@link module:utils/ckeditorerror~CKEditorError CKEditorError} when the `children`
|
|
34
|
+
* parameter is passed to inform that the usage of `RawElement` is incorrect (adding child nodes to `RawElement` is forbidden).
|
|
35
|
+
*
|
|
36
|
+
* @see module:engine/view/downcastwriter~DowncastWriter#createRawElement
|
|
37
|
+
* @protected
|
|
38
|
+
* @param {module:engine/view/document~Document} document The document instance to which this element belongs.
|
|
39
|
+
* @param {String} name A node name.
|
|
40
|
+
* @param {Object|Iterable} [attrs] The collection of attributes.
|
|
41
|
+
* @param {module:engine/view/node~Node|Iterable.<module:engine/view/node~Node>} [children]
|
|
42
|
+
* A list of nodes to be inserted into the created element.
|
|
43
|
+
*/
|
|
44
|
+
constructor(...args) {
|
|
45
|
+
super(...args);
|
|
46
|
+
/**
|
|
47
|
+
* Returns `null` because filler is not needed for raw elements.
|
|
48
|
+
*
|
|
49
|
+
* @method #getFillerOffset
|
|
50
|
+
* @returns {null} Always returns null.
|
|
51
|
+
*/
|
|
52
|
+
this.getFillerOffset = getFillerOffset;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Overrides the {@link module:engine/view/element~Element#_insertChild} method.
|
|
56
|
+
* Throws the `view-rawelement-cannot-add` {@link module:utils/ckeditorerror~CKEditorError CKEditorError} to prevent
|
|
57
|
+
* adding any child nodes to a raw element.
|
|
58
|
+
*
|
|
59
|
+
* @protected
|
|
60
|
+
*/
|
|
61
|
+
_insertChild(index, items) {
|
|
62
|
+
if (items && (items instanceof Node || Array.from(items).length > 0)) {
|
|
63
|
+
/**
|
|
64
|
+
* Cannot add children to a {@link module:engine/view/rawelement~RawElement} instance.
|
|
65
|
+
*
|
|
66
|
+
* @error view-rawelement-cannot-add
|
|
67
|
+
*/
|
|
68
|
+
throw new CKEditorError('view-rawelement-cannot-add', [this, items]);
|
|
69
|
+
}
|
|
70
|
+
return 0;
|
|
71
|
+
}
|
|
72
|
+
render() { }
|
|
139
73
|
}
|
|
140
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Checks whether this object is of the given type or name.
|
|
76
|
+
*
|
|
77
|
+
* rawElement.is( 'rawElement' ); // -> true
|
|
78
|
+
* rawElement.is( 'element' ); // -> true
|
|
79
|
+
* rawElement.is( 'node' ); // -> true
|
|
80
|
+
* rawElement.is( 'view:rawElement' ); // -> true
|
|
81
|
+
* rawElement.is( 'view:element' ); // -> true
|
|
82
|
+
* rawElement.is( 'view:node' ); // -> true
|
|
83
|
+
*
|
|
84
|
+
* rawElement.is( 'model:element' ); // -> false
|
|
85
|
+
* rawElement.is( 'documentFragment' ); // -> false
|
|
86
|
+
*
|
|
87
|
+
* Assuming that the object being checked is a raw element, you can also check its
|
|
88
|
+
* {@link module:engine/view/rawelement~RawElement#name name}:
|
|
89
|
+
*
|
|
90
|
+
* rawElement.is( 'img' ); // -> true if this is an img element
|
|
91
|
+
* rawElement.is( 'rawElement', 'img' ); // -> same as above
|
|
92
|
+
* text.is( 'img' ); -> false
|
|
93
|
+
*
|
|
94
|
+
* {@link module:engine/view/node~Node#is Check the entire list of view objects} which implement the `is()` method.
|
|
95
|
+
*
|
|
96
|
+
* @param {String} type The type to check when the `name` parameter is present.
|
|
97
|
+
* Otherwise, it acts like the `name` parameter.
|
|
98
|
+
* @param {String} [name] The element name.
|
|
99
|
+
* @returns {Boolean}
|
|
100
|
+
*/
|
|
101
|
+
RawElement.prototype.is = function (type, name) {
|
|
102
|
+
if (!name) {
|
|
103
|
+
return type === 'rawElement' || type === 'view:rawElement' ||
|
|
104
|
+
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
|
|
105
|
+
type === this.name || type === 'view:' + this.name ||
|
|
106
|
+
type === 'element' || type === 'view:element' ||
|
|
107
|
+
type === 'node' || type === 'view:node';
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
return name === this.name && (type === 'rawElement' || type === 'view:rawElement' ||
|
|
111
|
+
type === 'element' || type === 'view:element');
|
|
112
|
+
}
|
|
113
|
+
};
|
|
141
114
|
// Returns `null` because block filler is not needed for raw elements.
|
|
142
115
|
//
|
|
143
116
|
// @returns {null}
|
|
144
117
|
function getFillerOffset() {
|
|
145
|
-
|
|
118
|
+
return null;
|
|
146
119
|
}
|