@@ -578,14 +578,15 @@ class CsvEditorController {
578578 const htmlChunk = allRows . slice ( i , i + CHUNK_SIZE ) . map ( ( row , localR ) => {
579579 const startAbs = headerFlag ? offset + 1 : offset ;
580580 const absRow = startAbs + i + localR ;
581+ const displayIdx = i + localR + 1 ; // numbering relative to first visible data row
581582 let cells = '' ;
582583 for ( let cIdx = 0 ; cIdx < numColumns ; cIdx ++ ) {
583584 const safe = this . escapeHtml ( row [ cIdx ] || '' ) ;
584585 cells += `<td tabindex="0" style="min-width:${ Math . min ( columnWidths [ cIdx ] || 0 , 100 ) } ch;max-width:100ch;border:1px solid ${ isDark ?'#555' :'#ccc' } ;color:${ columnColors [ cIdx ] } ;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" data-row="${ absRow } " data-col="${ cIdx } ">${ safe } </td>` ;
585586 }
586587
587588 return `<tr>${
588- addSerialIndex ? `<td tabindex="0" style="min-width:4ch;max-width:4ch;border:1px solid ${ isDark ?'#555' :'#ccc' } ;color:#888;" data-row="${ absRow } " data-col="-1">${ absRow } </td>` : ''
589+ addSerialIndex ? `<td tabindex="0" style="min-width:4ch;max-width:4ch;border:1px solid ${ isDark ?'#555' :'#ccc' } ;color:#888;" data-row="${ absRow } " data-col="-1">${ displayIdx } </td>` : ''
589590 } ${ cells } </tr>`;
590591 } ) . join ( '' ) ;
591592
@@ -615,7 +616,7 @@ class CsvEditorController {
615616 bodyData . forEach ( ( row , r ) => {
616617 tableHtml += `<tr>${
617618 addSerialIndex
618- ? `<td tabindex="0" style="min-width: 4ch; max-width: 4ch; border: 1px solid ${ isDark ? '#555' : '#ccc' } ; color: #888;" data-row="${ offset + 1 + r } " data-col="-1">${ offset + 1 + r } </td>`
619+ ? `<td tabindex="0" style="min-width: 4ch; max-width: 4ch; border: 1px solid ${ isDark ? '#555' : '#ccc' } ; color: #888;" data-row="${ offset + 1 + r } " data-col="-1">${ r + 1 } </td>`
619620 : ''
620621 } `;
621622 for ( let i = 0 ; i < numColumns ; i ++ ) {
@@ -626,7 +627,7 @@ class CsvEditorController {
626627 } ) ;
627628 if ( ! chunked ) {
628629 const virtualAbs = offset + 1 + bodyData . length ;
629- const idxCell = addSerialIndex ? `<td tabindex="0" style="min-width: 4ch; max-width: 4ch; border: 1px solid ${ isDark ? '#555' : '#ccc' } ; color: #888;" data-row="${ virtualAbs } " data-col="-1">${ virtualAbs } </td>` : '' ;
630+ const idxCell = addSerialIndex ? `<td tabindex="0" style="min-width: 4ch; max-width: 4ch; border: 1px solid ${ isDark ? '#555' : '#ccc' } ; color: #888;" data-row="${ virtualAbs } " data-col="-1">${ bodyData . length + 1 } </td>` : '' ;
630631 const dataCells = Array . from ( { length : numColumns } , ( _ , i ) => `<td tabindex="0" style="min-width: ${ Math . min ( columnWidths [ i ] || 0 , 100 ) } ch; max-width: 100ch; border: 1px solid ${ isDark ? '#555' : '#ccc' } ; color: ${ columnColors [ i ] } ; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;" data-row="${ virtualAbs } " data-col="${ i } "></td>` ) . join ( '' ) ;
631632 tableHtml += `<tr>${ idxCell } ${ dataCells } </tr>` ;
632633 }
@@ -660,7 +661,7 @@ class CsvEditorController {
660661 if ( chunked ) {
661662 const startAbs = headerFlag ? offset + 1 : offset ;
662663 const virtualAbs = startAbs + allRows . length ;
663- const displayIdx = headerFlag ? virtualAbs : ( allRows . length + 1 ) ;
664+ const displayIdx = allRows . length + 1 ;
664665 const idxCell = addSerialIndex ? `<td tabindex="0" style="min-width: 4ch; max-width: 4ch; border: 1px solid ${ isDark ? '#555' : '#ccc' } ; color: #888;" data-row="${ virtualAbs } " data-col="-1">${ displayIdx } </td>` : '' ;
665666 const dataCells = Array . from ( { length : numColumns } , ( _ , i ) => `<td tabindex="0" style="min-width: ${ Math . min ( columnWidths [ i ] || 0 , 100 ) } ch; max-width: 100ch; border: 1px solid ${ isDark ? '#555' : '#ccc' } ; color: ${ columnColors [ i ] } ; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;" data-row="${ virtualAbs } " data-col="${ i } "></td>` ) . join ( '' ) ;
666667 const vrow = `<tr>${ idxCell } ${ dataCells } </tr>` ;
@@ -843,15 +844,26 @@ class CsvEditorController {
843844 return ! isNaN ( Date . parse ( value ) ) ;
844845 }
845846
847+ private isBooleanish ( value : string ) : boolean {
848+ const v = ( value ?? '' ) . trim ( ) . toLowerCase ( ) ;
849+ if ( ! v ) return false ;
850+ if ( v === 'true' || v === 'false' ) return true ;
851+ if ( v === 't' || v === 'f' ) return true ;
852+ if ( v === 'yes' || v === 'no' ) return true ;
853+ if ( v === 'y' || v === 'n' ) return true ;
854+ if ( v === 'on' || v === 'off' ) return true ;
855+ if ( v === '1' || v === '0' ) return true ;
856+ return false ;
857+ }
858+
846859 private estimateColumnDataType ( column : string [ ] ) : string {
847860 let allBoolean = true , allDate = true , allInteger = true , allFloat = true , allEmpty = true ;
848861 for ( const cell of column ) {
849862 const items = cell . split ( ',' ) . map ( item => item . trim ( ) ) ;
850863 for ( const item of items ) {
851864 if ( item === '' ) continue ;
852865 allEmpty = false ;
853- const lower = item . toLowerCase ( ) ;
854- if ( ! ( lower === 'true' || lower === 'false' ) ) allBoolean = false ;
866+ if ( ! this . isBooleanish ( item ) ) allBoolean = false ;
855867 if ( ! this . isDate ( item ) ) allDate = false ;
856868 const num = Number ( item ) ;
857869 if ( ! Number . isInteger ( num ) ) allInteger = false ;
0 commit comments