fix: restore text paste in message editor (Quill)
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions

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) <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-04-09 23:50:56 +02:00
parent d463f4b6df
commit 43c9ba6c77
2 changed files with 7 additions and 8 deletions

View File

@ -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 () {

View File

@ -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 %}