Editor 如何在froala编辑器中将类添加到表中?

Editor 如何在froala编辑器中将类添加到表中?,editor,froala,Editor,Froala,如何将一些css类添加到froala编辑器中生成的表中?我需要它,因为我在表上使用了一些引导类,我想从编辑器中将它们添加到表中 我需要添加以下内容:class=“table table striped table hover responsive” 谢谢你的帮助 编辑: 您将看到代码中的差异: 1) 这就是我现在得到的: 2) 这就是我需要的: <table class="table table-striped table-hover responsive"> 我刚刚意识到我可以在

如何将一些css类添加到froala编辑器中生成的表中?我需要它,因为我在表上使用了一些引导类,我想从编辑器中将它们添加到表中

我需要添加以下内容:
class=“table table striped table hover responsive”

谢谢你的帮助

编辑:

您将看到代码中的差异:

1) 这就是我现在得到的:

2) 这就是我需要的:

<table class="table table-striped table-hover responsive">

我刚刚意识到我可以在保存到数据库之前使用str\u replace函数。我将使用此解决方案:

function repairTables($text){
    return str_replace('<table width="100%">', '<table class="table table-striped table-hover responsive">', $text);
}
功能维修表($text){
返回str_replace(“”,,$text);
}

使用Jquery,您还可以添加如下类:

$('div#froala-editor table').addClass('table table-bordered');
如果要在插入表时添加它,可以覆盖默认的Froala行为:

$.FroalaEditor.RegisterCommand('tableInsert', {
callback: function (cmd, rows, cols) {
  this.table.insert(rows, cols);
  this.popups.hide('table.insert');
  $('div#froala-editor table').addClass('table table-bordered');
}

}))

请解释清楚;我希望现在一切都清楚了