refactoring
This commit is contained in:
@@ -4,11 +4,13 @@ import { createExtension } from '../Extension'
|
||||
export const Try = createExtension({
|
||||
addCommands() {
|
||||
return {
|
||||
try: (fn: (props: Parameters<Command>[0]) => Command[]): Command => props => {
|
||||
const commands = fn(props)
|
||||
try: (commands: Command[] | ((props: Parameters<Command>[0]) => Command[])): Command => props => {
|
||||
const items = typeof commands === 'function'
|
||||
? commands(props)
|
||||
: commands
|
||||
|
||||
for (let i = 0; i < commands.length; i += 1) {
|
||||
if (commands[i](props)) {
|
||||
for (let i = 0; i < items.length; i += 1) {
|
||||
if (items[i](props)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user