Skip to content

Commit

Permalink
Code refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
niegowski committed Feb 26, 2021
1 parent cbcaa1e commit f9ee5f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
12 changes: 6 additions & 6 deletions packages/ckeditor5-alignment/src/alignmentediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ function buildDowncastInlineDefinition( options ) {
view: {}
};

for ( const option of options ) {
definition.view[ option.name ] = {
for ( const { name } of options ) {
definition.view[ name ] = {
key: 'style',
value: {
'text-align': option.name
'text-align': name
}
};
}
Expand All @@ -104,17 +104,17 @@ function buildDowncastInlineDefinition( options ) {
function buildUpcastInlineDefinitions( options ) {
const definitions = [];

for ( const option of options ) {
for ( const { name } of options ) {
definitions.push( {
view: {
key: 'style',
value: {
'text-align': option.name
'text-align': name
}
},
model: {
key: 'alignment',
value: option.name
value: name
}
} );
}
Expand Down
6 changes: 1 addition & 5 deletions packages/ckeditor5-alignment/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ import { CKEditorError, logWarning } from 'ckeditor5/src/utils';
*/
export const supportedOptions = [ 'left', 'right', 'center', 'justify' ];

const optionNameToOptionMap = Object.fromEntries(
supportedOptions.map( option => [ option, { name: option } ] )
);

/**
* Checks whether the passed option is supported by {@link module:alignment/alignmentediting~AlignmentEditing}.
*
Expand Down Expand Up @@ -65,7 +61,7 @@ export function normalizeAlignmentOptions( configuredOptions ) {
if ( typeof option == 'string' ) {
result = { name: option };
} else {
result = { ...optionNameToOptionMap[ option.name ], ...option };
result = option;
}

return result;
Expand Down

0 comments on commit f9ee5f4

Please sign in to comment.