UNPKG

slate-edit-list

Version:

A Slate plugin to handle keyboard events in lists.

20 lines (13 loc) 626 B
const expect = require('expect'); module.exports = function(plugin, state) { const selectedBlock = state.document.getDescendant('_selection_key'); state = state.transform().moveToRangeOf(selectedBlock).apply(); const initialText = state.startBlock.text; const initialSelection = state.selection; state = plugin.transforms.increaseItemDepth(state.transform()).apply(); state = state.transform().undo().apply(); // Back to previous cursor position expect(state.startBlock.text).toEqual(initialText); expect(state.selection.toJS()).toEqual(initialSelection.toJS()); return state; };