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:
@@ -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>
|
||||||
|
)
|
@@ -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>
|
||||||
|
)
|
@@ -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) {
|
||||||
|
Reference in New Issue
Block a user