自定义颜色选择器TinyMCE

时间:2013-03-27 18:59:11

标签: javascript tinymce wysiwyg color-picker

我正在使用TinyMCE在我的网站上使用WYSIWYG编辑器,除了使用forecolor的现有颜色选择器之外,我还想在编辑器中添加自定义颜色选择器。我找到了这个http://fiddle.tinymce.com/lwcaab/16并用它来显示按钮,但有2个问题。我需要过滤显示在该按钮中的颜色(仅显示几种颜色),当您单击颜色时,它不会更改编辑器中的字体颜色。

tinymce.create('tinymce.plugins.ExamplePlugin', {
    createControl: function(n, cm) 
        {
            switch(n)
            {
            case "universityColors":
               var o = {};
               ed=tinyMCE.activeEditor;
               o.scriptURL = ed.baseURI.getURI();
               o['class'] = 'mce_forecolor';
               o.title='University Font Colors';
               o.scope=this;
               o.image = '../images/uor.ico',
               o.onclick = function (color) { console.log('clicked',color);/*this.cs.showMenu(); if (this.o.onClick) this.o.onClick(c);*/};
               o.onselect = function (color) {console.log('selected',color); /*this.color=this.o.color=c; if (this.o.onSelect) this.o.onSelect(c);*/};

                var mcsb = cm.createColorSplitButton('universityColors', o);

                // return the new ColorSplitButton instance
                return mcsb;
            }
            return null;
        }
   });
tinymce.PluginManager.add('universityColorPicker', tinymce.plugins.ExamplePlugin);
tinyMCE.init({
    mode: "specific_textareas",
    editor_selector: "tinyMCE",
    theme : "advanced",
    plugins : "emotions,spellchecker,advhr,insertdatetime,preview, -universityColorPicker", 

     // Theme options - button# indicated the row# only
    theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,fontselect,fontsizeselect,formatselect",
    theme_advanced_buttons2 : "cut,copy,paste,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,|,code,preview,|,forecolor,backcolor, universityColors",
    theme_advanced_buttons3 : "insertdate,inserttime,|,spellchecker,advhr,,removeformat,|,sub,sup,|,charmap,emotions",      
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_statusbar_location : "bottom",
    theme_advanced_resizing : true,


    });

我也在http://fiddle.tinymce.com/jYcaab

做了一个小提琴

1 个答案:

答案 0 :(得分:3)

我做了那个老小提琴:) 这里是您修改过的限定颜色的小提琴:http://fiddle.tinymce.com/jYcaab/1

将字体应用于内容是另一回事。 更新:现在应用字体:http://fiddle.tinymce.com/jYcaab/2

相关问题