Skip to content

fix(web): treat spans with unsupported inline styles as custom HTML - #594

Open
pcbeingused333 wants to merge 1 commit into
useplunk:nextfrom
pcbeingused333:fix/editor-span-style-flip
Open

pcbeingused333 wants to merge 1 commit into
useplunk:nextfrom
pcbeingused333:fix/editor-span-style-flip

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Fixes #494

Description

detectCustomHtmlPatterns lets every <span style="..."> through as "TipTap can round-trip it". That is only true for color (the editor loads TextStyle + Color only). A span with e.g. background-color: #ff0 (a highlight, as in the issue) or font-size: 20px was classified as visual-editor content, so after saving, the template reopened in the visual editor and TipTap silently dropped those styles.

Now a span counts as custom HTML when its style has any declaration other than color (or the harmless background-color: initial|transparent export artifact already covered by existing tests). Such templates stay in the HTML editor, which matches the guidance in the issue to keep using the HTML editor for things the visual editor can't represent, and switching to visual now shows the existing "custom HTML will be lost" warning instead of stripping silently.

This is a narrow detection fix; it does not add new editor extensions.

Type of Change

  • feat: New feature (MINOR version bump)
  • fix: Bug fix (PATCH version bump)
  • feat!: Breaking change - new feature (MAJOR version bump)
  • fix!: Breaking change - bug fix (MAJOR version bump)
  • docs: Documentation update (no version bump)
  • chore: Maintenance/dependencies (no version bump)
  • refactor: Code refactoring (no version bump)
  • test: Adding tests (no version bump)
  • perf: Performance improvement (PATCH version bump)

Testing

Added two cases to apps/web/src/lib/__tests__/emailStyles.test.ts (a real background-color; font-size next to color). Both fail on main and pass with the change (vitest run on that file: 26/26). The existing color-only / initial / transparent span cases still pass.

Checklist

  • PR title follows conventional commits format
  • Code builds successfully
  • Tests pass locally (emailStyles.test.ts)
  • Documentation updated (if needed)

Related Issues

Closes #494


This PR was prepared with AI assistance (Claude Code); the change is submitted by the account owner.

A <span> whose style has anything besides color (a real background-color,
font-size, ...) was not flagged as custom, so the editor reopened the
template in the visual editor, where TipTap's TextStyle drops those
styles on save.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Editor strips normal style tags like highlights

1 participant