Implement complete collection persistence with database-backed survival across server restarts

• Add full multi-table schema for collections with normalized design (collections, collection_templates, collection_items, collection_item_versions)
• Implement collection detection and processing in enhancement pipeline for .insertr-add elements
• Add template extraction and storage from existing HTML children with multi-variant support
• Enable collection reconstruction from database on server restart with proper DOM rebuilding
• Extend ContentClient interface with collection operations and full database integration
• Update enhance command to use engine.DatabaseClient for collection persistence support
This commit is contained in:
2025-09-22 18:29:58 +02:00
parent b25663f76b
commit 2315ba4750
36 changed files with 4356 additions and 46 deletions

View File

@@ -1,4 +1,5 @@
import { InsertrFormRenderer } from '../ui/form-renderer.js';
import { CollectionManager } from '../ui/collection-manager.js';
/**
* InsertrEditor - Content editing workflow and business logic
@@ -67,8 +68,18 @@ export class InsertrEditor {
initializeElement(meta) {
const { element } = meta;
// Add click handler for editing
this.addClickHandler(element, meta);
if (meta.editorType === 'collection') {
// Initialize collection management
this.initializeCollection(meta);
} else {
// Add click handler for editing individual elements
this.addClickHandler(element, meta);
}
}
initializeCollection(meta) {
const collectionManager = new CollectionManager(meta, this.apiClient, this.auth);
collectionManager.initialize();
}
addClickHandler(element, meta) {

View File

@@ -12,17 +12,19 @@ export class InsertrCore {
// Find all enhanced elements on the page
findEnhancedElements() {
return document.querySelectorAll('.insertr');
return document.querySelectorAll('.insertr, .insertr-add');
}
// Get element metadata
getElementMetadata(element) {
const existingId = element.getAttribute('data-content-id');
const isCollection = element.classList.contains('insertr-add');
return {
contentId: existingId,
element: element,
htmlMarkup: element.outerHTML // Server will generate ID from this
htmlMarkup: element.outerHTML, // Server will generate ID from this
editorType: isCollection ? 'collection' : 'element'
};
}