@ckeditor/ckeditor5-engine 29.0.0 → 31.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 +1 -1
- package/README.md +1 -1
- package/package.json +24 -21
- package/src/controller/datacontroller.js +50 -1
- package/src/conversion/downcasthelpers.js +21 -18
- package/src/conversion/upcasthelpers.js +10 -17
- package/src/dataprocessor/htmldataprocessor.js +13 -16
- package/src/dataprocessor/xmldataprocessor.js +15 -19
- package/src/dev-utils/view.js +21 -3
- package/src/index.js +1 -0
- package/src/model/markercollection.js +5 -4
- package/src/model/range.js +4 -3
- package/src/model/schema.js +28 -24
- package/src/model/selection.js +1 -1
- package/src/model/utils/deletecontent.js +3 -3
- package/src/model/utils/selection-post-fixer.js +10 -2
- package/src/view/document.js +12 -0
- package/src/view/domconverter.js +286 -73
- package/src/view/matcher.js +89 -13
- package/src/view/observer/selectionobserver.js +48 -1
- package/src/view/rawelement.js +3 -2
- package/src/view/renderer.js +103 -39
- package/src/view/styles/border.js +10 -10
- package/src/view/styles/utils.js +5 -0
- package/src/view/uielement.js +5 -2
- package/src/view/view.js +1 -1
- package/theme/renderer.css +9 -0
- package/CHANGELOG.md +0 -823
package/src/model/range.js
CHANGED
|
@@ -25,8 +25,9 @@ export default class Range {
|
|
|
25
25
|
/**
|
|
26
26
|
* Creates a range spanning from `start` position to `end` position.
|
|
27
27
|
*
|
|
28
|
-
* @param {module:engine/model/position~Position} start
|
|
29
|
-
* @param {module:engine/model/position~Position} [end]
|
|
28
|
+
* @param {module:engine/model/position~Position} start The start position.
|
|
29
|
+
* @param {module:engine/model/position~Position} [end] The end position. If not set,
|
|
30
|
+
* the range will be collapsed at the `start` position.
|
|
30
31
|
*/
|
|
31
32
|
constructor( start, end = null ) {
|
|
32
33
|
/**
|
|
@@ -445,7 +446,7 @@ export default class Range {
|
|
|
445
446
|
* You may specify additional options for the tree walker. See {@link module:engine/model/treewalker~TreeWalker} for
|
|
446
447
|
* a full list of available options.
|
|
447
448
|
*
|
|
448
|
-
* @param {Object} options Object with configuration options. See {@link module:engine/model/treewalker~TreeWalker}.
|
|
449
|
+
* @param {Object} [options] Object with configuration options. See {@link module:engine/model/treewalker~TreeWalker}.
|
|
449
450
|
* @returns {Iterable.<module:engine/model/item~Item>}
|
|
450
451
|
*/
|
|
451
452
|
* getItems( options = {} ) {
|
package/src/model/schema.js
CHANGED
|
@@ -18,23 +18,23 @@ import Text from './text';
|
|
|
18
18
|
import TreeWalker from './treewalker';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
|
-
* The model's schema. It defines allowed and disallowed structures of nodes as well as nodes' attributes.
|
|
22
|
-
* The schema is usually defined by features and based on them the editing framework and features
|
|
23
|
-
* make decisions how to change and process the model.
|
|
21
|
+
* The model's schema. It defines the allowed and disallowed structures of nodes as well as nodes' attributes.
|
|
22
|
+
* The schema is usually defined by the features and based on them, the editing framework and features
|
|
23
|
+
* make decisions on how to change and process the model.
|
|
24
24
|
*
|
|
25
25
|
* The instance of schema is available in {@link module:engine/model/model~Model#schema `editor.model.schema`}.
|
|
26
26
|
*
|
|
27
27
|
* Read more about the schema in:
|
|
28
28
|
*
|
|
29
|
-
* * {@glink framework/guides/architecture/editing-engine#schema
|
|
30
|
-
* {@glink framework/guides/architecture/editing-engine Introduction to the Editing engine architecture}.
|
|
31
|
-
* * {@glink framework/guides/deep-dive/schema Schema deep dive} guide.
|
|
29
|
+
* * The {@glink framework/guides/architecture/editing-engine#schema schema section} of the
|
|
30
|
+
* {@glink framework/guides/architecture/editing-engine Introduction to the Editing engine architecture} guide.
|
|
31
|
+
* * The {@glink framework/guides/deep-dive/schema Schema deep dive} guide.
|
|
32
32
|
*
|
|
33
33
|
* @mixes module:utils/observablemixin~ObservableMixin
|
|
34
34
|
*/
|
|
35
35
|
export default class Schema {
|
|
36
36
|
/**
|
|
37
|
-
* Creates schema instance.
|
|
37
|
+
* Creates a schema instance.
|
|
38
38
|
*/
|
|
39
39
|
constructor() {
|
|
40
40
|
this._sourceDefinitions = {};
|
|
@@ -61,7 +61,7 @@ export default class Schema {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
* Registers schema item. Can only be called once for every item name.
|
|
64
|
+
* Registers a schema item. Can only be called once for every item name.
|
|
65
65
|
*
|
|
66
66
|
* schema.register( 'paragraph', {
|
|
67
67
|
* inheritAllFrom: '$block'
|
|
@@ -221,8 +221,8 @@ export default class Schema {
|
|
|
221
221
|
* const paragraphElement = writer.createElement( 'paragraph' );
|
|
222
222
|
* schema.isBlock( paragraphElement ); // -> true
|
|
223
223
|
*
|
|
224
|
-
* See the {@glink framework/guides/deep-dive/schema#block-elements Block elements} section of
|
|
225
|
-
* guide for more details.
|
|
224
|
+
* See the {@glink framework/guides/deep-dive/schema#block-elements Block elements} section of
|
|
225
|
+
* the {@glink framework/guides/deep-dive/schema Schema deep dive} guide for more details.
|
|
226
226
|
*
|
|
227
227
|
* @param {module:engine/model/item~Item|module:engine/model/schema~SchemaContextItem|String} item
|
|
228
228
|
* @returns {Boolean}
|
|
@@ -247,8 +247,8 @@ export default class Schema {
|
|
|
247
247
|
* schema.isLimit( editor.model.document.getRoot() ); // -> true
|
|
248
248
|
* schema.isLimit( 'imageBlock' ); // -> true
|
|
249
249
|
*
|
|
250
|
-
* See the {@glink framework/guides/deep-dive/schema#limit-elements Limit elements} section of
|
|
251
|
-
* guide for more details.
|
|
250
|
+
* See the {@glink framework/guides/deep-dive/schema#limit-elements Limit elements} section of
|
|
251
|
+
* the {@glink framework/guides/deep-dive/schema Schema deep dive} guide for more details.
|
|
252
252
|
*
|
|
253
253
|
* @param {module:engine/model/item~Item|module:engine/model/schema~SchemaContextItem|String} item
|
|
254
254
|
* @returns {Boolean}
|
|
@@ -277,8 +277,8 @@ export default class Schema {
|
|
|
277
277
|
* const imageElement = writer.createElement( 'imageBlock' );
|
|
278
278
|
* schema.isObject( imageElement ); // -> true
|
|
279
279
|
*
|
|
280
|
-
* See the {@glink framework/guides/deep-dive/schema#object-elements Object elements} section of
|
|
281
|
-
* guide for more details.
|
|
280
|
+
* See the {@glink framework/guides/deep-dive/schema#object-elements Object elements} section of
|
|
281
|
+
* the {@glink framework/guides/deep-dive/schema Schema deep dive} guide for more details.
|
|
282
282
|
*
|
|
283
283
|
* @param {module:engine/model/item~Item|module:engine/model/schema~SchemaContextItem|String} item
|
|
284
284
|
* @returns {Boolean}
|
|
@@ -305,8 +305,8 @@ export default class Schema {
|
|
|
305
305
|
* const text = writer.createText( 'foo' );
|
|
306
306
|
* schema.isInline( text ); // -> true
|
|
307
307
|
*
|
|
308
|
-
* See the {@glink framework/guides/deep-dive/schema#inline-elements Inline elements} section of
|
|
309
|
-
* guide for more details.
|
|
308
|
+
* See the {@glink framework/guides/deep-dive/schema#inline-elements Inline elements} section of
|
|
309
|
+
* the {@glink framework/guides/deep-dive/schema Schema deep dive} guide for more details.
|
|
310
310
|
*
|
|
311
311
|
* @param {module:engine/model/item~Item|module:engine/model/schema~SchemaContextItem|String} item
|
|
312
312
|
* @returns {Boolean}
|
|
@@ -329,8 +329,8 @@ export default class Schema {
|
|
|
329
329
|
* const text = writer.createText( 'foo' );
|
|
330
330
|
* schema.isSelectable( text ); // -> false
|
|
331
331
|
*
|
|
332
|
-
* See the {@glink framework/guides/deep-dive/schema#selectable-elements Selectable elements section} of
|
|
333
|
-
* guide for more details.
|
|
332
|
+
* See the {@glink framework/guides/deep-dive/schema#selectable-elements Selectable elements section} of
|
|
333
|
+
* the {@glink framework/guides/deep-dive/schema Schema deep dive} guide for more details.
|
|
334
334
|
*
|
|
335
335
|
* @param {module:engine/model/item~Item|module:engine/model/schema~SchemaContextItem|String} item
|
|
336
336
|
* @returns {Boolean}
|
|
@@ -357,8 +357,8 @@ export default class Schema {
|
|
|
357
357
|
* const text = writer.createText( 'foo' );
|
|
358
358
|
* schema.isContent( text ); // -> true
|
|
359
359
|
*
|
|
360
|
-
* See the {@glink framework/guides/deep-dive/schema#content-elements Content elements section} of
|
|
361
|
-
* guide for more details.
|
|
360
|
+
* See the {@glink framework/guides/deep-dive/schema#content-elements Content elements section} of
|
|
361
|
+
* the {@glink framework/guides/deep-dive/schema Schema deep dive} guide for more details.
|
|
362
362
|
*
|
|
363
363
|
* @param {module:engine/model/item~Item|module:engine/model/schema~SchemaContextItem|String} item
|
|
364
364
|
* @returns {Boolean}
|
|
@@ -1243,7 +1243,8 @@ mix( Schema, ObservableMixin );
|
|
|
1243
1243
|
* Most block type items will inherit from `$block` (through `inheritAllFrom`).
|
|
1244
1244
|
*
|
|
1245
1245
|
* Read more about the block elements in the
|
|
1246
|
-
* {@glink framework/guides/deep-dive/schema#block-elements Block elements section} of
|
|
1246
|
+
* {@glink framework/guides/deep-dive/schema#block-elements Block elements section} of
|
|
1247
|
+
* the {@glink framework/guides/deep-dive/schema Schema deep dive}.
|
|
1247
1248
|
*
|
|
1248
1249
|
* @property {Boolean} isInline
|
|
1249
1250
|
* Whether an item is "text-like" and should be treated as an inline node. Examples of inline elements:
|
|
@@ -1258,7 +1259,8 @@ mix( Schema, ObservableMixin );
|
|
|
1258
1259
|
* a limit element are limited to its content.
|
|
1259
1260
|
*
|
|
1260
1261
|
* Read more about the limit elements in the
|
|
1261
|
-
* {@glink framework/guides/deep-dive/schema#limit-elements Limit elements section} of
|
|
1262
|
+
* {@glink framework/guides/deep-dive/schema#limit-elements Limit elements section} of
|
|
1263
|
+
* the {@glink framework/guides/deep-dive/schema Schema deep dive} guide.
|
|
1262
1264
|
*
|
|
1263
1265
|
* @property {Boolean} isObject
|
|
1264
1266
|
* Whether an item is "self-contained" and should be treated as a whole. Examples of object elements:
|
|
@@ -1278,7 +1280,8 @@ mix( Schema, ObservableMixin );
|
|
|
1278
1280
|
* {@link module:engine/model/schema~Schema#isSelectable `isSelectable()`} returns `true` for object elements automatically.
|
|
1279
1281
|
*
|
|
1280
1282
|
* Read more about selectable elements in the
|
|
1281
|
-
* {@glink framework/guides/deep-dive/schema#selectable-elements Selectable elements section} of
|
|
1283
|
+
* {@glink framework/guides/deep-dive/schema#selectable-elements Selectable elements section} of
|
|
1284
|
+
* the {@glink framework/guides/deep-dive/schema Schema deep dive} guide.
|
|
1282
1285
|
*
|
|
1283
1286
|
* @property {Boolean} isContent
|
|
1284
1287
|
* An item is a content when it always finds its way to the editor data output regardless of the number and type of its descendants.
|
|
@@ -1288,7 +1291,8 @@ mix( Schema, ObservableMixin );
|
|
|
1288
1291
|
* {@link module:engine/model/schema~Schema#isContent `isContent()`} returns `true` for object elements automatically.
|
|
1289
1292
|
*
|
|
1290
1293
|
* Read more about content elements in the
|
|
1291
|
-
* {@glink framework/guides/deep-dive/schema#content-elements Content elements section} of
|
|
1294
|
+
* {@glink framework/guides/deep-dive/schema#content-elements Content elements section} of
|
|
1295
|
+
* the {@glink framework/guides/deep-dive/schema Schema deep dive} guide.
|
|
1292
1296
|
*/
|
|
1293
1297
|
|
|
1294
1298
|
/**
|
package/src/model/selection.js
CHANGED
|
@@ -71,7 +71,7 @@ export default class Selection {
|
|
|
71
71
|
* // Creates backward selection.
|
|
72
72
|
* const selection = writer.createSelection( range, { backward: true } );
|
|
73
73
|
*
|
|
74
|
-
* @param {module:engine/model/selection~Selectable} selectable
|
|
74
|
+
* @param {module:engine/model/selection~Selectable} [selectable]
|
|
75
75
|
* @param {Number|'before'|'end'|'after'|'on'|'in'} [placeOrOffset] Sets place or offset of the selection.
|
|
76
76
|
* @param {Object} [options]
|
|
77
77
|
* @param {Boolean} [options.backward] Sets this selection instance to be backward.
|
|
@@ -53,7 +53,7 @@ import DocumentSelection from '../documentselection';
|
|
|
53
53
|
* If you use this option you need to make sure to handle invalid selections yourself or leave
|
|
54
54
|
* them to the selection post-fixer (may not always work).
|
|
55
55
|
*
|
|
56
|
-
* **Note:**
|
|
56
|
+
* **Note:** If there is no valid position for the selection, the paragraph will always be created:
|
|
57
57
|
*
|
|
58
58
|
* `[<imageBlock src="foo.jpg"></imageBlock>]` -> `<paragraph>[]</paragraph>`.
|
|
59
59
|
*/
|
|
@@ -150,10 +150,10 @@ function getLivePositionsForSelectedBlocks( range ) {
|
|
|
150
150
|
|
|
151
151
|
const newEndPosition = selection.getLastPosition();
|
|
152
152
|
|
|
153
|
-
// For such model and selection:
|
|
153
|
+
// For such a model and selection:
|
|
154
154
|
// <paragraph>A[</paragraph><imageBlock></imageBlock><paragraph>]B</paragraph>
|
|
155
155
|
//
|
|
156
|
-
// After modifySelection() we would end up with this:
|
|
156
|
+
// After modifySelection(), we would end up with this:
|
|
157
157
|
// <paragraph>A[</paragraph>]<imageBlock></imageBlock><paragraph>B</paragraph>
|
|
158
158
|
//
|
|
159
159
|
// So we need to check if there is no content in the skipped range (because we want to include the <imageBlock>).
|
|
@@ -128,9 +128,17 @@ function tryFixingCollapsedRange( range, schema ) {
|
|
|
128
128
|
|
|
129
129
|
const nearestSelectionRange = schema.getNearestSelectionRange( originalPosition );
|
|
130
130
|
|
|
131
|
-
// This might be null ie when editor data is empty
|
|
132
|
-
//
|
|
131
|
+
// This might be null ie when editor data is empty or the selection is inside limit element
|
|
132
|
+
// that doesn't allow text inside.
|
|
133
|
+
// In the first case there is no need to fix the selection range.
|
|
134
|
+
// In the second let's go up to the outer selectable element
|
|
133
135
|
if ( !nearestSelectionRange ) {
|
|
136
|
+
const ancestorObject = originalPosition.getAncestors().reverse().find( item => schema.isObject( item ) );
|
|
137
|
+
|
|
138
|
+
if ( ancestorObject ) {
|
|
139
|
+
return Range._createOn( ancestorObject );
|
|
140
|
+
}
|
|
141
|
+
|
|
134
142
|
return null;
|
|
135
143
|
}
|
|
136
144
|
|
package/src/view/document.js
CHANGED
|
@@ -80,6 +80,18 @@ export default class Document {
|
|
|
80
80
|
*/
|
|
81
81
|
this.set( 'isFocused', false );
|
|
82
82
|
|
|
83
|
+
/**
|
|
84
|
+
* `true` while the user is making a selection in the document (e.g. holding the mouse button and moving the cursor).
|
|
85
|
+
* When they stop selecting, the property goes back to `false`.
|
|
86
|
+
*
|
|
87
|
+
* This property is updated by the {@link module:engine/view/observer/selectionobserver~SelectionObserver}.
|
|
88
|
+
*
|
|
89
|
+
* @readonly
|
|
90
|
+
* @observable
|
|
91
|
+
* @member {Boolean} module:engine/view/document~Document#isSelecting
|
|
92
|
+
*/
|
|
93
|
+
this.set( 'isSelecting', false );
|
|
94
|
+
|
|
83
95
|
/**
|
|
84
96
|
* True if composition is in progress inside the document.
|
|
85
97
|
*
|