1
0
Fork 0
forked from Mirrors/gomuks

web/composer: use insertText instead of react state

This seems to be the only way to preserve the browser's native undo history
This commit is contained in:
Tulir Asokan 2024-11-02 11:16:37 +02:00
parent 8318cbdf17
commit 438b5fb737

View file

@ -278,11 +278,9 @@ const MessageComposer = () => {
input.selectionStart !== input.selectionEnd
&& (text.startsWith("http://") || text.startsWith("https://") || text.startsWith("matrix:"))
) {
setState({
text: `${state.text.slice(0, input.selectionStart)}[${
escapeMarkdown(state.text.slice(input.selectionStart, input.selectionEnd))
}](${escapeMarkdown(text)})${state.text.slice(input.selectionEnd)}`,
})
document.execCommand("insertText", false, `[${
escapeMarkdown(state.text.slice(input.selectionStart, input.selectionEnd))
}](${escapeMarkdown(text)})`)
} else {
return
}