diff --git a/src/shared/components/BlockEditor/utils/caret.js b/src/shared/components/BlockEditor/utils/caret.js index 1a512d1..169cde0 100644 --- a/src/shared/components/BlockEditor/utils/caret.js +++ b/src/shared/components/BlockEditor/utils/caret.js @@ -93,6 +93,7 @@ function locateOffset(el, offset) { } export function getCaretOffset(el) { + if (!el) return 0; const sel = typeof window !== 'undefined' ? window.getSelection() : null; if (!sel || sel.rangeCount === 0) return 0; const range = sel.getRangeAt(0); @@ -101,6 +102,7 @@ export function getCaretOffset(el) { } export function getCaretRange(el) { + if (!el) return null; const sel = typeof window !== 'undefined' ? window.getSelection() : null; if (!sel || sel.rangeCount === 0) return null; const range = sel.getRangeAt(0);