Skip to content

Feature: Inline CSS from <style> Tags During HTML Import #8318

@tomsarduy

Description

@tomsarduy

Description

When pasting HTML from applications like Microsoft Excel, Google Sheets, and some email clients, styles are often defined in <style> blocks using class selectors instead of inline styles.

Example:

<style>
  .foo { background: red; color: blue; }
</style>
<table>
  <tr>
    <td class="foo">Hello</td>
  </tr>
</table>

Currently, Lexical’s import pipeline only reads (most) inline styles (element.style.), so all class-based styles (background color, text color, font size, etc.) are silently lost.

Use Cases

  • Pasting tables from Excel → cell backgrounds, width and text colors are lost
  • Pasting formatted content from some email clients
  • Any HTML import where styles are defined via <style> instead of inline

Proposed Solution

Add a pre-processing step at the start to inline CSS rules from <style> tags before the conversion.
This ensures all existing converters automatically support these styles without modification.

Impact

Any Lexical user pasting from Excel, Google Sheets, Outlook, or similar tools

Scope:
  • Affects all Lexical-based editors
  • Changes live in:
    • @lexical/html (import pipeline)
    • @lexical/table (color propagation)
Frequency:
  • Copy-paste from spreadsheets and email is extremely common in enterprise workflows.
  • Losing formatting is a frequent and highly visible UX issue.
EXCEL TABLE AFTER COPY

Metadata

Metadata

Assignees

No one assigned

    Labels

    copy+pasteRelates to Lexical Copy/PasteenhancementImprovement over existing feature

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions