8
0
Quellcode durchsuchen

Merge pull request #13 from ckeditor/t/ckeditor5/742

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`.
Piotrek Koszuliński vor 7 Jahren
Ursprung
Commit
0918cd1a14

+ 2 - 2
packages/ckeditor5-font/src/fontfamily/fontfamilyui.js

@@ -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 );

+ 1 - 1
packages/ckeditor5-font/src/fontfamily/utils.js

@@ -69,7 +69,7 @@ function generateFontPreset( fontDefinition ) {
 		model: firstFontName,
 		view: {
 			name: 'span',
-			style: {
+			styles: {
 				'font-family': cssFontNames
 			}
 		}

+ 4 - 4
packages/ckeditor5-font/src/fontsize/fontsizeui.js

@@ -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 );

+ 5 - 5
packages/ckeditor5-font/src/fontsize/utils.js

@@ -29,7 +29,7 @@ const namedPresets = {
 		model: 'tiny',
 		view: {
 			name: 'span',
-			class: 'text-tiny'
+			classes: 'text-tiny'
 		}
 	},
 	small: {
@@ -37,7 +37,7 @@ const namedPresets = {
 		model: 'small',
 		view: {
 			name: 'span',
-			class: 'text-small'
+			classes: 'text-small'
 		}
 	},
 	big: {
@@ -45,7 +45,7 @@ const namedPresets = {
 		model: 'big',
 		view: {
 			name: 'span',
-			class: 'text-big'
+			classes: 'text-big'
 		}
 	},
 	huge: {
@@ -53,7 +53,7 @@ const namedPresets = {
 		model: 'huge',
 		view: {
 			name: 'span',
-			class: 'text-huge'
+			classes: 'text-huge'
 		}
 	}
 };
@@ -106,7 +106,7 @@ function generatePixelPreset( size ) {
 		model: size,
 		view: {
 			name: 'span',
-			style: {
+			styles: {
 				'font-size': `${ size }px`
 			}
 		}

+ 8 - 8
packages/ckeditor5-font/tests/fontfamily/fontfamilyediting.js

@@ -68,7 +68,7 @@ describe( 'FontFamilyEditing', () => {
 								model: 'my',
 								view: {
 									name: 'mark',
-									class: 'my-style'
+									classes: 'my-style'
 								}
 							}
 						]
@@ -120,7 +120,7 @@ describe( 'FontFamilyEditing', () => {
 								model: 'my-other',
 								view: {
 									name: 'span',
-									style: { 'font-family': 'Other' }
+									styles: { 'font-family': 'Other' }
 								}
 							},
 							{
@@ -128,8 +128,8 @@ describe( 'FontFamilyEditing', () => {
 								model: 'my',
 								view: {
 									name: 'mark',
-									style: { 'font-family': 'Verdana' },
-									class: 'my-style'
+									styles: { 'font-family': 'Verdana' },
+									classes: 'my-style'
 								}
 							},
 							{
@@ -137,12 +137,12 @@ describe( 'FontFamilyEditing', () => {
 								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' } }
 								]
 							}
 						]

+ 5 - 5
packages/ckeditor5-font/tests/fontfamily/utils.js

@@ -19,7 +19,7 @@ describe( 'FontFamily utils', () => {
 					model: 'comic',
 					view: {
 						name: 'span',
-						style: {
+						styles: {
 							'font-family': 'Comic Sans'
 						}
 					}
@@ -34,7 +34,7 @@ describe( 'FontFamily utils', () => {
 					model: 'comic',
 					view: {
 						name: 'span',
-						style: {
+						styles: {
 							'font-family': 'Comic Sans'
 						}
 					}
@@ -54,7 +54,7 @@ describe( 'FontFamily utils', () => {
 						model: 'Arial',
 						view: {
 							name: 'span',
-							style: {
+							styles: {
 								'font-family': 'Arial'
 							}
 						}
@@ -64,7 +64,7 @@ describe( 'FontFamily utils', () => {
 						model: 'Comic Sans MS',
 						view: {
 							name: 'span',
-							style: {
+							styles: {
 								'font-family': '\'Comic Sans MS\', sans-serif'
 							}
 						}
@@ -74,7 +74,7 @@ describe( 'FontFamily utils', () => {
 						model: 'Lucida Console',
 						view: {
 							name: 'span',
-							style: {
+							styles: {
 								'font-family': '\'Lucida Console\', \'Courier New\', Courier, monospace'
 							}
 						}

+ 8 - 8
packages/ckeditor5-font/tests/fontsize/fontsizeediting.js

@@ -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'
 								}
 							}
 						]
@@ -113,8 +113,8 @@ describe( 'FontSizeEditing', () => {
 								model: 'my',
 								view: {
 									name: 'mark',
-									style: { 'font-size': '30px' },
-									class: 'my-style'
+									styles: { 'font-size': '30px' },
+									classes: 'my-style'
 								}
 							},
 							{
@@ -122,7 +122,7 @@ describe( 'FontSizeEditing', () => {
 								model: 'big-multiple',
 								view: {
 									name: 'span',
-									class: [ 'foo', 'foo-big' ]
+									classes: [ 'foo', 'foo-big' ]
 								}
 							},
 							{
@@ -130,11 +130,11 @@ describe( 'FontSizeEditing', () => {
 								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' } }
 								]
 							}
 						]

+ 4 - 4
packages/ckeditor5-font/tests/fontsize/fontsizeui.js

@@ -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' } }
 				] );
 			} );
 

+ 10 - 10
packages/ckeditor5-font/tests/fontsize/utils.js

@@ -15,12 +15,12 @@ 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;' }
 				}
 			] );
 		} );
@@ -28,11 +28,11 @@ describe( 'FontSizeEditing Utils', () => {
 		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' } }
 				] );
 			} );
 		} );
@@ -40,11 +40,11 @@ describe( 'FontSizeEditing Utils', () => {
 		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' } } }
 				] );
 			} );
 		} );