├── .dockerignore ├── .env.example ├── .eslintrc.json ├── .github ├── FUNDING.yml ├── dependabot.yml ├── pull_request_template.md └── workflows │ ├── lint.yml │ └── rapidapi.yml ├── .gitignore ├── .gitpod.yml ├── .vscode └── settings.json ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE ├── NOTES.md ├── README.md ├── SECURITY.md ├── banner.svg ├── docker-compose.yml ├── package-lock.json ├── package.json ├── public ├── images │ ├── custom-code-editor-rounded.svg │ ├── custom-code-editor-white-rounded.svg │ ├── custom-code-editor-white.svg │ └── custom-code-editor.svg ├── index.html ├── robots.txt └── sitemap.xml └── src ├── App.js ├── components ├── Footer.js ├── GithubSignIn.js ├── GoogleSignIn.js ├── IconButton.js ├── css │ ├── CircularLoading.css │ ├── EditorComponent.css │ ├── GithubSignIn.css │ └── index.css ├── firebase.js ├── images │ ├── CppLogo.js │ ├── JavaLogo.js │ ├── JavaScriptLogo.js │ └── PythonLogo.js └── js │ ├── CircularLoading.js │ ├── EditorThemeSelect.js │ ├── LanguageSelect.js │ ├── SnackbarProvider.js │ ├── Stars.js │ ├── ToggleTheme.js │ ├── defineEditorTheme.js │ ├── sitemapGenerator.js │ └── sitemapRoutes.js ├── constants └── constants.js ├── context └── AuthContext.js ├── hooks └── useGetStars.js ├── index.js ├── pages └── EditorComponent.js └── theme.js /.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .git 3 | .gitignore 4 | .env.example 5 | .env -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | REACT_APP_RAPID_API_HOST= 2 | REACT_APP_RAPID_API_KEY= 3 | REACT_APP_RAPID_API_URL= 4 | JUDGE0_SUBMISSION_URL= 5 | 6 | # Docker Compose Project Name (Optional) eg.custom_code_editor 7 | COMPOSE_PROJECT_NAME=my_project_name 8 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "eslint:recommended", 4 | "plugin:import/errors", 5 | "plugin:import/warnings", 6 | "plugin:import/typescript", 7 | "plugin:react/recommended", 8 | "plugin:jsx-a11y/recommended", 9 | "plugin:react-hooks/recommended" 10 | ], 11 | "plugins": ["react", "import", "jsx-a11y", "react-hooks"], 12 | "rules": { 13 | "react/prop-types": "off", 14 | "react/react-in-jsx-scope": "off", 15 | "indent": ["error", 2], 16 | // "linebreak-style": ["error", "unix"], 17 | "linebreak-style": 0, 18 | "quotes": ["error", "double"], 19 | "no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }], 20 | "import/order": ["error", { "groups": [["builtin", "external", "internal"]] }], 21 | "react-hooks/rules-of-hooks": "error", 22 | "react-hooks/exhaustive-deps": "warn", 23 | "object-curly-spacing": ["error", "always"] 24 | }, 25 | "parserOptions": { 26 | "ecmaVersion": 2023, 27 | "sourceType": "module", 28 | "ecmaFeatures": { 29 | "jsx": true 30 | } 31 | }, 32 | "env": { 33 | "es6": true, 34 | "browser": true, 35 | "node": true 36 | }, 37 | 38 | "settings": { 39 | "react": { 40 | "version": "detect" 41 | }, 42 | "import/resolver": { 43 | "node": { 44 | "extensions": [".js", ".jsx", ".ts", ".tsx"] 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [DhanushNehru] 4 | patreon: dhanushnehru 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: dhanushnehru 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 12 | polar: # Replace with a single Polar username 13 | buy_me_a_coffee: dhanushnehru 14 | thanks_dev: dhanushnehru 15 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 16 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "npm" # See documentation for possible values 9 | directory: "/node_modules" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | Resolves #[Issue Number if there] 2 | ### PR Fixes: 3 | - 1 4 | - 2 5 | 6 | ### Checklist before requesting a review 7 | - [ ] I have pull latest changes from `main` branch 8 | - [ ] I have tested the changes locally 9 | - [ ] I have run `npm run lint:fix` locally 10 | - [ ] I have performed a self-review of my code 11 | - [ ] I assure there is no similar/duplicate pull request regarding same issue 12 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Linting Check for commits 2 | 3 | on: 4 | push: 5 | branches: 6 | - 'main' 7 | pull_request: 8 | branches: 9 | - 'main' 10 | 11 | jobs: 12 | Continuous-Integration: 13 | name: Performs linting on the application 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout repository 17 | uses: actions/checkout@v4 18 | 19 | - name: Set up Node.js 20 | uses: actions/setup-node@v4 21 | with: 22 | node-version: 20 23 | cache: 'npm' 24 | 25 | - run: npm ci 26 | 27 | - name: Run lint check 28 | run: npm run lint -------------------------------------------------------------------------------- /.github/workflows/rapidapi.yml: -------------------------------------------------------------------------------- 1 | name: Rapid API 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | deploy: 10 | runs-on: ubuntu-latest 11 | 12 | env: 13 | REACT_APP_RAPID_API_HOST: ${{ secrets.REACT_APP_RAPID_API_HOST }} 14 | REACT_APP_RAPID_API_KEY: ${{ secrets.REACT_APP_RAPID_API_KEY }} 15 | REACT_APP_RAPID_API_URL: ${{ secrets.REACT_APP_RAPID_API_URL }} 16 | 17 | steps: 18 | - name: Checkout repository 19 | uses: actions/checkout@v2 20 | 21 | - name: Set up Node.js 22 | uses: actions/setup-node@v2 23 | with: 24 | node-version: '16' 25 | 26 | - name: Install dependencies 27 | run: npm install 28 | 29 | - name: Build project 30 | run: npm run build 31 | 32 | - name: Deploy to a server or hosting platform 33 | run: | 34 | echo "Deploying to server" 35 | # Add your deployment commands here, for example: 36 | # scp -r ./build user@server:/path/to/deploy 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | # project dependencies 11 | /node_modules 12 | /.pnp 13 | .pnp.js 14 | 15 | # testing 16 | /test-coverage 17 | 18 | # production 19 | /build 20 | 21 | # misc 22 | .env 23 | .DS_Store 24 | .env.local 25 | .env.development.local 26 | .env.test.local 27 | .env.production.local 28 | t.env 29 | /.vscode 30 | /dist 31 | .env -------------------------------------------------------------------------------- /.gitpod.yml: -------------------------------------------------------------------------------- 1 | # This configuration file was automatically generated by Gitpod. 2 | # Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml) 3 | # and commit this file to your remote git repository to share the goodness with others. 4 | 5 | # Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart 6 | 7 | tasks: 8 | - init: npm install && npm run build 9 | command: npm run start 10 | 11 | 12 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "githubPullRequests.ignoredPullRequestBranches": [ 3 | "main" 4 | ], 5 | "cSpell.words": [ 6 | "linebreak" 7 | ] 8 | } -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | education, socio-economic status, nationality, personal appearance, race, 10 | religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at {{ email }}. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Custom Code Editor 2 | 3 | :tada: Before we begin, thank you for taking the time to contribute! :tada: 4 | 5 | We are open-source, and are thankful for any help we can get! 6 | 7 | The following is a set of guidelines for contributing to Custom Code Editor, hosted [here](https://github.com/DhanushNehru/CustomCodeEditor) on GitHub. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request. 8 | 9 | ## Table Of Contents 10 | 11 | 1. [Code of Conduct](#code-of-conduct) 12 | 2. [What should I know before I get started?](#what-should-i-know-before-i-get-started) 13 | 3. [How Can I Contribute?](#how-can-i-contribute) 14 | * [Reporting Bugs](#reporting-bugs) 15 | * [Suggesting Enhancements](#suggesting-enhancements) 16 | * [Your First Code Contribution](#your-first-code-contribution) 17 | 4. [Styleguides](#styleguides) 18 | * [Git Commit Messages](#git-commit-messages) 19 | * [Documentation Styleguide](#documentation-styleguide) 20 | 5. [FAQ](#faq) 21 | 22 | ## Code of Conduct 23 | 24 | This project and everyone participating in it is governed by this [Code of Conduct](https://github.com/atom/atom/blob/master/CODE_OF_CONDUCT.md) *(taking reference from Atom's code of conduct)*. By participating, you are expected to uphold this code. 25 | 26 | Please report unacceptable behavior [here](https://discord.com/invite/Yn9g6KuWyA). 27 | 28 | ## What should I know before I get started? 29 | 30 | 1. Read through the [README](README.md) file for prerequisites, installation details and configuration requirements. 31 | 2. The editor is live [here](https://custom-code-editor.vercel.app/). 32 | 3. If you want to contribute, see [here](#how-can-i-contribute). 33 | 4. If you have a question, see the [FAQ](#faq) before opening an issue. It could be answered already 34 | 35 | ## How can I contribute? :hand: 36 | 37 | ### Reporting Bugs :bug: 38 | 39 | This section guides you through submitting a bug report for the Custom Code Editor. 40 | 41 | **Following these guidelines** helps maintainers and the community... 42 | 43 | 1. Understand your report 44 | 2. Reproduce the behavior 45 | 3. Find related reports 46 | 47 | #### Guidelines for Reporting Bugs 48 | 49 | 1. Perform a cursory search [here](https://github.com/DhanushNehru/CustomCodeEditor/issues) for whether the issue has already been reported. 50 | 2. Asumming no, please be as detailed as possible in describing the issue. 51 | 3. Fill out the below template when *opening an issue*. 52 | 53 | --- 54 | 55 | > Issue template starts here 56 | 57 | #### Description 58 | * 59 | #### Steps to Reproduce 60 | 1. 61 | 2. 62 | 3. 63 | 64 | ##### Expected behavior: 65 | * 66 | 67 | ##### Actual behavior: 68 | * 69 | 70 | ##### Reproduces how often: 71 | * 72 | 73 | #### Versions 74 | * 75 | 76 | #### Additional Information 77 | * 78 | 79 | > Issue template ends here 80 | 81 | --- 82 | 83 | #### NOTE :warning: 84 | 85 | * If you find a Closed issue that seems like it is the same thing that you're experiencing, open a new issue and include a link to the original issue in the body of your new one. 86 | 87 | ### Suggesting Enhancements 88 | 89 | 1. Perform a cursory search [here](https://github.com/DhanushNehru/CustomCodeEditor/issues) for whether the enhancement has already been suggested. 90 | 2. If it has already been suggested, add a comment to **that issue** instead of opening a new issue. 91 | 3. Asumming no, please do the following when describing the enhancements. 92 | * Use a clear and descriptive title for the issue to identify the suggestion. 93 | * Provide a step-by-step description of the suggested enhancement in as many details as possible. 94 | * Provide specific examples to demonstrate the steps. Include copy/pasteable snippets which you use in those examples, as Markdown code blocks. 95 | * Describe the current behavior and explain which behavior you expected to see instead and why. 96 | * Include screenshots and animated GIFs if possible to demonstrate the steps or point out the part of Custom Code Editor the suggestion is related to. 97 | 98 | ### Your First Code Contribution :tada: 99 | 100 | Unsure where to begin contributing to Custom Code Editor? You can start by looking through these beginner and help-wanted issues: 101 | 102 | * [Beginner issues](https://github.com/DhanushNehru/CustomCodeEditor/labels/good%20first%20issue) - issues which should only require a few lines of code, and a test or two. 103 | * [Help wanted issues](https://github.com/DhanushNehru/CustomCodeEditor/labels/help%20wanted) - issues which should be a bit more involved than beginner issues. 104 | 105 | As for **how** to contribute to Open Source projects, follow [this guide](https://daily.dev/blog/how-to-contribute-to-open-source-projects-as-a-beginner) for a step-by-step walkthrough of opening a pull request. 106 | 107 | #### Other useful references 108 | 109 | * [Open Source Friday](https://opensourcefriday.com/) 110 | 111 | ## Styleguides 112 | 113 | ### Git Commit Messages 114 | 115 | In general, we follow [these guidelines](https://gist.github.com/robertpainsi/b632364184e70900af4ab688decf6f53) to style commit messages. Keep them concise and informative. 116 | 117 | ### Documentation Styleguide 118 | 119 | In general, our documentation is written in [Markdown](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax), and we follow the [Github Markdown Styleguide](https://github.com/google/styleguide/blob/gh-pages/docguide/style.md). 120 | 121 | ## FAQ :question: 122 | 123 | 1. 124 | 125 | > This is to be updated with more FAQ here as they come in. Future contributors are welcome! 126 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:20-alpine 2 | 3 | WORKDIR /app 4 | 5 | COPY package.json package-lock.json ./ 6 | 7 | RUN npm install 8 | 9 | COPY . . 10 | 11 | EXPOSE 3000 12 | 13 | CMD ["npm", "run", "start"] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /NOTES.md: -------------------------------------------------------------------------------- 1 | ## Python3 Code: 2 | 3 | Business case problem: calculating the total revenue from a list of sales transactions. 4 | 5 | ``` 6 | def calculate_total_revenue(sales): 7 | total_revenue = 0 8 | for item, price in sales: 9 | total_revenue += price 10 | return total_revenue 11 | ``` 12 | 13 | ### Example usage: This would be given as inputs 14 | 15 | ``` 16 | sales = [("Product A", 10), ("Product B", 20), ("Product C", 15)] 17 | total_revenue = calculate_total_revenue(sales) 18 | print("Total Revenue:", total_revenue) 19 | ``` 20 | 21 | ## Javascript Code: 22 | 23 | Shortest path between multiple locations on a map 24 | 25 | ``` 26 | function calculateTotalDistance(locations) { 27 | // Helper function to calculate distance between two points (using Euclidean distance for simplicity) 28 | function distance(point1, point2) { 29 | return Math.sqrt(Math.pow(point2.x - point1.x, 2) + Math.pow(point2.y - point1.y, 2)); 30 | } 31 | 32 | // Helper function to calculate total distance of a route 33 | function routeDistance(route) { 34 | let totalDistance = 0; 35 | for (let i = 0; i < route.length - 1; i++) { 36 | totalDistance += distance(locations[route[i]], locations[route[i + 1]]); 37 | } 38 | return totalDistance; 39 | } 40 | 41 | // Generate all possible permutations of routes 42 | function* permutations(arr) { 43 | if (arr.length === 1) { 44 | yield arr; 45 | } else { 46 | for (let i = 0; i < arr.length; i++) { 47 | const rest = [...arr.slice(0, i), ...arr.slice(i + 1)]; 48 | for (const perm of permutations(rest)) { 49 | yield [arr[i], ...perm]; 50 | } 51 | } 52 | } 53 | } 54 | 55 | // Find the shortest route among all permutations 56 | let shortestDistance = Infinity; 57 | let shortestRoute = null; 58 | for (const perm of permutations([...Array(locations.length).keys()])) { 59 | const dist = routeDistance(perm); 60 | if (dist < shortestDistance) { 61 | shortestDistance = dist; 62 | shortestRoute = perm; 63 | } 64 | } 65 | 66 | return shortestDistance; 67 | } 68 | ``` 69 | 70 | ### Example usage: Would be passed as inputs 71 | 72 | ``` 73 | const locations = [ 74 | { x: 0, y: 0 }, 75 | { x: 1, y: 2 }, 76 | { x: 3, y: 1 }, 77 | { x: 2, y: 3 } 78 | ]; 79 | 80 | const totalDistance = calculateTotalDistance(locations); 81 | console.log("Total Distance in meters:", totalDistance); 82 | ``` 83 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Custom Code Editor 2 |

3 | Custom Code Editor 4 |

5 | 6 |
7 | 8 | [![Join Our Discord](https://img.shields.io/badge/Discord-Join%20Server-blue?logo=discord&style=for-the-badge)](https://discord.com/invite/Yn9g6KuWyA) 9 | [![Subscribe on YouTube](https://img.shields.io/badge/YouTube-Subscribe-red?logo=youtube&style=for-the-badge)](https://www.youtube.com/@dhanushnehru?sub_confirmation=1) 10 | [![Subscribe to Newsletter](https://img.shields.io/badge/Newsletter-Subscribe-orange?style=for-the-badge)](https://dhanushn.substack.com/) 11 | 12 |
13 | 14 | 15 | This project is a React-based code builder that utilizes the Monaco Editor. It allows users to write and execute code snippets within a web browser. It uses Judge0 as a code execution system 16 | 17 | ## Getting Started 18 | Follow these instructions to get the project up and running on your local machine. 19 | 20 | ## Prerequisites 21 | Node.js installed on your machine 22 | npm or yarn package manager 23 | 24 | ## Installation 25 | Clone the repository to your local machine: 26 | 27 | ``` 28 | git clone https://github.com/DhanushNehru/CustomCodeEditor 29 | ``` 30 | - Note:- Please fill in the necessary keys in the `.env` file for successful code submissions 31 | # Without Docker 32 | Install dependencies using npm or yarn: 33 | bash 34 | ``` 35 | npm install 36 | # or 37 | yarn install 38 | ``` 39 | 40 | To Start project 41 | ``` 42 | npm run start 43 | ``` 44 | # With Docker 45 | ## Prerequisites 46 | Before starting with the project, ensure you have Docker installed. If not, follow these steps to install Docker: 47 | 48 | ### Docker Installation 49 | 50 | 1. **Windows**: 51 | - Download Docker Desktop from [Docker Hub](https://hub.docker.com/editions/community/docker-ce-desktop-windows). 52 | - Follow the installation instructions. 53 | 54 | 2. **Mac**: 55 | - Download Docker Desktop from [Docker Hub](https://hub.docker.com/editions/community/docker-ce-desktop-mac). 56 | - Follow the installation instructions. 57 | 58 | 3. **Linux**: 59 | - Docker Engine installation varies by Linux distribution. Refer to [Docker's official documentation](https://docs.docker.com/engine/install/) for installation instructions specific to your Linux distribution. 60 | 61 | To start the project using Docker Compose: 62 | 1. Build and run the project: 63 | ```bash 64 | #Detach mode 65 | docker-compose up -d 66 | ``` 67 | ``` 68 | docker-compose up 69 | ``` 70 | 2. Access the project: 71 | - Once Docker Compose has started the containers, access the project using your web browser at `http://localhost:3000`. 72 | 73 | 3. Close project 74 | ``` 75 | docker-compose down 76 | ``` 77 | 78 | ## Setting Up Judge0 with RapidAPI 79 | 80 | 1. **Navigate to Judge0**: 81 | - Start by going to the [Judge0 page on RapidAPI](https://rapidapi.com/judge0-official/api/judge0-ce). 82 | - Select the **Basic Plan**, which offers a limit of 50 requests per day. 83 | 84 | 2. **Sign Up for the Basic Plan**: 85 | - RapidAPI hosts Judge0, so you need to sign up for the Basic Plan on RapidAPI. 86 | - Follow the sign-up process to get started. 87 | 88 | 3. **Access the RapidAPI Dashboard**: 89 | - After signing up, go to the [RapidAPI Dashboard](https://rapidapi.com/judge0-official/api/judge0-ce). 90 | - In the navigation bar, select **API Hub**. 91 | 92 | 4. **Navigate to the API's Section**: 93 | - Click on **Endpoints** to view 94 | - You will see multiple endpoints such as Submissions, About, and Languages. 95 | 96 | 5. **Using the Submissions Endpoint**: 97 | - For code submissions, go to the **Submissions** endpoint and then select **Create Submission**. 98 | - Here, you will find `X-RapidAPI-Key`, `X-RapidAPI-Host`, and the URL (`url`) needed for API calls. Url is located below the "Code Snippets" section. 99 | 100 | 6. **Copy Required Keys**: 101 | - Copy the `RAPIDAPI_HOST` and `RAPIDAPI_KEY` values. These are necessary to perform API calls to the code execution system. 102 | - Ensure you have these keys saved as they will be used in your API requests. 103 | 104 | By following these steps, you'll be able to set up Judge0 for code submissions using RapidAPI's infrastructure, enabling you to execute and evaluate code within your application. 105 | 106 | ## Firebase Configuration 107 | 108 | 1. Create a Firebase account at [firebase.google.com](https://firebase.google.com/) and go to the console. 109 | 2. Go to Authentication. 110 | 3. In Sign-in method, choose the Google provider. 111 | 4. Go to settings and you'll see authorized domains. 112 | 5. Add your production URL in authorized domains for our project: `https://custom-code-editor.vercel.app/` 113 | 6. Create a `.env` file in your root directory and add these values: 114 | ``` 115 | REACT_APP_FIREBASE_API_KEY="" 116 | REACT_APP_FIREBASE_AUTH_DOMAIN="" 117 | REACT_APP_FIREBASE_PROJECT_ID="" 118 | REACT_APP_FIREBASE_STORAGE_BUCKET="" 119 | REACT_APP_FIREBASE_MESSAGING_SENDER_ID="" 120 | REACT_APP_FIREBASE_APP_ID="" 121 | ``` 122 | ## GitHub Authentication Configuration 123 | 124 | To enable GitHub authentication for the Custom Code Editor, follow these steps: 125 | 126 | 1. **Enable GitHub Authentication in Firebase Console:** 127 | - Go to your Firebase project in the [Firebase Console](https://firebase.google.com/). 128 | - Navigate to **Authentication** > **Sign-in method**. 129 | - Enable **GitHub** as a sign-in provider. 130 | - Note the **Authorization Callback URL** provided by Firebase, as you will need this for your GitHub OAuth App. 131 | 132 | 2. **Register a New OAuth Application on GitHub:** 133 | - Go to your GitHub [Developer Settings](https://github.com/settings/developers). 134 | - Click on **OAuth Apps** and select **New OAuth App**. 135 | - Fill in the application details: 136 | - **Application Name**: Custom Code Editor 137 | - **Homepage URL**: 138 | - For **local development**, use `http://localhost:3000` 139 | - For **production deployment**, use your public URL (e.g., `https://custom-code-editor.vercel.app/`) 140 | - **Authorization Callback URL**: 141 | - Use the **Authorization Callback URL** provided by Firebase. 142 | - Click **Register Application**. 143 | 144 | 3. **Retrieve GitHub Client ID and Client Secret:** 145 | - Once the app is registered, you will see the **Client ID** and **Client Secret** in the GitHub OAuth App settings. Copy these values. 146 | 147 | 4. **Add GitHub OAuth Credentials to Firebase:** 148 | - Return to the Firebase Console and go back to the **GitHub** provider configuration. 149 | - Enter the **Client ID** and **Client Secret** from GitHub. 150 | - Save these settings. 151 | 152 | 5. **Update Environment Variables:** 153 | - Open your `.env` file in your project root and add the following: 154 | 155 | ```plaintext 156 | REACT_APP_GITHUB_CLIENT_ID=YOUR_GITHUB_CLIENT_ID 157 | REACT_APP_GITHUB_CLIENT_SECRET=YOUR_GITHUB_CLIENT_SECRET 158 | ``` 159 | 160 | - Replace `YOUR_GITHUB_CLIENT_ID` and `YOUR_GITHUB_CLIENT_SECRET` with the values you copied from GitHub. 161 | 162 | ## Local Configuration 163 | 164 | - Create a .env file in the root directory of your project if it doesn't already exist. 165 | - You can copy content from `.env.example` to `.env`, you can run below command. 166 | ``` 167 | cp .env.example .env 168 | ``` 169 | - Set the following environment variables in the .env file: 170 | 171 | ``` 172 | REACT_APP_RAPID_API_HOST=YOUR_HOST_URL 173 | REACT_APP_RAPID_API_KEY=YOUR_SECRET_KEY 174 | REACT_APP_RAPID_API_URL=YOUR_SUBMISSIONS_URL 175 | 176 | # key for docker container name 177 | COMPOSE_PROJECT_NAME=custom_code_editor 178 | ``` 179 | Replace YOUR_HOST_URL, YOUR_SECRET_KEY, & YOUR_SUBMISSIONS_URL with the appropriate values for your Rapid API and Judge0 API endpoints. 180 | 181 | ## Server Setup Configuration 182 | Create a .env file in the root directory of your project if it doesn't already exist. 183 | Set the JUDGE0_SUBMISSION_URL environment variable in the .env file. This variable should point to the URL of the Judge0 API endpoint you want to use for code execution. For example: 184 | plaintext 185 | 186 | ``` 187 | JUDGE0_SUBMISSION_URL=https://api.judge0.com/submissions 188 | ``` 189 | 190 | Replace https://api.judge0.com/submissions with the appropriate URL for your Judge0 API endpoint. 191 | 192 | Running the Development Server 193 | Once the configuration is complete, you can start the development server to see the React code builder in action. 194 | 195 | ``` 196 | npm start 197 | # or 198 | yarn start 199 | ``` 200 | 201 | Open your web browser and navigate to http://localhost:3000 to access the application. 202 | 203 | ## Usage 204 | 205 | - Write your code in the Monaco Editor. 206 | - Execute the code snippet by clicking the "Run" button. 207 | - View the output in the console or output panel. 208 | 209 | ## Important Information 210 | Currently the project url is based out of the free version of judge0 this means at most one can have 50 requests per day. 211 | 212 | ## Contributing 213 | Contributions are welcome! Feel free to submit pull requests or open issues. 214 | 215 | ### Contributors 216 | 217 | 218 | 219 | 220 | ## Gitpod 221 | 222 | In the cloud-free development environment where you can directly start coding. 223 | 224 | You can use Gitpod in the cloud [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/DhanushNehru/CustomCodeEditor/) 225 | 226 | ---- 227 | 228 | Contributions are welcome. Drop a PR or reach out if you need any help! 229 | 230 | 231 | 232 | ## GitAds Sponsored 233 | [![Sponsored by GitAds](https://gitads.dev/v1/ad-serve?source=dhanushnehru/customcodeeditor@github)](https://gitads.dev/v1/ad-track?source=dhanushnehru/customcodeeditor@github) 234 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting Security Vulnerabilities 4 | 5 | At Custom Code Builder, we take security seriously and value the contributions of security researchers. If you discover any security vulnerabilities in our project, we encourage you to responsibly disclose them to us. We are committed to promptly addressing and fixing such issues. 6 | 7 | To report a security vulnerability, please join our Discord server at [Custom Code Builder Discord](https://discord.gg/Yn9g6KuWyA) . Once there, you can privately message one of the moderators or administrators with the following information: 8 | 9 | - Description of the vulnerability, including any relevant technical details 10 | - Steps to reproduce the vulnerability 11 | - Any potential impact or exploit scenario 12 | - Your name/handle and a means of contacting you for further discussion 13 | 14 | We kindly request that you refrain from publicly disclosing the vulnerability until we have had an opportunity to address it. 15 | 16 | ## Responsible Disclosure Policy 17 | 18 | We follow a responsible disclosure policy and strive to address security vulnerabilities in a timely manner. Once we receive a report of a security vulnerability, we will: 19 | 20 | 1. **Confirm Receipt**: We will acknowledge receipt of the report and assign it a tracking number. 21 | 2. **Investigate**: We will investigate the reported vulnerability to validate its existence and assess its severity. 22 | 3. **Develop Fix**: If the vulnerability is confirmed, we will develop a fix to address it. 23 | 4. **Release Fix**: We will release the fix as soon as possible and notify our users about the security update. 24 | 5. **Credit**: We will publicly acknowledge the individual or organization that reported the vulnerability, unless requested otherwise. 25 | 26 | We appreciate the efforts of security researchers in helping us maintain the security of Custom Code Builder and its users. 27 | 28 | ## Contact Us 29 | 30 | If you have any questions or concerns about our security practices or this policy, please contact us through our Discord server or via email at [Custom Code Builder Discord](https://discord.gg/Yn9g6KuWyA). 31 | 32 | Thank you for your commitment to security. 33 | -------------------------------------------------------------------------------- /banner.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.8' 2 | 3 | services: 4 | app: 5 | build: 6 | context: . 7 | dockerfile: Dockerfile 8 | ports: 9 | - "3000:3000" 10 | volumes: 11 | - .:/app 12 | env_file: 13 | - .env 14 | command: ["npm", "run", "start"] 15 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "CustomCodeEditor", 3 | "version": "stable", 4 | "private": true, 5 | "dependencies": { 6 | "@emotion/react": "^11.11.4", 7 | "@emotion/styled": "^11.11.5", 8 | "@fortawesome/fontawesome-free": "^6.5.2", 9 | "@monaco-editor/react": "^4.6.0", 10 | "@mui/material": "^6.1.1", 11 | "@mui/styled-engine-sc": "^6.0.0-alpha.18", 12 | "@snaddyvitch-dispenser/react-router-sitemap": "^1.2.6", 13 | "CustomCodeEditor": "file:", 14 | "firebase": "^11.2.0", 15 | "monaco-themes": "^0.4.4", 16 | "notistack": "^3.0.1", 17 | "react": "^18.3.1", 18 | "react-dom": "^18.3.1", 19 | "react-icons": "^5.2.1", 20 | "react-router-dom": "^6.23.1", 21 | "react-scripts": "5.0.1", 22 | "react-share": "^5.2.2", 23 | "styled-components": "^6.1.11" 24 | }, 25 | "scripts": { 26 | "start": "react-scripts start", 27 | "sitemap": "babel-node src/components/js/sitemapGenerator.js", 28 | "build": "react-scripts build", 29 | "eject": "react-scripts eject", 30 | "lint": "eslint \"src/**/*.{js,jsx}\"", 31 | "lint:fix": "eslint \"src/**/*.{js,jsx}\" --fix" 32 | }, 33 | "eslintConfig": { 34 | "extends": [ 35 | "react-app" 36 | ] 37 | }, 38 | "browserslist": { 39 | "production": [ 40 | ">0.2%", 41 | "not dead", 42 | "not op_mini all" 43 | ], 44 | "development": [ 45 | "last 1 chrome version", 46 | "last 1 firefox version", 47 | "last 1 safari version" 48 | ] 49 | }, 50 | "devDependencies": { 51 | "@babel/plugin-proposal-private-property-in-object": "^7.21.11", 52 | "babel-cli": "^6.26.0", 53 | "babel-preset-es2015": "^6.24.1", 54 | "babel-preset-react": "^6.24.1", 55 | "babel-register": "^6.26.0", 56 | "eslint": "^8.57.0", 57 | "eslint-plugin-import": "^2.29.1", 58 | "eslint-plugin-jsx-a11y": "^6.8.0", 59 | "eslint-plugin-react": "^7.34.1" 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /public/images/custom-code-editor-rounded.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /public/images/custom-code-editor-white-rounded.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /public/images/custom-code-editor-white.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /public/images/custom-code-editor.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | Custom Code Editor 13 | 14 | 15 | 16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Allow: / 3 | Sitemap: https://custom-code-editor.vercel.app/sitemap.xml 4 | -------------------------------------------------------------------------------- /public/sitemap.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | https://custom-code-editor.vercel.app/ 4 | https://custom-code-editor.vercel.app/ 5 | https://custom-code-editor.vercel.app/editor 6 | 7 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import { BrowserRouter, Routes, Route } from "react-router-dom"; 2 | import { ThemeProvider } from "@mui/material"; 3 | import CssBaseline from "@mui/material/CssBaseline"; 4 | 5 | import EditorComponent from "./pages/EditorComponent"; 6 | import theme from "./theme"; 7 | import SnackbarProvider from "./components/js/SnackbarProvider"; 8 | import { AuthProvider } from "./context/AuthContext"; 9 | function App() { 10 | return ( 11 | 12 | 13 | 14 | 15 | 16 | 17 | } /> 18 | } /> 19 | 20 | 21 | 22 | 23 | 24 | ); 25 | } 26 | 27 | export default App; 28 | -------------------------------------------------------------------------------- /src/components/Footer.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { FaGithub, FaLinkedin } from "react-icons/fa"; 3 | import { GrInstagram } from "react-icons/gr"; 4 | import { FaXTwitter } from "react-icons/fa6"; 5 | import { IoLogoYoutube } from "react-icons/io"; 6 | import { 7 | LinkedinIcon, 8 | LinkedinShareButton, 9 | PinterestIcon, 10 | PinterestShareButton, 11 | RedditIcon, 12 | RedditShareButton, 13 | TwitterShareButton, 14 | TwitterIcon, 15 | WhatsappIcon, 16 | WhatsappShareButton, 17 | } from "react-share"; 18 | import IconButton from "./IconButton"; 19 | 20 | function App() { 21 | const containerStyle = { 22 | display: "flex", 23 | alignItems: "center", 24 | justifyContent: "space-between", 25 | gap: "1rem", 26 | flexDirection: "row", 27 | width: "100%", 28 | }; 29 | 30 | const iconStyle = { color: "white" }; 31 | 32 | const socialMediaStyle = { 33 | display: "flex", 34 | gap: "1rem", 35 | justifyContent: "center", 36 | marginLeft: "1rem", 37 | flex: 1, 38 | }; 39 | 40 | const shareStyle = { 41 | display: "flex", 42 | flexDirection: "column", 43 | alignItems: "flex-end", 44 | }; 45 | 46 | const madeWithStyle = { 47 | display: "flex", 48 | alignItems: "center", 49 | marginLeft: "0.5rem", 50 | }; 51 | 52 | return ( 53 |
54 |
55 | Made with ❤️ by {" "} 56 | 60 | Dhanush Nehru 61 | 62 |
63 |
64 | 70 | 71 | 72 | 73 | 74 | 80 | 81 | 82 | 83 | 84 | 90 | 91 | 92 | 93 | 94 | 100 | 101 | 102 | 103 | 104 | 110 | 111 | 112 | 113 | 114 |
115 |
116 |
117 | Share 118 |
119 | 120 | 121 | 122 |
123 |
124 | 125 | 126 | 127 |
128 |
129 | 130 | 131 | 132 |
133 |
134 | 138 | 139 | 140 |
141 |
142 | 146 | 147 | 148 |
149 |
150 |
151 |
152 | ); 153 | } 154 | 155 | export default App; 156 | -------------------------------------------------------------------------------- /src/components/GithubSignIn.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from "react"; 2 | import { Button } from "@mui/material"; 3 | import { useAuth } from "../context/AuthContext.js"; 4 | 5 | const GithubSignIn = () => { 6 | const { currentUser, githubSignIn } = useAuth(); 7 | const [loading, setLoading] = useState(true); 8 | 9 | useEffect(() => { 10 | const checkAuthentication = async () => { 11 | await new Promise((resolve) => setTimeout(resolve, 50)); 12 | setLoading(false); 13 | }; 14 | checkAuthentication(); 15 | }, [currentUser]); 16 | 17 | const handleSignIn = async () => { 18 | try { 19 | await githubSignIn(); 20 | } catch (error) { 21 | console.log(error); 22 | } 23 | }; 24 | 25 | return loading ? null : ( 26 | 50 | ); 51 | }; 52 | 53 | export default GithubSignIn; 54 | -------------------------------------------------------------------------------- /src/components/GoogleSignIn.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from "react"; 2 | import { Button } from "@mui/material"; 3 | import { useAuth } from "../context/AuthContext.js"; 4 | 5 | const GoogleSignIn = () => { 6 | const { currentUser, googleSignIn } = useAuth(); 7 | const [loading, setLoading] = useState(true); 8 | useEffect(() => { 9 | const checkAuthentication = async () => { 10 | await new Promise((resolve) => setTimeout(resolve, 50)); 11 | setLoading(false); 12 | }; 13 | checkAuthentication(); 14 | }, [currentUser]); 15 | 16 | const handleSignIn = async () => { 17 | try { 18 | await googleSignIn(); 19 | } catch (error) { 20 | console.log(error); 21 | } 22 | }; 23 | 24 | return loading ? null : ( 25 | 49 | ); 50 | }; 51 | 52 | export default GoogleSignIn; 53 | -------------------------------------------------------------------------------- /src/components/IconButton.js: -------------------------------------------------------------------------------- 1 | import { useRef, useState } from "react" 2 | 3 | export default function IconButton({ children, text, color, ...props }) { 4 | const [hovered, setHovered] = useState(false) 5 | const ref = useRef(null) 6 | 7 | const buttonStyle = { 8 | display: "flex", 9 | padding: "0.5rem", // equivalent to p-2 10 | alignItems: "center", 11 | borderRadius: "0.5rem", // equivalent to rounded-lg 12 | color: "white", 13 | backgroundColor: color || "black", 14 | cursor: "pointer", 15 | border: "none", 16 | outline: "none" 17 | } 18 | 19 | const textDivStyle = { 20 | overflowX: "hidden", 21 | transition: "all 0.3s ease-out", 22 | width: hovered ? ref.current?.offsetWidth || 0 : 0, 23 | } 24 | 25 | const textStyle = { 26 | paddingLeft: "0.375rem", // equivalent to px-1.5 27 | paddingRight: "0.375rem", 28 | } 29 | 30 | return ( 31 | 42 | ) 43 | } 44 | -------------------------------------------------------------------------------- /src/components/css/CircularLoading.css: -------------------------------------------------------------------------------- 1 | .wrapper { 2 | height: 4.25rem; 3 | } 4 | 5 | .loading { 6 | border: 5px solid rgb(203, 203, 203); 7 | border-top: 5px solid rgb(35, 61, 255); 8 | width: 1.5rem; 9 | height: 1.5rem; 10 | border-radius: 50%; 11 | animation: spin 1.5s linear infinite; 12 | margin: 0 auto; 13 | } 14 | 15 | @keyframes spin { 16 | 0% { 17 | transform: rotate(0deg); 18 | } 19 | 20 | 100% { 21 | transform: rotate(360deg); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/components/css/EditorComponent.css: -------------------------------------------------------------------------------- 1 | .editor-container { 2 | display: flex; 3 | flex-direction: column; 4 | width: 100%; 5 | height: 100vh; 6 | } 7 | 8 | .sidebar { 9 | display: flex; 10 | flex-direction: column; 11 | align-items: center; 12 | width: 100%; 13 | margin-top: 1rem; 14 | padding:2px 0px; 15 | } 16 | 17 | .editor { 18 | width: 100%; 19 | height: 40vh; 20 | } 21 | 22 | @media (min-width: 1024px) { 23 | .sidebar { 24 | width: 15vw; 25 | margin-top: 0; 26 | } 27 | 28 | .editor { 29 | width: 85vw; 30 | height: 85vh; 31 | } 32 | } 33 | 34 | .flex-container { 35 | display: flex; 36 | flex-direction: column; 37 | align-items: center; 38 | } 39 | 40 | @media (min-width: 576px) { 41 | .editor { 42 | width: 100%; 43 | height: 50vh; 44 | } 45 | .flex-container { 46 | flex-direction: row; 47 | justify-content: space-between; 48 | gap: 0.6em; 49 | } 50 | } 51 | 52 | .flex { 53 | display: flex; 54 | align-items: center; 55 | } 56 | 57 | .items-center { 58 | align-items: center; 59 | } 60 | 61 | .space-x-2 > *:not(:last-child) { 62 | margin-right: 8px; 63 | } 64 | 65 | .welcome-text { 66 | color: #000; 67 | font-weight: bold; 68 | } 69 | 70 | .signout-container { 71 | display: flex; 72 | align-items: center; 73 | border: 1px solid #d1d1d1; /* border-gray-300 */ 74 | border-radius: 4px; 75 | padding: 4px 8px; 76 | background-color: #fff; 77 | transition: background-color 0.25s; 78 | } 79 | 80 | .signout-container:hover { 81 | background-color: #fff; 82 | 83 | transition: 0.5s all ease; 84 | } 85 | 86 | .signout-button { 87 | font-weight: bold; 88 | color: #4a4a4a; /* text-gray-700 */ 89 | background: none; 90 | border: none; 91 | cursor: pointer; 92 | } 93 | 94 | .signout-button span:hover { 95 | color: #000; /* Black text */ 96 | } 97 | 98 | /* Dark mode styles */ 99 | @media (prefers-color-scheme: dark) { 100 | .welcome-text { 101 | color: #fff; /* text-white */ 102 | } 103 | 104 | .signout-container { 105 | background-color: #000; /* dark:bg-black */ 106 | color: #fff; 107 | border-color: #666; /* dark:border-gray-500 */ 108 | } 109 | 110 | .signout-button span { 111 | color: #fff; 112 | } 113 | } 114 | 115 | .footer { 116 | margin-bottom: 12px; 117 | margin-top: -8px; 118 | } 119 | -------------------------------------------------------------------------------- /src/components/css/GithubSignIn.css: -------------------------------------------------------------------------------- 1 | .github-sign-in-button { 2 | display: flex; 3 | align-items: center; 4 | gap: 0.5rem; 5 | padding: 0.5rem 1rem; 6 | border: 1px solid #e2e8f0; 7 | border-radius: 0.5rem; 8 | color: #334155; 9 | background-color: black; 10 | transition: all 150ms ease-in-out; 11 | cursor: pointer; 12 | } 13 | 14 | .github-sign-in-button:hover { 15 | border-color: #94a3b8; 16 | color: #0f172a; 17 | box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); 18 | } 19 | 20 | .github-logo { 21 | width: 1.5rem; 22 | height: 1.5rem; 23 | } 24 | 25 | /* Dark mode styles */ 26 | @media (prefers-color-scheme: dark) { 27 | .github-sign-in-button { 28 | color: #ffffff; 29 | } 30 | 31 | .github-sign-in-button:hover { 32 | color: #f1f5f9; 33 | } 34 | } -------------------------------------------------------------------------------- /src/components/css/index.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap'); 2 | 3 | body { 4 | margin: 0; 5 | font-family: 'Poppins'; 6 | } 7 | -------------------------------------------------------------------------------- /src/components/firebase.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | import { initializeApp } from "firebase/app"; 4 | import { getAuth, GoogleAuthProvider, GithubAuthProvider, signInWithPopup } from "firebase/auth"; 5 | import { getFirestore } from "firebase/firestore"; 6 | 7 | const firebaseConfig = { 8 | apiKey: process.env.REACT_APP_FIREBASE_API_KEY, 9 | authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN, 10 | projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID, 11 | storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET, 12 | messagingSenderId: process.env.REACT_APP_FIREBASE_MESSAGING_SENDER_ID, 13 | appId: process.env.REACT_APP_FIREBASE_APP_ID 14 | }; 15 | 16 | 17 | const app = initializeApp(firebaseConfig); 18 | 19 | const auth = getAuth(app); 20 | const db = getFirestore(app); 21 | 22 | export { auth, GoogleAuthProvider, GithubAuthProvider, signInWithPopup, db }; 23 | -------------------------------------------------------------------------------- /src/components/images/CppLogo.js: -------------------------------------------------------------------------------- 1 | export default function CppLogo({ width = 40, height = 40 }) { 2 | return ( 3 | 11 | 19 | 20 | 21 | 22 | 23 | 24 | 30 | 38 | 39 | 40 | 41 | 47 | 53 | 61 | 62 | 63 | 64 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 82 | 86 | 87 | 91 | 95 | 96 | 97 | ); 98 | } 99 | -------------------------------------------------------------------------------- /src/components/images/JavaLogo.js: -------------------------------------------------------------------------------- 1 | export default function JavaLogo({ width = 40, height = 40 }) { 2 | return ( 3 | 11 | 15 | 19 | 20 | 24 | 28 | 32 | 36 | 40 | 41 | 42 | ); 43 | } 44 | -------------------------------------------------------------------------------- /src/components/images/JavaScriptLogo.js: -------------------------------------------------------------------------------- 1 | export default function JavascriptLogo({ width = 40, height = 40 }) { 2 | return ( 3 | 11 | 12 | 28 | 29 | 30 | 34 | 35 | 36 | 37 | 38 | ); 39 | } -------------------------------------------------------------------------------- /src/components/images/PythonLogo.js: -------------------------------------------------------------------------------- 1 | export default function PythonLogo({ width = 40, height = 40 }) { 2 | return ( 3 | 11 | 12 | 28 | 29 | 33 | 37 | 38 | 39 | 40 | 41 | ); 42 | } -------------------------------------------------------------------------------- /src/components/js/CircularLoading.js: -------------------------------------------------------------------------------- 1 | import "../css/CircularLoading.css"; 2 | 3 | const CircularLoading = () => { 4 | return ( 5 |
6 |
7 |
8 | ); 9 | }; 10 | 11 | export default CircularLoading; 12 | -------------------------------------------------------------------------------- /src/components/js/EditorThemeSelect.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import Autocomplete from "@mui/material/Autocomplete"; 3 | import TextField from "@mui/material/TextField"; 4 | import { EDITOR_THEMES } from "../../constants/constants"; 5 | 6 | function EditorThemeSelect({ handleEditorThemeChange, defaultEditorTheme }) { 7 | return ( 8 | option.ID === value.ID} 12 | options={EDITOR_THEMES} 13 | getOptionLabel={(option) => option.NAME} 14 | value={defaultEditorTheme} 15 | onChange={(event, value) => handleEditorThemeChange(event, value)} 16 | renderInput={(params) => ( 17 | 23 | )} 24 | /> 25 | ); 26 | } 27 | 28 | export default EditorThemeSelect; 29 | -------------------------------------------------------------------------------- /src/components/js/LanguageSelect.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import Autocomplete from "@mui/material/Autocomplete"; 3 | import TextField from "@mui/material/TextField"; 4 | import { LANGUAGES } from "../../constants/constants"; 5 | 6 | function LanguageSelect({ handleLanguageChange, defaultLanguage }) { 7 | return ( 8 | option.DEFAULT_LANGUAGE === value.DEFAULT_LANGUAGE} 12 | options={LANGUAGES} 13 | getOptionLabel={(option) => option.NAME} 14 | value={defaultLanguage} 15 | onChange={(event, value) => handleLanguageChange(event, value)} 16 | renderInput={(params) => ( 17 | 23 | )} 24 | /> 25 | ); 26 | } 27 | 28 | export default LanguageSelect; 29 | -------------------------------------------------------------------------------- /src/components/js/SnackbarProvider.js: -------------------------------------------------------------------------------- 1 | // src/index.js 2 | import React from "react"; 3 | import { SnackbarProvider as Notistack, closeSnackbar } from "notistack"; 4 | import { IconButton } from "@mui/material"; 5 | import { IoCloseCircleOutline } from "react-icons/io5"; 6 | 7 | const SnackbarProvider = ({ children }) => { 8 | 9 | return ( 10 | ( 20 | closeSnackbar(key)}> 21 | 22 | 23 | )} 24 | style={{ width: "auto", minWidth: "100px", fontSize: "1em" }} 25 | > 26 | {children} 27 | 28 | ) 29 | } 30 | 31 | export default SnackbarProvider -------------------------------------------------------------------------------- /src/components/js/Stars.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Link } from "react-router-dom"; 3 | import { FaStar, FaGithub } from "react-icons/fa"; 4 | import CircularLoading from "./CircularLoading"; 5 | import { useGetStars } from "../../hooks/useGetStars"; 6 | 7 | const Stars = () => { 8 | const { fetchState, repositoryStarts, getStars } = useGetStars(); 9 | 10 | if (fetchState.isLoading) return ; 11 | 12 | if (fetchState.isError) 13 | return ( 14 | <> 15 |

