@ckeditor/ckeditor5-table 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 (565) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/LICENSE.md +21 -0
  3. package/README.md +26 -0
  4. package/build/table.js +5 -0
  5. package/build/translations/ar.js +1 -0
  6. package/build/translations/az.js +1 -0
  7. package/build/translations/bg.js +1 -0
  8. package/build/translations/bn.js +1 -0
  9. package/build/translations/ca.js +1 -0
  10. package/build/translations/cs.js +1 -0
  11. package/build/translations/da.js +1 -0
  12. package/build/translations/de-ch.js +1 -0
  13. package/build/translations/de.js +1 -0
  14. package/build/translations/el.js +1 -0
  15. package/build/translations/en-au.js +1 -0
  16. package/build/translations/en-gb.js +1 -0
  17. package/build/translations/es.js +1 -0
  18. package/build/translations/et.js +1 -0
  19. package/build/translations/fa.js +1 -0
  20. package/build/translations/fi.js +1 -0
  21. package/build/translations/fr.js +1 -0
  22. package/build/translations/gl.js +1 -0
  23. package/build/translations/he.js +1 -0
  24. package/build/translations/hi.js +1 -0
  25. package/build/translations/hr.js +1 -0
  26. package/build/translations/hu.js +1 -0
  27. package/build/translations/hy.js +1 -0
  28. package/build/translations/id.js +1 -0
  29. package/build/translations/it.js +1 -0
  30. package/build/translations/ja.js +1 -0
  31. package/build/translations/ko.js +1 -0
  32. package/build/translations/ku.js +1 -0
  33. package/build/translations/lt.js +1 -0
  34. package/build/translations/lv.js +1 -0
  35. package/build/translations/ms.js +1 -0
  36. package/build/translations/nb.js +1 -0
  37. package/build/translations/ne.js +1 -0
  38. package/build/translations/nl.js +1 -0
  39. package/build/translations/no.js +1 -0
  40. package/build/translations/pl.js +1 -0
  41. package/build/translations/pt-br.js +1 -0
  42. package/build/translations/pt.js +1 -0
  43. package/build/translations/ro.js +1 -0
  44. package/build/translations/ru.js +1 -0
  45. package/build/translations/sk.js +1 -0
  46. package/build/translations/sl.js +1 -0
  47. package/build/translations/sq.js +1 -0
  48. package/build/translations/sr-latn.js +1 -0
  49. package/build/translations/sr.js +1 -0
  50. package/build/translations/sv.js +1 -0
  51. package/build/translations/th.js +1 -0
  52. package/build/translations/tk.js +1 -0
  53. package/build/translations/tr.js +1 -0
  54. package/build/translations/tt.js +1 -0
  55. package/build/translations/ug.js +1 -0
  56. package/build/translations/uk.js +1 -0
  57. package/build/translations/ur.js +1 -0
  58. package/build/translations/uz.js +1 -0
  59. package/build/translations/vi.js +1 -0
  60. package/build/translations/zh-cn.js +1 -0
  61. package/build/translations/zh.js +1 -0
  62. package/ckeditor5-metadata.json +193 -0
  63. package/dist/augmentation.d.ts +80 -0
  64. package/dist/commands/insertcolumncommand.d.ts +59 -0
  65. package/dist/commands/insertrowcommand.d.ts +58 -0
  66. package/dist/commands/inserttablecommand.d.ts +48 -0
  67. package/dist/commands/mergecellcommand.d.ts +72 -0
  68. package/dist/commands/mergecellscommand.d.ts +32 -0
  69. package/dist/commands/removecolumncommand.d.ts +33 -0
  70. package/dist/commands/removerowcommand.d.ts +33 -0
  71. package/dist/commands/selectcolumncommand.d.ts +37 -0
  72. package/dist/commands/selectrowcommand.d.ts +37 -0
  73. package/dist/commands/setheadercolumncommand.d.ts +54 -0
  74. package/dist/commands/setheaderrowcommand.d.ts +57 -0
  75. package/dist/commands/splitcellcommand.d.ts +47 -0
  76. package/dist/converters/downcast.d.ts +67 -0
  77. package/dist/converters/table-caption-post-fixer.d.ts +24 -0
  78. package/dist/converters/table-cell-paragraph-post-fixer.d.ts +36 -0
  79. package/dist/converters/table-cell-refresh-handler.d.ts +22 -0
  80. package/dist/converters/table-headings-refresh-handler.d.ts +21 -0
  81. package/dist/converters/table-layout-post-fixer.d.ts +230 -0
  82. package/dist/converters/tableproperties.d.ts +58 -0
  83. package/dist/converters/upcasttable.d.ts +53 -0
  84. package/dist/index-content.css +76 -0
  85. package/dist/index-editor.css +201 -0
  86. package/dist/index.css +394 -0
  87. package/dist/index.css.map +1 -0
  88. package/dist/index.d.ts +64 -0
  89. package/dist/index.js +11522 -0
  90. package/dist/index.js.map +1 -0
  91. package/dist/plaintableoutput.d.ts +34 -0
  92. package/dist/table.d.ts +48 -0
  93. package/dist/tablecaption/tablecaptionediting.d.ts +71 -0
  94. package/dist/tablecaption/tablecaptionui.d.ts +29 -0
  95. package/dist/tablecaption/toggletablecaptioncommand.d.ts +72 -0
  96. package/dist/tablecaption/utils.d.ts +42 -0
  97. package/dist/tablecaption.d.ts +32 -0
  98. package/dist/tablecellproperties/commands/tablecellbackgroundcolorcommand.d.ts +36 -0
  99. package/dist/tablecellproperties/commands/tablecellbordercolorcommand.d.ts +41 -0
  100. package/dist/tablecellproperties/commands/tablecellborderstylecommand.d.ts +41 -0
  101. package/dist/tablecellproperties/commands/tablecellborderwidthcommand.d.ts +55 -0
  102. package/dist/tablecellproperties/commands/tablecellheightcommand.d.ts +50 -0
  103. package/dist/tablecellproperties/commands/tablecellhorizontalalignmentcommand.d.ts +36 -0
  104. package/dist/tablecellproperties/commands/tablecellpaddingcommand.d.ts +55 -0
  105. package/dist/tablecellproperties/commands/tablecellpropertycommand.d.ts +66 -0
  106. package/dist/tablecellproperties/commands/tablecellverticalalignmentcommand.d.ts +44 -0
  107. package/dist/tablecellproperties/tablecellpropertiesediting.d.ts +51 -0
  108. package/dist/tablecellproperties/tablecellpropertiesui.d.ts +120 -0
  109. package/dist/tablecellproperties/ui/tablecellpropertiesview.d.ts +232 -0
  110. package/dist/tablecellproperties.d.ts +38 -0
  111. package/dist/tablecellwidth/commands/tablecellwidthcommand.d.ts +50 -0
  112. package/dist/tablecellwidth/tablecellwidthediting.d.ts +37 -0
  113. package/dist/tableclipboard.d.ts +78 -0
  114. package/dist/tablecolumnresize/constants.d.ts +24 -0
  115. package/dist/tablecolumnresize/converters.d.ts +22 -0
  116. package/dist/tablecolumnresize/tablecolumnresizeediting.d.ts +147 -0
  117. package/dist/tablecolumnresize/tablewidthscommand.d.ts +42 -0
  118. package/dist/tablecolumnresize/utils.d.ts +152 -0
  119. package/dist/tablecolumnresize.d.ts +34 -0
  120. package/dist/tableconfig.d.ts +347 -0
  121. package/dist/tableediting.d.ts +106 -0
  122. package/dist/tablekeyboard.d.ts +76 -0
  123. package/dist/tablemouse/mouseeventsobserver.d.ts +66 -0
  124. package/dist/tablemouse.d.ts +56 -0
  125. package/dist/tableproperties/commands/tablealignmentcommand.d.ts +36 -0
  126. package/dist/tableproperties/commands/tablebackgroundcolorcommand.d.ts +36 -0
  127. package/dist/tableproperties/commands/tablebordercolorcommand.d.ts +41 -0
  128. package/dist/tableproperties/commands/tableborderstylecommand.d.ts +41 -0
  129. package/dist/tableproperties/commands/tableborderwidthcommand.d.ts +55 -0
  130. package/dist/tableproperties/commands/tableheightcommand.d.ts +50 -0
  131. package/dist/tableproperties/commands/tablepropertycommand.d.ts +65 -0
  132. package/dist/tableproperties/commands/tablewidthcommand.d.ts +50 -0
  133. package/dist/tableproperties/tablepropertiesediting.d.ts +48 -0
  134. package/dist/tableproperties/tablepropertiesui.d.ts +122 -0
  135. package/dist/tableproperties/ui/tablepropertiesview.d.ts +211 -0
  136. package/dist/tableproperties.d.ts +38 -0
  137. package/dist/tableselection.d.ts +115 -0
  138. package/dist/tabletoolbar.d.ts +40 -0
  139. package/dist/tableui.d.ts +62 -0
  140. package/dist/tableutils.d.ts +456 -0
  141. package/dist/tablewalker.d.ts +366 -0
  142. package/dist/translations/ar.d.ts +8 -0
  143. package/dist/translations/ar.js +5 -0
  144. package/dist/translations/ar.umd.js +11 -0
  145. package/dist/translations/az.d.ts +8 -0
  146. package/dist/translations/az.js +5 -0
  147. package/dist/translations/az.umd.js +11 -0
  148. package/dist/translations/bg.d.ts +8 -0
  149. package/dist/translations/bg.js +5 -0
  150. package/dist/translations/bg.umd.js +11 -0
  151. package/dist/translations/bn.d.ts +8 -0
  152. package/dist/translations/bn.js +5 -0
  153. package/dist/translations/bn.umd.js +11 -0
  154. package/dist/translations/ca.d.ts +8 -0
  155. package/dist/translations/ca.js +5 -0
  156. package/dist/translations/ca.umd.js +11 -0
  157. package/dist/translations/cs.d.ts +8 -0
  158. package/dist/translations/cs.js +5 -0
  159. package/dist/translations/cs.umd.js +11 -0
  160. package/dist/translations/da.d.ts +8 -0
  161. package/dist/translations/da.js +5 -0
  162. package/dist/translations/da.umd.js +11 -0
  163. package/dist/translations/de-ch.d.ts +8 -0
  164. package/dist/translations/de-ch.js +5 -0
  165. package/dist/translations/de-ch.umd.js +11 -0
  166. package/dist/translations/de.d.ts +8 -0
  167. package/dist/translations/de.js +5 -0
  168. package/dist/translations/de.umd.js +11 -0
  169. package/dist/translations/el.d.ts +8 -0
  170. package/dist/translations/el.js +5 -0
  171. package/dist/translations/el.umd.js +11 -0
  172. package/dist/translations/en-au.d.ts +8 -0
  173. package/dist/translations/en-au.js +5 -0
  174. package/dist/translations/en-au.umd.js +11 -0
  175. package/dist/translations/en-gb.d.ts +8 -0
  176. package/dist/translations/en-gb.js +5 -0
  177. package/dist/translations/en-gb.umd.js +11 -0
  178. package/dist/translations/en.d.ts +8 -0
  179. package/dist/translations/en.js +5 -0
  180. package/dist/translations/en.umd.js +11 -0
  181. package/dist/translations/es.d.ts +8 -0
  182. package/dist/translations/es.js +5 -0
  183. package/dist/translations/es.umd.js +11 -0
  184. package/dist/translations/et.d.ts +8 -0
  185. package/dist/translations/et.js +5 -0
  186. package/dist/translations/et.umd.js +11 -0
  187. package/dist/translations/fa.d.ts +8 -0
  188. package/dist/translations/fa.js +5 -0
  189. package/dist/translations/fa.umd.js +11 -0
  190. package/dist/translations/fi.d.ts +8 -0
  191. package/dist/translations/fi.js +5 -0
  192. package/dist/translations/fi.umd.js +11 -0
  193. package/dist/translations/fr.d.ts +8 -0
  194. package/dist/translations/fr.js +5 -0
  195. package/dist/translations/fr.umd.js +11 -0
  196. package/dist/translations/gl.d.ts +8 -0
  197. package/dist/translations/gl.js +5 -0
  198. package/dist/translations/gl.umd.js +11 -0
  199. package/dist/translations/he.d.ts +8 -0
  200. package/dist/translations/he.js +5 -0
  201. package/dist/translations/he.umd.js +11 -0
  202. package/dist/translations/hi.d.ts +8 -0
  203. package/dist/translations/hi.js +5 -0
  204. package/dist/translations/hi.umd.js +11 -0
  205. package/dist/translations/hr.d.ts +8 -0
  206. package/dist/translations/hr.js +5 -0
  207. package/dist/translations/hr.umd.js +11 -0
  208. package/dist/translations/hu.d.ts +8 -0
  209. package/dist/translations/hu.js +5 -0
  210. package/dist/translations/hu.umd.js +11 -0
  211. package/dist/translations/hy.d.ts +8 -0
  212. package/dist/translations/hy.js +5 -0
  213. package/dist/translations/hy.umd.js +11 -0
  214. package/dist/translations/id.d.ts +8 -0
  215. package/dist/translations/id.js +5 -0
  216. package/dist/translations/id.umd.js +11 -0
  217. package/dist/translations/it.d.ts +8 -0
  218. package/dist/translations/it.js +5 -0
  219. package/dist/translations/it.umd.js +11 -0
  220. package/dist/translations/ja.d.ts +8 -0
  221. package/dist/translations/ja.js +5 -0
  222. package/dist/translations/ja.umd.js +11 -0
  223. package/dist/translations/ko.d.ts +8 -0
  224. package/dist/translations/ko.js +5 -0
  225. package/dist/translations/ko.umd.js +11 -0
  226. package/dist/translations/ku.d.ts +8 -0
  227. package/dist/translations/ku.js +5 -0
  228. package/dist/translations/ku.umd.js +11 -0
  229. package/dist/translations/lt.d.ts +8 -0
  230. package/dist/translations/lt.js +5 -0
  231. package/dist/translations/lt.umd.js +11 -0
  232. package/dist/translations/lv.d.ts +8 -0
  233. package/dist/translations/lv.js +5 -0
  234. package/dist/translations/lv.umd.js +11 -0
  235. package/dist/translations/ms.d.ts +8 -0
  236. package/dist/translations/ms.js +5 -0
  237. package/dist/translations/ms.umd.js +11 -0
  238. package/dist/translations/nb.d.ts +8 -0
  239. package/dist/translations/nb.js +5 -0
  240. package/dist/translations/nb.umd.js +11 -0
  241. package/dist/translations/ne.d.ts +8 -0
  242. package/dist/translations/ne.js +5 -0
  243. package/dist/translations/ne.umd.js +11 -0
  244. package/dist/translations/nl.d.ts +8 -0
  245. package/dist/translations/nl.js +5 -0
  246. package/dist/translations/nl.umd.js +11 -0
  247. package/dist/translations/no.d.ts +8 -0
  248. package/dist/translations/no.js +5 -0
  249. package/dist/translations/no.umd.js +11 -0
  250. package/dist/translations/pl.d.ts +8 -0
  251. package/dist/translations/pl.js +5 -0
  252. package/dist/translations/pl.umd.js +11 -0
  253. package/dist/translations/pt-br.d.ts +8 -0
  254. package/dist/translations/pt-br.js +5 -0
  255. package/dist/translations/pt-br.umd.js +11 -0
  256. package/dist/translations/pt.d.ts +8 -0
  257. package/dist/translations/pt.js +5 -0
  258. package/dist/translations/pt.umd.js +11 -0
  259. package/dist/translations/ro.d.ts +8 -0
  260. package/dist/translations/ro.js +5 -0
  261. package/dist/translations/ro.umd.js +11 -0
  262. package/dist/translations/ru.d.ts +8 -0
  263. package/dist/translations/ru.js +5 -0
  264. package/dist/translations/ru.umd.js +11 -0
  265. package/dist/translations/sk.d.ts +8 -0
  266. package/dist/translations/sk.js +5 -0
  267. package/dist/translations/sk.umd.js +11 -0
  268. package/dist/translations/sl.d.ts +8 -0
  269. package/dist/translations/sl.js +5 -0
  270. package/dist/translations/sl.umd.js +11 -0
  271. package/dist/translations/sq.d.ts +8 -0
  272. package/dist/translations/sq.js +5 -0
  273. package/dist/translations/sq.umd.js +11 -0
  274. package/dist/translations/sr-latn.d.ts +8 -0
  275. package/dist/translations/sr-latn.js +5 -0
  276. package/dist/translations/sr-latn.umd.js +11 -0
  277. package/dist/translations/sr.d.ts +8 -0
  278. package/dist/translations/sr.js +5 -0
  279. package/dist/translations/sr.umd.js +11 -0
  280. package/dist/translations/sv.d.ts +8 -0
  281. package/dist/translations/sv.js +5 -0
  282. package/dist/translations/sv.umd.js +11 -0
  283. package/dist/translations/th.d.ts +8 -0
  284. package/dist/translations/th.js +5 -0
  285. package/dist/translations/th.umd.js +11 -0
  286. package/dist/translations/tk.d.ts +8 -0
  287. package/dist/translations/tk.js +5 -0
  288. package/dist/translations/tk.umd.js +11 -0
  289. package/dist/translations/tr.d.ts +8 -0
  290. package/dist/translations/tr.js +5 -0
  291. package/dist/translations/tr.umd.js +11 -0
  292. package/dist/translations/tt.d.ts +8 -0
  293. package/dist/translations/tt.js +5 -0
  294. package/dist/translations/tt.umd.js +11 -0
  295. package/dist/translations/ug.d.ts +8 -0
  296. package/dist/translations/ug.js +5 -0
  297. package/dist/translations/ug.umd.js +11 -0
  298. package/dist/translations/uk.d.ts +8 -0
  299. package/dist/translations/uk.js +5 -0
  300. package/dist/translations/uk.umd.js +11 -0
  301. package/dist/translations/ur.d.ts +8 -0
  302. package/dist/translations/ur.js +5 -0
  303. package/dist/translations/ur.umd.js +11 -0
  304. package/dist/translations/uz.d.ts +8 -0
  305. package/dist/translations/uz.js +5 -0
  306. package/dist/translations/uz.umd.js +11 -0
  307. package/dist/translations/vi.d.ts +8 -0
  308. package/dist/translations/vi.js +5 -0
  309. package/dist/translations/vi.umd.js +11 -0
  310. package/dist/translations/zh-cn.d.ts +8 -0
  311. package/dist/translations/zh-cn.js +5 -0
  312. package/dist/translations/zh-cn.umd.js +11 -0
  313. package/dist/translations/zh.d.ts +8 -0
  314. package/dist/translations/zh.js +5 -0
  315. package/dist/translations/zh.umd.js +11 -0
  316. package/dist/ui/colorinputview.d.ts +144 -0
  317. package/dist/ui/formrowview.d.ts +65 -0
  318. package/dist/ui/inserttableview.d.ts +85 -0
  319. package/dist/utils/common.d.ts +50 -0
  320. package/dist/utils/structure.d.ts +249 -0
  321. package/dist/utils/table-properties.d.ts +101 -0
  322. package/dist/utils/ui/contextualballoon.d.ts +38 -0
  323. package/dist/utils/ui/table-properties.d.ts +199 -0
  324. package/dist/utils/ui/widget.d.ts +24 -0
  325. package/lang/contexts.json +67 -0
  326. package/lang/translations/ar.po +278 -0
  327. package/lang/translations/az.po +278 -0
  328. package/lang/translations/bg.po +278 -0
  329. package/lang/translations/bn.po +280 -0
  330. package/lang/translations/ca.po +278 -0
  331. package/lang/translations/cs.po +278 -0
  332. package/lang/translations/da.po +278 -0
  333. package/lang/translations/de-ch.po +278 -0
  334. package/lang/translations/de.po +278 -0
  335. package/lang/translations/el.po +278 -0
  336. package/lang/translations/en-au.po +278 -0
  337. package/lang/translations/en-gb.po +278 -0
  338. package/lang/translations/en.po +278 -0
  339. package/lang/translations/es.po +278 -0
  340. package/lang/translations/et.po +278 -0
  341. package/lang/translations/fa.po +278 -0
  342. package/lang/translations/fi.po +278 -0
  343. package/lang/translations/fr.po +278 -0
  344. package/lang/translations/gl.po +278 -0
  345. package/lang/translations/he.po +278 -0
  346. package/lang/translations/hi.po +278 -0
  347. package/lang/translations/hr.po +278 -0
  348. package/lang/translations/hu.po +278 -0
  349. package/lang/translations/hy.po +278 -0
  350. package/lang/translations/id.po +278 -0
  351. package/lang/translations/it.po +278 -0
  352. package/lang/translations/ja.po +278 -0
  353. package/lang/translations/ko.po +278 -0
  354. package/lang/translations/ku.po +278 -0
  355. package/lang/translations/lt.po +278 -0
  356. package/lang/translations/lv.po +278 -0
  357. package/lang/translations/ms.po +278 -0
  358. package/lang/translations/nb.po +278 -0
  359. package/lang/translations/ne.po +278 -0
  360. package/lang/translations/nl.po +278 -0
  361. package/lang/translations/no.po +278 -0
  362. package/lang/translations/pl.po +278 -0
  363. package/lang/translations/pt-br.po +278 -0
  364. package/lang/translations/pt.po +278 -0
  365. package/lang/translations/ro.po +278 -0
  366. package/lang/translations/ru.po +278 -0
  367. package/lang/translations/sk.po +278 -0
  368. package/lang/translations/sl.po +278 -0
  369. package/lang/translations/sq.po +278 -0
  370. package/lang/translations/sr-latn.po +278 -0
  371. package/lang/translations/sr.po +278 -0
  372. package/lang/translations/sv.po +278 -0
  373. package/lang/translations/th.po +278 -0
  374. package/lang/translations/tk.po +278 -0
  375. package/lang/translations/tr.po +278 -0
  376. package/lang/translations/tt.po +278 -0
  377. package/lang/translations/ug.po +278 -0
  378. package/lang/translations/uk.po +278 -0
  379. package/lang/translations/ur.po +278 -0
  380. package/lang/translations/uz.po +278 -0
  381. package/lang/translations/vi.po +278 -0
  382. package/lang/translations/zh-cn.po +278 -0
  383. package/lang/translations/zh.po +278 -0
  384. package/package.json +45 -0
  385. package/src/augmentation.d.ts +76 -0
  386. package/src/augmentation.js +5 -0
  387. package/src/commands/insertcolumncommand.d.ts +55 -0
  388. package/src/commands/insertcolumncommand.js +67 -0
  389. package/src/commands/insertrowcommand.d.ts +54 -0
  390. package/src/commands/insertrowcommand.js +66 -0
  391. package/src/commands/inserttablecommand.d.ts +44 -0
  392. package/src/commands/inserttablecommand.js +69 -0
  393. package/src/commands/mergecellcommand.d.ts +68 -0
  394. package/src/commands/mergecellcommand.js +198 -0
  395. package/src/commands/mergecellscommand.d.ts +28 -0
  396. package/src/commands/mergecellscommand.js +94 -0
  397. package/src/commands/removecolumncommand.d.ts +29 -0
  398. package/src/commands/removecolumncommand.js +109 -0
  399. package/src/commands/removerowcommand.d.ts +29 -0
  400. package/src/commands/removerowcommand.js +82 -0
  401. package/src/commands/selectcolumncommand.d.ts +33 -0
  402. package/src/commands/selectcolumncommand.js +60 -0
  403. package/src/commands/selectrowcommand.d.ts +33 -0
  404. package/src/commands/selectrowcommand.js +56 -0
  405. package/src/commands/setheadercolumncommand.d.ts +50 -0
  406. package/src/commands/setheadercolumncommand.js +71 -0
  407. package/src/commands/setheaderrowcommand.d.ts +53 -0
  408. package/src/commands/setheaderrowcommand.js +79 -0
  409. package/src/commands/splitcellcommand.d.ts +43 -0
  410. package/src/commands/splitcellcommand.js +54 -0
  411. package/src/converters/downcast.d.ts +63 -0
  412. package/src/converters/downcast.js +146 -0
  413. package/src/converters/table-caption-post-fixer.d.ts +20 -0
  414. package/src/converters/table-caption-post-fixer.js +53 -0
  415. package/src/converters/table-cell-paragraph-post-fixer.d.ts +32 -0
  416. package/src/converters/table-cell-paragraph-post-fixer.js +107 -0
  417. package/src/converters/table-cell-refresh-handler.d.ts +18 -0
  418. package/src/converters/table-cell-refresh-handler.js +45 -0
  419. package/src/converters/table-headings-refresh-handler.d.ts +17 -0
  420. package/src/converters/table-headings-refresh-handler.js +49 -0
  421. package/src/converters/table-layout-post-fixer.d.ts +226 -0
  422. package/src/converters/table-layout-post-fixer.js +367 -0
  423. package/src/converters/tableproperties.d.ts +54 -0
  424. package/src/converters/tableproperties.js +159 -0
  425. package/src/converters/upcasttable.d.ts +49 -0
  426. package/src/converters/upcasttable.js +243 -0
  427. package/src/index.d.ts +60 -0
  428. package/src/index.js +30 -0
  429. package/src/plaintableoutput.d.ts +30 -0
  430. package/src/plaintableoutput.js +129 -0
  431. package/src/table.d.ts +44 -0
  432. package/src/table.js +50 -0
  433. package/src/tablecaption/tablecaptionediting.d.ts +67 -0
  434. package/src/tablecaption/tablecaptionediting.js +128 -0
  435. package/src/tablecaption/tablecaptionui.d.ts +25 -0
  436. package/src/tablecaption/tablecaptionui.js +63 -0
  437. package/src/tablecaption/toggletablecaptioncommand.d.ts +68 -0
  438. package/src/tablecaption/toggletablecaptioncommand.js +105 -0
  439. package/src/tablecaption/utils.d.ts +38 -0
  440. package/src/tablecaption/utils.js +57 -0
  441. package/src/tablecaption.d.ts +28 -0
  442. package/src/tablecaption.js +34 -0
  443. package/src/tablecellproperties/commands/tablecellbackgroundcolorcommand.d.ts +32 -0
  444. package/src/tablecellproperties/commands/tablecellbackgroundcolorcommand.js +30 -0
  445. package/src/tablecellproperties/commands/tablecellbordercolorcommand.d.ts +37 -0
  446. package/src/tablecellproperties/commands/tablecellbordercolorcommand.js +44 -0
  447. package/src/tablecellproperties/commands/tablecellborderstylecommand.d.ts +37 -0
  448. package/src/tablecellproperties/commands/tablecellborderstylecommand.js +44 -0
  449. package/src/tablecellproperties/commands/tablecellborderwidthcommand.d.ts +51 -0
  450. package/src/tablecellproperties/commands/tablecellborderwidthcommand.js +64 -0
  451. package/src/tablecellproperties/commands/tablecellheightcommand.d.ts +46 -0
  452. package/src/tablecellproperties/commands/tablecellheightcommand.js +51 -0
  453. package/src/tablecellproperties/commands/tablecellhorizontalalignmentcommand.d.ts +32 -0
  454. package/src/tablecellproperties/commands/tablecellhorizontalalignmentcommand.js +30 -0
  455. package/src/tablecellproperties/commands/tablecellpaddingcommand.d.ts +51 -0
  456. package/src/tablecellproperties/commands/tablecellpaddingcommand.js +64 -0
  457. package/src/tablecellproperties/commands/tablecellpropertycommand.d.ts +62 -0
  458. package/src/tablecellproperties/commands/tablecellpropertycommand.js +92 -0
  459. package/src/tablecellproperties/commands/tablecellverticalalignmentcommand.d.ts +40 -0
  460. package/src/tablecellproperties/commands/tablecellverticalalignmentcommand.js +38 -0
  461. package/src/tablecellproperties/tablecellpropertiesediting.d.ts +47 -0
  462. package/src/tablecellproperties/tablecellpropertiesediting.js +247 -0
  463. package/src/tablecellproperties/tablecellpropertiesui.d.ts +116 -0
  464. package/src/tablecellproperties/tablecellpropertiesui.js +336 -0
  465. package/src/tablecellproperties/ui/tablecellpropertiesview.d.ts +228 -0
  466. package/src/tablecellproperties/ui/tablecellpropertiesview.js +541 -0
  467. package/src/tablecellproperties.d.ts +34 -0
  468. package/src/tablecellproperties.js +40 -0
  469. package/src/tablecellwidth/commands/tablecellwidthcommand.d.ts +46 -0
  470. package/src/tablecellwidth/commands/tablecellwidthcommand.js +51 -0
  471. package/src/tablecellwidth/tablecellwidthediting.d.ts +33 -0
  472. package/src/tablecellwidth/tablecellwidthediting.js +51 -0
  473. package/src/tableclipboard.d.ts +74 -0
  474. package/src/tableclipboard.js +473 -0
  475. package/src/tablecolumnresize/constants.d.ts +20 -0
  476. package/src/tablecolumnresize/constants.js +20 -0
  477. package/src/tablecolumnresize/converters.d.ts +18 -0
  478. package/src/tablecolumnresize/converters.js +46 -0
  479. package/src/tablecolumnresize/tablecolumnresizeediting.d.ts +143 -0
  480. package/src/tablecolumnresize/tablecolumnresizeediting.js +589 -0
  481. package/src/tablecolumnresize/tablewidthscommand.d.ts +38 -0
  482. package/src/tablecolumnresize/tablewidthscommand.js +61 -0
  483. package/src/tablecolumnresize/utils.d.ts +148 -0
  484. package/src/tablecolumnresize/utils.js +358 -0
  485. package/src/tablecolumnresize.d.ts +30 -0
  486. package/src/tablecolumnresize.js +36 -0
  487. package/src/tableconfig.d.ts +343 -0
  488. package/src/tableconfig.js +5 -0
  489. package/src/tableediting.d.ts +102 -0
  490. package/src/tableediting.js +197 -0
  491. package/src/tablekeyboard.d.ts +72 -0
  492. package/src/tablekeyboard.js +310 -0
  493. package/src/tablemouse/mouseeventsobserver.d.ts +62 -0
  494. package/src/tablemouse/mouseeventsobserver.js +35 -0
  495. package/src/tablemouse.d.ts +52 -0
  496. package/src/tablemouse.js +178 -0
  497. package/src/tableproperties/commands/tablealignmentcommand.d.ts +32 -0
  498. package/src/tableproperties/commands/tablealignmentcommand.js +30 -0
  499. package/src/tableproperties/commands/tablebackgroundcolorcommand.d.ts +32 -0
  500. package/src/tableproperties/commands/tablebackgroundcolorcommand.js +30 -0
  501. package/src/tableproperties/commands/tablebordercolorcommand.d.ts +37 -0
  502. package/src/tableproperties/commands/tablebordercolorcommand.js +44 -0
  503. package/src/tableproperties/commands/tableborderstylecommand.d.ts +37 -0
  504. package/src/tableproperties/commands/tableborderstylecommand.js +44 -0
  505. package/src/tableproperties/commands/tableborderwidthcommand.d.ts +51 -0
  506. package/src/tableproperties/commands/tableborderwidthcommand.js +64 -0
  507. package/src/tableproperties/commands/tableheightcommand.d.ts +46 -0
  508. package/src/tableproperties/commands/tableheightcommand.js +54 -0
  509. package/src/tableproperties/commands/tablepropertycommand.d.ts +61 -0
  510. package/src/tableproperties/commands/tablepropertycommand.js +81 -0
  511. package/src/tableproperties/commands/tablewidthcommand.d.ts +46 -0
  512. package/src/tableproperties/commands/tablewidthcommand.js +54 -0
  513. package/src/tableproperties/tablepropertiesediting.d.ts +44 -0
  514. package/src/tableproperties/tablepropertiesediting.js +212 -0
  515. package/src/tableproperties/tablepropertiesui.d.ts +118 -0
  516. package/src/tableproperties/tablepropertiesui.js +327 -0
  517. package/src/tableproperties/ui/tablepropertiesview.d.ts +207 -0
  518. package/src/tableproperties/ui/tablepropertiesview.js +458 -0
  519. package/src/tableproperties.d.ts +34 -0
  520. package/src/tableproperties.js +40 -0
  521. package/src/tableselection.d.ts +111 -0
  522. package/src/tableselection.js +303 -0
  523. package/src/tabletoolbar.d.ts +36 -0
  524. package/src/tabletoolbar.js +63 -0
  525. package/src/tableui.d.ts +58 -0
  526. package/src/tableui.js +337 -0
  527. package/src/tableutils.d.ts +452 -0
  528. package/src/tableutils.js +1076 -0
  529. package/src/tablewalker.d.ts +362 -0
  530. package/src/tablewalker.js +393 -0
  531. package/src/ui/colorinputview.d.ts +140 -0
  532. package/src/ui/colorinputview.js +271 -0
  533. package/src/ui/formrowview.d.ts +61 -0
  534. package/src/ui/formrowview.js +57 -0
  535. package/src/ui/inserttableview.d.ts +81 -0
  536. package/src/ui/inserttableview.js +178 -0
  537. package/src/utils/common.d.ts +46 -0
  538. package/src/utils/common.js +68 -0
  539. package/src/utils/structure.d.ts +245 -0
  540. package/src/utils/structure.js +426 -0
  541. package/src/utils/table-properties.d.ts +97 -0
  542. package/src/utils/table-properties.js +115 -0
  543. package/src/utils/ui/contextualballoon.d.ts +34 -0
  544. package/src/utils/ui/contextualballoon.js +109 -0
  545. package/src/utils/ui/table-properties.d.ts +195 -0
  546. package/src/utils/ui/table-properties.js +362 -0
  547. package/src/utils/ui/widget.d.ts +20 -0
  548. package/src/utils/ui/widget.js +48 -0
  549. package/theme/colorinput.css +39 -0
  550. package/theme/form.css +11 -0
  551. package/theme/formrow.css +23 -0
  552. package/theme/icons/table-cell-properties.svg +1 -0
  553. package/theme/icons/table-column.svg +1 -0
  554. package/theme/icons/table-merge-cell.svg +1 -0
  555. package/theme/icons/table-properties.svg +1 -0
  556. package/theme/icons/table-row.svg +1 -0
  557. package/theme/inserttable.css +10 -0
  558. package/theme/table.css +84 -0
  559. package/theme/tablecaption.css +63 -0
  560. package/theme/tablecellproperties.css +28 -0
  561. package/theme/tablecolumnresize.css +67 -0
  562. package/theme/tableediting.css +10 -0
  563. package/theme/tableform.css +59 -0
  564. package/theme/tableproperties.css +18 -0
  565. package/theme/tableselection.css +10 -0
