mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-16 04:04:06 +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:
5
.changeset/orange-ears-help.md
Normal file
5
.changeset/orange-ears-help.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate-react': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix a crash on iOS when composing text using an IME at the start of a block, at the cost of breaking capitalization on iOS in an empty editor.
|
@@ -3,7 +3,7 @@ import { Editor, Text, Path, Element, Node } from 'slate'
|
|||||||
|
|
||||||
import { ReactEditor, useSlateStatic } from '..'
|
import { ReactEditor, useSlateStatic } from '..'
|
||||||
import { useIsomorphicLayoutEffect } from '../hooks/use-isomorphic-layout-effect'
|
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'
|
import { MARK_PLACEHOLDER_SYMBOL } from 'slate-dom'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -127,9 +127,17 @@ export const ZeroWidthString = (props: {
|
|||||||
attributes['data-slate-mark-placeholder'] = true
|
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 (
|
return (
|
||||||
<span {...attributes}>
|
<span {...attributes}>
|
||||||
{!(IS_ANDROID || IS_IOS) || !isLineBreak ? '\uFEFF' : null}
|
{!IS_ANDROID || !isLineBreak ? '\uFEFF' : null}
|
||||||
{isLineBreak ? <br /> : null}
|
{isLineBreak ? <br /> : null}
|
||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user