@ckeditor/ckeditor5-engine 44.1.0 → 44.2.0-alpha.1

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,278 +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/document
11
- */
12
- import Differ from './differ.js';
13
- import DocumentSelection from './documentselection.js';
14
- import History from './history.js';
15
- import RootElement from './rootelement.js';
16
- import type { default as Model } from './model.js';
17
- import type Batch from './batch.js';
18
- import type Range from './range.js';
19
- import type Writer from './writer.js';
20
- import { Collection } from '@ckeditor/ckeditor5-utils';
21
- declare const Document_base: {
22
- new (): import("@ckeditor/ckeditor5-utils").Emitter;
23
- prototype: import("@ckeditor/ckeditor5-utils").Emitter; /**
24
- * The model differ object. Its role is to buffer changes done on the model document and then calculate a diff of those changes.
25
- */
26
- };
27
- /**
28
- * Data model's document. It contains the model's structure, its selection and the history of changes.
29
- *
30
- * Read more about working with the model in
31
- * {@glink framework/architecture/editing-engine#model introduction to the the editing engine's architecture}.
32
- *
33
- * Usually, the document contains just one {@link module:engine/model/document~Document#roots root element}, so
34
- * you can retrieve it by just calling {@link module:engine/model/document~Document#getRoot} without specifying its name:
35
- *
36
- * ```ts
37
- * model.document.getRoot(); // -> returns the main root
38
- * ```
39
- *
40
- * However, the document may contain multiple roots – e.g. when the editor has multiple editable areas
41
- * (e.g. a title and a body of a message).
42
- */
43
- export default class Document extends /* #__PURE__ */ Document_base {
44
- /**
45
- * The {@link module:engine/model/model~Model model} that the document is a part of.
46
- */
47
- readonly model: Model;
48
- /**
49
- * The document's history.
50
- */
51
- readonly history: History;
52
- /**
53
- * The selection in this document.
54
- */
55
- readonly selection: DocumentSelection;
56
- /**
57
- * A list of roots that are owned and managed by this document. Use {@link #createRoot}, {@link #getRoot} and
58
- * {@link #getRootNames} to manipulate it.
59
- */
60
- readonly roots: Collection<RootElement>;
61
- /**
62
- * The model differ object. Its role is to buffer changes done on the model document and then calculate a diff of those changes.
63
- */
64
- readonly differ: Differ;
65
- /**
66
- * Defines whether the document is in a read-only mode.
67
- *
68
- * The user should not be able to change the data of a document that is read-only.
69
- *
70
- * @readonly
71
- */
72
- isReadOnly: boolean;
73
- /**
74
- * Post-fixer callbacks registered to the model document.
75
- */
76
- private readonly _postFixers;
77
- /**
78
- * A flag that indicates whether the selection has changed since last change block.
79
- */
80
- private _hasSelectionChangedFromTheLastChangeBlock;
81
- /**
82
- * Creates an empty document instance with no {@link #roots} (other than
83
- * the {@link #graveyard graveyard root}).
84
- */
85
- constructor(model: Model);
86
- /**
87
- * The document version. Every applied operation increases the version number. It is used to
88
- * ensure that operations are applied on a proper document version.
89
- *
90
- * This property is equal to {@link module:engine/model/history~History#version `model.Document#history#version`}.
91
- *
92
- * If the {@link module:engine/model/operation/operation~Operation#baseVersion base version} does not match the document version,
93
- * a {@link module:utils/ckeditorerror~CKEditorError model-document-applyoperation-wrong-version} error is thrown.
94
- */
95
- get version(): number;
96
- set version(version: number);
97
- /**
98
- * The graveyard tree root. A document always has a graveyard root that stores removed nodes.
99
- */
100
- get graveyard(): RootElement;
101
- /**
102
- * Creates a new root.
103
- *
104
- * **Note:** do not use this method after the editor has been initialized! If you want to dynamically add a root, use
105
- * {@link module:engine/model/writer~Writer#addRoot `model.Writer#addRoot`} instead.
106
- *
107
- * @param elementName The element name. Defaults to `'$root'` which also has some basic schema defined
108
- * (e.g. `$block` elements are allowed inside the `$root`). Make sure to define a proper schema if you use a different name.
109
- * @param rootName A unique root name.
110
- * @returns The created root.
111
- */
112
- createRoot(elementName?: string, rootName?: string): RootElement;
113
- /**
114
- * Removes all event listeners set by the document instance.
115
- */
116
- destroy(): void;
117
- /**
118
- * Returns a root by its name.
119
- *
120
- * Detached roots are returned by this method. This is to be able to operate on the detached root (for example, to be able to create
121
- * a position inside such a root for undo feature purposes).
122
- *
123
- * @param name The root name of the root to return.
124
- * @returns The root registered under a given name or `null` when there is no root with the given name.
125
- */
126
- getRoot(name?: string): RootElement | null;
127
- /**
128
- * Returns an array with names of all roots added to the document (except the {@link #graveyard graveyard root}).
129
- *
130
- * Detached roots **are not** returned by this method by default. This is to make sure that all features or algorithms that operate
131
- * on the document data know which roots are still a part of the document and should be processed.
132
- *
133
- * @param includeDetached Specified whether detached roots should be returned as well.
134
- */
135
- getRootNames(includeDetached?: boolean): Array<string>;
136
- /**
137
- * Returns an array with all roots added to the document (except the {@link #graveyard graveyard root}).
138
- *
139
- * Detached roots **are not** returned by this method by default. This is to make sure that all features or algorithms that operate
140
- * on the document data know which roots are still a part of the document and should be processed.
141
- *
142
- * @param includeDetached Specified whether detached roots should be returned as well.
143
- */
144
- getRoots(includeDetached?: boolean): Array<RootElement>;
145
- /**
146
- * Used to register a post-fixer callback. A post-fixer mechanism guarantees that the features
147
- * will operate on a correct model state.
148
- *
149
- * An execution of a feature may lead to an incorrect document tree state. The callbacks are used to fix the document tree after
150
- * it has changed. Post-fixers are fired just after all changes from the outermost change block were applied but
151
- * before the {@link module:engine/model/document~Document#event:change change event} is fired. If a post-fixer callback made
152
- * a change, it should return `true`. When this happens, all post-fixers are fired again to check if something else should
153
- * not be fixed in the new document tree state.
154
- *
155
- * As a parameter, a post-fixer callback receives a {@link module:engine/model/writer~Writer writer} instance connected with the
156
- * executed changes block. Thanks to that, all changes done by the callback will be added to the same
157
- * {@link module:engine/model/batch~Batch batch} (and undo step) as the original changes. This makes post-fixer changes transparent
158
- * for the user.
159
- *
160
- * An example of a post-fixer is a callback that checks if all the data were removed from the editor. If so, the
161
- * callback should add an empty paragraph so that the editor is never empty:
162
- *
163
- * ```ts
164
- * document.registerPostFixer( writer => {
165
- * const changes = document.differ.getChanges();
166
- *
167
- * // Check if the changes lead to an empty root in the editor.
168
- * for ( const entry of changes ) {
169
- * if ( entry.type == 'remove' && entry.position.root.isEmpty ) {
170
- * writer.insertElement( 'paragraph', entry.position.root, 0 );
171
- *
172
- * // It is fine to return early, even if multiple roots would need to be fixed.
173
- * // All post-fixers will be fired again, so if there are more empty roots, those will be fixed, too.
174
- * return true;
175
- * }
176
- * }
177
- *
178
- * return false;
179
- * } );
180
- * ```
181
- */
182
- registerPostFixer(postFixer: ModelPostFixer): void;
183
- /**
184
- * A custom `toJSON()` method to solve child-parent circular dependencies.
185
- *
186
- * @returns A clone of this object with the document property changed to a string.
187
- */
188
- toJSON(): unknown;
189
- /**
190
- * Check if there were any changes done on document, and if so, call post-fixers,
191
- * fire `change` event for features and conversion and then reset the differ.
192
- * Fire `change:data` event when at least one operation or buffered marker changes the data.
193
- *
194
- * @internal
195
- * @fires change
196
- * @fires change:data
197
- * @param writer The writer on which post-fixers will be called.
198
- */
199
- _handleChangeBlock(writer: Writer): void;
200
- /**
201
- * Returns whether there is a buffered change or if the selection has changed from the last
202
- * {@link module:engine/model/model~Model#enqueueChange `enqueueChange()` block}
203
- * or {@link module:engine/model/model~Model#change `change()` block}.
204
- *
205
- * @returns Returns `true` if document has changed from the last `change()` or `enqueueChange()` block.
206
- */
207
- protected _hasDocumentChangedFromTheLastChangeBlock(): boolean;
208
- /**
209
- * Returns the default root for this document which is either the first root that was added to the document using
210
- * {@link #createRoot} or the {@link #graveyard graveyard root} if no other roots were created.
211
- *
212
- * @returns The default root for this document.
213
- */
214
- protected _getDefaultRoot(): RootElement;
215
- /**
216
- * Returns the default range for this selection. The default range is a collapsed range that starts and ends
217
- * at the beginning of this selection's document {@link #_getDefaultRoot default root}.
218
- *
219
- * @internal
220
- */
221
- _getDefaultRange(): Range;
222
- /**
223
- * Checks whether a given {@link module:engine/model/range~Range range} is a valid range for
224
- * the {@link #selection document's selection}.
225
- *
226
- * @internal
227
- * @param range A range to check.
228
- * @returns `true` if `range` is valid, `false` otherwise.
229
- */
230
- _validateSelectionRange(range: Range): boolean;
231
- /**
232
- * Performs post-fixer loops. Executes post-fixer callbacks as long as none of them has done any changes to the model.
233
- *
234
- * @param writer The writer on which post-fixer callbacks will be called.
235
- */
236
- private _callPostFixers;
237
- }
238
- /**
239
- * Fired after each {@link module:engine/model/model~Model#enqueueChange `enqueueChange()` block} or the outermost
240
- * {@link module:engine/model/model~Model#change `change()` block} was executed and the document was changed
241
- * during that block's execution.
242
- *
243
- * The changes which this event will cover include:
244
- *
245
- * * document structure changes,
246
- * * selection changes,
247
- * * marker changes.
248
- *
249
- * If you want to be notified about all these changes, then simply listen to this event like this:
250
- *
251
- * ```ts
252
- * model.document.on( 'change', () => {
253
- * console.log( 'The document has changed!' );
254
- * } );
255
- * ```
256
- *
257
- * If, however, you only want to be notified about the data changes, then use `change:data` event,
258
- * which is fired for document structure changes and marker changes (which affects the data).
259
- *
260
- * ```ts
261
- * model.document.on( 'change:data', () => {
262
- * console.log( 'The data has changed!' );
263
- * } );
264
- * ```
265
- *
266
- * @eventName ~Document#change
267
- * @eventName ~Document#change:data
268
- * @param batch The batch that was used in the executed changes block.
269
- */
270
- export type DocumentChangeEvent = {
271
- name: 'change' | 'change:data';
272
- args: [batch: Batch];
273
- };
274
- /**
275
- * Callback passed as an argument to the {@link module:engine/model/document~Document#registerPostFixer} method.
276
- */
277
- export type ModelPostFixer = (writer: Writer) => boolean;
278
- export {};
@@ -1,223 +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/documentfragment
11
- */
12
- import TypeCheckable from './typecheckable.js';
13
- import type Item from './item.js';
14
- import type Node from './node.js';
15
- import type Range from './range.js';
16
- /**
17
- * DocumentFragment represents a part of model which does not have a common root but its top-level nodes
18
- * can be seen as siblings. In other words, it is a detached part of model tree, without a root.
19
- *
20
- * DocumentFragment has own {@link module:engine/model/markercollection~MarkerCollection}. Markers from this collection
21
- * will be set to the {@link module:engine/model/model~Model#markers model markers} by a
22
- * {@link module:engine/model/writer~Writer#insert} function.
23
- */
24
- export default class DocumentFragment extends TypeCheckable implements Iterable<Node> {
25
- /**
26
- * DocumentFragment static markers map. This is a list of names and {@link module:engine/model/range~Range ranges}
27
- * which will be set as Markers to {@link module:engine/model/model~Model#markers model markers collection}
28
- * when DocumentFragment will be inserted to the document.
29
- */
30
- readonly markers: Map<string, Range>;
31
- /**
32
- * Artificial element name. Returns `undefined`. Added for compatibility reasons.
33
- */
34
- name?: undefined;
35
- /**
36
- * Artificial root name. Returns `undefined`. Added for compatibility reasons.
37
- */
38
- rootName?: undefined;
39
- /**
40
- * List of nodes contained inside the document fragment.
41
- */
42
- private readonly _children;
43
- /**
44
- * Creates an empty `DocumentFragment`.
45
- *
46
- * **Note:** Constructor of this class shouldn't be used directly in the code.
47
- * Use the {@link module:engine/model/writer~Writer#createDocumentFragment} method instead.
48
- *
49
- * @internal
50
- * @param children Nodes to be contained inside the `DocumentFragment`.
51
- */
52
- constructor(children?: Node | Iterable<Node>);
53
- /**
54
- * Returns an iterator that iterates over all nodes contained inside this document fragment.
55
- */
56
- [Symbol.iterator](): IterableIterator<Node>;
57
- /**
58
- * Number of this document fragment's children.
59
- */
60
- get childCount(): number;
61
- /**
62
- * Sum of {@link module:engine/model/node~Node#offsetSize offset sizes} of all of this document fragment's children.
63
- */
64
- get maxOffset(): number;
65
- /**
66
- * Is `true` if there are no nodes inside this document fragment, `false` otherwise.
67
- */
68
- get isEmpty(): boolean;
69
- /**
70
- * Artificial next sibling. Returns `null`. Added for compatibility reasons.
71
- */
72
- get nextSibling(): null;
73
- /**
74
- * Artificial previous sibling. Returns `null`. Added for compatibility reasons.
75
- */
76
- get previousSibling(): null;
77
- /**
78
- * Artificial root of `DocumentFragment`. Returns itself. Added for compatibility reasons.
79
- */
80
- get root(): DocumentFragment;
81
- /**
82
- * Artificial parent of `DocumentFragment`. Returns `null`. Added for compatibility reasons.
83
- */
84
- get parent(): null;
85
- /**
86
- * Artificial owner of `DocumentFragment`. Returns `null`. Added for compatibility reasons.
87
- */
88
- get document(): null;
89
- /**
90
- * Returns `false` as `DocumentFragment` by definition is not attached to a document. Added for compatibility reasons.
91
- */
92
- isAttached(): false;
93
- /**
94
- * Returns empty array. Added for compatibility reasons.
95
- */
96
- getAncestors(): Array<never>;
97
- /**
98
- * Gets the child at the given index. Returns `null` if incorrect index was passed.
99
- *
100
- * @param index Index in this document fragment.
101
- * @returns Child node.
102
- */
103
- getChild(index: number): Node | null;
104
- /**
105
- * Gets the child at the given offset. Returns `null` if incorrect index was passed.
106
- *
107
- * @param offset Offset in this document fragment.
108
- * @returns Child node.
109
- */
110
- getChildAtOffset(offset: number): Node | null;
111
- /**
112
- * Returns an iterator that iterates over all of this document fragment's children.
113
- */
114
- getChildren(): IterableIterator<Node>;
115
- /**
116
- * Returns an index of the given child node. Returns `null` if given node is not a child of this document fragment.
117
- *
118
- * @param node Child node to look for.
119
- * @returns Child node's index.
120
- */
121
- getChildIndex(node: Node): number | null;
122
- /**
123
- * Returns the starting offset of given child. Starting offset is equal to the sum of
124
- * {@link module:engine/model/node~Node#offsetSize offset sizes} of all node's siblings that are before it. Returns `null` if
125
- * given node is not a child of this document fragment.
126
- *
127
- * @param node Child node to look for.
128
- * @returns Child node's starting offset.
129
- */
130
- getChildStartOffset(node: Node): number | null;
131
- /**
132
- * Returns path to a `DocumentFragment`, which is an empty array. Added for compatibility reasons.
133
- */
134
- getPath(): Array<number>;
135
- /**
136
- * Returns a descendant node by its path relative to this element.
137
- *
138
- * ```ts
139
- * // <this>a<b>c</b></this>
140
- * this.getNodeByPath( [ 0 ] ); // -> "a"
141
- * this.getNodeByPath( [ 1 ] ); // -> <b>
142
- * this.getNodeByPath( [ 1, 0 ] ); // -> "c"
143
- * ```
144
- *
145
- * @param relativePath Path of the node to find, relative to this element.
146
- */
147
- getNodeByPath(relativePath: Array<number>): Node | DocumentFragment;
148
- /**
149
- * Converts offset "position" to index "position".
150
- *
151
- * Returns index of a node that occupies given offset. If given offset is too low, returns `0`. If given offset is
152
- * too high, returns index after last child.
153
- *
154
- * ```ts
155
- * const textNode = new Text( 'foo' );
156
- * const pElement = new Element( 'p' );
157
- * const docFrag = new DocumentFragment( [ textNode, pElement ] );
158
- * docFrag.offsetToIndex( -1 ); // Returns 0, because offset is too low.
159
- * docFrag.offsetToIndex( 0 ); // Returns 0, because offset 0 is taken by `textNode` which is at index 0.
160
- * docFrag.offsetToIndex( 1 ); // Returns 0, because `textNode` has `offsetSize` equal to 3, so it occupies offset 1 too.
161
- * docFrag.offsetToIndex( 2 ); // Returns 0.
162
- * docFrag.offsetToIndex( 3 ); // Returns 1.
163
- * docFrag.offsetToIndex( 4 ); // Returns 2. There are no nodes at offset 4, so last available index is returned.
164
- * ```
165
- *
166
- * @param offset Offset to look for.
167
- * @returns Index of a node that occupies given offset.
168
- */
169
- offsetToIndex(offset: number): number;
170
- /**
171
- * Converts `DocumentFragment` instance to plain object and returns it.
172
- * Takes care of converting all of this document fragment's children.
173
- *
174
- * @returns `DocumentFragment` instance converted to plain object.
175
- */
176
- toJSON(): unknown;
177
- /**
178
- * Creates a `DocumentFragment` instance from given plain object (i.e. parsed JSON string).
179
- * Converts `DocumentFragment` children to proper nodes.
180
- *
181
- * @param json Plain object to be converted to `DocumentFragment`.
182
- * @returns `DocumentFragment` instance created using given plain object.
183
- */
184
- static fromJSON(json: any): DocumentFragment;
185
- /**
186
- * {@link #_insertChild Inserts} one or more nodes at the end of this document fragment.
187
- *
188
- * @internal
189
- * @param items Items to be inserted.
190
- */
191
- _appendChild(items: string | Item | Iterable<string | Item>): void;
192
- /**
193
- * Inserts one or more nodes at the given index and sets {@link module:engine/model/node~Node#parent parent} of these nodes
194
- * to this document fragment.
195
- *
196
- * @internal
197
- * @param index Index at which nodes should be inserted.
198
- * @param items Items to be inserted.
199
- */
200
- _insertChild(index: number, items: string | Item | Iterable<string | Item>): void;
201
- /**
202
- * Removes one or more nodes starting at the given index
203
- * and sets {@link module:engine/model/node~Node#parent parent} of these nodes to `null`.
204
- *
205
- * @internal
206
- * @param index Index of the first node to remove.
207
- * @param howMany Number of nodes to remove.
208
- * @returns Array containing removed nodes.
209
- */
210
- _removeChildren(index: number, howMany?: number): Array<Node>;
211
- /**
212
- * Removes children nodes provided as an array and sets
213
- * the {@link module:engine/model/node~Node#parent parent} of these nodes to `null`.
214
- *
215
- * These nodes do not need to be direct siblings.
216
- *
217
- * This method is faster than removing nodes one by one, as it recalculates offsets only once.
218
- *
219
- * @internal
220
- * @param nodes Array of nodes.
221
- */
222
- _removeChildrenArray(nodes: Array<Node>): void;
223
- }