mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-19 21:51:51 +02:00
fix: Operation.isOperationList
just check value[0] (#4061)
* Fix list queries.
This commit is contained in:
@@ -47,10 +47,7 @@ export const Element: ElementInterface = {
|
||||
*/
|
||||
|
||||
isElementList(value: any): value is Element[] {
|
||||
return (
|
||||
Array.isArray(value) &&
|
||||
(value.length === 0 || Element.isElement(value[0]))
|
||||
)
|
||||
return Array.isArray(value) && value.every(val => Element.isElement(val))
|
||||
},
|
||||
|
||||
/**
|
||||
|
@@ -383,7 +383,7 @@ export const Node: NodeInterface = {
|
||||
*/
|
||||
|
||||
isNodeList(value: any): value is Node[] {
|
||||
return Array.isArray(value) && (value.length === 0 || Node.isNode(value[0]))
|
||||
return Array.isArray(value) && value.every(val => Node.isNode(val))
|
||||
},
|
||||
|
||||
/**
|
||||
|
@@ -219,8 +219,7 @@ export const Operation: OperationInterface = {
|
||||
|
||||
isOperationList(value: any): value is Operation[] {
|
||||
return (
|
||||
Array.isArray(value) &&
|
||||
(value.length === 0 || Operation.isOperation(value[0]))
|
||||
Array.isArray(value) && value.every(val => Operation.isOperation(val))
|
||||
)
|
||||
},
|
||||
|
||||
|
@@ -71,7 +71,7 @@ export const Text: TextInterface = {
|
||||
*/
|
||||
|
||||
isTextList(value: any): value is Text[] {
|
||||
return Array.isArray(value) && (value.length === 0 || Text.isText(value[0]))
|
||||
return Array.isArray(value) && value.every(val => Text.isText(val))
|
||||
},
|
||||
|
||||
/**
|
||||
|
@@ -0,0 +1,17 @@
|
||||
import { Element } from 'slate'
|
||||
|
||||
export const input = [
|
||||
{
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
type: 'set_node',
|
||||
path: [0],
|
||||
properties: {},
|
||||
newProperties: {},
|
||||
},
|
||||
]
|
||||
export const test = value => {
|
||||
return Element.isElementList(value)
|
||||
}
|
||||
export const output = false
|
@@ -0,0 +1,13 @@
|
||||
import { Node } from 'slate'
|
||||
|
||||
export const input = [
|
||||
{
|
||||
children: [],
|
||||
selection: null,
|
||||
},
|
||||
'a string',
|
||||
]
|
||||
export const test = value => {
|
||||
return Node.isNodeList(value)
|
||||
}
|
||||
export const output = false
|
@@ -0,0 +1,17 @@
|
||||
import { Operation } from 'slate'
|
||||
|
||||
export const input = [
|
||||
{
|
||||
type: 'set_node',
|
||||
path: [0],
|
||||
properties: {},
|
||||
newProperties: {},
|
||||
},
|
||||
{
|
||||
text: '',
|
||||
},
|
||||
]
|
||||
export const test = value => {
|
||||
return Operation.isOperationList(value)
|
||||
}
|
||||
export const output = false
|
@@ -0,0 +1,17 @@
|
||||
import { Text } from 'slate'
|
||||
|
||||
export const input = [
|
||||
{
|
||||
text: '',
|
||||
},
|
||||
{
|
||||
type: 'set_node',
|
||||
path: [0],
|
||||
properties: {},
|
||||
newProperties: {},
|
||||
},
|
||||
]
|
||||
export const test = value => {
|
||||
return Text.isTextList(value)
|
||||
}
|
||||
export const output = false
|
@@ -1,11 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": false,
|
||||
@@ -19,12 +15,6 @@
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve"
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
],
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx"
|
||||
]
|
||||
"exclude": ["node_modules"],
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
|
||||
}
|
||||
|
Reference in New Issue
Block a user