@1771technologies/lytenyte-pro
Version:
Blazingly fast headless React data grid with 100s of features.
8 lines (7 loc) • 325 B
JavaScript
export function replaceWordAtCursor(text, wordRange, replacement) {
const before = text.substring(0, wordRange.start);
const after = text.substring(wordRange.end);
const value = before + replacement + after;
const cursorPosition = wordRange.start + replacement.length;
return { value, cursorPosition };
}