Goal:
Let users save selected code from any webpage directly into StashSnip via a right click context menu.
User story:
As a user, I want to right click selected code on any page so that I can save it without switching apps.
Depends on:
#25 this needs an API endpoint to POST snippets to before work can start.
Tasks:
- Build a minimal browser extension using Manifest V3
- Add a right click context menu entry that only appears when text is selected (e.g. "Save selection to StashSnip")
- On click, grab the current text selection (window.getSelection() in the content script)
- Show a small popup/prompt for title, language and tags before saving; don't save automatically with no metadata
- POST the snippet to the StashSnip API endpoint
- Handle the case where the API request fails (show an error in the popup, don't fail silently)
- Handle authentication/API key if the API requires one (confirm approach with maintainer before starting, since the API issue may not have this decided yet)
- Target both Firefox and Chrome/Edge from the start using the webextension-polyfill library for cross browser API compatibility, rather than building Chrome-only and porting later
- If cross browser from day one isn't feasible, build Firefox first (maintainer's primary browser) with Chrome/Edge as an explicit follow up issue
Acceptance Criteria:
- Right click menu option only appears when text is actually selected, not on every right click
- Selecting code on any webpage and completing the popup form successfully creates a new snippet
- A failed save (e.g. API down, network error) shows a clear error message in the extension popup, not a silent failure
- Saved snippet appears correctly in the main app afterward, with the correct title, language, tags and code intact
- Works on Firefox and Chrome/Edge
- Extension requires no more permissions than necessary (avoid requesting broad host permissions if activeTab is sufficient)
Goal:
Let users save selected code from any webpage directly into StashSnip via a right click context menu.
User story:
As a user, I want to right click selected code on any page so that I can save it without switching apps.
Depends on:
#25 this needs an API endpoint to POST snippets to before work can start.
Tasks:
Acceptance Criteria: