Skip to content

feat: add HTML import and export for layers#146

Merged
tristan-mouchet merged 5 commits intodevelopfrom
feat/html-import-export
Apr 10, 2026
Merged

feat: add HTML import and export for layers#146
tristan-mouchet merged 5 commits intodevelopfrom
feat/html-import-export

Conversation

@liamwalder
Copy link
Copy Markdown
Collaborator

Summary

Add bidirectional HTML ↔ Layer conversion so users can import external HTML
(with Tailwind class mapping) and export their layer trees back to clean HTML.

Changes

  • Add htmlToLayers parser and layersToHtml serializer in html-layer-converter
  • Add ImportHtmlDialog and ExportHtmlDialog UI components with code editor
  • Add context-menu actions for import/export on any layer
  • Map Tailwind classes (including v3→v4 normalization) to design properties
  • Handle rich text via Tiptap document format for inline content
  • Capture and export attributes for textarea, select, and form elements
  • Parse overflow classes into SizingDesign in classesToDesign
  • Convert inline styles (background-image, flex-grow/shrink/basis, order) to Tailwind
  • Sanitize imported SVGs by stripping script tags and on* attributes
  • Extract shared escapeHtml, tailwind-colors, and tailwind-normalizer modules
  • Fix <span> treated as block-level, causing nested <p> in rendered output
  • Fix <br> incorrectly mapped to <hr>
  • Add error handling with user-facing toast messages on import/export failures
  • Replace deprecated execCommand('copy') fallback with toast instruction

Test plan

  • Import the pricing section HTML from the PR description — no nested <p> warning
  • Import HTML with <span> inside <p> — inline text preserved, no nesting errors
  • Import HTML with <textarea>, <select>, <form> — attributes round-trip on export
  • Import HTML with inline styles — converted to Tailwind classes in design panel
  • Import SVG containing <script> or onclick — malicious content stripped
  • Import malformed HTML — toast error shown, no crash
  • Export layers to HTML — copy button works, clean output
  • Verify overflow classes (e.g. overflow-hidden) map to design panel correctly

Made with Cursor

- Add context menu options to import HTML into a layer and export a
  layer as HTML with syntax-highlighted code editor modals
- Convert HTML elements to Ycode layer trees with proper TipTap rich
  text structure, design properties, and layer settings
- Export layers back to HTML preserving rich text marks (bold, italic,
  links) and resolving Ycode layer names to standard HTML tags
- Normalize Tailwind v3 classes to v4 on import: opacity modifiers,
  scale-shifted utilities, gradient renames, placeholder variants,
  and standalone utility removal
- Convert inline CSS styles to Tailwind classes during import
- Resolve named Tailwind color classes (bg-blue-600) to hex arbitrary
  values (bg-[#2563eb]) for compatibility with Ycode design system

Made-with: Cursor
- Add span to INLINE_TEXT_TAGS to prevent nested <p> in rendered output
- Extract shared escapeHtml, tailwind-colors, and tailwind-normalizer
- Fix br incorrectly mapped to hr; skip br at block level
- Add textarea/select/form attribute capture on import and export
- Add overflow class parsing to classesToDesign
- Add background-image, flex-grow/shrink/basis, order to styleToClasses
- Sanitize SVG on import by stripping script tags and on* attributes
- Wrap htmlToLayers and handleImportHtml in try/catch error handling
- Replace deprecated execCommand copy fallback with toast message
- Widen makeTextLayer to accept string|object, remove inline duplicate

Made-with: Cursor
@tristan-mouchet tristan-mouchet merged commit 6550261 into develop Apr 10, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature request A new feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants