Commit Graph

12 Commits

Author SHA1 Message Date
ef1d1083ce fix: systematic element matching bug in enhancement pipeline
- Problem: Element ID collisions between similar elements (logo h1 vs hero h1)
  causing content to be injected into wrong elements
- Root cause: Enhancer used naive tag+class matching instead of parser's
  sophisticated semantic analysis for element identification

Systematic solution:
- Enhanced parser architecture with exported utilities (GetClasses, ContainsClass)
- Added FindElementInDocument() with content-based semantic matching
- Replaced naive findAndInjectNodes() with parser-based element matching
- Removed code duplication between parser and enhancer packages

Backend improvements:
- Moved ID generation to backend for single source of truth
- Added ElementContext struct for frontend-backend communication
- Updated API handlers to support context-based content ID generation

Frontend improvements:
- Enhanced getElementMetadata() to extract semantic context
- Updated save flow to handle both enhanced and non-enhanced elements
- Improved API client to use backend-generated content IDs

Result:
- Unique content IDs: navbar-logo-200530 vs hero-title-a1de7b
- Precise element matching using content validation
- Single source of truth for DOM utilities in parser package
- Eliminated 40+ lines of duplicate code while fixing core bug
2025-09-11 14:14:57 +02:00
bc1dcdffbd feat: implement professional HTML ↔ Markdown conversion for group editing
- Add marked and turndown libraries for bidirectional conversion
- Create comprehensive MarkdownConverter utility with proper paragraph preservation
- Implement perfect round-trip HTML→Markdown→HTML conversion
- Add rich formatting support (bold, italic, paragraphs) with live preview
- Fix save handler conflict where general editor overwrote group changes
- Implement debounced live preview for group editing (500ms like regular elements)
- Enable dynamic paragraph creation/removal during markdown editing
- Add comprehensive test cases with HTML formatting examples

Result: World-class drop-in markdown editing with 29KB bundle size
2025-09-07 21:22:12 +02:00
fdf9e1bb7e feat: implement container expansion and group editing functionality
- Add container element detection and child expansion in InsertrCore
- Implement .insertr descendant expansion matching CLI behavior
- Add .insertr-group collective editing with markdown editor
- Fix UX issue where div.insertr got text input instead of proper child editors
- Add comprehensive test cases for both features in about.html
- Enable live preview for group editing with proper content splitting
2025-09-07 20:43:43 +02:00
ae9d8e4058 refactor: implement script tag approach for library inclusion
- Add script tags to demo-site HTML files for manual development
- Disable CLI inline script injection to prevent duplicate scripts
- Add library serving endpoints to servedev command
- Update build process to auto-copy library to demo-site
- Add CDN URL helpers for future production deployment
- Update .gitignore for generated demo-site files

Fixes .insertr-gate authentication for manual npm run serve workflow
while maintaining clean separation between CLI and manual setups.
2025-09-07 18:28:34 +02:00
6fef293df3 feat: implement flexible editor gate system
- Replace automatic auth controls with developer-placed .insertr-gate elements
- Add OAuth-ready authentication flow with mock implementation
- Support any HTML element as gate with custom styling
- Implement proper gate restoration after authentication
- Move auth controls to bottom-right corner for better UX
- Add editor gates to demo pages (footer link and styled button)
- Maintain gates visible by default with hideGatesAfterAuth option
- Prevent duplicate authentication attempts with loading states

This enables small business owners to access editor via discrete
footer links or custom-styled elements placed anywhere by developers.
2025-09-04 18:42:30 +02:00
81d8ef2bf5 Remove remaining data-field-type attributes from demo site
- Complete transition to zero-config approach
- Container expansion now handles content type detection automatically
- No manual field type declarations needed with div.insertr containers
2025-09-03 12:20:08 +02:00
9bc2751ff2 Clean up demo site: remove manual IDs and frontend-only approach
- Remove all manual data-content-id attributes from HTML files
- Archive old insertr JS/CSS assets to demo-site/archive/
- Remove hardcoded script includes and CSS links
- Remove old authentication controls and mock API
- Enable pure zero-config approach with class='insertr' only
- Parser now generates all 40 content IDs automatically
2025-09-03 12:18:43 +02:00
afd4879cef Refactor to modular architecture with extensible configuration system
- Split monolithic insertr.js (932 lines) into 6 focused modules
- Extract configuration system for extensible field types and validation
- Separate validation, form rendering, content management, and markdown processing
- Maintain same API surface while improving maintainability and testability
- Update demo pages to use modular system
- Remove legacy support for cleaner codebase
2025-09-01 13:55:01 +02:00
e639c5e807 Implement client-side validation and sanitization
Add UX-focused validation to prevent user accidents and provide immediate feedback. Includes DOMPurify integration for basic content sanitization and real-time form validation.

Features:
- Real-time input validation with visual feedback
- Field-type specific validation (text, URL, markdown)
- DOMPurify integration for display sanitization
- Validation messages with auto-dismiss
- Prevents common user mistakes (HTML in text fields, invalid URLs)
- Client-side sanitization for markdown rendering
- Maintains security awareness while focusing on user experience

Note: This is UX-focused validation - server-side validation remains the primary security boundary.
2025-09-01 13:33:16 +02:00
39e60e0b3f Add hybrid editing system with markdown collections
Implement markdown collection support alongside existing element-level editing. Users can now choose between individual element editing (headlines, buttons) and rich markdown editing (stories, bios). Includes responsive overlay forms, smart field detection, and comprehensive documentation updates.

Features:
- Markdown collections with data-field-type="markdown"
- Responsive overlay forms that adapt to element width
- Element-level editing for granular control
- Updated documentation and integration guide
- Fixed marked.js renderer configuration issues
- Enhanced about.html to demonstrate both approaches
2025-09-01 13:20:29 +02:00
0d79ab1fef Replace custom markdown parser with marked.js v16.2.1
🚀 Major Upgrade: Professional markdown handling with marked.js

 Fixed Issues:
- No more recursion errors or browser crashes
- Proper handling of complex markdown (multiple links per line)
- Robust parsing of edge cases and nested formatting

🔧 Implementation:
- Added marked.js v16.2.1 via CDN to both HTML pages
- Custom renderer preserves button styling (btn-primary)
- Smart lead paragraph detection for styling preservation
- Intelligent element merging to maintain layout
- Removed all buggy custom parsing code (100+ lines)

🎯 New Capabilities:
- Multiple buttons per line: [Get Started](link1) [Or tomorrow](link2)
- Full CommonMark support (tables, lists, formatting)
- Better performance with optimized C-like parsing
- Extensible renderer system for future enhancements

 User Experience:
- Edit forms now handle complex markdown perfectly
- Layout and styling fully preserved after saves
- No more crashes when editing rich content
- Professional markdown processing

Ready to test the two-button hero scenario! 🚀
2025-08-30 12:37:45 +02:00
af88e57272 Add working frontend prototype with edit-in-place functionality
 Features implemented:
- Complete demo website (Acme Consulting Services)
- Core insertr.js library with edit-in-place functionality
- Support for simple text and rich markdown content
- Mock authentication system (login/logout simulation)
- Edit mode toggle for client interface
- Local storage persistence
- Visual feedback for saving content
- Multi-page support (index.html, about.html)
- Responsive design with clean UI

🎯 Three user experiences:
- Customer: Clean website with no edit interface
- Client: Same website + edit buttons when authenticated
- Developer: Simple class-based integration

🏗️ Architecture:
- Vanilla JavaScript (no framework dependencies)
- Alpine.js ready for enhanced interactivity
- CSS-only styling for edit indicators
- Mock API structure for backend planning

Next: Connect to Go backend with real persistence
2025-08-29 22:41:15 +02:00