-
Notifications
You must be signed in to change notification settings - Fork 78
Description
Summary
Preserve text alignment (center, right, justify) when pasting content from Google Docs into SuperDoc.
Problem
When pasting from Google Docs, all text alignment is lost — everything becomes left-aligned. Google Docs sends text-align as an inline CSS style on <p> elements, but parseAttrs only reads data-* attributes.
Repro
- Create a Google Doc with centered, right-aligned, and justified paragraphs.
- Copy the content and paste into SuperDoc.
- All paragraphs are left-aligned.
Expected
Text alignment from the pasted content is preserved in SuperDoc.
Notes
parseAttrs in packages/super-editor/src/extensions/paragraph/helpers/parseAttrs.js only reads data-indent, data-spacing, and data-num-id/data-level attributes. It never checks node.style.textAlign.
Google Docs sends alignment as inline styles:
style="text-align: center; line-height: 1.38; margin-top: 12pt"
The fix should check node.style.textAlign in parseAttrs and map it to paragraphProperties.justification. The TextAlign extension already uses this path internally via commands.updateAttributes('paragraph', { 'paragraphProperties.justification': alignment }).
File: packages/super-editor/src/extensions/paragraph/helpers/parseAttrs.js
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-1978