@1771technologies/lytenyte-pro
Version:
Blazingly fast headless React data grid with 100s of features.
12 lines (11 loc) • 493 B
JavaScript
import { getIndentation } from "./get-indentation.js";
export function handleEnterKey(value, selectionStart, selectionEnd, multiline) {
if (!multiline) {
return null;
}
const indent = getIndentation(value, selectionStart);
const insertion = "\n" + indent;
const newValue = value.substring(0, selectionStart) + insertion + value.substring(selectionEnd);
const cursorPosition = selectionStart + insertion.length;
return { value: newValue, cursorPosition };
}