A Slate plugin to handle table edition.
npm install @strelka/slate-edit-table
- Pressing Up and Down, move the cursor to next/previous row
import EditTable from '@strelka/slate-edit-table'
const plugins = [
EditTable()
]
[typeTable: String]
— type for table[typeRow: String]
— type for the rows[typeCell: String]
— type for the cells[typeDefault: String]
— type for cell content (default toparagraph
)
slate-edit-table
exports utilities and changes:
plugin.utils.isSelectionInTable(state: State) => Boolean
Return true if selection is inside a table.
plugin.changes.insertTable(transform: Transform, columns: Number?, rows: Number?) => Transform
Insert a new empty table.
plugin.changes.insertRow(transform: Transform, at: Number?) => Transform
Insert a new row after the current one or at the specific index (at
).
plugin.changes.insertColumn(transform: Transform, at: Number?) => Transform
Insert a new column after the current one or at the specific index (at
).
plugin.changes.removeTable(transform: Transform) => Transform
Remove current table.
plugin.changes.removeRow(transform: Transform, at: Number?) => Transform
Remove current row or the one at a specific index (at
).
plugin.changes.removeColumn(transform: Transform, at: Number?) => Transform
Remove current column or the one at a specific index (at
).
plugin.changes.moveSelection(transform: Transform, column: Number, row: Number) => Transform
Move the selection to a specific position in the table.
plugin.changes.moveSelectionBy(transform: Transform, column: Number, row: Number) => Transform
Move the selection by the given amount of columns and rows.
plugin.changes.setColumnAlign(transform: Transform, align: String, at: Number) => Transform
Sets column alignment for a given column (at
), in the current table. align
defaults to center, at
is optional and defaults to current cursor position.