First commit on the local Gitea server, made after moving the tree off the Windows machine. Build outputs, node_modules and the AI models stay out (see .gitignore); everything the installer build needs is tracked. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
7.6 KiB
Enhanced Tools Integration Guide
Overview
This guide explains how to integrate the enhanced annotation tools into the existing Bible App. The enhanced tools add new annotation capabilities including text annotations, shape tools, and an advanced color picker.
Quick Integration
Step 1: Add CSS File
Add the enhanced tools CSS to your index.html:
<head>
<!-- Existing styles -->
<link rel="stylesheet" href="styles.css">
<!-- Add enhanced tools styles -->
<link rel="stylesheet" href="enhanced-tools.css">
</head>
Step 2: Add JavaScript Module
Add the enhanced tools JavaScript to your index.html:
<body>
<!-- Existing content -->
<!-- Add enhanced tools script -->
<script src="enhanced-tools.js"></script>
<script type="module" src="app.js"></script>
</body>
Step 3: Update Toolbar HTML
The enhanced tools will automatically add new tool buttons to the existing toolbar. No manual HTML changes required.
Manual Integration (If Needed)
If you prefer manual integration, add these buttons to your toolbar:
<div class="tool-slider" id="toolSlider">
<div class="tool-wrapper">
<!-- Existing tools -->
<button class="tool-icon selected" data-tool="pen" id="penToolBtn">
<i class="fas fa-pen"></i>
</button>
<button class="tool-icon" data-tool="highlight" id="highlightToolBtn">
<i class="fas fa-highlighter"></i>
</button>
<!-- New enhanced tools -->
<button class="tool-icon" data-tool="text" id="textToolBtn" title="Text Annotation">
<i class="fas fa-font"></i>
</button>
<button class="tool-icon" data-tool="rectangle" id="rectangleToolBtn" title="Rectangle">
<i class="fas fa-square"></i>
</button>
<button class="tool-icon" data-tool="circle" id="circleToolBtn" title="Circle">
<i class="fas fa-circle"></i>
</button>
<button class="tool-icon" data-tool="arrow" id="arrowToolBtn" title="Arrow">
<i class="fas fa-arrow-right"></i>
</button>
<!-- Existing eraser -->
<button class="tool-icon" data-tool="erase">
<i class="fas fa-eraser"></i>
</button>
</div>
</div>
Integration with Existing Code
Automatic Integration
The enhanced tools module automatically:
- Detects existing toolbar and adds new tools
- Integrates with existing drawing system for pen/highlighter/eraser
- Uses existing storage system for persistence
- Maintains compatibility with current features
No Breaking Changes
- All existing functionality remains intact
- Current annotation system continues to work
- Existing storage format is preserved
- Touch gestures remain functional
Testing the Integration
1. Open the Test Page
Navigate to test-tools.html to test all tools:
# If using local server
http://localhost:8000/bible-app/test-tools.html
2. Test Each Tool
- Text Tool: Click text icon, then click on canvas to add text
- Rectangle Tool: Click rectangle icon, drag to draw rectangles
- Circle Tool: Click circle icon, drag to draw circles
- Arrow Tool: Click arrow icon, drag to draw arrows
- Advanced Color Picker: Click pen/highlighter icon twice
3. Test in Main App
- Open
index.html - Load a Bible passage
- Try the new tools on actual Bible text
- Verify persistence works across tabs
Configuration Options
Customizing Tool Settings
Modify the default settings in enhanced-tools.js:
this.toolSettings = {
pen: { color: '#fefefe', size: 4, opacity: 1.0 },
highlight: { color: '#ffff00', size: 20, opacity: 0.3 },
text: { color: '#000000', size: 16, font: 'Inter', opacity: 1.0 },
rectangle: { color: '#ff3333', size: 2, fill: false, opacity: 1.0 },
circle: { color: '#0090ff', size: 2, fill: false, opacity: 1.0 },
arrow: { color: '#00ff00', size: 3, opacity: 1.0 }
};
Adding Custom Colors
Modify the color presets in the createAdvancedColorPicker() method:
const colorPresets = [
{ color: '#fefefe', name: 'White' },
{ color: '#ff3333', name: 'Red' },
{ color: '#0090ff', name: 'Blue' },
// Add more colors here
];
Troubleshooting
Common Issues
-
Tools Not Appearing:
- Check that
enhanced-tools.jsis loaded afterapp.js - Verify the toolbar element exists with class
.tool-slider - Check browser console for JavaScript errors
- Check that
-
Drawing Not Working:
- Ensure canvas elements are properly created
- Check that event listeners are attached
- Verify tool selection is working
-
Color Picker Not Showing:
- Check that CSS is properly loaded
- Verify z-index values are correct
- Ensure click events are not being blocked
Debug Mode
Enable debug logging:
// In browser console
localStorage.setItem('bible-app-debug', 'true');
window.enhancedTools.debug = true;
Performance Considerations
Optimization Tips
- Canvas Management: The enhanced tools use efficient canvas rendering
- Memory Usage: Annotations are stored as JSON, not images
- Event Handling: Optimized event listeners with proper cleanup
- Mobile Performance: Touch events are optimized for mobile devices
Browser Compatibility
- Chrome: Full support
- Firefox: Full support
- Safari: Full support
- Edge: Full support
- Mobile Browsers: Full touch support
Advanced Customization
Adding New Tools
To add a custom tool:
- Add tool button to HTML:
<button class="tool-icon" data-tool="custom" id="customToolBtn" title="Custom Tool">
<i class="fas fa-custom-icon"></i>
</button>
- Add tool settings:
this.toolSettings.custom = {
color: '#ff0000',
size: 5,
opacity: 1.0
};
- Add drawing logic:
if (this.currentTool === 'custom') {
// Custom drawing logic
}
Custom Storage Format
Modify the storage format in saveAnnotations():
const annotations = {
text: this.textAnnotations,
shapes: this.shapeAnnotations,
custom: this.customAnnotations, // Add custom data
timestamp: Date.now()
};
File Dependencies
Required Files
enhanced-tools.js- Main enhanced tools moduleenhanced-tools.css- Enhanced tools stylingapp.js- Existing main application (unchanged)styles.css- Existing main styles (unchanged)
Optional Files
test-tools.html- Testing interfaceTOOLS_DOCUMENTATION.md- Complete documentation
Support
Getting Help
- Check the browser console for error messages
- Review the
TOOLS_DOCUMENTATION.mdfor detailed information - Test with the
test-tools.htmlpage - Verify all files are properly loaded
Reporting Issues
When reporting issues, include:
- Browser and version
- Error messages from console
- Steps to reproduce
- Expected vs actual behavior
Conclusion
The enhanced tools provide a significant upgrade to the Bible App's annotation capabilities while maintaining full compatibility with existing features. The integration is designed to be seamless and requires minimal changes to the existing codebase.
For advanced customization or additional features, refer to the main documentation or modify the enhanced tools module as needed.