diff --git a/frontend/src/components/DocumentChunks.tsx b/frontend/src/components/DocumentChunks.tsx index d2c402a9..9f3f639f 100644 --- a/frontend/src/components/DocumentChunks.tsx +++ b/frontend/src/components/DocumentChunks.tsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect, useRef } from 'react'; +import React, { useState, useEffect } from 'react'; import { useSelector } from 'react-redux'; import { useTranslation } from 'react-i18next'; import { selectToken } from '../preferences/preferenceSlice'; @@ -15,6 +15,67 @@ import { ChunkType } from '../settings/types'; import EditIcon from '../assets/edit.svg'; import Pagination from './DocumentPagination'; +interface LineNumberedTextareaProps { + value: string; + onChange: (value: string) => void; + placeholder?: string; + ariaLabel?: string; + className?: string; +} + +const LineNumberedTextarea: React.FC = ({ + value, + onChange, + placeholder, + ariaLabel, + className = '' +}) => { + const handleChange = (e: React.ChangeEvent) => { + onChange(e.target.value); + }; + + const lineHeight = 19.93; + const contentLines = value.split('\n').length; + const minLinesForDisplay = Math.ceil((typeof window !== 'undefined' ? window.innerHeight - 300 : 600) / lineHeight); + const totalLines = Math.max(contentLines, minLinesForDisplay); + + return ( +
+
+ {Array.from({ length: totalLines }, (_, i) => ( +
+ {i + 1} +
+ ))} +
+ -
- - -
- - +
+
) : editingChunk && ( @@ -365,13 +411,12 @@ const DocumentChunks: React.FC = ({ {editingChunk.metadata.token_count ? editingChunk.metadata.token_count.toLocaleString() : '-'} tokens -
- + onChange={setEditingText} + ariaLabel={t('modals.chunk.promptText')} + />