1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import * as arrow from './arrow'
- import * as rectangle from './rectangle'
- import * as circle from './circle'
- import * as triangle from './triangle'
- import * as polygon from './polygon'
- import * as line from './line'
- import * as text from './text'
- import * as icon from './icon'
- import * as image from './image'
- import { ArrowData } from './arrow'
- import { RectangleData } from './rectangle'
- import { CircleData } from './circle'
- import { TriangleData } from './triangle'
- import { PolygonData } from './polygon'
- import { LineData } from './line'
- import { TextData } from './text'
- import { IconData } from './icon'
- import { ImageData } from './image'
- import { Pos } from '@/utils/math'
- const _components = {
- arrow,
- rectangle,
- circle,
- triangle,
- polygon,
- line,
- text,
- icon,
- image
- }
- export const components = _components as Components
- export type Components = {
- [key in keyof typeof _components]: (typeof _components)[key] & {
- getSnapInfos?: (items: DrawItem<key>) => ComponentSnapInfo[]
- }
- }
- export type ComponentValue<T extends ShapeType, K extends keyof Components[T]> = Components[T][K]
- export type DrawDataItem = {
- arrow: ArrowData,
- rectangle: RectangleData,
- circle: CircleData,
- triangle: TriangleData,
- polygon: PolygonData,
- line: LineData,
- text: TextData,
- icon: IconData,
- image: ImageData,
- }
- export type ShapeType = keyof DrawDataItem
- export type DrawData = {
- [k in ShapeType]?: DrawDataItem[k][]
- }
- export type DrawItem<T extends ShapeType = ShapeType> = DrawDataItem[T]
- export type SnapPoint = Pos & { view?: boolean }
- export type ComponentSnapInfo = {
- point: SnapPoint,
- links: Pos[]
- linkDirections: Pos[],
- linkAngle: number[]
- }
|