jWYSIWYG set font color button

1k views Asked by At

I am using jQuery WYSIWYG (https://github.com/akzhan/jwysiwyg)

I realize that jwysiwyg now includes a color pallete that allows you to color text. But, what I want to do, is to have a custom button OUTSIDE of the editor that applies the color.

Is there a way to trigger the setting of the font color and pass in a color value?

1

There are 1 answers

1
phloopy On

I'm going to go with "Maybe".

Here's what the colorpicker does when you click submit.

var color = $('input[name="color"]', dialog.data).val();
self.color.fore.prev = color;
self.addColorToPalette("fore", color);

if ($.browser.msie) {
    Wysiwyg.ui.returnRange();
}

Wysiwyg.editorDoc.execCommand('ForeColor', false, color);
$.modal.close();
return false;

Most of that is only useful to the colorpicker, but there's one line that appears to actually set the color in the plugin:

Wysiwyg.editorDoc.execCommand('ForeColor', false, color);

If the Wysiwyg object is in scope for you, you should be able to call this directly with your own colors. The color variable is just a string in the "#rrggbb" format.