fix(messages): prevent double image paste in Quill editor
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
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
Use stopImmediatePropagation + capture phase to prevent Quill's built-in clipboard handler from also inserting the image as base64. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
9c296644f7
commit
73d9de8c9c
@ -677,18 +677,19 @@
|
||||
.catch(function() { alert('Błąd połączenia'); });
|
||||
}
|
||||
|
||||
/* Handle paste with images (screenshots) */
|
||||
/* Handle paste with images (screenshots) — capture phase to beat Quill's handler */
|
||||
quill.root.addEventListener('paste', function(e) {
|
||||
var items = (e.clipboardData || {}).items || [];
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
if (items[i].type.indexOf('image') !== -1) {
|
||||
e.stopImmediatePropagation();
|
||||
e.preventDefault();
|
||||
var file = items[i].getAsFile();
|
||||
if (file) uploadImage(file);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}, true);
|
||||
|
||||
/* Sync Quill content to hidden textarea on every change */
|
||||
var textarea = document.getElementById('content');
|
||||
|
||||
@ -636,13 +636,14 @@
|
||||
var items = (e.clipboardData || {}).items || [];
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
if (items[i].type.indexOf('image') !== -1) {
|
||||
e.stopImmediatePropagation();
|
||||
e.preventDefault();
|
||||
var file = items[i].getAsFile();
|
||||
if (file) uploadImage(file);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}, true);
|
||||
|
||||
var textarea = document.getElementById('reply-content');
|
||||
quill.on('text-change', function() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user