Unlock seamless workflows and faster delivery with our latest releases – get the details

How to migrate your block text schema for the new definition of inline objects

Previously inline objects in your text blocks were defined like this via the options.inline property:

{
  name: 'body',
  type: 'array',
  title: 'Content',
  of: [
    {type: 'block'},
    {
      name: 'author',
      title: 'Author',
      type: 'reference',
      to: {type: 'author'},
      options: {inline: true}
    }
}

We didn’t get the syntax totally right here, as inline nodes are children of the block type and therefore shouldn’t be defined on the same level as the other blocks in your block array.

So we needed to change it to make it work with validations – the new way to do this is via the block type’s of property:

{
  name: 'body',
  type: 'array',
  title: 'Content',
  of: [
    {
      type: 'block',
      of: [
        {
          name: 'author',
          title: 'Author',
          type: 'reference',
          to: {type: 'author'}
        }
      ]
    }
}

If you would like to support embedding an author object both inline and as a block, you would do it like this:

{
  name: 'body',
  type: 'array',
  title: 'Content',
  of: [
    {
      type: 'block',
      of: [
        {
          name: 'author',
          title: 'Author',
          type: 'reference',
          to: {type: 'author'}
        }
      ]
    },
    {
      name: 'author',
      title: 'Author',
      type: 'reference',
      to: {type: 'author'}
    }
}

Was this article helpful?