mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
fix(editor): caret can be null in firefox (#9438)
Fix: https://toeverything.sentry.io/issues/6185588184/events/b205b6caf0224b51882c1d10bb3dd9bc/
This commit is contained in:
@@ -9,7 +9,7 @@ declare global {
|
||||
): {
|
||||
offsetNode: Node;
|
||||
offset: number;
|
||||
};
|
||||
} | null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,9 @@ export function caretRangeFromPoint(
|
||||
): Range | null {
|
||||
if (IS_FIREFOX) {
|
||||
const caret = document.caretPositionFromPoint(clientX, clientY);
|
||||
if (!caret) {
|
||||
return null;
|
||||
}
|
||||
// TODO handle caret is covered by popup
|
||||
const range = document.createRange();
|
||||
range.setStart(caret.offsetNode, caret.offset);
|
||||
|
||||
Reference in New Issue
Block a user