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

Feature request: Allow type: array in cellSchema #8

Open
RyanWarner opened this issue Apr 8, 2023 · 1 comment
Open

Feature request: Allow type: array in cellSchema #8

RyanWarner opened this issue Apr 8, 2023 · 1 comment

Comments

@RyanWarner
Copy link

RyanWarner commented Apr 8, 2023

Thank you for this great library.

I'd like to put images or custom components in my cells.

When I use the suggested Sanity schema, I get a type error, "Type '"array"' is not assignable to type '"block"'."

cellSchema: {
  name: 'content',
  type: 'array',
  title: 'Content',
  of: [
    {
      type: 'block'
    },
    {
      type: 'image'
    }
  ]
}
@davydog187
Copy link
Owner

davydog187 commented Apr 10, 2023

@RyanWarner thank you for reporting! I was aware of this issue, but was unable to fix due to #4

Now that there seems to be a solution in place, I can resolve this issue.

However, I want to make you aware of something: you cannot have an array as a child of a block, which is what Sanity is complaining about. Right now, this library only allows a single block definition, but I will extend it to support multiple block types, e.g.

cellSchema: [{
    name: "table-block",
    type: "block",
    marks: [ ... ],
    lists: [ ... ]  
  },
  {  type: "my-custom-block" },
  {  type: "my-image" },
  ...
]

Let me know if this suits your needs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants