@ckeditor/ckeditor5-engine 0.0.0-internal-20241017.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/CHANGELOG.md +4 -0
  2. package/LICENSE.md +21 -0
  3. package/README.md +36 -0
  4. package/dist/controller/datacontroller.d.ts +339 -0
  5. package/dist/controller/editingcontroller.d.ts +102 -0
  6. package/dist/conversion/conversion.d.ts +482 -0
  7. package/dist/conversion/conversionhelpers.d.ts +30 -0
  8. package/dist/conversion/downcastdispatcher.d.ts +566 -0
  9. package/dist/conversion/downcasthelpers.d.ts +1194 -0
  10. package/dist/conversion/mapper.d.ts +507 -0
  11. package/dist/conversion/modelconsumable.d.ts +205 -0
  12. package/dist/conversion/upcastdispatcher.d.ts +496 -0
  13. package/dist/conversion/upcasthelpers.d.ts +503 -0
  14. package/dist/conversion/viewconsumable.d.ts +373 -0
  15. package/dist/dataprocessor/basichtmlwriter.d.ts +22 -0
  16. package/dist/dataprocessor/dataprocessor.d.ts +65 -0
  17. package/dist/dataprocessor/htmldataprocessor.d.ts +80 -0
  18. package/dist/dataprocessor/htmlwriter.d.ts +20 -0
  19. package/dist/dataprocessor/xmldataprocessor.d.ts +94 -0
  20. package/dist/dev-utils/model.d.ts +130 -0
  21. package/dist/dev-utils/operationreplayer.d.ts +55 -0
  22. package/dist/dev-utils/utils.d.ts +41 -0
  23. package/dist/dev-utils/view.d.ts +324 -0
  24. package/dist/index-content.css +4 -0
  25. package/dist/index-editor.css +24 -0
  26. package/dist/index.css +49 -0
  27. package/dist/index.css.map +1 -0
  28. package/dist/index.d.ts +122 -0
  29. package/dist/index.js +37775 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/model/batch.d.ts +110 -0
  32. package/dist/model/differ.d.ts +511 -0
  33. package/dist/model/document.d.ts +278 -0
  34. package/dist/model/documentfragment.d.ts +204 -0
  35. package/dist/model/documentselection.d.ts +424 -0
  36. package/dist/model/element.d.ts +169 -0
  37. package/dist/model/history.d.ts +118 -0
  38. package/dist/model/item.d.ts +18 -0
  39. package/dist/model/liveposition.d.ts +81 -0
  40. package/dist/model/liverange.d.ts +106 -0
  41. package/dist/model/markercollection.d.ts +339 -0
  42. package/dist/model/model.d.ts +923 -0
  43. package/dist/model/node.d.ts +259 -0
  44. package/dist/model/nodelist.d.ts +95 -0
  45. package/dist/model/operation/attributeoperation.d.ts +107 -0
  46. package/dist/model/operation/detachoperation.d.ts +64 -0
  47. package/dist/model/operation/insertoperation.d.ts +94 -0
  48. package/dist/model/operation/markeroperation.d.ts +95 -0
  49. package/dist/model/operation/mergeoperation.d.ts +104 -0
  50. package/dist/model/operation/moveoperation.d.ts +100 -0
  51. package/dist/model/operation/nooperation.d.ts +42 -0
  52. package/dist/model/operation/operation.d.ts +100 -0
  53. package/dist/model/operation/operationfactory.d.ts +22 -0
  54. package/dist/model/operation/renameoperation.d.ts +87 -0
  55. package/dist/model/operation/rootattributeoperation.d.ts +102 -0
  56. package/dist/model/operation/rootoperation.d.ts +80 -0
  57. package/dist/model/operation/splitoperation.d.ts +113 -0
  58. package/dist/model/operation/transform.d.ts +104 -0
  59. package/dist/model/operation/utils.d.ts +75 -0
  60. package/dist/model/position.d.ts +542 -0
  61. package/dist/model/range.d.ts +462 -0
  62. package/dist/model/rootelement.d.ts +64 -0
  63. package/dist/model/schema.d.ts +1334 -0
  64. package/dist/model/selection.d.ts +486 -0
  65. package/dist/model/text.d.ts +70 -0
  66. package/dist/model/textproxy.d.ts +148 -0
  67. package/dist/model/treewalker.d.ts +190 -0
  68. package/dist/model/typecheckable.d.ts +289 -0
  69. package/dist/model/utils/autoparagraphing.d.ts +41 -0
  70. package/dist/model/utils/deletecontent.d.ts +62 -0
  71. package/dist/model/utils/getselectedcontent.d.ts +34 -0
  72. package/dist/model/utils/insertcontent.d.ts +50 -0
  73. package/dist/model/utils/insertobject.d.ts +51 -0
  74. package/dist/model/utils/modifyselection.d.ts +52 -0
  75. package/dist/model/utils/selection-post-fixer.d.ts +78 -0
  76. package/dist/model/writer.d.ts +855 -0
  77. package/dist/view/attributeelement.d.ts +112 -0
  78. package/dist/view/containerelement.d.ts +53 -0
  79. package/dist/view/datatransfer.d.ts +83 -0
  80. package/dist/view/document.d.ts +188 -0
  81. package/dist/view/documentfragment.d.ts +157 -0
  82. package/dist/view/documentselection.d.ts +310 -0
  83. package/dist/view/domconverter.d.ts +665 -0
  84. package/dist/view/downcastwriter.d.ts +1000 -0
  85. package/dist/view/editableelement.d.ts +66 -0
  86. package/dist/view/element.d.ts +472 -0
  87. package/dist/view/elementdefinition.d.ts +91 -0
  88. package/dist/view/emptyelement.d.ts +45 -0
  89. package/dist/view/filler.d.ts +115 -0
  90. package/dist/view/item.d.ts +18 -0
  91. package/dist/view/matcher.d.ts +490 -0
  92. package/dist/view/node.d.ts +166 -0
  93. package/dist/view/observer/arrowkeysobserver.d.ts +49 -0
  94. package/dist/view/observer/bubblingemittermixin.d.ts +170 -0
  95. package/dist/view/observer/bubblingeventinfo.d.ts +51 -0
  96. package/dist/view/observer/clickobserver.d.ts +47 -0
  97. package/dist/view/observer/compositionobserver.d.ts +86 -0
  98. package/dist/view/observer/domeventdata.d.ts +54 -0
  99. package/dist/view/observer/domeventobserver.d.ts +82 -0
  100. package/dist/view/observer/fakeselectionobserver.d.ts +51 -0
  101. package/dist/view/observer/focusobserver.d.ts +98 -0
  102. package/dist/view/observer/inputobserver.d.ts +90 -0
  103. package/dist/view/observer/keyobserver.d.ts +70 -0
  104. package/dist/view/observer/mouseobserver.d.ts +93 -0
  105. package/dist/view/observer/mutationobserver.d.ts +119 -0
  106. package/dist/view/observer/observer.d.ts +93 -0
  107. package/dist/view/observer/selectionobserver.d.ts +151 -0
  108. package/dist/view/observer/tabobserver.d.ts +50 -0
  109. package/dist/view/placeholder.d.ts +100 -0
  110. package/dist/view/position.d.ts +192 -0
  111. package/dist/view/range.d.ts +283 -0
  112. package/dist/view/rawelement.d.ts +77 -0
  113. package/dist/view/renderer.d.ts +281 -0
  114. package/dist/view/rooteditableelement.d.ts +45 -0
  115. package/dist/view/selection.d.ts +379 -0
  116. package/dist/view/styles/background.d.ts +37 -0
  117. package/dist/view/styles/border.d.ts +47 -0
  118. package/dist/view/styles/margin.d.ts +33 -0
  119. package/dist/view/styles/padding.d.ts +33 -0
  120. package/dist/view/styles/utils.d.ts +97 -0
  121. package/dist/view/stylesmap.d.ts +677 -0
  122. package/dist/view/text.d.ts +78 -0
  123. package/dist/view/textproxy.d.ts +101 -0
  124. package/dist/view/treewalker.d.ts +199 -0
  125. package/dist/view/typecheckable.d.ts +452 -0
  126. package/dist/view/uielement.d.ts +100 -0
  127. package/dist/view/upcastwriter.d.ts +421 -0
  128. package/dist/view/view.d.ts +488 -0
  129. package/package.json +49 -0
  130. package/src/controller/datacontroller.d.ts +335 -0
  131. package/src/controller/datacontroller.js +481 -0
  132. package/src/controller/editingcontroller.d.ts +98 -0
  133. package/src/controller/editingcontroller.js +191 -0
  134. package/src/conversion/conversion.d.ts +478 -0
  135. package/src/conversion/conversion.js +601 -0
  136. package/src/conversion/conversionhelpers.d.ts +26 -0
  137. package/src/conversion/conversionhelpers.js +32 -0
  138. package/src/conversion/downcastdispatcher.d.ts +562 -0
  139. package/src/conversion/downcastdispatcher.js +548 -0
  140. package/src/conversion/downcasthelpers.d.ts +1190 -0
  141. package/src/conversion/downcasthelpers.js +2161 -0
  142. package/src/conversion/mapper.d.ts +503 -0
  143. package/src/conversion/mapper.js +536 -0
  144. package/src/conversion/modelconsumable.d.ts +201 -0
  145. package/src/conversion/modelconsumable.js +333 -0
  146. package/src/conversion/upcastdispatcher.d.ts +492 -0
  147. package/src/conversion/upcastdispatcher.js +460 -0
  148. package/src/conversion/upcasthelpers.d.ts +499 -0
  149. package/src/conversion/upcasthelpers.js +943 -0
  150. package/src/conversion/viewconsumable.d.ts +369 -0
  151. package/src/conversion/viewconsumable.js +535 -0
  152. package/src/dataprocessor/basichtmlwriter.d.ts +18 -0
  153. package/src/dataprocessor/basichtmlwriter.js +20 -0
  154. package/src/dataprocessor/dataprocessor.d.ts +61 -0
  155. package/src/dataprocessor/dataprocessor.js +5 -0
  156. package/src/dataprocessor/htmldataprocessor.d.ts +76 -0
  157. package/src/dataprocessor/htmldataprocessor.js +96 -0
  158. package/src/dataprocessor/htmlwriter.d.ts +16 -0
  159. package/src/dataprocessor/htmlwriter.js +5 -0
  160. package/src/dataprocessor/xmldataprocessor.d.ts +90 -0
  161. package/src/dataprocessor/xmldataprocessor.js +108 -0
  162. package/src/dev-utils/model.d.ts +126 -0
  163. package/src/dev-utils/model.js +397 -0
  164. package/src/dev-utils/operationreplayer.d.ts +51 -0
  165. package/src/dev-utils/operationreplayer.js +112 -0
  166. package/src/dev-utils/utils.d.ts +37 -0
  167. package/src/dev-utils/utils.js +80 -0
  168. package/src/dev-utils/view.d.ts +320 -0
  169. package/src/dev-utils/view.js +970 -0
  170. package/src/index.d.ts +118 -0
  171. package/src/index.js +83 -0
  172. package/src/model/batch.d.ts +106 -0
  173. package/src/model/batch.js +96 -0
  174. package/src/model/differ.d.ts +507 -0
  175. package/src/model/differ.js +1285 -0
  176. package/src/model/document.d.ts +274 -0
  177. package/src/model/document.js +360 -0
  178. package/src/model/documentfragment.d.ts +200 -0
  179. package/src/model/documentfragment.js +306 -0
  180. package/src/model/documentselection.d.ts +420 -0
  181. package/src/model/documentselection.js +993 -0
  182. package/src/model/element.d.ts +165 -0
  183. package/src/model/element.js +281 -0
  184. package/src/model/history.d.ts +114 -0
  185. package/src/model/history.js +207 -0
  186. package/src/model/item.d.ts +14 -0
  187. package/src/model/item.js +5 -0
  188. package/src/model/liveposition.d.ts +77 -0
  189. package/src/model/liveposition.js +93 -0
  190. package/src/model/liverange.d.ts +102 -0
  191. package/src/model/liverange.js +120 -0
  192. package/src/model/markercollection.d.ts +335 -0
  193. package/src/model/markercollection.js +403 -0
  194. package/src/model/model.d.ts +919 -0
  195. package/src/model/model.js +838 -0
  196. package/src/model/node.d.ts +255 -0
  197. package/src/model/node.js +373 -0
  198. package/src/model/nodelist.d.ts +91 -0
  199. package/src/model/nodelist.js +170 -0
  200. package/src/model/operation/attributeoperation.d.ts +103 -0
  201. package/src/model/operation/attributeoperation.js +148 -0
  202. package/src/model/operation/detachoperation.d.ts +60 -0
  203. package/src/model/operation/detachoperation.js +77 -0
  204. package/src/model/operation/insertoperation.d.ts +90 -0
  205. package/src/model/operation/insertoperation.js +135 -0
  206. package/src/model/operation/markeroperation.d.ts +91 -0
  207. package/src/model/operation/markeroperation.js +107 -0
  208. package/src/model/operation/mergeoperation.d.ts +100 -0
  209. package/src/model/operation/mergeoperation.js +167 -0
  210. package/src/model/operation/moveoperation.d.ts +96 -0
  211. package/src/model/operation/moveoperation.js +164 -0
  212. package/src/model/operation/nooperation.d.ts +38 -0
  213. package/src/model/operation/nooperation.js +48 -0
  214. package/src/model/operation/operation.d.ts +96 -0
  215. package/src/model/operation/operation.js +59 -0
  216. package/src/model/operation/operationfactory.d.ts +18 -0
  217. package/src/model/operation/operationfactory.js +44 -0
  218. package/src/model/operation/renameoperation.d.ts +83 -0
  219. package/src/model/operation/renameoperation.js +115 -0
  220. package/src/model/operation/rootattributeoperation.d.ts +98 -0
  221. package/src/model/operation/rootattributeoperation.js +155 -0
  222. package/src/model/operation/rootoperation.d.ts +76 -0
  223. package/src/model/operation/rootoperation.js +90 -0
  224. package/src/model/operation/splitoperation.d.ts +109 -0
  225. package/src/model/operation/splitoperation.js +194 -0
  226. package/src/model/operation/transform.d.ts +100 -0
  227. package/src/model/operation/transform.js +2119 -0
  228. package/src/model/operation/utils.d.ts +71 -0
  229. package/src/model/operation/utils.js +217 -0
  230. package/src/model/position.d.ts +538 -0
  231. package/src/model/position.js +977 -0
  232. package/src/model/range.d.ts +458 -0
  233. package/src/model/range.js +872 -0
  234. package/src/model/rootelement.d.ts +60 -0
  235. package/src/model/rootelement.js +74 -0
  236. package/src/model/schema.d.ts +1330 -0
  237. package/src/model/schema.js +1524 -0
  238. package/src/model/selection.d.ts +482 -0
  239. package/src/model/selection.js +789 -0
  240. package/src/model/text.d.ts +66 -0
  241. package/src/model/text.js +85 -0
  242. package/src/model/textproxy.d.ts +144 -0
  243. package/src/model/textproxy.js +189 -0
  244. package/src/model/treewalker.d.ts +186 -0
  245. package/src/model/treewalker.js +244 -0
  246. package/src/model/typecheckable.d.ts +285 -0
  247. package/src/model/typecheckable.js +16 -0
  248. package/src/model/utils/autoparagraphing.d.ts +37 -0
  249. package/src/model/utils/autoparagraphing.js +63 -0
  250. package/src/model/utils/deletecontent.d.ts +58 -0
  251. package/src/model/utils/deletecontent.js +488 -0
  252. package/src/model/utils/getselectedcontent.d.ts +30 -0
  253. package/src/model/utils/getselectedcontent.js +125 -0
  254. package/src/model/utils/insertcontent.d.ts +46 -0
  255. package/src/model/utils/insertcontent.js +661 -0
  256. package/src/model/utils/insertobject.d.ts +47 -0
  257. package/src/model/utils/insertobject.js +135 -0
  258. package/src/model/utils/modifyselection.d.ts +48 -0
  259. package/src/model/utils/modifyselection.js +186 -0
  260. package/src/model/utils/selection-post-fixer.d.ts +74 -0
  261. package/src/model/utils/selection-post-fixer.js +260 -0
  262. package/src/model/writer.d.ts +851 -0
  263. package/src/model/writer.js +1306 -0
  264. package/src/view/attributeelement.d.ts +108 -0
  265. package/src/view/attributeelement.js +185 -0
  266. package/src/view/containerelement.d.ts +49 -0
  267. package/src/view/containerelement.js +80 -0
  268. package/src/view/datatransfer.d.ts +79 -0
  269. package/src/view/datatransfer.js +98 -0
  270. package/src/view/document.d.ts +184 -0
  271. package/src/view/document.js +122 -0
  272. package/src/view/documentfragment.d.ts +153 -0
  273. package/src/view/documentfragment.js +234 -0
  274. package/src/view/documentselection.d.ts +306 -0
  275. package/src/view/documentselection.js +256 -0
  276. package/src/view/domconverter.d.ts +661 -0
  277. package/src/view/domconverter.js +1523 -0
  278. package/src/view/downcastwriter.d.ts +996 -0
  279. package/src/view/downcastwriter.js +1696 -0
  280. package/src/view/editableelement.d.ts +62 -0
  281. package/src/view/editableelement.js +62 -0
  282. package/src/view/element.d.ts +468 -0
  283. package/src/view/element.js +724 -0
  284. package/src/view/elementdefinition.d.ts +87 -0
  285. package/src/view/elementdefinition.js +5 -0
  286. package/src/view/emptyelement.d.ts +41 -0
  287. package/src/view/emptyelement.js +73 -0
  288. package/src/view/filler.d.ts +111 -0
  289. package/src/view/filler.js +150 -0
  290. package/src/view/item.d.ts +14 -0
  291. package/src/view/item.js +5 -0
  292. package/src/view/matcher.d.ts +486 -0
  293. package/src/view/matcher.js +507 -0
  294. package/src/view/node.d.ts +162 -0
  295. package/src/view/node.js +226 -0
  296. package/src/view/observer/arrowkeysobserver.d.ts +45 -0
  297. package/src/view/observer/arrowkeysobserver.js +40 -0
  298. package/src/view/observer/bubblingemittermixin.d.ts +166 -0
  299. package/src/view/observer/bubblingemittermixin.js +172 -0
  300. package/src/view/observer/bubblingeventinfo.d.ts +47 -0
  301. package/src/view/observer/bubblingeventinfo.js +37 -0
  302. package/src/view/observer/clickobserver.d.ts +43 -0
  303. package/src/view/observer/clickobserver.js +29 -0
  304. package/src/view/observer/compositionobserver.d.ts +82 -0
  305. package/src/view/observer/compositionobserver.js +62 -0
  306. package/src/view/observer/domeventdata.d.ts +50 -0
  307. package/src/view/observer/domeventdata.js +47 -0
  308. package/src/view/observer/domeventobserver.d.ts +78 -0
  309. package/src/view/observer/domeventobserver.js +84 -0
  310. package/src/view/observer/fakeselectionobserver.d.ts +47 -0
  311. package/src/view/observer/fakeselectionobserver.js +91 -0
  312. package/src/view/observer/focusobserver.d.ts +94 -0
  313. package/src/view/observer/focusobserver.js +116 -0
  314. package/src/view/observer/inputobserver.d.ts +86 -0
  315. package/src/view/observer/inputobserver.js +166 -0
  316. package/src/view/observer/keyobserver.d.ts +66 -0
  317. package/src/view/observer/keyobserver.js +39 -0
  318. package/src/view/observer/mouseobserver.d.ts +89 -0
  319. package/src/view/observer/mouseobserver.js +29 -0
  320. package/src/view/observer/mutationobserver.d.ts +115 -0
  321. package/src/view/observer/mutationobserver.js +203 -0
  322. package/src/view/observer/observer.d.ts +89 -0
  323. package/src/view/observer/observer.js +84 -0
  324. package/src/view/observer/selectionobserver.d.ts +147 -0
  325. package/src/view/observer/selectionobserver.js +220 -0
  326. package/src/view/observer/tabobserver.d.ts +46 -0
  327. package/src/view/observer/tabobserver.js +42 -0
  328. package/src/view/placeholder.d.ts +96 -0
  329. package/src/view/placeholder.js +267 -0
  330. package/src/view/position.d.ts +188 -0
  331. package/src/view/position.js +322 -0
  332. package/src/view/range.d.ts +279 -0
  333. package/src/view/range.js +430 -0
  334. package/src/view/rawelement.d.ts +73 -0
  335. package/src/view/rawelement.js +105 -0
  336. package/src/view/renderer.d.ts +277 -0
  337. package/src/view/renderer.js +1056 -0
  338. package/src/view/rooteditableelement.d.ts +41 -0
  339. package/src/view/rooteditableelement.js +69 -0
  340. package/src/view/selection.d.ts +375 -0
  341. package/src/view/selection.js +559 -0
  342. package/src/view/styles/background.d.ts +33 -0
  343. package/src/view/styles/background.js +74 -0
  344. package/src/view/styles/border.d.ts +43 -0
  345. package/src/view/styles/border.js +316 -0
  346. package/src/view/styles/margin.d.ts +29 -0
  347. package/src/view/styles/margin.js +34 -0
  348. package/src/view/styles/padding.d.ts +29 -0
  349. package/src/view/styles/padding.js +34 -0
  350. package/src/view/styles/utils.d.ts +93 -0
  351. package/src/view/styles/utils.js +219 -0
  352. package/src/view/stylesmap.d.ts +673 -0
  353. package/src/view/stylesmap.js +762 -0
  354. package/src/view/text.d.ts +74 -0
  355. package/src/view/text.js +93 -0
  356. package/src/view/textproxy.d.ts +97 -0
  357. package/src/view/textproxy.js +124 -0
  358. package/src/view/treewalker.d.ts +195 -0
  359. package/src/view/treewalker.js +327 -0
  360. package/src/view/typecheckable.d.ts +448 -0
  361. package/src/view/typecheckable.js +19 -0
  362. package/src/view/uielement.d.ts +96 -0
  363. package/src/view/uielement.js +183 -0
  364. package/src/view/upcastwriter.d.ts +417 -0
  365. package/src/view/upcastwriter.js +359 -0
  366. package/src/view/view.d.ts +484 -0
  367. package/src/view/view.js +560 -0
  368. package/theme/placeholder.css +36 -0
  369. package/theme/renderer.css +9 -0
