I've successfully implemented a hashtag autocomplete feature for your Tiptap editor using the @tiptap/suggestion extension. Here's what was created:
- Main suggestion extension that handles the hashtag trigger (#)
- Provides autocomplete dropdown with existing tags
- Allows creation of new tags by typing and pressing Enter
- Integrates with the notes store to persist tags
- Custom Tiptap extension for rendering tags
- Makes tags clickable (currently set to navigate to
/tags/{tagname}) - Provides proper styling and hover effects
- Reusable hook for tag management
- Handles tag creation, addition to notes, and retrieval
- Integrates with the existing notes store
- Added
createTagAPI method inapi.ts - Added
create_tagTauri command in Rust backend - Properly exposed the command in the invoke handler
- Added tag styles to
index.css - Tags appear as rounded pills with primary color
- Hover effects and smooth transitions
- Dropdown styling for the autocomplete menu
- Type # in the editor - This triggers the autocomplete dropdown
- Type to search - The dropdown filters existing tags as you type
- Select a tag - Use arrow keys and Enter, or click to select
- Create new tags - If your text doesn't match any existing tag, press Enter to create it
- Click tags - Tags are clickable and will navigate to tag search (you can customize this behavior)
- Real-time tag filtering
- Create tags on the fly
- Keyboard navigation (Arrow keys + Enter/Tab)
- Mouse support
- Escape key to dismiss
- Automatic tag persistence to database
- Visual feedback with hover states
- Responsive positioning (dropdown adjusts to viewport boundaries)
You can customize:
- Tag click behavior (currently navigates to
/tags/{tagname}) - Tag appearance via CSS
- Number of suggestions shown (currently 8)
- Tag creation logic
- Integration with your existing tag management system
To fully integrate this feature, you may want to:
- Implement the
/tags/{tagname}route for tag-based search - Add tag management UI (edit/delete tags)
- Display tag counts in the autocomplete
- Add tag colors support
- Implement tag-based filtering in your notes view