2

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

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

4

1 回答 1

3

我做了那个较旧的小提琴:)在这里你修改过的小提琴限制了颜色: http: //fiddle.tinymce.com/jYcaab/1

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

于 2013-03-28T10:07:39.140 回答