diff --git a/README.md b/README.md index 49984ab..390a4c0 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,8 @@ var editor = EditorJS({ | ------------------ | -------- | ---------------------------------------- | | `rows` | `number` | initial number of rows. `2` by default | | `cols` | `number` | initial number of columns. `2` by default | -| `withHeadings` | `boolean` | toggle table headings. `false` by default | +| `withHeadings` | `boolean`| toggle table headings. `false` by default | +| `allowEmptyRows` | `boolean`| toggle saving empty rows. `false` by default | ## Output data diff --git a/src/table.js b/src/table.js index 28d10ad..971ddbb 100644 --- a/src/table.js +++ b/src/table.js @@ -43,6 +43,11 @@ export default class Table { this.data = data; this.config = config; + /** + * Config default + */ + this.config.allowEmptyRows = config.allowEmptyRows ?? false; + /** * DOM nodes */ @@ -934,8 +939,8 @@ export default class Table { const cells = Array.from(row.querySelectorAll(`.${CSS.cell}`)); const isEmptyRow = cells.every(cell => !cell.textContent.trim()); - if (isEmptyRow) { - continue; + if(!this.config.allowEmptyRows && isEmptyRow){ + continue; } data.push(cells.map(cell => cell.innerHTML));