Skip to content

Instantly share code, notes, and snippets.

@amiri
Created December 31, 2019 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amiri/cfe000358ad0efec906e00c38a7c136d to your computer and use it in GitHub Desktop.
Save amiri/cfe000358ad0efec906e00c38a7c136d to your computer and use it in GitHub Desktop.
const findLastWord = (editor) => {
console.log(editor.selection);
Transforms.move(editor, { distance: 1, unit: 'word', reverse: true, edge: 'start' })
console.log(editor.selection);
const selected = Editor.string(editor, editor.selection);
console.log(selected);
Transforms.move(editor, {distance: 2, unit: 'word', edge: 'start'});
editor.insertText(' ');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment