Creating Documents
New Document Creation
When you first open the editor or navigate to/editor#new, CodeInk automatically creates a new document for you.
Click 'Create Document'
Click the “Create a document” button in the empty state, or if you have existing documents, use the header button
Each document is assigned a unique UUID automatically. The document URL updates to
/editor#[document-id] so you can bookmark or share specific documents.Document Creation Code
Here’s how documents are created internally:Auto-Save System
CodeInk automatically saves your work as you type, so you never lose your progress.How Auto-Save Works
- Debounced Saving: Changes are saved 1 second after you stop typing
- Visual Feedback: The status bar shows “Saving…” while saving and “Saved locally” when complete
- No Manual Save Required: Every keystroke triggers the auto-save timer
Watch the status bar in the bottom-right corner to see save status in real-time:
- Saving… (with spinning icon): Your changes are being saved
- Saved locally (with checkmark): All changes are saved to IndexedDB
Save State Implementation
The editor listens for content changes and triggers auto-save:Viewing Documents
All your documents are displayed on the Documents page at/documents.
Document Cards
Each document card shows:- Title: Extracted from the first H1 heading, or custom title if set
- Preview: First 100 characters of content
- Timestamp: Relative time (“Just now”, “5m ago”, “2h ago”, etc.)
Sorting
Documents are automatically sorted by last updated time, with the most recently modified documents appearing first.Renaming Documents
You can rename any document to give it a custom title that overrides the auto-extracted heading.Rename Implementation
The rename feature uses inline editing:Deleting Documents
Remove documents you no longer need from your local storage.Delete Code
Document Structure
Every document in CodeInk follows this TypeScript interface:Storage Location
Documents are stored in IndexedDB under:
- Database:
codeink-docs - Object Store:
documents - Key Path:
id(UUID)
Storage Advantages
- Offline Access: No internet connection required
- Fast Performance: Local database queries are instant
- Privacy: Your data never leaves your browser
- Persistent: Data survives browser restarts
Empty State
When you have no documents, CodeInk displays a helpful empty state:- Friendly message encouraging you to create your first document
- Prominent “Create a document” button
- Information about getting started
Best Practices
Use Descriptive H1 Headings
The first
# Heading in your document becomes the auto-extracted title. Make it descriptive!Export Regularly
While auto-save is reliable, export important documents to markdown files for backup.
Rename for Organization
Use custom titles to organize documents with specific naming conventions.
Delete Old Drafts
Keep your documents page clean by removing drafts and test documents you no longer need.