Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
editor.ui.componentFactory.add( FONT_SIZE, locale => {
const dropdownView = createDropdown( locale );
addListToDropdown( dropdownView, _prepareListOptions( options, command ) );
// Create dropdown model.
dropdownView.buttonView.set( {
label: t( 'Font Size' ),
icon: fontSizeIcon,
tooltip: true
} );
dropdownView.extendTemplate( {
attributes: {
class: [
'ck-font-size-dropdown'
]
}
} );
_prepareDropdown( label, icon, options, locale ) {
const editor = this.editor;
const dropdownView = createDropdown( locale );
const commands = [];
// Prepare dropdown list items for list dropdown.
const itemDefinitions = new Collection();
for ( const option of options ) {
addListOption( option, editor, commands, itemDefinitions );
}
addListToDropdown( dropdownView, itemDefinitions );
// Decorate dropdown's button.
dropdownView.buttonView.set( {
label,
icon,
tooltip: true
} );
// Make dropdown button disabled when all options are disabled.
dropdownView.bind( 'isEnabled' ).toMany( commands, 'isEnabled', ( ...areEnabled ) => {
return areEnabled.some( isEnabled => isEnabled );
} );
this.listenTo( dropdownView, 'execute', evt => {
editor.execute( evt.source.commandName );
editor.editing.view.focus();
editor.ui.componentFactory.add( FONT_FAMILY, locale => {
const dropdownView = createDropdown( locale );
addListToDropdown( dropdownView, _prepareListOptions( options, command ) );
dropdownView.buttonView.set( {
label: t( 'Font Family' ),
icon: fontFamilyIcon,
tooltip: true
} );
dropdownView.extendTemplate( {
attributes: {
class: 'ck-font-family-dropdown'
}
} );
dropdownView.bind( 'isEnabled' ).to( command );
// Execute command when an item from the dropdown is selected.