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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (369) hide show
  1. package/LICENSE.md +1 -1
  2. package/dist/index-content.css +2 -2
  3. package/dist/index-editor.css +2 -2
  4. package/dist/index.css +4 -4
  5. package/dist/index.css.map +1 -1
  6. package/dist/index.js +646 -77
  7. package/dist/index.js.map +1 -1
  8. package/package.json +23 -3
  9. package/src/controller/datacontroller.d.ts +1 -1
  10. package/src/controller/datacontroller.js +1 -1
  11. package/src/controller/editingcontroller.d.ts +1 -1
  12. package/src/controller/editingcontroller.js +1 -1
  13. package/src/conversion/conversion.d.ts +1 -1
  14. package/src/conversion/conversion.js +1 -1
  15. package/src/conversion/conversionhelpers.d.ts +1 -1
  16. package/src/conversion/conversionhelpers.js +1 -1
  17. package/src/conversion/downcastdispatcher.d.ts +1 -1
  18. package/src/conversion/downcastdispatcher.js +1 -1
  19. package/src/conversion/downcasthelpers.d.ts +1 -1
  20. package/src/conversion/downcasthelpers.js +1 -1
  21. package/src/conversion/mapper.d.ts +249 -20
  22. package/src/conversion/mapper.js +524 -38
  23. package/src/conversion/modelconsumable.d.ts +1 -1
  24. package/src/conversion/modelconsumable.js +1 -1
  25. package/src/conversion/upcastdispatcher.d.ts +1 -1
  26. package/src/conversion/upcastdispatcher.js +1 -1
  27. package/src/conversion/upcasthelpers.d.ts +1 -1
  28. package/src/conversion/upcasthelpers.js +1 -1
  29. package/src/conversion/viewconsumable.d.ts +1 -1
  30. package/src/conversion/viewconsumable.js +1 -1
  31. package/src/dataprocessor/basichtmlwriter.d.ts +1 -1
  32. package/src/dataprocessor/basichtmlwriter.js +1 -1
  33. package/src/dataprocessor/dataprocessor.d.ts +1 -1
  34. package/src/dataprocessor/dataprocessor.js +1 -1
  35. package/src/dataprocessor/htmldataprocessor.d.ts +1 -1
  36. package/src/dataprocessor/htmldataprocessor.js +1 -1
  37. package/src/dataprocessor/htmlwriter.d.ts +1 -1
  38. package/src/dataprocessor/htmlwriter.js +1 -1
  39. package/src/dataprocessor/xmldataprocessor.d.ts +1 -1
  40. package/src/dataprocessor/xmldataprocessor.js +1 -1
  41. package/src/dev-utils/model.d.ts +1 -1
  42. package/src/dev-utils/model.js +1 -1
  43. package/src/dev-utils/operationreplayer.d.ts +1 -1
  44. package/src/dev-utils/operationreplayer.js +1 -1
  45. package/src/dev-utils/utils.d.ts +1 -1
  46. package/src/dev-utils/utils.js +1 -1
  47. package/src/dev-utils/view.d.ts +1 -1
  48. package/src/dev-utils/view.js +1 -1
  49. package/src/index.d.ts +4 -2
  50. package/src/index.js +2 -1
  51. package/src/model/batch.d.ts +1 -1
  52. package/src/model/batch.js +7 -3
  53. package/src/model/differ.d.ts +1 -1
  54. package/src/model/differ.js +1 -1
  55. package/src/model/document.d.ts +1 -1
  56. package/src/model/document.js +1 -1
  57. package/src/model/documentfragment.d.ts +1 -1
  58. package/src/model/documentfragment.js +1 -1
  59. package/src/model/documentselection.d.ts +1 -1
  60. package/src/model/documentselection.js +1 -1
  61. package/src/model/element.d.ts +1 -1
  62. package/src/model/element.js +1 -1
  63. package/src/model/history.d.ts +1 -1
  64. package/src/model/history.js +1 -1
  65. package/src/model/item.d.ts +1 -1
  66. package/src/model/item.js +1 -1
  67. package/src/model/liveposition.d.ts +1 -1
  68. package/src/model/liveposition.js +1 -1
  69. package/src/model/liverange.d.ts +1 -1
  70. package/src/model/liverange.js +1 -1
  71. package/src/model/markercollection.d.ts +1 -1
  72. package/src/model/markercollection.js +1 -1
  73. package/src/model/model.d.ts +1 -1
  74. package/src/model/model.js +1 -1
  75. package/src/model/node.d.ts +1 -1
  76. package/src/model/node.js +1 -1
  77. package/src/model/nodelist.d.ts +1 -1
  78. package/src/model/nodelist.js +1 -1
  79. package/src/model/operation/attributeoperation.d.ts +1 -1
  80. package/src/model/operation/attributeoperation.js +1 -1
  81. package/src/model/operation/detachoperation.d.ts +1 -1
  82. package/src/model/operation/detachoperation.js +1 -1
  83. package/src/model/operation/insertoperation.d.ts +1 -1
  84. package/src/model/operation/insertoperation.js +1 -1
  85. package/src/model/operation/markeroperation.d.ts +1 -1
  86. package/src/model/operation/markeroperation.js +1 -1
  87. package/src/model/operation/mergeoperation.d.ts +1 -1
  88. package/src/model/operation/mergeoperation.js +1 -1
  89. package/src/model/operation/moveoperation.d.ts +1 -1
  90. package/src/model/operation/moveoperation.js +1 -1
  91. package/src/model/operation/nooperation.d.ts +1 -1
  92. package/src/model/operation/nooperation.js +1 -1
  93. package/src/model/operation/operation.d.ts +4 -1
  94. package/src/model/operation/operation.js +2 -2
  95. package/src/model/operation/operationfactory.d.ts +1 -1
  96. package/src/model/operation/operationfactory.js +1 -1
  97. package/src/model/operation/renameoperation.d.ts +1 -1
  98. package/src/model/operation/renameoperation.js +1 -1
  99. package/src/model/operation/rootattributeoperation.d.ts +1 -1
  100. package/src/model/operation/rootattributeoperation.js +1 -1
  101. package/src/model/operation/rootoperation.d.ts +1 -1
  102. package/src/model/operation/rootoperation.js +1 -1
  103. package/src/model/operation/splitoperation.d.ts +1 -1
  104. package/src/model/operation/splitoperation.js +1 -1
  105. package/src/model/operation/transform.d.ts +1 -1
  106. package/src/model/operation/transform.js +1 -1
  107. package/src/model/operation/utils.d.ts +1 -1
  108. package/src/model/operation/utils.js +1 -1
  109. package/src/model/position.d.ts +1 -1
  110. package/src/model/position.js +1 -1
  111. package/src/model/range.d.ts +1 -1
  112. package/src/model/range.js +1 -1
  113. package/src/model/rootelement.d.ts +1 -1
  114. package/src/model/rootelement.js +1 -1
  115. package/src/model/schema.d.ts +1 -1
  116. package/src/model/schema.js +1 -1
  117. package/src/model/selection.d.ts +1 -1
  118. package/src/model/selection.js +9 -2
  119. package/src/model/text.d.ts +1 -1
  120. package/src/model/text.js +1 -1
  121. package/src/model/textproxy.d.ts +1 -1
  122. package/src/model/textproxy.js +1 -1
  123. package/src/model/treewalker.d.ts +17 -1
  124. package/src/model/treewalker.js +26 -1
  125. package/src/model/typecheckable.d.ts +1 -1
  126. package/src/model/typecheckable.js +1 -1
  127. package/src/model/utils/autoparagraphing.d.ts +1 -1
  128. package/src/model/utils/autoparagraphing.js +1 -1
  129. package/src/model/utils/deletecontent.d.ts +1 -1
  130. package/src/model/utils/deletecontent.js +1 -1
  131. package/src/model/utils/getselectedcontent.d.ts +1 -1
  132. package/src/model/utils/getselectedcontent.js +1 -1
  133. package/src/model/utils/insertcontent.d.ts +1 -1
  134. package/src/model/utils/insertcontent.js +1 -1
  135. package/src/model/utils/insertobject.d.ts +1 -1
  136. package/src/model/utils/insertobject.js +1 -1
  137. package/src/model/utils/modifyselection.d.ts +1 -1
  138. package/src/model/utils/modifyselection.js +1 -1
  139. package/src/model/utils/selection-post-fixer.d.ts +1 -1
  140. package/src/model/utils/selection-post-fixer.js +1 -1
  141. package/src/model/writer.d.ts +1 -1
  142. package/src/model/writer.js +1 -1
  143. package/src/view/attributeelement.d.ts +1 -1
  144. package/src/view/attributeelement.js +1 -1
  145. package/src/view/containerelement.d.ts +1 -1
  146. package/src/view/containerelement.js +1 -1
  147. package/src/view/datatransfer.d.ts +1 -1
  148. package/src/view/datatransfer.js +1 -1
  149. package/src/view/document.d.ts +1 -1
  150. package/src/view/document.js +1 -1
  151. package/src/view/documentfragment.d.ts +6 -4
  152. package/src/view/documentfragment.js +7 -7
  153. package/src/view/documentselection.d.ts +1 -1
  154. package/src/view/documentselection.js +1 -1
  155. package/src/view/domconverter.d.ts +1 -1
  156. package/src/view/domconverter.js +1 -1
  157. package/src/view/downcastwriter.d.ts +1 -1
  158. package/src/view/downcastwriter.js +1 -1
  159. package/src/view/editableelement.d.ts +1 -1
  160. package/src/view/editableelement.js +1 -1
  161. package/src/view/element.d.ts +1 -1
  162. package/src/view/element.js +3 -3
  163. package/src/view/elementdefinition.d.ts +1 -1
  164. package/src/view/elementdefinition.js +1 -1
  165. package/src/view/emptyelement.d.ts +1 -1
  166. package/src/view/emptyelement.js +1 -1
  167. package/src/view/filler.d.ts +1 -1
  168. package/src/view/filler.js +1 -1
  169. package/src/view/item.d.ts +1 -1
  170. package/src/view/item.js +1 -1
  171. package/src/view/matcher.d.ts +1 -1
  172. package/src/view/matcher.js +1 -1
  173. package/src/view/node.d.ts +13 -4
  174. package/src/view/node.js +5 -4
  175. package/src/view/observer/arrowkeysobserver.d.ts +1 -1
  176. package/src/view/observer/arrowkeysobserver.js +1 -1
  177. package/src/view/observer/bubblingemittermixin.d.ts +1 -1
  178. package/src/view/observer/bubblingemittermixin.js +1 -1
  179. package/src/view/observer/bubblingeventinfo.d.ts +1 -1
  180. package/src/view/observer/bubblingeventinfo.js +1 -1
  181. package/src/view/observer/clickobserver.d.ts +1 -1
  182. package/src/view/observer/clickobserver.js +1 -1
  183. package/src/view/observer/compositionobserver.d.ts +1 -1
  184. package/src/view/observer/compositionobserver.js +1 -1
  185. package/src/view/observer/domeventdata.d.ts +1 -1
  186. package/src/view/observer/domeventdata.js +1 -1
  187. package/src/view/observer/domeventobserver.d.ts +1 -1
  188. package/src/view/observer/domeventobserver.js +1 -1
  189. package/src/view/observer/fakeselectionobserver.d.ts +1 -1
  190. package/src/view/observer/fakeselectionobserver.js +1 -1
  191. package/src/view/observer/focusobserver.d.ts +1 -1
  192. package/src/view/observer/focusobserver.js +1 -1
  193. package/src/view/observer/inputobserver.d.ts +1 -1
  194. package/src/view/observer/inputobserver.js +1 -1
  195. package/src/view/observer/keyobserver.d.ts +1 -1
  196. package/src/view/observer/keyobserver.js +1 -1
  197. package/src/view/observer/mouseobserver.d.ts +1 -1
  198. package/src/view/observer/mouseobserver.js +1 -1
  199. package/src/view/observer/mutationobserver.d.ts +1 -1
  200. package/src/view/observer/mutationobserver.js +1 -1
  201. package/src/view/observer/observer.d.ts +1 -1
  202. package/src/view/observer/observer.js +1 -1
  203. package/src/view/observer/selectionobserver.d.ts +1 -1
  204. package/src/view/observer/selectionobserver.js +1 -1
  205. package/src/view/observer/tabobserver.d.ts +1 -1
  206. package/src/view/observer/tabobserver.js +1 -1
  207. package/src/view/observer/touchobserver.d.ts +73 -0
  208. package/src/view/observer/touchobserver.js +29 -0
  209. package/src/view/placeholder.d.ts +1 -1
  210. package/src/view/placeholder.js +23 -17
  211. package/src/view/position.d.ts +1 -1
  212. package/src/view/position.js +1 -1
  213. package/src/view/range.d.ts +1 -1
  214. package/src/view/range.js +1 -1
  215. package/src/view/rawelement.d.ts +1 -1
  216. package/src/view/rawelement.js +1 -1
  217. package/src/view/renderer.d.ts +1 -1
  218. package/src/view/renderer.js +1 -1
  219. package/src/view/rooteditableelement.d.ts +1 -1
  220. package/src/view/rooteditableelement.js +1 -1
  221. package/src/view/selection.d.ts +1 -1
  222. package/src/view/selection.js +1 -1
  223. package/src/view/styles/background.d.ts +1 -1
  224. package/src/view/styles/background.js +1 -1
  225. package/src/view/styles/border.d.ts +1 -1
  226. package/src/view/styles/border.js +1 -1
  227. package/src/view/styles/margin.d.ts +1 -1
  228. package/src/view/styles/margin.js +1 -1
  229. package/src/view/styles/padding.d.ts +1 -1
  230. package/src/view/styles/padding.js +1 -1
  231. package/src/view/styles/utils.d.ts +1 -1
  232. package/src/view/styles/utils.js +1 -1
  233. package/src/view/stylesmap.d.ts +1 -1
  234. package/src/view/stylesmap.js +1 -1
  235. package/src/view/text.d.ts +1 -1
  236. package/src/view/text.js +1 -1
  237. package/src/view/textproxy.d.ts +1 -1
  238. package/src/view/textproxy.js +1 -1
  239. package/src/view/treewalker.d.ts +17 -1
  240. package/src/view/treewalker.js +25 -1
  241. package/src/view/typecheckable.d.ts +1 -1
  242. package/src/view/typecheckable.js +1 -1
  243. package/src/view/uielement.d.ts +1 -1
  244. package/src/view/uielement.js +1 -1
  245. package/src/view/upcastwriter.d.ts +1 -1
  246. package/src/view/upcastwriter.js +1 -1
  247. package/src/view/view.d.ts +1 -1
  248. package/src/view/view.js +1 -1
  249. package/theme/placeholder.css +1 -1
  250. package/theme/renderer.css +1 -1
  251. package/dist/controller/datacontroller.d.ts +0 -339
  252. package/dist/controller/editingcontroller.d.ts +0 -102
  253. package/dist/conversion/conversion.d.ts +0 -482
  254. package/dist/conversion/conversionhelpers.d.ts +0 -30
  255. package/dist/conversion/downcastdispatcher.d.ts +0 -566
  256. package/dist/conversion/downcasthelpers.d.ts +0 -1194
  257. package/dist/conversion/mapper.d.ts +0 -507
  258. package/dist/conversion/modelconsumable.d.ts +0 -205
  259. package/dist/conversion/upcastdispatcher.d.ts +0 -496
  260. package/dist/conversion/upcasthelpers.d.ts +0 -503
  261. package/dist/conversion/viewconsumable.d.ts +0 -373
  262. package/dist/dataprocessor/basichtmlwriter.d.ts +0 -22
  263. package/dist/dataprocessor/dataprocessor.d.ts +0 -65
  264. package/dist/dataprocessor/htmldataprocessor.d.ts +0 -80
  265. package/dist/dataprocessor/htmlwriter.d.ts +0 -20
  266. package/dist/dataprocessor/xmldataprocessor.d.ts +0 -94
  267. package/dist/dev-utils/model.d.ts +0 -130
  268. package/dist/dev-utils/operationreplayer.d.ts +0 -55
  269. package/dist/dev-utils/utils.d.ts +0 -41
  270. package/dist/dev-utils/view.d.ts +0 -324
  271. package/dist/index.d.ts +0 -122
  272. package/dist/model/batch.d.ts +0 -110
  273. package/dist/model/differ.d.ts +0 -511
  274. package/dist/model/document.d.ts +0 -278
  275. package/dist/model/documentfragment.d.ts +0 -223
  276. package/dist/model/documentselection.d.ts +0 -424
  277. package/dist/model/element.d.ts +0 -191
  278. package/dist/model/history.d.ts +0 -118
  279. package/dist/model/item.d.ts +0 -18
  280. package/dist/model/liveposition.d.ts +0 -81
  281. package/dist/model/liverange.d.ts +0 -106
  282. package/dist/model/markercollection.d.ts +0 -339
  283. package/dist/model/model.d.ts +0 -923
  284. package/dist/model/node.d.ts +0 -262
  285. package/dist/model/nodelist.d.ts +0 -119
  286. package/dist/model/operation/attributeoperation.d.ts +0 -107
  287. package/dist/model/operation/detachoperation.d.ts +0 -64
  288. package/dist/model/operation/insertoperation.d.ts +0 -94
  289. package/dist/model/operation/markeroperation.d.ts +0 -95
  290. package/dist/model/operation/mergeoperation.d.ts +0 -104
  291. package/dist/model/operation/moveoperation.d.ts +0 -100
  292. package/dist/model/operation/nooperation.d.ts +0 -42
  293. package/dist/model/operation/operation.d.ts +0 -100
  294. package/dist/model/operation/operationfactory.d.ts +0 -22
  295. package/dist/model/operation/renameoperation.d.ts +0 -87
  296. package/dist/model/operation/rootattributeoperation.d.ts +0 -102
  297. package/dist/model/operation/rootoperation.d.ts +0 -80
  298. package/dist/model/operation/splitoperation.d.ts +0 -113
  299. package/dist/model/operation/transform.d.ts +0 -104
  300. package/dist/model/operation/utils.d.ts +0 -75
  301. package/dist/model/position.d.ts +0 -549
  302. package/dist/model/range.d.ts +0 -462
  303. package/dist/model/rootelement.d.ts +0 -64
  304. package/dist/model/schema.d.ts +0 -1334
  305. package/dist/model/selection.d.ts +0 -486
  306. package/dist/model/text.d.ts +0 -70
  307. package/dist/model/textproxy.d.ts +0 -148
  308. package/dist/model/treewalker.d.ts +0 -190
  309. package/dist/model/typecheckable.d.ts +0 -289
  310. package/dist/model/utils/autoparagraphing.d.ts +0 -41
  311. package/dist/model/utils/deletecontent.d.ts +0 -62
  312. package/dist/model/utils/getselectedcontent.d.ts +0 -34
  313. package/dist/model/utils/insertcontent.d.ts +0 -50
  314. package/dist/model/utils/insertobject.d.ts +0 -51
  315. package/dist/model/utils/modifyselection.d.ts +0 -52
  316. package/dist/model/utils/selection-post-fixer.d.ts +0 -78
  317. package/dist/model/writer.d.ts +0 -855
  318. package/dist/view/attributeelement.d.ts +0 -112
  319. package/dist/view/containerelement.d.ts +0 -53
  320. package/dist/view/datatransfer.d.ts +0 -83
  321. package/dist/view/document.d.ts +0 -188
  322. package/dist/view/documentfragment.d.ts +0 -157
  323. package/dist/view/documentselection.d.ts +0 -310
  324. package/dist/view/domconverter.d.ts +0 -665
  325. package/dist/view/downcastwriter.d.ts +0 -1000
  326. package/dist/view/editableelement.d.ts +0 -66
  327. package/dist/view/element.d.ts +0 -472
  328. package/dist/view/elementdefinition.d.ts +0 -91
  329. package/dist/view/emptyelement.d.ts +0 -45
  330. package/dist/view/filler.d.ts +0 -115
  331. package/dist/view/item.d.ts +0 -18
  332. package/dist/view/matcher.d.ts +0 -490
  333. package/dist/view/node.d.ts +0 -166
  334. package/dist/view/observer/arrowkeysobserver.d.ts +0 -49
  335. package/dist/view/observer/bubblingemittermixin.d.ts +0 -170
  336. package/dist/view/observer/bubblingeventinfo.d.ts +0 -51
  337. package/dist/view/observer/clickobserver.d.ts +0 -47
  338. package/dist/view/observer/compositionobserver.d.ts +0 -86
  339. package/dist/view/observer/domeventdata.d.ts +0 -54
  340. package/dist/view/observer/domeventobserver.d.ts +0 -82
  341. package/dist/view/observer/fakeselectionobserver.d.ts +0 -51
  342. package/dist/view/observer/focusobserver.d.ts +0 -98
  343. package/dist/view/observer/inputobserver.d.ts +0 -90
  344. package/dist/view/observer/keyobserver.d.ts +0 -70
  345. package/dist/view/observer/mouseobserver.d.ts +0 -93
  346. package/dist/view/observer/mutationobserver.d.ts +0 -119
  347. package/dist/view/observer/observer.d.ts +0 -93
  348. package/dist/view/observer/selectionobserver.d.ts +0 -151
  349. package/dist/view/observer/tabobserver.d.ts +0 -50
  350. package/dist/view/placeholder.d.ts +0 -100
  351. package/dist/view/position.d.ts +0 -192
  352. package/dist/view/range.d.ts +0 -283
  353. package/dist/view/rawelement.d.ts +0 -77
  354. package/dist/view/renderer.d.ts +0 -281
  355. package/dist/view/rooteditableelement.d.ts +0 -45
  356. package/dist/view/selection.d.ts +0 -379
  357. package/dist/view/styles/background.d.ts +0 -37
  358. package/dist/view/styles/border.d.ts +0 -47
  359. package/dist/view/styles/margin.d.ts +0 -33
  360. package/dist/view/styles/padding.d.ts +0 -33
  361. package/dist/view/styles/utils.d.ts +0 -97
  362. package/dist/view/stylesmap.d.ts +0 -685
  363. package/dist/view/text.d.ts +0 -78
  364. package/dist/view/textproxy.d.ts +0 -101
  365. package/dist/view/treewalker.d.ts +0 -199
  366. package/dist/view/typecheckable.d.ts +0 -452
  367. package/dist/view/uielement.d.ts +0 -100
  368. package/dist/view/upcastwriter.d.ts +0 -421
  369. package/dist/view/view.d.ts +0 -488
