@ckeditor/ckeditor5-table 0.0.0-nightly-next-20251230.0 → 0.0.0-nightly-20251231.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.
- 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 -1
- 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 +2 -11
- package/dist/index-content.css +30 -30
- package/dist/index-editor.css +170 -104
- package/dist/index.css +237 -147
- package/dist/index.css.map +1 -1
- package/dist/index.js +2433 -448
- package/dist/index.js.map +1 -1
- package/lang/contexts.json +4 -2
- package/package.json +9 -9
- package/src/augmentation.d.ts +15 -0
- package/src/converters/downcast.js +13 -6
- package/src/index.d.ts +5 -2
- package/src/index.js +5 -1
- package/src/tablecellproperties/commands/tablecelltypecommand.d.ts +4 -0
- package/src/tablecellproperties/commands/tablecelltypecommand.js +1 -2
- package/src/tablecellproperties/tablecellpropertiesediting.js +8 -48
- package/src/tablecellproperties/tablecellpropertiesui.js +11 -33
- package/src/tablecellproperties/tablecellpropertiesuiexperimental.d.ts +128 -0
- package/src/tablecellproperties/tablecellpropertiesuiexperimental.js +408 -0
- package/src/tablecellproperties/ui/tablecellpropertiesview.d.ts +0 -36
- package/src/tablecellproperties/ui/tablecellpropertiesview.js +23 -143
- package/src/tablecellproperties/ui/tablecellpropertiesviewexperimental.d.ts +266 -0
- package/src/tablecellproperties/ui/tablecellpropertiesviewexperimental.js +744 -0
- package/src/tableconfig.d.ts +4 -24
- package/src/tablelayout/tablelayoutui.js +8 -2
- package/src/tableproperties/tablepropertiesediting.js +147 -14
- package/src/tableproperties/tablepropertiesuiexperimental.d.ts +136 -0
- package/src/tableproperties/tablepropertiesuiexperimental.js +375 -0
- package/src/tableproperties/ui/tablepropertiesview.d.ts +0 -8
- package/src/tableproperties/ui/tablepropertiesview.js +37 -59
- package/src/tableproperties/ui/tablepropertiesviewexperimental.d.ts +216 -0
- package/src/tableproperties/ui/tablepropertiesviewexperimental.js +544 -0
- package/src/tableutils.js +23 -58
- package/src/utils/common.js +4 -4
- package/src/utils/ui/table-propertiesexperimental.d.ts +215 -0
- package/src/utils/ui/table-propertiesexperimental.js +391 -0
- package/theme/formrow-experimental.css +15 -0
- package/theme/formrow.css +0 -2
- package/theme/tablecellproperties-experimental.css +4 -0
- package/theme/tableform-experimental.css +61 -0
- package/theme/tableform.css +5 -1
- package/theme/tableproperties-experimental.css +78 -0
- package/theme/tableproperties.css +0 -60
- package/src/tablecellproperties/tablecellpropertiesutils.d.ts +0 -18
- package/src/tablecellproperties/tablecellpropertiesutils.js +0 -15
package/lang/contexts.json
CHANGED
|
@@ -26,8 +26,6 @@
|
|
|
26
26
|
"Cell type": "The label for the dropdown that allows configuring the type of a table cell (data or header).",
|
|
27
27
|
"Data cell": "The label for the dropdown option for a data table cell.",
|
|
28
28
|
"Header cell": "The label for the dropdown option for a header table cell.",
|
|
29
|
-
"Column header": "The label for the dropdown option for a header table cell that represents a column header.",
|
|
30
|
-
"Row header": "The label for the dropdown option for a header table cell that represents a row header.",
|
|
31
29
|
"Border": "The label describing a group of border–related form fields (border style, color, etc.).",
|
|
32
30
|
"Style": "The label for the dropdown that allows configuring the border style of a table or a table cell.",
|
|
33
31
|
"Width": "The label for the input that allows configuring the width of a table or a table cell or the width of a border.",
|
|
@@ -38,6 +36,7 @@
|
|
|
38
36
|
"Dimensions": "The label describing a group of form fields that allows setting dimensions of a table or a table cell.",
|
|
39
37
|
"Table cell text alignment": "The label for the group of toolbars that allows configuring the text alignment in a table cell.",
|
|
40
38
|
"Table Alignment": "The label for the toolbar that allows configuring the alignment of a table.",
|
|
39
|
+
"Alignment": "The label for the toolbar that allows configuring the alignment of a table.",
|
|
41
40
|
"Horizontal text alignment toolbar": "The label used by assistive technologies describing a toolbar that allows configuring the horizontal text alignment in a table cell.",
|
|
42
41
|
"Vertical text alignment toolbar": "The label used by assistive technologies describing a toolbar that allows configuring the vertical text alignment in a table cell.",
|
|
43
42
|
"Table alignment toolbar": "The label used by assistive technologies describing a toolbar that allows configuring the alignment of a table.",
|
|
@@ -62,6 +61,9 @@
|
|
|
62
61
|
"Align table to the right with text wrapping": "The label used by assistive technologies describing a button that aligns the table to the right as an inline element, allowing text to wrap around it.",
|
|
63
62
|
"Align table to the left with no text wrapping": "The label used by assistive technologies describing a button that aligns the table to the left as a block element with no text wrapping.",
|
|
64
63
|
"Align table to the right with no text wrapping": "The label used by assistive technologies describing a button that aligns the table to the right as a block element with no text wrapping.",
|
|
64
|
+
"Align table to the left": "The label used by assistive technologies describing a button that aligns the table to the left.",
|
|
65
|
+
"Center table": "The label used by assistive technologies describing a button that centers the table.",
|
|
66
|
+
"Align table to the right": "The label used by assistive technologies describing a button that aligns the table to the right.",
|
|
65
67
|
"The color is invalid. Try \"#FF0000\" or \"rgb(255,0,0)\" or \"red\".": "The localized error string that can be displayed next to color (background, border) fields that have an invalid value",
|
|
66
68
|
"The value is invalid. Try \"10px\" or \"2em\" or simply \"2\".": "The localized error string that can be displayed next to length (padding, border width) fields that have an invalid value.",
|
|
67
69
|
"Enter table caption": "The placeholder text for the table caption displayed when the caption is empty.",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-table",
|
|
3
|
-
"version": "0.0.0-nightly-
|
|
3
|
+
"version": "0.0.0-nightly-20251231.0",
|
|
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": "0.0.0-nightly-
|
|
17
|
-
"@ckeditor/ckeditor5-clipboard": "0.0.0-nightly-
|
|
18
|
-
"@ckeditor/ckeditor5-core": "0.0.0-nightly-
|
|
19
|
-
"@ckeditor/ckeditor5-engine": "0.0.0-nightly-
|
|
20
|
-
"@ckeditor/ckeditor5-icons": "0.0.0-nightly-
|
|
21
|
-
"@ckeditor/ckeditor5-ui": "0.0.0-nightly-
|
|
22
|
-
"@ckeditor/ckeditor5-utils": "0.0.0-nightly-
|
|
23
|
-
"@ckeditor/ckeditor5-widget": "0.0.0-nightly-
|
|
16
|
+
"ckeditor5": "0.0.0-nightly-20251231.0",
|
|
17
|
+
"@ckeditor/ckeditor5-clipboard": "0.0.0-nightly-20251231.0",
|
|
18
|
+
"@ckeditor/ckeditor5-core": "0.0.0-nightly-20251231.0",
|
|
19
|
+
"@ckeditor/ckeditor5-engine": "0.0.0-nightly-20251231.0",
|
|
20
|
+
"@ckeditor/ckeditor5-icons": "0.0.0-nightly-20251231.0",
|
|
21
|
+
"@ckeditor/ckeditor5-ui": "0.0.0-nightly-20251231.0",
|
|
22
|
+
"@ckeditor/ckeditor5-utils": "0.0.0-nightly-20251231.0",
|
|
23
|
+
"@ckeditor/ckeditor5-widget": "0.0.0-nightly-20251231.0",
|
|
24
24
|
"es-toolkit": "1.39.5"
|
|
25
25
|
},
|
|
26
26
|
"author": "CKSource (http://cksource.com/)",
|
package/src/augmentation.d.ts
CHANGED
|
@@ -15,6 +15,21 @@ declare module '@ckeditor/ckeditor5-engine' {
|
|
|
15
15
|
* This will be enabled by default in the future CKEditor 5 releases.
|
|
16
16
|
*/
|
|
17
17
|
upcastTableBorderZeroAttributes?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* When enabled, the the {@link module:table/tableproperties/tablepropertiesediting~TablePropertiesEditing table properties feature}
|
|
20
|
+
* will support extended alignment options for tables, i.e. `blockLeft` and `blockRight`, using CSS `margin` property.
|
|
21
|
+
*
|
|
22
|
+
* This will be enabled by default in the future CKEditor 5 releases.
|
|
23
|
+
*/
|
|
24
|
+
useExtendedTableBlockAlignment?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* When enabled, the
|
|
27
|
+
* {@link module:table/tablecellproperties/tablecellpropertiesediting~TableCellPropertiesEditing table cell properties feature}
|
|
28
|
+
* will introduce a special selector for table cell types (i.e. header and data cells) in the cell properties dropdown.
|
|
29
|
+
*
|
|
30
|
+
* This will be enabled by default in the future CKEditor 5 releases.
|
|
31
|
+
*/
|
|
32
|
+
tableCellTypeSupport?: boolean;
|
|
18
33
|
}
|
|
19
34
|
}
|
|
20
35
|
declare module '@ckeditor/ckeditor5-core' {
|
|
@@ -6,7 +6,6 @@ import { toWidget, toWidgetEditable } from 'ckeditor5/src/widget.js';
|
|
|
6
6
|
import { downcastTableAlignmentConfig } from './tableproperties.js';
|
|
7
7
|
import { getNormalizedDefaultTableProperties } from '../utils/table-properties.js';
|
|
8
8
|
import { TableWalker } from '../tablewalker.js';
|
|
9
|
-
import { isTableHeaderCellType } from '../tablecellproperties/tablecellpropertiesutils.js';
|
|
10
9
|
/**
|
|
11
10
|
* Model table element to view table element conversion helper.
|
|
12
11
|
*
|
|
@@ -67,8 +66,7 @@ export function downcastCell(options) {
|
|
|
67
66
|
return (tableCell, { writer }) => {
|
|
68
67
|
// If the table cell type feature is enabled, then we can simply check the cell type attribute.
|
|
69
68
|
if (options.cellTypeEnabled?.()) {
|
|
70
|
-
const
|
|
71
|
-
const cellElementName = (isTableHeaderCellType(tableCellType) ?
|
|
69
|
+
const cellElementName = (tableCell.getAttribute('tableCellType') === 'header' ?
|
|
72
70
|
'th' :
|
|
73
71
|
'td');
|
|
74
72
|
return createCellElement(writer, cellElementName);
|
|
@@ -176,7 +174,10 @@ function hasAnyAttribute(element) {
|
|
|
176
174
|
*/
|
|
177
175
|
export function convertPlainTable(editor) {
|
|
178
176
|
return (table, conversionApi) => {
|
|
179
|
-
|
|
177
|
+
const hasPlainTableOutput = editor.plugins.has('PlainTableOutput');
|
|
178
|
+
const isClipboardPipeline = conversionApi.options.isClipboardPipeline;
|
|
179
|
+
const useExtendedAlignment = editor.config.get('experimentalFlags.useExtendedTableBlockAlignment');
|
|
180
|
+
if (!hasPlainTableOutput && !(useExtendedAlignment && isClipboardPipeline)) {
|
|
180
181
|
return null;
|
|
181
182
|
}
|
|
182
183
|
return downcastPlainTable(table, conversionApi, editor);
|
|
@@ -187,7 +188,10 @@ export function convertPlainTable(editor) {
|
|
|
187
188
|
*/
|
|
188
189
|
export function convertPlainTableCaption(editor) {
|
|
189
190
|
return (modelElement, { writer, options }) => {
|
|
190
|
-
|
|
191
|
+
const hasPlainTableOutput = editor.plugins.has('PlainTableOutput');
|
|
192
|
+
const isClipboardPipeline = options.isClipboardPipeline;
|
|
193
|
+
const useExtendedAlignment = editor.config.get('experimentalFlags.useExtendedTableBlockAlignment');
|
|
194
|
+
if (!hasPlainTableOutput && !(useExtendedAlignment && isClipboardPipeline)) {
|
|
191
195
|
return null;
|
|
192
196
|
}
|
|
193
197
|
if (modelElement.parent.name === 'table') {
|
|
@@ -272,7 +276,10 @@ export function downcastTableBorderAndBackgroundAttributes(editor) {
|
|
|
272
276
|
return dispatcher.on(`attribute:${modelAttribute}:table`, (evt, data, conversionApi) => {
|
|
273
277
|
const { item, attributeNewValue } = data;
|
|
274
278
|
const { mapper, writer } = conversionApi;
|
|
275
|
-
|
|
279
|
+
const hasPlainTableOutput = editor.plugins.has('PlainTableOutput');
|
|
280
|
+
const isClipboardPipeline = conversionApi.options.isClipboardPipeline;
|
|
281
|
+
const useExtendedAlignment = editor.config.get('experimentalFlags.useExtendedTableBlockAlignment');
|
|
282
|
+
if (!hasPlainTableOutput && !(useExtendedAlignment && isClipboardPipeline)) {
|
|
276
283
|
return;
|
|
277
284
|
}
|
|
278
285
|
if (!conversionApi.consumable.consume(item, evt.name)) {
|
package/src/index.d.ts
CHANGED
|
@@ -34,6 +34,10 @@ export { TableUtils, type TableIndexesObject } from './tableutils.js';
|
|
|
34
34
|
export { TableColumnResize } from './tablecolumnresize.js';
|
|
35
35
|
export { TableColumnResizeEditing } from './tablecolumnresize/tablecolumnresizeediting.js';
|
|
36
36
|
export { TableWidthsCommand, type TableWidthsCommandOptions } from './tablecolumnresize/tablewidthscommand.js';
|
|
37
|
+
export { TablePropertiesUIExperimental } from './tableproperties/tablepropertiesuiexperimental.js';
|
|
38
|
+
export { TablePropertiesViewExperimental, type TablePropertiesViewOptionsExperimental } from './tableproperties/ui/tablepropertiesviewexperimental.js';
|
|
39
|
+
export { TableCellPropertiesUIExperimental } from './tablecellproperties/tablecellpropertiesuiexperimental.js';
|
|
40
|
+
export { TableCellPropertiesViewExperimental, type TableCellPropertiesViewOptionsExperimental } from './tablecellproperties/ui/tablecellpropertiesviewexperimental.js';
|
|
37
41
|
export { InsertColumnCommand } from './commands/insertcolumncommand.js';
|
|
38
42
|
export { InsertRowCommand } from './commands/insertrowcommand.js';
|
|
39
43
|
export { InsertTableCommand } from './commands/inserttablecommand.js';
|
|
@@ -66,8 +70,7 @@ export { TableBorderWidthCommand } from './tableproperties/commands/tableborderw
|
|
|
66
70
|
export { TableHeightCommand } from './tableproperties/commands/tableheightcommand.js';
|
|
67
71
|
export { TableWidthCommand } from './tableproperties/commands/tablewidthcommand.js';
|
|
68
72
|
export { TablePropertyCommand, type TablePropertyCommandExecuteOptions } from './tableproperties/commands/tablepropertycommand.js';
|
|
69
|
-
export { TableCellTypeCommand } from './tablecellproperties/commands/tablecelltypecommand.js';
|
|
70
|
-
export { isTableHeaderCellType, type TableCellType } from './tablecellproperties/tablecellpropertiesutils.js';
|
|
73
|
+
export { TableCellTypeCommand, type TableCellType } from './tablecellproperties/commands/tablecelltypecommand.js';
|
|
71
74
|
export { TableCellPropertyCommand, type TableCellPropertyCommandAfterExecuteEvent, type TableCellPropertyCommandAfterExecuteEventData } from './tablecellproperties/commands/tablecellpropertycommand.js';
|
|
72
75
|
export type { ViewDocumentTableMouseMoveEvent, ViewDocumentTableMouseLeaveEvent } from './tablemouse/mouseeventsobserver.js';
|
|
73
76
|
export type { TableConfig, TableAlignmentConfig, TablePropertiesConfig, TablePropertiesOptions, TableCellPropertiesConfig, TableColorConfig, TableCellPropertiesOptions, TableLayoutConfig, TableCaptionConfig, TableType } from './tableconfig.js';
|
package/src/index.js
CHANGED
|
@@ -34,6 +34,11 @@ export { TableUtils } from './tableutils.js';
|
|
|
34
34
|
export { TableColumnResize } from './tablecolumnresize.js';
|
|
35
35
|
export { TableColumnResizeEditing } from './tablecolumnresize/tablecolumnresizeediting.js';
|
|
36
36
|
export { TableWidthsCommand } from './tablecolumnresize/tablewidthscommand.js';
|
|
37
|
+
// [experimental] Remove in the v48.
|
|
38
|
+
export { TablePropertiesUIExperimental } from './tableproperties/tablepropertiesuiexperimental.js';
|
|
39
|
+
export { TablePropertiesViewExperimental } from './tableproperties/ui/tablepropertiesviewexperimental.js';
|
|
40
|
+
export { TableCellPropertiesUIExperimental } from './tablecellproperties/tablecellpropertiesuiexperimental.js';
|
|
41
|
+
export { TableCellPropertiesViewExperimental } from './tablecellproperties/ui/tablecellpropertiesviewexperimental.js';
|
|
37
42
|
export { InsertColumnCommand } from './commands/insertcolumncommand.js';
|
|
38
43
|
export { InsertRowCommand } from './commands/insertrowcommand.js';
|
|
39
44
|
export { InsertTableCommand } from './commands/inserttablecommand.js';
|
|
@@ -67,7 +72,6 @@ export { TableHeightCommand } from './tableproperties/commands/tableheightcomman
|
|
|
67
72
|
export { TableWidthCommand } from './tableproperties/commands/tablewidthcommand.js';
|
|
68
73
|
export { TablePropertyCommand } from './tableproperties/commands/tablepropertycommand.js';
|
|
69
74
|
export { TableCellTypeCommand } from './tablecellproperties/commands/tablecelltypecommand.js';
|
|
70
|
-
export { isTableHeaderCellType } from './tablecellproperties/tablecellpropertiesutils.js';
|
|
71
75
|
export { TableCellPropertyCommand } from './tablecellproperties/commands/tablecellpropertycommand.js';
|
|
72
76
|
// Internal exports.
|
|
73
77
|
export { downcastTable as _downcastTable, downcastRow as _downcastTableRow, downcastCell as _downcastTableCell, convertParagraphInTableCell as _convertParagraphInTableCell, isSingleParagraphWithoutAttributes as _isSingleTableParagraphWithoutAttributes } from './converters/downcast.js';
|
|
@@ -42,6 +42,10 @@ export declare class TableCellTypeCommand extends TableCellPropertyCommand {
|
|
|
42
42
|
*/
|
|
43
43
|
protected _getAttribute(tableCell: ModelElement | undefined): unknown;
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Type of the table cell.
|
|
47
|
+
*/
|
|
48
|
+
export type TableCellType = 'data' | 'header';
|
|
45
49
|
/**
|
|
46
50
|
* Updates the `headingRows` and `headingColumns` attributes of the given tables
|
|
47
51
|
* based on the `tableCellType` of their cells.
|
|
@@ -6,7 +6,6 @@ import { TableUtils } from '../../tableutils.js';
|
|
|
6
6
|
import { TableCellPropertyCommand } from './tablecellpropertycommand.js';
|
|
7
7
|
import { groupCellsByTable, getSelectionAffectedTable } from '../../utils/common.js';
|
|
8
8
|
import { TableWalker } from '../../tablewalker.js';
|
|
9
|
-
import { isTableHeaderCellType } from '../tablecellpropertiesutils.js';
|
|
10
9
|
/**
|
|
11
10
|
* The table cell type command.
|
|
12
11
|
*
|
|
@@ -142,7 +141,7 @@ function getAdjustedHeadingSectionSize(tableUtils, table, mode, currentSize, per
|
|
|
142
141
|
// Check each cell in the current row/column.
|
|
143
142
|
for (const { cell, row, column } of walker) {
|
|
144
143
|
// If we find a non-header cell, this row/column can't be part of the heading section.
|
|
145
|
-
if (
|
|
144
|
+
if (cell.getAttribute('tableCellType') !== 'header') {
|
|
146
145
|
allCellsAreHeaders = false;
|
|
147
146
|
break;
|
|
148
147
|
}
|
|
@@ -24,7 +24,6 @@ import { getNormalizedDefaultCellProperties } from '../utils/table-properties.js
|
|
|
24
24
|
import { enableProperty } from '../utils/common.js';
|
|
25
25
|
import { TableUtils } from '../tableutils.js';
|
|
26
26
|
import { TableWalker } from '../tablewalker.js';
|
|
27
|
-
import { isTableHeaderCellType } from './tablecellpropertiesutils.js';
|
|
28
27
|
const VALIGN_VALUES_REG_EXP = /^(top|middle|bottom)$/;
|
|
29
28
|
const ALIGN_VALUES_REG_EXP = /^(left|center|right|justify)$/;
|
|
30
29
|
/**
|
|
@@ -130,8 +129,10 @@ export class TableCellPropertiesEditing extends Plugin {
|
|
|
130
129
|
editor.commands.add('tableCellHorizontalAlignment', new TableCellHorizontalAlignmentCommand(editor, defaultTableCellProperties.horizontalAlignment));
|
|
131
130
|
enableVerticalAlignmentProperty(schema, conversion, defaultTableCellProperties.verticalAlignment);
|
|
132
131
|
editor.commands.add('tableCellVerticalAlignment', new TableCellVerticalAlignmentCommand(editor, defaultTableCellProperties.verticalAlignment));
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
if (editor.config.get('experimentalFlags.tableCellTypeSupport')) {
|
|
133
|
+
enableCellTypeProperty(editor);
|
|
134
|
+
editor.commands.add('tableCellType', new TableCellTypeCommand(editor));
|
|
135
|
+
}
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
/**
|
|
@@ -301,9 +302,8 @@ function enableVerticalAlignmentProperty(schema, conversion, defaultValue) {
|
|
|
301
302
|
* Enables the `tableCellType` attribute for table cells.
|
|
302
303
|
*/
|
|
303
304
|
function enableCellTypeProperty(editor) {
|
|
304
|
-
const { model, conversion, editing
|
|
305
|
+
const { model, conversion, editing } = editor;
|
|
305
306
|
const { schema } = model;
|
|
306
|
-
const scopedHeaders = !!config.get('table.tableCellProperties.scopedHeaders');
|
|
307
307
|
const tableUtils = editor.plugins.get(TableUtils);
|
|
308
308
|
schema.extend('tableCell', {
|
|
309
309
|
allowAttributes: ['tableCellType']
|
|
@@ -324,7 +324,7 @@ function enableCellTypeProperty(editor) {
|
|
|
324
324
|
const { writer } = conversionApi;
|
|
325
325
|
const { modelRange } = data;
|
|
326
326
|
const modelElement = modelRange?.start.nodeAfter;
|
|
327
|
-
if (modelElement?.is('element', 'tableCell')
|
|
327
|
+
if (modelElement?.is('element', 'tableCell')) {
|
|
328
328
|
writer.setAttribute('tableCellType', 'header', modelElement);
|
|
329
329
|
}
|
|
330
330
|
});
|
|
@@ -336,8 +336,7 @@ function enableCellTypeProperty(editor) {
|
|
|
336
336
|
const modelElement = modelRange?.start.nodeAfter;
|
|
337
337
|
if (modelElement?.is('element', 'table') && modelElement.getAttribute('tableType') === 'layout') {
|
|
338
338
|
for (const { cell } of new TableWalker(modelElement)) {
|
|
339
|
-
|
|
340
|
-
if (isTableHeaderCellType(tableCellType)) {
|
|
339
|
+
if (cell.getAttribute('tableCellType') === 'header') {
|
|
341
340
|
writer.setAttribute('tableType', 'content', modelElement);
|
|
342
341
|
break;
|
|
343
342
|
}
|
|
@@ -345,45 +344,6 @@ function enableCellTypeProperty(editor) {
|
|
|
345
344
|
}
|
|
346
345
|
}, { priority: priorities.low - 1 });
|
|
347
346
|
});
|
|
348
|
-
// If scoped headers are enabled, add conversion for the `scope` attribute.
|
|
349
|
-
if (scopedHeaders) {
|
|
350
|
-
conversion.for('downcast').attributeToAttribute({
|
|
351
|
-
model: {
|
|
352
|
-
name: 'tableCell',
|
|
353
|
-
key: 'tableCellType'
|
|
354
|
-
},
|
|
355
|
-
view: (modelAttributeValue) => {
|
|
356
|
-
switch (modelAttributeValue) {
|
|
357
|
-
case 'header-row':
|
|
358
|
-
return { key: 'scope', value: 'row' };
|
|
359
|
-
case 'header-column':
|
|
360
|
-
return { key: 'scope', value: 'col' };
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
// Attribute to attribute conversion tend to not override existing `tableCellType` set by other converters.
|
|
365
|
-
// However, in this scenario if the previous converter set `tableCellType` to `header`, we can adjust it
|
|
366
|
-
// based on the `scope` attribute.
|
|
367
|
-
conversion.for('upcast').add(dispatcher => {
|
|
368
|
-
dispatcher.on('element:th', (_, data, conversionApi) => {
|
|
369
|
-
const { writer, consumable } = conversionApi;
|
|
370
|
-
const { viewItem, modelRange } = data;
|
|
371
|
-
const modelElement = modelRange.start.nodeAfter;
|
|
372
|
-
const previousTableCellType = modelElement?.getAttribute('tableCellType');
|
|
373
|
-
if (previousTableCellType === 'header' && consumable.consume(viewItem, { attributes: ['scope'] })) {
|
|
374
|
-
const scope = viewItem.getAttribute('scope');
|
|
375
|
-
switch (scope) {
|
|
376
|
-
case 'row':
|
|
377
|
-
writer.setAttribute('tableCellType', 'header-row', modelElement);
|
|
378
|
-
break;
|
|
379
|
-
case 'col':
|
|
380
|
-
writer.setAttribute('tableCellType', 'header-column', modelElement);
|
|
381
|
-
break;
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
});
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
347
|
// Registers a post-fixer that ensures the `headingRows` and `headingColumns` attributes
|
|
388
348
|
// are consistent with the `tableCellType` attribute of the cells. `tableCellType` has priority
|
|
389
349
|
// over `headingRows` and `headingColumns` and we use it to adjust the heading sections of the table.
|
|
@@ -443,7 +403,7 @@ function enableCellTypeProperty(editor) {
|
|
|
443
403
|
for (const tableCell of cellsToReconvert) {
|
|
444
404
|
const viewElement = editing.mapper.toViewElement(tableCell);
|
|
445
405
|
const cellType = tableCell.getAttribute('tableCellType');
|
|
446
|
-
const expectedElementName =
|
|
406
|
+
const expectedElementName = cellType === 'header' ? 'th' : 'td';
|
|
447
407
|
if (viewElement?.name !== expectedElementName) {
|
|
448
408
|
editing.reconvertItem(tableCell);
|
|
449
409
|
}
|
|
@@ -25,8 +25,7 @@ const propertyToCommandMap = {
|
|
|
25
25
|
padding: 'tableCellPadding',
|
|
26
26
|
backgroundColor: 'tableCellBackgroundColor',
|
|
27
27
|
horizontalAlignment: 'tableCellHorizontalAlignment',
|
|
28
|
-
verticalAlignment: 'tableCellVerticalAlignment'
|
|
29
|
-
cellType: 'tableCellType'
|
|
28
|
+
verticalAlignment: 'tableCellVerticalAlignment'
|
|
30
29
|
};
|
|
31
30
|
/**
|
|
32
31
|
* The table cell properties UI plugin. It introduces the `'tableCellProperties'` button
|
|
@@ -125,10 +124,8 @@ export class TableCellPropertiesUI extends Plugin {
|
|
|
125
124
|
tooltip: true
|
|
126
125
|
});
|
|
127
126
|
this.listenTo(view, 'execute', () => this._showView());
|
|
128
|
-
const commands = (
|
|
129
|
-
.
|
|
130
|
-
.map(commandName => editor.commands.get(commandName))
|
|
131
|
-
.filter(val => !!val));
|
|
127
|
+
const commands = Object.values(propertyToCommandMap)
|
|
128
|
+
.map(commandName => editor.commands.get(commandName));
|
|
132
129
|
view.bind('isEnabled').toMany(commands, 'isEnabled', (...areEnabled) => (areEnabled.some(isCommandEnabled => isCommandEnabled)));
|
|
133
130
|
return view;
|
|
134
131
|
});
|
|
@@ -152,7 +149,6 @@ export class TableCellPropertiesUI extends Plugin {
|
|
|
152
149
|
_createPropertiesView(defaultTableCellProperties) {
|
|
153
150
|
const editor = this.editor;
|
|
154
151
|
const config = editor.config.get('table.tableCellProperties');
|
|
155
|
-
const scopedHeaders = !!editor.config.get('table.tableCellProperties.scopedHeaders');
|
|
156
152
|
const borderColorsConfig = normalizeColorOptions(config.borderColors);
|
|
157
153
|
const localizedBorderColors = getLocalizedColorOptions(editor.locale, borderColorsConfig);
|
|
158
154
|
const backgroundColorsConfig = normalizeColorOptions(config.backgroundColors);
|
|
@@ -162,8 +158,7 @@ export class TableCellPropertiesUI extends Plugin {
|
|
|
162
158
|
borderColors: localizedBorderColors,
|
|
163
159
|
backgroundColors: localizedBackgroundColors,
|
|
164
160
|
defaultTableCellProperties,
|
|
165
|
-
colorPickerConfig: hasColorPicker ? (config.colorPicker || {}) : false
|
|
166
|
-
showScopedHeaderOptions: scopedHeaders
|
|
161
|
+
colorPickerConfig: hasColorPicker ? (config.colorPicker || {}) : false
|
|
167
162
|
});
|
|
168
163
|
const t = editor.t;
|
|
169
164
|
// Render the view so its #element is available for the clickOutsideHandler.
|
|
@@ -236,11 +231,6 @@ export class TableCellPropertiesUI extends Plugin {
|
|
|
236
231
|
}));
|
|
237
232
|
view.on('change:horizontalAlignment', this._getPropertyChangeCallback('tableCellHorizontalAlignment'));
|
|
238
233
|
view.on('change:verticalAlignment', this._getPropertyChangeCallback('tableCellVerticalAlignment'));
|
|
239
|
-
const cellTypeCommand = editor.commands.get('tableCellType');
|
|
240
|
-
if (cellTypeCommand) {
|
|
241
|
-
view.cellTypeDropdown.bind('isEnabled').to(cellTypeCommand, 'isEnabled');
|
|
242
|
-
view.on('change:cellType', this._getPropertyChangeCallback('tableCellType'));
|
|
243
|
-
}
|
|
244
234
|
return view;
|
|
245
235
|
}
|
|
246
236
|
/**
|
|
@@ -254,28 +244,16 @@ export class TableCellPropertiesUI extends Plugin {
|
|
|
254
244
|
_fillViewFormFromCommandValues() {
|
|
255
245
|
const commands = this.editor.commands;
|
|
256
246
|
const borderStyleCommand = commands.get('tableCellBorderStyle');
|
|
257
|
-
Object
|
|
258
|
-
.
|
|
259
|
-
.flatMap(([property, commandName]) => {
|
|
260
|
-
const command = commands.get(commandName);
|
|
261
|
-
if (!command) {
|
|
262
|
-
return [];
|
|
263
|
-
}
|
|
247
|
+
Object.entries(propertyToCommandMap)
|
|
248
|
+
.map(([property, commandName]) => {
|
|
264
249
|
const propertyKey = property;
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
else {
|
|
270
|
-
defaultValue = this.view === this._viewWithContentTableDefaults ?
|
|
271
|
-
this._defaultContentTableCellProperties[propertyKey] || '' :
|
|
272
|
-
this._defaultLayoutTableCellProperties[propertyKey] || '';
|
|
273
|
-
}
|
|
274
|
-
const entry = [
|
|
250
|
+
const defaultValue = this.view === this._viewWithContentTableDefaults ?
|
|
251
|
+
this._defaultContentTableCellProperties[propertyKey] || '' :
|
|
252
|
+
this._defaultLayoutTableCellProperties[propertyKey] || '';
|
|
253
|
+
return [
|
|
275
254
|
property,
|
|
276
|
-
|
|
255
|
+
commands.get(commandName).value || defaultValue
|
|
277
256
|
];
|
|
278
|
-
return [entry];
|
|
279
257
|
})
|
|
280
258
|
.forEach(([property, value]) => {
|
|
281
259
|
// Do not set the `border-color` and `border-width` fields if `border-style:none`.
|
|
@@ -0,0 +1,128 @@
|
|
|
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/tablecellproperties/tablecellpropertiesuiexperimental
|
|
7
|
+
*/
|
|
8
|
+
import { Plugin, type Editor } from 'ckeditor5/src/core.js';
|
|
9
|
+
import { ContextualBalloon } from 'ckeditor5/src/ui.js';
|
|
10
|
+
import { TableCellPropertiesViewExperimental } from './ui/tablecellpropertiesviewexperimental.js';
|
|
11
|
+
/**
|
|
12
|
+
* The table cell properties UI plugin. It introduces the `'tableCellProperties'` button
|
|
13
|
+
* that opens a form allowing to specify the visual styling of a table cell.
|
|
14
|
+
*
|
|
15
|
+
* It uses the {@link module:ui/panel/balloon/contextualballoon~ContextualBalloon contextual balloon plugin}.
|
|
16
|
+
*/
|
|
17
|
+
export declare class TableCellPropertiesUIExperimental extends Plugin {
|
|
18
|
+
/**
|
|
19
|
+
* The default table cell properties.
|
|
20
|
+
*/
|
|
21
|
+
private _defaultContentTableCellProperties;
|
|
22
|
+
/**
|
|
23
|
+
* The default layout table cell properties.
|
|
24
|
+
*/
|
|
25
|
+
private _defaultLayoutTableCellProperties;
|
|
26
|
+
/**
|
|
27
|
+
* The contextual balloon plugin instance.
|
|
28
|
+
*/
|
|
29
|
+
private _balloon?;
|
|
30
|
+
/**
|
|
31
|
+
* The cell properties form view displayed inside the balloon.
|
|
32
|
+
*/
|
|
33
|
+
view?: TableCellPropertiesViewExperimental | 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?;
|
|
42
|
+
/**
|
|
43
|
+
* The batch used to undo all changes made by the form (which are live, as the user types)
|
|
44
|
+
* when "Cancel" was pressed. Each time the view is shown, a new batch is created.
|
|
45
|
+
*/
|
|
46
|
+
private _undoStepBatch?;
|
|
47
|
+
/**
|
|
48
|
+
* Flag used to indicate whether view is ready to execute update commands
|
|
49
|
+
* (it finished loading initial data).
|
|
50
|
+
*/
|
|
51
|
+
private _isReady?;
|
|
52
|
+
/**
|
|
53
|
+
* @inheritDoc
|
|
54
|
+
*/
|
|
55
|
+
static get requires(): readonly [typeof ContextualBalloon];
|
|
56
|
+
/**
|
|
57
|
+
* @inheritDoc
|
|
58
|
+
*/
|
|
59
|
+
static get pluginName(): "TableCellPropertiesUIExperimental";
|
|
60
|
+
/**
|
|
61
|
+
* @inheritDoc
|
|
62
|
+
*/
|
|
63
|
+
static get isOfficialPlugin(): true;
|
|
64
|
+
/**
|
|
65
|
+
* @inheritDoc
|
|
66
|
+
*/
|
|
67
|
+
constructor(editor: Editor);
|
|
68
|
+
/**
|
|
69
|
+
* @inheritDoc
|
|
70
|
+
*/
|
|
71
|
+
init(): void;
|
|
72
|
+
/**
|
|
73
|
+
* @inheritDoc
|
|
74
|
+
*/
|
|
75
|
+
destroy(): void;
|
|
76
|
+
/**
|
|
77
|
+
* Creates the {@link module:table/tablecellproperties/ui/tablecellpropertiesview~TableCellPropertiesView} instance.
|
|
78
|
+
*
|
|
79
|
+
* @returns The cell properties form view instance.
|
|
80
|
+
*/
|
|
81
|
+
private _createPropertiesView;
|
|
82
|
+
/**
|
|
83
|
+
* In this method the "editor data -> UI" binding is happening.
|
|
84
|
+
*
|
|
85
|
+
* When executed, this method obtains selected cell property values from various table commands
|
|
86
|
+
* and passes them to the {@link #view}.
|
|
87
|
+
*
|
|
88
|
+
* This way, the UI stays up–to–date with the editor data.
|
|
89
|
+
*/
|
|
90
|
+
private _fillViewFormFromCommandValues;
|
|
91
|
+
/**
|
|
92
|
+
* Shows the {@link #view} in the {@link #_balloon}.
|
|
93
|
+
*
|
|
94
|
+
* **Note**: Each time a view is shown, a new {@link #_undoStepBatch} is created. It contains
|
|
95
|
+
* all changes made to the document when the view is visible, allowing a single undo step
|
|
96
|
+
* for all of them.
|
|
97
|
+
*/
|
|
98
|
+
protected _showView(): void;
|
|
99
|
+
/**
|
|
100
|
+
* Removes the {@link #view} from the {@link #_balloon}.
|
|
101
|
+
*/
|
|
102
|
+
protected _hideView(): void;
|
|
103
|
+
/**
|
|
104
|
+
* Repositions the {@link #_balloon} or hides the {@link #view} if a table cell is no longer selected.
|
|
105
|
+
*/
|
|
106
|
+
protected _updateView(): void;
|
|
107
|
+
/**
|
|
108
|
+
* Returns `true` when the {@link #view} is visible in the {@link #_balloon}.
|
|
109
|
+
*/
|
|
110
|
+
private get _isViewVisible();
|
|
111
|
+
/**
|
|
112
|
+
* Returns `true` when the {@link #view} is in the {@link #_balloon}.
|
|
113
|
+
*/
|
|
114
|
+
private get _isViewInBalloon();
|
|
115
|
+
/**
|
|
116
|
+
* Creates a callback that when executed upon the {@link #view view's} property change
|
|
117
|
+
* executes a related editor command with the new property value.
|
|
118
|
+
*
|
|
119
|
+
* @param commandName The default value of the command.
|
|
120
|
+
*/
|
|
121
|
+
private _getPropertyChangeCallback;
|
|
122
|
+
/**
|
|
123
|
+
* Creates a callback that when executed upon the {@link #view view's} property change:
|
|
124
|
+
* * Executes a related editor command with the new property value if the value is valid,
|
|
125
|
+
* * Or sets the error text next to the invalid field, if the value did not pass the validation.
|
|
126
|
+
*/
|
|
127
|
+
private _getValidatedPropertyChangeCallback;
|
|
128
|
+
}
|