@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/view.js DELETED
@@ -1,579 +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/view
7
- */
8
- import { ViewDocument } from './document.js';
9
- import { ViewDowncastWriter } from './downcastwriter.js';
10
- import { ViewRenderer } from './renderer.js';
11
- import { ViewDomConverter } from './domconverter.js';
12
- import { ViewPosition } from './position.js';
13
- import { ViewRange } from './range.js';
14
- import { ViewSelection } from './selection.js';
15
- import { KeyObserver } from './observer/keyobserver.js';
16
- import { FakeSelectionObserver } from './observer/fakeselectionobserver.js';
17
- import { MutationObserver } from './observer/mutationobserver.js';
18
- import { SelectionObserver } from './observer/selectionobserver.js';
19
- import { FocusObserver } from './observer/focusobserver.js';
20
- import { CompositionObserver } from './observer/compositionobserver.js';
21
- import { InputObserver } from './observer/inputobserver.js';
22
- import { ArrowKeysObserver } from './observer/arrowkeysobserver.js';
23
- import { TabObserver } from './observer/tabobserver.js';
24
- import { CKEditorError, env, ObservableMixin, scrollViewportToShowTarget } from '@ckeditor/ckeditor5-utils';
25
- import { injectUiElementHandling } from './uielement.js';
26
- import { injectQuirksHandling } from './filler.js';
27
- import { cloneDeep } from 'es-toolkit/compat';
28
- /**
29
- * Editor's view controller class. Its main responsibility is DOM - View management for editing purposes, to provide
30
- * abstraction over the DOM structure and events and hide all browsers quirks.
31
- *
32
- * View controller renders view document to DOM whenever view structure changes. To determine when view can be rendered,
33
- * all changes need to be done using the {@link module:engine/view/view~EditingView#change} method, using
34
- * {@link module:engine/view/downcastwriter~ViewDowncastWriter}:
35
- *
36
- * ```ts
37
- * view.change( writer => {
38
- * writer.insert( position, writer.createText( 'foo' ) );
39
- * } );
40
- * ```
41
- *
42
- * View controller also register {@link module:engine/view/observer/observer~Observer observers} which observes changes
43
- * on DOM and fire events on the {@link module:engine/view/document~ViewDocument Document}.
44
- * Note that the following observers are added by the class constructor and are always available:
45
- *
46
- * * {@link module:engine/view/observer/selectionobserver~SelectionObserver},
47
- * * {@link module:engine/view/observer/focusobserver~FocusObserver},
48
- * * {@link module:engine/view/observer/keyobserver~KeyObserver},
49
- * * {@link module:engine/view/observer/fakeselectionobserver~FakeSelectionObserver}.
50
- * * {@link module:engine/view/observer/compositionobserver~CompositionObserver}.
51
- * * {@link module:engine/view/observer/inputobserver~InputObserver}.
52
- * * {@link module:engine/view/observer/arrowkeysobserver~ArrowKeysObserver}.
53
- * * {@link module:engine/view/observer/tabobserver~TabObserver}.
54
- *
55
- * This class also {@link module:engine/view/view~EditingView#attachDomRoot binds the DOM and the view elements}.
56
- *
57
- * If you do not need full a DOM - view management, and only want to transform a tree of view elements to a tree of DOM
58
- * elements you do not need this controller. You can use the {@link module:engine/view/domconverter~ViewDomConverter ViewDomConverter}
59
- * instead.
60
- */
61
- export class EditingView extends /* #__PURE__ */ ObservableMixin() {
62
- /**
63
- * Instance of the {@link module:engine/view/document~ViewDocument} associated with this view controller.
64
- */
65
- document;
66
- /**
67
- * Instance of the {@link module:engine/view/domconverter~ViewDomConverter domConverter} used by
68
- * {@link module:engine/view/view~EditingView#_renderer renderer}
69
- * and {@link module:engine/view/observer/observer~Observer observers}.
70
- */
71
- domConverter;
72
- /**
73
- * Roots of the DOM tree. Map on the `HTMLElement`s with roots names as keys.
74
- */
75
- domRoots = new Map();
76
- /**
77
- * Instance of the {@link module:engine/view/renderer~ViewRenderer renderer}.
78
- */
79
- _renderer;
80
- /**
81
- * A DOM root attributes cache. It saves the initial values of DOM root attributes before the DOM element
82
- * is {@link module:engine/view/view~EditingView#attachDomRoot attached} to the view so later on, when
83
- * the view is destroyed ({@link module:engine/view/view~EditingView#detachDomRoot}), they can be easily restored.
84
- * This way, the DOM element can go back to the (clean) state as if the editing view never used it.
85
- */
86
- _initialDomRootAttributes = new WeakMap();
87
- /**
88
- * Map of registered {@link module:engine/view/observer/observer~Observer observers}.
89
- */
90
- _observers = new Map();
91
- /**
92
- * ViewDowncastWriter instance used in {@link #change change method} callbacks.
93
- */
94
- _writer;
95
- /**
96
- * Is set to `true` when {@link #change view changes} are currently in progress.
97
- */
98
- _ongoingChange = false;
99
- /**
100
- * Used to prevent calling {@link #forceRender} and {@link #change} during rendering view to the DOM.
101
- */
102
- _postFixersInProgress = false;
103
- /**
104
- * Internal flag to temporary disable rendering. See the usage in the {@link #_disableRendering}.
105
- */
106
- _renderingDisabled = false;
107
- /**
108
- * Internal flag that disables rendering when there are no changes since the last rendering.
109
- * It stores information about changed selection and changed elements from attached document roots.
110
- */
111
- _hasChangedSinceTheLastRendering = false;
112
- /**
113
- * @param stylesProcessor The styles processor instance.
114
- */
115
- constructor(stylesProcessor) {
116
- super();
117
- this.document = new ViewDocument(stylesProcessor);
118
- this.domConverter = new ViewDomConverter(this.document);
119
- this.set('isRenderingInProgress', false);
120
- this.set('hasDomSelection', false);
121
- this._renderer = new ViewRenderer(this.domConverter, this.document.selection);
122
- this._renderer.bind('isFocused', 'isSelecting', 'isComposing')
123
- .to(this.document, 'isFocused', 'isSelecting', 'isComposing');
124
- this._writer = new ViewDowncastWriter(this.document);
125
- // Add default observers.
126
- // Make sure that this list matches AlwaysRegisteredViewObservers type.
127
- this.addObserver(MutationObserver);
128
- this.addObserver(FocusObserver);
129
- this.addObserver(SelectionObserver);
130
- this.addObserver(KeyObserver);
131
- this.addObserver(FakeSelectionObserver);
132
- this.addObserver(CompositionObserver);
133
- this.addObserver(ArrowKeysObserver);
134
- this.addObserver(InputObserver);
135
- this.addObserver(TabObserver);
136
- // Inject quirks handlers.
137
- injectQuirksHandling(this);
138
- injectUiElementHandling(this);
139
- // Use 'normal' priority so that rendering is performed as first when using that priority.
140
- this.on('render', () => {
141
- this._render();
142
- // Informs that layout has changed after render.
143
- this.document.fire('layoutChanged');
144
- // Reset the `_hasChangedSinceTheLastRendering` flag after rendering.
145
- this._hasChangedSinceTheLastRendering = false;
146
- });
147
- // Listen to the document selection changes directly.
148
- this.listenTo(this.document.selection, 'change', () => {
149
- this._hasChangedSinceTheLastRendering = true;
150
- });
151
- // Trigger re-render if only the focus changed.
152
- this.listenTo(this.document, 'change:isFocused', () => {
153
- this._hasChangedSinceTheLastRendering = true;
154
- });
155
- // Remove ranges from DOM selection if editor is blurred.
156
- // See https://github.com/ckeditor/ckeditor5/issues/5753.
157
- if (env.isiOS) {
158
- this.listenTo(this.document, 'blur', (evt, data) => {
159
- const relatedViewElement = this.domConverter.mapDomToView(data.domEvent.relatedTarget);
160
- // Do not modify DOM selection if focus is moved to other editable of the same editor.
161
- if (!relatedViewElement) {
162
- this.domConverter._clearDomSelection();
163
- }
164
- });
165
- }
166
- // Listen to external content mutations (directly in the DOM) and mark them to get verified by the renderer.
167
- this.listenTo(this.document, 'mutations', (evt, { mutations }) => {
168
- mutations.forEach(mutation => this._renderer.markToSync(mutation.type, mutation.node));
169
- }, { priority: 'low' });
170
- // After all mutated nodes were marked to sync we can trigger view to DOM synchronization
171
- // to make sure the DOM structure matches the view.
172
- this.listenTo(this.document, 'mutations', () => {
173
- this.forceRender();
174
- }, { priority: 'lowest' });
175
- }
176
- /**
177
- * Attaches a DOM root element to the view element and enable all observers on that element.
178
- * Also {@link module:engine/view/renderer~ViewRenderer#markToSync mark element} to be synchronized
179
- * with the view what means that all child nodes will be removed and replaced with content of the view root.
180
- *
181
- * This method also will change view element name as the same as tag name of given dom root.
182
- * Name is always transformed to lower case.
183
- *
184
- * **Note:** Use {@link #detachDomRoot `detachDomRoot()`} to revert this action.
185
- *
186
- * @param domRoot DOM root element.
187
- * @param name Name of the root.
188
- */
189
- attachDomRoot(domRoot, name = 'main') {
190
- const viewRoot = this.document.getRoot(name);
191
- // Set view root name the same as DOM root tag name.
192
- viewRoot._name = domRoot.tagName.toLowerCase();
193
- const initialDomRootAttributes = {};
194
- // 1. Copy and cache the attributes to remember the state of the element before attaching.
195
- // The cached attributes will be restored in detachDomRoot() so the element goes to the
196
- // clean state as if the editing view never used it.
197
- // 2. Apply the attributes using the view writer, so they all go under the control of the engine.
198
- // The editing view takes over the attribute management completely because various
199
- // features (e.g. addPlaceholder()) require dynamic changes of those attributes and they
200
- // cannot be managed by the engine and the UI library at the same time.
201
- for (const { name, value } of Array.from(domRoot.attributes)) {
202
- initialDomRootAttributes[name] = value;
203
- // Do not use writer.setAttribute() for the class attribute. The EditableUIView class
204
- // and its descendants could have already set some using the writer.addClass() on the view
205
- // document root. They haven't been rendered yet so they are not present in the DOM root.
206
- // Using writer.setAttribute( 'class', ... ) would override them completely.
207
- if (name === 'class') {
208
- this._writer.addClass(value.split(' '), viewRoot);
209
- }
210
- else {
211
- // There is a chance that some attributes have already been set on the view root before attaching
212
- // the DOM root and should be preserved. This is a similar case to the "class" attribute except
213
- // this time there is no workaround using a some low-level API.
214
- if (!viewRoot.hasAttribute(name)) {
215
- this._writer.setAttribute(name, value, viewRoot);
216
- }
217
- }
218
- }
219
- this._initialDomRootAttributes.set(domRoot, initialDomRootAttributes);
220
- const updateContenteditableAttribute = () => {
221
- this._writer.setAttribute('contenteditable', (!viewRoot.isReadOnly).toString(), viewRoot);
222
- if (viewRoot.isReadOnly) {
223
- this._writer.addClass('ck-read-only', viewRoot);
224
- }
225
- else {
226
- this._writer.removeClass('ck-read-only', viewRoot);
227
- }
228
- };
229
- // Set initial value.
230
- updateContenteditableAttribute();
231
- this.domRoots.set(name, domRoot);
232
- this.domConverter.bindElements(domRoot, viewRoot);
233
- this._renderer.markToSync('children', viewRoot);
234
- this._renderer.markToSync('attributes', viewRoot);
235
- this._renderer.domDocuments.add(domRoot.ownerDocument);
236
- viewRoot.on('change:children', (evt, node) => this._renderer.markToSync('children', node));
237
- viewRoot.on('change:attributes', (evt, node) => this._renderer.markToSync('attributes', node));
238
- viewRoot.on('change:text', (evt, node) => this._renderer.markToSync('text', node));
239
- viewRoot.on('change:isReadOnly', () => this.change(updateContenteditableAttribute));
240
- viewRoot.on('change', () => {
241
- this._hasChangedSinceTheLastRendering = true;
242
- });
243
- for (const observer of this._observers.values()) {
244
- observer.observe(domRoot, name);
245
- }
246
- }
247
- /**
248
- * Detaches a DOM root element from the view element and restores its attributes to the state before
249
- * {@link #attachDomRoot `attachDomRoot()`}.
250
- *
251
- * @param name Name of the root to detach.
252
- */
253
- detachDomRoot(name) {
254
- const domRoot = this.domRoots.get(name);
255
- // Remove all root attributes so the DOM element is "bare".
256
- Array.from(domRoot.attributes).forEach(({ name }) => domRoot.removeAttribute(name));
257
- const initialDomRootAttributes = this._initialDomRootAttributes.get(domRoot);
258
- // Revert all view root attributes back to the state before attachDomRoot was called.
259
- for (const attribute in initialDomRootAttributes) {
260
- domRoot.setAttribute(attribute, initialDomRootAttributes[attribute]);
261
- }
262
- this.domRoots.delete(name);
263
- this.domConverter.unbindDomElement(domRoot);
264
- for (const observer of this._observers.values()) {
265
- observer.stopObserving(domRoot);
266
- }
267
- }
268
- /**
269
- * Gets DOM root element.
270
- *
271
- * @param name Name of the root.
272
- * @returns DOM root element instance.
273
- */
274
- getDomRoot(name = 'main') {
275
- return this.domRoots.get(name);
276
- }
277
- /**
278
- * Creates observer of the given type if not yet created, {@link module:engine/view/observer/observer~Observer#enable enables} it
279
- * and {@link module:engine/view/observer/observer~Observer#observe attaches} to all existing and future
280
- * {@link #domRoots DOM roots}.
281
- *
282
- * Note: Observers are recognized by their constructor (classes). A single observer will be instantiated and used only
283
- * when registered for the first time. This means that features and other components can register a single observer
284
- * multiple times without caring whether it has been already added or not.
285
- *
286
- * @param ObserverConstructor The constructor of an observer to add.
287
- * Should create an instance inheriting from {@link module:engine/view/observer/observer~Observer}.
288
- * @returns Added observer instance.
289
- */
290
- addObserver(ObserverConstructor) {
291
- let observer = this._observers.get(ObserverConstructor);
292
- if (observer) {
293
- return observer;
294
- }
295
- observer = new ObserverConstructor(this);
296
- this._observers.set(ObserverConstructor, observer);
297
- for (const [name, domElement] of this.domRoots) {
298
- observer.observe(domElement, name);
299
- }
300
- observer.enable();
301
- return observer;
302
- }
303
- /**
304
- * Returns observer of the given type or `undefined` if such observer has not been added yet.
305
- *
306
- * @param ObserverConstructor The constructor of an observer to get.
307
- * @returns Observer instance or undefined.
308
- */
309
- getObserver(ObserverConstructor) {
310
- return this._observers.get(ObserverConstructor);
311
- }
312
- /**
313
- * Disables all added observers.
314
- */
315
- disableObservers() {
316
- for (const observer of this._observers.values()) {
317
- observer.disable();
318
- }
319
- }
320
- /**
321
- * Enables all added observers.
322
- */
323
- enableObservers() {
324
- for (const observer of this._observers.values()) {
325
- observer.enable();
326
- }
327
- }
328
- /**
329
- * Scrolls the page viewport and {@link #domRoots} with their ancestors to reveal the
330
- * caret, **if not already visible to the user**.
331
- *
332
- * **Note**: Calling this method fires the {@link module:engine/view/view~ViewScrollToTheSelectionEvent} event that
333
- * allows custom behaviors.
334
- *
335
- * @param options Additional configuration of the scrolling behavior.
336
- * @param options.viewportOffset A distance between the DOM selection and the viewport boundary to be maintained
337
- * while scrolling to the selection (default is 20px). Setting this value to `0` will reveal the selection precisely at
338
- * the viewport boundary.
339
- * @param options.ancestorOffset A distance between the DOM selection and scrollable DOM root ancestor(s) to be maintained
340
- * while scrolling to the selection (default is 20px). Setting this value to `0` will reveal the selection precisely at
341
- * the scrollable ancestor(s) boundary.
342
- * @param options.alignToTop When set `true`, the DOM selection will be aligned to the top of the viewport if not already visible
343
- * (see `forceScroll` to learn more).
344
- * @param options.forceScroll When set `true`, the DOM selection will be aligned to the top of the viewport and scrollable ancestors
345
- * whether it is already visible or not. This option will only work when `alignToTop` is `true`.
346
- */
347
- scrollToTheSelection({ alignToTop, forceScroll, viewportOffset = 20, ancestorOffset = 20 } = {}) {
348
- const range = this.document.selection.getFirstRange();
349
- if (!range) {
350
- return;
351
- }
352
- // Clone to make sure properties like `viewportOffset` are not mutated in the event listeners.
353
- const originalArgs = cloneDeep({ alignToTop, forceScroll, viewportOffset, ancestorOffset });
354
- if (typeof viewportOffset === 'number') {
355
- viewportOffset = {
356
- top: viewportOffset,
357
- bottom: viewportOffset,
358
- left: viewportOffset,
359
- right: viewportOffset
360
- };
361
- }
362
- const options = {
363
- target: this.domConverter.viewRangeToDom(range),
364
- viewportOffset,
365
- ancestorOffset,
366
- alignToTop,
367
- forceScroll
368
- };
369
- this.fire('scrollToTheSelection', options, originalArgs);
370
- scrollViewportToShowTarget(options);
371
- }
372
- /**
373
- * It will focus DOM element representing {@link module:engine/view/editableelement~ViewEditableElement ViewEditableElement}
374
- * that is currently having selection inside.
375
- */
376
- focus() {
377
- if (!this.document.isFocused) {
378
- const editable = this.document.selection.editableElement;
379
- if (editable) {
380
- this.domConverter.focus(editable);
381
- this.forceRender();
382
- }
383
- else {
384
- // Before focusing view document, selection should be placed inside one of the view's editables.
385
- // Normally its selection will be converted from model document (which have default selection), but
386
- // when using view document on its own, we need to manually place selection before focusing it.
387
- //
388
- // @if CK_DEBUG // console.warn( 'There is no selection in any editable to focus.' );
389
- }
390
- }
391
- }
392
- /**
393
- * The `change()` method is the primary way of changing the view. You should use it to modify any node in the view tree.
394
- * It makes sure that after all changes are made the view is rendered to the DOM (assuming that the view will be changed
395
- * inside the callback). It prevents situations when the DOM is updated when the view state is not yet correct. It allows
396
- * to nest calls one inside another and still performs a single rendering after all those changes are made.
397
- * It also returns the return value of its callback.
398
- *
399
- * ```ts
400
- * const text = view.change( writer => {
401
- * const newText = writer.createText( 'foo' );
402
- * writer.insert( position1, newText );
403
- *
404
- * view.change( writer => {
405
- * writer.insert( position2, writer.createText( 'bar' ) );
406
- * } );
407
- *
408
- * writer.remove( range );
409
- *
410
- * return newText;
411
- * } );
412
- * ```
413
- *
414
- * When the outermost change block is done and rendering to the DOM is over the
415
- * {@link module:engine/view/view~EditingView#event:render `View#render`} event is fired.
416
- *
417
- * This method throws a `applying-view-changes-on-rendering` error when
418
- * the change block is used after rendering to the DOM has started.
419
- *
420
- * @param callback Callback function which may modify the view.
421
- * @returns Value returned by the callback.
422
- */
423
- change(callback) {
424
- if (this.isRenderingInProgress || this._postFixersInProgress) {
425
- /**
426
- * Thrown when there is an attempt to make changes to the view tree when it is in incorrect state. This may
427
- * cause some unexpected behaviour and inconsistency between the DOM and the view.
428
- * This may be caused by:
429
- *
430
- * * calling {@link module:engine/view/view~EditingView#change} or {@link module:engine/view/view~EditingView#forceRender}
431
- * during rendering process,
432
- * * calling {@link module:engine/view/view~EditingView#change} or {@link module:engine/view/view~EditingView#forceRender}
433
- * inside of {@link module:engine/view/document~ViewDocument#registerPostFixer post-fixer function}.
434
- *
435
- * @error cannot-change-view-tree
436
- */
437
- throw new CKEditorError('cannot-change-view-tree', this);
438
- }
439
- try {
440
- // Recursive call to view.change() method - execute listener immediately.
441
- if (this._ongoingChange) {
442
- return callback(this._writer);
443
- }
444
- // This lock will assure that all recursive calls to view.change() will end up in same block - one "render"
445
- // event for all nested calls.
446
- this._ongoingChange = true;
447
- const callbackResult = callback(this._writer);
448
- this._ongoingChange = false;
449
- // This lock is used by editing controller to render changes from outer most model.change() once. As plugins might call
450
- // view.change() inside model.change() block - this will ensures that postfixers and rendering are called once after all
451
- // changes. Also, we don't need to render anything if there're no changes since last rendering.
452
- if (!this._renderingDisabled && this._hasChangedSinceTheLastRendering) {
453
- this._postFixersInProgress = true;
454
- this.document._callPostFixers(this._writer);
455
- this._postFixersInProgress = false;
456
- this.fire('render');
457
- }
458
- return callbackResult;
459
- }
460
- catch (err) {
461
- // @if CK_DEBUG // throw err;
462
- /* istanbul ignore next -- @preserve */
463
- CKEditorError.rethrowUnexpectedError(err, this);
464
- }
465
- }
466
- /**
467
- * Forces rendering {@link module:engine/view/document~ViewDocument view document} to DOM. If any view changes are
468
- * currently in progress, rendering will start after all {@link #change change blocks} are processed.
469
- *
470
- * Note that this method is dedicated for special cases. All view changes should be wrapped in the {@link #change}
471
- * block and the view will automatically check whether it needs to render DOM or not.
472
- *
473
- * Throws {@link module:utils/ckeditorerror~CKEditorError CKEditorError} `applying-view-changes-on-rendering` when
474
- * trying to re-render when rendering to DOM has already started.
475
- */
476
- forceRender() {
477
- this._hasChangedSinceTheLastRendering = true;
478
- this.getObserver(FocusObserver).flush();
479
- this.change(() => { });
480
- }
481
- /**
482
- * Destroys this instance. Makes sure that all observers are destroyed and listeners removed.
483
- */
484
- destroy() {
485
- for (const observer of this._observers.values()) {
486
- observer.destroy();
487
- }
488
- this.document.destroy();
489
- this.stopListening();
490
- }
491
- /**
492
- * Creates position at the given location. The location can be specified as:
493
- *
494
- * * a {@link module:engine/view/position~ViewPosition position},
495
- * * parent element and offset (offset defaults to `0`),
496
- * * parent element and `'end'` (sets position at the end of that element),
497
- * * {@link module:engine/view/item~ViewItem view item} and `'before'` or `'after'` (sets position before or after given view item).
498
- *
499
- * This method is a shortcut to other constructors such as:
500
- *
501
- * * {@link #createPositionBefore},
502
- * * {@link #createPositionAfter},
503
- *
504
- * @param offset Offset or one of the flags. Used only when first parameter is a {@link module:engine/view/item~ViewItem view item}.
505
- */
506
- createPositionAt(itemOrPosition, offset) {
507
- return ViewPosition._createAt(itemOrPosition, offset);
508
- }
509
- /**
510
- * Creates a new position after given view item.
511
- *
512
- * @param item View item after which the position should be located.
513
- */
514
- createPositionAfter(item) {
515
- return ViewPosition._createAfter(item);
516
- }
517
- /**
518
- * Creates a new position before given view item.
519
- *
520
- * @param item View item before which the position should be located.
521
- */
522
- createPositionBefore(item) {
523
- return ViewPosition._createBefore(item);
524
- }
525
- /**
526
- * Creates a range spanning from `start` position to `end` position.
527
- *
528
- * **Note:** This factory method creates it's own {@link module:engine/view/position~ViewPosition} instances basing on passed values.
529
- *
530
- * @param start Start position.
531
- * @param end End position. If not set, range will be collapsed at `start` position.
532
- */
533
- createRange(start, end) {
534
- return new ViewRange(start, end);
535
- }
536
- /**
537
- * Creates a range that starts before given {@link module:engine/view/item~ViewItem view item} and ends after it.
538
- */
539
- createRangeOn(item) {
540
- return ViewRange._createOn(item);
541
- }
542
- /**
543
- * Creates a range inside an {@link module:engine/view/element~ViewElement element} which starts before the first child of
544
- * that element and ends after the last child of that element.
545
- *
546
- * @param element Element which is a parent for the range.
547
- */
548
- createRangeIn(element) {
549
- return ViewRange._createIn(element);
550
- }
551
- createSelection(...args) {
552
- return new ViewSelection(...args);
553
- }
554
- /**
555
- * Disables or enables rendering. If the flag is set to `true` then the rendering will be disabled.
556
- * If the flag is set to `false` and if there was some change in the meantime, then the rendering action will be performed.
557
- *
558
- * @internal
559
- * @param flag A flag indicates whether the rendering should be disabled.
560
- */
561
- _disableRendering(flag) {
562
- this._renderingDisabled = flag;
563
- if (flag == false) {
564
- // Render when you stop blocking rendering.
565
- this.change(() => { });
566
- }
567
- }
568
- /**
569
- * Renders all changes. In order to avoid triggering the observers (e.g. selection) all observers are disabled
570
- * before rendering and re-enabled after that.
571
- */
572
- _render() {
573
- this.isRenderingInProgress = true;
574
- this.disableObservers();
575
- this._renderer.render();
576
- this.enableObservers();
577
- this.isRenderingInProgress = false;
578
- }
579
- }
@@ -1,36 +0,0 @@
1
- /*
2
- * 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
- /* See ckeditor/ckeditor5#936. */
7
- .ck.ck-placeholder,
8
- .ck .ck-placeholder {
9
- position: relative;
10
-
11
- &::before {
12
- position: absolute;
13
- left: 0;
14
- right: 0;
15
- content: attr(data-placeholder);
16
-
17
- /* See ckeditor/ckeditor5#469. */
18
- pointer-events: none;
19
- }
20
- }
21
-
22
- /* See ckeditor/ckeditor5#1987. */
23
- .ck.ck-read-only .ck-placeholder {
24
- &::before {
25
- display: none;
26
- }
27
- }
28
-
29
- /*
30
- * Rules for the `ck-placeholder` are loaded before the rules for `ck-reset_all` in the base CKEditor 5 DLL build.
31
- * This fix overwrites the incorrectly set `position: static` from `ck-reset_all`.
32
- * See https://github.com/ckeditor/ckeditor5/issues/11418.
33
- */
34
- .ck.ck-reset_all .ck-placeholder {
35
- position: relative;
36
- }
@@ -1,9 +0,0 @@
1
- /*
2
- * 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
- /* Elements marked by the Renderer as hidden should be invisible in the editor. */
7
- .ck.ck-editor__editable span[data-ck-unsafe-element] {
8
- display: none;
9
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes