mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-13 18:53:59 +02:00
Fix firefox newline crash (#5549)
This commit is contained in:
5
.changeset/chatty-chefs-sneeze.md
Normal file
5
.changeset/chatty-chefs-sneeze.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate-react': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Firefox compat: Fix incorrect focus.offset when text node ends with \n
|
@@ -943,6 +943,17 @@ export const ReactEditor: ReactEditorInterface = {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// COMPAT: Firefox sometimes includes an extra \n (rendered by TextString
|
||||||
|
// when isTrailing is true) in the focusOffset, resulting in an invalid
|
||||||
|
// Slate point. (2023/11/01)
|
||||||
|
if (
|
||||||
|
IS_FIREFOX &&
|
||||||
|
focusNode.textContent?.endsWith('\n\n') &&
|
||||||
|
focusOffset === focusNode.textContent.length
|
||||||
|
) {
|
||||||
|
focusOffset--
|
||||||
|
}
|
||||||
|
|
||||||
// COMPAT: Triple-clicking a word in chrome will sometimes place the focus
|
// COMPAT: Triple-clicking a word in chrome will sometimes place the focus
|
||||||
// inside a `contenteditable="false"` DOM node following the word, which
|
// inside a `contenteditable="false"` DOM node following the word, which
|
||||||
// will cause `toSlatePoint` to throw an error. (2023/03/07)
|
// will cause `toSlatePoint` to throw an error. (2023/03/07)
|
||||||
|
Reference in New Issue
Block a user