简体   繁体   English

jWYSIWYG设置字体颜色按钮

[英]jWYSIWYG set font color button

I am using jQuery WYSIWYG ( https://github.com/akzhan/jwysiwyg ) 我正在使用jQuery所见即所得( https://github.com/akzhan/jwysiwyg

I realize that jwysiwyg now includes a color pallete that allows you to color text. 我意识到jwysiwyg现在包括一个允许您为文本jwysiwyg颜色的调色板。 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? 有没有一种方法可以触发字体颜色的设置并传递颜色值?

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. 如果Wysiwyg对象在您的范围内,则应该可以使用自己的颜色直接调用此对象。 The color variable is just a string in the "#rrggbb" format. color变量只是“ #rrggbb”格式的字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM