refactoring

This commit is contained in:
Philipp Kühn
2021-02-16 18:00:40 +01:00
parent ca8d1a4245
commit 8fda044502

View File

@@ -35,8 +35,7 @@ export default class CommandManager {
.entries(commands) .entries(commands)
.map(([name, command]) => { .map(([name, command]) => {
const method = (...args: any) => { const method = (...args: any) => {
// TODO: fix any const callback = command(...args)(props)
const callback = command(...args as any)(props)
if (!tr.getMeta('preventDispatch')) { if (!tr.getMeta('preventDispatch')) {
view.dispatch(tr) view.dispatch(tr)
@@ -109,7 +108,7 @@ export default class CommandManager {
tr.setStoredMarks(state.storedMarks) tr.setStoredMarks(state.storedMarks)
} }
const props = { const props: CommandProps = {
tr, tr,
editor, editor,
view, view,
@@ -119,14 +118,10 @@ export default class CommandManager {
: undefined, : undefined,
chain: () => this.createChain(tr), chain: () => this.createChain(tr),
can: () => this.createCan(tr), can: () => this.createCan(tr),
// TODO: fix
// @ts-ignore
get commands() { get commands() {
return Object.fromEntries(Object return Object.fromEntries(Object
.entries(commands) .entries(commands)
.map(([name, command]) => { .map(([name, command]) => {
// TODO: fix
// @ts-ignore
return [name, (...args: any[]) => command(...args)(props)] return [name, (...args: any[]) => command(...args)(props)]
})) as SingleCommands })) as SingleCommands
}, },