Просмотр исходного кода

add bootstrap table classes with markdown-it configuration

Yuki Takei 8 лет назад
Родитель
Сommit
aea34f93a2
3 измененных файлов с 15 добавлено и 64 удалено
  1. 0 64
      resource/css/_wiki.scss
  2. 2 0
      resource/js/util/GrowiRenderer.js
  3. 13 0
      resource/js/util/markdown-it/table.js

+ 0 - 64
resource/css/_wiki.scss

@@ -211,70 +211,6 @@ div.body {
     border-radius: 3px;
     border-radius: 3px;
   }
   }
 
 
-  // {{{ table (copied from bootstrap .table
-  table {
-    width: 100%;
-    margin-bottom: $line-height-computed;
-    // Cells
-    > thead,
-    > tbody,
-    > tfoot {
-      > tr {
-        > th,
-        > td {
-          padding: $table-cell-padding;
-          line-height: $line-height-base;
-          vertical-align: top;
-          border-top: 1px solid $table-border-color;
-        }
-      }
-    }
-    // Bottom align for column headings
-    > thead > tr > th {
-      vertical-align: bottom;
-      border-bottom: 2px solid $table-border-color;
-    }
-    // Remove top border from thead by default
-    > caption + thead,
-    > colgroup + thead,
-    > thead:first-child {
-      > tr:first-child {
-        > th,
-        > td {
-          border-top: 0;
-        }
-      }
-    }
-    // Account for multiple tbody instances
-    > tbody + tbody {
-      border-top: 2px solid $table-border-color;
-    }
-
-    // Nesting
-    table {
-      background-color: $body-bg;
-    }
-
-    // .table-bordered
-    border: 1px solid $table-border-color;
-    > thead,
-    > tbody,
-    > tfoot {
-      > tr {
-        > th,
-        > td {
-          border: 1px solid $table-border-color;
-        }
-      }
-    }
-    > thead > tr {
-      > th,
-      > td {
-        border-bottom-width: 2px;
-      }
-    }
-  }
-  // }}}
 }
 }
 
 
 
 

+ 2 - 0
resource/js/util/GrowiRenderer.js

@@ -10,6 +10,7 @@ import Template from './LangProcessor/Template';
 import EmojiConfigurer from './markdown-it/emoji';
 import EmojiConfigurer from './markdown-it/emoji';
 import MathJaxConfigurer from './markdown-it/mathjax';
 import MathJaxConfigurer from './markdown-it/mathjax';
 import PlantUMLConfigurer from './markdown-it/plantuml';
 import PlantUMLConfigurer from './markdown-it/plantuml';
+import TableConfigurer from './markdown-it/table';
 
 
 export default class GrowiRenderer {
 export default class GrowiRenderer {
 
 
@@ -28,6 +29,7 @@ export default class GrowiRenderer {
       new EmojiConfigurer(crowi),
       new EmojiConfigurer(crowi),
       new MathJaxConfigurer(crowi),
       new MathJaxConfigurer(crowi),
       new PlantUMLConfigurer(crowi),
       new PlantUMLConfigurer(crowi),
+      new TableConfigurer(crowi),
     ];
     ];
     this.langProcessors = {
     this.langProcessors = {
       'template': new Template(crowi),
       'template': new Template(crowi),

+ 13 - 0
resource/js/util/markdown-it/table.js

@@ -0,0 +1,13 @@
+export default class TableConfigurer {
+
+  constructor(crowi) {
+    this.crowi = crowi;
+  }
+
+  configure(md) {
+    md.renderer.rules.table_open = (tokens, idx) => {
+      return '<table class="table table-bordered">';
+    };
+  }
+
+}