@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.
Files changed (258) hide show
  1. package/LICENSE.md +1 -1
  2. package/{src → dist}/engineconfig.d.ts +6 -15
  3. package/dist/index-editor.css +38 -15
  4. package/dist/index.css +37 -37
  5. package/dist/index.css.map +1 -1
  6. package/{src → dist}/index.d.ts +0 -1
  7. package/dist/index.js +588 -94
  8. package/dist/index.js.map +1 -1
  9. package/{src → dist}/model/model.d.ts +10 -4
  10. package/{src → dist}/model/selection.d.ts +1 -1
  11. package/{src → dist}/view/downcastwriter.d.ts +3 -2
  12. package/{src → dist}/view/element.d.ts +2 -2
  13. package/{src → dist}/view/matcher.d.ts +4 -2
  14. package/dist/view/styles/background.d.ts +18 -0
  15. package/{src → dist}/view/styles/border.d.ts +0 -12
  16. package/{src → dist}/view/styles/margin.d.ts +0 -13
  17. package/{src → dist}/view/styles/padding.d.ts +0 -13
  18. package/{src → dist}/view/styles/utils.d.ts +12 -0
  19. package/package.json +20 -39
  20. package/src/controller/datacontroller.js +0 -522
  21. package/src/controller/editingcontroller.js +0 -181
  22. package/src/conversion/conversion.js +0 -606
  23. package/src/conversion/conversionhelpers.js +0 -33
  24. package/src/conversion/downcastdispatcher.js +0 -563
  25. package/src/conversion/downcasthelpers.js +0 -2160
  26. package/src/conversion/mapper.js +0 -1050
  27. package/src/conversion/modelconsumable.js +0 -331
  28. package/src/conversion/upcastdispatcher.js +0 -470
  29. package/src/conversion/upcasthelpers.js +0 -952
  30. package/src/conversion/viewconsumable.js +0 -541
  31. package/src/dataprocessor/basichtmlwriter.js +0 -22
  32. package/src/dataprocessor/dataprocessor.js +0 -5
  33. package/src/dataprocessor/htmldataprocessor.js +0 -107
  34. package/src/dataprocessor/htmlwriter.js +0 -5
  35. package/src/dataprocessor/xmldataprocessor.js +0 -127
  36. package/src/dev-utils/model.js +0 -396
  37. package/src/dev-utils/operationreplayer.js +0 -116
  38. package/src/dev-utils/utils.js +0 -122
  39. package/src/dev-utils/view.js +0 -990
  40. package/src/engineconfig.js +0 -5
  41. package/src/index.js +0 -134
  42. package/src/legacyerrors.js +0 -17
  43. package/src/model/batch.js +0 -98
  44. package/src/model/differ.js +0 -1288
  45. package/src/model/document.js +0 -398
  46. package/src/model/documentfragment.js +0 -332
  47. package/src/model/documentselection.js +0 -1026
  48. package/src/model/element.js +0 -323
  49. package/src/model/history.js +0 -206
  50. package/src/model/item.js +0 -5
  51. package/src/model/liveposition.js +0 -93
  52. package/src/model/liverange.js +0 -121
  53. package/src/model/markercollection.js +0 -436
  54. package/src/model/model.js +0 -866
  55. package/src/model/node.js +0 -371
  56. package/src/model/nodelist.js +0 -244
  57. package/src/model/operation/attributeoperation.js +0 -172
  58. package/src/model/operation/detachoperation.js +0 -87
  59. package/src/model/operation/insertoperation.js +0 -153
  60. package/src/model/operation/markeroperation.js +0 -136
  61. package/src/model/operation/mergeoperation.js +0 -184
  62. package/src/model/operation/moveoperation.js +0 -179
  63. package/src/model/operation/nooperation.js +0 -48
  64. package/src/model/operation/operation.js +0 -78
  65. package/src/model/operation/operationfactory.js +0 -44
  66. package/src/model/operation/renameoperation.js +0 -128
  67. package/src/model/operation/rootattributeoperation.js +0 -173
  68. package/src/model/operation/rootoperation.js +0 -106
  69. package/src/model/operation/splitoperation.js +0 -214
  70. package/src/model/operation/transform.js +0 -2211
  71. package/src/model/operation/utils.js +0 -217
  72. package/src/model/position.js +0 -1041
  73. package/src/model/range.js +0 -880
  74. package/src/model/rootelement.js +0 -82
  75. package/src/model/schema.js +0 -1542
  76. package/src/model/selection.js +0 -814
  77. package/src/model/text.js +0 -92
  78. package/src/model/textproxy.js +0 -202
  79. package/src/model/treewalker.js +0 -313
  80. package/src/model/typecheckable.js +0 -16
  81. package/src/model/utils/autoparagraphing.js +0 -63
  82. package/src/model/utils/deletecontent.js +0 -509
  83. package/src/model/utils/getselectedcontent.js +0 -126
  84. package/src/model/utils/insertcontent.js +0 -750
  85. package/src/model/utils/insertobject.js +0 -135
  86. package/src/model/utils/modifyselection.js +0 -187
  87. package/src/model/utils/selection-post-fixer.js +0 -264
  88. package/src/model/writer.js +0 -1318
  89. package/src/view/attributeelement.js +0 -220
  90. package/src/view/containerelement.js +0 -91
  91. package/src/view/datatransfer.js +0 -106
  92. package/src/view/document.js +0 -139
  93. package/src/view/documentfragment.js +0 -251
  94. package/src/view/documentselection.js +0 -270
  95. package/src/view/domconverter.js +0 -1661
  96. package/src/view/downcastwriter.js +0 -1589
  97. package/src/view/editableelement.js +0 -74
  98. package/src/view/element.js +0 -1053
  99. package/src/view/elementdefinition.js +0 -5
  100. package/src/view/emptyelement.js +0 -83
  101. package/src/view/filler.js +0 -161
  102. package/src/view/item.js +0 -5
  103. package/src/view/matcher.js +0 -437
  104. package/src/view/node.js +0 -238
  105. package/src/view/observer/arrowkeysobserver.js +0 -40
  106. package/src/view/observer/bubblingemittermixin.js +0 -215
  107. package/src/view/observer/bubblingeventinfo.js +0 -49
  108. package/src/view/observer/clickobserver.js +0 -26
  109. package/src/view/observer/compositionobserver.js +0 -64
  110. package/src/view/observer/domeventdata.js +0 -63
  111. package/src/view/observer/domeventobserver.js +0 -81
  112. package/src/view/observer/fakeselectionobserver.js +0 -95
  113. package/src/view/observer/focusobserver.js +0 -166
  114. package/src/view/observer/inputobserver.js +0 -236
  115. package/src/view/observer/keyobserver.js +0 -36
  116. package/src/view/observer/mouseobserver.js +0 -26
  117. package/src/view/observer/mutationobserver.js +0 -219
  118. package/src/view/observer/observer.js +0 -92
  119. package/src/view/observer/pointerobserver.js +0 -26
  120. package/src/view/observer/selectionobserver.js +0 -318
  121. package/src/view/observer/tabobserver.js +0 -42
  122. package/src/view/observer/touchobserver.js +0 -26
  123. package/src/view/placeholder.js +0 -285
  124. package/src/view/position.js +0 -341
  125. package/src/view/range.js +0 -451
  126. package/src/view/rawelement.js +0 -115
  127. package/src/view/renderer.js +0 -1148
  128. package/src/view/rooteditableelement.js +0 -78
  129. package/src/view/selection.js +0 -594
  130. package/src/view/styles/background.d.ts +0 -33
  131. package/src/view/styles/background.js +0 -74
  132. package/src/view/styles/border.js +0 -316
  133. package/src/view/styles/margin.js +0 -34
  134. package/src/view/styles/padding.js +0 -34
  135. package/src/view/styles/utils.js +0 -219
  136. package/src/view/stylesmap.js +0 -941
  137. package/src/view/text.js +0 -110
  138. package/src/view/textproxy.js +0 -136
  139. package/src/view/tokenlist.js +0 -194
  140. package/src/view/treewalker.js +0 -389
  141. package/src/view/typecheckable.js +0 -19
  142. package/src/view/uielement.js +0 -194
  143. package/src/view/upcastwriter.js +0 -363
  144. package/src/view/view.js +0 -579
  145. package/theme/placeholder.css +0 -36
  146. package/theme/renderer.css +0 -9
  147. /package/{src → dist}/controller/datacontroller.d.ts +0 -0
  148. /package/{src → dist}/controller/editingcontroller.d.ts +0 -0
  149. /package/{src → dist}/conversion/conversion.d.ts +0 -0
  150. /package/{src → dist}/conversion/conversionhelpers.d.ts +0 -0
  151. /package/{src → dist}/conversion/downcastdispatcher.d.ts +0 -0
  152. /package/{src → dist}/conversion/downcasthelpers.d.ts +0 -0
  153. /package/{src → dist}/conversion/mapper.d.ts +0 -0
  154. /package/{src → dist}/conversion/modelconsumable.d.ts +0 -0
  155. /package/{src → dist}/conversion/upcastdispatcher.d.ts +0 -0
  156. /package/{src → dist}/conversion/upcasthelpers.d.ts +0 -0
  157. /package/{src → dist}/conversion/viewconsumable.d.ts +0 -0
  158. /package/{src → dist}/dataprocessor/basichtmlwriter.d.ts +0 -0
  159. /package/{src → dist}/dataprocessor/dataprocessor.d.ts +0 -0
  160. /package/{src → dist}/dataprocessor/htmldataprocessor.d.ts +0 -0
  161. /package/{src → dist}/dataprocessor/htmlwriter.d.ts +0 -0
  162. /package/{src → dist}/dataprocessor/xmldataprocessor.d.ts +0 -0
  163. /package/{src → dist}/dev-utils/model.d.ts +0 -0
  164. /package/{src → dist}/dev-utils/operationreplayer.d.ts +0 -0
  165. /package/{src → dist}/dev-utils/utils.d.ts +0 -0
  166. /package/{src → dist}/dev-utils/view.d.ts +0 -0
  167. /package/{src → dist}/legacyerrors.d.ts +0 -0
  168. /package/{src → dist}/model/batch.d.ts +0 -0
  169. /package/{src → dist}/model/differ.d.ts +0 -0
  170. /package/{src → dist}/model/document.d.ts +0 -0
  171. /package/{src → dist}/model/documentfragment.d.ts +0 -0
  172. /package/{src → dist}/model/documentselection.d.ts +0 -0
  173. /package/{src → dist}/model/element.d.ts +0 -0
  174. /package/{src → dist}/model/history.d.ts +0 -0
  175. /package/{src → dist}/model/item.d.ts +0 -0
  176. /package/{src → dist}/model/liveposition.d.ts +0 -0
  177. /package/{src → dist}/model/liverange.d.ts +0 -0
  178. /package/{src → dist}/model/markercollection.d.ts +0 -0
  179. /package/{src → dist}/model/node.d.ts +0 -0
  180. /package/{src → dist}/model/nodelist.d.ts +0 -0
  181. /package/{src → dist}/model/operation/attributeoperation.d.ts +0 -0
  182. /package/{src → dist}/model/operation/detachoperation.d.ts +0 -0
  183. /package/{src → dist}/model/operation/insertoperation.d.ts +0 -0
  184. /package/{src → dist}/model/operation/markeroperation.d.ts +0 -0
  185. /package/{src → dist}/model/operation/mergeoperation.d.ts +0 -0
  186. /package/{src → dist}/model/operation/moveoperation.d.ts +0 -0
  187. /package/{src → dist}/model/operation/nooperation.d.ts +0 -0
  188. /package/{src → dist}/model/operation/operation.d.ts +0 -0
  189. /package/{src → dist}/model/operation/operationfactory.d.ts +0 -0
  190. /package/{src → dist}/model/operation/renameoperation.d.ts +0 -0
  191. /package/{src → dist}/model/operation/rootattributeoperation.d.ts +0 -0
  192. /package/{src → dist}/model/operation/rootoperation.d.ts +0 -0
  193. /package/{src → dist}/model/operation/splitoperation.d.ts +0 -0
  194. /package/{src → dist}/model/operation/transform.d.ts +0 -0
  195. /package/{src → dist}/model/operation/utils.d.ts +0 -0
  196. /package/{src → dist}/model/position.d.ts +0 -0
  197. /package/{src → dist}/model/range.d.ts +0 -0
  198. /package/{src → dist}/model/rootelement.d.ts +0 -0
  199. /package/{src → dist}/model/schema.d.ts +0 -0
  200. /package/{src → dist}/model/text.d.ts +0 -0
  201. /package/{src → dist}/model/textproxy.d.ts +0 -0
  202. /package/{src → dist}/model/treewalker.d.ts +0 -0
  203. /package/{src → dist}/model/typecheckable.d.ts +0 -0
  204. /package/{src → dist}/model/utils/autoparagraphing.d.ts +0 -0
  205. /package/{src → dist}/model/utils/deletecontent.d.ts +0 -0
  206. /package/{src → dist}/model/utils/getselectedcontent.d.ts +0 -0
  207. /package/{src → dist}/model/utils/insertcontent.d.ts +0 -0
  208. /package/{src → dist}/model/utils/insertobject.d.ts +0 -0
  209. /package/{src → dist}/model/utils/modifyselection.d.ts +0 -0
  210. /package/{src → dist}/model/utils/selection-post-fixer.d.ts +0 -0
  211. /package/{src → dist}/model/writer.d.ts +0 -0
  212. /package/{src → dist}/view/attributeelement.d.ts +0 -0
  213. /package/{src → dist}/view/containerelement.d.ts +0 -0
  214. /package/{src → dist}/view/datatransfer.d.ts +0 -0
  215. /package/{src → dist}/view/document.d.ts +0 -0
  216. /package/{src → dist}/view/documentfragment.d.ts +0 -0
  217. /package/{src → dist}/view/documentselection.d.ts +0 -0
  218. /package/{src → dist}/view/domconverter.d.ts +0 -0
  219. /package/{src → dist}/view/editableelement.d.ts +0 -0
  220. /package/{src → dist}/view/elementdefinition.d.ts +0 -0
  221. /package/{src → dist}/view/emptyelement.d.ts +0 -0
  222. /package/{src → dist}/view/filler.d.ts +0 -0
  223. /package/{src → dist}/view/item.d.ts +0 -0
  224. /package/{src → dist}/view/node.d.ts +0 -0
  225. /package/{src → dist}/view/observer/arrowkeysobserver.d.ts +0 -0
  226. /package/{src → dist}/view/observer/bubblingemittermixin.d.ts +0 -0
  227. /package/{src → dist}/view/observer/bubblingeventinfo.d.ts +0 -0
  228. /package/{src → dist}/view/observer/clickobserver.d.ts +0 -0
  229. /package/{src → dist}/view/observer/compositionobserver.d.ts +0 -0
  230. /package/{src → dist}/view/observer/domeventdata.d.ts +0 -0
  231. /package/{src → dist}/view/observer/domeventobserver.d.ts +0 -0
  232. /package/{src → dist}/view/observer/fakeselectionobserver.d.ts +0 -0
  233. /package/{src → dist}/view/observer/focusobserver.d.ts +0 -0
  234. /package/{src → dist}/view/observer/inputobserver.d.ts +0 -0
  235. /package/{src → dist}/view/observer/keyobserver.d.ts +0 -0
  236. /package/{src → dist}/view/observer/mouseobserver.d.ts +0 -0
  237. /package/{src → dist}/view/observer/mutationobserver.d.ts +0 -0
  238. /package/{src → dist}/view/observer/observer.d.ts +0 -0
  239. /package/{src → dist}/view/observer/pointerobserver.d.ts +0 -0
  240. /package/{src → dist}/view/observer/selectionobserver.d.ts +0 -0
  241. /package/{src → dist}/view/observer/tabobserver.d.ts +0 -0
  242. /package/{src → dist}/view/observer/touchobserver.d.ts +0 -0
  243. /package/{src → dist}/view/placeholder.d.ts +0 -0
  244. /package/{src → dist}/view/position.d.ts +0 -0
  245. /package/{src → dist}/view/range.d.ts +0 -0
  246. /package/{src → dist}/view/rawelement.d.ts +0 -0
  247. /package/{src → dist}/view/renderer.d.ts +0 -0
  248. /package/{src → dist}/view/rooteditableelement.d.ts +0 -0
  249. /package/{src → dist}/view/selection.d.ts +0 -0
  250. /package/{src → dist}/view/stylesmap.d.ts +0 -0
  251. /package/{src → dist}/view/text.d.ts +0 -0
  252. /package/{src → dist}/view/textproxy.d.ts +0 -0
  253. /package/{src → dist}/view/tokenlist.d.ts +0 -0
  254. /package/{src → dist}/view/treewalker.d.ts +0 -0
  255. /package/{src → dist}/view/typecheckable.d.ts +0 -0
  256. /package/{src → dist}/view/uielement.d.ts +0 -0
  257. /package/{src → dist}/view/upcastwriter.d.ts +0 -0
  258. /package/{src → dist}/view/view.d.ts +0 -0
package/src/view/text.js DELETED
@@ -1,110 +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/text
7
- */
8
- import { ViewNode } from './node.js';
9
- /**
10
- * Tree view text node.
11
- *
12
- * The constructor of this class should not be used directly. To create a new text node instance
13
- * use the {@link module:engine/view/downcastwriter~ViewDowncastWriter#createText `ViewDowncastWriter#createText()`}
14
- * method when working on data downcasted from the model or the
15
- * {@link module:engine/view/upcastwriter~ViewUpcastWriter#createText `ViewUpcastWriter#createText()`}
16
- * method when working on non-semantic views.
17
- */
18
- export class ViewText extends ViewNode {
19
- /**
20
- * The text content.
21
- *
22
- * Setting the data fires the {@link module:engine/view/node~ViewNode#event:change:text change event}.
23
- */
24
- _textData;
25
- /**
26
- * Creates a tree view text node.
27
- *
28
- * @see module:engine/view/downcastwriter~ViewDowncastWriter#createText
29
- * @internal
30
- * @param document The document instance to which this text node belongs.
31
- * @param data The text's data.
32
- */
33
- constructor(document, data) {
34
- super(document);
35
- this._textData = data;
36
- }
37
- /**
38
- * The text content.
39
- */
40
- get data() {
41
- return this._textData;
42
- }
43
- /**
44
- * The `_data` property is controlled by a getter and a setter.
45
- *
46
- * The getter is required when using the addition assignment operator on protected property:
47
- *
48
- * ```ts
49
- * const foo = downcastWriter.createText( 'foo' );
50
- * const bar = downcastWriter.createText( 'bar' );
51
- *
52
- * foo._data += bar.data; // executes: `foo._data = foo._data + bar.data`
53
- * console.log( foo.data ); // prints: 'foobar'
54
- * ```
55
- *
56
- * If the protected getter didn't exist, `foo._data` will return `undefined` and result of the merge will be invalid.
57
- *
58
- * The setter sets data and fires the {@link module:engine/view/node~ViewNode#event:change:text change event}.
59
- *
60
- * @internal
61
- */
62
- get _data() {
63
- return this.data;
64
- }
65
- set _data(data) {
66
- this._fireChange('text', this);
67
- this._textData = data;
68
- }
69
- /**
70
- * Checks if this text node is similar to other text node.
71
- * Both nodes should have the same data to be considered as similar.
72
- *
73
- * @param otherNode Node to check if it is same as this node.
74
- */
75
- isSimilar(otherNode) {
76
- if (!(otherNode instanceof ViewText)) {
77
- return false;
78
- }
79
- return this === otherNode || this.data === otherNode.data;
80
- }
81
- /**
82
- * Converts `ViewText` instance to plain object and returns it.
83
- *
84
- * @returns `ViewText` instance converted to plain object.
85
- */
86
- toJSON() {
87
- const json = super.toJSON();
88
- json.type = 'Text';
89
- json.data = this.data;
90
- return json;
91
- }
92
- /**
93
- * Clones this node.
94
- *
95
- * @internal
96
- * @returns Text node that is a clone of this node.
97
- */
98
- _clone() {
99
- return new ViewText(this.document, this.data);
100
- }
101
- }
102
- // The magic of type inference using `is` method is centralized in `TypeCheckable` class.
103
- // Proper overload would interfere with that.
104
- ViewText.prototype.is = function (type) {
105
- return type === '$text' || type === 'view:$text' ||
106
- // This are legacy values kept for backward compatibility.
107
- type === 'text' || type === 'view:text' ||
108
- // From super.is(). This is highly utilised method and cannot call super. See ckeditor/ckeditor5#6529.
109
- type === 'node' || type === 'view:node';
110
- };
@@ -1,136 +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/textproxy
7
- */
8
- import { ViewTypeCheckable } from './typecheckable.js';
9
- import { CKEditorError } from '@ckeditor/ckeditor5-utils';
10
- /**
11
- * ViewTextProxy is a wrapper for substring of {@link module:engine/view/text~ViewText}. Instance of this class is created by
12
- * {@link module:engine/view/treewalker~ViewTreeWalker} when only a part of {@link module:engine/view/text~ViewText} needs to be returned.
13
- *
14
- * `ViewTextProxy` has an API similar to {@link module:engine/view/text~ViewText Text} and allows to do most of the common tasks performed
15
- * on view nodes.
16
- *
17
- * **Note:** Some `ViewTextProxy` instances may represent whole text node, not just a part of it.
18
- * See {@link module:engine/view/textproxy~ViewTextProxy#isPartial}.
19
- *
20
- * **Note:** `ViewTextProxy` is a readonly interface.
21
- *
22
- * **Note:** `ViewTextProxy` instances are created on the fly basing
23
- * on the current state of parent {@link module:engine/view/text~ViewText}.
24
- * Because of this it is highly unrecommended to store references to `TextProxy instances because they might get
25
- * invalidated due to operations on Document. Also ViewTextProxy is not a {@link module:engine/view/node~ViewNode} so it cannot be
26
- * inserted as a child of {@link module:engine/view/element~ViewElement}.
27
- *
28
- * `ViewTextProxy` instances are created by {@link module:engine/view/treewalker~ViewTreeWalker view tree walker}.
29
- * You should not need to create an instance of this class by your own.
30
- */
31
- export class ViewTextProxy extends ViewTypeCheckable {
32
- /**
33
- * Reference to the {@link module:engine/view/text~ViewText} element which ViewTextProxy is a substring.
34
- */
35
- textNode;
36
- /**
37
- * Text data represented by this text proxy.
38
- */
39
- data;
40
- /**
41
- * Offset in the `textNode` where this `ViewTextProxy` instance starts.
42
- */
43
- offsetInText;
44
- /**
45
- * Creates a text proxy.
46
- *
47
- * @internal
48
- * @param textNode Text node which part is represented by this text proxy.
49
- * @param offsetInText Offset in {@link module:engine/view/textproxy~ViewTextProxy#textNode text node}
50
- * from which the text proxy starts.
51
- * @param length Text proxy length, that is how many text node's characters, starting from `offsetInText` it represents.
52
- */
53
- constructor(textNode, offsetInText, length) {
54
- super();
55
- this.textNode = textNode;
56
- if (offsetInText < 0 || offsetInText > textNode.data.length) {
57
- /**
58
- * Given offsetInText value is incorrect.
59
- *
60
- * @error view-textproxy-wrong-offsetintext
61
- */
62
- throw new CKEditorError('view-textproxy-wrong-offsetintext', this);
63
- }
64
- if (length < 0 || offsetInText + length > textNode.data.length) {
65
- /**
66
- * Given length value is incorrect.
67
- *
68
- * @error view-textproxy-wrong-length
69
- */
70
- throw new CKEditorError('view-textproxy-wrong-length', this);
71
- }
72
- this.data = textNode.data.substring(offsetInText, offsetInText + length);
73
- this.offsetInText = offsetInText;
74
- }
75
- /**
76
- * Offset size of this node.
77
- */
78
- get offsetSize() {
79
- return this.data.length;
80
- }
81
- /**
82
- * Flag indicating whether `ViewTextProxy` instance covers only part of the original {@link module:engine/view/text~ViewText text node}
83
- * (`true`) or the whole text node (`false`).
84
- *
85
- * This is `false` when text proxy starts at the very beginning of {@link module:engine/view/textproxy~ViewTextProxy#textNode textNode}
86
- * ({@link module:engine/view/textproxy~ViewTextProxy#offsetInText offsetInText} equals `0`) and text proxy sizes is equal to
87
- * text node size.
88
- */
89
- get isPartial() {
90
- return this.data.length !== this.textNode.data.length;
91
- }
92
- /**
93
- * Parent of this text proxy, which is same as parent of text node represented by this text proxy.
94
- */
95
- get parent() {
96
- return this.textNode.parent;
97
- }
98
- /**
99
- * Root of this text proxy, which is same as root of text node represented by this text proxy.
100
- */
101
- get root() {
102
- return this.textNode.root;
103
- }
104
- /**
105
- * {@link module:engine/view/document~ViewDocument View document} that owns this text proxy, or `null` if the text proxy is inside
106
- * {@link module:engine/view/documentfragment~ViewDocumentFragment document fragment}.
107
- */
108
- get document() {
109
- return this.textNode.document;
110
- }
111
- /**
112
- * Returns ancestors array of this text proxy.
113
- *
114
- * @param options Options object.
115
- * @param options.includeSelf When set to `true`, textNode will be also included in parent's array.
116
- * @param options.parentFirst When set to `true`, array will be sorted from text proxy parent to
117
- * root element, otherwise root element will be the first item in the array.
118
- * @returns Array with ancestors.
119
- */
120
- getAncestors(options = {}) {
121
- const ancestors = [];
122
- let parent = options.includeSelf ? this.textNode : this.parent;
123
- while (parent !== null) {
124
- ancestors[options.parentFirst ? 'push' : 'unshift'](parent);
125
- parent = parent.parent;
126
- }
127
- return ancestors;
128
- }
129
- }
130
- // The magic of type inference using `is` method is centralized in `TypeCheckable` class.
131
- // Proper overload would interfere with that.
132
- ViewTextProxy.prototype.is = function (type) {
133
- return type === '$textProxy' || type === 'view:$textProxy' ||
134
- // This are legacy values kept for backward compatibility.
135
- type === 'textProxy' || type === 'view:textProxy';
136
- };
@@ -1,194 +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/tokenlist
7
- */
8
- import { toArray } from '@ckeditor/ckeditor5-utils';
9
- /**
10
- * Token list. Allows handling (adding, removing, retrieving) a set of tokens (for example class names).
11
- */
12
- export class ViewTokenList {
13
- /**
14
- * The set of tokens.
15
- */
16
- _set = new Set();
17
- /**
18
- * Returns true if token list has no tokens set.
19
- */
20
- get isEmpty() {
21
- return this._set.size == 0;
22
- }
23
- /**
24
- * Number of tokens.
25
- */
26
- get size() {
27
- return this._set.size;
28
- }
29
- /**
30
- * Checks if a given token is set.
31
- */
32
- has(name) {
33
- return this._set.has(name);
34
- }
35
- /**
36
- * Returns all tokens.
37
- */
38
- keys() {
39
- return Array.from(this._set.keys());
40
- }
41
- /**
42
- * Resets the value to the given one.
43
- */
44
- setTo(value) {
45
- this.clear();
46
- for (const token of value.split(/\s+/)) {
47
- if (token) {
48
- this._set.add(token);
49
- }
50
- }
51
- return this;
52
- }
53
- /**
54
- * Sets a given token without affecting other tokens.
55
- */
56
- set(tokens) {
57
- for (const token of toArray(tokens)) {
58
- if (token) {
59
- this._set.add(token);
60
- }
61
- }
62
- }
63
- /**
64
- * Removes given token.
65
- */
66
- remove(tokens) {
67
- for (const token of toArray(tokens)) {
68
- this._set.delete(token);
69
- }
70
- }
71
- /**
72
- * Removes all tokens.
73
- */
74
- clear() {
75
- this._set.clear();
76
- }
77
- /**
78
- * Returns a normalized tokens string.
79
- */
80
- toString() {
81
- return Array.from(this._set).join(' ');
82
- }
83
- /**
84
- * Returns `true` if both attributes have the same tokens.
85
- */
86
- isSimilar(other) {
87
- if (this.size !== other.size) {
88
- return false;
89
- }
90
- for (const token of this.keys()) {
91
- if (!other.has(token)) {
92
- return false;
93
- }
94
- }
95
- return true;
96
- }
97
- /**
98
- * Clones the attribute value.
99
- *
100
- * @internal
101
- */
102
- _clone() {
103
- const clone = new this.constructor();
104
- clone._set = new Set(this._set);
105
- return clone;
106
- }
107
- /**
108
- * Used by the {@link module:engine/view/matcher~Matcher Matcher} to collect matching attribute tokens.
109
- *
110
- * @internal
111
- * @param tokenPattern The matched token name pattern.
112
- * @returns An array of matching tokens.
113
- */
114
- _getTokensMatch(tokenPattern) {
115
- const match = [];
116
- if (tokenPattern === true) {
117
- for (const token of this._set.keys()) {
118
- match.push(token);
119
- }
120
- return match;
121
- }
122
- if (typeof tokenPattern == 'string') {
123
- for (const token of tokenPattern.split(/\s+/)) {
124
- if (this._set.has(token)) {
125
- match.push(token);
126
- }
127
- else {
128
- return undefined;
129
- }
130
- }
131
- return match;
132
- }
133
- for (const token of this._set.keys()) {
134
- if (token.match(tokenPattern)) {
135
- match.push(token);
136
- }
137
- }
138
- return match.length ? match : undefined;
139
- }
140
- /**
141
- * Returns a list of consumables for the attribute.
142
- *
143
- * Could be filtered by the given token name.
144
- *
145
- * @internal
146
- */
147
- _getConsumables(name) {
148
- return name ? [name] : this.keys();
149
- }
150
- /**
151
- * Used by {@link module:engine/view/element~ViewElement#_canMergeAttributesFrom} to verify if the given attribute
152
- * can be merged without conflicts into the attribute.
153
- *
154
- * This method is indirectly used by the {@link module:engine/view/downcastwriter~ViewDowncastWriter} while downcasting
155
- * an {@link module:engine/view/attributeelement~ViewAttributeElement} to merge it with other `AttributeElement`.
156
- *
157
- * @internal
158
- */
159
- _canMergeFrom() {
160
- return true;
161
- }
162
- /**
163
- * Used by {@link module:engine/view/element~ViewElement#_mergeAttributesFrom} to merge a given attribute into the attribute.
164
- *
165
- * This method is indirectly used by the {@link module:engine/view/downcastwriter~ViewDowncastWriter} while down-casting
166
- * an {@link module:engine/view/attributeelement~ViewAttributeElement} to merge it with other ViewAttributeElement.
167
- *
168
- * @internal
169
- */
170
- _mergeFrom(other) {
171
- for (const token of other._set.keys()) {
172
- if (!this._set.has(token)) {
173
- this._set.add(token);
174
- }
175
- }
176
- }
177
- /**
178
- * Used by {@link module:engine/view/element~ViewElement#_canSubtractAttributesOf} to verify if the given attribute
179
- * can be fully subtracted from the attribute.
180
- *
181
- * This method is indirectly used by the {@link module:engine/view/downcastwriter~ViewDowncastWriter} while down-casting
182
- * an {@link module:engine/view/attributeelement~ViewAttributeElement} to unwrap the ViewAttributeElement.
183
- *
184
- * @internal
185
- */
186
- _isMatching(other) {
187
- for (const name of other._set.keys()) {
188
- if (!this._set.has(name)) {
189
- return false;
190
- }
191
- }
192
- return true;
193
- }
194
- }