@ckeditor/ckeditor5-table 45.0.0-alpha.2 → 45.0.0-alpha.3
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/build/table.js +1 -1
- package/ckeditor5-metadata.json +2 -2
- package/dist/index-editor.css +4 -0
- package/dist/index.css +6 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +39 -86
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
- package/src/converters/tableproperties.d.ts +5 -1
- package/src/converters/tableproperties.js +12 -10
- package/src/tablecellproperties/tablecellpropertiesediting.js +5 -42
- package/src/tablelayout.d.ts +1 -1
- package/src/tablelayout.js +1 -1
- package/src/tableproperties/tablepropertiesediting.js +21 -18
- package/theme/tablelayout.css +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-table",
|
|
3
|
-
"version": "45.0.0-alpha.
|
|
3
|
+
"version": "45.0.0-alpha.3",
|
|
4
4
|
"description": "Table feature for CKEditor 5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ckeditor",
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
"type": "module",
|
|
14
14
|
"main": "src/index.js",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"ckeditor5": "45.0.0-alpha.
|
|
17
|
-
"@ckeditor/ckeditor5-clipboard": "45.0.0-alpha.
|
|
18
|
-
"@ckeditor/ckeditor5-core": "45.0.0-alpha.
|
|
19
|
-
"@ckeditor/ckeditor5-engine": "45.0.0-alpha.
|
|
20
|
-
"@ckeditor/ckeditor5-icons": "45.0.0-alpha.
|
|
21
|
-
"@ckeditor/ckeditor5-ui": "45.0.0-alpha.
|
|
22
|
-
"@ckeditor/ckeditor5-utils": "45.0.0-alpha.
|
|
23
|
-
"@ckeditor/ckeditor5-widget": "45.0.0-alpha.
|
|
16
|
+
"ckeditor5": "45.0.0-alpha.3",
|
|
17
|
+
"@ckeditor/ckeditor5-clipboard": "45.0.0-alpha.3",
|
|
18
|
+
"@ckeditor/ckeditor5-core": "45.0.0-alpha.3",
|
|
19
|
+
"@ckeditor/ckeditor5-engine": "45.0.0-alpha.3",
|
|
20
|
+
"@ckeditor/ckeditor5-icons": "45.0.0-alpha.3",
|
|
21
|
+
"@ckeditor/ckeditor5-ui": "45.0.0-alpha.3",
|
|
22
|
+
"@ckeditor/ckeditor5-utils": "45.0.0-alpha.3",
|
|
23
|
+
"@ckeditor/ckeditor5-widget": "45.0.0-alpha.3",
|
|
24
24
|
"es-toolkit": "1.32.0"
|
|
25
25
|
},
|
|
26
26
|
"author": "CKSource (http://cksource.com/)",
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @module table/converters/tableproperties
|
|
7
7
|
*/
|
|
8
|
-
import type { Conversion, ViewElement } from 'ckeditor5/src/engine.js';
|
|
8
|
+
import type { Conversion, UpcastConversionData, ViewElement } from 'ckeditor5/src/engine.js';
|
|
9
9
|
/**
|
|
10
10
|
* Conversion helper for upcasting attributes using normalized styles.
|
|
11
11
|
*
|
|
@@ -52,3 +52,7 @@ export declare function downcastTableAttribute(conversion: Conversion, options:
|
|
|
52
52
|
modelAttribute: string;
|
|
53
53
|
styleName: string;
|
|
54
54
|
}): void;
|
|
55
|
+
/**
|
|
56
|
+
* Returns the default value for table or table cell property adjusted for layout tables.
|
|
57
|
+
*/
|
|
58
|
+
export declare function getDefaultValueAdjusted(defaultValue: string, layoutTableDefault: string, data: UpcastConversionData<ViewElement>): string;
|
|
@@ -27,16 +27,7 @@ export function upcastStyleToAttribute(conversion, options) {
|
|
|
27
27
|
if (!shouldUpcast(viewElement)) {
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
// Adjust default for layout tables.
|
|
32
|
-
if (data.modelRange) {
|
|
33
|
-
const modelElement = first(data.modelRange.getItems({ shallow: true }));
|
|
34
|
-
const tableElement = modelElement && modelElement.is('element') &&
|
|
35
|
-
modelElement.findAncestor('table', { includeSelf: true });
|
|
36
|
-
if (tableElement && tableElement.getAttribute('tableType') == 'layout') {
|
|
37
|
-
localDefaultValue = '';
|
|
38
|
-
}
|
|
39
|
-
}
|
|
30
|
+
const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);
|
|
40
31
|
const normalized = viewElement.getNormalizedStyle(styleName);
|
|
41
32
|
const value = reduceBoxSides ? reduceBoxSidesValue(normalized) : normalized;
|
|
42
33
|
if (localDefaultValue !== value) {
|
|
@@ -157,6 +148,17 @@ export function downcastTableAttribute(conversion, options) {
|
|
|
157
148
|
}
|
|
158
149
|
}));
|
|
159
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Returns the default value for table or table cell property adjusted for layout tables.
|
|
153
|
+
*/
|
|
154
|
+
export function getDefaultValueAdjusted(defaultValue, layoutTableDefault, data) {
|
|
155
|
+
const modelElement = data.modelRange && first(data.modelRange.getItems({ shallow: true }));
|
|
156
|
+
const tableElement = modelElement && modelElement.is('element') && modelElement.findAncestor('table', { includeSelf: true });
|
|
157
|
+
if (tableElement && tableElement.getAttribute('tableType') === 'layout') {
|
|
158
|
+
return layoutTableDefault;
|
|
159
|
+
}
|
|
160
|
+
return defaultValue;
|
|
161
|
+
}
|
|
160
162
|
/**
|
|
161
163
|
* Reduces the full top, right, bottom, left object to a single string if all sides are equal.
|
|
162
164
|
* Returns original style otherwise.
|
|
@@ -6,9 +6,8 @@
|
|
|
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';
|
|
10
9
|
import { addBorderRules, addPaddingRules, addBackgroundRules } from 'ckeditor5/src/engine.js';
|
|
11
|
-
import { downcastAttributeToStyle, upcastBorderStyles } from '../converters/tableproperties.js';
|
|
10
|
+
import { downcastAttributeToStyle, getDefaultValueAdjusted, upcastBorderStyles } from '../converters/tableproperties.js';
|
|
12
11
|
import TableEditing from './../tableediting.js';
|
|
13
12
|
import TableCellWidthEditing from '../tablecellwidth/tablecellwidthediting.js';
|
|
14
13
|
import TableCellPaddingCommand from './commands/tablecellpaddingcommand.js';
|
|
@@ -168,16 +167,7 @@ function enableHorizontalAlignmentProperty(schema, conversion, defaultValue) {
|
|
|
168
167
|
model: {
|
|
169
168
|
key: 'tableCellHorizontalAlignment',
|
|
170
169
|
value: (viewElement, conversionApi, data) => {
|
|
171
|
-
|
|
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
|
+
const localDefaultValue = getDefaultValueAdjusted(defaultValue, 'left', data);
|
|
181
171
|
const align = viewElement.getStyle('text-align');
|
|
182
172
|
return align === localDefaultValue ? null : align;
|
|
183
173
|
}
|
|
@@ -194,16 +184,7 @@ function enableHorizontalAlignmentProperty(schema, conversion, defaultValue) {
|
|
|
194
184
|
model: {
|
|
195
185
|
key: 'tableCellHorizontalAlignment',
|
|
196
186
|
value: (viewElement, conversionApi, data) => {
|
|
197
|
-
|
|
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
|
-
}
|
|
187
|
+
const localDefaultValue = getDefaultValueAdjusted(defaultValue, 'left', data);
|
|
207
188
|
const align = viewElement.getAttribute('align');
|
|
208
189
|
return align === localDefaultValue ? null : align;
|
|
209
190
|
}
|
|
@@ -244,16 +225,7 @@ function enableVerticalAlignmentProperty(schema, conversion, defaultValue) {
|
|
|
244
225
|
model: {
|
|
245
226
|
key: 'tableCellVerticalAlignment',
|
|
246
227
|
value: (viewElement, conversionApi, data) => {
|
|
247
|
-
|
|
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
|
-
}
|
|
228
|
+
const localDefaultValue = getDefaultValueAdjusted(defaultValue, 'middle', data);
|
|
257
229
|
const align = viewElement.getStyle('vertical-align');
|
|
258
230
|
return align === localDefaultValue ? null : align;
|
|
259
231
|
}
|
|
@@ -270,16 +242,7 @@ function enableVerticalAlignmentProperty(schema, conversion, defaultValue) {
|
|
|
270
242
|
model: {
|
|
271
243
|
key: 'tableCellVerticalAlignment',
|
|
272
244
|
value: (viewElement, conversionApi, data) => {
|
|
273
|
-
|
|
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
|
-
}
|
|
245
|
+
const localDefaultValue = getDefaultValueAdjusted(defaultValue, 'middle', data);
|
|
283
246
|
const valign = viewElement.getAttribute('valign');
|
|
284
247
|
return valign === localDefaultValue ? null : valign;
|
|
285
248
|
}
|
package/src/tablelayout.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import TableColumnResize from './tablecolumnresize.js';
|
|
|
13
13
|
/**
|
|
14
14
|
* The table plugin.
|
|
15
15
|
*
|
|
16
|
-
* For a detailed overview, check the {@glink features/tables/tables
|
|
16
|
+
* For a detailed overview, check the {@glink features/tables/layout-tables Layout table feature documentation}.
|
|
17
17
|
*/
|
|
18
18
|
export default class TableLayout extends Plugin {
|
|
19
19
|
/**
|
package/src/tablelayout.js
CHANGED
|
@@ -13,7 +13,7 @@ import TableColumnResize from './tablecolumnresize.js';
|
|
|
13
13
|
/**
|
|
14
14
|
* The table plugin.
|
|
15
15
|
*
|
|
16
|
-
* For a detailed overview, check the {@glink features/tables/tables
|
|
16
|
+
* For a detailed overview, check the {@glink features/tables/layout-tables Layout table feature documentation}.
|
|
17
17
|
*/
|
|
18
18
|
export default class TableLayout extends Plugin {
|
|
19
19
|
/**
|
|
@@ -6,10 +6,9 @@
|
|
|
6
6
|
* @module table/tableproperties/tablepropertiesediting
|
|
7
7
|
*/
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
|
9
|
-
import { first } from 'ckeditor5/src/utils.js';
|
|
10
9
|
import { addBackgroundRules, addBorderRules } from 'ckeditor5/src/engine.js';
|
|
11
10
|
import TableEditing from '../tableediting.js';
|
|
12
|
-
import { downcastAttributeToStyle, downcastTableAttribute, upcastBorderStyles, upcastStyleToAttribute } from '../converters/tableproperties.js';
|
|
11
|
+
import { downcastAttributeToStyle, downcastTableAttribute, getDefaultValueAdjusted, upcastBorderStyles, upcastStyleToAttribute } from '../converters/tableproperties.js';
|
|
13
12
|
import TableBackgroundColorCommand from './commands/tablebackgroundcolorcommand.js';
|
|
14
13
|
import TableBorderColorCommand from './commands/tablebordercolorcommand.js';
|
|
15
14
|
import TableBorderStyleCommand from './commands/tableborderstylecommand.js';
|
|
@@ -178,14 +177,7 @@ function enableAlignmentProperty(schema, conversion, defaultValue) {
|
|
|
178
177
|
model: {
|
|
179
178
|
key: 'tableAlignment',
|
|
180
179
|
value: (viewElement, conversionApi, data) => {
|
|
181
|
-
|
|
182
|
-
// Adjust default for layout tables.
|
|
183
|
-
if (data.modelRange) {
|
|
184
|
-
const modelElement = first(data.modelRange.getItems({ shallow: true }));
|
|
185
|
-
if (modelElement && modelElement.is('element') && modelElement.getAttribute('tableType') == 'layout') {
|
|
186
|
-
localDefaultValue = '';
|
|
187
|
-
}
|
|
188
|
-
}
|
|
180
|
+
const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);
|
|
189
181
|
let align = viewElement.getStyle('float');
|
|
190
182
|
// CSS: `float:none` => Model: `alignment:center`.
|
|
191
183
|
if (align === 'none') {
|
|
@@ -194,6 +186,24 @@ function enableAlignmentProperty(schema, conversion, defaultValue) {
|
|
|
194
186
|
return align === localDefaultValue ? null : align;
|
|
195
187
|
}
|
|
196
188
|
}
|
|
189
|
+
})
|
|
190
|
+
// Support for the `margin-left:auto; margin-right:auto;` CSS definition for the table alignment.
|
|
191
|
+
.attributeToAttribute({
|
|
192
|
+
view: {
|
|
193
|
+
name: /^(table|figure)$/,
|
|
194
|
+
styles: {
|
|
195
|
+
'margin-left': 'auto',
|
|
196
|
+
'margin-right': 'auto'
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
model: {
|
|
200
|
+
key: 'tableAlignment',
|
|
201
|
+
value: (viewElement, conversionApi, data) => {
|
|
202
|
+
const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);
|
|
203
|
+
const align = 'center';
|
|
204
|
+
return align === localDefaultValue ? null : align;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
197
207
|
})
|
|
198
208
|
// Support for the `align` attribute as the backward compatibility while pasting from other sources.
|
|
199
209
|
.attributeToAttribute({
|
|
@@ -206,14 +216,7 @@ function enableAlignmentProperty(schema, conversion, defaultValue) {
|
|
|
206
216
|
name: 'table',
|
|
207
217
|
key: 'tableAlignment',
|
|
208
218
|
value: (viewElement, conversionApi, data) => {
|
|
209
|
-
|
|
210
|
-
// Adjust default for layout tables.
|
|
211
|
-
if (data.modelRange) {
|
|
212
|
-
const modelElement = first(data.modelRange.getItems({ shallow: true }));
|
|
213
|
-
if (modelElement && modelElement.is('element') && modelElement.getAttribute('tableType') == 'layout') {
|
|
214
|
-
localDefaultValue = '';
|
|
215
|
-
}
|
|
216
|
-
}
|
|
219
|
+
const localDefaultValue = getDefaultValueAdjusted(defaultValue, '', data);
|
|
217
220
|
const align = viewElement.getAttribute('align');
|
|
218
221
|
return align === localDefaultValue ? null : align;
|
|
219
222
|
}
|
package/theme/tablelayout.css
CHANGED
|
@@ -27,6 +27,12 @@
|
|
|
27
27
|
|
|
28
28
|
/* Widget type around overrides. */
|
|
29
29
|
&.ck-widget {
|
|
30
|
+
&:hover {
|
|
31
|
+
/* To prevent the widget outline from being cut off at the bottom
|
|
32
|
+
when the next cell or table has a background color, for example. */
|
|
33
|
+
z-index: var(--ck-z-default);
|
|
34
|
+
}
|
|
35
|
+
|
|
30
36
|
&:hover > .ck-widget__selection-handle {
|
|
31
37
|
opacity: 0.75;
|
|
32
38
|
visibility: visible;
|