side-notes/openspec/changes/archive/2026-08-03-add-notes-extension/specs/note-editor/spec.md

60 lines
3.6 KiB
Markdown
Raw Normal View History

2026-08-03 17:54:16 +02:00
## Purpose
Provides the per-tab side panel where a user reads and edits the markdown note for the current page, preserving native text-editing behavior and staying consistent when the same note is open in more than one tab.
## ADDED Requirements
### Requirement: Side panel scoped to a browser tab
The system SHALL provide a side panel, opened via the toolbar action or a keyboard shortcut, that displays the note for the active tab's current page. Each tab SHALL have its own panel instance, so editor state in one tab is unaffected by other tabs.
#### Scenario: Opening the panel shows the current tab's note
- **WHEN** a user opens the side panel while viewing a page
- **THEN** the panel loads and displays the note associated with that page's URL key
#### Scenario: Switching tabs shows the new tab's note
- **WHEN** a user activates a different tab that also has the side panel open
- **THEN** that tab's panel shows the note for its own current URL, independent of other tabs' panels
### Requirement: Native text editing
Note content SHALL be edited in a plain text input area, so that text selection, copy, cut, paste, and undo/redo behave exactly as native browser text-field editing, with no custom interaction to learn.
#### Scenario: Copy and paste behave like any text field
- **WHEN** a user selects text in the note and copies it, then pastes it elsewhere
- **THEN** the pasted text matches the selection exactly, using the browser's native clipboard behavior
### Requirement: Autosave on edit
Edits to a note SHALL be saved automatically as the user types, without requiring an explicit save action.
#### Scenario: Content is saved without a save button
- **WHEN** a user types in the note editor and then closes the panel or navigates away
- **THEN** the typed content is already persisted and reappears the next time the note is opened
### Requirement: In-panel find
WHEN the panel has focus and the user presses the find shortcut (Ctrl+F / Cmd+F), the system SHALL open an in-panel find control instead of triggering the browser's page-level find, allow searching the note's text, and indicate matches using the editor's native text selection.
#### Scenario: Find highlights a match via selection
- **WHEN** a user opens in-panel find and types a search term that matches note text
- **THEN** the matching text becomes selected in the editor and is scrolled into view
#### Scenario: Browser page find is not triggered
- **WHEN** the side panel's editor has focus and the user presses Ctrl+F / Cmd+F
- **THEN** the browser's own page-level find UI does not open
### Requirement: Consistency across panels sharing a note
WHEN the same note is open in more than one tab's panel and one panel saves an edit, the other open panel(s) showing that note SHALL refresh to the latest saved content, except that a panel whose editor currently has input focus SHALL defer the refresh until focus leaves the editor.
#### Scenario: Unfocused panel picks up the update
- **WHEN** a note open in tab A is edited and saved, and the same note is open in tab B without focus in B's editor
- **THEN** tab B's panel updates to show the content saved from tab A
#### Scenario: Focused panel is not overwritten mid-edit
- **WHEN** a note open in tab A is edited and saved, and the same note is open in tab B with focus currently in B's editor
- **THEN** tab B's editor content is not replaced until focus leaves B's editor
### Requirement: Dark theme by default
The side panel SHALL render using a dark color theme by default.
#### Scenario: Panel opens in dark theme
- **WHEN** a user opens the side panel with no prior theme preference set
- **THEN** the panel is displayed using the dark theme