Skip to content

Detect heading levels from Google Docs styled paragraphs #2152

@caio-pizzol

Description

@caio-pizzol

Summary

Detect and preserve heading levels (H1, H3-H6) when pasting from Google Docs, which converts them to styled <p> tags.

Problem

When pasting content with H1, H3-H6 headings from Google Docs, they lose their heading level and paste as plain paragraphs. Only H2 is reliably preserved as a heading tag.

Repro

  1. Create a Google Doc with headings at all levels (H1 through H6).
  2. Copy the content and paste into SuperDoc.
  3. Only H2 headings are preserved. H1 and H3-H6 paste as regular paragraphs.

Expected

All heading levels from pasted content are preserved in SuperDoc.

Notes

Google Docs converts most heading levels to <p> tags with inline font-size/font-weight styling instead of semantic <h1>-<h6> tags. The paragraph.parseDOM has rules for h1-h6 but they never fire for these styled <p> elements.

The fix should detect heading-like paragraphs by font-size/font-weight in the Google Docs paste handler before ProseMirror parsing, and convert them to proper <h1>-<h6> tags. Google Docs typically uses predictable font sizes for each heading level (e.g., 24pt=H1, 18pt=H2, 14pt=H3, etc.).

File: packages/super-editor/src/core/inputRules/google-docs-paste/google-docs-paste.js

copy-paste-test.docx


Want to work on this? Check the Contributing Guide to get started. Comment on the GitHub issue to let us know you're picking it up.


Want to work on this? Check the Contributing Guide to get started. Comment on this issue to let us know you're picking it up.

Ref: SD-1981

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions