8
0
Просмотр исходного кода

Removed unused part of the code.

Kamil Piechaczek 5 лет назад
Родитель
Сommit
7a5fe3d029

+ 1 - 1
packages/ckeditor5-font/src/fontsize/fontsizeediting.js

@@ -70,7 +70,7 @@ export default class FontSizeEditing extends Plugin {
 		const supportAllValues = editor.config.get( 'fontSize.supportAllValues' );
 		const supportAllValues = editor.config.get( 'fontSize.supportAllValues' );
 
 
 		// Define view to model conversion.
 		// Define view to model conversion.
-		const options = normalizeOptions( this.editor.config.get( 'fontSize.options' ), { supportAllValues } )
+		const options = normalizeOptions( this.editor.config.get( 'fontSize.options' ) )
 			.filter( item => item.model );
 			.filter( item => item.model );
 		const definition = buildDefinition( FONT_SIZE, options );
 		const definition = buildDefinition( FONT_SIZE, options );
 
 

+ 3 - 21
packages/ckeditor5-font/src/fontsize/utils.js

@@ -14,28 +14,16 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
  * to the {@link module:font/fontsize~FontSizeOption} format.
  * to the {@link module:font/fontsize~FontSizeOption} format.
  *
  *
  * @param {Array.<String|Number|Object>} configuredOptions An array of options taken from the configuration.
  * @param {Array.<String|Number|Object>} configuredOptions An array of options taken from the configuration.
- * @param {Object} [options={}]
- * @param {Boolean} [options.supportAllValues=false]
  * @returns {Array.<module:font/fontsize~FontSizeOption>}
  * @returns {Array.<module:font/fontsize~FontSizeOption>}
  */
  */
-export function normalizeOptions( configuredOptions, options = {} ) {
-	const supportAllValues = options.supportAllValues || false;
-
+export function normalizeOptions( configuredOptions ) {
 	// Convert options to objects.
 	// Convert options to objects.
 	return configuredOptions
 	return configuredOptions
-		.map( item => getOptionDefinition( item, supportAllValues ) )
+		.map( item => getOptionDefinition( item ) )
 		// Filter out undefined values that `getOptionDefinition` might return.
 		// Filter out undefined values that `getOptionDefinition` might return.
 		.filter( option => !!option );
 		.filter( option => !!option );
 }
 }
 
 
-// The values should be synchronized with values specified in the "/theme/fontsize.css" file.
-export const FONT_SIZE_PRESET_UNITS = {
-	tiny: '0.7em',
-	small: '0.85em',
-	big: '1.4em',
-	huge: '1.8em'
-};
-
 // Default named presets map. Always create a new instance of the preset object in order to avoid modifying references.
 // Default named presets map. Always create a new instance of the preset object in order to avoid modifying references.
 const namedPresets = {
 const namedPresets = {
 	get tiny() {
 	get tiny() {
@@ -86,12 +74,10 @@ const namedPresets = {
 
 
 // Returns an option definition either from preset or creates one from number shortcut.
 // Returns an option definition either from preset or creates one from number shortcut.
 // If object is passed then this method will return it without alternating it. Returns undefined for item than cannot be parsed.
 // If object is passed then this method will return it without alternating it. Returns undefined for item than cannot be parsed.
-// If supportAllValues=true, model will be set to a specified unit value instead of text.
 //
 //
 // @param {String|Number|Object} item
 // @param {String|Number|Object} item
-// @param {Boolean} supportAllValues
 // @returns {undefined|module:font/fontsize~FontSizeOption}
 // @returns {undefined|module:font/fontsize~FontSizeOption}
-function getOptionDefinition( option, supportAllValues ) {
+function getOptionDefinition( option ) {
 	// Check whether passed option is a full item definition provided by user in configuration.
 	// Check whether passed option is a full item definition provided by user in configuration.
 	if ( isFullItemDefinition( option ) ) {
 	if ( isFullItemDefinition( option ) ) {
 		return attachPriority( option );
 		return attachPriority( option );
@@ -101,10 +87,6 @@ function getOptionDefinition( option, supportAllValues ) {
 
 
 	// Item is a named preset.
 	// Item is a named preset.
 	if ( preset ) {
 	if ( preset ) {
-		if ( supportAllValues ) {
-			preset.model = FONT_SIZE_PRESET_UNITS[ option ];
-		}
-
 		return attachPriority( preset );
 		return attachPriority( preset );
 	}
 	}
 
 

+ 1 - 19
packages/ckeditor5-font/tests/fontsize/utils.js

@@ -3,7 +3,7 @@
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  */
  */
 
 
-import { normalizeOptions, FONT_SIZE_PRESET_UNITS } from '../../src/fontsize/utils';
+import { normalizeOptions } from '../../src/fontsize/utils';
 import { expectToThrowCKEditorError } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 import { expectToThrowCKEditorError } from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
 
 
 describe( 'FontSizeEditing Utils', () => {
 describe( 'FontSizeEditing Utils', () => {
@@ -37,18 +37,6 @@ describe( 'FontSizeEditing Utils', () => {
 				] );
 				] );
 			} );
 			} );
 
 
-			it( 'should return defined presets with units in model values if supportAllValues=true', () => {
-				const options = normalizeOptions( [ 'tiny', 'small', 'default', 'big', 'huge' ], { supportAllValues: true } );
-
-				expect( options ).to.deep.equal( [
-					{ title: 'Tiny', model: '0.7em', view: { name: 'span', classes: 'text-tiny', priority: 7 } },
-					{ title: 'Small', model: '0.85em', view: { name: 'span', classes: 'text-small', priority: 7 } },
-					{ title: 'Default', model: undefined },
-					{ title: 'Big', model: '1.4em', view: { name: 'span', classes: 'text-big', priority: 7 } },
-					{ title: 'Huge', model: '1.8em', view: { name: 'span', classes: 'text-huge', priority: 7 } }
-				] );
-			} );
-
 			it( 'should add "view" definition if missing', () => {
 			it( 'should add "view" definition if missing', () => {
 				const tinyOption = {
 				const tinyOption = {
 					title: 'Tiny',
 					title: 'Tiny',
@@ -165,10 +153,4 @@ describe( 'FontSizeEditing Utils', () => {
 			} );
 			} );
 		} );
 		} );
 	} );
 	} );
-
-	describe( 'FONT_SIZE_PRESET_UNITS', () => {
-		it( 'provides default values', () => {
-			expect( Object.keys( FONT_SIZE_PRESET_UNITS ).length ).to.equal( 4 );
-		} );
-	} );
 } );
 } );