Summary
Add a configurable hotkey/command that opens the comment dialog immediately for the user’s current text selection. This makes commenting faster than using the mouse/menus.
User story
As a user, when I highlight text in the editor, I want to press a hotkey to open the SideNote comment dialog with that selection pre-filled, so I can add a comment without leaving the keyboard.
Proposed UX
- User selects text in the active editor.
- User presses a hotkey (default suggestion: none, user-configurable via Obsidian hotkeys).
- SideNote opens the “Add Comment” dialog:
- selection is pre-populated / stored as the anchor (same as current selection-based workflow, if any)
- cursor focus goes to the comment input field
- If no text is selected:
- either show a Notice like “Select text to add a comment” (recommended), or
- open dialog but require the user to select text first.
Implementation notes
- Add a command in
onload():
- e.g.
this.addCommand({ id: 'sidenote-add-comment-from-selection', name: 'Add comment from selection', ... })
- In the callback:
- get the active
MarkdownView and editor: this.app.workspace.getActiveViewOfType(MarkdownView)?.editor
- read selection:
editor.getSelection()
- validate non-empty selection
- open the same modal/dialog used elsewhere for adding comments, passing the selection + location metadata as needed
- Ensure it works for:
- Reading view vs source/live preview (if applicable)
- Multiple cursors (take primary selection or first range)
Acceptance criteria
Optional enhancements
Summary
Add a configurable hotkey/command that opens the comment dialog immediately for the user’s current text selection. This makes commenting faster than using the mouse/menus.
User story
As a user, when I highlight text in the editor, I want to press a hotkey to open the SideNote comment dialog with that selection pre-filled, so I can add a comment without leaving the keyboard.
Proposed UX
Implementation notes
onload():this.addCommand({ id: 'sidenote-add-comment-from-selection', name: 'Add comment from selection', ... })MarkdownViewand editor:this.app.workspace.getActiveViewOfType(MarkdownView)?.editoreditor.getSelection()Acceptance criteria
Optional enhancements