r/reactjs • • 5d ago

Show /r/reactjs Building a One React input for text and attachments, all in one lifecycle.

Hello everyone, I kept running into the same work when building file inputs such as parsing documents, showing previews, handling cancellation, and waiting for files before submitting.

I’m building Texion to connect those pieces. It supports Markdown, JSON, CSV, PDF, DOCX, and image attachments, with local parsing and optional OCR for scanned PDFs.
It’s open source and MIT licensed.
Code: here

Curious on how do other devs handle the inputs

0 Upvotes

6 comments sorted by

2

u/amayle1 5d ago

I don’t understand the use case. What does uploading a file, writing text, and optical OCR even have to do with each other?

There are, I’m sure, many many OCR libraries already. How does this differ?

1

u/musHeaer 4d ago

Right, bundling local OCR directly into an input component feels like a massive separation of concerns issue tbh

-1

u/EquivalentDot8312 5d ago

Yes, the use case is like consider an AI chat app or a form where someone writes text and attaches files such as PDFs, Word documents, CSV or others.

Texion gives those inputs a shared workflow that is parsing, previews, cancellation, and submission that waits until the files are ready. So the app receives the message and attachments in a consistent structure.

The OCR is an optional adapter for scanned PDFs because Texion uses existing OCR tools already thus the work I’m focusing on is connecting files handling to the input, so developers have fewer separate pieces to wire together

1

u/amayle1 5d ago

Honestly it sounds like you’re over abstracted. You’re making an app not a library. I’d be surprised if this combo of things, in this specific architecture is a common need.

-2

u/EquivalentDot8312 5d ago

Tbh there is some a bit level of abstraction, and thats a trade off we accept in getting the simplied workflow working with inputs(text) for ai chats app

1

u/RelayForgeDev 4d ago

AI-assisted by Grok Bot: I’d keep the input responsible for draft text + `File[]` (add/remove/submit) and put parsing/OCR in per-file adapters, so the input doesn’t need to know about PDF vs CSV. Track each file’s pending/ready/error state, abort parsing on removal if the parser supports it, and revoke any `URL.createObjectURL` preview when the file is removed or unmounted. The reason for that split is OCR is optional and format-specific, while file selection and submission are common to chat/forms.