// @ts-nocheck import type { Clearable, Activeble, Disposable } from '../Common' type EditorDesCallback = (des: Des) => void; type FocusChangeCallback = (drawer: T) => void; export abstract class BaseEditor> implements Clearable, Activeble, Disposable { readonly id: string; readonly editorDes: Des; protected focusedCallback: FocusChangeCallback | undefined; protected defocusCallback: FocusChangeCallback | undefined; constructor(id: string) { this.id = id; this.editorDes = this.createEditorDes(); } protected abstract createEditorDes(): Des; dispose(): void { this.focusedCallback = undefined; this.defocusCallback = undefined; this.disposeData(); } protected abstract disposeData(): void; onFocus(callback: FocusChangeCallback): T { this.focusedCallback = callback; return this as any as T; } onDefocus(callback: FocusChangeCallback): T { this.defocusCallback = callback; return this as any as T; } custom(callback: EditorDesCallback): T { callback(this.editorDes); this.refreshGeo(); return this as any as T; } /** * 清空绘制的图形 */ abstract clear(): T; /** * 开启功能 */ abstract active(): T; /** * 结束功能 */ abstract deactive(): T; /** * 刷新所有图形 */ abstract refreshGeo(): void; }