Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

I/3287: Table and table cell properties plugins #224

Merged
merged 135 commits into from
Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
0d2ee1d
Add manual tests for table styles.
jodator Sep 25, 2019
bd7d9c1
Define basic table border conversion.
jodator Sep 25, 2019
931a4e2
Add basic table border style upcast conversion test.
jodator Sep 25, 2019
bc7144f
Revert border converter to previous definition.
jodator Sep 26, 2019
6c1b7de
Add support for pasting table borders.
jodator Oct 1, 2019
6d0b176
Add support for background-color.
jodator Oct 1, 2019
4193ac0
Enhance table styles manual test.
jodator Oct 1, 2019
f083069
Align code to changes in styles API.
jodator Oct 2, 2019
54064d3
Separate border style to three attributes.
jodator Oct 2, 2019
891d19d
Add microsoft word table sample.
jodator Oct 7, 2019
3f7e799
Make border to be stored as one property.
jodator Oct 8, 2019
e257eb6
Add table cell padding support.
jodator Oct 8, 2019
4368e8d
Add vertical alignment support.
jodator Oct 8, 2019
45a41df
Refactor table styles conversion & add more styles to convert.
jodator Oct 8, 2019
dfc0e12
Extract table styles plugin.
jodator Oct 9, 2019
88e8aeb
Stub border width UI using prompt command.
jodator Oct 10, 2019
4321dfa
Add other border properties stub UI.
jodator Oct 11, 2019
7b1d0b2
Add padding and background UI stubs.
jodator Oct 11, 2019
9fe009c
Convert borders to three separate values.
jodator Oct 14, 2019
747cc2f
Extract UI to own method.
jodator Oct 16, 2019
82b4cf2
Merge branch 'master' into i/3287
jodator Oct 16, 2019
f0b80d5
Add stub file for table styles conversion tests.
jodator Oct 16, 2019
eb537e7
Add temporary table styles dropdown option.
jodator Oct 16, 2019
065f426
Add tests for border-style, border-color and border-width upcast.
jodator Oct 16, 2019
b847e73
Add tests for border-(top,right,bottom,left) upcast.
jodator Oct 16, 2019
36a6108
Add border longhand styles to tests.
jodator Oct 16, 2019
704581c
Remove .only from tests.
jodator Oct 16, 2019
5aa1555
Add table styles downcast tests stub.
jodator Oct 21, 2019
74b1a49
Introduce assertTableCellStyle() test helper.
jodator Oct 21, 2019
94232c6
Add tests for other tableCell border attributes.
jodator Oct 21, 2019
04ed31f
Add tests for other different top, right, bottom, left values.
jodator Oct 21, 2019
10adbd9
Add tests for border attributes change.
jodator Oct 21, 2019
eed0f4e
Add tests for table cell background.
jodator Oct 21, 2019
6e53294
Add table row styles conversion tests.
jodator Oct 21, 2019
bacf21e
Add tests for padding attribute in tableCell.
jodator Oct 21, 2019
4e7b3b9
Add tests for vertical-align attribute in tableCell.
jodator Oct 21, 2019
309be11
Add tests for table's attributes: borderColor, borderStyle, borderWid…
jodator Oct 21, 2019
e744841
Add tests for table's attributes: borderColor, borderStyle, borderWid…
jodator Oct 21, 2019
000ff16
Re-organize table styles editing converters code.
jodator Oct 21, 2019
d68002f
Add table attributes tests.
jodator Oct 21, 2019
25a336b
Simplify border upcast converter checks.
jodator Oct 21, 2019
afbb437
Fix TableStyles UI background color.
jodator Oct 21, 2019
e539f0b
Extract TableProperties, TableColumnRowProperties and TableCellProper…
jodator Oct 22, 2019
83f48ca
Rename tablestyles to tableproperties manual tests.
jodator Oct 22, 2019
53a0e94
Refactor table * properties tests.
jodator Oct 22, 2019
e01694a
Extract test utils for table styles assertions.
jodator Oct 22, 2019
e498260
Remove custom table formatting utils in favor of assertEqualMarkup().
jodator Oct 22, 2019
b9f25aa
Change how hasStyle() is checked due to table border converter issues.
jodator Oct 22, 2019
0cb7e80
Add tests for overriding the border conversion.
jodator Oct 22, 2019
3007b49
Merge branch 'master' into i/3287
jodator Oct 23, 2019
efcb273
Update row height and column width conversion.
jodator Oct 23, 2019
3b110c2
Update table properties tests.
jodator Oct 23, 2019
6fd5c75
Update table cell properties tests.
jodator Oct 23, 2019
13a8ac4
Add support for vertical table alignment.
jodator Oct 24, 2019
95e7197
Add support for horizontal alignment for table cell.
jodator Oct 24, 2019
70b97f0
Rename TableProperties.enableBorderProperty to enableBorderProperties().
jodator Oct 24, 2019
6110c57
Fix *properties files names.
jodator Oct 24, 2019
7bcedb7
Use the same API for TableCellProperties methods.
jodator Oct 24, 2019
930a6fa
Add tableCell name to model conversion definition.
jodator Oct 24, 2019
63f3f15
Align alignment attributes RegExps.
jodator Oct 25, 2019
58cd1f6
Merge branch 'master' into i/3287
jodator Jan 7, 2020
27318ad
Use border styles processor.
jodator Jan 13, 2020
eab8033
Use required style processors.
jodator Jan 13, 2020
bbc8464
Update code to the changes in styles conversion API.
jodator Jan 13, 2020
ac4d77c
Align code to the changes in engine view.
jodator Jan 15, 2020
fe6b65d
Remove TableStyleUI.
jodator Jan 15, 2020
eb53c9b
Extract TablePropertiesEditing class.
jodator Jan 15, 2020
0b2816f
Extract TableCellPropertiesEditing.
jodator Jan 15, 2020
44f1235
Refactor TableCellPropertiesEditing class and add docs.
jodator Jan 16, 2020
ff00494
Add docs to TableCellProperties class.
jodator Jan 16, 2020
b7dd2c1
Refactor the TableCellProperties tests.
jodator Jan 16, 2020
78950af
Refactor TableCellPropertiesEditing tests.
jodator Jan 16, 2020
1b171dd
Fix TableCellProperties tests.
jodator Jan 16, 2020
cc63a69
Refactor TablePropertiesEditing.
jodator Jan 16, 2020
41b394d
Rename enablePropertyConversion() to enableProperty().
jodator Jan 16, 2020
a737502
Extract table properties editing tests.
jodator Jan 16, 2020
d9c27ec
Bump year in the PR files.
jodator Jan 16, 2020
4492f6e
Move schema and conversion definition to init method of table propert…
jodator Jan 16, 2020
966bd7d
Refactor table properties conversion helpers.
jodator Jan 16, 2020
40f6e2a
Add tableCellPaddingCommand.
jodator Jan 16, 2020
6c162ed
Add TableCellHeightCommand and TableCellWidthCommand.
jodator Jan 16, 2020
ab5c60f
Add TableCellBackgroundColor command.
jodator Jan 16, 2020
cd7e7c4
Add alignment commands.
jodator Jan 16, 2020
ec767ed
Add table cell border commands.
jodator Jan 16, 2020
42ef456
Add table background color command.
jodator Jan 16, 2020
3364544
Add table border color command.
jodator Jan 16, 2020
8753fb0
Add table border style command.
jodator Jan 16, 2020
ca3fdeb
Add table border width command.
jodator Jan 16, 2020
274785a
Add table height & width commands.
jodator Jan 16, 2020
059655c
Add table alignment command.
jodator Jan 16, 2020
8432df9
Add table alignment command.
jodator Jan 16, 2020
dd11900
Group attributes enabling in TablePropertiesEditing.init().
jodator Jan 16, 2020
4c8bfe4
Group attributes enabling in TableCellPropertiesEditing.init().
jodator Jan 16, 2020
5c39c9f
Move table properties classes to own namespace.
jodator Jan 16, 2020
76012da
Move table cell properties classes to own namespace.
jodator Jan 16, 2020
57c915d
Fix imports to moved classes.
jodator Jan 17, 2020
fccdf72
Align test code directories to source files.
jodator Jan 17, 2020
0a73fb3
Add tests for commands in table properties editing.
jodator Jan 17, 2020
ad885e5
Add tests for commands in table cell properties editing.
jodator Jan 17, 2020
91f8b3f
Add table cell background color command tests.
jodator Jan 20, 2020
8dc5fc2
Re-organize table cell properties tests.
jodator Jan 20, 2020
fe4d34e
Add table cell border color command tests.
jodator Jan 20, 2020
cf982f8
Add table cell border style command tests.
jodator Jan 20, 2020
2de7f06
Add table cell border width command tests.
jodator Jan 20, 2020
e72a0b8
Remove double empty line at the end of a file.
jodator Jan 20, 2020
db71830
Add table cell height command tests.
jodator Jan 20, 2020
b2f0c5a
Add table cell width command tests.
jodator Jan 20, 2020
649ac1f
Add table cell padding command tests.
jodator Jan 20, 2020
7730797
Add table cell vertical alignment command tests.
jodator Jan 20, 2020
1d10b4e
Add table cell horizontal alignment command tests.
jodator Jan 20, 2020
9409256
Add table alignment command tests.
jodator Jan 20, 2020
55b5575
Add table width command tests.
jodator Jan 20, 2020
fa0abca
Add table height command tests.
jodator Jan 20, 2020
1dea069
Add table background color command tests.
jodator Jan 20, 2020
296316b
Add table border color command tests.
jodator Jan 20, 2020
dcfc5b1
Add table border style command tests.
jodator Jan 20, 2020
12ceb56
Add table border width command tests.
jodator Jan 20, 2020
954e223
Move TableProperties test suite under table properties suite.
jodator Jan 20, 2020
09a9948
Move TablePropertiesEditing test suite under table properties suite.
jodator Jan 20, 2020
2dc548b
De-duplicate table cell commands code.
jodator Jan 20, 2020
89eae71
De-duplicate table commands code.
jodator Jan 20, 2020
6115a59
Use better values in docs for table cell commands.
jodator Jan 20, 2020
af0f62a
Table commands should operate on single table.
jodator Jan 20, 2020
58da8d5
Add missing dependencies.
jodator Jan 21, 2020
9e6fb36
Docs: Improved wording and fixed mistakes in various modules.
oleq Jan 23, 2020
77e2666
Add docs to getSingleValue().
jodator Jan 23, 2020
0bfddbf
Add missing docs for glue plugins.
jodator Jan 23, 2020
afb334f
Add docs about commands for editing plugins.
jodator Jan 23, 2020
a209338
Use global RegExp in conversion and test utils.
jodator Jan 23, 2020
e3567c0
Add manual test description and make source data side by side to the …
jodator Jan 23, 2020
6744aba
Rename BoxEdges to BoxSides.
jodator Jan 24, 2020
fbc81be
Tests: Improved the manual test description.
oleq Jan 24, 2020
96505bd
Docs: Update src/commands/utils.js
oleq Jan 24, 2020
bdd6b3d
Docs: Update src/commands/utils.js
oleq Jan 24, 2020
3719705
Tests: Improved the manual test description.
oleq Jan 24, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/commands/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,22 @@ export function createEmptyTableCell( writer, insertPosition, attributes = {} )
writer.insert( tableCell, insertPosition );
}

