Search code examples
editorfroala

How to add class to table in froala editor?


How can I add some css classes to tables made in froala editor? I need it because I use some bootstrap classes on tables and I want to add them to tables from the editor.

I need to add this: class="table table-striped table-hover responsive"

Thanks for your help.

EDIT: https://i.sstatic.net/cCZXo.png

You'll see the difference in the code:

1) This is what I get now: <table>

2) And this is what I need:

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

Solution

  • I just realized that I can use function str_replace before saving to the database. I'll use this solution:

    function repairTables($text){
        return str_replace('<table width="100%">', '<table class="table table-striped table-hover responsive">', $text);
    }