├── .babelrc ├── .github ├── FUNDING.yml └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── .prettierrc ├── CNAME ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── app ├── App.js ├── components │ ├── CardMenu.js │ ├── ConfirmDialog.js │ ├── DataErrorAlert.js │ ├── EditCard.js │ ├── Flashcards.js │ ├── HeaderMenu.js │ ├── Settings.js │ ├── StudyMode.js │ ├── Table.js │ ├── ViewCards.js │ └── ViewMode.js ├── index.html ├── lib │ └── FlashcardsManager.js ├── main.js └── stylesheets │ └── main.scss ├── demo.ext.json ├── dist ├── dist.css ├── dist.css.map ├── dist.js ├── dist.js.map ├── highlight.js │ └── 9.18.1 │ │ └── styles │ │ ├── github-gist.min.css │ │ └── googlecode.min.css ├── icons │ ├── ic-close.svg │ ├── ic-help.svg │ ├── ic-print.svg │ ├── ic-settings.svg │ └── ic-undo.svg ├── index.html └── katex │ ├── latest │ ├── README.md │ ├── contrib │ │ ├── auto-render.js │ │ ├── auto-render.min.js │ │ ├── auto-render.mjs │ │ ├── copy-tex.css │ │ ├── copy-tex.js │ │ ├── copy-tex.min.css │ │ ├── copy-tex.min.js │ │ ├── copy-tex.mjs │ │ ├── mathtex-script-type.js │ │ ├── mathtex-script-type.min.js │ │ ├── mathtex-script-type.mjs │ │ ├── mhchem.js │ │ ├── mhchem.min.js │ │ ├── mhchem.mjs │ │ ├── render-a11y-string.js │ │ ├── render-a11y-string.min.js │ │ └── render-a11y-string.mjs │ ├── fonts │ │ ├── KaTeX_AMS-Regular.ttf │ │ ├── KaTeX_AMS-Regular.woff │ │ ├── KaTeX_AMS-Regular.woff2 │ │ ├── KaTeX_Caligraphic-Bold.ttf │ │ ├── KaTeX_Caligraphic-Bold.woff │ │ ├── KaTeX_Caligraphic-Bold.woff2 │ │ ├── KaTeX_Caligraphic-Regular.ttf │ │ ├── KaTeX_Caligraphic-Regular.woff │ │ ├── KaTeX_Caligraphic-Regular.woff2 │ │ ├── KaTeX_Fraktur-Bold.ttf │ │ ├── KaTeX_Fraktur-Bold.woff │ │ ├── KaTeX_Fraktur-Bold.woff2 │ │ ├── KaTeX_Fraktur-Regular.ttf │ │ ├── KaTeX_Fraktur-Regular.woff │ │ ├── KaTeX_Fraktur-Regular.woff2 │ │ ├── KaTeX_Main-Bold.ttf │ │ ├── KaTeX_Main-Bold.woff │ │ ├── KaTeX_Main-Bold.woff2 │ │ ├── KaTeX_Main-BoldItalic.ttf │ │ ├── KaTeX_Main-BoldItalic.woff │ │ ├── KaTeX_Main-BoldItalic.woff2 │ │ ├── KaTeX_Main-Italic.ttf │ │ ├── KaTeX_Main-Italic.woff │ │ ├── KaTeX_Main-Italic.woff2 │ │ ├── KaTeX_Main-Regular.ttf │ │ ├── KaTeX_Main-Regular.woff │ │ ├── KaTeX_Main-Regular.woff2 │ │ ├── KaTeX_Math-BoldItalic.ttf │ │ ├── KaTeX_Math-BoldItalic.woff │ │ ├── KaTeX_Math-BoldItalic.woff2 │ │ ├── KaTeX_Math-Italic.ttf │ │ ├── KaTeX_Math-Italic.woff │ │ ├── KaTeX_Math-Italic.woff2 │ │ ├── KaTeX_SansSerif-Bold.ttf │ │ ├── KaTeX_SansSerif-Bold.woff │ │ ├── KaTeX_SansSerif-Bold.woff2 │ │ ├── KaTeX_SansSerif-Italic.ttf │ │ ├── KaTeX_SansSerif-Italic.woff │ │ ├── KaTeX_SansSerif-Italic.woff2 │ │ ├── KaTeX_SansSerif-Regular.ttf │ │ ├── KaTeX_SansSerif-Regular.woff │ │ ├── KaTeX_SansSerif-Regular.woff2 │ │ ├── KaTeX_Script-Regular.ttf │ │ ├── KaTeX_Script-Regular.woff │ │ ├── KaTeX_Script-Regular.woff2 │ │ ├── KaTeX_Size1-Regular.ttf │ │ ├── KaTeX_Size1-Regular.woff │ │ ├── KaTeX_Size1-Regular.woff2 │ │ ├── KaTeX_Size2-Regular.ttf │ │ ├── KaTeX_Size2-Regular.woff │ │ ├── KaTeX_Size2-Regular.woff2 │ │ ├── KaTeX_Size3-Regular.ttf │ │ ├── KaTeX_Size3-Regular.woff │ │ ├── KaTeX_Size3-Regular.woff2 │ │ ├── KaTeX_Size4-Regular.ttf │ │ ├── KaTeX_Size4-Regular.woff │ │ ├── KaTeX_Size4-Regular.woff2 │ │ ├── KaTeX_Typewriter-Regular.ttf │ │ ├── KaTeX_Typewriter-Regular.woff │ │ └── KaTeX_Typewriter-Regular.woff2 │ ├── katex.css │ ├── katex.js │ ├── katex.min.css │ ├── katex.min.js │ └── katex.mjs │ └── v0.11.1 │ ├── README.md │ ├── contrib │ ├── auto-render.js │ ├── auto-render.min.js │ ├── auto-render.mjs │ ├── copy-tex.css │ ├── copy-tex.js │ ├── copy-tex.min.css │ ├── copy-tex.min.js │ ├── copy-tex.mjs │ ├── mathtex-script-type.js │ ├── mathtex-script-type.min.js │ ├── mathtex-script-type.mjs │ ├── mhchem.js │ ├── mhchem.min.js │ ├── mhchem.mjs │ ├── render-a11y-string.js │ ├── render-a11y-string.min.js │ └── render-a11y-string.mjs │ ├── fonts │ ├── KaTeX_AMS-Regular.ttf │ ├── KaTeX_AMS-Regular.woff │ ├── KaTeX_AMS-Regular.woff2 │ ├── KaTeX_Caligraphic-Bold.ttf │ ├── KaTeX_Caligraphic-Bold.woff │ ├── KaTeX_Caligraphic-Bold.woff2 │ ├── KaTeX_Caligraphic-Regular.ttf │ ├── KaTeX_Caligraphic-Regular.woff │ ├── KaTeX_Caligraphic-Regular.woff2 │ ├── KaTeX_Fraktur-Bold.ttf │ ├── KaTeX_Fraktur-Bold.woff │ ├── KaTeX_Fraktur-Bold.woff2 │ ├── KaTeX_Fraktur-Regular.ttf │ ├── KaTeX_Fraktur-Regular.woff │ ├── KaTeX_Fraktur-Regular.woff2 │ ├── KaTeX_Main-Bold.ttf │ ├── KaTeX_Main-Bold.woff │ ├── KaTeX_Main-Bold.woff2 │ ├── KaTeX_Main-BoldItalic.ttf │ ├── KaTeX_Main-BoldItalic.woff │ ├── KaTeX_Main-BoldItalic.woff2 │ ├── KaTeX_Main-Italic.ttf │ ├── KaTeX_Main-Italic.woff │ ├── KaTeX_Main-Italic.woff2 │ ├── KaTeX_Main-Regular.ttf │ ├── KaTeX_Main-Regular.woff │ ├── KaTeX_Main-Regular.woff2 │ ├── KaTeX_Math-BoldItalic.ttf │ ├── KaTeX_Math-BoldItalic.woff │ ├── KaTeX_Math-BoldItalic.woff2 │ ├── KaTeX_Math-Italic.ttf │ ├── KaTeX_Math-Italic.woff │ ├── KaTeX_Math-Italic.woff2 │ ├── KaTeX_SansSerif-Bold.ttf │ ├── KaTeX_SansSerif-Bold.woff │ ├── KaTeX_SansSerif-Bold.woff2 │ ├── KaTeX_SansSerif-Italic.ttf │ ├── KaTeX_SansSerif-Italic.woff │ ├── KaTeX_SansSerif-Italic.woff2 │ ├── KaTeX_SansSerif-Regular.ttf │ ├── KaTeX_SansSerif-Regular.woff │ ├── KaTeX_SansSerif-Regular.woff2 │ ├── KaTeX_Script-Regular.ttf │ ├── KaTeX_Script-Regular.woff │ ├── KaTeX_Script-Regular.woff2 │ ├── KaTeX_Size1-Regular.ttf │ ├── KaTeX_Size1-Regular.woff │ ├── KaTeX_Size1-Regular.woff2 │ ├── KaTeX_Size2-Regular.ttf │ ├── KaTeX_Size2-Regular.woff │ ├── KaTeX_Size2-Regular.woff2 │ ├── KaTeX_Size3-Regular.ttf │ ├── KaTeX_Size3-Regular.woff │ ├── KaTeX_Size3-Regular.woff2 │ ├── KaTeX_Size4-Regular.ttf │ ├── KaTeX_Size4-Regular.woff │ ├── KaTeX_Size4-Regular.woff2 │ ├── KaTeX_Typewriter-Regular.ttf │ ├── KaTeX_Typewriter-Regular.woff │ └── KaTeX_Typewriter-Regular.woff2 │ ├── katex.css │ ├── katex.js │ ├── katex.min.css │ ├── katex.min.js │ └── katex.mjs ├── index.html ├── package-lock.json ├── package.json ├── sample.ext.json └── webpack.config.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ "@babel/preset-env", "@babel/preset-react"], 3 | "plugins": [ 4 | "@babel/plugin-proposal-class-properties" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: theodorechu # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 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 | otechie: # Replace with a single Otechie username 12 | custom: ['https://www.paypal.me/theodorechu'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | 6 | # Runtime data 7 | pids 8 | *.pid 9 | *.seed 10 | *.pid.lock 11 | 12 | ext.json 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 21 | .grunt 22 | 23 | # nyc test coverage 24 | .nyc_output 25 | 26 | # Optional npm cache directory 27 | .npm 28 | 29 | # Optional REPL history 30 | .node_repl_history 31 | 32 | # node-waf configuration 33 | .lock-wscript 34 | 35 | # Dependency directory 36 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 37 | node_modules 38 | 39 | ## building output directory 40 | build 41 | 42 | # OSX 43 | .DS_Store 44 | 45 | # Packaged and compiled files 46 | .eslintcache 47 | 48 | # Env configuration 49 | .env 50 | 51 | # Editor 52 | .idea 53 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true 3 | } 4 | -------------------------------------------------------------------------------- /CNAME: -------------------------------------------------------------------------------- 1 | demo.flashcardeditor.com -------------------------------------------------------------------------------- /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, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, 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 coc@theochu.com. 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 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flashcard Editor 2 | 3 |
4 | 5 | [![Release](https://img.shields.io/github/release/theodorechu/flashcard-editor.svg)](https://github.com/theodorechu/flashcard-editor/releases) 6 | [![License](https://img.shields.io/github/license/theodorechu/flashcard-editor?color=blue)](https://github.com/theodorechu/flashcard-editor/blob/develop/LICENSE) 7 | [![Not ready for use](https://img.shields.io/badge/ready%20for%20use%3F-no-red)](https://github.com/theodorechu/flashcard-editor#development) 8 | [![Status](https://img.shields.io/badge/status-not%20ready-orange.svg)](https://appendeditor.com/#installation) 9 | [![Cost](https://img.shields.io/badge/cost-free-darkgreen.svg)](https://appendeditor.com/#installation) 10 | [![GitHub issues](https://img.shields.io/github/issues/theodorechu/flashcard-editor.svg)](https://github.com/theodorechu/flashcard-editor/issues/) 11 | [![Slack](https://img.shields.io/badge/slack-standardnotes-CC2B5E.svg?style=flat&logo=slack)](https://standardnotes.org/slack) 12 | [![Downloads](https://img.shields.io/github/downloads/theodorechu/flashcard-editor/total.svg)](https://github.com/theodorechu/flashcard-editor/releases) 13 | [![GitHub Stars](https://img.shields.io/github/stars/theodorechu/flashcard-editor?style=social)](https://github.com/theodorechu/flashcard-editor) 14 | 15 |
16 | 17 | ## Introduction 18 | 19 | The Flashcard Editor is an **unofficial** [editor](https://standardnotes.org/help/77/what-are-editors) for [Standard Notes](https://standardnotes.org), a free, [open-source](https://standardnotes.org/knowledge/5/what-is-free-and-open-source-software), and [end-to-end encrypted](https://standardnotes.org/knowledge/2/what-is-end-to-end-encryption) notes app. It is currently in development and not ready for use. :smile: 20 | 21 | You can find the beta demo at [demo.flashcardeditor.com](https://demo.flashcardeditor.com). 22 | 23 | The editor supports Markdown, $\LaTeX/ \KaTeX$, emoji codes, syntax highlighting, inline HTML, table of contents, footnotes, auto-linking, and more. 24 | 25 | ## Features 26 | 27 | - [Markdown](https://guides.github.com/features/mastering-markdown/) support provided by [Unified/Remark](https://github.com/remarkjs/remark) 28 | - $\LaTeX/\KaTeX$ provided by hosted [KaTeX](https://github.com/KaTeX/KaTeX) 29 | - Emojis provided by [emoji codes](https://github.com/ikatyang/emoji-cheat-sheet/blob/master/README.md) 30 | - Google Code and GitHub Gist flavored Syntax Highlighting provided by [highlight.js](https://github.com/highlightjs/highlight.js) stylesheets 31 | - Table of Contents (links don't work on mobile) provided by [Remark TOC](https://github.com/remarkjs/remark-toc) 32 | - Footnotes (links don't work on mobile) provided by [Remark footnotes](https://github.com/remarkjs/remark-footnotes) 33 | - Notes are stored in plaintext (great for longevity) 34 | 35 | ## Installation 36 | 37 | 1. Register for an account at Standard Notes using the [Desktop App](https://standardnotes.org/download) or [Web app](https://app.standardnotes.org). Remember to use a strong and memorable password. 38 | 1. Click **Extensions** in the lower left corner. 39 | 1. Click **Import Extension**. 40 | 1. Paste this into the box: 41 | ``` 42 | https://raw.githubusercontent.com/TheodoreChu/flashcard-editor/develop/demo.ext.json 43 | ``` 44 | Alternatively, paste this link: 45 | ``` 46 | https://notes.theochu.com/p/FV2A4HJFRN 47 | ``` 48 | 1. Press Enter or Return on your keyboard. 49 | 1. Click **Install**. 50 | 1. At the top of your note, click **Editor**, then click **Flashcard Editor - Beta**. 51 | 52 | After you have installed the editor on the web or desktop app, it will automatically sync to your [mobile app](https://standardnotes.org/download) after you log in. 53 | 54 | ## Development 55 | 56 | The instructions for local setup can be found [here](https://docs.standardnotes.org/extensions/local-setup). All commands are performed in the root directory: 57 | 58 | 1. Fork the [repository](https://github.com/theodorechu/flashcard-editor) on GitHub 59 | 2. [Clone](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository) your fork of the repository 60 | 3. Type `cd flashcard-editor` 61 | 4. Run `npm install` to locally install the packages in `package.json` 62 | 5. Create `ext.json` as shown [here](https://docs.standardnotes.org/extensions/local-setup) with `url: "http://localhost:8002"`. Optionally, create your `ext.json` as a copy of `sample.ext.json`. 63 | 6. Install http-server using `sudo npm install -g http-server` 64 | 7. Start the server at `http://localhost:8002` using `npm run server` 65 | 8. Import the extension into the [web](https://app.standardnotes.org) or [desktop](https://standardnotes.org/download) app with `http://localhost:8002/ext.json`. 66 | 9. To build the editor, open another command window and run `npm run build`. For live builds, use `npm run watch`. You can also run `npm run start` and open the editor at `http://localhost:8080`. 67 | 68 | ## License 69 | 70 | Copyright (c) Theodore Chu. All Rights Reserved. Licensed under [AGPL-3.0](https://github.com/TheodoreChu/flashcard-editor/blob/develop/LICENSE) or later. 71 | 72 | ## Further Resources 73 | 74 | - [GitHub](https://github.com/TheodoreChu/flashcard-editor) for the source code of the Flashcard Editor 75 | - [GitHub Issues](https://github.com/TheodoreChu/flashcard-editor/issues) for reporting issues concerning the Flashcard Editor 76 | - [Docs](https://docs.theochu.com/flashcard-editor) for how to use the Flashcard Editor 77 | - [Contact](https://theochu.com/contact) for how to contact the developer of the Flashcard Editor 78 | - [Flashcard Editor To do List](https://github.com/TheodoreChu/flashcard-editor/projects/1) for the roadmap of the Flashcard Editor 79 | - [Standard Notes Slack](https://standardnotes.org/slack) for connecting with the Standard Notes Community 80 | - [Standard Notes Help](https://standardnotes.org/help) for help with issues related to Standard Notes but unrelated to this editor 81 | -------------------------------------------------------------------------------- /app/App.js: -------------------------------------------------------------------------------- 1 | import 'regenerator-runtime/runtime'; 2 | import React from 'react'; 3 | import Flashcards from './components/Flashcards'; 4 | 5 | export default class App extends React.Component { 6 | constructor(props) { 7 | super(props); 8 | } 9 | 10 | render() { 11 | return ( 12 |
13 | 14 |
15 | ); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/components/CardMenu.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | export default class CardMenu extends React.Component { 4 | constructor(props) { 5 | super(props); 6 | 7 | this.state = { 8 | show: false, 9 | }; 10 | } 11 | 12 | onToggle = () => { 13 | this.setState({ 14 | show: !this.state.show, 15 | }); 16 | }; 17 | 18 | onEdit = () => { 19 | this.onToggle(); 20 | this.props.onEdit(); 21 | }; 22 | 23 | onRemove = () => { 24 | this.onToggle(); 25 | this.props.onRemove(); 26 | }; 27 | 28 | render() { 29 | const { onFlip } = this.props; 30 | 31 | return ( 32 |
33 |
34 |
•••
35 |
36 | {this.state.show && [ 37 | //
, 38 |
39 |
40 |
Mark
41 |
42 |
43 |
Flip
44 |
45 |
46 |
Edit
47 |
48 |
49 |
Remove
50 |
51 |
, 52 | ]} 53 |
54 | ); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/components/ConfirmDialog.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const ConfirmDialog = ({ title, message, onConfirm, onCancel }) => ( 4 |
5 |
6 |
7 |
{title}
8 |
9 |
10 |
11 |
12 |
{message}
13 |
14 |
15 |
16 |
17 |
18 | 21 | 24 |
25 |
26 |
27 |
28 | ); 29 | 30 | export default ConfirmDialog; 31 | -------------------------------------------------------------------------------- /app/components/DataErrorAlert.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | const DataErrorAlert = () => ( 4 |
5 |
6 |
7 |
Invalid Note
8 |
9 |
10 |
11 |
12 |
13 | The note you selected already has existing data that is not valid 14 | with this editor. Please clear the note, or select a new one, and 15 | try again. 16 |
17 |
18 |
19 |
20 |
21 |
22 | ); 23 | 24 | export default DataErrorAlert; 25 | -------------------------------------------------------------------------------- /app/components/EditCard.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | let keyMap = new Map(); 4 | 5 | export default class EditCard extends React.Component { 6 | static defaultProps = { 7 | entry: { 8 | forward: true, 9 | reverse: true, 10 | timeLeft: 0, 11 | }, 12 | }; 13 | 14 | constructor(props) { 15 | super(props); 16 | 17 | this.state = { 18 | id: this.props.id, 19 | entry: this.props.entry, 20 | }; 21 | } 22 | 23 | handleInputChange = (event) => { 24 | const target = event.target; 25 | const name = target.name; 26 | const value = target.value; 27 | 28 | this.setState((state) => ({ 29 | entry: { ...state.entry, [name]: value }, 30 | })); 31 | }; 32 | 33 | onSave = (e) => { 34 | e.preventDefault(); 35 | const { id, entry } = this.state; 36 | this.props.onSave({ id, entry }); 37 | this.setState( 38 | { 39 | id: null, 40 | entry: {}, 41 | }, 42 | () => { 43 | // Clear the text areas 44 | var x = document.getElementsByTagName('textarea'); 45 | var i; 46 | for (i = 0; i < x.length; i++) { 47 | x[i].value = ''; 48 | } 49 | const textAreaSide1 = document.getElementById('textAreaSide1'); 50 | textAreaSide1.focus(); 51 | } 52 | ); 53 | }; 54 | 55 | // this is the default behavior for 'input' boxes but not 'textarea' 56 | // we want it to be control + enter 57 | onKeyDown = (e) => { 58 | keyMap.set(e.key, true); 59 | //const submit = document.querySelector('#submit'); 60 | console.log( 61 | 'keydown control: ' + 62 | keyMap.get('Control') + 63 | 'enter: ' + 64 | keyMap.get('Enter') 65 | ); 66 | if (keyMap.get('Control') && keyMap.get('Enter')) { 67 | e.preventDefault(); 68 | keyMap.set('Control', false); 69 | keyMap.set('Enter', false); 70 | this.onSave(e); 71 | //submit.click(); 72 | //alert('You pressed Control and Enter'); 73 | } else if (keyMap.get('Control') && keyMap.get('s')) { 74 | e.preventDefault(); 75 | keyMap.set('Control', false); 76 | keyMap.set('s', false); 77 | this.onSave(e); 78 | } else if (keyMap.get('Escape')) { 79 | e.preventDefault(); 80 | keyMap.set('Escape', false); 81 | this.props.onCancel(); 82 | } 83 | }; 84 | 85 | onKeyUp = (e) => { 86 | keyMap.set(e.key, false); 87 | }; 88 | 89 | render() { 90 | const { id, entry } = this.state; 91 | 92 | return ( 93 |
94 |
95 |
96 |
97 | {id != null ? 'Edit card' : 'Add new card'} 98 |
99 |
100 | Side 1: 101 |