Repository navigation
fix(web): treat spans with unsupported inline styles as custom HTML - #594
Open
pcbeingused333 wants to merge 1 commit into
Open
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #494
Description
detectCustomHtmlPatternslets every<span style="...">through as "TipTap can round-trip it". That is only true forcolor(the editor loads TextStyle + Color only). A span with e.g.background-color: #ff0(a highlight, as in the issue) orfont-size: 20pxwas 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
stylehas any declaration other thancolor(or the harmlessbackground-color: initial|transparentexport 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 realbackground-color;font-sizenext tocolor). Both fail onmainand pass with the change (vitest runon that file: 26/26). The existing color-only /initial/transparentspan cases still pass.Checklist
emailStyles.test.ts)Related Issues
Closes #494
This PR was prepared with AI assistance (Claude Code); the change is submitted by the account owner.