@trustquery/browser 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/AttachmentManager.js
CHANGED
|
@@ -315,6 +315,69 @@ export default class AttachmentManager {
|
|
|
315
315
|
// Update metadata
|
|
316
316
|
attachment.metadata.headers = headers;
|
|
317
317
|
|
|
318
|
+
// Re-scan headers for matches
|
|
319
|
+
const newMatches = this.scanCSVHeaders(headers);
|
|
320
|
+
attachment.matches = newMatches;
|
|
321
|
+
|
|
322
|
+
// Update icon visibility based on matches
|
|
323
|
+
if (attachment.wrapper) {
|
|
324
|
+
const iconPlaceholder = attachment.wrapper.querySelector('.tq-attachment-icon-placeholder');
|
|
325
|
+
const existingIcon = iconPlaceholder?.querySelector('.tq-attachment-icon');
|
|
326
|
+
|
|
327
|
+
if (newMatches.length === 0 && existingIcon) {
|
|
328
|
+
// No more matches - remove the icon and collapse placeholder
|
|
329
|
+
existingIcon.remove();
|
|
330
|
+
|
|
331
|
+
// Collapse the icon placeholder by setting width to 0
|
|
332
|
+
if (iconPlaceholder) {
|
|
333
|
+
iconPlaceholder.style.width = '0';
|
|
334
|
+
iconPlaceholder.style.minWidth = '0';
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (this.options.debug) {
|
|
338
|
+
console.log('[AttachmentManager] Removed warning icon - all warnings resolved');
|
|
339
|
+
}
|
|
340
|
+
} else if (newMatches.length > 0 && !existingIcon) {
|
|
341
|
+
// New matches appeared - add icon and expand placeholder
|
|
342
|
+
const match = newMatches[0];
|
|
343
|
+
const messageState = match.intent?.handler?.['message-state'] || 'warning';
|
|
344
|
+
const iconMap = {
|
|
345
|
+
'error': 'trustquery-error.svg',
|
|
346
|
+
'warning': 'trustquery-warning.svg',
|
|
347
|
+
'info': 'trustquery-info.svg'
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
// Expand the icon placeholder back to normal width
|
|
351
|
+
if (iconPlaceholder) {
|
|
352
|
+
iconPlaceholder.style.width = '24px';
|
|
353
|
+
iconPlaceholder.style.minWidth = '24px';
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
const icon = document.createElement('img');
|
|
357
|
+
icon.className = 'tq-attachment-icon';
|
|
358
|
+
icon.src = `./assets/${iconMap[messageState] || iconMap.warning}`;
|
|
359
|
+
icon.title = `CSV column ${messageState} - click to review`;
|
|
360
|
+
|
|
361
|
+
// Handle icon click
|
|
362
|
+
icon.addEventListener('mousedown', (e) => {
|
|
363
|
+
e.preventDefault();
|
|
364
|
+
e.stopPropagation();
|
|
365
|
+
this.handleWarningClick(icon, newMatches, attachment.wrapper, fileName);
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
// Apply styles if styleManager exists
|
|
369
|
+
if (this.options.styleManager) {
|
|
370
|
+
this.options.styleManager.applyIconStyles(icon);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
iconPlaceholder?.appendChild(icon);
|
|
374
|
+
|
|
375
|
+
if (this.options.debug) {
|
|
376
|
+
console.log('[AttachmentManager] Added warning icon - new warnings detected');
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
318
381
|
if (this.options.debug) {
|
|
319
382
|
console.log('[AttachmentManager] Updated CSV column', colIndex, 'to', headers[colIndex]);
|
|
320
383
|
}
|