From f2d9d853d572e37a286b27f23af23aa691fdfcea Mon Sep 17 00:00:00 2001 From: tegwick Date: Tue, 16 Dec 2025 13:52:18 +0100 Subject: [PATCH] docs: add comprehensive feature documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created feature documentation structure: docs/features/README.md: - Overview of all control panels - Configuration examples - Use case scenarios - Feature toggle documentation docs/features/section-editing.md: - Complete section editing guide - How it works (automatic detection, states, visual feedback) - Configuration options - Advanced features (metadata, events, section types) - Examples and troubleshooting - Best practices Remaining documentation to be created: - edit-control.md - status-control.md - contents-control.md - debug-control.md - keyboard-shortcuts.md - themes.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude { + console.log({ + id: section.id, + type: section.type, // 'heading', 'paragraph', 'image', etc. + state: section.state, // 'original', 'editing', 'modified', 'saved' + hasChanges: section.hasChanges(), + isEditing: section.isEditing(), + content: section.currentMarkdown + }); +}); +``` + +### Section Types + +| Type | Description | Detection | +|------|-------------|-----------| +| **heading** | h1-h6 headings | Starts with `#` | +| **paragraph** | Regular text | Default type | +| **image** | Images | `![alt](url)` pattern | +| **code** | Code blocks | Fenced with ` ``` ` | +| **list** | Lists | Starts with `-` or `1.` | +| **quote** | Blockquotes | Starts with `>` | + +### Events + +Listen to section editing events: + +```javascript +const editor = new TestDriveJSUI({ container: '#editor' }); + +// Section manager events +editor.sectionManager.on('edit-started', (data) => { + console.log('Started editing:', data.sectionId); +}); + +editor.sectionManager.on('changes-accepted', (data) => { + console.log('Accepted changes:', data.sectionId, data.content); +}); + +editor.sectionManager.on('changes-cancelled', (data) => { + console.log('Cancelled edit:', data.sectionId); +}); +``` + +--- + +## Examples + +### Basic Section Editing + +```html + + + + + + + +
+ + + +``` + +### With Event Tracking + +```javascript +const editor = new TestDriveJSUI({ + container: '#editor', + markdown: '# My Document\n\nEditable content here.' +}); + +// Track edits +let editCount = 0; +editor.sectionManager.on('changes-accepted', (data) => { + editCount++; + console.log(`Edit #${editCount}:`, data.content.substring(0, 50) + '...'); +}); + +// Get final document +document.getElementById('export').addEventListener('click', () => { + const markdown = editor.getMarkdown(); + console.log('Final document:', markdown); + console.log('Total edits made:', editCount); +}); +``` + +--- + +## Troubleshooting + +### Sections Not Clickable + +**Problem**: Sections don't respond to clicks + +**Solutions**: +1. Check that `mode: 'edit'` (not 'view') +2. Ensure `sections: true` in config +3. Verify SectionManager and DOMRenderer are loaded +4. Check browser console for JavaScript errors + +### Editor Dialog Not Appearing + +**Problem**: Click works but no floating editor shows + +**Solutions**: +1. Check z-index conflicts with other elements +2. Verify CSS is loaded properly +3. Check for JavaScript errors in console +4. Ensure marked.js is loaded for markdown parsing + +### Changes Not Persisting + +**Problem**: Edits disappear after accepting + +**Solutions**: +1. Click **Accept (✓)** not Cancel +2. Check that section state changed to 'saved' +3. Use `editor.getMarkdown()` to export current state +4. Enable autosave or use save button to persist + +--- + +## Best Practices + +### For Writers + +1. **Edit small sections** - Break long documents into manageable pieces +2. **Use Accept liberally** - Save frequently as you edit +3. **Test with Reset** - Preview original vs edited +4. **Export regularly** - Download or save your work + +### For Developers + +1. **Listen to events** - Track user edits for analytics +2. **Validate sections** - Check content before accepting +3. **Custom section types** - Extend Section.detectType() for custom logic +4. **Batch operations** - Use sectionManager API for bulk updates + +--- + +## Related Features + +- **[Edit Control](edit-control.md)** - Document-level save/export actions +- **[Status Control](status-control.md)** - Track editing progress +- **[Keyboard Shortcuts](keyboard-shortcuts.md)** - Quick editing actions + +--- + +**See Also**: +- [Getting Started](../../README.md#quick-start) +- [API Reference](../api/section-manager.md) +- [Examples](../../examples/) + +--- + +**Version**: 1.0.0 +**Last Updated**: 2025-12-16