Table block tool for Editor.js
npm install @coolbytes/editorjs-tableThis is a clone of this Editor.js block tool. It fixes the default withHeadings issue.
Using npm
``sh`
npm install @coolbytes/editorjs-table
Using yarn
`sh`
yarn add @coolbytes/editorjs-table
Include it in the tools property of Editor.js config:
`js`
const editor = new EditorJS({
tools: {
table: Table
}
});
Or init the Table tool with additional settings
`javascript`
const editor = new EditorJS({
tools: {
table: {
class: Table,
inlineToolbar: true,
config: {
rows: 2,
cols: 3,
},
},
},
});
| Field | Type | Description |
| ------------------ | -------- | ---------------------------------------- |
| 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 |
This Tool returns data in the following format
| Field | Type | Description |
| -------------- | ------------ | ----------------------------------------- |
| withHeadings | boolean | Uses the first line as headings |content
| | string[][] | two-dimensional array with table contents |
Example:
`json``
{
"time": 1721500689337,
"blocks": [
{
"id": "XXVTfnMlcE",
"type": "table",
"data": {
"withHeadings": true,
"content": [
[ "Kine", "Pigs", "Chicken" ],
[ "1 pcs", "3 pcs", "12 pcs" ],
[ "100$", "200$", "150$" ]
]
}
}
],
"version": "2.30.2"
}