reviw 0.17.1 → 0.17.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.
Files changed (2) hide show
  1. package/cli.cjs +84 -16
  2. package/package.json +1 -1
package/cli.cjs CHANGED
@@ -126,6 +126,13 @@ function sanitizeHtml(html) {
126
126
  }
127
127
 
128
128
  marked.use({
129
+ hooks: {
130
+ // テーブルをスクロールラッパーで囲む(後処理)
131
+ postprocess: function(html) {
132
+ return html.replace(/<table>/g, '<div class="table-scroll-container"><span class="scroll-hint">← scroll →</span><div class="table-scroll-wrapper"><table>')
133
+ .replace(/<\/table>/g, '</table></div></div>');
134
+ }
135
+ },
129
136
  renderer: {
130
137
  // 生HTMLブロックをサニタイズ
131
138
  html: function(token) {
@@ -2730,7 +2737,7 @@ function htmlTemplate(dataRows, cols, projectRoot, relativePath, mode, previewHt
2730
2737
  flex: 1;
2731
2738
  min-width: 0;
2732
2739
  overflow-y: auto;
2733
- overflow-x: hidden;
2740
+ overflow-x: auto;
2734
2741
  overscroll-behavior: contain;
2735
2742
  }
2736
2743
  .md-left .md-preview {
@@ -2772,8 +2779,6 @@ function htmlTemplate(dataRows, cols, projectRoot, relativePath, mode, previewHt
2772
2779
  display: block;
2773
2780
  width: 100%;
2774
2781
  height: auto;
2775
- min-width: 120px;
2776
- max-width: 250px;
2777
2782
  }
2778
2783
  .md-preview code { background: rgba(255,255,255,0.08); padding: 2px 4px; border-radius: 4px; }
2779
2784
  .md-preview pre {
@@ -2899,12 +2904,38 @@ function htmlTemplate(dataRows, cols, projectRoot, relativePath, mode, previewHt
2899
2904
  [data-theme="light"] .frontmatter-table tbody th {
2900
2905
  color: #7c3aed;
2901
2906
  }
2907
+ /* Table scroll container and indicator */
2908
+ .table-scroll-container {
2909
+ position: relative;
2910
+ margin: 16px 0;
2911
+ }
2912
+ .table-scroll-wrapper {
2913
+ overflow-x: auto;
2914
+ border-radius: 8px;
2915
+ }
2916
+ .scroll-hint {
2917
+ text-align: right;
2918
+ font-size: 12px;
2919
+ color: var(--accent);
2920
+ padding: 4px 8px;
2921
+ margin-bottom: 4px;
2922
+ opacity: 0;
2923
+ visibility: hidden;
2924
+ transition: opacity 200ms ease;
2925
+ }
2926
+ .table-scroll-container.can-scroll .scroll-hint {
2927
+ opacity: 0.8;
2928
+ visibility: visible;
2929
+ }
2930
+ .table-scroll-container.scrolled-end .scroll-hint {
2931
+ opacity: 0;
2932
+ visibility: hidden;
2933
+ }
2902
2934
  /* Markdown tables in preview */
2903
2935
  .md-preview table:not(.frontmatter-table table) {
2904
- width: 100%;
2936
+ min-width: 100%;
2937
+ width: max-content;
2905
2938
  border-collapse: collapse;
2906
- table-layout: fixed;
2907
- margin: 16px 0;
2908
2939
  border: 1px solid var(--border);
2909
2940
  border-radius: 8px;
2910
2941
  }
@@ -2916,17 +2947,12 @@ function htmlTemplate(dataRows, cols, projectRoot, relativePath, mode, previewHt
2916
2947
  vertical-align: top;
2917
2948
  word-break: break-word;
2918
2949
  overflow-wrap: anywhere;
2950
+ width: auto;
2919
2951
  }
2920
- .md-preview table:not(.frontmatter-table table) th:first-child,
2921
- .md-preview table:not(.frontmatter-table table) td:first-child {
2922
- width: 30%;
2923
- min-width: 200px;
2924
- }
2925
- .md-preview table:not(.frontmatter-table table) th:last-child,
2926
- .md-preview table:not(.frontmatter-table table) td:last-child {
2927
- width: 180px;
2928
- min-width: 180px;
2929
- max-width: 180px;
2952
+ /* Force equal column widths when colgroup is not specified */
2953
+ .md-preview table:not(.frontmatter-table table) colgroup ~ * th,
2954
+ .md-preview table:not(.frontmatter-table table) colgroup ~ * td {
2955
+ width: auto;
2930
2956
  }
2931
2957
  .md-preview table:not(.frontmatter-table table) td:has(video),
2932
2958
  .md-preview table:not(.frontmatter-table table) td:has(img) {
@@ -4036,6 +4062,48 @@ function htmlTemplate(dataRows, cols, projectRoot, relativePath, mode, previewHt
4036
4062
  themeToggle.addEventListener('click', toggleTheme);
4037
4063
  })();
4038
4064
 
4065
+ // --- Table Scroll Indicator ---
4066
+ (function initTableScrollIndicators() {
4067
+ function updateScrollIndicator(wrapper) {
4068
+ const container = wrapper.closest('.table-scroll-container');
4069
+ if (!container) return;
4070
+
4071
+ const canScroll = wrapper.scrollWidth > wrapper.clientWidth;
4072
+ const isAtEnd = wrapper.scrollLeft + wrapper.clientWidth >= wrapper.scrollWidth - 5;
4073
+
4074
+ container.classList.toggle('can-scroll', canScroll && !isAtEnd);
4075
+ container.classList.toggle('scrolled-end', isAtEnd);
4076
+ }
4077
+
4078
+ function initWrapper(wrapper) {
4079
+ updateScrollIndicator(wrapper);
4080
+ wrapper.addEventListener('scroll', () => updateScrollIndicator(wrapper));
4081
+ }
4082
+
4083
+ // Initialize existing wrappers
4084
+ document.querySelectorAll('.table-scroll-wrapper').forEach(initWrapper);
4085
+
4086
+ // Watch for dynamically added wrappers
4087
+ const observer = new MutationObserver((mutations) => {
4088
+ mutations.forEach((mutation) => {
4089
+ mutation.addedNodes.forEach((node) => {
4090
+ if (node.nodeType === 1) {
4091
+ if (node.classList?.contains('table-scroll-wrapper')) {
4092
+ initWrapper(node);
4093
+ }
4094
+ node.querySelectorAll?.('.table-scroll-wrapper').forEach(initWrapper);
4095
+ }
4096
+ });
4097
+ });
4098
+ });
4099
+ observer.observe(document.body, { childList: true, subtree: true });
4100
+
4101
+ // Update on resize
4102
+ window.addEventListener('resize', () => {
4103
+ document.querySelectorAll('.table-scroll-wrapper').forEach(updateScrollIndicator);
4104
+ });
4105
+ })();
4106
+
4039
4107
  // --- History Management ---
4040
4108
  // History is now server-side (file-based), HISTORY_DATA is provided by server
4041
4109
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reviw",
3
- "version": "0.17.1",
3
+ "version": "0.17.2",
4
4
  "description": "Lightweight file reviewer with in-browser comments for CSV, TSV, Markdown, and Git diffs.",
5
5
  "type": "module",
6
6
  "bin": {