slate-suggenstions: adding moveBackward (#55576)

This commit is contained in:
Sven Grossmann 2022-09-21 19:39:54 +02:00 committed by GitHub
parent 9e0d349bf9
commit e55003174a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -143,6 +143,8 @@ export function SuggestionsPlugin({
const preserveSuffix = suggestion.kind === 'function';
const move = suggestion.move || 0;
const moveForward = move > 0 ? move : 0;
const moveBackward = move < 0 ? -move : 0;
const { typeaheadPrefix, typeaheadText, typeaheadContext } = state;
@ -180,7 +182,8 @@ export function SuggestionsPlugin({
.deleteBackward(backward)
.deleteForward(forward)
.insertText(suggestionText)
.moveForward(move)
.moveForward(moveForward)
.moveBackward(moveBackward)
.focus();
return editor;