move 'env' from state to context

This commit is contained in:
Joeri Exelmans 2025-05-13 14:33:35 +02:00
parent 9ef160aeb7
commit f09261df93
13 changed files with 178 additions and 148 deletions

View file

@ -1,3 +1,4 @@
import type { Ref } from "react";
// If there is a caret anywhere in the document (user entering text), returns the position of the caret in the focused element
export function getCaretPosition(): number | undefined {
@ -46,4 +47,10 @@ export function focusPrevElement() {
prevElem.focus();
setRightMostCaretPosition(prevElem);
}
}
}
export const autoInputWidth = (inputRef: React.RefObject<HTMLInputElement| null>, text) => {
if (inputRef.current) {
inputRef.current.style.width = `${text.length === 0 ? 140 : (text.length*8.7)}px`;
}
}