Firefox: fix copy from edit textarea

This commit is contained in:
Cohee 2024-10-18 12:54:26 +00:00
parent 027d710716
commit 80f91d129e
1 changed files with 4 additions and 0 deletions

View File

@ -6,6 +6,10 @@ function sanitizeInlineQuotationOnCopy() {
// STRG+C, STRG+V on firefox leads to duplicate double quotes when inline quotation elements are copied. // STRG+C, STRG+V on firefox leads to duplicate double quotes when inline quotation elements are copied.
// To work around this, take the selection and transform <q> to <span> before calling toString(). // To work around this, take the selection and transform <q> to <span> before calling toString().
document.addEventListener('copy', function (event) { document.addEventListener('copy', function (event) {
if (document.activeElement instanceof HTMLInputElement || document.activeElement instanceof HTMLTextAreaElement) {
return;
}
const selection = window.getSelection(); const selection = window.getSelection();
if (!selection.anchorNode?.parentElement.closest('.mes_text')) { if (!selection.anchorNode?.parentElement.closest('.mes_text')) {
return; return;