fix(core): isNodeSelection, isTextSelection not always false (#3089)
Fixes #2979. Since the ProseMirror TypeScript upgrade, these have always returned false, since the Selection type tree are all classes now.
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import { NodeSelection } from 'prosemirror-state'
|
||||
|
||||
import { isObject } from '../utilities/isObject'
|
||||
|
||||
export function isNodeSelection(value: unknown): value is NodeSelection {
|
||||
return isObject(value) && value instanceof NodeSelection
|
||||
return value instanceof NodeSelection
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { TextSelection } from 'prosemirror-state'
|
||||
|
||||
import { isObject } from '../utilities/isObject'
|
||||
|
||||
export function isTextSelection(value: unknown): value is TextSelection {
|
||||
return isObject(value) && value instanceof TextSelection
|
||||
return value instanceof TextSelection
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
export function isClass(value: any): boolean {
|
||||
if (value.constructor?.toString().substring(0, 5) !== 'class') {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
import { isClass } from './isClass'
|
||||
|
||||
export function isObject(value: any): boolean {
|
||||
return (
|
||||
value
|
||||
&& typeof value === 'object'
|
||||
&& !Array.isArray(value)
|
||||
&& !isClass(value)
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user