@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
|
@@ -1,220 +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/attributeelement
|
|
7
|
-
*/
|
|
8
|
-
import { ViewElement } from './element.js';
|
|
9
|
-
import { CKEditorError } from '@ckeditor/ckeditor5-utils';
|
|
10
|
-
// Default attribute priority.
|
|
11
|
-
const DEFAULT_PRIORITY = 10;
|
|
12
|
-
/**
|
|
13
|
-
* Attribute elements are used to represent formatting elements in the view (think – `<b>`, `<span style="font-size: 2em">`, etc.).
|
|
14
|
-
* Most often they are created when downcasting model text attributes.
|
|
15
|
-
*
|
|
16
|
-
* Editing engine does not define a fixed HTML DTD. This is why a feature developer needs to choose between various
|
|
17
|
-
* types (container element, {@link module:engine/view/attributeelement~ViewAttributeElement attribute element},
|
|
18
|
-
* {@link module:engine/view/emptyelement~ViewEmptyElement empty element}, etc) when developing a feature.
|
|
19
|
-
*
|
|
20
|
-
* To create a new attribute element instance use the
|
|
21
|
-
* {@link module:engine/view/downcastwriter~ViewDowncastWriter#createAttributeElement `ViewDowncastWriter#createAttributeElement()`} method.
|
|
22
|
-
*/
|
|
23
|
-
export class ViewAttributeElement extends ViewElement {
|
|
24
|
-
static DEFAULT_PRIORITY = DEFAULT_PRIORITY;
|
|
25
|
-
/**
|
|
26
|
-
* Element priority. Decides in what order elements are wrapped by {@link module:engine/view/downcastwriter~ViewDowncastWriter}.
|
|
27
|
-
*
|
|
28
|
-
* @internal
|
|
29
|
-
* @readonly
|
|
30
|
-
*/
|
|
31
|
-
_priority = DEFAULT_PRIORITY;
|
|
32
|
-
/**
|
|
33
|
-
* Element identifier. If set, it is used by {@link module:engine/view/element~ViewElement#isSimilar},
|
|
34
|
-
* and then two elements are considered similar if, and only if they have the same `_id`.
|
|
35
|
-
*
|
|
36
|
-
* @internal
|
|
37
|
-
* @readonly
|
|
38
|
-
*/
|
|
39
|
-
_id = null;
|
|
40
|
-
/**
|
|
41
|
-
* Keeps all the attribute elements that have the same {@link module:engine/view/attributeelement~ViewAttributeElement#id ids}
|
|
42
|
-
* and still exist in the view tree.
|
|
43
|
-
*
|
|
44
|
-
* This property is managed by {@link module:engine/view/downcastwriter~ViewDowncastWriter}.
|
|
45
|
-
*/
|
|
46
|
-
_clonesGroup = null;
|
|
47
|
-
/**
|
|
48
|
-
* Creates an attribute element.
|
|
49
|
-
*
|
|
50
|
-
* @see module:engine/view/downcastwriter~ViewDowncastWriter#createAttributeElement
|
|
51
|
-
* @see module:engine/view/element~ViewElement
|
|
52
|
-
* @protected
|
|
53
|
-
* @param document The document instance to which this element belongs.
|
|
54
|
-
* @param name Node name.
|
|
55
|
-
* @param attrs Collection of attributes.
|
|
56
|
-
* @param children A list of nodes to be inserted into created element.
|
|
57
|
-
*/
|
|
58
|
-
constructor(document, name, attrs, children) {
|
|
59
|
-
super(document, name, attrs, children);
|
|
60
|
-
this.getFillerOffset = getFillerOffset;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Element priority. Decides in what order elements are wrapped by {@link module:engine/view/downcastwriter~ViewDowncastWriter}.
|
|
64
|
-
*/
|
|
65
|
-
get priority() {
|
|
66
|
-
return this._priority;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Element identifier. If set, it is used by {@link module:engine/view/element~ViewElement#isSimilar},
|
|
70
|
-
* and then two elements are considered similar if, and only if they have the same `id`.
|
|
71
|
-
*/
|
|
72
|
-
get id() {
|
|
73
|
-
return this._id;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Returns all {@link module:engine/view/attributeelement~ViewAttributeElement attribute elements} that has the
|
|
77
|
-
* same {@link module:engine/view/attributeelement~ViewAttributeElement#id id} and are in the view tree (were not removed).
|
|
78
|
-
*
|
|
79
|
-
* Note: If this element has been removed from the tree, returned set will not include it.
|
|
80
|
-
*
|
|
81
|
-
* Throws {@link module:utils/ckeditorerror~CKEditorError attribute-element-get-elements-with-same-id-no-id}
|
|
82
|
-
* if this element has no `id`.
|
|
83
|
-
*
|
|
84
|
-
* @returns Set containing all the attribute elements
|
|
85
|
-
* with the same `id` that were added and not removed from the view tree.
|
|
86
|
-
*/
|
|
87
|
-
getElementsWithSameId() {
|
|
88
|
-
if (this.id === null) {
|
|
89
|
-
/**
|
|
90
|
-
* Cannot get elements with the same id for an attribute element without id.
|
|
91
|
-
*
|
|
92
|
-
* @error attribute-element-get-elements-with-same-id-no-id
|
|
93
|
-
*/
|
|
94
|
-
throw new CKEditorError('attribute-element-get-elements-with-same-id-no-id', this);
|
|
95
|
-
}
|
|
96
|
-
return new Set(this._clonesGroup);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Checks if this element is similar to other element.
|
|
100
|
-
*
|
|
101
|
-
* If none of elements has set {@link module:engine/view/attributeelement~ViewAttributeElement#id}, then both elements
|
|
102
|
-
* should have the same name, attributes and priority to be considered as similar. Two similar elements can contain
|
|
103
|
-
* different set of children nodes.
|
|
104
|
-
*
|
|
105
|
-
* If at least one element has {@link module:engine/view/attributeelement~ViewAttributeElement#id} set, then both
|
|
106
|
-
* elements have to have the same {@link module:engine/view/attributeelement~ViewAttributeElement#id} value to be
|
|
107
|
-
* considered similar.
|
|
108
|
-
*
|
|
109
|
-
* Similarity is important for {@link module:engine/view/downcastwriter~ViewDowncastWriter}. For example:
|
|
110
|
-
*
|
|
111
|
-
* * two following similar elements can be merged together into one, longer element,
|
|
112
|
-
* * {@link module:engine/view/downcastwriter~ViewDowncastWriter#unwrap} checks similarity of passed element and processed element to
|
|
113
|
-
* decide whether processed element should be unwrapped,
|
|
114
|
-
* * etc.
|
|
115
|
-
*/
|
|
116
|
-
isSimilar(otherElement) {
|
|
117
|
-
// If any element has an `id` set, just compare the ids.
|
|
118
|
-
if (this.id !== null || otherElement.id !== null) {
|
|
119
|
-
return this.id === otherElement.id;
|
|
120
|
-
}
|
|
121
|
-
return super.isSimilar(otherElement) && this.priority == otherElement.priority;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Converts `ViewAttributeElement` instance to plain object and returns it.
|
|
125
|
-
*
|
|
126
|
-
* @returns `ViewAttributeElement` instance converted to plain object.
|
|
127
|
-
*/
|
|
128
|
-
toJSON() {
|
|
129
|
-
const json = super.toJSON();
|
|
130
|
-
json.type = 'AttributeElement';
|
|
131
|
-
return json;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Clones provided element with priority.
|
|
135
|
-
*
|
|
136
|
-
* @internal
|
|
137
|
-
* @param deep If set to `true` clones element and all its children recursively. When set to `false`,
|
|
138
|
-
* element will be cloned without any children.
|
|
139
|
-
* @returns Clone of this element.
|
|
140
|
-
*/
|
|
141
|
-
_clone(deep = false) {
|
|
142
|
-
const cloned = super._clone(deep);
|
|
143
|
-
// Clone priority too.
|
|
144
|
-
cloned._priority = this._priority;
|
|
145
|
-
// And id too.
|
|
146
|
-
cloned._id = this._id;
|
|
147
|
-
return cloned;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Used by {@link module:engine/view/element~ViewElement#_mergeAttributesFrom} to verify if the given element can be merged without
|
|
151
|
-
* conflicts into this element.
|
|
152
|
-
*
|
|
153
|
-
* @internal
|
|
154
|
-
*/
|
|
155
|
-
_canMergeAttributesFrom(otherElement) {
|
|
156
|
-
// Can't merge if any of elements have an id or a difference of priority.
|
|
157
|
-
if (this.id !== null || otherElement.id !== null || this.priority !== otherElement.priority) {
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
return super._canMergeAttributesFrom(otherElement);
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Used by {@link module:engine/view/element~ViewElement#_subtractAttributesOf} to verify if the given element attributes
|
|
164
|
-
* can be fully subtracted from this element.
|
|
165
|
-
*
|
|
166
|
-
* @internal
|
|
167
|
-
*/
|
|
168
|
-
_canSubtractAttributesOf(otherElement) {
|
|
169
|
-
// Can't subtract if any of elements have an id or a difference of priority.
|
|
170
|
-
if (this.id !== null || otherElement.id !== null || this.priority !== otherElement.priority) {
|
|
171
|
-
return false;
|
|
172
|
-
}
|
|
173
|
-
return super._canSubtractAttributesOf(otherElement);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
// The magic of type inference using `is` method is centralized in `TypeCheckable` class.
|
|
177
|
-
// Proper overload would interfere with that.
|
|
178
|
-
ViewAttributeElement.prototype.is = function (type, name) {
|
|
179
|
-
if (!name) {
|
|
180
|
-
return type === 'attributeElement' || type === 'view:attributeElement' ||
|
|
181
|
-
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
|
|
182
|
-
type === 'element' || type === 'view:element' ||
|
|
183
|
-
type === 'node' || type === 'view:node';
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
return name === this.name && (type === 'attributeElement' || type === 'view:attributeElement' ||
|
|
187
|
-
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
|
|
188
|
-
type === 'element' || type === 'view:element');
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
/**
|
|
192
|
-
* Returns block {@link module:engine/view/filler~Filler filler} offset or `null` if block filler is not needed.
|
|
193
|
-
*
|
|
194
|
-
* @returns Block filler offset or `null` if block filler is not needed.
|
|
195
|
-
*/
|
|
196
|
-
function getFillerOffset() {
|
|
197
|
-
// <b>foo</b> does not need filler.
|
|
198
|
-
if (nonUiChildrenCount(this)) {
|
|
199
|
-
return null;
|
|
200
|
-
}
|
|
201
|
-
let element = this.parent;
|
|
202
|
-
// <p><b></b></p> needs filler -> <p><b><br></b></p>
|
|
203
|
-
while (element && element.is('attributeElement')) {
|
|
204
|
-
if (nonUiChildrenCount(element) > 1) {
|
|
205
|
-
return null;
|
|
206
|
-
}
|
|
207
|
-
element = element.parent;
|
|
208
|
-
}
|
|
209
|
-
if (!element || nonUiChildrenCount(element) > 1) {
|
|
210
|
-
return null;
|
|
211
|
-
}
|
|
212
|
-
// Render block filler at the end of element (after all ui elements).
|
|
213
|
-
return this.childCount;
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Returns total count of children that are not {@link module:engine/view/uielement~ViewUIElement UIElements}.
|
|
217
|
-
*/
|
|
218
|
-
function nonUiChildrenCount(element) {
|
|
219
|
-
return Array.from(element.getChildren()).filter(element => !element.is('uiElement')).length;
|
|
220
|
-
}
|
|
@@ -1,91 +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/containerelement
|
|
7
|
-
*/
|
|
8
|
-
import { ViewElement } from './element.js';
|
|
9
|
-
/**
|
|
10
|
-
* Containers are elements which define document structure. They define boundaries for
|
|
11
|
-
* {@link module:engine/view/attributeelement~ViewAttributeElement attributes}.
|
|
12
|
-
* They are mostly used for block elements like `<p>` or `<div>`.
|
|
13
|
-
*
|
|
14
|
-
* Editing engine does not define a fixed HTML DTD. This is why a feature developer needs to choose between various
|
|
15
|
-
* types (container element, {@link module:engine/view/attributeelement~ViewAttributeElement attribute element},
|
|
16
|
-
* {@link module:engine/view/emptyelement~ViewEmptyElement empty element}, etc) when developing a feature.
|
|
17
|
-
*
|
|
18
|
-
* The container element should be your default choice when writing a converter, unless:
|
|
19
|
-
*
|
|
20
|
-
* * this element represents a model text attribute (then use {@link module:engine/view/attributeelement~ViewAttributeElement}),
|
|
21
|
-
* * this is an empty element like `<img>` (then use {@link module:engine/view/emptyelement~ViewEmptyElement}),
|
|
22
|
-
* * this is a root element,
|
|
23
|
-
* * this is a nested editable element (then use {@link module:engine/view/editableelement~ViewEditableElement}).
|
|
24
|
-
*
|
|
25
|
-
* To create a new container element instance use the
|
|
26
|
-
* {@link module:engine/view/downcastwriter~ViewDowncastWriter#createContainerElement `ViewDowncastWriter#createContainerElement()`}
|
|
27
|
-
* method.
|
|
28
|
-
*/
|
|
29
|
-
export class ViewContainerElement extends ViewElement {
|
|
30
|
-
/**
|
|
31
|
-
* Creates a container element.
|
|
32
|
-
*
|
|
33
|
-
* @see module:engine/view/downcastwriter~ViewDowncastWriter#createContainerElement
|
|
34
|
-
* @see module:engine/view/element~ViewElement
|
|
35
|
-
* @internal
|
|
36
|
-
* @param document The document instance to which this element belongs.
|
|
37
|
-
* @param name Node name.
|
|
38
|
-
* @param attrs Collection of attributes.
|
|
39
|
-
* @param children A list of nodes to be inserted into created element.
|
|
40
|
-
*/
|
|
41
|
-
constructor(document, name, attrs, children) {
|
|
42
|
-
super(document, name, attrs, children);
|
|
43
|
-
this.getFillerOffset = getViewFillerOffset;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Converts `ViewContainerElement` instance to plain object and returns it.
|
|
47
|
-
*
|
|
48
|
-
* @returns `ViewContainerElement` instance converted to plain object.
|
|
49
|
-
*/
|
|
50
|
-
toJSON() {
|
|
51
|
-
const json = super.toJSON();
|
|
52
|
-
json.type = 'ContainerElement';
|
|
53
|
-
return json;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
// The magic of type inference using `is` method is centralized in `TypeCheckable` class.
|
|
57
|
-
// Proper overload would interfere with that.
|
|
58
|
-
ViewContainerElement.prototype.is = function (type, name) {
|
|
59
|
-
if (!name) {
|
|
60
|
-
return type === 'containerElement' || type === 'view:containerElement' ||
|
|
61
|
-
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
|
|
62
|
-
type === 'element' || type === 'view:element' ||
|
|
63
|
-
type === 'node' || type === 'view:node';
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
return name === this.name && (type === 'containerElement' || type === 'view:containerElement' ||
|
|
67
|
-
// From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
|
|
68
|
-
type === 'element' || type === 'view:element');
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* Returns block {@link module:engine/view/filler filler} offset or `null` if block filler is not needed.
|
|
73
|
-
*
|
|
74
|
-
* @returns Block filler offset or `null` if block filler is not needed.
|
|
75
|
-
*/
|
|
76
|
-
export function getViewFillerOffset() {
|
|
77
|
-
const children = [...this.getChildren()];
|
|
78
|
-
const lastChild = children[this.childCount - 1];
|
|
79
|
-
// Block filler is required after a `<br>` if it's the last element in its container. See #1422.
|
|
80
|
-
if (lastChild && lastChild.is('element', 'br')) {
|
|
81
|
-
return this.childCount;
|
|
82
|
-
}
|
|
83
|
-
for (const child of children) {
|
|
84
|
-
// If there's any non-UI element – don't render the bogus.
|
|
85
|
-
if (!child.is('uiElement')) {
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
// If there are only UI elements – render the bogus at the end of the element.
|
|
90
|
-
return this.childCount;
|
|
91
|
-
}
|
package/src/view/datatransfer.js
DELETED
|
@@ -1,106 +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
|
-
* A facade over the native [`DataTransfer`](https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer) object.
|
|
7
|
-
*/
|
|
8
|
-
export class ViewDataTransfer {
|
|
9
|
-
/**
|
|
10
|
-
* The array of files created from the native `DataTransfer#files` or `DataTransfer#items`.
|
|
11
|
-
*/
|
|
12
|
-
_files;
|
|
13
|
-
/**
|
|
14
|
-
* The native DataTransfer object.
|
|
15
|
-
*/
|
|
16
|
-
_native;
|
|
17
|
-
/**
|
|
18
|
-
* @param nativeDataTransfer The native [`DataTransfer`](https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer) object.
|
|
19
|
-
* @param options.cacheFiles Whether `files` list should be initialized in the constructor.
|
|
20
|
-
*/
|
|
21
|
-
constructor(nativeDataTransfer, options = {}) {
|
|
22
|
-
// We should store references to the File instances in case someone would like to process this files
|
|
23
|
-
// outside the event handler. Files are stored only for `drop` and `paste` events because they are not usable
|
|
24
|
-
// in other events and are generating a huge delay on Firefox while dragging.
|
|
25
|
-
// See https://github.com/ckeditor/ckeditor5/issues/13366.
|
|
26
|
-
this._files = options.cacheFiles ? getFiles(nativeDataTransfer) : null;
|
|
27
|
-
this._native = nativeDataTransfer;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* The array of files created from the native `DataTransfer#files` or `DataTransfer#items`.
|
|
31
|
-
*/
|
|
32
|
-
get files() {
|
|
33
|
-
if (!this._files) {
|
|
34
|
-
this._files = getFiles(this._native);
|
|
35
|
-
}
|
|
36
|
-
return this._files;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Returns an array of available native content types.
|
|
40
|
-
*/
|
|
41
|
-
get types() {
|
|
42
|
-
return this._native.types;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Gets the data from the data transfer by its MIME type.
|
|
46
|
-
*
|
|
47
|
-
* ```ts
|
|
48
|
-
* dataTransfer.getData( 'text/plain' );
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* @param type The MIME type. E.g. `text/html` or `text/plain`.
|
|
52
|
-
*/
|
|
53
|
-
getData(type) {
|
|
54
|
-
return this._native.getData(type);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Sets the data in the data transfer.
|
|
58
|
-
*
|
|
59
|
-
* @param type The MIME type. E.g. `text/html` or `text/plain`.
|
|
60
|
-
*/
|
|
61
|
-
setData(type, data) {
|
|
62
|
-
this._native.setData(type, data);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* The effect that is allowed for a drag operation.
|
|
66
|
-
*/
|
|
67
|
-
set effectAllowed(value) {
|
|
68
|
-
this._native.effectAllowed = value;
|
|
69
|
-
}
|
|
70
|
-
get effectAllowed() {
|
|
71
|
-
return this._native.effectAllowed;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* The actual drop effect.
|
|
75
|
-
*/
|
|
76
|
-
set dropEffect(value) {
|
|
77
|
-
this._native.dropEffect = value;
|
|
78
|
-
}
|
|
79
|
-
get dropEffect() {
|
|
80
|
-
return this._native.dropEffect;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Set a preview image of the dragged content.
|
|
84
|
-
*/
|
|
85
|
-
setDragImage(image, x, y) {
|
|
86
|
-
this._native.setDragImage(image, x, y);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Whether the dragging operation was canceled.
|
|
90
|
-
*/
|
|
91
|
-
get isCanceled() {
|
|
92
|
-
return this._native.dropEffect == 'none' || !!this._native.mozUserCancelled;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function getFiles(nativeDataTransfer) {
|
|
96
|
-
// DataTransfer.files and items are array-like and might not have an iterable interface.
|
|
97
|
-
const files = Array.from(nativeDataTransfer.files || []);
|
|
98
|
-
const items = Array.from(nativeDataTransfer.items || []);
|
|
99
|
-
if (files.length) {
|
|
100
|
-
return files;
|
|
101
|
-
}
|
|
102
|
-
// Chrome has empty DataTransfer.files, but allows getting files through the items interface.
|
|
103
|
-
return items
|
|
104
|
-
.filter(item => item.kind === 'file')
|
|
105
|
-
.map(item => item.getAsFile());
|
|
106
|
-
}
|
package/src/view/document.js
DELETED
|
@@ -1,139 +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/document
|
|
7
|
-
*/
|
|
8
|
-
import { ViewDocumentSelection } from './documentselection.js';
|
|
9
|
-
import { BubblingEmitterMixin } from './observer/bubblingemittermixin.js';
|
|
10
|
-
import { Collection, ObservableMixin } from '@ckeditor/ckeditor5-utils';
|
|
11
|
-
// @if CK_DEBUG_ENGINE // const { logDocument } = require( '../dev-utils/utils' );
|
|
12
|
-
/**
|
|
13
|
-
* Document class creates an abstract layer over the content editable area, contains a tree of view elements and
|
|
14
|
-
* {@link module:engine/view/documentselection~ViewDocumentSelection view selection} associated with this document.
|
|
15
|
-
*/
|
|
16
|
-
export class ViewDocument extends /* #__PURE__ */ BubblingEmitterMixin(/* #__PURE__ */ ObservableMixin()) {
|
|
17
|
-
/**
|
|
18
|
-
* Selection done on this document.
|
|
19
|
-
*/
|
|
20
|
-
selection;
|
|
21
|
-
/**
|
|
22
|
-
* Roots of the view tree. Collection of the {@link module:engine/view/element~ViewElement view elements}.
|
|
23
|
-
*
|
|
24
|
-
* View roots are created as a result of binding between {@link module:engine/view/document~ViewDocument#roots} and
|
|
25
|
-
* {@link module:engine/model/document~ModelDocument#roots} and this is handled by
|
|
26
|
-
* {@link module:engine/controller/editingcontroller~EditingController}, so to create view root we need to create
|
|
27
|
-
* model root using {@link module:engine/model/document~ModelDocument#createRoot}.
|
|
28
|
-
*/
|
|
29
|
-
roots;
|
|
30
|
-
/**
|
|
31
|
-
* The styles processor instance used by this document when normalizing styles.
|
|
32
|
-
*/
|
|
33
|
-
stylesProcessor;
|
|
34
|
-
/**
|
|
35
|
-
* Post-fixer callbacks registered to the view document.
|
|
36
|
-
*/
|
|
37
|
-
_postFixers = new Set();
|
|
38
|
-
/**
|
|
39
|
-
* Creates a Document instance.
|
|
40
|
-
*
|
|
41
|
-
* @param stylesProcessor The styles processor instance.
|
|
42
|
-
*/
|
|
43
|
-
constructor(stylesProcessor) {
|
|
44
|
-
super();
|
|
45
|
-
this.selection = new ViewDocumentSelection();
|
|
46
|
-
this.roots = new Collection({ idProperty: 'rootName' });
|
|
47
|
-
this.stylesProcessor = stylesProcessor;
|
|
48
|
-
this.set('isReadOnly', false);
|
|
49
|
-
this.set('isFocused', false);
|
|
50
|
-
this.set('isSelecting', false);
|
|
51
|
-
this.set('isComposing', false);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Gets a {@link module:engine/view/document~ViewDocument#roots view root element} with the specified name. If the name is not
|
|
55
|
-
* specific "main" root is returned.
|
|
56
|
-
*
|
|
57
|
-
* @param name Name of the root.
|
|
58
|
-
* @returns The view root element with the specified name or null when there is no root of given name.
|
|
59
|
-
*/
|
|
60
|
-
getRoot(name = 'main') {
|
|
61
|
-
return this.roots.get(name);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Allows registering post-fixer callbacks. A post-fixers mechanism allows to update the view tree just before it is rendered
|
|
65
|
-
* to the DOM.
|
|
66
|
-
*
|
|
67
|
-
* Post-fixers are executed right after all changes from the outermost change block were applied but
|
|
68
|
-
* before the {@link module:engine/view/view~EditingView#event:render render event} is fired. If a post-fixer callback made
|
|
69
|
-
* a change, it should return `true`. When this happens, all post-fixers are fired again to check if something else should
|
|
70
|
-
* not be fixed in the new document tree state.
|
|
71
|
-
*
|
|
72
|
-
* View post-fixers are useful when you want to apply some fixes whenever the view structure changes. Keep in mind that
|
|
73
|
-
* changes executed in a view post-fixer should not break model-view mapping.
|
|
74
|
-
*
|
|
75
|
-
* The types of changes which should be safe:
|
|
76
|
-
*
|
|
77
|
-
* * adding or removing attribute from elements,
|
|
78
|
-
* * changes inside of {@link module:engine/view/uielement~ViewUIElement UI elements},
|
|
79
|
-
* * {@link module:engine/controller/editingcontroller~EditingController#reconvertItem marking some of the model elements to be
|
|
80
|
-
* re-converted}.
|
|
81
|
-
*
|
|
82
|
-
* Try to avoid changes which touch view structure:
|
|
83
|
-
*
|
|
84
|
-
* * you should not add or remove nor wrap or unwrap any view elements,
|
|
85
|
-
* * you should not change the editor data model in a view post-fixer.
|
|
86
|
-
*
|
|
87
|
-
* As a parameter, a post-fixer callback receives a {@link module:engine/view/downcastwriter~ViewDowncastWriter downcast writer}.
|
|
88
|
-
*
|
|
89
|
-
* Typically, a post-fixer will look like this:
|
|
90
|
-
*
|
|
91
|
-
* ```ts
|
|
92
|
-
* editor.editing.view.document.registerPostFixer( writer => {
|
|
93
|
-
* if ( checkSomeCondition() ) {
|
|
94
|
-
* writer.doSomething();
|
|
95
|
-
*
|
|
96
|
-
* // Let other post-fixers know that something changed.
|
|
97
|
-
* return true;
|
|
98
|
-
* }
|
|
99
|
-
*
|
|
100
|
-
* return false;
|
|
101
|
-
* } );
|
|
102
|
-
* ```
|
|
103
|
-
*
|
|
104
|
-
* Note that nothing happens right after you register a post-fixer (e.g. execute such a code in the console).
|
|
105
|
-
* That is because adding a post-fixer does not execute it.
|
|
106
|
-
* The post-fixer will be executed as soon as any change in the document needs to cause its rendering.
|
|
107
|
-
* If you want to re-render the editor's view after registering the post-fixer then you should do it manually by calling
|
|
108
|
-
* {@link module:engine/view/view~EditingView#forceRender `view.forceRender()`}.
|
|
109
|
-
*
|
|
110
|
-
* If you need to register a callback which is executed when DOM elements are already updated,
|
|
111
|
-
* use {@link module:engine/view/view~EditingView#event:render render event}.
|
|
112
|
-
*/
|
|
113
|
-
registerPostFixer(postFixer) {
|
|
114
|
-
this._postFixers.add(postFixer);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Destroys this instance. Makes sure that all observers are destroyed and listeners removed.
|
|
118
|
-
*/
|
|
119
|
-
destroy() {
|
|
120
|
-
this.roots.forEach(root => root.destroy());
|
|
121
|
-
this.stopListening();
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Performs post-fixer loops. Executes post-fixer callbacks as long as none of them has done any changes to the model.
|
|
125
|
-
*
|
|
126
|
-
* @internal
|
|
127
|
-
*/
|
|
128
|
-
_callPostFixers(writer) {
|
|
129
|
-
let wasFixed = false;
|
|
130
|
-
do {
|
|
131
|
-
for (const callback of this._postFixers) {
|
|
132
|
-
wasFixed = callback(writer);
|
|
133
|
-
if (wasFixed) {
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
} while (wasFixed);
|
|
138
|
-
}
|
|
139
|
-
}
|