2017-07-28 1 views
0

次の例はtinyMCEにカスタムドロップダウンを追加していますが、init tinyMCEの後に再び変更できますか?たとえば、tinyMCEを初期化した後、別のリストで別のボタンでリストを再度更新します。 https://codepen.io/tinymce/pen/JYwJVrtinymceの初期化後にtinyMCEのカスタムツールバーリストボックスの値を変更することは可能です

tinymce.init({ 
    selector: 'textarea', 
    height: 500, 
    toolbar: 'mybutton', 
    menubar: false, 
    content_css: [ 
    '//fonts.googleapis.com/css?family=Lato:300,300i,400,400i', 
    '//www.tinymce.com/css/codepen.min.css'], 

    setup: function (editor) { 
    editor.addButton('mybutton', { 
     type: 'listbox', 
     text: 'My listbox', 
     icon: false, 
     onselect: function (e) { 
     editor.insertContent(this.value()); 
     }, 
     values: [ 
     { text: 'Menu item 1', value: '&nbsp;<strong>Some bold text!</strong>' }, 
     { text: 'Menu item 2', value: '&nbsp;<em>Some italic text!</em>' }, 
     { text: 'Menu item 3', value: '&nbsp;Some plain text ...' } 
     ], 
     onPostRender: function() { 
     // Select the second item by default 
     this.value('&nbsp;<em>Some italic text!</em>'); 
     } 
    }); 
    } 
}); 

答えて

0

私は私だけのカスタムドロップダウンのために更新することができます任意の選択肢を見つけることができませんでした。これは良い方法ではありませんが、私はそれを動作させる唯一の方法です。だから、私がやったことは、はっきりとしたものを取り除き、それを再び追加することでした。

tinymce.remove(); 
tinymce.init({ 
selector: 'textarea', 
    setup: function (editor) { 
       var self = this; 
       editor.addButton('mybutton', { 
        type: 'listbox', 
        text: 'myList', 
        icon: false, 

        onselect: function (e) {  

        editor.insertContent(this.value()); 
        }, 
        values: newList, 
        onPostRender: function() { 
        // Select the second item by default 
        this.value('&nbsp;<em>Some italic text!</em>'); 
        } 
       }); 
      } 
}); 
関連する問題