Smart select inner content after bold or italics. Fixes #497 (#577)

This commit is contained in:
Dessalines 2022-02-14 14:43:07 -05:00 committed by GitHub
parent a1125ddbf0
commit 99f652422f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -459,6 +459,21 @@ export class MarkdownTextArea extends Component<
} }
this.contentChange(); this.contentChange();
this.setState(this.state); 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(() => { setTimeout(() => {
autosize.update(textarea); autosize.update(textarea);
}, 10); }, 10);