XF 2.1 Editor - Programmatically get/set button/dropdowns state

XFA

Well-known member
Hi,

I am trying to extend the editor in order to get some buttons state change when clicked as well as fonts dropdown or color editor.
I also want to change potentially their state upon editor load.

For color and font related dropdowns, I was able to get the state upon click through the commands.after event:
Code:
ed.events.on('commands.after', function(cmd, param1, param2)
{
    console.log(cmd);
    console.log(param1);
});

However, the other buttons such as bold or italic doesn't provide a state.
I could know their state by managing a state keeper all along since initialization of course but that's not necessarly convenient.

So four questions:
  • Is there a way to get buttons state in the editor ?
  • Is there a way to set the state of a button in the editor upon editor initialization ?
  • Is there a way to select a default color in the editor upon editor initialization ?
  • Is there a way to select an item from a dropdown (basically font size/family) in the editor upon editor initialization ?

To set the buttons initial state, I tried doing that :
Code:
ed.$tb.find('.fr-command.fr-btn[data-cmd=bold]')[0].click();
But it didn't work.

Hope you can help,
Thanks

Clément
 
Ok in fact for setting initial state, I wasn't doing it the right way, found out you just need to call:
Code:
ed.commands.bold();

So I guess from there I'll be able to keep track without getting states.
 
Top Bottom