An intelligent writing assistant that uses AI to continue your text seamlessly. Built with React, XState, ProseMirror, and Radix UI.
- βοΈ AI-Powered Writing: Continue your text with AI-generated content
- β¨οΈ Keyboard Shortcuts: Quick access with Ctrl+Space (or Cmd+Space on Mac)
- π¨ Rich Text Editor: Powered by ProseMirror with formatting support
- π State Management: Robust state handling with XState
- π― Content Control: Accept, clear, or discard AI suggestions
- π± Responsive Design: Works on desktop and mobile
- βΏ Accessible: Built with Radix UI for WCAG compliance
- React 18: Modern UI library with hooks
- XState v5: State machine for predictable state management
- ProseMirror: Powerful rich text editor framework
- Radix UI: Accessible, unstyled UI primitives
- OpenAI API: GPT-4 for content generation
- Vite: Fast build tool and dev server
- Node.js 16+ and npm
- OpenAI API key (Get one here)
-
Clone the repository
git clone <repository-url> cd chronicle_assignment_sheetal_singh
-
Install dependencies
npm install
-
Configure API Key
Create a
.envfile in the project root:cp .env.example .env
Edit
.envand add your OpenAI API key:VITE_OPENAI_API_KEY=your_openai_api_key_here -
Start the development server
npm run dev
-
Open in browser
Navigate to
http://localhost:5173
- Start typing in the editor
- Click "Continue Writing" or press
Ctrl+Space(Windows/Linux) orCmd+Space(Mac) - Wait for AI to generate content
- Review the highlighted AI-generated text
- Choose an action:
- Accept All: Keep the AI content
- Clear All: Remove the AI content
- Discard Session: Revert to before AI generation
Ctrl+Space/Cmd+Space: Trigger AI generationCtrl+Z/Cmd+Z: UndoCtrl+Y/Cmd+Y: Redo
src/
βββ components/
β βββ Editor.jsx # ProseMirror editor component
β βββ Editor.css # Editor styles
β βββ Toolbar.jsx # Main toolbar with Continue button
β βββ StatusBar.jsx # Status indicator at bottom
β βββ AIToolbar.jsx # Floating toolbar for AI actions
βββ machines/
β βββ editorMachine.js # XState state machine
βββ services/
β βββ aiService.js # OpenAI API integration
βββ App.jsx # Main application component
βββ App.css # Global styles
The application uses XState to manage states:
idle β generating β review β idle
β β
error ββββββββββββββββ
- idle: Ready for user input
- generating: AI is creating content
- review: AI content ready for user action
- error: Something went wrong
All code files include extensive comments explaining:
- What each function does
- Why certain approaches were chosen
- How different parts interact
- React and JavaScript concepts for beginners
npm run buildnpm run previewnpm run lint- Never expose API keys in frontend code
- Use a backend server to make API calls
- Implement proper authentication
- Add rate limiting
- Local AI fallback with transformers.js
- Multiple AI model selection
- Customizable AI parameters (temperature, max tokens)
- Export to Markdown/PDF
- Dark mode support
- Collaborative editing
- Version history with branching
MIT
Sheetal Singh