@@ -0,0 +1,191 @@
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
+ * @module engine/controller/editingcontroller
7
+ */
8
+ import { CKEditorError, ObservableMixin, env } from '@ckeditor/ckeditor5-utils';
9
+ import RootEditableElement from '../view/rooteditableelement.js';
10
+ import View from '../view/view.js';
11
+ import Mapper from '../conversion/mapper.js';
12
+ import DowncastDispatcher from '../conversion/downcastdispatcher.js';
13
+ import { cleanSelection, convertCollapsedSelection, convertRangeSelection, insertAttributesAndChildren, insertText, remove } from '../conversion/downcasthelpers.js';
14
+ import { convertSelectionChange } from '../conversion/upcasthelpers.js';
15
+ import { tryFixingRange } from '../model/utils/selection-post-fixer.js';
16
+ // @if CK_DEBUG_ENGINE // const { dumpTrees, initDocumentDumping } = require( '../dev-utils/utils' );
17
+ /**
18
+ * A controller for the editing pipeline. The editing pipeline controls the {@link ~EditingController#model model} rendering,
19
+ * including selection handling. It also creates the {@link ~EditingController#view view} which builds a
20
+ * browser-independent virtualization over the DOM elements. The editing controller also attaches default converters.
21
+ */
22
+ export default class EditingController extends /* #__PURE__ */ ObservableMixin() {
23
+ /**
24
+ * Creates an editing controller instance.
25
+ *
26
+ * @param model Editing model.
27
+ * @param stylesProcessor The styles processor instance.
28
+ */
29
+ constructor(model, stylesProcessor) {
30
+ super();
31
+ this.model = model;
32
+ this.view = new View(stylesProcessor);
33
+ this.mapper = new Mapper();
34
+ this.downcastDispatcher = new DowncastDispatcher({
35
+ mapper: this.mapper,
36
+ schema: model.schema
37
+ });
38
+ const doc = this.model.document;
39
+ const selection = doc.selection;
40
+ const markers = this.model.markers;
41
+ // When plugins listen on model changes (on selection change, post fixers, etc.) and change the view as a result of
42
+ // the model's change, they might trigger view rendering before the conversion is completed (e.g. before the selection
43
+ // is converted). We disable rendering for the length of the outermost model change() block to prevent that.
44
+ //
45
+ // See https://github.com/ckeditor/ckeditor5-engine/issues/1528
46
+ this.listenTo(this.model, '_beforeChanges', () => {
47
+ this.view._disableRendering(true);
48
+ }, { priority: 'highest' });
49
+ this.listenTo(this.model, '_afterChanges', () => {
50
+ this.view._disableRendering(false);
51
+ }, { priority: 'lowest' });
52
+ // Whenever model document is changed, convert those changes to the view (using model.Document#differ).
53
+ // Do it on 'low' priority, so changes are converted after other listeners did their job.
54
+ // Also convert model selection.
55
+ this.listenTo(doc, 'change', () => {
56
+ this.view.change(writer => {
57
+ this.downcastDispatcher.convertChanges(doc.differ, markers, writer);
58
+ this.downcastDispatcher.convertSelection(selection, markers, writer);
59
+ });
60
+ }, { priority: 'low' });
61
+ // Convert selection from the view to the model when it changes in the view.
62
+ this.listenTo(this.view.document, 'selectionChange', convertSelectionChange(this.model, this.mapper));
63
+ // Fix `beforeinput` target ranges so that they map to the valid model ranges.
64
+ this.listenTo(this.view.document, 'beforeinput', fixTargetRanges(this.mapper, this.model.schema, this.view), { priority: 'high' });
65
+ // Attach default model converters.
66
+ this.downcastDispatcher.on('insert:$text', insertText(), { priority: 'lowest' });
67
+ this.downcastDispatcher.on('insert', insertAttributesAndChildren(), { priority: 'lowest' });
68
+ this.downcastDispatcher.on('remove', remove(), { priority: 'low' });
69
+ // Attach default model selection converters.
70
+ this.downcastDispatcher.on('cleanSelection', cleanSelection());
71
+ this.downcastDispatcher.on('selection', convertRangeSelection(), { priority: 'low' });
72
+ this.downcastDispatcher.on('selection', convertCollapsedSelection(), { priority: 'low' });
73
+ // Binds {@link module:engine/view/document~Document#roots view roots collection} to
74
+ // {@link module:engine/model/document~Document#roots model roots collection} so creating
75
+ // model root automatically creates corresponding view root.
76
+ this.view.document.roots.bindTo(this.model.document.roots).using(root => {
77
+ // $graveyard is a special root that has no reflection in the view.
78
+ if (root.rootName == '$graveyard') {
79
+ return null;
80
+ }
81
+ const viewRoot = new RootEditableElement(this.view.document, root.name);
82
+ viewRoot.rootName = root.rootName;
83
+ this.mapper.bindElements(root, viewRoot);
84
+ return viewRoot;
85
+ });
86
+ // @if CK_DEBUG_ENGINE // initDocumentDumping( this.model.document );
87
+ // @if CK_DEBUG_ENGINE // initDocumentDumping( this.view.document );
88
+ // @if CK_DEBUG_ENGINE // dumpTrees( this.model.document, this.model.document.version );
89
+ // @if CK_DEBUG_ENGINE // dumpTrees( this.view.document, this.model.document.version );
90
+ // @if CK_DEBUG_ENGINE // this.model.document.on( 'change', () => {
91
+ // @if CK_DEBUG_ENGINE // dumpTrees( this.view.document, this.model.document.version );
92
+ // @if CK_DEBUG_ENGINE // }, { priority: 'lowest' } );
93
+ }
94
+ /**
95
+ * Removes all event listeners attached to the `EditingController`. Destroys all objects created
96
+ * by `EditingController` that need to be destroyed.
97
+ */
98
+ destroy() {
99
+ this.view.destroy();
100
+ this.stopListening();
101
+ }
102
+ /**
103
+ * Calling this method will refresh the marker by triggering the downcast conversion for it.
104
+ *
105
+ * Reconverting the marker is useful when you want to change its {@link module:engine/view/element~Element view element}
106
+ * without changing any marker data. For instance:
107
+ *
108
+ * ```ts
109
+ * let isCommentActive = false;
110
+ *
111
+ * model.conversion.markerToHighlight( {
112
+ * model: 'comment',
113
+ * view: data => {
114
+ * const classes = [ 'comment-marker' ];
115
+ *
116
+ * if ( isCommentActive ) {
117
+ * classes.push( 'comment-marker--active' );
118
+ * }
119
+ *
120
+ * return { classes };
121
+ * }
122
+ * } );
123
+ *
124
+ * // ...
125
+ *
126
+ * // Change the property that indicates if marker is displayed as active or not.
127
+ * isCommentActive = true;
128
+ *
129
+ * // Reconverting will downcast and synchronize the marker with the new isCommentActive state value.
130
+ * editor.editing.reconvertMarker( 'comment' );
131
+ * ```
132
+ *
133
+ * **Note**: If you want to reconvert a model item, use {@link #reconvertItem} instead.
134
+ *
135
+ * @param markerOrName Name of a marker to update, or a marker instance.
136
+ */
137
+ reconvertMarker(markerOrName) {
138
+ const markerName = typeof markerOrName == 'string' ? markerOrName : markerOrName.name;
139
+ const currentMarker = this.model.markers.get(markerName);
140
+ if (!currentMarker) {
141
+ /**
142
+ * The marker with the provided name does not exist and cannot be reconverted.
143
+ *
144
+ * @error editingcontroller-reconvertmarker-marker-not-exist
145
+ * @param {String} markerName The name of the reconverted marker.
146
+ */
147
+ throw new CKEditorError('editingcontroller-reconvertmarker-marker-not-exist', this, { markerName });
148
+ }
149
+ this.model.change(() => {
150
+ this.model.markers._refresh(currentMarker);
151
+ });
152
+ }
153
+ /**
154
+ * Calling this method will downcast a model item on demand (by requesting a refresh in the {@link module:engine/model/differ~Differ}).
155
+ *
156
+ * You can use it if you want the view representation of a specific item updated as a response to external modifications. For instance,
157
+ * when the view structure depends not only on the associated model data but also on some external state.
158
+ *
159
+ * **Note**: If you want to reconvert a model marker, use {@link #reconvertMarker} instead.
160
+ *
161
+ * @param item Item to refresh.
162
+ */
163
+ reconvertItem(item) {
164
+ this.model.change(() => {
165
+ this.model.document.differ._refreshItem(item);
166
+ });
167
+ }
168
+ }
169
+ /**
170
+ * Checks whether the target ranges provided by the `beforeInput` event can be properly mapped to model ranges and fixes them if needed.
171
+ *
172
+ * This is using the same logic as the selection post-fixer.
173
+ */
174
+ function fixTargetRanges(mapper, schema, view) {
175
+ return (evt, data) => {
176
+ // The Renderer is disabled while composing on non-android browsers, so we can't be sure that target ranges
177
+ // could be properly mapped to view and model because the DOM and view tree drifted apart.
178
+ if (view.document.isComposing && !env.isAndroid) {
179
+ return;
180
+ }
181
+ for (let i = 0; i < data.targetRanges.length; i++) {
182
+ const viewRange = data.targetRanges[i];
183
+ const modelRange = mapper.toModelRange(viewRange);
184
+ const correctedRange = tryFixingRange(modelRange, schema);
185
+ if (!correctedRange || correctedRange.isEqual(modelRange)) {
186
+ continue;
187
+ }
188
+ data.targetRanges[i] = mapper.toViewRange(correctedRange);
189
+ }
190
+ };
191
+ }
@@ -0,0 +1,478 @@
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
+ * @module engine/conversion/conversion
7
+ */
8
+ import { type ArrayOrItem, type PriorityString } from '@ckeditor/ckeditor5-utils';
9
+ import UpcastHelpers from './upcasthelpers.js';
10
+ import DowncastHelpers, { type AttributeCreatorFunction, type AttributeDescriptor } from './downcasthelpers.js';
11
+ import type DowncastDispatcher from './downcastdispatcher.js';
12
+ import type UpcastDispatcher from './upcastdispatcher.js';
13
+ import type ElementDefinition from '../view/elementdefinition.js';
14
+ import type { MatcherPattern } from '../view/matcher.js';
15
+ /**
16
+ * A utility class that helps add converters to upcast and downcast dispatchers.
17
+ *
18
+ * We recommend reading the {@glink framework/deep-dive/conversion/intro editor conversion} guide first to
19
+ * understand the core concepts of the conversion mechanisms.
20
+ *
21
+ * An instance of the conversion manager is available in the
22
+ * {@link module:core/editor/editor~Editor#conversion `editor.conversion`} property
23
+ * and by default has the following groups of dispatchers (i.e. directions of conversion):
24
+ *
25
+ * * `downcast` (editing and data downcasts)
26
+ * * `editingDowncast`
27
+ * * `dataDowncast`
28
+ * * `upcast`
29
+ *
30
+ * # One-way converters
31
+ *
32
+ * To add a converter to a specific group, use the {@link module:engine/conversion/conversion~Conversion#for `for()`}
33
+ * method:
34
+ *
35
+ * ```ts
36
+ * // Add a converter to editing downcast and data downcast.
37
+ * editor.conversion.for( 'downcast' ).elementToElement( config ) );
38
+ *
39
+ * // Add a converter to the data pipepline only:
40
+ * editor.conversion.for( 'dataDowncast' ).elementToElement( dataConversionConfig ) );
41
+ *
42
+ * // And a slightly different one for the editing pipeline:
43
+ * editor.conversion.for( 'editingDowncast' ).elementToElement( editingConversionConfig ) );
44
+ * ```
45
+ *
46
+ * See {@link module:engine/conversion/conversion~Conversion#for `for()`} method documentation to learn more about
47
+ * available conversion helpers and how to use your custom ones.
48
+ *
49
+ * # Two-way converters
50
+ *
51
+ * Besides using one-way converters via the `for()` method, you can also use other methods available in this
52
+ * class to add two-way converters (upcast and downcast):
53
+ *
54
+ * * {@link module:engine/conversion/conversion~Conversion#elementToElement `elementToElement()`} &ndash;
55
+ * Model element to view element and vice versa.
56
+ * * {@link module:engine/conversion/conversion~Conversion#attributeToElement `attributeToElement()`} &ndash;
57
+ * Model attribute to view element and vice versa.
58
+ * * {@link module:engine/conversion/conversion~Conversion#attributeToAttribute `attributeToAttribute()`} &ndash;
59
+ * Model attribute to view attribute and vice versa.
60
+ */
61
+ export default class Conversion {
62
+ /**
63
+ * Maps dispatchers group name to ConversionHelpers instances.
64
+ */
65
+ private readonly _helpers;
66
+ private readonly _downcast;
67
+ private readonly _upcast;
68
+ /**
69
+ * Creates a new conversion instance.
70
+ */
71
+ constructor(downcastDispatchers: ArrayOrItem<DowncastDispatcher>, upcastDispatchers: ArrayOrItem<UpcastDispatcher>);
72
+ addAlias(alias: `${string}Downcast`, dispatcher: DowncastDispatcher): void;
73
+ addAlias(alias: `${string}Upcast`, dispatcher: UpcastDispatcher): void;
74
+ addAlias(alias: string, dispatcher: DowncastDispatcher | UpcastDispatcher): void;
75
+ for(groupName: 'downcast' | 'dataDowncast' | 'editingDowncast'): DowncastHelpers;
76
+ for(groupName: 'upcast'): UpcastHelpers;
77
+ for<T extends string>(groupName: T): ConversionType<T>;
78
+ /**
79
+ * Sets up converters between the model and the view that convert a model element to a view element (and vice versa).
80
+ * For example, the model `<paragraph>Foo</paragraph>` is turned into `<p>Foo</p>` in the view.
81
+ *
82
+ * ```ts
83
+ * // A simple conversion from the `paragraph` model element to the `<p>` view element (and vice versa).
84
+ * editor.conversion.elementToElement( { model: 'paragraph', view: 'p' } );
85
+ *
86
+ * // Override other converters by specifying a converter definition with a higher priority.
87
+ * editor.conversion.elementToElement( { model: 'paragraph', view: 'div', converterPriority: 'high' } );
88
+ *
89
+ * // View specified as an object instead of a string.
90
+ * editor.conversion.elementToElement( {
91
+ * model: 'fancyParagraph',
92
+ * view: {
93
+ * name: 'p',
94
+ * classes: 'fancy'
95
+ * }
96
+ * } );
97
+ *
98
+ * // Use `upcastAlso` to define other view elements that should also be converted to a `paragraph` element.
99
+ * editor.conversion.elementToElement( {
100
+ * model: 'paragraph',
101
+ * view: 'p',
102
+ * upcastAlso: [
103
+ * 'div',
104
+ * {
105
+ * // Any element with the `display: block` style.
106
+ * styles: {
107
+ * display: 'block'
108
+ * }
109
+ * }
110
+ * ]
111
+ * } );
112
+ *
113
+ * // `upcastAlso` set as callback enables a conversion of a wide range of different view elements.
114
+ * editor.conversion.elementToElement( {
115
+ * model: 'heading',
116
+ * view: 'h2',
117
+ * // Convert "heading-like" paragraphs to headings.
118
+ * upcastAlso: viewElement => {
119
+ * const fontSize = viewElement.getStyle( 'font-size' );
120
+ *
121
+ * if ( !fontSize ) {
122
+ * return null;
123
+ * }
124
+ *
125
+ * const match = fontSize.match( /(\d+)\s*px/ );
126
+ *
127
+ * if ( !match ) {
128
+ * return null;
129
+ * }
130
+ *
131
+ * const size = Number( match[ 1 ] );
132
+ *
133
+ * if ( size > 26 ) {
134
+ * // Returned value can be an object with the matched properties.
135
+ * // These properties will be "consumed" during the conversion.
136
+ * // See `engine.view.Matcher~MatcherPattern` and `engine.view.Matcher#match` for more details.
137
+ *
138
+ * return { name: true, styles: [ 'font-size' ] };
139
+ * }
140
+ *
141
+ * return null;
142
+ * }
143
+ * } );
144
+ * ```
145
+ *
146
+ * `definition.model` is a `String` with a model element name to convert from or to.
147
+ *
148
+ * @param definition The converter definition.
149
+ */
150
+ elementToElement(definition: {
151
+ model: string;
152
+ view: ElementDefinition;
153
+ upcastAlso?: ArrayOrItem<ElementDefinition | MatcherPattern>;
154
+ converterPriority?: PriorityString;
155
+ }): void;
156
+ /**
157
+ * Sets up converters between the model and the view that convert a model attribute to a view element (and vice versa).
158
+ * For example, a model text node with `"Foo"` as data and the `bold` attribute will be turned to `<strong>Foo</strong>` in the view.
159
+ *
160
+ * ```ts
161
+ * // A simple conversion from the `bold=true` attribute to the `<strong>` view element (and vice versa).
162
+ * editor.conversion.attributeToElement( { model: 'bold', view: 'strong' } );
163
+ *
164
+ * // Override other converters by specifying a converter definition with a higher priority.
165
+ * editor.conversion.attributeToElement( { model: 'bold', view: 'b', converterPriority: 'high' } );
166
+ *
167
+ * // View specified as an object instead of a string.
168
+ * editor.conversion.attributeToElement( {
169
+ * model: 'bold',
170
+ * view: {
171
+ * name: 'span',
172
+ * classes: 'bold'
173
+ * }
174
+ * } );
175
+ *
176
+ * // Use `config.model.name` to define the conversion only from a given node type, `$text` in this case.
177
+ * // The same attribute on different elements may then be handled by a different converter.
178
+ * editor.conversion.attributeToElement( {
179
+ * model: {
180
+ * key: 'textDecoration',
181
+ * values: [ 'underline', 'lineThrough' ],
182
+ * name: '$text'
183
+ * },
184
+ * view: {
185
+ * underline: {
186
+ * name: 'span',
187
+ * styles: {
188
+ * 'text-decoration': 'underline'
189
+ * }
190
+ * },
191
+ * lineThrough: {
192
+ * name: 'span',
193
+ * styles: {
194
+ * 'text-decoration': 'line-through'
195
+ * }
196
+ * }
197
+ * }
198
+ * } );
199
+ *
200
+ * // Use `upcastAlso` to define other view elements that should also be converted to the `bold` attribute.
201
+ * editor.conversion.attributeToElement( {
202
+ * model: 'bold',
203
+ * view: 'strong',
204
+ * upcastAlso: [
205
+ * 'b',
206
+ * {
207
+ * name: 'span',
208
+ * classes: 'bold'
209
+ * },
210
+ * {
211
+ * name: 'span',
212
+ * styles: {
213
+ * 'font-weight': 'bold'
214
+ * }
215
+ * },
216
+ * viewElement => {
217
+ * const fontWeight = viewElement.getStyle( 'font-weight' );
218
+ *
219
+ * if ( viewElement.is( 'element', 'span' ) && fontWeight && /\d+/.test() && Number( fontWeight ) > 500 ) {
220
+ * // Returned value can be an object with the matched properties.
221
+ * // These properties will be "consumed" during the conversion.
222
+ * // See `engine.view.Matcher~MatcherPattern` and `engine.view.Matcher#match` for more details.
223
+ *
224
+ * return {
225
+ * name: true,
226
+ * styles: [ 'font-weight' ]
227
+ * };
228
+ * }
229
+ * }
230
+ * ]
231
+ * } );
232
+ *
233
+ * // Conversion from and to a model attribute key whose value is an enum (`fontSize=big|small`).
234
+ * // `upcastAlso` set as callback enables a conversion of a wide range of different view elements.
235
+ * editor.conversion.attributeToElement( {
236
+ * model: {
237
+ * key: 'fontSize',
238
+ * values: [ 'big', 'small' ]
239
+ * },
240
+ * view: {
241
+ * big: {
242
+ * name: 'span',
243
+ * styles: {
244
+ * 'font-size': '1.2em'
245
+ * }
246
+ * },
247
+ * small: {
248
+ * name: 'span',
249
+ * styles: {
250
+ * 'font-size': '0.8em'
251
+ * }
252
+ * }
253
+ * },
254
+ * upcastAlso: {
255
+ * big: viewElement => {
256
+ * const fontSize = viewElement.getStyle( 'font-size' );
257
+ *
258
+ * if ( !fontSize ) {
259
+ * return null;
260
+ * }
261
+ *
262
+ * const match = fontSize.match( /(\d+)\s*px/ );
263
+ *
264
+ * if ( !match ) {
265
+ * return null;
266
+ * }
267
+ *
268
+ * const size = Number( match[ 1 ] );
269
+ *
270
+ * if ( viewElement.is( 'element', 'span' ) && size > 10 ) {
271
+ * // Returned value can be an object with the matched properties.
272
+ * // These properties will be "consumed" during the conversion.
273
+ * // See `engine.view.Matcher~MatcherPattern` and `engine.view.Matcher#match` for more details.
274
+ *
275
+ * return { name: true, styles: [ 'font-size' ] };
276
+ * }
277
+ *
278
+ * return null;
279
+ * },
280
+ * small: viewElement => {
281
+ * const fontSize = viewElement.getStyle( 'font-size' );
282
+ *
283
+ * if ( !fontSize ) {
284
+ * return null;
285
+ * }
286
+ *
287
+ * const match = fontSize.match( /(\d+)\s*px/ );
288
+ *
289
+ * if ( !match ) {
290
+ * return null;
291
+ * }
292
+ *
293
+ * const size = Number( match[ 1 ] );
294
+ *
295
+ * if ( viewElement.is( 'element', 'span' ) && size < 10 ) {
296
+ * // Returned value can be an object with the matched properties.
297
+ * // These properties will be "consumed" during the conversion.
298
+ * // See `engine.view.Matcher~MatcherPattern` and `engine.view.Matcher#match` for more details.
299
+ *
300
+ * return { name: true, styles: [ 'font-size' ] };
301
+ * }
302
+ *
303
+ * return null;
304
+ * }
305
+ * }
306
+ * } );
307
+ * ```
308
+ *
309
+ * The `definition.model` parameter specifies which model attribute should be converted from or to. It can be a `{ key, value }` object
310
+ * describing the attribute key and value to convert or a `String` specifying just the attribute key (in such a case
311
+ * `value` is set to `true`).
312
+ *
313
+ * @param definition The converter definition.
314
+ */
315
+ attributeToElement<TValues extends string>(definition: {
316
+ model: string | {
317
+ key: string;
318
+ name?: string;
319
+ };
320
+ view: ElementDefinition;
321
+ upcastAlso?: ArrayOrItem<MatcherPattern>;
322
+ converterPriority?: PriorityString;
323
+ } | {
324
+ model: {
325
+ key: string;
326
+ name?: string;
327
+ values: Array<TValues>;
328
+ };
329
+ view: Record<TValues, ElementDefinition>;
330
+ upcastAlso?: Record<TValues, ArrayOrItem<MatcherPattern>>;
331
+ converterPriority?: PriorityString;
332
+ }): void;
333
+ /**
334
+ * Sets up converters between the model and the view that convert a model attribute to a view attribute (and vice versa). For example,
335
+ * `<imageBlock src='foo.jpg'></imageBlock>` is converted to `<img src='foo.jpg'></img>` (the same attribute key and value).
336
+ * This type of converters is intended to be used with {@link module:engine/model/element~Element model element} nodes.
337
+ * To convert the text attributes,
338
+ * the {@link module:engine/conversion/conversion~Conversion#attributeToElement `attributeToElement converter`}should be set up.
339
+ *
340
+ * ```ts
341
+ * // A simple conversion from the `source` model attribute to the `src` view attribute (and vice versa).
342
+ * editor.conversion.attributeToAttribute( { model: 'source', view: 'src' } );
343
+ *
344
+ * // Attribute values are strictly specified.
345
+ * editor.conversion.attributeToAttribute( {
346
+ * model: {
347
+ * name: 'imageInline',
348
+ * key: 'aside',
349
+ * values: [ 'aside' ]
350
+ * },
351
+ * view: {
352
+ * aside: {
353
+ * name: 'img',
354
+ * key: 'class',
355
+ * value: [ 'aside', 'half-size' ]
356
+ * }
357
+ * }
358
+ * } );
359
+ *
360
+ * // Set the style attribute.
361
+ * editor.conversion.attributeToAttribute( {
362
+ * model: {
363
+ * name: 'imageInline',
364
+ * key: 'aside',
365
+ * values: [ 'aside' ]
366
+ * },
367
+ * view: {
368
+ * aside: {
369
+ * name: 'img',
370
+ * key: 'style',
371
+ * value: {
372
+ * float: 'right',
373
+ * width: '50%',
374
+ * margin: '5px'
375
+ * }
376
+ * }
377
+ * }
378
+ * } );
379
+ *
380
+ * // Conversion from and to a model attribute key whose value is an enum (`align=right|center`).
381
+ * // Use `upcastAlso` to define other view elements that should also be converted to the `align=right` attribute.
382
+ * editor.conversion.attributeToAttribute( {
383
+ * model: {
384
+ * key: 'align',
385
+ * values: [ 'right', 'center' ]
386
+ * },
387
+ * view: {
388
+ * right: {
389
+ * key: 'class',
390
+ * value: 'align-right'
391
+ * },
392
+ * center: {
393
+ * key: 'class',
394
+ * value: 'align-center'
395
+ * }
396
+ * },
397
+ * upcastAlso: {
398
+ * right: {
399
+ * styles: {
400
+ * 'text-align': 'right'
401
+ * }
402
+ * },
403
+ * center: {
404
+ * styles: {
405
+ * 'text-align': 'center'
406
+ * }
407
+ * }
408
+ * }
409
+ * } );
410
+ * ```
411
+ *
412
+ * The `definition.model` parameter specifies which model attribute should be converted from and to.
413
+ * It can be a `{ key, [ values ], [ name ] }` object or a `String`, which will be treated like `{ key: definition.model }`.
414
+ * The `key` property is the model attribute key to convert from and to.
415
+ * The `values` are the possible model attribute values. If the `values` parameter is not set, the model attribute value
416
+ * will be the same as the view attribute value.
417
+ * If `name` is set, the conversion will be set up only for model elements with the given name.
418
+ *
419
+ * The `definition.view` parameter specifies which view attribute should be converted from and to.
420
+ * It can be a `{ key, value, [ name ] }` object or a `String`, which will be treated like `{ key: definition.view }`.
421
+ * The `key` property is the view attribute key to convert from and to.
422
+ * The `value` is the view attribute value to convert from and to. If `definition.value` is not set, the view attribute value will be
423
+ * the same as the model attribute value.
424
+ * If `key` is `'class'`, `value` can be a `String` or an array of `String`s.
425
+ * If `key` is `'style'`, `value` is an object with key-value pairs.
426
+ * In other cases, `value` is a `String`.
427
+ * If `name` is set, the conversion will be set up only for model elements with the given name.
428
+ * If `definition.model.values` is set, `definition.view` is an object that assigns values from `definition.model.values`
429
+ * to `{ key, value, [ name ] }` objects.
430
+ *
431
+ * `definition.upcastAlso` specifies which other matching view elements should also be upcast to the given model configuration.
432
+ * If `definition.model.values` is set, `definition.upcastAlso` should be an object assigning values from `definition.model.values`
433
+ * to {@link module:engine/view/matcher~MatcherPattern}s or arrays of {@link module:engine/view/matcher~MatcherPattern}s.
434
+ *
435
+ * **Note:** `definition.model` and `definition.view` form should be mirrored, so the same types of parameters should
436
+ * be given in both parameters.
437
+ *
438
+ * @param definition The converter definition.
439
+ * @param definition.model The model attribute to convert from and to.
440
+ * @param definition.view The view attribute to convert from and to.
441
+ * @param definition.upcastAlso Any view element matching `definition.upcastAlso` will also be converted to the given model attribute.
442
+ * `definition.upcastAlso` is used only if `config.model.values` is specified.
443
+ */
444
+ attributeToAttribute<TValues extends string>(definition: {
445
+ model: string | {
446
+ key: string;
447
+ name?: string;
448
+ };
449
+ view: string | (AttributeDescriptor & {
450
+ name?: string;
451
+ });
452
+ upcastAlso?: ArrayOrItem<string | (AttributeDescriptor & {
453
+ name?: string;
454
+ }) | AttributeCreatorFunction>;
455
+ converterPriority?: PriorityString;
456
+ } | {
457
+ model: {
458
+ key: string;
459
+ name?: string;
460
+ values: Array<TValues>;
461
+ };
462
+ view: Record<TValues, (AttributeDescriptor & {
463
+ name?: string;
464
+ })>;
465
+ upcastAlso?: Record<TValues, (AttributeDescriptor & {
466
+ name?: string;
467
+ }) | AttributeCreatorFunction>;
468
+ converterPriority?: PriorityString;
469
+ }): void;
470
+ /**
471
+ * Creates and caches conversion helpers for given dispatchers group.
472
+ *
473
+ * @param options.name Group name.
474
+ */
475
+ private _createConversionHelpers;
476
+ }
477
+ type ConversionType<T extends string> = T extends `${string}Downcast` ? DowncastHelpers : T extends `${string}Upcast` ? UpcastHelpers : DowncastHelpers | UpcastHelpers;
478
+ export {};