fix: pasted emails are sent with the same text repeated many times (#31890)

With Rich Text Input for Chat on, pasting an HTML email or newsletter into the chat input looked fine, but the sent message repeated the same text over and over as Markdown table rows. These emails are laid out with tables nested inside other tables, and the content of each inner table was counted again for every table around it. Pasted content is now sent once, and regular tables are unaffected.

Fixes #24657
This commit is contained in:
Classic298 2026-10-05 04:46:33 +02:00 • committed by GitHub
parent 808b90c031
commit c5dac0070d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -66,13 +66,13 @@
filter: 'table',
replacement: function (content, node) {
// Extract rows
const rows = Array.from(node.querySelectorAll('tr'));
const rows = Array.from(node.rows);
if (rows.length === 0) return content;
let markdown = '\n';
rows.forEach((row, rowIndex) => {
const cells = Array.from(row.querySelectorAll('th, td'));
const cells = Array.from(row.cells);
const cellContents = cells.map((cell) => {
// Get the text content and clean it up
let cellContent = turndownService.turndown(cell.innerHTML).trim();