2016-06-26 12 views
1

TinyMCEでstyle_formatsを使用しますです。後TinyMCE - 1つのdivに複数の要素をラップします

<p>Hello!</p> 
<p>More stuff...</p> 

::前

:ワンstyle_formatはよくこのようにコンテンツをラップする必要があり

<div class="well"> 
    <p>Hello!</p> 
    <p>More stuff...</p> 
</div> 

...しかし、私が取得することである:

<div class="well"> 
    <p>Hello</p> 
</div> 
<div class="well"> 
    <p>More stuff...</p> 
</div> 

マイstyle_formatは次のようになります。

style_formats: [{ 
    title: 'Box', 
    block: 'div', 
    classes: "well" 
}] 

私は間違っていますか? ありがとうございます!

答えて

1

私は方法を見つけた:

setup: function(ed) { 
    ed.addButton('well', { 
     title: 'Make Well', 
     icon: false, 
     onclick: function() { 
      var text = ed.selection.getContent({ 
       'format': 'html' 
      }); 
      if (text && text.length > 0) { 
       ed.execCommand('mceInsertContent', false, 
        '<div class="well">' + text + '</div>'); 
      } 
     } 
    }); 
}, 
toolbar: "well" 

...誰がそれを必要とするだけの場合。

関連する問題