简体   繁体   English

禁用TinyMCE按钮

[英]Disable TinyMCE buttons

I have a TinyMCE Editor using the following buttons: 我有一个使用以下按钮的TinyMCE编辑器:

toolbar1: "newdocument fullpage | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | styleselect formatselect fontselect fontsizeselect",
toolbar2:  "cut copy paste | searchreplace | bullist numlist | outdent indent blockquote | undo redo | link unlink anchor | insertdatetime preview | forecolor backcolor",
toolbar3: "table | hr removeformat | subscript superscript | charmap | print fullscreen | ltr rtl | spellchecker | visualchars visualblocks",
toolbar4: 'contactButton | datesButton | feesButton | propertyButton'

toolbar4 is my default buttons. 工具栏4是我的默认按钮。 How can I disable all buttons except the print button? 如何禁用除打印按钮以外的所有按钮? My problem is that I have 2 type of users to open my editor. 我的问题是我有两种类型的用户可以打开编辑器。 The first is a manager user that can edit the content, and the second user only can see and print the content. 第一个是可以编辑内容的管理员用户,第二个用户只能查看和打印内容。

Thanks 谢谢

When you load TinyMCE you do so by calling init() ... 加载TinyMCE时,可以通过调用init()

tinymce.init({
   selector: textarea
   .
   .  
   .
});

The item you are passing to init is just a simple JavaScript object. 您传递给init的项目只是一个简单的JavaScript对象。 You can have one object that exposes all the buttons you need for editing and one object that only includes the print button. 您可以使一个对象显示您需要编辑的所有按钮,而让一个对象仅包含print按钮。 When you load your page you then initialize TinyMCE appropriately based on need. 加载页面时,您可以根据需要适当初始化TinyMCE。 For example: 例如:

var normalEditor = {
  selector: textarea, 
  toolbar1: '.....',
  toolbar2: '.....',
  .
  . 
  .
}

var reducedEditor = {
  selector: textarea, 
  toolbar1: 'print',
  .
  . 
  .
}


//pseudocode
if (<user is manager>) {
    tinymce.init(normalEditor);
} else {
    tinymce.init(reducedEditor);
} 

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

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