mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 10:33:41 -05:00
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:
parent
8318cbdf17
commit
438b5fb737
1 changed files with 3 additions and 5 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue