@ckeditor/ckeditor5-engine 44.1.0-alpha.5 → 44.2.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 (369) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/index-content.css +2 -2
  3. package/dist/index-editor.css +2 -2
  4. package/dist/index.css +4 -4
  5. package/dist/index.css.map +1 -1
  6. package/dist/index.js +646 -77
  7. package/dist/index.js.map +1 -1
  8. package/package.json +23 -3
  9. package/src/controller/datacontroller.d.ts +1 -1
  10. package/src/controller/datacontroller.js +1 -1
  11. package/src/controller/editingcontroller.d.ts +1 -1
  12. package/src/controller/editingcontroller.js +1 -1
  13. package/src/conversion/conversion.d.ts +1 -1
  14. package/src/conversion/conversion.js +1 -1
  15. package/src/conversion/conversionhelpers.d.ts +1 -1
  16. package/src/conversion/conversionhelpers.js +1 -1
  17. package/src/conversion/downcastdispatcher.d.ts +1 -1
  18. package/src/conversion/downcastdispatcher.js +1 -1
  19. package/src/conversion/downcasthelpers.d.ts +1 -1
  20. package/src/conversion/downcasthelpers.js +1 -1
  21. package/src/conversion/mapper.d.ts +249 -20
  22. package/src/conversion/mapper.js +524 -38
  23. package/src/conversion/modelconsumable.d.ts +1 -1
  24. package/src/conversion/modelconsumable.js +1 -1
  25. package/src/conversion/upcastdispatcher.d.ts +1 -1
  26. package/src/conversion/upcastdispatcher.js +1 -1
  27. package/src/conversion/upcasthelpers.d.ts +1 -1
  28. package/src/conversion/upcasthelpers.js +1 -1
  29. package/src/conversion/viewconsumable.d.ts +1 -1
  30. package/src/conversion/viewconsumable.js +1 -1
  31. package/src/dataprocessor/basichtmlwriter.d.ts +1 -1
  32. package/src/dataprocessor/basichtmlwriter.js +1 -1
  33. package/src/dataprocessor/dataprocessor.d.ts +1 -1
  34. package/src/dataprocessor/dataprocessor.js +1 -1
  35. package/src/dataprocessor/htmldataprocessor.d.ts +1 -1
  36. package/src/dataprocessor/htmldataprocessor.js +1 -1
  37. package/src/dataprocessor/htmlwriter.d.ts +1 -1
  38. package/src/dataprocessor/htmlwriter.js +1 -1
  39. package/src/dataprocessor/xmldataprocessor.d.ts +1 -1
  40. package/src/dataprocessor/xmldataprocessor.js +1 -1
  41. package/src/dev-utils/model.d.ts +1 -1
  42. package/src/dev-utils/model.js +1 -1
  43. package/src/dev-utils/operationreplayer.d.ts +1 -1
  44. package/src/dev-utils/operationreplayer.js +1 -1
  45. package/src/dev-utils/utils.d.ts +1 -1
  46. package/src/dev-utils/utils.js +1 -1
  47. package/src/dev-utils/view.d.ts +1 -1
  48. package/src/dev-utils/view.js +1 -1
  49. package/src/index.d.ts +4 -2
  50. package/src/index.js +2 -1
  51. package/src/model/batch.d.ts +1 -1
  52. package/src/model/batch.js +7 -3
  53. package/src/model/differ.d.ts +1 -1
  54. package/src/model/differ.js +1 -1
  55. package/src/model/document.d.ts +1 -1
  56. package/src/model/document.js +1 -1
  57. package/src/model/documentfragment.d.ts +1 -1
  58. package/src/model/documentfragment.js +1 -1
  59. package/src/model/documentselection.d.ts +1 -1
  60. package/src/model/documentselection.js +1 -1
  61. package/src/model/element.d.ts +1 -1
  62. package/src/model/element.js +1 -1
  63. package/src/model/history.d.ts +1 -1
  64. package/src/model/history.js +1 -1
  65. package/src/model/item.d.ts +1 -1
  66. package/src/model/item.js +1 -1
  67. package/src/model/liveposition.d.ts +1 -1
  68. package/src/model/liveposition.js +1 -1
  69. package/src/model/liverange.d.ts +1 -1
  70. package/src/model/liverange.js +1 -1
  71. package/src/model/markercollection.d.ts +1 -1
  72. package/src/model/markercollection.js +1 -1
  73. package/src/model/model.d.ts +1 -1
  74. package/src/model/model.js +1 -1
  75. package/src/model/node.d.ts +1 -1
  76. package/src/model/node.js +1 -1
  77. package/src/model/nodelist.d.ts +1 -1
  78. package/src/model/nodelist.js +1 -1
  79. package/src/model/operation/attributeoperation.d.ts +1 -1
  80. package/src/model/operation/attributeoperation.js +1 -1
  81. package/src/model/operation/detachoperation.d.ts +1 -1
  82. package/src/model/operation/detachoperation.js +1 -1
  83. package/src/model/operation/insertoperation.d.ts +1 -1
  84. package/src/model/operation/insertoperation.js +1 -1
  85. package/src/model/operation/markeroperation.d.ts +1 -1
  86. package/src/model/operation/markeroperation.js +1 -1
  87. package/src/model/operation/mergeoperation.d.ts +1 -1
  88. package/src/model/operation/mergeoperation.js +1 -1
  89. package/src/model/operation/moveoperation.d.ts +1 -1
  90. package/src/model/operation/moveoperation.js +1 -1
  91. package/src/model/operation/nooperation.d.ts +1 -1
  92. package/src/model/operation/nooperation.js +1 -1
  93. package/src/model/operation/operation.d.ts +4 -1
  94. package/src/model/operation/operation.js +2 -2
  95. package/src/model/operation/operationfactory.d.ts +1 -1
  96. package/src/model/operation/operationfactory.js +1 -1
  97. package/src/model/operation/renameoperation.d.ts +1 -1
  98. package/src/model/operation/renameoperation.js +1 -1
  99. package/src/model/operation/rootattributeoperation.d.ts +1 -1
  100. package/src/model/operation/rootattributeoperation.js +1 -1
  101. package/src/model/operation/rootoperation.d.ts +1 -1
  102. package/src/model/operation/rootoperation.js +1 -1
  103. package/src/model/operation/splitoperation.d.ts +1 -1
  104. package/src/model/operation/splitoperation.js +1 -1
  105. package/src/model/operation/transform.d.ts +1 -1
  106. package/src/model/operation/transform.js +1 -1
  107. package/src/model/operation/utils.d.ts +1 -1
  108. package/src/model/operation/utils.js +1 -1
  109. package/src/model/position.d.ts +1 -1
  110. package/src/model/position.js +1 -1
  111. package/src/model/range.d.ts +1 -1
  112. package/src/model/range.js +1 -1
  113. package/src/model/rootelement.d.ts +1 -1
  114. package/src/model/rootelement.js +1 -1
  115. package/src/model/schema.d.ts +1 -1
  116. package/src/model/schema.js +1 -1
  117. package/src/model/selection.d.ts +1 -1
  118. package/src/model/selection.js +9 -2
  119. package/src/model/text.d.ts +1 -1
  120. package/src/model/text.js +1 -1
  121. package/src/model/textproxy.d.ts +1 -1
  122. package/src/model/textproxy.js +1 -1
  123. package/src/model/treewalker.d.ts +17 -1
  124. package/src/model/treewalker.js +26 -1
  125. package/src/model/typecheckable.d.ts +1 -1
  126. package/src/model/typecheckable.js +1 -1
  127. package/src/model/utils/autoparagraphing.d.ts +1 -1
  128. package/src/model/utils/autoparagraphing.js +1 -1
  129. package/src/model/utils/deletecontent.d.ts +1 -1
  130. package/src/model/utils/deletecontent.js +1 -1
  131. package/src/model/utils/getselectedcontent.d.ts +1 -1
  132. package/src/model/utils/getselectedcontent.js +1 -1
  133. package/src/model/utils/insertcontent.d.ts +1 -1
  134. package/src/model/utils/insertcontent.js +1 -1
  135. package/src/model/utils/insertobject.d.ts +1 -1
  136. package/src/model/utils/insertobject.js +1 -1
  137. package/src/model/utils/modifyselection.d.ts +1 -1
  138. package/src/model/utils/modifyselection.js +1 -1
  139. package/src/model/utils/selection-post-fixer.d.ts +1 -1
  140. package/src/model/utils/selection-post-fixer.js +1 -1
  141. package/src/model/writer.d.ts +1 -1
  142. package/src/model/writer.js +1 -1
  143. package/src/view/attributeelement.d.ts +1 -1
  144. package/src/view/attributeelement.js +1 -1
  145. package/src/view/containerelement.d.ts +1 -1
  146. package/src/view/containerelement.js +1 -1
  147. package/src/view/datatransfer.d.ts +1 -1
  148. package/src/view/datatransfer.js +1 -1
  149. package/src/view/document.d.ts +1 -1
  150. package/src/view/document.js +1 -1
  151. package/src/view/documentfragment.d.ts +6 -4
  152. package/src/view/documentfragment.js +7 -7
  153. package/src/view/documentselection.d.ts +1 -1
  154. package/src/view/documentselection.js +1 -1
  155. package/src/view/domconverter.d.ts +1 -1
  156. package/src/view/domconverter.js +1 -1
  157. package/src/view/downcastwriter.d.ts +1 -1
  158. package/src/view/downcastwriter.js +1 -1
  159. package/src/view/editableelement.d.ts +1 -1
  160. package/src/view/editableelement.js +1 -1
  161. package/src/view/element.d.ts +1 -1
  162. package/src/view/element.js +3 -3
  163. package/src/view/elementdefinition.d.ts +1 -1
  164. package/src/view/elementdefinition.js +1 -1
  165. package/src/view/emptyelement.d.ts +1 -1
  166. package/src/view/emptyelement.js +1 -1
  167. package/src/view/filler.d.ts +1 -1
  168. package/src/view/filler.js +1 -1
  169. package/src/view/item.d.ts +1 -1
  170. package/src/view/item.js +1 -1
  171. package/src/view/matcher.d.ts +1 -1
  172. package/src/view/matcher.js +1 -1
  173. package/src/view/node.d.ts +13 -4
  174. package/src/view/node.js +5 -4
  175. package/src/view/observer/arrowkeysobserver.d.ts +1 -1
  176. package/src/view/observer/arrowkeysobserver.js +1 -1
  177. package/src/view/observer/bubblingemittermixin.d.ts +1 -1
  178. package/src/view/observer/bubblingemittermixin.js +1 -1
  179. package/src/view/observer/bubblingeventinfo.d.ts +1 -1
  180. package/src/view/observer/bubblingeventinfo.js +1 -1
  181. package/src/view/observer/clickobserver.d.ts +1 -1
  182. package/src/view/observer/clickobserver.js +1 -1
  183. package/src/view/observer/compositionobserver.d.ts +1 -1
  184. package/src/view/observer/compositionobserver.js +1 -1
  185. package/src/view/observer/domeventdata.d.ts +1 -1
  186. package/src/view/observer/domeventdata.js +1 -1
  187. package/src/view/observer/domeventobserver.d.ts +1 -1
  188. package/src/view/observer/domeventobserver.js +1 -1
  189. package/src/view/observer/fakeselectionobserver.d.ts +1 -1
  190. package/src/view/observer/fakeselectionobserver.js +1 -1
  191. package/src/view/observer/focusobserver.d.ts +1 -1
  192. package/src/view/observer/focusobserver.js +1 -1
  193. package/src/view/observer/inputobserver.d.ts +1 -1
  194. package/src/view/observer/inputobserver.js +1 -1
  195. package/src/view/observer/keyobserver.d.ts +1 -1
  196. package/src/view/observer/keyobserver.js +1 -1
  197. package/src/view/observer/mouseobserver.d.ts +1 -1
  198. package/src/view/observer/mouseobserver.js +1 -1
  199. package/src/view/observer/mutationobserver.d.ts +1 -1
  200. package/src/view/observer/mutationobserver.js +1 -1
  201. package/src/view/observer/observer.d.ts +1 -1
  202. package/src/view/observer/observer.js +1 -1
  203. package/src/view/observer/selectionobserver.d.ts +1 -1
  204. package/src/view/observer/selectionobserver.js +1 -1
  205. package/src/view/observer/tabobserver.d.ts +1 -1
  206. package/src/view/observer/tabobserver.js +1 -1
  207. package/src/view/observer/touchobserver.d.ts +73 -0
  208. package/src/view/observer/touchobserver.js +29 -0
  209. package/src/view/placeholder.d.ts +1 -1
  210. package/src/view/placeholder.js +23 -17
  211. package/src/view/position.d.ts +1 -1
  212. package/src/view/position.js +1 -1
  213. package/src/view/range.d.ts +1 -1
  214. package/src/view/range.js +1 -1
  215. package/src/view/rawelement.d.ts +1 -1
  216. package/src/view/rawelement.js +1 -1
  217. package/src/view/renderer.d.ts +1 -1
  218. package/src/view/renderer.js +1 -1
  219. package/src/view/rooteditableelement.d.ts +1 -1
  220. package/src/view/rooteditableelement.js +1 -1
  221. package/src/view/selection.d.ts +1 -1
  222. package/src/view/selection.js +1 -1
  223. package/src/view/styles/background.d.ts +1 -1
  224. package/src/view/styles/background.js +1 -1
  225. package/src/view/styles/border.d.ts +1 -1
  226. package/src/view/styles/border.js +1 -1
  227. package/src/view/styles/margin.d.ts +1 -1
  228. package/src/view/styles/margin.js +1 -1
  229. package/src/view/styles/padding.d.ts +1 -1
  230. package/src/view/styles/padding.js +1 -1
  231. package/src/view/styles/utils.d.ts +1 -1
  232. package/src/view/styles/utils.js +1 -1
  233. package/src/view/stylesmap.d.ts +1 -1
  234. package/src/view/stylesmap.js +1 -1
  235. package/src/view/text.d.ts +1 -1
  236. package/src/view/text.js +1 -1
  237. package/src/view/textproxy.d.ts +1 -1
  238. package/src/view/textproxy.js +1 -1
  239. package/src/view/treewalker.d.ts +17 -1
  240. package/src/view/treewalker.js +25 -1
  241. package/src/view/typecheckable.d.ts +1 -1
  242. package/src/view/typecheckable.js +1 -1
  243. package/src/view/uielement.d.ts +1 -1
  244. package/src/view/uielement.js +1 -1
  245. package/src/view/upcastwriter.d.ts +1 -1
  246. package/src/view/upcastwriter.js +1 -1
  247. package/src/view/view.d.ts +1 -1
  248. package/src/view/view.js +1 -1
  249. package/theme/placeholder.css +1 -1
  250. package/theme/renderer.css +1 -1
  251. package/dist/controller/datacontroller.d.ts +0 -339
  252. package/dist/controller/editingcontroller.d.ts +0 -102
  253. package/dist/conversion/conversion.d.ts +0 -482
  254. package/dist/conversion/conversionhelpers.d.ts +0 -30
  255. package/dist/conversion/downcastdispatcher.d.ts +0 -566
  256. package/dist/conversion/downcasthelpers.d.ts +0 -1194
  257. package/dist/conversion/mapper.d.ts +0 -507
  258. package/dist/conversion/modelconsumable.d.ts +0 -205
  259. package/dist/conversion/upcastdispatcher.d.ts +0 -496
  260. package/dist/conversion/upcasthelpers.d.ts +0 -503
  261. package/dist/conversion/viewconsumable.d.ts +0 -373
  262. package/dist/dataprocessor/basichtmlwriter.d.ts +0 -22
  263. package/dist/dataprocessor/dataprocessor.d.ts +0 -65
  264. package/dist/dataprocessor/htmldataprocessor.d.ts +0 -80
  265. package/dist/dataprocessor/htmlwriter.d.ts +0 -20
  266. package/dist/dataprocessor/xmldataprocessor.d.ts +0 -94
  267. package/dist/dev-utils/model.d.ts +0 -130
  268. package/dist/dev-utils/operationreplayer.d.ts +0 -55
  269. package/dist/dev-utils/utils.d.ts +0 -41
  270. package/dist/dev-utils/view.d.ts +0 -324
  271. package/dist/index.d.ts +0 -122
  272. package/dist/model/batch.d.ts +0 -110
  273. package/dist/model/differ.d.ts +0 -511
  274. package/dist/model/document.d.ts +0 -278
  275. package/dist/model/documentfragment.d.ts +0 -223
  276. package/dist/model/documentselection.d.ts +0 -424
  277. package/dist/model/element.d.ts +0 -191
  278. package/dist/model/history.d.ts +0 -118
  279. package/dist/model/item.d.ts +0 -18
  280. package/dist/model/liveposition.d.ts +0 -81
  281. package/dist/model/liverange.d.ts +0 -106
  282. package/dist/model/markercollection.d.ts +0 -339
  283. package/dist/model/model.d.ts +0 -923
  284. package/dist/model/node.d.ts +0 -262
  285. package/dist/model/nodelist.d.ts +0 -119
  286. package/dist/model/operation/attributeoperation.d.ts +0 -107
  287. package/dist/model/operation/detachoperation.d.ts +0 -64
  288. package/dist/model/operation/insertoperation.d.ts +0 -94
  289. package/dist/model/operation/markeroperation.d.ts +0 -95
  290. package/dist/model/operation/mergeoperation.d.ts +0 -104
  291. package/dist/model/operation/moveoperation.d.ts +0 -100
  292. package/dist/model/operation/nooperation.d.ts +0 -42
  293. package/dist/model/operation/operation.d.ts +0 -100
  294. package/dist/model/operation/operationfactory.d.ts +0 -22
  295. package/dist/model/operation/renameoperation.d.ts +0 -87
  296. package/dist/model/operation/rootattributeoperation.d.ts +0 -102
  297. package/dist/model/operation/rootoperation.d.ts +0 -80
  298. package/dist/model/operation/splitoperation.d.ts +0 -113
  299. package/dist/model/operation/transform.d.ts +0 -104
  300. package/dist/model/operation/utils.d.ts +0 -75
  301. package/dist/model/position.d.ts +0 -549
  302. package/dist/model/range.d.ts +0 -462
  303. package/dist/model/rootelement.d.ts +0 -64
  304. package/dist/model/schema.d.ts +0 -1334
  305. package/dist/model/selection.d.ts +0 -486
  306. package/dist/model/text.d.ts +0 -70
  307. package/dist/model/textproxy.d.ts +0 -148
  308. package/dist/model/treewalker.d.ts +0 -190
  309. package/dist/model/typecheckable.d.ts +0 -289
  310. package/dist/model/utils/autoparagraphing.d.ts +0 -41
  311. package/dist/model/utils/deletecontent.d.ts +0 -62
  312. package/dist/model/utils/getselectedcontent.d.ts +0 -34
  313. package/dist/model/utils/insertcontent.d.ts +0 -50
  314. package/dist/model/utils/insertobject.d.ts +0 -51
  315. package/dist/model/utils/modifyselection.d.ts +0 -52
  316. package/dist/model/utils/selection-post-fixer.d.ts +0 -78
  317. package/dist/model/writer.d.ts +0 -855
  318. package/dist/view/attributeelement.d.ts +0 -112
  319. package/dist/view/containerelement.d.ts +0 -53
  320. package/dist/view/datatransfer.d.ts +0 -83
  321. package/dist/view/document.d.ts +0 -188
  322. package/dist/view/documentfragment.d.ts +0 -157
  323. package/dist/view/documentselection.d.ts +0 -310
  324. package/dist/view/domconverter.d.ts +0 -665
  325. package/dist/view/downcastwriter.d.ts +0 -1000
  326. package/dist/view/editableelement.d.ts +0 -66
  327. package/dist/view/element.d.ts +0 -472
  328. package/dist/view/elementdefinition.d.ts +0 -91
  329. package/dist/view/emptyelement.d.ts +0 -45
  330. package/dist/view/filler.d.ts +0 -115
  331. package/dist/view/item.d.ts +0 -18
  332. package/dist/view/matcher.d.ts +0 -490
  333. package/dist/view/node.d.ts +0 -166
  334. package/dist/view/observer/arrowkeysobserver.d.ts +0 -49
  335. package/dist/view/observer/bubblingemittermixin.d.ts +0 -170
  336. package/dist/view/observer/bubblingeventinfo.d.ts +0 -51
  337. package/dist/view/observer/clickobserver.d.ts +0 -47
  338. package/dist/view/observer/compositionobserver.d.ts +0 -86
  339. package/dist/view/observer/domeventdata.d.ts +0 -54
  340. package/dist/view/observer/domeventobserver.d.ts +0 -82
  341. package/dist/view/observer/fakeselectionobserver.d.ts +0 -51
  342. package/dist/view/observer/focusobserver.d.ts +0 -98
  343. package/dist/view/observer/inputobserver.d.ts +0 -90
  344. package/dist/view/observer/keyobserver.d.ts +0 -70
  345. package/dist/view/observer/mouseobserver.d.ts +0 -93
  346. package/dist/view/observer/mutationobserver.d.ts +0 -119
  347. package/dist/view/observer/observer.d.ts +0 -93
  348. package/dist/view/observer/selectionobserver.d.ts +0 -151
  349. package/dist/view/observer/tabobserver.d.ts +0 -50
  350. package/dist/view/placeholder.d.ts +0 -100
  351. package/dist/view/position.d.ts +0 -192
  352. package/dist/view/range.d.ts +0 -283
  353. package/dist/view/rawelement.d.ts +0 -77
  354. package/dist/view/renderer.d.ts +0 -281
  355. package/dist/view/rooteditableelement.d.ts +0 -45
  356. package/dist/view/selection.d.ts +0 -379
  357. package/dist/view/styles/background.d.ts +0 -37
  358. package/dist/view/styles/border.d.ts +0 -47
  359. package/dist/view/styles/margin.d.ts +0 -33
  360. package/dist/view/styles/padding.d.ts +0 -33
  361. package/dist/view/styles/utils.d.ts +0 -97
  362. package/dist/view/stylesmap.d.ts +0 -685
  363. package/dist/view/text.d.ts +0 -78
  364. package/dist/view/textproxy.d.ts +0 -101
  365. package/dist/view/treewalker.d.ts +0 -199
  366. package/dist/view/typecheckable.d.ts +0 -452
  367. package/dist/view/uielement.d.ts +0 -100
  368. package/dist/view/upcastwriter.d.ts +0 -421
  369. package/dist/view/view.d.ts +0 -488
