diff --git a/packages/core/src/app.ts b/packages/core/src/app.ts index ca0baf5a..42353be6 100644 --- a/packages/core/src/app.ts +++ b/packages/core/src/app.ts @@ -2,13 +2,13 @@ import { BaseService } from '@pictode/utils'; import { fabric } from 'fabric'; import { MouseService } from './services/mouse'; -import { AppOption, ControlsOption, EventArgs, Plugin, ToolStrategy } from './types'; +import { AppOption, ControlsOption, EventArgs, Plugin, Tool } from './types'; import { DEFAULT_APP_OPTION } from './utils'; export class App extends BaseService { public canvas: fabric.Canvas; public mouseService: MouseService; - public currentTool: ToolStrategy | null = null; + public currentTool: Tool | null = null; private option: AppOption & { controls: ControlsOption }; private installedPlugins: Map = new Map(); @@ -55,7 +55,7 @@ export class App extends BaseService { this.render(true); } - public setTool(tool: ToolStrategy): void { + public setTool(tool: Tool): void { this.currentTool = tool; this.canvas.discardActiveObject(); this.render(); diff --git a/packages/core/src/tools/ellipse-tool.ts b/packages/core/src/tools/ellipse-tool.ts index 0a2c5f27..aee6bc98 100644 --- a/packages/core/src/tools/ellipse-tool.ts +++ b/packages/core/src/tools/ellipse-tool.ts @@ -1,11 +1,11 @@ import { fabric } from 'fabric'; import { Ellipse } from '../customs/ellipse'; -import { AppMouseEvent, ToolStrategy } from '../types'; +import { AppMouseEvent, Tool } from '../types'; import { selectTool } from './select-tool'; -class EllipseTool implements ToolStrategy { +class EllipseTool implements Tool { public name: string = 'ellipseTool'; public drawable: boolean = true; private startPointer: fabric.Point = new fabric.Point(0, 0); diff --git a/packages/core/src/tools/polyline-tool.ts b/packages/core/src/tools/polyline-tool.ts index b86cd959..7bcf71f2 100644 --- a/packages/core/src/tools/polyline-tool.ts +++ b/packages/core/src/tools/polyline-tool.ts @@ -1,11 +1,11 @@ import { fabric } from 'fabric'; import { Polyline } from '../customs/polyline'; -import { AppMouseEvent, ToolStrategy } from '../types'; +import { AppMouseEvent, Tool } from '../types'; import { selectTool } from './select-tool'; -class PolylineTool implements ToolStrategy { +class PolylineTool implements Tool { public name: string = 'polylineTool'; public drawable: boolean = true; private points: fabric.Point[] = []; diff --git a/packages/core/src/tools/rect-tool.ts b/packages/core/src/tools/rect-tool.ts index 2fc1ca6a..f45c2c8b 100644 --- a/packages/core/src/tools/rect-tool.ts +++ b/packages/core/src/tools/rect-tool.ts @@ -1,11 +1,11 @@ import { fabric } from 'fabric'; import { Rect } from '../customs/rect'; -import { AppMouseEvent, ToolStrategy } from '../types'; +import { AppMouseEvent, Tool } from '../types'; import { selectTool } from './select-tool'; -class RectTool implements ToolStrategy { +class RectTool implements Tool { public name: string = 'rectTool'; public drawable: boolean = true; private startPointer: fabric.Point = new fabric.Point(0, 0); diff --git a/packages/core/src/tools/select-tool.ts b/packages/core/src/tools/select-tool.ts index 3fd544ef..00f44c56 100644 --- a/packages/core/src/tools/select-tool.ts +++ b/packages/core/src/tools/select-tool.ts @@ -1,6 +1,6 @@ -import { AppMouseEvent, ToolStrategy } from '../types'; +import { AppMouseEvent, Tool } from '../types'; -class SelectTool implements ToolStrategy { +class SelectTool implements Tool { public name: string = 'selectTool'; public drawable: boolean = false; diff --git a/packages/core/src/tools/triangle-tool.ts b/packages/core/src/tools/triangle-tool.ts index d33a0865..4be25da9 100644 --- a/packages/core/src/tools/triangle-tool.ts +++ b/packages/core/src/tools/triangle-tool.ts @@ -1,11 +1,11 @@ import { fabric } from 'fabric'; import { Triangle } from '../customs/triangle'; -import { AppMouseEvent, ToolStrategy } from '../types'; +import { AppMouseEvent, Tool } from '../types'; import { selectTool } from './select-tool'; -class TriangleTool implements ToolStrategy { +class TriangleTool implements Tool { public name: string = 'triangleTool'; public drawable: boolean = true; private startPointer: fabric.Point = new fabric.Point(0, 0); diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 47b94414..26031036 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -16,7 +16,7 @@ export interface AppMouseEvent { app: App; } -export interface ToolStrategy { +export interface Tool { name: string; drawable: boolean; onMouseDown?: (event: AppMouseEvent) => void;