@ckeditor/ckeditor5-engine 44.1.0 → 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,923 +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/model
11
- */
12
- import Batch, { type BatchType } from './batch.js';
13
- import Document from './document.js';
14
- import MarkerCollection from './markercollection.js';
15
- import ModelPosition, { type PositionOffset, type PositionStickiness } from './position.js';
16
- import ModelRange from './range.js';
17
- import ModelSelection, { type PlaceOrOffset, type Selectable } from './selection.js';
18
- import DocumentSelection from './documentselection.js';
19
- import Schema from './schema.js';
20
- import Writer from './writer.js';
21
- import Node from './node.js';
22
- import type ModelDocumentFragment from './documentfragment.js';
23
- import type Item from './item.js';
24
- import type ModelElement from './element.js';
25
- import type Operation from './operation/operation.js';
26
- import { type DecoratedMethodEvent } from '@ckeditor/ckeditor5-utils';
27
- declare const Model_base: {
28
- new (): import("@ckeditor/ckeditor5-utils").Observable;
29
- prototype: import("@ckeditor/ckeditor5-utils").Observable;
30
- };
31
- /**
32
- * Editor's data model. Read about the model in the
33
- * {@glink framework/architecture/editing-engine engine architecture} guide.
34
- */
35
- export default class Model extends /* #__PURE__ */ Model_base {
36
- /**
37
- * Model's marker collection.
38
- */
39
- readonly markers: MarkerCollection;
40
- /**
41
- * Model's document.
42
- */
43
- readonly document: Document;
44
- /**
45
- * Model's schema.
46
- */
47
- readonly schema: Schema;
48
- /**
49
- * All callbacks added by {@link module:engine/model/model~Model#change} or
50
- * {@link module:engine/model/model~Model#enqueueChange} methods waiting to be executed.
51
- */
52
- private readonly _pendingChanges;
53
- /**
54
- * The last created and currently used writer instance.
55
- */
56
- private _currentWriter;
57
- constructor();
58
- /**
59
- * The `change()` method is the primary way of changing the model. You should use it to modify all document nodes
60
- * (including detached nodes – i.e. nodes not added to the {@link module:engine/model/model~Model#document model document}),
61
- * the {@link module:engine/model/document~Document#selection document's selection}, and
62
- * {@link module:engine/model/model~Model#markers model markers}.
63
- *
64
- * ```ts
65
- * model.change( writer => {
66
- * writer.insertText( 'foo', paragraph, 'end' );
67
- * } );
68
- * ```
69
- *
70
- * All changes inside the change block use the same {@link module:engine/model/batch~Batch} so they are combined
71
- * into a single undo step.
72
- *
73
- * ```ts
74
- * model.change( writer => {
75
- * writer.insertText( 'foo', paragraph, 'end' ); // foo.
76
- *
77
- * model.change( writer => {
78
- * writer.insertText( 'bar', paragraph, 'end' ); // foobar.
79
- * } );
80
- *
81
- * writer.insertText( 'bom', paragraph, 'end' ); // foobarbom.
82
- * } );
83
- * ```
84
- *
85
- * The callback of the `change()` block is executed synchronously.
86
- *
87
- * You can also return a value from the change block.
88
- *
89
- * ```ts
90
- * const img = model.change( writer => {
91
- * return writer.createElement( 'img' );
92
- * } );
93
- * ```
94
- *
95
- * @see #enqueueChange
96
- * @typeParam TReturn The return type of the provided callback.
97
- * @param callback Callback function which may modify the model.
98
- */
99
- change<TReturn>(callback: (writer: Writer) => TReturn): TReturn;
100
- /**
101
- * The `enqueueChange()` method performs similar task as the {@link #change `change()` method}, with two major differences.
102
- *
103
- * First, the callback of `enqueueChange()` is executed when all other enqueued changes are done. It might be executed
104
- * immediately if it is not nested in any other change block, but if it is nested in another (enqueue)change block,
105
- * it will be delayed and executed after the outermost block.
106
- *
107
- * ```ts
108
- * model.change( writer => {
109
- * console.log( 1 );
110
- *
111
- * model.enqueueChange( writer => {
112
- * console.log( 2 );
113
- * } );
114
- *
115
- * console.log( 3 );
116
- * } ); // Will log: 1, 3, 2.
117
- * ```
118
- *
119
- * In addition to that, the changes enqueued with `enqueueChange()` will be converted separately from the changes
120
- * done in the outer `change()` block.
121
- *
122
- * By default, a new batch with the default {@link module:engine/model/batch~Batch#constructor batch type} is created.
123
- * To define the {@link module:engine/model/batch~Batch} into which you want to add your changes,
124
- * use {@link #enqueueChange:CUSTOM_BATCH `enqueueChange( batchOrType, callback )`}.
125
- *
126
- * @label DEFAULT_BATCH
127
- * @param callback Callback function which may modify the model.
128
- */
129
- enqueueChange(callback: (writer: Writer) => unknown): void;
130
- /**
131
- * The `enqueueChange()` method performs similar task as the {@link #change `change()` method}, with two major differences.
132
- *
133
- * First, the callback of `enqueueChange()` is executed when all other enqueued changes are done. It might be executed
134
- * immediately if it is not nested in any other change block, but if it is nested in another (enqueue)change block,
135
- * it will be delayed and executed after the outermost block.
136
- *
137
- * ```ts
138
- * model.change( new Batch(), writer => {
139
- * console.log( 1 );
140
- *
141
- * model.enqueueChange( new Batch(), writer => {
142
- * console.log( 2 );
143
- * } );
144
- *
145
- * console.log( 3 );
146
- * } ); // Will log: 1, 3, 2.
147
- * ```
148
- *
149
- * In addition to that, the changes enqueued with `enqueueChange()` will be converted separately from the changes
150
- * done in the outer `change()` block.
151
- *
152
- * Second, it lets you define the {@link module:engine/model/batch~Batch} into which you want to add your changes.
153
- * If you want to use default {@link module:engine/model/batch~Batch#constructor batch type}, use
154
- * {@link #enqueueChange:DEFAULT_BATCH `enqueueChange( callback )`}.
155
- *
156
- * ```ts
157
- * model.enqueueChange( { isUndoable: false }, writer => {
158
- * writer.insertText( 'foo', paragraph, 'end' );
159
- * } );
160
- * ```
161
- *
162
- * When using the `enqueueChange()` block you can also add some changes to the batch you used before.
163
- *
164
- * ```ts
165
- * model.enqueueChange( batch, writer => {
166
- * writer.insertText( 'foo', paragraph, 'end' );
167
- * } );
168
- * ```
169
- *
170
- * In order to make a nested `enqueueChange()` create a single undo step together with the changes done in the outer `change()`
171
- * block, you can obtain the batch instance from the {@link module:engine/model/writer~Writer#batch writer} of the outer block.
172
- *
173
- * @label CUSTOM_BATCH
174
- * @param batchOrType A batch or a {@link module:engine/model/batch~Batch#constructor batch type} that should be used in the callback.
175
- * If not defined, a new batch with the default type will be created.
176
- * @param callback Callback function which may modify the model.
177
- */
178
- enqueueChange(batchOrType: Batch | BatchType | undefined, callback: (writer: Writer) => unknown): void;
179
- /**
180
- * {@link module:utils/observablemixin~Observable#decorate Decorated} function for applying
181
- * {@link module:engine/model/operation/operation~Operation operations} to the model.
182
- *
183
- * This is a low-level way of changing the model. It is exposed for very specific use cases (like the undo feature).
184
- * Normally, to modify the model, you will want to use {@link module:engine/model/writer~Writer `Writer`}.
185
- * See also {@glink framework/architecture/editing-engine#changing-the-model Changing the model} section
186
- * of the {@glink framework/architecture/editing-engine Editing architecture} guide.
187
- *
188
- * @param operation The operation to apply.
189
- */
190
- applyOperation(operation: Operation): void;
191
- /**
192
- * Inserts content at the position in the editor specified by the selection, as one would expect the paste
193
- * functionality to work.
194
- *
195
- * **Note**: If you want to insert an {@glink framework/deep-dive/schema#object-elements object element}
196
- * (e.g. a {@link module:widget/utils~toWidget widget}), see {@link #insertObject} instead.
197
- *
198
- * This is a high-level method. It takes the {@link #schema schema} into consideration when inserting
199
- * the content, clears the given selection's content before inserting nodes and moves the selection
200
- * to its target position at the end of the process.
201
- * It can split elements, merge them, wrap bare text nodes with paragraphs, etc. &ndash; just like the
202
- * pasting feature should do.
203
- *
204
- * For lower-level methods see {@link module:engine/model/writer~Writer `Writer`}.
205
- *
206
- * This method, unlike {@link module:engine/model/writer~Writer `Writer`}'s methods, does not have to be used
207
- * inside a {@link #change `change()` block}.
208
- *
209
- * # Conversion and schema
210
- *
211
- * Inserting elements and text nodes into the model is not enough to make CKEditor 5 render that content
212
- * to the user. CKEditor 5 implements a model-view-controller architecture and what `model.insertContent()` does
213
- * is only adding nodes to the model. Additionally, you need to define
214
- * {@glink framework/architecture/editing-engine#conversion converters} between the model and view
215
- * and define those nodes in the {@glink framework/architecture/editing-engine#schema schema}.
216
- *
217
- * So, while this method may seem similar to CKEditor 4 `editor.insertHtml()` (in fact, both methods
218
- * are used for paste-like content insertion), the CKEditor 5 method cannot be use to insert arbitrary HTML
219
- * unless converters are defined for all elements and attributes in that HTML.
220
- *
221
- * # Examples
222
- *
223
- * Using `insertContent()` with a manually created model structure:
224
- *
225
- * ```ts
226
- * // Let's create a document fragment containing such content as:
227
- * //
228
- * // <paragraph>foo</paragraph>
229
- * // <blockQuote>
230
- * // <paragraph>bar</paragraph>
231
- * // </blockQuote>
232
- * const docFrag = editor.model.change( writer => {
233
- * const p1 = writer.createElement( 'paragraph' );
234
- * const p2 = writer.createElement( 'paragraph' );
235
- * const blockQuote = writer.createElement( 'blockQuote' );
236
- * const docFrag = writer.createDocumentFragment();
237
- *
238
- * writer.append( p1, docFrag );
239
- * writer.append( blockQuote, docFrag );
240
- * writer.append( p2, blockQuote );
241
- * writer.insertText( 'foo', p1 );
242
- * writer.insertText( 'bar', p2 );
243
- *
244
- * return docFrag;
245
- * } );
246
- *
247
- * // insertContent() does not have to be used in a change() block. It can, though,
248
- * // so this code could be moved to the callback defined above.
249
- * editor.model.insertContent( docFrag );
250
- * ```
251
- *
252
- * Using `insertContent()` with an HTML string converted to a model document fragment (similar to the pasting mechanism):
253
- *
254
- * ```ts
255
- * // You can create your own HtmlDataProcessor instance or use editor.data.processor
256
- * // if you have not overridden the default one (which is the HtmlDataProcessor instance).
257
- * const htmlDP = new HtmlDataProcessor( viewDocument );
258
- *
259
- * // Convert an HTML string to a view document fragment:
260
- * const viewFragment = htmlDP.toView( htmlString );
261
- *
262
- * // Convert the view document fragment to a model document fragment
263
- * // in the context of $root. This conversion takes the schema into
264
- * // account so if, for example, the view document fragment contained a bare text node,
265
- * // this text node cannot be a child of $root, so it will be automatically
266
- * // wrapped with a <paragraph>. You can define the context yourself (in the second parameter),
267
- * // and e.g. convert the content like it would happen in a <paragraph>.
268
- * // Note: The clipboard feature uses a custom context called $clipboardHolder
269
- * // which has a loosened schema.
270
- * const modelFragment = editor.data.toModel( viewFragment );
271
- *
272
- * editor.model.insertContent( modelFragment );
273
- * ```
274
- *
275
- * By default this method will use the document selection but it can also be used with a position, range or selection instance.
276
- *
277
- * ```ts
278
- * // Insert text at the current document selection position.
279
- * editor.model.change( writer => {
280
- * editor.model.insertContent( writer.createText( 'x' ) );
281
- * } );
282
- *
283
- * // Insert text at a given position - the document selection will not be modified.
284
- * editor.model.change( writer => {
285
- * editor.model.insertContent( writer.createText( 'x' ), doc.getRoot(), 2 );
286
- *
287
- * // Which is a shorthand for:
288
- * editor.model.insertContent( writer.createText( 'x' ), writer.createPositionAt( doc.getRoot(), 2 ) );
289
- * } );
290
- * ```
291
- *
292
- * If you want the document selection to be moved to the inserted content, use the
293
- * {@link module:engine/model/writer~Writer#setSelection `setSelection()`} method of the writer after inserting
294
- * the content:
295
- *
296
- * ```ts
297
- * editor.model.change( writer => {
298
- * const paragraph = writer.createElement( 'paragraph' );
299
- *
300
- * // Insert an empty paragraph at the beginning of the root.
301
- * editor.model.insertContent( paragraph, writer.createPositionAt( editor.model.document.getRoot(), 0 ) );
302
- *
303
- * // Move the document selection to the inserted paragraph.
304
- * writer.setSelection( paragraph, 'in' );
305
- * } );
306
- * ```
307
- *
308
- * If an instance of the {@link module:engine/model/selection~Selection model selection} is passed as `selectable`,
309
- * the new content will be inserted at the passed selection (instead of document selection):
310
- *
311
- * ```ts
312
- * editor.model.change( writer => {
313
- * // Create a selection in a paragraph that will be used as a place of insertion.
314
- * const selection = writer.createSelection( paragraph, 'in' );
315
- *
316
- * // Insert the new text at the created selection.
317
- * editor.model.insertContent( writer.createText( 'x' ), selection );
318
- *
319
- * // insertContent() modifies the passed selection instance so it can be used to set the document selection.
320
- * // Note: This is not necessary when you passed the document selection to insertContent().
321
- * writer.setSelection( selection );
322
- * } );
323
- * ```
324
- *
325
- * @fires insertContent
326
- * @param content The content to insert.
327
- * @param selectable The selection into which the content should be inserted.
328
- * If not provided the current model document selection will be used.
329
- * @param placeOrOffset To be used when a model item was passed as `selectable`.
330
- * This param defines a position in relation to that item.
331
- * at the insertion position.
332
- */
333
- insertContent(content: Item | ModelDocumentFragment, selectable?: Selectable, placeOrOffset?: PlaceOrOffset, ...rest: Array<unknown>): ModelRange;
334
- /**
335
- * Inserts an {@glink framework/deep-dive/schema#object-elements object element} at a specific position in the editor content.
336
- *
337
- * This is a high-level API:
338
- * * It takes the {@link #schema schema} into consideration,
339
- * * It clears the content of passed `selectable` before inserting,
340
- * * It can move the selection at the end of the process,
341
- * * It will copy the selected block's attributes to preserve them upon insertion,
342
- * * It can split elements or wrap inline objects with paragraphs if they are not allowed in target position,
343
- * * etc.
344
- *
345
- * # Notes
346
- *
347
- * * If you want to insert a non-object content, see {@link #insertContent} instead.
348
- * * For lower-level API, see {@link module:engine/model/writer~Writer `Writer`}.
349
- * * Unlike {@link module:engine/model/writer~Writer `Writer`}, this method does not have to be used inside
350
- * a {@link #change `change()` block}.
351
- * * Inserting object into the model is not enough to make CKEditor 5 render that content to the user.
352
- * CKEditor 5 implements a model-view-controller architecture and what `model.insertObject()` does
353
- * is only adding nodes to the model. Additionally, you need to define
354
- * {@glink framework/architecture/editing-engine#conversion converters} between the model and view
355
- * and define those nodes in the {@glink framework/architecture/editing-engine#schema schema}.
356
- *
357
- * # Examples
358
- *
359
- * Use the following code to insert an object at the current selection and keep the selection on the inserted element:
360
- *
361
- * ```ts
362
- * const rawHtmlEmbedElement = writer.createElement( 'rawHtml' );
363
- *
364
- * model.insertObject( rawHtmlEmbedElement, null, null, {
365
- * setSelection: 'on'
366
- * } );
367
- * ```
368
- *
369
- * Use the following code to insert an object at the current selection and nudge the selection after the inserted object:
370
- *
371
- * ```ts
372
- * const pageBreakElement = writer.createElement( 'pageBreak' );
373
- *
374
- * model.insertObject( pageBreakElement, null, null, {
375
- * setSelection: 'after'
376
- * } );
377
- * ```
378
- *
379
- * Use the following code to insert an object at the current selection and avoid splitting the content (non-destructive insertion):
380
- *
381
- * ```ts
382
- * const tableElement = writer.createElement( 'table' );
383
- *
384
- * model.insertObject( tableElement, null, null, {
385
- * findOptimalPosition: 'auto'
386
- * } );
387
- * ```
388
- *
389
- * Use the following code to insert an object at the specific range (also: replace the content of the range):
390
- *
391
- * ```ts
392
- * const tableElement = writer.createElement( 'table' );
393
- * const range = model.createRangeOn( model.document.getRoot().getChild( 1 ) );
394
- *
395
- * model.insertObject( tableElement, range );
396
- * ```
397
- *
398
- * @param element An object to be inserted into the model document.
399
- * @param selectable A selectable where the content should be inserted. If not specified, the current
400
- * {@link module:engine/model/document~Document#selection document selection} will be used instead.
401
- * @param placeOrOffset Specifies the exact place or offset for the insertion to take place, relative to `selectable`.
402
- * @param options Additional options.
403
- * @param options.findOptimalPosition An option that, when set, adjusts the insertion position (relative to
404
- * `selectable` and `placeOrOffset`) so that the content of `selectable` is not split upon insertion (a.k.a. non-destructive insertion).
405
- * * When `'auto'`, the algorithm will decide whether to insert the object before or after `selectable` to avoid content splitting.
406
- * * When `'before'`, the closest position before `selectable` will be used that will not result in content splitting.
407
- * * When `'after'`, the closest position after `selectable` will be used that will not result in content splitting.
408
- *
409
- * Note that this option only works for block objects. Inline objects are inserted into text and do not split blocks.
410
- * @param options.setSelection An option that, when set, moves the
411
- * {@link module:engine/model/document~Document#selection document selection} after inserting the object.
412
- * * When `'on'`, the document selection will be set on the inserted object.
413
- * * When `'after'`, the document selection will move to the closest text node after the inserted object. If there is no
414
- * such text node, a paragraph will be created and the document selection will be moved inside it.
415
- * at the insertion position.
416
- */
417
- insertObject(element: ModelElement, selectable?: Selectable, placeOrOffset?: PlaceOrOffset | null, options?: {
418
- findOptimalPosition?: 'auto' | 'before' | 'after';
419
- setSelection?: 'on' | 'after';
420
- }, ...rest: Array<unknown>): ModelRange;
421
- /**
422
- * Deletes content of the selection and merge siblings. The resulting selection is always collapsed.
423
- *
424
- * **Note:** For the sake of predictability, the resulting selection should always be collapsed.
425
- * In cases where a feature wants to modify deleting behavior so selection isn't collapsed
426
- * (e.g. a table feature may want to keep row selection after pressing <kbd>Backspace</kbd>),
427
- * then that behavior should be implemented in the view's listener. At the same time, the table feature
428
- * will need to modify this method's behavior too, e.g. to "delete contents and then collapse
429
- * the selection inside the last selected cell" or "delete the row and collapse selection somewhere near".
430
- * That needs to be done in order to ensure that other features which use `deleteContent()` will work well with tables.
431
- *
432
- * @fires deleteContent
433
- * @param selection Selection of which the content should be deleted.
434
- * @param options.leaveUnmerged Whether to merge elements after removing the content of the selection.
435
- *
436
- * For example `<heading1>x[x</heading1><paragraph>y]y</paragraph>` will become:
437
- *
438
- * * `<heading1>x^y</heading1>` with the option disabled (`leaveUnmerged == false`)
439
- * * `<heading1>x^</heading1><paragraph>y</paragraph>` with enabled (`leaveUnmerged == true`).
440
- *
441
- * Note: {@link module:engine/model/schema~Schema#isObject object} and {@link module:engine/model/schema~Schema#isLimit limit}
442
- * elements will not be merged.
443
- *
444
- * @param options.doNotResetEntireContent Whether to skip replacing the entire content with a
445
- * paragraph when the entire content was selected.
446
- *
447
- * For example `<heading1>[x</heading1><paragraph>y]</paragraph>` will become:
448
- *
449
- * * `<paragraph>^</paragraph>` with the option disabled (`doNotResetEntireContent == false`)
450
- * * `<heading1>^</heading1>` with enabled (`doNotResetEntireContent == true`)
451
- *
452
- * @param options.doNotAutoparagraph Whether to create a paragraph if after content deletion selection is moved
453
- * to a place where text cannot be inserted.
454
- *
455
- * For example `<paragraph>x</paragraph>[<imageBlock src="foo.jpg"></imageBlock>]` will become:
456
- *
457
- * * `<paragraph>x</paragraph><paragraph>[]</paragraph>` with the option disabled (`doNotAutoparagraph == false`)
458
- * * `<paragraph>x[]</paragraph>` with the option enabled (`doNotAutoparagraph == true`).
459
- *
460
- * **Note:** if there is no valid position for the selection, the paragraph will always be created:
461
- *
462
- * `[<imageBlock src="foo.jpg"></imageBlock>]` -> `<paragraph>[]</paragraph>`.
463
- *
464
- * @param options.direction The direction in which the content is being consumed.
465
- * Deleting backward corresponds to using the <kbd>Backspace</kbd> key, while deleting content forward corresponds to
466
- * the <kbd>Shift</kbd>+<kbd>Backspace</kbd> keystroke.
467
- */
468
- deleteContent(selection: ModelSelection | DocumentSelection, options?: {
469
- leaveUnmerged?: boolean;
470
- doNotResetEntireContent?: boolean;
471
- doNotAutoparagraph?: boolean;
472
- direction?: 'forward' | 'backward';
473
- [i: string]: unknown;
474
- }): void;
475
- /**
476
- * Modifies the selection. Currently, the supported modifications are:
477
- *
478
- * * Extending. The selection focus is moved in the specified `options.direction` with a step specified in `options.unit`.
479
- * Possible values for `unit` are:
480
- * * `'character'` (default) - moves selection by one user-perceived character. In most cases this means moving by one
481
- * character in `String` sense. However, unicode also defines "combing marks". These are special symbols, that combines
482
- * with a symbol before it ("base character") to create one user-perceived character. For example, `q̣̇` is a normal
483
- * letter `q` with two "combining marks": upper dot (`Ux0307`) and lower dot (`Ux0323`). For most actions, i.e. extending
484
- * selection by one position, it is correct to include both "base character" and all of it's "combining marks". That is
485
- * why `'character'` value is most natural and common method of modifying selection.
486
- * * `'codePoint'` - moves selection by one unicode code point. In contrary to, `'character'` unit, this will insert
487
- * selection between "base character" and "combining mark", because "combining marks" have their own unicode code points.
488
- * However, for technical reasons, unicode code points with values above `UxFFFF` are represented in native `String` by
489
- * two characters, called "surrogate pairs". Halves of "surrogate pairs" have a meaning only when placed next to each other.
490
- * For example `𨭎` is represented in `String` by `\uD862\uDF4E`. Both `\uD862` and `\uDF4E` do not have any meaning
491
- * outside the pair (are rendered as ? when alone). Position between them would be incorrect. In this case, selection
492
- * extension will include whole "surrogate pair".
493
- * * `'word'` - moves selection by a whole word.
494
- *
495
- * **Note:** if you extend a forward selection in a backward direction you will in fact shrink it.
496
- *
497
- * @fires modifySelection
498
- * @param selection The selection to modify.
499
- * @param options.direction The direction in which the selection should be modified.
500
- * @param options.unit The unit by which selection should be modified.
501
- * @param options.treatEmojiAsSingleUnit Whether multi-characer emoji sequences should be handled as single unit.
502
- */
503
- modifySelection(selection: ModelSelection | DocumentSelection, options?: {
504
- direction?: 'forward' | 'backward';
505
- unit?: 'character' | 'codePoint' | 'word';
506
- treatEmojiAsSingleUnit?: boolean;
507
- }): void;
508
- /**
509
- * Gets a clone of the selected content.
510
- *
511
- * For example, for the following selection:
512
- *
513
- * ```html
514
- * <paragraph>x</paragraph>
515
- * <blockQuote>
516
- * <paragraph>y</paragraph>
517
- * <heading1>fir[st</heading1>
518
- * </blockQuote>
519
- * <paragraph>se]cond</paragraph>
520
- * <paragraph>z</paragraph>
521
- * ```
522
- *
523
- * It will return a document fragment with such a content:
524
- *
525
- * ```html
526
- * <blockQuote>
527
- * <heading1>st</heading1>
528
- * </blockQuote>
529
- * <paragraph>se</paragraph>
530
- * ```
531
- *
532
- * @fires getSelectedContent
533
- * @param selection The selection of which content will be returned.
534
- */
535
- getSelectedContent(selection: ModelSelection | DocumentSelection): ModelDocumentFragment;
536
- /**
537
- * Checks whether the given {@link module:engine/model/range~Range range} or
538
- * {@link module:engine/model/element~Element element} has any meaningful content.
539
- *
540
- * Meaningful content is:
541
- *
542
- * * any text node (`options.ignoreWhitespaces` allows controlling whether this text node must also contain
543
- * any non-whitespace characters),
544
- * * or any {@link module:engine/model/schema~Schema#isContent content element},
545
- * * or any {@link module:engine/model/markercollection~Marker marker} which
546
- * {@link module:engine/model/markercollection~Marker#_affectsData affects data}.
547
- *
548
- * This means that a range containing an empty `<paragraph></paragraph>` is not considered to have a meaningful content.
549
- * However, a range containing an `<imageBlock></imageBlock>` (which would normally be marked in the schema as an object element)
550
- * is considered non-empty.
551
- *
552
- * @param rangeOrElement Range or element to check.
553
- * @param options.ignoreWhitespaces Whether text node with whitespaces only should be considered empty.
554
- * @param options.ignoreMarkers Whether markers should be ignored.
555
- */
556
- hasContent(rangeOrElement: ModelRange | ModelElement | ModelDocumentFragment, options?: {
557
- ignoreWhitespaces?: boolean;
558
- ignoreMarkers?: boolean;
559
- }): boolean;
560
- /**
561
- * Check whether given selectable is at a place in the model where it can be edited (returns `true`) or not (returns `false`).
562
- *
563
- * Should be used instead of {@link module:core/editor/editor~Editor#isReadOnly} to check whether a user action can happen at
564
- * given selectable. It may be decorated and used differently in different environment (e.g. multi-root editor can disable
565
- * a particular root).
566
- *
567
- * This method is decorated. Although this method accepts any parameter of `Selectable` type, the
568
- * {@link ~Model#event:canEditAt `canEditAt` event} is fired with `selectable` normalized to an instance of
569
- * {@link module:engine/model/selection~Selection} or {@link module:engine/model/documentselection~DocumentSelection}
570
- *
571
- * @fires canEditAt
572
- */
573
- canEditAt(selectable: Selectable): boolean;
574
- /**
575
- * Creates a position from the given root and path in that root.
576
- *
577
- * Note: This method is also available as
578
- * {@link module:engine/model/writer~Writer#createPositionFromPath `Writer#createPositionFromPath()`}.
579
- *
580
- * @param root Root of the position.
581
- * @param path Position path. See {@link module:engine/model/position~Position#path}.
582
- * @param stickiness Position stickiness. See {@link module:engine/model/position~PositionStickiness}.
583
- */
584
- createPositionFromPath(root: ModelElement | ModelDocumentFragment, path: ReadonlyArray<number>, stickiness?: PositionStickiness): ModelPosition;
585
- /**
586
- * Creates position at the given location. The location can be specified as:
587
- *
588
- * * a {@link module:engine/model/position~Position position},
589
- * * a parent element and offset in that element,
590
- * * a parent element and `'end'` (the position will be set at the end of that element),
591
- * * a {@link module:engine/model/item~Item model item} and `'before'` or `'after'`
592
- * (the position will be set before or after the given model item).
593
- *
594
- * This method is a shortcut to other factory methods such as:
595
- *
596
- * * {@link module:engine/model/model~Model#createPositionBefore `createPositionBefore()`},
597
- * * {@link module:engine/model/model~Model#createPositionAfter `createPositionAfter()`}.
598
- *
599
- * Note: This method is also available as
600
- * {@link module:engine/model/writer~Writer#createPositionAt `Writer#createPositionAt()`},
601
- *
602
- * @param itemOrPosition
603
- * @param offset Offset or one of the flags. Used only when first parameter is a {@link module:engine/model/item~Item model item}.
604
- */
605
- createPositionAt(itemOrPosition: Item | ModelPosition | ModelDocumentFragment, offset?: PositionOffset): ModelPosition;
606
- /**
607
- * Creates a new position after the given {@link module:engine/model/item~Item model item}.
608
- *
609
- * Note: This method is also available as
610
- * {@link module:engine/model/writer~Writer#createPositionAfter `Writer#createPositionAfter()`}.
611
- *
612
- * @param item Item after which the position should be placed.
613
- */
614
- createPositionAfter(item: Item): ModelPosition;
615
- /**
616
- * Creates a new position before the given {@link module:engine/model/item~Item model item}.
617
- *
618
- * Note: This method is also available as
619
- * {@link module:engine/model/writer~Writer#createPositionBefore `Writer#createPositionBefore()`}.
620
- *
621
- * @param item Item before which the position should be placed.
622
- */
623
- createPositionBefore(item: Item): ModelPosition;
624
- /**
625
- * Creates a range spanning from the `start` position to the `end` position.
626
- *
627
- * Note: This method is also available as
628
- * {@link module:engine/model/writer~Writer#createRange `Writer#createRange()`}:
629
- *
630
- * ```ts
631
- * model.change( writer => {
632
- * const range = writer.createRange( start, end );
633
- * } );
634
- * ```
635
- *
636
- * @param start Start position.
637
- * @param end End position. If not set, the range will be collapsed to the `start` position.
638
- */
639
- createRange(start: ModelPosition, end?: ModelPosition): ModelRange;
640
- /**
641
- * Creates a range inside the given element which starts before the first child of
642
- * that element and ends after the last child of that element.
643
- *
644
- * Note: This method is also available as
645
- * {@link module:engine/model/writer~Writer#createRangeIn `Writer#createRangeIn()`}:
646
- *
647
- * ```ts
648
- * model.change( writer => {
649
- * const range = writer.createRangeIn( paragraph );
650
- * } );
651
- * ```
652
- *
653
- * @param element Element which is a parent for the range.
654
- */
655
- createRangeIn(element: ModelElement | ModelDocumentFragment): ModelRange;
656
- /**
657
- * Creates a range that starts before the given {@link module:engine/model/item~Item model item} and ends after it.
658
- *
659
- * Note: This method is also available on `writer` instance as
660
- * {@link module:engine/model/writer~Writer#createRangeOn `Writer.createRangeOn()`}:
661
- *
662
- * ```ts
663
- * model.change( writer => {
664
- * const range = writer.createRangeOn( paragraph );
665
- * } );
666
- * ```
667
- *
668
- * @param item
669
- */
670
- createRangeOn(item: Item): ModelRange;
671
- /**
672
- * Creates a new selection instance based on the given {@link module:engine/model/selection~Selectable selectable}
673
- * or creates an empty selection if no arguments were passed.
674
- *
675
- * Note: This method is also available as
676
- * {@link module:engine/model/writer~Writer#createSelection `Writer#createSelection()`}.
677
- *
678
- * ```ts
679
- * // Creates selection at the given offset in the given element.
680
- * const paragraph = writer.createElement( 'paragraph' );
681
- * const selection = writer.createSelection( paragraph, offset );
682
- *
683
- * // Creates a range inside an {@link module:engine/model/element~Element element} which starts before the
684
- * // first child of that element and ends after the last child of that element.
685
- * const selection = writer.createSelection( paragraph, 'in' );
686
- *
687
- * // Creates a range on an {@link module:engine/model/item~Item item} which starts before the item and ends
688
- * // just after the item.
689
- * const selection = writer.createSelection( paragraph, 'on' );
690
- *
691
- * // Additional options (`'backward'`) can be specified as the last argument.
692
- *
693
- * // Creates backward selection.
694
- * const selection = writer.createSelection( element, 'in', { backward: true } );
695
- * ```
696
- *
697
- * See also: {@link #createSelection:SELECTABLE `createSelection( selectable, options )`}.
698
- *
699
- * @label NODE_OFFSET
700
- */
701
- createSelection(selectable: Node, placeOrOffset: PlaceOrOffset, options?: {
702
- backward?: boolean;
703
- }): ModelSelection;
704
- /**
705
- * Creates a new selection instance based on the given {@link module:engine/model/selection~Selectable selectable}
706
- * or creates an empty selection if no arguments were passed.
707
- *
708
- * Note: This method is also available as
709
- * {@link module:engine/model/writer~Writer#createSelection `Writer#createSelection()`}.
710
- *
711
- * ```ts
712
- * // Creates empty selection without ranges.
713
- * const selection = writer.createSelection();
714
- *
715
- * // Creates selection at the given range.
716
- * const range = writer.createRange( start, end );
717
- * const selection = writer.createSelection( range );
718
- *
719
- * // Creates selection at the given ranges
720
- * const ranges = [ writer.createRange( start1, end2 ), writer.createRange( star2, end2 ) ];
721
- * const selection = writer.createSelection( ranges );
722
- *
723
- * // Creates selection from the other selection.
724
- * // Note: It doesn't copies selection attributes.
725
- * const otherSelection = writer.createSelection();
726
- * const selection = writer.createSelection( otherSelection );
727
- *
728
- * // Creates selection from the given document selection.
729
- * // Note: It doesn't copies selection attributes.
730
- * const documentSelection = model.document.selection;
731
- * const selection = writer.createSelection( documentSelection );
732
- *
733
- * // Creates selection at the given position.
734
- * const position = writer.createPositionFromPath( root, path );
735
- * const selection = writer.createSelection( position );
736
- *
737
- * // Additional options (`'backward'`) can be specified as the last argument.
738
- *
739
- * // Creates backward selection.
740
- * const selection = writer.createSelection( range, { backward: true } );
741
- * ```
742
- *
743
- * See also: {@link #createSelection:NODE_OFFSET `createSelection( node, placeOrOffset, options )`}.
744
- *
745
- * @label SELECTABLE
746
- */
747
- createSelection(selectable?: Exclude<Selectable, Node>, options?: {
748
- backward?: boolean;
749
- }): ModelSelection;
750
- /**
751
- * Creates a {@link module:engine/model/batch~Batch} instance.
752
- *
753
- * **Note:** In most cases creating a batch instance is not necessary as they are created when using:
754
- *
755
- * * {@link #change `change()`},
756
- * * {@link #enqueueChange `enqueueChange()`}.
757
- *
758
- * @param type {@link module:engine/model/batch~Batch#constructor The type} of the batch.
759
- */
760
- createBatch(type?: BatchType): Batch;
761
- /**
762
- * Creates an operation instance from a JSON object (parsed JSON string).
763
- *
764
- * This is an alias for {@link module:engine/model/operation/operationfactory~OperationFactory.fromJSON `OperationFactory.fromJSON()`}.
765
- *
766
- * @param json Deserialized JSON object.
767
- */
768
- createOperationFromJSON(json: unknown): Operation;
769
- /**
770
- * Removes all events listeners set by model instance and destroys {@link module:engine/model/document~Document}.
771
- */
772
- destroy(): void;
773
- /**
774
- * Common part of {@link module:engine/model/model~Model#change} and {@link module:engine/model/model~Model#enqueueChange}
775
- * which calls callbacks and returns array of values returned by these callbacks.
776
- */
777
- private _runPendingChanges;
778
- }
779
- /**
780
- * Fired when entering the outermost {@link module:engine/model/model~Model#enqueueChange} or
781
- * {@link module:engine/model/model~Model#change} block.
782
- *
783
- * @internal
784
- * @eventName ~Model#_beforeChanges
785
- */
786
- export type BeforeChangesEvent = {
787
- name: '_beforeChanges';
788
- args: [];
789
- };
790
- /**
791
- * Fired when leaving the outermost {@link module:engine/model/model~Model#enqueueChange} or
792
- * {@link module:engine/model/model~Model#change} block.
793
- *
794
- * @internal
795
- * @eventName ~Model#_afterChanges
796
- */
797
- export type AfterChangesEvent = {
798
- name: '_afterChanges';
799
- args: [];
800
- };
801
- /**
802
- * Fired every time any {@link module:engine/model/operation/operation~Operation operation} is applied on the model
803
- * using {@link ~Model#applyOperation}.
804
- *
805
- * Note that this event is suitable only for very specific use-cases. Use it if you need to listen to every single operation
806
- * applied on the document. However, in most cases {@link module:engine/model/document~Document#event:change} should
807
- * be used.
808
- *
809
- * A few callbacks are already added to this event by engine internal classes:
810
- *
811
- * * with `highest` priority operation is validated,
812
- * * with `normal` priority operation is executed,
813
- * * with `low` priority the {@link module:engine/model/document~Document} updates its version,
814
- * * with `low` priority {@link module:engine/model/liveposition~LivePosition} and {@link module:engine/model/liverange~LiveRange}
815
- * update themselves.
816
- *
817
- * @eventName ~Model#applyOperation
818
- * @param args Arguments of the `applyOperation` which is an array with a single element - applied
819
- * {@link module:engine/model/operation/operation~Operation operation}.
820
- */
821
- export type ModelApplyOperationEvent = DecoratedMethodEvent<Model, 'applyOperation'>;
822
- /**
823
- * Event fired when {@link ~Model#insertContent} method is called.
824
- *
825
- * The {@link ~Model#insertContent default action of that method} is implemented as a
826
- * listener to this event so it can be fully customized by the features.
827
- *
828
- * **Note** The `selectable` parameter for the {@link ~Model#insertContent} is optional. When `undefined` value is passed the method uses
829
- * {@link module:engine/model/document~Document#selection document selection}.
830
- *
831
- * @eventName ~Model#insertContent
832
- * @param args The arguments passed to the original method.
833
- */
834
- export type ModelInsertContentEvent = {
835
- name: 'insertContent';
836
- args: [
837
- [
838
- content: Item | ModelDocumentFragment,
839
- selectable?: ModelSelection | DocumentSelection,
840
- ...rest: Array<unknown>
841
- ]
842
- ];
843
- return: ModelRange;
844
- };
845
- /**
846
- * Event fired when the {@link ~Model#insertObject} method is called.
847
- *
848
- * The {@link ~Model#insertObject default action of that method} is implemented as a
849
- * listener to this event so it can be fully customized by the features.
850
- *
851
- * **Note** The `selectable` parameter for the {@link ~Model#insertObject} is optional. When `undefined` value is passed the method uses
852
- * {@link module:engine/model/document~Document#selection document selection}.
853
- *
854
- * @eventName ~Model#insertObject
855
- * @param args The arguments passed to the original method.
856
- */
857
- export type ModelInsertObjectEvent = {
858
- name: 'insertObject';
859
- args: [
860
- [
861
- element: ModelElement,
862
- selectable?: ModelSelection | DocumentSelection | null,
863
- options?: {
864
- findOptimalPosition?: 'auto' | 'before' | 'after';
865
- setSelection?: 'on' | 'after';
866
- },
867
- ...rest: Array<unknown>
868
- ]
869
- ];
870
- return: ModelRange;
871
- };
872
- /**
873
- * Event fired when {@link ~Model#deleteContent} method is called.
874
- *
875
- * The {@link ~Model#deleteContent default action of that method} is implemented as a
876
- * listener to this event, so it can be fully customized by the features.
877
- *
878
- * @eventName ~Model#deleteContent
879
- * @param args The arguments passed to the original method.
880
- */
881
- export type ModelDeleteContentEvent = DecoratedMethodEvent<Model, 'deleteContent'>;
882
- /**
883
- * Event fired when {@link ~Model#modifySelection} method is called.
884
- *
885
- * The {@link ~Model#modifySelection default action of that method} is implemented as a
886
- * listener to this event, so it can be fully customized by the features.
887
- *
888
- * @eventName ~Model#modifySelection
889
- * @param args The arguments passed to the original method.
890
- */
891
- export type ModelModifySelectionEvent = DecoratedMethodEvent<Model, 'modifySelection'>;
892
- /**
893
- * Event fired when {@link ~Model#getSelectedContent} method is called.
894
- *
895
- * The {@link ~Model#getSelectedContent default action of that method} is implemented as a
896
- * listener to this event, so it can be fully customized by the features.
897
- *
898
- * @eventName ~Model#getSelectedContent
899
- * @param args The arguments passed to the original method.
900
- */
901
- export type ModelGetSelectedContentEvent = DecoratedMethodEvent<Model, 'getSelectedContent'>;
902
- /**
903
- * Event fired when {@link ~Model#canEditAt} method is called.
904
- *
905
- * The {@link ~Model#canEditAt default action of that method} is implemented as a
906
- * listener to this event, so it can be fully customized by the features.
907
- *
908
- * Although the original method accepts any parameter of `Selectable` type, this event is fired with `selectable` normalized
909
- * to an instance of {@link module:engine/model/selection~Selection} or {@link module:engine/model/documentselection~DocumentSelection}.
910
- *
911
- * @eventName ~Model#canEditAt
912
- * @param args The arguments passed to the original method.
913
- */
914
- export type ModelCanEditAtEvent = {
915
- name: 'canEditAt';
916
- args: [
917
- [
918
- selectable?: ModelSelection | DocumentSelection
919
- ]
920
- ];
921
- return: boolean;
922
- };
923
- export {};