2

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?

Nic Hubbard
  • 41,587
  • 63
  • 251
  • 412

1 Answers1

0

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.

phloopy
  • 5,563
  • 4
  • 26
  • 37
  • `Wysiwyg` is an object within the plugin that is not exposed externally. It looks like you'll have to add your own custom method to the plugin that calls the execCommand for you. – phloopy Jan 28 '13 at 17:11