Files
insertr/TODO.md
Joakim c777fc92dd refactor: consolidate all Node.js development into lib package
- Move scripts/ to lib/scripts/ and convert to ESM modules
- Consolidate dependencies: add live-server to lib/package.json
- Remove root package.json and node_modules split
- Preserve CLI integration via existing rebuild-library.sh
- Add development quickstart guide for new unified workflow
- Clean up outdated file references and duplicate assets
2025-09-04 21:40:45 +02:00

150 lines
6.0 KiB
Markdown

# Insertr Library Feature Parity TODO
## Overview
Bring the current library (`lib/`) up to feature parity with the archived prototype (`demo-site/archive/insertr-old/`). The prototype has significantly more features and professional polish than our current basic library.
## Critical Feature Gaps Identified
### Current Library Status: Basic Proof-of-Concept
- ❌ Simple prompt() editing only
- ❌ No authentication or state management
- ❌ No form system or validation
- ❌ No content persistence
- ❌ Text-only editing (no markdown, links)
- ❌ Basic hover effects only
### Prototype Status: Production-Ready
- ✅ Professional modal editing system
- ✅ Full authentication & edit mode states
- ✅ Sophisticated form renderer with validation
- ✅ LocalStorage persistence
- ✅ Multiple content types (text/markdown/link)
- ✅ Mobile-responsive design
## Implementation Plan
### 🔴 Phase 1: Critical Foundation (IMMEDIATE)
#### 1.1 Authentication System ✅ **COMPLETED**
- [x] Add state management for authentication and edit mode
- [x] Implement body class management (`insertr-authenticated`, `insertr-edit-mode`)
- [x] Create authentication controls (login/logout toggle)
- [x] Add edit mode toggle (separate from authentication)
**Implementation Details:**
- Created `lib/src/core/auth.js` with complete state management
- Auto-creates authentication controls in top-right corner if missing
- Two-step process: Login → Enable Edit Mode → Click to edit
- Visual state indicators: status badge (bottom-left) + body classes
- Mock OAuth integration placeholder for production use
- Protected editing: only authenticated users in edit mode can edit
- Professional UI with status indicators and smooth transitions
#### 1.2 Professional Edit Forms ⭐ **HIGH IMPACT** ✅ **COMPLETED**
- [x] Replace prompt() with professional modal overlays
- [x] Create dynamic form renderer based on content type
- [x] Implement smart form positioning relative to elements
- [x] Add mobile-responsive form layouts
**Implementation Details:**
- Created `lib/src/ui/form-renderer.js` with modern ES6+ modules
- Professional modal overlays with backdrop and ESC/click-outside to cancel
- Dynamic form generation: text, textarea, markdown, link (with URL field)
- Smart field detection based on HTML element type (H1-H6, P, A, etc.)
- Responsive positioning and mobile-optimized form widths
- Complete CSS styling with focus states and transitions
- Integrated into main editor with proper save/cancel handlers
#### 1.3 Content Type Support
- [ ] Text fields with length validation
- [ ] Textarea fields for paragraphs
- [ ] Link fields (URL + text) with validation
- [ ] Markdown fields with live preview
#### 1.4 Data Persistence
- [ ] Implement LocalStorage-based content persistence
- [ ] Create centralized content management system
- [ ] Add content caching and invalidation
### 🟡 Phase 2: Enhanced UX (IMPORTANT)
#### 2.1 Visual Polish
- [ ] Add positioned edit buttons on element hover
- [ ] Implement professional hover effects and transitions
- [ ] Create loading states for save operations
- [ ] Add success/error toast notifications
#### 2.2 Validation System
- [ ] Input validation (length, required fields, format)
- [ ] URL validation for link fields
- [ ] Markdown syntax validation and warnings
- [ ] XSS protection and content sanitization
#### 2.3 Configuration System
- [ ] Auto-detect field types from HTML elements (H1-H6, P, A, etc.)
- [ ] CSS class-based enhancement (`.lead`, `.btn-primary`, etc.)
- [ ] Developer-extensible field type system
- [ ] Configurable validation rules per field type
### 🟢 Phase 3: Advanced Features (NICE-TO-HAVE)
#### 3.1 Markdown System
- [ ] Port full markdown processing system from prototype
- [ ] Real-time markdown preview in edit forms
- [ ] DOMPurify integration for security
- [ ] Markdown toolbar (bold, italic, links)
#### 3.2 Mobile Optimization
- [ ] Touch-friendly edit interactions
- [ ] Full-screen mobile edit experience
- [ ] Adaptive modal sizing and positioning
- [ ] Touch-optimized hover states
#### 3.3 Server / CLI
- [ ] A better way to inject insertr.js library into our CLI. Maybe use a cdn when library is stable.
## Key Files to Port/Adapt
### From Prototype (`demo-site/archive/insertr-old/`)
- `config.js``lib/src/core/config.js` (field type detection)
- `form-renderer.js``lib/src/ui/form-renderer.js` (modal forms)
- `validation.js``lib/src/core/validation.js` (input validation)
- `content-manager.js``lib/src/core/content-manager.js` (persistence)
- `markdown-processor.js``lib/src/core/markdown.js` (markdown support)
- `insertr.css``lib/src/styles/` (professional styling)
### Architecture Adaptations Needed
- **Build-Time Integration**: Ensure features work with CLI-enhanced HTML
- **Hot Reload Compatibility**: Maintain development experience
- **Library Independence**: Keep self-contained for CDN usage
- **Modern ES6+ Modules**: Update from class-based to module-based architecture
## Success Criteria
After Phase 1 & 2 completion:
- ✅ Professional editing experience matching prototype quality
- ✅ All critical content types supported (text/markdown/link)
- ✅ Authentication and state management working
- ✅ Persistent content storage with LocalStorage
- ✅ Mobile-responsive editing interface
- ✅ Input validation and XSS protection
## Next Steps
1. **Start with Phase 1.2** (Professional Edit Forms) - highest user impact
2. **Port form-renderer.js** first - creates immediate professional feel
3. **Test integration** with CLI enhancement pipeline
4. **Maintain hot reload** functionality during development
## Architecture Decision
Keep the current library + CLI architecture while porting prototype features:
- Library remains independent and CDN-ready
- CLI continues build-time enhancement approach
- Hot reload development experience preserved
- "Tailwind of CMS" philosophy maintained
---
*This TODO represents bringing a basic proof-of-concept up to production-ready feature parity with the original prototype.*