2013-07-24 39 views
4

我使用TinyMCE的一個嘗試擴展插件,以顯示與特定佈局的對話框:tinymce.ui簡單的文字組成

editor.windowManager.open({ 
     title: 'Title of my dialog', 
     body: [ 
      {type: 'label', text: 'my label'}, 
      { name:'my_input', type: 'textbox'}, 
     // { type: 'text', html:'some content with <b>bold</b> if posilbe!'}, 
      // { type: 'html', value:'<div>with custom formating</div>'} 
     ] 
    } 

我檢查了該文檔tinymce.ui幾次,但可以找到一種方法,在對話框的構造函數中添加html或文本組件(如示例中的註釋行)。

我知道有一個選項使用對話框的準備HTML模板..但也有很多事件和觸發器,所以使用構造函數和.ui組件更適合我的情況。

回答

4

我曾經爲此使用JQuery UI對話框,但在TinyMCE 4.0之後遇到了一些問題。

我有一個TinyMCE插件,可以讓人們在WordPress編輯器中獲取其文章的純文本版本。然後,我告訴他們使用這個文本:

var plain_block = { 
    type: 'container', 
    html: '<textarea style="margin: 10px; width: 550px !important; height: 450px !important; background-color: #eee;" readonly="readonly">Whatever plain text I need to show goes here</textarea>' 
}; 

ed.windowManager.open({ 
    title: "Plain Text of This Post", 
    spacing: 10, 
    padding: 10, 
    items: [ 
    plain_block 
    ], 
    buttons: [ 
    { 
      text: "Close", 
      onclick: function() { ed.windowManager.close();} 
     } 
    ] 
}); 

最終的結果是一些HTML和關閉按鈕,一個漂亮的純珍對話框