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

check null or not in normalizeCells

utsushiiro 7 лет назад
Родитель
Сommit
ce82927a5d
1 измененных файлов с 7 добавлено и 2 удалено
  1. 7 2
      src/client/js/models/MarkdownTable.js

+ 7 - 2
src/client/js/models/MarkdownTable.js

@@ -41,12 +41,17 @@ export default class MarkdownTable {
   }
   }
 
 
   /**
   /**
-   * normalize all cell data(trim & convert the newline character to space)
+   * normalize all cell data(trim & convert the newline character to space or pad '' if cell data is null)
    */
    */
   normalizeCells() {
   normalizeCells() {
     for (let i = 0; i < this.table.length; i++) {
     for (let i = 0; i < this.table.length; i++) {
       for (let j = 0; j < this.table[i].length; j++) {
       for (let j = 0; j < this.table[i].length; j++) {
-        this.table[i][j] = this.table[i][j].trim().replace(/\r?\n/g, ' ');
+        if (this.table[i][j] != null) {
+          this.table[i][j] = this.table[i][j].trim().replace(/\r?\n/g, ' ');
+        }
+        else {
+          this.table[i][j] = '';
+        }
       }
       }
     }
     }