1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-21 06:31:28 +02:00

add more schema tests

This commit is contained in:
Ian Storm Taylor
2019-12-05 17:34:00 -05:00
parent 8653e74f6c
commit 5c37bfc024
3 changed files with 82 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
/** @jsx jsx */
import { jsx } from 'slate-hyperscript'
export const schema = [
{
for: 'node',
match: { a: true },
validate: {
children: [{ match: 'text', max: 1 }],
},
},
]
export const input = (
<editor>
<element a>
<element b>one</element>
</element>
</editor>
)
export const output = (
<editor>
<element a>
<text />
</element>
</editor>
)

View File

@@ -0,0 +1,27 @@
/** @jsx jsx */
import { jsx } from 'slate-hyperscript'
export const schema = [
{
for: 'node',
match: { a: true },
validate: {
children: [
{ match: { b: true }, min: 1, max: 1 },
{ match: { c: true }, min: 0 },
],
},
},
]
export const input = (
<editor>
<element a>
<element b>one</element>
<element c>two</element>
</element>
</editor>
)
export const output = input

View File

@@ -0,0 +1,26 @@
/** @jsx jsx */
import { jsx } from 'slate-hyperscript'
export const schema = [
{
for: 'node',
match: { a: true },
validate: {
children: [
{ match: { b: true }, min: 1, max: 1 },
{ match: { c: true }, min: 0 },
],
},
},
]
export const input = (
<editor>
<element a>
<element b>one</element>
</element>
</editor>
)
export const output = input