谢谢你的好解决方案!
但它不起作用,我这样做:
RTE 配置:
editor:
externalPlugins:
table_responsive: { resource: "EXT:rlp_base/Resources/Public/RTE/Plugins/Table.js" }
table_wrap: {resource: "EXT:rlp_base/Resources/Public/RTE/Plugins/TableWrap.js"}
和这个:
editor:
...
config:
...
extraPlugins:
- justify
- table_responsive
- table_wrap
在 TableWrap.js 中是这样的:
'use strict';
(function() {
CKEDITOR.plugins.add('table_wrap', {
init: function (editor) {
editor.on('insertElement', function (event) {
if (event.data.getName() === 'table') {
var div = new CKEDITOR.dom.element('div').addClass('table-responsive'); // Create a new div element to use as a wrapper.
event.data.appendTo(div); // Append the original element to the new wrapper.
event.data = div; // Replace the original element with the wrapper.
}
}, null, null, 1);
}
});
})();
像这样的例子: https ://github.com/benjaminkott/bootstrap_package/blob/master/Resources/Public/CKEditor/Plugins/Table/plugin.js
我的前端 HTML 输出是这样的:
<div class="ce-bodytext">
<table class="table">
<tbody><tr>
...
</tr></tbody>
</table>
</div>
也许这是另一个javascript错误?