slate-edit-code
Version:
A Slate plugin to handle code blocks editing.
13 lines (9 loc) • 333 B
JavaScript
import simulateKey from '../simulate-key';
export default function(plugin, change) {
const { value } = change;
const block = value.document.findDescendant(
node => node.type == 'code_block'
);
change.collapseToStartOf(block).moveOffsetsTo(0);
return plugin.onKeyDown(simulateKey('tab'), change, {});
}