gpt4 book ai didi

javascript - 自定义颜色选择器 TinyMCE

转载 作者:行者123 更新时间:2023-11-29 19:57:49 35 4
gpt4 key购买 nike

我在我的网站上使用 TinyMCE 作为 WYSIWYG 编辑器,除了使用前景色的现有颜色选择器之外,我还想向编辑器添加自定义颜色选择器。我找到了这个 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,


});

我也做了一个 fiddle 的工作:http://fiddle.tinymce.com/jYcaab

最佳答案

我制作了那个旧的 fiddle :)这是您修改后的限制颜色的 fiddle :http://fiddle.tinymce.com/jYcaab/1

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

关于javascript - 自定义颜色选择器 TinyMCE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15667207/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com