Implement professional smart formatting with toggle logic and whitespace preservation
This commit is contained in:
@@ -9,29 +9,23 @@ export class InsertrCore {
|
||||
...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
|
||||
contentId: existingId,
|
||||
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;
|
||||
@@ -41,11 +35,10 @@ export class InsertrCore {
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user