From b23386d35fc3127d7ec2ecbfa279f2b3a623134c Mon Sep 17 00:00:00 2001 From: githoniel <githoniel88@gmail.com> Date: Thu, 1 Apr 2021 16:45:30 +0800 Subject: [PATCH 1/5] fix ime double when apply mark --- packages/slate-react/src/components/leaf.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/slate-react/src/components/leaf.tsx b/packages/slate-react/src/components/leaf.tsx index 21e064af86..39165424a6 100644 --- a/packages/slate-react/src/components/leaf.tsx +++ b/packages/slate-react/src/components/leaf.tsx @@ -43,7 +43,13 @@ const Leaf = (props: { }, [placeholderRef]) let children = ( - <String isLast={isLast} leaf={leaf} parent={parent} text={text} /> + <String + key={Math.random()} + isLast={isLast} + leaf={leaf} + parent={parent} + text={text} + /> ) if (leaf[PLACEHOLDER_SYMBOL]) { From 66727f4905957bac5e8b1d65f88d717b62ddad51 Mon Sep 17 00:00:00 2001 From: githoniel <githoniel88@gmail.com> Date: Thu, 1 Apr 2021 16:46:35 +0800 Subject: [PATCH 2/5] add changeset --- .changeset/lovely-walls-knock.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/lovely-walls-knock.md diff --git a/.changeset/lovely-walls-knock.md b/.changeset/lovely-walls-knock.md new file mode 100644 index 0000000000..edf7809038 --- /dev/null +++ b/.changeset/lovely-walls-knock.md @@ -0,0 +1,5 @@ +--- +'slate-react': major +--- + +refresh String element to avoid double input using IME From 308574af259cfece895ae103ace565468be9bf25 Mon Sep 17 00:00:00 2001 From: githoniel <githoniel88@gmail.com> Date: Fri, 2 Apr 2021 10:31:23 +0800 Subject: [PATCH 3/5] refactor to use auto-incrementing key and add comments for it --- packages/slate-react/src/components/leaf.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/slate-react/src/components/leaf.tsx b/packages/slate-react/src/components/leaf.tsx index 39165424a6..0d09ea99b4 100644 --- a/packages/slate-react/src/components/leaf.tsx +++ b/packages/slate-react/src/components/leaf.tsx @@ -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. */ @@ -44,7 +47,7 @@ const Leaf = (props: { let children = ( <String - key={Math.random()} + key={keyForString++} isLast={isLast} leaf={leaf} parent={parent} From 4b60bcee8247a1b848a4bf6dbb1474b81f8aa17b Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor <ian@ianstormtaylor.com> Date: Tue, 13 Apr 2021 10:41:05 -0400 Subject: [PATCH 4/5] Update lovely-walls-knock.md --- .changeset/lovely-walls-knock.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/lovely-walls-knock.md b/.changeset/lovely-walls-knock.md index edf7809038..dd96c0a2e2 100644 --- a/.changeset/lovely-walls-knock.md +++ b/.changeset/lovely-walls-knock.md @@ -2,4 +2,4 @@ 'slate-react': major --- -refresh String element to avoid double input using IME +Fixed a bug that resulted in doubly-input characters when using an IME. From 9208676c7b411ead3cd27e6f8c2c0a60d1b5a8a1 Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor <ian@ianstormtaylor.com> Date: Tue, 13 Apr 2021 10:41:12 -0400 Subject: [PATCH 5/5] Update lovely-walls-knock.md --- .changeset/lovely-walls-knock.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/lovely-walls-knock.md b/.changeset/lovely-walls-knock.md index dd96c0a2e2..b949103856 100644 --- a/.changeset/lovely-walls-knock.md +++ b/.changeset/lovely-walls-knock.md @@ -1,5 +1,5 @@ --- -'slate-react': major +'slate-react': patch --- Fixed a bug that resulted in doubly-input characters when using an IME.