mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-04-20 05:11:53 +02:00
Convert Slate tests to TypeScript (#3784)
* changed to tsx * slate tests * finished making typescript tests * linting * linting * reverted slate-hyperscript files to jsx and changed edlint config * removed extra file * Update package.json * Update package.json * deleted { file * changed to tsx * slate tests * finished making typescript tests * linting * linting * reverted slate-hyperscript files to jsx and changed edlint config * removed extra file * Update package.json * Update package.json * deleted { file * rebase * removed ~ files * changed yarn
This commit is contained in:
parent
97dbab13a8
commit
93fe251517
@ -123,7 +123,7 @@
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": "**/test/**/*.js",
|
||||
"files": "**/test/**/*.{js,jsx,ts,tsx}",
|
||||
"rules": {
|
||||
"import/no-extraneous-dependencies": "off",
|
||||
"import/no-unresolved": "off"
|
||||
|
@ -1,11 +1,9 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from '../..'
|
||||
|
||||
export const run = editor => {
|
||||
editor.deleteBackward()
|
||||
}
|
||||
|
||||
export const input = (
|
||||
<editor>
|
||||
<block>Hello</block>
|
||||
@ -15,7 +13,6 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = (
|
||||
<editor>
|
||||
<block>Hello</block>
|
@ -1,11 +1,9 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from '../..'
|
||||
|
||||
export const run = editor => {
|
||||
editor.deleteBackward()
|
||||
}
|
||||
|
||||
export const input = (
|
||||
<editor>
|
||||
<block>Hello</block>
|
||||
@ -17,7 +15,6 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = (
|
||||
<editor>
|
||||
<block>Hello</block>
|
@ -1,12 +1,10 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Transforms } from 'slate'
|
||||
import { jsx } from '../..'
|
||||
|
||||
export const run = editor => {
|
||||
Transforms.delete(editor)
|
||||
}
|
||||
|
||||
export const input = (
|
||||
<editor>
|
||||
<block>
|
||||
@ -16,5 +14,4 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = input
|
@ -1,12 +1,10 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Transforms } from 'slate'
|
||||
import { jsx } from '../..'
|
||||
|
||||
export const run = editor => {
|
||||
Transforms.delete(editor)
|
||||
}
|
||||
|
||||
export const input = (
|
||||
<editor>
|
||||
<block a>
|
||||
@ -19,5 +17,4 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = input
|
@ -1,12 +1,10 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Transforms } from 'slate'
|
||||
import { jsx } from '../..'
|
||||
|
||||
export const run = editor => {
|
||||
Transforms.delete(editor)
|
||||
}
|
||||
|
||||
export const input = (
|
||||
<editor>
|
||||
<block>
|
||||
@ -27,5 +25,4 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = input
|
@ -1,12 +1,10 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../..'
|
||||
|
||||
export const run = editor => {
|
||||
editor.insertBreak()
|
||||
}
|
||||
|
||||
export const input = (
|
||||
<editor>
|
||||
<block>
|
||||
@ -18,5 +16,4 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = input
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from '../..'
|
||||
|
||||
const fragment = (
|
||||
@ -20,11 +19,9 @@ const fragment = (
|
||||
</block>
|
||||
</block>
|
||||
)
|
||||
|
||||
export const run = editor => {
|
||||
editor.insertFragment(fragment)
|
||||
}
|
||||
|
||||
export const input = (
|
||||
<editor>
|
||||
<block type="d">
|
||||
@ -36,7 +33,5 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = input
|
||||
|
||||
export const skip = true
|
@ -1,11 +1,9 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from '../..'
|
||||
|
||||
export const run = editor => {
|
||||
editor.insertText('text')
|
||||
}
|
||||
|
||||
export const input = (
|
||||
<editor>
|
||||
<block>
|
||||
@ -14,5 +12,4 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = input
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from '../..'
|
||||
|
||||
export const run = editor => {
|
||||
@ -7,7 +6,6 @@ export const run = editor => {
|
||||
editor.insertText('w')
|
||||
editor.insertText('o')
|
||||
}
|
||||
|
||||
export const input = (
|
||||
<editor>
|
||||
<block>
|
||||
@ -16,5 +14,4 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = input
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Transforms } from 'slate'
|
||||
import { jsx } from '../..'
|
||||
|
||||
@ -10,7 +9,6 @@ export const run = editor => {
|
||||
Transforms.move(editor, { reverse: true })
|
||||
editor.insertText('o')
|
||||
}
|
||||
|
||||
export const input = (
|
||||
<editor>
|
||||
<block>
|
||||
@ -19,7 +17,6 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = (
|
||||
<editor>
|
||||
<block>
|
||||
@ -28,5 +25,4 @@ export const output = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const skip = true
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
@ -11,7 +10,6 @@ export const input = (
|
||||
</element>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
children: [
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
@ -16,7 +15,6 @@ export const input = (
|
||||
</element>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
children: [
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
@ -14,7 +13,6 @@ export const input = (
|
||||
</element>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
children: [
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
@ -14,7 +13,6 @@ export const input = (
|
||||
</element>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
children: [
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
@ -14,7 +13,6 @@ export const input = (
|
||||
</element>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
children: [
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
@ -9,7 +8,6 @@ export const input = (
|
||||
</element>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
children: [
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
@ -10,7 +9,6 @@ export const input = (
|
||||
</element>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
children: [
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
@ -10,7 +9,6 @@ export const input = (
|
||||
</element>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
children: [
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
@ -12,7 +11,6 @@ export const input = (
|
||||
</element>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
children: [
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
@ -13,7 +12,6 @@ export const input = (
|
||||
</element>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
children: [
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
@ -12,7 +11,6 @@ export const input = (
|
||||
</element>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
children: [
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
@ -10,7 +9,6 @@ export const input = (
|
||||
</element>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
children: [
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
@ -11,7 +10,6 @@ export const input = (
|
||||
</element>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
children: [
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { createHyperscript } from 'slate-hyperscript'
|
||||
|
||||
const jsx = createHyperscript({
|
||||
@ -7,9 +6,7 @@ const jsx = createHyperscript({
|
||||
paragraph: { type: 'paragraph' },
|
||||
},
|
||||
})
|
||||
|
||||
export const input = <paragraph>word</paragraph>
|
||||
|
||||
export const output = {
|
||||
type: 'paragraph',
|
||||
children: [
|
||||
|
@ -1,9 +1,7 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = <element />
|
||||
|
||||
export const output = {
|
||||
children: [],
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
@ -7,7 +6,6 @@ export const input = (
|
||||
<element />
|
||||
</element>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
children: [
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
@ -7,7 +6,6 @@ export const input = (
|
||||
<element>word</element>
|
||||
</element>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
children: [
|
||||
{
|
||||
|
@ -1,9 +1,7 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = <element>word</element>
|
||||
|
||||
export const output = {
|
||||
children: [
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
@ -7,7 +6,6 @@ export const input = (
|
||||
<text />
|
||||
</element>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
children: [
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
@ -7,7 +6,6 @@ export const input = (
|
||||
<text>word</text>
|
||||
</element>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
children: [
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
@ -7,7 +6,6 @@ export const input = (
|
||||
<element>word</element>
|
||||
</fragment>
|
||||
)
|
||||
|
||||
export const output = [
|
||||
{
|
||||
children: [
|
||||
|
@ -1,7 +1,5 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = <fragment />
|
||||
|
||||
export const output = []
|
||||
|
@ -1,9 +1,7 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = <fragment>word</fragment>
|
||||
|
||||
export const output = [
|
||||
{
|
||||
text: 'word',
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
@ -11,7 +10,6 @@ export const input = (
|
||||
</selection>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
children: [
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
@ -11,7 +10,6 @@ export const input = (
|
||||
</selection>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
children: [
|
||||
{
|
||||
|
@ -1,9 +1,7 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = <text a />
|
||||
|
||||
export const output = {
|
||||
text: '',
|
||||
a: true,
|
||||
|
@ -1,9 +1,7 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = <text a>word</text>
|
||||
|
||||
export const output = {
|
||||
text: 'word',
|
||||
a: true,
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = (
|
||||
@ -7,7 +6,6 @@ export const input = (
|
||||
<text a>word</text>
|
||||
</text>
|
||||
)
|
||||
|
||||
export const output = {
|
||||
text: 'word',
|
||||
a: true,
|
||||
|
@ -1,9 +1,7 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
export const input = <editor />
|
||||
|
||||
export const output = {
|
||||
children: [],
|
||||
selection: null,
|
||||
|
@ -6,29 +6,23 @@ import { createHyperscript } from 'slate-hyperscript'
|
||||
describe('slate', () => {
|
||||
fixtures(__dirname, 'interfaces', ({ module }) => {
|
||||
let { input, test, output } = module
|
||||
|
||||
if (Editor.isEditor(input)) {
|
||||
input = withTest(input)
|
||||
}
|
||||
|
||||
const result = test(input)
|
||||
assert.deepEqual(result, output)
|
||||
})
|
||||
|
||||
fixtures(__dirname, 'operations', ({ module }) => {
|
||||
const { input, operations, output } = module
|
||||
const editor = withTest(input)
|
||||
|
||||
Editor.withoutNormalizing(editor, () => {
|
||||
for (const op of operations) {
|
||||
editor.apply(op)
|
||||
}
|
||||
})
|
||||
|
||||
assert.deepEqual(editor.children, output.children)
|
||||
assert.deepEqual(editor.selection, output.selection)
|
||||
})
|
||||
|
||||
fixtures(__dirname, 'normalization', ({ module }) => {
|
||||
const { input, output } = module
|
||||
const editor = withTest(input)
|
||||
@ -36,7 +30,6 @@ describe('slate', () => {
|
||||
assert.deepEqual(editor.children, output.children)
|
||||
assert.deepEqual(editor.selection, output.selection)
|
||||
})
|
||||
|
||||
fixtures(__dirname, 'transforms', ({ module }) => {
|
||||
const { input, run, output } = module
|
||||
const editor = withTest(input)
|
||||
@ -45,21 +38,16 @@ describe('slate', () => {
|
||||
assert.deepEqual(editor.selection, output.selection)
|
||||
})
|
||||
})
|
||||
|
||||
const withTest = editor => {
|
||||
const { isInline, isVoid } = editor
|
||||
|
||||
editor.isInline = element => {
|
||||
return element.inline === true ? true : isInline(element)
|
||||
}
|
||||
|
||||
editor.isVoid = element => {
|
||||
return element.void === true ? true : isVoid(element)
|
||||
}
|
||||
|
||||
return editor
|
||||
}
|
||||
|
||||
export const jsx = createHyperscript({
|
||||
elements: {
|
||||
block: {},
|
||||
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -10,7 +9,6 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
return Editor.above(editor, {
|
||||
at: [0, 0, 0],
|
||||
@ -18,7 +16,6 @@ export const test = editor => {
|
||||
mode: 'highest',
|
||||
})
|
||||
}
|
||||
|
||||
export const output = [
|
||||
<block>
|
||||
<block>one</block>
|
@ -6,7 +6,7 @@ import { jsx } from '../../..'
|
||||
export const input = (
|
||||
<editor>
|
||||
<block>
|
||||
<block>one</block>
|
||||
<block>one </block>
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
@ -19,4 +19,4 @@ export const test = editor => {
|
||||
})
|
||||
}
|
||||
|
||||
export const output = [<block>one</block>, [0, 0]]
|
||||
export const output = [<block>one </block>, [0, 0]]
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -8,9 +7,7 @@ export const input = (
|
||||
<block>one</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
return Editor.end(editor, [0])
|
||||
}
|
||||
|
||||
export const output = { path: [0, 0], offset: 3 }
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -8,9 +7,7 @@ export const input = (
|
||||
<block>one</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
return Editor.end(editor, { path: [0, 0], offset: 1 })
|
||||
}
|
||||
|
||||
export const output = { path: [0, 0], offset: 1 }
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -8,12 +7,10 @@ export const input = (
|
||||
<block>one</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
return Editor.end(editor, {
|
||||
anchor: { path: [0, 0], offset: 1 },
|
||||
focus: { path: [0, 0], offset: 2 },
|
||||
})
|
||||
}
|
||||
|
||||
export const output = { path: [0, 0], offset: 2 }
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -10,10 +9,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const block = editor.children[0]
|
||||
return Editor.hasBlocks(editor, block)
|
||||
}
|
||||
|
||||
export const output = true
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -8,10 +7,8 @@ export const input = (
|
||||
<block>one</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const block = editor.children[0]
|
||||
return Editor.hasBlocks(editor, block)
|
||||
}
|
||||
|
||||
export const output = false
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -14,10 +13,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const inline = editor.children[0].children[1]
|
||||
return Editor.hasBlocks(editor, inline)
|
||||
}
|
||||
|
||||
export const output = false
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -10,10 +9,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const block = editor.children[0]
|
||||
return Editor.hasBlocks(editor, block)
|
||||
}
|
||||
|
||||
export const output = false
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -10,10 +9,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const block = editor.children[0]
|
||||
return Editor.hasInlines(editor, block)
|
||||
}
|
||||
|
||||
export const output = false
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -8,10 +7,8 @@ export const input = (
|
||||
<block>one</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const block = editor.children[0]
|
||||
return Editor.hasInlines(editor, block)
|
||||
}
|
||||
|
||||
export const output = true
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -14,10 +13,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const inline = editor.children[0].children[1]
|
||||
return Editor.hasInlines(editor, inline)
|
||||
}
|
||||
|
||||
export const output = true
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -10,10 +9,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const block = editor.children[0]
|
||||
return Editor.hasInlines(editor, block)
|
||||
}
|
||||
|
||||
export const output = true
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -10,10 +9,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const block = editor.children[0]
|
||||
return Editor.hasTexts(editor, block)
|
||||
}
|
||||
|
||||
export const output = false
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -8,10 +7,8 @@ export const input = (
|
||||
<block>one</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const block = editor.children[0]
|
||||
return Editor.hasTexts(editor, block)
|
||||
}
|
||||
|
||||
export const output = true
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -14,10 +13,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const inline = editor.children[0].children[1]
|
||||
return Editor.hasTexts(editor, inline)
|
||||
}
|
||||
|
||||
export const output = false
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -10,10 +9,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const inline = editor.children[0].children[1]
|
||||
return Editor.hasTexts(editor, inline)
|
||||
}
|
||||
|
||||
export const output = true
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -8,10 +7,8 @@ export const input = (
|
||||
<block>one</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const block = editor.children[0]
|
||||
return Editor.isBlock(editor, block)
|
||||
}
|
||||
|
||||
export const output = true
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -10,10 +9,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const inline = editor.children[0].children[1]
|
||||
return Editor.isBlock(editor, inline)
|
||||
}
|
||||
|
||||
export const output = false
|
@ -1,20 +1,17 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
export const input = (
|
||||
<editor>
|
||||
<block>
|
||||
<cursor />
|
||||
one
|
||||
<cursor />
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const { anchor } = editor.selection
|
||||
return Editor.isEdge(editor, anchor, [0])
|
||||
}
|
||||
|
||||
export const output = true
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -11,10 +10,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const { anchor } = editor.selection
|
||||
return Editor.isEdge(editor, anchor, [0])
|
||||
}
|
||||
|
||||
export const output = false
|
@ -1,20 +1,17 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
export const input = (
|
||||
<editor>
|
||||
<block>
|
||||
one
|
||||
<cursor />
|
||||
one
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const { anchor } = editor.selection
|
||||
return Editor.isEdge(editor, anchor, [0])
|
||||
}
|
||||
|
||||
export const output = true
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -10,10 +9,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const block = editor.children[0]
|
||||
return Editor.isEmpty(editor, block)
|
||||
}
|
||||
|
||||
export const output = true
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -8,10 +7,8 @@ export const input = (
|
||||
<block />
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const block = editor.children[0]
|
||||
return Editor.isEmpty(editor, block)
|
||||
}
|
||||
|
||||
export const output = true
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -8,10 +7,8 @@ export const input = (
|
||||
<block>one</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const block = editor.children[0]
|
||||
return Editor.isEmpty(editor, block)
|
||||
}
|
||||
|
||||
export const output = false
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -10,10 +9,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const block = editor.children[0]
|
||||
return Editor.isEmpty(editor, block)
|
||||
}
|
||||
|
||||
export const output = false
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -14,10 +13,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const inline = editor.children[0].children[1]
|
||||
return Editor.isEmpty(editor, inline)
|
||||
}
|
||||
|
||||
export const output = true
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -12,10 +11,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const inline = editor.children[0].children[1]
|
||||
return Editor.isEmpty(editor, inline)
|
||||
}
|
||||
|
||||
export const output = true
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -10,10 +9,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const inline = editor.children[0].children[1]
|
||||
return Editor.isEmpty(editor, inline)
|
||||
}
|
||||
|
||||
export const output = false
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -14,10 +13,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const inline = editor.children[0].children[1]
|
||||
return Editor.isEmpty(editor, inline)
|
||||
}
|
||||
|
||||
export const output = false
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -11,10 +10,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const { anchor } = editor.selection
|
||||
return Editor.isEnd(editor, anchor, [0])
|
||||
}
|
||||
|
||||
export const output = true
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -11,10 +10,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const { anchor } = editor.selection
|
||||
return Editor.isEnd(editor, anchor, [0])
|
||||
}
|
||||
|
||||
export const output = false
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -11,10 +10,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const { anchor } = editor.selection
|
||||
return Editor.isEnd(editor, anchor, [0])
|
||||
}
|
||||
|
||||
export const output = false
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -8,10 +7,8 @@ export const input = (
|
||||
<block>one</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const block = editor.children[0]
|
||||
return Editor.isInline(editor, block)
|
||||
}
|
||||
|
||||
export const output = false
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -10,10 +9,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const inline = editor.children[0].children[1]
|
||||
return Editor.isInline(editor, inline)
|
||||
}
|
||||
|
||||
export const output = true
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -11,10 +10,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const { anchor } = editor.selection
|
||||
return Editor.isStart(editor, anchor, [0])
|
||||
}
|
||||
|
||||
export const output = false
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -11,10 +10,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const { anchor } = editor.selection
|
||||
return Editor.isStart(editor, anchor, [0])
|
||||
}
|
||||
|
||||
export const output = false
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -11,10 +10,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const { anchor } = editor.selection
|
||||
return Editor.isStart(editor, anchor, [0])
|
||||
}
|
||||
|
||||
export const output = true
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -8,10 +7,8 @@ export const input = (
|
||||
<block void>one</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const block = editor.children[0]
|
||||
return Editor.isVoid(editor, block)
|
||||
}
|
||||
|
||||
export const output = true
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -8,10 +7,8 @@ export const input = (
|
||||
<block>one</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const block = editor.children[0]
|
||||
return Editor.isVoid(editor, block)
|
||||
}
|
||||
|
||||
export const output = false
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -10,10 +9,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const inline = editor.children[0].children[1]
|
||||
return Editor.isVoid(editor, inline)
|
||||
}
|
||||
|
||||
export const output = true
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from '../../..'
|
||||
|
||||
@ -10,10 +9,8 @@ export const input = (
|
||||
</block>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
const inline = editor.children[0].children[1]
|
||||
return Editor.isVoid(editor, inline)
|
||||
}
|
||||
|
||||
export const output = false
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
@ -10,7 +9,6 @@ export const input = (
|
||||
</element>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
return Array.from(
|
||||
Editor.levels(editor, {
|
||||
@ -19,7 +17,6 @@ export const test = editor => {
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
export const output = [
|
||||
[
|
||||
<element a>
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
@ -10,7 +9,6 @@ export const input = (
|
||||
</element>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
return Array.from(
|
||||
Editor.levels(editor, {
|
||||
@ -19,7 +17,6 @@ export const test = editor => {
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
export const output = [
|
||||
[<text />, [0, 0]],
|
||||
[
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
@ -10,11 +9,9 @@ export const input = (
|
||||
</element>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
return Array.from(Editor.levels(editor, { at: [0, 0] }))
|
||||
}
|
||||
|
||||
export const output = [
|
||||
[input, []],
|
||||
[
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
@ -10,11 +9,9 @@ export const input = (
|
||||
</element>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
return Array.from(Editor.levels(editor, { at: [0, 0] }))
|
||||
}
|
||||
|
||||
export const output = [
|
||||
[input, []],
|
||||
[
|
@ -1,5 +1,4 @@
|
||||
/** @jsx jsx */
|
||||
|
||||
import { Editor } from 'slate'
|
||||
import { jsx } from 'slate-hyperscript'
|
||||
|
||||
@ -10,7 +9,6 @@ export const input = (
|
||||
</element>
|
||||
</editor>
|
||||
)
|
||||
|
||||
export const test = editor => {
|
||||
return Array.from(
|
||||
Editor.levels(editor, {
|
||||
@ -19,7 +17,6 @@ export const test = editor => {
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
export const output = [
|
||||
[input, []],
|
||||
[
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user