mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-11 09:43:58 +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:
5
.changeset/lovely-walls-knock.md
Normal file
5
.changeset/lovely-walls-knock.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate-react': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixed a bug that resulted in doubly-input characters when using an IME.
|
@@ -4,6 +4,9 @@ import String from './string'
|
|||||||
import { PLACEHOLDER_SYMBOL } from '../utils/weak-maps'
|
import { PLACEHOLDER_SYMBOL } from '../utils/weak-maps'
|
||||||
import { RenderLeafProps } from './editable'
|
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.
|
* Individual leaves in a text node with unique formatting.
|
||||||
*/
|
*/
|
||||||
@@ -43,7 +46,13 @@ const Leaf = (props: {
|
|||||||
}, [placeholderRef])
|
}, [placeholderRef])
|
||||||
|
|
||||||
let children = (
|
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]) {
|
if (leaf[PLACEHOLDER_SYMBOL]) {
|
||||||
|
Reference in New Issue
Block a user