refactor: Complete UI cleanup and simplify editor architecture

- Remove complex style preservation system from editor
- Simplify markdown conversion back to straightforward approach
- Remove StyleContext class and style-aware conversion methods
- Switch content type from 'html' back to 'markdown' for consistency
- Clean up editor workflow to focus on core markdown editing
- Remove ~500 lines of unnecessary style complexity

This completes the UI unification cleanup by removing the overly complex
style preservation system that was making the editor harder to maintain.
This commit is contained in:
2025-09-19 16:15:56 +02:00
parent b7998a4b3c
commit 968e64a57e
6 changed files with 21 additions and 496 deletions

View File

@@ -1,5 +1,4 @@
import { InsertrFormRenderer } from '../ui/form-renderer.js';
import { markdownConverter } from '../utils/markdown.js';
/**
* InsertrEditor - Content editing workflow and business logic
@@ -115,35 +114,16 @@ export class InsertrEditor {
try {
// Extract content value based on type
let markdownContent;
let contentValue;
if (meta.element.tagName.toLowerCase() === 'a') {
// For links, save the text content (URL is handled separately if needed)
markdownContent = formData.text || formData;
contentValue = formData.text || formData;
} else {
markdownContent = formData.text || formData;
}
// Convert markdown to HTML with style preservation
let contentValue;
const contentType = this.determineContentType(meta.element);
if (contentType === 'html') {
// Extract style context from original element and convert markdown to HTML
const { markdown, styleContext } = markdownConverter.htmlToMarkdownWithContext(meta.element.innerHTML, meta.element);
if (styleContext && styleContext.hasPreservableContent) {
// Convert markdown back to HTML with style preservation
contentValue = markdownConverter.markdownToHtmlWithStyles(markdownContent, styleContext);
} else {
// No styles to preserve, simple conversion
contentValue = markdownConverter.markdownToHtml(markdownContent);
}
} else {
// For other content types (text, link), use markdown as-is
contentValue = markdownContent;
contentValue = formData.text || formData;
}
// Universal upsert - server handles ID extraction/generation from markup
const contentType = this.determineContentType(meta.element);
const result = await this.apiClient.createContent(
contentValue,
contentType,
@@ -175,8 +155,8 @@ export class InsertrEditor {
return 'link';
}
// ALL text elements use HTML storage with markdown editing interface
return 'html';
// ALL text elements use markdown for consistent editing experience
return 'markdown';
}
handleCancel(meta) {