UNPKG

slate-edit-table

Version:

A Slate plugin to handle keyboard events in tables.

18 lines (11 loc) 482 B
const expect = require('expect'); module.exports = function(plugin, state) { const cursorBlock = state.document.getDescendant('_cursor_'); const transform = state.transform(); state = transform.moveToRangeOf(cursorBlock).apply(); state = plugin.transforms.insertRow(state.transform()).apply(); state = state.transform().undo().apply(); // Back to previous cursor position expect(state.startBlock.text).toEqual('Col 1, Row 1'); return state; };