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

Commit

Permalink
Merge pull request #13 from ckeditor/t/ckeditor5/742
Browse files Browse the repository at this point in the history
Other: Aligned `ElementDefinition` usage to the changes in the engine. See ckeditor/ckeditor5#742.

BREAKING CHANGES: In the custom format of the font size configuration the `view.style`, `view.class` and `view.attribute` properties are now called `view.styles`, `view.classes` and `view.attributes`.
  • Loading branch information
Reinmar authored Apr 5, 2018
2 parents 0cf8645 + fe97b00 commit 5705b42
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 47 deletions.
4 changes: 2 additions & 2 deletions src/fontfamily/fontfamilyui.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ function _prepareListOptions( options, command ) {
itemModel.bind( 'isActive' ).to( command, 'value', value => value === option.model );

// Try to set a dropdown list item style.
if ( option.view && option.view.style ) {
itemModel.set( 'style', `font-family: ${ option.view.style[ 'font-family' ] }` );
if ( option.view && option.view.styles ) {
itemModel.set( 'style', `font-family: ${ option.view.styles[ 'font-family' ] }` );
}

dropdownItems.add( itemModel );
Expand Down
2 changes: 1 addition & 1 deletion src/fontfamily/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function generateFontPreset( fontDefinition ) {
model: firstFontName,
view: {
name: 'span',
style: {
styles: {
'font-family': cssFontNames
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/fontsize/fontsizeui.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ function _prepareListOptions( options, command ) {
class: 'ck-fontsize-option'
} );

if ( option.view && option.view.style ) {
itemModel.set( 'style', `font-size:${ option.view.style[ 'font-size' ] }` );
if ( option.view && option.view.styles ) {
itemModel.set( 'style', `font-size:${ option.view.styles[ 'font-size' ] }` );
}

if ( option.view && option.view.class ) {
itemModel.set( 'class', `${ itemModel.class } ${ option.view.class }` );
if ( option.view && option.view.classes ) {
itemModel.set( 'class', `${ itemModel.class } ${ option.view.classes }` );
}

itemModel.bind( 'isActive' ).to( command, 'value', value => value === option.model );
Expand Down
10 changes: 5 additions & 5 deletions src/fontsize/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,31 @@ const namedPresets = {
model: 'tiny',
view: {
name: 'span',
class: 'text-tiny'
classes: 'text-tiny'
}
},
small: {
title: 'Small',
model: 'small',
view: {
name: 'span',
class: 'text-small'
classes: 'text-small'
}
},
big: {
title: 'Big',
model: 'big',
view: {
name: 'span',
class: 'text-big'
classes: 'text-big'
}
},
huge: {
title: 'Huge',
model: 'huge',
view: {
name: 'span',
class: 'text-huge'
classes: 'text-huge'
}
}
};
Expand Down Expand Up @@ -106,7 +106,7 @@ function generatePixelPreset( size ) {
model: size,
view: {
name: 'span',
style: {
styles: {
'font-size': `${ size }px`
}
}
Expand Down
16 changes: 8 additions & 8 deletions tests/fontfamily/fontfamilyediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe( 'FontFamilyEditing', () => {
model: 'my',
view: {
name: 'mark',
class: 'my-style'
classes: 'my-style'
}
}
]
Expand Down Expand Up @@ -120,29 +120,29 @@ describe( 'FontFamilyEditing', () => {
model: 'my-other',
view: {
name: 'span',
style: { 'font-family': 'Other' }
styles: { 'font-family': 'Other' }
}
},
{
title: 'My setting',
model: 'my',
view: {
name: 'mark',
style: { 'font-family': 'Verdana' },
class: 'my-style'
styles: { 'font-family': 'Verdana' },
classes: 'my-style'
}
},
{
title: 'Hybrid',
model: 'complex',
view: {
name: 'span',
class: [ 'text-complex' ]
classes: [ 'text-complex' ]
},
upcastAlso: [
{ name: 'span', style: { 'font-family': 'Arial' } },
{ name: 'span', style: { 'font-family': 'Arial,sans-serif' } },
{ name: 'span', attribute: { 'data-font': 'Arial' } }
{ name: 'span', styles: { 'font-family': 'Arial' } },
{ name: 'span', styles: { 'font-family': 'Arial,sans-serif' } },
{ name: 'span', attributes: { 'data-font': 'Arial' } }
]
}
]
Expand Down
10 changes: 5 additions & 5 deletions tests/fontfamily/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe( 'FontFamily utils', () => {
model: 'comic',
view: {
name: 'span',
style: {
styles: {
'font-family': 'Comic Sans'
}
}
Expand All @@ -34,7 +34,7 @@ describe( 'FontFamily utils', () => {
model: 'comic',
view: {
name: 'span',
style: {
styles: {
'font-family': 'Comic Sans'
}
}
Expand All @@ -54,7 +54,7 @@ describe( 'FontFamily utils', () => {
model: 'Arial',
view: {
name: 'span',
style: {
styles: {
'font-family': 'Arial'
}
}
Expand All @@ -64,7 +64,7 @@ describe( 'FontFamily utils', () => {
model: 'Comic Sans MS',
view: {
name: 'span',
style: {
styles: {
'font-family': '\'Comic Sans MS\', sans-serif'
}
}
Expand All @@ -74,7 +74,7 @@ describe( 'FontFamily utils', () => {
model: 'Lucida Console',
view: {
name: 'span',
style: {
styles: {
'font-family': '\'Lucida Console\', \'Courier New\', Courier, monospace'
}
}
Expand Down
16 changes: 8 additions & 8 deletions tests/fontsize/fontsizeediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ describe( 'FontSizeEditing', () => {
model: 'my',
view: {
name: 'mark',
style: { 'font-size': '30px' },
class: 'my-style'
styles: { 'font-size': '30px' },
classes: 'my-style'
}
}
]
Expand Down Expand Up @@ -113,28 +113,28 @@ describe( 'FontSizeEditing', () => {
model: 'my',
view: {
name: 'mark',
style: { 'font-size': '30px' },
class: 'my-style'
styles: { 'font-size': '30px' },
classes: 'my-style'
}
},
{
title: 'Big multiple classes',
model: 'big-multiple',
view: {
name: 'span',
class: [ 'foo', 'foo-big' ]
classes: [ 'foo', 'foo-big' ]
}
},
{
title: 'Hybrid',
model: 'complex',
view: {
name: 'span',
class: [ 'text-complex' ]
classes: [ 'text-complex' ]
},
upcastAlso: [
{ name: 'span', style: { 'font-size': '77em' } },
{ name: 'span', attribute: { 'data-size': '77em' } }
{ name: 'span', styles: { 'font-size': '77em' } },
{ name: 'span', attributes: { 'data-size': '77em' } }
]
}
]
Expand Down
8 changes: 4 additions & 4 deletions tests/fontsize/fontsizeui.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,11 @@ describe( 'FontSizeUI', () => {
it( 'does not alter normalizeOptions() internals', () => {
const options = normalizeOptions( [ 'tiny', 'small', 'default', 'big', 'huge' ] );
expect( options ).to.deep.equal( [
{ title: 'Tiny', model: 'tiny', view: { name: 'span', class: 'text-tiny' } },
{ title: 'Small', model: 'small', view: { name: 'span', class: 'text-small' } },
{ title: 'Tiny', model: 'tiny', view: { name: 'span', classes: 'text-tiny' } },
{ title: 'Small', model: 'small', view: { name: 'span', classes: 'text-small' } },
{ title: 'Default', model: undefined },
{ title: 'Big', model: 'big', view: { name: 'span', class: 'text-big' } },
{ title: 'Huge', model: 'huge', view: { name: 'span', class: 'text-huge' } }
{ title: 'Big', model: 'big', view: { name: 'span', classes: 'text-big' } },
{ title: 'Huge', model: 'huge', view: { name: 'span', classes: 'text-huge' } }
] );
} );

Expand Down
20 changes: 10 additions & 10 deletions tests/fontsize/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,36 @@ describe( 'FontSizeEditing Utils', () => {
expect( normalizeOptions( [ {
title: 'My Size',
model: 'my-size',
view: { name: 'span', style: 'font-size: 12em;' }
view: { name: 'span', styles: 'font-size: 12em;' }
} ] ) ).to.deep.equal( [
{
title: 'My Size',
model: 'my-size',
view: { name: 'span', style: 'font-size: 12em;' }
view: { name: 'span', styles: 'font-size: 12em;' }
}
] );
} );

describe( 'named presets', () => {
it( 'should return defined presets', () => {
expect( normalizeOptions( [ 'tiny', 'small', 'default', 'big', 'huge' ] ) ).to.deep.equal( [
{ title: 'Tiny', model: 'tiny', view: { name: 'span', class: 'text-tiny' } },
{ title: 'Small', model: 'small', view: { name: 'span', class: 'text-small' } },
{ title: 'Tiny', model: 'tiny', view: { name: 'span', classes: 'text-tiny' } },
{ title: 'Small', model: 'small', view: { name: 'span', classes: 'text-small' } },
{ title: 'Default', model: undefined },
{ title: 'Big', model: 'big', view: { name: 'span', class: 'text-big' } },
{ title: 'Huge', model: 'huge', view: { name: 'span', class: 'text-huge' } }
{ title: 'Big', model: 'big', view: { name: 'span', classes: 'text-big' } },
{ title: 'Huge', model: 'huge', view: { name: 'span', classes: 'text-huge' } }
] );
} );
} );

describe( 'numerical presets', () => {
it( 'should return generated presets', () => {
expect( normalizeOptions( [ '10', 12, 'default', '14.1', 18.3 ] ) ).to.deep.equal( [
{ title: '10', model: 10, view: { name: 'span', style: { 'font-size': '10px' } } },
{ title: '12', model: 12, view: { name: 'span', style: { 'font-size': '12px' } } },
{ title: '10', model: 10, view: { name: 'span', styles: { 'font-size': '10px' } } },
{ title: '12', model: 12, view: { name: 'span', styles: { 'font-size': '12px' } } },
{ title: 'Default', model: undefined },
{ title: '14.1', model: 14.1, view: { name: 'span', style: { 'font-size': '14.1px' } } },
{ title: '18.3', model: 18.3, view: { name: 'span', style: { 'font-size': '18.3px' } } }
{ title: '14.1', model: 14.1, view: { name: 'span', styles: { 'font-size': '14.1px' } } },
{ title: '18.3', model: 18.3, view: { name: 'span', styles: { 'font-size': '18.3px' } } }
] );
} );
} );
Expand Down

0 comments on commit 5705b42

Please sign in to comment.