@davidpdd/sanity-plugin-byo-table

2.0.0 • Public • Published

sanity-plugin-byo-table

Sanity plugin that supplies the react editor for a user defined table and row. Basically, bring your own schema.

This repo is forked from sanity-plugin-byo-table

Installing

Install using the Sanity CLI.

sanity install @davidpdd/sanity-plugin-byo-table

Usage

You need to define the schema types yourself and refer to this plugin as an input component there:

import RowsInput from 'part:@davidpdd/sanity-plugin-byo-table/rows-input';

export default {
  title: 'Table',
  name: 'table',
  type: 'object',
  fields: [
    {
      name: 'rows',
      type: 'array',
      of: [
        {
          type: 'tableRow',
        }
      ],
      inputComponent: RowsInput
    }
  ]
};

You can use both strings and sanity objects as cell value. There are no restrictions on the naming of the schema types involved, but 'rows' need to be an array of the row object, and the row object needs to only have one field of type array.

To ease implementation you should probably just copy-paste the contents of /example-schema into your sanity repo /schema/whatever-table. Then declare those table components like you usually would. The examples are not totally complete.

Migrating from sanity-plugin-table

If coming from the original fork and wanting to switch to this plugin, you can do it without migrating. Just install this plugin, remove the old one, copy in the schema and point the RowsInput-component to the 'rows' field.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @davidpdd/sanity-plugin-byo-table

Weekly Downloads

4

Version

2.0.0

License

MIT

Unpacked Size

42.5 kB

Total Files

19

Last publish

Collaborators

  • davidpdd