@ckeditor/ckeditor5-table 44.3.0-alpha.7 → 45.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (366) hide show
  1. package/LICENSE.md +1 -1
  2. package/build/table.js +2 -2
  3. package/build/translations/af.js +1 -1
  4. package/build/translations/ar.js +1 -1
  5. package/build/translations/ast.js +1 -1
  6. package/build/translations/az.js +1 -1
  7. package/build/translations/be.js +1 -0
  8. package/build/translations/bg.js +1 -1
  9. package/build/translations/bn.js +1 -1
  10. package/build/translations/bs.js +1 -1
  11. package/build/translations/ca.js +1 -1
  12. package/build/translations/cs.js +1 -1
  13. package/build/translations/da.js +1 -1
  14. package/build/translations/de-ch.js +1 -1
  15. package/build/translations/de.js +1 -1
  16. package/build/translations/el.js +1 -1
  17. package/build/translations/en-au.js +1 -1
  18. package/build/translations/en-gb.js +1 -1
  19. package/build/translations/eo.js +1 -1
  20. package/build/translations/es-co.js +1 -1
  21. package/build/translations/es.js +1 -1
  22. package/build/translations/et.js +1 -1
  23. package/build/translations/eu.js +1 -1
  24. package/build/translations/fa.js +1 -1
  25. package/build/translations/fi.js +1 -1
  26. package/build/translations/fr.js +1 -1
  27. package/build/translations/gl.js +1 -1
  28. package/build/translations/gu.js +1 -1
  29. package/build/translations/he.js +1 -1
  30. package/build/translations/hi.js +1 -1
  31. package/build/translations/hr.js +1 -1
  32. package/build/translations/hu.js +1 -1
  33. package/build/translations/hy.js +1 -1
  34. package/build/translations/id.js +1 -1
  35. package/build/translations/it.js +1 -1
  36. package/build/translations/ja.js +1 -1
  37. package/build/translations/jv.js +1 -1
  38. package/build/translations/kk.js +1 -1
  39. package/build/translations/km.js +1 -1
  40. package/build/translations/kn.js +1 -1
  41. package/build/translations/ko.js +1 -1
  42. package/build/translations/ku.js +1 -1
  43. package/build/translations/lt.js +1 -1
  44. package/build/translations/lv.js +1 -1
  45. package/build/translations/ms.js +1 -1
  46. package/build/translations/nb.js +1 -1
  47. package/build/translations/ne.js +1 -1
  48. package/build/translations/nl.js +1 -1
  49. package/build/translations/no.js +1 -1
  50. package/build/translations/oc.js +1 -1
  51. package/build/translations/pl.js +1 -1
  52. package/build/translations/pt-br.js +1 -1
  53. package/build/translations/pt.js +1 -1
  54. package/build/translations/ro.js +1 -1
  55. package/build/translations/ru.js +1 -1
  56. package/build/translations/si.js +1 -1
  57. package/build/translations/sk.js +1 -1
  58. package/build/translations/sl.js +1 -1
  59. package/build/translations/sq.js +1 -1
  60. package/build/translations/sr-latn.js +1 -1
  61. package/build/translations/sr.js +1 -1
  62. package/build/translations/sv.js +1 -1
  63. package/build/translations/th.js +1 -1
  64. package/build/translations/ti.js +1 -1
  65. package/build/translations/tk.js +1 -1
  66. package/build/translations/tr.js +1 -1
  67. package/build/translations/tt.js +1 -1
  68. package/build/translations/ug.js +1 -1
  69. package/build/translations/uk.js +1 -1
  70. package/build/translations/ur.js +1 -1
  71. package/build/translations/uz.js +1 -1
  72. package/build/translations/vi.js +1 -1
  73. package/build/translations/zh-cn.js +1 -1
  74. package/build/translations/zh.js +1 -1
  75. package/ckeditor5-metadata.json +64 -6
  76. package/dist/index-content.css +50 -25
  77. package/dist/index-editor.css +115 -16
  78. package/dist/index.css +226 -60
  79. package/dist/index.css.map +1 -1
  80. package/dist/index.js +2907 -2247
  81. package/dist/index.js.map +1 -1
  82. package/dist/translations/af.js +1 -1
  83. package/dist/translations/af.umd.js +1 -1
  84. package/dist/translations/ar.js +1 -1
  85. package/dist/translations/ar.umd.js +1 -1
  86. package/dist/translations/ast.js +1 -1
  87. package/dist/translations/ast.umd.js +1 -1
  88. package/dist/translations/az.js +1 -1
  89. package/dist/translations/az.umd.js +1 -1
  90. package/dist/translations/be.d.ts +8 -0
  91. package/dist/translations/be.js +5 -0
  92. package/dist/translations/be.umd.js +11 -0
  93. package/dist/translations/bg.js +1 -1
  94. package/dist/translations/bg.umd.js +1 -1
  95. package/dist/translations/bn.js +1 -1
  96. package/dist/translations/bn.umd.js +1 -1
  97. package/dist/translations/bs.js +1 -1
  98. package/dist/translations/bs.umd.js +1 -1
  99. package/dist/translations/ca.js +1 -1
  100. package/dist/translations/ca.umd.js +1 -1
  101. package/dist/translations/cs.js +1 -1
  102. package/dist/translations/cs.umd.js +1 -1
  103. package/dist/translations/da.js +1 -1
  104. package/dist/translations/da.umd.js +1 -1
  105. package/dist/translations/de-ch.js +1 -1
  106. package/dist/translations/de-ch.umd.js +1 -1
  107. package/dist/translations/de.js +1 -1
  108. package/dist/translations/de.umd.js +1 -1
  109. package/dist/translations/el.js +1 -1
  110. package/dist/translations/el.umd.js +1 -1
  111. package/dist/translations/en-au.js +1 -1
  112. package/dist/translations/en-au.umd.js +1 -1
  113. package/dist/translations/en-gb.js +1 -1
  114. package/dist/translations/en-gb.umd.js +1 -1
  115. package/dist/translations/en.js +1 -1
  116. package/dist/translations/en.umd.js +1 -1
  117. package/dist/translations/eo.js +1 -1
  118. package/dist/translations/eo.umd.js +1 -1
  119. package/dist/translations/es-co.js +1 -1
  120. package/dist/translations/es-co.umd.js +1 -1
  121. package/dist/translations/es.js +1 -1
  122. package/dist/translations/es.umd.js +1 -1
  123. package/dist/translations/et.js +1 -1
  124. package/dist/translations/et.umd.js +1 -1
  125. package/dist/translations/eu.js +1 -1
  126. package/dist/translations/eu.umd.js +1 -1
  127. package/dist/translations/fa.js +1 -1
  128. package/dist/translations/fa.umd.js +1 -1
  129. package/dist/translations/fi.js +1 -1
  130. package/dist/translations/fi.umd.js +1 -1
  131. package/dist/translations/fr.js +1 -1
  132. package/dist/translations/fr.umd.js +1 -1
  133. package/dist/translations/gl.js +1 -1
  134. package/dist/translations/gl.umd.js +1 -1
  135. package/dist/translations/gu.js +1 -1
  136. package/dist/translations/gu.umd.js +1 -1
  137. package/dist/translations/he.js +1 -1
  138. package/dist/translations/he.umd.js +1 -1
  139. package/dist/translations/hi.js +1 -1
  140. package/dist/translations/hi.umd.js +1 -1
  141. package/dist/translations/hr.js +1 -1
  142. package/dist/translations/hr.umd.js +1 -1
  143. package/dist/translations/hu.js +1 -1
  144. package/dist/translations/hu.umd.js +1 -1
  145. package/dist/translations/hy.js +1 -1
  146. package/dist/translations/hy.umd.js +1 -1
  147. package/dist/translations/id.js +1 -1
  148. package/dist/translations/id.umd.js +1 -1
  149. package/dist/translations/it.js +1 -1
  150. package/dist/translations/it.umd.js +1 -1
  151. package/dist/translations/ja.js +1 -1
  152. package/dist/translations/ja.umd.js +1 -1
  153. package/dist/translations/jv.js +1 -1
  154. package/dist/translations/jv.umd.js +1 -1
  155. package/dist/translations/kk.js +1 -1
  156. package/dist/translations/kk.umd.js +1 -1
  157. package/dist/translations/km.js +1 -1
  158. package/dist/translations/km.umd.js +1 -1
  159. package/dist/translations/kn.js +1 -1
  160. package/dist/translations/kn.umd.js +1 -1
  161. package/dist/translations/ko.js +1 -1
  162. package/dist/translations/ko.umd.js +1 -1
  163. package/dist/translations/ku.js +1 -1
  164. package/dist/translations/ku.umd.js +1 -1
  165. package/dist/translations/lt.js +1 -1
  166. package/dist/translations/lt.umd.js +1 -1
  167. package/dist/translations/lv.js +1 -1
  168. package/dist/translations/lv.umd.js +1 -1
  169. package/dist/translations/ms.js +1 -1
  170. package/dist/translations/ms.umd.js +1 -1
  171. package/dist/translations/nb.js +1 -1
  172. package/dist/translations/nb.umd.js +1 -1
  173. package/dist/translations/ne.js +1 -1
  174. package/dist/translations/ne.umd.js +1 -1
  175. package/dist/translations/nl.js +1 -1
  176. package/dist/translations/nl.umd.js +1 -1
  177. package/dist/translations/no.js +1 -1
  178. package/dist/translations/no.umd.js +1 -1
  179. package/dist/translations/oc.js +1 -1
  180. package/dist/translations/oc.umd.js +1 -1
  181. package/dist/translations/pl.js +1 -1
  182. package/dist/translations/pl.umd.js +1 -1
  183. package/dist/translations/pt-br.js +1 -1
  184. package/dist/translations/pt-br.umd.js +1 -1
  185. package/dist/translations/pt.js +1 -1
  186. package/dist/translations/pt.umd.js +1 -1
  187. package/dist/translations/ro.js +1 -1
  188. package/dist/translations/ro.umd.js +1 -1
  189. package/dist/translations/ru.js +1 -1
  190. package/dist/translations/ru.umd.js +1 -1
  191. package/dist/translations/si.js +1 -1
  192. package/dist/translations/si.umd.js +1 -1
  193. package/dist/translations/sk.js +1 -1
  194. package/dist/translations/sk.umd.js +1 -1
  195. package/dist/translations/sl.js +1 -1
  196. package/dist/translations/sl.umd.js +1 -1
  197. package/dist/translations/sq.js +1 -1
  198. package/dist/translations/sq.umd.js +1 -1
  199. package/dist/translations/sr-latn.js +1 -1
  200. package/dist/translations/sr-latn.umd.js +1 -1
  201. package/dist/translations/sr.js +1 -1
  202. package/dist/translations/sr.umd.js +1 -1
  203. package/dist/translations/sv.js +1 -1
  204. package/dist/translations/sv.umd.js +1 -1
  205. package/dist/translations/th.js +1 -1
  206. package/dist/translations/th.umd.js +1 -1
  207. package/dist/translations/ti.js +1 -1
  208. package/dist/translations/ti.umd.js +1 -1
  209. package/dist/translations/tk.js +1 -1
  210. package/dist/translations/tk.umd.js +1 -1
  211. package/dist/translations/tr.js +1 -1
  212. package/dist/translations/tr.umd.js +1 -1
  213. package/dist/translations/tt.js +1 -1
  214. package/dist/translations/tt.umd.js +1 -1
  215. package/dist/translations/ug.js +1 -1
  216. package/dist/translations/ug.umd.js +1 -1
  217. package/dist/translations/uk.js +1 -1
  218. package/dist/translations/uk.umd.js +1 -1
  219. package/dist/translations/ur.js +1 -1
  220. package/dist/translations/ur.umd.js +1 -1
  221. package/dist/translations/uz.js +1 -1
  222. package/dist/translations/uz.umd.js +1 -1
  223. package/dist/translations/vi.js +1 -1
  224. package/dist/translations/vi.umd.js +1 -1
  225. package/dist/translations/zh-cn.js +1 -1
  226. package/dist/translations/zh-cn.umd.js +1 -1
  227. package/dist/translations/zh.js +1 -1
  228. package/dist/translations/zh.umd.js +1 -1
  229. package/lang/contexts.json +8 -1
  230. package/lang/translations/af.po +28 -0
  231. package/lang/translations/ar.po +28 -0
  232. package/lang/translations/ast.po +28 -0
  233. package/lang/translations/az.po +28 -0
  234. package/lang/translations/be.po +296 -0
  235. package/lang/translations/bg.po +28 -0
  236. package/lang/translations/bn.po +28 -0
  237. package/lang/translations/bs.po +28 -0
  238. package/lang/translations/ca.po +28 -0
  239. package/lang/translations/cs.po +28 -0
  240. package/lang/translations/da.po +28 -0
  241. package/lang/translations/de-ch.po +28 -0
  242. package/lang/translations/de.po +28 -0
  243. package/lang/translations/el.po +28 -0
  244. package/lang/translations/en-au.po +28 -0
  245. package/lang/translations/en-gb.po +28 -0
  246. package/lang/translations/en.po +28 -0
  247. package/lang/translations/eo.po +28 -0
  248. package/lang/translations/es-co.po +28 -0
  249. package/lang/translations/es.po +28 -0
  250. package/lang/translations/et.po +28 -0
  251. package/lang/translations/eu.po +28 -0
  252. package/lang/translations/fa.po +28 -0
  253. package/lang/translations/fi.po +28 -0
  254. package/lang/translations/fr.po +28 -0
  255. package/lang/translations/gl.po +28 -0
  256. package/lang/translations/gu.po +28 -0
  257. package/lang/translations/he.po +28 -0
  258. package/lang/translations/hi.po +28 -0
  259. package/lang/translations/hr.po +28 -0
  260. package/lang/translations/hu.po +28 -0
  261. package/lang/translations/hy.po +28 -0
  262. package/lang/translations/id.po +28 -0
  263. package/lang/translations/it.po +28 -0
  264. package/lang/translations/ja.po +28 -0
  265. package/lang/translations/jv.po +28 -0
  266. package/lang/translations/kk.po +28 -0
  267. package/lang/translations/km.po +28 -0
  268. package/lang/translations/kn.po +28 -0
  269. package/lang/translations/ko.po +28 -0
  270. package/lang/translations/ku.po +28 -0
  271. package/lang/translations/lt.po +28 -0
  272. package/lang/translations/lv.po +28 -0
  273. package/lang/translations/ms.po +28 -0
  274. package/lang/translations/nb.po +28 -0
  275. package/lang/translations/ne.po +28 -0
  276. package/lang/translations/nl.po +28 -0
  277. package/lang/translations/no.po +28 -0
  278. package/lang/translations/oc.po +28 -0
  279. package/lang/translations/pl.po +28 -0
  280. package/lang/translations/pt-br.po +28 -0
  281. package/lang/translations/pt.po +28 -0
  282. package/lang/translations/ro.po +28 -0
  283. package/lang/translations/ru.po +28 -0
  284. package/lang/translations/si.po +28 -0
  285. package/lang/translations/sk.po +28 -0
  286. package/lang/translations/sl.po +28 -0
  287. package/lang/translations/sq.po +28 -0
  288. package/lang/translations/sr-latn.po +28 -0
  289. package/lang/translations/sr.po +28 -0
  290. package/lang/translations/sv.po +28 -0
  291. package/lang/translations/th.po +28 -0
  292. package/lang/translations/ti.po +28 -0
  293. package/lang/translations/tk.po +28 -0
  294. package/lang/translations/tr.po +28 -0
  295. package/lang/translations/tt.po +28 -0
  296. package/lang/translations/ug.po +28 -0
  297. package/lang/translations/uk.po +28 -0
  298. package/lang/translations/ur.po +28 -0
  299. package/lang/translations/uz.po +28 -0
  300. package/lang/translations/vi.po +28 -0
  301. package/lang/translations/zh-cn.po +28 -0
  302. package/lang/translations/zh.po +28 -0
  303. package/package.json +10 -9
  304. package/src/augmentation.d.ts +5 -1
  305. package/src/commands/insertcolumncommand.js +4 -0
  306. package/src/commands/insertrowcommand.js +4 -0
  307. package/src/commands/inserttablelayoutcommand.d.ts +39 -0
  308. package/src/commands/inserttablelayoutcommand.js +65 -0
  309. package/src/commands/mergecellcommand.js +8 -0
  310. package/src/commands/setheadercolumncommand.js +9 -4
  311. package/src/commands/setheaderrowcommand.js +8 -3
  312. package/src/commands/splitcellcommand.js +4 -0
  313. package/src/converters/downcast.js +1 -1
  314. package/src/index.d.ts +4 -0
  315. package/src/index.js +2 -0
  316. package/src/plaintableoutput.d.ts +3 -0
  317. package/src/plaintableoutput.js +12 -1
  318. package/src/tablecaption/tablecaptionediting.js +7 -0
  319. package/src/tablecaption/tablecaptionui.js +3 -2
  320. package/src/tablecaption/toggletablecaptioncommand.js +1 -1
  321. package/src/tablecellproperties/commands/tablecellpropertycommand.js +8 -0
  322. package/src/tablecellproperties/tablecellpropertiesui.js +25 -3
  323. package/src/tablecellproperties/ui/tablecellpropertiesview.d.ts +2 -1
  324. package/src/tablecellproperties/ui/tablecellpropertiesview.js +82 -13
  325. package/src/tableclipboard.d.ts +9 -0
  326. package/src/tableclipboard.js +28 -1
  327. package/src/tablecolumnresize/constants.d.ts +4 -0
  328. package/src/tablecolumnresize/constants.js +4 -0
  329. package/src/tablecolumnresize/tablecolumnresizeediting.d.ts +8 -0
  330. package/src/tablecolumnresize/tablecolumnresizeediting.js +50 -10
  331. package/src/tableconfig.d.ts +38 -0
  332. package/src/tableediting.js +4 -0
  333. package/src/tablelayout/commands/tabletypecommand.d.ts +43 -0
  334. package/src/tablelayout/commands/tabletypecommand.js +68 -0
  335. package/src/tablelayout/tablelayoutediting.d.ts +54 -0
  336. package/src/tablelayout/tablelayoutediting.js +276 -0
  337. package/src/tablelayout/tablelayoutui.d.ts +32 -0
  338. package/src/tablelayout/tablelayoutui.js +189 -0
  339. package/src/tablelayout.d.ts +31 -0
  340. package/src/tablelayout.js +37 -0
  341. package/src/tablemouse/mouseeventsobserver.js +3 -6
  342. package/src/tableproperties/commands/tablepropertycommand.js +8 -0
  343. package/src/tableproperties/tablepropertiesui.d.ts +8 -2
  344. package/src/tableproperties/tablepropertiesui.js +44 -19
  345. package/src/tableproperties/ui/tablepropertiesview.d.ts +2 -1
  346. package/src/tableproperties/ui/tablepropertiesview.js +70 -9
  347. package/src/tableselection.js +19 -1
  348. package/src/tableui.js +7 -9
  349. package/src/tablewalker.js +99 -4
  350. package/src/ui/colorinputview.js +34 -0
  351. package/src/ui/inserttableview.js +12 -0
  352. package/src/utils/structure.js +7 -1
  353. package/src/utils/table-properties.js +1 -1
  354. package/theme/formrow.css +0 -10
  355. package/theme/table.css +52 -35
  356. package/theme/tablecolumnresize.css +5 -0
  357. package/theme/tableform.css +6 -0
  358. package/theme/tablelayout.css +62 -0
  359. package/src/ui/formrowview.d.ts +0 -61
  360. package/src/ui/formrowview.js +0 -57
  361. package/theme/form.css +0 -11
  362. package/theme/icons/table-cell-properties.svg +0 -1
  363. package/theme/icons/table-column.svg +0 -1
  364. package/theme/icons/table-merge-cell.svg +0 -1
  365. package/theme/icons/table-properties.svg +0 -1
  366. package/theme/icons/table-row.svg +0 -1
@@ -29,6 +29,15 @@ export default class TableClipboard extends Plugin {
29
29
  * @inheritDoc
30
30
  */
31
31
  init(): void;
32
+ /**
33
+ * Sets up listening for events from the clipboard pipeline to properly handle
34
+ * table content merging during paste/drop operations.
35
+ *
36
+ * When a user is dragging and dropping a table, we want to insert the entire table into
37
+ * a table cell instead of merging table contents. For paste and other events,
38
+ * the normal table merge behavior is applied.
39
+ */
40
+ private _listenToContentInsertion;
32
41
  /**
33
42
  * Copies table content to a clipboard on "copy" & "cut" events.
34
43
  *
@@ -39,9 +39,36 @@ export default class TableClipboard extends Plugin {
39
39
  const viewDocument = editor.editing.view.document;
40
40
  this.listenTo(viewDocument, 'copy', (evt, data) => this._onCopyCut(evt, data));
41
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' });
42
+ this._listenToContentInsertion();
43
43
  this.decorate('_replaceTableSlotCell');
44
44
  }
45
+ /**
46
+ * Sets up listening for events from the clipboard pipeline to properly handle
47
+ * table content merging during paste/drop operations.
48
+ *
49
+ * When a user is dragging and dropping a table, we want to insert the entire table into
50
+ * a table cell instead of merging table contents. For paste and other events,
51
+ * the normal table merge behavior is applied.
52
+ */
53
+ _listenToContentInsertion() {
54
+ const { editor } = this;
55
+ const clipboardPipeline = editor.plugins.get(ClipboardPipeline);
56
+ const tableSelection = editor.plugins.get(TableSelection);
57
+ let isPaste = false;
58
+ clipboardPipeline.on('contentInsertion', (evt, data) => {
59
+ isPaste = data.method === 'paste';
60
+ });
61
+ this.listenTo(editor.model, 'insertContent', (evt, [content, selectable]) => {
62
+ // Handles drag-and-drop of tables, where tables are inserted into selected cells rather than merged.
63
+ // The `isPaste` flag handles scenarios where other features (e.g., Templates) insert tables into specific cells.
64
+ if (isPaste || tableSelection.getSelectedTableCells() !== null) {
65
+ this._onInsertContent(evt, content, selectable);
66
+ }
67
+ }, { priority: 'high' });
68
+ clipboardPipeline.on('contentInsertion', () => {
69
+ isPaste = false;
70
+ }, { priority: 'lowest' });
71
+ }
45
72
  /**
46
73
  * Copies table content to a clipboard on "copy" & "cut" events.
47
74
  *
@@ -18,3 +18,7 @@ export declare const COLUMN_MIN_WIDTH_IN_PIXELS = 40;
18
18
  * Determines how many digits after the decimal point are used to store the column width as a percentage value.
19
19
  */
20
20
  export declare const COLUMN_WIDTH_PRECISION = 2;
21
+ /**
22
+ * The distance in pixels that the mouse has to move to start resizing the column.
23
+ */
24
+ export declare const COLUMN_RESIZE_DISTANCE_THRESHOLD = 3;
@@ -18,3 +18,7 @@ export const COLUMN_MIN_WIDTH_IN_PIXELS = 40;
18
18
  * Determines how many digits after the decimal point are used to store the column width as a percentage value.
19
19
  */
20
20
  export const COLUMN_WIDTH_PRECISION = 2;
21
+ /**
22
+ * The distance in pixels that the mouse has to move to start resizing the column.
23
+ */
24
+ export const COLUMN_RESIZE_DISTANCE_THRESHOLD = 3;
@@ -35,6 +35,10 @@ export default class TableColumnResizeEditing extends Plugin {
35
35
  * A local reference to the {@link module:table/tableutils~TableUtils} plugin.
36
36
  */
37
37
  private _tableUtilsPlugin;
38
+ /**
39
+ * Starting mouse position data used to add a threshold to the resizing process.
40
+ */
41
+ private _initialMouseEventData;
38
42
  /**
39
43
  * @inheritDoc
40
44
  */
@@ -111,6 +115,10 @@ export default class TableColumnResizeEditing extends Plugin {
111
115
  * @param domEventData The data related to the DOM event.
112
116
  */
113
117
  private _onMouseDownHandler;
118
+ /**
119
+ * Starts the resizing process after the threshold is reached.
120
+ */
121
+ private _startResizingAfterThreshold;
114
122
  /**
115
123
  * Handles the `mousemove` event.
116
124
  * * If resizing process is not in progress, it does nothing.
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * @module table/tablecolumnresize/tablecolumnresizeediting
7
7
  */
8
- import { throttle, isEqual } from 'lodash-es';
8
+ import { throttle, isEqual } from 'es-toolkit/compat';
9
9
  import { global, DomEmitterMixin } from 'ckeditor5/src/utils.js';
10
10
  import { Plugin } from 'ckeditor5/src/core.js';
11
11
  import MouseEventsObserver from '../../src/tablemouse/mouseeventsobserver.js';
@@ -15,11 +15,32 @@ import TableWalker from '../tablewalker.js';
15
15
  import TableWidthsCommand from './tablewidthscommand.js';
16
16
  import { downcastTableResizedClass, upcastColgroupElement } from './converters.js';
17
17
  import { clamp, createFilledArray, sumArray, getColumnEdgesIndexes, getChangedResizedTables, getColumnMinWidthAsPercentage, getElementWidthInPixels, getTableWidthInPixels, normalizeColumnWidths, toPrecision, getDomCellOuterWidth, updateColumnElements, getColumnGroupElement, getTableColumnElements, getTableColumnsWidths } from './utils.js';
18
- import { COLUMN_MIN_WIDTH_IN_PIXELS } from './constants.js';
18
+ import { COLUMN_MIN_WIDTH_IN_PIXELS, COLUMN_RESIZE_DISTANCE_THRESHOLD } from './constants.js';
19
19
  /**
20
20
  * The table column resize editing plugin.
21
21
  */
22
22
  export default class TableColumnResizeEditing extends Plugin {
23
+ /**
24
+ * A flag indicating if the column resizing is in progress.
25
+ */
26
+ _isResizingActive;
27
+ /**
28
+ * A temporary storage for the required data needed to correctly calculate the widths of the resized columns. This storage is
29
+ * initialized when column resizing begins, and is purged upon completion.
30
+ */
31
+ _resizingData;
32
+ /**
33
+ * DOM emitter.
34
+ */
35
+ _domEmitter;
36
+ /**
37
+ * A local reference to the {@link module:table/tableutils~TableUtils} plugin.
38
+ */
39
+ _tableUtilsPlugin;
40
+ /**
41
+ * Starting mouse position data used to add a threshold to the resizing process.
42
+ */
43
+ _initialMouseEventData = null;
23
44
  /**
24
45
  * @inheritDoc
25
46
  */
@@ -233,9 +254,8 @@ export default class TableColumnResizeEditing extends Plugin {
233
254
  // Table width style
234
255
  conversion.for('upcast').attributeToAttribute({
235
256
  view: {
236
- name: 'figure',
237
- key: 'style',
238
- value: {
257
+ name: /^(figure|table)$/,
258
+ styles: {
239
259
  width: /[\s\S]+/
240
260
  }
241
261
  },
@@ -336,13 +356,21 @@ export default class TableColumnResizeEditing extends Plugin {
336
356
  }
337
357
  domEventData.preventDefault();
338
358
  eventInfo.stop();
339
- // The column widths are calculated upon mousedown to allow lazy applying the `columnWidths` attribute on the table.
340
- const columnWidthsInPx = _calculateDomColumnWidths(modelTable, this._tableUtilsPlugin, editor);
359
+ this._initialMouseEventData = domEventData;
360
+ }
361
+ /**
362
+ * Starts the resizing process after the threshold is reached.
363
+ */
364
+ _startResizingAfterThreshold() {
365
+ const domEventData = this._initialMouseEventData;
366
+ const { target } = domEventData;
367
+ const modelTable = this.editor.editing.mapper.toModelElement(target.findAncestor('figure'));
341
368
  const viewTable = target.findAncestor('table');
342
- const editingView = editor.editing.view;
369
+ // Calculate the initial column widths in pixels.
370
+ const columnWidthsInPx = _calculateDomColumnWidths(modelTable, this._tableUtilsPlugin, this.editor);
343
371
  // Insert colgroup for the table that is resized for the first time.
344
372
  if (!Array.from(viewTable.getChildren()).find(viewCol => viewCol.is('element', 'colgroup'))) {
345
- editingView.change(viewWriter => {
373
+ this.editor.editing.view.change(viewWriter => {
346
374
  _insertColgroupElement(viewWriter, columnWidthsInPx, viewTable);
347
375
  });
348
376
  }
@@ -350,7 +378,7 @@ export default class TableColumnResizeEditing extends Plugin {
350
378
  this._resizingData = this._getResizingData(domEventData, columnWidthsInPx);
351
379
  // At this point we change only the editor view - we don't want other users to see our changes yet,
352
380
  // so we can't apply them in the model.
353
- editingView.change(writer => _applyResizingAttributesToTable(writer, viewTable, this._resizingData));
381
+ this.editor.editing.view.change(writer => _applyResizingAttributesToTable(writer, viewTable, this._resizingData));
354
382
  /**
355
383
  * Calculates the DOM columns' widths. It is done by taking the width of the widest cell
356
384
  * from each table column (we rely on the {@link module:table/tablewalker~TableWalker}
@@ -415,6 +443,17 @@ export default class TableColumnResizeEditing extends Plugin {
415
443
  * @param mouseEventData The native DOM event.
416
444
  */
417
445
  _onMouseMoveHandler(eventInfo, mouseEventData) {
446
+ if (this._initialMouseEventData) {
447
+ const mouseEvent = this._initialMouseEventData.domEvent;
448
+ const distanceX = Math.abs(mouseEventData.clientX - mouseEvent.clientX);
449
+ if (distanceX >= COLUMN_RESIZE_DISTANCE_THRESHOLD) {
450
+ this._startResizingAfterThreshold();
451
+ this._initialMouseEventData = null;
452
+ }
453
+ else {
454
+ return;
455
+ }
456
+ }
418
457
  if (!this._isResizingActive) {
419
458
  return;
420
459
  }
@@ -455,6 +494,7 @@ export default class TableColumnResizeEditing extends Plugin {
455
494
  * * Otherwise it propagates the changes from view to the model by executing the adequate commands.
456
495
  */
457
496
  _onMouseUpHandler() {
497
+ this._initialMouseEventData = null;
458
498
  if (!this._isResizingActive) {
459
499
  return;
460
500
  }
@@ -200,6 +200,16 @@ export interface TableConfig {
200
200
  * Read more about configuring the table feature in {@link module:table/tableconfig~TableConfig}.
201
201
  */
202
202
  tableCellProperties?: TableCellPropertiesConfig;
203
+ /**
204
+ * Configuration of the table layout feature.
205
+ *
206
+ * ```ts
207
+ * const tableConfig = {
208
+ * tableLayout: ... // Table layout feature config.
209
+ * };
210
+ * ```
211
+ */
212
+ tableLayout?: TableLayoutConfig;
203
213
  }
204
214
  /**
205
215
  * The configuration of the table properties user interface (balloon).
@@ -341,3 +351,31 @@ export interface TableCellPropertiesOptions {
341
351
  */
342
352
  verticalAlignment?: string;
343
353
  }
354
+ /**
355
+ * The configuration of the table layout feature.
356
+ */
357
+ export interface TableLayoutConfig {
358
+ /**
359
+ * Sets the preferred type for loading external tables.
360
+ *
361
+ * This setting overrides the default detection method and uses the specified type ('content' or 'layout').
362
+ *
363
+ * ```ts
364
+ * ClassicEditor
365
+ * .create( {
366
+ * table: {
367
+ * tableLayout: {
368
+ * preferredExternalTableType: 'content' // or 'layout'
369
+ * }
370
+ * }
371
+ * } )
372
+ * .then( ... )
373
+ * .catch( ... );
374
+ * ```
375
+ */
376
+ preferredExternalTableType: TableType;
377
+ }
378
+ /**
379
+ * The type of the table.
380
+ */
381
+ export type TableType = 'content' | 'layout';
@@ -30,6 +30,10 @@ import '../theme/tableediting.css';
30
30
  * The table editing feature.
31
31
  */
32
32
  export default class TableEditing extends Plugin {
33
+ /**
34
+ * Handlers for creating additional slots in the table.
35
+ */
36
+ _additionalSlots;
33
37
  /**
34
38
  * @inheritDoc
35
39
  */
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
+ /**
6
+ * @module table/tablelayout/commands/tabletypecommand
7
+ */
8
+ import { Command } from 'ckeditor5/src/core.js';
9
+ import type { TableType } from '../../tableconfig.js';
10
+ /**
11
+ * The set table type command.
12
+ *
13
+ * The command is registered by {@link module:table/tablelayout/tablelayoutediting~TableLayoutEditing}
14
+ * as the `'tableType'` editor command.
15
+ *
16
+ * To set the table type at the current selection, execute the command and specify the table type:
17
+ *
18
+ * ```ts
19
+ * editor.execute( 'tableType', 'layout' );
20
+ * ```
21
+ */
22
+ export default class TableTypeCommand extends Command {
23
+ /**
24
+ * The table type of selected table.
25
+ *
26
+ * @observable
27
+ * @readonly
28
+ */
29
+ value: TableType | null;
30
+ /**
31
+ * @inheritDoc
32
+ */
33
+ refresh(): void;
34
+ /**
35
+ * Executes the command.
36
+ *
37
+ * Set table type by the given table type parameter.
38
+ *
39
+ * @param tableType The type of table it should become.
40
+ * @fires execute
41
+ */
42
+ execute(tableType: TableType): void;
43
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
+ /**
6
+ * @module table/tablelayout/commands/tabletypecommand
7
+ */
8
+ import { Command } from 'ckeditor5/src/core.js';
9
+ import { getSelectionAffectedTable } from '../../utils/common.js';
10
+ /**
11
+ * The set table type command.
12
+ *
13
+ * The command is registered by {@link module:table/tablelayout/tablelayoutediting~TableLayoutEditing}
14
+ * as the `'tableType'` editor command.
15
+ *
16
+ * To set the table type at the current selection, execute the command and specify the table type:
17
+ *
18
+ * ```ts
19
+ * editor.execute( 'tableType', 'layout' );
20
+ * ```
21
+ */
22
+ export default class TableTypeCommand extends Command {
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ refresh() {
27
+ const model = this.editor.model;
28
+ const selection = model.document.selection;
29
+ const selectedTable = getSelectionAffectedTable(selection);
30
+ if (selectedTable) {
31
+ this.isEnabled = true;
32
+ this.value = selectedTable.getAttribute('tableType');
33
+ }
34
+ else {
35
+ this.isEnabled = false;
36
+ this.value = null;
37
+ }
38
+ }
39
+ /**
40
+ * Executes the command.
41
+ *
42
+ * Set table type by the given table type parameter.
43
+ *
44
+ * @param tableType The type of table it should become.
45
+ * @fires execute
46
+ */
47
+ execute(tableType) {
48
+ const editor = this.editor;
49
+ const model = editor.model;
50
+ const selection = model.document.selection;
51
+ const table = getSelectionAffectedTable(selection);
52
+ const currentTableType = table.getAttribute('tableType');
53
+ if (currentTableType === tableType) {
54
+ return;
55
+ }
56
+ model.change(writer => {
57
+ writer.setAttribute('tableType', tableType, table);
58
+ model.schema.removeDisallowedAttributes([table], writer);
59
+ const tableChildren = table.getChildren();
60
+ // Check if all children are allowed for the new table type.
61
+ for (const child of tableChildren) {
62
+ if (!model.schema.checkChild(table, child)) {
63
+ writer.remove(child);
64
+ }
65
+ }
66
+ });
67
+ }
68
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
+ /**
6
+ * @module table/tablelayout/tablelayoutediting
7
+ */
8
+ import { Plugin } from 'ckeditor5/src/core.js';
9
+ import TableColumnResize from '../tablecolumnresize.js';
10
+ import '../../theme/tablelayout.css';
11
+ /**
12
+ * The table layout editing plugin.
13
+ */
14
+ export default class TableLayoutEditing extends Plugin {
15
+ /**
16
+ * @inheritDoc
17
+ */
18
+ static get pluginName(): "TableLayoutEditing";
19
+ /**
20
+ * @inheritDoc
21
+ */
22
+ static get requires(): readonly [typeof TableColumnResize];
23
+ /**
24
+ * @inheritDoc
25
+ */
26
+ static get isOfficialPlugin(): true;
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ init(): void;
31
+ /**
32
+ * Defines the schema for the table layout feature.
33
+ */
34
+ private _defineSchema;
35
+ /**
36
+ * Defines the converters for the table layout feature.
37
+ */
38
+ private _defineConverters;
39
+ /**
40
+ * Handles the clipboard content insertion events.
41
+ *
42
+ * - If the content is from another editor, do not override the table type.
43
+ * - If the content is from another source, set the table type to 'content'.
44
+ *
45
+ * It handles the scenario when user copies `<table></table>` from Word. We do not want to
46
+ * change the table type to `layout` because it is really `content` table.
47
+ */
48
+ private _defineClipboardPasteHandlers;
49
+ /**
50
+ * Registers a post-fixer that sets the `tableType` attribute to `content` for inserted "default" tables.
51
+ * Also fixes potential issues with the table structure when the `tableType` attribute has been changed.
52
+ */
53
+ private _registerTableTypeAttributePostfixer;
54
+ }