[PB-6529]:feat/adding .txt files previewable view#2005
Open
jaaaaavier wants to merge 11 commits into
Open
Conversation
Deploying drive-web with
|
| Latest commit: |
694b49a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://839c3ae0.drive-web.pages.dev |
| Branch Preview URL: | https://feat-txt-files-viewer.drive-web.pages.dev |
xabg2
reviewed
Jun 23, 2026
Comment on lines
+44
to
+50
| const handleScroll = (event: React.UIEvent<HTMLDivElement>) => { | ||
| if (!hasMore || loadingRef.current) return; | ||
| const { scrollTop, clientHeight, scrollHeight } = event.currentTarget; | ||
| if (scrollTop + clientHeight >= scrollHeight - SCROLL_THRESHOLD_PX) { | ||
| readChunk(offset); | ||
| } | ||
| }; |
Contributor
There was a problem hiding this comment.
What about using the IntersectionObserver instead?
Something like:
useEffect(() => {
const sentinel = sentinelRef.current;
if (!sentinel) return;
const observer = new IntersectionObserver(
(entries) => {
if (entries[0].isIntersecting) readChunk();
},
{ rootMargin: '300px' },
);
observer.observe(sentinel);
return () => observer.disconnect();
}, [readChunk]);
And then adding a <div ref={sentinelRef} />
I did not test the code but, maybe it can work and is cleaner, WDYT?
Contributor
Author
There was a problem hiding this comment.
Yeah, that's a better idea to be honest, I didn't remember about IntersectionObserver. Change applied.
xabg2
previously approved these changes
Jun 25, 2026
xabg2
previously approved these changes
Jun 26, 2026
Contributor
Author
|
We updated the bg-color of the viewer for a correct vision in dark mode |
|
xabg2
approved these changes
Jun 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
This PR adds preview functionality for .txt files that users may have; the requirements are that the text be rendered and be readable. There are also requests for features such as support for large files: up to ~5–10 MB (lazy load beyond that). This is being addressed; we will load in 2MB increments, and when there are 300px left to reach the end, I have tried to use something similar to how it’s done in the XLSX preview.
Related Issues
Related Pull Requests
Checklist
Testing Process
I uploaded a small file and checked that it renders correctly; I also uploaded a 60MB text file and verified that it renders correctly, the load times are fine.

Additional Notes