@@ -0,0 +1,51 @@
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
+ import TableCellPropertyCommand from '../../tablecellproperties/commands/tablecellpropertycommand.js';
6
+ import { addDefaultUnitToNumericValue } from '../../utils/table-properties.js';
7
+ /**
8
+ * The table cell width command.
9
+ *
10
+ * The command is registered by the {@link module:table/tablecellwidth/tablecellwidthediting~TableCellWidthEditing} as
11
+ * the `'tableCellWidth'` editor command.
12
+ *
13
+ * To change the width of selected cells, execute the command:
14
+ *
15
+ * ```ts
16
+ * editor.execute( 'tableCellWidth', {
17
+ * value: '50px'
18
+ * } );
19
+ * ```
20
+ *
21
+ * **Note**: This command adds a default `'px'` unit to numeric values. Executing:
22
+ *
23
+ * ```ts
24
+ * editor.execute( 'tableCellWidth', {
25
+ * value: '50'
26
+ * } );
27
+ * ```
28
+ *
29
+ * will set the `width` attribute to `'50px'` in the model.
30
+ */
31
+ export default class TableCellWidthCommand extends TableCellPropertyCommand {
32
+ /**
33
+ * Creates a new `TableCellWidthCommand` instance.
34
+ *
35
+ * @param editor An editor in which this command will be used.
36
+ * @param defaultValue The default value of the attribute.
37
+ */
38
+ constructor(editor, defaultValue) {
39
+ super(editor, 'tableCellWidth', defaultValue);
40
+ }
41
+ /**
42
+ * @inheritDoc
43
+ */
44
+ _getValueToSet(value) {
45
+ value = addDefaultUnitToNumericValue(value, 'px');
46
+ if (value === this._defaultValue) {
47
+ return;
48
+ }
49
+ return value;
50
+ }
51
+ }
@@ -0,0 +1,33 @@
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 table/tablecellwidth/tablecellwidthediting
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import TableEditing from './../tableediting.js';
10
+ /**
11
+ * The table cell width editing feature.
12
+ *
13
+ * Introduces `tableCellWidth` table cell model attribute alongside with its converters
14
+ * and a command.
15
+ */
16
+ export default class TableCellWidthEditing extends Plugin {
17
+ /**
18
+ * @inheritDoc
19
+ */
20
+ static get pluginName(): "TableCellWidthEditing";
21
+ /**
22
+ * @inheritDoc
23
+ */
24
+ static get isOfficialPlugin(): true;
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ static get requires(): readonly [typeof TableEditing];
29
+ /**
30
+ * @inheritDoc
31
+ */
32
+ init(): void;
33
+ }
@@ -0,0 +1,51 @@
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 table/tablecellwidth/tablecellwidthediting
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import TableEditing from './../tableediting.js';
10
+ import TableCellWidthCommand from './commands/tablecellwidthcommand.js';
11
+ import { getNormalizedDefaultCellProperties } from '../utils/table-properties.js';
12
+ import { enableProperty } from '../utils/common.js';
13
+ /**
14
+ * The table cell width editing feature.
15
+ *
16
+ * Introduces `tableCellWidth` table cell model attribute alongside with its converters
17
+ * and a command.
18
+ */
19
+ export default class TableCellWidthEditing extends Plugin {
20
+ /**
21
+ * @inheritDoc
22
+ */
23
+ static get pluginName() {
24
+ return 'TableCellWidthEditing';
25
+ }
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ static get isOfficialPlugin() {
30
+ return true;
31
+ }
32
+ /**
33
+ * @inheritDoc
34
+ */
35
+ static get requires() {
36
+ return [TableEditing];
37
+ }
38
+ /**
39
+ * @inheritDoc
40
+ */
41
+ init() {
42
+ const editor = this.editor;
43
+ const defaultTableCellProperties = getNormalizedDefaultCellProperties(editor.config.get('table.tableCellProperties.defaultProperties'));
44
+ enableProperty(editor.model.schema, editor.conversion, {
45
+ modelAttribute: 'tableCellWidth',
46
+ styleName: 'width',
47
+ defaultValue: defaultTableCellProperties.width
48
+ });
49
+ editor.commands.add('tableCellWidth', new TableCellWidthCommand(editor, defaultTableCellProperties.width));
50
+ }
51
+ }
@@ -0,0 +1,74 @@
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
+ import { ClipboardPipeline, ClipboardMarkersUtils } from 'ckeditor5/src/clipboard.js';
6
+ import { Plugin } from 'ckeditor5/src/core.js';
7
+ import type { DocumentFragment, Element, Item, Model, Position, Writer } from 'ckeditor5/src/engine.js';
8
+ import TableSelection from './tableselection.js';
9
+ import { type TableSlot } from './tablewalker.js';
10
+ import TableUtils from './tableutils.js';
11
+ /**
12
+ * This plugin adds support for copying/cutting/pasting fragments of tables.
13
+ * It is loaded automatically by the {@link module:table/table~Table} plugin.
14
+ */
15
+ export default class TableClipboard extends Plugin {
16
+ /**
17
+ * @inheritDoc
18
+ */
19
+ static get pluginName(): "TableClipboard";
20
+ /**
21
+ * @inheritDoc
22
+ */
23
+ static get isOfficialPlugin(): true;
24
+ /**
25
+ * @inheritDoc
26
+ */
27
+ static get requires(): readonly [typeof ClipboardMarkersUtils, typeof ClipboardPipeline, typeof TableSelection, typeof TableUtils];
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ init(): void;
32
+ /**
33
+ * Copies table content to a clipboard on "copy" & "cut" events.
34
+ *
35
+ * @param evt An object containing information about the handled event.
36
+ * @param data Clipboard event data.
37
+ */
38
+ private _onCopyCut;
39
+ /**
40
+ * Overrides default {@link module:engine/model/model~Model#insertContent `model.insertContent()`} method to handle pasting table inside
41
+ * selected table fragment.
42
+ *
43
+ * Depending on selected table fragment:
44
+ * - If a selected table fragment is smaller than paste table it will crop pasted table to match dimensions.
45
+ * - If dimensions are equal it will replace selected table fragment with a pasted table contents.
46
+ *
47
+ * @param content The content to insert.
48
+ * @param selectable The selection into which the content should be inserted.
49
+ * If not provided the current model document selection will be used.
50
+ */
51
+ private _onInsertContent;
52
+ /**
53
+ * Inserts provided `selectedTableCells` into `pastedTable`.
54
+ */
55
+ private _replaceSelectedCells;
56
+ /**
57
+ * Replaces the part of selectedTable with pastedTable.
58
+ */
59
+ private _replaceSelectedCellsWithPasted;
60
+ /**
61
+ * Replaces a single table slot.
62
+ *
63
+ * @returns Inserted table cell or null if slot should remain empty.
64
+ * @private
65
+ */
66
+ _replaceTableSlotCell(tableSlot: TableSlot, cellToInsert: Element | null, insertPosition: Position, writer: Writer): Element | null;
67
+ /**
68
+ * Extracts the table for pasting into a table.
69
+ *
70
+ * @param content The content to insert.
71
+ * @param model The editor model.
72
+ */
73
+ getTableIfOnlyTableInContent(content: DocumentFragment | Item, model: Model): Element | null;
74
+ }
@@ -0,0 +1,473 @@
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
+ import { ClipboardPipeline, ClipboardMarkersUtils } from 'ckeditor5/src/clipboard.js';
6
+ import { Plugin } from 'ckeditor5/src/core.js';
7
+ import TableSelection from './tableselection.js';
8
+ import TableWalker from './tablewalker.js';
9
+ import TableUtils from './tableutils.js';
10
+ import { cropTableToDimensions, getHorizontallyOverlappingCells, getVerticallyOverlappingCells, removeEmptyRowsColumns, splitHorizontally, splitVertically, trimTableCellIfNeeded, adjustLastRowIndex, adjustLastColumnIndex } from './utils/structure.js';
11
+ /**
12
+ * This plugin adds support for copying/cutting/pasting fragments of tables.
13
+ * It is loaded automatically by the {@link module:table/table~Table} plugin.
14
+ */
15
+ export default class TableClipboard extends Plugin {
16
+ /**
17
+ * @inheritDoc
18
+ */
19
+ static get pluginName() {
20
+ return 'TableClipboard';
21
+ }
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ static get isOfficialPlugin() {
26
+ return true;
27
+ }
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ static get requires() {
32
+ return [ClipboardMarkersUtils, ClipboardPipeline, TableSelection, TableUtils];
33
+ }
34
+ /**
35
+ * @inheritDoc
36
+ */
37
+ init() {
38
+ const editor = this.editor;
39
+ const viewDocument = editor.editing.view.document;
40
+ this.listenTo(viewDocument, 'copy', (evt, data) => this._onCopyCut(evt, data));
41
+ this.listenTo(viewDocument, 'cut', (evt, data) => this._onCopyCut(evt, data));
42
+ this.listenTo(editor.model, 'insertContent', (evt, [content, selectable]) => this._onInsertContent(evt, content, selectable), { priority: 'high' });
43
+ this.decorate('_replaceTableSlotCell');
44
+ }
45
+ /**
46
+ * Copies table content to a clipboard on "copy" & "cut" events.
47
+ *
48
+ * @param evt An object containing information about the handled event.
49
+ * @param data Clipboard event data.
50
+ */
51
+ _onCopyCut(evt, data) {
52
+ const view = this.editor.editing.view;
53
+ const tableSelection = this.editor.plugins.get(TableSelection);
54
+ const clipboardMarkersUtils = this.editor.plugins.get(ClipboardMarkersUtils);
55
+ if (!tableSelection.getSelectedTableCells()) {
56
+ return;
57
+ }
58
+ if (evt.name == 'cut' && !this.editor.model.canEditAt(this.editor.model.document.selection)) {
59
+ return;
60
+ }
61
+ data.preventDefault();
62
+ evt.stop();
63
+ this.editor.model.enqueueChange({ isUndoable: evt.name === 'cut' }, () => {
64
+ const documentFragment = clipboardMarkersUtils._copySelectedFragmentWithMarkers(evt.name, this.editor.model.document.selection, () => tableSelection.getSelectionAsFragment());
65
+ view.document.fire('clipboardOutput', {
66
+ dataTransfer: data.dataTransfer,
67
+ content: this.editor.data.toView(documentFragment),
68
+ method: evt.name
69
+ });
70
+ });
71
+ }
72
+ /**
73
+ * Overrides default {@link module:engine/model/model~Model#insertContent `model.insertContent()`} method to handle pasting table inside
74
+ * selected table fragment.
75
+ *
76
+ * Depending on selected table fragment:
77
+ * - If a selected table fragment is smaller than paste table it will crop pasted table to match dimensions.
78
+ * - If dimensions are equal it will replace selected table fragment with a pasted table contents.
79
+ *
80
+ * @param content The content to insert.
81
+ * @param selectable The selection into which the content should be inserted.
82
+ * If not provided the current model document selection will be used.
83
+ */
84
+ _onInsertContent(evt, content, selectable) {
85
+ if (selectable && !selectable.is('documentSelection')) {
86
+ return;
87
+ }
88
+ const model = this.editor.model;
89
+ const tableUtils = this.editor.plugins.get(TableUtils);
90
+ const clipboardMarkersUtils = this.editor.plugins.get(ClipboardMarkersUtils);
91
+ // We might need to crop table before inserting so reference might change.
92
+ const pastedTable = this.getTableIfOnlyTableInContent(content, model);
93
+ if (!pastedTable) {
94
+ return;
95
+ }
96
+ const selectedTableCells = tableUtils.getSelectionAffectedTableCells(model.document.selection);
97
+ if (!selectedTableCells.length) {
98
+ removeEmptyRowsColumns(pastedTable, tableUtils);
99
+ return;
100
+ }
101
+ // Override default model.insertContent() handling at this point.
102
+ evt.stop();
103
+ if (content.is('documentFragment')) {
104
+ clipboardMarkersUtils._pasteMarkersIntoTransformedElement(content.markers, writer => this._replaceSelectedCells(pastedTable, selectedTableCells, writer));
105
+ }
106
+ else {
107
+ this.editor.model.change(writer => {
108
+ this._replaceSelectedCells(pastedTable, selectedTableCells, writer);
109
+ });
110
+ }
111
+ }
112
+ /**
113
+ * Inserts provided `selectedTableCells` into `pastedTable`.
114
+ */
115
+ _replaceSelectedCells(pastedTable, selectedTableCells, writer) {
116
+ const tableUtils = this.editor.plugins.get(TableUtils);
117
+ const pastedDimensions = {
118
+ width: tableUtils.getColumns(pastedTable),
119
+ height: tableUtils.getRows(pastedTable)
120
+ };
121
+ // Prepare the table for pasting.
122
+ const selection = prepareTableForPasting(selectedTableCells, pastedDimensions, writer, tableUtils);
123
+ // Beyond this point we operate on a fixed content table with rectangular selection and proper last row/column values.
124
+ const selectionHeight = selection.lastRow - selection.firstRow + 1;
125
+ const selectionWidth = selection.lastColumn - selection.firstColumn + 1;
126
+ // Crop pasted table if:
127
+ // - Pasted table dimensions exceeds selection area.
128
+ // - Pasted table has broken layout (ie some cells sticks out by the table dimensions established by the first and last row).
129
+ //
130
+ // Note: The table dimensions are established by the width of the first row and the total number of rows.
131
+ // It is possible to programmatically create a table that has rows which would have cells anchored beyond first row width but
132
+ // such table will not be created by other editing solutions.
133
+ const cropDimensions = {
134
+ startRow: 0,
135
+ startColumn: 0,
136
+ endRow: Math.min(selectionHeight, pastedDimensions.height) - 1,
137
+ endColumn: Math.min(selectionWidth, pastedDimensions.width) - 1
138
+ };
139
+ pastedTable = cropTableToDimensions(pastedTable, cropDimensions, writer);
140
+ // Content table to which we insert a pasted table.
141
+ const selectedTable = selectedTableCells[0].findAncestor('table');
142
+ const cellsToSelect = this._replaceSelectedCellsWithPasted(pastedTable, pastedDimensions, selectedTable, selection, writer);
143
+ if (this.editor.plugins.get('TableSelection').isEnabled) {
144
+ // Selection ranges must be sorted because the first and last selection ranges are considered
145
+ // as anchor/focus cell ranges for multi-cell selection.
146
+ const selectionRanges = tableUtils.sortRanges(cellsToSelect.map(cell => writer.createRangeOn(cell)));
147
+ writer.setSelection(selectionRanges);
148
+ }
149
+ else {
150
+ // Set selection inside first cell if multi-cell selection is disabled.
151
+ writer.setSelection(cellsToSelect[0], 0);
152
+ }
153
+ return selectedTable;
154
+ }
155
+ /**
156
+ * Replaces the part of selectedTable with pastedTable.
157
+ */
158
+ _replaceSelectedCellsWithPasted(pastedTable, pastedDimensions, selectedTable, selection, writer) {
159
+ const { width: pastedWidth, height: pastedHeight } = pastedDimensions;
160
+ // Holds two-dimensional array that is addressed by [ row ][ column ] that stores cells anchored at given location.
161
+ const pastedTableLocationMap = createLocationMap(pastedTable, pastedWidth, pastedHeight);
162
+ const selectedTableMap = [...new TableWalker(selectedTable, {
163
+ startRow: selection.firstRow,
164
+ endRow: selection.lastRow,
165
+ startColumn: selection.firstColumn,
166
+ endColumn: selection.lastColumn,
167
+ includeAllSlots: true
168
+ })];
169
+ // Selection must be set to pasted cells (some might be removed or new created).
170
+ const cellsToSelect = [];
171
+ // Store next cell insert position.
172
+ let insertPosition;
173
+ // Content table replace cells algorithm iterates over a selected table fragment and:
174
+ //
175
+ // - Removes existing table cells at current slot (location).
176
+ // - Inserts cell from a pasted table for a matched slots.
177
+ //
178
+ // This ensures proper table geometry after the paste
179
+ for (const tableSlot of selectedTableMap) {
180
+ const { row, column } = tableSlot;
181
+ // Save the insert position for current row start.
182
+ if (column === selection.firstColumn) {
183
+ insertPosition = tableSlot.getPositionBefore();
184
+ }
185
+ // Map current table slot location to an pasted table slot location.
186
+ const pastedRow = row - selection.firstRow;
187
+ const pastedColumn = column - selection.firstColumn;
188
+ const pastedCell = pastedTableLocationMap[pastedRow % pastedHeight][pastedColumn % pastedWidth];
189
+ // Clone cell to insert (to duplicate its attributes and children).
190
+ // Cloning is required to support repeating pasted table content when inserting to a bigger selection.
191
+ const cellToInsert = pastedCell ? writer.cloneElement(pastedCell) : null;
192
+ // Replace the cell from the current slot with new table cell.
193
+ const newTableCell = this._replaceTableSlotCell(tableSlot, cellToInsert, insertPosition, writer);
194
+ // The cell was only removed.
195
+ if (!newTableCell) {
196
+ continue;
197
+ }
198
+ // Trim the cell if it's row/col-spans would exceed selection area.
199
+ trimTableCellIfNeeded(newTableCell, row, column, selection.lastRow, selection.lastColumn, writer);
200
+ cellsToSelect.push(newTableCell);
201
+ insertPosition = writer.createPositionAfter(newTableCell);
202
+ }
203
+ // If there are any headings, all the cells that overlap from heading must be splitted.
204
+ const headingRows = parseInt(selectedTable.getAttribute('headingRows') || '0');
205
+ const headingColumns = parseInt(selectedTable.getAttribute('headingColumns') || '0');
206
+ const areHeadingRowsIntersectingSelection = selection.firstRow < headingRows && headingRows <= selection.lastRow;
207
+ const areHeadingColumnsIntersectingSelection = selection.firstColumn < headingColumns && headingColumns <= selection.lastColumn;
208
+ if (areHeadingRowsIntersectingSelection) {
209
+ const columnsLimit = { first: selection.firstColumn, last: selection.lastColumn };
210
+ const newCells = doHorizontalSplit(selectedTable, headingRows, columnsLimit, writer, selection.firstRow);
211
+ cellsToSelect.push(...newCells);
212
+ }
213
+ if (areHeadingColumnsIntersectingSelection) {
214
+ const rowsLimit = { first: selection.firstRow, last: selection.lastRow };
215
+ const newCells = doVerticalSplit(selectedTable, headingColumns, rowsLimit, writer);
216
+ cellsToSelect.push(...newCells);
217
+ }
218
+ return cellsToSelect;
219
+ }
220
+ /**
221
+ * Replaces a single table slot.
222
+ *
223
+ * @returns Inserted table cell or null if slot should remain empty.
224
+ * @private
225
+ */
226
+ _replaceTableSlotCell(tableSlot, cellToInsert, insertPosition, writer) {
227
+ const { cell, isAnchor } = tableSlot;
228
+ // If the slot is occupied by a cell in a selected table - remove it.
229
+ // The slot of this cell will be either:
230
+ // - Replaced by a pasted table cell.
231
+ // - Spanned by a previously pasted table cell.
232
+ if (isAnchor) {
233
+ writer.remove(cell);
234
+ }
235
+ // There is no cell to insert (might be spanned by other cell in a pasted table) - advance to the next content table slot.
236
+ if (!cellToInsert) {
237
+ return null;
238
+ }
239
+ writer.insert(cellToInsert, insertPosition);
240
+ return cellToInsert;
241
+ }
242
+ /**
243
+ * Extracts the table for pasting into a table.
244
+ *
245
+ * @param content The content to insert.
246
+ * @param model The editor model.
247
+ */
248
+ getTableIfOnlyTableInContent(content, model) {
249
+ if (!content.is('documentFragment') && !content.is('element')) {
250
+ return null;
251
+ }
252
+ // Table passed directly.
253
+ if (content.is('element', 'table')) {
254
+ return content;
255
+ }
256
+ // We do not support mixed content when pasting table into table.
257
+ // See: https://github.com/ckeditor/ckeditor5/issues/6817.
258
+ if (content.childCount == 1 && content.getChild(0).is('element', 'table')) {
259
+ return content.getChild(0);
260
+ }
261
+ // If there are only whitespaces around a table then use that table for pasting.
262
+ const contentRange = model.createRangeIn(content);
263
+ for (const element of contentRange.getItems()) {
264
+ if (element.is('element', 'table')) {
265
+ // Stop checking if there is some content before table.
266
+ const rangeBefore = model.createRange(contentRange.start, model.createPositionBefore(element));
267
+ if (model.hasContent(rangeBefore, { ignoreWhitespaces: true })) {
268
+ return null;
269
+ }
270
+ // Stop checking if there is some content after table.
271
+ const rangeAfter = model.createRange(model.createPositionAfter(element), contentRange.end);
272
+ if (model.hasContent(rangeAfter, { ignoreWhitespaces: true })) {
273
+ return null;
274
+ }
275
+ // There wasn't any content neither before nor after.
276
+ return element;
277
+ }
278
+ }
279
+ return null;
280
+ }
281
+ }
282
+ /**
283
+ * Prepares a table for pasting and returns adjusted selection dimensions.
284
+ */
285
+ function prepareTableForPasting(selectedTableCells, pastedDimensions, writer, tableUtils) {
286
+ const selectedTable = selectedTableCells[0].findAncestor('table');
287
+ const columnIndexes = tableUtils.getColumnIndexes(selectedTableCells);
288
+ const rowIndexes = tableUtils.getRowIndexes(selectedTableCells);
289
+ const selection = {
290
+ firstColumn: columnIndexes.first,
291
+ lastColumn: columnIndexes.last,
292
+ firstRow: rowIndexes.first,
293
+ lastRow: rowIndexes.last
294
+ };
295
+ // Single cell selected - expand selection to pasted table dimensions.
296
+ const shouldExpandSelection = selectedTableCells.length === 1;
297
+ if (shouldExpandSelection) {
298
+ selection.lastRow += pastedDimensions.height - 1;
299
+ selection.lastColumn += pastedDimensions.width - 1;
300
+ expandTableSize(selectedTable, selection.lastRow + 1, selection.lastColumn + 1, tableUtils);
301
+ }
302
+ // In case of expanding selection we do not reset the selection so in this case we will always try to fix selection
303
+ // like in the case of a non-rectangular area. This might be fixed by re-setting selected cells array but this shortcut is safe.
304
+ if (shouldExpandSelection || !tableUtils.isSelectionRectangular(selectedTableCells)) {
305
+ // For a non-rectangular selection (ie in which some cells sticks out from a virtual selection rectangle) we need to create
306
+ // a table layout that has a rectangular selection. This will split cells so the selection become rectangular.
307
+ // Beyond this point we will operate on fixed content table.
308
+ splitCellsToRectangularSelection(selectedTable, selection, writer);
309
+ }
310
+ // However a selected table fragment might be invalid if examined alone. Ie such table fragment:
311
+ //
312
+ // +---+---+---+---+
313
+ // 0 | a | b | c | d |
314
+ // + + +---+---+
315
+ // 1 | | e | f | g |
316
+ // + +---+ +---+
317
+ // 2 | | h | | i | <- last row, each cell has rowspan = 2,
318
+ // + + + + + so we need to return 3, not 2
319
+ // 3 | | | | |
320
+ // +---+---+---+---+
321
+ //
322
+ // is invalid as the cells "h" and "i" have rowspans.
323
+ // This case needs only adjusting the selection dimension as the rest of the algorithm operates on empty slots also.
324
+ else {
325
+ selection.lastRow = adjustLastRowIndex(selectedTable, selection);
326
+ selection.lastColumn = adjustLastColumnIndex(selectedTable, selection);
327
+ }
328
+ return selection;
329
+ }
330
+ /**
331
+ * Expand table (in place) to expected size.
332
+ */
333
+ function expandTableSize(table, expectedHeight, expectedWidth, tableUtils) {
334
+ const tableWidth = tableUtils.getColumns(table);
335
+ const tableHeight = tableUtils.getRows(table);
336
+ if (expectedWidth > tableWidth) {
337
+ tableUtils.insertColumns(table, {
338
+ at: tableWidth,
339
+ columns: expectedWidth - tableWidth
340
+ });
341
+ }
342
+ if (expectedHeight > tableHeight) {
343
+ tableUtils.insertRows(table, {
344
+ at: tableHeight,
345
+ rows: expectedHeight - tableHeight
346
+ });
347
+ }
348
+ }
349
+ /**
350
+ * Returns two-dimensional array that is addressed by [ row ][ column ] that stores cells anchored at given location.
351
+ *
352
+ * At given row & column location it might be one of:
353
+ *
354
+ * * cell - cell from pasted table anchored at this location.
355
+ * * null - if no cell is anchored at this location.
356
+ *
357
+ * For instance, from a table below:
358
+ *
359
+ * +----+----+----+----+
360
+ * | 00 | 01 | 02 | 03 |
361
+ * + +----+----+----+
362
+ * | | 11 | 13 |
363
+ * +----+ +----+
364
+ * | 20 | | 23 |
365
+ * +----+----+----+----+
366
+ *
367
+ * The method will return an array (numbers represents cell element):
368
+ *
369
+ * ```ts
370
+ * const map = [
371
+ * [ '00', '01', '02', '03' ],
372
+ * [ null, '11', null, '13' ],
373
+ * [ '20', null, null, '23' ]
374
+ * ]
375
+ * ```
376
+ *
377
+ * This allows for a quick access to table at give row & column. For instance to access table cell "13" from pasted table call:
378
+ *
379
+ * ```ts
380
+ * const cell = map[ 1 ][ 3 ]
381
+ * ```
382
+ */
383
+ function createLocationMap(table, width, height) {
384
+ // Create height x width (row x column) two-dimensional table to store cells.
385
+ const map = new Array(height).fill(null)
386
+ .map(() => new Array(width).fill(null));
387
+ for (const { column, row, cell } of new TableWalker(table)) {
388
+ map[row][column] = cell;
389
+ }
390
+ return map;
391
+ }
392
+ /**
393
+ * Make selected cells rectangular by splitting the cells that stand out from a rectangular selection.
394
+ *
395
+ * In the table below a selection is shown with "::" and slots with anchor cells are named.
396
+ *
397
+ * +----+----+----+----+----+ +----+----+----+----+----+
398
+ * | 00 | 01 | 02 | 03 | | 00 | 01 | 02 | 03 |
399
+ * + +----+ +----+----+ | ::::::::::::::::----+
400
+ * | | 11 | | 13 | 14 | | ::11 | | 13:: 14 | <- first row
401
+ * +----+----+ + +----+ +----::---| | ::----+
402
+ * | 20 | 21 | | | 24 | select cells: | 20 ::21 | | :: 24 |
403
+ * +----+----+ +----+----+ 11 -> 33 +----::---| |---::----+
404
+ * | 30 | | 33 | 34 | | 30 :: | | 33:: 34 | <- last row
405
+ * + + +----+ + | :::::::::::::::: +
406
+ * | | | 43 | | | | | 43 | |
407
+ * +----+----+----+----+----+ +----+----+----+----+----+
408
+ * ^ ^
409
+ * first & last columns
410
+ *
411
+ * Will update table to:
412
+ *
413
+ * +----+----+----+----+----+
414
+ * | 00 | 01 | 02 | 03 |
415
+ * + +----+----+----+----+
416
+ * | | 11 | | 13 | 14 |
417
+ * +----+----+ + +----+
418
+ * | 20 | 21 | | | 24 |
419
+ * +----+----+ +----+----+
420
+ * | 30 | | | 33 | 34 |
421
+ * + +----+----+----+ +
422
+ * | | | | 43 | |
423
+ * +----+----+----+----+----+
424
+ *
425
+ * In th example above:
426
+ * - Cell "02" which have `rowspan = 4` must be trimmed at first and at after last row.
427
+ * - Cell "03" which have `rowspan = 2` and `colspan = 2` must be trimmed at first column and after last row.
428
+ * - Cells "00", "03" & "30" which cannot be cut by this algorithm as they are outside the trimmed area.
429
+ * - Cell "13" cannot be cut as it is inside the trimmed area.
430
+ */
431
+ function splitCellsToRectangularSelection(table, dimensions, writer) {
432
+ const { firstRow, lastRow, firstColumn, lastColumn } = dimensions;
433
+ const rowIndexes = { first: firstRow, last: lastRow };
434
+ const columnIndexes = { first: firstColumn, last: lastColumn };
435
+ // 1. Split cells vertically in two steps as first step might create cells that needs to split again.
436
+ doVerticalSplit(table, firstColumn, rowIndexes, writer);
437
+ doVerticalSplit(table, lastColumn + 1, rowIndexes, writer);
438
+ // 2. Split cells horizontally in two steps as first step might create cells that needs to split again.
439
+ doHorizontalSplit(table, firstRow, columnIndexes, writer);
440
+ doHorizontalSplit(table, lastRow + 1, columnIndexes, writer, firstRow);
441
+ }
442
+ function doHorizontalSplit(table, splitRow, limitColumns, writer, startRow = 0) {
443
+ // If selection starts at first row then no split is needed.
444
+ if (splitRow < 1) {
445
+ return;
446
+ }
447
+ const overlappingCells = getVerticallyOverlappingCells(table, splitRow, startRow);
448
+ // Filter out cells that are not touching insides of the rectangular selection.
449
+ const cellsToSplit = overlappingCells.filter(({ column, cellWidth }) => isAffectedBySelection(column, cellWidth, limitColumns));
450
+ return cellsToSplit.map(({ cell }) => splitHorizontally(cell, splitRow, writer));
451
+ }
452
+ function doVerticalSplit(table, splitColumn, limitRows, writer) {
453
+ // If selection starts at first column then no split is needed.
454
+ if (splitColumn < 1) {
455
+ return;
456
+ }
457
+ const overlappingCells = getHorizontallyOverlappingCells(table, splitColumn);
458
+ // Filter out cells that are not touching insides of the rectangular selection.
459
+ const cellsToSplit = overlappingCells.filter(({ row, cellHeight }) => isAffectedBySelection(row, cellHeight, limitRows));
460
+ return cellsToSplit.map(({ cell, column }) => splitVertically(cell, column, splitColumn, writer));
461
+ }
462
+ /**
463
+ * Checks if cell at given row (column) is affected by a rectangular selection defined by first/last column (row).
464
+ *
465
+ * The same check is used for row as for column.
466
+ */
467
+ function isAffectedBySelection(index, span, limit) {
468
+ const endIndex = index + span - 1;
469
+ const { first, last } = limit;
470
+ const isInsideSelection = index >= first && index <= last;
471
+ const overlapsSelectionFromOutside = index < first && endIndex >= first;
472
+ return isInsideSelection || overlapsSelectionFromOutside;
473
+ }