@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,424 +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/documentselection
11
- */
12
- import TypeCheckable from './typecheckable.js';
13
- import Selection, { type SelectionChangeAttributeEvent, type SelectionChangeRangeEvent } from './selection.js';
14
- import type { default as Document } from './document.js';
15
- import type { Marker } from './markercollection.js';
16
- import type Element from './element.js';
17
- import type Item from './item.js';
18
- import type { default as Position, PositionOffset } from './position.js';
19
- import type Range from './range.js';
20
- import { Collection } from '@ckeditor/ckeditor5-utils';
21
- declare const DocumentSelection_base: import("@ckeditor/ckeditor5-utils").Mixed<typeof TypeCheckable, import("@ckeditor/ckeditor5-utils").Emitter>;
22
- /**
23
- * `DocumentSelection` is a special selection which is used as the
24
- * {@link module:engine/model/document~Document#selection document's selection}.
25
- * There can be only one instance of `DocumentSelection` per document.
26
- *
27
- * Document selection can only be changed by using the {@link module:engine/model/writer~Writer} instance
28
- * inside the {@link module:engine/model/model~Model#change `change()`} block, as it provides a secure way to modify model.
29
- *
30
- * `DocumentSelection` is automatically updated upon changes in the {@link module:engine/model/document~Document document}
31
- * to always contain valid ranges. Its attributes are inherited from the text unless set explicitly.
32
- *
33
- * Differences between {@link module:engine/model/selection~Selection} and `DocumentSelection` are:
34
- * * there is always a range in `DocumentSelection` - even if no ranges were added there is a "default range"
35
- * present in the selection,
36
- * * ranges added to this selection updates automatically when the document changes,
37
- * * attributes of `DocumentSelection` are updated automatically according to selection ranges.
38
- *
39
- * Since `DocumentSelection` uses {@link module:engine/model/liverange~LiveRange live ranges}
40
- * and is updated when {@link module:engine/model/document~Document document}
41
- * changes, it cannot be set on {@link module:engine/model/node~Node nodes}
42
- * that are inside {@link module:engine/model/documentfragment~DocumentFragment document fragment}.
43
- * If you need to represent a selection in document fragment,
44
- * use {@link module:engine/model/selection~Selection Selection class} instead.
45
- */
46
- export default class DocumentSelection extends /* #__PURE__ */ DocumentSelection_base {
47
- /**
48
- * Selection used internally by that class (`DocumentSelection` is a proxy to that selection).
49
- */
50
- private _selection;
51
- /**
52
- * Creates an empty live selection for given {@link module:engine/model/document~Document}.
53
- *
54
- * @param doc Document which owns this selection.
55
- */
56
- constructor(doc: Document);
57
- /**
58
- * Describes whether the selection is collapsed. Selection is collapsed when there is exactly one range which is
59
- * collapsed.
60
- */
61
- get isCollapsed(): boolean;
62
- /**
63
- * Selection anchor. Anchor may be described as a position where the most recent part of the selection starts.
64
- * Together with {@link #focus} they define the direction of selection, which is important
65
- * when expanding/shrinking selection. Anchor is always {@link module:engine/model/range~Range#start start} or
66
- * {@link module:engine/model/range~Range#end end} position of the most recently added range.
67
- *
68
- * Is set to `null` if there are no ranges in selection.
69
- *
70
- * @see #focus
71
- */
72
- get anchor(): Position | null;
73
- /**
74
- * Selection focus. Focus is a position where the selection ends.
75
- *
76
- * Is set to `null` if there are no ranges in selection.
77
- *
78
- * @see #anchor
79
- */
80
- get focus(): Position | null;
81
- /**
82
- * Number of ranges in selection.
83
- */
84
- get rangeCount(): number;
85
- /**
86
- * Describes whether `Documentselection` has own range(s) set, or if it is defaulted to
87
- * {@link module:engine/model/document~Document#_getDefaultRange document's default range}.
88
- */
89
- get hasOwnRange(): boolean;
90
- /**
91
- * Specifies whether the {@link #focus}
92
- * precedes {@link #anchor}.
93
- *
94
- * @readonly
95
- * @type {Boolean}
96
- */
97
- get isBackward(): boolean;
98
- /**
99
- * Describes whether the gravity is overridden (using {@link module:engine/model/writer~Writer#overrideSelectionGravity}) or not.
100
- *
101
- * Note that the gravity remains overridden as long as will not be restored the same number of times as it was overridden.
102
- */
103
- get isGravityOverridden(): boolean;
104
- /**
105
- * A collection of selection {@link module:engine/model/markercollection~Marker markers}.
106
- * Marker is a selection marker when selection range is inside the marker range.
107
- *
108
- * **Note**: Only markers from {@link ~DocumentSelection#observeMarkers observed markers groups} are collected.
109
- */
110
- get markers(): Collection<Marker>;
111
- /**
112
- * Used for the compatibility with the {@link module:engine/model/selection~Selection#isEqual} method.
113
- *
114
- * @internal
115
- */
116
- get _ranges(): Array<Range>;
117
- /**
118
- * Returns an iterable that iterates over copies of selection ranges.
119
- */
120
- getRanges(): IterableIterator<Range>;
121
- /**
122
- * Returns the first position in the selection.
123
- * First position is the position that {@link module:engine/model/position~Position#isBefore is before}
124
- * any other position in the selection.
125
- *
126
- * Returns `null` if there are no ranges in selection.
127
- */
128
- getFirstPosition(): Position | null;
129
- /**
130
- * Returns the last position in the selection.
131
- * Last position is the position that {@link module:engine/model/position~Position#isAfter is after}
132
- * any other position in the selection.
133
- *
134
- * Returns `null` if there are no ranges in selection.
135
- */
136
- getLastPosition(): Position | null;
137
- /**
138
- * Returns a copy of the first range in the selection.
139
- * First range is the one which {@link module:engine/model/range~Range#start start} position
140
- * {@link module:engine/model/position~Position#isBefore is before} start position of all other ranges
141
- * (not to confuse with the first range added to the selection).
142
- *
143
- * Returns `null` if there are no ranges in selection.
144
- */
145
- getFirstRange(): Range | null;
146
- /**
147
- * Returns a copy of the last range in the selection.
148
- * Last range is the one which {@link module:engine/model/range~Range#end end} position
149
- * {@link module:engine/model/position~Position#isAfter is after} end position of all other ranges (not to confuse with the range most
150
- * recently added to the selection).
151
- *
152
- * Returns `null` if there are no ranges in selection.
153
- */
154
- getLastRange(): Range | null;
155
- /**
156
- * Gets elements of type {@link module:engine/model/schema~Schema#isBlock "block"} touched by the selection.
157
- *
158
- * This method's result can be used for example to apply block styling to all blocks covered by this selection.
159
- *
160
- * **Note:** `getSelectedBlocks()` returns blocks that are nested in other non-block elements
161
- * but will not return blocks nested in other blocks.
162
- *
163
- * In this case the function will return exactly all 3 paragraphs (note: `<blockQuote>` is not a block itself):
164
- *
165
- * ```
166
- * <paragraph>[a</paragraph>
167
- * <blockQuote>
168
- * <paragraph>b</paragraph>
169
- * </blockQuote>
170
- * <paragraph>c]d</paragraph>
171
- * ```
172
- *
173
- * In this case the paragraph will also be returned, despite the collapsed selection:
174
- *
175
- * ```
176
- * <paragraph>[]a</paragraph>
177
- * ```
178
- *
179
- * In such a scenario, however, only blocks A, B & E will be returned as blocks C & D are nested in block B:
180
- *
181
- * ```
182
- * [<blockA></blockA>
183
- * <blockB>
184
- * <blockC></blockC>
185
- * <blockD></blockD>
186
- * </blockB>
187
- * <blockE></blockE>]
188
- * ```
189
- *
190
- * If the selection is inside a block all the inner blocks (A & B) are returned:
191
- *
192
- * ```
193
- * <block>
194
- * <blockA>[a</blockA>
195
- * <blockB>b]</blockB>
196
- * </block>
197
- * ```
198
- *
199
- * **Special case**: If a selection ends at the beginning of a block, that block is not returned as from user perspective
200
- * this block wasn't selected. See [#984](https://github.com/ckeditor/ckeditor5-engine/issues/984) for more details.
201
- *
202
- * ```
203
- * <paragraph>[a</paragraph>
204
- * <paragraph>b</paragraph>
205
- * <paragraph>]c</paragraph> // this block will not be returned
206
- * ```
207
- */
208
- getSelectedBlocks(): IterableIterator<Element>;
209
- /**
210
- * Returns the selected element. {@link module:engine/model/element~Element Element} is considered as selected if there is only
211
- * one range in the selection, and that range contains exactly one element.
212
- * Returns `null` if there is no selected element.
213
- */
214
- getSelectedElement(): Element | null;
215
- /**
216
- * Checks whether the selection contains the entire content of the given element. This means that selection must start
217
- * at a position {@link module:engine/model/position~Position#isTouching touching} the element's start and ends at position
218
- * touching the element's end.
219
- *
220
- * By default, this method will check whether the entire content of the selection's current root is selected.
221
- * Useful to check if e.g. the user has just pressed <kbd>Ctrl</kbd> + <kbd>A</kbd>.
222
- */
223
- containsEntireContent(element: Element): boolean;
224
- /**
225
- * Unbinds all events previously bound by document selection.
226
- */
227
- destroy(): void;
228
- /**
229
- * Returns iterable that iterates over this selection's attribute keys.
230
- */
231
- getAttributeKeys(): IterableIterator<string>;
232
- /**
233
- * Returns iterable that iterates over this selection's attributes.
234
- *
235
- * Attributes are returned as arrays containing two items. First one is attribute key and second is attribute value.
236
- * This format is accepted by native `Map` object and also can be passed in `Node` constructor.
237
- */
238
- getAttributes(): IterableIterator<[string, unknown]>;
239
- /**
240
- * Gets an attribute value for given key or `undefined` if that attribute is not set on the selection.
241
- *
242
- * @param key Key of attribute to look for.
243
- * @returns Attribute value or `undefined`.
244
- */
245
- getAttribute(key: string): unknown;
246
- /**
247
- * Checks if the selection has an attribute for given key.
248
- *
249
- * @param key Key of attribute to check.
250
- * @returns `true` if attribute with given key is set on selection, `false` otherwise.
251
- */
252
- hasAttribute(key: string): boolean;
253
- /**
254
- * Refreshes selection attributes and markers according to the current position in the model.
255
- */
256
- refresh(): void;
257
- /**
258
- * Registers a marker group prefix or a marker name to be collected in the
259
- * {@link ~DocumentSelection#markers selection markers collection}.
260
- *
261
- * See also {@link module:engine/model/markercollection~MarkerCollection#getMarkersGroup `MarkerCollection#getMarkersGroup()`}.
262
- *
263
- * @param prefixOrName The marker group prefix or marker name.
264
- */
265
- observeMarkers(prefixOrName: string): void;
266
- /**
267
- * Moves {@link module:engine/model/documentselection~DocumentSelection#focus} to the specified location.
268
- * Should be used only within the {@link module:engine/model/writer~Writer#setSelectionFocus} method.
269
- *
270
- * The location can be specified in the same form as
271
- * {@link module:engine/model/writer~Writer#createPositionAt writer.createPositionAt()} parameters.
272
- *
273
- * @see module:engine/model/writer~Writer#setSelectionFocus
274
- * @internal
275
- * @param offset Offset or one of the flags. Used only when
276
- * first parameter is a {@link module:engine/model/item~Item model item}.
277
- */
278
- _setFocus(itemOrPosition: Item | Position, offset?: PositionOffset): void;
279
- /**
280
- * Sets this selection's ranges and direction to the specified location based on the given
281
- * {@link module:engine/model/selection~Selectable selectable}.
282
- * Should be used only within the {@link module:engine/model/writer~Writer#setSelection} method.
283
- *
284
- * @see module:engine/model/writer~Writer#setSelection
285
- * @internal
286
- */
287
- _setTo(...args: Parameters<Selection['setTo']>): void;
288
- /**
289
- * Sets attribute on the selection. If attribute with the same key already is set, it's value is overwritten.
290
- * Should be used only within the {@link module:engine/model/writer~Writer#setSelectionAttribute} method.
291
- *
292
- * @see module:engine/model/writer~Writer#setSelectionAttribute
293
- * @internal
294
- * @param key Key of the attribute to set.
295
- * @param value Attribute value.
296
- */
297
- _setAttribute(key: string, value: unknown): void;
298
- /**
299
- * Removes an attribute with given key from the selection.
300
- * If the given attribute was set on the selection, fires the {@link module:engine/model/selection~Selection#event:change:range}
301
- * event with removed attribute key.
302
- * Should be used only within the {@link module:engine/model/writer~Writer#removeSelectionAttribute} method.
303
- *
304
- * @see module:engine/model/writer~Writer#removeSelectionAttribute
305
- * @internal
306
- * @param key Key of the attribute to remove.
307
- */
308
- _removeAttribute(key: string): void;
309
- /**
310
- * Returns an iterable that iterates through all selection attributes stored in current selection's parent.
311
- *
312
- * @internal
313
- */
314
- _getStoredAttributes(): Iterable<[string, unknown]>;
315
- /**
316
- * Temporarily changes the gravity of the selection from the left to the right.
317
- *
318
- * The gravity defines from which direction the selection inherits its attributes. If it's the default left
319
- * gravity, the selection (after being moved by the the user) inherits attributes from its left hand side.
320
- * This method allows to temporarily override this behavior by forcing the gravity to the right.
321
- *
322
- * It returns an unique identifier which is required to restore the gravity. It guarantees the symmetry
323
- * of the process.
324
- *
325
- * @see module:engine/model/writer~Writer#overrideSelectionGravity
326
- * @internal
327
- * @returns The unique id which allows restoring the gravity.
328
- */
329
- _overrideGravity(): string;
330
- /**
331
- * Restores the {@link ~DocumentSelection#_overrideGravity overridden gravity}.
332
- *
333
- * Restoring the gravity is only possible using the unique identifier returned by
334
- * {@link ~DocumentSelection#_overrideGravity}. Note that the gravity remains overridden as long as won't be restored
335
- * the same number of times it was overridden.
336
- *
337
- * @see module:engine/model/writer~Writer#restoreSelectionGravity
338
- * @internal
339
- * @param uid The unique id returned by {@link #_overrideGravity}.
340
- */
341
- _restoreGravity(uid: string): void;
342
- /**
343
- * Generates and returns an attribute key for selection attributes store, basing on original attribute key.
344
- *
345
- * @internal
346
- * @param key Attribute key to convert.
347
- * @returns Converted attribute key, applicable for selection store.
348
- */
349
- static _getStoreAttributeKey(key: string): string;
350
- /**
351
- * Checks whether the given attribute key is an attribute stored on an element.
352
- *
353
- * @internal
354
- */
355
- static _isStoreAttributeKey(key: string): boolean;
356
- }
357
- /**
358
- * Fired when selection range(s) changed.
359
- *
360
- * @eventName ~DocumentSelection#change:range
361
- * @param directChange In case of {@link module:engine/model/selection~Selection} class it is always set
362
- * to `true` which indicates that the selection change was caused by a direct use of selection's API.
363
- * The {@link module:engine/model/documentselection~DocumentSelection}, however, may change because its position
364
- * was directly changed through the {@link module:engine/model/writer~Writer writer} or because its position was
365
- * changed because the structure of the model has been changed (which means an indirect change).
366
- * The indirect change does not occur in case of normal (detached) selections because they are "static" (as "not live")
367
- * which mean that they are not updated once the document changes.
368
- */
369
- export type DocumentSelectionChangeRangeEvent = SelectionChangeRangeEvent;
370
- /**
371
- * Fired when selection attribute changed.
372
- *
373
- * @eventName ~DocumentSelection#change:attribute
374
- * @param directChange In case of {@link module:engine/model/selection~Selection} class it is always set
375
- * to `true` which indicates that the selection change was caused by a direct use of selection's API.
376
- * The {@link module:engine/model/documentselection~DocumentSelection}, however, may change because its attributes
377
- * were directly changed through the {@link module:engine/model/writer~Writer writer} or because its position was
378
- * changed in the model and its attributes were refreshed (which means an indirect change).
379
- * The indirect change does not occur in case of normal (detached) selections because they are "static" (as "not live")
380
- * which mean that they are not updated once the document changes.
381
- * @param attributeKeys Array containing keys of attributes that changed.
382
- */
383
- export type DocumentSelectionChangeAttributeEvent = SelectionChangeAttributeEvent;
384
- /**
385
- * Fired when selection marker(s) changed.
386
- *
387
- * @eventName ~DocumentSelection#change:marker
388
- * @param directChange This is always set to `false` in case of `change:marker` event as there is no possibility
389
- * to change markers directly through {@link module:engine/model/documentselection~DocumentSelection} API.
390
- * See also {@link module:engine/model/documentselection~DocumentSelection#event:change:range} and
391
- * {@link module:engine/model/documentselection~DocumentSelection#event:change:attribute}.
392
- * @param oldMarkers Markers in which the selection was before the change.
393
- */
394
- export type DocumentSelectionChangeMarkerEvent = {
395
- name: 'change:marker';
396
- args: [
397
- {
398
- directChange: boolean;
399
- oldMarkers: Array<Marker>;
400
- }
401
- ];
402
- };
403
- /**
404
- * Fired when selection range(s), attribute(s) or marker(s) changed.
405
- *
406
- * @eventName ~DocumentSelection#change
407
- * @param directChange This is always set to `false` in case of `change:marker` event as there is no possibility
408
- * to change markers directly through {@link module:engine/model/documentselection~DocumentSelection} API.
409
- * See also {@link module:engine/model/documentselection~DocumentSelection#event:change:range} and
410
- * {@link module:engine/model/documentselection~DocumentSelection#event:change:attribute}.
411
- * @param attributeKeys Array containing keys of attributes that changed.
412
- * @param oldMarkers Markers in which the selection was before the change.
413
- */
414
- export type DocumentSelectionChangeEvent = {
415
- name: 'change' | 'change:attribute' | 'change:marker' | 'change:range';
416
- args: [
417
- {
418
- directChange: boolean;
419
- attributeKeys?: Array<string>;
420
- oldMarkers?: Array<Marker>;
421
- }
422
- ];
423
- };
424
- export {};
@@ -1,191 +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/element
11
- */
12
- import Node, { type NodeAttributes } from './node.js';
13
- import type Item from './item.js';
14
- /**
15
- * Model element. Type of {@link module:engine/model/node~Node node} that has a {@link module:engine/model/element~Element#name name} and
16
- * {@link module:engine/model/element~Element#getChildren child nodes}.
17
- *
18
- * **Important**: see {@link module:engine/model/node~Node} to read about restrictions using `Element` and `Node` API.
19
- */
20
- export default class Element extends Node {
21
- /**
22
- * Element name.
23
- */
24
- readonly name: string;
25
- /**
26
- * List of children nodes.
27
- */
28
- private readonly _children;
29
- /**
30
- * Creates a model element.
31
- *
32
- * **Note:** Constructor of this class shouldn't be used directly in the code.
33
- * Use the {@link module:engine/model/writer~Writer#createElement} method instead.
34
- *
35
- * @internal
36
- * @param name Element's name.
37
- * @param attrs Element's attributes. See {@link module:utils/tomap~toMap} for a list of accepted values.
38
- * @param children One or more nodes to be inserted as children of created element.
39
- */
40
- constructor(name: string, attrs?: NodeAttributes, children?: string | Item | Iterable<string | Item>);
41
- /**
42
- * Number of this element's children.
43
- */
44
- get childCount(): number;
45
- /**
46
- * Sum of {@link module:engine/model/node~Node#offsetSize offset sizes} of all of this element's children.
47
- */
48
- get maxOffset(): number;
49
- /**
50
- * Is `true` if there are no nodes inside this element, `false` otherwise.
51
- */
52
- get isEmpty(): boolean;
53
- /**
54
- * Gets the child at the given index. Returns `null` if incorrect index was passed.
55
- *
56
- * @param index Index in this element.
57
- * @returns Child node.
58
- */
59
- getChild(index: number): Node | null;
60
- /**
61
- * Gets the child at the given offset. Returns `null` if incorrect index was passed.
62
- *
63
- * @param offset Offset in this element.
64
- * @returns Child node.
65
- */
66
- getChildAtOffset(offset: number): Node | null;
67
- /**
68
- * Returns an iterator that iterates over all of this element's children.
69
- */
70
- getChildren(): IterableIterator<Node>;
71
- /**
72
- * Returns an index of the given child node. Returns `null` if given node is not a child of this element.
73
- *
74
- * @param node Child node to look for.
75
- * @returns Child node's index in this element.
76
- */
77
- getChildIndex(node: Node): number | null;
78
- /**
79
- * Returns the starting offset of given child. Starting offset is equal to the sum of
80
- * {@link module:engine/model/node~Node#offsetSize offset sizes} of all node's siblings that are before it. Returns `null` if
81
- * given node is not a child of this element.
82
- *
83
- * @param node Child node to look for.
84
- * @returns Child node's starting offset.
85
- */
86
- getChildStartOffset(node: Node): number | null;
87
- /**
88
- * Returns index of a node that occupies given offset. If given offset is too low, returns `0`. If given offset is
89
- * too high, returns {@link module:engine/model/element~Element#getChildIndex index after last child}.
90
- *
91
- * ```ts
92
- * const textNode = new Text( 'foo' );
93
- * const pElement = new Element( 'p' );
94
- * const divElement = new Element( [ textNode, pElement ] );
95
- * divElement.offsetToIndex( -1 ); // Returns 0, because offset is too low.
96
- * divElement.offsetToIndex( 0 ); // Returns 0, because offset 0 is taken by `textNode` which is at index 0.
97
- * divElement.offsetToIndex( 1 ); // Returns 0, because `textNode` has `offsetSize` equal to 3, so it occupies offset 1 too.
98
- * divElement.offsetToIndex( 2 ); // Returns 0.
99
- * divElement.offsetToIndex( 3 ); // Returns 1.
100
- * divElement.offsetToIndex( 4 ); // Returns 2. There are no nodes at offset 4, so last available index is returned.
101
- * ```
102
- */
103
- offsetToIndex(offset: number): number;
104
- /**
105
- * Returns a descendant node by its path relative to this element.
106
- *
107
- * ```ts
108
- * // <this>a<b>c</b></this>
109
- * this.getNodeByPath( [ 0 ] ); // -> "a"
110
- * this.getNodeByPath( [ 1 ] ); // -> <b>
111
- * this.getNodeByPath( [ 1, 0 ] ); // -> "c"
112
- * ```
113
- *
114
- * @param relativePath Path of the node to find, relative to this element.
115
- */
116
- getNodeByPath(relativePath: Array<number>): Node;
117
- /**
118
- * Returns the parent element of the given name. Returns null if the element is not inside the desired parent.
119
- *
120
- * @param parentName The name of the parent element to find.
121
- * @param options Options object.
122
- * @param options.includeSelf When set to `true` this node will be also included while searching.
123
- */
124
- findAncestor(parentName: string, options?: {
125
- includeSelf?: boolean;
126
- }): Element | null;
127
- /**
128
- * Converts `Element` instance to plain object and returns it. Takes care of converting all of this element's children.
129
- *
130
- * @returns `Element` instance converted to plain object.
131
- */
132
- toJSON(): unknown;
133
- /**
134
- * Creates a copy of this element and returns it. Created element has the same name and attributes as the original element.
135
- * If clone is deep, the original element's children are also cloned. If not, then empty element is returned.
136
- *
137
- * @internal
138
- * @param deep If set to `true` clones element and all its children recursively. When set to `false`,
139
- * element will be cloned without any child.
140
- */
141
- _clone(deep?: boolean): Element;
142
- /**
143
- * {@link module:engine/model/element~Element#_insertChild Inserts} one or more nodes at the end of this element.
144
- *
145
- * @see module:engine/model/writer~Writer#append
146
- * @internal
147
- * @param nodes Nodes to be inserted.
148
- */
149
- _appendChild(nodes: string | Item | Iterable<string | Item>): void;
150
- /**
151
- * Inserts one or more nodes at the given index and sets {@link module:engine/model/node~Node#parent parent} of these nodes
152
- * to this element.
153
- *
154
- * @see module:engine/model/writer~Writer#insert
155
- * @internal
156
- * @param index Index at which nodes should be inserted.
157
- * @param items Items to be inserted.
158
- */
159
- _insertChild(index: number, items: string | Item | Iterable<string | Item>): void;
160
- /**
161
- * Removes one or more nodes starting at the given index and sets
162
- * {@link module:engine/model/node~Node#parent parent} of these nodes to `null`.
163
- *
164
- * @see module:engine/model/writer~Writer#remove
165
- * @internal
166
- * @param index Index of the first node to remove.
167
- * @param howMany Number of nodes to remove.
168
- * @returns Array containing removed nodes.
169
- */
170
- _removeChildren(index: number, howMany?: number): Array<Node>;
171
- /**
172
- * Removes children nodes provided as an array and sets
173
- * the {@link module:engine/model/node~Node#parent parent} of these nodes to `null`.
174
- *
175
- * These nodes do not need to be direct siblings.
176
- *
177
- * This method is faster than removing nodes one by one, as it recalculates offsets only once.
178
- *
179
- * @internal
180
- * @param nodes Array of nodes.
181
- */
182
- _removeChildrenArray(nodes: Array<Node>): void;
183
- /**
184
- * Creates an `Element` instance from given plain object (i.e. parsed JSON string).
185
- * Converts `Element` children to proper nodes.
186
- *
187
- * @param json Plain object to be converted to `Element`.
188
- * @returns `Element` instance created using given plain object.
189
- */
190
- static fromJSON(json: any): Element;
191
- }