Skip to content

Commit

Permalink
replace lineAccFromColumns with annotationLineAccFromColumns
Browse files Browse the repository at this point in the history
  • Loading branch information
fsimonjetz committed Jul 31, 2024
1 parent 8747a5f commit 6b48a24
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
16 changes: 16 additions & 0 deletions src/transliteration/domain/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ export function lineAccFromColumns({
}, new LineAccumulator())
}

export function annotationLineAccFromColumns(
columns: readonly TextLineColumn[]
): LineAccumulator {
return columns.reduce((acc: LineAccumulator, column) => {
acc.addColumn(column.span)
column.content.reduce(
(acc: LineAccumulator, token: Token, index: number) => {
acc.addColumnToken(token, index, false, false, false, {}, [], true)
return acc
},
acc
)
return acc
}, new LineAccumulator())
}

export function numberOfColumns(columns: readonly TextLineColumn[]): number {
return _(columns)
.map((column) => column.span ?? defaultSpan)
Expand Down
27 changes: 14 additions & 13 deletions src/transliteration/ui/line-tokens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from './LineLemmasContext'
import { ColumnData, LineAccumulator } from './LineAccumulator'
import {
annotationLineAccFromColumns,
lineAccFromColumns,
TextLineColumn,
} from 'transliteration/domain/columns'
Expand Down Expand Up @@ -90,24 +91,24 @@ export function AnnotationLineColumns({
columns: readonly TextLineColumn[]
maxColumns: number
}): JSX.Element {
const lineAccumulator = lineAccFromColumns({
columns,
highlightLemmas: [],
isInPopover: true,
})
const lineAccumulator = annotationLineAccFromColumns(columns)

return (
<>
{lineAccumulator.columns.map((column: ColumnData, index: number) => (
<td key={index} colSpan={column.span ?? maxColumns}>
{column.content.map((tokenComponent, index) => (
<span
key={index}
onClick={() => console.log(`clicked on token at index=${index}`)}
>
{tokenComponent}
</span>
))}
{column.content.map((tokenComponent, index) => {
return (
<span
key={index}
onClick={() =>
console.log(`clicked on token at index=${index}`)
}
>
{tokenComponent}
</span>
)
})}
</td>
))}
</>
Expand Down

0 comments on commit 6b48a24

Please sign in to comment.