fix: clean Word inline styles when pasting into rich editor#73
Open
mindcraft-research wants to merge 1 commit into
Open
fix: clean Word inline styles when pasting into rich editor#73mindcraft-research wants to merge 1 commit into
mindcraft-research wants to merge 1 commit into
Conversation
Quand l'utilisateur·rice colle du contenu depuis Word (ou Google Docs, Excel...), les balises inline reçoivent des inline-styles parasites (color, font-family, font-size...) qui écrasent ensuite les couleurs définies au niveau des titres via le bouton « couleur » de l'éditeur. Exemple typique signalé : on colle un titre depuis Word, puis on tente de le passer en bleu via la toolbar. Visuellement le titre reste noir parce que le <strong style="color:black"> hérité de Word gagne sur le <span style="color:blue"> ajouté par l'éditeur. Fix : intercepter le coller via editorProps.transformPastedHTML, parser le contenu, retirer les inline-styles color / background / font-family / font-size / font-weight des balises inline (strong, b, em, i, u, span). On nettoie aussi les classes Word « MsoXxx » et les balises Office (<o:p>, <w:WordDocument>). Le formatage utile (gras, italique, souligné, listes, alignement, titres) reste préservé. Bug signalé par MaximeVIALA dans le feedback #cmp2cj1ok (qui avait identifié la cause lui-même).
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.
Summary
Quand l'utilisateur·rice colle du contenu depuis Word (ou Google Docs / Excel / etc.) dans l'éditeur riche, les balises inline (``, ``, ``...) reçoivent des inline-styles parasites (`color`, `font-family`, `font-size`...) qui écrasent ensuite les couleurs définies au niveau des titres via le bouton « couleur » de l'éditeur.
Exemple typique signalé : on colle un titre depuis Word, puis on tente de le passer en bleu via la toolbar. Visuellement le titre reste noir parce que le `` hérité de Word gagne sur le `` ajouté par l'éditeur.
Fix
Intercepter le coller via `editorProps.transformPastedHTML` de TipTap :
Le formatage utile (gras, italique, souligné, listes, alignement, titres) reste préservé.
Test plan
🤖 Generated with Claude Code