@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,855 +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
- import DocumentFragment from './documentfragment.js';
10
- import Element from './element.js';
11
- import Position, { type PositionOffset, type PositionStickiness } from './position.js';
12
- import Range from './range.js';
13
- import RootElement from './rootelement.js';
14
- import Text from './text.js';
15
- import type { Marker } from './markercollection.js';
16
- import type { default as Selection, PlaceOrOffset, Selectable } from './selection.js';
17
- import type Batch from './batch.js';
18
- import type Item from './item.js';
19
- import type Model from './model.js';
20
- import type { default as Node, NodeAttributes } from './node.js';
21
- /**
22
- * The model can only be modified by using the writer. It should be used whenever you want to create a node, modify
23
- * child nodes, attributes or text, set the selection's position and its attributes.
24
- *
25
- * The instance of the writer is only available in the {@link module:engine/model/model~Model#change `change()`} or
26
- * {@link module:engine/model/model~Model#enqueueChange `enqueueChange()`}.
27
- *
28
- * ```ts
29
- * model.change( writer => {
30
- * writer.insertText( 'foo', paragraph, 'end' );
31
- * } );
32
- * ```
33
- *
34
- * Note that the writer should never be stored and used outside of the `change()` and
35
- * `enqueueChange()` blocks.
36
- *
37
- * Note that writer's methods do not check the {@link module:engine/model/schema~Schema}. It is possible
38
- * to create incorrect model structures by using the writer. Read more about in
39
- * {@glink framework/deep-dive/schema#who-checks-the-schema "Who checks the schema?"}.
40
- *
41
- * @see module:engine/model/model~Model#change
42
- * @see module:engine/model/model~Model#enqueueChange
43
- */
44
- export default class Writer {
45
- /**
46
- * Instance of the model on which this writer operates.
47
- */
48
- readonly model: Model;
49
- /**
50
- * The batch to which this writer will add changes.
51
- */
52
- readonly batch: Batch;
53
- /**
54
- * Creates a writer instance.
55
- *
56
- * **Note:** It is not recommended to use it directly. Use {@link module:engine/model/model~Model#change `Model#change()`} or
57
- * {@link module:engine/model/model~Model#enqueueChange `Model#enqueueChange()`} instead.
58
- *
59
- * @internal
60
- */
61
- constructor(model: Model, batch: Batch);
62
- /**
63
- * Creates a new {@link module:engine/model/text~Text text node}.
64
- *
65
- * ```ts
66
- * writer.createText( 'foo' );
67
- * writer.createText( 'foo', { bold: true } );
68
- * ```
69
- *
70
- * @param data Text data.
71
- * @param attributes Text attributes.
72
- * @returns {module:engine/model/text~Text} Created text node.
73
- */
74
- createText(data: string, attributes?: NodeAttributes): Text;
75
- /**
76
- * Creates a new {@link module:engine/model/element~Element element}.
77
- *
78
- * ```ts
79
- * writer.createElement( 'paragraph' );
80
- * writer.createElement( 'paragraph', { alignment: 'center' } );
81
- * ```
82
- *
83
- * @param name Name of the element.
84
- * @param attributes Elements attributes.
85
- * @returns Created element.
86
- */
87
- createElement(name: string, attributes?: NodeAttributes): Element;
88
- /**
89
- * Creates a new {@link module:engine/model/documentfragment~DocumentFragment document fragment}.
90
- *
91
- * @returns Created document fragment.
92
- */
93
- createDocumentFragment(): DocumentFragment;
94
- /**
95
- * Creates a copy of the element and returns it. Created element has the same name and attributes as the original element.
96
- * If clone is deep, the original element's children are also cloned. If not, then empty element is returned.
97
- *
98
- * @param element The element to clone.
99
- * @param deep If set to `true` clones element and all its children recursively. When set to `false`,
100
- * element will be cloned without any child.
101
- */
102
- cloneElement(element: Element, deep?: boolean): Element;
103
- /**
104
- * Inserts item on given position.
105
- *
106
- * ```ts
107
- * const paragraph = writer.createElement( 'paragraph' );
108
- * writer.insert( paragraph, position );
109
- * ```
110
- *
111
- * Instead of using position you can use parent and offset:
112
- *
113
- * ```ts
114
- * const text = writer.createText( 'foo' );
115
- * writer.insert( text, paragraph, 5 );
116
- * ```
117
- *
118
- * You can also use `end` instead of the offset to insert at the end:
119
- *
120
- * ```ts
121
- * const text = writer.createText( 'foo' );
122
- * writer.insert( text, paragraph, 'end' );
123
- * ```
124
- *
125
- * Or insert before or after another element:
126
- *
127
- * ```ts
128
- * const paragraph = writer.createElement( 'paragraph' );
129
- * writer.insert( paragraph, anotherParagraph, 'after' );
130
- * ```
131
- *
132
- * These parameters works the same way as {@link #createPositionAt `writer.createPositionAt()`}.
133
- *
134
- * Note that if the item already has parent it will be removed from the previous parent.
135
- *
136
- * Note that you cannot re-insert a node from a document to a different document or a document fragment. In this case,
137
- * `model-writer-insert-forbidden-move` is thrown.
138
- *
139
- * If you want to move {@link module:engine/model/range~Range range} instead of an
140
- * {@link module:engine/model/item~Item item} use {@link module:engine/model/writer~Writer#move `Writer#move()`}.
141
- *
142
- * **Note:** For a paste-like content insertion mechanism see
143
- * {@link module:engine/model/model~Model#insertContent `model.insertContent()`}.
144
- *
145
- * @param item Item or document fragment to insert.
146
- * @param offset Offset or one of the flags. Used only when second parameter is a {@link module:engine/model/item~Item model item}.
147
- */
148
- insert(item: Item | DocumentFragment, itemOrPosition: Item | DocumentFragment | Position, offset?: PositionOffset): void;
149
- /**
150
- * Creates and inserts text on given position.
151
- *
152
- * ```ts
153
- * writer.insertText( 'foo', position );
154
- * ```
155
- *
156
- * Instead of using position you can use parent and offset or define that text should be inserted at the end
157
- * or before or after other node:
158
- *
159
- * ```ts
160
- * // Inserts 'foo' in paragraph, at offset 5:
161
- * writer.insertText( 'foo', paragraph, 5 );
162
- * // Inserts 'foo' at the end of a paragraph:
163
- * writer.insertText( 'foo', paragraph, 'end' );
164
- * // Inserts 'foo' after an image:
165
- * writer.insertText( 'foo', image, 'after' );
166
- * ```
167
- *
168
- * These parameters work in the same way as {@link #createPositionAt `writer.createPositionAt()`}.
169
- *
170
- * @label WITHOUT_ATTRIBUTES
171
- * @param text Text data.
172
- * @param offset Offset or one of the flags. Used only when second parameter is a {@link module:engine/model/item~Item model item}.
173
- */
174
- insertText(text: string, itemOrPosition?: Item | Position, offset?: PositionOffset): void;
175
- /**
176
- * Creates and inserts text with specified attributes on given position.
177
- *
178
- * ```ts
179
- * writer.insertText( 'foo', { bold: true }, position );
180
- * ```
181
- *
182
- * Instead of using position you can use parent and offset or define that text should be inserted at the end
183
- * or before or after other node:
184
- *
185
- * ```ts
186
- * // Inserts 'foo' in paragraph, at offset 5:
187
- * writer.insertText( 'foo', { bold: true }, paragraph, 5 );
188
- * // Inserts 'foo' at the end of a paragraph:
189
- * writer.insertText( 'foo', { bold: true }, paragraph, 'end' );
190
- * // Inserts 'foo' after an image:
191
- * writer.insertText( 'foo', { bold: true }, image, 'after' );
192
- * ```
193
- *
194
- * These parameters work in the same way as {@link #createPositionAt `writer.createPositionAt()`}.
195
- *
196
- * @label WITH_ATTRIBUTES
197
- * @param text Text data.
198
- * @param attributes Text attributes.
199
- * @param offset Offset or one of the flags. Used only when third parameter is a {@link module:engine/model/item~Item model item}.
200
- */
201
- insertText(text: string, attributes?: NodeAttributes, itemOrPosition?: Item | Position, offset?: PositionOffset): void;
202
- /**
203
- * Creates and inserts element on given position. You can optionally set attributes:
204
- *
205
- * ```ts
206
- * writer.insertElement( 'paragraph', position );
207
- * ```
208
- *
209
- * Instead of using position you can use parent and offset or define that text should be inserted at the end
210
- * or before or after other node:
211
- *
212
- * ```ts
213
- * // Inserts paragraph in the root at offset 5:
214
- * writer.insertElement( 'paragraph', root, 5 );
215
- * // Inserts paragraph at the end of a blockquote:
216
- * writer.insertElement( 'paragraph', blockquote, 'end' );
217
- * // Inserts after an image:
218
- * writer.insertElement( 'paragraph', image, 'after' );
219
- * ```
220
- *
221
- * These parameters works the same way as {@link #createPositionAt `writer.createPositionAt()`}.
222
- *
223
- * @label WITHOUT_ATTRIBUTES
224
- * @param name Name of the element.
225
- * @param offset Offset or one of the flags. Used only when second parameter is a {@link module:engine/model/item~Item model item}.
226
- */
227
- insertElement(name: string, itemOrPosition: Item | DocumentFragment | Position, offset?: PositionOffset): void;
228
- /**
229
- * Creates and inserts element with specified attributes on given position.
230
- *
231
- * ```ts
232
- * writer.insertElement( 'paragraph', { alignment: 'center' }, position );
233
- * ```
234
- *
235
- * Instead of using position you can use parent and offset or define that text should be inserted at the end
236
- * or before or after other node:
237
- *
238
- * ```ts
239
- * // Inserts paragraph in the root at offset 5:
240
- * writer.insertElement( 'paragraph', { alignment: 'center' }, root, 5 );
241
- * // Inserts paragraph at the end of a blockquote:
242
- * writer.insertElement( 'paragraph', { alignment: 'center' }, blockquote, 'end' );
243
- * // Inserts after an image:
244
- * writer.insertElement( 'paragraph', { alignment: 'center' }, image, 'after' );
245
- * ```
246
- *
247
- * These parameters works the same way as {@link #createPositionAt `writer.createPositionAt()`}.
248
- *
249
- * @label WITH_ATTRIBUTES
250
- * @param name Name of the element.
251
- * @param attributes Elements attributes.
252
- * @param offset Offset or one of the flags. Used only when third parameter is a {@link module:engine/model/item~Item model item}.
253
- */
254
- insertElement(name: string, attributes: NodeAttributes, itemOrPosition: Item | DocumentFragment | Position, offset?: PositionOffset): void;
255
- /**
256
- * Inserts item at the end of the given parent.
257
- *
258
- * ```ts
259
- * const paragraph = writer.createElement( 'paragraph' );
260
- * writer.append( paragraph, root );
261
- * ```
262
- *
263
- * Note that if the item already has parent it will be removed from the previous parent.
264
- *
265
- * If you want to move {@link module:engine/model/range~Range range} instead of an
266
- * {@link module:engine/model/item~Item item} use {@link module:engine/model/writer~Writer#move `Writer#move()`}.
267
- *
268
- * @param item Item or document fragment to insert.
269
- */
270
- append(item: Item | DocumentFragment, parent: Element | DocumentFragment): void;
271
- /**
272
- * Creates text node and inserts it at the end of the parent.
273
- *
274
- * ```ts
275
- * writer.appendText( 'foo', paragraph );
276
- * ```
277
- *
278
- * @label WITHOUT_ATTRIBUTES
279
- * @param text Text data.
280
- */
281
- appendText(text: string, parent: Element | DocumentFragment): void;
282
- /**
283
- * Creates text node with specified attributes and inserts it at the end of the parent.
284
- *
285
- * ```ts
286
- * writer.appendText( 'foo', { bold: true }, paragraph );
287
- * ```
288
- *
289
- * @label WITH_ATTRIBUTES
290
- * @param text Text data.
291
- * @param attributes Text attributes.
292
- */
293
- appendText(text: string, attributes: NodeAttributes, parent: Element | DocumentFragment): void;
294
- /**
295
- * Creates element and inserts it at the end of the parent.
296
- *
297
- * ```ts
298
- * writer.appendElement( 'paragraph', root );
299
- * ```
300
- *
301
- * @label WITHOUT_ATTRIBUTES
302
- * @param name Name of the element.
303
- */
304
- appendElement(name: string, parent: Element | DocumentFragment): void;
305
- /**
306
- * Creates element with specified attributes and inserts it at the end of the parent.
307
- *
308
- * ```ts
309
- * writer.appendElement( 'paragraph', { alignment: 'center' }, root );
310
- * ```
311
- *
312
- * @label WITH_ATTRIBUTES
313
- * @param name Name of the element.
314
- * @param attributes Elements attributes.
315
- */
316
- appendElement(name: string, attributes: NodeAttributes, parent: Element | DocumentFragment): void;
317
- /**
318
- * Sets value of the attribute with given key on a {@link module:engine/model/item~Item model item}
319
- * or on a {@link module:engine/model/range~Range range}.
320
- *
321
- * @param key Attribute key.
322
- * @param value Attribute new value.
323
- * @param itemOrRange Model item or range on which the attribute will be set.
324
- */
325
- setAttribute(key: string, value: unknown, itemOrRange: Item | Range): void;
326
- /**
327
- * Sets values of attributes on a {@link module:engine/model/item~Item model item}
328
- * or on a {@link module:engine/model/range~Range range}.
329
- *
330
- * ```ts
331
- * writer.setAttributes( {
332
- * bold: true,
333
- * italic: true
334
- * }, range );
335
- * ```
336
- *
337
- * @param attributes Attributes keys and values.
338
- * @param itemOrRange Model item or range on which the attributes will be set.
339
- */
340
- setAttributes(attributes: NodeAttributes, itemOrRange: Item | Range): void;
341
- /**
342
- * Removes an attribute with given key from a {@link module:engine/model/item~Item model item}
343
- * or from a {@link module:engine/model/range~Range range}.
344
- *
345
- * @param key Attribute key.
346
- * @param itemOrRange Model item or range from which the attribute will be removed.
347
- */
348
- removeAttribute(key: string, itemOrRange: Item | Range): void;
349
- /**
350
- * Removes all attributes from all elements in the range or from the given item.
351
- *
352
- * @param itemOrRange Model item or range from which all attributes will be removed.
353
- */
354
- clearAttributes(itemOrRange: Item | Range): void;
355
- /**
356
- * Moves all items in the source range to the target position.
357
- *
358
- * ```ts
359
- * writer.move( sourceRange, targetPosition );
360
- * ```
361
- *
362
- * Instead of the target position you can use parent and offset or define that range should be moved to the end
363
- * or before or after chosen item:
364
- *
365
- * ```ts
366
- * // Moves all items in the range to the paragraph at offset 5:
367
- * writer.move( sourceRange, paragraph, 5 );
368
- * // Moves all items in the range to the end of a blockquote:
369
- * writer.move( sourceRange, blockquote, 'end' );
370
- * // Moves all items in the range to a position after an image:
371
- * writer.move( sourceRange, image, 'after' );
372
- * ```
373
- *
374
- * These parameters work the same way as {@link #createPositionAt `writer.createPositionAt()`}.
375
- *
376
- * Note that items can be moved only within the same tree. It means that you can move items within the same root
377
- * (element or document fragment) or between {@link module:engine/model/document~Document#roots documents roots},
378
- * but you can not move items from document fragment to the document or from one detached element to another. Use
379
- * {@link module:engine/model/writer~Writer#insert} in such cases.
380
- *
381
- * @param range Source range.
382
- * @param offset Offset or one of the flags. Used only when second parameter is a {@link module:engine/model/item~Item model item}.
383
- */
384
- move(range: Range, itemOrPosition: Item | Position, offset?: PositionOffset): void;
385
- /**
386
- * Removes given model {@link module:engine/model/item~Item item} or {@link module:engine/model/range~Range range}.
387
- *
388
- * @param itemOrRange Model item or range to remove.
389
- */
390
- remove(itemOrRange: Item | Range): void;
391
- /**
392
- * Merges two siblings at the given position.
393
- *
394
- * Node before and after the position have to be an element. Otherwise `writer-merge-no-element-before` or
395
- * `writer-merge-no-element-after` error will be thrown.
396
- *
397
- * @param position Position between merged elements.
398
- */
399
- merge(position: Position): void;
400
- /**
401
- * Shortcut for {@link module:engine/model/model~Model#createPositionFromPath `Model#createPositionFromPath()`}.
402
- *
403
- * @param root Root of the position.
404
- * @param path Position path. See {@link module:engine/model/position~Position#path}.
405
- * @param stickiness Position stickiness. See {@link module:engine/model/position~PositionStickiness}.
406
- */
407
- createPositionFromPath(root: Element | DocumentFragment, path: ReadonlyArray<number>, stickiness?: PositionStickiness): Position;
408
- /**
409
- * Shortcut for {@link module:engine/model/model~Model#createPositionAt `Model#createPositionAt()`}.
410
- *
411
- * @param offset Offset or one of the flags. Used only when first parameter is a {@link module:engine/model/item~Item model item}.
412
- */
413
- createPositionAt(itemOrPosition: Item | Position | DocumentFragment, offset?: PositionOffset): Position;
414
- /**
415
- * Shortcut for {@link module:engine/model/model~Model#createPositionAfter `Model#createPositionAfter()`}.
416
- *
417
- * @param item Item after which the position should be placed.
418
- */
419
- createPositionAfter(item: Item): Position;
420
- /**
421
- * Shortcut for {@link module:engine/model/model~Model#createPositionBefore `Model#createPositionBefore()`}.
422
- *
423
- * @param item Item after which the position should be placed.
424
- */
425
- createPositionBefore(item: Item): Position;
426
- /**
427
- * Shortcut for {@link module:engine/model/model~Model#createRange `Model#createRange()`}.
428
- *
429
- * @param start Start position.
430
- * @param end End position. If not set, range will be collapsed at `start` position.
431
- */
432
- createRange(start: Position, end?: Position): Range;
433
- /**
434
- * Shortcut for {@link module:engine/model/model~Model#createRangeIn `Model#createRangeIn()`}.
435
- *
436
- * @param element Element which is a parent for the range.
437
- */
438
- createRangeIn(element: Element | DocumentFragment): Range;
439
- /**
440
- * Shortcut for {@link module:engine/model/model~Model#createRangeOn `Model#createRangeOn()`}.
441
- *
442
- * @param element Element which is a parent for the range.
443
- */
444
- createRangeOn(element: Item): Range;
445
- /**
446
- * Shortcut for {@link module:engine/model/model~Model#createSelection:NODE_OFFSET `Model#createSelection()`}.
447
- *
448
- * @label NODE_OFFSET
449
- */
450
- createSelection(selectable: Node, placeOrOffset: PlaceOrOffset, options?: {
451
- backward?: boolean;
452
- }): Selection;
453
- /**
454
- * Shortcut for {@link module:engine/model/model~Model#createSelection:SELECTABLE `Model#createSelection()`}.
455
- *
456
- * @label SELECTABLE
457
- */
458
- createSelection(selectable?: Exclude<Selectable, Node>, options?: {
459
- backward?: boolean;
460
- }): Selection;
461
- /**
462
- * Performs merge action in a detached tree.
463
- *
464
- * @param position Position between merged elements.
465
- */
466
- private _mergeDetached;
467
- /**
468
- * Performs merge action in a non-detached tree.
469
- *
470
- * @param position Position between merged elements.
471
- */
472
- private _merge;
473
- /**
474
- * Renames the given element.
475
- *
476
- * @param element The element to rename.
477
- * @param newName New element name.
478
- */
479
- rename(element: Element | DocumentFragment, newName: string): void;
480
- /**
481
- * Splits elements starting from the given position and going to the top of the model tree as long as given
482
- * `limitElement` is reached. When `limitElement` is not defined then only the parent of the given position will be split.
483
- *
484
- * The element needs to have a parent. It cannot be a root element nor a document fragment.
485
- * The `writer-split-element-no-parent` error will be thrown if you try to split an element with no parent.
486
- *
487
- * @param position Position of split.
488
- * @param limitElement Stop splitting when this element will be reached.
489
- * @returns Split result with properties:
490
- * * `position` - Position between split elements.
491
- * * `range` - Range that stars from the end of the first split element and ends at the beginning of the first copy element.
492
- */
493
- split(position: Position, limitElement?: Node | DocumentFragment): {
494
- position: Position;
495
- range: Range;
496
- };
497
- /**
498
- * Wraps the given range with the given element or with a new element (if a string was passed).
499
- *
500
- * **Note:** range to wrap should be a "flat range" (see {@link module:engine/model/range~Range#isFlat `Range#isFlat`}).
501
- * If not, an error will be thrown.
502
- *
503
- * @param range Range to wrap.
504
- * @param elementOrString Element or name of element to wrap the range with.
505
- */
506
- wrap(range: Range, elementOrString: Element | string): void;
507
- /**
508
- * Unwraps children of the given element – all its children are moved before it and then the element is removed.
509
- * Throws error if you try to unwrap an element which does not have a parent.
510
- *
511
- * @param element Element to unwrap.
512
- */
513
- unwrap(element: Element): void;
514
- /**
515
- * Adds a {@link module:engine/model/markercollection~Marker marker}. Marker is a named range, which tracks
516
- * changes in the document and updates its range automatically, when model tree changes.
517
- *
518
- * As the first parameter you can set marker name.
519
- *
520
- * The required `options.usingOperation` parameter lets you decide if the marker should be managed by operations or not. See
521
- * {@link module:engine/model/markercollection~Marker marker class description} to learn about the difference between
522
- * markers managed by operations and not-managed by operations.
523
- *
524
- * The `options.affectsData` parameter, which defaults to `false`, allows you to define if a marker affects the data. It should be
525
- * `true` when the marker change changes the data returned by the
526
- * {@link module:core/editor/editor~Editor#getData `editor.getData()`} method.
527
- * When set to `true` it fires the {@link module:engine/model/document~Document#event:change:data `change:data`} event.
528
- * When set to `false` it fires the {@link module:engine/model/document~Document#event:change `change`} event.
529
- *
530
- * Create marker directly base on marker's name:
531
- *
532
- * ```ts
533
- * addMarker( markerName, { range, usingOperation: false } );
534
- * ```
535
- *
536
- * Create marker using operation:
537
- *
538
- * ```ts
539
- * addMarker( markerName, { range, usingOperation: true } );
540
- * ```
541
- *
542
- * Create marker that affects the editor data:
543
- *
544
- * ```ts
545
- * addMarker( markerName, { range, usingOperation: false, affectsData: true } );
546
- * ```
547
- *
548
- * Note: For efficiency reasons, it's best to create and keep as little markers as possible.
549
- *
550
- * @see module:engine/model/markercollection~Marker
551
- * @param name Name of a marker to create - must be unique.
552
- * @param options.usingOperation Flag indicating that the marker should be added by MarkerOperation.
553
- * See {@link module:engine/model/markercollection~Marker#managedUsingOperations}.
554
- * @param options.range Marker range.
555
- * @param options.affectsData Flag indicating that the marker changes the editor data.
556
- * @returns Marker that was set.
557
- */
558
- addMarker(name: string, options: {
559
- usingOperation: boolean;
560
- affectsData?: boolean;
561
- range: Range;
562
- }): Marker;
563
- /**
564
- * Adds, updates or refreshes a {@link module:engine/model/markercollection~Marker marker}. Marker is a named range, which tracks
565
- * changes in the document and updates its range automatically, when model tree changes. Still, it is possible to change the
566
- * marker's range directly using this method.
567
- *
568
- * As the first parameter you can set marker name or instance. If none of them is provided, new marker, with a unique
569
- * name is created and returned.
570
- *
571
- * **Note**: If you want to change the {@link module:engine/view/element~Element view element} of the marker while its data in the model
572
- * remains the same, use the dedicated {@link module:engine/controller/editingcontroller~EditingController#reconvertMarker} method.
573
- *
574
- * The `options.usingOperation` parameter lets you change if the marker should be managed by operations or not. See
575
- * {@link module:engine/model/markercollection~Marker marker class description} to learn about the difference between
576
- * markers managed by operations and not-managed by operations. It is possible to change this option for an existing marker.
577
- *
578
- * The `options.affectsData` parameter, which defaults to `false`, allows you to define if a marker affects the data. It should be
579
- * `true` when the marker change changes the data returned by
580
- * the {@link module:core/editor/editor~Editor#getData `editor.getData()`} method.
581
- * When set to `true` it fires the {@link module:engine/model/document~Document#event:change:data `change:data`} event.
582
- * When set to `false` it fires the {@link module:engine/model/document~Document#event:change `change`} event.
583
- *
584
- * Update marker directly base on marker's name:
585
- *
586
- * ```ts
587
- * updateMarker( markerName, { range } );
588
- * ```
589
- *
590
- * Update marker using operation:
591
- *
592
- * ```ts
593
- * updateMarker( marker, { range, usingOperation: true } );
594
- * updateMarker( markerName, { range, usingOperation: true } );
595
- * ```
596
- *
597
- * Change marker's option (start using operations to manage it):
598
- *
599
- * ```ts
600
- * updateMarker( marker, { usingOperation: true } );
601
- * ```
602
- *
603
- * Change marker's option (inform the engine, that the marker does not affect the data anymore):
604
- *
605
- * ```ts
606
- * updateMarker( markerName, { affectsData: false } );
607
- * ```
608
- *
609
- * @see module:engine/model/markercollection~Marker
610
- * @param markerOrName Name of a marker to update, or a marker instance.
611
- * @param options If options object is not defined then marker will be refreshed by triggering
612
- * downcast conversion for this marker with the same data.
613
- * @param options.range Marker range to update.
614
- * @param options.usingOperation Flag indicated whether the marker should be added by MarkerOperation.
615
- * See {@link module:engine/model/markercollection~Marker#managedUsingOperations}.
616
- * @param options.affectsData Flag indicating that the marker changes the editor data.
617
- */
618
- updateMarker(markerOrName: string | Marker, options?: {
619
- range?: Range;
620
- usingOperation?: boolean;
621
- affectsData?: boolean;
622
- }): void;
623
- /**
624
- * Removes given {@link module:engine/model/markercollection~Marker marker} or marker with given name.
625
- * The marker is removed accordingly to how it has been created, so if the marker was created using operation,
626
- * it will be destroyed using operation.
627
- *
628
- * @param markerOrName Marker or marker name to remove.
629
- */
630
- removeMarker(markerOrName: string | Marker): void;
631
- /**
632
- * Adds a new root to the document (or re-attaches a {@link #detachRoot detached root}).
633
- *
634
- * Throws an error, if trying to add a root that is already added and attached.
635
- *
636
- * @param rootName Name of the added root.
637
- * @param elementName The element name. Defaults to `'$root'` which also has some basic schema defined
638
- * (e.g. `$block` elements are allowed inside the `$root`). Make sure to define a proper schema if you use a different name.
639
- * @returns The added root element.
640
- */
641
- addRoot(rootName: string, elementName?: string): RootElement;
642
- /**
643
- * Detaches the root from the document.
644
- *
645
- * All content and markers are removed from the root upon detaching. New content and new markers cannot be added to the root, as long
646
- * as it is detached.
647
- *
648
- * A root cannot be fully removed from the document, it can be only detached. A root is permanently removed only after you
649
- * re-initialize the editor and do not specify the root in the initial data.
650
- *
651
- * A detached root can be re-attached using {@link #addRoot}.
652
- *
653
- * Throws an error if the root does not exist or the root is already detached.
654
- *
655
- * @param rootOrName Name of the detached root.
656
- */
657
- detachRoot(rootOrName: string | RootElement): void;
658
- /**
659
- * Sets the document's selection (ranges and direction) to the specified location based on the given
660
- * {@link module:engine/model/selection~Selectable selectable} or creates an empty selection if no arguments were passed.
661
- *
662
- * ```ts
663
- * // Sets collapsed selection at the position of the given node and an offset.
664
- * writer.setSelection( paragraph, offset );
665
- * ```
666
- *
667
- * Creates a range inside an {@link module:engine/model/element~Element element} which starts before the first child of
668
- * that element and ends after the last child of that element.
669
- *
670
- * ```ts
671
- * writer.setSelection( paragraph, 'in' );
672
- * ```
673
- *
674
- * Creates a range on an {@link module:engine/model/item~Item item} which starts before the item and ends just after the item.
675
- *
676
- * ```ts
677
- * writer.setSelection( paragraph, 'on' );
678
- * ```
679
- *
680
- * `Writer#setSelection()` allow passing additional options (`backward`) as the last argument.
681
- *
682
- * ```ts
683
- * // Sets selection as backward.
684
- * writer.setSelection( element, 'in', { backward: true } );
685
- * ```
686
- *
687
- * Throws `writer-incorrect-use` error when the writer is used outside the `change()` block.
688
- *
689
- * See also: {@link #setSelection:SELECTABLE `setSelection( selectable, options )`}.
690
- *
691
- * @label NODE_OFFSET
692
- */
693
- setSelection(selectable: Node, placeOrOffset: PlaceOrOffset, options?: {
694
- backward?: boolean;
695
- }): void;
696
- /**
697
- * Sets the document's selection (ranges and direction) to the specified location based on the given
698
- * {@link module:engine/model/selection~Selectable selectable} or creates an empty selection if no arguments were passed.
699
- *
700
- * ```ts
701
- * // Sets selection to the given range.
702
- * const range = writer.createRange( start, end );
703
- * writer.setSelection( range );
704
- *
705
- * // Sets selection to given ranges.
706
- * const ranges = [ writer.createRange( start1, end2 ), writer.createRange( star2, end2 ) ];
707
- * writer.setSelection( ranges );
708
- *
709
- * // Sets selection to other selection.
710
- * const otherSelection = writer.createSelection();
711
- * writer.setSelection( otherSelection );
712
- *
713
- * // Sets selection to the given document selection.
714
- * const documentSelection = model.document.selection;
715
- * writer.setSelection( documentSelection );
716
- *
717
- * // Sets collapsed selection at the given position.
718
- * const position = writer.createPosition( root, path );
719
- * writer.setSelection( position );
720
- *
721
- * // Removes all selection's ranges.
722
- * writer.setSelection( null );
723
- * ```
724
- *
725
- * `Writer#setSelection()` allow passing additional options (`backward`) as the last argument.
726
- *
727
- * ```ts
728
- * // Sets selection as backward.
729
- * writer.setSelection( range, { backward: true } );
730
- * ```
731
- *
732
- * Throws `writer-incorrect-use` error when the writer is used outside the `change()` block.
733
- *
734
- * See also: {@link #setSelection:NODE_OFFSET `setSelection( node, placeOrOffset, options )`}.
735
- *
736
- * @label SELECTABLE
737
- */
738
- setSelection(selectable: Exclude<Selectable, Node>, options?: {
739
- backward?: boolean;
740
- }): void;
741
- /**
742
- * Moves {@link module:engine/model/documentselection~DocumentSelection#focus} to the specified location.
743
- *
744
- * The location can be specified in the same form as
745
- * {@link #createPositionAt `writer.createPositionAt()`} parameters.
746
- *
747
- * @param itemOrPosition
748
- * @param offset Offset or one of the flags. Used only when first parameter is a {@link module:engine/model/item~Item model item}.
749
- */
750
- setSelectionFocus(itemOrPosition: Item | Position, offset?: PositionOffset): void;
751
- /**
752
- * Sets attribute on the selection. If attribute with the same key already is set, it's value is overwritten.
753
- *
754
- * ```ts
755
- * writer.setSelectionAttribute( 'italic', true );
756
- * ```
757
- *
758
- * @label KEY_VALUE
759
- * @param key Key of the attribute to set.
760
- * @param value Attribute value.
761
- */
762
- setSelectionAttribute(key: string, value: unknown): void;
763
- /**
764
- * Sets attributes on the selection. If any attribute with the same key already is set, it's value is overwritten.
765
- *
766
- * Using key-value object:
767
- *
768
- * ```ts
769
- * writer.setSelectionAttribute( { italic: true, bold: false } );
770
- * ```
771
- *
772
- * Using iterable object:
773
- *
774
- * ```ts
775
- * writer.setSelectionAttribute( new Map( [ [ 'italic', true ] ] ) );
776
- * ```
777
- *
778
- * @label OBJECT
779
- * @param objectOrIterable Object / iterable of key => value attribute pairs.
780
- */
781
- setSelectionAttribute(objectOrIterable: NodeAttributes): void;
782
- /**
783
- * Removes attribute(s) with given key(s) from the selection.
784
- *
785
- * Remove one attribute:
786
- *
787
- * ```ts
788
- * writer.removeSelectionAttribute( 'italic' );
789
- * ```
790
- *
791
- * Remove multiple attributes:
792
- *
793
- * ```ts
794
- * writer.removeSelectionAttribute( [ 'italic', 'bold' ] );
795
- * ```
796
- *
797
- * @param keyOrIterableOfKeys Key of the attribute to remove or an iterable of attribute keys to remove.
798
- */
799
- removeSelectionAttribute(keyOrIterableOfKeys: string | Iterable<string>): void;
800
- /**
801
- * Temporarily changes the {@link module:engine/model/documentselection~DocumentSelection#isGravityOverridden gravity}
802
- * of the selection from left to right.
803
- *
804
- * The gravity defines from which direction the selection inherits its attributes. If it's the default left gravity,
805
- * then the selection (after being moved by the user) inherits attributes from its left-hand side.
806
- * This method allows to temporarily override this behavior by forcing the gravity to the right.
807
- *
808
- * For the following model fragment:
809
- *
810
- * ```xml
811
- * <$text bold="true" linkHref="url">bar[]</$text><$text bold="true">biz</$text>
812
- * ```
813
- *
814
- * * Default gravity: selection will have the `bold` and `linkHref` attributes.
815
- * * Overridden gravity: selection will have `bold` attribute.
816
- *
817
- * **Note**: It returns an unique identifier which is required to restore the gravity. It guarantees the symmetry
818
- * of the process.
819
- *
820
- * @returns The unique id which allows restoring the gravity.
821
- */
822
- overrideSelectionGravity(): string;
823
- /**
824
- * Restores {@link ~Writer#overrideSelectionGravity} gravity to default.
825
- *
826
- * Restoring the gravity is only possible using the unique identifier returned by
827
- * {@link ~Writer#overrideSelectionGravity}. Note that the gravity remains overridden as long as won't be restored
828
- * the same number of times it was overridden.
829
- *
830
- * @param uid The unique id returned by {@link ~Writer#overrideSelectionGravity}.
831
- */
832
- restoreSelectionGravity(uid: string): void;
833
- /**
834
- * @param key Key of the attribute to remove.
835
- * @param value Attribute value.
836
- */
837
- private _setSelectionAttribute;
838
- /**
839
- * @param key Key of the attribute to remove.
840
- */
841
- private _removeSelectionAttribute;
842
- /**
843
- * Throws `writer-detached-writer-tries-to-modify-model` error when the writer is used outside of the `change()` block.
844
- */
845
- private _assertWriterUsedCorrectly;
846
- /**
847
- * For given action `type` and `positionOrRange` where the action happens, this function finds all affected markers
848
- * and applies a marker operation with the new marker range equal to the current range. Thanks to this, the marker range
849
- * can be later correctly processed during undo.
850
- *
851
- * @param type Writer action type.
852
- * @param positionOrRange Position or range where the writer action happens.
853
- */
854
- private _addOperationForAffectedMarkers;
855
- }