A slate plugin to handle table nested with block; this plugin is expected to be used with GitbookIO/slate-edit-table
npm i --save slate-bad-table
- Provides customized
getFragmentAtRange
anddeleteAtRange
for copy/paste - Provides rules for customizing your own
getFragmentAtRange
anddeleteAtRange
import createBadTablePlugin from 'slate-bad-table';
const plugins = [createBadTablePlugin()]
[typeBadTable: 'bad-table']
string for the table type[typeBadRow: 'bad-table-row']
string for the row type[typeBadCell: 'bad-table-cell']
string for the cell type[typeParagraph: 'paragraph']
string for paragraph type
Customized method for copying. The method memics the default node.getFragmentAtRange
, but tries to avoid bad-table*
in the returned fragment;
Return true if selection is inside a bad-table-cell
Return true if selection starts and ends both outside any bad table. (Notice: it is NOT the opposite value of isSelectionInCell)
Customized method for delete and paste at range. The method memics the default change.deleteAtRange
, but tries to keep valid bad tables.
Optional option normalize
is for enable/disable normalization after deleteAtRange
remove bad-table if the focus is in the table
remove bad-table-row if the focus is in the row;
remove bad-table-row if the focus is in the row;
Rules for rules-combinator for customizing copy/paste logic with other plugins
rules.getFragmentAtRange: Array< ( getFragmentAtRange: (Node, Range) => Document, node: Node, range: Range, next: () => Document ): Document >
getFragmentAtRange
for the root function entry, used for node or range change; You can see example of usage atlib/rules/getFragmentAtRange/ifStartInCell
node
,range
: node and rangenext
evaluate the following rules for binding rules, see example atlib/rules/getFragmentAtRange/index
rules.deleteAtRange: Array< ( deleteAtRange: (Change, Range) => Change, node: Node, range: Range, next: () => Change ): Change >
deleteAtRange
for the root function entry, used for range change; You can see example of usage atlib/rules/deleteAtRange/ifStartInCell
change
,range
: change and rangenext
evaluate the following rules for binding rules, see example atlib/rules/deleteAtRange/index