@leafer-in/editor
Version:
37 lines (25 loc) • 990 B
text/typescript
import { IUI, IPointData } from '@leafer-ui/interface'
import { Event, isArray } from '@leafer-ui/draw'
import { IEditor, IEditorEvent } from '@leafer-in/interface'
function toList(value: IUI | IUI[]): IUI[] {
return value ? (isArray(value) ? value : [value]) : []
}
export class EditorEvent extends Event implements IEditorEvent {
static BEFORE_SELECT = 'editor.before_select'
static SELECT = 'editor.select'
static AFTER_SELECT = 'editor.after_select'
static BEFORE_HOVER = 'editor.before_hover'
static HOVER = 'editor.hover'
declare readonly target: IUI
readonly editor: IEditor
readonly value: IUI | IUI[]
readonly oldValue: IUI | IUI[]
get list() { return toList(this.value) }
get oldList() { return toList(this.oldValue) }
readonly worldOrigin: IPointData
declare readonly origin: IPointData
constructor(type: string, data?: IEditorEvent) {
super(type)
if (data) Object.assign(this, data)
}
}