-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
214 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'slate': minor | ||
--- | ||
|
||
- Add `isSelectable` to `editor` (default true). A non-selectable element is skipped over when navigating using arrow keys. | ||
- Add `ignoreNonSelectable` to `Editor.nodes`, `Editor.positions`, `Editor.after` and `Editor.before` (default false) | ||
- `Transforms.move` ignores non-selectable elements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/slate/test/interfaces/Editor/after/non-selectable-inline.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** @jsx jsx */ | ||
|
||
import { Editor } from 'slate' | ||
import { jsx } from '../../..' | ||
|
||
export const input = ( | ||
<editor> | ||
<block> | ||
one<inline nonSelectable>two</inline>three | ||
</block> | ||
</editor> | ||
) | ||
|
||
export const test = editor => { | ||
return Editor.after( | ||
editor, | ||
{ path: [0, 0], offset: 3 }, | ||
{ ignoreNonSelectable: true } | ||
) | ||
} | ||
|
||
export const output = { path: [0, 2], offset: 0 } |
22 changes: 22 additions & 0 deletions
22
packages/slate/test/interfaces/Editor/before/non-selectable-inline.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** @jsx jsx */ | ||
|
||
import { Editor } from 'slate' | ||
import { jsx } from '../../..' | ||
|
||
export const input = ( | ||
<editor> | ||
<block> | ||
one<inline nonSelectable>two</inline>three | ||
</block> | ||
</editor> | ||
) | ||
|
||
export const test = editor => { | ||
return Editor.before( | ||
editor, | ||
{ path: [0, 2], offset: 0 }, | ||
{ ignoreNonSelectable: true } | ||
) | ||
} | ||
|
||
export const output = { path: [0, 0], offset: 3 } |
19 changes: 19 additions & 0 deletions
19
packages/slate/test/interfaces/Editor/nodes/ignore-non-selectable/block.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** @jsx jsx */ | ||
import { Editor, Text } from 'slate' | ||
import { jsx } from '../../../..' | ||
|
||
export const input = ( | ||
<editor> | ||
<block nonSelectable>one</block> | ||
</editor> | ||
) | ||
export const test = editor => { | ||
return Array.from( | ||
Editor.nodes(editor, { | ||
at: [], | ||
match: Text.isText, | ||
ignoreNonSelectable: true, | ||
}) | ||
) | ||
} | ||
export const output = [] |
20 changes: 20 additions & 0 deletions
20
packages/slate/test/interfaces/Editor/nodes/ignore-non-selectable/inline.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** @jsx jsx */ | ||
import { Editor, Text } from 'slate' | ||
import { jsx } from '../../../..' | ||
|
||
export const input = ( | ||
<editor> | ||
<block> | ||
one<inline nonSelectable>two</inline>three | ||
</block> | ||
</editor> | ||
) | ||
export const test = editor => { | ||
return Array.from(Editor.nodes(editor, { at: [], ignoreNonSelectable: true })) | ||
} | ||
export const output = [ | ||
[input, []], | ||
[input.children[0], [0]], | ||
[input.children[0].children[0], [0, 0]], | ||
[input.children[0].children[2], [0, 2]], | ||
] |
15 changes: 15 additions & 0 deletions
15
packages/slate/test/interfaces/Editor/positions/ignore-non-selectable/block.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** @jsx jsx */ | ||
import { Editor } from 'slate' | ||
import { jsx } from '../../../..' | ||
|
||
export const input = ( | ||
<editor> | ||
<block nonSelectable>one</block> | ||
</editor> | ||
) | ||
export const test = editor => { | ||
return Array.from( | ||
Editor.positions(editor, { at: [], ignoreNonSelectable: true }) | ||
) | ||
} | ||
export const output = [] |
32 changes: 32 additions & 0 deletions
32
packages/slate/test/interfaces/Editor/positions/ignore-non-selectable/inline.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** @jsx jsx */ | ||
import { Editor } from 'slate' | ||
import { jsx } from '../../../..' | ||
|
||
export const input = ( | ||
<editor> | ||
<block> | ||
one<inline nonSelectable>two</inline>three | ||
</block> | ||
</editor> | ||
) | ||
export const test = editor => { | ||
return Array.from( | ||
Editor.positions(editor, { at: [], ignoreNonSelectable: true }) | ||
) | ||
} | ||
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 }, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.