diff --git a/packages/core/src/plugins/helper.ts b/packages/core/src/plugins/helper.ts index 420eccb..1c32122 100644 --- a/packages/core/src/plugins/helper.ts +++ b/packages/core/src/plugins/helper.ts @@ -1,7 +1,47 @@ -import { InterfacePlugin } from '@idraw/types'; +import { + InterfaceHelperPlugin, TypeHelperPluginEventDetail, + TypeHelperPluginEventResult, +} from '@idraw/types'; +import util from '@idraw/util'; + + +export class HelperPlugin implements Required { + + readonly name: string = 'helper-plugin'; + + readonly uuid: string; -export class HelperPlugin implements InterfacePlugin { constructor() { // TODO + this.uuid = util.uuid.createUUID(); } + + onHover(detail: TypeHelperPluginEventDetail): void | TypeHelperPluginEventResult { + if (detail.controller === null) { + + } + } + + onPoint(detail: TypeHelperPluginEventDetail): void | TypeHelperPluginEventResult { + + } + + onClick(detail: TypeHelperPluginEventDetail): void | TypeHelperPluginEventResult { + + } + + + onMoveStart(detail: TypeHelperPluginEventDetail): void | TypeHelperPluginEventResult { + + } + + onMove(detail: TypeHelperPluginEventDetail): void | TypeHelperPluginEventResult { + + + } + + onMoveEnd(detail: TypeHelperPluginEventDetail): void | TypeHelperPluginEventResult { + + } + } \ No newline at end of file diff --git a/packages/types/src/lib/plugin.ts b/packages/types/src/lib/plugin.ts index 222152a..35fcd3c 100644 --- a/packages/types/src/lib/plugin.ts +++ b/packages/types/src/lib/plugin.ts @@ -3,36 +3,34 @@ import { TypeElemDesc, TypeElement } from './element'; import { TypeContext } from './context'; import { TypePoint, TypePointCursor } from './board'; +export type TypeHelperPluginEventDetail = { + controller: string | null, + point: TypePoint, + selectedElement: TypeElement | null, + data: TypeData, + helperCtx:TypeContext, +} -export interface InterfacePlugin { - onHover?: (detail: { - point: TypePoint, - selectedElement: TypeElement | null, - data: TypeData, - helperCtx:TypeContext, - }) => void | { cursor?: TypePointCursor }; - onClick?: (detail: { - point: TypePoint, - selectedElement: TypeElement | null, - data: TypeData, - helperCtx:TypeContext - }) => void; - onMoveStart?: (detail: { - point: TypePoint, - selectedElement: TypeElement | null, - data: TypeData, - helperCtx:TypeContext - }) => void; - onMove?: (detail: { - point: TypePoint, - selectedElement: TypeElement | null, - data: TypeData, - helperCtx:TypeContext - }) => void; - onMoveEnd?: (detail: { - point: TypePoint, - selectedElement?: TypeElement | null, - data: TypeData, - helperCtx:TypeContext - }) => void; +export type TypeHelperPluginEventResult = { + cursor?: TypePointCursor, + beController?: boolean; +} + +export interface InterfaceHelperPlugin { + + readonly name?: string; + + readonly uuid?: string; + + onHover?: (detail: TypeHelperPluginEventDetail) => void | TypeHelperPluginEventResult; + + onPoint?: (detail: TypeHelperPluginEventDetail) => void | TypeHelperPluginEventResult; + + onClick?: (detail: TypeHelperPluginEventDetail) => void | TypeHelperPluginEventResult; + + onMoveStart?: (detail: TypeHelperPluginEventDetail) => void | TypeHelperPluginEventResult; + + onMove?: (detail: TypeHelperPluginEventDetail) => void | TypeHelperPluginEventResult; + + onMoveEnd?: (detail: TypeHelperPluginEventDetail) => void | TypeHelperPluginEventResult; } \ No newline at end of file