@ckeditor/ckeditor5-table 44.3.0 → 45.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/build/table.js +2 -2
- package/build/translations/af.js +1 -1
- package/build/translations/ar.js +1 -1
- package/build/translations/ast.js +1 -1
- package/build/translations/az.js +1 -1
- package/build/translations/be.js +1 -0
- package/build/translations/bg.js +1 -1
- package/build/translations/bn.js +1 -1
- package/build/translations/bs.js +1 -1
- package/build/translations/ca.js +1 -1
- package/build/translations/cs.js +1 -1
- package/build/translations/da.js +1 -1
- package/build/translations/de-ch.js +1 -1
- package/build/translations/de.js +1 -1
- package/build/translations/el.js +1 -1
- package/build/translations/en-au.js +1 -1
- package/build/translations/en-gb.js +1 -1
- package/build/translations/eo.js +1 -1
- package/build/translations/es-co.js +1 -1
- package/build/translations/es.js +1 -1
- package/build/translations/et.js +1 -1
- package/build/translations/eu.js +1 -1
- package/build/translations/fa.js +1 -1
- package/build/translations/fi.js +1 -1
- package/build/translations/fr.js +1 -1
- package/build/translations/gl.js +1 -1
- package/build/translations/gu.js +1 -1
- package/build/translations/he.js +1 -1
- package/build/translations/hi.js +1 -1
- package/build/translations/hr.js +1 -1
- package/build/translations/hu.js +1 -1
- package/build/translations/hy.js +1 -1
- package/build/translations/id.js +1 -1
- package/build/translations/it.js +1 -1
- package/build/translations/ja.js +1 -1
- package/build/translations/jv.js +1 -1
- package/build/translations/kk.js +1 -1
- package/build/translations/km.js +1 -1
- package/build/translations/kn.js +1 -1
- package/build/translations/ko.js +1 -1
- package/build/translations/ku.js +1 -1
- package/build/translations/lt.js +1 -1
- package/build/translations/lv.js +1 -1
- package/build/translations/ms.js +1 -1
- package/build/translations/nb.js +1 -1
- package/build/translations/ne.js +1 -1
- package/build/translations/nl.js +1 -1
- package/build/translations/no.js +1 -1
- package/build/translations/oc.js +1 -1
- package/build/translations/pl.js +1 -1
- package/build/translations/pt-br.js +1 -1
- package/build/translations/pt.js +1 -1
- package/build/translations/ro.js +1 -1
- package/build/translations/ru.js +1 -1
- package/build/translations/si.js +1 -1
- package/build/translations/sk.js +1 -1
- package/build/translations/sl.js +1 -1
- package/build/translations/sq.js +1 -1
- package/build/translations/sr-latn.js +1 -1
- package/build/translations/sr.js +1 -1
- package/build/translations/sv.js +1 -1
- package/build/translations/th.js +1 -1
- package/build/translations/ti.js +1 -1
- package/build/translations/tk.js +1 -1
- package/build/translations/tr.js +1 -1
- package/build/translations/tt.js +1 -1
- package/build/translations/ug.js +1 -1
- package/build/translations/uk.js +1 -1
- package/build/translations/ur.js +1 -1
- package/build/translations/uz.js +1 -1
- package/build/translations/vi.js +1 -1
- package/build/translations/zh-cn.js +1 -1
- package/build/translations/zh.js +1 -1
- package/ckeditor5-metadata.json +64 -6
- package/dist/index-content.css +50 -25
- package/dist/index-editor.css +115 -16
- package/dist/index.css +226 -60
- package/dist/index.css.map +1 -1
- package/dist/index.js +3128 -2275
- package/dist/index.js.map +1 -1
- package/dist/translations/af.js +1 -1
- package/dist/translations/af.umd.js +1 -1
- package/dist/translations/ar.js +1 -1
- package/dist/translations/ar.umd.js +1 -1
- package/dist/translations/ast.js +1 -1
- package/dist/translations/ast.umd.js +1 -1
- package/dist/translations/az.js +1 -1
- package/dist/translations/az.umd.js +1 -1
- package/dist/translations/be.d.ts +8 -0
- package/dist/translations/be.js +5 -0
- package/dist/translations/be.umd.js +11 -0
- package/dist/translations/bg.js +1 -1
- package/dist/translations/bg.umd.js +1 -1
- package/dist/translations/bn.js +1 -1
- package/dist/translations/bn.umd.js +1 -1
- package/dist/translations/bs.js +1 -1
- package/dist/translations/bs.umd.js +1 -1
- package/dist/translations/ca.js +1 -1
- package/dist/translations/ca.umd.js +1 -1
- package/dist/translations/cs.js +1 -1
- package/dist/translations/cs.umd.js +1 -1
- package/dist/translations/da.js +1 -1
- package/dist/translations/da.umd.js +1 -1
- package/dist/translations/de-ch.js +1 -1
- package/dist/translations/de-ch.umd.js +1 -1
- package/dist/translations/de.js +1 -1
- package/dist/translations/de.umd.js +1 -1
- package/dist/translations/el.js +1 -1
- package/dist/translations/el.umd.js +1 -1
- package/dist/translations/en-au.js +1 -1
- package/dist/translations/en-au.umd.js +1 -1
- package/dist/translations/en-gb.js +1 -1
- package/dist/translations/en-gb.umd.js +1 -1
- package/dist/translations/en.js +1 -1
- package/dist/translations/en.umd.js +1 -1
- package/dist/translations/eo.js +1 -1
- package/dist/translations/eo.umd.js +1 -1
- package/dist/translations/es-co.js +1 -1
- package/dist/translations/es-co.umd.js +1 -1
- package/dist/translations/es.js +1 -1
- package/dist/translations/es.umd.js +1 -1
- package/dist/translations/et.js +1 -1
- package/dist/translations/et.umd.js +1 -1
- package/dist/translations/eu.js +1 -1
- package/dist/translations/eu.umd.js +1 -1
- package/dist/translations/fa.js +1 -1
- package/dist/translations/fa.umd.js +1 -1
- package/dist/translations/fi.js +1 -1
- package/dist/translations/fi.umd.js +1 -1
- package/dist/translations/fr.js +1 -1
- package/dist/translations/fr.umd.js +1 -1
- package/dist/translations/gl.js +1 -1
- package/dist/translations/gl.umd.js +1 -1
- package/dist/translations/gu.js +1 -1
- package/dist/translations/gu.umd.js +1 -1
- package/dist/translations/he.js +1 -1
- package/dist/translations/he.umd.js +1 -1
- package/dist/translations/hi.js +1 -1
- package/dist/translations/hi.umd.js +1 -1
- package/dist/translations/hr.js +1 -1
- package/dist/translations/hr.umd.js +1 -1
- package/dist/translations/hu.js +1 -1
- package/dist/translations/hu.umd.js +1 -1
- package/dist/translations/hy.js +1 -1
- package/dist/translations/hy.umd.js +1 -1
- package/dist/translations/id.js +1 -1
- package/dist/translations/id.umd.js +1 -1
- package/dist/translations/it.js +1 -1
- package/dist/translations/it.umd.js +1 -1
- package/dist/translations/ja.js +1 -1
- package/dist/translations/ja.umd.js +1 -1
- package/dist/translations/jv.js +1 -1
- package/dist/translations/jv.umd.js +1 -1
- package/dist/translations/kk.js +1 -1
- package/dist/translations/kk.umd.js +1 -1
- package/dist/translations/km.js +1 -1
- package/dist/translations/km.umd.js +1 -1
- package/dist/translations/kn.js +1 -1
- package/dist/translations/kn.umd.js +1 -1
- package/dist/translations/ko.js +1 -1
- package/dist/translations/ko.umd.js +1 -1
- package/dist/translations/ku.js +1 -1
- package/dist/translations/ku.umd.js +1 -1
- package/dist/translations/lt.js +1 -1
- package/dist/translations/lt.umd.js +1 -1
- package/dist/translations/lv.js +1 -1
- package/dist/translations/lv.umd.js +1 -1
- package/dist/translations/ms.js +1 -1
- package/dist/translations/ms.umd.js +1 -1
- package/dist/translations/nb.js +1 -1
- package/dist/translations/nb.umd.js +1 -1
- package/dist/translations/ne.js +1 -1
- package/dist/translations/ne.umd.js +1 -1
- package/dist/translations/nl.js +1 -1
- package/dist/translations/nl.umd.js +1 -1
- package/dist/translations/no.js +1 -1
- package/dist/translations/no.umd.js +1 -1
- package/dist/translations/oc.js +1 -1
- package/dist/translations/oc.umd.js +1 -1
- package/dist/translations/pl.js +1 -1
- package/dist/translations/pl.umd.js +1 -1
- package/dist/translations/pt-br.js +1 -1
- package/dist/translations/pt-br.umd.js +1 -1
- package/dist/translations/pt.js +1 -1
- package/dist/translations/pt.umd.js +1 -1
- package/dist/translations/ro.js +1 -1
- package/dist/translations/ro.umd.js +1 -1
- package/dist/translations/ru.js +1 -1
- package/dist/translations/ru.umd.js +1 -1
- package/dist/translations/si.js +1 -1
- package/dist/translations/si.umd.js +1 -1
- package/dist/translations/sk.js +1 -1
- package/dist/translations/sk.umd.js +1 -1
- package/dist/translations/sl.js +1 -1
- package/dist/translations/sl.umd.js +1 -1
- package/dist/translations/sq.js +1 -1
- package/dist/translations/sq.umd.js +1 -1
- package/dist/translations/sr-latn.js +1 -1
- package/dist/translations/sr-latn.umd.js +1 -1
- package/dist/translations/sr.js +1 -1
- package/dist/translations/sr.umd.js +1 -1
- package/dist/translations/sv.js +1 -1
- package/dist/translations/sv.umd.js +1 -1
- package/dist/translations/th.js +1 -1
- package/dist/translations/th.umd.js +1 -1
- package/dist/translations/ti.js +1 -1
- package/dist/translations/ti.umd.js +1 -1
- package/dist/translations/tk.js +1 -1
- package/dist/translations/tk.umd.js +1 -1
- package/dist/translations/tr.js +1 -1
- package/dist/translations/tr.umd.js +1 -1
- package/dist/translations/tt.js +1 -1
- package/dist/translations/tt.umd.js +1 -1
- package/dist/translations/ug.js +1 -1
- package/dist/translations/ug.umd.js +1 -1
- package/dist/translations/uk.js +1 -1
- package/dist/translations/uk.umd.js +1 -1
- package/dist/translations/ur.js +1 -1
- package/dist/translations/ur.umd.js +1 -1
- package/dist/translations/uz.js +1 -1
- package/dist/translations/uz.umd.js +1 -1
- package/dist/translations/vi.js +1 -1
- package/dist/translations/vi.umd.js +1 -1
- package/dist/translations/zh-cn.js +1 -1
- package/dist/translations/zh-cn.umd.js +1 -1
- package/dist/translations/zh.js +1 -1
- package/dist/translations/zh.umd.js +1 -1
- package/lang/contexts.json +8 -1
- package/lang/translations/af.po +28 -0
- package/lang/translations/ar.po +28 -0
- package/lang/translations/ast.po +28 -0
- package/lang/translations/az.po +28 -0
- package/lang/translations/be.po +296 -0
- package/lang/translations/bg.po +28 -0
- package/lang/translations/bn.po +28 -0
- package/lang/translations/bs.po +28 -0
- package/lang/translations/ca.po +28 -0
- package/lang/translations/cs.po +28 -0
- package/lang/translations/da.po +28 -0
- package/lang/translations/de-ch.po +28 -0
- package/lang/translations/de.po +28 -0
- package/lang/translations/el.po +28 -0
- package/lang/translations/en-au.po +28 -0
- package/lang/translations/en-gb.po +28 -0
- package/lang/translations/en.po +28 -0
- package/lang/translations/eo.po +28 -0
- package/lang/translations/es-co.po +28 -0
- package/lang/translations/es.po +28 -0
- package/lang/translations/et.po +28 -0
- package/lang/translations/eu.po +28 -0
- package/lang/translations/fa.po +28 -0
- package/lang/translations/fi.po +28 -0
- package/lang/translations/fr.po +28 -0
- package/lang/translations/gl.po +28 -0
- package/lang/translations/gu.po +28 -0
- package/lang/translations/he.po +28 -0
- package/lang/translations/hi.po +28 -0
- package/lang/translations/hr.po +28 -0
- package/lang/translations/hu.po +28 -0
- package/lang/translations/hy.po +28 -0
- package/lang/translations/id.po +28 -0
- package/lang/translations/it.po +28 -0
- package/lang/translations/ja.po +28 -0
- package/lang/translations/jv.po +28 -0
- package/lang/translations/kk.po +28 -0
- package/lang/translations/km.po +28 -0
- package/lang/translations/kn.po +28 -0
- package/lang/translations/ko.po +28 -0
- package/lang/translations/ku.po +28 -0
- package/lang/translations/lt.po +28 -0
- package/lang/translations/lv.po +28 -0
- package/lang/translations/ms.po +28 -0
- package/lang/translations/nb.po +28 -0
- package/lang/translations/ne.po +28 -0
- package/lang/translations/nl.po +28 -0
- package/lang/translations/no.po +28 -0
- package/lang/translations/oc.po +28 -0
- package/lang/translations/pl.po +28 -0
- package/lang/translations/pt-br.po +28 -0
- package/lang/translations/pt.po +28 -0
- package/lang/translations/ro.po +28 -0
- package/lang/translations/ru.po +28 -0
- package/lang/translations/si.po +28 -0
- package/lang/translations/sk.po +28 -0
- package/lang/translations/sl.po +28 -0
- package/lang/translations/sq.po +28 -0
- package/lang/translations/sr-latn.po +28 -0
- package/lang/translations/sr.po +28 -0
- package/lang/translations/sv.po +28 -0
- package/lang/translations/th.po +28 -0
- package/lang/translations/ti.po +28 -0
- package/lang/translations/tk.po +28 -0
- package/lang/translations/tr.po +28 -0
- package/lang/translations/tt.po +28 -0
- package/lang/translations/ug.po +28 -0
- package/lang/translations/uk.po +28 -0
- package/lang/translations/ur.po +28 -0
- package/lang/translations/uz.po +28 -0
- package/lang/translations/vi.po +28 -0
- package/lang/translations/zh-cn.po +28 -0
- package/lang/translations/zh.po +28 -0
- package/package.json +10 -9
- package/src/augmentation.d.ts +5 -1
- package/src/commands/insertcolumncommand.js +4 -0
- package/src/commands/insertrowcommand.js +4 -0
- package/src/commands/inserttablelayoutcommand.d.ts +39 -0
- package/src/commands/inserttablelayoutcommand.js +65 -0
- package/src/commands/mergecellcommand.js +8 -0
- package/src/commands/setheadercolumncommand.js +9 -4
- package/src/commands/setheaderrowcommand.js +8 -3
- package/src/commands/splitcellcommand.js +4 -0
- package/src/converters/downcast.js +1 -1
- package/src/converters/tableproperties.js +25 -5
- package/src/index.d.ts +4 -0
- package/src/index.js +2 -0
- package/src/plaintableoutput.d.ts +3 -0
- package/src/plaintableoutput.js +12 -1
- package/src/tablecaption/tablecaptionediting.js +7 -0
- package/src/tablecaption/tablecaptionui.js +3 -2
- package/src/tablecaption/toggletablecaptioncommand.js +1 -1
- package/src/tablecellproperties/commands/tablecellpropertycommand.d.ts +11 -1
- package/src/tablecellproperties/commands/tablecellpropertycommand.js +40 -2
- package/src/tablecellproperties/tablecellpropertiesediting.js +50 -9
- package/src/tablecellproperties/tablecellpropertiesui.d.ts +13 -1
- package/src/tablecellproperties/tablecellpropertiesui.js +60 -11
- package/src/tablecellproperties/ui/tablecellpropertiesview.d.ts +2 -1
- package/src/tablecellproperties/ui/tablecellpropertiesview.js +82 -13
- package/src/tableclipboard.d.ts +9 -0
- package/src/tableclipboard.js +28 -1
- package/src/tablecolumnresize/constants.d.ts +4 -0
- package/src/tablecolumnresize/constants.js +4 -0
- package/src/tablecolumnresize/tablecolumnresizeediting.d.ts +8 -0
- package/src/tablecolumnresize/tablecolumnresizeediting.js +50 -10
- package/src/tableconfig.d.ts +38 -0
- package/src/tableediting.js +4 -0
- package/src/tablelayout/commands/tabletypecommand.d.ts +43 -0
- package/src/tablelayout/commands/tabletypecommand.js +68 -0
- package/src/tablelayout/tablelayoutediting.d.ts +54 -0
- package/src/tablelayout/tablelayoutediting.js +276 -0
- package/src/tablelayout/tablelayoutui.d.ts +32 -0
- package/src/tablelayout/tablelayoutui.js +189 -0
- package/src/tablelayout.d.ts +31 -0
- package/src/tablelayout.js +37 -0
- package/src/tablemouse/mouseeventsobserver.js +3 -6
- package/src/tableproperties/commands/tablepropertycommand.d.ts +11 -1
- package/src/tableproperties/commands/tablepropertycommand.js +23 -1
- package/src/tableproperties/tablepropertiesediting.js +49 -11
- package/src/tableproperties/tablepropertiesui.d.ts +21 -3
- package/src/tableproperties/tablepropertiesui.js +73 -26
- package/src/tableproperties/ui/tablepropertiesview.d.ts +4 -3
- package/src/tableproperties/ui/tablepropertiesview.js +70 -9
- package/src/tableselection.js +19 -1
- package/src/tableui.js +7 -9
- package/src/tablewalker.js +99 -4
- package/src/ui/colorinputview.js +34 -0
- package/src/ui/inserttableview.js +12 -0
- package/src/utils/structure.js +7 -1
- package/src/utils/table-properties.d.ts +3 -3
- package/src/utils/table-properties.js +1 -1
- package/src/utils/ui/table-properties.js +7 -1
- package/theme/formrow.css +0 -10
- package/theme/table.css +52 -35
- package/theme/tablecolumnresize.css +5 -0
- package/theme/tableform.css +6 -0
- package/theme/tablelayout.css +62 -0
- package/src/ui/formrowview.d.ts +0 -61
- package/src/ui/formrowview.js +0 -57
- package/theme/form.css +0 -11
- package/theme/icons/table-cell-properties.svg +0 -1
- package/theme/icons/table-column.svg +0 -1
- package/theme/icons/table-merge-cell.svg +0 -1
- package/theme/icons/table-properties.svg +0 -1
- package/theme/icons/table-row.svg +0 -1
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
* @module table/tablecellproperties/tablecellpropertiesediting
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { first } from 'ckeditor5/src/utils.js';
|
|
9
10
|
import { addBorderRules, addPaddingRules, addBackgroundRules } from 'ckeditor5/src/engine.js';
|
|
10
|
-
import { downcastAttributeToStyle, upcastBorderStyles } from '
|
|
11
|
+
import { downcastAttributeToStyle, upcastBorderStyles } from '../converters/tableproperties.js';
|
|
11
12
|
import TableEditing from './../tableediting.js';
|
|
12
13
|
import TableCellWidthEditing from '../tablecellwidth/tablecellwidthediting.js';
|
|
13
14
|
import TableCellPaddingCommand from './commands/tablecellpaddingcommand.js';
|
|
@@ -166,9 +167,19 @@ function enableHorizontalAlignmentProperty(schema, conversion, defaultValue) {
|
|
|
166
167
|
},
|
|
167
168
|
model: {
|
|
168
169
|
key: 'tableCellHorizontalAlignment',
|
|
169
|
-
value: (viewElement) => {
|
|
170
|
+
value: (viewElement, conversionApi, data) => {
|
|
171
|
+
let localDefaultValue = defaultValue;
|
|
172
|
+
// Adjust default for layout tables.
|
|
173
|
+
if (data.modelRange) {
|
|
174
|
+
const modelElement = first(data.modelRange.getItems({ shallow: true }));
|
|
175
|
+
const tableElement = modelElement && modelElement.is('element') &&
|
|
176
|
+
modelElement.findAncestor('table', { includeSelf: true });
|
|
177
|
+
if (tableElement && tableElement.getAttribute('tableType') == 'layout') {
|
|
178
|
+
localDefaultValue = 'left';
|
|
179
|
+
}
|
|
180
|
+
}
|
|
170
181
|
const align = viewElement.getStyle('text-align');
|
|
171
|
-
return align ===
|
|
182
|
+
return align === localDefaultValue ? null : align;
|
|
172
183
|
}
|
|
173
184
|
}
|
|
174
185
|
})
|
|
@@ -182,9 +193,19 @@ function enableHorizontalAlignmentProperty(schema, conversion, defaultValue) {
|
|
|
182
193
|
},
|
|
183
194
|
model: {
|
|
184
195
|
key: 'tableCellHorizontalAlignment',
|
|
185
|
-
value: (viewElement) => {
|
|
196
|
+
value: (viewElement, conversionApi, data) => {
|
|
197
|
+
let localDefaultValue = defaultValue;
|
|
198
|
+
// Adjust default for layout tables.
|
|
199
|
+
if (data.modelRange) {
|
|
200
|
+
const modelElement = first(data.modelRange.getItems({ shallow: true }));
|
|
201
|
+
const tableElement = modelElement && modelElement.is('element') &&
|
|
202
|
+
modelElement.findAncestor('table', { includeSelf: true });
|
|
203
|
+
if (tableElement && tableElement.getAttribute('tableType') == 'layout') {
|
|
204
|
+
localDefaultValue = 'left';
|
|
205
|
+
}
|
|
206
|
+
}
|
|
186
207
|
const align = viewElement.getAttribute('align');
|
|
187
|
-
return align ===
|
|
208
|
+
return align === localDefaultValue ? null : align;
|
|
188
209
|
}
|
|
189
210
|
}
|
|
190
211
|
});
|
|
@@ -222,9 +243,19 @@ function enableVerticalAlignmentProperty(schema, conversion, defaultValue) {
|
|
|
222
243
|
},
|
|
223
244
|
model: {
|
|
224
245
|
key: 'tableCellVerticalAlignment',
|
|
225
|
-
value: (viewElement) => {
|
|
246
|
+
value: (viewElement, conversionApi, data) => {
|
|
247
|
+
let localDefaultValue = defaultValue;
|
|
248
|
+
// Adjust default for layout tables.
|
|
249
|
+
if (data.modelRange) {
|
|
250
|
+
const modelElement = first(data.modelRange.getItems({ shallow: true }));
|
|
251
|
+
const tableElement = modelElement && modelElement.is('element') &&
|
|
252
|
+
modelElement.findAncestor('table', { includeSelf: true });
|
|
253
|
+
if (tableElement && tableElement.getAttribute('tableType') == 'layout') {
|
|
254
|
+
localDefaultValue = 'middle';
|
|
255
|
+
}
|
|
256
|
+
}
|
|
226
257
|
const align = viewElement.getStyle('vertical-align');
|
|
227
|
-
return align ===
|
|
258
|
+
return align === localDefaultValue ? null : align;
|
|
228
259
|
}
|
|
229
260
|
}
|
|
230
261
|
})
|
|
@@ -238,9 +269,19 @@ function enableVerticalAlignmentProperty(schema, conversion, defaultValue) {
|
|
|
238
269
|
},
|
|
239
270
|
model: {
|
|
240
271
|
key: 'tableCellVerticalAlignment',
|
|
241
|
-
value: (viewElement) => {
|
|
272
|
+
value: (viewElement, conversionApi, data) => {
|
|
273
|
+
let localDefaultValue = defaultValue;
|
|
274
|
+
// Adjust default for layout tables.
|
|
275
|
+
if (data.modelRange) {
|
|
276
|
+
const modelElement = first(data.modelRange.getItems({ shallow: true }));
|
|
277
|
+
const tableElement = modelElement && modelElement.is('element') &&
|
|
278
|
+
modelElement.findAncestor('table', { includeSelf: true });
|
|
279
|
+
if (tableElement && tableElement.getAttribute('tableType') == 'layout') {
|
|
280
|
+
localDefaultValue = 'middle';
|
|
281
|
+
}
|
|
282
|
+
}
|
|
242
283
|
const valign = viewElement.getAttribute('valign');
|
|
243
|
-
return valign ===
|
|
284
|
+
return valign === localDefaultValue ? null : valign;
|
|
244
285
|
}
|
|
245
286
|
}
|
|
246
287
|
});
|
|
@@ -18,7 +18,11 @@ export default class TableCellPropertiesUI extends Plugin {
|
|
|
18
18
|
/**
|
|
19
19
|
* The default table cell properties.
|
|
20
20
|
*/
|
|
21
|
-
private
|
|
21
|
+
private _defaultContentTableCellProperties;
|
|
22
|
+
/**
|
|
23
|
+
* The default layout table cell properties.
|
|
24
|
+
*/
|
|
25
|
+
private _defaultLayoutTableCellProperties;
|
|
22
26
|
/**
|
|
23
27
|
* The contextual balloon plugin instance.
|
|
24
28
|
*/
|
|
@@ -27,6 +31,14 @@ export default class TableCellPropertiesUI extends Plugin {
|
|
|
27
31
|
* The cell properties form view displayed inside the balloon.
|
|
28
32
|
*/
|
|
29
33
|
view?: TableCellPropertiesView | null;
|
|
34
|
+
/**
|
|
35
|
+
* The cell properties form view displayed inside the balloon (content table).
|
|
36
|
+
*/
|
|
37
|
+
private _viewWithContentTableDefaults?;
|
|
38
|
+
/**
|
|
39
|
+
* The cell properties form view displayed inside the balloon (layout table).
|
|
40
|
+
*/
|
|
41
|
+
private _viewWithLayoutTableDefaults?;
|
|
30
42
|
/**
|
|
31
43
|
* The batch used to undo all changes made by the form (which are live, as the user types)
|
|
32
44
|
* when "Cancel" was pressed. Each time the view is shown, a new batch is created.
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
* @module table/tablecellproperties/tablecellpropertiesui
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { IconTableCellProperties } from 'ckeditor5/src/icons.js';
|
|
9
10
|
import { ButtonView, clickOutsideHandler, ContextualBalloon, getLocalizedColorOptions, normalizeColorOptions } from 'ckeditor5/src/ui.js';
|
|
10
11
|
import TableCellPropertiesView from './ui/tablecellpropertiesview.js';
|
|
11
12
|
import { colorFieldValidator, getLocalizedColorErrorText, getLocalizedLengthErrorText, defaultColors, lengthFieldValidator, lineWidthFieldValidator } from '../utils/ui/table-properties.js';
|
|
12
|
-
import { debounce } from '
|
|
13
|
-
import { getTableWidgetAncestor } from '../utils/ui/widget.js';
|
|
13
|
+
import { debounce } from 'es-toolkit/compat';
|
|
14
|
+
import { getSelectionAffectedTableWidget, getTableWidgetAncestor } from '../utils/ui/widget.js';
|
|
14
15
|
import { getBalloonCellPositionData, repositionContextualBalloon } from '../utils/ui/contextualballoon.js';
|
|
15
|
-
import
|
|
16
|
-
import { getNormalizedDefaultCellProperties } from '../utils/table-properties.js';
|
|
16
|
+
import { getNormalizedDefaultCellProperties, getNormalizedDefaultProperties } from '../utils/table-properties.js';
|
|
17
17
|
const ERROR_TEXT_TIMEOUT = 500;
|
|
18
18
|
// Map of view properties and related commands.
|
|
19
19
|
const propertyToCommandMap = {
|
|
@@ -34,6 +34,40 @@ const propertyToCommandMap = {
|
|
|
34
34
|
* It uses the {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon plugin}.
|
|
35
35
|
*/
|
|
36
36
|
export default class TableCellPropertiesUI extends Plugin {
|
|
37
|
+
/**
|
|
38
|
+
* The default table cell properties.
|
|
39
|
+
*/
|
|
40
|
+
_defaultContentTableCellProperties;
|
|
41
|
+
/**
|
|
42
|
+
* The default layout table cell properties.
|
|
43
|
+
*/
|
|
44
|
+
_defaultLayoutTableCellProperties;
|
|
45
|
+
/**
|
|
46
|
+
* The contextual balloon plugin instance.
|
|
47
|
+
*/
|
|
48
|
+
_balloon;
|
|
49
|
+
/**
|
|
50
|
+
* The cell properties form view displayed inside the balloon.
|
|
51
|
+
*/
|
|
52
|
+
view;
|
|
53
|
+
/**
|
|
54
|
+
* The cell properties form view displayed inside the balloon (content table).
|
|
55
|
+
*/
|
|
56
|
+
_viewWithContentTableDefaults;
|
|
57
|
+
/**
|
|
58
|
+
* The cell properties form view displayed inside the balloon (layout table).
|
|
59
|
+
*/
|
|
60
|
+
_viewWithLayoutTableDefaults;
|
|
61
|
+
/**
|
|
62
|
+
* The batch used to undo all changes made by the form (which are live, as the user types)
|
|
63
|
+
* when "Cancel" was pressed. Each time the view is shown, a new batch is created.
|
|
64
|
+
*/
|
|
65
|
+
_undoStepBatch;
|
|
66
|
+
/**
|
|
67
|
+
* Flag used to indicate whether view is ready to execute update commands
|
|
68
|
+
* (it finished loading initial data).
|
|
69
|
+
*/
|
|
70
|
+
_isReady;
|
|
37
71
|
/**
|
|
38
72
|
* @inheritDoc
|
|
39
73
|
*/
|
|
@@ -68,12 +102,17 @@ export default class TableCellPropertiesUI extends Plugin {
|
|
|
68
102
|
init() {
|
|
69
103
|
const editor = this.editor;
|
|
70
104
|
const t = editor.t;
|
|
71
|
-
this.
|
|
105
|
+
this._defaultContentTableCellProperties = getNormalizedDefaultCellProperties(editor.config.get('table.tableCellProperties.defaultProperties'), {
|
|
72
106
|
includeVerticalAlignmentProperty: true,
|
|
73
107
|
includeHorizontalAlignmentProperty: true,
|
|
74
108
|
includePaddingProperty: true,
|
|
75
109
|
isRightToLeftContent: editor.locale.contentLanguageDirection === 'rtl'
|
|
76
110
|
});
|
|
111
|
+
this._defaultLayoutTableCellProperties = getNormalizedDefaultProperties(undefined, {
|
|
112
|
+
includeVerticalAlignmentProperty: true,
|
|
113
|
+
includeHorizontalAlignmentProperty: true,
|
|
114
|
+
isRightToLeftContent: editor.locale.contentLanguageDirection === 'rtl'
|
|
115
|
+
});
|
|
77
116
|
this._balloon = editor.plugins.get(ContextualBalloon);
|
|
78
117
|
this.view = null;
|
|
79
118
|
this._isReady = false;
|
|
@@ -81,7 +120,7 @@ export default class TableCellPropertiesUI extends Plugin {
|
|
|
81
120
|
const view = new ButtonView(locale);
|
|
82
121
|
view.set({
|
|
83
122
|
label: t('Cell properties'),
|
|
84
|
-
icon:
|
|
123
|
+
icon: IconTableCellProperties,
|
|
85
124
|
tooltip: true
|
|
86
125
|
});
|
|
87
126
|
this.listenTo(view, 'execute', () => this._showView());
|
|
@@ -107,7 +146,7 @@ export default class TableCellPropertiesUI extends Plugin {
|
|
|
107
146
|
*
|
|
108
147
|
* @returns The cell properties form view instance.
|
|
109
148
|
*/
|
|
110
|
-
_createPropertiesView() {
|
|
149
|
+
_createPropertiesView(defaultTableCellProperties) {
|
|
111
150
|
const editor = this.editor;
|
|
112
151
|
const config = editor.config.get('table.tableCellProperties');
|
|
113
152
|
const borderColorsConfig = normalizeColorOptions(config.borderColors);
|
|
@@ -118,7 +157,7 @@ export default class TableCellPropertiesUI extends Plugin {
|
|
|
118
157
|
const view = new TableCellPropertiesView(editor.locale, {
|
|
119
158
|
borderColors: localizedBorderColors,
|
|
120
159
|
backgroundColors: localizedBackgroundColors,
|
|
121
|
-
defaultTableCellProperties
|
|
160
|
+
defaultTableCellProperties,
|
|
122
161
|
colorPickerConfig: hasColorPicker ? (config.colorPicker || {}) : false
|
|
123
162
|
});
|
|
124
163
|
const t = editor.t;
|
|
@@ -207,7 +246,10 @@ export default class TableCellPropertiesUI extends Plugin {
|
|
|
207
246
|
const borderStyleCommand = commands.get('tableCellBorderStyle');
|
|
208
247
|
Object.entries(propertyToCommandMap)
|
|
209
248
|
.map(([property, commandName]) => {
|
|
210
|
-
const
|
|
249
|
+
const propertyKey = property;
|
|
250
|
+
const defaultValue = this.view === this._viewWithContentTableDefaults ?
|
|
251
|
+
this._defaultContentTableCellProperties[propertyKey] || '' :
|
|
252
|
+
this._defaultLayoutTableCellProperties[propertyKey] || '';
|
|
211
253
|
return [
|
|
212
254
|
property,
|
|
213
255
|
commands.get(commandName).value || defaultValue
|
|
@@ -231,9 +273,16 @@ export default class TableCellPropertiesUI extends Plugin {
|
|
|
231
273
|
*/
|
|
232
274
|
_showView() {
|
|
233
275
|
const editor = this.editor;
|
|
234
|
-
|
|
235
|
-
|
|
276
|
+
const viewTable = getSelectionAffectedTableWidget(editor.editing.view.document.selection);
|
|
277
|
+
const modelTable = viewTable && editor.editing.mapper.toModelElement(viewTable);
|
|
278
|
+
const useDefaults = !modelTable || modelTable.getAttribute('tableType') !== 'layout';
|
|
279
|
+
if (useDefaults && !this._viewWithContentTableDefaults) {
|
|
280
|
+
this._viewWithContentTableDefaults = this._createPropertiesView(this._defaultContentTableCellProperties);
|
|
281
|
+
}
|
|
282
|
+
else if (!useDefaults && !this._viewWithLayoutTableDefaults) {
|
|
283
|
+
this._viewWithLayoutTableDefaults = this._createPropertiesView(this._defaultLayoutTableCellProperties);
|
|
236
284
|
}
|
|
285
|
+
this.view = useDefaults ? this._viewWithContentTableDefaults : this._viewWithLayoutTableDefaults;
|
|
237
286
|
this.listenTo(editor.ui, 'update', () => {
|
|
238
287
|
this._updateView();
|
|
239
288
|
});
|
|
@@ -9,7 +9,8 @@ import { ButtonView, FocusCycler, LabeledFieldView, ToolbarView, View, ViewColle
|
|
|
9
9
|
import { KeystrokeHandler, FocusTracker, type Locale } from 'ckeditor5/src/utils.js';
|
|
10
10
|
import type ColorInputView from '../../ui/colorinputview.js';
|
|
11
11
|
import type { TableCellPropertiesOptions } from '../../tableconfig.js';
|
|
12
|
-
import '
|
|
12
|
+
import '@ckeditor/ckeditor5-ui/theme/components/form/form.css';
|
|
13
|
+
import '../../../theme/formrow.css';
|
|
13
14
|
import '../../../theme/tableform.css';
|
|
14
15
|
import '../../../theme/tablecellproperties.css';
|
|
15
16
|
export interface TableCellPropertiesViewOptions {
|
|
@@ -5,12 +5,13 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module table/tablecellproperties/ui/tablecellpropertiesview
|
|
7
7
|
*/
|
|
8
|
-
import { addListToDropdown, ButtonView, createLabeledDropdown, createLabeledInputText, FocusCycler, FormHeaderView, LabeledFieldView, LabelView, submitHandler, ToolbarView, View, ViewCollection } from 'ckeditor5/src/ui.js';
|
|
8
|
+
import { addListToDropdown, ButtonView, createLabeledDropdown, createLabeledInputText, FocusCycler, FormRowView, FormHeaderView, LabeledFieldView, LabelView, submitHandler, ToolbarView, View, ViewCollection } from 'ckeditor5/src/ui.js';
|
|
9
9
|
import { KeystrokeHandler, FocusTracker } from 'ckeditor5/src/utils.js';
|
|
10
|
-
import {
|
|
10
|
+
import { IconAlignBottom, IconAlignCenter, IconAlignJustify, IconAlignLeft, IconAlignMiddle, IconAlignRight, IconAlignTop, IconCancel, IconCheck } from 'ckeditor5/src/icons.js';
|
|
11
11
|
import { fillToolbar, getBorderStyleDefinitions, getBorderStyleLabels, getLabeledColorInputCreator } from '../../utils/ui/table-properties.js';
|
|
12
|
-
|
|
13
|
-
import '
|
|
12
|
+
// eslint-disable-next-line ckeditor5-rules/ckeditor-imports
|
|
13
|
+
import '@ckeditor/ckeditor5-ui/theme/components/form/form.css';
|
|
14
|
+
import '../../../theme/formrow.css';
|
|
14
15
|
import '../../../theme/tableform.css';
|
|
15
16
|
import '../../../theme/tablecellproperties.css';
|
|
16
17
|
/**
|
|
@@ -18,6 +19,74 @@ import '../../../theme/tablecellproperties.css';
|
|
|
18
19
|
* certain style aspects of a table cell, for instance, border, padding, text alignment, etc..
|
|
19
20
|
*/
|
|
20
21
|
export default class TableCellPropertiesView extends View {
|
|
22
|
+
/**
|
|
23
|
+
* Options passed to the view. See {@link #constructor} to learn more.
|
|
24
|
+
*/
|
|
25
|
+
options;
|
|
26
|
+
/**
|
|
27
|
+
* Tracks information about the DOM focus in the form.
|
|
28
|
+
*/
|
|
29
|
+
focusTracker;
|
|
30
|
+
/**
|
|
31
|
+
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
32
|
+
*/
|
|
33
|
+
keystrokes;
|
|
34
|
+
/**
|
|
35
|
+
* A collection of child views in the form.
|
|
36
|
+
*/
|
|
37
|
+
children;
|
|
38
|
+
/**
|
|
39
|
+
* A dropdown that allows selecting the style of the table cell border.
|
|
40
|
+
*/
|
|
41
|
+
borderStyleDropdown;
|
|
42
|
+
/**
|
|
43
|
+
* An input that allows specifying the width of the table cell border.
|
|
44
|
+
*/
|
|
45
|
+
borderWidthInput;
|
|
46
|
+
/**
|
|
47
|
+
* An input that allows specifying the color of the table cell border.
|
|
48
|
+
*/
|
|
49
|
+
borderColorInput;
|
|
50
|
+
/**
|
|
51
|
+
* An input that allows specifying the table cell background color.
|
|
52
|
+
*/
|
|
53
|
+
backgroundInput;
|
|
54
|
+
/**
|
|
55
|
+
* An input that allows specifying the table cell padding.
|
|
56
|
+
*/
|
|
57
|
+
paddingInput;
|
|
58
|
+
/**
|
|
59
|
+
* An input that allows specifying the table cell width.
|
|
60
|
+
*/
|
|
61
|
+
widthInput;
|
|
62
|
+
/**
|
|
63
|
+
* An input that allows specifying the table cell height.
|
|
64
|
+
*/
|
|
65
|
+
heightInput;
|
|
66
|
+
/**
|
|
67
|
+
* A toolbar with buttons that allow changing the horizontal text alignment in a table cell.
|
|
68
|
+
*/
|
|
69
|
+
horizontalAlignmentToolbar;
|
|
70
|
+
/**
|
|
71
|
+
* A toolbar with buttons that allow changing the vertical text alignment in a table cell.
|
|
72
|
+
*/
|
|
73
|
+
verticalAlignmentToolbar;
|
|
74
|
+
/**
|
|
75
|
+
* The "Save" button view.
|
|
76
|
+
*/
|
|
77
|
+
saveButtonView;
|
|
78
|
+
/**
|
|
79
|
+
* The "Cancel" button view.
|
|
80
|
+
*/
|
|
81
|
+
cancelButtonView;
|
|
82
|
+
/**
|
|
83
|
+
* A collection of views that can be focused in the form.
|
|
84
|
+
*/
|
|
85
|
+
_focusables;
|
|
86
|
+
/**
|
|
87
|
+
* Helps cycling over {@link #_focusables} in the form.
|
|
88
|
+
*/
|
|
89
|
+
_focusCycler;
|
|
21
90
|
/**
|
|
22
91
|
* @param locale The {@link module:core/editor/editor~Editor#locale} instance.
|
|
23
92
|
* @param options Additional configuration of the view.
|
|
@@ -412,13 +481,13 @@ export default class TableCellPropertiesView extends View {
|
|
|
412
481
|
const t = this.t;
|
|
413
482
|
const alignmentLabel = new LabelView(locale);
|
|
414
483
|
const ALIGNMENT_ICONS = {
|
|
415
|
-
left:
|
|
416
|
-
center:
|
|
417
|
-
right:
|
|
418
|
-
justify:
|
|
419
|
-
top:
|
|
420
|
-
middle:
|
|
421
|
-
bottom:
|
|
484
|
+
left: IconAlignLeft,
|
|
485
|
+
center: IconAlignCenter,
|
|
486
|
+
right: IconAlignRight,
|
|
487
|
+
justify: IconAlignJustify,
|
|
488
|
+
top: IconAlignTop,
|
|
489
|
+
middle: IconAlignMiddle,
|
|
490
|
+
bottom: IconAlignBottom
|
|
422
491
|
};
|
|
423
492
|
alignmentLabel.text = t('Table cell text alignment');
|
|
424
493
|
// -- Horizontal ---------------------------------------------------
|
|
@@ -489,7 +558,7 @@ export default class TableCellPropertiesView extends View {
|
|
|
489
558
|
];
|
|
490
559
|
saveButtonView.set({
|
|
491
560
|
label: t('Save'),
|
|
492
|
-
icon:
|
|
561
|
+
icon: IconCheck,
|
|
493
562
|
class: 'ck-button-save',
|
|
494
563
|
type: 'submit',
|
|
495
564
|
withText: true
|
|
@@ -499,7 +568,7 @@ export default class TableCellPropertiesView extends View {
|
|
|
499
568
|
});
|
|
500
569
|
cancelButtonView.set({
|
|
501
570
|
label: t('Cancel'),
|
|
502
|
-
icon:
|
|
571
|
+
icon: IconCancel,
|
|
503
572
|
class: 'ck-button-cancel',
|
|
504
573
|
withText: true
|
|
505
574
|
});
|
package/src/tableclipboard.d.ts
CHANGED
|
@@ -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
|
*
|
package/src/tableclipboard.js
CHANGED
|
@@ -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.
|
|
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 '
|
|
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:
|
|
237
|
-
|
|
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
|
-
|
|
340
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|
package/src/tableconfig.d.ts
CHANGED
|
@@ -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';
|