Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit:offset tests. #5269

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/** @jsx jsx */
import { Editor } from 'slate'
import { jsx } from '../../../..'

export const input = (
<editor>
<block>
1<inline>2</inline><text></text>

Check failure on line 8 in packages/slate/test/interfaces/Editor/positions/all/unit-character-final-inline-fragmentation-reverse.tsx

View workflow job for this annotation

GitHub Actions / lint:eslint

Insert `⏎······`

Check failure on line 8 in packages/slate/test/interfaces/Editor/positions/all/unit-character-final-inline-fragmentation-reverse.tsx

View workflow job for this annotation

GitHub Actions / lint:eslint

Empty components are self-closing
</block>
</editor>
)
export const test = editor => {
return Array.from(Editor.positions(editor, { at: [], unit: 'character', reverse: true }))

Check failure on line 13 in packages/slate/test/interfaces/Editor/positions/all/unit-character-final-inline-fragmentation-reverse.tsx

View workflow job for this annotation

GitHub Actions / lint:eslint

Replace `Editor.positions(editor,·{·at:·[],·unit:·'character',·reverse:·true·})` with `⏎····Editor.positions(editor,·{·at:·[],·unit:·'character',·reverse:·true·})⏎··`
}
export const output = [
{ path: [0, 2], offset: 0 },
{ path: [0, 1, 0], offset: 0 },
{ path: [0, 0], offset: 0 },
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/** @jsx jsx */
import { Editor } from 'slate'
import { jsx } from '../../../..'

export const input = (
<editor>
<block>
1<inline>2</inline><text></text>

Check failure on line 8 in packages/slate/test/interfaces/Editor/positions/all/unit-character-final-inline-fragmentation.tsx

View workflow job for this annotation

GitHub Actions / lint:eslint

Insert `⏎······`

Check failure on line 8 in packages/slate/test/interfaces/Editor/positions/all/unit-character-final-inline-fragmentation.tsx

View workflow job for this annotation

GitHub Actions / lint:eslint

Empty components are self-closing
</block>
</editor>
)
export const test = editor => {
return Array.from(Editor.positions(editor, { at: [], unit: 'character' }))
}
export const output = [
{ path: [0, 0], offset: 0 },
{ path: [0, 0], offset: 1 },
{ path: [0, 1, 0], offset: 1 },
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/** @jsx jsx */
import { Editor } from 'slate'
import { jsx } from '../../../..'

export const input = (
<editor>
<block>
1<inline>2</inline><text></text>

Check failure on line 8 in packages/slate/test/interfaces/Editor/positions/all/unit-offset-final-inline-fragmentation-reverse.tsx

View workflow job for this annotation

GitHub Actions / lint:eslint

Insert `⏎······`

Check failure on line 8 in packages/slate/test/interfaces/Editor/positions/all/unit-offset-final-inline-fragmentation-reverse.tsx

View workflow job for this annotation

GitHub Actions / lint:eslint

Empty components are self-closing
</block>
</editor>
)
export const test = editor => {
return Array.from(Editor.positions(editor, { at: [], unit: 'offset', reverse: true }))

Check failure on line 13 in packages/slate/test/interfaces/Editor/positions/all/unit-offset-final-inline-fragmentation-reverse.tsx

View workflow job for this annotation

GitHub Actions / lint:eslint

Replace `Editor.positions(editor,·{·at:·[],·unit:·'offset',·reverse:·true·})` with `⏎····Editor.positions(editor,·{·at:·[],·unit:·'offset',·reverse:·true·})⏎··`
}
export const output = [
{ path: [0, 2], offset: 0 },
{ path: [0, 1, 0], offset: 1 },
{ path: [0, 1, 0], offset: 0 },
{ path: [0, 0], offset: 1 },
{ path: [0, 0], offset: 0 },
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/** @jsx jsx */
import { Editor } from 'slate'
import { jsx } from '../../../..'

export const input = (
<editor>
<block>
1<inline>2</inline><text></text>

Check failure on line 8 in packages/slate/test/interfaces/Editor/positions/all/unit-offset-final-inline-fragmentation.tsx

View workflow job for this annotation

GitHub Actions / lint:eslint

Insert `⏎······`

Check failure on line 8 in packages/slate/test/interfaces/Editor/positions/all/unit-offset-final-inline-fragmentation.tsx

View workflow job for this annotation

GitHub Actions / lint:eslint

Empty components are self-closing
</block>
</editor>
)
export const test = editor => {
return Array.from(Editor.positions(editor, { at: [], unit: 'offset' }))
}
export const output = [
{ path: [0, 0], offset: 0 },
{ path: [0, 0], offset: 1 },
{ path: [0, 1, 0], offset: 0 },
{ path: [0, 1, 0], offset: 1 },
{ path: [0, 2], offset: 0 },
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/** @jsx jsx */
import { Editor } from 'slate'
import { jsx } from '../../../..'

export const input = (
<editor>
<block>
one<inline>two</inline>three
</block>
<block>
four<inline>five</inline>six
</block>
</editor>
)
export const test = editor => {
return Array.from(Editor.positions(editor, { at: [], unit: 'offset', reverse: true }))
}
export const output = [
{ path: [1, 2], offset: 3 },
{ path: [1, 2], offset: 2 },
{ path: [1, 2], offset: 1 },
{ path: [1, 2], offset: 0 },
{ path: [1, 1, 0], offset: 4 },
{ path: [1, 1, 0], offset: 3 },
{ path: [1, 1, 0], offset: 2 },
{ path: [1, 1, 0], offset: 1 },
{ path: [1, 1, 0], offset: 0 },
{ path: [1, 0], offset: 4 },
{ path: [1, 0], offset: 3 },
{ path: [1, 0], offset: 2 },
{ path: [1, 0], offset: 1 },
{ path: [1, 0], offset: 0 },
{ path: [0, 2], offset: 5 },
{ path: [0, 2], offset: 4 },
{ path: [0, 2], offset: 3 },
{ path: [0, 2], offset: 2 },
{ path: [0, 2], offset: 1 },
{ path: [0, 2], offset: 0 },
{ path: [0, 1, 0], offset: 3 },
{ path: [0, 1, 0], offset: 2 },
{ path: [0, 1, 0], offset: 1 },
{ path: [0, 1, 0], offset: 0 },
{ path: [0, 0], offset: 3 },
{ path: [0, 0], offset: 2 },
{ path: [0, 0], offset: 1 },
{ path: [0, 0], offset: 0 },
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/** @jsx jsx */
import { Editor } from 'slate'
import { jsx } from '../../../..'

export const input = (
<editor>
<block>
one<inline>two</inline>three
</block>
<block>
four<inline>five</inline>six
</block>
</editor>
)
export const test = editor => {
return Array.from(Editor.positions(editor, { at: [], unit: 'offset' }))
}
export const output = [
{ path: [0, 0], offset: 0 },
{ path: [0, 0], offset: 1 },
{ path: [0, 0], offset: 2 },
{ path: [0, 0], offset: 3 },
{ path: [0, 1, 0], offset: 0 },
{ path: [0, 1, 0], offset: 1 },
{ path: [0, 1, 0], offset: 2 },
{ path: [0, 1, 0], offset: 3 },
{ path: [0, 2], offset: 0 },
{ path: [0, 2], offset: 1 },
{ path: [0, 2], offset: 2 },
{ path: [0, 2], offset: 3 },
{ path: [0, 2], offset: 4 },
{ path: [0, 2], offset: 5 },
{ path: [1, 0], offset: 0 },
{ path: [1, 0], offset: 1 },
{ path: [1, 0], offset: 2 },
{ path: [1, 0], offset: 3 },
{ path: [1, 0], offset: 4 },
{ path: [1, 1, 0], offset: 0 },
{ path: [1, 1, 0], offset: 1 },
{ path: [1, 1, 0], offset: 2 },
{ path: [1, 1, 0], offset: 3 },
{ path: [1, 1, 0], offset: 4 },
{ path: [1, 2], offset: 0 },
{ path: [1, 2], offset: 1 },
{ path: [1, 2], offset: 2 },
{ path: [1, 2], offset: 3 },
]
Loading