You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow annotation creation without a prior selection
When grading, the context menu previously disabled all annotation
creation options if no region was selected. Graders can now create
annotations at any time; a fallback selection is synthesized
automatically:
- Text/code: first character of the first non-empty line
- HTML/Jupyter: first character of the first text node in the iframe
- Image: 40×40 px box centred at the right-click position
- PDF: 40×40 box centred at the right-click position (with
rotation correction), in COORDINATE_MULTIPLIER-scaled percentage space
If no fallback can be synthesized (empty file, no text content, etc.)
an I18n alert is shown instead of silently failing.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- CSS/SCSS source: `app/assets/stylesheets/`; built by a separate Sass watcher
27
+
28
+
To verify changes compile (fast — skips minification):
29
+
```bash
30
+
docker compose run --rm webpack node_modules/.bin/webpack --config webpack.development.js --no-watch
31
+
```
32
+
33
+
To do a one-shot production build (JS + CSS bundled together, slow):
34
+
```bash
35
+
docker compose run --rm webpack node_modules/.bin/webpack --config webpack.production.js --no-watch
36
+
```
37
+
38
+
**Always use the `webpack` service (not `rails`) and pass `--no-watch`** — using the `rails` service or omitting `--no-watch` enables watch mode and the process never terminates.
39
+
40
+
## JS tests
41
+
42
+
```bash
43
+
docker compose run --rm rails npx jest # all JS tests
44
+
docker compose run --rm rails npx jest path/to/test # specific file
45
+
```
46
+
47
+
## Jest testing conventions
48
+
49
+
Test files live in `app/javascript/Components/__tests__/` and match `**/__tests__/*.test.[jt]s?(x)` (see `jest.config.js`).
50
+
51
+
### Importing legacy IIFE scripts
52
+
53
+
Some JS lives in `app/assets/javascripts/` as plain IIFEs (not ES modules) — e.g. `Annotations/pdf_annotation_manager.js`, `Annotations/globals.js`. To use them in Jest, require them for their side-effects:
// Note: 3 levels up reaches app/, then into assets/javascripts/
59
+
```
60
+
61
+
The IIFE assigns to `window.X`, so access the export as `window.PdfAnnotationManager` after requiring.
62
+
63
+
### Globals defined by legacy scripts
64
+
65
+
`app/assets/javascripts/Annotations/globals.js` assigns bare globals (`annotation_type`, `ANNOTATION_TYPES`, `annotation_manager`, etc.) to `window`. These are not in the Jest module graph. Set them manually in `beforeEach`:
jQuery UI plugins used in production code (like `ui-contextmenu`) are available as npm dependencies but may need mocking for test isolation. Capture the options object by spying before calling the setup function:
0 commit comments