@trustquery/browser 0.3.1 → 0.3.2

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trustquery/browser",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Turn any textarea into an interactive trigger-based editor with inline styling",
5
5
  "type": "module",
6
6
  "main": "dist/trustquery.js",
@@ -315,6 +315,56 @@ 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
329
+ existingIcon.remove();
330
+ if (this.options.debug) {
331
+ console.log('[AttachmentManager] Removed warning icon - all warnings resolved');
332
+ }
333
+ } else if (newMatches.length > 0 && !existingIcon) {
334
+ // New matches appeared - add icon (shouldn't happen in normal flow, but handle it)
335
+ const match = newMatches[0];
336
+ const messageState = match.intent?.handler?.['message-state'] || 'warning';
337
+ const iconMap = {
338
+ 'error': 'trustquery-error.svg',
339
+ 'warning': 'trustquery-warning.svg',
340
+ 'info': 'trustquery-info.svg'
341
+ };
342
+
343
+ const icon = document.createElement('img');
344
+ icon.className = 'tq-attachment-icon';
345
+ icon.src = `./assets/${iconMap[messageState] || iconMap.warning}`;
346
+ icon.title = `CSV column ${messageState} - click to review`;
347
+
348
+ // Handle icon click
349
+ icon.addEventListener('mousedown', (e) => {
350
+ e.preventDefault();
351
+ e.stopPropagation();
352
+ this.handleWarningClick(icon, newMatches, attachment.wrapper, fileName);
353
+ });
354
+
355
+ // Apply styles if styleManager exists
356
+ if (this.options.styleManager) {
357
+ this.options.styleManager.applyIconStyles(icon);
358
+ }
359
+
360
+ iconPlaceholder?.appendChild(icon);
361
+
362
+ if (this.options.debug) {
363
+ console.log('[AttachmentManager] Added warning icon - new warnings detected');
364
+ }
365
+ }
366
+ }
367
+
318
368
  if (this.options.debug) {
319
369
  console.log('[AttachmentManager] Updated CSV column', colIndex, 'to', headers[colIndex]);
320
370
  }