feat: Implement HTML-first style preservation system

- Add StyleContext class for extracting and applying HTML attributes/styles
- Enhance MarkdownConverter with style-aware conversion methods
- Switch backend storage from markdown to HTML with 'html' content type
- Update editor workflow to preserve CSS classes, IDs, and attributes
- Maintain markdown editing UX while storing HTML for style preservation
- Support complex attributes like rel, data-*, aria-*, etc.

This enables editing styled content like <a class="fancy" rel="me">text</a>
while preserving all styling attributes through the markdown editing process.
This commit is contained in:
2025-09-19 16:03:05 +02:00
parent 00c2ba34e6
commit b7998a4b3c
7 changed files with 498 additions and 26 deletions

View File

@@ -299,13 +299,13 @@ func (h *ContentHandler) CreateContent(w http.ResponseWriter, r *http.Request) {
}
}
// Determine content type: use provided type, fallback to existing type, default to "text"
// Determine content type: use provided type, fallback to existing type, default to "html"
contentType := req.Type
if contentType == "" && contentExists {
contentType = h.getContentType(existingContent)
}
if contentType == "" {
contentType = "text" // default type for new content
contentType = "html" // default type for new content (changed from "text")
}
var content interface{}

View File

@@ -103,6 +103,8 @@ func (i *Injector) InjectBulkContent(elements []ElementWithID) error {
i.injectTextContent(elem.Element.Node, contentItem.Value)
case "markdown":
i.injectMarkdownContent(elem.Element.Node, contentItem.Value)
case "html":
i.injectHTMLContent(elem.Element.Node, contentItem.Value)
case "link":
i.injectLinkContent(elem.Element.Node, contentItem.Value)
default: