From 99f652422f7d3a25490ef938f0f85cce48d121ce Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 14 Feb 2022 14:43:07 -0500 Subject: [PATCH] Smart select inner content after bold or italics. Fixes #497 (#577) --- .../components/common/markdown-textarea.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/shared/components/common/markdown-textarea.tsx b/src/shared/components/common/markdown-textarea.tsx index 5b1c8ee..381ecb4 100644 --- a/src/shared/components/common/markdown-textarea.tsx +++ b/src/shared/components/common/markdown-textarea.tsx @@ -459,6 +459,21 @@ export class MarkdownTextArea extends Component< } this.contentChange(); this.setState(this.state); + + textarea.focus(); + + if (start !== end) { + textarea.setSelectionRange( + start + beforeChars.length, + end + afterChars.length + ); + } else { + textarea.setSelectionRange( + start + beforeChars.length, + end + emptyChars.length + afterChars.length + ); + } + setTimeout(() => { autosize.update(textarea); }, 10); -- 2.44.1