Skip to content

Preserve line spacing and indentation on Google Docs paste #2151

@caio-pizzol

Description

@caio-pizzol

Summary

Preserve line spacing and paragraph indentation when pasting content from Google Docs into SuperDoc.

Problem

Line spacing (single, 1.5x, double) and paragraph indentation are lost when pasting from Google Docs. Everything pastes as default spacing with no indentation.

Repro

  1. Create a Google Doc with different line spacings (single, 1.5, double) and indented paragraphs.
  2. Copy the content and paste into SuperDoc.
  3. All spacing is default and indentation is gone.

Expected

Line spacing and indentation from pasted content are preserved in SuperDoc.

Notes

parseAttrs reads data-indent and data-spacing JSON attributes (SuperDoc's internal format), but Google Docs uses inline CSS on <p> elements:

  • Line height: lineHeight: "1.2" (single), "1.8" (1.5x), "2.4" (double)
  • Margins: marginTop/marginBottom in pt
  • Indentation: marginLeft: "30pt" (indented), "60pt" (double-indented)
  • Blockquote: Google Docs sends marginLeft: "30pt" as a <p>, not a <blockquote> tag

The fix should extract node.style.lineHeight, node.style.marginLeft, node.style.marginTop, and node.style.marginBottom in parseAttrs, then convert them to paragraphProperties.spacing and paragraphProperties.indent.

File: packages/super-editor/src/extensions/paragraph/helpers/parseAttrs.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-1980

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions