Javascript 如何在 tinymce 编辑器中启用字体系列和颜色选项?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12247339/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 07:30:50  来源:igfitidea点击:

how to enable font family and color options in tinymce editor?

javascriptfontstinymce

提问by Harish Kumar

I am using a tinymce editor on my cms its having a normal text toolbar where it has bold,italic,underline, and justify option but it dont have the font family change option and not even color change. how to enable that?

我在我的 cms 上使用了一个 tinymce 编辑器,它有一个普通的文本工具栏,它有粗体、斜体、下划线和对齐选项,但它没有字体系列更改选项,甚至没有颜色更改。如何启用?

回答by Harish Kumar

i have done this in this way

我已经这样做了

tinyMCE.init({
theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
    theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
    theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
)};

回答by Harish Kumar

for the upgraded version here is the full featured example

对于升级版本,这里是全功能示例

  tinymce.init({
    selector: 'textarea',
    height: 500,
    theme: 'modern',
    plugins: ['advlist autolink lists link image charmap print preview hr anchor pagebreak',
    'searchreplace wordcount visualblocks visualchars code fullscreen',
    'insertdatetime media nonbreaking save table contextmenu directionality',
    'emoticons template paste textcolor colorpicker textpattern imagetools'
    ],
   toolbar1: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
   toolbar2: 'print preview media | forecolor backcolor emoticons',
   image_advtab: true,
   templates: [
   { title: 'Test template 1', content: 'Test 1' },
   { title: 'Test template 2', content: 'Test 2' }
   ],
   content_css: ['//fast.fonts.net/cssapi/e6dc9b99-64fe-4292-ad98-6974f93cd2a2.css',
    '//www.tinymce.com/css/codepen.min.css'
   ]
   });

for more reference visit https://www.tinymce.com/docs/demo/full-featured/

如需更多参考,请访问https://www.tinymce.com/docs/demo/full-featured/

回答by Matthew Lock

In my old version of TinyMCE 4.0.10 font and color controls are added like so to tinymce.init in addition to your other init toolbar and plugin options:

在我的旧版本 TinyMCE 4.0.10 中,除了其他 init 工具栏和插件选项之外,还向 tinymce.init 添加了字体和颜色控件:

toolbar: "styleselect fontselect fontsizeselect | forecolor backcolor",
plugins: "textcolor"