{fetchState.errorMessage}

{" "} 16 | 19 | 20 | ); 21 | 22 | return ( 23 | 24 |
25 |
26 | 27 |
28 | Stars on GitHub 29 | 30 | {repositoryStarts} {repositoryStarts > 1 ? "stars" : "star"}{" "} 31 | 32 | 33 |
34 |
35 |
36 | 37 | ); 38 | }; 39 | 40 | export default Stars; 41 | 42 | const styles = { 43 | starsCon: { 44 | display: "flex", 45 | alignItems: "center", 46 | justifyContent: "center", 47 | gap: "0.5rem", 48 | fontWeight: "bold", 49 | height: "4.2rem", 50 | }, 51 | stars: { 52 | padding: ".25rem 1rem", 53 | display: "flex", 54 | alignItems: "center", 55 | gap: ".5rem", 56 | }, 57 | starsCount: { 58 | display: "flex", 59 | flexDirection: "column", 60 | alignItems: "start", 61 | justifyContent: "center", 62 | }, 63 | star: { 64 | transform: "translateY(.15rem)", 65 | }, 66 | error: { 67 | color: "red", 68 | }, 69 | retry: { 70 | border: "none", 71 | padding: ".5rem 1rem", 72 | borderRadius: "5px", 73 | cursor: "pointer", 74 | }, 75 | githubLink: { 76 | textDecoration: "none", 77 | color: "inherit" 78 | } 79 | }; 80 | -------------------------------------------------------------------------------- /src/components/js/ToggleTheme.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from "react"; 2 | import { useColorScheme, styled } from "@mui/material/styles"; 3 | import Switch from "@mui/material/Switch"; 4 | 5 | const MaterialUISwitch = styled(Switch)(({ theme }) => ({ 6 | width: 62, 7 | height: 34, 8 | padding: 7, 9 | "& .MuiSwitch-switchBase": { 10 | margin: 1, 11 | padding: 0, 12 | transform: "translateX(6px)", 13 | "&.Mui-checked": { 14 | color: "#fff", 15 | transform: "translateX(22px)", 16 | "& .MuiSwitch-thumb:before": { 17 | backgroundImage: `url('data:image/svg+xml;utf8,')`, 20 | }, 21 | "& + .MuiSwitch-track": { 22 | opacity: 1, 23 | backgroundColor: "#aab4be", 24 | ...theme.applyStyles("dark", { 25 | backgroundColor: "#8796A5", 26 | }), 27 | }, 28 | }, 29 | }, 30 | "& .MuiSwitch-thumb": { 31 | backgroundColor: "#2837BA", 32 | width: 32, 33 | height: 32, 34 | "&::before": { 35 | content: "''", 36 | position: "absolute", 37 | width: "100%", 38 | height: "100%", 39 | left: 0, 40 | top: 0, 41 | backgroundRepeat: "no-repeat", 42 | backgroundPosition: "center", 43 | backgroundImage: `url('data:image/svg+xml;utf8,')`, 46 | }, 47 | ...theme.applyStyles("dark", { 48 | backgroundColor: "#2F1888", 49 | }), 50 | }, 51 | "& .MuiSwitch-track": { 52 | opacity: 1, 53 | backgroundColor: "#aab4be", 54 | borderRadius: 20 / 2, 55 | ...theme.applyStyles("dark", { 56 | backgroundColor: "#8796A5", 57 | }), 58 | }, 59 | })); 60 | 61 | function ToggleTheme() { 62 | const { mode, setMode } = useColorScheme(); 63 | 64 | useEffect(() => { 65 | const savedMode = localStorage.getItem("themeMode"); 66 | if (!savedMode) { 67 | setMode("dark"); // Set default to dark mode 68 | localStorage.setItem("themeMode", "dark"); 69 | } else { 70 | setMode(savedMode); 71 | } 72 | }, [setMode]); 73 | 74 | const changeMode = () => { 75 | const newMode = mode === "dark" ? "light" : "dark"; 76 | setMode(newMode); 77 | localStorage.setItem("themeMode", newMode); // Save mode to local storage 78 | }; 79 | 80 | return ( 81 | <> 82 | 83 | 84 | ); 85 | } 86 | 87 | export default ToggleTheme; 88 | -------------------------------------------------------------------------------- /src/components/js/defineEditorTheme.js: -------------------------------------------------------------------------------- 1 | import { loader } from "@monaco-editor/react"; 2 | 3 | const defineEditorTheme = (theme) => { 4 | 5 | return new Promise(() => { 6 | Promise.all([ 7 | loader.init(), 8 | import(`monaco-themes/themes/${theme.NAME}.json`), 9 | ]).then(([monaco, themeData]) => { 10 | monaco.editor.defineTheme(theme.ID, themeData); 11 | monaco.editor.setTheme(theme.ID); 12 | }); 13 | }); 14 | }; 15 | 16 | export { defineEditorTheme }; 17 | -------------------------------------------------------------------------------- /src/components/js/sitemapGenerator.js: -------------------------------------------------------------------------------- 1 | require("babel-register")({ 2 | presets: ["es2015", "react"] 3 | }); 4 | 5 | const Sitemap = require("@snaddyvitch-dispenser/react-router-sitemap").default; 6 | const router = require("./sitemapRoutes").default; 7 | 8 | function generateSitemap() { 9 | return ( 10 | new Sitemap(router) 11 | .build("https://custom-code-editor.vercel.app") 12 | .save("./public/sitemap.xml") 13 | ); 14 | } 15 | 16 | generateSitemap(); 17 | -------------------------------------------------------------------------------- /src/components/js/sitemapRoutes.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Route } from "react-router"; 3 | 4 | export default ( 5 | 6 | 7 | 8 | 9 | ); 10 | -------------------------------------------------------------------------------- /src/constants/constants.js: -------------------------------------------------------------------------------- 1 | import CppLogo from "../components/images/CppLogo"; 2 | import JavaLogo from "../components/images/JavaLogo"; 3 | import JavascriptLogo from "../components/images/JavaScriptLogo"; 4 | import PythonLogo from "../components/images/PythonLogo"; 5 | 6 | export const judge0SubmitUrl = process.env.REACT_APP_RAPID_API_URL; 7 | export const rapidApiHost = process.env.REACT_APP_RAPID_API_HOST; 8 | export const rapidApiKey = process.env.REACT_APP_RAPID_API_KEY; 9 | 10 | export const LANGUAGE_ID_FOR_JAVASCRIPT = 63; 11 | export const LANGUAGE_ID_FOR_PYTHON3 = 71; 12 | export const LANGUAGE_ID_FOR_CPP = 76; 13 | export const LANGUAGE_ID_FOR_JAVA = 62; 14 | 15 | export const LANGUAGES = [ 16 | { 17 | ID: LANGUAGE_ID_FOR_JAVASCRIPT, 18 | NAME: "Javascript", 19 | DEFAULT_LANGUAGE: "javascript", 20 | LOGO: , 21 | HELLO_WORLD: `console.log("Hello World") 22 | `, 23 | }, 24 | { 25 | ID: LANGUAGE_ID_FOR_PYTHON3, 26 | NAME: "Python3", 27 | DEFAULT_LANGUAGE: "python", 28 | LOGO: , 29 | HELLO_WORLD: `print("Hello World") 30 | `, 31 | }, 32 | { 33 | ID: LANGUAGE_ID_FOR_CPP, 34 | NAME: "C++", 35 | DEFAULT_LANGUAGE: "C++(Clang 7.0.1)", 36 | LOGO: , 37 | HELLO_WORLD: `#include 38 | using namespace std; 39 | int main(){ 40 | cout<<"Hello World"<, 49 | HELLO_WORLD: `public class Main 50 | { 51 | public static void main(String[] args) { 52 | System.out.println("Hello World"); 53 | } 54 | }`, 55 | }, 56 | ]; 57 | 58 | export const EDITOR_THEMES = [ 59 | { 60 | ID: "light", 61 | NAME: "light", 62 | }, 63 | { 64 | ID: "vs-dark", 65 | NAME: "vs-dark", 66 | }, 67 | { 68 | ID: "active4d", 69 | NAME: "Active4D", 70 | }, 71 | { 72 | ID: "all-hallows-eve", 73 | NAME: "All Hallows Eve", 74 | }, 75 | { 76 | ID: "amy", 77 | NAME: "Amy", 78 | }, 79 | { 80 | ID: "birds-of-paradise", 81 | NAME: "Birds of Paradise", 82 | }, 83 | { 84 | ID: "blackboard", 85 | NAME: "Blackboard", 86 | }, 87 | { 88 | ID: "brilliance-black", 89 | NAME: "Brilliance Black", 90 | }, 91 | { 92 | ID: "brilliance-dull", 93 | NAME: "Brilliance Dull", 94 | }, 95 | { 96 | ID: "chrome-devtools", 97 | NAME: "Chrome DevTools", 98 | }, 99 | { 100 | ID: "clouds-midnight", 101 | NAME: "Clouds Midnight", 102 | }, 103 | { 104 | ID: "clouds", 105 | NAME: "Clouds", 106 | }, 107 | { 108 | ID: "cobalt", 109 | NAME: "Cobalt", 110 | }, 111 | { 112 | ID: "cobalt2", 113 | NAME: "Cobalt2", 114 | }, 115 | { 116 | ID: "dawn", 117 | NAME: "Dawn", 118 | }, 119 | { 120 | ID: "dracula", 121 | NAME: "Dracula", 122 | }, 123 | { 124 | ID: "dreamweaver", 125 | NAME: "Dreamweaver", 126 | }, 127 | { 128 | ID: "eiffel", 129 | NAME: "Eiffel", 130 | }, 131 | { 132 | ID: "espresso-libre", 133 | NAME: "Espresso Libre", 134 | }, 135 | { 136 | ID: "github-dark", 137 | NAME: "GitHub Dark", 138 | }, 139 | { 140 | ID: "github-light", 141 | NAME: "GitHub Light", 142 | }, 143 | { 144 | ID: "github", 145 | NAME: "GitHub", 146 | }, 147 | { 148 | ID: "idle", 149 | NAME: "IDLE", 150 | }, 151 | { 152 | ID: "katzenmilch", 153 | NAME: "Katzenmilch", 154 | }, 155 | { 156 | ID: "kuroir-theme", 157 | NAME: "Kuroir Theme", 158 | }, 159 | { 160 | ID: "lazy", 161 | NAME: "LAZY", 162 | }, 163 | { 164 | ID: "magicwb--amiga-", 165 | NAME: "MagicWB (Amiga)", 166 | }, 167 | { 168 | ID: "merbivore-soft", 169 | NAME: "Merbivore Soft", 170 | }, 171 | { 172 | ID: "merbivore", 173 | NAME: "Merbivore", 174 | }, 175 | { 176 | ID: "monokai-bright", 177 | NAME: "Monokai Bright", 178 | }, 179 | { 180 | ID: "monokai", 181 | NAME: "Monokai", 182 | }, 183 | { 184 | ID: "night-owl", 185 | NAME: "Night Owl", 186 | }, 187 | { 188 | ID: "nord", 189 | NAME: "Nord", 190 | }, 191 | { 192 | ID: "oceanic-next", 193 | NAME: "Oceanic Next", 194 | }, 195 | { 196 | ID: "pastels-on-dark", 197 | NAME: "Pastels on Dark", 198 | }, 199 | { 200 | ID: "slush-and-poppies", 201 | NAME: "Slush and Poppies", 202 | }, 203 | { 204 | ID: "solarized-dark", 205 | NAME: "Solarized-dark", 206 | }, 207 | { 208 | ID: "solarized-light", 209 | NAME: "Solarized-light", 210 | }, 211 | { 212 | ID: "spacecadet", 213 | NAME: "SpaceCadet", 214 | }, 215 | { 216 | ID: "sunburst", 217 | NAME: "Sunburst", 218 | }, 219 | { 220 | ID: "textmate--mac-classic-", 221 | NAME: "Textmate (Mac Classic)", 222 | }, 223 | { 224 | ID: "tomorrow-night-blue", 225 | NAME: "Tomorrow-Night-Blue", 226 | }, 227 | { 228 | ID: "tomorrow-night-bright", 229 | NAME: "Tomorrow-Night-Bright", 230 | }, 231 | { 232 | ID: "tomorrow-night-eighties", 233 | NAME: "Tomorrow-Night-Eighties", 234 | }, 235 | { 236 | ID: "tomorrow-night", 237 | NAME: "Tomorrow-Night", 238 | }, 239 | { 240 | ID: "tomorrow", 241 | NAME: "Tomorrow", 242 | }, 243 | { 244 | ID: "twilight", 245 | NAME: "Twilight", 246 | }, 247 | { 248 | ID: "upstream-sunburst", 249 | NAME: "Upstream Sunburst", 250 | }, 251 | { 252 | ID: "vibrant-ink", 253 | NAME: "Vibrant Ink", 254 | }, 255 | { 256 | ID: "xcode-default", 257 | NAME: "Xcode_default", 258 | }, 259 | { 260 | ID: "zenburnesque", 261 | NAME: "Zenburnesque", 262 | }, 263 | { 264 | ID: "iplastic", 265 | NAME: "iPlastic", 266 | }, 267 | { 268 | ID: "idlefingers", 269 | NAME: "idleFingers", 270 | }, 271 | { 272 | ID: "krtheme", 273 | NAME: "krTheme", 274 | }, 275 | { 276 | ID: "monoindustrial", 277 | NAME: "monoindustrial", 278 | }, 279 | ]; 280 | -------------------------------------------------------------------------------- /src/context/AuthContext.js: -------------------------------------------------------------------------------- 1 | import { onAuthStateChanged, signOut, fetchSignInMethodsForEmail, signInWithPopup } from "firebase/auth"; 2 | import React, { useContext, useEffect, useState } from "react"; 3 | import { GithubAuthProvider, GoogleAuthProvider, auth } from "../components/firebase"; 4 | 5 | const AuthContext = React.createContext(); 6 | 7 | export function useAuth() { 8 | return useContext(AuthContext); 9 | } 10 | 11 | export function AuthProvider({ children }) { 12 | const [currentUser, setCurrentUser] = useState(null); 13 | 14 | const googleSignIn = async () => { 15 | const provider = new GoogleAuthProvider(); 16 | await signInWithPopup(auth, provider); 17 | }; 18 | 19 | const githubSignIn = async () => { 20 | const provider = new GithubAuthProvider(); 21 | 22 | try { 23 | // Attempt to sign in with GitHub 24 | const result = await signInWithPopup(auth, provider); 25 | return result.user; 26 | } catch (error) { 27 | // Check if the error is for an existing account 28 | if (error.code === "auth/account-exists-with-different-credential") { 29 | const email = error.customData.email; 30 | const signInMethods = await fetchSignInMethodsForEmail(auth, email); 31 | if (signInMethods.includes("google.com")) { 32 | // If the existing account is Google, sign in with Google instead 33 | alert("You already have an account with this email using Google. Signing you in with Google now."); 34 | const googleProvider = new GoogleAuthProvider(); 35 | const googleResult = await signInWithPopup(auth, googleProvider); 36 | return googleResult.user; 37 | } else { 38 | alert("An account already exists with this email. Please sign in using one of the other method"); 39 | } 40 | } 41 | throw error; 42 | } 43 | }; 44 | 45 | function logOut() { 46 | signOut(auth); 47 | } 48 | 49 | useEffect(() => { 50 | const unsubscribe = onAuthStateChanged(auth, (user) => { 51 | setCurrentUser(user); 52 | }); 53 | 54 | return () => unsubscribe(); 55 | }, []); 56 | 57 | return {children}; 58 | } -------------------------------------------------------------------------------- /src/hooks/useGetStars.js: -------------------------------------------------------------------------------- 1 | import { useEffect, useState } from "react"; 2 | 3 | const initialFetchState = { 4 | isLoading: false, 5 | isError: false, 6 | errorMessage: "", 7 | }; 8 | 9 | export const useGetStars = () => { 10 | const [fetchState, setFetchState] = useState(initialFetchState); 11 | const [repositoryStarts, setRepositoryStars] = useState(0); 12 | 13 | const getStars = async () => { 14 | try { 15 | setFetchState({ ...initialFetchState, isLoading: true }); 16 | const res = await fetch( 17 | "https://api.github.com/repos/DhanushNehru/CustomCodeEditor" 18 | ); 19 | if (res.status === 200) { 20 | const result = await res.json(); 21 | setRepositoryStars(result.stargazers_count); 22 | setFetchState(initialFetchState); 23 | } else 24 | throw Error("Unable to retrieve repository stars. Please try again later."); 25 | } catch (error) { 26 | setFetchState({ 27 | ...initialFetchState, 28 | isError: true, 29 | errorMessage: error.message, 30 | }); 31 | } 32 | }; 33 | 34 | useEffect(() => { 35 | getStars(); 36 | }, []); 37 | 38 | return { fetchState, repositoryStarts, getStars }; 39 | }; 40 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom/client"; 3 | import "./components/css/index.css"; 4 | import App from "./App"; 5 | 6 | const root = ReactDOM.createRoot(document.getElementById("root")); 7 | root.render( 8 | 9 | 10 | 11 | ); 12 | -------------------------------------------------------------------------------- /src/pages/EditorComponent.js: -------------------------------------------------------------------------------- 1 | import "@fortawesome/fontawesome-free/css/all.css"; 2 | import { Editor } from "@monaco-editor/react"; 3 | import { Avatar, Button, CircularProgress, styled } from "@mui/material"; 4 | import Box from "@mui/material/Box"; 5 | import { useSnackbar } from "notistack"; 6 | import React, { useCallback, useEffect, useRef, useState } from "react"; 7 | import { FaPlay, FaFileUpload, FaFileDownload } from "react-icons/fa"; 8 | // import { FaFileUpload } from "react-icons/fa"; 9 | import GithubSignIn from "../components/GithubSignIn"; 10 | import GoogleSignIn from "../components/GoogleSignIn"; 11 | import "../components/css/EditorComponent.css"; 12 | import EditorThemeSelect from "../components/js/EditorThemeSelect"; 13 | import LanguageSelect from "../components/js/LanguageSelect"; 14 | import Stars from "../components/js/Stars"; 15 | import ToggleTheme from "../components/js/ToggleTheme"; 16 | import { defineEditorTheme } from "../components/js/defineEditorTheme"; 17 | import { 18 | EDITOR_THEMES, 19 | LANGUAGES, 20 | judge0SubmitUrl, 21 | rapidApiHost, 22 | rapidApiKey, 23 | } from "../constants/constants"; 24 | import { useAuth } from "../context/AuthContext"; 25 | import Footer from "../components/Footer"; 26 | // import FileUploadIcon from "@mui/icons-material/FileUpload"; 27 | 28 | const StyledButton = styled(Button)({ 29 | display: "flex", 30 | alignItems: "center", 31 | justifyContent: "center", 32 | gap: "0.5rem", 33 | }); 34 | 35 | const StyledLayout = styled("div")(({ theme }) => ({ 36 | display: "flex", 37 | flexDirection: "column", 38 | height: "80%", 39 | margin: "0.5rem", 40 | border: `2px solid ${theme.palette.divider}`, 41 | borderRadius: "1rem", 42 | "@media (min-width: 1024px)": { 43 | flexDirection: "row", 44 | padding: "1.5rem", 45 | alignItems: "center", 46 | }, 47 | })); 48 | 49 | const OutputLayout = styled("div")(({ theme }) => ({ 50 | backgroundColor: theme.palette.background.paper, 51 | height: "50vh", 52 | margin: "1rem 0", 53 | border: `2px solid ${theme.palette.divider}`, 54 | borderRadius: "1rem", 55 | "@media (min-width: 1024px)": { 56 | height: "30vh", 57 | padding: "1rem", 58 | }, 59 | })); 60 | 61 | const WelcomeText = styled("span")(({ theme }) => ({ 62 | color: theme.palette.text.primary, 63 | fontWeight: "bold", 64 | })); 65 | 66 | function EditorComponent() { 67 | const [code, setCode] = useState(null); 68 | const [output, setOutput] = useState([]); 69 | const [currentLanguage, setCurrentLanguage] = useState( 70 | LANGUAGES[0].DEFAULT_LANGUAGE 71 | ); 72 | const [languageDetails, setLanguageDetails] = useState(LANGUAGES[0]); 73 | const [currentEditorTheme, setCurrentEditorTheme] = useState( 74 | EDITOR_THEMES[1] 75 | ); 76 | const [loading, setLoading] = useState(false); 77 | const { enqueueSnackbar } = useSnackbar(); 78 | const editorRef = useRef(null); 79 | const monacoRef = useRef(null); 80 | const { currentUser, logOut } = useAuth(); 81 | 82 | const styles = { 83 | flex: { 84 | display: "flex", 85 | flexDirection: "row", 86 | alignItems: "center", 87 | justifyContent: "space-between", 88 | }, 89 | languageDropdown: { 90 | marginTop: "1rem", 91 | display: "flex", 92 | alignItems: "center", 93 | }, 94 | "@media (min-width: 576px)": { 95 | flex: { 96 | display: "flex", 97 | flexDirection: "row", 98 | justifyContent: "space-between", 99 | alignItems: "center", 100 | gap: "0.6em", 101 | }, 102 | }, 103 | }; 104 | 105 | useEffect(() => { 106 | if (isImportingRef.current) return; 107 | 108 | const selectedLanguage = LANGUAGES.find( 109 | (lang) => lang.DEFAULT_LANGUAGE === currentLanguage 110 | ); 111 | setLanguageDetails({ 112 | ID: selectedLanguage.ID, 113 | LANGUAGE_NAME: selectedLanguage.NAME, 114 | DEFAULT_LANGUAGE: selectedLanguage.DEFAULT_LANGUAGE, 115 | NAME: selectedLanguage.NAME, 116 | }); 117 | setCode(selectedLanguage.HELLO_WORLD); 118 | }, [currentLanguage]); 119 | 120 | const handleEditorThemeChange = async (_, theme) => { 121 | if (["light", "vs-dark"].includes(theme.ID)) { 122 | setCurrentEditorTheme(theme); 123 | } else { 124 | setCurrentEditorTheme(theme); 125 | defineEditorTheme(theme).then((_) => setCurrentEditorTheme(theme)); 126 | } 127 | }; 128 | 129 | const getLanguageLogoById = (id) => { 130 | const language = LANGUAGES.find( 131 | (lang) => parseInt(lang.ID) === parseInt(id) 132 | ); 133 | return language ? language.LOGO : null; 134 | }; 135 | 136 | const submitCode = useCallback(async () => { 137 | console.log("Submitting code..."); // Debug log 138 | if (!editorRef.current) { 139 | console.log("Editor reference not available"); 140 | return; 141 | } 142 | const codeToSubmit = editorRef.current.getValue(); 143 | if (codeToSubmit === "") { 144 | enqueueSnackbar("Please enter valid code", { variant: "error" }); 145 | return; 146 | } 147 | setLoading(true); 148 | try { 149 | const encodedCode = btoa(codeToSubmit); 150 | const response = await fetch( 151 | `${judge0SubmitUrl}?base64_encoded=true&wait=false&fields=*`, 152 | { 153 | method: "POST", 154 | headers: { 155 | "Content-Type": "application/json", 156 | "X-RapidAPI-Key": rapidApiKey, 157 | "X-RapidAPI-Host": rapidApiHost, 158 | }, 159 | body: JSON.stringify({ 160 | source_code: encodedCode, 161 | language_id: languageDetails.ID, 162 | stdin: "", 163 | expected_output: "", 164 | }), 165 | } 166 | ); 167 | 168 | if (!response.ok) { 169 | enqueueSnackbar( 170 | `Failed to create submission. Status code: ${response.status}`, 171 | { variant: "error" } 172 | ); 173 | setLoading(false); 174 | return; 175 | } 176 | const data = await response.json(); 177 | const submissionId = data["token"]; 178 | 179 | setTimeout(() => { 180 | fetch( 181 | `${judge0SubmitUrl}/${submissionId}?base64_encoded=true&fields=*`, 182 | { 183 | method: "GET", 184 | headers: { 185 | "X-RapidAPI-Key": rapidApiKey, 186 | "X-RapidAPI-Host": rapidApiHost, 187 | }, 188 | } 189 | ) 190 | .then((response) => response.json()) 191 | .then((data) => { 192 | if (!data.stdout) { 193 | enqueueSnackbar("Please check the code", { variant: "error" }); 194 | setOutput(data.message); 195 | return; 196 | } 197 | const decodedOutput = atob(data.stdout); 198 | const formattedData = decodedOutput.split("\n"); 199 | setOutput(formattedData); 200 | }) 201 | .catch((error) => { 202 | enqueueSnackbar("Error retrieving output: " + error.message, { 203 | variant: "error", 204 | }); 205 | }) 206 | .finally(() => setLoading(false)); 207 | }, 2000); 208 | } catch (error) { 209 | enqueueSnackbar("Error: " + error.message, { variant: "error" }); 210 | } 211 | }, [enqueueSnackbar, languageDetails]); 212 | 213 | // import file 214 | const [isImporting, setIsImporting] = React.useState(false); 215 | const isImportingRef = useRef(false); 216 | const fileInputRef = React.useRef(null); 217 | 218 | const handleFileImport = (e) => { 219 | const file = e.target.files[0]; 220 | if (!file) return; 221 | 222 | setCode(""); 223 | if (fileInputRef.current) { 224 | fileInputRef.current.value = ""; 225 | } 226 | 227 | isImportingRef.current = true; 228 | setIsImporting(true); 229 | 230 | const extension = file.name.split(".").pop().toLowerCase(); 231 | 232 | const languageMap = { 233 | js: "Javascript", 234 | py: "Python3", 235 | cpp: "C++", 236 | java: "Java", 237 | }; 238 | 239 | const languageName = languageMap[extension]; 240 | const selectedLanguage = LANGUAGES.find( 241 | (lang) => lang.NAME === languageName 242 | ); 243 | if (!selectedLanguage) { 244 | console.error("Unsupported file type"); 245 | enqueueSnackbar("Unsupported file type", { variant: "error" }); 246 | isImportingRef.current = false; 247 | setIsImporting(false); 248 | return; 249 | } 250 | const reader = new FileReader(); 251 | reader.onload = (event) => { 252 | setCurrentLanguage(selectedLanguage.DEFAULT_LANGUAGE); 253 | setLanguageDetails({ 254 | ID: selectedLanguage.ID, 255 | NAME: selectedLanguage.NAME, 256 | DEFAULT_LANGUAGE: selectedLanguage.DEFAULT_LANGUAGE, 257 | LANGUAGE_NAME: selectedLanguage.NAME, 258 | }); 259 | setCode(event.target.result); 260 | // console.log("file code ", event.target.result); 261 | setOutput(""); 262 | setIsImporting(false); 263 | }; 264 | reader.onerror = () => { 265 | console.error("Error reading file"); 266 | isImportingRef.current = false; 267 | setIsImporting(false); 268 | }; 269 | reader.readAsText(file); 270 | }; 271 | 272 | // download file 273 | const [isDownloading, setDownloading] = React.useState(false); 274 | const exportFile = () => { 275 | if (!code) return; 276 | 277 | setDownloading(true); 278 | const fileContent = code; 279 | 280 | const extensionMap = { 281 | javascript: "js", 282 | python: "py", 283 | cpp: "cpp", 284 | java: "java", 285 | }; 286 | 287 | const extension = extensionMap[languageDetails.DEFAULT_LANGUAGE] || "txt"; 288 | 289 | const blob = new Blob([fileContent], { type: "text/plain" }); 290 | const url = URL.createObjectURL(blob); 291 | const link = document.createElement("a"); 292 | 293 | link.href = url; 294 | link.download = `code.${extension}`; 295 | document.body.appendChild(link); 296 | link.click(); 297 | 298 | document.body.removeChild(link); 299 | URL.revokeObjectURL(url); 300 | setDownloading(false); 301 | }; 302 | 303 | const handleEditorDidMount = useCallback( 304 | (editor, monaco) => { 305 | console.log("Editor mounted"); // Debug log 306 | editorRef.current = editor; 307 | monacoRef.current = monaco; 308 | editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter, () => { 309 | console.log("Ctrl+Enter pressed in editor"); 310 | submitCode(); 311 | }); 312 | }, 313 | [submitCode] 314 | ); 315 | 316 | useEffect(() => { 317 | const handleKeyDown = (event) => { 318 | if ((event.ctrlKey || event.metaKey) && event.key === "Enter") { 319 | console.log("Ctrl+Enter pressed globally"); 320 | event.preventDefault(); 321 | submitCode(); 322 | } 323 | }; 324 | 325 | document.addEventListener("keydown", handleKeyDown); 326 | 327 | return () => { 328 | document.removeEventListener("keydown", handleKeyDown); 329 | }; 330 | }, [submitCode]); 331 | 332 | useEffect(() => { 333 | if (editorRef.current && monacoRef.current) { 334 | const editor = editorRef.current; 335 | const monaco = monacoRef.current; 336 | handleEditorDidMount(editor, monaco); 337 | } 338 | }, [handleEditorDidMount]); 339 | 340 | function handleLanguageChange(_, value) { 341 | if (isImporting) return; 342 | setCurrentLanguage(value.DEFAULT_LANGUAGE); 343 | setOutput(""); 344 | setCode(code ? code : value.HELLO_WORLD); 345 | } 346 | 347 | const handleSignOut = async () => { 348 | try { 349 | await logOut(); 350 | } catch (error) { 351 | console.log(error); 352 | } 353 | }; 354 | 355 | const renderAuthenticatedContent = () => ( 356 | <> 357 | 358 | 367 |
371 | {/* import and export btn */} 372 |
373 | fileInputRef.current.click()} 375 | disabled={isImporting} 376 | sx={(theme) => ({ 377 | padding: "8px 10px", 378 | backgroundColor: theme.palette.primary.main, 379 | color: theme.palette.primary.contrastText, 380 | border: `1px solid ${theme.palette.primary.dark}`, 381 | borderRadius: "8px", 382 | fontSize: "0.875rem", 383 | fontWeight: 500, 384 | cursor: "pointer", 385 | boxShadow: "0 2px 4px rgba(0, 0, 0, 0.08)", 386 | transition: "all 0.2s ease", 387 | display: "flex", 388 | alignItems: "center", 389 | justifyContent: "center", 390 | gap: "8px", 391 | "&:hover": { 392 | backgroundColor: theme.palette.primary.dark, 393 | boxShadow: "0 4px 8px rgba(0, 0, 0, 0.12)", 394 | transform: "translateY(-1px)", 395 | }, 396 | "&:active": { 397 | transform: "translateY(0)", 398 | boxShadow: "0 2px 4px rgba(0, 0, 0, 0.1)", 399 | }, 400 | "&:disabled": { 401 | backgroundColor: theme.palette.action.disabled, 402 | color: theme.palette.action.disabledBackground, 403 | cursor: "not-allowed", 404 | transform: "none", 405 | }, 406 | "@media (max-width: 768px)": { 407 | padding: "8px 12px", 408 | fontSize: "0.8125rem", 409 | }, 410 | })} 411 | > 412 | {isImporting ? ( 413 | <> 414 | 415 | Importing... 416 | 417 | ) : ( 418 | <> 419 | 420 | Import 421 | 422 | )} 423 | 424 | 431 | 432 | ({ 435 | padding: "8px 10px", 436 | backgroundColor: theme.palette.primary.main, 437 | color: theme.palette.primary.contrastText, 438 | border: `1px solid ${theme.palette.primary.dark}`, 439 | borderRadius: "8px", 440 | fontSize: "0.875rem", 441 | fontWeight: 500, 442 | cursor: "pointer", 443 | boxShadow: "0 2px 4px rgba(0, 0, 0, 0.08)", 444 | transition: "all 0.2s ease", 445 | display: "flex", 446 | alignItems: "center", 447 | justifyContent: "center", 448 | gap: "8px", 449 | "&:hover": { 450 | backgroundColor: theme.palette.primary.dark, 451 | boxShadow: "0 4px 8px rgba(0, 0, 0, 0.12)", 452 | transform: "translateY(-1px)", 453 | }, 454 | "&:active": { 455 | transform: "translateY(0)", 456 | boxShadow: "0 2px 4px rgba(0, 0, 0, 0.1)", 457 | }, 458 | "&:disabled": { 459 | backgroundColor: theme.palette.action.disabled, 460 | color: theme.palette.action.disabledBackground, 461 | cursor: "not-allowed", 462 | transform: "none", 463 | }, 464 | "@media (max-width: 768px)": { 465 | padding: "8px 12px", 466 | fontSize: "0.8125rem", 467 | }, 468 | })} 469 | > 470 | {isDownloading ? ( 471 | <> 472 | 473 | Exporting... 474 | 475 | ) : ( 476 | <> 477 | 478 | Export 479 | 480 | )} 481 | 482 |
483 | 484 | {getLanguageLogoById(languageDetails.ID)} 485 |
486 | {languageDetails.LANGUAGE_NAME} 487 |
488 |
489 | 493 |
494 |
495 | 499 |
500 | ({ 502 | marginTop: "1rem", 503 | padding: "10px 20px", 504 | bgcolor: theme.palette.text.primary, 505 | color: theme.palette.background.default, 506 | border: "none", 507 | borderRadius: "15px", 508 | fontSize: "0.8em", 509 | cursor: "pointer", 510 | boxShadow: "0 4px 6px rgba(0, 0, 0, 0.1)", 511 | width: "50%", 512 | "@media (min-width: 1024px)": { 513 | width: "100%", 514 | }, 515 | })} 516 | onClick={submitCode} 517 | variant="contained" 518 | color="primary" 519 | disabled={loading} 520 | > 521 | 522 | {loading ? : } 523 | 524 | Run {languageDetails.LANGUAGE_NAME} 525 | 526 |
527 |
528 | 529 | {Array.isArray(output) && 530 | output.map((result, i) =>
{result}
)} 531 |
532 | 533 | ); 534 | 535 | const renderUnauthenticatedContent = () => ( 536 |
545 |

Please sign in to use the Code Editor

546 | 547 |
548 | 549 |
550 | ); 551 | 552 | return ( 553 |
554 | ({ 557 | height: "auto", 558 | margin: "0.5rem", 559 | paddingLeft: "0.5rem", 560 | paddingRight: "0.5rem", 561 | border: `2px solid ${theme.palette.divider}`, 562 | borderRadius: "1rem", 563 | }), 564 | ]} 565 | > 566 |
567 |
568 | Custom Code Editor icon 574 | 585 | Custom Code Editor 586 | 587 |
588 | 589 | 590 | {currentUser && ( 591 |
592 |
593 | <> 594 | Welcome, {currentUser.displayName} 595 | 605 |
606 | 609 |
610 | 611 |
612 |
613 | )} 614 |
615 |
616 | {currentUser 617 | ? renderAuthenticatedContent() 618 | : renderUnauthenticatedContent()} 619 |
620 |
622 |
623 | ); 624 | } 625 | 626 | export default EditorComponent; 627 | -------------------------------------------------------------------------------- /src/theme.js: -------------------------------------------------------------------------------- 1 | import { createTheme } from "@mui/material/styles"; 2 | 3 | const theme = createTheme({ 4 | colorSchemes: { 5 | dark: { 6 | palette: { 7 | primary: { 8 | main: "#2F1888", 9 | }, 10 | secondary: { 11 | main: "#2837BA", 12 | }, 13 | divider: ["#868e96"] 14 | } 15 | } 16 | }, 17 | palette: { 18 | primary: { 19 | main: "#2F1888", 20 | }, 21 | secondary: { 22 | main: "#2837BA", 23 | }, 24 | divider: ["#868e96"] 25 | }, 26 | typography: { 27 | h1: { 28 | fontSize: "2rem", 29 | }, 30 | fontFamily: ["Poppins"], 31 | }, 32 | }); 33 | 34 | export default theme; --------------------------------------------------------------------------------