From ed1f7c92d1f5a7cc98c285b5a06d839f6489d45a Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 14 Feb 2022 14:41:16 -0500 Subject: [PATCH] Smart select inner content after bold or italics. Fixes #497 --- .../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 5b1c8ee0..381ecb46 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);