mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-18 13:11:17 +02:00
add value deprecations
This commit is contained in:
@@ -20,7 +20,7 @@ Here's a really simple plugin:
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClick(event, change, editor) {
|
onClick(event, change, editor) {
|
||||||
if (change.value.isBlurred) {
|
if (change.value.selection.isBlurred) {
|
||||||
change.moveToRangeOfDocument().focus()
|
change.moveToRangeOfDocument().focus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -117,76 +117,6 @@ Get a list of the lowest-depth [`Inline`](./inline.md) nodes in the current sele
|
|||||||
|
|
||||||
Get a list of the [`Text`](./text.md) nodes in the current selection.
|
Get a list of the [`Text`](./text.md) nodes in the current selection.
|
||||||
|
|
||||||
### `hasUndos`
|
|
||||||
|
|
||||||
`Boolean`
|
|
||||||
|
|
||||||
Whether there are undoable snapshots to revert to in the history.
|
|
||||||
|
|
||||||
### `hasRedos`
|
|
||||||
|
|
||||||
`Boolean`
|
|
||||||
|
|
||||||
Whether there are redoable snapshots to revert to in the history.
|
|
||||||
|
|
||||||
## Range-like Properties
|
|
||||||
|
|
||||||
These properties are exact proxies of the selection [`Range`](./range.md) equivalents.
|
|
||||||
|
|
||||||
### `{edge}Key`
|
|
||||||
|
|
||||||
`String`
|
|
||||||
|
|
||||||
Get the current key at an `{edge}`. Where `{edge}` is one of: `anchor`, `focus`, `start` or `end`.
|
|
||||||
|
|
||||||
### `{edge}Offset`
|
|
||||||
|
|
||||||
`Number`
|
|
||||||
|
|
||||||
Get the current offset at an `{edge}`. Where `{edge}` is one of: `anchor`, `focus`, `start` or `end`.
|
|
||||||
|
|
||||||
### `isBackward`
|
|
||||||
|
|
||||||
`Boolean`
|
|
||||||
|
|
||||||
Whether the current selection is backward.
|
|
||||||
|
|
||||||
### `isBlurred`
|
|
||||||
|
|
||||||
`Boolean`
|
|
||||||
|
|
||||||
Whether the current selection is blurred.
|
|
||||||
|
|
||||||
### `isCollapsed`
|
|
||||||
|
|
||||||
`Boolean`
|
|
||||||
|
|
||||||
Whether the current selection is collapsed.
|
|
||||||
|
|
||||||
### `isExpanded`
|
|
||||||
|
|
||||||
`Boolean`
|
|
||||||
|
|
||||||
Whether the current selection is expanded.
|
|
||||||
|
|
||||||
### `isFocused`
|
|
||||||
|
|
||||||
`Boolean`
|
|
||||||
|
|
||||||
Whether the current selection is focused.
|
|
||||||
|
|
||||||
### `isForward`
|
|
||||||
|
|
||||||
`Boolean`
|
|
||||||
|
|
||||||
Whether the current selection is forward.
|
|
||||||
|
|
||||||
### `isEmpty`
|
|
||||||
|
|
||||||
`Boolean`
|
|
||||||
|
|
||||||
Whether the current selection is empty.
|
|
||||||
|
|
||||||
## Static Methods
|
## Static Methods
|
||||||
|
|
||||||
### `Value.create`
|
### `Value.create`
|
||||||
|
@@ -442,7 +442,8 @@ class Content extends React.Component {
|
|||||||
renderNode = (child, isSelected, decorations) => {
|
renderNode = (child, isSelected, decorations) => {
|
||||||
const { editor, readOnly } = this.props
|
const { editor, readOnly } = this.props
|
||||||
const { value } = editor
|
const { value } = editor
|
||||||
const { document, isFocused } = value
|
const { document, selection } = value
|
||||||
|
const { isFocused } = selection
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Node
|
<Node
|
||||||
|
@@ -367,7 +367,7 @@ function BeforePlugin() {
|
|||||||
|
|
||||||
function onInput(event, change, editor) {
|
function onInput(event, change, editor) {
|
||||||
if (isComposing) return true
|
if (isComposing) return true
|
||||||
if (change.value.isBlurred) return true
|
if (change.value.selection.isBlurred) return true
|
||||||
|
|
||||||
debug('onInput', { event })
|
debug('onInput', { event })
|
||||||
}
|
}
|
||||||
|
@@ -174,46 +174,6 @@ class Value extends Record(DEFAULTS) {
|
|||||||
return this.object
|
return this.object
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Are there undoable events?
|
|
||||||
*
|
|
||||||
* @return {Boolean}
|
|
||||||
*/
|
|
||||||
|
|
||||||
get hasUndos() {
|
|
||||||
return this.history.undos.size > 0
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Are there redoable events?
|
|
||||||
*
|
|
||||||
* @return {Boolean}
|
|
||||||
*/
|
|
||||||
|
|
||||||
get hasRedos() {
|
|
||||||
return this.history.redos.size > 0
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is the current selection blurred?
|
|
||||||
*
|
|
||||||
* @return {Boolean}
|
|
||||||
*/
|
|
||||||
|
|
||||||
get isBlurred() {
|
|
||||||
return this.selection.isBlurred
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is the current selection focused?
|
|
||||||
*
|
|
||||||
* @return {Boolean}
|
|
||||||
*/
|
|
||||||
|
|
||||||
get isFocused() {
|
|
||||||
return this.selection.isFocused
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current start text node's closest block parent.
|
* Get the current start text node's closest block parent.
|
||||||
*
|
*
|
||||||
@@ -521,32 +481,6 @@ class Value extends Record(DEFAULTS) {
|
|||||||
: this.document.getTextsAtRange(this.selection)
|
: this.document.getTextsAtRange(this.selection)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check whether the selection is empty.
|
|
||||||
*
|
|
||||||
* @return {Boolean}
|
|
||||||
*/
|
|
||||||
|
|
||||||
get isEmpty() {
|
|
||||||
logger.deprecate('0.38.0', 'The `Value.isEmpty` property is deprecated.')
|
|
||||||
if (this.selection.isCollapsed) return true
|
|
||||||
if (this.selection.end.offset != 0 && this.selection.start.offset != 0)
|
|
||||||
return false
|
|
||||||
return this.fragment.isEmpty
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check whether the selection is collapsed in a void node.
|
|
||||||
*
|
|
||||||
* @return {Boolean}
|
|
||||||
*/
|
|
||||||
|
|
||||||
get isInVoid() {
|
|
||||||
logger.deprecate('0.38.0', 'The `Value.isInVoid` property is deprecated.')
|
|
||||||
if (this.selection.isExpanded) return false
|
|
||||||
return this.document.hasVoidParent(this.selection.start.key, this.schema)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new `Change` with the current value as a starting point.
|
* Create a new `Change` with the current value as a starting point.
|
||||||
*
|
*
|
||||||
@@ -1017,6 +951,56 @@ class Value extends Record(DEFAULTS) {
|
|||||||
* Deprecated.
|
* Deprecated.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
get hasUndos() {
|
||||||
|
logger.deprecate(
|
||||||
|
'0.38.0',
|
||||||
|
'The `Value.hasUndos` property is deprecated, please use `history.undos.size` instead.'
|
||||||
|
)
|
||||||
|
|
||||||
|
return this.history.undos.size > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
get hasRedos() {
|
||||||
|
logger.deprecate(
|
||||||
|
'0.38.0',
|
||||||
|
'The `Value.hasRedos` property is deprecated, please use `history.redos.size` instead.'
|
||||||
|
)
|
||||||
|
|
||||||
|
return this.history.redos.size > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
get isBlurred() {
|
||||||
|
logger.deprecate(
|
||||||
|
'0.38.0',
|
||||||
|
'The `Value.isBlurred` property is deprecated, please use `selection.isBlurred` instead.'
|
||||||
|
)
|
||||||
|
|
||||||
|
return this.selection.isBlurred
|
||||||
|
}
|
||||||
|
|
||||||
|
get isFocused() {
|
||||||
|
logger.deprecate(
|
||||||
|
'0.38.0',
|
||||||
|
'The `Value.isFocused` property is deprecated, please use `selection.isFocused` instead.'
|
||||||
|
)
|
||||||
|
|
||||||
|
return this.selection.isFocused
|
||||||
|
}
|
||||||
|
|
||||||
|
get isEmpty() {
|
||||||
|
logger.deprecate('0.38.0', 'The `Value.isEmpty` property is deprecated.')
|
||||||
|
if (this.selection.isCollapsed) return true
|
||||||
|
if (this.selection.end.offset != 0 && this.selection.start.offset != 0)
|
||||||
|
return false
|
||||||
|
return this.fragment.isEmpty
|
||||||
|
}
|
||||||
|
|
||||||
|
get isInVoid() {
|
||||||
|
logger.deprecate('0.38.0', 'The `Value.isInVoid` property is deprecated.')
|
||||||
|
if (this.selection.isExpanded) return false
|
||||||
|
return this.document.hasVoidParent(this.selection.start.key, this.schema)
|
||||||
|
}
|
||||||
|
|
||||||
get isCollapsed() {
|
get isCollapsed() {
|
||||||
logger.deprecate(
|
logger.deprecate(
|
||||||
'0.37.0',
|
'0.37.0',
|
||||||
|
Reference in New Issue
Block a user