diff --git a/packages/core/src/tools/drawing-tool.ts b/packages/core/src/tools/drawing-tool.ts index e3992ec0..6501e71c 100644 --- a/packages/core/src/tools/drawing-tool.ts +++ b/packages/core/src/tools/drawing-tool.ts @@ -1,13 +1,14 @@ import Konva from 'konva'; import { Tool } from '../types'; -import { Point } from '../utils'; +import { guid, Point } from '../utils'; import { selectTool } from './select-tool'; export const drawingTool = (): Tool => { let points: Point[] = []; const line = new Konva.Line({ + id: guid(), stroke: 'black', strokeWidth: 2, globalCompositeOperation: 'source-over', diff --git a/packages/core/src/tools/ellipse-tool.ts b/packages/core/src/tools/ellipse-tool.ts index 12ce7217..7b582080 100644 --- a/packages/core/src/tools/ellipse-tool.ts +++ b/packages/core/src/tools/ellipse-tool.ts @@ -1,12 +1,13 @@ import { Ellipse } from '../customs/ellipse'; import { AppMouseEvent, Tool } from '../types'; -import { Point } from '../utils'; +import { guid, Point } from '../utils'; import { selectTool } from './select-tool'; export const ellipseTool = (): Tool => { const startPointer: Point = new Point(0, 0); const ellipse: Ellipse = new Ellipse({ + id: guid(), radiusX: 0, radiusY: 0, fill: 'transparent', diff --git a/packages/core/src/tools/image-tool.ts b/packages/core/src/tools/image-tool.ts index 6ea7cac2..f5d7462d 100644 --- a/packages/core/src/tools/image-tool.ts +++ b/packages/core/src/tools/image-tool.ts @@ -1,16 +1,14 @@ -import { readeFile, selectFile } from '@pictode/utils'; - import { Image as Img } from '../customs/image'; import { Tool } from '../types'; +import { guid, readeFile, selectFile } from '../utils'; import { selectTool } from './select-tool'; export const imageTool = (): Tool => { const imageObject = new Image(); const img = new Img({ + id: guid(), image: imageObject, - stroke: 'black', - strokeWidth: 2, }); return { diff --git a/packages/core/src/tools/line-tool.ts b/packages/core/src/tools/line-tool.ts index 1a6972ff..f77df936 100644 --- a/packages/core/src/tools/line-tool.ts +++ b/packages/core/src/tools/line-tool.ts @@ -1,6 +1,6 @@ import { Line } from '../customs/line'; import { Tool } from '../types'; -import { Point } from '../utils'; +import { guid, Point } from '../utils'; import { selectTool } from './select-tool'; @@ -10,6 +10,7 @@ const flatPoints = (points: Point[]): number[] => export const lineTool = (): Tool => { let points: Point[] = []; let line: Line = new Line({ + id: guid(), points: flatPoints(points), fill: 'transparent', stroke: 'black', diff --git a/packages/core/src/tools/rect-tool.ts b/packages/core/src/tools/rect-tool.ts index 6774c6bf..2c5a5864 100644 --- a/packages/core/src/tools/rect-tool.ts +++ b/packages/core/src/tools/rect-tool.ts @@ -1,12 +1,13 @@ import { Rect } from '../customs/rect'; import { AppMouseEvent, Tool } from '../types'; -import { Point } from '../utils'; +import { guid, Point } from '../utils'; import { selectTool } from './select-tool'; export const rectTool = (): Tool => { const startPointer: Point = new Point(0, 0); const rectangle: Rect = new Rect({ + id: guid(), fill: 'transparent', stroke: 'black', strokeWidth: 2, diff --git a/packages/core/src/tools/regular-polygon-tool.ts b/packages/core/src/tools/regular-polygon-tool.ts index 4438a3dc..d612d94f 100644 --- a/packages/core/src/tools/regular-polygon-tool.ts +++ b/packages/core/src/tools/regular-polygon-tool.ts @@ -1,12 +1,13 @@ import { RegularPolygon } from '../customs/regular-polygon'; import { Tool } from '../types'; -import { Point } from '../utils'; +import { guid, Point } from '../utils'; import { selectTool } from './select-tool'; export const regularPolygonTool = (): Tool => { const startPointer: Point = new Point(0, 0); const regularPolygon: RegularPolygon = new RegularPolygon({ + id: guid(), fill: 'transparent', stroke: 'black', strokeWidth: 2, diff --git a/packages/core/src/utils/index.ts b/packages/core/src/utils/index.ts index 871a9637..b6d5699c 100644 --- a/packages/core/src/utils/index.ts +++ b/packages/core/src/utils/index.ts @@ -2,6 +2,8 @@ import { AppConfig } from '../types'; export * from './math'; +export { guid, readeFile, selectFile } from '@pictode/utils'; + export const DEFAULT_APP_CONFIG: AppConfig = { backgroundColor: '#ffffff', };