add command scope
This commit is contained in:
@@ -35,7 +35,8 @@ export default class CommandManager {
|
||||
.entries(commands)
|
||||
.map(([name, command]) => {
|
||||
const method = (...args: any) => {
|
||||
const callback = command(...args)(props)
|
||||
// TODO: fix any
|
||||
const callback = command(...args as any)(props)
|
||||
|
||||
if (!tr.getMeta('preventDispatch')) {
|
||||
view.dispatch(tr)
|
||||
@@ -85,7 +86,7 @@ export default class CommandManager {
|
||||
public createCan(startTr?: Transaction): CanCommands {
|
||||
const { commands, editor } = this
|
||||
const { state } = editor
|
||||
const dispatch = false
|
||||
const dispatch = undefined
|
||||
const tr = startTr || state.tr
|
||||
const props = this.buildProps(tr, dispatch)
|
||||
const formattedCommands = Object.fromEntries(Object
|
||||
@@ -118,10 +119,14 @@ export default class CommandManager {
|
||||
: undefined,
|
||||
chain: () => this.createChain(tr),
|
||||
can: () => this.createCan(tr),
|
||||
// TODO: fix
|
||||
// @ts-ignore
|
||||
get commands() {
|
||||
return Object.fromEntries(Object
|
||||
.entries(commands)
|
||||
.map(([name, command]) => {
|
||||
// TODO: fix
|
||||
// @ts-ignore
|
||||
return [name, (...args: any[]) => command(...args)(props)]
|
||||
})) as SingleCommands
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user