From 8c8190e2e97f9c15d5c934488cbe5ebd2572b793 Mon Sep 17 00:00:00 2001 From: JZou-Code Date: Wed, 17 Sep 2025 00:22:26 +1200 Subject: [PATCH] Desktop: Fixes #12239: Prevent the default cut action handler to avoid double deletion (#13208) --- .../app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.tsx b/packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.tsx index f67ad07187..0b7314253f 100644 --- a/packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.tsx +++ b/packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.tsx @@ -1393,10 +1393,10 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: Ref) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied async function onCut(event: any) { + event.preventDefault(); const selectedContent = editor.selection.getContent(); copyHtmlToClipboard(selectedContent); editor.insertContent(''); - event.preventDefault(); onChangeHandler(); } @@ -1444,7 +1444,7 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: Ref) => { // `compositionend` means that a user has finished entering a Chinese // (or other languages that require IME) character. editor.on(TinyMceEditorEvents.CompositionEnd, onChangeHandler); - editor.on(TinyMceEditorEvents.Cut, onCut); + editor.on(TinyMceEditorEvents.Cut, onCut, true); editor.on(TinyMceEditorEvents.JoplinChange, onChangeHandler); editor.on(TinyMceEditorEvents.Undo, onChangeHandler); editor.on(TinyMceEditorEvents.Redo, onChangeHandler);