reviw 0.17.0 → 0.17.1

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.
Files changed (2) hide show
  1. package/cli.cjs +46 -5
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -159,7 +159,8 @@ marked.use({
159
159
  if (videoExtensions.test(href)) {
160
160
  // For videos, render as video element with controls and thumbnail preview
161
161
  var displayText = text || href.split('/').pop();
162
- return '<video src="' + escapeHtmlForXss(href) + '" controls preload="metadata" class="video-preview"' + titleAttr + '>' +
162
+ var dataAlt = text ? ' data-alt="' + escapeHtmlForXss(text) + '"' : "";
163
+ return '<video src="' + escapeHtmlForXss(href) + '" controls preload="metadata" class="video-preview"' + titleAttr + dataAlt + '>' +
163
164
  '<a href="' + escapeHtmlForXss(href) + '">📹' + escapeHtmlForXss(displayText) + '</a></video>';
164
165
  }
165
166
  return '<img src="' + escapeHtmlForXss(href) + '"' + altAttr + titleAttr + '>';
@@ -2730,6 +2731,7 @@ function htmlTemplate(dataRows, cols, projectRoot, relativePath, mode, previewHt
2730
2731
  min-width: 0;
2731
2732
  overflow-y: auto;
2732
2733
  overflow-x: hidden;
2734
+ overscroll-behavior: contain;
2733
2735
  }
2734
2736
  .md-left .md-preview {
2735
2737
  max-height: none;
@@ -2739,6 +2741,7 @@ function htmlTemplate(dataRows, cols, projectRoot, relativePath, mode, previewHt
2739
2741
  min-width: 0;
2740
2742
  overflow-y: auto;
2741
2743
  overflow-x: auto;
2744
+ overscroll-behavior: contain;
2742
2745
  }
2743
2746
  .md-right .table-box {
2744
2747
  max-width: none;
@@ -6117,8 +6120,46 @@ function htmlTemplate(dataRows, cols, projectRoot, relativePath, mode, previewHt
6117
6120
  .trim();
6118
6121
  }
6119
6122
 
6120
- // Helper: find matching source line for text
6121
- function findSourceLine(text) {
6123
+ // Helper: find matching source line for text or element
6124
+ // If element is provided, also searches by media src attributes
6125
+ function findSourceLine(text, element = null) {
6126
+ // First, try to find by media src (images, videos) in the element
6127
+ if (element) {
6128
+ const mediaElements = element.querySelectorAll('img, video');
6129
+ for (const m of mediaElements) {
6130
+ const src = m.getAttribute('src');
6131
+ if (!src) continue;
6132
+
6133
+ const fileName = src.split('/').pop();
6134
+ const alt = m.getAttribute('alt') || m.getAttribute('data-alt') || m.getAttribute('title') || '';
6135
+
6136
+ // Search for lines containing this media file (![...](path) syntax)
6137
+ // Prioritize exact match with alt text
6138
+ let bestMatch = -1;
6139
+ for (let i = 0; i < DATA.length; i++) {
6140
+ const lineText = (DATA[i][0] || '');
6141
+ if (!lineText.includes(fileName)) continue;
6142
+
6143
+ // Check if it's an image/video markdown syntax
6144
+ const match = lineText.match(/!\\[([^\\]]*)\\]\\(([^)]+)\\)/);
6145
+ if (!match) continue;
6146
+
6147
+ const [, mdAlt, mdPath] = match;
6148
+
6149
+ // Exact path match
6150
+ if (mdPath.includes(fileName)) {
6151
+ // If alt text matches exactly, this is definitely the right one
6152
+ if (alt && mdAlt && mdAlt === alt) {
6153
+ return i + 1;
6154
+ }
6155
+ // Otherwise, remember as fallback (prefer first match)
6156
+ if (bestMatch === -1) bestMatch = i + 1;
6157
+ }
6158
+ }
6159
+ if (bestMatch !== -1) return bestMatch;
6160
+ }
6161
+ }
6162
+
6122
6163
  if (!text) return -1;
6123
6164
  const normalized = text.trim().replace(/\\s+/g, ' ').slice(0, 100);
6124
6165
  if (!normalized) return -1;
@@ -6358,9 +6399,9 @@ function htmlTemplate(dataRows, cols, projectRoot, relativePath, mode, previewHt
6358
6399
  const target = e.target.closest('p, h1, h2, h3, h4, h5, h6, li, blockquote, td, th');
6359
6400
  if (!target) return;
6360
6401
 
6361
- // Use table-specific search for table cells
6402
+ // Use table-specific search for table cells, otherwise use element-aware search
6362
6403
  const isTableCell = target.tagName === 'TD' || target.tagName === 'TH';
6363
- const line = isTableCell ? findTableSourceLine(target.textContent) : findSourceLine(target.textContent);
6404
+ const line = isTableCell ? findTableSourceLine(target.textContent) : findSourceLine(target.textContent, target);
6364
6405
  if (line <= 0) return;
6365
6406
 
6366
6407
  e.preventDefault();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reviw",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "description": "Lightweight file reviewer with in-browser comments for CSV, TSV, Markdown, and Git diffs.",
5
5
  "type": "module",
6
6
  "bin": {