简体   繁体   中英

Disable TinyMCE buttons

I have a TinyMCE Editor using the following buttons:

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. 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({
   selector: textarea
   .
   .  
   .
});

The item you are passing to init is just a simple JavaScript object. You can have one object that exposes all the buttons you need for editing and one object that only includes the print button. When you load your page you then initialize TinyMCE appropriately based on need. 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);
} 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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