mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-06 15:26:34 +02:00
Add tests for Editor.unhangRange() (#4703)
* Add tests for Editor.unhangRange() * Extend tests for `Editor.unhangRange()` to cover voids * Fix lint * Add changeset
This commit is contained in:
5
.changeset/soft-trees-taste.md
Normal file
5
.changeset/soft-trees-taste.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add tests for Editor.unhangRange() behavior
|
@@ -0,0 +1,26 @@
|
|||||||
|
/** @jsx jsx */
|
||||||
|
import { Editor } from 'slate'
|
||||||
|
import { jsx } from '../../..'
|
||||||
|
|
||||||
|
export const input = (
|
||||||
|
<editor>
|
||||||
|
<block>
|
||||||
|
<anchor />
|
||||||
|
This is a first paragraph
|
||||||
|
</block>
|
||||||
|
<block>This is the second paragraph</block>
|
||||||
|
<block void />
|
||||||
|
<block>
|
||||||
|
<focus />
|
||||||
|
</block>
|
||||||
|
</editor>
|
||||||
|
)
|
||||||
|
|
||||||
|
export const test = editor => {
|
||||||
|
return Editor.unhangRange(editor, editor.selection, { voids: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
export const output = {
|
||||||
|
anchor: { path: [0, 0], offset: 0 },
|
||||||
|
focus: { path: [1, 0], offset: 28 },
|
||||||
|
}
|
@@ -0,0 +1,26 @@
|
|||||||
|
/** @jsx jsx */
|
||||||
|
import { Editor } from 'slate'
|
||||||
|
import { jsx } from '../../..'
|
||||||
|
|
||||||
|
export const input = (
|
||||||
|
<editor>
|
||||||
|
<block>
|
||||||
|
<anchor />
|
||||||
|
This is a first paragraph
|
||||||
|
</block>
|
||||||
|
<block>This is the second paragraph</block>
|
||||||
|
<block void />
|
||||||
|
<block>
|
||||||
|
<focus />
|
||||||
|
</block>
|
||||||
|
</editor>
|
||||||
|
)
|
||||||
|
|
||||||
|
export const test = editor => {
|
||||||
|
return Editor.unhangRange(editor, editor.selection)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const output = {
|
||||||
|
anchor: { path: [0, 0], offset: 0 },
|
||||||
|
focus: { path: [1, 0], offset: 28 },
|
||||||
|
}
|
@@ -0,0 +1,25 @@
|
|||||||
|
/** @jsx jsx */
|
||||||
|
import { Editor } from 'slate'
|
||||||
|
import { jsx } from '../../..'
|
||||||
|
|
||||||
|
export const input = (
|
||||||
|
<editor>
|
||||||
|
<block>
|
||||||
|
<anchor />
|
||||||
|
word
|
||||||
|
</block>
|
||||||
|
<block>
|
||||||
|
<focus />
|
||||||
|
another
|
||||||
|
</block>
|
||||||
|
</editor>
|
||||||
|
)
|
||||||
|
|
||||||
|
export const test = editor => {
|
||||||
|
return Editor.unhangRange(editor, editor.selection)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const output = {
|
||||||
|
anchor: { path: [0, 0], offset: 0 },
|
||||||
|
focus: { path: [0, 0], offset: 4 },
|
||||||
|
}
|
@@ -0,0 +1,19 @@
|
|||||||
|
/** @jsx jsx */
|
||||||
|
import { Editor } from 'slate'
|
||||||
|
import { jsx } from '../../..'
|
||||||
|
|
||||||
|
export const input = (
|
||||||
|
<editor>
|
||||||
|
<block>
|
||||||
|
one
|
||||||
|
<cursor />
|
||||||
|
</block>
|
||||||
|
</editor>
|
||||||
|
)
|
||||||
|
export const test = editor => {
|
||||||
|
return Editor.unhangRange(editor, editor.selection)
|
||||||
|
}
|
||||||
|
export const output = {
|
||||||
|
anchor: { path: [0, 0], offset: 3 },
|
||||||
|
focus: { path: [0, 0], offset: 3 },
|
||||||
|
}
|
@@ -0,0 +1,28 @@
|
|||||||
|
/** @jsx jsx */
|
||||||
|
import { Editor } from 'slate'
|
||||||
|
import { jsx } from '../../..'
|
||||||
|
|
||||||
|
export const input = (
|
||||||
|
<editor>
|
||||||
|
<block>
|
||||||
|
<text>
|
||||||
|
before
|
||||||
|
<anchor />
|
||||||
|
</text>
|
||||||
|
<text>selected</text>
|
||||||
|
<text>
|
||||||
|
<focus />
|
||||||
|
after
|
||||||
|
</text>
|
||||||
|
</block>
|
||||||
|
</editor>
|
||||||
|
)
|
||||||
|
|
||||||
|
export const test = editor => {
|
||||||
|
return Editor.unhangRange(editor, editor.selection)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const output = {
|
||||||
|
anchor: { path: [0, 0], offset: 6 },
|
||||||
|
focus: { path: [0, 2], offset: 0 },
|
||||||
|
}
|
@@ -0,0 +1,25 @@
|
|||||||
|
/** @jsx jsx */
|
||||||
|
import { Editor } from 'slate'
|
||||||
|
import { jsx } from '../../..'
|
||||||
|
|
||||||
|
export const input = (
|
||||||
|
<editor>
|
||||||
|
<block>
|
||||||
|
<anchor />
|
||||||
|
This is a first paragraph
|
||||||
|
</block>
|
||||||
|
<block>This is the second paragraph</block>
|
||||||
|
<block void>
|
||||||
|
<focus />
|
||||||
|
</block>
|
||||||
|
</editor>
|
||||||
|
)
|
||||||
|
|
||||||
|
export const test = editor => {
|
||||||
|
return Editor.unhangRange(editor, editor.selection, { voids: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
export const output = {
|
||||||
|
anchor: { path: [0, 0], offset: 0 },
|
||||||
|
focus: { path: [1, 0], offset: 28 },
|
||||||
|
}
|
@@ -0,0 +1,25 @@
|
|||||||
|
/** @jsx jsx */
|
||||||
|
import { Editor } from 'slate'
|
||||||
|
import { jsx } from '../../..'
|
||||||
|
|
||||||
|
export const input = (
|
||||||
|
<editor>
|
||||||
|
<block>
|
||||||
|
<anchor />
|
||||||
|
This is a first paragraph
|
||||||
|
</block>
|
||||||
|
<block>This is the second paragraph</block>
|
||||||
|
<block void>
|
||||||
|
<focus />
|
||||||
|
</block>
|
||||||
|
</editor>
|
||||||
|
)
|
||||||
|
|
||||||
|
export const test = editor => {
|
||||||
|
return Editor.unhangRange(editor, editor.selection)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const output = {
|
||||||
|
anchor: { path: [0, 0], offset: 0 },
|
||||||
|
focus: { path: [0, 0], offset: 25 },
|
||||||
|
}
|
Reference in New Issue
Block a user