generated from coulomb/repo-seed
feat: implement JavaScript-first TestDriveJSUI library (v1.0.0)
Completed Phase 1 refactoring to JavaScript-first architecture: Core Library Implementation: - Created js/testdrive-jsui.js main library class - Integrated all existing components (SectionManager, DOMRenderer, DocumentControls) - Added marked.js integration for markdown rendering - Implemented event-driven API (on/off/emit) - Support for edit/view modes and themes - LocalStorage save/load functionality - Download as markdown file - Keyboard shortcuts (Ctrl+S, Escape) - Auto-save capability (optional) Examples: - examples/full-editor.html - Complete demo with all features - Updated examples/README.md with full documentation Documentation: - Updated README.md with JavaScript-first architecture section - Added complete API reference (constructor, methods, events) - Updated CLAUDE.md with library quick start and API - Emphasized JavaScript-first design principles Architecture: - JavaScript provides ALL functionality - Language adapters are optional integration helpers - Works standalone in browser (no backend required) - Clean separation: JS (functionality) vs Adapters (integration) This completes the architectural shift documented in ARCHITECTURE.md and JS_FIRST_REFACTORING.md Phase 1. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
138
README.md
138
README.md
@@ -1,18 +1,131 @@
|
||||
# TestDrive-JSUI
|
||||
|
||||
A standalone JavaScript UI rendering engine and testing framework. Originally developed for MarkiTect, TestDrive-JSUI is designed as an independent, reusable capability that can be integrated into any Python project.
|
||||
**A JavaScript-first markdown editor and UI library.**
|
||||
|
||||
TestDrive-JSUI is a pure JavaScript library for interactive markdown editing with section-based management. Language adapters (Python, Ruby, Java) are optional integration helpers for serving assets and backend integration - they do not provide core functionality.
|
||||
|
||||
## 🎯 **Purpose**
|
||||
|
||||
TestDrive-JSUI is designed to:
|
||||
|
||||
- **📝 Render markdown with interactive JavaScript UI** for editing and viewing
|
||||
- **🔌 Work as a standalone plugin** or integrate with any Python project
|
||||
- **🔒 Protect existing JavaScript UI functionality** during refactoring and development
|
||||
- **🧪 Integrate JavaScript tests** into Python test suites
|
||||
- **🏗️ Provide a clean architecture** for JavaScript framework development
|
||||
- **📊 Enable comprehensive testing** of JavaScript UI components
|
||||
- **🚀 Support extensibility** for JavaScript framework evolution
|
||||
- **📝 Provide a complete JavaScript library** for interactive markdown editing
|
||||
- **🌐 Work standalone in any browser** without backend requirements
|
||||
- **🔌 Offer optional language adapters** for Python, Ruby, Java, etc.
|
||||
- **✂️ Enable section-based editing** with independent section management
|
||||
- **🎨 Support multiple modes** (edit/view) and themes
|
||||
- **💾 Handle content persistence** (localStorage, download, custom backends)
|
||||
- **🧪 Include comprehensive testing** for JavaScript and integrations
|
||||
- **🚀 Support extensibility** through events and configuration
|
||||
|
||||
## 🏛️ **Architecture: JavaScript-First Design**
|
||||
|
||||
TestDrive-JSUI follows a **JavaScript-first architecture**:
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────┐
|
||||
│ Core: JavaScript Library │
|
||||
│ - All functionality in JS │
|
||||
│ - Works standalone in browser │
|
||||
│ - No backend required │
|
||||
│ - Uses marked.js for markdown │
|
||||
└─────────────────────────────────────┘
|
||||
↑ ↑ ↑
|
||||
│ │ │
|
||||
┌──────────┴──┐ ┌───┴────┐ ┌──┴──────┐
|
||||
│ Python │ │ Ruby │ │ Java │
|
||||
│ Adapter │ │ Adapter│ │ Adapter │
|
||||
│ (optional) │ │(future)│ │(future) │
|
||||
└─────────────┘ └────────┘ └─────────┘
|
||||
```
|
||||
|
||||
**Key Principle:** JavaScript provides ALL functionality. Language adapters only help with:
|
||||
- Asset serving
|
||||
- Configuration injection
|
||||
- Backend integration (storage, auth, etc.)
|
||||
- Testing infrastructure
|
||||
|
||||
### Quick Start: JavaScript Library
|
||||
|
||||
```html
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||
<script src="testdrive-jsui.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="editor"></div>
|
||||
<script>
|
||||
const editor = new TestDriveJSUI({
|
||||
container: '#editor',
|
||||
markdown: '# Hello World\n\nEdit me!',
|
||||
mode: 'edit',
|
||||
theme: 'github'
|
||||
});
|
||||
|
||||
// Listen to events
|
||||
editor.on('save', (data) => {
|
||||
console.log('Saved:', data.markdown);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
### API Reference
|
||||
|
||||
#### Constructor Options
|
||||
|
||||
```javascript
|
||||
new TestDriveJSUI({
|
||||
container: '#editor', // CSS selector or DOM element (required)
|
||||
markdown: '# Content', // Initial markdown content
|
||||
mode: 'edit', // 'edit' or 'view' (default: 'edit')
|
||||
theme: 'github', // Theme name (default: 'github')
|
||||
autosave: false, // Auto-save to localStorage (default: false)
|
||||
shortcuts: true, // Keyboard shortcuts (default: true)
|
||||
sections: true, // Section-based editing (default: true)
|
||||
debug: false // Debug mode (default: false)
|
||||
})
|
||||
```
|
||||
|
||||
#### Methods
|
||||
|
||||
| Method | Description |
|
||||
|--------|-------------|
|
||||
| `getMarkdown()` | Get current document content |
|
||||
| `setMarkdown(markdown)` | Set document content |
|
||||
| `getStatus()` | Get editor status (sections, words, etc.) |
|
||||
| `save()` | Trigger save event |
|
||||
| `download(filename)` | Download as markdown file |
|
||||
| `loadFromLocalStorage()` | Load from browser storage |
|
||||
| `saveToLocalStorage()` | Save to browser storage |
|
||||
| `resetAll()` | Reset all sections to original content |
|
||||
| `destroy()` | Clean up and destroy editor |
|
||||
| `on(event, callback)` | Listen to events |
|
||||
| `off(event, callback)` | Remove event listener |
|
||||
|
||||
#### Events
|
||||
|
||||
| Event | Data | Description |
|
||||
|-------|------|-------------|
|
||||
| `initialized` | `{mode, theme, sections}` | Editor finished initializing |
|
||||
| `save` | `{markdown}` | Save triggered |
|
||||
| `content-changed` | `{markdown}` | Content modified |
|
||||
| `autosave` | `{markdown}` | Auto-save occurred |
|
||||
| `download` | `{filename, markdown}` | Document downloaded |
|
||||
| `reset` | `{}` | Document reset |
|
||||
| `destroyed` | `{}` | Editor destroyed |
|
||||
|
||||
### Examples
|
||||
|
||||
See the `/examples` directory for:
|
||||
- **`standalone.html`** - Minimal proof of concept (works from file://)
|
||||
- **`full-editor.html`** - Complete demo with all features
|
||||
|
||||
## 🐍 **Python Adapter (Optional)**
|
||||
|
||||
For Python projects, TestDrive-JSUI provides an **optional adapter** for integration:
|
||||
|
||||
## 🏗️ **Architecture**
|
||||
|
||||
@@ -459,6 +572,9 @@ MIT License - See main MarkiTect project for details.
|
||||
|
||||
---
|
||||
|
||||
*Generated: 2025-11-09*
|
||||
*Status: Phase 1 Implementation*
|
||||
*Next: Copy JavaScript files and create integration tests*
|
||||
**Version:** 1.0.0
|
||||
**Status:** Full JavaScript Library Implementation Complete ✅
|
||||
**Architecture:** JavaScript-First with Optional Language Adapters
|
||||
**Last Updated:** 2025-12-16
|
||||
|
||||
See `/examples` for working demos and `ARCHITECTURE.md` for detailed design documentation.
|
||||
Reference in New Issue
Block a user