mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-22 06:53:25 +02:00
add value deprecations
This commit is contained in:
@@ -442,7 +442,8 @@ class Content extends React.Component {
|
||||
renderNode = (child, isSelected, decorations) => {
|
||||
const { editor, readOnly } = this.props
|
||||
const { value } = editor
|
||||
const { document, isFocused } = value
|
||||
const { document, selection } = value
|
||||
const { isFocused } = selection
|
||||
|
||||
return (
|
||||
<Node
|
||||
|
@@ -367,7 +367,7 @@ function BeforePlugin() {
|
||||
|
||||
function onInput(event, change, editor) {
|
||||
if (isComposing) return true
|
||||
if (change.value.isBlurred) return true
|
||||
if (change.value.selection.isBlurred) return true
|
||||
|
||||
debug('onInput', { event })
|
||||
}
|
||||
|
@@ -174,46 +174,6 @@ class Value extends Record(DEFAULTS) {
|
||||
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.
|
||||
*
|
||||
@@ -521,32 +481,6 @@ class Value extends Record(DEFAULTS) {
|
||||
: 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.
|
||||
*
|
||||
@@ -1017,6 +951,56 @@ class Value extends Record(DEFAULTS) {
|
||||
* 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() {
|
||||
logger.deprecate(
|
||||
'0.37.0',
|
||||
|
Reference in New Issue
Block a user