0.52.6 • Published 6 years ago

slate-schema v0.52.6

Weekly downloads
6
License
MIT
Repository
github
Last release
6 years ago

slate-schema

NPM version Linux Build Status

Slate plugin to do schema validation, the concept is based on Prosemirror schemas.

The schema describes the kind of nodes that may occur in the document, and the way they are nested. For example, it might say that the top-level node can contain one or more blocks, and that paragraph nodes can contain any number of inline nodes, with any marks applied to them.

Install

npm install slate-schema --save

Usage

import Schema from 'slate-schema'

const plugins = [
  Schema({
      document: {
          nodes: {
              except: ['text'],
              min: 1,
              fillWith: { kind: 'block', type: 'paragraph', nodes: [] }
          }
      },
      paragraph: {
          nodes: { only: ['text'] }
      },
      code_block: {
          nodes: { only: ['text'] },
          marks: { only: [] }
      }
  })
];

Schema Format

A schema is a map of type string to a spec to describe a node. A node spec can have two properties nodes and marks.

nodes describe the allowed nested nodes; and marks describe the styling marks allowed for nested text nodes.

Examples

This repository contains multiple example that might help you get a better understanding of the schema format:

0.52.6

6 years ago

0.52.5

6 years ago

0.52.3

6 years ago

0.52.4

6 years ago

0.52.2

6 years ago

0.52.1

6 years ago

0.52.0

6 years ago

0.51.0

6 years ago

0.50.13

6 years ago

0.50.10

6 years ago

0.50.11

6 years ago

0.50.12

6 years ago

0.50.9

6 years ago

0.50.8

6 years ago

0.50.7

6 years ago

0.50.5

6 years ago

0.50.6

6 years ago

0.50.3

6 years ago

0.50.4

6 years ago

0.50.2

6 years ago

0.50.1

6 years ago

0.50.0

6 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago