Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function _prepareListOptions( options, command ) {
const itemDefinitions = new Collection();
// Create dropdown items.
for ( const option of options ) {
const def = {
type: 'button',
model: new Model( {
commandName: FONT_FAMILY,
commandParam: option.model,
label: option.title,
withText: true
} )
};
def.model.bind( 'isOn' ).to( command, 'value', value => value === option.model );
// Try to set a dropdown list item style.
if ( option.view && option.view.styles ) {
def.model.set( 'labelStyle', `font-family: ${ option.view.styles[ 'font-family' ] }` );
}
itemDefinitions.add( def );
}
function addListOption( option, editor, commands, itemDefinitions ) {
const model = option.model = new Model( option.model );
const { commandName, bindIsOn } = option.model;
if ( option.type !== 'separator' ) {
const command = editor.commands.get( commandName );
commands.push( command );
model.set( { commandName } );
model.bind( 'isEnabled' ).to( command );
if ( bindIsOn ) {
model.bind( 'isOn' ).to( command, 'value' );
}
}
function _prepareListOptions( options, command ) {
const itemDefinitions = new Collection();
for ( const option of options ) {
const def = {
type: 'button',
model: new Model( {
commandName: FONT_SIZE,
commandParam: option.model,
label: option.title,
class: 'ck-fontsize-option',
withText: true
} )
};
if ( option.view && option.view.styles ) {
def.model.set( 'labelStyle', `font-size:${ option.view.styles[ 'font-size' ] }` );
}
if ( option.view && option.view.classes ) {
def.model.set( 'class', `${ def.model.class } ${ option.view.classes }` );
}