@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,549 +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/position
11
- */
12
- import TypeCheckable from './typecheckable.js';
13
- import { type TreeWalkerOptions, type TreeWalkerValue } from './treewalker.js';
14
- import type Document from './document.js';
15
- import type DocumentFragment from './documentfragment.js';
16
- import type Element from './element.js';
17
- import type InsertOperation from './operation/insertoperation.js';
18
- import type Item from './item.js';
19
- import type MergeOperation from './operation/mergeoperation.js';
20
- import type MoveOperation from './operation/moveoperation.js';
21
- import type Node from './node.js';
22
- import type Operation from './operation/operation.js';
23
- import type SplitOperation from './operation/splitoperation.js';
24
- import type Text from './text.js';
25
- /**
26
- * Represents a position in the model tree.
27
- *
28
- * A position is represented by its {@link module:engine/model/position~Position#root} and
29
- * a {@link module:engine/model/position~Position#path} in that root.
30
- *
31
- * You can create position instances via its constructor or the `createPosition*()` factory methods of
32
- * {@link module:engine/model/model~Model} and {@link module:engine/model/writer~Writer}.
33
- *
34
- * **Note:** Position is based on offsets, not indexes. This means that a position between two text nodes
35
- * `foo` and `bar` has offset `3`, not `1`. See {@link module:engine/model/position~Position#path} for more information.
36
- *
37
- * Since a position in the model is represented by a {@link module:engine/model/position~Position#root position root} and
38
- * {@link module:engine/model/position~Position#path position path} it is possible to create positions placed in non-existing places.
39
- * This requirement is important for operational transformation algorithms.
40
- *
41
- * Also, {@link module:engine/model/operation/operation~Operation operations}
42
- * kept in the {@link module:engine/model/document~Document#history document history}
43
- * are storing positions (and ranges) which were correct when those operations were applied, but may not be correct
44
- * after the document has changed.
45
- *
46
- * When changes are applied to the model, it may also happen that {@link module:engine/model/position~Position#parent position parent}
47
- * will change even if position path has not changed. Keep in mind, that if a position leads to non-existing element,
48
- * {@link module:engine/model/position~Position#parent} and some other properties and methods will throw errors.
49
- *
50
- * In most cases, position with wrong path is caused by an error in code, but it is sometimes needed, as described above.
51
- */
52
- export default class Position extends TypeCheckable {
53
- /**
54
- * Root of the position path.
55
- */
56
- readonly root: Element | DocumentFragment;
57
- /**
58
- * Position of the node in the tree. **Path contains offsets, not indexes.**
59
- *
60
- * Position can be placed before, after or in a {@link module:engine/model/node~Node node} if that node has
61
- * {@link module:engine/model/node~Node#offsetSize} greater than `1`. Items in position path are
62
- * {@link module:engine/model/node~Node#startOffset starting offsets} of position ancestors, starting from direct root children,
63
- * down to the position offset in it's parent.
64
- *
65
- * ```
66
- * ROOT
67
- * |- P before: [ 0 ] after: [ 1 ]
68
- * |- UL before: [ 1 ] after: [ 2 ]
69
- * |- LI before: [ 1, 0 ] after: [ 1, 1 ]
70
- * | |- foo before: [ 1, 0, 0 ] after: [ 1, 0, 3 ]
71
- * |- LI before: [ 1, 1 ] after: [ 1, 2 ]
72
- * |- bar before: [ 1, 1, 0 ] after: [ 1, 1, 3 ]
73
- * ```
74
- *
75
- * `foo` and `bar` are representing {@link module:engine/model/text~Text text nodes}. Since text nodes has offset size
76
- * greater than `1` you can place position offset between their start and end:
77
- *
78
- * ```
79
- * ROOT
80
- * |- P
81
- * |- UL
82
- * |- LI
83
- * | |- f^o|o ^ has path: [ 1, 0, 1 ] | has path: [ 1, 0, 2 ]
84
- * |- LI
85
- * |- b^a|r ^ has path: [ 1, 1, 1 ] | has path: [ 1, 1, 2 ]
86
- * ```
87
- */
88
- readonly path: ReadonlyArray<number>;
89
- /**
90
- * Position stickiness. See {@link module:engine/model/position~PositionStickiness}.
91
- */
92
- stickiness: PositionStickiness;
93
- /**
94
- * Creates a position.
95
- *
96
- * @param root Root of the position.
97
- * @param path Position path. See {@link module:engine/model/position~Position#path}.
98
- * @param stickiness Position stickiness. See {@link module:engine/model/position~PositionStickiness}.
99
- */
100
- constructor(root: Element | DocumentFragment, path: ReadonlyArray<number>, stickiness?: PositionStickiness);
101
- /**
102
- * Offset at which this position is located in its {@link module:engine/model/position~Position#parent parent}. It is equal
103
- * to the last item in position {@link module:engine/model/position~Position#path path}.
104
- *
105
- * @type {Number}
106
- */
107
- get offset(): number;
108
- set offset(newOffset: number);
109
- /**
110
- * Parent element of this position.
111
- *
112
- * Keep in mind that `parent` value is calculated when the property is accessed.
113
- * If {@link module:engine/model/position~Position#path position path}
114
- * leads to a non-existing element, `parent` property will throw error.
115
- *
116
- * Also it is a good idea to cache `parent` property if it is used frequently in an algorithm (i.e. in a long loop).
117
- */
118
- get parent(): Element | DocumentFragment;
119
- /**
120
- * Position {@link module:engine/model/position~Position#offset offset} converted to an index in position's parent node. It is
121
- * equal to the {@link module:engine/model/node~Node#index index} of a node after this position. If position is placed
122
- * in text node, position index is equal to the index of that text node.
123
- */
124
- get index(): number;
125
- /**
126
- * Returns {@link module:engine/model/text~Text text node} instance in which this position is placed or `null` if this
127
- * position is not in a text node.
128
- */
129
- get textNode(): Text | null;
130
- /**
131
- * Node directly after this position. Returns `null` if this position is at the end of its parent, or if it is in a text node.
132
- */
133
- get nodeAfter(): Node | null;
134
- /**
135
- * Node directly before this position. Returns `null` if this position is at the start of its parent, or if it is in a text node.
136
- */
137
- get nodeBefore(): Node | null;
138
- /**
139
- * Is `true` if position is at the beginning of its {@link module:engine/model/position~Position#parent parent}, `false` otherwise.
140
- */
141
- get isAtStart(): boolean;
142
- /**
143
- * Is `true` if position is at the end of its {@link module:engine/model/position~Position#parent parent}, `false` otherwise.
144
- */
145
- get isAtEnd(): boolean;
146
- /**
147
- * Checks whether the position is valid in current model tree, that is whether it points to an existing place in the model.
148
- */
149
- isValid(): boolean;
150
- /**
151
- * Checks whether this position is before or after given position.
152
- *
153
- * This method is safe to use it on non-existing positions (for example during operational transformation).
154
- */
155
- compareWith(otherPosition: Position): PositionRelation;
156
- /**
157
- * Gets the farthest position which matches the callback using
158
- * {@link module:engine/model/treewalker~TreeWalker TreeWalker}.
159
- *
160
- * For example:
161
- *
162
- * ```ts
163
- * getLastMatchingPosition( value => value.type == 'text' );
164
- * // <paragraph>[]foo</paragraph> -> <paragraph>foo[]</paragraph>
165
- *
166
- * getLastMatchingPosition( value => value.type == 'text', { direction: 'backward' } );
167
- * // <paragraph>foo[]</paragraph> -> <paragraph>[]foo</paragraph>
168
- *
169
- * getLastMatchingPosition( value => false );
170
- * // Do not move the position.
171
- * ```
172
- *
173
- * @param skip Callback function. Gets {@link module:engine/model/treewalker~TreeWalkerValue} and should
174
- * return `true` if the value should be skipped or `false` if not.
175
- * @param options Object with configuration options. See {@link module:engine/model/treewalker~TreeWalker}.
176
- *
177
- * @returns The position after the last item which matches the `skip` callback test.
178
- */
179
- getLastMatchingPosition(skip: (value: TreeWalkerValue) => boolean, options?: TreeWalkerOptions): Position;
180
- /**
181
- * Returns a path to this position's parent. Parent path is equal to position {@link module:engine/model/position~Position#path path}
182
- * but without the last item.
183
- *
184
- * This method is safe to use it on non-existing positions (for example during operational transformation).
185
- *
186
- * @returns Path to the parent.
187
- */
188
- getParentPath(): Array<number>;
189
- /**
190
- * Returns ancestors array of this position, that is this position's parent and its ancestors.
191
- *
192
- * @returns Array with ancestors.
193
- */
194
- getAncestors(): Array<Element | DocumentFragment>;
195
- /**
196
- * Returns the parent element of the given name. Returns null if the position is not inside the desired parent.
197
- *
198
- * @param parentName The name of the parent element to find.
199
- */
200
- findAncestor(parentName: string): Element | null;
201
- /**
202
- * Returns the slice of two position {@link #path paths} which is identical. The {@link #root roots}
203
- * of these two paths must be identical.
204
- *
205
- * This method is safe to use it on non-existing positions (for example during operational transformation).
206
- *
207
- * @param position The second position.
208
- * @returns The common path.
209
- */
210
- getCommonPath(position: Position): Array<number>;
211
- /**
212
- * Returns an {@link module:engine/model/element~Element} or {@link module:engine/model/documentfragment~DocumentFragment}
213
- * which is a common ancestor of both positions. The {@link #root roots} of these two positions must be identical.
214
- *
215
- * @param position The second position.
216
- */
217
- getCommonAncestor(position: Position): Element | DocumentFragment | null;
218
- /**
219
- * Returns a new instance of `Position`, that has same {@link #parent parent} but it's offset
220
- * is shifted by `shift` value (can be a negative value).
221
- *
222
- * This method is safe to use it on non-existing positions (for example during operational transformation).
223
- *
224
- * @param shift Offset shift. Can be a negative value.
225
- * @returns Shifted position.
226
- */
227
- getShiftedBy(shift: number): Position;
228
- /**
229
- * Checks whether this position is after given position.
230
- *
231
- * This method is safe to use it on non-existing positions (for example during operational transformation).
232
- *
233
- * @see module:engine/model/position~Position#isBefore
234
- * @param otherPosition Position to compare with.
235
- * @returns True if this position is after given position.
236
- */
237
- isAfter(otherPosition: Position): boolean;
238
- /**
239
- * Checks whether this position is before given position.
240
- *
241
- * **Note:** watch out when using negation of the value returned by this method, because the negation will also
242
- * be `true` if positions are in different roots and you might not expect this. You should probably use
243
- * `a.isAfter( b ) || a.isEqual( b )` or `!a.isBefore( p ) && a.root == b.root` in most scenarios. If your
244
- * condition uses multiple `isAfter` and `isBefore` checks, build them so they do not use negated values, i.e.:
245
- *
246
- * ```ts
247
- * if ( a.isBefore( b ) && c.isAfter( d ) ) {
248
- * // do A.
249
- * } else {
250
- * // do B.
251
- * }
252
- * ```
253
- *
254
- * or, if you have only one if-branch:
255
- *
256
- * ```ts
257
- * if ( !( a.isBefore( b ) && c.isAfter( d ) ) {
258
- * // do B.
259
- * }
260
- * ```
261
- *
262
- * rather than:
263
- *
264
- * ```ts
265
- * if ( !a.isBefore( b ) || && !c.isAfter( d ) ) {
266
- * // do B.
267
- * } else {
268
- * // do A.
269
- * }
270
- * ```
271
- *
272
- * This method is safe to use it on non-existing positions (for example during operational transformation).
273
- *
274
- * @param otherPosition Position to compare with.
275
- * @returns True if this position is before given position.
276
- */
277
- isBefore(otherPosition: Position): boolean;
278
- /**
279
- * Checks whether this position is equal to given position.
280
- *
281
- * This method is safe to use it on non-existing positions (for example during operational transformation).
282
- *
283
- * @param otherPosition Position to compare with.
284
- * @returns True if positions are same.
285
- */
286
- isEqual(otherPosition: Position): boolean;
287
- /**
288
- * Checks whether this position is touching given position. Positions touch when there are no text nodes
289
- * or empty nodes in a range between them. Technically, those positions are not equal but in many cases
290
- * they are very similar or even indistinguishable.
291
- *
292
- * @param otherPosition Position to compare with.
293
- * @returns True if positions touch.
294
- */
295
- isTouching(otherPosition: Position): boolean;
296
- /**
297
- * Checks if two positions are in the same parent.
298
- *
299
- * This method is safe to use it on non-existing positions (for example during operational transformation).
300
- *
301
- * @param position Position to compare with.
302
- * @returns `true` if positions have the same parent, `false` otherwise.
303
- */
304
- hasSameParentAs(position: Position): boolean;
305
- /**
306
- * Returns a copy of this position that is transformed by given `operation`.
307
- *
308
- * The new position's parameters are updated accordingly to the effect of the `operation`.
309
- *
310
- * For example, if `n` nodes are inserted before the position, the returned position {@link ~Position#offset} will be
311
- * increased by `n`. If the position was in a merged element, it will be accordingly moved to the new element, etc.
312
- *
313
- * This method is safe to use it on non-existing positions (for example during operational transformation).
314
- *
315
- * @param operation Operation to transform by.
316
- * @returns Transformed position.
317
- */
318
- getTransformedByOperation(operation: Operation): Position;
319
- /**
320
- * Returns a copy of this position transformed by an insert operation.
321
- *
322
- * @internal
323
- */
324
- _getTransformedByInsertOperation(operation: InsertOperation): Position;
325
- /**
326
- * Returns a copy of this position transformed by a move operation.
327
- *
328
- * @internal
329
- */
330
- _getTransformedByMoveOperation(operation: MoveOperation): Position;
331
- /**
332
- * Returns a copy of this position transformed by a split operation.
333
- *
334
- * @internal
335
- */
336
- _getTransformedBySplitOperation(operation: SplitOperation): Position;
337
- /**
338
- * Returns a copy of this position transformed by merge operation.
339
- *
340
- * @internal
341
- */
342
- _getTransformedByMergeOperation(operation: MergeOperation): Position;
343
- /**
344
- * Returns a copy of this position that is updated by removing `howMany` nodes starting from `deletePosition`.
345
- * It may happen that this position is in a removed node. If that is the case, `null` is returned instead.
346
- *
347
- * @internal
348
- * @param deletePosition Position before the first removed node.
349
- * @param howMany How many nodes are removed.
350
- * @returns Transformed position or `null`.
351
- */
352
- _getTransformedByDeletion(deletePosition: Position, howMany: number): Position | null;
353
- /**
354
- * Returns a copy of this position that is updated by inserting `howMany` nodes at `insertPosition`.
355
- *
356
- * @internal
357
- * @param insertPosition Position where nodes are inserted.
358
- * @param howMany How many nodes are inserted.
359
- * @returns Transformed position.
360
- */
361
- _getTransformedByInsertion(insertPosition: Position, howMany: number): Position;
362
- /**
363
- * Returns a copy of this position that is updated by moving `howMany` nodes from `sourcePosition` to `targetPosition`.
364
- *
365
- * @internal
366
- * @param sourcePosition Position before the first element to move.
367
- * @param targetPosition Position where moved elements will be inserted.
368
- * @param howMany How many consecutive nodes to move, starting from `sourcePosition`.
369
- * @returns Transformed position.
370
- */
371
- _getTransformedByMove(sourcePosition: Position, targetPosition: Position, howMany: number): Position;
372
- /**
373
- * Returns a new position that is a combination of this position and given positions.
374
- *
375
- * The combined position is a copy of this position transformed by moving a range starting at `source` position
376
- * to the `target` position. It is expected that this position is inside the moved range.
377
- *
378
- * Example:
379
- *
380
- * ```ts
381
- * let original = model.createPositionFromPath( root, [ 2, 3, 1 ] );
382
- * let source = model.createPositionFromPath( root, [ 2, 2 ] );
383
- * let target = model.createPositionFromPath( otherRoot, [ 1, 1, 3 ] );
384
- * original._getCombined( source, target ); // path is [ 1, 1, 4, 1 ], root is `otherRoot`
385
- * ```
386
- *
387
- * Explanation:
388
- *
389
- * We have a position `[ 2, 3, 1 ]` and move some nodes from `[ 2, 2 ]` to `[ 1, 1, 3 ]`. The original position
390
- * was inside moved nodes and now should point to the new place. The moved nodes will be after
391
- * positions `[ 1, 1, 3 ]`, `[ 1, 1, 4 ]`, `[ 1, 1, 5 ]`. Since our position was in the second moved node,
392
- * the transformed position will be in a sub-tree of a node at `[ 1, 1, 4 ]`. Looking at original path, we
393
- * took care of `[ 2, 3 ]` part of it. Now we have to add the rest of the original path to the transformed path.
394
- * Finally, the transformed position will point to `[ 1, 1, 4, 1 ]`.
395
- *
396
- * @internal
397
- * @param source Beginning of the moved range.
398
- * @param target Position where the range is moved.
399
- * @returns Combined position.
400
- */
401
- _getCombined(source: Position, target: Position): Position;
402
- /**
403
- * @inheritDoc
404
- */
405
- toJSON(): unknown;
406
- /**
407
- * Returns a new position that is equal to current position.
408
- */
409
- clone(): this;
410
- /**
411
- * Creates position at the given location. The location can be specified as:
412
- *
413
- * * a {@link module:engine/model/position~Position position},
414
- * * parent element and offset (offset defaults to `0`),
415
- * * parent element and `'end'` (sets position at the end of that element),
416
- * * {@link module:engine/model/item~Item model item} and `'before'` or `'after'` (sets position before or after given model item).
417
- *
418
- * This method is a shortcut to other factory methods such as:
419
- *
420
- * * {@link module:engine/model/position~Position._createBefore},
421
- * * {@link module:engine/model/position~Position._createAfter}.
422
- *
423
- * @internal
424
- * @param offset Offset or one of the flags. Used only when the first parameter is a {@link module:engine/model/item~Item model item}.
425
- * @param stickiness Position stickiness. Used only when the first parameter is a {@link module:engine/model/item~Item model item}.
426
- */
427
- static _createAt(itemOrPosition: Item | Position | DocumentFragment, offset?: PositionOffset, stickiness?: PositionStickiness): Position;
428
- /**
429
- * Creates a new position, after given {@link module:engine/model/item~Item model item}.
430
- *
431
- * @internal
432
- * @param item Item after which the position should be placed.
433
- * @param stickiness Position stickiness.
434
- */
435
- static _createAfter(item: Item | DocumentFragment, stickiness?: PositionStickiness): Position;
436
- /**
437
- * Creates a new position, before the given {@link module:engine/model/item~Item model item}.
438
- *
439
- * @internal
440
- * @param item Item before which the position should be placed.
441
- * @param stickiness Position stickiness.
442
- */
443
- static _createBefore(item: Item | DocumentFragment, stickiness?: PositionStickiness): Position;
444
- /**
445
- * Creates a `Position` instance from given plain object (i.e. parsed JSON string).
446
- *
447
- * @param json Plain object to be converted to `Position`.
448
- * @param doc Document object that will be position owner.
449
- * @returns `Position` instance created using given plain object.
450
- */
451
- static fromJSON(json: any, doc: Document): Position;
452
- }
453
- /**
454
- * A flag indicating whether this position is `'before'` or `'after'` or `'same'` as given position.
455
- * If positions are in different roots `'different'` flag is returned.
456
- */
457
- export type PositionRelation = 'before' | 'after' | 'same' | 'different';
458
- /**
459
- * Offset or one of the flags.
460
- */
461
- export type PositionOffset = number | 'before' | 'after' | 'end';
462
- /**
463
- * Represents how position is "sticking" with neighbour nodes. Used to define how position should be transformed (moved)
464
- * in edge cases. Possible values: `'toNone'`, `'toNext'`, `'toPrevious'`.
465
- *
466
- * Examples:
467
- *
468
- * ```
469
- * Insert. Position is at | and nodes are inserted at the same position, marked as ^:
470
- *
471
- * - sticks to none: <p>f^|oo</p> -> <p>fbar|oo</p>
472
- * - sticks to next node: <p>f^|oo</p> -> <p>fbar|oo</p>
473
- * - sticks to previous node: <p>f|^oo</p> -> <p>f|baroo</p>
474
- * ```
475
- *
476
- *
477
- * Move. Position is at | and range [oo] is moved to position ^:
478
- *
479
- * ```
480
- * - sticks to none: <p>f|[oo]</p><p>b^ar</p> -> <p>f|</p><p>booar</p>
481
- * - sticks to none: <p>f[oo]|</p><p>b^ar</p> -> <p>f|</p><p>booar</p>
482
- *
483
- * - sticks to next node: <p>f|[oo]</p><p>b^ar</p> -> <p>f</p><p>b|ooar</p>
484
- * - sticks to next node: <p>f[oo]|</p><p>b^ar</p> -> <p>f|</p><p>booar</p>
485
- *
486
- * - sticks to previous node: <p>f|[oo]</p><p>b^ar</p> -> <p>f|</p><p>booar</p>
487
- * - sticks to previous node: <p>f[oo]|</p><p>b^ar</p> -> <p>f</p><p>boo|ar</p>
488
- * ```
489
- */
490
- export type PositionStickiness = 'toNone' | 'toNext' | 'toPrevious';
491
- /**
492
- * Returns a text node at the given position.
493
- *
494
- * This is a helper function optimized to reuse the position parent instance for performance reasons.
495
- *
496
- * Normally, you should use {@link module:engine/model/position~Position#textNode `Position#textNode`}.
497
- * If you start hitting performance issues with {@link module:engine/model/position~Position#parent `Position#parent`}
498
- * check if your algorithm does not access it multiple times (which can happen directly or indirectly via other position properties).
499
- *
500
- * See https://github.com/ckeditor/ckeditor5/issues/6579.
501
- *
502
- * See also:
503
- *
504
- * * {@link module:engine/model/position~getNodeAfterPosition}
505
- * * {@link module:engine/model/position~getNodeBeforePosition}
506
- *
507
- * @param position
508
- * @param positionParent The parent of the given position.
509
- */
510
- export declare function getTextNodeAtPosition(position: Position, positionParent: Element | DocumentFragment): Text | null;
511
- /**
512
- * Returns the node after the given position.
513
- *
514
- * This is a helper function optimized to reuse the position parent instance and the calculation of the text node at the
515
- * specific position for performance reasons.
516
- *
517
- * Normally, you should use {@link module:engine/model/position~Position#nodeAfter `Position#nodeAfter`}.
518
- * If you start hitting performance issues with {@link module:engine/model/position~Position#parent `Position#parent`} and/or
519
- * {@link module:engine/model/position~Position#textNode `Position#textNode`}
520
- * check if your algorithm does not access those properties multiple times
521
- * (which can happen directly or indirectly via other position properties).
522
- *
523
- * See https://github.com/ckeditor/ckeditor5/issues/6579 and https://github.com/ckeditor/ckeditor5/issues/6582.
524
- *
525
- * See also:
526
- *
527
- * * {@link module:engine/model/position~getTextNodeAtPosition}
528
- * * {@link module:engine/model/position~getNodeBeforePosition}
529
- *
530
- * @param position Position to check.
531
- * @param positionParent The parent of the given position.
532
- * @param textNode Text node at the given position.
533
- */
534
- export declare function getNodeAfterPosition(position: Position, positionParent: Element | DocumentFragment, textNode: Text | null): Node | null;
535
- /**
536
- * Returns the node before the given position.
537
- *
538
- * Refer to {@link module:engine/model/position~getNodeBeforePosition} for documentation on when to use this util method.
539
- *
540
- * See also:
541
- *
542
- * * {@link module:engine/model/position~getTextNodeAtPosition}
543
- * * {@link module:engine/model/position~getNodeAfterPosition}
544
- *
545
- * @param position Position to check.
546
- * @param positionParent The parent of the given position.
547
- * @param textNode Text node at the given position.
548
- */
549
- export declare function getNodeBeforePosition(position: Position, positionParent: Element | DocumentFragment, textNode: Text | null): Node | null;