diff --git a/src/util/selection.ts b/src/util/selection.ts index cca1305756..fea0cbf584 100644 --- a/src/util/selection.ts +++ b/src/util/selection.ts @@ -4,6 +4,11 @@ export function insertHtmlInSelection(html: string) { const selection = window.getSelection(); if (selection?.getRangeAt && selection.rangeCount) { + // Attempt to use execCommand for undo support + if (document.execCommand && document.execCommand('insertHTML', false, html)) { + return; + } + const range = selection.getRangeAt(0); range.deleteContents();