From 43c9ba6c77ac8448021559ee0e3689c20df18c42 Mon Sep 17 00:00:00 2001 From: Maciej Pienczyn Date: Thu, 9 Apr 2026 23:50:56 +0200 Subject: [PATCH] fix: restore text paste in message editor (Quill) The clipboard.onPaste override broke text pasting in Quill 2.x where this internal API is no longer public. Replaced with a DOM paste event listener on quill.root that only intercepts image pastes and lets Quill handle text paste natively. Co-Authored-By: Claude Opus 4.6 (1M context) --- static/js/conversations.js | 13 ++++++------- templates/messages/conversations.html | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/static/js/conversations.js b/static/js/conversations.js index d5fc442..aaef514 100644 --- a/static/js/conversations.js +++ b/static/js/conversations.js @@ -1289,23 +1289,22 @@ input.click(); }); - // Intercept paste at Quill's clipboard module level - var originalPaste = state.quill.clipboard.onPaste; - state.quill.clipboard.onPaste = function(e) { + // Intercept paste — only handle images, let Quill handle text natively + state.quill.root.addEventListener('paste', function(e) { var clipboardData = e.clipboardData || window.clipboardData; if (clipboardData && clipboardData.items) { for (var i = 0; i < clipboardData.items.length; i++) { if (clipboardData.items[i].type.indexOf('image') !== -1) { e.preventDefault(); + e.stopPropagation(); var file = clipboardData.items[i].getAsFile(); if (file) Composer.uploadAndInsertImage(file); - return; // Don't call original paste + return; } } } - // No image — let Quill handle text paste normally - if (originalPaste) originalPaste.call(this, e); - }; + // Text paste — do nothing, Quill handles it natively + }, true); // Typing indicator state.quill.on('text-change', function () { diff --git a/templates/messages/conversations.html b/templates/messages/conversations.html index 48449b2..f536c5e 100644 --- a/templates/messages/conversations.html +++ b/templates/messages/conversations.html @@ -326,7 +326,7 @@ window.__CSRF_TOKEN__ = '{{ csrf_token() }}'; // Load conversations.js after data is set (function() { var s = document.createElement('script'); - s.src = '{{ url_for("static", filename="js/conversations.js") }}?v=27'; + s.src = '{{ url_for("static", filename="js/conversations.js") }}?v=28'; document.body.appendChild(s); })(); {% endblock %}