cell_style.html 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0" />
  6. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">
  7. <link rel="stylesheet" href="../../css/froala_editor.css">
  8. <link rel="stylesheet" href="../../css/froala_style.css">
  9. <link rel="stylesheet" href="../../css/plugins/table.css">
  10. <style>
  11. body {
  12. text-align: center;
  13. }
  14. section {
  15. width: 81%;
  16. margin: auto;
  17. text-align: left;
  18. }
  19. .class1 {
  20. text-align: center;
  21. color: red;
  22. }
  23. .class2 {
  24. font-weight: 700;
  25. font-size: 14px;
  26. }
  27. </style>
  28. </head>
  29. <body>
  30. <section id="editor">
  31. <div id='edit' style="margin-top: 30px;">
  32. <h1>Table Cell Style</h1>
  33. <p>The <code>table.min.js</code> plugin it is possible to add custom style on the selected table cell inside the
  34. WYSIWYG HTML editor.</p>
  35. <p>The classes should be defined in CSS, otherwise no changes will be visible on the table's appearance.</p>
  36. <table style="width: 100%;">
  37. <tbody>
  38. <tr>
  39. <td style="width: 25%;">
  40. <br>
  41. </td>
  42. <td style="width: 25%;">
  43. <br>
  44. </td>
  45. <td style="width: 25%;">
  46. <br>
  47. </td>
  48. <td style="width: 25%;">
  49. <br>
  50. </td>
  51. </tr>
  52. <tr>
  53. <td style="width: 25%;">
  54. <br>
  55. </td>
  56. <td style="width: 25%;">
  57. <br>
  58. </td>
  59. <td style="width: 25%;">
  60. <br>
  61. </td>
  62. <td style="width: 25%;">
  63. <br>
  64. </td>
  65. </tr>
  66. </tbody>
  67. </table>
  68. <p>You can define your own table cell styles using the <a
  69. href="http://www.froala.dev/wysiwyg-editor/docs/options#tableCellStyles"
  70. title="tableCellStyles">tableCellStyles</a> option. This option is an Object where the key represents the
  71. class name and its value is the style name that appears in the dropdown list. It is important to have unique
  72. keys otherwise they will not work properly.</p>
  73. <p>By default you can select multiple table cell styles at a time. If you want to toggle them and allow only one
  74. style to be selected at a time use the <a
  75. href="http://www.froala.dev/wysiwyg-editor/docs/options#tableCellMultipleStyles"
  76. title="tableCellMultipleStyles">tableCellMultipleStyles</a> option.</p>
  77. </div>
  78. </section>
  79. <script type="text/javascript" src="../../js/froala_editor.min.js"></script>
  80. <script type="text/javascript" src="../../js/plugins/link.min.js"></script>
  81. <script type="text/javascript" src="../../js/plugins/table.min.js"></script>
  82. <script>
  83. (function () {
  84. new FroalaEditor("#edit", {
  85. toolbarButtons: [ ['bold', 'italic', 'underline', 'strikeThrough', 'table'], ['undo', 'redo'] ],
  86. // Define new table cell styles.
  87. tableCellStyles: {
  88. class1: 'Class 1',
  89. class2: 'Class 2'
  90. }
  91. })
  92. })()
  93. </script>
  94. </body>
  95. </html>