Skip to content

Define: look up the selected word in Wiktionary - #21

Merged
Kevin-Taha merged 1 commit into
mainfrom
kevin-taha-define-from-the-book
Nov 11, 2026
Merged

Kevin-Taha merged 1 commit into
mainfrom
kevin-taha-define-from-the-book

Conversation

@Kevin-Taha

Copy link
Copy Markdown
Owner

Select a word or short phrase (up to four words) and press D, or the new Define icon in the selection toolbar, to see its dictionary entry in a card beside the selection.

What's in it

  • Dictionary card: definitions from Wiktionary's REST API, grouped by part of speech (three senses each at most), with a link to the full entry. "plural of vector" entries link the base word, which opens in the same card. A capitalised word with no English entry ("Impulse" at the start of a sentence) is retried in lower case. If there's no English entry, the card shows the first language that has one.
  • States: looking up, no entry, and couldn't reach the dictionary (offline).
  • Closing: Esc, clicking outside, scrolling the page or resizing the window closes the card. Esc only closes the card, not focus mode or the Return pill.
  • Selection toolbar is icon-only: Add margin note and Define are now icon buttons, with their names and keys in tooltips, aria-label and aria-keyshortcuts.
  • Shortcut: D is in the shortcuts dialog, the README and the roadmap.

Privacy and CSP

This is the app's first network request of its own. Only the selected word is sent, to en.wiktionary.org, and only when the reader asks. connect-src now allows https://en.wiktionary.org, and the privacy section of docs/DATA.md says so. Results are cached in memory for the session. The service worker ignores other origins, so nothing changes there.

Not included

  • An optional offline dictionary download. It's listed in the roadmap as a follow-up.

Testing

  • Unit tests for parsing (stripping HTML, "form of" entries, falling back to another language) and for lookups (caching, the lower-case retry, 404, network errors, 5xx).
  • An end-to-end spec with Wiktionary mocked through page.route, run against the production build, so it also checks that the CSP allows the request. It covers the toolbar button, D, Esc, no entry, and long selections not offering Define.
  • Type-check, lint and the unit suite pass. The new spec and the notes, review, highlights, discoverability and CSP specs pass.

Select a word or short phrase and press D (or the Define icon in the
selection toolbar) for a dictionary card: senses by part of speech,
'plural of X' links that look up X, and a link to the full entry.
Only the word is sent, to Wiktionary; the CSP and privacy note say so.
The selection toolbar's note and define actions are now icon-only,
with names and keys in their tooltips.

Co-authored-by: Copilot App <[email protected]>
@Kevin-Taha
Kevin-Taha merged commit 12f578a into main Nov 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant