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

move markdown-it config specific to handsontable to another config file

utsushiiro 7 лет назад
Родитель
Сommit
536bb9054d

+ 18 - 0
src/client/js/util/markdown-it/table-with-handsontable-button.js

@@ -0,0 +1,18 @@
+export default class TableWithHandsontableButtonConfigurer {
+
+  constructor(crowi) {
+    this.crowi = crowi;
+  }
+
+  configure(md) {
+    md.renderer.rules.table_open = (tokens, idx) => {
+      const beginLine = tokens[idx].map[0] + 1;
+      const endLine  = tokens[idx].map[1];
+      return `<div><button onClick="crowi.launchHandsontableModal('page', ${beginLine}, ${endLine})"><i class="fa fa-table"></i></button><table class="table table-bordered">`;
+    };
+
+    md.renderer.rules.table_close = (tokens, idx) => {
+      return '</table></div>';
+    };
+  }
+}

+ 2 - 7
src/client/js/util/markdown-it/table.js

@@ -6,13 +6,8 @@ export default class TableConfigurer {
 
   configure(md) {
     md.renderer.rules.table_open = (tokens, idx) => {
-      const beginLine = tokens[idx].map[0] + 1;
-      const endLine  = tokens[idx].map[1];
-      return `<div><button onClick="crowi.launchHandsontableModal('page', ${beginLine}, ${endLine})"><i class="fa fa-table"></i></button><table class="table table-bordered">`;
-    };
-
-    md.renderer.rules.table_close = (tokens, idx) => {
-      return '</table></div>';
+      return '<table class="table table-bordered">';
     };
   }
+
 }