Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Non-empty array for content breaks editor #5198

Open
1 task done
gpunto opened this issue Jun 1, 2024 · 0 comments
Open
1 task done

[Bug]: Non-empty array for content breaks editor #5198

gpunto opened this issue Jun 1, 2024 · 0 comments
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug

Comments

@gpunto
Copy link

gpunto commented Jun 1, 2024

Affected Packages

pm, react, starter-kit, extension-underline

Version(s)

2.4.0

Bug Description

The bug is the same as #3773:

As per the typings for Content:

export declare type Content = HTMLContent | JSONContent | JSONContent[] | null;

A JSONContent array is valid, however the editor breaks if you supply an array

It was supposed to be fixed by #3786, however, the fix only works for empty arrays and Tiptap still fails for non-empty ones.

For example, using this as content succeeds:

{
  type: "doc",
  content: [
    {
      type: "paragraph",
      content: [{type: "text", text: "Hello"}]
    }
  ]
}

but this fails:

[
  {
    type: "paragraph",
    content: [{type: "text", text: "Hello"}]
  }
]

Given that the error is:

Uncaught TypeError: config.doc.type is undefined

I guess it happens because, in case of arrays, createNodeForContent returns a Fragment, but Fragment has no type while Node does.

Browser Used

Chrome

Code Example URL

No response

Expected Behavior

The editor should load and display the JSONContent[] as its content.

Additional Context (Optional)

No response

Dependency Updates

  • Yes, I've updated all my dependencies.
@gpunto gpunto added Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug labels Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug
Projects
Status: Triage open
Development

No branches or pull requests

1 participant