Skip to content

Commit 408898e

Browse files
committed
feat: adds option to save empty rows
1 parent 605a73d commit 408898e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ var editor = EditorJS({
5454
| ------------------ | -------- | ---------------------------------------- |
5555
| `rows` | `number` | initial number of rows. `2` by default |
5656
| `cols` | `number` | initial number of columns. `2` by default |
57-
| `withHeadings` | `boolean` | toggle table headings. `false` by default |
57+
| `withHeadings` | `boolean`| toggle table headings. `false` by default |
58+
| `allowEmptyRows` | `boolean`| toggle saving empty rows. `false` by default |
5859

5960
## Output data
6061

src/table.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ export default class Table {
4343
this.data = data;
4444
this.config = config;
4545

46+
/**
47+
* Config default
48+
*/
49+
this.config.allowEmptyRows = config.allowEmptyRows ?? false;
50+
4651
/**
4752
* DOM nodes
4853
*/
@@ -934,8 +939,8 @@ export default class Table {
934939
const cells = Array.from(row.querySelectorAll(`.${CSS.cell}`));
935940
const isEmptyRow = cells.every(cell => !cell.textContent.trim());
936941

937-
if (isEmptyRow) {
938-
continue;
942+
if(!this.config.allowEmptyRows && isEmptyRow){
943+
continue;
939944
}
940945

941946
data.push(cells.map(cell => cell.innerHTML));

0 commit comments

Comments
 (0)