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 input.selectionStart !== input.selectionEnd
&& (text.startsWith("http://") || text.startsWith("https://") || text.startsWith("matrix:")) && (text.startsWith("http://") || text.startsWith("https://") || text.startsWith("matrix:"))
) { ) {
setState({ document.execCommand("insertText", false, `[${
text: `${state.text.slice(0, input.selectionStart)}[${
escapeMarkdown(state.text.slice(input.selectionStart, input.selectionEnd)) escapeMarkdown(state.text.slice(input.selectionStart, input.selectionEnd))
}](${escapeMarkdown(text)})${state.text.slice(input.selectionEnd)}`, }](${escapeMarkdown(text)})`)
})
} else { } else {
return return
} }