mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-06 23:36:31 +02:00
fixes
This commit is contained in:
@@ -29,17 +29,17 @@ Transform methods can either operate on the [`Document`](./document.md), the [`S
|
|||||||
- [`wrapInline`](#wrapinline)
|
- [`wrapInline`](#wrapinline)
|
||||||
- [Selection Transforms](#selection-transforms)
|
- [Selection Transforms](#selection-transforms)
|
||||||
- [`blur`](#blur)
|
- [`blur`](#blur)
|
||||||
- [`extend{Direction}`](#extenddirection)
|
- [`collapseTo{Edge}Of`](#collapsetoedgeof)
|
||||||
|
- [`collapseTo{Edge}Of{Direction}Block`](#collapsetoedgeofdirectionblock)
|
||||||
|
- [`collapseTo{Edge}Of{Direction}Text`](#collapsetoedgeofdirectiontext)
|
||||||
|
- [`collapseTo{Edge}`](#collapsetoedge)
|
||||||
- [`extendTo{Edge}Of`](#extendtoedgeof)
|
- [`extendTo{Edge}Of`](#extendtoedgeof)
|
||||||
|
- [`extend{Direction}`](#extenddirection)
|
||||||
- [`focus`](#focus)
|
- [`focus`](#focus)
|
||||||
- [`move{Direction}`](#movedirection)
|
|
||||||
- [`moveToOffsets`](#movetooffsets)
|
- [`moveToOffsets`](#movetooffsets)
|
||||||
- [`moveToRangeOf`](#movetorangeof)
|
- [`moveToRangeOf`](#movetorangeof)
|
||||||
- [`moveTo`](#moveto)
|
- [`moveTo`](#moveto)
|
||||||
- [`moveTo{Edge}`](#movetoedge)
|
- [`move{Direction}`](#movedirection)
|
||||||
- [`moveTo{Edge}Of`](#movetoedgeof)
|
|
||||||
- [`moveTo{Edge}Of{Direction}Block`](#movetoedgeofdirectionblock)
|
|
||||||
- [`moveTo{Edge}Of{Direction}Text`](#movetoedgeofdirectiontext)
|
|
||||||
- [Document Transforms](#document-transforms)
|
- [Document Transforms](#document-transforms)
|
||||||
- [`deleteAtRange`](#deleteatrange)
|
- [`deleteAtRange`](#deleteatrange)
|
||||||
- [`deleteBackwardAtRange`](#deletebackwardatrange)
|
- [`deleteBackwardAtRange`](#deletebackwardatrange)
|
||||||
@@ -152,6 +152,26 @@ Wrap the [`Inline`](./inline.md) nodes in the current selection with a new [`Inl
|
|||||||
|
|
||||||
Blur the current selection.
|
Blur the current selection.
|
||||||
|
|
||||||
|
### `collapseTo{Edge}`
|
||||||
|
`collapseTo{Edge}() => Transform`
|
||||||
|
|
||||||
|
Collapse the current selection to its `{Edge}`. Where `{Edge}` is either `Anchor`, `Focus`, `Start` or `End`.
|
||||||
|
|
||||||
|
### `collapseTo{Edge}Of`
|
||||||
|
`collapseTo{Edge}Of(node: Node) => Transform`
|
||||||
|
|
||||||
|
Collapse the current selection to the `{Edge}` of `node`. Where `{Edge}` is either `Start` or `End`.
|
||||||
|
|
||||||
|
### `collapseTo{Edge}Of{Direction}Block`
|
||||||
|
`collapseTo{Edge}Of{Direction}Block() => Transform`
|
||||||
|
|
||||||
|
Collapse the current selection to the `{Edge}` of the next [`Block`](./block.md) node in `{Direction}`. Where `{Edge}` is either `{Start}` or `{End}` and `{Direction}` is either `Next` or `Previous`.
|
||||||
|
|
||||||
|
### `collapseTo{Edge}Of{Direction}Text`
|
||||||
|
`collapseTo{Edge}Of{Direction}Text() => Transform`
|
||||||
|
|
||||||
|
Collapse the current selection to the `{Edge}` of the next [`Text`](./text.md) node in `{Direction}`. Where `{Edge}` is either `{Start}` or `{End}` and `{Direction}` is either `Next` or `Previous`.
|
||||||
|
|
||||||
### `extend{Direction}`
|
### `extend{Direction}`
|
||||||
`extend{Direction}(n: Number) => Transform`
|
`extend{Direction}(n: Number) => Transform`
|
||||||
|
|
||||||
@@ -187,26 +207,6 @@ Move the current selection's anchor point to the start of a `node` and its focus
|
|||||||
|
|
||||||
Move the current selection to a selection with merged `properties`.
|
Move the current selection to a selection with merged `properties`.
|
||||||
|
|
||||||
### `collapseTo{Edge}`
|
|
||||||
`collapseTo{Edge}() => Transform`
|
|
||||||
|
|
||||||
Collapse the current selection to its `{Edge}`. Where `{Edge}` is either `Anchor`, `Focus`, `Start` or `End`.
|
|
||||||
|
|
||||||
### `collapseTo{Edge}Of`
|
|
||||||
`collapseTo{Edge}Of(node: Node) => Transform`
|
|
||||||
|
|
||||||
Collapse the current selection to the `{Edge}` of `node`. Where `{Edge}` is either `Start` or `End`.
|
|
||||||
|
|
||||||
### `collapseTo{Edge}Of{Direction}Block`
|
|
||||||
`collapseTo{Edge}Of{Direction}Block() => Transform`
|
|
||||||
|
|
||||||
Collapse the current selection to the `{Edge}` of the next [`Block`](./block.md) node in `{Direction}`. Where `{Edge}` is either `{Start}` or `{End}` and `{Direction}` is either `Next` or `Previous`.
|
|
||||||
|
|
||||||
### `collapseTo{Edge}Of{Direction}Text`
|
|
||||||
`collapseTo{Edge}Of{Direction}Text() => Transform`
|
|
||||||
|
|
||||||
Collapse the current selection to the `{Edge}` of the next [`Text`](./text.md) node in `{Direction}`. Where `{Edge}` is either `{Start}` or `{End}` and `{Direction}` is either `Next` or `Previous`.
|
|
||||||
|
|
||||||
|
|
||||||
## Document Transforms
|
## Document Transforms
|
||||||
|
|
||||||
|
@@ -142,11 +142,21 @@ class Images extends React.Component {
|
|||||||
|
|
||||||
if (anchorBlock.text != '') {
|
if (anchorBlock.text != '') {
|
||||||
if (selection.isAtEndOf(anchorBlock)) {
|
if (selection.isAtEndOf(anchorBlock)) {
|
||||||
transform = transform.splitBlock()
|
transform = transform
|
||||||
} else if (selection.isAtStartOf(anchorBlock)) {
|
.splitBlock()
|
||||||
transform = transform.splitBlock().moveToStartOfPreviousBlock()
|
}
|
||||||
} else {
|
|
||||||
transform = transform.splitBlock().splitBlock().moveToStartOfPreviousBlock()
|
else if (selection.isAtStartOf(anchorBlock)) {
|
||||||
|
transform = transform
|
||||||
|
.splitBlock()
|
||||||
|
.collapseToStartOfPreviousBlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
transform = transform
|
||||||
|
.splitBlock()
|
||||||
|
.splitBlock()
|
||||||
|
.collapseToStartOfPreviousBlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -78,7 +78,7 @@ class Links extends React.Component {
|
|||||||
.insertText(text)
|
.insertText(text)
|
||||||
.extendBackward(text.length)
|
.extendBackward(text.length)
|
||||||
.wrapInline('link', new Map({ href }))
|
.wrapInline('link', new Map({ href }))
|
||||||
.moveToEnd(text.length)
|
.collapseToEnd()
|
||||||
.apply()
|
.apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,7 +6,7 @@ import { Record } from 'immutable'
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const START_END_METHODS = [
|
const START_END_METHODS = [
|
||||||
'moveTo%'
|
'collapseTo%'
|
||||||
]
|
]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -50,6 +50,12 @@ const DOCUMENT_TRANSFORMS = [
|
|||||||
|
|
||||||
const SELECTION_TRANSFORMS = [
|
const SELECTION_TRANSFORMS = [
|
||||||
'blur',
|
'blur',
|
||||||
|
'collapseToAnchor',
|
||||||
|
'collapseToEnd',
|
||||||
|
'collapseToEndOf',
|
||||||
|
'collapseToFocus',
|
||||||
|
'collapseToStart',
|
||||||
|
'collapseToStartOf',
|
||||||
'extendBackward',
|
'extendBackward',
|
||||||
'extendForward',
|
'extendForward',
|
||||||
'extendToEndOf',
|
'extendToEndOf',
|
||||||
@@ -57,14 +63,8 @@ const SELECTION_TRANSFORMS = [
|
|||||||
'focus',
|
'focus',
|
||||||
'moveBackward',
|
'moveBackward',
|
||||||
'moveForward',
|
'moveForward',
|
||||||
'collapseToAnchor',
|
|
||||||
'collapseToEnd',
|
|
||||||
'collapseToEndOf',
|
|
||||||
'collapseToFocus',
|
|
||||||
'moveToOffsets',
|
'moveToOffsets',
|
||||||
'moveToRangeOf',
|
'moveToRangeOf'
|
||||||
'collapseToStart',
|
|
||||||
'collapseToStartOf'
|
|
||||||
]
|
]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,6 +72,14 @@ const SELECTION_TRANSFORMS = [
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const STATE_TRANSFORMS = [
|
const STATE_TRANSFORMS = [
|
||||||
|
'collapseToEndOfNextBlock',
|
||||||
|
'collapseToEndOfNextText',
|
||||||
|
'collapseToEndOfPreviousBlock',
|
||||||
|
'collapseToEndOfPreviousText',
|
||||||
|
'collapseToStartOfNextBlock',
|
||||||
|
'collapseToStartOfNextText',
|
||||||
|
'collapseToStartOfPreviousBlock',
|
||||||
|
'collapseToStartOfPreviousText',
|
||||||
'delete',
|
'delete',
|
||||||
'deleteBackward',
|
'deleteBackward',
|
||||||
'deleteForward',
|
'deleteForward',
|
||||||
@@ -79,14 +87,6 @@ const STATE_TRANSFORMS = [
|
|||||||
'insertText',
|
'insertText',
|
||||||
'mark',
|
'mark',
|
||||||
'moveTo',
|
'moveTo',
|
||||||
'collapseToStartOfPreviousBlock',
|
|
||||||
'collapseToEndOfPreviousBlock',
|
|
||||||
'collapseToStartOfNextBlock',
|
|
||||||
'collapseToEndOfNextBlock',
|
|
||||||
'collapseToStartOfPreviousText',
|
|
||||||
'collapseToEndOfPreviousText',
|
|
||||||
'collapseToStartOfNextText',
|
|
||||||
'collapseToEndOfNextText',
|
|
||||||
'setBlock',
|
'setBlock',
|
||||||
'setInline',
|
'setInline',
|
||||||
'splitBlock',
|
'splitBlock',
|
||||||
|
Reference in New Issue
Block a user