Tinymce download buttons according to users choice

We use Tinymce for transcription / annotation. Each button is a type of “thing”. However, we have many things and therefore do not want all of them to load.

Instead, we would ideally want the tiny mce editor to have all the buttons hidden by default, with the exception of a drop-down list that contains all the types of documents you are rewriting. Then the user can select the type of document and buttons that will be displayed.

Is this possible with Tinymce? Has anyone else done this?

This needs to be done in the tinymce editor, since we load the editor as a floating window.

+4
source share
2 answers

, .

@Pete, .

:

    <script type="text/javascript">

    var settings = {
        selector: "textarea",
        plugins: [
            "advlist autolink lists link image charmap print preview anchor",
            "searchreplace visualblocks code fullscreen",
            "insertdatetime media table contextmenu paste"
        ],
        toolbar: []
    };

    function loadTinyMce(type) {
        if (type !== null) {
            switch (type) {
                case "a":
                    settings.toolbar = "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image";
                    break;
                case "b":
                    settings.toolbar = "insertfile undo redo | styleselect | bold italic";
                    break;
                case "c":
                    settings.toolbar = "bullist numlist outdent indent | link image";
                    break;
            }

            tinymce.remove();

            //Run setup function with a custom set of toolbars  
            tinymce.init(settings);
        }



    }

</script>

<select onchange="loadTinyMce(this.value);">
<option value="">Choose</option>
<option value="a">Example A</option>
<option value="b">Example B</option>
<option value="c">Example C</option>
</select>

<Br><Br>
<textarea name="content" id="content"></textarea>
+1

tinyMCE ?

( ), 3 Tiny MCE . / - ( )

http://fiddle.tinymce.com/fVeaab/2

:

<script type="text/javascript">

function loadTinyMce(type) {
    var toolbar

    if(type!==null) {
        switch(type) {
          case "a":
              toolbar = "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image";
          break;
          case "b":
              toolbar = "insertfile undo redo | styleselect | bold italic";
          break;
          case "c":
              toolbar = "bullist numlist outdent indent | link image";
          break;
      }

        //Kill current (Probably better way to do this)
        destroy();

      //Run setup function with a custom set of toolbars    
      setup(toolbar);
    }



}

function setup(toolbarOptions) {

    tinymce.init({
      selector: "textarea",
      plugins: [
          "advlist autolink lists link image charmap print preview anchor",
          "searchreplace visualblocks code fullscreen",
          "insertdatetime media table contextmenu paste"
      ],
      toolbar: toolbarOptions
  });
}

function destroy() {
    tinymce.remove();
}

</script>

<select onchange="loadTinyMce(this.value);">
<option value="">Choose</option>
<option value="a">Example A</option>
<option value="b">Example B</option>
<option value="c">Example C</option>
</select>

<Br><Br>
<textarea name="content" id="content"></textarea>
+1

Source: https://habr.com/ru/post/1599339/


All Articles