From ecf618a4d6533794dc52411ebe4529156d9f0c77 Mon Sep 17 00:00:00 2001 From: AYHD-youtube Date: Tue, 25 Nov 2025 02:38:32 -0700 Subject: [PATCH] fix: enable undo for pasted text by using execCommand --- src/util/selection.ts | 5 +++++ 1 file changed, 5 insertions(+) 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();