Skip to content

Commit

Permalink
fix: fixed ts
Browse files Browse the repository at this point in the history
  • Loading branch information
mbret committed Nov 26, 2024
1 parent 66114f5 commit 906d11c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/core/src/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,16 @@ function createRangeOrCaretFromPoint(
// @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretPositionFromPoint
if (`caretPositionFromPoint` in doc) {
// @see https://developer.mozilla.org/en-US/docs/Web/API/CaretPosition
// @ts-expect-error limited availability
return doc.caretPositionFromPoint(startX, startY) as {
offsetNode: Node
offset: number
}
} else if (typeof doc.caretRangeFromPoint !== `undefined`) {
} else if (
"caretRangeFromPoint" in doc &&
// @ts-expect-error limited availability
typeof doc.caretRangeFromPoint !== `undefined`
) {
// @ts-expect-error limited availability
return doc.caretRangeFromPoint(startX, startY)
}
}
Expand Down

0 comments on commit 906d11c

Please sign in to comment.