1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-13 18:53:59 +02:00

Fix IME crash on iOS, but break capitalisation on iOS (#5877)

* Revert "Make capitalizing work for iOS (#5654)"

This reverts commit 2a8b4e958b.

* Add changeset

* Reference the older issue in comment
This commit is contained in:
Joe Anderson
2025-05-24 21:53:27 +01:00
committed by GitHub
parent 11b957a441
commit 747ebfda0a
2 changed files with 15 additions and 2 deletions

View File

@@ -3,7 +3,7 @@ import { Editor, Text, Path, Element, Node } from 'slate'
import { ReactEditor, useSlateStatic } from '..'
import { useIsomorphicLayoutEffect } from '../hooks/use-isomorphic-layout-effect'
import { IS_ANDROID, IS_IOS } from 'slate-dom'
import { IS_ANDROID } from 'slate-dom'
import { MARK_PLACEHOLDER_SYMBOL } from 'slate-dom'
/**
@@ -127,9 +127,17 @@ export const ZeroWidthString = (props: {
attributes['data-slate-mark-placeholder'] = true
}
// FIXME: Inserting the \uFEFF on iOS breaks capitalization at the start of an
// empty editor (https://github.com/ianstormtaylor/slate/issues/5199).
//
// However, not inserting the \uFEFF on iOS causes the editor to crash when
// inserting any text using an IME at the start of a block. This appears to
// be because accepting an IME suggestion when at the start of a block (no
// preceding \uFEFF) removes one or more DOM elements that `toSlateRange`
// depends on. (https://github.com/ianstormtaylor/slate/issues/5703)
return (
<span {...attributes}>
{!(IS_ANDROID || IS_IOS) || !isLineBreak ? '\uFEFF' : null}
{!IS_ANDROID || !isLineBreak ? '\uFEFF' : null}
{isLineBreak ? <br /> : null}
</span>
)