- Add backend container transformation in engine.go following syntactic sugar specification - Containers with .insertr get class removed and viable children get .insertr added - Remove incorrect frontend container expansion - frontend only finds enhanced elements - Fix StyleAwareEditor hasMultiPropertyElements runtime error - Add addClass/removeClass methods to ContentEngine for class manipulation - Update frontend to match HTML-first approach with no runtime container logic - Test verified: container <section class='insertr'> transforms to individual h1.insertr, p.insertr, button.insertr This completes the container expansion functionality per CLASSES.md: Developer convenience (one .insertr enables section editing) + granular control (individual element editing)
51 lines
1.8 KiB
JavaScript
51 lines
1.8 KiB
JavaScript
/**
|
|
* InsertrCore - Core functionality for content management
|
|
*/
|
|
export class InsertrCore {
|
|
constructor(options = {}) {
|
|
this.options = {
|
|
apiEndpoint: options.apiEndpoint || '/api/content',
|
|
siteId: options.siteId || 'default',
|
|
...options
|
|
};
|
|
}
|
|
|
|
// Find all enhanced elements on the page
|
|
// Note: Container expansion is handled at build-time by the backend enhancer
|
|
// Frontend should only find elements that already have .insertr class
|
|
findEnhancedElements() {
|
|
return document.querySelectorAll('.insertr');
|
|
}
|
|
|
|
// Note: All container expansion logic removed - handled by backend enhancer
|
|
// Frontend only works with elements that already have .insertr class
|
|
|
|
// Get element metadata
|
|
getElementMetadata(element) {
|
|
const existingId = element.getAttribute('data-content-id');
|
|
|
|
// HTML-first approach: no content type needed, just HTML markup for ID generation
|
|
return {
|
|
contentId: existingId, // null if new content, existing ID if updating
|
|
element: element,
|
|
htmlMarkup: element.outerHTML // Server will generate ID from this
|
|
};
|
|
}
|
|
|
|
// Get current file path from URL for consistent ID generation
|
|
getCurrentFilePath() {
|
|
const path = window.location.pathname;
|
|
if (path === '/' || path === '') {
|
|
return 'index.html';
|
|
}
|
|
// Remove leading slash: "/about.html" → "about.html"
|
|
return path.replace(/^\//, '');
|
|
}
|
|
|
|
// Get all elements with their metadata
|
|
// Note: Container expansion handled by backend - frontend finds enhanced elements only
|
|
getAllElements() {
|
|
const elements = this.findEnhancedElements();
|
|
return Array.from(elements).map(el => this.getElementMetadata(el));
|
|
}
|
|
} |