Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const buttonView = componentFactory.create( 'highlight:' + option.model );
// Update lastExecutedHighlight on execute.
this.listenTo( buttonView, 'execute', () => dropdownView.buttonView.set( { lastExecuted: option.model } ) );
return buttonView;
} );
// Make toolbar button enabled when any button in dropdown is enabled before adding separator and eraser.
dropdownView.bind( 'isEnabled' ).toMany( buttons, 'isEnabled', ( ...areEnabled ) => areEnabled.some( isEnabled => isEnabled ) );
// Add separator and eraser buttons to dropdown.
buttons.push( new ToolbarSeparatorView() );
buttons.push( componentFactory.create( 'removeHighlight' ) );
addToolbarToDropdown( dropdownView, buttons );
bindToolbarIconStyleToActiveColor( dropdownView );
dropdownView.toolbarView.ariaLabel = t( 'Text highlight toolbar' );
// Execute current action from dropdown's split button action button.
splitButtonView.on( 'execute', () => {
editor.execute( 'highlight', { value: splitButtonView.commandValue } );
editor.editing.view.focus();
} );
// Returns active highlighter option depending on current command value.
// If current is not set or it is the same as last execute this method will return the option key (like icon or color)
// of last executed highlighter. Otherwise it will return option key for current one.
function getActiveOption( current, key ) {
const whichHighlighter = !current ||
current === splitButtonView.lastExecuted ? splitButtonView.lastExecuted : current;
componentFactory.add( 'alignment', locale => {
const dropdownView = createDropdown( locale );
// Add existing alignment buttons to dropdown's toolbar.
const buttons = options.map( option => componentFactory.create( `alignment:${ option }` ) );
addToolbarToDropdown( dropdownView, buttons );
// Configure dropdown properties an behavior.
dropdownView.buttonView.set( {
label: t( 'Text alignment' ),
tooltip: true
} );
dropdownView.toolbarView.isVertical = true;
dropdownView.toolbarView.ariaLabel = t( 'Text alignment toolbar' );
dropdownView.extendTemplate( {
attributes: {
class: 'ck-alignment-dropdown'
}
} );