move commands again
This commit is contained in:
15
packages/core/src/commands/try.ts
Normal file
15
packages/core/src/commands/try.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Command } from '../Editor'
|
||||
|
||||
export default (commands: Command[] | ((props: Parameters<Command>[0]) => Command[])): Command => props => {
|
||||
const items = typeof commands === 'function'
|
||||
? commands(props)
|
||||
: commands
|
||||
|
||||
for (let i = 0; i < items.length; i += 1) {
|
||||
if (items[i](props)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user