diff --git a/src/commands/view/CommandAbstract.ts b/src/commands/view/CommandAbstract.ts index 46e8e007e..1a42e1281 100644 --- a/src/commands/view/CommandAbstract.ts +++ b/src/commands/view/CommandAbstract.ts @@ -6,6 +6,7 @@ import EditorModel from '../../editor/model/Editor'; interface ICommand { run?: CommandAbstract['run']; stop?: CommandAbstract['stop']; + [key: string]: unknown; } type AnyObject = Record; @@ -14,6 +15,10 @@ export type CustomCommand = T & ThisType>; +export function defineCommand(def: CustomCommand) { + return def; +} + export default class CommandAbstract extends Model { config: any; em: EditorModel; diff --git a/src/commands/view/ComponentEnter.js b/src/commands/view/ComponentEnter.ts similarity index 50% rename from src/commands/view/ComponentEnter.js rename to src/commands/view/ComponentEnter.ts index bdc81e1b4..c6f7a31c9 100644 --- a/src/commands/view/ComponentEnter.js +++ b/src/commands/view/ComponentEnter.ts @@ -1,14 +1,17 @@ +import Component from '../../dom_components/model/Component'; +import { CustomCommand } from './CommandAbstract'; + export default { run(ed) { if (!ed.Canvas.hasFocus()) return; - const toSelect = []; + const toSelect: Component[] = []; ed.getSelectedAll().forEach(component => { const coll = component.components(); - const next = coll && coll.filter(c => c.get('selectable'))[0]; + const next = coll && coll.filter((c: any) => c.get('selectable'))[0]; next && toSelect.push(next); }); toSelect.length && ed.select(toSelect); }, -}; +} as CustomCommand;