Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You would start by defining your different toolbars in the <strong>config.js</strong></p> <pre><code>config.toolbar_MyToolUserMode1 = [ ['Find', 'SelectAll'], ['Anchor'], ['Maximize'] ]; config.toolbar_MyToolUserMode2 = [ ['Find'], ['Anchor'], ['Maximize'] ]; </code></pre> <p>Those toolbar-definitions can then be used later <strong>in your page</strong>, but be aware that as soon as you create an instance of CKEditor, the toolbar layout CAN NOT be changed:</p> <pre><code>CKEDITOR.config.toolbar = "MyToolUserMode1"; var instance = CKEDITOR.appendTo(parentElement); </code></pre> <p><strong>Solution 1:</strong></p> <p>You would have to create a new instance to change the toolbar dynamically:</p> <pre><code>switch(UserMode) { case "1": if (instance) instance.destroy(); CKEDITOR.config.toolbar = "MyToolUserMode1"; instance = CKEDITOR.appendTo(parentElement); break; case "2": if (instance) instance.destroy(); CKEDITOR.config.toolbar = "MyToolUserMode2"; instance = CKEDITOR.appendTo(parentElement); break; } </code></pre> <p><strong>Solution 2:</strong></p> <p>However, if you are happy with showing the full toolbar also in usermode 2 and greying the SelectAll-Button, then the following could be your solution:</p> <pre><code>CKEDITOR.config.toolbar = "MyToolUserMode1"; var instance = CKEDITOR.appendTo(parentElement); switch(UserMode) { case "1": instance.getCommand('selectAll').enable(); break; case "2": instance.getCommand('selectAll').disable(); break; } </code></pre> <p>[EDIT feb 15]</p> <p><strong>Solution 3:</strong></p> <p>According to your comment -> how to dynamically construct with array.push</p> <p><strong>No configuration needed in config.js</strong></p> <pre><code> // your code var myToolbarSection1 = new Array(); myToolbarSection1.push('Bold'); myToolbarSection1.push('Italic'); // attaching this section to toolbar var myToolbar = new Array(); myToolbar.push(myToolbarSection1); // setting the toolbar CKEDITOR.config.toolbar_Dynamic = myToolbar; CKEDITOR.config.toolbar = 'Dynamic'; var instance = CKEDITOR.appendTo('myDIVID'); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload