Go Behind the Experience to see how Tecovas brings the West to life with Sanity 🀠 July 18th

Issue with block content editor resolved by updating Sanity Studio

3 replies
Last updated: Jun 19, 2024
Hey all, ive noticed an issue with our block content editor, here is my schema for the editor
import {defineType} from 'sanity'

export default defineType({
  title: 'Content',
  name: 'richText',
  type: 'array',
  // All possible "Blocks" that a content editor can use
  options: {
    sortable: true,
  },
  of: [
    {
      type: 'block',
      styles: [
        {title: 'Normal', value: 'normal'},
        {title: 'Heading 2', value: 'h2'},
        {title: 'Heading 3', value: 'h3'},
        {title: 'Heading 4', value: 'h4'},
        {title: 'Heading 5', value: 'h5'},
      ],
    },
    {
      type: 'image',
      icon: () => 'πŸ–ΌοΈ',
      options: {hotspot: true},
      fields: [
        {
          name: 'alt',
          type: 'string',
          title: 'Alternative text',
          description: 'Describe the image. Important for SEO and accessiblity.',
        },
        {
          name: 'wide',
          type: 'boolean',
          title: 'Wide Image?',
          description: 'Makes images wider than the text column.',
          initialValue: false,
        },
        {
          name: 'background',
          type: 'boolean',
          title: 'Add grey background?',
          description: 'Adds a grey background/border to the image.',
          initialValue: false,
        },
      ],
    },
    // Rest of my blocks
  ],
  validation: (Rule) => Rule.required(),
  group: 'content',
})
When i paste an image into the editor, i get the following error:


Could not validate the resulting portable text to insert. Editor value must be an array of Portable Text blocks, or undefined. Try to insert as plain text (shift-paste) instead.
Could someone help here? I know i can paste images in because it works in another studio i have, but the schema seems similar
Jun 18, 2024, 2:16 PM
πŸ‘‹ What version of the Studio are you running?
Jun 18, 2024, 4:27 PM
Its v3 πŸ™‚ Specifically 3.31.0
Jun 19, 2024, 7:54 AM
Have updated it and it seems to now work πŸ€”
Jun 19, 2024, 7:58 AM

Sanity– build remarkable experiences at scale

Sanity is a modern 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?