-
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.
Add support for read-only and non-selectable elements (#5374)
* Add `isElementReadOnly` fix delete while selected fix type while selected fix failing test add tests add e2e test linter fixes add changeset * fix yarn build:next * Add `isSelectable`
- Loading branch information
Showing
22 changed files
with
416 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'slate': minor | ||
--- | ||
|
||
- Add `isElementReadOnly` to `editor`. A read-only element behaves much like a void with regard to selection and deletion, but renders its `children` the same as any other non-void node. |
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 } |
Oops, something went wrong.