1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-04-19 12:51:59 +02:00

fix ime double input with mark (#4158)

* fix ime double when apply mark

* add changeset

* refactor to use auto-incrementing key and add comments for it

* Update lovely-walls-knock.md

* Update lovely-walls-knock.md

Co-authored-by: Ian Storm Taylor <ian@ianstormtaylor.com>
This commit is contained in:
Githoniel 2021-04-13 22:59:07 +08:00 committed by GitHub
parent de5cc7e5ed
commit ea6dc08913
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
'slate-react': patch
---
Fixed a bug that resulted in doubly-input characters when using an IME.

View File

@ -4,6 +4,9 @@ import String from './string'
import { PLACEHOLDER_SYMBOL } from '../utils/weak-maps'
import { RenderLeafProps } from './editable'
// auto-incrementing key for String component, force it refresh to
// prevent inconsistent rendering by React with IME input
let keyForString = 0
/**
* Individual leaves in a text node with unique formatting.
*/
@ -43,7 +46,13 @@ const Leaf = (props: {
}, [placeholderRef])
let children = (
<String isLast={isLast} leaf={leaf} parent={parent} text={text} />
<String
key={keyForString++}
isLast={isLast}
leaf={leaf}
parent={parent}
text={text}
/>
)
if (leaf[PLACEHOLDER_SYMBOL]) {