# Writer Editor Improvements Improvements to `modules/hudozka-writer/` — the Tiptap-based page editor for the hudozka CMS. ## 1. Fix Markdown Serialization + Global Toggle ### Problem The `@tiptap/markdown` extension is registered but not used in the serialization layer (`src/lib/serialize.ts`). Currently: - `docToTiptap()` splits text on `\n\n` and wraps each chunk in a plain paragraph node — no markdown parsing - `tiptapToDoc()` extracts raw text content, discarding all inline marks (bold, italic, links) and block structure (headings, lists) Result: formatting applied via toolbar is lost on save. ### Solution Use `@tiptap/markdown` for both directions: **Loading (DocV1 → Tiptap):** For each `text` block, call `editor.commands.setContent(block.text)` or use the Markdown extension's parser to convert the markdown string into Tiptap JSON nodes. This replaces the naive paragraph splitting in `textBlockToTiptap()`. **Saving (Tiptap → DocV1):** When flushing the text buffer in `tiptapToDoc()`, use the Markdown extension's serializer (`editor.storage.markdown.getMarkdown()`) to convert Tiptap JSON back to a markdown string. This replaces the lossy `tiptapTextContent()` that strips all formatting. Implementation approach: create a headless Tiptap editor instance (no DOM) used solely for markdown↔JSON conversion in `serialize.ts`. This keeps serialization pure and avoids coupling to the live editor instance. ### Global Markdown Toggle Add a toolbar button that switches the entire editor between two modes: - **Rendered mode** (default): Normal WYSIWYG editing via Tiptap - **Markdown mode**: Replace the Tiptap editor surface with a plain `