mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-12 18:24:03 +02:00
only apply Firefox toSlatePoint offset fix if ending in \n\n
(#4552)
This commit is contained in:
5
.changeset/firefox-newline-fix.md
Normal file
5
.changeset/firefox-newline-fix.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Only apply Firefox `toSlatePoint()` offset fix when the cloned contents end in `\n\n` instead of just `\n`.
|
@@ -515,7 +515,7 @@ export const ReactEditor = {
|
|||||||
// COMPAT: In Firefox, `range.cloneContents()` returns an extra trailing '\n'
|
// COMPAT: In Firefox, `range.cloneContents()` returns an extra trailing '\n'
|
||||||
// when the document ends with a new-line character. This results in the offset
|
// when the document ends with a new-line character. This results in the offset
|
||||||
// length being off by one, so we need to subtract one to account for this.
|
// length being off by one, so we need to subtract one to account for this.
|
||||||
(IS_FIREFOX && domNode.textContent?.endsWith('\n')))
|
(IS_FIREFOX && domNode.textContent?.endsWith('\n\n')))
|
||||||
) {
|
) {
|
||||||
offset--
|
offset--
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user