1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-07-31 12:30:11 +02:00

add more schema tests

add more schema tests
This commit is contained in:
Ian Storm Taylor
2019-12-06 10:34:14 -05:00
parent 8982ba9b2f
commit 624c03339b
3 changed files with 63 additions and 1 deletions

View File

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

View File

@@ -0,0 +1,30 @@
/** @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 b>two</element>
</element>
</editor>
)
export const output = (
<editor>
<element a>
<text />
</element>
</editor>
)

View File

@@ -40,7 +40,7 @@ export const GeneralTransforms = {
} }
Editor.withoutNormalizing(editor, () => { Editor.withoutNormalizing(editor, () => {
const max = getDirtyPaths(editor).length * 42 // HACK: better way to do editor? const max = getDirtyPaths(editor).length * 42 // HACK: better way?
let m = 0 let m = 0
while (getDirtyPaths(editor).length !== 0) { while (getDirtyPaths(editor).length !== 0) {