Skip to content

Conversation

@Stonebanks-js
Copy link
Contributor

⌨️ Add Keyboard Shortcuts Feature

ISSUE FIXED : #204

Changes:

  • Added global keydown listener in Editor.jsx to support:
    • Ctrl+S → Save / Download current code
    • Ctrl+O → Open/import code from file
    • Ctrl+L → Clear output panel
    • Ctrl+C → Copy output text
    • Ctrl+/ → Toggle line numbers
    • Ctrl+Shift+W → Toggle word wrap
  • Integrated with existing clearOutput and copyOutput props
  • Prevent default browser behaviors (like Save dialog)

Tests / Manual Verification:

  1. Open editor, press Ctrl+S → code downloads
  2. Ctrl+O opens file dialog → loads content
  3. Ctrl+L clears output
  4. Ctrl+C copies output
  5. Ctrl+/ toggles line numbers
  6. Ctrl+Shift+W toggles wrap

Please review and test if it causes any conflicts with Monaco internal keybindings.


Closes issue #204

@DhanushNehru I request you to run checks and merge the pull request into main.

@vercel
Copy link

vercel bot commented Oct 15, 2025

@Stonebanks-js is attempting to deploy a commit to the Dhanush Nehru's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Stonebanks-js
Copy link
Contributor Author

@DhanushNehru The Liniting check is fixed and passed successfully, I hereby request you to check the deployment status.

@Stonebanks-js
Copy link
Contributor Author

@DhanushNehru Kindly review this PR and add hacktoberfest labels please

@vercel
Copy link

vercel bot commented Oct 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
custom-code-editor Ready Ready Preview Comment Oct 17, 2025 10:13am

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds keyboard/UX enhancements and refactors the editor page, with improved Judge0 submission handling and import/export utilities. However, the advertised global keyboard shortcuts are not implemented in the diff, and there appear to be regressions in the sidebar controls.

  • Adds submit/polling improvements and safer theme definition.
  • Implements import/export helpers, output copy/clear, and state cleanup on unmount.
  • Wires a global keydown handler for Ctrl+Enter only.

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/pages/EditorComponent.js Refactors editor logic, adds import/export and output utilities, adds Ctrl+Enter global handler, adjusts state handling and UI blocks.
package.json Bumps eslint to ^8.57.1.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Stonebanks-js
Copy link
Contributor Author

Stonebanks-js commented Oct 17, 2025

@DhanushNehru Sir please merge this PR, all the checks have passed successfully, Kindly assign it with hacktoberfest labels 2025. Thank you.

@DhanushNehru DhanushNehru requested a review from Copilot October 22, 2025 17:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 6 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

const isImportingRef = useRef(false);
const fileInputRef = useRef(null);
const timeoutRef = useRef(null);
const [isDownloading, setDownloading] = useState(false);
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

The isDownloading state is declared but never set to true anywhere in the code. The setDownloading(true) call was removed from the exportFile function, making this state variable unused. Consider removing this state if it's not needed, or ensure it's properly managed if the downloading indicator is still required.

Suggested change
const [isDownloading, setDownloading] = useState(false);

Copilot uses AI. Check for mistakes.
Comment on lines +233 to +241
const decoded = atob(result.stdout);
setOutput(decoded.split("\n"));
} else if (result && result.compile_output) {
const decoded = atob(result.compile_output);
setOutput(decoded.split("\n"));
enqueueSnackbar("Compilation error. See output.", { variant: "error" });
} else if (result && result.stderr) {
const decoded = atob(result.stderr);
setOutput(decoded.split("\n"));
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

The decodeFormat function is defined earlier in the file but is no longer being used. The base64 decoding and splitting logic has been duplicated inline here and in multiple other places (lines 236, 240). Consider using the existing decodeFormat function to maintain consistency and reduce code duplication.

Suggested change
const decoded = atob(result.stdout);
setOutput(decoded.split("\n"));
} else if (result && result.compile_output) {
const decoded = atob(result.compile_output);
setOutput(decoded.split("\n"));
enqueueSnackbar("Compilation error. See output.", { variant: "error" });
} else if (result && result.stderr) {
const decoded = atob(result.stderr);
setOutput(decoded.split("\n"));
setOutput(decodeFormat(result.stdout));
} else if (result && result.compile_output) {
setOutput(decodeFormat(result.compile_output));
enqueueSnackbar("Compilation error. See output.", { variant: "error" });
} else if (result && result.stderr) {
setOutput(decodeFormat(result.stderr));

Copilot uses AI. Check for mistakes.
java: "Java",
};

