Added complete documentation for all TestDrive-JSUI controls and features, plus flexible HTML generation system supporting standalone and external modes. Documentation (8 files, 3,533 lines): - docs/features/README.md: Central hub with overview, config, examples - docs/features/section-editing.md: Section editing guide - docs/features/edit-control.md: Document actions and editing tools - docs/features/status-control.md: Real-time statistics and tracking - docs/features/contents-control.md: Table of contents navigation - docs/features/debug-control.md: Development and debugging tools - docs/features/keyboard-shortcuts.md: Complete shortcuts reference - docs/features/themes.md: Visual theming and customization HTML Generation System (3 files, 1,104 lines): - js/utils/html-generator.js: Dual-mode HTML generator class * Standalone mode: All CSS/JS embedded inline * External mode: References _jsui/ directory * Configurable options for title, content, controls, theme * Download and save functionality - _jsui/ directory: External resources structure * README.md: Comprehensive usage guide * css/: Symlinked CSS files (base, editor, controls, themes) * js/: Symlinked JavaScript files (core, components, controls) * Enables smaller HTML files with browser caching - examples/html-generator-demo.html: Interactive demo * Web-based configuration form * Side-by-side mode comparison * Live generation and preview * Download and copy functionality Key Features: - 4,637 total lines of documentation and code - All controls documented with examples and troubleshooting - Flexible deployment options (standalone vs external) - Developer-friendly structure with clear guides - Production-ready system 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
9.2 KiB
Edit Control
Document actions and editing tools 📝
The Edit Control provides comprehensive document-level actions including save, export, print, navigation tools, text formatting, and markdown shortcuts. Positioned in the northeast by default.
Overview
The Edit Control is your command center for document-wide operations. It groups related actions into organized sections for easy access.
Position
- Default: Northeast (ne) - top-right corner
- Appearance: ✏️ icon when collapsed
- Title: "Edit"
Key Features
- 📄 Document actions (save, print, export, reset)
- 🧭 Navigation tools (scroll to top/bottom, go to line)
- 🔍 Text tools (find & replace, font size)
- ✍️ Markdown shortcuts (bold, italic, headers, links)
Configuration
Enable/Disable
new TestDriveJSUI({
container: '#editor',
controls: {
editControl: true // Enable (default: true)
}
});
Custom Position
new TestDriveJSUI({
container: '#editor',
controlPositions: {
editControl: 'ne' // Northeast (default), or: nw, e, se, s, sw, w
}
});
Features
1. Document Actions
🖨️ Print Document
Opens browser print dialog for the current document.
Usage:
- Click "Print Document" button
- Or use keyboard shortcut:
Ctrl+P
What happens:
- Formats document for printing
- Opens browser print dialog
- Preserves markdown formatting
💾 Save Changes
Downloads the current document as a markdown file.
Usage:
- Click "Save Changes" button
- Or use keyboard shortcut:
Ctrl+S
Behavior:
- Generates timestamped filename
- Downloads as
.mdfile - Includes all accepted edits
Example filename: document-edited-2025-12-16-143052.md
📄 Export Document
Export document in various formats.
Usage:
- Click "Export Document" button
- Choose format in dialog
Formats (coming soon):
- Markdown (
.md) - HTML (
.html) - PDF (
.pdf) - Plain text (
.txt)
🔄 Reset All
Resets all sections to their original content.
Usage:
- Click "Reset All" button
- Confirm in dialog
Warning: This discards ALL changes! Cannot be undone.
2. Navigation Tools
⬆️ Scroll to Top
Instantly scrolls to the beginning of the document.
Usage:
- Click "Top" button
- Smooth scroll animation
⬇️ Scroll to Bottom
Instantly scrolls to the end of the document.
Usage:
- Click "Bottom" button
- Smooth scroll animation
🎯 Go to Line
Jump to a specific line or section in the document.
Usage:
- Click "Go to Line" button
- Enter line number or section name
- Press Enter to navigate
3. Text Tools
🔍 Find & Replace
Search and replace text across the document.
Usage:
- Click "Find & Replace" button
- Or use keyboard shortcut:
Ctrl+F
Features:
- Case-sensitive option
- Replace one or all occurrences
- Regex support (coming soon)
- Highlight matches
🔍+ / 🔍- Font Size
Adjust document font size for better readability.
Usage:
- Click "🔍+ Font" to increase
- Click "🔍- Font" to decrease
Range: 12px - 24px
Tip: Useful for presentations or accessibility
📋 Copy Page Link
Copies the current page URL to clipboard.
Usage:
- Click "Copy Page Link" button
- Link copied to clipboard
- Paste anywhere with
Ctrl+V
4. Markdown Tools
Quick markdown formatting shortcuts.
B Bold
Wraps selected text in **bold** markers.
Usage:
- Select text
- Click "B" button
- Or use:
Ctrl+B
Result: **selected text**
I Italic
Wraps selected text in *italic* markers.
Usage:
- Select text
- Click "I" button
- Or use:
Ctrl+I
Result: *selected text*
# Header
Converts line to heading.
Levels:
- H1:
# Heading - H2:
## Heading - H3:
### Heading
🔗 Link
Inserts markdown link format.
Usage:
- Click "Link" button
- Inserts:
[text](url)
📋 Code
Wraps text in code markers.
Inline: `code`
Block:
```language
code block
---
## Examples
### Basic Usage
```javascript
const editor = new TestDriveJSUI({
container: '#editor',
markdown: '# My Document\n\nContent here...',
controls: {
editControl: true
}
});
Custom Position
// Move to northwest (top-left)
const editor = new TestDriveJSUI({
container: '#editor',
controlPositions: {
editControl: 'nw' // Top-left instead of top-right
}
});
With Event Tracking
const editor = new TestDriveJSUI({
container: '#editor',
controls: { editControl: true }
});
// Listen to save events
editor.on('save', (data) => {
console.log('Document saved:', data.markdown);
// Send to backend, update UI, etc.
});
// Access edit control directly
if (editor.editControl) {
// Programmatically trigger actions
editor.editControl.saveDocument();
}
API Reference
Methods
Access via editor.editControl:
const editCtrl = editor.editControl;
// Document actions
editCtrl.printDocument(); // Open print dialog
editCtrl.saveDocument(); // Download as .md
editCtrl.exportDocument(); // Export in format
editCtrl.resetAll(); // Reset all sections
// Navigation
editCtrl.scrollToTop(); // Scroll to top
editCtrl.scrollToBottom(); // Scroll to bottom
editCtrl.showGoToLine(); // Show go-to dialog
// Text tools
editCtrl.showFindReplace(); // Open find & replace
editCtrl.increaseFontSize(); // Increase font
editCtrl.decreaseFontSize(); // Decrease font
editCtrl.copyLink(); // Copy page URL
// Markdown tools
editCtrl.insertMarkdown(before, after, placeholder);
// Example: insertMarkdown('**', '**', 'bold text')
Properties
editCtrl.config.position // Current position (e.g., 'ne')
editCtrl.config.icon // Icon emoji ('✏️')
editCtrl.config.title // Panel title ('Edit')
editCtrl.isExpanded // true if panel expanded
editCtrl.fontSize // Current font size (px)
Keyboard Shortcuts
The Edit Control provides these shortcuts:
| Shortcut | Action |
|---|---|
Ctrl+S |
Save document |
Ctrl+P |
Print document |
Ctrl+F |
Find & replace |
Ctrl+B |
Bold selected text |
Ctrl+I |
Italic selected text |
Escape |
Exit edit mode |
Enable/disable:
new TestDriveJSUI({
container: '#editor',
shortcuts: true // Enable shortcuts (default: true)
});
Customization
Disable Specific Actions
Currently, all Edit Control actions are enabled by default. To hide the control entirely:
new TestDriveJSUI({
container: '#editor',
controls: {
editControl: false // Hide completely
}
});
Future: Granular Control
Planned for v1.1:
new TestDriveJSUI({
container: '#editor',
controls: {
editControl: {
enabled: true,
actions: {
print: true,
save: true,
export: false, // Hide export
reset: false // Hide reset
}
}
}
});
Best Practices
For Writers
- Save frequently - Use
Ctrl+Sor Save button regularly - Use shortcuts - Learn
Ctrl+B,Ctrl+Ifor quick formatting - Navigate efficiently - Use Top/Bottom for long documents
- Find & Replace - Bulk edit repetitive content
For Developers
- Listen to events - Track saves for auto-sync
- Custom save handlers - Override default behavior
- Programmatic control - Trigger actions via API
- Error handling - Catch save failures
Example custom save:
const editor = new TestDriveJSUI({ container: '#editor' });
editor.on('save', async (data) => {
try {
// Send to backend
await fetch('/api/save', {
method: 'POST',
body: JSON.stringify({ markdown: data.markdown })
});
alert('Saved to server!');
} catch (error) {
alert('Save failed: ' + error.message);
}
});
Troubleshooting
"Save Changes" Not Working
Problem: Clicking save does nothing
Solutions:
- Check browser console for errors
- Verify EditControl is loaded:
typeof EditControl !== 'undefined' - Check if control is enabled in config
- Test programmatically:
editor.editControl.saveDocument()
Print Dialog Not Opening
Problem: Print button doesn't open dialog
Solutions:
- Check browser pop-up blocker
- Test with
Ctrl+Pkeyboard shortcut - Verify browser print permissions
- Try programmatically:
window.print()
Font Size Not Changing
Problem: Font buttons don't affect text size
Solutions:
- Check CSS conflicts with
font-size: inherit - Inspect element to verify font-size style applied
- Clear browser cache
- Test with browser zoom instead
Related Features
- Section Editing - Edit individual sections
- Keyboard Shortcuts - All available shortcuts
- Status Control - Track editing progress
See Also:
Version: 1.0.0 Last Updated: 2025-12-16