Hello! I try to create simple button which can change color peace of text, which i selected mouse
But, i don't understend how i can get this peace of text, and which parametrs and methods i can use, to do it(
Get text, set new color, (not dialog window) just one color, and see result it on textarea
Thank you!
Writing next code, maybe not correct but working, like i want
exec: function (editor) {
var text = editor.getSelection().getSelectedText();
var element = CKEDITOR.dom.element.createFromHtml('<p style="color:##00000"/>' + text + '</p>');
CKEDITOR.instances.editor1.insertElement(element);
Someone know's how do it like basicstyles plugin?
So, can anyone help me and
So, can anyone help me and explain? Please
I tried something like this:
CKEDITOR.plugins.add('abcolor', {
lang: 'af,ar,bg,bn,bs,ca,cs,cy,da,de,el,en-au,en-ca,en-gb,en,eo,es,et,eu,fa,fi,fo,fr-ca,fr,gl,gu,he,hi,hr,hu,is,it,ja,ka,km,ko,ku,lt,lv,mk,mn,ms,nb,nl,no,pl,pt-br,pt,ro,ru,sk,sl,sr-latn,sr,sv,th,tr,ug,uk,vi,zh-cn,zh', // %REMOVE_LINE_CORE%
icons: 'red, green, blue',
init: function (editor) {
var order = 0;
var addButtonCommand = function (buttonName, buttonLabel, commandName, colorDefinition) {
if (!colorDefinition)
return;
var style = new CKEDITOR.style(colorDefinition),
forms = contentForms[commandName];
forms.unshift(style);
editor.attachStyleStateChange(style, function (state) {
!editor.readOnly && editor.getCommand(commandName).setState(state);
});
editor.addCommand(commandName, new CKEDITOR.styleCommand(style, {
contentForms: forms
}));
if (editor.ui.addButton) {
editor.ui.addButton(buttonName, {
label: buttonLabel,
command: commandName,
toolbar: 'about',
});
}
};
var contentForms = {
red:[
'r',
['span', function (el) {
return el.styles['color'] == '#FF0000'; //#FF0000
}]
],
green: [
'g',
['span', function (el) {
return el.styles['color'] == '#008000'; //#008000
}]
],
blue: [
'b',
['span', function (el) {
return el.styles['color'] == '#0000FF'; //#0000FF
}]
]
},
config = editor.config,
lang = editor.lang.abcolor;
addButtonCommand('Red', lang.red, 'red', config.coreStyles_red);
addButtonCommand('Green', lang.green, 'green', config.coreStyles_green);
addButtonCommand('Blue', lang.blue, 'blue', config.coreStyles_blue);
}
});
CKEDITOR.config.coreStyles_red = { element: 'r' };
CKEDITOR.config.coreStyles_green = { element: 'g' };
CKEDITOR.config.coreStyles_blue = { element: 'b' };
What's wrong here?
Hey!!!!!!!!!!!!!
Hey!!!!!!!!!!!!!
This is support forum?
Can somebody help me create this !# button which set selected text one color????