import React, { useState, useEffect } from 'react'; import { useSelector } from 'react-redux'; import { useTranslation } from 'react-i18next'; import { selectToken } from '../preferences/preferenceSlice'; import { useDarkTheme, useLoaderState, useMediaQuery } from '../hooks'; import userService from '../api/services/userService'; import ArrowLeft from '../assets/arrow-left.svg'; import NoFilesIcon from '../assets/no-files.svg'; import NoFilesDarkIcon from '../assets/no-files-dark.svg'; import OutlineSource from '../assets/outline-source.svg'; import Spinner from '../components/Spinner'; import ChunkModal from '../modals/ChunkModal'; import ConfirmationModal from '../modals/ConfirmationModal'; import { ActiveState } from '../models/misc'; 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; editable?: boolean; } const LineNumberedTextarea: React.FC = ({ value, onChange, placeholder, ariaLabel, className = '', editable = true }) => { const { isMobile } = useMediaQuery(); const handleChange = (e: React.ChangeEvent) => { onChange(e.target.value); }; const lineHeight = 19.93; const contentLines = value.split('\n').length; const heightOffset = isMobile ? 200 : 300; const minLinesForDisplay = Math.ceil((typeof window !== 'undefined' ? window.innerHeight - heightOffset : 600) / lineHeight); const totalLines = Math.max(contentLines, minLinesForDisplay); return (
{Array.from({ length: totalLines }, (_, i) => (
{i + 1}
))}
{editable ? (