improve command handling
This commit is contained in:
@@ -37,7 +37,13 @@ export interface CommandSpec {
|
||||
|
||||
export interface Commands {}
|
||||
|
||||
// export type CommandNames = Extract<keyof Commands, string>
|
||||
export type CommandNames = Extract<keyof Commands, string>
|
||||
|
||||
export type SingleCommands = {
|
||||
[Command in keyof Commands]: Commands[Command] extends (...args: any[]) => any
|
||||
? (...args: Parameters<Commands[Command]>) => boolean
|
||||
: never
|
||||
}
|
||||
|
||||
export type ChainedCommands = {
|
||||
[Command in keyof Commands]: Commands[Command] extends (...args: any[]) => any
|
||||
@@ -62,6 +68,10 @@ interface EditorOptions {
|
||||
editable: boolean,
|
||||
}
|
||||
|
||||
declare module './Editor' {
|
||||
interface Editor extends SingleCommands {}
|
||||
}
|
||||
|
||||
@magicMethods
|
||||
export class Editor extends EventEmitter {
|
||||
|
||||
@@ -85,7 +95,6 @@ export class Editor extends EventEmitter {
|
||||
editable: true,
|
||||
}
|
||||
|
||||
|
||||
constructor(options: Partial<EditorOptions> = {}) {
|
||||
super()
|
||||
this.options = { ...this.options, ...options }
|
||||
|
||||
Reference in New Issue
Block a user