Skip to content

UI: New text-strings preview mode #1051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KWMORALE
Copy link
Member

@KWMORALE KWMORALE commented Jul 23, 2025

Your checklist for this pull request

  • I've read the contributing guideline.
  • I've tested my changes by building and running the project, and testing changed functionality (if applicable)
  • I've added automated tests for my change (if applicable, optional)
  • I've updated documentation to reflect my change (if applicable)

What is the current behaviour?

Only raw and hex mode in sample preview.

What is the new behaviour?

  • Added a dropdown to select the file content display mode.
  • Rename component HexView to ObjectPreview
  • New preview mode: text - that prints the printable character sequences that are at least

Test plan

Go to sample preview and change mode on some files.

Screencast.from.2025-07-23.12-07-29.webm

@KWMORALE KWMORALE requested a review from postrowinski July 23, 2025 10:08
if (!props.content) return "";
if (props.mode === "raw") {
if (props.content instanceof ArrayBuffer)
return new TextDecoder().decode(props.content);
else return props.content;
} else if (props.mode === "text") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, there are too many if-logic blocks here. I suggest creating separate utility functions for each mode — 'raw', 'text', and 'hex' to handle the value for each of them individually.

else buffer = new TextEncoder().encode(props.content);

const MIN_LENGTH = 4;
let result: string[] = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let result: string[] = [];
const result: string[] = [];

Comment on lines +18 to +23
const selectedStyle = {
fontWeight: selected ? "bold" : "normal",
pointerEvents: (selected ? "none" : "auto") as
| "none"
| "auto",
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const selectedStyle = {
fontWeight: selected ? "bold" : "normal",
pointerEvents: (selected ? "none" : "auto") as
| "none"
| "auto",
};
const styles = { fontWeight: selected ? "bold" : "normal" };

};

return (
<span className="nav-item" style={selectedStyle} key={mode}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<span className="nav-item" style={selectedStyle} key={mode}>
<span className="nav-item" style={styles} key={mode}>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants