UNPKG

@plait/draw

Version:

Implementation of the core logic of the flowchart drawing tool plugin.

76 lines (75 loc) 2.45 kB
import { Direction, PlaitBoard, PlaitElement, Point, PointOfRectangle, Vector } from '@plait/core'; import { Element } from 'slate'; import { PlaitShapeElement } from '.'; import { StrokeStyle } from '@plait/common'; export declare enum ArrowLineMarkerType { arrow = "arrow", none = "none", openTriangle = "open-triangle", solidTriangle = "solid-triangle", sharpArrow = "sharp-arrow", oneSideUp = "one-side-up", oneSideDown = "one-side-down", hollowTriangle = "hollow-triangle", singleSlash = "single-slash" } export declare enum ArrowLineShape { straight = "straight", curve = "curve", elbow = "elbow" } export declare enum ArrowLineHandleKey { source = "source", target = "target" } export interface ArrowLineText { text: Element; position: number; width: number; height: number; } export interface ArrowLineHandle { boundId?: string; connection?: PointOfRectangle; marker: ArrowLineMarkerType; } export interface ArrowLineHandleRef { key: ArrowLineHandleKey; direction: Direction; point: PointOfRectangle; vector: Vector; boundElement?: PlaitShapeElement; } export interface ArrowLineHandleRefPair { source: ArrowLineHandleRef; target: ArrowLineHandleRef; } export interface PlaitArrowLine extends PlaitElement { type: 'arrow-line'; shape: ArrowLineShape; points: Point[]; source: ArrowLineHandle; target: ArrowLineHandle; texts: ArrowLineText[]; strokeColor?: string; strokeWidth?: number; strokeStyle?: StrokeStyle; opacity: number; } export interface PlaitStraightArrowLine extends PlaitArrowLine { shape: ArrowLineShape.straight; } export interface PlaitCurveArrowLine extends PlaitArrowLine { shape: ArrowLineShape.curve; } export interface PlaitElbowArrowLine extends PlaitArrowLine { shape: ArrowLineShape.elbow; } export declare const PlaitArrowLine: { isSourceMarkOrTargetMark(line: PlaitArrowLine, markType: ArrowLineMarkerType, handleKey: ArrowLineHandleKey): boolean; isSourceMark(line: PlaitArrowLine, markType: ArrowLineMarkerType): boolean; isTargetMark(line: PlaitArrowLine, markType: ArrowLineMarkerType): boolean; isBoundElementOfSource(line: PlaitArrowLine, element: PlaitShapeElement): boolean; isBoundElementOfTarget(line: PlaitArrowLine, element: PlaitShapeElement): boolean; getPoints(board: PlaitBoard, line: PlaitArrowLine): Point[]; };