@ckeditor/ckeditor5-engine 35.3.2 → 35.4.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/package.json +22 -22
- package/src/controller/datacontroller.js +5 -7
- package/src/controller/editingcontroller.js +2 -3
- package/src/conversion/conversion.js +1 -2
- package/src/conversion/downcastdispatcher.js +2 -2
- package/src/conversion/downcasthelpers.js +1 -2
- package/src/conversion/mapper.js +2 -3
- package/src/conversion/modelconsumable.js +1 -1
- package/src/conversion/upcastdispatcher.js +2 -3
- package/src/conversion/upcasthelpers.js +2 -2
- package/src/conversion/viewconsumable.js +1 -1
- package/src/dataprocessor/htmldataprocessor.js +2 -1
- package/src/dataprocessor/xmldataprocessor.js +5 -1
- package/src/dev-utils/model.js +2 -2
- package/src/index.js +11 -2
- package/src/model/batch.js +1 -1
- package/src/model/document.js +2 -5
- package/src/model/documentfragment.js +1 -1
- package/src/model/documentselection.js +1 -6
- package/src/model/element.js +1 -1
- package/src/model/liveposition.js +1 -3
- package/src/model/liverange.js +1 -2
- package/src/model/markercollection.js +2 -4
- package/src/model/model.js +2 -3
- package/src/model/node.js +1 -3
- package/src/model/nodelist.js +1 -2
- package/src/model/operation/attributeoperation.js +1 -1
- package/src/model/operation/detachoperation.js +1 -1
- package/src/model/operation/insertoperation.js +1 -1
- package/src/model/operation/mergeoperation.js +1 -1
- package/src/model/operation/moveoperation.js +1 -2
- package/src/model/operation/renameoperation.js +1 -1
- package/src/model/operation/rootattributeoperation.js +1 -1
- package/src/model/operation/splitoperation.js +1 -1
- package/src/model/operation/transform.js +1 -1
- package/src/model/operation/utils.js +1 -2
- package/src/model/position.js +1 -2
- package/src/model/range.js +1 -2
- package/src/model/schema.js +9 -10
- package/src/model/selection.js +1 -4
- package/src/model/textproxy.js +1 -1
- package/src/model/treewalker.js +1 -1
- package/src/model/utils/findoptimalinsertionrange.js +1 -1
- package/src/model/utils/insertcontent.js +1 -1
- package/src/model/utils/insertobject.js +21 -19
- package/src/model/utils/modifyselection.js +1 -1
- package/src/model/writer.js +1 -2
- package/src/view/attributeelement.js +1 -1
- package/src/view/document.js +18 -4
- package/src/view/documentfragment.js +1 -3
- package/src/view/documentselection.js +1 -2
- package/src/view/domconverter.js +1 -6
- package/src/view/downcastwriter.js +1 -2
- package/src/view/editableelement.js +1 -2
- package/src/view/element.js +1 -3
- package/src/view/emptyelement.js +1 -1
- package/src/view/filler.js +1 -2
- package/src/view/matcher.js +1 -1
- package/src/view/node.js +1 -4
- package/src/view/observer/bubblingemittermixin.js +2 -5
- package/src/view/observer/bubblingeventinfo.js +1 -1
- package/src/view/observer/fakeselectionobserver.js +1 -1
- package/src/view/observer/focusobserver.js +5 -1
- package/src/view/observer/inputobserver.js +1 -1
- package/src/view/observer/keyobserver.js +1 -1
- package/src/view/observer/observer.js +2 -2
- package/src/view/observer/selectionobserver.js +9 -2
- package/src/view/observer/tabobserver.js +1 -1
- package/src/view/position.js +1 -2
- package/src/view/rawelement.js +1 -1
- package/src/view/renderer.js +15 -11
- package/src/view/selection.js +1 -5
- package/src/view/textproxy.js +1 -1
- package/src/view/treewalker.js +1 -1
- package/src/view/uielement.js +1 -2
- package/src/view/view.js +5 -5
|
@@ -9,8 +9,7 @@ import Node from '../node';
|
|
|
9
9
|
import Range from '../range';
|
|
10
10
|
import Text from '../text';
|
|
11
11
|
import TextProxy from '../textproxy';
|
|
12
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils
|
|
13
|
-
import isIterable from '@ckeditor/ckeditor5-utils/src/isiterable';
|
|
12
|
+
import { CKEditorError, isIterable } from '@ckeditor/ckeditor5-utils';
|
|
14
13
|
/**
|
|
15
14
|
* Contains functions used for composing model tree by {@link module:engine/model/operation/operation~Operation operations}.
|
|
16
15
|
* Those functions are built on top of {@link module:engine/model/node~Node node}, and it's child classes', APIs.
|
package/src/model/position.js
CHANGED
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import TypeCheckable from './typecheckable';
|
|
9
9
|
import TreeWalker from './treewalker';
|
|
10
|
-
import compareArrays from '@ckeditor/ckeditor5-utils
|
|
11
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
10
|
+
import { CKEditorError, compareArrays } from '@ckeditor/ckeditor5-utils';
|
|
12
11
|
// To check if component is loaded more than once.
|
|
13
12
|
import '@ckeditor/ckeditor5-utils/src/version';
|
|
14
13
|
/**
|
package/src/model/range.js
CHANGED
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
import TypeCheckable from './typecheckable';
|
|
9
9
|
import Position from './position';
|
|
10
10
|
import TreeWalker from './treewalker';
|
|
11
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils
|
|
12
|
-
import compareArrays from '@ckeditor/ckeditor5-utils/src/comparearrays';
|
|
11
|
+
import { CKEditorError, compareArrays } from '@ckeditor/ckeditor5-utils';
|
|
13
12
|
/**
|
|
14
13
|
* Represents a range in the model tree.
|
|
15
14
|
*
|
package/src/model/schema.js
CHANGED
|
@@ -10,8 +10,7 @@ import Position from './position';
|
|
|
10
10
|
import Range from './range';
|
|
11
11
|
import Text from './text';
|
|
12
12
|
import TreeWalker from './treewalker';
|
|
13
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils
|
|
14
|
-
import { Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
|
|
13
|
+
import { CKEditorError, ObservableMixin } from '@ckeditor/ckeditor5-utils';
|
|
15
14
|
/**
|
|
16
15
|
* The model's schema. It defines the allowed and disallowed structures of nodes as well as nodes' attributes.
|
|
17
16
|
* The schema is usually defined by the features and based on them, the editing framework and features
|
|
@@ -23,11 +22,11 @@ import { Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
|
|
|
23
22
|
*
|
|
24
23
|
* * The {@glink framework/guides/architecture/editing-engine#schema schema section} of the
|
|
25
24
|
* {@glink framework/guides/architecture/editing-engine Introduction to the Editing engine architecture} guide.
|
|
26
|
-
* * The {@glink framework/guides/deep-dive/schema Schema deep
|
|
25
|
+
* * The {@glink framework/guides/deep-dive/schema Schema deep-dive guide}.
|
|
27
26
|
*
|
|
28
27
|
* @mixes module:utils/observablemixin~ObservableMixin
|
|
29
28
|
*/
|
|
30
|
-
export default class Schema extends
|
|
29
|
+
export default class Schema extends ObservableMixin() {
|
|
31
30
|
/**
|
|
32
31
|
* Creates a schema instance.
|
|
33
32
|
*/
|
|
@@ -198,7 +197,7 @@ export default class Schema extends Observable {
|
|
|
198
197
|
* schema.isBlock( paragraphElement ); // -> true
|
|
199
198
|
*
|
|
200
199
|
* See the {@glink framework/guides/deep-dive/schema#block-elements Block elements} section of
|
|
201
|
-
* the {@glink framework/guides/deep-dive/schema Schema deep
|
|
200
|
+
* the {@glink framework/guides/deep-dive/schema Schema deep-dive guide} for more details.
|
|
202
201
|
*
|
|
203
202
|
* @param {module:engine/model/item~Item|module:engine/model/schema~SchemaContextItem|String} item
|
|
204
203
|
* @returns {Boolean}
|
|
@@ -222,7 +221,7 @@ export default class Schema extends Observable {
|
|
|
222
221
|
* schema.isLimit( 'imageBlock' ); // -> true
|
|
223
222
|
*
|
|
224
223
|
* See the {@glink framework/guides/deep-dive/schema#limit-elements Limit elements} section of
|
|
225
|
-
* the {@glink framework/guides/deep-dive/schema Schema deep
|
|
224
|
+
* the {@glink framework/guides/deep-dive/schema Schema deep-dive guide} for more details.
|
|
226
225
|
*
|
|
227
226
|
* @param {module:engine/model/item~Item|module:engine/model/schema~SchemaContextItem|String} item
|
|
228
227
|
* @returns {Boolean}
|
|
@@ -249,7 +248,7 @@ export default class Schema extends Observable {
|
|
|
249
248
|
* schema.isObject( imageElement ); // -> true
|
|
250
249
|
*
|
|
251
250
|
* See the {@glink framework/guides/deep-dive/schema#object-elements Object elements} section of
|
|
252
|
-
* the {@glink framework/guides/deep-dive/schema Schema deep
|
|
251
|
+
* the {@glink framework/guides/deep-dive/schema Schema deep-dive guide} for more details.
|
|
253
252
|
*
|
|
254
253
|
* @param {module:engine/model/item~Item|module:engine/model/schema~SchemaContextItem|String} item
|
|
255
254
|
* @returns {Boolean}
|
|
@@ -274,7 +273,7 @@ export default class Schema extends Observable {
|
|
|
274
273
|
* schema.isInline( text ); // -> true
|
|
275
274
|
*
|
|
276
275
|
* See the {@glink framework/guides/deep-dive/schema#inline-elements Inline elements} section of
|
|
277
|
-
* the {@glink framework/guides/deep-dive/schema Schema deep
|
|
276
|
+
* the {@glink framework/guides/deep-dive/schema Schema deep-dive guide} for more details.
|
|
278
277
|
*
|
|
279
278
|
* @param {module:engine/model/item~Item|module:engine/model/schema~SchemaContextItem|String} item
|
|
280
279
|
* @returns {Boolean}
|
|
@@ -296,7 +295,7 @@ export default class Schema extends Observable {
|
|
|
296
295
|
* schema.isSelectable( text ); // -> false
|
|
297
296
|
*
|
|
298
297
|
* See the {@glink framework/guides/deep-dive/schema#selectable-elements Selectable elements section} of
|
|
299
|
-
* the {@glink framework/guides/deep-dive/schema Schema deep
|
|
298
|
+
* the {@glink framework/guides/deep-dive/schema Schema deep-dive guide} for more details.
|
|
300
299
|
*
|
|
301
300
|
* @param {module:engine/model/item~Item|module:engine/model/schema~SchemaContextItem|String} item
|
|
302
301
|
* @returns {Boolean}
|
|
@@ -321,7 +320,7 @@ export default class Schema extends Observable {
|
|
|
321
320
|
* schema.isContent( text ); // -> true
|
|
322
321
|
*
|
|
323
322
|
* See the {@glink framework/guides/deep-dive/schema#content-elements Content elements section} of
|
|
324
|
-
* the {@glink framework/guides/deep-dive/schema Schema deep
|
|
323
|
+
* the {@glink framework/guides/deep-dive/schema Schema deep-dive guide} for more details.
|
|
325
324
|
*
|
|
326
325
|
* @param {module:engine/model/item~Item|module:engine/model/schema~SchemaContextItem|String} item
|
|
327
326
|
* @returns {Boolean}
|
package/src/model/selection.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
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
|
-
/* eslint-disable new-cap */
|
|
6
5
|
/**
|
|
7
6
|
* @module engine/model/selection
|
|
8
7
|
*/
|
|
@@ -10,9 +9,7 @@ import TypeCheckable from './typecheckable';
|
|
|
10
9
|
import Node from './node';
|
|
11
10
|
import Position from './position';
|
|
12
11
|
import Range from './range';
|
|
13
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils
|
|
14
|
-
import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';
|
|
15
|
-
import isIterable from '@ckeditor/ckeditor5-utils/src/isiterable';
|
|
12
|
+
import { CKEditorError, EmitterMixin, isIterable } from '@ckeditor/ckeditor5-utils';
|
|
16
13
|
/**
|
|
17
14
|
* Selection is a set of {@link module:engine/model/range~Range ranges}. It has a direction specified by its
|
|
18
15
|
* {@link module:engine/model/selection~Selection#anchor anchor} and {@link module:engine/model/selection~Selection#focus focus}
|
package/src/model/textproxy.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module engine/model/textproxy
|
|
7
7
|
*/
|
|
8
8
|
import TypeCheckable from './typecheckable';
|
|
9
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils
|
|
9
|
+
import { CKEditorError } from '@ckeditor/ckeditor5-utils';
|
|
10
10
|
// @if CK_DEBUG_ENGINE // const { convertMapToStringifiedObject } = require( '../dev-utils/utils' );
|
|
11
11
|
/**
|
|
12
12
|
* `TextProxy` represents a part of {@link module:engine/model/text~Text text node}.
|
package/src/model/treewalker.js
CHANGED
|
@@ -9,7 +9,7 @@ import Element from './element';
|
|
|
9
9
|
import { default as Position, getTextNodeAtPosition, getNodeAfterPosition, getNodeBeforePosition } from './position';
|
|
10
10
|
import Text from './text';
|
|
11
11
|
import TextProxy from './textproxy';
|
|
12
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils
|
|
12
|
+
import { CKEditorError } from '@ckeditor/ckeditor5-utils';
|
|
13
13
|
/**
|
|
14
14
|
* Position iterator class. It allows to iterate forward and backward over the document.
|
|
15
15
|
*/
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/model/utils/findoptimalinsertionrange
|
|
7
7
|
*/
|
|
8
|
-
import first from '@ckeditor/ckeditor5-utils
|
|
8
|
+
import { first } from '@ckeditor/ckeditor5-utils';
|
|
9
9
|
// Returns a model range which is optimal (in terms of UX) for inserting a widget block.
|
|
10
10
|
//
|
|
11
11
|
// For instance, if a selection is in the middle of a paragraph, the collapsed range before this paragraph
|
|
@@ -11,7 +11,7 @@ import LivePosition from '../liveposition';
|
|
|
11
11
|
import Position from '../position';
|
|
12
12
|
import Range from '../range';
|
|
13
13
|
import Selection from '../selection';
|
|
14
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils
|
|
14
|
+
import { CKEditorError } from '@ckeditor/ckeditor5-utils';
|
|
15
15
|
import { LiveRange } from '../../index';
|
|
16
16
|
/**
|
|
17
17
|
* Inserts content into the editor (specified selection) as one would expect the paste functionality to work.
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
import { findOptimalInsertionRange } from './findoptimalinsertionrange';
|
|
9
9
|
import DocumentSelection from '../documentselection';
|
|
10
10
|
import Selection from '../selection';
|
|
11
|
-
import first from '@ckeditor/ckeditor5-utils
|
|
12
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
11
|
+
import { CKEditorError, first } from '@ckeditor/ckeditor5-utils';
|
|
13
12
|
/**
|
|
14
13
|
* Inserts an {@glink framework/guides/deep-dive/schema#object-elements object element} at a specific position in the editor content.
|
|
15
14
|
*
|
|
@@ -118,25 +117,11 @@ export default function insertObject(model, object, selectable, placeOrOffset, o
|
|
|
118
117
|
// `place` parameter is equal to `after` but there is no element with `$text` node to set selection in.
|
|
119
118
|
function updateSelection(writer, contextElement, place, paragraphAttributes) {
|
|
120
119
|
const model = writer.model;
|
|
121
|
-
if (place == '
|
|
122
|
-
let nextElement = contextElement.nextSibling;
|
|
123
|
-
// Check whether an element next to the inserted element is defined and can contain a text.
|
|
124
|
-
const canSetSelection = nextElement && model.schema.checkChild(nextElement, '$text');
|
|
125
|
-
// If the element is missing, but a paragraph could be inserted next to the element, let's add it.
|
|
126
|
-
if (!canSetSelection && model.schema.checkChild(contextElement.parent, 'paragraph')) {
|
|
127
|
-
nextElement = writer.createElement('paragraph');
|
|
128
|
-
model.schema.setAllowedAttributes(nextElement, paragraphAttributes, writer);
|
|
129
|
-
model.insertContent(nextElement, writer.createPositionAfter(contextElement));
|
|
130
|
-
}
|
|
131
|
-
// Put the selection inside the element, at the beginning.
|
|
132
|
-
if (nextElement) {
|
|
133
|
-
writer.setSelection(nextElement, 0);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
else if (place == 'on') {
|
|
120
|
+
if (place == 'on') {
|
|
137
121
|
writer.setSelection(contextElement, 'on');
|
|
122
|
+
return;
|
|
138
123
|
}
|
|
139
|
-
|
|
124
|
+
if (place != 'after') {
|
|
140
125
|
/**
|
|
141
126
|
* The unsupported `options.setSelection` parameter was passed
|
|
142
127
|
* to the {@link module:engine/model/utils/insertobject insertObject()} function.
|
|
@@ -147,4 +132,21 @@ function updateSelection(writer, contextElement, place, paragraphAttributes) {
|
|
|
147
132
|
*/
|
|
148
133
|
throw new CKEditorError('insertobject-invalid-place-parameter-value', model);
|
|
149
134
|
}
|
|
135
|
+
let nextElement = contextElement.nextSibling;
|
|
136
|
+
if (model.schema.isInline(contextElement)) {
|
|
137
|
+
writer.setSelection(contextElement, 'after');
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
// Check whether an element next to the inserted element is defined and can contain a text.
|
|
141
|
+
const canSetSelection = nextElement && model.schema.checkChild(nextElement, '$text');
|
|
142
|
+
// If the element is missing, but a paragraph could be inserted next to the element, let's add it.
|
|
143
|
+
if (!canSetSelection && model.schema.checkChild(contextElement.parent, 'paragraph')) {
|
|
144
|
+
nextElement = writer.createElement('paragraph');
|
|
145
|
+
model.schema.setAllowedAttributes(nextElement, paragraphAttributes, writer);
|
|
146
|
+
model.insertContent(nextElement, writer.createPositionAfter(contextElement));
|
|
147
|
+
}
|
|
148
|
+
// Put the selection inside the element, at the beginning.
|
|
149
|
+
if (nextElement) {
|
|
150
|
+
writer.setSelection(nextElement, 0);
|
|
151
|
+
}
|
|
150
152
|
}
|
|
@@ -9,7 +9,7 @@ import DocumentSelection from '../documentselection';
|
|
|
9
9
|
import Position from '../position';
|
|
10
10
|
import Range from '../range';
|
|
11
11
|
import TreeWalker from '../treewalker';
|
|
12
|
-
import { isInsideSurrogatePair, isInsideCombinedSymbol, isInsideEmojiSequence } from '@ckeditor/ckeditor5-utils
|
|
12
|
+
import { isInsideSurrogatePair, isInsideCombinedSymbol, isInsideEmojiSequence } from '@ckeditor/ckeditor5-utils';
|
|
13
13
|
const wordBoundaryCharacters = ' ,.?!:;"-()';
|
|
14
14
|
/**
|
|
15
15
|
* Modifies the selection. Currently, the supported modifications are:
|
package/src/model/writer.js
CHANGED
|
@@ -21,8 +21,7 @@ import Position from './position';
|
|
|
21
21
|
import Range from './range';
|
|
22
22
|
import RootElement from './rootelement';
|
|
23
23
|
import Text from './text';
|
|
24
|
-
import toMap from '@ckeditor/ckeditor5-utils
|
|
25
|
-
import CKEditorError, { logWarning } from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
24
|
+
import { CKEditorError, logWarning, toMap } from '@ckeditor/ckeditor5-utils';
|
|
26
25
|
/**
|
|
27
26
|
* The model can only be modified by using the writer. It should be used whenever you want to create a node, modify
|
|
28
27
|
* child nodes, attributes or text, set the selection's position and its attributes.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module engine/view/attributeelement
|
|
7
7
|
*/
|
|
8
8
|
import Element from './element';
|
|
9
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils
|
|
9
|
+
import { CKEditorError } from '@ckeditor/ckeditor5-utils';
|
|
10
10
|
// Default attribute priority.
|
|
11
11
|
const DEFAULT_PRIORITY = 10;
|
|
12
12
|
/**
|
package/src/view/document.js
CHANGED
|
@@ -2,14 +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
|
-
/* eslint-disable new-cap */
|
|
6
5
|
/**
|
|
7
6
|
* @module engine/view/document
|
|
8
7
|
*/
|
|
9
8
|
import DocumentSelection from './documentselection';
|
|
10
|
-
import Collection from '@ckeditor/ckeditor5-utils/src/collection';
|
|
11
9
|
import BubblingEmitterMixin from './observer/bubblingemittermixin';
|
|
12
|
-
import {
|
|
10
|
+
import { Collection, ObservableMixin } from '@ckeditor/ckeditor5-utils';
|
|
13
11
|
// @if CK_DEBUG_ENGINE // const { logDocument } = require( '../dev-utils/utils' );
|
|
14
12
|
/**
|
|
15
13
|
* Document class creates an abstract layer over the content editable area, contains a tree of view elements and
|
|
@@ -18,7 +16,7 @@ import { Observable } from '@ckeditor/ckeditor5-utils/src/observablemixin';
|
|
|
18
16
|
* @mixes module:engine/view/observer/bubblingemittermixin~BubblingEmitterMixin
|
|
19
17
|
* @mixes module:utils/observablemixin~ObservableMixin
|
|
20
18
|
*/
|
|
21
|
-
export default class Document extends BubblingEmitterMixin(
|
|
19
|
+
export default class Document extends BubblingEmitterMixin(ObservableMixin()) {
|
|
22
20
|
/**
|
|
23
21
|
* Creates a Document instance.
|
|
24
22
|
*
|
|
@@ -73,6 +71,22 @@ export default class Document extends BubblingEmitterMixin(Observable) {
|
|
|
73
71
|
*/
|
|
74
72
|
this.set('isFocused', false);
|
|
75
73
|
/**
|
|
74
|
+
* Set to `true` if the document is in the process of setting the focus.
|
|
75
|
+
*
|
|
76
|
+
* To be precise, there are two browser events that we care about: `focus` and `selectionchange`.
|
|
77
|
+
*
|
|
78
|
+
* Different browsers handle them differently. Chromium sends the `focus` event before the
|
|
79
|
+
* `selectionchange` event, which leads to rendering with the old selection state.
|
|
80
|
+
*
|
|
81
|
+
* The flag is used to prevent rendering when setting the focus is in progress
|
|
82
|
+
* and we are waiting for the new value.
|
|
83
|
+
*
|
|
84
|
+
* @internal
|
|
85
|
+
* @observable
|
|
86
|
+
* @member {Boolean} module:engine/view/document~Document#_isFocusChanging
|
|
87
|
+
*/
|
|
88
|
+
this.set('_isFocusChanging', false);
|
|
89
|
+
/** @
|
|
76
90
|
* `true` while the user is making a selection in the document (e.g. holding the mouse button and moving the cursor).
|
|
77
91
|
* When they stop selecting, the property goes back to `false`.
|
|
78
92
|
*
|
|
@@ -2,15 +2,13 @@
|
|
|
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
|
-
/* eslint-disable new-cap */
|
|
6
5
|
/**
|
|
7
6
|
* @module engine/view/documentfragment
|
|
8
7
|
*/
|
|
9
8
|
import TypeCheckable from './typecheckable';
|
|
10
9
|
import Text from './text';
|
|
11
10
|
import TextProxy from './textproxy';
|
|
12
|
-
import isIterable from '@ckeditor/ckeditor5-utils
|
|
13
|
-
import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';
|
|
11
|
+
import { EmitterMixin, isIterable } from '@ckeditor/ckeditor5-utils';
|
|
14
12
|
/**
|
|
15
13
|
* Document fragment.
|
|
16
14
|
*
|
|
@@ -2,13 +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
|
-
/* eslint-disable new-cap */
|
|
6
5
|
/**
|
|
7
6
|
* @module engine/view/documentselection
|
|
8
7
|
*/
|
|
9
8
|
import TypeCheckable from './typecheckable';
|
|
10
9
|
import Selection from './selection';
|
|
11
|
-
import EmitterMixin from '@ckeditor/ckeditor5-utils
|
|
10
|
+
import { EmitterMixin } from '@ckeditor/ckeditor5-utils';
|
|
12
11
|
/**
|
|
13
12
|
* Class representing the document selection in the view.
|
|
14
13
|
*
|
package/src/view/domconverter.js
CHANGED
|
@@ -16,12 +16,7 @@ import ViewDocumentFragment from './documentfragment';
|
|
|
16
16
|
import ViewTreeWalker from './treewalker';
|
|
17
17
|
import { default as Matcher } from './matcher';
|
|
18
18
|
import { BR_FILLER, INLINE_FILLER_LENGTH, NBSP_FILLER, MARKED_NBSP_FILLER, getDataWithoutFiller, isInlineFiller, startsWithFiller } from './filler';
|
|
19
|
-
import global from '@ckeditor/ckeditor5-utils
|
|
20
|
-
import { logWarning } from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
21
|
-
import indexOf from '@ckeditor/ckeditor5-utils/src/dom/indexof';
|
|
22
|
-
import getAncestors from '@ckeditor/ckeditor5-utils/src/dom/getancestors';
|
|
23
|
-
import isText from '@ckeditor/ckeditor5-utils/src/dom/istext';
|
|
24
|
-
import isComment from '@ckeditor/ckeditor5-utils/src/dom/iscomment';
|
|
19
|
+
import { global, logWarning, indexOf, getAncestors, isText, isComment } from '@ckeditor/ckeditor5-utils';
|
|
25
20
|
const BR_FILLER_REF = BR_FILLER(global.document); // eslint-disable-line new-cap
|
|
26
21
|
const NBSP_FILLER_REF = NBSP_FILLER(global.document); // eslint-disable-line new-cap
|
|
27
22
|
const MARKED_NBSP_FILLER_REF = MARKED_NBSP_FILLER(global.document); // eslint-disable-line new-cap
|
|
@@ -13,9 +13,8 @@ import AttributeElement from './attributeelement';
|
|
|
13
13
|
import EmptyElement from './emptyelement';
|
|
14
14
|
import UIElement from './uielement';
|
|
15
15
|
import RawElement from './rawelement';
|
|
16
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils
|
|
16
|
+
import { CKEditorError, isIterable } from '@ckeditor/ckeditor5-utils';
|
|
17
17
|
import DocumentFragment from './documentfragment';
|
|
18
|
-
import isIterable from '@ckeditor/ckeditor5-utils/src/isiterable';
|
|
19
18
|
import Text from './text';
|
|
20
19
|
import EditableElement from './editableelement';
|
|
21
20
|
import { isPlainObject } from 'lodash-es';
|
|
@@ -2,12 +2,11 @@
|
|
|
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
|
-
/* eslint-disable new-cap */
|
|
6
5
|
/**
|
|
7
6
|
* @module engine/view/editableelement
|
|
8
7
|
*/
|
|
9
8
|
import ContainerElement from './containerelement';
|
|
10
|
-
import ObservableMixin from '@ckeditor/ckeditor5-utils
|
|
9
|
+
import { ObservableMixin } from '@ckeditor/ckeditor5-utils';
|
|
11
10
|
/**
|
|
12
11
|
* Editable element which can be a {@link module:engine/view/rooteditableelement~RootEditableElement root}
|
|
13
12
|
* or nested editable area in the editor.
|
package/src/view/element.js
CHANGED
|
@@ -8,9 +8,7 @@
|
|
|
8
8
|
import Node from './node';
|
|
9
9
|
import Text from './text';
|
|
10
10
|
import TextProxy from './textproxy';
|
|
11
|
-
import toMap from '@ckeditor/ckeditor5-utils
|
|
12
|
-
import toArray from '@ckeditor/ckeditor5-utils/src/toarray';
|
|
13
|
-
import isIterable from '@ckeditor/ckeditor5-utils/src/isiterable';
|
|
11
|
+
import { isIterable, toArray, toMap } from '@ckeditor/ckeditor5-utils';
|
|
14
12
|
import { default as Matcher } from './matcher';
|
|
15
13
|
import { default as StylesMap } from './stylesmap';
|
|
16
14
|
import { isPlainObject } from 'lodash-es';
|
package/src/view/emptyelement.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import Element from './element';
|
|
9
9
|
import Node from './node';
|
|
10
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils
|
|
10
|
+
import { CKEditorError } from '@ckeditor/ckeditor5-utils';
|
|
11
11
|
/**
|
|
12
12
|
* Empty element class. It is used to represent elements that cannot contain any child nodes (for example `<img>` elements).
|
|
13
13
|
*
|
package/src/view/filler.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
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
|
-
import { keyCodes } from '@ckeditor/ckeditor5-utils
|
|
6
|
-
import isText from '@ckeditor/ckeditor5-utils/src/dom/istext';
|
|
5
|
+
import { keyCodes, isText } from '@ckeditor/ckeditor5-utils';
|
|
7
6
|
/**
|
|
8
7
|
* Set of utilities related to handling block and inline fillers.
|
|
9
8
|
*
|
package/src/view/matcher.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
4
|
*/
|
|
5
5
|
import { isPlainObject } from 'lodash-es';
|
|
6
|
-
import { logWarning } from '@ckeditor/ckeditor5-utils
|
|
6
|
+
import { logWarning } from '@ckeditor/ckeditor5-utils';
|
|
7
7
|
/**
|
|
8
8
|
* View matcher class.
|
|
9
9
|
* Instance of this class can be used to find {@link module:engine/view/element~Element elements} that match given pattern.
|
package/src/view/node.js
CHANGED
|
@@ -2,14 +2,11 @@
|
|
|
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
|
-
/* eslint-disable new-cap */
|
|
6
5
|
/**
|
|
7
6
|
* @module engine/view/node
|
|
8
7
|
*/
|
|
9
8
|
import TypeCheckable from './typecheckable';
|
|
10
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils
|
|
11
|
-
import EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';
|
|
12
|
-
import compareArrays from '@ckeditor/ckeditor5-utils/src/comparearrays';
|
|
9
|
+
import { CKEditorError, EmitterMixin, compareArrays } from '@ckeditor/ckeditor5-utils';
|
|
13
10
|
import { clone } from 'lodash-es';
|
|
14
11
|
// To check if component is loaded more than once.
|
|
15
12
|
import '@ckeditor/ckeditor5-utils/src/version';
|
|
@@ -5,10 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/view/observer/bubblingemittermixin
|
|
7
7
|
*/
|
|
8
|
-
import EventInfo from '@ckeditor/ckeditor5-utils
|
|
9
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
10
|
-
import { Emitter } from '@ckeditor/ckeditor5-utils/src/emittermixin';
|
|
11
|
-
import toArray from '@ckeditor/ckeditor5-utils/src/toarray';
|
|
8
|
+
import { CKEditorError, EmitterMixin, EventInfo, toArray } from '@ckeditor/ckeditor5-utils';
|
|
12
9
|
import BubblingEventInfo from './bubblingeventinfo';
|
|
13
10
|
const contextsSymbol = Symbol('bubbling contexts');
|
|
14
11
|
/**
|
|
@@ -81,7 +78,7 @@ export default function BubblingEmitterMixin(base) {
|
|
|
81
78
|
for (const context of contexts) {
|
|
82
79
|
let emitter = eventContexts.get(context);
|
|
83
80
|
if (!emitter) {
|
|
84
|
-
emitter = new
|
|
81
|
+
emitter = new (EmitterMixin())();
|
|
85
82
|
eventContexts.set(context, emitter);
|
|
86
83
|
}
|
|
87
84
|
this.listenTo(emitter, event, callback, options);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/view/observer/bubblingeventinfo
|
|
7
7
|
*/
|
|
8
|
-
import EventInfo from '@ckeditor/ckeditor5-utils
|
|
8
|
+
import { EventInfo } from '@ckeditor/ckeditor5-utils';
|
|
9
9
|
/**
|
|
10
10
|
* The event object passed to bubbling event callbacks. It is used to provide information about the event as well as a tool to
|
|
11
11
|
* manipulate it.
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import Observer from './observer';
|
|
9
9
|
import ViewSelection from '../selection';
|
|
10
|
-
import { keyCodes } from '@ckeditor/ckeditor5-utils
|
|
10
|
+
import { keyCodes } from '@ckeditor/ckeditor5-utils';
|
|
11
11
|
import { debounce } from 'lodash-es';
|
|
12
12
|
/**
|
|
13
13
|
* Fake selection observer class. If view selection is fake it is placed in dummy DOM container. This observer listens
|
|
@@ -25,6 +25,7 @@ export default class FocusObserver extends DomEventObserver {
|
|
|
25
25
|
const document = this.document;
|
|
26
26
|
document.on('focus', () => {
|
|
27
27
|
document.isFocused = true;
|
|
28
|
+
document._isFocusChanging = true;
|
|
28
29
|
// Unfortunately native `selectionchange` event is fired asynchronously.
|
|
29
30
|
// We need to wait until `SelectionObserver` handle the event and then render. Otherwise rendering will
|
|
30
31
|
// overwrite new DOM selection with selection from the view.
|
|
@@ -33,7 +34,10 @@ export default class FocusObserver extends DomEventObserver {
|
|
|
33
34
|
//
|
|
34
35
|
// Using `view.change()` instead of `view.forceRender()` to prevent double rendering
|
|
35
36
|
// in a situation where `selectionchange` already caused selection change.
|
|
36
|
-
this._renderTimeoutId = setTimeout(() =>
|
|
37
|
+
this._renderTimeoutId = setTimeout(() => {
|
|
38
|
+
document._isFocusChanging = false;
|
|
39
|
+
view.change(() => { });
|
|
40
|
+
}, 50);
|
|
37
41
|
});
|
|
38
42
|
document.on('blur', (evt, data) => {
|
|
39
43
|
const selectedEditable = document.selection.editableElement;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import DomEventObserver from './domeventobserver';
|
|
9
9
|
import DataTransfer from '../datatransfer';
|
|
10
|
-
import env from '@ckeditor/ckeditor5-utils
|
|
10
|
+
import { env } from '@ckeditor/ckeditor5-utils';
|
|
11
11
|
/**
|
|
12
12
|
* Observer for events connected with data input.
|
|
13
13
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module engine/view/observer/keyobserver
|
|
7
7
|
*/
|
|
8
8
|
import DomEventObserver from './domeventobserver';
|
|
9
|
-
import { getCode } from '@ckeditor/ckeditor5-utils
|
|
9
|
+
import { getCode } from '@ckeditor/ckeditor5-utils';
|
|
10
10
|
/**
|
|
11
11
|
* Observer for events connected with pressing keyboard keys.
|
|
12
12
|
*
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module engine/view/observer/observer
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { DomEmitterMixin } from '@ckeditor/ckeditor5-utils';
|
|
9
9
|
/**
|
|
10
10
|
* Abstract base observer class. Observers are classes which listen to DOM events, do the preliminary
|
|
11
11
|
* processing and fire events on the {@link module:engine/view/document~Document} objects.
|
|
@@ -14,7 +14,7 @@ import { Emitter as DomEmitter } from '@ckeditor/ckeditor5-utils/src/dom/emitter
|
|
|
14
14
|
*
|
|
15
15
|
* @abstract
|
|
16
16
|
*/
|
|
17
|
-
export default class Observer extends
|
|
17
|
+
export default class Observer extends DomEmitterMixin() {
|
|
18
18
|
/**
|
|
19
19
|
* Creates an instance of the observer.
|
|
20
20
|
*
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
/* global setInterval, clearInterval */
|
|
9
9
|
import Observer from './observer';
|
|
10
10
|
import MutationObserver from './mutationobserver';
|
|
11
|
-
import env from '@ckeditor/ckeditor5-utils
|
|
11
|
+
import { env } from '@ckeditor/ckeditor5-utils';
|
|
12
12
|
import { debounce } from 'lodash-es';
|
|
13
13
|
/**
|
|
14
14
|
* Selection observer class observes selection changes in the document. If a selection changes on the document this
|
|
@@ -171,6 +171,12 @@ export default class SelectionObserver extends Observer {
|
|
|
171
171
|
this._fireSelectionChangeDoneDebounced.cancel();
|
|
172
172
|
this._documentIsSelectingInactivityTimeoutDebounced.cancel();
|
|
173
173
|
}
|
|
174
|
+
// @if CK_DEBUG // _reportInfiniteLoop() {
|
|
175
|
+
// @if CK_DEBUG // throw new Error(
|
|
176
|
+
// @if CK_DEBUG // 'Selection change observer detected an infinite rendering loop.\n\n' +
|
|
177
|
+
// @if CK_DEBUG // '⚠️⚠️ Report this error on https://github.com/ckeditor/ckeditor5/issues/11658.'
|
|
178
|
+
// @if CK_DEBUG // );
|
|
179
|
+
// @if CK_DEBUG // }
|
|
174
180
|
/**
|
|
175
181
|
* Selection change listener. {@link module:engine/view/observer/mutationobserver~MutationObserver#flush Flush} mutations, check if
|
|
176
182
|
* a selection changes and fires {@link module:engine/view/document~Document#event:selectionChange} event on every change
|
|
@@ -212,7 +218,7 @@ export default class SelectionObserver extends Observer {
|
|
|
212
218
|
// by the browser and browser fixes it automatically what causes `selectionchange` event on
|
|
213
219
|
// which a loopback through a model tries to re-render the wrong selection and again.
|
|
214
220
|
//
|
|
215
|
-
// @if CK_DEBUG //
|
|
221
|
+
// @if CK_DEBUG // this._reportInfiniteLoop();
|
|
216
222
|
return;
|
|
217
223
|
}
|
|
218
224
|
if (this.selection.isSimilar(newViewSelection)) {
|
|
@@ -232,6 +238,7 @@ export default class SelectionObserver extends Observer {
|
|
|
232
238
|
// @if CK_DEBUG_TYPING // newViewSelection.getFirstRange()
|
|
233
239
|
// @if CK_DEBUG_TYPING // );
|
|
234
240
|
// @if CK_DEBUG_TYPING // }
|
|
241
|
+
this.document._isFocusChanging = false;
|
|
235
242
|
// Prepare data for new selection and fire appropriate events.
|
|
236
243
|
this.document.fire('selectionChange', data);
|
|
237
244
|
// Call `#_fireSelectionChangeDoneDebounced` every time when `selectionChange` event is fired.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import Observer from './observer';
|
|
6
6
|
import BubblingEventInfo from './bubblingeventinfo';
|
|
7
|
-
import { keyCodes } from '@ckeditor/ckeditor5-utils
|
|
7
|
+
import { keyCodes } from '@ckeditor/ckeditor5-utils';
|
|
8
8
|
/**
|
|
9
9
|
* Tab observer introduces the {@link module:engine/view/document~Document#event:tab `Document#tab`} event.
|
|
10
10
|
*
|
package/src/view/position.js
CHANGED
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
* @module engine/view/position
|
|
7
7
|
*/
|
|
8
8
|
import TypeCheckable from './typecheckable';
|
|
9
|
-
import compareArrays from '@ckeditor/ckeditor5-utils
|
|
10
|
-
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
9
|
+
import { CKEditorError, compareArrays } from '@ckeditor/ckeditor5-utils';
|
|
11
10
|
import EditableElement from './editableelement';
|
|
12
11
|
// To check if component is loaded more than once.
|
|
13
12
|
import '@ckeditor/ckeditor5-utils/src/version';
|
package/src/view/rawelement.js
CHANGED