/**
* Returns a string if all four values of box edges are equal.
oleq marked this conversation as resolved.
Show resolved Hide resolved
*
* If string is passed it is treated as a single value (pass-through).
oleq marked this conversation as resolved.
Show resolved Hide resolved
*
* // returns 'foo':
* getSingleValue( { top: 'foo', right: 'foo', bottom: 'foo', left: 'foo' } );
* getSingleValue( 'foo' );
*
* // Returns undefined:
* getSingleValue( { top: 'foo', right: 'foo', bottom: 'bar', left: 'foo' } );
* getSingleValue( { top: 'foo', right: 'foo' } );
*
* @param objectOrString
* @returns {module:engine/view/stylesmap~BoxEdges|String}
*/
export function getSingleValue( objectOrString ) {
jodator marked this conversation as resolved.
Show resolved Hide resolved
if ( !objectOrString || !isObject( objectOrString ) ) {
return objectOrString;
Expand Down
4 changes: 2 additions & 2 deletions src/tablecellproperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import TableCellPropertiesEditing from './tablecellproperties/tablecellpropertie
* The table cell properties feature.
*
* This is a "glue" plugin which loads the
* {@link module:table/tablecellproperties/tablecellpropertiesediting~TableCellPropertiesEditing table editing feature} and
* table UI feature.
* {@link module:table/tablecellproperties/tablecellpropertiesediting~TableCellPropertiesEditing table properties editing feature} and
* table cell properties UI feature.
*
* @extends module:core/plugin~Plugin
*/
Expand Down
8 changes: 8 additions & 0 deletions src/tablecellproperties/tablecellpropertiesediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ import TableCellBorderWidthCommand from './commands/tablecellborderwidthcommand'
* - horizontal and vertical alignment: `horizontalAlignment`, `verticalAlignment`
* - cell width & height: `width` & `height`
*
* It also registers commands used to manipulate the above attributes:
*
* - border: `'tableCellBorderStyle'`, `'tableCellBorderColor'` and `'tableCellBorderWidth'` commands
* - background color: `'tableCellBackgroundColor'`
* - cell padding: `'tableCellPadding'`
* - horizontal and vertical alignment: `'tableCellHorizontalAlignment'`, `'tableCellVerticalAlignment'`
* - width & height: `'tableCellWidth'` & `'tableCellHeight'`
*
* @extends module:core/plugin~Plugin
*/
export default class TableCellPropertiesEditing extends Plugin {
Expand Down
4 changes: 4 additions & 0 deletions src/tableproperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import TablePropertiesEditing from './tableproperties/tablepropertiesediting';
/**
* The table properties feature.
jodator marked this conversation as resolved.
Show resolved Hide resolved
*
* This is a "glue" plugin which loads the
* {@link module:table/tableproperties/tablepropertiesediting~TableCellPropertiesEditing table editing feature} and
* table UI feature.
*
* @extends module:core/plugin~Plugin
*/
export default class TableProperties extends Plugin {
Expand Down
24 changes: 21 additions & 3 deletions src/tableproperties/tablepropertiesediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,27 @@ import TableWidthCommand from './commands/tablewidthcommand';
import TableHeightCommand from './commands/tableheightcommand';
import TableAlignmentCommand from './commands/tablealignmentcommand';

// RegExp used for matching margin style in converters.
const MARGIN_REG_EXP = /^(auto|0(%|[a-z]{2,4})?)$/;
const ALIGN_VALUES_REG_EXP = /^(left|right|center)$/;

/**
* The table properties editing feature.
jodator marked this conversation as resolved.
Show resolved Hide resolved
*
* Introduces table's model attributes and their conversion:
*
* - border: `borderStyle`, `borderColor` and `borderWidth`
* - background color: `backgroundColor`
* - horizontal alignment: `alignment`
* - width & height: `width` & `height`
*
* It also registers commands used to manipulate the above attributes:
*
* - border: `'tableBorderStyle'`, `'tableBorderColor'` and `'tableBorderWidth'` commands
* - background color: `'tableBackgroundColor'`
* - horizontal alignment: `'tableAlignment'`
* - width & height: `'tableWidth'` & `'tableHeight'`
*
* @extends module:core/plugin~Plugin
*/
export default class TablePropertiesEditing extends Plugin {
Expand Down Expand Up @@ -97,8 +115,8 @@ function enableAlignmentProperty( schema, conversion ) {
.attributeToAttribute( {
view: {
styles: {
'margin-right': /^(auto|0(%|[a-z]{2,4})?)$/,
'margin-left': /^(auto|0(%|[a-z]{2,4})?)$/
'margin-right': MARGIN_REG_EXP,
'margin-left': MARGIN_REG_EXP
}
},
model: {
Expand All @@ -122,7 +140,7 @@ function enableAlignmentProperty( schema, conversion ) {
.attributeToAttribute( {
view: {
attributes: {
align: /^(left|right|center)$/
align: ALIGN_VALUES_REG_EXP
}
},
model: {
Expand Down
3 changes: 2 additions & 1 deletion tests/_utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils'
import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';

const WIDGET_TABLE_CELL_CLASS = 'ck-editor__editable ck-editor__nested-editable';
const BORDER_REG_EXP = /[\s\S]+/;

/**
* Returns a model representation of a table shorthand notation:
Expand Down Expand Up @@ -247,7 +248,7 @@ export function defaultConversion( conversion, asWidget = false ) {
view: {
name: 'td',
styles: {
border: /[\s\S]+/
border: BORDER_REG_EXP
}
},
model: {
Expand Down
Loading