@@ -1,507 +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/conversion/mapper
11
- */
12
- import ModelPosition from '../model/position.js';
13
- import ModelRange from '../model/range.js';
14
- import ViewPosition from '../view/position.js';
15
- import ViewRange from '../view/range.js';
16
- import type ViewDocumentFragment from '../view/documentfragment.js';
17
- import type ViewElement from '../view/element.js';
18
- import type ModelElement from '../model/element.js';
19
- import type ModelDocumentFragment from '../model/documentfragment.js';
20
- import type ViewNode from '../view/node.js';
21
- declare const Mapper_base: {
22
- new (): import("@ckeditor/ckeditor5-utils").Emitter;
23
- prototype: import("@ckeditor/ckeditor5-utils").Emitter;
24
- };
25
- /**
26
- * Maps elements, positions and markers between the {@link module:engine/view/document~Document view} and
27
- * the {@link module:engine/model/model model}.
28
- *
29
- * The instance of the Mapper used for the editing pipeline is available in
30
- * {@link module:engine/controller/editingcontroller~EditingController#mapper `editor.editing.mapper`}.
31
- *
32
- * Mapper uses bound elements to find corresponding elements and positions, so, to get proper results,
33
- * all model elements should be {@link module:engine/conversion/mapper~Mapper#bindElements bound}.
34
- *
35
- * To map the complex model to/from view relations, you may provide custom callbacks for the
36
- * {@link module:engine/conversion/mapper~Mapper#event:modelToViewPosition modelToViewPosition event} and
37
- * {@link module:engine/conversion/mapper~Mapper#event:viewToModelPosition viewToModelPosition event} that are fired whenever
38
- * a position mapping request occurs.
39
- * Those events are fired by the {@link module:engine/conversion/mapper~Mapper#toViewPosition toViewPosition}
40
- * and {@link module:engine/conversion/mapper~Mapper#toModelPosition toModelPosition} methods. `Mapper` adds its own default callbacks
41
- * with `'lowest'` priority. To override default `Mapper` mapping, add custom callback with higher priority and
42
- * stop the event.
43
- */
44
- export default class Mapper extends /* #__PURE__ */ Mapper_base {
45
- /**
46
- * Model element to view element mapping.
47
- */
48
- private _modelToViewMapping;
49
- /**
50
- * View element to model element mapping.
51
- */
52
- private _viewToModelMapping;
53
- /**
54
- * A map containing callbacks between view element names and functions evaluating length of view elements
55
- * in model.
56
- */
57
- private _viewToModelLengthCallbacks;
58
- /**
59
- * Model marker name to view elements mapping.
60
- *
61
- * Keys are `String`s while values are `Set`s with {@link module:engine/view/element~Element view elements}.
62
- * One marker (name) can be mapped to multiple elements.
63
- */
64
- private _markerNameToElements;
65
- /**
66
- * View element to model marker names mapping.
67
- *
68
- * This is reverse to {@link ~Mapper#_markerNameToElements} map.
69
- */
70
- private _elementToMarkerNames;
71
- /**
72
- * The map of removed view elements with their current root (used for deferred unbinding).
73
- */
74
- private _deferredBindingRemovals;
75
- /**
76
- * Stores marker names of markers which have changed due to unbinding a view element (so it is assumed that the view element
77
- * has been removed, moved or renamed).
78
- */
79
- private _unboundMarkerNames;
80
- /**
81
- * Creates an instance of the mapper.
82
- */
83
- constructor();
84
- /**
85
- * Marks model and view elements as corresponding. Corresponding elements can be retrieved by using
86
- * the {@link module:engine/conversion/mapper~Mapper#toModelElement toModelElement} and
87
- * {@link module:engine/conversion/mapper~Mapper#toViewElement toViewElement} methods.
88
- * The information that elements are bound is also used to translate positions.
89
- *
90
- * @param modelElement Model element.
91
- * @param viewElement View element.
92
- */
93
- bindElements(modelElement: ModelElement | ModelDocumentFragment, viewElement: ViewElement | ViewDocumentFragment): void;
94
- /**
95
- * Unbinds the given {@link module:engine/view/element~Element view element} from the map.
96
- *
97
- * **Note:** view-to-model binding will be removed, if it existed. However, corresponding model-to-view binding
98
- * will be removed only if model element is still bound to the passed `viewElement`.
99
- *
100
- * This behavior allows for re-binding model element to another view element without fear of losing the new binding
101
- * when the previously bound view element is unbound.
102
- *
103
- * @param viewElement View element to unbind.
104
- * @param options The options object.
105
- * @param options.defer Controls whether the binding should be removed immediately or deferred until a
106
- * {@link #flushDeferredBindings `flushDeferredBindings()`} call.
107
- */
108
- unbindViewElement(viewElement: ViewElement, options?: {
109
- defer?: boolean;
110
- }): void;
111
- /**
112
- * Unbinds the given {@link module:engine/model/element~Element model element} from the map.
113
- *
114
- * **Note:** the model-to-view binding will be removed, if it existed. However, the corresponding view-to-model binding
115
- * will be removed only if the view element is still bound to the passed `modelElement`.
116
- *
117
- * This behavior lets for re-binding view element to another model element without fear of losing the new binding
118
- * when the previously bound model element is unbound.
119
- *
120
- * @param modelElement Model element to unbind.
121
- */
122
- unbindModelElement(modelElement: ModelElement): void;
123
- /**
124
- * Binds the given marker name with the given {@link module:engine/view/element~Element view element}. The element
125
- * will be added to the current set of elements bound with the given marker name.
126
- *
127
- * @param element Element to bind.
128
- * @param name Marker name.
129
- */
130
- bindElementToMarker(element: ViewElement, name: string): void;
131
- /**
132
- * Unbinds an element from given marker name.
133
- *
134
- * @param element Element to unbind.
135
- * @param name Marker name.
136
- */
137
- unbindElementFromMarkerName(element: ViewElement, name: string): void;
138
- /**
139
- * Returns all marker names of markers which have changed due to unbinding a view element (so it is assumed that the view element
140
- * has been removed, moved or renamed) since the last flush. After returning, the marker names list is cleared.
141
- */
142
- flushUnboundMarkerNames(): Array<string>;
143
- /**
144
- * Unbinds all deferred binding removals of view elements that in the meantime were not re-attached to some root or document fragment.
145
- *
146
- * See: {@link #unbindViewElement `unbindViewElement()`}.
147
- */
148
- flushDeferredBindings(): void;
149
- /**
150
- * Removes all model to view and view to model bindings.
151
- */
152
- clearBindings(): void;
153
- /**
154
- * Gets the corresponding model element.
155
- *
156
- * **Note:** {@link module:engine/view/uielement~UIElement} does not have corresponding element in model.
157
- *
158
- * @label ELEMENT
159
- * @param viewElement View element.
160
- * @returns Corresponding model element or `undefined` if not found.
161
- */
162
- toModelElement(viewElement: ViewElement): ModelElement | undefined;
163
- /**
164
- * Gets the corresponding model document fragment.
165
- *
166
- * @label DOCUMENT_FRAGMENT
167
- * @param viewDocumentFragment View document fragment.
168
- * @returns Corresponding model document fragment or `undefined` if not found.
169
- */
170
- toModelElement(viewDocumentFragment: ViewDocumentFragment): ModelDocumentFragment | undefined;
171
- /**
172
- * Gets the corresponding view element.
173
- *
174
- * @label ELEMENT
175
- * @param modelElement Model element.
176
- * @returns Corresponding view element or `undefined` if not found.
177
- */
178
- toViewElement(modelElement: ModelElement): ViewElement | undefined;
179
- /**
180
- * Gets the corresponding view document fragment.
181
- *
182
- * @label DOCUMENT_FRAGMENT
183
- * @param modelDocumentFragment Model document fragment.
184
- * @returns Corresponding view document fragment or `undefined` if not found.
185
- */
186
- toViewElement(modelDocumentFragment: ModelDocumentFragment): ViewDocumentFragment | undefined;
187
- /**
188
- * Gets the corresponding model range.
189
- *
190
- * @param viewRange View range.
191
- * @returns Corresponding model range.
192
- */
193
- toModelRange(viewRange: ViewRange): ModelRange;
194
- /**
195
- * Gets the corresponding view range.
196
- *
197
- * @param modelRange Model range.
198
- * @returns Corresponding view range.
199
- */
200
- toViewRange(modelRange: ModelRange): ViewRange;
201
- /**
202
- * Gets the corresponding model position.
203
- *
204
- * @fires viewToModelPosition
205
- * @param viewPosition View position.
206
- * @returns Corresponding model position.
207
- */
208
- toModelPosition(viewPosition: ViewPosition): ModelPosition;
209
- /**
210
- * Gets the corresponding view position.
211
- *
212
- * @fires modelToViewPosition
213
- * @param modelPosition Model position.
214
- * @param options Additional options for position mapping process.
215
- * @param options.isPhantom Should be set to `true` if the model position to map is pointing to a place
216
- * in model tree which no longer exists. For example, it could be an end of a removed model range.
217
- * @returns Corresponding view position.
218
- */
219
- toViewPosition(modelPosition: ModelPosition, options?: {
220
- isPhantom?: boolean;
221
- }): ViewPosition;
222
- /**
223
- * Gets all view elements bound to the given marker name.
224
- *
225
- * @param name Marker name.
226
- * @returns View elements bound with the given marker name or `null`
227
- * if no elements are bound to the given marker name.
228
- */
229
- markerNameToElements(name: string): Set<ViewElement> | null;
230
- /**
231
- * Registers a callback that evaluates the length in the model of a view element with the given name.
232
- *
233
- * The callback is fired with one argument, which is a view element instance. The callback is expected to return
234
- * a number representing the length of the view element in the model.
235
- *
236
- * ```ts
237
- * // List item in view may contain nested list, which have other list items. In model though,
238
- * // the lists are represented by flat structure. Because of those differences, length of list view element
239
- * // may be greater than one. In the callback it's checked how many nested list items are in evaluated list item.
240
- *
241
- * function getViewListItemLength( element ) {
242
- * let length = 1;
243
- *
244
- * for ( let child of element.getChildren() ) {
245
- * if ( child.name == 'ul' || child.name == 'ol' ) {
246
- * for ( let item of child.getChildren() ) {
247
- * length += getViewListItemLength( item );
248
- * }
249
- * }
250
- * }
251
- *
252
- * return length;
253
- * }
254
- *
255
- * mapper.registerViewToModelLength( 'li', getViewListItemLength );
256
- * ```
257
- *
258
- * @param viewElementName Name of view element for which callback is registered.
259
- * @param lengthCallback Function return a length of view element instance in model.
260
- */
261
- registerViewToModelLength(viewElementName: string, lengthCallback: (element: ViewElement) => number): void;
262
- /**
263
- * For the given `viewPosition`, finds and returns the closest ancestor of this position that has a mapping to
264
- * the model.
265
- *
266
- * @param viewPosition Position for which a mapped ancestor should be found.
267
- */
268
- findMappedViewAncestor(viewPosition: ViewPosition): ViewElement;
269
- /**
270
- * Calculates model offset based on the view position and the block element.
271
- *
272
- * Example:
273
- *
274
- * ```html
275
- * <p>foo<b>ba|r</b></p> // _toModelOffset( b, 2, p ) -> 5
276
- * ```
277
- *
278
- * Is a sum of:
279
- *
280
- * ```html
281
- * <p>foo|<b>bar</b></p> // _toModelOffset( p, 3, p ) -> 3
282
- * <p>foo<b>ba|r</b></p> // _toModelOffset( b, 2, b ) -> 2
283
- * ```
284
- *
285
- * @param viewParent Position parent.
286
- * @param viewOffset Position offset.
287
- * @param viewBlock Block used as a base to calculate offset.
288
- * @returns Offset in the model.
289
- */
290
- private _toModelOffset;
291
- /**
292
- * Gets the length of the view element in the model.
293
- *
294
- * The length is calculated as follows:
295
- * * if a {@link #registerViewToModelLength length mapping callback} is provided for the given `viewNode`, it is used to
296
- * evaluate the model length (`viewNode` is used as first and only parameter passed to the callback),
297
- * * length of a {@link module:engine/view/text~Text text node} is equal to the length of its
298
- * {@link module:engine/view/text~Text#data data},
299
- * * length of a {@link module:engine/view/uielement~UIElement ui element} is equal to 0,
300
- * * length of a mapped {@link module:engine/view/element~Element element} is equal to 1,
301
- * * length of a non-mapped {@link module:engine/view/element~Element element} is equal to the length of its children.
302
- *
303
- * Examples:
304
- *
305
- * ```
306
- * foo -> 3 // Text length is equal to its data length.
307
- * <p>foo</p> -> 1 // Length of an element which is mapped is by default equal to 1.
308
- * <b>foo</b> -> 3 // Length of an element which is not mapped is a length of its children.
309
- * <div><p>x</p><p>y</p></div> -> 2 // Assuming that <div> is not mapped and <p> are mapped.
310
- * ```
311
- *
312
- * @param viewNode View node.
313
- * @returns Length of the node in the tree model.
314
- */
315
- getModelLength(viewNode: ViewNode | ViewDocumentFragment): number;
316
- /**
317
- * Finds the position in the view node (or in its children) with the expected model offset.
318
- *
319
- * Example:
320
- *
321
- * ```
322
- * <p>fo<b>bar</b>bom</p> -> expected offset: 4
323
- *
324
- * findPositionIn( p, 4 ):
325
- * <p>|fo<b>bar</b>bom</p> -> expected offset: 4, actual offset: 0
326
- * <p>fo|<b>bar</b>bom</p> -> expected offset: 4, actual offset: 2
327
- * <p>fo<b>bar</b>|bom</p> -> expected offset: 4, actual offset: 5 -> we are too far
328
- *
329
- * findPositionIn( b, 4 - ( 5 - 3 ) ):
330
- * <p>fo<b>|bar</b>bom</p> -> expected offset: 2, actual offset: 0
331
- * <p>fo<b>bar|</b>bom</p> -> expected offset: 2, actual offset: 3 -> we are too far
332
- *
333
- * findPositionIn( bar, 2 - ( 3 - 3 ) ):
334
- * We are in the text node so we can simple find the offset.
335
- * <p>fo<b>ba|r</b>bom</p> -> expected offset: 2, actual offset: 2 -> position found
336
- * ```
337
- *
338
- * @param viewParent Tree view element in which we are looking for the position.
339
- * @param expectedOffset Expected offset.
340
- * @returns Found position.
341
- */
342
- findPositionIn(viewParent: ViewNode | ViewDocumentFragment, expectedOffset: number): ViewPosition;
343
- /**
344
- * Because we prefer positions in the text nodes over positions next to text nodes, if the view position was next to a text node,
345
- * it moves it into the text node instead.
346
- *
347
- * ```
348
- * <p>[]<b>foo</b></p> -> <p>[]<b>foo</b></p> // do not touch if position is not directly next to text
349
- * <p>foo[]<b>foo</b></p> -> <p>foo{}<b>foo</b></p> // move to text node
350
- * <p><b>[]foo</b></p> -> <p><b>{}foo</b></p> // move to text node
351
- * ```
352
- *
353
- * @param viewPosition Position potentially next to the text node.
354
- * @returns Position in the text node if possible.
355
- */
356
- private _moveViewPositionToTextNode;
357
- }
358
- /**
359
- * Fired for each model-to-view position mapping request. The purpose of this event is to enable custom model-to-view position
360
- * mapping. Callbacks added to this event take {@link module:engine/model/position~Position model position} and are expected to
361
- * calculate the {@link module:engine/view/position~Position view position}. The calculated view position should be added as
362
- * a `viewPosition` value in the `data` object that is passed as one of parameters to the event callback.
363
- *
364
- * ```ts
365
- * // Assume that "captionedImage" model element is converted to <img> and following <span> elements in view,
366
- * // and the model element is bound to <img> element. Force mapping model positions inside "captionedImage" to that
367
- * // <span> element.
368
- * mapper.on( 'modelToViewPosition', ( evt, data ) => {
369
- * const positionParent = modelPosition.parent;
370
- *
371
- * if ( positionParent.name == 'captionedImage' ) {
372
- * const viewImg = data.mapper.toViewElement( positionParent );
373
- * const viewCaption = viewImg.nextSibling; // The <span> element.
374
- *
375
- * data.viewPosition = new ViewPosition( viewCaption, modelPosition.offset );
376
- *
377
- * // Stop the event if other callbacks should not modify calculated value.
378
- * evt.stop();
379
- * }
380
- * } );
381
- * ```
382
- *
383
- * **Note:** keep in mind that sometimes a "phantom" model position is being converted. A "phantom" model position is
384
- * a position that points to a nonexistent place in model. Such a position might still be valid for conversion, though
385
- * (it would point to a correct place in the view when converted). One example of such a situation is when a range is
386
- * removed from the model, there may be a need to map the range's end (which is no longer a valid model position). To
387
- * handle such situations, check the `data.isPhantom` flag:
388
- *
389
- * ```ts
390
- * // Assume that there is a "customElement" model element and whenever the position is before it,
391
- * // we want to move it to the inside of the view element bound to "customElement".
392
- * mapper.on( 'modelToViewPosition', ( evt, data ) => {
393
- * if ( data.isPhantom ) {
394
- * return;
395
- * }
396
- *
397
- * // Below line might crash for phantom position that does not exist in model.
398
- * const sibling = data.modelPosition.nodeBefore;
399
- *
400
- * // Check if this is the element we are interested in.
401
- * if ( !sibling.is( 'element', 'customElement' ) ) {
402
- * return;
403
- * }
404
- *
405
- * const viewElement = data.mapper.toViewElement( sibling );
406
- *
407
- * data.viewPosition = new ViewPosition( sibling, 0 );
408
- *
409
- * evt.stop();
410
- * } );
411
- * ```
412
- *
413
- * **Note:** the default mapping callback is provided with a `low` priority setting and does not cancel the event, so it is possible to
414
- * attach a custom callback after a default callback and also use `data.viewPosition` calculated by the default callback
415
- * (for example to fix it).
416
- *
417
- * **Note:** the default mapping callback will not fire if `data.viewPosition` is already set.
418
- *
419
- * **Note:** these callbacks are called **very often**. For efficiency reasons, it is advised to use them only when position
420
- * mapping between the given model and view elements is unsolvable by using just elements mapping and default algorithm.
421
- * Also, the condition that checks if a special case scenario happened should be as simple as possible.
422
- *
423
- * @eventName ~Mapper#modelToViewPosition
424
- */
425
- export type MapperModelToViewPositionEvent = {
426
- name: 'modelToViewPosition';
427
- args: [MapperModelToViewPositionEventData];
428
- };
429
- /**
430
- * Data pipeline object that can store and pass data between callbacks. The callback should add
431
- * the `viewPosition` value to that object with calculated the {@link module:engine/view/position~Position view position}.
432
- */
433
- export type MapperModelToViewPositionEventData = {
434
- /**
435
- * Mapper instance that fired the event.
436
- */
437
- mapper: Mapper;
438
- /**
439
- * The model position.
440
- */
441
- modelPosition: ModelPosition;
442
- /**
443
- * The callback should add the `viewPosition` value to that object with calculated the
444
- * {@link module:engine/view/position~Position view position}.
445
- */
446
- viewPosition?: ViewPosition;
447
- /**
448
- * Should be set to `true` if the model position to map is pointing to a place
449
- * in model tree which no longer exists. For example, it could be an end of a removed model range.
450
- */
451
- isPhantom?: boolean;
452
- };
453
- /**
454
- * Fired for each view-to-model position mapping request. See {@link module:engine/conversion/mapper~Mapper#event:modelToViewPosition}.
455
- *
456
- * ```ts
457
- * // See example in `modelToViewPosition` event description.
458
- * // This custom mapping will map positions from <span> element next to <img> to the "captionedImage" element.
459
- * mapper.on( 'viewToModelPosition', ( evt, data ) => {
460
- * const positionParent = viewPosition.parent;
461
- *
462
- * if ( positionParent.hasClass( 'image-caption' ) ) {
463
- * const viewImg = positionParent.previousSibling;
464
- * const modelImg = data.mapper.toModelElement( viewImg );
465
- *
466
- * data.modelPosition = new ModelPosition( modelImg, viewPosition.offset );
467
- * evt.stop();
468
- * }
469
- * } );
470
- * ```
471
- *
472
- * **Note:** the default mapping callback is provided with a `low` priority setting and does not cancel the event, so it is possible to
473
- * attach a custom callback after the default callback and also use `data.modelPosition` calculated by the default callback
474
- * (for example to fix it).
475
- *
476
- * **Note:** the default mapping callback will not fire if `data.modelPosition` is already set.
477
- *
478
- * **Note:** these callbacks are called **very often**. For efficiency reasons, it is advised to use them only when position
479
- * mapping between the given model and view elements is unsolvable by using just elements mapping and default algorithm.
480
- * Also, the condition that checks if special case scenario happened should be as simple as possible.
481
- *
482
- * @eventName ~Mapper#viewToModelPosition
483
- */
484
- export type MapperViewToModelPositionEvent = {
485
- name: 'viewToModelPosition';
486
- args: [MapperViewToModelPositionEventData];
487
- };
488
- /**
489
- * Data pipeline object that can store and pass data between callbacks. The callback should add
490
- * `modelPosition` value to that object with calculated {@link module:engine/model/position~Position model position}.
491
- */
492
- export type MapperViewToModelPositionEventData = {
493
- /**
494
- * Mapper instance that fired the event.
495
- */
496
- mapper: Mapper;
497
- /**
498
- * The callback should add `modelPosition` value to that object with calculated
499
- * {@link module:engine/model/position~Position model position}.
500
- */
501
- modelPosition?: ModelPosition;
502
- /**
503
- * The view position.
504
- */
505
- viewPosition: ViewPosition;
506
- };
507
- export {};