|
1 | | -# React + TypeScript + Vite |
| 1 | +# Mothra Annotator |
2 | 2 |
|
3 | | -This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. |
| 3 | +A browser-based image annotation tool for creating bounding box annotations on document images. Built for annotating text, music, and staves regions in scanned documents and sheet music. |
4 | 4 |
|
5 | | -Currently, two official plugins are available: |
| 5 | +**Live demo:** [https://ddmal.ca/mothra-annotator/](https://ddmal.ca/mothra-annotator/) |
6 | 6 |
|
7 | | -- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh |
8 | | -- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh |
| 7 | +## Key Features |
9 | 8 |
|
10 | | -## React Compiler |
| 9 | +- **Bounding box annotation** — Draw, move, and resize bounding boxes directly on images |
| 10 | +- **Three annotation classes** — Text, Music, and Staves, each with a distinct color and keyboard shortcut (`1`, `2`, `3`) |
| 11 | +- **Draw and Select modes** — Switch between creating new boxes (`D`) and selecting/editing existing ones (`V`) |
| 12 | +- **Resize handles** — 8-handle hit testing for precise box adjustments |
| 13 | +- **Zoom and pan** — Scroll to pan, Shift+Scroll to zoom, or use `+`/`-` keys; press `0` to reset view |
| 14 | +- **Class filter toggles** — Show or hide annotations by class |
| 15 | +- **Label visibility toggle** — Press `L` to show/hide annotation labels |
| 16 | +- **Undo support** — `Ctrl/Cmd+Z` to undo actions |
| 17 | +- **Auto-save** — Annotations persist to localStorage automatically |
| 18 | +- **Export formats** — Export as JSON (full session) or YOLO (normalized center-format with 0-indexed class IDs), with ZIP support for batch export |
| 19 | +- **Import** — Load previously exported JSON annotations |
| 20 | +- **Quick save** — `Ctrl/Cmd+S` to download annotations as JSON |
| 21 | +- **Keyboard-driven workflow** — Shortcuts for class selection, mode switching, deletion (`Delete`/`Backspace`), and more |
11 | 22 |
|
12 | | -The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation). |
| 23 | +## Tech Stack |
13 | 24 |
|
14 | | -## Expanding the ESLint configuration |
| 25 | +React 19, TypeScript, Vite 7, Tailwind CSS 4, Zustand |
15 | 26 |
|
16 | | -If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules: |
| 27 | +## Getting Started |
17 | 28 |
|
18 | | -```js |
19 | | -export default defineConfig([ |
20 | | - globalIgnores(['dist']), |
21 | | - { |
22 | | - files: ['**/*.{ts,tsx}'], |
23 | | - extends: [ |
24 | | - // Other configs... |
25 | | - |
26 | | - // Remove tseslint.configs.recommended and replace with this |
27 | | - tseslint.configs.recommendedTypeChecked, |
28 | | - // Alternatively, use this for stricter rules |
29 | | - tseslint.configs.strictTypeChecked, |
30 | | - // Optionally, add this for stylistic rules |
31 | | - tseslint.configs.stylisticTypeChecked, |
32 | | - |
33 | | - // Other configs... |
34 | | - ], |
35 | | - languageOptions: { |
36 | | - parserOptions: { |
37 | | - project: ['./tsconfig.node.json', './tsconfig.app.json'], |
38 | | - tsconfigRootDir: import.meta.dirname, |
39 | | - }, |
40 | | - // other options... |
41 | | - }, |
42 | | - }, |
43 | | -]); |
| 29 | +```bash |
| 30 | +npm install |
| 31 | +npm run dev |
44 | 32 | ``` |
45 | 33 |
|
46 | | -You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules: |
| 34 | +## Scripts |
47 | 35 |
|
48 | | -```js |
49 | | -// eslint.config.js |
50 | | -import reactX from 'eslint-plugin-react-x'; |
51 | | -import reactDom from 'eslint-plugin-react-dom'; |
52 | | - |
53 | | -export default defineConfig([ |
54 | | - globalIgnores(['dist']), |
55 | | - { |
56 | | - files: ['**/*.{ts,tsx}'], |
57 | | - extends: [ |
58 | | - // Other configs... |
59 | | - // Enable lint rules for React |
60 | | - reactX.configs['recommended-typescript'], |
61 | | - // Enable lint rules for React DOM |
62 | | - reactDom.configs.recommended, |
63 | | - ], |
64 | | - languageOptions: { |
65 | | - parserOptions: { |
66 | | - project: ['./tsconfig.node.json', './tsconfig.app.json'], |
67 | | - tsconfigRootDir: import.meta.dirname, |
68 | | - }, |
69 | | - // other options... |
70 | | - }, |
71 | | - }, |
72 | | -]); |
73 | | -``` |
| 36 | +| Command | Description | |
| 37 | +| -------------------- | ---------------------------------------- | |
| 38 | +| `npm run dev` | Start Vite dev server with HMR | |
| 39 | +| `npm run build` | Type-check and build for production | |
| 40 | +| `npm run lint` | Run ESLint | |
| 41 | +| `npm run format` | Format with Prettier | |
| 42 | +| `npm run deploy` | Build and deploy to GitHub Pages | |
0 commit comments