From f700f846a0dda22ca6d1eba7efda07893773c76c Mon Sep 17 00:00:00 2001 From: SctEdwin <72842751+sctEdwin@users.noreply.github.com> Date: Fri, 19 Mar 2021 17:08:22 +0000 Subject: [PATCH 01/11] fix hiragana katakana from being treated as emoji --- src/components/Messages/MessageText/emoji.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Messages/MessageText/emoji.js b/src/components/Messages/MessageText/emoji.js index 28fc7cd35..9777311b7 100644 --- a/src/components/Messages/MessageText/emoji.js +++ b/src/components/Messages/MessageText/emoji.js @@ -1,6 +1,6 @@ import shortnameToUnicode from '../../Emoji/shortnameToUnicode'; -const emojiUnicode = '\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff]'; // unicode emoji from https://www.regextester.com/106421 +const emojiUnicode = '\u00a9|\u00ae|[\u2000-\u3039]|[\u3100-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff]'; // unicode emoji from https://www.regextester.com/106421 const emojiRanges = [ emojiUnicode, // unicode emoji from https://www.regextester.com/106421 From 59cdaa3f60676ba62a8465cb5cad8ff6d01a9d2b Mon Sep 17 00:00:00 2001 From: SctEdwin <72842751+sctEdwin@users.noreply.github.com> Date: Fri, 19 Mar 2021 17:36:53 +0000 Subject: [PATCH 02/11] fix ime conversion problem --- src/components/Composer/index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/components/Composer/index.js b/src/components/Composer/index.js index c95b42649..7187d8cab 100644 --- a/src/components/Composer/index.js +++ b/src/components/Composer/index.js @@ -63,6 +63,9 @@ export class Composer extends Component { } handleInput = (onChange) => () => { + if (inputLock) { + return; + } onChange && onChange(sanitize(this.el.innerText)); } @@ -247,6 +250,17 @@ export class Composer extends Component { onClick: this.handleClick, } )} + + onCompositionStart={(e)=>{ + inputLock = true; + }} + + onCompositionEnd={(e)=>{ + inputLock = false; + onChange && onChange(this.el.innerText); + }} + + className={createClassName(styles, 'composer__input')} /> {post} From 59913b6f9469c8d309578d45e1116eec5d41f9de Mon Sep 17 00:00:00 2001 From: SctEdwin <72842751+sctEdwin@users.noreply.github.com> Date: Mon, 22 Mar 2021 09:23:43 +0000 Subject: [PATCH 03/11] inputLock as state --- src/components/Composer/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/Composer/index.js b/src/components/Composer/index.js index 7187d8cab..379de5cbf 100644 --- a/src/components/Composer/index.js +++ b/src/components/Composer/index.js @@ -58,12 +58,13 @@ const replaceCaret = (el) => { }; export class Composer extends Component { + handleRef = (el) => { this.el = el; } handleInput = (onChange) => () => { - if (inputLock) { + if (this.state.inputLock) { return; } onChange && onChange(sanitize(this.el.innerText)); @@ -150,6 +151,9 @@ export class Composer extends Component { constructor(props) { super(props); + this.state = { + inputLock: false + } this.value = this.props.value; this.handleNotifyEmojiSelect = this.handleNotifyEmojiSelect.bind(this); @@ -252,11 +256,11 @@ export class Composer extends Component { )} onCompositionStart={(e)=>{ - inputLock = true; + this.state.inputLock = true; }} onCompositionEnd={(e)=>{ - inputLock = false; + this.state.inputLock = false; onChange && onChange(this.el.innerText); }} From 95e1c22a6f0710007d595464e999a71629f7d5d4 Mon Sep 17 00:00:00 2001 From: SctEdwin <72842751+sctEdwin@users.noreply.github.com> Date: Wed, 24 Mar 2021 15:54:53 +0000 Subject: [PATCH 04/11] do not directly mutate state setState outside to keep render function pure --- src/components/Composer/index.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/Composer/index.js b/src/components/Composer/index.js index 379de5cbf..721ff968b 100644 --- a/src/components/Composer/index.js +++ b/src/components/Composer/index.js @@ -151,9 +151,9 @@ export class Composer extends Component { constructor(props) { super(props); - this.state = { + this.state = { inputLock: false - } + }; this.value = this.props.value; this.handleNotifyEmojiSelect = this.handleNotifyEmojiSelect.bind(this); @@ -235,7 +235,13 @@ export class Composer extends Component { return 0; } + handleInputLock(isNot){ + this.setState({ inputLock: isNot }); + return 0; + } + render = ({ pre, post, value, placeholder, onChange, onSubmit, onUpload, className, style }) => ( +
{pre}
{ - this.state.inputLock = true; + this.handleInputLock(true); }} onCompositionEnd={(e)=>{ - this.state.inputLock = false; + this.handleInputLock(false); onChange && onChange(this.el.innerText); }} From ff1bfbd0901ac95069e4fc529b3ab6f500f27f83 Mon Sep 17 00:00:00 2001 From: sctEdwin <72842751+sctEdwin@users.noreply.github.com> Date: Thu, 15 Apr 2021 09:02:49 +0900 Subject: [PATCH 05/11] Update src/components/Composer/index.js Co-authored-by: Rafael Ferreira --- src/components/Composer/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Composer/index.js b/src/components/Composer/index.js index 721ff968b..7439b72a1 100644 --- a/src/components/Composer/index.js +++ b/src/components/Composer/index.js @@ -152,7 +152,7 @@ export class Composer extends Component { constructor(props) { super(props); this.state = { - inputLock: false + inputLock: false }; this.value = this.props.value; this.handleNotifyEmojiSelect = this.handleNotifyEmojiSelect.bind(this); From 6217bee76d9ec3c7deaf0c9c3e41f5153b75fa09 Mon Sep 17 00:00:00 2001 From: sctEdwin <72842751+sctEdwin@users.noreply.github.com> Date: Thu, 15 Apr 2021 09:03:05 +0900 Subject: [PATCH 06/11] Update src/components/Composer/index.js Co-authored-by: Rafael Ferreira --- src/components/Composer/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Composer/index.js b/src/components/Composer/index.js index 7439b72a1..cf919d287 100644 --- a/src/components/Composer/index.js +++ b/src/components/Composer/index.js @@ -262,7 +262,7 @@ export class Composer extends Component { )} - onCompositionStart={(e)=>{ + onCompositionStart={() => { this.handleInputLock(true); }} From 3c0c3b2ef4cbdd88f8641b90de3eaa27da334ada Mon Sep 17 00:00:00 2001 From: sctEdwin <72842751+sctEdwin@users.noreply.github.com> Date: Thu, 15 Apr 2021 09:03:13 +0900 Subject: [PATCH 07/11] Update src/components/Composer/index.js Co-authored-by: Rafael Ferreira --- src/components/Composer/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Composer/index.js b/src/components/Composer/index.js index cf919d287..2f5fdb53f 100644 --- a/src/components/Composer/index.js +++ b/src/components/Composer/index.js @@ -266,7 +266,7 @@ export class Composer extends Component { this.handleInputLock(true); }} - onCompositionEnd={(e)=>{ + onCompositionEnd={() => { this.handleInputLock(false); onChange && onChange(this.el.innerText); }} From 6800d428e93f1f46f31cd3172d4994cecc6c03d3 Mon Sep 17 00:00:00 2001 From: sctEdwin <72842751+sctEdwin@users.noreply.github.com> Date: Thu, 15 Apr 2021 09:03:37 +0900 Subject: [PATCH 08/11] Update src/components/Composer/index.js Co-authored-by: Rafael Ferreira --- src/components/Composer/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Composer/index.js b/src/components/Composer/index.js index 2f5fdb53f..2ca3b6f74 100644 --- a/src/components/Composer/index.js +++ b/src/components/Composer/index.js @@ -235,7 +235,7 @@ export class Composer extends Component { return 0; } - handleInputLock(isNot){ + handleInputLock(isNot) { this.setState({ inputLock: isNot }); return 0; } From 4a4fed92c884734563fc3b96596d4734b8bdf264 Mon Sep 17 00:00:00 2001 From: sctEdwin <72842751+sctEdwin@users.noreply.github.com> Date: Thu, 15 Apr 2021 09:03:47 +0900 Subject: [PATCH 09/11] Update src/components/Composer/index.js Co-authored-by: Rafael Ferreira --- src/components/Composer/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Composer/index.js b/src/components/Composer/index.js index 2ca3b6f74..0b02d932c 100644 --- a/src/components/Composer/index.js +++ b/src/components/Composer/index.js @@ -58,7 +58,6 @@ const replaceCaret = (el) => { }; export class Composer extends Component { - handleRef = (el) => { this.el = el; } From e77f08ed60421b7b54ec4149539f5e2b48298800 Mon Sep 17 00:00:00 2001 From: SctEdwin <72842751+sctEdwin@users.noreply.github.com> Date: Mon, 19 Apr 2021 09:50:45 +0000 Subject: [PATCH 10/11] fixed ESLint error --- src/components/Composer/index.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/components/Composer/index.js b/src/components/Composer/index.js index 721ff968b..650d9f9ff 100644 --- a/src/components/Composer/index.js +++ b/src/components/Composer/index.js @@ -58,7 +58,6 @@ const replaceCaret = (el) => { }; export class Composer extends Component { - handleRef = (el) => { this.el = el; } @@ -151,8 +150,8 @@ export class Composer extends Component { constructor(props) { super(props); - this.state = { - inputLock: false + this.state = { + inputLock: false, }; this.value = this.props.value; this.handleNotifyEmojiSelect = this.handleNotifyEmojiSelect.bind(this); @@ -235,7 +234,7 @@ export class Composer extends Component { return 0; } - handleInputLock(isNot){ + handleInputLock(isNot) { this.setState({ inputLock: isNot }); return 0; } @@ -260,13 +259,12 @@ export class Composer extends Component { onClick: this.handleClick, } )} - - onCompositionStart={(e)=>{ + onCompositionStart={() => { this.handleInputLock(true); }} - onCompositionEnd={(e)=>{ + onCompositionEnd={() => { this.handleInputLock(false); onChange && onChange(this.el.innerText); }} From aa2e69e2472c4de5b225403cda3e19144c600f28 Mon Sep 17 00:00:00 2001 From: SctEdwin <72842751+sctEdwin@users.noreply.github.com> Date: Tue, 20 Apr 2021 17:21:51 +0000 Subject: [PATCH 11/11] improve naming 2 --- src/components/Composer/index.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/components/Composer/index.js b/src/components/Composer/index.js index 48f01c102..19ac7ed1d 100644 --- a/src/components/Composer/index.js +++ b/src/components/Composer/index.js @@ -150,13 +150,8 @@ export class Composer extends Component { constructor(props) { super(props); -<<<<<<< HEAD this.state = { inputLock: false, -======= - this.state = { - inputLock: false ->>>>>>> 4a4fed92c884734563fc3b96596d4734b8bdf264 }; this.value = this.props.value; this.handleNotifyEmojiSelect = this.handleNotifyEmojiSelect.bind(this);