Skip to content

[Bug] TextAlign extension adds "textAlign: null" to JSON output by default #7561

@romancavry

Description

@romancavry

Affected Packages

extension-text-align

Version(s)

3.19.0

Bug Description

When using the TextAlign extension, every node of the specified types (e.g., paragraph, heading) gets a textAlign: null attribute in the JSON output, even if no alignment has been applied.

This behavior leads to bloated JSON data and can cause issues when synchronizing with databases or external systems that expect clean data structures. Ideally, the attribute should only be present if a non-default alignment is set.

Steps to reproduce:

  • Install and configure @tiptap/extension-text-align with default settings.
  • Create a simple paragraph without applying any alignment.
  • Call editor.getJSON().
  • Observe that the paragraph node contains "attrs": { "textAlign": null }

Browser Used

Chrome

Code Example URL

No response

Expected Behavior

The textAlign attribute should be omitted from the attrs object if its value is the default (null or left), similar to how other extensions handle default attributes.

Additional Context (Optional)

No response

Dependency Updates

  • Yes, I've updated all my dependencies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Open SourceThe issue or pull reuqest is related to the open source packages of Tiptap.

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions