I hope someone can help.
I am in the process of writing a plugin for CKEditor v3, which applies a text style to the selected text.
The code I'm using is:
var start_element = editor.getSelection().getStartElement();
//get the selected html from the element
var selected_text = start_element.$.innerHTML;
var new_text;
new_text = "<h2 class='toc'>" + selected_text + "</h2>";
start_element.$.innerHTML = new_text;
Although this works, the above code seems to add an empty paragraph above the H2.
The "toc" class is available in the Styles Combo defined as a custom style, so I was wondering if it was possible to use some CKEditor code to apply this style directly instead of me creating a string to represent this.
Is this possible and if so, how do I go about doing it?
Thanks
I am in the process of writing a plugin for CKEditor v3, which applies a text style to the selected text.
The code I'm using is:
var start_element = editor.getSelection().getStartElement();
//get the selected html from the element
var selected_text = start_element.$.innerHTML;
var new_text;
new_text = "<h2 class='toc'>" + selected_text + "</h2>";
start_element.$.innerHTML = new_text;
Although this works, the above code seems to add an empty paragraph above the H2.
The "toc" class is available in the Styles Combo defined as a custom style, so I was wondering if it was possible to use some CKEditor code to apply this style directly instead of me creating a string to represent this.
Is this possible and if so, how do I go about doing it?
Thanks