我想在 TinyMCE 4 中使用 style_formats
。一个 style_format
应该像这样将内容包装成一个井:
之前:
<p>Hello!</p>
<p>More stuff...</p>
之后:
<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"
}]
我做错了什么? 提前致谢!
最佳答案
我找到了一个方法:
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"
...以防万一有人需要它。
关于javascript - TinyMCE - 将多个元素包装在一个 div 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38037787/