mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-20 06:01:24 +02:00
fix: Operation.isOperationList
just check value[0] (#4061)
* Fix list queries.
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
This package contains the core logic of Slate. Feel free to poke around to learn more!
|
||||
|
||||
Note: A number of source files contain extracted types for `Interfaces` or `Transforms`. This is done currently to enable custom type extensions as found in `packages/src/interfaces/custom-types.ts`.
|
||||
Note: A number of source files contain extracted types for `Interfaces` or `Transforms`. This is done currently to enable custom type extensions as found in `packages/src/interfaces/custom-types.ts`.
|
||||
|
@@ -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,30 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": false,
|
||||
"downlevelIteration": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve"
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
],
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx"
|
||||
]
|
||||
}
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": false,
|
||||
"downlevelIteration": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve"
|
||||
},
|
||||
"exclude": ["node_modules"],
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
|
||||
}
|
||||
|
Reference in New Issue
Block a user