Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug with parsing border colors #1406

Merged
merged 6 commits into from
Jan 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Fixed Issues:
* [#889](https://github.com/ckeditor/ckeditor-dev/issues/889): Fixed: Unclear error message for width and height fields in [Image](https://ckeditor.com/cke4/addon/image) and [Enhanced Image](https://ckeditor.com/cke4/addon/image2) plugins.
* [#859](https://github.com/ckeditor/ckeditor-dev/issues/859): Fixed: Can't edit link after double click on text in link.
* [#1013](https://github.com/ckeditor/ckeditor-dev/issues/1013): Fixed: [Paste from Word](https://ckeditor.com/cke4/addon/pastefromword) does not work correctly with [`config.forcePasteAsPlainText`](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.config-cfg-forcePasteAsPlainText) property.
* [#1356](https://github.com/ckeditor/ckeditor-dev/issues/1356): Fixed: [Border parse function](https://docs.ckeditor.com/ckeditor4/docs/#!/api/CKEDITOR.tools.style.parse-method-border) should allow spaces in the color value.

## CKEditor 4.8

Expand Down
15 changes: 6 additions & 9 deletions core/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -1877,17 +1877,14 @@
*/
border: function( value ) {
var ret = {},
input = value.split( /\s+/ );
input = value.split( /\s+/g ),
parseColor = CKEDITOR.tools.style.parse._findColor( value );

CKEDITOR.tools.array.forEach( input, function( val ) {
if ( !ret.color ) {
var parseColor = CKEDITOR.tools.style.parse._findColor( val );
if ( parseColor.length ) {
ret.color = parseColor[ 0 ];
return;
}
}
if ( parseColor.length ) {
ret.color = parseColor[ 0 ];
}

CKEDITOR.tools.array.forEach( input, function( val ) {
if ( !ret.style ) {
if ( CKEDITOR.tools.indexOf( CKEDITOR.tools.style.parse._borderStyle, val ) !== -1 ) {
ret.style = val;
Expand Down
6 changes: 5 additions & 1 deletion tests/core/tools/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@

'test style.parse.border with style and hsla color': function() {
objectAssert.areEqual( { style: 'dotted', color: 'hsla(10,30%,30%,1)' }, CKEDITOR.tools.style.parse.border( 'dotted hsla(10,30%,30%,1)' ) );
}
},

'test style.parse.border with color white spaces': function() {
objectAssert.areEqual( { style: 'solid', color: 'rgba(10, 20, 30, .75)', width: '1px' },
CKEDITOR.tools.style.parse.border( '1px solid rgba(10, 20, 30, .75)' ) );
}
} );
} )();