cursor issue
This commit is contained in:
@@ -497,7 +497,8 @@ export const ParagraphEditor: React.FC<ParagraphEditorProps> = ({
|
|||||||
if (!hasPreview) setHasPreview(true);
|
if (!hasPreview) setHasPreview(true);
|
||||||
if (!initialCaretApplied.current) {
|
if (!initialCaretApplied.current) {
|
||||||
initialCaretApplied.current = true;
|
initialCaretApplied.current = true;
|
||||||
if (caretClick && lay) setGlobalCaretOffset(el, globalFromPoint(caretClick.x, caretClick.y, lay, el.textContent ?? ''));
|
const fullLen = (el.textContent ?? '').length;
|
||||||
|
setGlobalCaretOffset(el, fullLen);
|
||||||
}
|
}
|
||||||
positionCaret();
|
positionCaret();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -379,7 +379,6 @@ export const TextEditLayer: React.FC<TextEditLayerProps> = ({
|
|||||||
const [fontFamily, setFontFamily] = useState('inherit');
|
const [fontFamily, setFontFamily] = useState('inherit');
|
||||||
const committedRef = useRef(false);
|
const committedRef = useRef(false);
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
const caretIdxRef = useRef<number | null>(null);
|
|
||||||
const modelRef = useRef<any>(null);
|
const modelRef = useRef<any>(null);
|
||||||
const [paraEdit, setParaEdit] = useState<{
|
const [paraEdit, setParaEdit] = useState<{
|
||||||
para: any; pushColumnLeft?: number; leading?: number; align?: ReflowAlign; columnLeft?: number; columnRight?: number;
|
para: any; pushColumnLeft?: number; leading?: number; align?: ReflowAlign; columnLeft?: number; columnRight?: number;
|
||||||
@@ -511,7 +510,6 @@ export const TextEditLayer: React.FC<TextEditLayerProps> = ({
|
|||||||
}
|
}
|
||||||
committedRef.current = false;
|
committedRef.current = false;
|
||||||
const fb = fallbackFamily(run.fontName);
|
const fb = fallbackFamily(run.fontName);
|
||||||
caretIdxRef.current = caretIndexFromX(run.text, `${displayFontSize(run) * zoom}px ${fb}`, clickX);
|
|
||||||
setEditing(i);
|
setEditing(i);
|
||||||
setValue(run.text);
|
setValue(run.text);
|
||||||
setFontFamily(fb);
|
setFontFamily(fb);
|
||||||
@@ -702,11 +700,8 @@ export const TextEditLayer: React.FC<TextEditLayerProps> = ({
|
|||||||
value={value}
|
value={value}
|
||||||
onChange={(e) => setValue(e.target.value)}
|
onChange={(e) => setValue(e.target.value)}
|
||||||
onFocus={(e) => {
|
onFocus={(e) => {
|
||||||
const idx = caretIdxRef.current;
|
const end = e.currentTarget.value.length;
|
||||||
if (idx != null) {
|
e.currentTarget.setSelectionRange(end, end);
|
||||||
e.currentTarget.setSelectionRange(idx, idx);
|
|
||||||
caretIdxRef.current = null;
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
onBlur={commit}
|
onBlur={commit}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user