const languageMap = { js: "Javascript", jsx: "Javascript", ts: "Typescript", py: "Python3", cpp: "C++", c: "C", java: "Java" };
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

This language mapping is now defined inline within the handleFileImport function, but a similar mapping exists in the exportFile function at line 335. Consider extracting this to a constant at the module level to maintain consistency and avoid duplication.

Copilot uses AI. Check for mistakes.
Comment on lines +447 to +455
<Box sx={{ flexGrow: 1 }}>
{currentUser ? renderAuthenticatedContent() : (
<div>
<GithubSignIn />
<GoogleSignIn />
</div>
</Box>
{currentUser
? renderAuthenticatedContent()
: renderUnauthenticatedContent()}
<div className="footer">
<Footer />
</div>
</div>
)}
<Footer />
</Box>
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

The entire header section with logo, theme toggle, stars component, and user profile has been removed from the render. This removes critical UI elements including the logout button and user information display, which breaks the user experience. The handleSignOut function is still defined but no longer accessible from the UI.

Copilot uses AI. Check for mistakes.
Comment on lines +431 to +440
{/* Run, Copy, Clear */}
<div style={{ display: "flex", gap: "0.5rem", marginTop: "1rem" }}>
<StyledButton onClick={submitCode}><FaPlay /> Run</StyledButton>
<StyledButton onClick={copyOutput}><FaCopy /> Copy Output</StyledButton>
<StyledButton onClick={clearOutput}><FaTrash /> Clear Output</StyledButton>
</div>
<StyledButton
sx={(theme) => ({
marginTop: "1rem",
padding: "10px 20px",
bgcolor: theme.palette.text.primary,
color: theme.palette.background.default,
border: "none",
borderRadius: "15px",
fontSize: "0.8em",
cursor: "pointer",
boxShadow: "0 4px 6px rgba(0, 0, 0, 0.1)",
width: "50%",
"@media (min-width: 1024px)": {
width: "100%",
},
})}
onClick={submitCode}
variant="contained"
color="primary"
disabled={loading}
>
<span>
{loading ? <CircularProgress size={13} /> : <FaPlay size="13" />}
</span>
Run {languageDetails.LANGUAGE_NAME}
</StyledButton>
{/* Output */}
<OutputLayout>
<pre>{output && output.length ? output.join("\n") : "Output will appear here..."}</pre>
</OutputLayout>
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

The language selector, theme selector, and editor settings (line numbers toggle, word wrap toggle, font size slider) have been completely removed from the UI. While these state variables and handlers still exist in the code, users can no longer access these controls. This breaks functionality that was previously available.

Copilot uses AI. Check for mistakes.
Export
</>
)}
<input type="file" ref={fileInputRef} style={{ display: "none" }} accept=".java,.js,.jsx,.ts,.py,.cpp,.c" onChange={handleFileImport} />
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

The PR description mentions adding keyboard shortcuts including Ctrl+O for opening/importing files, but there is no keyboard event listener implemented for this functionality. The file input only works via button click, not via the Ctrl+O shortcut as described.

Copilot uses AI. Check for mistakes.
@DhanushNehru
Copy link
Owner

The landing page is not proper @Stonebanks-js

Screenshot 2025-10-22 at 10 40 30 PM

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.

Add Essential Keyboard Shortcuts for Better User Experience

2 participants