@@ -248,6 +248,55 @@ export function NoteContent({
248248 border-radius: 3px;
249249 }
250250
251+ /* Table wrapper for horizontal scroll */
252+ .table-wrapper {
253+ overflow-x: auto;
254+ -webkit-overflow-scrolling: touch;
255+ margin: 12px 0;
256+ }
257+
258+ /* Tables */
259+ table {
260+ border-collapse: collapse;
261+ width: auto;
262+ min-width: 100%;
263+ table-layout: auto;
264+ }
265+
266+ th, td {
267+ border: 1px solid ${ theme . colors . border } !important;
268+ padding: 8px 12px !important;
269+ vertical-align: top;
270+ font-size: 16px !important;
271+ white-space: nowrap;
272+ }
273+
274+ /* Allow text wrapping for cells with longer content */
275+ td p, th p {
276+ white-space: normal;
277+ min-width: 120px;
278+ }
279+
280+ th {
281+ background-color: ${ theme . isDark ? 'rgba(255, 255, 255, 0.05)' : theme . colors . muted } !important;
282+ font-weight: 600;
283+ }
284+
285+ /* Force consistent font-size inside table cells */
286+ th *, td *,
287+ th p, td p,
288+ th span, td span {
289+ font-size: 16px !important;
290+ margin: 0 !important;
291+ }
292+
293+ /* Remove p margins inside table cells and force inherit alignment */
294+ th p, td p,
295+ th > p, td > p,
296+ table th p, table td p {
297+ text-align: inherit !important;
298+ }
299+
251300 .note-header {
252301 padding: 8px 16px 0 16px;
253302 }
@@ -359,6 +408,56 @@ ${note.content}
359408 document.querySelectorAll('pre code').forEach((block) => {
360409 hljs.highlightElement(block);
361410 });
411+
412+ // Fix tables: wrap in scrollable div and normalize styling
413+ document.querySelectorAll('table').forEach((table) => {
414+ // Wrap table in scrollable div if not already wrapped
415+ if (!table.parentElement.classList.contains('table-wrapper')) {
416+ const wrapper = document.createElement('div');
417+ wrapper.className = 'table-wrapper';
418+ table.parentNode.insertBefore(wrapper, table);
419+ wrapper.appendChild(table);
420+ }
421+
422+ // Remove inline styles from table
423+ table.removeAttribute('style');
424+
425+ // Remove colgroup widths
426+ table.querySelectorAll('col').forEach((col) => {
427+ col.removeAttribute('style');
428+ col.removeAttribute('width');
429+ });
430+ });
431+
432+ // Fix table cell alignment and remove fixed widths
433+ document.querySelectorAll('th, td').forEach((cell) => {
434+ // Remove colwidth attribute
435+ cell.removeAttribute('colwidth');
436+
437+ // Get alignment before removing style
438+ const style = cell.getAttribute('style') || '';
439+ const alignMatch = style.match(/text-align:\\s*(left|center|right|justify)/i);
440+
441+ // Remove all inline styles (including width)
442+ cell.removeAttribute('style');
443+
444+ // Re-apply alignment if it was set
445+ if (alignMatch) {
446+ const alignment = alignMatch[1];
447+ cell.style.textAlign = alignment;
448+ cell.querySelectorAll('p').forEach((p) => {
449+ p.style.textAlign = alignment;
450+ });
451+ }
452+
453+ // Remove inline styles from all child elements
454+ cell.querySelectorAll('*').forEach((el) => {
455+ if (el.style) {
456+ el.style.fontSize = '';
457+ el.style.width = '';
458+ }
459+ });
460+ });
362461 ` }
363462
364463 // Send content height to React Native
@@ -480,6 +579,8 @@ ${note.content}
480579 }
481580 } else if ( data . type === 'error' ) {
482581 console . error ( 'WebView error:' , data . error ) ;
582+ } else if ( data . type === 'debug' ) {
583+ console . log ( 'DEBUG TABLE HTML:' , data . table ) ;
483584 }
484585 } catch {
485586 // Ignore parse errors
0 commit comments