| @@ -261,9 +261,10 @@ | ||
| 261 | 261 | function formatMarkdownHeaders(text) { |
| 262 | 262 | // Handle h1 to h6 headers |
| 263 | 263 | return text.replace(/^(#{1,6})\s(.+)$/gm, function(match, hashes, content) { |
| 264 | 264 | const level = hashes.length; |
| 265 | - return `<h${level} class="chat-heading">${content}</h${level}>`; | |
| 265 | + // Apply the same color as the bot message font color | |
| 266 | + return `<h${level} class="chat-heading" style="color: inherit;">${content}</h${level}>`; | |
| 266 | 267 | }); |
| 267 | 268 | } |
| 268 | 269 | |
| 269 | 270 | // Update the linkify function to handle both URLs and markdown |
| @@ -1129,10 +1130,18 @@ | ||
| 1129 | 1130 | document.getElementById('word-upload').click(); |
| 1130 | 1131 | }); |
| 1131 | 1132 | } |
| 1132 | 1133 | |
| 1134 | +function addSafeEventListener(elementId, eventType, handler) { | |
| 1135 | + const element = document.getElementById(elementId); | |
| 1136 | + if (element) { | |
| 1137 | + element.addEventListener(eventType, handler); | |
| 1138 | + } | |
| 1139 | +} | |
| 1140 | + | |
| 1141 | + | |
| 1133 | 1142 | // PDF file input change handler |
| 1134 | -document.getElementById('pdf-upload').addEventListener('change', async function(e) { | |
| 1143 | +addSafeEventListener('pdf-upload', 'change', async function(e) { | |
| 1135 | 1144 | const file = e.target.files[0]; |
| 1136 | 1145 | |
| 1137 | 1146 | if (!file || file.type !== 'application/pdf') { |
| 1138 | 1147 | alert('Please select a valid PDF file.'); |
| @@ -1204,9 +1213,9 @@ | ||
| 1204 | 1213 | } |
| 1205 | 1214 | }); |
| 1206 | 1215 | |
| 1207 | 1216 | // Word file input change handler |
| 1208 | -document.getElementById('word-upload').addEventListener('change', async function(e) { | |
| 1217 | +addSafeEventListener('word-upload', 'change', async function(e) { | |
| 1209 | 1218 | const file = e.target.files[0]; |
| 1210 | 1219 | |
| 1211 | 1220 | if (!file || file.type !== 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') { |
| 1212 | 1221 | alert('Please select a valid Word document (.docx).'); |
| @@ -1439,21 +1448,24 @@ | ||
| 1439 | 1448 | document.addEventListener('DOMContentLoaded', function() { |
| 1440 | 1449 | checkInitialDocumentStatus(); |
| 1441 | 1450 | }); |
| 1442 | 1451 | |
| 1443 | -// Style all toolbar elements | |
| 1444 | 1452 | const toolbarElements = [ |
| 1445 | 1453 | '#mxchat-chatbot .toolbar-btn svg', |
| 1446 | 1454 | '#mxchat-chatbot .active-pdf-name', |
| 1447 | 1455 | '#mxchat-chatbot .active-word-name', |
| 1448 | 1456 | '#mxchat-chatbot .remove-pdf-btn svg', |
| 1449 | - '#mxchat-chatbot .remove-word-btn svg' | |
| 1457 | + '#mxchat-chatbot .remove-word-btn svg', | |
| 1458 | + '#mxchat-chatbot .toolbar-perplexity svg' | |
| 1450 | 1459 | ]; |
| 1451 | -$(toolbarElements.join(', ')).css({ | |
| 1452 | - 'fill': toolbarIconColor, | |
| 1453 | - 'color': toolbarIconColor | |
| 1460 | + | |
| 1461 | +toolbarElements.forEach(selector => { | |
| 1462 | + $(selector).css({ | |
| 1463 | + 'fill': toolbarIconColor, | |
| 1464 | + 'stroke': toolbarIconColor, | |
| 1465 | + 'color': toolbarIconColor | |
| 1466 | + }); | |
| 1454 | 1467 | }); |
| 1455 | - | |
| 1456 | 1468 | |
| 1457 | 1469 | |
| 1458 | 1470 | // Ensure essential elements are defined |
| 1459 | 1471 | const emailForm = document.getElementById('email-collection-form'); |