1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-17 20:51:20 +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:
Maria Jaramillo
2020-07-14 12:47:47 -05:00
committed by GitHub
parent 97dbab13a8
commit 93fe251517
890 changed files with 43 additions and 3230 deletions

View File

@@ -123,7 +123,7 @@
}, },
"overrides": [ "overrides": [
{ {
"files": "**/test/**/*.js", "files": "**/test/**/*.{js,jsx,ts,tsx}",
"rules": { "rules": {
"import/no-extraneous-dependencies": "off", "import/no-extraneous-dependencies": "off",
"import/no-unresolved": "off" "import/no-unresolved": "off"

View File

@@ -1,11 +1,9 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from '../..' import { jsx } from '../..'
export const run = editor => { export const run = editor => {
editor.deleteBackward() editor.deleteBackward()
} }
export const input = ( export const input = (
<editor> <editor>
<block>Hello</block> <block>Hello</block>
@@ -15,7 +13,6 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const output = ( export const output = (
<editor> <editor>
<block>Hello</block> <block>Hello</block>

View File

@@ -1,11 +1,9 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from '../..' import { jsx } from '../..'
export const run = editor => { export const run = editor => {
editor.deleteBackward() editor.deleteBackward()
} }
export const input = ( export const input = (
<editor> <editor>
<block>Hello</block> <block>Hello</block>
@@ -17,7 +15,6 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const output = ( export const output = (
<editor> <editor>
<block>Hello</block> <block>Hello</block>

View File

@@ -1,12 +1,10 @@
/** @jsx jsx */ /** @jsx jsx */
import { Transforms } from 'slate' import { Transforms } from 'slate'
import { jsx } from '../..' import { jsx } from '../..'
export const run = editor => { export const run = editor => {
Transforms.delete(editor) Transforms.delete(editor)
} }
export const input = ( export const input = (
<editor> <editor>
<block> <block>
@@ -16,5 +14,4 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const output = input export const output = input

View File

@@ -1,12 +1,10 @@
/** @jsx jsx */ /** @jsx jsx */
import { Transforms } from 'slate' import { Transforms } from 'slate'
import { jsx } from '../..' import { jsx } from '../..'
export const run = editor => { export const run = editor => {
Transforms.delete(editor) Transforms.delete(editor)
} }
export const input = ( export const input = (
<editor> <editor>
<block a> <block a>
@@ -19,5 +17,4 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const output = input export const output = input

View File

@@ -1,12 +1,10 @@
/** @jsx jsx */ /** @jsx jsx */
import { Transforms } from 'slate' import { Transforms } from 'slate'
import { jsx } from '../..' import { jsx } from '../..'
export const run = editor => { export const run = editor => {
Transforms.delete(editor) Transforms.delete(editor)
} }
export const input = ( export const input = (
<editor> <editor>
<block> <block>
@@ -27,5 +25,4 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const output = input export const output = input

View File

@@ -1,12 +1,10 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../..' import { jsx } from '../..'
export const run = editor => { export const run = editor => {
editor.insertBreak() editor.insertBreak()
} }
export const input = ( export const input = (
<editor> <editor>
<block> <block>
@@ -18,5 +16,4 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const output = input export const output = input

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from '../..' import { jsx } from '../..'
const fragment = ( const fragment = (
@@ -20,11 +19,9 @@ const fragment = (
</block> </block>
</block> </block>
) )
export const run = editor => { export const run = editor => {
editor.insertFragment(fragment) editor.insertFragment(fragment)
} }
export const input = ( export const input = (
<editor> <editor>
<block type="d"> <block type="d">
@@ -36,7 +33,5 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const output = input export const output = input
export const skip = true export const skip = true

View File

@@ -1,11 +1,9 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from '../..' import { jsx } from '../..'
export const run = editor => { export const run = editor => {
editor.insertText('text') editor.insertText('text')
} }
export const input = ( export const input = (
<editor> <editor>
<block> <block>
@@ -14,5 +12,4 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const output = input export const output = input

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from '../..' import { jsx } from '../..'
export const run = editor => { export const run = editor => {
@@ -7,7 +6,6 @@ export const run = editor => {
editor.insertText('w') editor.insertText('w')
editor.insertText('o') editor.insertText('o')
} }
export const input = ( export const input = (
<editor> <editor>
<block> <block>
@@ -16,5 +14,4 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const output = input export const output = input

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Transforms } from 'slate' import { Transforms } from 'slate'
import { jsx } from '../..' import { jsx } from '../..'
@@ -10,7 +9,6 @@ export const run = editor => {
Transforms.move(editor, { reverse: true }) Transforms.move(editor, { reverse: true })
editor.insertText('o') editor.insertText('o')
} }
export const input = ( export const input = (
<editor> <editor>
<block> <block>
@@ -19,7 +17,6 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const output = ( export const output = (
<editor> <editor>
<block> <block>
@@ -28,5 +25,4 @@ export const output = (
</block> </block>
</editor> </editor>
) )
export const skip = true export const skip = true

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = ( export const input = (
@@ -11,7 +10,6 @@ export const input = (
</element> </element>
</editor> </editor>
) )
export const output = { export const output = {
children: [ children: [
{ {

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = ( export const input = (
@@ -16,7 +15,6 @@ export const input = (
</element> </element>
</editor> </editor>
) )
export const output = { export const output = {
children: [ children: [
{ {

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = ( export const input = (
@@ -14,7 +13,6 @@ export const input = (
</element> </element>
</editor> </editor>
) )
export const output = { export const output = {
children: [ children: [
{ {

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = ( export const input = (
@@ -14,7 +13,6 @@ export const input = (
</element> </element>
</editor> </editor>
) )
export const output = { export const output = {
children: [ children: [
{ {

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = ( export const input = (
@@ -14,7 +13,6 @@ export const input = (
</element> </element>
</editor> </editor>
) )
export const output = { export const output = {
children: [ children: [
{ {

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = ( export const input = (
@@ -9,7 +8,6 @@ export const input = (
</element> </element>
</editor> </editor>
) )
export const output = { export const output = {
children: [ children: [
{ {

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = ( export const input = (
@@ -10,7 +9,6 @@ export const input = (
</element> </element>
</editor> </editor>
) )
export const output = { export const output = {
children: [ children: [
{ {

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = ( export const input = (
@@ -10,7 +9,6 @@ export const input = (
</element> </element>
</editor> </editor>
) )
export const output = { export const output = {
children: [ children: [
{ {

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = ( export const input = (
@@ -12,7 +11,6 @@ export const input = (
</element> </element>
</editor> </editor>
) )
export const output = { export const output = {
children: [ children: [
{ {

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = ( export const input = (
@@ -13,7 +12,6 @@ export const input = (
</element> </element>
</editor> </editor>
) )
export const output = { export const output = {
children: [ children: [
{ {

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = ( export const input = (
@@ -12,7 +11,6 @@ export const input = (
</element> </element>
</editor> </editor>
) )
export const output = { export const output = {
children: [ children: [
{ {

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = ( export const input = (
@@ -10,7 +9,6 @@ export const input = (
</element> </element>
</editor> </editor>
) )
export const output = { export const output = {
children: [ children: [
{ {

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = ( export const input = (
@@ -11,7 +10,6 @@ export const input = (
</element> </element>
</editor> </editor>
) )
export const output = { export const output = {
children: [ children: [
{ {

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { createHyperscript } from 'slate-hyperscript' import { createHyperscript } from 'slate-hyperscript'
const jsx = createHyperscript({ const jsx = createHyperscript({
@@ -7,9 +6,7 @@ const jsx = createHyperscript({
paragraph: { type: 'paragraph' }, paragraph: { type: 'paragraph' },
}, },
}) })
export const input = <paragraph>word</paragraph> export const input = <paragraph>word</paragraph>
export const output = { export const output = {
type: 'paragraph', type: 'paragraph',
children: [ children: [

View File

@@ -1,9 +1,7 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = <element /> export const input = <element />
export const output = { export const output = {
children: [], children: [],
} }

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = ( export const input = (
@@ -7,7 +6,6 @@ export const input = (
<element /> <element />
</element> </element>
) )
export const output = { export const output = {
children: [ children: [
{ {

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = ( export const input = (
@@ -7,7 +6,6 @@ export const input = (
<element>word</element> <element>word</element>
</element> </element>
) )
export const output = { export const output = {
children: [ children: [
{ {

View File

@@ -1,9 +1,7 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = <element>word</element> export const input = <element>word</element>
export const output = { export const output = {
children: [ children: [
{ {

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = ( export const input = (
@@ -7,7 +6,6 @@ export const input = (
<text /> <text />
</element> </element>
) )
export const output = { export const output = {
children: [ children: [
{ {

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = ( export const input = (
@@ -7,7 +6,6 @@ export const input = (
<text>word</text> <text>word</text>
</element> </element>
) )
export const output = { export const output = {
children: [ children: [
{ {

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = ( export const input = (
@@ -7,7 +6,6 @@ export const input = (
<element>word</element> <element>word</element>
</fragment> </fragment>
) )
export const output = [ export const output = [
{ {
children: [ children: [

View File

@@ -1,7 +1,5 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = <fragment /> export const input = <fragment />
export const output = [] export const output = []

View File

@@ -1,9 +1,7 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = <fragment>word</fragment> export const input = <fragment>word</fragment>
export const output = [ export const output = [
{ {
text: 'word', text: 'word',

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = ( export const input = (
@@ -11,7 +10,6 @@ export const input = (
</selection> </selection>
</editor> </editor>
) )
export const output = { export const output = {
children: [ children: [
{ {

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = ( export const input = (
@@ -11,7 +10,6 @@ export const input = (
</selection> </selection>
</editor> </editor>
) )
export const output = { export const output = {
children: [ children: [
{ {

View File

@@ -1,9 +1,7 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = <text a /> export const input = <text a />
export const output = { export const output = {
text: '', text: '',
a: true, a: true,

View File

@@ -1,9 +1,7 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = <text a>word</text> export const input = <text a>word</text>
export const output = { export const output = {
text: 'word', text: 'word',
a: true, a: true,

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = ( export const input = (
@@ -7,7 +6,6 @@ export const input = (
<text a>word</text> <text a>word</text>
</text> </text>
) )
export const output = { export const output = {
text: 'word', text: 'word',
a: true, a: true,

View File

@@ -1,9 +1,7 @@
/** @jsx jsx */ /** @jsx jsx */
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
export const input = <editor /> export const input = <editor />
export const output = { export const output = {
children: [], children: [],
selection: null, selection: null,

View File

@@ -6,29 +6,23 @@ import { createHyperscript } from 'slate-hyperscript'
describe('slate', () => { describe('slate', () => {
fixtures(__dirname, 'interfaces', ({ module }) => { fixtures(__dirname, 'interfaces', ({ module }) => {
let { input, test, output } = module let { input, test, output } = module
if (Editor.isEditor(input)) { if (Editor.isEditor(input)) {
input = withTest(input) input = withTest(input)
} }
const result = test(input) const result = test(input)
assert.deepEqual(result, output) assert.deepEqual(result, output)
}) })
fixtures(__dirname, 'operations', ({ module }) => { fixtures(__dirname, 'operations', ({ module }) => {
const { input, operations, output } = module const { input, operations, output } = module
const editor = withTest(input) const editor = withTest(input)
Editor.withoutNormalizing(editor, () => { Editor.withoutNormalizing(editor, () => {
for (const op of operations) { for (const op of operations) {
editor.apply(op) editor.apply(op)
} }
}) })
assert.deepEqual(editor.children, output.children) assert.deepEqual(editor.children, output.children)
assert.deepEqual(editor.selection, output.selection) assert.deepEqual(editor.selection, output.selection)
}) })
fixtures(__dirname, 'normalization', ({ module }) => { fixtures(__dirname, 'normalization', ({ module }) => {
const { input, output } = module const { input, output } = module
const editor = withTest(input) const editor = withTest(input)
@@ -36,7 +30,6 @@ describe('slate', () => {
assert.deepEqual(editor.children, output.children) assert.deepEqual(editor.children, output.children)
assert.deepEqual(editor.selection, output.selection) assert.deepEqual(editor.selection, output.selection)
}) })
fixtures(__dirname, 'transforms', ({ module }) => { fixtures(__dirname, 'transforms', ({ module }) => {
const { input, run, output } = module const { input, run, output } = module
const editor = withTest(input) const editor = withTest(input)
@@ -45,21 +38,16 @@ describe('slate', () => {
assert.deepEqual(editor.selection, output.selection) assert.deepEqual(editor.selection, output.selection)
}) })
}) })
const withTest = editor => { const withTest = editor => {
const { isInline, isVoid } = editor const { isInline, isVoid } = editor
editor.isInline = element => { editor.isInline = element => {
return element.inline === true ? true : isInline(element) return element.inline === true ? true : isInline(element)
} }
editor.isVoid = element => { editor.isVoid = element => {
return element.void === true ? true : isVoid(element) return element.void === true ? true : isVoid(element)
} }
return editor return editor
} }
export const jsx = createHyperscript({ export const jsx = createHyperscript({
elements: { elements: {
block: {}, block: {},

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -10,7 +9,6 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
return Editor.above(editor, { return Editor.above(editor, {
at: [0, 0, 0], at: [0, 0, 0],
@@ -18,7 +16,6 @@ export const test = editor => {
mode: 'highest', mode: 'highest',
}) })
} }
export const output = [ export const output = [
<block> <block>
<block>one</block> <block>one</block>

View File

@@ -6,7 +6,7 @@ import { jsx } from '../../..'
export const input = ( export const input = (
<editor> <editor>
<block> <block>
<block>one</block> <block>one </block>
</block> </block>
</editor> </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]]

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -8,9 +7,7 @@ export const input = (
<block>one</block> <block>one</block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
return Editor.end(editor, [0]) return Editor.end(editor, [0])
} }
export const output = { path: [0, 0], offset: 3 } export const output = { path: [0, 0], offset: 3 }

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -8,9 +7,7 @@ export const input = (
<block>one</block> <block>one</block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
return Editor.end(editor, { path: [0, 0], offset: 1 }) return Editor.end(editor, { path: [0, 0], offset: 1 })
} }
export const output = { path: [0, 0], offset: 1 } export const output = { path: [0, 0], offset: 1 }

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -8,12 +7,10 @@ export const input = (
<block>one</block> <block>one</block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
return Editor.end(editor, { return Editor.end(editor, {
anchor: { path: [0, 0], offset: 1 }, anchor: { path: [0, 0], offset: 1 },
focus: { path: [0, 0], offset: 2 }, focus: { path: [0, 0], offset: 2 },
}) })
} }
export const output = { path: [0, 0], offset: 2 } export const output = { path: [0, 0], offset: 2 }

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -10,10 +9,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const block = editor.children[0] const block = editor.children[0]
return Editor.hasBlocks(editor, block) return Editor.hasBlocks(editor, block)
} }
export const output = true export const output = true

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -8,10 +7,8 @@ export const input = (
<block>one</block> <block>one</block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const block = editor.children[0] const block = editor.children[0]
return Editor.hasBlocks(editor, block) return Editor.hasBlocks(editor, block)
} }
export const output = false export const output = false

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -14,10 +13,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const inline = editor.children[0].children[1] const inline = editor.children[0].children[1]
return Editor.hasBlocks(editor, inline) return Editor.hasBlocks(editor, inline)
} }
export const output = false export const output = false

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -10,10 +9,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const block = editor.children[0] const block = editor.children[0]
return Editor.hasBlocks(editor, block) return Editor.hasBlocks(editor, block)
} }
export const output = false export const output = false

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -10,10 +9,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const block = editor.children[0] const block = editor.children[0]
return Editor.hasInlines(editor, block) return Editor.hasInlines(editor, block)
} }
export const output = false export const output = false

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -8,10 +7,8 @@ export const input = (
<block>one</block> <block>one</block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const block = editor.children[0] const block = editor.children[0]
return Editor.hasInlines(editor, block) return Editor.hasInlines(editor, block)
} }
export const output = true export const output = true

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -14,10 +13,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const inline = editor.children[0].children[1] const inline = editor.children[0].children[1]
return Editor.hasInlines(editor, inline) return Editor.hasInlines(editor, inline)
} }
export const output = true export const output = true

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -10,10 +9,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const block = editor.children[0] const block = editor.children[0]
return Editor.hasInlines(editor, block) return Editor.hasInlines(editor, block)
} }
export const output = true export const output = true

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -10,10 +9,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const block = editor.children[0] const block = editor.children[0]
return Editor.hasTexts(editor, block) return Editor.hasTexts(editor, block)
} }
export const output = false export const output = false

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -8,10 +7,8 @@ export const input = (
<block>one</block> <block>one</block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const block = editor.children[0] const block = editor.children[0]
return Editor.hasTexts(editor, block) return Editor.hasTexts(editor, block)
} }
export const output = true export const output = true

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -14,10 +13,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const inline = editor.children[0].children[1] const inline = editor.children[0].children[1]
return Editor.hasTexts(editor, inline) return Editor.hasTexts(editor, inline)
} }
export const output = false export const output = false

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -10,10 +9,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const inline = editor.children[0].children[1] const inline = editor.children[0].children[1]
return Editor.hasTexts(editor, inline) return Editor.hasTexts(editor, inline)
} }
export const output = true export const output = true

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -8,10 +7,8 @@ export const input = (
<block>one</block> <block>one</block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const block = editor.children[0] const block = editor.children[0]
return Editor.isBlock(editor, block) return Editor.isBlock(editor, block)
} }
export const output = true export const output = true

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -10,10 +9,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const inline = editor.children[0].children[1] const inline = editor.children[0].children[1]
return Editor.isBlock(editor, inline) return Editor.isBlock(editor, inline)
} }
export const output = false export const output = false

View File

@@ -1,20 +1,17 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
export const input = ( export const input = (
<editor> <editor>
<block> <block>
<cursor />
one one
<cursor />
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const { anchor } = editor.selection const { anchor } = editor.selection
return Editor.isEdge(editor, anchor, [0]) return Editor.isEdge(editor, anchor, [0])
} }
export const output = true export const output = true

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -11,10 +10,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const { anchor } = editor.selection const { anchor } = editor.selection
return Editor.isEdge(editor, anchor, [0]) return Editor.isEdge(editor, anchor, [0])
} }
export const output = false export const output = false

View File

@@ -1,20 +1,17 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
export const input = ( export const input = (
<editor> <editor>
<block> <block>
one
<cursor /> <cursor />
one
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const { anchor } = editor.selection const { anchor } = editor.selection
return Editor.isEdge(editor, anchor, [0]) return Editor.isEdge(editor, anchor, [0])
} }
export const output = true export const output = true

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -10,10 +9,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const block = editor.children[0] const block = editor.children[0]
return Editor.isEmpty(editor, block) return Editor.isEmpty(editor, block)
} }
export const output = true export const output = true

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -8,10 +7,8 @@ export const input = (
<block /> <block />
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const block = editor.children[0] const block = editor.children[0]
return Editor.isEmpty(editor, block) return Editor.isEmpty(editor, block)
} }
export const output = true export const output = true

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -8,10 +7,8 @@ export const input = (
<block>one</block> <block>one</block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const block = editor.children[0] const block = editor.children[0]
return Editor.isEmpty(editor, block) return Editor.isEmpty(editor, block)
} }
export const output = false export const output = false

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -10,10 +9,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const block = editor.children[0] const block = editor.children[0]
return Editor.isEmpty(editor, block) return Editor.isEmpty(editor, block)
} }
export const output = false export const output = false

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -14,10 +13,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const inline = editor.children[0].children[1] const inline = editor.children[0].children[1]
return Editor.isEmpty(editor, inline) return Editor.isEmpty(editor, inline)
} }
export const output = true export const output = true

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -12,10 +11,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const inline = editor.children[0].children[1] const inline = editor.children[0].children[1]
return Editor.isEmpty(editor, inline) return Editor.isEmpty(editor, inline)
} }
export const output = true export const output = true

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -10,10 +9,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const inline = editor.children[0].children[1] const inline = editor.children[0].children[1]
return Editor.isEmpty(editor, inline) return Editor.isEmpty(editor, inline)
} }
export const output = false export const output = false

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -14,10 +13,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const inline = editor.children[0].children[1] const inline = editor.children[0].children[1]
return Editor.isEmpty(editor, inline) return Editor.isEmpty(editor, inline)
} }
export const output = false export const output = false

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -11,10 +10,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const { anchor } = editor.selection const { anchor } = editor.selection
return Editor.isEnd(editor, anchor, [0]) return Editor.isEnd(editor, anchor, [0])
} }
export const output = true export const output = true

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -11,10 +10,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const { anchor } = editor.selection const { anchor } = editor.selection
return Editor.isEnd(editor, anchor, [0]) return Editor.isEnd(editor, anchor, [0])
} }
export const output = false export const output = false

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -11,10 +10,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const { anchor } = editor.selection const { anchor } = editor.selection
return Editor.isEnd(editor, anchor, [0]) return Editor.isEnd(editor, anchor, [0])
} }
export const output = false export const output = false

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -8,10 +7,8 @@ export const input = (
<block>one</block> <block>one</block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const block = editor.children[0] const block = editor.children[0]
return Editor.isInline(editor, block) return Editor.isInline(editor, block)
} }
export const output = false export const output = false

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -10,10 +9,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const inline = editor.children[0].children[1] const inline = editor.children[0].children[1]
return Editor.isInline(editor, inline) return Editor.isInline(editor, inline)
} }
export const output = true export const output = true

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -11,10 +10,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const { anchor } = editor.selection const { anchor } = editor.selection
return Editor.isStart(editor, anchor, [0]) return Editor.isStart(editor, anchor, [0])
} }
export const output = false export const output = false

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -11,10 +10,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const { anchor } = editor.selection const { anchor } = editor.selection
return Editor.isStart(editor, anchor, [0]) return Editor.isStart(editor, anchor, [0])
} }
export const output = false export const output = false

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -11,10 +10,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const { anchor } = editor.selection const { anchor } = editor.selection
return Editor.isStart(editor, anchor, [0]) return Editor.isStart(editor, anchor, [0])
} }
export const output = true export const output = true

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -8,10 +7,8 @@ export const input = (
<block void>one</block> <block void>one</block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const block = editor.children[0] const block = editor.children[0]
return Editor.isVoid(editor, block) return Editor.isVoid(editor, block)
} }
export const output = true export const output = true

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -8,10 +7,8 @@ export const input = (
<block>one</block> <block>one</block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const block = editor.children[0] const block = editor.children[0]
return Editor.isVoid(editor, block) return Editor.isVoid(editor, block)
} }
export const output = false export const output = false

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -10,10 +9,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const inline = editor.children[0].children[1] const inline = editor.children[0].children[1]
return Editor.isVoid(editor, inline) return Editor.isVoid(editor, inline)
} }
export const output = true export const output = true

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from '../../..' import { jsx } from '../../..'
@@ -10,10 +9,8 @@ export const input = (
</block> </block>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
const inline = editor.children[0].children[1] const inline = editor.children[0].children[1]
return Editor.isVoid(editor, inline) return Editor.isVoid(editor, inline)
} }
export const output = false export const output = false

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
@@ -10,7 +9,6 @@ export const input = (
</element> </element>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
return Array.from( return Array.from(
Editor.levels(editor, { Editor.levels(editor, {
@@ -19,7 +17,6 @@ export const test = editor => {
}) })
) )
} }
export const output = [ export const output = [
[ [
<element a> <element a>

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
@@ -10,7 +9,6 @@ export const input = (
</element> </element>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
return Array.from( return Array.from(
Editor.levels(editor, { Editor.levels(editor, {
@@ -19,7 +17,6 @@ export const test = editor => {
}) })
) )
} }
export const output = [ export const output = [
[<text />, [0, 0]], [<text />, [0, 0]],
[ [

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
@@ -10,11 +9,9 @@ export const input = (
</element> </element>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
return Array.from(Editor.levels(editor, { at: [0, 0] })) return Array.from(Editor.levels(editor, { at: [0, 0] }))
} }
export const output = [ export const output = [
[input, []], [input, []],
[ [

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
@@ -10,11 +9,9 @@ export const input = (
</element> </element>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
return Array.from(Editor.levels(editor, { at: [0, 0] })) return Array.from(Editor.levels(editor, { at: [0, 0] }))
} }
export const output = [ export const output = [
[input, []], [input, []],
[ [

View File

@@ -1,5 +1,4 @@
/** @jsx jsx */ /** @jsx jsx */
import { Editor } from 'slate' import { Editor } from 'slate'
import { jsx } from 'slate-hyperscript' import { jsx } from 'slate-hyperscript'
@@ -10,7 +9,6 @@ export const input = (
</element> </element>
</editor> </editor>
) )
export const test = editor => { export const test = editor => {
return Array.from( return Array.from(
Editor.levels(editor, { Editor.levels(editor, {
@@ -19,7 +17,6 @@ export const test = editor => {
}) })
) )
} }
export const output = [ export const output = [
[input, []], [input, []],
[ [

Some files were not shown because too many files have changed in this diff Show More