0.0.14 • Published 3 years ago

sanity-plugin-power-table v0.0.14

Weekly downloads
27
License
MIT
Repository
-
Last release
3 years ago

sanity-plugin-power-table

Create powerful tables in sanity:

  • Custom row and cell schema
  • Cell-level management, each cell can have its own rowSpan and colSpan

based on sanity-plugin-byo-table

Installation

sanity install power-table

Usage

  • First import the schema generating function:

    import tableSchema from 'part:power-table/schema'
  • Next create and export schema for your table.

    • Row Schema is optional. It should be an object if provided.
    • Cell schema can be a string or object.

    • Minimal example:

      export const myTableSchemas = tableSchema({
        name: 'myTable',
        title: 'My table',
        cellSchema: {
          type: 'string',
        },
      })
    • Bigger example:

      export const myTableSchemas = tableSchema({
        name: 'myTable',
        title: 'My table',
        rowSchema: {
          type: 'object',
          fields: [
            {
              name: 'heading',
              title: 'Heading',
              type: 'boolean',
            },
          ],
        },
        cellSchema: {
          type: 'object',
          fields: [
            {
              name: 'contents',
              title: 'Contents',
              type: 'array',
              of: [{ type: 'block' }] 
            },
          ],
        },
      })
  • Use the table by the name you provided

    export default {
      name: 'mySchema',
      title: 'My Schema',
      type: 'document',
      fields: [
        {
          name: 'headline',
          title: 'Headline',
          type: 'array',
          of: [{ type: 'block' }],
        },
        {
          name: 'table',
          title: 'My Table',
          type: 'myTable'
        }
      ],
    }
  • Import the table schemas in your schema.js:

    import createSchema from 'part:@sanity/base/schema-creator'
    import mySchema, {myTableSchemas} from './mySchema'
    
    export default createSchema({
      name: 'default',
      types: [
        mySchema,
        ...myTableSchemas
      ],
    });

License

MIT © Christopher Fraser See LICENSE

0.0.13

3 years ago

0.0.14

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago