Skip to content

Commit

Permalink
extend TokenAnnotationTool, make each line a separate table
Browse files Browse the repository at this point in the history
  • Loading branch information
fsimonjetz committed Jul 31, 2024
1 parent b29be53 commit 75075e1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 23 deletions.
51 changes: 29 additions & 22 deletions src/fragmentarium/ui/fragment/TokenAnnotationTool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ export default class TokenAnnotationTool extends Component<Props> {

displayMarkableLine({
line,
lineIndex,
numberOfColumns,
}: {
line: TextLine
lineIndex: number
numberOfColumns: number
}): JSX.Element {
return (
Expand All @@ -34,6 +36,7 @@ export default class TokenAnnotationTool extends Component<Props> {
<LineNumber line={line} />
</td>
<AnnotationLineColumns
lineIndex={lineIndex}
columns={line.columns}
maxColumns={numberOfColumns}
/>
Expand All @@ -43,29 +46,33 @@ export default class TokenAnnotationTool extends Component<Props> {

render(): JSX.Element {
const text = this.fragment.text

return (
<table>
<tbody>
{text.allLines.map((line: AbstractLine, index) => {
if (isTextLine(line)) {
return (
<this.displayMarkableLine
key={index}
line={line}
numberOfColumns={text.numberOfColumns}
/>
)
}
const LineComponent =
lineComponents.get(line.type) || DisplayControlLine
return (
<tr key={index}>
<LineComponent line={line} columns={text.numberOfColumns} />
</tr>
)
})}
</tbody>
</table>
<>
{text.allLines.map((line: AbstractLine, index) => {
const LineComponent =
lineComponents.get(line.type) || DisplayControlLine

return (
<table key={index}>
<tbody>
{isTextLine(line) ? (
<this.displayMarkableLine
key={index}
line={line}
lineIndex={index}
numberOfColumns={text.numberOfColumns}
/>
) : (
<tr key={index}>
<LineComponent line={line} columns={text.numberOfColumns} />
</tr>
)}
</tbody>
</table>
)
})}
</>
)
}
}
5 changes: 4 additions & 1 deletion src/transliteration/ui/line-tokens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ export function LineColumns({
}

export function AnnotationLineColumns({
lineIndex,
columns,
maxColumns,
}: {
lineIndex: number
columns: readonly TextLineColumn[]
maxColumns: number
}): JSX.Element {
Expand All @@ -101,7 +103,8 @@ export function AnnotationLineColumns({
key={index}
onClick={() =>
console.log(
`clicked on token ${markableToken.token.cleanValue} at index=${index}`
`clicked on token ${markableToken.token.cleanValue} at line=${lineIndex}, index=${index}`,
markableToken.token
)
}
>
Expand Down

0 comments on commit 75075e1

Please sign in to comment.