@ckeditor/ckeditor5-engine 30.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 +17 -0
- package/README.md +30 -0
- package/package.json +70 -0
- package/src/controller/datacontroller.js +563 -0
- package/src/controller/editingcontroller.js +149 -0
- package/src/conversion/conversion.js +644 -0
- package/src/conversion/conversionhelpers.js +40 -0
- package/src/conversion/downcastdispatcher.js +914 -0
- package/src/conversion/downcasthelpers.js +1706 -0
- package/src/conversion/mapper.js +696 -0
- package/src/conversion/modelconsumable.js +329 -0
- package/src/conversion/upcastdispatcher.js +807 -0
- package/src/conversion/upcasthelpers.js +997 -0
- package/src/conversion/viewconsumable.js +623 -0
- package/src/dataprocessor/basichtmlwriter.js +32 -0
- package/src/dataprocessor/dataprocessor.jsdoc +64 -0
- package/src/dataprocessor/htmldataprocessor.js +159 -0
- package/src/dataprocessor/htmlwriter.js +22 -0
- package/src/dataprocessor/xmldataprocessor.js +161 -0
- package/src/dev-utils/model.js +482 -0
- package/src/dev-utils/operationreplayer.js +140 -0
- package/src/dev-utils/utils.js +103 -0
- package/src/dev-utils/view.js +1091 -0
- package/src/index.js +52 -0
- package/src/model/batch.js +82 -0
- package/src/model/differ.js +1282 -0
- package/src/model/document.js +483 -0
- package/src/model/documentfragment.js +390 -0
- package/src/model/documentselection.js +1261 -0
- package/src/model/element.js +438 -0
- package/src/model/history.js +138 -0
- package/src/model/item.jsdoc +14 -0
- package/src/model/liveposition.js +182 -0
- package/src/model/liverange.js +221 -0
- package/src/model/markercollection.js +553 -0
- package/src/model/model.js +934 -0
- package/src/model/node.js +507 -0
- package/src/model/nodelist.js +217 -0
- package/src/model/operation/attributeoperation.js +202 -0
- package/src/model/operation/detachoperation.js +103 -0
- package/src/model/operation/insertoperation.js +188 -0
- package/src/model/operation/markeroperation.js +154 -0
- package/src/model/operation/mergeoperation.js +216 -0
- package/src/model/operation/moveoperation.js +209 -0
- package/src/model/operation/nooperation.js +58 -0
- package/src/model/operation/operation.js +139 -0
- package/src/model/operation/operationfactory.js +49 -0
- package/src/model/operation/renameoperation.js +155 -0
- package/src/model/operation/rootattributeoperation.js +211 -0
- package/src/model/operation/splitoperation.js +254 -0
- package/src/model/operation/transform.js +2389 -0
- package/src/model/operation/utils.js +292 -0
- package/src/model/position.js +1164 -0
- package/src/model/range.js +1049 -0
- package/src/model/rootelement.js +111 -0
- package/src/model/schema.js +1851 -0
- package/src/model/selection.js +902 -0
- package/src/model/text.js +138 -0
- package/src/model/textproxy.js +279 -0
- package/src/model/treewalker.js +414 -0
- package/src/model/utils/autoparagraphing.js +77 -0
- package/src/model/utils/deletecontent.js +528 -0
- package/src/model/utils/getselectedcontent.js +150 -0
- package/src/model/utils/insertcontent.js +824 -0
- package/src/model/utils/modifyselection.js +229 -0
- package/src/model/utils/selection-post-fixer.js +297 -0
- package/src/model/writer.js +1574 -0
- package/src/view/attributeelement.js +274 -0
- package/src/view/containerelement.js +123 -0
- package/src/view/document.js +221 -0
- package/src/view/documentfragment.js +273 -0
- package/src/view/documentselection.js +387 -0
- package/src/view/domconverter.js +1437 -0
- package/src/view/downcastwriter.js +2121 -0
- package/src/view/editableelement.js +118 -0
- package/src/view/element.js +945 -0
- package/src/view/elementdefinition.jsdoc +59 -0
- package/src/view/emptyelement.js +119 -0
- package/src/view/filler.js +161 -0
- package/src/view/item.jsdoc +14 -0
- package/src/view/matcher.js +776 -0
- package/src/view/node.js +391 -0
- package/src/view/observer/arrowkeysobserver.js +58 -0
- package/src/view/observer/bubblingemittermixin.js +307 -0
- package/src/view/observer/bubblingeventinfo.js +71 -0
- package/src/view/observer/clickobserver.js +46 -0
- package/src/view/observer/compositionobserver.js +79 -0
- package/src/view/observer/domeventdata.js +82 -0
- package/src/view/observer/domeventobserver.js +99 -0
- package/src/view/observer/fakeselectionobserver.js +118 -0
- package/src/view/observer/focusobserver.js +106 -0
- package/src/view/observer/inputobserver.js +44 -0
- package/src/view/observer/keyobserver.js +83 -0
- package/src/view/observer/mouseobserver.js +56 -0
- package/src/view/observer/mutationobserver.js +345 -0
- package/src/view/observer/observer.js +118 -0
- package/src/view/observer/selectionobserver.js +242 -0
- package/src/view/placeholder.js +285 -0
- package/src/view/position.js +426 -0
- package/src/view/range.js +533 -0
- package/src/view/rawelement.js +148 -0
- package/src/view/renderer.js +1037 -0
- package/src/view/rooteditableelement.js +107 -0
- package/src/view/selection.js +718 -0
- package/src/view/styles/background.js +73 -0
- package/src/view/styles/border.js +362 -0
- package/src/view/styles/margin.js +41 -0
- package/src/view/styles/padding.js +40 -0
- package/src/view/styles/utils.js +277 -0
- package/src/view/stylesmap.js +938 -0
- package/src/view/text.js +147 -0
- package/src/view/textproxy.js +199 -0
- package/src/view/treewalker.js +496 -0
- package/src/view/uielement.js +238 -0
- package/src/view/upcastwriter.js +484 -0
- package/src/view/view.js +721 -0
- package/theme/placeholder.css +27 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @module engine/view/elementdefinition
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A plain object that describes a view element in a way that a concrete, exact view element could be created from that description.
|
|
12
|
+
*
|
|
13
|
+
* const viewDefinition = {
|
|
14
|
+
* name: 'h1',
|
|
15
|
+
* classes: [ 'foo', 'bar' ]
|
|
16
|
+
* };
|
|
17
|
+
*
|
|
18
|
+
* Above describes a view element:
|
|
19
|
+
*
|
|
20
|
+
* <h1 class="foo bar"></h1>
|
|
21
|
+
*
|
|
22
|
+
* An example with styles and attributes:
|
|
23
|
+
*
|
|
24
|
+
* const viewDefinition = {
|
|
25
|
+
* name: 'span',
|
|
26
|
+
* styles: {
|
|
27
|
+
* 'font-size': '12px',
|
|
28
|
+
* 'font-weight': 'bold'
|
|
29
|
+
* },
|
|
30
|
+
* attributes: {
|
|
31
|
+
* 'data-id': '123'
|
|
32
|
+
* }
|
|
33
|
+
* };
|
|
34
|
+
*
|
|
35
|
+
* Describes:
|
|
36
|
+
*
|
|
37
|
+
* <span style="font-size:12px;font-weight:bold" data-id="123"></span>
|
|
38
|
+
*
|
|
39
|
+
* Elements without attributes can be given simply as a string:
|
|
40
|
+
*
|
|
41
|
+
* const viewDefinition = 'p';
|
|
42
|
+
*
|
|
43
|
+
* Which will be treated as:
|
|
44
|
+
*
|
|
45
|
+
* const viewDefinition = {
|
|
46
|
+
* name: 'p'
|
|
47
|
+
* };
|
|
48
|
+
*
|
|
49
|
+
* @typedef {String|Object} module:engine/view/elementdefinition~ElementDefinition
|
|
50
|
+
*
|
|
51
|
+
* @property {String} name View element name.
|
|
52
|
+
* @property {String|Array.<String>} [classes] Class name or array of class names to match. Each name can be
|
|
53
|
+
* provided in a form of string.
|
|
54
|
+
* @property {Object} [styles] Object with key-value pairs representing styles. Each object key represents style name.
|
|
55
|
+
* Value under that key must be a string.
|
|
56
|
+
* @property {Object} [attributes] Object with key-value pairs representing attributes. Each object key represents
|
|
57
|
+
* attribute name. Value under that key must be a string.
|
|
58
|
+
* @property {Number} [priority] Element's {@link module:engine/view/attributeelement~AttributeElement#priority priority}.
|
|
59
|
+
*/
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @module engine/view/emptyelement
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import Element from './element';
|
|
11
|
+
import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
|
|
12
|
+
import Node from './node';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Empty element class. It is used to represent elements that cannot contain any child nodes (for example `<img>` elements).
|
|
16
|
+
*
|
|
17
|
+
* To create a new empty element use the
|
|
18
|
+
* {@link module:engine/view/downcastwriter~DowncastWriter#createEmptyElement `downcastWriter#createEmptyElement()`} method.
|
|
19
|
+
*
|
|
20
|
+
* @extends module:engine/view/element~Element
|
|
21
|
+
*/
|
|
22
|
+
export default class EmptyElement extends Element {
|
|
23
|
+
/**
|
|
24
|
+
* Creates new instance of EmptyElement.
|
|
25
|
+
*
|
|
26
|
+
* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-emptyelement-cannot-add` when third parameter is passed,
|
|
27
|
+
* to inform that usage of EmptyElement is incorrect (adding child nodes to EmptyElement is forbidden).
|
|
28
|
+
*
|
|
29
|
+
* @see module:engine/view/downcastwriter~DowncastWriter#createEmptyElement
|
|
30
|
+
* @protected
|
|
31
|
+
* @param {module:engine/view/document~Document} document The document instance to which this element belongs.
|
|
32
|
+
* @param {String} name Node name.
|
|
33
|
+
* @param {Object|Iterable} [attrs] Collection of attributes.
|
|
34
|
+
* @param {module:engine/view/node~Node|Iterable.<module:engine/view/node~Node>} [children]
|
|
35
|
+
* A list of nodes to be inserted into created element.
|
|
36
|
+
*/
|
|
37
|
+
constructor( document, name, attrs, children ) {
|
|
38
|
+
super( document, name, attrs, children );
|
|
39
|
+
|
|
40
|
+
// Override the default of the base class.
|
|
41
|
+
this._isAllowedInsideAttributeElement = true;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Returns `null` because filler is not needed for EmptyElements.
|
|
45
|
+
*
|
|
46
|
+
* @method #getFillerOffset
|
|
47
|
+
* @returns {null} Always returns null.
|
|
48
|
+
*/
|
|
49
|
+
this.getFillerOffset = getFillerOffset;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Checks whether this object is of the given.
|
|
54
|
+
*
|
|
55
|
+
* emptyElement.is( 'emptyElement' ); // -> true
|
|
56
|
+
* emptyElement.is( 'element' ); // -> true
|
|
57
|
+
* emptyElement.is( 'node' ); // -> true
|
|
58
|
+
* emptyElement.is( 'view:emptyElement' ); // -> true
|
|
59
|
+
* emptyElement.is( 'view:element' ); // -> true
|
|
60
|
+
* emptyElement.is( 'view:node' ); // -> true
|
|
61
|
+
*
|
|
62
|
+
* emptyElement.is( 'model:element' ); // -> false
|
|
63
|
+
* emptyElement.is( 'documentFragment' ); // -> false
|
|
64
|
+
*
|
|
65
|
+
* Assuming that the object being checked is an empty element, you can also check its
|
|
66
|
+
* {@link module:engine/view/emptyelement~EmptyElement#name name}:
|
|
67
|
+
*
|
|
68
|
+
* emptyElement.is( 'element', 'img' ); // -> true if this is a img element
|
|
69
|
+
* emptyElement.is( 'emptyElement', 'img' ); // -> same as above
|
|
70
|
+
* text.is( 'element', 'img' ); -> false
|
|
71
|
+
*
|
|
72
|
+
* {@link module:engine/view/node~Node#is Check the entire list of view objects} which implement the `is()` method.
|
|
73
|
+
*
|
|
74
|
+
* @param {String} type Type to check.
|
|
75
|
+
* @param {String} [name] Element name.
|
|
76
|
+
* @returns {Boolean}
|
|
77
|
+
*/
|
|
78
|
+
is( type, name = null ) {
|
|
79
|
+
if ( !name ) {
|
|
80
|
+
return type === 'emptyElement' || type === 'view:emptyElement' ||
|
|
81
|
+
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
|
|
82
|
+
type === 'element' || type === 'view:element' ||
|
|
83
|
+
type === 'node' || type === 'view:node';
|
|
84
|
+
} else {
|
|
85
|
+
return name === this.name && (
|
|
86
|
+
type === 'emptyElement' || type === 'view:emptyElement' ||
|
|
87
|
+
type === 'element' || type === 'view:element'
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Overrides {@link module:engine/view/element~Element#_insertChild} method.
|
|
94
|
+
* Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `view-emptyelement-cannot-add` to prevent
|
|
95
|
+
* adding any child nodes to EmptyElement.
|
|
96
|
+
*
|
|
97
|
+
* @protected
|
|
98
|
+
*/
|
|
99
|
+
_insertChild( index, nodes ) {
|
|
100
|
+
if ( nodes && ( nodes instanceof Node || Array.from( nodes ).length > 0 ) ) {
|
|
101
|
+
/**
|
|
102
|
+
* Cannot add children to {@link module:engine/view/emptyelement~EmptyElement}.
|
|
103
|
+
*
|
|
104
|
+
* @error view-emptyelement-cannot-add
|
|
105
|
+
*/
|
|
106
|
+
throw new CKEditorError(
|
|
107
|
+
'view-emptyelement-cannot-add',
|
|
108
|
+
[ this, nodes ]
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Returns `null` because block filler is not needed for EmptyElements.
|
|
115
|
+
//
|
|
116
|
+
// @returns {null}
|
|
117
|
+
function getFillerOffset() {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';
|
|
7
|
+
import isText from '@ckeditor/ckeditor5-utils/src/dom/istext';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Set of utilities related to handling block and inline fillers.
|
|
11
|
+
*
|
|
12
|
+
* Browsers do not allow to put caret in elements which does not have height. Because of it, we need to fill all
|
|
13
|
+
* empty elements which should be selectable with elements or characters called "fillers". Unfortunately there is no one
|
|
14
|
+
* universal filler, this is why two types are uses:
|
|
15
|
+
*
|
|
16
|
+
* * Block filler is an element which fill block elements, like `<p>`. CKEditor uses `<br>` as a block filler during the editing,
|
|
17
|
+
* as browsers do natively. So instead of an empty `<p>` there will be `<p><br></p>`. The advantage of block filler is that
|
|
18
|
+
* it is transparent for the selection, so when the caret is before the `<br>` and user presses right arrow he will be
|
|
19
|
+
* moved to the next paragraph, not after the `<br>`. The disadvantage is that it breaks a block, so it can not be used
|
|
20
|
+
* in the middle of a line of text. The {@link module:engine/view/filler~BR_FILLER `<br>` filler} can be replaced with any other
|
|
21
|
+
* character in the data output, for instance {@link module:engine/view/filler~NBSP_FILLER non-breaking space} or
|
|
22
|
+
* {@link module:engine/view/filler~MARKED_NBSP_FILLER marked non-breaking space}.
|
|
23
|
+
*
|
|
24
|
+
* * Inline filler is a filler which does not break a line of text, so it can be used inside the text, for instance in the empty
|
|
25
|
+
* `<b>` surrendered by text: `foo<b></b>bar`, if we want to put the caret there. CKEditor uses a sequence of the zero-width
|
|
26
|
+
* spaces as an {@link module:engine/view/filler~INLINE_FILLER inline filler} having the predetermined
|
|
27
|
+
* {@link module:engine/view/filler~INLINE_FILLER_LENGTH length}. A sequence is used, instead of a single character to
|
|
28
|
+
* avoid treating random zero-width spaces as the inline filler. Disadvantage of the inline filler is that it is not
|
|
29
|
+
* transparent for the selection. The arrow key moves the caret between zero-width spaces characters, so the additional
|
|
30
|
+
* code is needed to handle the caret.
|
|
31
|
+
*
|
|
32
|
+
* Both inline and block fillers are handled by the {@link module:engine/view/renderer~Renderer renderer} and are not present in the
|
|
33
|
+
* view.
|
|
34
|
+
*
|
|
35
|
+
* @module engine/view/filler
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Non-breaking space filler creator. This function creates the ` ` text node.
|
|
40
|
+
* It defines how the filler is created.
|
|
41
|
+
*
|
|
42
|
+
* @see module:engine/view/filler~MARKED_NBSP_FILLER
|
|
43
|
+
* @see module:engine/view/filler~BR_FILLER
|
|
44
|
+
* @function
|
|
45
|
+
*/
|
|
46
|
+
export const NBSP_FILLER = domDocument => domDocument.createTextNode( '\u00A0' );
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Marked non-breaking space filler creator. This function creates the `<span data-cke-filler="true"> </span>` element.
|
|
50
|
+
* It defines how the filler is created.
|
|
51
|
+
*
|
|
52
|
+
* @see module:engine/view/filler~NBSP_FILLER
|
|
53
|
+
* @see module:engine/view/filler~BR_FILLER
|
|
54
|
+
* @function
|
|
55
|
+
*/
|
|
56
|
+
export const MARKED_NBSP_FILLER = domDocument => {
|
|
57
|
+
const span = domDocument.createElement( 'span' );
|
|
58
|
+
span.dataset.ckeFiller = true;
|
|
59
|
+
span.innerHTML = '\u00A0';
|
|
60
|
+
|
|
61
|
+
return span;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* `<br>` filler creator. This function creates the `<br data-cke-filler="true">` element.
|
|
66
|
+
* It defines how the filler is created.
|
|
67
|
+
*
|
|
68
|
+
* @see module:engine/view/filler~NBSP_FILLER
|
|
69
|
+
* @see module:engine/view/filler~MARKED_NBSP_FILLER
|
|
70
|
+
* @function
|
|
71
|
+
*/
|
|
72
|
+
export const BR_FILLER = domDocument => {
|
|
73
|
+
const fillerBr = domDocument.createElement( 'br' );
|
|
74
|
+
fillerBr.dataset.ckeFiller = true;
|
|
75
|
+
|
|
76
|
+
return fillerBr;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Length of the {@link module:engine/view/filler~INLINE_FILLER INLINE_FILLER}.
|
|
81
|
+
*/
|
|
82
|
+
export const INLINE_FILLER_LENGTH = 7;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Inline filler which is a sequence of the word joiners.
|
|
86
|
+
*
|
|
87
|
+
* @type {String}
|
|
88
|
+
*/
|
|
89
|
+
export const INLINE_FILLER = '\u2060'.repeat( INLINE_FILLER_LENGTH );
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Checks if the node is a text node which starts with the {@link module:engine/view/filler~INLINE_FILLER inline filler}.
|
|
93
|
+
*
|
|
94
|
+
* startsWithFiller( document.createTextNode( INLINE_FILLER ) ); // true
|
|
95
|
+
* startsWithFiller( document.createTextNode( INLINE_FILLER + 'foo' ) ); // true
|
|
96
|
+
* startsWithFiller( document.createTextNode( 'foo' ) ); // false
|
|
97
|
+
* startsWithFiller( document.createElement( 'p' ) ); // false
|
|
98
|
+
*
|
|
99
|
+
* @param {Node} domNode DOM node.
|
|
100
|
+
* @returns {Boolean} True if the text node starts with the {@link module:engine/view/filler~INLINE_FILLER inline filler}.
|
|
101
|
+
*/
|
|
102
|
+
export function startsWithFiller( domNode ) {
|
|
103
|
+
return isText( domNode ) && ( domNode.data.substr( 0, INLINE_FILLER_LENGTH ) === INLINE_FILLER );
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Checks if the text node contains only the {@link module:engine/view/filler~INLINE_FILLER inline filler}.
|
|
108
|
+
*
|
|
109
|
+
* isInlineFiller( document.createTextNode( INLINE_FILLER ) ); // true
|
|
110
|
+
* isInlineFiller( document.createTextNode( INLINE_FILLER + 'foo' ) ); // false
|
|
111
|
+
*
|
|
112
|
+
* @param {Text} domText DOM text node.
|
|
113
|
+
* @returns {Boolean} True if the text node contains only the {@link module:engine/view/filler~INLINE_FILLER inline filler}.
|
|
114
|
+
*/
|
|
115
|
+
export function isInlineFiller( domText ) {
|
|
116
|
+
return domText.data.length == INLINE_FILLER_LENGTH && startsWithFiller( domText );
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Get string data from the text node, removing an {@link module:engine/view/filler~INLINE_FILLER inline filler} from it,
|
|
121
|
+
* if text node contains it.
|
|
122
|
+
*
|
|
123
|
+
* getDataWithoutFiller( document.createTextNode( INLINE_FILLER + 'foo' ) ) == 'foo' // true
|
|
124
|
+
* getDataWithoutFiller( document.createTextNode( 'foo' ) ) == 'foo' // true
|
|
125
|
+
*
|
|
126
|
+
* @param {Text} domText DOM text node, possible with inline filler.
|
|
127
|
+
* @returns {String} Data without filler.
|
|
128
|
+
*/
|
|
129
|
+
export function getDataWithoutFiller( domText ) {
|
|
130
|
+
if ( startsWithFiller( domText ) ) {
|
|
131
|
+
return domText.data.slice( INLINE_FILLER_LENGTH );
|
|
132
|
+
} else {
|
|
133
|
+
return domText.data;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Assign key observer which move cursor from the end of the inline filler to the beginning of it when
|
|
139
|
+
* the left arrow is pressed, so the filler does not break navigation.
|
|
140
|
+
*
|
|
141
|
+
* @param {module:engine/view/view~View} view View controller instance we should inject quirks handling on.
|
|
142
|
+
*/
|
|
143
|
+
export function injectQuirksHandling( view ) {
|
|
144
|
+
view.document.on( 'arrowKey', jumpOverInlineFiller, { priority: 'low' } );
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Move cursor from the end of the inline filler to the beginning of it when, so the filler does not break navigation.
|
|
148
|
+
function jumpOverInlineFiller( evt, data ) {
|
|
149
|
+
if ( data.keyCode == keyCodes.arrowleft ) {
|
|
150
|
+
const domSelection = data.domTarget.ownerDocument.defaultView.getSelection();
|
|
151
|
+
|
|
152
|
+
if ( domSelection.rangeCount == 1 && domSelection.getRangeAt( 0 ).collapsed ) {
|
|
153
|
+
const domParent = domSelection.getRangeAt( 0 ).startContainer;
|
|
154
|
+
const domOffset = domSelection.getRangeAt( 0 ).startOffset;
|
|
155
|
+
|
|
156
|
+
if ( startsWithFiller( domParent ) && domOffset <= INLINE_FILLER_LENGTH ) {
|
|
157
|
+
domSelection.collapse( domParent, 0 );
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @module engine/view/item
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Item is a {@link module:engine/view/node~Node Node} or {@link module:engine/view/textproxy~TextProxy TextProxy}.
|
|
12
|
+
*
|
|
13
|
+
* @typedef {module:engine/view/node~Node|module:engine/view/textproxy~TextProxy} module:engine/view/item~Item
|
|
14
|
+
*/
|