@@ -1,511 +0,0 @@
1
- /**
2
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
- */
5
- /**
6
- * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
7
- * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
8
- */
9
- /**
10
- * @module engine/model/differ
11
- */
12
- import Position from './position.js';
13
- import Range from './range.js';
14
- import type { default as MarkerCollection, MarkerData } from './markercollection.js';
15
- import type Item from './item.js';
16
- import type Node from './node.js';
17
- import type RootElement from './rootelement.js';
18
- import type Operation from './operation/operation.js';
19
- /**
20
- * Calculates the difference between two model states.
21
- *
22
- * Receives operations that are to be applied on the model document. Marks parts of the model document tree which
23
- * are changed and saves the state of these elements before the change. Then, it compares saved elements with the
24
- * changed elements, after all changes are applied on the model document. Calculates the diff between saved
25
- * elements and new ones and returns a change set.
26
- */
27
- export default class Differ {
28
- /**
29
- * Priority of the {@link ~Differ#_elementState element states}. States on higher indexes of the array can overwrite states on the lower
30
- * indexes.
31
- */
32
- private static readonly _statesPriority;
33
- /**
34
- * Reference to the model's marker collection.
35
- */
36
- private readonly _markerCollection;
37
- /**
38
- * A map that stores changes that happened in a given element.
39
- *
40
- * The keys of the map are references to the model elements.
41
- * The values of the map are arrays with changes that were done on this element.
42
- */
43
- private readonly _changesInElement;
44
- /**
45
- * Stores a snapshot for these model nodes that might have changed.
46
- *
47
- * This complements {@link ~Differ#_elementChildrenSnapshots `_elementChildrenSnapshots`}.
48
- *
49
- * See also {@link ~DifferSnapshot}.
50
- */
51
- private readonly _elementsSnapshots;
52
- /**
53
- * For each element or document fragment inside which there was a change, it stores a snapshot of the child nodes list (an array
54
- * of children snapshots that represent the state in the element / fragment before any change has happened).
55
- *
56
- * This complements {@link ~Differ#_elementsSnapshots `_elementsSnapshots`}.
57
- *
58
- * See also {@link ~DifferSnapshot}.
59
- */
60
- private readonly _elementChildrenSnapshots;
61
- /**
62
- * Keeps the state for a given element, describing how the element was changed so far. It is used to evaluate the `action` property
63
- * of diff items returned by {@link ~Differ#getChanges}.
64
- *
65
- * Possible values, in the order from the lowest priority to the highest priority:
66
- *
67
- * * `'refresh'` - element was refreshed,
68
- * * `'rename'` - element was renamed,
69
- * * `'move'` - element was moved (or, usually, removed, that is moved to the graveyard).
70
- *
71
- * Element that was refreshed, may change its state to `'rename'` if it was later renamed, or to `'move'` if it was removed.
72
- * But the element cannot change its state from `'move'` to `'rename'`, or from `'rename'` to `'refresh'`.
73
- *
74
- * Only already existing elements are registered in `_elementState`. If a new element was inserted as a result of a buffered operation,
75
- * it is not be registered in `_elementState`.
76
- */
77
- private readonly _elementState;
78
- /**
79
- * A map that stores all changed markers.
80
- *
81
- * The keys of the map are marker names.
82
- *
83
- * The values of the map are objects with the following properties:
84
- *
85
- * * `oldMarkerData`,
86
- * * `newMarkerData`.
87
- */
88
- private readonly _changedMarkers;
89
- /**
90
- * A map that stores all roots that have been changed.
91
- *
92
- * The keys are the names of the roots while value represents the changes.
93
- */
94
- private readonly _changedRoots;
95
- /**
96
- * Stores the number of changes that were processed. Used to order the changes chronologically. It is important
97
- * when changes are sorted.
98
- */
99
- private _changeCount;
100
- /**
101
- * For efficiency purposes, `Differ` stores the change set returned by the differ after {@link #getChanges} call.
102
- * Cache is reset each time a new operation is buffered. If the cache has not been reset, {@link #getChanges} will
103
- * return the cached value instead of calculating it again.
104
- *
105
- * This property stores those changes that did not take place in graveyard root.
106
- */
107
- private _cachedChanges;
108
- /**
109
- * For efficiency purposes, `Differ` stores the change set returned by the differ after the {@link #getChanges} call.
110
- * The cache is reset each time a new operation is buffered. If the cache has not been reset, {@link #getChanges} will
111
- * return the cached value instead of calculating it again.
112
- *
113
- * This property stores all changes evaluated by `Differ`, including those that took place in the graveyard.
114
- */
115
- private _cachedChangesWithGraveyard;
116
- /**
117
- * Set of model items that were marked to get refreshed in {@link #_refreshItem}.
118
- */
119
- private _refreshedItems;
120
- /**
121
- * Creates a `Differ` instance.
122
- *
123
- * @param markerCollection Model's marker collection.
124
- */
125
- constructor(markerCollection: MarkerCollection);
126
- /**
127
- * Informs whether there are any changes buffered in `Differ`.
128
- */
129
- get isEmpty(): boolean;
130
- /**
131
- * Buffers the given operation. **An operation has to be buffered before it is executed.**
132
- *
133
- * @param operationToBuffer An operation to buffer.
134
- */
135
- bufferOperation(operationToBuffer: Operation): void;
136
- /**
137
- * Buffers a marker change.
138
- *
139
- * @param markerName The name of the marker that changed.
140
- * @param oldMarkerData Marker data before the change.
141
- * @param newMarkerData Marker data after the change.
142
- */
143
- bufferMarkerChange(markerName: string, oldMarkerData: MarkerData, newMarkerData: MarkerData): void;
144
- /**
145
- * Returns all markers that should be removed as a result of buffered changes.
146
- *
147
- * @returns Markers to remove. Each array item is an object containing the `name` and `range` properties.
148
- */
149
- getMarkersToRemove(): Array<{
150
- name: string;
151
- range: Range;
152
- }>;
153
- /**
154
- * Returns all markers which should be added as a result of buffered changes.
155
- *
156
- * @returns Markers to add. Each array item is an object containing the `name` and `range` properties.
157
- */
158
- getMarkersToAdd(): Array<{
159
- name: string;
160
- range: Range;
161
- }>;
162
- /**
163
- * Returns all markers which changed.
164
- */
165
- getChangedMarkers(): Array<{
166
- name: string;
167
- data: {
168
- oldRange: Range | null;
169
- newRange: Range | null;
170
- };
171
- }>;
172
- /**
173
- * Checks whether some of the buffered changes affect the editor data.
174
- *
175
- * Types of changes which affect the editor data:
176
- *
177
- * * model structure changes,
178
- * * attribute changes,
179
- * * a root is added or detached,
180
- * * changes of markers which were defined as `affectsData`,
181
- * * changes of markers' `affectsData` property.
182
- */
183
- hasDataChanges(): boolean;
184
- /**
185
- * Calculates the diff between the old model tree state (the state before the first buffered operations since the last {@link #reset}
186
- * call) and the new model tree state (actual one). It should be called after all buffered operations are executed.
187
- *
188
- * The diff set is returned as an array of {@link module:engine/model/differ~DiffItem diff items}, each describing a change done
189
- * on the model. The items are sorted by the position on which the change happened. If a position
190
- * {@link module:engine/model/position~Position#isBefore is before} another one, it will be on an earlier index in the diff set.
191
- *
192
- * **Note**: Elements inside inserted element will not have a separate diff item, only the top most element change will be reported.
193
- *
194
- * Because calculating the diff is a costly operation, the result is cached. If no new operation was buffered since the
195
- * previous {@link #getChanges} call, the next call will return the cached value.
196
- *
197
- * @param options Additional options.
198
- * @param options.includeChangesInGraveyard If set to `true`, also changes that happened
199
- * in the graveyard root will be returned. By default, changes in the graveyard root are not returned.
200
- * @returns Diff between the old and the new model tree state.
201
- */
202
- getChanges(options?: {
203
- includeChangesInGraveyard?: boolean;
204
- }): Array<DiffItem>;
205
- /**
206
- * Returns all roots that have changed (either were attached, or detached, or their attributes changed).
207
- *
208
- * @returns Diff between the old and the new roots state.
209
- */
210
- getChangedRoots(): Array<DiffItemRoot>;
211
- /**
212
- * Returns a set of model items that were marked to get refreshed.
213
- */
214
- getRefreshedItems(): Set<Item>;
215
- /**
216
- * Resets `Differ`. Removes all buffered changes.
217
- */
218
- reset(): void;
219
- /**
220
- * Marks the given `item` in differ to be "refreshed". It means that the item will be marked as removed and inserted
221
- * in the differ changes set, so it will be effectively re-converted when the differ changes are handled by a dispatcher.
222
- *
223
- * @internal
224
- * @param item Item to refresh.
225
- */
226
- _refreshItem(item: Item): void;
227
- /**
228
- * Buffers all the data related to given root like it was all just added to the editor.
229
- *
230
- * Following changes are buffered:
231
- *
232
- * * root is attached,
233
- * * all root content is inserted,
234
- * * all root attributes are added,
235
- * * all markers inside the root are added.
236
- *
237
- * @internal
238
- */
239
- _bufferRootLoad(root: RootElement): void;
240
- /**
241
- * Buffers the root state change after the root was attached or detached
242
- */
243
- private _bufferRootStateChange;
244
- /**
245
- * Buffers a root attribute change.
246
- */
247
- private _bufferRootAttributeChange;
248
- /**
249
- * Saves and handles an insert change.
250
- */
251
- private _markInsert;
252
- /**
253
- * Saves and handles a remove change.
254
- */
255
- private _markRemove;
256
- /**
257
- * Saves and handles an attribute change.
258
- */
259
- private _markAttribute;
260
- /**
261
- * Saves and handles a model change.
262
- */
263
- private _markChange;
264
- /**
265
- * Tries to set given state for given item.
266
- *
267
- * This method does simple validation (it sets the state only for model elements, not for text proxy nodes). It also follows state
268
- * setting rules, that is, `'refresh'` cannot overwrite `'rename'`, and `'rename'` cannot overwrite `'move'`.
269
- */
270
- private _setElementState;
271
- /**
272
- * Returns a value for {@link ~DifferItemAction `action`} property for diff items returned by {@link ~Differ#getChanges}.
273
- * This method aims to return `'rename'` or `'refresh'` when it should, and `diffItemType` ("default action") in all other cases.
274
- *
275
- * It bases on a few factors:
276
- *
277
- * * for text nodes, the method always returns `diffItemType`,
278
- * * for newly inserted element, the method returns `diffItemType`,
279
- * * if {@link ~Differ#_elementState element state} was not recorded, the method returns `diffItemType`,
280
- * * if state was recorded, and it was `'move'` (default action), the method returns `diffItemType`,
281
- * * finally, if state was `'refresh'` or `'rename'`, the method returns the state value.
282
- */
283
- private _getDiffActionForNode;
284
- /**
285
- * Gets an array of changes that have already been saved for a given element.
286
- */
287
- private _getChangesForElement;
288
- /**
289
- * Creates and saves a snapshot for all children of the given element.
290
- */
291
- private _makeSnapshots;
292
- /**
293
- * For a given newly saved change, compares it with a change already done on the element and modifies the incoming
294
- * change and/or the old change.
295
- *
296
- * @param inc Incoming (new) change.
297
- * @param changes An array containing all the changes done on that element.
298
- */
299
- private _handleChange;
300
- /**
301
- * Returns an object with a single insert change description.
302
- *
303
- * @param parent The element in which the change happened.
304
- * @param offset The offset at which change happened.
305
- * @param action Further specifies what kind of action led to generating this change.
306
- * @param elementSnapshot Snapshot of the inserted node after changes.
307
- * @param elementSnapshotBefore Snapshot of the inserted node before changes.
308
- * @returns The diff item.
309
- */
310
- private _getInsertDiff;
311
- /**
312
- * Returns an object with a single remove change description.
313
- *
314
- * @param parent The element in which change happened.
315
- * @param offset The offset at which change happened.
316
- * @param action Further specifies what kind of action led to generating this change.
317
- * @param elementSnapshot The snapshot of the removed node before changes.
318
- * @returns The diff item.
319
- */
320
- private _getRemoveDiff;
321
- /**
322
- * Returns an array of objects where each one is a single attribute change description.
323
- *
324
- * @param range The range where the change happened.
325
- * @param oldAttributes A map, map iterator or compatible object that contains attributes before the change.
326
- * @param newAttributes A map, map iterator or compatible object that contains attributes after the change.
327
- * @returns An array containing one or more diff items.
328
- */
329
- private _getAttributesDiff;
330
- /**
331
- * Checks whether given element or any of its parents is an element that is buffered as an inserted element.
332
- */
333
- private _isInInsertedElement;
334
- /**
335
- * Removes deeply all buffered changes that are registered in elements from range specified by `parent`, `offset`
336
- * and `howMany`.
337
- */
338
- private _removeAllNestedChanges;
339
- }
340
- /**
341
- * Further specifies what kind of action led to generating a change:
342
- *
343
- * * `'insert'` if element was inserted,
344
- * * `'remove'` if element was removed,
345
- * * `'rename'` if element got renamed (e.g. `writer.rename()`),
346
- * * `'refresh'` if element got refreshed (e.g. `model.editing.reconvertItem()`).
347
- */
348
- export type DifferItemAction = 'insert' | 'remove' | 'rename' | 'refresh';
349
- /**
350
- * A snapshot is representing state of a given element before the first change was applied on that element.
351
- */
352
- export interface DifferSnapshot {
353
- /**
354
- * Node for which was snapshot was made.
355
- */
356
- node: Node;
357
- /**
358
- * Name of the element at the time when the snapshot was made. For text node snapshots, it is set to `'$text'`.
359
- */
360
- name: string;
361
- /**
362
- * Attributes of the node at the time when the snapshot was made.
363
- */
364
- attributes: Map<string, unknown>;
365
- }
366
- /**
367
- * The single diff item.
368
- *
369
- * Could be one of:
370
- *
371
- * * {@link module:engine/model/differ~DiffItemInsert `DiffItemInsert`},
372
- * * {@link module:engine/model/differ~DiffItemRemove `DiffItemRemove`},
373
- * * {@link module:engine/model/differ~DiffItemAttribute `DiffItemAttribute`}.
374
- */
375
- export type DiffItem = DiffItemInsert | DiffItemRemove | DiffItemAttribute;
376
- /**
377
- * A single diff item for inserted nodes.
378
- */
379
- export interface DiffItemInsert {
380
- /**
381
- * The type of diff item.
382
- */
383
- type: 'insert';
384
- /**
385
- * Further specifies what kind of action led to generating this change.
386
- *
387
- * The action is set in relation to the document state before any change. It means that, for example, if an element was added and
388
- * then renamed (during the same {@link module:engine/model/batch~Batch batch}), the action will be set to `'insert'`, because when
389
- * compared to the document state before changes, a new element was inserted, and the renaming does not matter from this point of view.
390
- */
391
- action: DifferItemAction;
392
- /**
393
- * The name of the inserted elements or `'$text'` for a text node.
394
- */
395
- name: string;
396
- /**
397
- * Map of attributes of the inserted element.
398
- */
399
- attributes: Map<string, unknown>;
400
- /**
401
- * The position where the node was inserted.
402
- */
403
- position: Position;
404
- /**
405
- * The length of an inserted text node. For elements, it is always 1 as each inserted element is counted as a one.
406
- */
407
- length: number;
408
- /**
409
- * Holds information about the element state before all changes happened.
410
- *
411
- * For example, when `<paragraph textAlign="right">` was changed to `<codeBlock language="plaintext">`,
412
- * `before.name` will be equal to `'paragraph'` and `before.attributes` map will have one entry: `'textAlign' -> 'right'`.
413
- *
414
- * The property is available only if the insertion change was due to element rename or refresh (when `action` property is `'rename'`
415
- * or `'refresh'`). As such, `before` property is never available for text node changes.
416
- */
417
- before?: {
418
- /**
419
- * The name of the inserted element before all changes.
420
- */
421
- name: string;
422
- /**
423
- * Map of the attributes of the inserted element before all changes.
424
- */
425
- attributes: Map<string, unknown>;
426
- };
427
- }
428
- /**
429
- * A single diff item for removed nodes.
430
- */
431
- export interface DiffItemRemove {
432
- /**
433
- * The type of diff item.
434
- */
435
- type: 'remove';
436
- /**
437
- * Further specifies what kind of action led to generating this change.
438
- *
439
- * The action is set in relation to the document state before any change. It means that, for example, if an element was renamed and
440
- * then removed (during the same {@link module:engine/model/batch~Batch batch}), the action will be set to `'remove'`, because when
441
- * compared to the document state before changes, the element was removed, and it does not matter that it was also renamed at one point.
442
- */
443
- action: DifferItemAction;
444
- /**
445
- * The name of the removed element or `'$text'` for a text node.
446
- */
447
- name: string;
448
- /**
449
- * Map of attributes that were set on the item while it was removed.
450
- */
451
- attributes: Map<string, unknown>;
452
- /**
453
- * The position where the node was removed.
454
- */
455
- position: Position;
456
- /**
457
- * The length of a removed text node. For elements, it is always 1, as each removed element is counted as a one.
458
- */
459
- length: number;
460
- }
461
- /**
462
- * A single diff item for attribute change.
463
- */
464
- export interface DiffItemAttribute {
465
- /**
466
- * The type of diff item.
467
- */
468
- type: 'attribute';
469
- /**
470
- * The name of the changed attribute.
471
- */
472
- attributeKey: string;
473
- /**
474
- * An attribute previous value (before change).
475
- */
476
- attributeOldValue: unknown;
477
- /**
478
- * An attribute new value (after change).
479
- */
480
- attributeNewValue: unknown;
481
- /**
482
- * The range where the change happened.
483
- */
484
- range: Range;
485
- }
486
- /**
487
- * A single diff item for a changed root.
488
- */
489
- export interface DiffItemRoot {
490
- /**
491
- * Name of the changed root.
492
- */
493
- name: string;
494
- /**
495
- * Set accordingly if the root got attached or detached. Otherwise, not set.
496
- */
497
- state?: 'attached' | 'detached';
498
- /**
499
- * Keeps all attribute changes that happened on the root.
500
- *
501
- * The keys are keys of the changed attributes. The values are objects containing the attribute value before the change
502
- * (`oldValue`) and after the change (`newValue`).
503
- *
504
- * Note, that if the root state changed (`state` is set), then `attributes` property will not be set. All attributes should be
505
- * handled together with the root being attached or detached.
506
- */
507
- attributes?: Record<string, {
508
- oldValue: unknown;
509
- newValue: unknown;
510
- }>;
511
- }