Discussion about using Portable Text-editor in Sanity and resolving errors.

22 replies
Last updated: Mar 6, 2023
Idk why but I am not being able to use Portable Text-editor properly, these photos depict my schema for content as well as the error.
Mar 6, 2023, 2:34 AM
Looks like you're just copying from the Sanity docs and looks correct to me. Are you getting any other errors in your terminal? Also what version are you on?
Mar 6, 2023, 3:21 AM
I am on v3.
Mar 6, 2023, 3:21 AM
Have you already tried nuking node modules and re-installing?
Mar 6, 2023, 3:22 AM
And let me check the errors. And yes I tried
Mar 6, 2023, 3:23 AM
Let me do reinstalling of node_mudules, should I use yarn or npm?
Mar 6, 2023, 3:23 AM
Shouldn't matter if you're starting from scratch - Otherwise use whatever your project currently uses.
Mar 6, 2023, 3:24 AM
Could you send the entire file of code with your block?
Mar 6, 2023, 3:24 AM
Starting from scratch!!
Mar 6, 2023, 3:25 AM
Ah nice!
Mar 6, 2023, 3:25 AM
I typically use yarn, but you should be fine either way.
Mar 6, 2023, 3:25 AM
I have commented it.
Mar 6, 2023, 3:26 AM
Interesting... I think part of it might be your folder structure. When I create a NextJS app I have two parent folders,
app
and
studio
to keep their packages/configs separate but it looks like you've put them under the same umbrella.
Mar 6, 2023, 3:31 AM
Actually, I was following this tutorial

https://youtu.be/6uiX6mYVPxw
Mar 6, 2023, 3:32 AM
Does your config work with the exception of that block content?
Mar 6, 2023, 3:33 AM
yep!
Mar 6, 2023, 3:33 AM
Hmm I'm about to hit the hay for tonight but can try looking tomorrow if nobody beats me to it. I have a personal project and just copy/pasted the snippet from Sanity's docs and it works for me:
Mar 6, 2023, 3:39 AM
It would be great if you can send me that particular code.
And I am so much thankful for your help here.
Mar 6, 2023, 3:40 AM
Sure thing, I just added the block as a field to my
song
object:
export default {
  title: "Song",
  name: "song",
  type: "object",
  fields: [
    {
      title: "created",
      name: "created",
      type: "date",
      validation: (Rule: any) => Rule.required(),
    },
    {
      tile: "songFile",
      name: "songFile",
      type: "file",
    },
    {
      tile: "songName",
      name: "songName",
      type: "string",
    },
    {
      name: 'content',
      title: 'Content',
      type: 'array',
      of: [
        {
          type: 'block',
          marks: {
            decorators: [
              { title: 'Strong', value: 'strong' },
              { title: 'Emphasis', value: 'em' },
              { title: 'Code', value: 'code' }
            ]
          }
        }
      ]
    }
  ],
};
Mar 6, 2023, 3:41 AM
Thank You so much sir.
Mar 6, 2023, 3:41 AM
No problem, hope it helps you.
Mar 6, 2023, 3:42 AM
I think I need to get other kind of solution that's not working.
Mar 6, 2023, 3:43 AM

Sanity– build remarkable experiences at scale

The Sanity Composable Content Cloud is the headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?